@chainrails/react 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,42 +1,42 @@
1
- (function(Tt,Be){typeof exports=="object"&&typeof module<"u"?Be(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],Be):(Tt=typeof globalThis<"u"?globalThis:Tt||self,Be(Tt.Chainrails={},Tt.React,Tt.jsxRuntime))})(this,(function(Tt,Be,Jn){"use strict";var xu=document.createElement("style");xu.textContent=`.payment-modal-wrapper{position:fixed;inset:0;z-index:10000;height:100dvh;width:100vw;transition:all .1s ease-in-out}.payment-modal-wrapper.loading{background-color:#0003;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.payment-modal-wrapper.not-loading{background-color:#0008;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0;pointer-events:none}.payment-modal-wrapper.closed *{pointer-events:none!important}.payment-modal-wrapper.open iframe{transform:translateY(0);transform:scale(1)}.payment-modal-wrapper.closed iframe{transform:translateY(50vh);transform:scale(1)}.payment-modal-loader{position:absolute;inset:0;z-index:10000;display:grid;height:100%;width:100%;place-content:center}.payment-modal-loader .icon{height:48px;width:48px;animation:cr-spin 1s linear infinite;fill:#2563eb;color:#475569}.payment-modal{position:absolute;inset:0;z-index:10000;height:100%;width:100%;transition:all .3s cubic-bezier(.25,1,.5,1)}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@keyframes cr-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
2
- /*$vite$:1*/`,document.head.appendChild(xu);class Ao extends Error{response;request;options;constructor(e,n,r){const s=e.status||e.status===0?e.status:"",i=e.statusText??"",o=`${s} ${i}`.trim(),a=o?`status code ${o}`:"an unknown error";super(`Request failed with ${a}: ${n.method} ${n.url}`),this.name="HTTPError",this.response=e,this.request=n,this.options=r}}class Tu extends Error{name="NonError";value;constructor(e){let n="Non-error value was thrown";try{typeof e=="string"?n=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(n=e.message)}catch{}super(n),this.value=e}}class So extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new Tu(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",n?{cause:n}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const Iu=(()=>{let t=!1,e=!1;const n=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(n&&r)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(s){if(s instanceof Error&&s.message==="unsupported BodyInit type")return!1;throw s}return t&&!e})(),D0=typeof globalThis.AbortController=="function",Ou=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",P0=typeof globalThis.ReadableStream=="function",F0=typeof globalThis.FormData=="function",Nu=["get","post","put","patch","head","delete"],$0={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},xo=2147483647,z0=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Cu=Symbol("stop");class Mu{options;constructor(e){this.options=e}}const j0=t=>new Mu(t),V0={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},H0={next:!0},G0={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},q0=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,r]of t)e+=z0,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,e+=typeof r=="string"?new TextEncoder().encode(r).length:r.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},ku=(t,e,n)=>{let r,s=0;return t.pipeThrough(new TransformStream({transform(i,o){if(o.enqueue(i),r){s+=r.byteLength;let a=e===0?0:s/e;a>=1&&(a=1-Number.EPSILON),n?.({percent:a,totalBytes:Math.max(e,s),transferredBytes:s},r)}r=i},flush(){r&&(s+=r.byteLength,n?.({percent:1,totalBytes:Math.max(e,s),transferredBytes:s},r))}}))},K0=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const n=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(ku(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},W0=(t,e,n)=>{if(!t.body)return t;const r=q0(n??t.body);return new Request(t,{duplex:"half",body:ku(t.body,r,e)})},Xn=t=>t!==null&&typeof t=="object",ti=(...t)=>{for(const e of t)if((!Xn(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return To({},...t)},Bu=(t={},e={})=>{const n=new globalThis.Headers(t),r=e instanceof globalThis.Headers,s=new globalThis.Headers(e);for(const[i,o]of s.entries())r&&o==="undefined"||o===void 0?n.delete(i):n.set(i,o);return n};function ni(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:To(t[n]??[],e[n]??[])}const Uu=(t={},e={})=>({beforeRequest:ni(t,e,"beforeRequest"),beforeRetry:ni(t,e,"beforeRetry"),afterResponse:ni(t,e,"afterResponse"),beforeError:ni(t,e,"beforeError")}),Z0=(t,e)=>{const n=new URLSearchParams;for(const r of[t,e])if(r!==void 0)if(r instanceof URLSearchParams)for(const[s,i]of r.entries())n.append(s,i);else if(Array.isArray(r))for(const s of r){if(!Array.isArray(s)||s.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");n.append(String(s[0]),String(s[1]))}else if(Xn(r))for(const[s,i]of Object.entries(r))i!==void 0&&n.append(s,String(i));else{const s=new URLSearchParams(r);for(const[i,o]of s.entries())n.append(i,o)}return n},To=(...t)=>{let e={},n={},r={},s;const i=[];for(const o of t)if(Array.isArray(o))Array.isArray(e)||(e=[]),e=[...e,...o];else if(Xn(o)){for(let[a,d]of Object.entries(o)){if(a==="signal"&&d instanceof globalThis.AbortSignal){i.push(d);continue}if(a==="context"){if(d!=null&&(!Xn(d)||Array.isArray(d)))throw new TypeError("The `context` option must be an object");e={...e,context:d==null?{}:{...e.context,...d}};continue}if(a==="searchParams"){d==null?s=void 0:s=s===void 0?d:Z0(s,d);continue}Xn(d)&&a in e&&(d=To(e[a],d)),e={...e,[a]:d}}Xn(o.hooks)&&(r=Uu(r,o.hooks),e.hooks=r),Xn(o.headers)&&(n=Bu(n,o.headers),e.headers=n)}return s!==void 0&&(e.searchParams=s),i.length>0&&(i.length===1?e.signal=i[0]:Ou?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e.context===void 0&&(e.context={}),e},Y0=t=>Nu.includes(t)?t.toUpperCase():t,Lu={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},J0=(t={})=>{if(typeof t=="number")return{...Lu,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Lu,...t}};class Io extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function X0(t,e,n,r){return new Promise((s,i)=>{const o=setTimeout(()=>{n&&n.abort(),i(new Io(t))},r.timeout);r.fetch(t,e).then(s).catch(i).then(()=>{clearTimeout(o)})})}async function Q0(t,{signal:e}){return new Promise((n,r)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",s,{once:!0}));function s(){clearTimeout(i),r(e.reason)}const i=setTimeout(()=>{e?.removeEventListener("abort",s),n()},t)})}const ep=(t,e)=>{const n={};for(const r in e)Object.hasOwn(e,r)&&!(r in G0)&&!(r in V0)&&(!(r in t)||r in H0)&&(n[r]=e[r]);return n},tp=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function np(t){return t instanceof Ao||t?.name===Ao.name}function rp(t){return t instanceof Io||t?.name===Io.name}class Qr{static create(e,n){const r=new Qr(e,n),s=async()=>{if(typeof r.#e.timeout=="number"&&r.#e.timeout>xo)throw new RangeError(`The \`timeout\` option cannot be greater than ${xo}`);await Promise.resolve();let o=await r.#m();for(const a of r.#e.hooks.afterResponse){const d=r.#d(o.clone()),m=await a(r.request,r.#a(),d,{retryCount:r.#n});if(m instanceof globalThis.Response&&(o=m),m instanceof Mu)throw await Promise.all([d.body?.cancel(),o.body?.cancel()]),new So(m.options)}if(r.#d(o),!o.ok&&(typeof r.#e.throwHttpErrors=="function"?r.#e.throwHttpErrors(o.status):r.#e.throwHttpErrors)){let a=new Ao(o,r.request,r.#a());for(const d of r.#e.hooks.beforeError)a=await d(a,{retryCount:r.#n});throw a}if(r.#e.onDownloadProgress){if(typeof r.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!P0)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return K0(o.clone(),r.#e.onDownloadProgress)}return o},i=r.#l(s).finally(async()=>{const o=r.#i,a=[];o&&!o.bodyUsed&&a.push(o.body?.cancel()),r.request.bodyUsed||a.push(r.request.body?.cancel()),await Promise.all(a)});for(const[o,a]of Object.entries($0))o==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[o]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||a);const d=await i;if(o==="json"){if(d.status===204)return"";const m=await d.text();return m===""?"":n.parseJson?n.parseJson(m):JSON.parse(m)}return d[o]()});return i}static#h(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)):e}request;#r;#n=0;#t;#e;#i;#s;#o;constructor(e,n={}){if(this.#t=e,this.#e={...n,headers:Bu(this.#t.headers,n.headers),hooks:Uu({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:Y0(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:J0(n.retry),throwHttpErrors:n.throwHttpErrors??!0,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis),context:n.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}D0&&Ou&&(this.#s=this.#e.signal??this.#t.signal,this.#r=new globalThis.AbortController,this.#e.signal=this.#s?AbortSignal.any([this.#s,this.#r.signal]):this.#r.signal),Iu&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const r=n.headers&&new globalThis.Headers(n.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(F0&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!r&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),tp(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(Qr.#h(this.#e.searchParams)).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(o,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Iu)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#f(this.request,this.#e.body??void 0)}}#c(){const e=this.#e.retry.delay(this.#n);let n=e;return this.#e.retry.jitter===!0?n=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(n=this.#e.retry.jitter(e),(!Number.isFinite(n)||n<0)&&(n=e)),Math.min(this.#e.retry.backoffLimit,n)}async#p(e){if(this.#n++,this.#n>this.#e.retry.limit)throw e;const n=e instanceof Error?e:new Tu(e);if(n instanceof So)return n.customDelay??this.#c();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const r=await this.#e.retry.shouldRetry({error:n,retryCount:this.#n});if(r===!1)throw e;if(r===!0)return this.#c()}if(rp(e)&&!this.#e.retry.retryOnTimeout)throw e;if(np(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const r=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(r&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let s=Number(r)*1e3;Number.isNaN(s)?s=Date.parse(r)-Date.now():s>=Date.parse("2024-01-01")&&(s-=Date.now());const i=this.#e.retry.maxRetryAfter??s;return s<i?s:i}if(e.response.status===413)throw e}return this.#c()}#d(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}async#l(e){try{return await e()}catch(n){const r=Math.min(await this.#p(n),xo);if(this.#n<1)throw n;if(await Q0(r,this.#s?{signal:this.#s}:{}),n instanceof So&&n.customRequest){const s=this.#e.signal?new globalThis.Request(n.customRequest,{signal:this.#e.signal}):new globalThis.Request(n.customRequest);this.#u(s)}for(const s of this.#e.hooks.beforeRetry){const i=await s({request:this.request,options:this.#a(),error:n,retryCount:this.#n});if(i instanceof globalThis.Request){this.#u(i);break}if(i instanceof globalThis.Response)return i;if(i===Cu)return}return this.#l(e)}}async#m(){this.#r?.signal.aborted&&(this.#r=new globalThis.AbortController,this.#e.signal=this.#s?AbortSignal.any([this.#s,this.#r.signal]):this.#r.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const n of this.#e.hooks.beforeRequest){const r=await n(this.request,this.#a(),{retryCount:this.#n});if(r instanceof Response)return r;if(r instanceof globalThis.Request){this.#u(r);break}}const e=ep(this.request,this.#e);return this.#i=this.request,this.request=this.#i.clone(),this.#e.timeout===!1?this.#e.fetch(this.#i,e):X0(this.#i,e,this.#r,this.#e)}#a(){if(!this.#o){const{hooks:e,...n}=this.#e;this.#o=Object.freeze(n)}return this.#o}#u(e){this.#o=void 0,this.request=this.#f(e)}#f(e,n){return!this.#e.onUploadProgress||!e.body?e:W0(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const Oo=t=>{const e=(n,r)=>Qr.create(n,ti(t,r));for(const n of Nu)e[n]=(r,s)=>Qr.create(r,ti(t,s,{method:n}));return e.create=n=>Oo(ti(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),Oo(ti(t,n))),e.stop=Cu,e.retry=j0,e},sp=Oo(),et={ARBITRUM:"ARBITRUM_MAINNET",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE_MAINNET",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE_MAINNET",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC_MAINNET",ETHEREUM:"ETHEREUM_MAINNET",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM_MAINNET",LISK:"LISK_MAINNET",MONAD:"MONAD_MAINNET",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM_MAINNET",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON_MAINNET",STARKNET:"STARKNET_MAINNET",STARKNET_TESTNET:"STARKNET_TESTNET"},Du={ARBITRUM:"ARBITRUM",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC",ETHEREUM:"ETHEREUM",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM",LISK:"LISK",MONAD:"MONAD",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON",STARKNET:"STARKNET",STARKNET_TESTNET:"STARKNET_TESTNET"};function No(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function Pu(t){return No(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Fu="2.43.4";let Co={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${Fu}`},es=class vu extends Error{constructor(e,n={}){const r=n.cause instanceof vu?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof vu&&n.cause.docsPath||n.docsPath,i=Co.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...Co.version?[`Version: ${Co.version}`]:[]].join(`
3
- `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=Fu}walk(e){return $u(this,e)}};function $u(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?$u(t.cause,e):e?null:t}let zu=class extends es{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}};function ri(t,{dir:e,size:n=32}={}){return typeof t=="string"?ip(t,{dir:e,size:n}):op(t,{dir:e,size:n})}function ip(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new zu({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function op(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new zu({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=e==="right";r[i?s:n-s-1]=t[i?s:t.length-s-1]}return r}let ap=class extends es{constructor({max:e,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}},cp=class extends es{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function Mo(t,{size:e}){if(Pu(t)>e)throw new cp({givenSize:Pu(t),maxSize:e})}function up(t,e={}){const{signed:n,size:r}=e,s=BigInt(t);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const d=typeof t=="bigint"?"n":"";throw new ap({max:i?`${i}${d}`:void 0,min:`${o}${d}`,signed:n,size:r,value:`${t}${d}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?ri(a,{size:r}):a}const dp=new TextEncoder;function lp(t,e={}){return typeof t=="number"||typeof t=="bigint"?hp(t,e):typeof t=="boolean"?fp(t,e):No(t)?Vu(t,e):Hu(t,e)}function fp(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Mo(n,{size:e.size}),ri(n,{size:e.size})):n}const yn={zero:48,nine:57,A:65,F:70,a:97,f:102};function ju(t){if(t>=yn.zero&&t<=yn.nine)return t-yn.zero;if(t>=yn.A&&t<=yn.F)return t-(yn.A-10);if(t>=yn.a&&t<=yn.f)return t-(yn.a-10)}function Vu(t,e={}){let n=t;e.size&&(Mo(n,{size:e.size}),n=ri(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const d=ju(r.charCodeAt(a++)),m=ju(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new es(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function hp(t,e){const n=up(t,e);return Vu(n)}function Hu(t,e={}){const n=dp.encode(t);return typeof e.size=="number"?(Mo(n,{size:e.size}),ri(n,{dir:"right",size:e.size})):n}const si=BigInt(2**32-1),Gu=BigInt(32);function pp(t,e=!1){return e?{h:Number(t&si),l:Number(t>>Gu&si)}:{h:Number(t>>Gu&si)|0,l:Number(t&si)|0}}function mp(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:o,l:a}=pp(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const gp=(t,e,n)=>t<<n|e>>>32-n,yp=(t,e,n)=>e<<n|t>>>32-n,bp=(t,e,n)=>e<<n-32|t>>>64-n,_p=(t,e,n)=>t<<n-32|e>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ep(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function qu(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ii(t,...e){if(!Ep(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Ku(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function wp(t,e){ii(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function vp(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Wu(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Rp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ap(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Sp(t){for(let e=0;e<t.length;e++)t[e]=Ap(t[e]);return t}const Zu=Rp?t=>t:Sp;function xp(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Yu(t){return typeof t=="string"&&(t=xp(t)),ii(t),t}let Tp=class{};function Ip(t){const e=r=>t().update(Yu(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}const Op=BigInt(0),ts=BigInt(1),Np=BigInt(2),Cp=BigInt(7),Mp=BigInt(256),kp=BigInt(113),Ju=[],Xu=[],Qu=[];for(let t=0,e=ts,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Ju.push(2*(5*r+n)),Xu.push((t+1)*(t+2)/2%64);let s=Op;for(let i=0;i<7;i++)e=(e<<ts^(e>>Cp)*kp)%Mp,e&Np&&(s^=ts<<(ts<<BigInt(i))-ts);Qu.push(s)}const ed=mp(Qu,!0),Bp=ed[0],Up=ed[1],td=(t,e,n)=>n>32?bp(t,e,n):gp(t,e,n),nd=(t,e,n)=>n>32?_p(t,e,n):yp(t,e,n);function Lp(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=n[d],g=n[d+1],S=td(m,g,1)^n[a],I=nd(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=S,t[o+N+1]^=I}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=Xu[o],d=td(s,i,a),m=nd(s,i,a),g=Ju[o];s=t[g],i=t[g+1],t[g]=d,t[g+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=Bp[r],t[1]^=Up[r]}Wu(n)}let Dp=class B0 extends Tp{constructor(e,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,qu(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=vp(this.state)}clone(){return this._cloneInto()}keccak(){Zu(this.state32),Lp(this.state32,this.rounds),Zu(this.state32),this.posOut=0,this.pos=0}update(e){Ku(this),e=Yu(e),ii(e);const{blockLen:n,state:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Ku(this,!1),ii(e),this.finish();const n=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(n.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 qu(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(wp(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,Wu(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new B0(n,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 Pp=(t,e,n)=>Ip(()=>new Dp(e,t,n)),Fp=Pp(1,136,256/8);function $p(t,e){return Fp(No(t,{strict:!1})?lp(t):t)}let zp=class extends es{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}};class rd extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const ko=new rd(8192);function sd(t,e){if(ko.has(`${t}.${e}`))return ko.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=$p(Hu(n)),s=n.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const i=`0x${s.join("")}`;return ko.set(`${t}.${e}`,i),i}function It(t,e){if(!Vp(t,{strict:!1}))throw new zp({address:t});return sd(t,e)}const jp=/^0x[a-fA-F0-9]{40}$/,Bo=new rd(8192);function Vp(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(Bo.has(r))return Bo.get(r);const s=jp.test(t)?t.toLowerCase()===t?!0:n?sd(t)===t:!0:!1;return Bo.set(r,s),s}const X={USDC:"USDC",USDT:"USDT",DAI:"DAI",BUSD:"BUSD",EURC:"EURC",ETH:"ETH",WETH:"WETH",STRK:"STRK",BNB:"BNB",LORDS:"LORDS"};X.USDC;const id={[et.ARBITRUM]:{[X.DAI]:{address:It("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.USDC]:{address:It("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:It("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:It("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[et.ARBITRUM_TESTNET]:{[X.USDC]:{address:It("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[et.AVALANCHE]:{[X.DAI]:{address:"0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.USDC]:{address:It("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[et.AVALANCHE_TESTNET]:{[X.USDC]:{address:It("0x5425890298aed601595a70AB815c96711a31Bc65"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[et.BASE]:{[X.DAI]:{address:"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.EURC]:{address:"0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",symbol:X.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[X.USDC]:{address:It("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.WETH]:{address:It("0x4200000000000000000000000000000000000006"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[et.BASE_TESTNET]:{[X.USDC]:{address:It("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[et.BSC]:{[X.BNB]:{address:"0x0000000000000000000000000000000000000000",symbol:X.BNB,name:"BNB",decimals:18,logoURI:"/images/chains/bsc.webp",nativeToken:!0},[X.BUSD]:{address:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",symbol:X.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[X.DAI]:{address:"0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[X.USDC]:{address:It("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:X.USDC,decimals:18,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:"0x55d398326f99059fF775485246999027B3197955",symbol:X.USDT,name:"Tether USD",decimals:18,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[et.ETHEREUM]:{[X.BUSD]:{address:"0x4Fabb145d64652a948d72533023f6E7A623C7C53",symbol:X.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[X.DAI]:{address:It("0x6B175474E89094C44Da98b954EedeAC495271d0F"),symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.EURC]:{address:"0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",symbol:X.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[X.STRK]:{address:"0xCa14007Eff0dB1f8135f4C25B34De49AB0d42766",symbol:X.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[X.USDC]:{address:It("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:It("0xdAC17F958D2ee523a2206206994597C13D831ec7"),symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:It("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[et.ETHEREUM_TESTNET]:{[X.USDC]:{address:It("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:X.USDC,decimals:6,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[et.HYPEREVM]:{[X.USDC]:{address:"0xb88339CB7199b77E23DB6E890353E22632Ba630f",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[et.LISK]:{[X.USDC]:{address:"0xF242275d3a6527d877f2c927a82D9b057609cc71",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[et.MONAD]:{[X.USDC]:{address:"0x754704Bc059F8C67012fEd69BC8A327a5aafb603",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[et.MONAD_TESTNET]:{[X.USDC]:{address:"0x534b2f3A21130d7a60830c2Df862319e593943A3",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[et.OPTIMISM]:{[X.DAI]:{address:"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.USDC]:{address:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:"0x4200000000000000000000000000000000000006",symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[et.OPTIMISM_TESTNET]:{[X.USDC]:{address:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[et.POLYGON]:{[X.DAI]:{address:"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.USDC]:{address:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[et.STARKNET]:{[X.DAI]:{address:"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[X.LORDS]:{address:"0x0124aeb495b947201f5faC96fD1138E326AD86195B98df6DEc9009158A533B49",symbol:X.LORDS,name:"LORDS Token",decimals:18,logoURI:"/images/tokens/lords.png",nativeToken:!1},[X.STRK]:{address:"0x04718f5a0Fc34cC1AF16A1cdee98fFB20C31f5cD61D6Ab07201858f4287c938D",symbol:X.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[X.USDC]:{address:"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[et.STARKNET_TESTNET]:{[X.USDC]:{address:"0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}}},Hp=new Set(Object.values(et));function Pt(t){if(Gp(t))return t;const e=et[t];if(!e)throw new Error(`Invalid chain: ${t}. Chain must be a valid chain alias or internal chain value from Chains.`);return e}function Gp(t){return Hp.has(t)}function qp(t,e){const n=e.toLowerCase().trim(),r=id[t];if(!r)throw new Error(`Chain not found: ${t}. The chain key must be a valid chain identifier.`);let s;for(const i in r){const o=r[i];if(o&&o.address.toLowerCase()===n.toLowerCase()){s=o;break}}if(!s)throw new Error(`Token address mismatch: address ${e} does not exist on chain ${t}. The token address must be a valid token address on the specified chain.`);return s}function Uo(t,e,n){const r=qp(t,e);if(r.symbol!==n)throw new Error(`Token address and symbol mismatch: address ${e} on chain ${t} corresponds to token "${r.symbol}", but expected "${n}". The token address must correspond to a token with the expected symbol on the specified chain.`);return r}function Kp(t,e){return id[t]?.[e]}function od(t,e){return Kp(t,e)?.address}var Lo=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(Lo||{});let Mn=class Xe{constructor({api_key:e,env:n,seesion_token:r,props:s}){this.api_key=e||"",this.sessionToken=r||"",this.env=n??Lo.PRODUCTION,this.props=s}static async config(e){if(!Xe.app){if(!e)throw new Error("Please provide an api_key");Xe.app=new Xe(e)}return e&&(e.api_key!==void 0&&(Xe.app.api_key=e.api_key),e.seesion_token!==void 0&&(Xe.app.sessionToken=e.seesion_token),e.env!==void 0&&(Xe.app.env=e.env),e.props!==void 0&&(Xe.app.props=e.props)),Xe.app}static getApiKey(){if(!Xe.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Xe.app.api_key}static getSessionToken(){if(!Xe.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Xe.app.sessionToken}static getProps(){if(!Xe.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Xe.app.props}static getEnv(){if(!Xe.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Xe.app.env==="internal"?"staging":Xe.app.env}static getBaseUrl(){if(!Xe.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(Xe.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(e){if(!Xe.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const n=Xe.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",r=Number(e),s=e&&!isNaN(Number(e))&&r>0?"/pay/":"/deposit/",i=`${e&&!isNaN(Number(e))&&r>0?r*100:""}`;return n+s+i}},Do=null;function Wp(){Do=sp.create({prefixUrl:Mn.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=Mn.getSessionToken()||Mn.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,n)=>n]},retry:{limit:2}})}function je(){return Do||Wp(),Do}let Zp=class{async getById(e){return await je().get("intents/"+e).json()}async getForSender(e){return await je().get("intents/user/"+e).json()}async getForAddress(e){return await je().get("intents/address/"+e).json()}async getForSession(e){return await je().get("modal/sessions/intents/"+e).json()}async getAll(e){return await je().get("intents",{searchParams:e}).json()}async create(e){const n=Pt(e.source_chain),r=Pt(e.destination_chain);return await je().post("intents",{json:{...e,source_chain:n,destination_chain:r}}).json()}async createForSession(e){const n=Pt(e.sourceChain);return await je().post("modal/sessions/intents",{json:{...e,sourceChain:n}}).json()}async update(e,n){return await je().post("intents",{json:n}).json()}async triggerProcessing(e){return await je().post(`intents/${e}/trigger-processing`).json()}async triggerProcessingForSession(e){return await je().post(`modal/sessions/intents/${e}/process`).json()}},Yp=class{async getFromSpecificBridge(e){const n=Pt(e.sourceChain);Uo(n,e.tokenIn,e.amountSymbol);const r=Pt(e.destinationChain);return await je().get("quotes/single",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getFromAllBridges(e){const n=Pt(e.sourceChain);Uo(n,e.tokenIn,e.amountSymbol);const r=Pt(e.destinationChain);return await je().get("quotes/multiple",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getBestAcrossBridges(e){const n=Pt(e.sourceChain);Uo(n,e.tokenIn,e.amountSymbol);const r=Pt(e.destinationChain);return await je().get("quotes/best",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getAll(e){const n=Pt(e.destinationChain);return await je().get("quotes/multi-source",{searchParams:{...e,destinationChain:n}}).json()}async getAllForSession(e){return await je().get("modal/sessions/quotes",{searchParams:e}).json()}},Jp=class{async getOptimalRoutes(e){const n=Pt(e.sourceChain),r=Pt(e.destinationChain);return await je().get("router/optimal-route",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getAllSupportedBridges(){return await je().get("router/supported-bridges/all").json()}async getSupportedBridges(e){const n=Pt(e.sourceChain),r=Pt(e.destinationChain);return await je().get("router/supported-bridges/route",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getSupportedRoutes(e){return await je().get("router/supported-routes/bridge/"+e).json()}},Xp=class{async getSupported(e){return await je().get("chains",{searchParams:e}).json()}async getBalance(e){return await je().get(`chains/balances/${e.address}`,{searchParams:e}).json()}},Qp=class{async getClientInfo(){return await je().get("client/auth/client-info").json()}async getClientInfoForSession(){return await je().get("modal/sessions/client").json()}},em=class{async getSessionToken(e){const n=Pt(e.destinationChain);let r=od(n,e.token);r||(console.error(`${e.token} on ${e.destinationChain} is currently unsupported, defaulting to usdc`),r=od(n,"USDC"));const s={recipient:e.recipient,tokenOut:r,destinationChain:n,amount:e.amount};return je().post("modal/sessions",{json:s}).json().then(i=>({...i,amount:s.amount}))}};const tm={router:new Jp,quotes:new Yp,intents:new Zp,chains:new Xp,client:new Qp,auth:new em};function ad(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;e<s;e++)t[e]&&(n=ad(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function nm(){for(var t,e,n=0,r="",s=arguments.length;n<s;n++)(t=arguments[n])&&(e=ad(t))&&(r&&(r+=" "),r+=e);return r}const un={CLOSED:"closed",COMPLETED:"completed",AUTH:"session",REQUEST_FARCASTER_CONNECT:"cr:request-farcaster-connect",REQUEST_FARCASTER_DISCONNECT:"cr:request-farcaster-disconnect",REQUEST_FARCASTER_SEND_TRANSACTION:"cr:request-farcaster-send-transaction",FARCASTER_SEND_TRANSACTION_RESULT:"cr:farcaster-send-transaction-result",FARCASTER_CONNECTED:"cr:farcaster-connected",FARCASTER_DISCONNECTED:"cr:farcaster-disconnected",IN_FARCASTER_MINI_APP:"cr:in-farcaster-mini-app"},Po="https://app.chainrails.io",Fo="https://chainrails-frontend-git-staging-horus-labs.vercel.app",rm=[{type:"event",name:"Approval",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"event",name:"Transfer",inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}];function br(t,{includeName:e=!1}={}){if(t.type!=="function"&&t.type!=="event"&&t.type!=="error")throw new hm(t.type);return`${t.name}(${$o(t.inputs,{includeName:e})})`}function $o(t,{includeName:e=!1}={}){return t?t.map(n=>sm(n,{includeName:e})).join(e?", ":","):""}function sm(t,{includeName:e}){return t.type.startsWith("tuple")?`(${$o(t.components,{includeName:e})})${t.type.slice(5)}`:t.type+(e&&t.name?` ${t.name}`:"")}function kn(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function Et(t){return kn(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const cd="2.43.4";let zo={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${cd}`},de=class Ru extends Error{constructor(e,n={}){const r=n.cause instanceof Ru?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof Ru&&n.cause.docsPath||n.docsPath,i=zo.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...zo.version?[`Version: ${zo.version}`]:[]].join(`
4
- `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=cd}walk(e){return ud(this,e)}};function ud(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?ud(t.cause,e):e?null:t}class im extends de{constructor({data:e,params:n,size:r}){super([`Data size of ${r} bytes is too small for given parameters.`].join(`
5
- `),{metaMessages:[`Params: (${$o(n,{includeName:!0})})`,`Data: ${e} (${r} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e,this.params=n,this.size=r}}class jo extends de{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class om extends de{constructor({expectedLength:e,givenLength:n,type:r}){super([`ABI encoding array length mismatch for type ${r}.`,`Expected length: ${e}`,`Given length: ${n}`].join(`
6
- `),{name:"AbiEncodingArrayLengthMismatchError"})}}class am extends de{constructor({expectedSize:e,value:n}){super(`Size of bytes "${n}" (bytes${Et(n)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class cm extends de{constructor({expectedLength:e,givenLength:n}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${e}`,`Given length (values): ${n}`].join(`
7
- `),{name:"AbiEncodingLengthMismatchError"})}}class dd extends de{constructor(e,{docsPath:n}){super([`Encoded error signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.`].join(`
8
- `),{docsPath:n,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class ld extends de{constructor(e,{docsPath:n}={}){super([`Function ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join(`
9
- `),{docsPath:n,name:"AbiFunctionNotFoundError"})}}class um extends de{constructor(e,n){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${br(e.abiItem)}\`, and`,`\`${n.type}\` in \`${br(n.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}class dm extends de{constructor(e,{docsPath:n}){super([`Type "${e}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(`
10
- `),{docsPath:n,name:"InvalidAbiEncodingType"})}}class lm extends de{constructor(e,{docsPath:n}){super([`Type "${e}" is not a valid decoding type.`,"Please provide a valid ABI type."].join(`
11
- `),{docsPath:n,name:"InvalidAbiDecodingType"})}}class fm extends de{constructor(e){super([`Value "${e}" is not a valid array.`].join(`
12
- `),{name:"InvalidArrayError"})}}class hm extends de{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(`
13
- `),{name:"InvalidDefinitionTypeError"})}}class ns extends de{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class fd extends de{constructor({offset:e,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}class hd extends de{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}class pd extends de{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} is expected to be ${n} ${r} long, but is ${e} ${r} long.`,{name:"InvalidBytesLengthError"})}}function _r(t,{dir:e,size:n=32}={}){return typeof t=="string"?Bn(t,{dir:e,size:n}):pm(t,{dir:e,size:n})}function Bn(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new hd({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function pm(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new hd({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=e==="right";r[i?s:n-s-1]=t[i?s:t.length-s-1]}return r}class md extends de{constructor({max:e,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class mm extends de{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class gm extends de{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}class ym extends de{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Qn(t,{dir:e="left"}={}){let n=typeof t=="string"?t.replace("0x",""):t,r=0;for(let s=0;s<n.length-1&&n[e==="left"?s:n.length-s-1].toString()==="0";s++)r++;return n=e==="left"?n.slice(r):n.slice(0,n.length-r),typeof t=="string"?(n.length===1&&e==="right"&&(n=`${n}0`),`0x${n.length%2===1?`0${n}`:n}`):n}function en(t,{size:e}){if(Et(t)>e)throw new ym({givenSize:Et(t),maxSize:e})}function bm(t,e){const n={to:e},r=n.to;return r==="number"?er(t,n):r==="bigint"?Er(t,n):r==="string"?Em(t,n):r==="boolean"?_m(t,n):nn(t,n)}function Er(t,e={}){const{signed:n}=e;e.size&&en(t,{size:e.size});const r=BigInt(t);if(!n)return r;const s=(t.length-2)/2,i=(1n<<BigInt(s)*8n-1n)-1n;return r<=i?r:r-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function _m(t,e={}){let n=t;if(e.size&&(en(n,{size:e.size}),n=Qn(n)),Qn(n)==="0x00")return!1;if(Qn(n)==="0x01")return!0;throw new gm(n)}function er(t,e={}){return Number(Er(t,e))}function Em(t,e={}){let n=nn(t);return e.size&&(en(n,{size:e.size}),n=Qn(n,{dir:"right"})),new TextDecoder().decode(n)}const wm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Vo(t,e={}){return typeof t=="number"||typeof t=="bigint"?Ue(t,e):typeof t=="string"?Ho(t,e):typeof t=="boolean"?gd(t,e):Ht(t,e)}function gd(t,e={}){const n=`0x${Number(t)}`;return typeof e.size=="number"?(en(n,{size:e.size}),_r(n,{size:e.size})):n}function Ht(t,e={}){let n="";for(let s=0;s<t.length;s++)n+=wm[t[s]];const r=`0x${n}`;return typeof e.size=="number"?(en(r,{size:e.size}),_r(r,{dir:"right",size:e.size})):r}function Ue(t,e={}){const{signed:n,size:r}=e,s=BigInt(t);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const d=typeof t=="bigint"?"n":"";throw new md({max:i?`${i}${d}`:void 0,min:`${o}${d}`,signed:n,size:r,value:`${t}${d}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?_r(a,{size:r}):a}const vm=new TextEncoder;function Ho(t,e={}){const n=vm.encode(t);return Ht(n,e)}const Rm=new TextEncoder;function Go(t,e={}){return typeof t=="number"||typeof t=="bigint"?Sm(t,e):typeof t=="boolean"?Am(t,e):kn(t)?nn(t,e):bd(t,e)}function Am(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(en(n,{size:e.size}),_r(n,{size:e.size})):n}const bn={zero:48,nine:57,A:65,F:70,a:97,f:102};function yd(t){if(t>=bn.zero&&t<=bn.nine)return t-bn.zero;if(t>=bn.A&&t<=bn.F)return t-(bn.A-10);if(t>=bn.a&&t<=bn.f)return t-(bn.a-10)}function nn(t,e={}){let n=t;e.size&&(en(n,{size:e.size}),n=_r(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const d=yd(r.charCodeAt(a++)),m=yd(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new de(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function Sm(t,e){const n=Ue(t,e);return nn(n)}function bd(t,e={}){const n=Rm.encode(t);return typeof e.size=="number"?(en(n,{size:e.size}),_r(n,{dir:"right",size:e.size})):n}const oi=BigInt(2**32-1),_d=BigInt(32);function xm(t,e=!1){return e?{h:Number(t&oi),l:Number(t>>_d&oi)}:{h:Number(t>>_d&oi)|0,l:Number(t&oi)|0}}function Ed(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:o,l:a}=xm(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const wd=(t,e,n)=>t>>>n,vd=(t,e,n)=>t<<32-n|e>>>n,wr=(t,e,n)=>t>>>n|e<<32-n,vr=(t,e,n)=>t<<32-n|e>>>n,ai=(t,e,n)=>t<<64-n|e>>>n-32,ci=(t,e,n)=>t>>>n-32|e<<64-n,Tm=(t,e,n)=>t<<n|e>>>32-n,Im=(t,e,n)=>e<<n|t>>>32-n,Om=(t,e,n)=>e<<n-32|t>>>64-n,Nm=(t,e,n)=>t<<n-32|e>>>64-n;function _n(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const Cm=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Mm=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,km=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Bm=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,Um=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0),Lm=(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0,Rr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Dm(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function rs(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function tr(t,...e){if(!Dm(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Pm(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");rs(t.outputLen),rs(t.blockLen)}function Ar(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Rd(t,e){tr(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Fm(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Un(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function qo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function dn(t,e){return t<<32-e|t>>>e}const $m=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function zm(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function jm(t){for(let e=0;e<t.length;e++)t[e]=zm(t[e]);return t}const Ad=$m?t=>t:jm;function Vm(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ui(t){return typeof t=="string"&&(t=Vm(t)),tr(t),t}function Hm(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];tr(s),e+=s.length}const n=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const i=t[r];n.set(i,s),s+=i.length}return n}class Ko{}function Wo(t){const e=r=>t().update(ui(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Sd(t=32){if(Rr&&typeof Rr.getRandomValues=="function")return Rr.getRandomValues(new Uint8Array(t));if(Rr&&typeof Rr.randomBytes=="function")return Uint8Array.from(Rr.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const Gm=BigInt(0),ss=BigInt(1),qm=BigInt(2),Km=BigInt(7),Wm=BigInt(256),Zm=BigInt(113),xd=[],Td=[],Id=[];for(let t=0,e=ss,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],xd.push(2*(5*r+n)),Td.push((t+1)*(t+2)/2%64);let s=Gm;for(let i=0;i<7;i++)e=(e<<ss^(e>>Km)*Zm)%Wm,e&qm&&(s^=ss<<(ss<<BigInt(i))-ss);Id.push(s)}const Od=Ed(Id,!0),Ym=Od[0],Jm=Od[1],Nd=(t,e,n)=>n>32?Om(t,e,n):Tm(t,e,n),Cd=(t,e,n)=>n>32?Nm(t,e,n):Im(t,e,n);function Xm(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=n[d],g=n[d+1],S=Nd(m,g,1)^n[a],I=Cd(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=S,t[o+N+1]^=I}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=Td[o],d=Nd(s,i,a),m=Cd(s,i,a),g=xd[o];s=t[g],i=t[g+1],t[g]=d,t[g+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=Ym[r],t[1]^=Jm[r]}Un(n)}class Zo extends Ko{constructor(e,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,rs(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Fm(this.state)}clone(){return this._cloneInto()}keccak(){Ad(this.state32),Xm(this.state32,this.rounds),Ad(this.state32),this.posOut=0,this.pos=0}update(e){Ar(this),e=ui(e),tr(e);const{blockLen:n,state:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Ar(this,!1),tr(e),this.finish();const n=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(n.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 rs(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Rd(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,Un(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Zo(n,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 Qm=(t,e,n)=>Wo(()=>new Zo(e,t,n)),eg=Qm(1,136,256/8);function di(t,e){const n=e||"hex",r=eg(kn(t,{strict:!1})?Go(t):t);return n==="bytes"?r:Vo(r)}class is extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const tg=/^0x[a-fA-F0-9]{40}$/,Yo=new is(8192);function Ln(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(Yo.has(r))return Yo.get(r);const s=tg.test(t)?t.toLowerCase()===t?!0:n?li(t)===t:!0:!1;return Yo.set(r,s),s}const Jo=new is(8192);function li(t,e){if(Jo.has(`${t}.${e}`))return Jo.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=di(bd(n),"bytes"),s=n.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const i=`0x${s.join("")}`;return Jo.set(`${t}.${e}`,i),i}function fi(t,e){if(!Ln(t,{strict:!1}))throw new ns({address:t});return li(t,e)}class Md extends de{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class ng extends de{constructor({length:e,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class rg extends de{constructor({count:e,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const sg={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new rg({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new ng({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new Md({offset:t});const e=this.position-t;this.assertPosition(e),this.position=e},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new Md({offset:t});const e=this.position+t;this.assertPosition(e),this.position=e},inspectByte(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectBytes(t,e){const n=e??this.position;return this.assertPosition(n+t-1),this.bytes.subarray(n,n+t)},inspectUint8(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectUint16(t){const e=t??this.position;return this.assertPosition(e+1),this.dataView.getUint16(e)},inspectUint24(t){const e=t??this.position;return this.assertPosition(e+2),(this.dataView.getUint16(e)<<8)+this.dataView.getUint8(e+2)},inspectUint32(t){const e=t??this.position;return this.assertPosition(e+3),this.dataView.getUint32(e)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,e){this.assertReadLimit(),this._touch();const n=this.inspectBytes(t);return this.position+=e??t,n},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const e=this.position;return this.assertPosition(t),this.position=t,()=>this.position=e},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function Xo(t,{recursiveReadLimit:e=8192}={}){const n=Object.create(sg);return n.bytes=t,n.dataView=new DataView(t.buffer??t,t.byteOffset,t.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=e,n}function hi(t,e,n,{strict:r}={}){return kn(t,{strict:!1})?ig(t,e,n,{strict:r}):Ud(t,e,n,{strict:r})}function kd(t,e){if(typeof e=="number"&&e>0&&e>Et(t)-1)throw new fd({offset:e,position:"start",size:Et(t)})}function Bd(t,e,n){if(typeof e=="number"&&typeof n=="number"&&Et(t)!==n-e)throw new fd({offset:n,position:"end",size:Et(t)})}function Ud(t,e,n,{strict:r}={}){kd(t,e);const s=t.slice(e,n);return r&&Bd(s,e,n),s}function ig(t,e,n,{strict:r}={}){kd(t,e);const s=`0x${t.replace("0x","").slice((e??0)*2,(n??t.length)*2)}`;return r&&Bd(s,e,n),s}function og(t,e={}){typeof e.size<"u"&&en(t,{size:e.size});const n=Ht(t,e);return Er(n,e)}function ag(t,e={}){let n=t;if(typeof e.size<"u"&&(en(n,{size:e.size}),n=Qn(n)),n.length>1||n[0]>1)throw new mm(n);return!!n[0]}function En(t,e={}){typeof e.size<"u"&&en(t,{size:e.size});const n=Ht(t,e);return er(n,e)}function cg(t,e={}){let n=t;return typeof e.size<"u"&&(en(n,{size:e.size}),n=Qn(n,{dir:"right"})),new TextDecoder().decode(n)}function Sr(t){return typeof t[0]=="string"?Qo(t):ug(t)}function ug(t){let e=0;for(const s of t)e+=s.length;const n=new Uint8Array(e);let r=0;for(const s of t)n.set(s,r),r+=s.length;return n}function Qo(t){return`0x${t.reduce((e,n)=>e+n.replace("0x",""),"")}`}const dg=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function lg(t,e){if(t.length!==e.length)throw new cm({expectedLength:t.length,givenLength:e.length});const n=fg({params:t,values:e}),r=ta(n);return r.length===0?"0x":r}function fg({params:t,values:e}){const n=[];for(let r=0;r<t.length;r++)n.push(ea({param:t[r],value:e[r]}));return n}function ea({param:t,value:e}){const n=na(t.type);if(n){const[r,s]=n;return pg(e,{length:r,param:{...t,type:s}})}if(t.type==="tuple")return _g(e,{param:t});if(t.type==="address")return hg(e);if(t.type==="bool")return gg(e);if(t.type.startsWith("uint")||t.type.startsWith("int")){const r=t.type.startsWith("int"),[,,s="256"]=dg.exec(t.type)??[];return yg(e,{signed:r,size:Number(s)})}if(t.type.startsWith("bytes"))return mg(e,{param:t});if(t.type==="string")return bg(e);throw new dm(t.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function ta(t){let e=0;for(let i=0;i<t.length;i++){const{dynamic:o,encoded:a}=t[i];o?e+=32:e+=Et(a)}const n=[],r=[];let s=0;for(let i=0;i<t.length;i++){const{dynamic:o,encoded:a}=t[i];o?(n.push(Ue(e+s,{size:32})),r.push(a),s+=Et(a)):n.push(a)}return Sr([...n,...r])}function hg(t){if(!Ln(t))throw new ns({address:t});return{dynamic:!1,encoded:Bn(t.toLowerCase())}}function pg(t,{length:e,param:n}){const r=e===null;if(!Array.isArray(t))throw new fm(t);if(!r&&t.length!==e)throw new om({expectedLength:e,givenLength:t.length,type:`${n.type}[${e}]`});let s=!1;const i=[];for(let o=0;o<t.length;o++){const a=ea({param:n,value:t[o]});a.dynamic&&(s=!0),i.push(a)}if(r||s){const o=ta(i);if(r){const a=Ue(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?Sr([a,o]):a}}if(s)return{dynamic:!0,encoded:o}}return{dynamic:!1,encoded:Sr(i.map(({encoded:o})=>o))}}function mg(t,{param:e}){const[,n]=e.type.split("bytes"),r=Et(t);if(!n){let s=t;return r%32!==0&&(s=Bn(s,{dir:"right",size:Math.ceil((t.length-2)/2/32)*32})),{dynamic:!0,encoded:Sr([Bn(Ue(r,{size:32})),s])}}if(r!==Number.parseInt(n,10))throw new am({expectedSize:Number.parseInt(n,10),value:t});return{dynamic:!1,encoded:Bn(t,{dir:"right"})}}function gg(t){if(typeof t!="boolean")throw new de(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Bn(gd(t))}}function yg(t,{signed:e,size:n=256}){if(typeof n=="number"){const r=2n**(BigInt(n)-(e?1n:0n))-1n,s=e?-r-1n:0n;if(t>r||t<s)throw new md({max:r.toString(),min:s.toString(),signed:e,size:n/8,value:t.toString()})}return{dynamic:!1,encoded:Ue(t,{size:32,signed:e})}}function bg(t){const e=Ho(t),n=Math.ceil(Et(e)/32),r=[];for(let s=0;s<n;s++)r.push(Bn(hi(e,s*32,(s+1)*32),{dir:"right"}));return{dynamic:!0,encoded:Sr([Bn(Ue(Et(e),{size:32})),...r])}}function _g(t,{param:e}){let n=!1;const r=[];for(let s=0;s<e.components.length;s++){const i=e.components[s],o=Array.isArray(t)?s:i.name,a=ea({param:i,value:t[o]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?ta(r):Sr(r.map(({encoded:s})=>s))}}function na(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}function Eg(t,e){const n=typeof e=="string"?nn(e):e,r=Xo(n);if(Et(n)===0&&t.length>0)throw new jo;if(Et(e)&&Et(e)<32)throw new im({data:typeof e=="string"?e:Ht(e),params:t,size:Et(e)});let s=0;const i=[];for(let o=0;o<t.length;++o){const a=t[o];r.setPosition(s);const[d,m]=xr(r,a,{staticPosition:0});s+=m,i.push(d)}return i}function xr(t,e,{staticPosition:n}){const r=na(e.type);if(r){const[s,i]=r;return vg(t,{...e,type:i},{length:s,staticPosition:n})}if(e.type==="tuple")return xg(t,e,{staticPosition:n});if(e.type==="address")return wg(t);if(e.type==="bool")return Rg(t);if(e.type.startsWith("bytes"))return Ag(t,e,{staticPosition:n});if(e.type.startsWith("uint")||e.type.startsWith("int"))return Sg(t,e);if(e.type==="string")return Tg(t,{staticPosition:n});throw new lm(e.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Ld=32,ra=32;function wg(t){const e=t.readBytes(32);return[li(Ht(Ud(e,-20))),32]}function vg(t,e,{length:n,staticPosition:r}){if(!n){const o=En(t.readBytes(ra)),a=r+o,d=a+Ld;t.setPosition(a);const m=En(t.readBytes(Ld)),g=os(e);let S=0;const I=[];for(let N=0;N<m;++N){t.setPosition(d+(g?N*32:S));const[F,M]=xr(t,e,{staticPosition:d});S+=M,I.push(F)}return t.setPosition(r+32),[I,32]}if(os(e)){const o=En(t.readBytes(ra)),a=r+o,d=[];for(let m=0;m<n;++m){t.setPosition(a+m*32);const[g]=xr(t,e,{staticPosition:a});d.push(g)}return t.setPosition(r+32),[d,32]}let s=0;const i=[];for(let o=0;o<n;++o){const[a,d]=xr(t,e,{staticPosition:r+s});s+=d,i.push(a)}return[i,s]}function Rg(t){return[ag(t.readBytes(32),{size:32}),32]}function Ag(t,e,{staticPosition:n}){const[r,s]=e.type.split("bytes");if(!s){const o=En(t.readBytes(32));t.setPosition(n+o);const a=En(t.readBytes(32));if(a===0)return t.setPosition(n+32),["0x",32];const d=t.readBytes(a);return t.setPosition(n+32),[Ht(d),32]}return[Ht(t.readBytes(Number.parseInt(s,10),32)),32]}function Sg(t,e){const n=e.type.startsWith("int"),r=Number.parseInt(e.type.split("int")[1]||"256",10),s=t.readBytes(32);return[r>48?og(s,{signed:n}):En(s,{signed:n}),32]}function xg(t,e,{staticPosition:n}){const r=e.components.length===0||e.components.some(({name:o})=>!o),s=r?[]:{};let i=0;if(os(e)){const o=En(t.readBytes(ra)),a=n+o;for(let d=0;d<e.components.length;++d){const m=e.components[d];t.setPosition(a+i);const[g,S]=xr(t,m,{staticPosition:a});i+=S,s[r?d:m?.name]=g}return t.setPosition(n+32),[s,32]}for(let o=0;o<e.components.length;++o){const a=e.components[o],[d,m]=xr(t,a,{staticPosition:n});s[r?o:a?.name]=d,i+=m}return[s,i]}function Tg(t,{staticPosition:e}){const n=En(t.readBytes(32)),r=e+n;t.setPosition(r);const s=En(t.readBytes(32));if(s===0)return t.setPosition(e+32),["",32];const i=t.readBytes(s,32),o=cg(Qn(i));return t.setPosition(e+32),[o,32]}function os(t){const{type:e}=t;if(e==="string"||e==="bytes"||e.endsWith("[]"))return!0;if(e==="tuple")return t.components?.some(os);const n=na(t.type);return!!(n&&os({...t,type:n[1]}))}const Ig=t=>di(Go(t));function Og(t){return Ig(t)}function Ng(t,e){return t.exec(e)?.groups}const Dd=/^tuple(?<array>(\[(\d*)\])*)$/;function sa(t){let e=t.type;if(Dd.test(t.type)&&"components"in t){e="(";const n=t.components.length;for(let s=0;s<n;s++){const i=t.components[s];e+=sa(i),s<n-1&&(e+=", ")}const r=Ng(Dd,t.type);return e+=`)${r?.array||""}`,sa({...t,type:e})}return"indexed"in t&&t.indexed&&(e=`${e} indexed`),t.name?`${e} ${t.name}`:e}function as(t){let e="";const n=t.length;for(let r=0;r<n;r++){const s=t[r];e+=sa(s),r!==n-1&&(e+=", ")}return e}function Cg(t){return t.type==="function"?`function ${t.name}(${as(t.inputs)})${t.stateMutability&&t.stateMutability!=="nonpayable"?` ${t.stateMutability}`:""}${t.outputs?.length?` returns (${as(t.outputs)})`:""}`:t.type==="event"?`event ${t.name}(${as(t.inputs)})`:t.type==="error"?`error ${t.name}(${as(t.inputs)})`:t.type==="constructor"?`constructor(${as(t.inputs)})${t.stateMutability==="payable"?" payable":""}`:t.type==="fallback"?`fallback() external${t.stateMutability==="payable"?" payable":""}`:"receive() external payable"}function Mg(t){let e=!0,n="",r=0,s="",i=!1;for(let o=0;o<t.length;o++){const a=t[o];if(["(",")",","].includes(a)&&(e=!0),a==="("&&r++,a===")"&&r--,!!e){if(r===0){if(a===" "&&["event","function",""].includes(s))s="";else if(s+=a,a===")"){i=!0;break}continue}if(a===" "){t[o-1]!==","&&n!==","&&n!==",("&&(n="",e=!1);continue}s+=a,n+=a}}if(!i)throw new de("Unable to normalize signature.");return s}const kg=t=>{const e=typeof t=="string"?t:Cg(t);return Mg(e)};function Pd(t){return Og(kg(t))}const Bg=Pd,ia=t=>hi(Pd(t),0,4);function Fd(t){const{abi:e,args:n=[],name:r}=t,s=kn(r,{strict:!1}),i=e.filter(a=>s?a.type==="function"?ia(a)===r:a.type==="event"?Bg(a)===r:!1:"name"in a&&a.name===r);if(i.length===0)return;if(i.length===1)return i[0];let o;for(const a of i){if(!("inputs"in a))continue;if(!n||n.length===0){if(!a.inputs||a.inputs.length===0)return a;continue}if(!a.inputs||a.inputs.length===0||a.inputs.length!==n.length)continue;if(n.every((m,g)=>{const S="inputs"in a&&a.inputs[g];return S?oa(m,S):!1})){if(o&&"inputs"in o&&o.inputs){const m=$d(a.inputs,o.inputs,n);if(m)throw new um({abiItem:a,type:m[0]},{abiItem:o,type:m[1]})}o=a}}return o||i[0]}function oa(t,e){const n=typeof t,r=e.type;switch(r){case"address":return Ln(t,{strict:!1});case"bool":return n==="boolean";case"function":return n==="string";case"string":return n==="string";default:return r==="tuple"&&"components"in e?Object.values(e.components).every((s,i)=>n==="object"&&oa(Object.values(t)[i],s)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?n==="number"||n==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?n==="string"||t instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)?Array.isArray(t)&&t.every(s=>oa(s,{...e,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function $d(t,e,n){for(const r in t){const s=t[r],i=e[r];if(s.type==="tuple"&&i.type==="tuple"&&"components"in s&&"components"in i)return $d(s.components,i.components,n[r]);const o=[s.type,i.type];if(o.includes("address")&&o.includes("bytes20")?!0:o.includes("address")&&o.includes("string")?Ln(n[r],{strict:!1}):o.includes("address")&&o.includes("bytes")?Ln(n[r],{strict:!1}):!1)return o}}const zd="/docs/contract/encodeFunctionData";function Ug(t){const{abi:e,args:n,functionName:r}=t;let s=e[0];if(r){const i=Fd({abi:e,args:n,name:r});if(!i)throw new ld(r,{docsPath:zd});s=i}if(s.type!=="function")throw new ld(void 0,{docsPath:zd});return{abi:[s],functionName:ia(br(s))}}function Lg(t){const{args:e}=t,{abi:n,functionName:r}=t.abi.length===1&&t.functionName?.startsWith("0x")?t:Ug(t),s=n[0],i=r,o="inputs"in s&&s.inputs?lg(s.inputs,e??[]):void 0;return Qo([i,o??"0x"])}class Dg extends de{constructor({chain:e,currentChainId:n}){super(`The current chain of the wallet (id: ${n}) does not match the target chain for the transaction (id: ${e.id} – ${e.name}).`,{metaMessages:[`Current Chain ID: ${n}`,`Expected Chain ID: ${e.id} – ${e.name}`],name:"ChainMismatchError"})}}class Pg extends de{constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(`
14
- `),{name:"ChainNotFoundError"})}}function wn(t){return typeof t=="string"?{address:t,type:"json-rpc"}:t}const Fg={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},$g={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},zg={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};function jg(t){const{abi:e,data:n}=t,r=hi(n,0,4);if(r==="0x")throw new jo;const i=[...e||[],$g,zg].find(o=>o.type==="error"&&r===ia(br(o)));if(!i)throw new dd(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:i,args:"inputs"in i&&i.inputs&&i.inputs.length>0?Eg(i.inputs,hi(n,4)):void 0,errorName:i.name}}const pi=(t,e,n)=>JSON.stringify(t,(r,s)=>typeof s=="bigint"?s.toString():s,n);function jd({abiItem:t,args:e,includeFunctionName:n=!0,includeName:r=!1}){if("name"in t&&"inputs"in t&&t.inputs)return`${n?t.name:""}(${t.inputs.map((s,i)=>`${r&&s.name?`${s.name}: `:""}${typeof e[i]=="object"?pi(e[i]):e[i]}`).join(", ")})`}const Vg={gwei:9,wei:18},Hg={ether:-9,wei:9};function Vd(t,e){let n=t.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(e,"0");let[s,i]=[n.slice(0,n.length-e),n.slice(n.length-e)];return i=i.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${i?`.${i}`:""}`}function Hd(t,e="wei"){return Vd(t,Vg[e])}function rn(t,e="wei"){return Vd(t,Hg[e])}class Gg extends de{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class qg extends de{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function mi(t){const e=Object.entries(t).map(([r,s])=>s===void 0||s===!1?null:[r,s]).filter(Boolean),n=e.reduce((r,[s])=>Math.max(r,s.length),0);return e.map(([r,s])=>` ${`${r}:`.padEnd(n+1)} ${s}`).join(`
15
- `)}class Kg extends de{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",mi(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class Wg extends de{constructor(e,{account:n,docsPath:r,chain:s,data:i,gas:o,gasPrice:a,maxFeePerGas:d,maxPriorityFeePerGas:m,nonce:g,to:S,value:I}){const N=mi({chain:s&&`${s?.name} (id: ${s?.id})`,from:n?.address,to:S,value:typeof I<"u"&&`${Hd(I)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:o,gasPrice:typeof a<"u"&&`${rn(a)} gwei`,maxFeePerGas:typeof d<"u"&&`${rn(d)} gwei`,maxPriorityFeePerGas:typeof m<"u"&&`${rn(m)} gwei`,nonce:g});super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Request Arguments:",N].filter(Boolean),name:"TransactionExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}const Zg=t=>t,Gd=t=>t;class Yg extends de{constructor(e,{abi:n,args:r,contractAddress:s,docsPath:i,functionName:o,sender:a}){const d=Fd({abi:n,args:r,name:o}),m=d?jd({abiItem:d,args:r,includeFunctionName:!1,includeName:!1}):void 0,g=d?br(d,{includeName:!0}):void 0,S=mi({address:s&&Zg(s),function:g,args:m&&m!=="()"&&`${[...Array(o?.length??0).keys()].map(()=>" ").join("")}${m}`,sender:a});super(e.shortMessage||`An unknown error occurred while executing the contract function "${o}".`,{cause:e,docsPath:i,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],S&&"Contract Call:",S].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=n,this.args=r,this.cause=e,this.contractAddress=s,this.functionName=o,this.sender=a}}class Jg extends de{constructor({abi:e,data:n,functionName:r,message:s}){let i,o,a,d;if(n&&n!=="0x")try{o=jg({abi:e,data:n});const{abiItem:g,errorName:S,args:I}=o;if(S==="Error")d=I[0];else if(S==="Panic"){const[N]=I;d=Fg[N]}else{const N=g?br(g,{includeName:!0}):void 0,F=g&&I?jd({abiItem:g,args:I,includeFunctionName:!1,includeName:!1}):void 0;a=[N?`Error: ${N}`:"",F&&F!=="()"?` ${[...Array(S?.length??0).keys()].map(()=>" ").join("")}${F}`:""]}}catch(g){i=g}else s&&(d=s);let m;i instanceof dd&&(m=i.signature,a=[`Unable to decode signature "${m}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${m}.`]),super(d&&d!=="execution reverted"||m?[`The contract function "${r}" reverted with the following ${m?"signature":"reason"}:`,d||m].join(`
16
- `):`The contract function "${r}" reverted.`,{cause:i,metaMessages:a,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=o,this.raw=n,this.reason=d,this.signature=m}}class Xg extends de{constructor({functionName:e}){super(`The contract function "${e}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${e}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class Qg extends de{constructor({data:e,message:n}){super(n||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e}}function Ot(t,e,n){const r=t[e.name];if(typeof r=="function")return r;const s=t[n];return typeof s=="function"?s:i=>e(t,i)}class qd extends de{constructor({body:e,cause:n,details:r,headers:s,status:i,url:o}){super("HTTP request failed.",{cause:n,details:r,metaMessages:[i&&`Status: ${i}`,`URL: ${Gd(o)}`,e&&`Request body: ${pi(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=s,this.status=i,this.url=o}}class Kd extends de{constructor({body:e,error:n,url:r}){super("RPC Request failed.",{cause:n,details:n.message,metaMessages:[`URL: ${Gd(r)}`,`Request body: ${pi(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=n.code,this.data=n.data,this.url=r}}const ey=-1;class Gt extends de{constructor(e,{code:n,docsPath:r,metaMessages:s,name:i,shortMessage:o}){super(o,{cause:e,docsPath:r,metaMessages:s||e?.metaMessages,name:i||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=i||e.name,this.code=e instanceof Kd?e.code:n??ey}}let Wt=class extends Gt{constructor(e,n){super(e,n),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n.data}};class cs extends Gt{constructor(e){super(e,{code:cs.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(cs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class us extends Gt{constructor(e){super(e,{code:us.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(us,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class ds extends Gt{constructor(e,{method:n}={}){super(e,{code:ds.code,name:"MethodNotFoundRpcError",shortMessage:`The method${n?` "${n}"`:""} does not exist / is not available.`})}}Object.defineProperty(ds,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class ls extends Gt{constructor(e){super(e,{code:ls.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
17
- `)})}}Object.defineProperty(ls,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class nr extends Gt{constructor(e){super(e,{code:nr.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(nr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Tr extends Gt{constructor(e){super(e,{code:Tr.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
18
- `)})}}Object.defineProperty(Tr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class fs extends Gt{constructor(e){super(e,{code:fs.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(fs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class hs extends Gt{constructor(e){super(e,{code:hs.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class ps extends Gt{constructor(e){super(e,{code:ps.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(ps,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class rr extends Gt{constructor(e,{method:n}={}){super(e,{code:rr.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${n?` "${n}"`:""} is not supported.`})}}Object.defineProperty(rr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class Ir extends Gt{constructor(e){super(e,{code:Ir.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(Ir,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class ms extends Gt{constructor(e){super(e,{code:ms.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(ms,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});let gi=class U0 extends Wt{constructor(e){super(e,{code:U0.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}};Object.defineProperty(gi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class gs extends Wt{constructor(e){super(e,{code:gs.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class ys extends Wt{constructor(e,{method:n}={}){super(e,{code:ys.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${n?` " ${n}"`:""}.`})}}Object.defineProperty(ys,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class bs extends Wt{constructor(e){super(e,{code:bs.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(bs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});let aa=class L0 extends Wt{constructor(e){super(e,{code:L0.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}};Object.defineProperty(aa,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Or extends Wt{constructor(e){super(e,{code:Or.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Or,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class _s extends Wt{constructor(e){super(e,{code:_s.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(_s,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Es extends Wt{constructor(e){super(e,{code:Es.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Es,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class ws extends Wt{constructor(e){super(e,{code:ws.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(ws,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class vs extends Wt{constructor(e){super(e,{code:vs.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Rs extends Wt{constructor(e){super(e,{code:Rs.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(Rs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class As extends Wt{constructor(e){super(e,{code:As.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(As,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Ss extends Wt{constructor(e){super(e,{code:Ss.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(Ss,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class ty extends Gt{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const ny=3;function ry(t,{abi:e,address:n,args:r,docsPath:s,functionName:i,sender:o}){const a=t instanceof Qg?t:t instanceof de?t.walk(F=>"data"in F)||t.walk():{},{code:d,data:m,details:g,message:S,shortMessage:I}=a,N=t instanceof jo?new Xg({functionName:i}):[ny,nr.code].includes(d)&&(m||g||S||I)||d===Tr.code&&g==="execution reverted"&&m?new Jg({abi:e,data:typeof m=="object"?m.data:m,functionName:i,message:a instanceof Kd?g:I??S}):t;return new Yg(N,{abi:e,args:r,contractAddress:n,docsPath:s,functionName:i,sender:o})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ca=BigInt(0),ua=BigInt(1);function xs(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function da(t){if(!xs(t))throw new Error("Uint8Array expected")}function Dn(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function yi(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Wd(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?ca:BigInt("0x"+t)}const Zd=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",sy=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Nr(t){if(da(t),Zd)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=sy[t[n]];return e}const vn={_0:48,_9:57,A:65,F:70,a:97,f:102};function Yd(t){if(t>=vn._0&&t<=vn._9)return t-vn._0;if(t>=vn.A&&t<=vn.F)return t-(vn.A-10);if(t>=vn.a&&t<=vn.f)return t-(vn.a-10)}function bi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Zd)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let s=0,i=0;s<n;s++,i+=2){const o=Yd(t.charCodeAt(i)),a=Yd(t.charCodeAt(i+1));if(o===void 0||a===void 0){const d=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+i)}r[s]=o*16+a}return r}function sr(t){return Wd(Nr(t))}function Ts(t){return da(t),Wd(Nr(Uint8Array.from(t).reverse()))}function Is(t,e){return bi(t.toString(16).padStart(e*2,"0"))}function _i(t,e){return Is(t,e).reverse()}function Qe(t,e,n){let r;if(typeof e=="string")try{r=bi(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(xs(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(t+" of length "+n+" expected, got "+s);return r}function Cr(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];da(s),e+=s.length}const n=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const i=t[r];n.set(i,s),s+=i.length}return n}const la=t=>typeof t=="bigint"&&ca<=t;function fa(t,e,n){return la(t)&&la(e)&&la(n)&&e<=t&&t<n}function sn(t,e,n,r){if(!fa(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function iy(t){let e;for(e=0;t>ca;t>>=ua,e+=1);return e}const Ei=t=>(ua<<BigInt(t))-ua,ha=t=>new Uint8Array(t),Jd=t=>Uint8Array.from(t);function oy(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=ha(t),s=ha(t),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...S)=>n(s,r,...S),d=(S=ha(0))=>{s=a(Jd([0]),S),r=a(),S.length!==0&&(s=a(Jd([1]),S),r=a())},m=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let S=0;const I=[];for(;S<e;){r=a();const N=r.slice();I.push(N),S+=r.length}return Cr(...I)};return(S,I)=>{o(),d(S);let N;for(;!(N=I(m()));)d();return o(),N}}const ay={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||xs(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Os(t,e,n={}){const r=(s,i,o)=>{const a=ay[i];if(typeof a!="function")throw new Error("invalid validator function");const d=t[s];if(!(o&&d===void 0)&&!a(d,t))throw new Error("param "+String(s)+" is invalid. Expected "+i+", got "+d)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(n))r(s,i,!0);return t}function wi(t){const e=new WeakMap;return(n,...r)=>{const s=e.get(n);if(s!==void 0)return s;const i=t(n,...r);return e.set(n,i),i}}class Mr extends de{constructor({cause:e,message:n}={}){const r=n?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${r?`with reason: ${r}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Mr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Mr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class vi extends de{constructor({cause:e,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${rn(n)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(vi,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class pa extends de{constructor({cause:e,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${rn(n)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(pa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class ma extends de{constructor({cause:e,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(ma,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class ga extends de{constructor({cause:e,nonce:n}={}){super([`Nonce provided for the transaction ${n?`(${n}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
19
- `),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(ga,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class ya extends de{constructor({cause:e,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(ya,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class ba extends de{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
20
- `),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(ba,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class _a extends de{constructor({cause:e,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(_a,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Ea extends de{constructor({cause:e,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(Ea,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class wa extends de{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(wa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Ri extends de{constructor({cause:e,maxPriorityFeePerGas:n,maxFeePerGas:r}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${n?` = ${rn(n)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r?` = ${rn(r)} gwei`:""}).`].join(`
21
- `),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Ri,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class va extends de{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Xd(t,e){const n=(t.details||"").toLowerCase(),r=t instanceof de?t.walk(s=>s?.code===Mr.code):t;return r instanceof de?new Mr({cause:t,message:r.details}):Mr.nodeMessage.test(n)?new Mr({cause:t,message:t.details}):vi.nodeMessage.test(n)?new vi({cause:t,maxFeePerGas:e?.maxFeePerGas}):pa.nodeMessage.test(n)?new pa({cause:t,maxFeePerGas:e?.maxFeePerGas}):ma.nodeMessage.test(n)?new ma({cause:t,nonce:e?.nonce}):ga.nodeMessage.test(n)?new ga({cause:t,nonce:e?.nonce}):ya.nodeMessage.test(n)?new ya({cause:t,nonce:e?.nonce}):ba.nodeMessage.test(n)?new ba({cause:t}):_a.nodeMessage.test(n)?new _a({cause:t,gas:e?.gas}):Ea.nodeMessage.test(n)?new Ea({cause:t,gas:e?.gas}):wa.nodeMessage.test(n)?new wa({cause:t}):Ri.nodeMessage.test(n)?new Ri({cause:t,maxFeePerGas:e?.maxFeePerGas,maxPriorityFeePerGas:e?.maxPriorityFeePerGas}):new va({cause:t})}function Ra(t,{format:e}){if(!e)return{};const n={};function r(i){const o=Object.keys(i);for(const a of o)a in t&&(n[a]=t[a]),i[a]&&typeof i[a]=="object"&&!Array.isArray(i[a])&&r(i[a])}const s=e(t||{});return r(s),n}const cy={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Aa(t,e){const n={};return typeof t.authorizationList<"u"&&(n.authorizationList=uy(t.authorizationList)),typeof t.accessList<"u"&&(n.accessList=t.accessList),typeof t.blobVersionedHashes<"u"&&(n.blobVersionedHashes=t.blobVersionedHashes),typeof t.blobs<"u"&&(typeof t.blobs[0]!="string"?n.blobs=t.blobs.map(r=>Ht(r)):n.blobs=t.blobs),typeof t.data<"u"&&(n.data=t.data),t.account&&(n.from=t.account.address),typeof t.from<"u"&&(n.from=t.from),typeof t.gas<"u"&&(n.gas=Ue(t.gas)),typeof t.gasPrice<"u"&&(n.gasPrice=Ue(t.gasPrice)),typeof t.maxFeePerBlobGas<"u"&&(n.maxFeePerBlobGas=Ue(t.maxFeePerBlobGas)),typeof t.maxFeePerGas<"u"&&(n.maxFeePerGas=Ue(t.maxFeePerGas)),typeof t.maxPriorityFeePerGas<"u"&&(n.maxPriorityFeePerGas=Ue(t.maxPriorityFeePerGas)),typeof t.nonce<"u"&&(n.nonce=Ue(t.nonce)),typeof t.to<"u"&&(n.to=t.to),typeof t.type<"u"&&(n.type=cy[t.type]),typeof t.value<"u"&&(n.value=Ue(t.value)),n}function uy(t){return t.map(e=>({address:e.address,r:e.r?Ue(BigInt(e.r)):e.r,s:e.s?Ue(BigInt(e.s)):e.s,chainId:Ue(e.chainId),nonce:Ue(e.nonce),...typeof e.yParity<"u"?{yParity:Ue(e.yParity)}:{},...typeof e.v<"u"&&typeof e.yParity>"u"?{v:Ue(e.v)}:{}}))}function Qd(t){if(!(!t||t.length===0))return t.reduce((e,{slot:n,value:r})=>{if(n.length!==66)throw new pd({size:n.length,targetSize:66,type:"hex"});if(r.length!==66)throw new pd({size:r.length,targetSize:66,type:"hex"});return e[n]=r,e},{})}function dy(t){const{balance:e,nonce:n,state:r,stateDiff:s,code:i}=t,o={};if(i!==void 0&&(o.code=i),e!==void 0&&(o.balance=Ue(e)),n!==void 0&&(o.nonce=Ue(n)),r!==void 0&&(o.state=Qd(r)),s!==void 0){if(o.state)throw new qg;o.stateDiff=Qd(s)}return o}function ly(t){if(!t)return;const e={};for(const{address:n,...r}of t){if(!Ln(n,{strict:!1}))throw new ns({address:n});if(e[n])throw new Gg({address:n});e[n]=dy(r)}return e}const fy=2n**256n-1n;function Ai(t){const{account:e,maxFeePerGas:n,maxPriorityFeePerGas:r,to:s}=t,i=e?wn(e):void 0;if(i&&!Ln(i.address))throw new ns({address:i.address});if(s&&!Ln(s))throw new ns({address:s});if(n&&n>fy)throw new vi({maxFeePerGas:n});if(r&&n&&r>n)throw new Ri({maxFeePerGas:n,maxPriorityFeePerGas:r})}function hy(t){const e=di(`0x${t.substring(4)}`).substring(26);return li(`0x${e}`)}async function py({hash:t,signature:e}){const n=kn(t)?t:Vo(t),{secp256k1:r}=await Promise.resolve().then(()=>v1);return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:m,s:g,v:S,yParity:I}=e,N=Number(I??S),F=el(N);return new r.Signature(Er(m),Er(g)).addRecoveryBit(F)}const o=kn(e)?e:Vo(e);if(Et(o)!==65)throw new Error("invalid signature length");const a=er(`0x${o.slice(130)}`),d=el(a);return r.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(d)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}function el(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function my({hash:t,signature:e}){return hy(await py({hash:t,signature:e}))}function gy(t,e="hex"){const n=tl(t),r=Xo(new Uint8Array(n.length));return n.encode(r),e==="hex"?Ht(r.bytes):r.bytes}function tl(t){return Array.isArray(t)?yy(t.map(e=>tl(e))):by(t)}function yy(t){const e=t.reduce((s,i)=>s+i.length,0),n=nl(e);return{length:e<=55?1+e:1+n+e,encode(s){e<=55?s.pushByte(192+e):(s.pushByte(247+n),n===1?s.pushUint8(e):n===2?s.pushUint16(e):n===3?s.pushUint24(e):s.pushUint32(e));for(const{encode:i}of t)i(s)}}}function by(t){const e=typeof t=="string"?nn(t):t,n=nl(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+n+e.length,encode(s){e.length===1&&e[0]<128?s.pushBytes(e):e.length<=55?(s.pushByte(128+e.length),s.pushBytes(e)):(s.pushByte(183+n),n===1?s.pushUint8(e.length):n===2?s.pushUint16(e.length):n===3?s.pushUint24(e.length):s.pushUint32(e.length),s.pushBytes(e))}}}function nl(t){if(t<2**8)return 1;if(t<2**16)return 2;if(t<2**24)return 3;if(t<2**32)return 4;throw new de("Length is too large.")}function _y(t){const{chainId:e,nonce:n,to:r}=t,s=t.contractAddress??t.address,i=di(Qo(["0x05",gy([e?Ue(e):"0x",s,n?Ue(n):"0x"])]));return r==="bytes"?nn(i):i}async function rl(t){const{authorization:e,signature:n}=t;return my({hash:_y(e),signature:n??e})}class Ey extends de{constructor(e,{account:n,docsPath:r,chain:s,data:i,gas:o,gasPrice:a,maxFeePerGas:d,maxPriorityFeePerGas:m,nonce:g,to:S,value:I}){const N=mi({from:n?.address,to:S,value:typeof I<"u"&&`${Hd(I)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:o,gasPrice:typeof a<"u"&&`${rn(a)} gwei`,maxFeePerGas:typeof d<"u"&&`${rn(d)} gwei`,maxPriorityFeePerGas:typeof m<"u"&&`${rn(m)} gwei`,nonce:g});super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Estimate Gas Arguments:",N].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}function wy(t,{docsPath:e,...n}){const r=(()=>{const s=Xd(t,n);return s instanceof va?t:s})();return new Ey(r,{docsPath:e,...n})}class sl extends de{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class Sa extends de{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class vy extends de{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${rn(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class Ry extends de{constructor({blockHash:e,blockNumber:n}){let r="Block";e&&(r=`Block at hash "${e}"`),n&&(r=`Block at number "${n}"`),super(`${r} could not be found.`,{name:"BlockNotFoundError"})}}const Ay={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function il(t,e){const n={...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,chainId:t.chainId?er(t.chainId):void 0,gas:t.gas?BigInt(t.gas):void 0,gasPrice:t.gasPrice?BigInt(t.gasPrice):void 0,maxFeePerBlobGas:t.maxFeePerBlobGas?BigInt(t.maxFeePerBlobGas):void 0,maxFeePerGas:t.maxFeePerGas?BigInt(t.maxFeePerGas):void 0,maxPriorityFeePerGas:t.maxPriorityFeePerGas?BigInt(t.maxPriorityFeePerGas):void 0,nonce:t.nonce?er(t.nonce):void 0,to:t.to?t.to:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,type:t.type?Ay[t.type]:void 0,typeHex:t.type?t.type:void 0,value:t.value?BigInt(t.value):void 0,v:t.v?BigInt(t.v):void 0};return t.authorizationList&&(n.authorizationList=Sy(t.authorizationList)),n.yParity=(()=>{if(t.yParity)return Number(t.yParity);if(typeof n.v=="bigint"){if(n.v===0n||n.v===27n)return 0;if(n.v===1n||n.v===28n)return 1;if(n.v>=35n)return n.v%2n===0n?1:0}})(),n.type==="legacy"&&(delete n.accessList,delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas,delete n.yParity),n.type==="eip2930"&&(delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas),n.type==="eip1559"&&delete n.maxFeePerBlobGas,n}function Sy(t){return t.map(e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))}function xy(t,e){const n=(t.transactions??[]).map(r=>typeof r=="string"?r:il(r));return{...t,baseFeePerGas:t.baseFeePerGas?BigInt(t.baseFeePerGas):null,blobGasUsed:t.blobGasUsed?BigInt(t.blobGasUsed):void 0,difficulty:t.difficulty?BigInt(t.difficulty):void 0,excessBlobGas:t.excessBlobGas?BigInt(t.excessBlobGas):void 0,gasLimit:t.gasLimit?BigInt(t.gasLimit):void 0,gasUsed:t.gasUsed?BigInt(t.gasUsed):void 0,hash:t.hash?t.hash:null,logsBloom:t.logsBloom?t.logsBloom:null,nonce:t.nonce?t.nonce:null,number:t.number?BigInt(t.number):null,size:t.size?BigInt(t.size):void 0,timestamp:t.timestamp?BigInt(t.timestamp):void 0,transactions:n,totalDifficulty:t.totalDifficulty?BigInt(t.totalDifficulty):null}}async function Ns(t,{blockHash:e,blockNumber:n,blockTag:r=t.experimental_blockTag??"latest",includeTransactions:s}={}){const i=s??!1,o=n!==void 0?Ue(n):void 0;let a=null;if(e?a=await t.request({method:"eth_getBlockByHash",params:[e,i]},{dedupe:!0}):a=await t.request({method:"eth_getBlockByNumber",params:[o||r,i]},{dedupe:!!o}),!a)throw new Ry({blockHash:e,blockNumber:n});return(t.chain?.formatters?.block?.format||xy)(a,"getBlock")}async function ol(t){const e=await t.request({method:"eth_gasPrice"});return BigInt(e)}async function Ty(t,e){const{block:n,chain:r=t.chain,request:s}=e||{};try{const i=r?.fees?.maxPriorityFeePerGas??r?.fees?.defaultPriorityFee;if(typeof i=="function"){const a=n||await Ot(t,Ns,"getBlock")({}),d=await i({block:a,client:t,request:s});if(d===null)throw new Error;return d}if(typeof i<"u")return i;const o=await t.request({method:"eth_maxPriorityFeePerGas"});return Er(o)}catch{const[i,o]=await Promise.all([n?Promise.resolve(n):Ot(t,Ns,"getBlock")({}),Ot(t,ol,"getGasPrice")({})]);if(typeof i.baseFeePerGas!="bigint")throw new Sa;const a=o-i.baseFeePerGas;return a<0n?0n:a}}async function al(t,e){const{block:n,chain:r=t.chain,request:s,type:i="eip1559"}=e||{},o=await(async()=>typeof r?.fees?.baseFeeMultiplier=="function"?r.fees.baseFeeMultiplier({block:n,client:t,request:s}):r?.fees?.baseFeeMultiplier??1.2)();if(o<1)throw new sl;const d=10**(o.toString().split(".")[1]?.length??0),m=I=>I*BigInt(Math.ceil(o*d))/BigInt(d),g=n||await Ot(t,Ns,"getBlock")({});if(typeof r?.fees?.estimateFeesPerGas=="function"){const I=await r.fees.estimateFeesPerGas({block:n,client:t,multiply:m,request:s,type:i});if(I!==null)return I}if(i==="eip1559"){if(typeof g.baseFeePerGas!="bigint")throw new Sa;const I=typeof s?.maxPriorityFeePerGas=="bigint"?s.maxPriorityFeePerGas:await Ty(t,{block:g,chain:r,request:s}),N=m(g.baseFeePerGas);return{maxFeePerGas:s?.maxFeePerGas??N+I,maxPriorityFeePerGas:I}}return{gasPrice:s?.gasPrice??m(await Ot(t,ol,"getGasPrice")({}))}}async function Iy(t,{address:e,blockTag:n="latest",blockNumber:r}){const s=await t.request({method:"eth_getTransactionCount",params:[e,typeof r=="bigint"?Ue(r):n]},{dedupe:!!r});return er(s)}function cl(t){const{kzg:e}=t,n=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),r=typeof t.blobs[0]=="string"?t.blobs.map(i=>nn(i)):t.blobs,s=[];for(const i of r)s.push(Uint8Array.from(e.blobToKzgCommitment(i)));return n==="bytes"?s:s.map(i=>Ht(i))}function ul(t){const{kzg:e}=t,n=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),r=typeof t.blobs[0]=="string"?t.blobs.map(o=>nn(o)):t.blobs,s=typeof t.commitments[0]=="string"?t.commitments.map(o=>nn(o)):t.commitments,i=[];for(let o=0;o<r.length;o++){const a=r[o],d=s[o];i.push(Uint8Array.from(e.computeBlobKzgProof(a,d)))}return n==="bytes"?i:i.map(o=>Ht(o))}function Oy(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),d=r?4:0,m=r?0:4;t.setUint32(e+d,o,r),t.setUint32(e+m,a,r)}function Ny(t,e,n){return t&e^~t&n}function Cy(t,e,n){return t&e^t&n^e&n}class dl extends Ko{constructor(e,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(e),this.view=qo(this.buffer)}update(e){Ar(this),e=ui(e),tr(e);const{view:n,buffer:r,blockLen:s}=this,i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const d=qo(e);for(;s<=i-o;o+=s)this.process(d,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ar(this),Rd(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;n[o++]=128,Un(this.buffer.subarray(o)),this.padOffset>s-o&&(this.process(r,0),o=0);for(let S=o;S<s;S++)n[S]=0;Oy(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=qo(e),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const m=d/4,g=this.get();if(m>g.length)throw new Error("_sha2: outputLen bigger than state");for(let S=0;S<m;S++)a.setUint32(4*S,g[S],i)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=i,e.length=s,e.pos=a,s%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const Pn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Nt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),My=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Fn=new Uint32Array(64);class ky extends dl{constructor(e=32){super(64,e,8,!1),this.A=Pn[0]|0,this.B=Pn[1]|0,this.C=Pn[2]|0,this.D=Pn[3]|0,this.E=Pn[4]|0,this.F=Pn[5]|0,this.G=Pn[6]|0,this.H=Pn[7]|0}get(){const{A:e,B:n,C:r,D:s,E:i,F:o,G:a,H:d}=this;return[e,n,r,s,i,o,a,d]}set(e,n,r,s,i,o,a,d){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=d|0}process(e,n){for(let S=0;S<16;S++,n+=4)Fn[S]=e.getUint32(n,!1);for(let S=16;S<64;S++){const I=Fn[S-15],N=Fn[S-2],F=dn(I,7)^dn(I,18)^I>>>3,M=dn(N,17)^dn(N,19)^N>>>10;Fn[S]=M+Fn[S-7]+F+Fn[S-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:d,G:m,H:g}=this;for(let S=0;S<64;S++){const I=dn(a,6)^dn(a,11)^dn(a,25),N=g+I+Ny(a,d,m)+My[S]+Fn[S]|0,M=(dn(r,2)^dn(r,13)^dn(r,22))+Cy(r,s,i)|0;g=m,m=d,d=a,a=o+N|0,o=i,i=s,s=r,r=N+M|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,d=d+this.F|0,m=m+this.G|0,g=g+this.H|0,this.set(r,s,i,o,a,d,m,g)}roundClean(){Un(Fn)}destroy(){this.set(0,0,0,0,0,0,0,0),Un(this.buffer)}}const ll=Ed(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),By=ll[0],Uy=ll[1],$n=new Uint32Array(80),zn=new Uint32Array(80);class Ly extends dl{constructor(e=64){super(128,e,16,!1),this.Ah=Nt[0]|0,this.Al=Nt[1]|0,this.Bh=Nt[2]|0,this.Bl=Nt[3]|0,this.Ch=Nt[4]|0,this.Cl=Nt[5]|0,this.Dh=Nt[6]|0,this.Dl=Nt[7]|0,this.Eh=Nt[8]|0,this.El=Nt[9]|0,this.Fh=Nt[10]|0,this.Fl=Nt[11]|0,this.Gh=Nt[12]|0,this.Gl=Nt[13]|0,this.Hh=Nt[14]|0,this.Hl=Nt[15]|0}get(){const{Ah:e,Al:n,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:d,Eh:m,El:g,Fh:S,Fl:I,Gh:N,Gl:F,Hh:M,Hl:B}=this;return[e,n,r,s,i,o,a,d,m,g,S,I,N,F,M,B]}set(e,n,r,s,i,o,a,d,m,g,S,I,N,F,M,B){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=d|0,this.Eh=m|0,this.El=g|0,this.Fh=S|0,this.Fl=I|0,this.Gh=N|0,this.Gl=F|0,this.Hh=M|0,this.Hl=B|0}process(e,n){for(let z=0;z<16;z++,n+=4)$n[z]=e.getUint32(n),zn[z]=e.getUint32(n+=4);for(let z=16;z<80;z++){const U=$n[z-15]|0,j=zn[z-15]|0,J=wr(U,j,1)^wr(U,j,8)^wd(U,j,7),ne=vr(U,j,1)^vr(U,j,8)^vd(U,j,7),te=$n[z-2]|0,V=zn[z-2]|0,C=wr(te,V,19)^ai(te,V,61)^wd(te,V,6),L=vr(te,V,19)^ci(te,V,61)^vd(te,V,6),q=km(ne,L,zn[z-7],zn[z-16]),w=Bm(q,J,C,$n[z-7],$n[z-16]);$n[z]=w|0,zn[z]=q|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:d,Dh:m,Dl:g,Eh:S,El:I,Fh:N,Fl:F,Gh:M,Gl:B,Hh:K,Hl:Y}=this;for(let z=0;z<80;z++){const U=wr(S,I,14)^wr(S,I,18)^ai(S,I,41),j=vr(S,I,14)^vr(S,I,18)^ci(S,I,41),J=S&N^~S&M,ne=I&F^~I&B,te=Um(Y,j,ne,Uy[z],zn[z]),V=Lm(te,K,U,J,By[z],$n[z]),C=te|0,L=wr(r,s,28)^ai(r,s,34)^ai(r,s,39),q=vr(r,s,28)^ci(r,s,34)^ci(r,s,39),w=r&i^r&a^i&a,c=s&o^s&d^o&d;K=M|0,Y=B|0,M=N|0,B=F|0,N=S|0,F=I|0,{h:S,l:I}=_n(m|0,g|0,V|0,C|0),m=a|0,g=d|0,a=i|0,d=o|0,i=r|0,o=s|0;const p=Cm(C,q,c);r=Mm(p,V,L,w),s=p|0}({h:r,l:s}=_n(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=_n(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:d}=_n(this.Ch|0,this.Cl|0,a|0,d|0),{h:m,l:g}=_n(this.Dh|0,this.Dl|0,m|0,g|0),{h:S,l:I}=_n(this.Eh|0,this.El|0,S|0,I|0),{h:N,l:F}=_n(this.Fh|0,this.Fl|0,N|0,F|0),{h:M,l:B}=_n(this.Gh|0,this.Gl|0,M|0,B|0),{h:K,l:Y}=_n(this.Hh|0,this.Hl|0,K|0,Y|0),this.set(r,s,i,o,a,d,m,g,S,I,N,F,M,B,K,Y)}roundClean(){Un($n,zn)}destroy(){Un(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const fl=Wo(()=>new ky),Dy=Wo(()=>new Ly),xa=fl;function Py(t,e){return xa(kn(t,{strict:!1})?Go(t):t)}function Fy(t){const{commitment:e,version:n=1}=t,r=t.to??(typeof e=="string"?"hex":"bytes"),s=Py(e);return s.set([n],0),r==="bytes"?s:Ht(s)}function $y(t){const{commitments:e,version:n}=t,r=t.to,s=[];for(const i of e)s.push(Fy({commitment:i,to:r,version:n}));return s}const hl=6,pl=32,Ta=4096,ml=pl*Ta,gl=ml*hl-1-1*Ta*hl;class zy extends de{constructor({maxSize:e,size:n}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${n} bytes`],name:"BlobSizeTooLargeError"})}}class jy extends de{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function Vy(t){const e=typeof t.data=="string"?nn(t.data):t.data,n=Et(e);if(!n)throw new jy;if(n>gl)throw new zy({maxSize:gl,size:n});const r=[];let s=!0,i=0;for(;s;){const o=Xo(new Uint8Array(ml));let a=0;for(;a<Ta;){const d=e.slice(i,i+(pl-1));if(o.pushByte(0),o.pushBytes(d),d.length<31){o.pushByte(128),s=!1;break}a++,i+=31}r.push(o)}return r.map(o=>Ht(o.bytes))}function Hy(t){const{data:e,kzg:n,to:r}=t,s=t.blobs??Vy({data:e}),i=t.commitments??cl({blobs:s,kzg:n,to:r}),o=t.proofs??ul({blobs:s,commitments:i,kzg:n,to:r}),a=[];for(let d=0;d<s.length;d++)a.push({blob:s[d],commitment:i[d],proof:o[d]});return a}function Gy(t){if(t.type)return t.type;if(typeof t.authorizationList<"u")return"eip7702";if(typeof t.blobs<"u"||typeof t.blobVersionedHashes<"u"||typeof t.maxFeePerBlobGas<"u"||typeof t.sidecars<"u")return"eip4844";if(typeof t.maxFeePerGas<"u"||typeof t.maxPriorityFeePerGas<"u")return"eip1559";if(typeof t.gasPrice<"u")return typeof t.accessList<"u"?"eip2930":"legacy";throw new Kg({transaction:t})}function yl(t,{docsPath:e,...n}){const r=(()=>{const s=Xd(t,n);return s instanceof va?t:s})();return new Wg(r,{docsPath:e,...n})}async function Ia(t){const e=await t.request({method:"eth_chainId"},{dedupe:!0});return er(e)}async function qy(t,e){const{account:n=t.account,accessList:r,authorizationList:s,chain:i=t.chain,blobVersionedHashes:o,blobs:a,data:d,gas:m,gasPrice:g,maxFeePerBlobGas:S,maxFeePerGas:I,maxPriorityFeePerGas:N,nonce:F,nonceManager:M,to:B,type:K,value:Y,...z}=e,U=await(async()=>{if(!n||!M||typeof F<"u")return F;const te=wn(n),V=i?i.id:await Ot(t,Ia,"getChainId")({});return await M.consume({address:te.address,chainId:V,client:t})})();Ai(e);const j=i?.formatters?.transactionRequest?.format,ne=(j||Aa)({...Ra(z,{format:j}),account:n?wn(n):void 0,accessList:r,authorizationList:s,blobs:a,blobVersionedHashes:o,data:d,gas:m,gasPrice:g,maxFeePerBlobGas:S,maxFeePerGas:I,maxPriorityFeePerGas:N,nonce:U,to:B,type:K,value:Y},"fillTransaction");try{const te=await t.request({method:"eth_fillTransaction",params:[ne]}),C=(i?.formatters?.transaction?.format||il)(te.tx);delete C.blockHash,delete C.blockNumber,delete C.r,delete C.s,delete C.transactionIndex,delete C.v,delete C.yParity,C.data=C.input,C.gas&&(C.gas=e.gas??C.gas),C.gasPrice&&(C.gasPrice=e.gasPrice??C.gasPrice),C.maxFeePerBlobGas&&(C.maxFeePerBlobGas=e.maxFeePerBlobGas??C.maxFeePerBlobGas),C.maxFeePerGas&&(C.maxFeePerGas=e.maxFeePerGas??C.maxFeePerGas),C.maxPriorityFeePerGas&&(C.maxPriorityFeePerGas=e.maxPriorityFeePerGas??C.maxPriorityFeePerGas),C.nonce&&(C.nonce=e.nonce??C.nonce);const L=await(async()=>{if(typeof i?.fees?.baseFeeMultiplier=="function"){const p=await Ot(t,Ns,"getBlock")({});return i.fees.baseFeeMultiplier({block:p,client:t,request:e})}return i?.fees?.baseFeeMultiplier??1.2})();if(L<1)throw new sl;const w=10**(L.toString().split(".")[1]?.length??0),c=p=>p*BigInt(Math.ceil(L*w))/BigInt(w);return C.maxFeePerGas&&!e.maxFeePerGas&&(C.maxFeePerGas=c(C.maxFeePerGas)),C.gasPrice&&!e.gasPrice&&(C.gasPrice=c(C.gasPrice)),{raw:te.raw,transaction:{from:ne.from,...C}}}catch(te){throw yl(te,{...e,chain:t.chain})}}const bl=["blobVersionedHashes","chainId","fees","gas","nonce","type"],_l=new Map,Oa=new is(128);async function El(t,e){let n=e;n.account??=t.account,n.parameters??=bl;const{account:r,chain:s=t.chain,nonceManager:i,parameters:o}=n,a=(()=>{if(typeof s?.prepareTransactionRequest=="function")return{fn:s.prepareTransactionRequest,runAt:["beforeFillTransaction"]};if(Array.isArray(s?.prepareTransactionRequest))return{fn:s.prepareTransactionRequest[0],runAt:s.prepareTransactionRequest[1].runAt}})();let d;async function m(){return d||(typeof n.chainId<"u"?n.chainId:s?s.id:(d=await Ot(t,Ia,"getChainId")({}),d))}const g=r&&wn(r);let S=n.nonce;if(o.includes("nonce")&&typeof S>"u"&&g&&i){const U=await m();S=await i.consume({address:g.address,chainId:U,client:t})}a?.fn&&a.runAt?.includes("beforeFillTransaction")&&(n=await a.fn({...n,chain:s},{phase:"beforeFillTransaction"}),S??=n.nonce);const N=((o.includes("blobVersionedHashes")||o.includes("sidecars"))&&n.kzg&&n.blobs||Oa.get(t.uid)===!1||!["fees","gas"].some(j=>o.includes(j))?!1:!!(o.includes("chainId")&&typeof n.chainId!="number"||o.includes("nonce")&&typeof S!="number"||o.includes("fees")&&typeof n.gasPrice!="bigint"&&(typeof n.maxFeePerGas!="bigint"||typeof n.maxPriorityFeePerGas!="bigint")||o.includes("gas")&&typeof n.gas!="bigint"))?await Ot(t,qy,"fillTransaction")({...n,nonce:S}).then(U=>{const{chainId:j,from:J,gas:ne,gasPrice:te,nonce:V,maxFeePerBlobGas:C,maxFeePerGas:L,maxPriorityFeePerGas:q,type:w,...c}=U.transaction;return Oa.set(t.uid,!0),{...n,...J?{from:J}:{},...w?{type:w}:{},...typeof j<"u"?{chainId:j}:{},...typeof ne<"u"?{gas:ne}:{},...typeof te<"u"?{gasPrice:te}:{},...typeof V<"u"?{nonce:V}:{},...typeof C<"u"?{maxFeePerBlobGas:C}:{},...typeof L<"u"?{maxFeePerGas:L}:{},...typeof q<"u"?{maxPriorityFeePerGas:q}:{},..."nonceKey"in c&&typeof c.nonceKey<"u"?{nonceKey:c.nonceKey}:{}}}).catch(U=>{const j=U;return j.name!=="TransactionExecutionError"||j.walk?.(ne=>{const te=ne;return te.name==="MethodNotFoundRpcError"||te.name==="MethodNotSupportedRpcError"})&&Oa.set(t.uid,!1),n}):n;S??=N.nonce,n={...N,...g?{from:g?.address}:{},...S?{nonce:S}:{}};const{blobs:F,gas:M,kzg:B,type:K}=n;a?.fn&&a.runAt?.includes("beforeFillParameters")&&(n=await a.fn({...n,chain:s},{phase:"beforeFillParameters"}));let Y;async function z(){return Y||(Y=await Ot(t,Ns,"getBlock")({blockTag:"latest"}),Y)}if(o.includes("nonce")&&typeof S>"u"&&g&&!i&&(n.nonce=await Ot(t,Iy,"getTransactionCount")({address:g.address,blockTag:"pending"})),(o.includes("blobVersionedHashes")||o.includes("sidecars"))&&F&&B){const U=cl({blobs:F,kzg:B});if(o.includes("blobVersionedHashes")){const j=$y({commitments:U,to:"hex"});n.blobVersionedHashes=j}if(o.includes("sidecars")){const j=ul({blobs:F,commitments:U,kzg:B}),J=Hy({blobs:F,commitments:U,proofs:j,to:"hex"});n.sidecars=J}}if(o.includes("chainId")&&(n.chainId=await m()),(o.includes("fees")||o.includes("type"))&&typeof K>"u")try{n.type=Gy(n)}catch{let U=_l.get(t.uid);typeof U>"u"&&(U=typeof(await z())?.baseFeePerGas=="bigint",_l.set(t.uid,U)),n.type=U?"eip1559":"legacy"}if(o.includes("fees"))if(n.type!=="legacy"&&n.type!=="eip2930"){if(typeof n.maxFeePerGas>"u"||typeof n.maxPriorityFeePerGas>"u"){const U=await z(),{maxFeePerGas:j,maxPriorityFeePerGas:J}=await al(t,{block:U,chain:s,request:n});if(typeof n.maxPriorityFeePerGas>"u"&&n.maxFeePerGas&&n.maxFeePerGas<J)throw new vy({maxPriorityFeePerGas:J});n.maxPriorityFeePerGas=J,n.maxFeePerGas=j}}else{if(typeof n.maxFeePerGas<"u"||typeof n.maxPriorityFeePerGas<"u")throw new Sa;if(typeof n.gasPrice>"u"){const U=await z(),{gasPrice:j}=await al(t,{block:U,chain:s,request:n,type:"legacy"});n.gasPrice=j}}return o.includes("gas")&&typeof M>"u"&&(n.gas=await Ot(t,Ky,"estimateGas")({...n,account:g,prepare:g?.type==="local"?[]:["blobVersionedHashes"]})),a?.fn&&a.runAt?.includes("afterFillParameters")&&(n=await a.fn({...n,chain:s},{phase:"afterFillParameters"})),Ai(n),delete n.parameters,n}async function Ky(t,e){const{account:n=t.account,prepare:r=!0}=e,s=n?wn(n):void 0,i=(()=>{if(Array.isArray(r))return r;if(s?.type!=="local")return["blobVersionedHashes"]})();try{const o=await(async()=>{if(e.to)return e.to;if(e.authorizationList&&e.authorizationList.length>0)return await rl({authorization:e.authorizationList[0]}).catch(()=>{throw new de("`to` is required. Could not infer from `authorizationList`")})})(),{accessList:a,authorizationList:d,blobs:m,blobVersionedHashes:g,blockNumber:S,blockTag:I,data:N,gas:F,gasPrice:M,maxFeePerBlobGas:B,maxFeePerGas:K,maxPriorityFeePerGas:Y,nonce:z,value:U,stateOverride:j,...J}=r?await El(t,{...e,parameters:i,to:o}):e;if(F&&e.gas!==F)return F;const te=(typeof S=="bigint"?Ue(S):void 0)||I,V=ly(j);Ai(e);const C=t.chain?.formatters?.transactionRequest?.format,q=(C||Aa)({...Ra(J,{format:C}),account:s,accessList:a,authorizationList:d,blobs:m,blobVersionedHashes:g,data:N,gasPrice:M,maxFeePerBlobGas:B,maxFeePerGas:K,maxPriorityFeePerGas:Y,nonce:z,to:o,value:U},"estimateGas");return BigInt(await t.request({method:"eth_estimateGas",params:V?[q,te??t.experimental_blockTag??"latest",V]:te?[q,te]:[q]}))}catch(o){throw wy(o,{...e,account:s,chain:t.chain})}}const Si=new is(8192);function Wy(t,{enabled:e=!0,id:n}){if(!e||!n)return t();if(Si.get(n))return Si.get(n);const r=t().finally(()=>Si.delete(n));return Si.set(n,r),r}async function Zy(t){return new Promise(e=>setTimeout(e,t))}function Yy(t,{delay:e=100,retryCount:n=2,shouldRetry:r=()=>!0}={}){return new Promise((s,i)=>{const o=async({count:a=0}={})=>{const d=async({error:m})=>{const g=typeof e=="function"?e({count:a,error:m}):e;g&&await Zy(g),o({count:a+1})};try{const m=await t();s(m)}catch(m){if(a<n&&await r({count:a,error:m}))return d({error:m});i(m)}};o()})}function Jy(t,e={}){return async(n,r={})=>{const{dedupe:s=!1,methods:i,retryDelay:o=150,retryCount:a=3,uid:d}={...e,...r},{method:m}=n;if(i?.exclude?.includes(m))throw new rr(new Error("method not supported"),{method:m});if(i?.include&&!i.include.includes(m))throw new rr(new Error("method not supported"),{method:m});const g=s?Ho(`${d}.${pi(n)}`):void 0;return Wy(()=>Yy(async()=>{try{return await t(n)}catch(S){const I=S;switch(I.code){case cs.code:throw new cs(I);case us.code:throw new us(I);case ds.code:throw new ds(I,{method:n.method});case ls.code:throw new ls(I);case nr.code:throw new nr(I);case Tr.code:throw new Tr(I);case fs.code:throw new fs(I);case hs.code:throw new hs(I);case ps.code:throw new ps(I);case rr.code:throw new rr(I,{method:n.method});case Ir.code:throw new Ir(I);case ms.code:throw new ms(I);case gi.code:throw new gi(I);case gs.code:throw new gs(I);case ys.code:throw new ys(I);case bs.code:throw new bs(I);case aa.code:throw new aa(I);case Or.code:throw new Or(I);case _s.code:throw new _s(I);case Es.code:throw new Es(I);case ws.code:throw new ws(I);case vs.code:throw new vs(I);case Rs.code:throw new Rs(I);case As.code:throw new As(I);case Ss.code:throw new Ss(I);case 5e3:throw new gi(I);default:throw S instanceof de?S:new ty(I)}}},{delay:({count:S,error:I})=>{if(I&&I instanceof qd){const N=I?.headers?.get("Retry-After");if(N?.match(/\d/))return Number.parseInt(N,10)*1e3}return~~(1<<S)*o},retryCount:a,shouldRetry:({error:S})=>Xy(S)}),{enabled:s,id:g})}}function Xy(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===Ir.code||t.code===nr.code:t instanceof qd&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function Qy({chain:t,currentChainId:e}){if(!t)throw new Pg;if(e!==t.id)throw new Dg({chain:t,currentChainId:e})}class wl extends Ko{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Pm(e);const r=ui(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),Un(i)}update(e){return Ar(this),this.iHash.update(e),this}digestInto(e){Ar(this),tr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const vl=(t,e,n)=>new wl(t,e).update(n).digest();vl.create=(t,e)=>new wl(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const qt=BigInt(0),At=BigInt(1),ir=BigInt(2),e1=BigInt(3),Rl=BigInt(4),Al=BigInt(5),Sl=BigInt(8);function Ve(t,e){const n=t%e;return n>=qt?n:e+n}function Ke(t,e,n){let r=t;for(;e-- >qt;)r*=r,r%=n;return r}function Na(t,e){if(t===qt)throw new Error("invert: expected non-zero number");if(e<=qt)throw new Error("invert: expected positive modulus, got "+e);let n=Ve(t,e),r=e,s=qt,i=At;for(;n!==qt;){const a=r/n,d=r%n,m=s-i*a;r=n,n=d,s=i,i=m}if(r!==At)throw new Error("invert: does not exist");return Ve(s,e)}function xl(t,e){const n=(t.ORDER+At)/Rl,r=t.pow(e,n);if(!t.eql(t.sqr(r),e))throw new Error("Cannot find square root");return r}function t1(t,e){const n=(t.ORDER-Al)/Sl,r=t.mul(e,ir),s=t.pow(r,n),i=t.mul(e,s),o=t.mul(t.mul(i,ir),s),a=t.mul(i,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),e))throw new Error("Cannot find square root");return a}function n1(t){if(t<BigInt(3))throw new Error("sqrt is not defined for small field");let e=t-At,n=0;for(;e%ir===qt;)e/=ir,n++;let r=ir;const s=Cs(t);for(;Tl(s,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return xl;let i=s.pow(r,e);const o=(e+At)/ir;return function(d,m){if(d.is0(m))return m;if(Tl(d,m)!==1)throw new Error("Cannot find square root");let g=n,S=d.mul(d.ONE,i),I=d.pow(m,e),N=d.pow(m,o);for(;!d.eql(I,d.ONE);){if(d.is0(I))return d.ZERO;let F=1,M=d.sqr(I);for(;!d.eql(M,d.ONE);)if(F++,M=d.sqr(M),F===g)throw new Error("Cannot find square root");const B=At<<BigInt(g-F-1),K=d.pow(S,B);g=F,S=d.sqr(K),I=d.mul(I,S),N=d.mul(N,K)}return N}}function r1(t){return t%Rl===e1?xl:t%Sl===Al?t1:n1(t)}const s1=(t,e)=>(Ve(t,e)&At)===At,i1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function o1(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=i1.reduce((r,s)=>(r[s]="function",r),e);return Os(t,n)}function a1(t,e,n){if(n<qt)throw new Error("invalid exponent, negatives unsupported");if(n===qt)return t.ONE;if(n===At)return e;let r=t.ONE,s=e;for(;n>qt;)n&At&&(r=t.mul(r,s)),s=t.sqr(s),n>>=At;return r}function Ca(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),s=e.reduce((o,a,d)=>t.is0(a)?o:(r[d]=o,t.mul(o,a)),t.ONE),i=t.inv(s);return e.reduceRight((o,a,d)=>t.is0(a)?o:(r[d]=t.mul(o,r[d]),t.mul(o,a)),i),r}function Tl(t,e){const n=(t.ORDER-At)/ir,r=t.pow(e,n),s=t.eql(r,t.ONE),i=t.eql(r,t.ZERO),o=t.eql(r,t.neg(t.ONE));if(!s&&!i&&!o)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function Il(t,e){e!==void 0&&rs(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Cs(t,e,n=!1,r={}){if(t<=qt)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:i}=Il(t,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:n,BITS:s,BYTES:i,MASK:Ei(s),ZERO:qt,ONE:At,create:d=>Ve(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return qt<=d&&d<t},is0:d=>d===qt,isOdd:d=>(d&At)===At,neg:d=>Ve(-d,t),eql:(d,m)=>d===m,sqr:d=>Ve(d*d,t),add:(d,m)=>Ve(d+m,t),sub:(d,m)=>Ve(d-m,t),mul:(d,m)=>Ve(d*m,t),pow:(d,m)=>a1(a,d,m),div:(d,m)=>Ve(d*Na(m,t),t),sqrN:d=>d*d,addN:(d,m)=>d+m,subN:(d,m)=>d-m,mulN:(d,m)=>d*m,inv:d=>Na(d,t),sqrt:r.sqrt||(d=>(o||(o=r1(t)),o(a,d))),toBytes:d=>n?_i(d,i):Is(d,i),fromBytes:d=>{if(d.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+d.length);return n?Ts(d):sr(d)},invertBatch:d=>Ca(a,d),cmov:(d,m,g)=>g?m:d});return Object.freeze(a)}function Ol(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Nl(t){const e=Ol(t);return e+Math.ceil(e/2)}function c1(t,e,n=!1){const r=t.length,s=Ol(e),i=Nl(e);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const o=n?Ts(t):sr(t),a=Ve(o,e-At)+At;return n?_i(a,s):Is(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Cl=BigInt(0),Ma=BigInt(1);function ka(t,e){const n=e.negate();return t?n:e}function Ml(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ba(t,e){Ml(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),s=2**t,i=Ei(t),o=BigInt(t);return{windows:n,windowSize:r,mask:i,maxNumber:s,shiftBy:o}}function kl(t,e,n){const{windowSize:r,mask:s,maxNumber:i,shiftBy:o}=n;let a=Number(t&s),d=t>>o;a>r&&(a-=i,d+=Ma);const m=e*r,g=m+Math.abs(a)-1,S=a===0,I=a<0,N=e%2!==0;return{nextN:d,offset:g,isZero:S,isNeg:I,isNegF:N,offsetF:m}}function u1(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function d1(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)})}const Ua=new WeakMap,Bl=new WeakMap;function La(t){return Bl.get(t)||1}function Ul(t,e){return{constTimeNegate:ka,hasPrecomputes(n){return La(n)!==1},unsafeLadder(n,r,s=t.ZERO){let i=n;for(;r>Cl;)r&Ma&&(s=s.add(i)),i=i.double(),r>>=Ma;return s},precomputeWindow(n,r){const{windows:s,windowSize:i}=Ba(r,e),o=[];let a=n,d=a;for(let m=0;m<s;m++){d=a,o.push(d);for(let g=1;g<i;g++)d=d.add(a),o.push(d);a=d.double()}return o},wNAF(n,r,s){let i=t.ZERO,o=t.BASE;const a=Ba(n,e);for(let d=0;d<a.windows;d++){const{nextN:m,offset:g,isZero:S,isNeg:I,isNegF:N,offsetF:F}=kl(s,d,a);s=m,S?o=o.add(ka(N,r[F])):i=i.add(ka(I,r[g]))}return{p:i,f:o}},wNAFUnsafe(n,r,s,i=t.ZERO){const o=Ba(n,e);for(let a=0;a<o.windows&&s!==Cl;a++){const{nextN:d,offset:m,isZero:g,isNeg:S}=kl(s,a,o);if(s=d,!g){const I=r[m];i=i.add(S?I.negate():I)}}return i},getPrecomputes(n,r,s){let i=Ua.get(r);return i||(i=this.precomputeWindow(r,n),n!==1&&Ua.set(r,s(i))),i},wNAFCached(n,r,s){const i=La(n);return this.wNAF(i,this.getPrecomputes(i,n,s),r)},wNAFCachedUnsafe(n,r,s,i){const o=La(n);return o===1?this.unsafeLadder(n,r,i):this.wNAFUnsafe(o,this.getPrecomputes(o,n,s),r,i)},setWindowSize(n,r){Ml(r,e),Bl.set(n,r),Ua.delete(n)}}}function Ll(t,e,n,r){u1(n,t),d1(r,e);const s=n.length,i=r.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=iy(BigInt(s));let d=1;a>12?d=a-3:a>4?d=a-2:a>0&&(d=2);const m=Ei(d),g=new Array(Number(m)+1).fill(o),S=Math.floor((e.BITS-1)/d)*d;let I=o;for(let N=S;N>=0;N-=d){g.fill(o);for(let M=0;M<i;M++){const B=r[M],K=Number(B>>BigInt(N)&m);g[K]=g[K].add(n[M])}let F=o;for(let M=g.length-1,B=o;M>0;M--)B=B.add(g[M]),F=F.add(B);if(I=I.add(F),N!==0)for(let M=0;M<d;M++)I=I.double()}return I}function Da(t){return o1(t.Fp),Os(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Il(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Dl(t){t.lowS!==void 0&&Dn("lowS",t.lowS),t.prehash!==void 0&&Dn("prehash",t.prehash)}function l1(t){const e=Da(t);Os(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:s}=e;if(n){if(!r.eql(s,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class f1 extends Error{constructor(e=""){super(e)}}const Rn={Err:f1,_tlv:{encode:(t,e)=>{const{Err:n}=Rn;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length&1)throw new n("tlv.encode: unpadded data");const r=e.length/2,s=yi(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?yi(s.length/2|128):"";return yi(t)+i+s+e},decode(t,e){const{Err:n}=Rn;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const s=e[r++],i=!!(s&128);let o=0;if(!i)o=s;else{const d=s&127;if(!d)throw new n("tlv.decode(long): indefinite length not supported");if(d>4)throw new n("tlv.decode(long): byte length is too big");const m=e.subarray(r,r+d);if(m.length!==d)throw new n("tlv.decode: length bytes not complete");if(m[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const g of m)o=o<<8|g;if(r+=d,o<128)throw new n("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+o);if(a.length!==o)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=Rn;if(t<An)throw new e("integer: negative integers are not allowed");let n=yi(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=Rn;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return sr(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=Rn,s=Qe("signature",t),{v:i,l:o}=r.decode(48,s);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:d}=r.decode(2,i),{v:m,l:g}=r.decode(2,d);if(g.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(m)}},hexFromSig(t){const{_tlv:e,_int:n}=Rn,r=e.encode(2,n.encode(t.r)),s=e.encode(2,n.encode(t.s)),i=r+s;return e.encode(48,i)}};function Pa(t,e){return Nr(Is(t,e))}const An=BigInt(0),wt=BigInt(1);BigInt(2);const Fa=BigInt(3),h1=BigInt(4);function p1(t){const e=l1(t),{Fp:n}=e,r=Cs(e.n,e.nBitLength),s=e.toBytes||((z,U,j)=>{const J=U.toAffine();return Cr(Uint8Array.from([4]),n.toBytes(J.x),n.toBytes(J.y))}),i=e.fromBytes||(z=>{const U=z.subarray(1),j=n.fromBytes(U.subarray(0,n.BYTES)),J=n.fromBytes(U.subarray(n.BYTES,2*n.BYTES));return{x:j,y:J}});function o(z){const{a:U,b:j}=e,J=n.sqr(z),ne=n.mul(J,z);return n.add(n.add(ne,n.mul(z,U)),j)}function a(z,U){const j=n.sqr(U),J=o(z);return n.eql(j,J)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const d=n.mul(n.pow(e.a,Fa),h1),m=n.mul(n.sqr(e.b),BigInt(27));if(n.is0(n.add(d,m)))throw new Error("bad curve params: a or b");function g(z){return fa(z,wt,e.n)}function S(z){const{allowedPrivateKeyLengths:U,nByteLength:j,wrapPrivateKey:J,n:ne}=e;if(U&&typeof z!="bigint"){if(xs(z)&&(z=Nr(z)),typeof z!="string"||!U.includes(z.length))throw new Error("invalid private key");z=z.padStart(j*2,"0")}let te;try{te=typeof z=="bigint"?z:sr(Qe("private key",z,j))}catch{throw new Error("invalid private key, expected hex or "+j+" bytes, got "+typeof z)}return J&&(te=Ve(te,ne)),sn("private key",te,wt,ne),te}function I(z){if(!(z instanceof M))throw new Error("ProjectivePoint expected")}const N=wi((z,U)=>{const{px:j,py:J,pz:ne}=z;if(n.eql(ne,n.ONE))return{x:j,y:J};const te=z.is0();U==null&&(U=te?n.ONE:n.inv(ne));const V=n.mul(j,U),C=n.mul(J,U),L=n.mul(ne,U);if(te)return{x:n.ZERO,y:n.ZERO};if(!n.eql(L,n.ONE))throw new Error("invZ was invalid");return{x:V,y:C}}),F=wi(z=>{if(z.is0()){if(e.allowInfinityPoint&&!n.is0(z.py))return;throw new Error("bad point: ZERO")}const{x:U,y:j}=z.toAffine();if(!n.isValid(U)||!n.isValid(j))throw new Error("bad point: x or y not FE");if(!a(U,j))throw new Error("bad point: equation left != right");if(!z.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class M{constructor(U,j,J){if(U==null||!n.isValid(U))throw new Error("x required");if(j==null||!n.isValid(j)||n.is0(j))throw new Error("y required");if(J==null||!n.isValid(J))throw new Error("z required");this.px=U,this.py=j,this.pz=J,Object.freeze(this)}static fromAffine(U){const{x:j,y:J}=U||{};if(!U||!n.isValid(j)||!n.isValid(J))throw new Error("invalid affine point");if(U instanceof M)throw new Error("projective point not allowed");const ne=te=>n.eql(te,n.ZERO);return ne(j)&&ne(J)?M.ZERO:new M(j,J,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(U){const j=Ca(n,U.map(J=>J.pz));return U.map((J,ne)=>J.toAffine(j[ne])).map(M.fromAffine)}static fromHex(U){const j=M.fromAffine(i(Qe("pointHex",U)));return j.assertValidity(),j}static fromPrivateKey(U){return M.BASE.multiply(S(U))}static msm(U,j){return Ll(M,r,U,j)}_setWindowSize(U){Y.setWindowSize(this,U)}assertValidity(){F(this)}hasEvenY(){const{y:U}=this.toAffine();if(n.isOdd)return!n.isOdd(U);throw new Error("Field doesn't support isOdd")}equals(U){I(U);const{px:j,py:J,pz:ne}=this,{px:te,py:V,pz:C}=U,L=n.eql(n.mul(j,C),n.mul(te,ne)),q=n.eql(n.mul(J,C),n.mul(V,ne));return L&&q}negate(){return new M(this.px,n.neg(this.py),this.pz)}double(){const{a:U,b:j}=e,J=n.mul(j,Fa),{px:ne,py:te,pz:V}=this;let C=n.ZERO,L=n.ZERO,q=n.ZERO,w=n.mul(ne,ne),c=n.mul(te,te),p=n.mul(V,V),y=n.mul(ne,te);return y=n.add(y,y),q=n.mul(ne,V),q=n.add(q,q),C=n.mul(U,q),L=n.mul(J,p),L=n.add(C,L),C=n.sub(c,L),L=n.add(c,L),L=n.mul(C,L),C=n.mul(y,C),q=n.mul(J,q),p=n.mul(U,p),y=n.sub(w,p),y=n.mul(U,y),y=n.add(y,q),q=n.add(w,w),w=n.add(q,w),w=n.add(w,p),w=n.mul(w,y),L=n.add(L,w),p=n.mul(te,V),p=n.add(p,p),w=n.mul(p,y),C=n.sub(C,w),q=n.mul(p,c),q=n.add(q,q),q=n.add(q,q),new M(C,L,q)}add(U){I(U);const{px:j,py:J,pz:ne}=this,{px:te,py:V,pz:C}=U;let L=n.ZERO,q=n.ZERO,w=n.ZERO;const c=e.a,p=n.mul(e.b,Fa);let y=n.mul(j,te),A=n.mul(J,V),v=n.mul(ne,C),R=n.add(j,J),O=n.add(te,V);R=n.mul(R,O),O=n.add(y,A),R=n.sub(R,O),O=n.add(j,ne);let _=n.add(te,C);return O=n.mul(O,_),_=n.add(y,v),O=n.sub(O,_),_=n.add(J,ne),L=n.add(V,C),_=n.mul(_,L),L=n.add(A,v),_=n.sub(_,L),w=n.mul(c,O),L=n.mul(p,v),w=n.add(L,w),L=n.sub(A,w),w=n.add(A,w),q=n.mul(L,w),A=n.add(y,y),A=n.add(A,y),v=n.mul(c,v),O=n.mul(p,O),A=n.add(A,v),v=n.sub(y,v),v=n.mul(c,v),O=n.add(O,v),y=n.mul(A,O),q=n.add(q,y),y=n.mul(_,O),L=n.mul(R,L),L=n.sub(L,y),y=n.mul(R,A),w=n.mul(_,w),w=n.add(w,y),new M(L,q,w)}subtract(U){return this.add(U.negate())}is0(){return this.equals(M.ZERO)}wNAF(U){return Y.wNAFCached(this,U,M.normalizeZ)}multiplyUnsafe(U){const{endo:j,n:J}=e;sn("scalar",U,An,J);const ne=M.ZERO;if(U===An)return ne;if(this.is0()||U===wt)return this;if(!j||Y.hasPrecomputes(this))return Y.wNAFCachedUnsafe(this,U,M.normalizeZ);let{k1neg:te,k1:V,k2neg:C,k2:L}=j.splitScalar(U),q=ne,w=ne,c=this;for(;V>An||L>An;)V&wt&&(q=q.add(c)),L&wt&&(w=w.add(c)),c=c.double(),V>>=wt,L>>=wt;return te&&(q=q.negate()),C&&(w=w.negate()),w=new M(n.mul(w.px,j.beta),w.py,w.pz),q.add(w)}multiply(U){const{endo:j,n:J}=e;sn("scalar",U,wt,J);let ne,te;if(j){const{k1neg:V,k1:C,k2neg:L,k2:q}=j.splitScalar(U);let{p:w,f:c}=this.wNAF(C),{p,f:y}=this.wNAF(q);w=Y.constTimeNegate(V,w),p=Y.constTimeNegate(L,p),p=new M(n.mul(p.px,j.beta),p.py,p.pz),ne=w.add(p),te=c.add(y)}else{const{p:V,f:C}=this.wNAF(U);ne=V,te=C}return M.normalizeZ([ne,te])[0]}multiplyAndAddUnsafe(U,j,J){const ne=M.BASE,te=(C,L)=>L===An||L===wt||!C.equals(ne)?C.multiplyUnsafe(L):C.multiply(L),V=te(this,j).add(te(U,J));return V.is0()?void 0:V}toAffine(U){return N(this,U)}isTorsionFree(){const{h:U,isTorsionFree:j}=e;if(U===wt)return!0;if(j)return j(M,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:U,clearCofactor:j}=e;return U===wt?this:j?j(M,this):this.multiplyUnsafe(e.h)}toRawBytes(U=!0){return Dn("isCompressed",U),this.assertValidity(),s(M,this,U)}toHex(U=!0){return Dn("isCompressed",U),Nr(this.toRawBytes(U))}}M.BASE=new M(e.Gx,e.Gy,n.ONE),M.ZERO=new M(n.ZERO,n.ONE,n.ZERO);const{endo:B,nBitLength:K}=e,Y=Ul(M,B?Math.ceil(K/2):K);return{CURVE:e,ProjectivePoint:M,normPrivateKeyToScalar:S,weierstrassEquation:o,isWithinCurveOrder:g}}function m1(t){const e=Da(t);return Os(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function g1(t){const e=m1(t),{Fp:n,n:r,nByteLength:s,nBitLength:i}=e,o=n.BYTES+1,a=2*n.BYTES+1;function d(p){return Ve(p,r)}function m(p){return Na(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:S,weierstrassEquation:I,isWithinCurveOrder:N}=p1({...e,toBytes(p,y,A){const v=y.toAffine(),R=n.toBytes(v.x),O=Cr;return Dn("isCompressed",A),A?O(Uint8Array.from([y.hasEvenY()?2:3]),R):O(Uint8Array.from([4]),R,n.toBytes(v.y))},fromBytes(p){const y=p.length,A=p[0],v=p.subarray(1);if(y===o&&(A===2||A===3)){const R=sr(v);if(!fa(R,wt,n.ORDER))throw new Error("Point is not on curve");const O=I(R);let _;try{_=n.sqrt(O)}catch(E){const T=E instanceof Error?": "+E.message:"";throw new Error("Point is not on curve"+T)}const u=(_&wt)===wt;return(A&1)===1!==u&&(_=n.neg(_)),{x:R,y:_}}else if(y===a&&A===4){const R=n.fromBytes(v.subarray(0,n.BYTES)),O=n.fromBytes(v.subarray(n.BYTES,2*n.BYTES));return{x:R,y:O}}else{const R=o,O=a;throw new Error("invalid Point, expected length of "+R+", or uncompressed "+O+", got "+y)}}});function F(p){const y=r>>wt;return p>y}function M(p){return F(p)?d(-p):p}const B=(p,y,A)=>sr(p.slice(y,A));class K{constructor(y,A,v){sn("r",y,wt,r),sn("s",A,wt,r),this.r=y,this.s=A,v!=null&&(this.recovery=v),Object.freeze(this)}static fromCompact(y){const A=s;return y=Qe("compactSignature",y,A*2),new K(B(y,0,A),B(y,A,2*A))}static fromDER(y){const{r:A,s:v}=Rn.toSig(Qe("DER",y));return new K(A,v)}assertValidity(){}addRecoveryBit(y){return new K(this.r,this.s,y)}recoverPublicKey(y){const{r:A,s:v,recovery:R}=this,O=ne(Qe("msgHash",y));if(R==null||![0,1,2,3].includes(R))throw new Error("recovery id invalid");const _=R===2||R===3?A+e.n:A;if(_>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=(R&1)===0?"02":"03",l=g.fromHex(u+Pa(_,n.BYTES)),E=m(_),T=d(-O*E),P=d(v*E),W=g.BASE.multiplyAndAddUnsafe(l,T,P);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return F(this.s)}normalizeS(){return this.hasHighS()?new K(this.r,d(-this.s),this.recovery):this}toDERRawBytes(){return bi(this.toDERHex())}toDERHex(){return Rn.hexFromSig(this)}toCompactRawBytes(){return bi(this.toCompactHex())}toCompactHex(){const y=s;return Pa(this.r,y)+Pa(this.s,y)}}const Y={isValidPrivateKey(p){try{return S(p),!0}catch{return!1}},normPrivateKeyToScalar:S,randomPrivateKey:()=>{const p=Nl(e.n);return c1(e.randomBytes(p),e.n)},precompute(p=8,y=g.BASE){return y._setWindowSize(p),y.multiply(BigInt(3)),y}};function z(p,y=!0){return g.fromPrivateKey(p).toRawBytes(y)}function U(p){if(typeof p=="bigint")return!1;if(p instanceof g)return!0;const A=Qe("key",p).length,v=n.BYTES,R=v+1,O=2*v+1;if(!(e.allowedPrivateKeyLengths||s===R))return A===R||A===O}function j(p,y,A=!0){if(U(p)===!0)throw new Error("first arg must be private key");if(U(y)===!1)throw new Error("second arg must be public key");return g.fromHex(y).multiply(S(p)).toRawBytes(A)}const J=e.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const y=sr(p),A=p.length*8-i;return A>0?y>>BigInt(A):y},ne=e.bits2int_modN||function(p){return d(J(p))},te=Ei(i);function V(p){return sn("num < 2^"+i,p,An,te),Is(p,s)}function C(p,y,A=L){if(["recovered","canonical"].some(ae=>ae in A))throw new Error("sign() legacy options not supported");const{hash:v,randomBytes:R}=e;let{lowS:O,prehash:_,extraEntropy:u}=A;O==null&&(O=!0),p=Qe("msgHash",p),Dl(A),_&&(p=Qe("prehashed msgHash",v(p)));const l=ne(p),E=S(y),T=[V(E),V(l)];if(u!=null&&u!==!1){const ae=u===!0?R(n.BYTES):u;T.push(Qe("extraEntropy",ae))}const P=Cr(...T),W=l;function se(ae){const Me=J(ae);if(!N(Me))return;const ve=m(Me),we=g.BASE.multiply(Me).toAffine(),Fe=d(we.x);if(Fe===An)return;const Re=d(ve*d(W+Fe*E));if(Re===An)return;let Ne=(we.x===Fe?0:2)|Number(we.y&wt),gn=Re;return O&&F(Re)&&(gn=M(Re),Ne^=1),new K(Fe,gn,Ne)}return{seed:P,k2sig:se}}const L={lowS:e.lowS,prehash:!1},q={lowS:e.lowS,prehash:!1};function w(p,y,A=L){const{seed:v,k2sig:R}=C(p,y,A),O=e;return oy(O.hash.outputLen,O.nByteLength,O.hmac)(v,R)}g.BASE._setWindowSize(8);function c(p,y,A,v=q){const R=p;y=Qe("msgHash",y),A=Qe("publicKey",A);const{lowS:O,prehash:_,format:u}=v;if(Dl(v),"strict"in v)throw new Error("options.strict was renamed to lowS");if(u!==void 0&&u!=="compact"&&u!=="der")throw new Error("format must be compact or der");const l=typeof R=="string"||xs(R),E=!l&&!u&&typeof R=="object"&&R!==null&&typeof R.r=="bigint"&&typeof R.s=="bigint";if(!l&&!E)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let T,P;try{if(E&&(T=new K(R.r,R.s)),l){try{u!=="compact"&&(T=K.fromDER(R))}catch(Ne){if(!(Ne instanceof Rn.Err))throw Ne}!T&&u!=="der"&&(T=K.fromCompact(R))}P=g.fromHex(A)}catch{return!1}if(!T||O&&T.hasHighS())return!1;_&&(y=e.hash(y));const{r:W,s:se}=T,ae=ne(y),Me=m(se),ve=d(ae*Me),we=d(W*Me),Fe=g.BASE.multiplyAndAddUnsafe(P,ve,we)?.toAffine();return Fe?d(Fe.x)===W:!1}return{CURVE:e,getPublicKey:z,getSharedSecret:j,sign:w,verify:c,ProjectivePoint:g,Signature:K,utils:Y}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function y1(t){return{hash:t,hmac:(e,...n)=>vl(t,e,Hm(...n)),randomBytes:Sd}}function b1(t,e){const n=r=>g1({...t,...y1(r)});return{...n(e),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Pl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Fl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1=BigInt(0),E1=BigInt(1),$a=BigInt(2),$l=(t,e)=>(t+e/$a)/e;function w1(t){const e=Pl,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),d=BigInt(88),m=t*t*t%e,g=m*m*t%e,S=Ke(g,n,e)*g%e,I=Ke(S,n,e)*g%e,N=Ke(I,$a,e)*m%e,F=Ke(N,s,e)*N%e,M=Ke(F,i,e)*F%e,B=Ke(M,a,e)*M%e,K=Ke(B,d,e)*B%e,Y=Ke(K,a,e)*M%e,z=Ke(Y,n,e)*g%e,U=Ke(z,o,e)*F%e,j=Ke(U,r,e)*m%e,J=Ke(j,$a,e);if(!za.eql(za.sqr(J),t))throw new Error("Cannot find square root");return J}const za=Cs(Pl,void 0,void 0,{sqrt:w1}),ja=b1({a:_1,b:BigInt(7),Fp:za,n:Fl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Fl,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-E1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,o=BigInt("0x100000000000000000000000000000000"),a=$l(i*t,e),d=$l(-r*t,e);let m=Ve(t-a*n-d*s,e),g=Ve(-a*r-d*i,e);const S=m>o,I=g>o;if(S&&(m=e-m),I&&(g=e-g),m>o||g>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:S,k1:m,k2neg:I,k2:g}}}},fl),v1=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:ja},Symbol.toStringTag,{value:"Module"}));class zl extends de{constructor({docsPath:e}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(`
22
- `),{docsPath:e,docsSlug:"account",name:"AccountNotFoundError"})}}class Va extends de{constructor({docsPath:e,metaMessages:n,type:r}){super(`Account type "${r}" is not supported.`,{docsPath:e,metaMessages:n,name:"AccountTypeNotSupportedError"})}}async function R1(t,{serializedTransaction:e}){return t.request({method:"eth_sendRawTransaction",params:[e]},{retryCount:0})}const Ha=new is(128);async function jl(t,e){const{account:n=t.account,chain:r=t.chain,accessList:s,authorizationList:i,blobs:o,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:S,maxPriorityFeePerGas:I,nonce:N,type:F,value:M,...B}=e;if(typeof n>"u")throw new zl({docsPath:"/docs/actions/wallet/sendTransaction"});const K=n?wn(n):null;try{Ai(e);const Y=await(async()=>{if(e.to)return e.to;if(e.to!==null&&i&&i.length>0)return await rl({authorization:i[0]}).catch(()=>{throw new de("`to` is required. Could not infer from `authorizationList`.")})})();if(K?.type==="json-rpc"||K===null){let z;r!==null&&(z=await Ot(t,Ia,"getChainId")({}),Qy({currentChainId:z,chain:r}));const U=t.chain?.formatters?.transactionRequest?.format,J=(U||Aa)({...Ra(B,{format:U}),accessList:s,account:K,authorizationList:i,blobs:o,chainId:z,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:S,maxPriorityFeePerGas:I,nonce:N,to:Y,type:F,value:M},"sendTransaction"),ne=Ha.get(t.uid),te=ne?"wallet_sendTransaction":"eth_sendTransaction";try{return await t.request({method:te,params:[J]},{retryCount:0})}catch(V){if(ne===!1)throw V;const C=V;if(C.name==="InvalidInputRpcError"||C.name==="InvalidParamsRpcError"||C.name==="MethodNotFoundRpcError"||C.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[J]},{retryCount:0}).then(L=>(Ha.set(t.uid,!0),L)).catch(L=>{const q=L;throw q.name==="MethodNotFoundRpcError"||q.name==="MethodNotSupportedRpcError"?(Ha.set(t.uid,!1),C):q});throw C}}if(K?.type==="local"){const z=await Ot(t,El,"prepareTransactionRequest")({account:K,accessList:s,authorizationList:i,blobs:o,chain:r,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:S,maxPriorityFeePerGas:I,nonce:N,nonceManager:K.nonceManager,parameters:[...bl,"sidecars"],type:F,value:M,...B,to:Y}),U=r?.serializers?.transaction,j=await K.signTransaction(z,{serializer:U});return await Ot(t,R1,"sendRawTransaction")({serializedTransaction:j})}throw K?.type==="smart"?new Va({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new Va({docsPath:"/docs/actions/wallet/sendTransaction",type:K?.type})}catch(Y){throw Y instanceof Va?Y:yl(Y,{...e,account:K,chain:e.chain||void 0})}}async function xi(t,e){return xi.internal(t,jl,"sendTransaction",e)}(function(t){async function e(n,r,s,i){const{abi:o,account:a=n.account,address:d,args:m,dataSuffix:g,functionName:S,...I}=i;if(typeof a>"u")throw new zl({docsPath:"/docs/contract/writeContract"});const N=a?wn(a):null,F=Lg({abi:o,args:m,functionName:S});try{return await Ot(n,r,s)({data:`${F}${g?g.replace("0x",""):""}`,to:d,account:N,...I})}catch(M){throw ry(M,{abi:o,address:d,args:m,docsPath:"/docs/contract/writeContract",functionName:S,sender:N?.address})}}t.internal=e})(xi||(xi={}));function Vl(t,e,n){const r=t[e.name];if(typeof r=="function")return r;const s=t[n];return typeof s=="function"?s:i=>e(t,i)}const A1="3.4.0",S1=()=>`@wagmi/core@${A1}`;var Hl=function(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)},Ti,Gl;let or=class Au extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return S1()}constructor(e,n={}){super(),Ti.add(this),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiCoreError"});const r=n.cause instanceof Au?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof Au&&n.cause.docsPath||n.docsPath;this.message=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${this.docsBaseUrl}${s}.html${n.docsSlug?`#${n.docsSlug}`:""}`]:[],...r?[`Details: ${r}`]:[],`Version: ${this.version}`].join(`
23
- `),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.shortMessage=e}walk(e){return Hl(this,Ti,"m",Gl).call(this,this,e)}};Ti=new WeakSet,Gl=function t(e,n){return n?.(e)?e:e.cause?Hl(this,Ti,"m",t).call(this,e.cause,n):e};class ql extends or{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class x1 extends or{constructor(){super("Connector already connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAlreadyConnectedError"})}}class T1 extends or{constructor(){super("Connector not connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorNotConnectedError"})}}class I1 extends or{constructor({address:e,connector:n}){super(`Account "${e}" not found for connector "${n.name}".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAccountNotFoundError"})}}class O1 extends or{constructor({connectionChainId:e,connectorChainId:n}){super(`The current chain of the connector (id: ${n}) does not match the connection's chain (id: ${e}).`,{metaMessages:[`Current Chain ID: ${n}`,`Expected Chain ID: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorChainMismatchError"})}}class N1 extends or{constructor({connector:e}){super(`Connector "${e.name}" unavailable while reconnecting.`,{details:["During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.","All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.","This error commonly occurs for connectors that asynchronously inject after reconnection has already started."].join(" ")}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorUnavailableReconnectingError"})}}async function C1(t,e){let n;if(typeof e.connector=="function"?n=t._internal.connectors.setup(e.connector):n=e.connector,n.uid===t.state.current)throw new x1;try{t.setState(o=>({...o,status:"connecting"})),n.emitter.emit("message",{type:"connecting"});const{connector:r,...s}=e,i=await n.connect(s);return n.emitter.off("connect",t._internal.events.connect),n.emitter.on("change",t._internal.events.change),n.emitter.on("disconnect",t._internal.events.disconnect),await t.storage?.setItem("recentConnectorId",n.id),t.setState(o=>({...o,connections:new Map(o.connections).set(n.uid,{accounts:s.withCapabilities?i.accounts.map(a=>typeof a=="object"?a.address:a):i.accounts,chainId:i.chainId,connector:n}),current:n.uid,status:"connected"})),{accounts:s.withCapabilities?i.accounts.map(o=>typeof o=="object"?o:{address:o,capabilities:{}}):i.accounts,chainId:i.chainId}}catch(r){throw t.setState(s=>({...s,status:s.current?"connected":"disconnected"})),r}}const Ga=256;let Ii=Ga,Oi;function Kl(t=11){if(!Oi||Ii+t>Ga*2){Oi="",Ii=0;for(let e=0;e<Ga;e++)Oi+=(256+Math.random()*256|0).toString(16).substring(1)}return Oi.substring(Ii,Ii+++t)}function M1(t){const{batch:e,chain:n,ccipRead:r,key:s="base",name:i="Base Client",type:o="base"}=t,a=t.experimental_blockTag??(typeof n?.experimental_preconfirmationTime=="number"?"pending":void 0),d=n?.blockTime??12e3,m=Math.min(Math.max(Math.floor(d/2),500),4e3),g=t.pollingInterval??m,S=t.cacheTime??g,I=t.account?wn(t.account):void 0,{config:N,request:F,value:M}=t.transport({account:I,chain:n,pollingInterval:g}),B={...N,...M},K={account:I,batch:e,cacheTime:S,ccipRead:r,chain:n,key:s,name:i,pollingInterval:g,request:F,transport:B,type:o,uid:Kl(),...a?{experimental_blockTag:a}:{}};function Y(z){return U=>{const j=U(z);for(const ne in K)delete j[ne];const J={...z,...j};return Object.assign(J,{extend:Y(J)})}}return Object.assign(K,{extend:Y(K)})}function k1({key:t,methods:e,name:n,request:r,retryCount:s=3,retryDelay:i=150,timeout:o,type:a},d){const m=Kl();return{config:{key:t,methods:e,name:n,request:r,retryCount:s,retryDelay:i,timeout:o,type:a},request:Jy(r,{methods:e,retryCount:s,retryDelay:i,uid:m}),value:d}}function B1(t,e={}){const{key:n="custom",methods:r,name:s="Custom Provider",retryDelay:i}=e;return({retryCount:o})=>k1({key:n,methods:r,name:s,request:t.request.bind(t),retryCount:e.retryCount??o,retryDelay:i,type:"custom"})}async function Wl(t,e={}){const{assertChainId:n=!0}=e;let r;if(e.connector){const{connector:g}=e;if(t.state.status==="reconnecting"&&!g.getAccounts&&!g.getChainId)throw new N1({connector:g});const[S,I]=await Promise.all([g.getAccounts().catch(N=>{if(e.account===null)return[];throw N}),g.getChainId()]);r={accounts:S,chainId:I,connector:g}}else r=t.state.connections.get(t.state.current);if(!r)throw new T1;const s=e.chainId??r.chainId,i=await r.connector.getChainId();if(n&&i!==s)throw new O1({connectionChainId:s,connectorChainId:i});const o=r.connector;if(o.getClient)return o.getClient({chainId:s});const a=wn(e.account??r.accounts[0]);if(a&&(a.address=fi(a.address)),e.account&&!r.accounts.some(g=>g.toLowerCase()===a.address.toLowerCase()))throw new I1({address:a.address,connector:o});const d=t.chains.find(g=>g.id===s),m=await r.connector.getProvider({chainId:s});return M1({account:a,chain:d,name:"Connector Client",transport:g=>B1(m)({...g,retryCount:0})})}async function U1(t,e={}){let n;if(e.connector)n=e.connector;else{const{connections:s,current:i}=t.state;n=s.get(i)?.connector}const r=t.state.connections;n&&(await n.disconnect(),n.emitter.off("change",t._internal.events.change),n.emitter.off("disconnect",t._internal.events.disconnect),n.emitter.on("connect",t._internal.events.connect),r.delete(n.uid)),t.setState(s=>{if(r.size===0)return{...s,connections:new Map,current:null,status:"disconnected"};const i=r.values().next().value;return{...s,connections:new Map(r),current:i.connector.uid}});{const s=t.state.current;if(!s)return;const i=t.state.connections.get(s)?.connector;if(!i)return;await t.storage?.setItem("recentConnectorId",i.id)}}function qa(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;let n,r;if(Array.isArray(t)&&Array.isArray(e)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!qa(t[r],e[r]))return!1;return!0}if(typeof t.valueOf=="function"&&t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(typeof t.toString=="function"&&t.toString!==Object.prototype.toString)return t.toString()===e.toString();const s=Object.keys(t);if(n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!Object.hasOwn(e,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(i&&!qa(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}let Ka=[];function L1(t){const e=t.chains;return qa(Ka,e)?Ka:(Ka=e,e)}async function D1(t,e){const{account:n,chainId:r,connector:s,...i}=e;let o;typeof n=="object"&&n?.type==="local"?o=t.getClient({chainId:r}):o=await Wl(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:s});const a=!r||o.chain?.id===r?o.chain:{id:r};return await Vl(o,jl,"sendTransaction")({...i,...n?{account:n}:{},assertChainId:!!r,chain:a,gas:i.gas??void 0})}class P1 extends or{constructor({connector:e}){super(`"${e.name}" does not support programmatic chain switching.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SwitchChainNotSupportedError"})}}async function F1(t,e){const{addEthereumChainParameter:n,chainId:r}=e,s=t.state.connections.get(e.connector?.uid??t.state.current);if(s){const o=s.connector;if(!o.switchChain)throw new P1({connector:o});return await o.switchChain({addEthereumChainParameter:n,chainId:r})}const i=t.chains.find(o=>o.id===r);if(!i)throw new ql;return t.setState(o=>({...o,chainId:r})),i}async function $1(t,e){const{account:n,chainId:r,connector:s,...i}=e;let o;typeof n=="object"&&n?.type==="local"?o=t.getClient({chainId:r}):o=await Wl(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:s});const a=!r||o.chain?.id===r?o.chain:{id:r};return await Vl(o,xi,"writeContract")({...i,...n?{account:n}:{},assertChainId:!!r,chain:a})}function ZT(t){return t}function Wa(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Za(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){var s=!1;try{s=this instanceof r}catch{}return s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var Ya={exports:{}},Zl;function z1(){return Zl||(Zl=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function s(d,m,g){this.fn=d,this.context=m,this.once=g||!1}function i(d,m,g,S,I){if(typeof g!="function")throw new TypeError("The listener must be a function");var N=new s(g,S||d,I),F=n?n+m:m;return d._events[F]?d._events[F].fn?d._events[F]=[d._events[F],N]:d._events[F].push(N):(d._events[F]=N,d._eventsCount++),d}function o(d,m){--d._eventsCount===0?d._events=new r:delete d._events[m]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var m=[],g,S;if(this._eventsCount===0)return m;for(S in g=this._events)e.call(g,S)&&m.push(n?S.slice(1):S);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(g)):m},a.prototype.listeners=function(m){var g=n?n+m:m,S=this._events[g];if(!S)return[];if(S.fn)return[S.fn];for(var I=0,N=S.length,F=new Array(N);I<N;I++)F[I]=S[I].fn;return F},a.prototype.listenerCount=function(m){var g=n?n+m:m,S=this._events[g];return S?S.fn?1:S.length:0},a.prototype.emit=function(m,g,S,I,N,F){var M=n?n+m:m;if(!this._events[M])return!1;var B=this._events[M],K=arguments.length,Y,z;if(B.fn){switch(B.once&&this.removeListener(m,B.fn,void 0,!0),K){case 1:return B.fn.call(B.context),!0;case 2:return B.fn.call(B.context,g),!0;case 3:return B.fn.call(B.context,g,S),!0;case 4:return B.fn.call(B.context,g,S,I),!0;case 5:return B.fn.call(B.context,g,S,I,N),!0;case 6:return B.fn.call(B.context,g,S,I,N,F),!0}for(z=1,Y=new Array(K-1);z<K;z++)Y[z-1]=arguments[z];B.fn.apply(B.context,Y)}else{var U=B.length,j;for(z=0;z<U;z++)switch(B[z].once&&this.removeListener(m,B[z].fn,void 0,!0),K){case 1:B[z].fn.call(B[z].context);break;case 2:B[z].fn.call(B[z].context,g);break;case 3:B[z].fn.call(B[z].context,g,S);break;case 4:B[z].fn.call(B[z].context,g,S,I);break;default:if(!Y)for(j=1,Y=new Array(K-1);j<K;j++)Y[j-1]=arguments[j];B[z].fn.apply(B[z].context,Y)}}return!0},a.prototype.on=function(m,g,S){return i(this,m,g,S,!1)},a.prototype.once=function(m,g,S){return i(this,m,g,S,!0)},a.prototype.removeListener=function(m,g,S,I){var N=n?n+m:m;if(!this._events[N])return this;if(!g)return o(this,N),this;var F=this._events[N];if(F.fn)F.fn===g&&(!I||F.once)&&(!S||F.context===S)&&o(this,N);else{for(var M=0,B=[],K=F.length;M<K;M++)(F[M].fn!==g||I&&!F[M].once||S&&F[M].context!==S)&&B.push(F[M]);B.length?this._events[N]=B.length===1?B[0]:B:o(this,N)}return this},a.prototype.removeAllListeners=function(m){var g;return m?(g=n?n+m:m,this._events[g]&&o(this,g)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a})(Ya)),Ya.exports}var j1=z1();const Yl=Wa(j1);let kr=class extends Error{name="BaseError";cause;constructor(e,n={}){super(e,n.cause?{cause:n.cause}:void 0),this.cause=n.cause}};class V1 extends kr{name="AddMiniApp.InvalidDomainManifest";constructor(){super("Invalid domain manifest")}}let H1=class extends kr{name="AddMiniApp.RejectedByUser";constructor(){super("Add miniapp rejected by user")}},Jl=class extends kr{name="SignIn.RejectedByUser";constructor(){super("Sign in rejected by user")}};class G1 extends kr{name="SignManifest.RejectedByUser";constructor(){super("Sign manifest rejected by user")}}class q1 extends kr{name="SignManifest.InvalidDomain";constructor(){super("Invalid domain provided")}}class K1 extends kr{name="SignManifest.GenericError";constructor(e="Manifest signing failed"){super(e)}}var Ce;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(const o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Ce||(Ce={}));var Xl;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Xl||(Xl={}));const le=Ce.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jn=t=>{switch(typeof t){case"undefined":return le.undefined;case"string":return le.string;case"number":return Number.isNaN(t)?le.nan:le.number;case"boolean":return le.boolean;case"function":return le.function;case"bigint":return le.bigint;case"symbol":return le.symbol;case"object":return Array.isArray(t)?le.array:t===null?le.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?le.promise:typeof Map<"u"&&t instanceof Map?le.map:typeof Set<"u"&&t instanceof Set?le.set:typeof Date<"u"&&t instanceof Date?le.date:le.object;default:return le.unknown}},re=Ce.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Sn extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,d=0;for(;d<o.path.length;){const m=o.path[d];d===o.path.length-1?(a[m]=a[m]||{_errors:[]},a[m]._errors.push(n(o))):a[m]=a[m]||{_errors:[]},a=a[m],d++}}};return s(this),r}static assert(e){if(!(e instanceof Sn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ce.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Sn.create=t=>new Sn(t);const Ja=(t,e)=>{let n;switch(t.code){case re.invalid_type:t.received===le.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case re.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Ce.jsonStringifyReplacer)}`;break;case re.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ce.joinValues(t.keys,", ")}`;break;case re.invalid_union:n="Invalid input";break;case re.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ce.joinValues(t.options)}`;break;case re.invalid_enum_value:n=`Invalid enum value. Expected ${Ce.joinValues(t.options)}, received '${t.received}'`;break;case re.invalid_arguments:n="Invalid function arguments";break;case re.invalid_return_type:n="Invalid function return type";break;case re.invalid_date:n="Invalid date";break;case re.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Ce.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case re.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case re.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case re.custom:n="Invalid input";break;case re.invalid_intersection_types:n="Intersection results could not be merged";break;case re.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case re.not_finite:n="Number must be finite";break;default:n=e.defaultError,Ce.assertNever(t)}return{message:n}};let W1=Ja;function Z1(){return W1}const Y1=t=>{const{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="";const d=r.filter(m=>!!m).slice().reverse();for(const m of d)a=m(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}};function oe(t,e){const n=Z1(),r=Y1({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Ja?void 0:Ja].filter(s=>!!s)});t.common.issues.push(r)}class Zt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const s of n){if(s.status==="aborted")return me;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const s of n){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return Zt.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return me;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}}const me=Object.freeze({status:"aborted"}),Ms=t=>({status:"dirty",value:t}),tn=t=>({status:"valid",value:t}),Ql=t=>t.status==="aborted",ef=t=>t.status==="dirty",Br=t=>t.status==="valid",Ni=t=>typeof Promise<"u"&&t instanceof Promise;var fe;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(fe||(fe={}));class Vn{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const tf=(t,e)=>{if(Br(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Sn(t.common.issues);return this._error=n,this._error}}};function Se(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{const{message:d}=t;return o.code==="invalid_enum_value"?{message:d??a.defaultError}:typeof a.data>"u"?{message:d??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:d??n??a.defaultError}},description:s}}class Oe{get description(){return this._def.description}_getType(e){return jn(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:jn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Zt,ctx:{common:e.parent.common,data:e.data,parsedType:jn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Ni(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:jn(e)},s=this._parseSync({data:e,path:r.path,parent:r});return tf(r,s)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:jn(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:n});return Br(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Br(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:jn(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Ni(s)?s:Promise.resolve(s));return tf(r,i)}refine(e,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=e(s),a=()=>i.addIssue({code:re.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new ur({schema:this,typeName:ge.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Tn.create(this,this._def)}nullable(){return dr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ln.create(this)}promise(){return Ui.create(this,this._def)}or(e){return Mi.create([this,e],this._def)}and(e){return ki.create(this,e,this._def)}transform(e){return new ur({...Se(this._def),schema:this,typeName:ge.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new Li({...Se(this._def),innerType:this,defaultValue:n,typeName:ge.ZodDefault})}brand(){return new ff({typeName:ge.ZodBranded,type:this,...Se(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new Di({...Se(this._def),innerType:this,catchValue:n,typeName:ge.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return oc.create(this,e)}readonly(){return Pi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const J1=/^c[^\s-]{8,}$/i,X1=/^[0-9a-z]+$/,Q1=/^[0-9A-HJKMNP-TV-Z]{26}$/i,eb=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,tb=/^[a-z0-9_-]{21}$/i,nb=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,rb=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,sb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ib="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Xa;const ob=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ab=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,cb=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ub=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,db=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,lb=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nf="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",fb=new RegExp(`^${nf}$`);function rf(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function hb(t){return new RegExp(`^${rf(t)}$`)}function pb(t){let e=`${nf}T${rf(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function mb(t,e){return!!((e==="v4"||!e)&&ob.test(t)||(e==="v6"||!e)&&cb.test(t))}function gb(t,e){if(!nb.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function yb(t,e){return!!((e==="v4"||!e)&&ab.test(t)||(e==="v6"||!e)&&ub.test(t))}class Hn extends Oe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==le.string){const i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_type,expected:le.string,received:i.parsedType}),me}const r=new Zt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),oe(s,{code:re.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),oe(s,{code:re.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?oe(s,{code:re.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&oe(s,{code:re.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")sb.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"email",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Xa||(Xa=new RegExp(ib,"u")),Xa.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"emoji",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")eb.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"uuid",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")tb.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"nanoid",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")J1.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"cuid",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")X1.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"cuid2",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Q1.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"ulid",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),oe(s,{validation:"url",code:re.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"regex",code:re.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),oe(s,{code:re.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),oe(s,{code:re.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),oe(s,{code:re.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?pb(i).test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{code:re.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?fb.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{code:re.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?hb(i).test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{code:re.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?rb.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"duration",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?mb(e.data,i.version)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"ip",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?gb(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"jwt",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?yb(e.data,i.version)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"cidr",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?db.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"base64",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?lb.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"base64url",code:re.invalid_string,message:i.message}),r.dirty()):Ce.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:re.invalid_string,...fe.errToObj(r)})}_addCheck(e){return new Hn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...fe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...fe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...fe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...fe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...fe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...fe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...fe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...fe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...fe.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...fe.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...fe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...fe.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...fe.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...fe.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...fe.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...fe.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...fe.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...fe.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...fe.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...fe.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...fe.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...fe.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...fe.errToObj(n)})}nonempty(e){return this.min(1,fe.errToObj(e))}trim(){return new Hn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Hn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Hn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Hn.create=t=>new Hn({checks:[],typeName:ge.ZodString,coerce:t?.coerce??!1,...Se(t)});function bb(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}class Ur extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==le.number){const i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_type,expected:le.number,received:i.parsedType}),me}let r;const s=new Zt;for(const i of this._def.checks)i.kind==="int"?Ce.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),oe(r,{code:re.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),oe(r,{code:re.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),oe(r,{code:re.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?bb(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),oe(r,{code:re.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),oe(r,{code:re.not_finite,message:i.message}),s.dirty()):Ce.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,fe.toString(n))}gt(e,n){return this.setLimit("min",e,!1,fe.toString(n))}lte(e,n){return this.setLimit("max",e,!0,fe.toString(n))}lt(e,n){return this.setLimit("max",e,!1,fe.toString(n))}setLimit(e,n,r,s){return new Ur({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:fe.toString(s)}]})}_addCheck(e){return new Ur({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:fe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:fe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:fe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:fe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:fe.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:fe.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:fe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:fe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:fe.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Ce.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Ur.create=t=>new Ur({checks:[],typeName:ge.ZodNumber,coerce:t?.coerce||!1,...Se(t)});class ks extends Oe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==le.bigint)return this._getInvalidInput(e);let r;const s=new Zt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),oe(r,{code:re.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),oe(r,{code:re.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),oe(r,{code:re.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Ce.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return oe(n,{code:re.invalid_type,expected:le.bigint,received:n.parsedType}),me}gte(e,n){return this.setLimit("min",e,!0,fe.toString(n))}gt(e,n){return this.setLimit("min",e,!1,fe.toString(n))}lte(e,n){return this.setLimit("max",e,!0,fe.toString(n))}lt(e,n){return this.setLimit("max",e,!1,fe.toString(n))}setLimit(e,n,r,s){return new ks({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:fe.toString(s)}]})}_addCheck(e){return new ks({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:fe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:fe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:fe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:fe.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:fe.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ks.create=t=>new ks({checks:[],typeName:ge.ZodBigInt,coerce:t?.coerce??!1,...Se(t)});class Qa extends Oe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==le.boolean){const r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:le.boolean,received:r.parsedType}),me}return tn(e.data)}}Qa.create=t=>new Qa({typeName:ge.ZodBoolean,coerce:t?.coerce||!1,...Se(t)});class Ci extends Oe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==le.date){const i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_type,expected:le.date,received:i.parsedType}),me}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_date}),me}const r=new Zt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),oe(s,{code:re.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),oe(s,{code:re.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Ce.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ci({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:fe.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:fe.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}Ci.create=t=>new Ci({checks:[],coerce:t?.coerce||!1,typeName:ge.ZodDate,...Se(t)});class sf extends Oe{_parse(e){if(this._getType(e)!==le.symbol){const r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:le.symbol,received:r.parsedType}),me}return tn(e.data)}}sf.create=t=>new sf({typeName:ge.ZodSymbol,...Se(t)});class ec extends Oe{_parse(e){if(this._getType(e)!==le.undefined){const r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:le.undefined,received:r.parsedType}),me}return tn(e.data)}}ec.create=t=>new ec({typeName:ge.ZodUndefined,...Se(t)});class tc extends Oe{_parse(e){if(this._getType(e)!==le.null){const r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:le.null,received:r.parsedType}),me}return tn(e.data)}}tc.create=t=>new tc({typeName:ge.ZodNull,...Se(t)});class of extends Oe{constructor(){super(...arguments),this._any=!0}_parse(e){return tn(e.data)}}of.create=t=>new of({typeName:ge.ZodAny,...Se(t)});class af extends Oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return tn(e.data)}}af.create=t=>new af({typeName:ge.ZodUnknown,...Se(t)});class Gn extends Oe{_parse(e){const n=this._getOrReturnCtx(e);return oe(n,{code:re.invalid_type,expected:le.never,received:n.parsedType}),me}}Gn.create=t=>new Gn({typeName:ge.ZodNever,...Se(t)});class cf extends Oe{_parse(e){if(this._getType(e)!==le.undefined){const r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:le.void,received:r.parsedType}),me}return tn(e.data)}}cf.create=t=>new cf({typeName:ge.ZodVoid,...Se(t)});class ln extends Oe{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==le.array)return oe(n,{code:re.invalid_type,expected:le.array,received:n.parsedType}),me;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(oe(n,{code:o?re.too_big:re.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(oe(n,{code:re.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(oe(n,{code:re.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new Vn(n,o,n.path,a)))).then(o=>Zt.mergeArray(r,o));const i=[...n.data].map((o,a)=>s.type._parseSync(new Vn(n,o,n.path,a)));return Zt.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new ln({...this._def,minLength:{value:e,message:fe.toString(n)}})}max(e,n){return new ln({...this._def,maxLength:{value:e,message:fe.toString(n)}})}length(e,n){return new ln({...this._def,exactLength:{value:e,message:fe.toString(n)}})}nonempty(e){return this.min(1,e)}}ln.create=(t,e)=>new ln({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ge.ZodArray,...Se(e)});function Lr(t){if(t instanceof tt){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Tn.create(Lr(r))}return new tt({...t._def,shape:()=>e})}else return t instanceof ln?new ln({...t._def,type:Lr(t.element)}):t instanceof Tn?Tn.create(Lr(t.unwrap())):t instanceof dr?dr.create(Lr(t.unwrap())):t instanceof ar?ar.create(t.items.map(e=>Lr(e))):t}class tt extends Oe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=Ce.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==le.object){const m=this._getOrReturnCtx(e);return oe(m,{code:re.invalid_type,expected:le.object,received:m.parsedType}),me}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Gn&&this._def.unknownKeys==="strip"))for(const m in s.data)o.includes(m)||a.push(m);const d=[];for(const m of o){const g=i[m],S=s.data[m];d.push({key:{status:"valid",value:m},value:g._parse(new Vn(s,S,s.path,m)),alwaysSet:m in s.data})}if(this._def.catchall instanceof Gn){const m=this._def.unknownKeys;if(m==="passthrough")for(const g of a)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(m==="strict")a.length>0&&(oe(s,{code:re.unrecognized_keys,keys:a}),r.dirty());else if(m!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const m=this._def.catchall;for(const g of a){const S=s.data[g];d.push({key:{status:"valid",value:g},value:m._parse(new Vn(s,S,s.path,g)),alwaysSet:g in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const m=[];for(const g of d){const S=await g.key,I=await g.value;m.push({key:S,value:I,alwaysSet:g.alwaysSet})}return m}).then(m=>Zt.mergeObjectSync(r,m)):Zt.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return fe.errToObj,new tt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{const s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:fe.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new tt({...this._def,unknownKeys:"strip"})}passthrough(){return new tt({...this._def,unknownKeys:"passthrough"})}extend(e){return new tt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new tt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ge.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new tt({...this._def,catchall:e})}pick(e){const n={};for(const r of Ce.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new tt({...this._def,shape:()=>n})}omit(e){const n={};for(const r of Ce.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new tt({...this._def,shape:()=>n})}deepPartial(){return Lr(this)}partial(e){const n={};for(const r of Ce.objectKeys(this.shape)){const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new tt({...this._def,shape:()=>n})}required(e){const n={};for(const r of Ce.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Tn;)i=i._def.innerType;n[r]=i}return new tt({...this._def,shape:()=>n})}keyof(){return df(Ce.objectKeys(this.shape))}}tt.create=(t,e)=>new tt({shape:()=>t,unknownKeys:"strip",catchall:Gn.create(),typeName:ge.ZodObject,...Se(e)}),tt.strictCreate=(t,e)=>new tt({shape:()=>t,unknownKeys:"strict",catchall:Gn.create(),typeName:ge.ZodObject,...Se(e)}),tt.lazycreate=(t,e)=>new tt({shape:t,unknownKeys:"strip",catchall:Gn.create(),typeName:ge.ZodObject,...Se(e)});class Mi extends Oe{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new Sn(a.ctx.common.issues));return oe(n,{code:re.invalid_union,unionErrors:o}),me}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const d of r){const m={...n,common:{...n.common,issues:[]},parent:null},g=d._parseSync({data:n.data,path:n.path,parent:m});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:m}),m.common.issues.length&&o.push(m.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(d=>new Sn(d));return oe(n,{code:re.invalid_union,unionErrors:a}),me}}get options(){return this._def.options}}Mi.create=(t,e)=>new Mi({options:t,typeName:ge.ZodUnion,...Se(e)});const xn=t=>t instanceof sc?xn(t.schema):t instanceof ur?xn(t.innerType()):t instanceof Bi?[t.value]:t instanceof cr?t.options:t instanceof ic?Ce.objectValues(t.enum):t instanceof Li?xn(t._def.innerType):t instanceof ec?[void 0]:t instanceof tc?[null]:t instanceof Tn?[void 0,...xn(t.unwrap())]:t instanceof dr?[null,...xn(t.unwrap())]:t instanceof ff||t instanceof Pi?xn(t.unwrap()):t instanceof Di?xn(t._def.innerType):[];class nc extends Oe{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==le.object)return oe(n,{code:re.invalid_type,expected:le.object,received:n.parsedType}),me;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(oe(n,{code:re.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),me)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){const s=new Map;for(const i of n){const o=xn(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new nc({typeName:ge.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...Se(r)})}}function rc(t,e){const n=jn(t),r=jn(e);if(t===e)return{valid:!0,data:t};if(n===le.object&&r===le.object){const s=Ce.objectKeys(e),i=Ce.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(const a of i){const d=rc(t[a],e[a]);if(!d.valid)return{valid:!1};o[a]=d.data}return{valid:!0,data:o}}else if(n===le.array&&r===le.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const o=t[i],a=e[i],d=rc(o,a);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return n===le.date&&r===le.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ki extends Oe{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Ql(i)||Ql(o))return me;const a=rc(i.value,o.value);return a.valid?((ef(i)||ef(o))&&n.dirty(),{status:n.value,value:a.data}):(oe(r,{code:re.invalid_intersection_types}),me)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}ki.create=(t,e,n)=>new ki({left:t,right:e,typeName:ge.ZodIntersection,...Se(n)});class ar extends Oe{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==le.array)return oe(r,{code:re.invalid_type,expected:le.array,received:r.parsedType}),me;if(r.data.length<this._def.items.length)return oe(r,{code:re.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&r.data.length>this._def.items.length&&(oe(r,{code:re.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,a)=>{const d=this._def.items[a]||this._def.rest;return d?d._parse(new Vn(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>Zt.mergeArray(n,o)):Zt.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new ar({...this._def,rest:e})}}ar.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ar({items:t,typeName:ge.ZodTuple,rest:null,...Se(e)})};class uf extends Oe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==le.map)return oe(r,{code:re.invalid_type,expected:le.map,received:r.parsedType}),me;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,d],m)=>({key:s._parse(new Vn(r,a,r.path,[m,"key"])),value:i._parse(new Vn(r,d,r.path,[m,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const d of o){const m=await d.key,g=await d.value;if(m.status==="aborted"||g.status==="aborted")return me;(m.status==="dirty"||g.status==="dirty")&&n.dirty(),a.set(m.value,g.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const d of o){const m=d.key,g=d.value;if(m.status==="aborted"||g.status==="aborted")return me;(m.status==="dirty"||g.status==="dirty")&&n.dirty(),a.set(m.value,g.value)}return{status:n.value,value:a}}}}uf.create=(t,e,n)=>new uf({valueType:e,keyType:t,typeName:ge.ZodMap,...Se(n)});class Bs extends Oe{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==le.set)return oe(r,{code:re.invalid_type,expected:le.set,received:r.parsedType}),me;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(oe(r,{code:re.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(oe(r,{code:re.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(d){const m=new Set;for(const g of d){if(g.status==="aborted")return me;g.status==="dirty"&&n.dirty(),m.add(g.value)}return{status:n.value,value:m}}const a=[...r.data.values()].map((d,m)=>i._parse(new Vn(r,d,r.path,m)));return r.common.async?Promise.all(a).then(d=>o(d)):o(a)}min(e,n){return new Bs({...this._def,minSize:{value:e,message:fe.toString(n)}})}max(e,n){return new Bs({...this._def,maxSize:{value:e,message:fe.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Bs.create=(t,e)=>new Bs({valueType:t,minSize:null,maxSize:null,typeName:ge.ZodSet,...Se(e)});class sc extends Oe{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}sc.create=(t,e)=>new sc({getter:t,typeName:ge.ZodLazy,...Se(e)});class Bi extends Oe{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return oe(n,{received:n.data,code:re.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}Bi.create=(t,e)=>new Bi({value:t,typeName:ge.ZodLiteral,...Se(e)});function df(t,e){return new cr({values:t,typeName:ge.ZodEnum,...Se(e)})}class cr extends Oe{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return oe(n,{expected:Ce.joinValues(r),received:n.parsedType,code:re.invalid_type}),me}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return oe(n,{received:n.data,code:re.invalid_enum_value,options:r}),me}return tn(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return cr.create(e,{...this._def,...n})}exclude(e,n=this._def){return cr.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}cr.create=df;class ic extends Oe{_parse(e){const n=Ce.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==le.string&&r.parsedType!==le.number){const s=Ce.objectValues(n);return oe(r,{expected:Ce.joinValues(s),received:r.parsedType,code:re.invalid_type}),me}if(this._cache||(this._cache=new Set(Ce.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=Ce.objectValues(n);return oe(r,{received:r.data,code:re.invalid_enum_value,options:s}),me}return tn(e.data)}get enum(){return this._def.values}}ic.create=(t,e)=>new ic({values:t,typeName:ge.ZodNativeEnum,...Se(e)});class Ui extends Oe{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==le.promise&&n.common.async===!1)return oe(n,{code:re.invalid_type,expected:le.promise,received:n.parsedType}),me;const r=n.parsedType===le.promise?n.data:Promise.resolve(n.data);return tn(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Ui.create=(t,e)=>new Ui({type:t,typeName:ge.ZodPromise,...Se(e)});class ur extends Oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ge.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{oe(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return me;const d=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return d.status==="aborted"?me:d.status==="dirty"||n.value==="dirty"?Ms(d.value):d});{if(n.value==="aborted")return me;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?me:a.status==="dirty"||n.value==="dirty"?Ms(a.value):a}}if(s.type==="refinement"){const o=a=>{const d=s.refinement(a,i);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?me:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?me:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Br(o))return me;const a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Br(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):me);Ce.assertNever(s)}}ur.create=(t,e,n)=>new ur({schema:t,typeName:ge.ZodEffects,effect:e,...Se(n)}),ur.createWithPreprocess=(t,e,n)=>new ur({schema:e,effect:{type:"preprocess",transform:t},typeName:ge.ZodEffects,...Se(n)});class Tn extends Oe{_parse(e){return this._getType(e)===le.undefined?tn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Tn.create=(t,e)=>new Tn({innerType:t,typeName:ge.ZodOptional,...Se(e)});class dr extends Oe{_parse(e){return this._getType(e)===le.null?tn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}dr.create=(t,e)=>new dr({innerType:t,typeName:ge.ZodNullable,...Se(e)});class Li extends Oe{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===le.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Li.create=(t,e)=>new Li({innerType:t,typeName:ge.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Se(e)});class Di extends Oe{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ni(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Sn(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Sn(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Di.create=(t,e)=>new Di({innerType:t,typeName:ge.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Se(e)});class lf extends Oe{_parse(e){if(this._getType(e)!==le.nan){const r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:le.nan,received:r.parsedType}),me}return{status:"valid",value:e.data}}}lf.create=t=>new lf({typeName:ge.ZodNaN,...Se(t)});class ff extends Oe{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class oc extends Oe{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?me:i.status==="dirty"?(n.dirty(),Ms(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?me:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new oc({in:e,out:n,typeName:ge.ZodPipeline})}}class Pi extends Oe{_parse(e){const n=this._def.innerType._parse(e),r=s=>(Br(s)&&(s.value=Object.freeze(s.value)),s);return Ni(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}Pi.create=(t,e)=>new Pi({innerType:t,typeName:ge.ZodReadonly,...Se(e)});var ge;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ge||(ge={}));const We=Hn.create,hf=Ur.create,_b=Qa.create;Gn.create;const lr=ln.create,St=tt.create,Fi=Mi.create,pf=nc.create;ki.create,ar.create;const Ct=Bi.create,ac=cr.create;Ui.create,Tn.create,dr.create;const Eb=/[@#$%^&*+=/\\|~«»]/,wb=/(!{2,}|\?{2,}|-{2,})/,vb=/[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u,Dr=({max:t,noSpaces:e}={})=>(e?We().max(t??Number.POSITIVE_INFINITY).regex(/^\S*$/,"Spaces are not allowed"):We().max(t??Number.POSITIVE_INFINITY)).refine(r=>!vb.test(r),{message:"Emojis and symbols are not allowed"}).refine(r=>!Eb.test(r),{message:"Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, «, ») are not allowed"}).refine(r=>!wb.test(r),{message:"Repeated punctuations (!!, ??, --) are not allowed"}),Ft=We().url().startsWith("https://",{message:"Must be an https url"}).max(1024).refine(t=>!t.includes(" "),{message:"URL must not contain spaces"}).refine(t=>{try{const e=new URL(t).hostname;return!(e==="localhost"||e.endsWith(".localhost")||/^(\d{1,3}\.){3}\d{1,3}$/.test(e)||e.startsWith("[")&&e.endsWith("]"))}catch{return!1}},{message:"URL must not use IP addresses or localhost"}),cc=We().max(32),mf=We().max(32),Rb=/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/(?:[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}(?:\/[-.%a-zA-Z0-9]{1,78})?|native)$/,Ab=We().regex(Rb,{message:"Invalid CAIP-19 asset ID"}),uc=We().regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i,{message:"Invalid hex color code. It should be in the format #RRGGBB or #RGB."}),Sb=/^(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,xb=We().max(1024).regex(Sb,{message:"Must be a valid domain name (e.g., example.com, sub.example.com)"}).refine(t=>!t.includes("://"),{message:"Domain must not include protocol (http://, https://, etc.)"}).refine(t=>!t.includes("/"),{message:"Domain must not include path separators"}).refine(t=>!t.includes("@"),{message:"Domain must not include @ symbol"}).refine(t=>!t.includes(":"),{message:"Domain must not include port numbers"}),Tb=Fi([Ct("1:1"),Ct("3:2")]),Ib=St({header:We(),payload:We(),signature:We()});St({fid:hf(),type:Ct("app_key"),key:We().startsWith("0x")});const Ob=St({type:Ct("launch_frame"),name:cc,url:Ft.optional(),splashImageUrl:Ft.optional(),splashBackgroundColor:uc.optional()}),Nb=St({type:Ct("launch_miniapp"),name:cc,url:Ft.optional(),splashImageUrl:Ft.optional(),splashBackgroundColor:uc.optional()}),Cb=St({type:Ct("view_token"),token:Ab}),Mb=pf("type",[Nb,Cb,Ob]),kb=St({title:mf,action:Mb});St({version:Fi([We(),hf()]).transform(t=>String(t)).pipe(Fi([Ct("next"),Ct("1")])),imageUrl:Ft,aspectRatio:Tb.optional(),button:kb});const gf=St({url:We(),token:We()});St({notificationId:We().max(128),title:We().max(32),body:We().max(128),targetUrl:Ft,tokens:We().array().max(100)}),St({result:St({successfulTokens:lr(We()),invalidTokens:lr(We()),rateLimitedTokens:lr(We())})});const Bb=St({event:Ct("miniapp_added"),notificationDetails:gf.optional()}),Ub=St({event:Ct("miniapp_removed")}),Lb=St({event:Ct("notifications_enabled"),notificationDetails:gf.required()}),Db=St({event:Ct("notifications_disabled")});pf("event",[Bb,Ub,Lb,Db]);const Pb=["wallet.getEthereumProvider","wallet.getSolanaProvider","actions.ready","actions.openUrl","actions.close","actions.setPrimaryButton","actions.addMiniApp","actions.signIn","actions.viewCast","actions.viewProfile","actions.composeCast","actions.viewToken","actions.sendToken","actions.swapToken","actions.openMiniApp","actions.requestCameraAndMicrophoneAccess","experimental.signManifest","haptics.impactOccurred","haptics.notificationOccurred","haptics.selectionChanged","back"],Fb=ac(["games","social","finance","utility","productivity","health-fitness","news-media","music","shopping","education","developer-tools","entertainment","art-creativity"]),$b=Fi([Ct("0.0.0"),Ct("0.0.1"),Ct("1"),Ct("next")]),zb=Dr({max:30}),jb=Dr({max:170}),Vb=lr(Ft).max(3),Hb=lr(Dr({max:20,noSpaces:!0})).max(5),Gb=Dr({max:30}),qb=Dr({max:30}),Kb=Dr({max:100}),Wb=_b(),Zb=["eip155:1","eip155:8453","eip155:42161","eip155:421614","eip155:84532","eip155:666666666","eip155:100","eip155:10","eip155:11155420","eip155:137","eip155:11155111","eip155:7777777","eip155:130","eip155:10143","eip155:42220","eip155:999","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"];function yf(t){const e=new Set(t);return Array.from(e)}const Yb=lr(ac(Zb)).transform(yf),Jb=lr(ac(Pb)).transform(yf),bf=St({version:$b,name:cc,iconUrl:Ft,homeUrl:Ft,imageUrl:Ft.optional(),buttonTitle:mf.optional(),splashImageUrl:Ft.optional(),splashBackgroundColor:uc.optional(),webhookUrl:Ft.optional(),subtitle:zb.optional(),description:jb.optional(),screenshotUrls:Vb.optional(),primaryCategory:Fb.optional(),tags:Hb.optional(),heroImageUrl:Ft.optional(),tagline:Gb.optional(),ogTitle:qb.optional(),ogDescription:Kb.optional(),ogImageUrl:Ft.optional(),noindex:Wb.optional(),requiredChains:Yb.optional(),requiredCapabilities:Jb.optional(),castShareUrl:Ft.optional(),canonicalDomain:xb.optional()}).refine(t=>{if(t.castShareUrl===void 0)return!0;try{const e=new URL(t.homeUrl).hostname,n=new URL(t.castShareUrl).hostname;return e===n}catch{return!1}},{message:"castShareUrl must have the same domain as homeUrl",path:["castShareUrl"]});St({accountAssociation:Ib,miniapp:bf.optional(),frame:bf.optional()}).refine(t=>t.frame&&t.miniapp?JSON.stringify(t.frame)===JSON.stringify(t.miniapp):!0,{message:'If both "frame" and "miniapp" are provided, they must be identical',path:["frame","miniapp"]}).transform(t=>({...t,frame:t.frame??t.miniapp}));var dc={},Us={},_f;function Xb(){if(_f)return Us;_f=1,Us.byteLength=a,Us.toByteArray=m,Us.fromByteArray=I;for(var t=[],e=[],n=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,i=r.length;s<i;++s)t[s]=r[s],e[r.charCodeAt(s)]=s;e[45]=62,e[95]=63;function o(N){var F=N.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var M=N.indexOf("=");M===-1&&(M=F);var B=M===F?0:4-M%4;return[M,B]}function a(N){var F=o(N),M=F[0],B=F[1];return(M+B)*3/4-B}function d(N,F,M){return(F+M)*3/4-M}function m(N){var F,M=o(N),B=M[0],K=M[1],Y=new n(d(N,B,K)),z=0,U=K>0?B-4:B,j;for(j=0;j<U;j+=4)F=e[N.charCodeAt(j)]<<18|e[N.charCodeAt(j+1)]<<12|e[N.charCodeAt(j+2)]<<6|e[N.charCodeAt(j+3)],Y[z++]=F>>16&255,Y[z++]=F>>8&255,Y[z++]=F&255;return K===2&&(F=e[N.charCodeAt(j)]<<2|e[N.charCodeAt(j+1)]>>4,Y[z++]=F&255),K===1&&(F=e[N.charCodeAt(j)]<<10|e[N.charCodeAt(j+1)]<<4|e[N.charCodeAt(j+2)]>>2,Y[z++]=F>>8&255,Y[z++]=F&255),Y}function g(N){return t[N>>18&63]+t[N>>12&63]+t[N>>6&63]+t[N&63]}function S(N,F,M){for(var B,K=[],Y=F;Y<M;Y+=3)B=(N[Y]<<16&16711680)+(N[Y+1]<<8&65280)+(N[Y+2]&255),K.push(g(B));return K.join("")}function I(N){for(var F,M=N.length,B=M%3,K=[],Y=16383,z=0,U=M-B;z<U;z+=Y)K.push(S(N,z,z+Y>U?U:z+Y));return B===1?(F=N[M-1],K.push(t[F>>2]+t[F<<4&63]+"==")):B===2&&(F=(N[M-2]<<8)+N[M-1],K.push(t[F>>10]+t[F>>4&63]+t[F<<2&63]+"=")),K.join("")}return Us}var $i={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var Ef;function Qb(){return Ef||(Ef=1,$i.read=function(t,e,n,r,s){var i,o,a=s*8-r-1,d=(1<<a)-1,m=d>>1,g=-7,S=n?s-1:0,I=n?-1:1,N=t[e+S];for(S+=I,i=N&(1<<-g)-1,N>>=-g,g+=a;g>0;i=i*256+t[e+S],S+=I,g-=8);for(o=i&(1<<-g)-1,i>>=-g,g+=r;g>0;o=o*256+t[e+S],S+=I,g-=8);if(i===0)i=1-m;else{if(i===d)return o?NaN:(N?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-m}return(N?-1:1)*o*Math.pow(2,i-r)},$i.write=function(t,e,n,r,s,i){var o,a,d,m=i*8-s-1,g=(1<<m)-1,S=g>>1,I=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=r?0:i-1,F=r?1:-1,M=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=g):(o=Math.floor(Math.log(e)/Math.LN2),e*(d=Math.pow(2,-o))<1&&(o--,d*=2),o+S>=1?e+=I/d:e+=I*Math.pow(2,1-S),e*d>=2&&(o++,d/=2),o+S>=g?(a=0,o=g):o+S>=1?(a=(e*d-1)*Math.pow(2,s),o=o+S):(a=e*Math.pow(2,S-1)*Math.pow(2,s),o=0));s>=8;t[n+N]=a&255,N+=F,a/=256,s-=8);for(o=o<<s|a,m+=s;m>0;t[n+N]=o&255,N+=F,o/=256,m-=8);t[n+N-F]|=M*128}),$i}/*!
1
+ (function(Rt,Ie){typeof exports=="object"&&typeof module<"u"?Ie(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],Ie):(Rt=typeof globalThis<"u"?globalThis:Rt||self,Ie(Rt.Chainrails={},Rt.React,Rt.jsxRuntime))})(this,(function(Rt,Ie,Jt){"use strict";var vu=document.createElement("style");vu.textContent=`.payment-modal-wrapper{position:fixed;inset:0;z-index:10000;height:100dvh;width:100vw;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);background-color:#0008;transition:all .2s ease-out}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0;pointer-events:none}.payment-modal-wrapper.closed *{pointer-events:none!important}.payment-modal-wrapper.open iframe{transform:translateY(0);transform:scale(1)}.payment-modal-wrapper.closed iframe{transform:translateY(50vh);transform:scale(1)}.payment-modal-loader{position:absolute;inset:0;z-index:10000;display:grid;height:100%;width:100%;place-content:center}.payment-modal-loader-logo{animation:cr-pulse 1.5s ease-in-out infinite;transform:scale(0);filter:blur(4px);transition:all .3s cubic-bezier(.25,1,.5,1),filter .2s 1.75s ease-out,transform .2s 1.75s ease-out}@keyframes cr-pulse{0%,to{opacity:1}50%{opacity:.5}}@media (prefers-color-scheme: dark){.payment-modal-container{background:#141414!important;border-color:#202020!important}}.payment-modal-loader .icon{height:48px;width:48px;animation:cr-spin 1s linear infinite;fill:#2563eb;color:#475569}.payment-modal{position:absolute;bottom:0;left:0;right:0;z-index:10000;height:100%;width:100%;transition:all .3s cubic-bezier(.25,1,.5,1)}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@keyframes cr-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.payment-modal-loader-container{position:absolute;bottom:0;left:50%;transform:translate(-50%) scale(.8);width:100%;max-width:28.375rem;border-top-left-radius:1.5rem;border-top-right-radius:1.5rem;pointer-events:none;transform-origin:50% 100%;transition:all .3s cubic-bezier(.25,1,.5,1),opacity .2s 1s ease-out,transform .2s 1s ease-out;opacity:0}.payment-modal-loader.light-mode .payment-modal-loader-container .payment-modal-loader-logo{color:#171717}.payment-modal-loader.dark-mode .payment-modal-loader-container .payment-modal-loader-logo{color:#f0f0f0}.payment-modal-loader-container.light-mode{background:#f8f8f8}.payment-modal-loader-container.dark-mode{background:#141414}.payment-modal-loader-container.no-amount{height:361px}.payment-modal-loader-container.has-amount{height:453.84px}@media (min-width: 48rem){.payment-modal-loader-container{bottom:3rem;border-bottom-left-radius:1.5rem;border-bottom-right-radius:1.5rem}.payment-modal-loader-container.no-amount{height:348.98px}.payment-modal-loader-container.has-amount{height:441.82px}}.payment-modal-wrapper.dark-mode .payment-modal-loader-container.dark-mode{background:#141414}.payment-modal-wrapper.light-mode .payment-modal-loader-container.light-mode{background:#f8f8f8}.payment-modal-loader-container.dark-mode .payment-modal-loader{color:#94a3b8}
2
+ /*$vite$:1*/`,document.head.appendChild(vu);class Eo extends Error{response;request;options;constructor(e,n,r){const s=e.status||e.status===0?e.status:"",i=e.statusText??"",o=`${s} ${i}`.trim(),a=o?`status code ${o}`:"an unknown error";super(`Request failed with ${a}: ${n.method} ${n.url}`),this.name="HTTPError",this.response=e,this.request=n,this.options=r}}class Ru extends Error{name="NonError";value;constructor(e){let n="Non-error value was thrown";try{typeof e=="string"?n=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(n=e.message)}catch{}super(n),this.value=e}}class vo extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new Ru(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",n?{cause:n}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const Au=(()=>{let t=!1,e=!1;const n=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(n&&r)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(s){if(s instanceof Error&&s.message==="unsupported BodyInit type")return!1;throw s}return t&&!e})(),B0=typeof globalThis.AbortController=="function",xu=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",k0=typeof globalThis.ReadableStream=="function",L0=typeof globalThis.FormData=="function",Su=["get","post","put","patch","head","delete"],P0={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Ro=2147483647,U0=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Tu=Symbol("stop");class Ou{options;constructor(e){this.options=e}}const D0=t=>new Ou(t),F0={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},$0={next:!0},z0={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},j0=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,r]of t)e+=U0,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,e+=typeof r=="string"?new TextEncoder().encode(r).length:r.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},Iu=(t,e,n)=>{let r,s=0;return t.pipeThrough(new TransformStream({transform(i,o){if(o.enqueue(i),r){s+=r.byteLength;let a=e===0?0:s/e;a>=1&&(a=1-Number.EPSILON),n?.({percent:a,totalBytes:Math.max(e,s),transferredBytes:s},r)}r=i},flush(){r&&(s+=r.byteLength,n?.({percent:1,totalBytes:Math.max(e,s),transferredBytes:s},r))}}))},V0=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const n=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(Iu(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},G0=(t,e,n)=>{if(!t.body)return t;const r=j0(n??t.body);return new Request(t,{duplex:"half",body:Iu(t.body,r,e)})},Zn=t=>t!==null&&typeof t=="object",Xs=(...t)=>{for(const e of t)if((!Zn(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return Ao({},...t)},Nu=(t={},e={})=>{const n=new globalThis.Headers(t),r=e instanceof globalThis.Headers,s=new globalThis.Headers(e);for(const[i,o]of s.entries())r&&o==="undefined"||o===void 0?n.delete(i):n.set(i,o);return n};function Qs(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:Ao(t[n]??[],e[n]??[])}const Cu=(t={},e={})=>({beforeRequest:Qs(t,e,"beforeRequest"),beforeRetry:Qs(t,e,"beforeRetry"),afterResponse:Qs(t,e,"afterResponse"),beforeError:Qs(t,e,"beforeError")}),H0=(t,e)=>{const n=new URLSearchParams;for(const r of[t,e])if(r!==void 0)if(r instanceof URLSearchParams)for(const[s,i]of r.entries())n.append(s,i);else if(Array.isArray(r))for(const s of r){if(!Array.isArray(s)||s.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");n.append(String(s[0]),String(s[1]))}else if(Zn(r))for(const[s,i]of Object.entries(r))i!==void 0&&n.append(s,String(i));else{const s=new URLSearchParams(r);for(const[i,o]of s.entries())n.append(i,o)}return n},Ao=(...t)=>{let e={},n={},r={},s;const i=[];for(const o of t)if(Array.isArray(o))Array.isArray(e)||(e=[]),e=[...e,...o];else if(Zn(o)){for(let[a,d]of Object.entries(o)){if(a==="signal"&&d instanceof globalThis.AbortSignal){i.push(d);continue}if(a==="context"){if(d!=null&&(!Zn(d)||Array.isArray(d)))throw new TypeError("The `context` option must be an object");e={...e,context:d==null?{}:{...e.context,...d}};continue}if(a==="searchParams"){d==null?s=void 0:s=s===void 0?d:H0(s,d);continue}Zn(d)&&a in e&&(d=Ao(e[a],d)),e={...e,[a]:d}}Zn(o.hooks)&&(r=Cu(r,o.hooks),e.hooks=r),Zn(o.headers)&&(n=Nu(n,o.headers),e.headers=n)}return s!==void 0&&(e.searchParams=s),i.length>0&&(i.length===1?e.signal=i[0]:xu?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e.context===void 0&&(e.context={}),e},q0=t=>Su.includes(t)?t.toUpperCase():t,Mu={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},K0=(t={})=>{if(typeof t=="number")return{...Mu,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Mu,...t}};class xo extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function W0(t,e,n,r){return new Promise((s,i)=>{const o=setTimeout(()=>{n&&n.abort(),i(new xo(t))},r.timeout);r.fetch(t,e).then(s).catch(i).then(()=>{clearTimeout(o)})})}async function Z0(t,{signal:e}){return new Promise((n,r)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",s,{once:!0}));function s(){clearTimeout(i),r(e.reason)}const i=setTimeout(()=>{e?.removeEventListener("abort",s),n()},t)})}const Y0=(t,e)=>{const n={};for(const r in e)Object.hasOwn(e,r)&&!(r in z0)&&!(r in F0)&&(!(r in t)||r in $0)&&(n[r]=e[r]);return n},J0=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function X0(t){return t instanceof Eo||t?.name===Eo.name}function Q0(t){return t instanceof xo||t?.name===xo.name}class Yr{static create(e,n){const r=new Yr(e,n),s=async()=>{if(typeof r.#e.timeout=="number"&&r.#e.timeout>Ro)throw new RangeError(`The \`timeout\` option cannot be greater than ${Ro}`);await Promise.resolve();let o=await r.#m();for(const a of r.#e.hooks.afterResponse){const d=r.#d(o.clone()),m=await a(r.request,r.#a(),d,{retryCount:r.#n});if(m instanceof globalThis.Response&&(o=m),m instanceof Ou)throw await Promise.all([d.body?.cancel(),o.body?.cancel()]),new vo(m.options)}if(r.#d(o),!o.ok&&(typeof r.#e.throwHttpErrors=="function"?r.#e.throwHttpErrors(o.status):r.#e.throwHttpErrors)){let a=new Eo(o,r.request,r.#a());for(const d of r.#e.hooks.beforeError)a=await d(a,{retryCount:r.#n});throw a}if(r.#e.onDownloadProgress){if(typeof r.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!k0)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return V0(o.clone(),r.#e.onDownloadProgress)}return o},i=r.#l(s).finally(async()=>{const o=r.#i,a=[];o&&!o.bodyUsed&&a.push(o.body?.cancel()),r.request.bodyUsed||a.push(r.request.body?.cancel()),await Promise.all(a)});for(const[o,a]of Object.entries(P0))o==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[o]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||a);const d=await i;if(o==="json"){if(d.status===204)return"";const m=await d.text();return m===""?"":n.parseJson?n.parseJson(m):JSON.parse(m)}return d[o]()});return i}static#h(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)):e}request;#r;#n=0;#t;#e;#i;#s;#o;constructor(e,n={}){if(this.#t=e,this.#e={...n,headers:Nu(this.#t.headers,n.headers),hooks:Cu({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:q0(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:K0(n.retry),throwHttpErrors:n.throwHttpErrors??!0,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis),context:n.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}B0&&xu&&(this.#s=this.#e.signal??this.#t.signal,this.#r=new globalThis.AbortController,this.#e.signal=this.#s?AbortSignal.any([this.#s,this.#r.signal]):this.#r.signal),Au&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const r=n.headers&&new globalThis.Headers(n.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(L0&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!r&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),J0(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(Yr.#h(this.#e.searchParams)).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(o,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Au)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#f(this.request,this.#e.body??void 0)}}#c(){const e=this.#e.retry.delay(this.#n);let n=e;return this.#e.retry.jitter===!0?n=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(n=this.#e.retry.jitter(e),(!Number.isFinite(n)||n<0)&&(n=e)),Math.min(this.#e.retry.backoffLimit,n)}async#p(e){if(this.#n++,this.#n>this.#e.retry.limit)throw e;const n=e instanceof Error?e:new Ru(e);if(n instanceof vo)return n.customDelay??this.#c();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const r=await this.#e.retry.shouldRetry({error:n,retryCount:this.#n});if(r===!1)throw e;if(r===!0)return this.#c()}if(Q0(e)&&!this.#e.retry.retryOnTimeout)throw e;if(X0(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const r=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(r&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let s=Number(r)*1e3;Number.isNaN(s)?s=Date.parse(r)-Date.now():s>=Date.parse("2024-01-01")&&(s-=Date.now());const i=this.#e.retry.maxRetryAfter??s;return s<i?s:i}if(e.response.status===413)throw e}return this.#c()}#d(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}async#l(e){try{return await e()}catch(n){const r=Math.min(await this.#p(n),Ro);if(this.#n<1)throw n;if(await Z0(r,this.#s?{signal:this.#s}:{}),n instanceof vo&&n.customRequest){const s=this.#e.signal?new globalThis.Request(n.customRequest,{signal:this.#e.signal}):new globalThis.Request(n.customRequest);this.#u(s)}for(const s of this.#e.hooks.beforeRetry){const i=await s({request:this.request,options:this.#a(),error:n,retryCount:this.#n});if(i instanceof globalThis.Request){this.#u(i);break}if(i instanceof globalThis.Response)return i;if(i===Tu)return}return this.#l(e)}}async#m(){this.#r?.signal.aborted&&(this.#r=new globalThis.AbortController,this.#e.signal=this.#s?AbortSignal.any([this.#s,this.#r.signal]):this.#r.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const n of this.#e.hooks.beforeRequest){const r=await n(this.request,this.#a(),{retryCount:this.#n});if(r instanceof Response)return r;if(r instanceof globalThis.Request){this.#u(r);break}}const e=Y0(this.request,this.#e);return this.#i=this.request,this.request=this.#i.clone(),this.#e.timeout===!1?this.#e.fetch(this.#i,e):W0(this.#i,e,this.#r,this.#e)}#a(){if(!this.#o){const{hooks:e,...n}=this.#e;this.#o=Object.freeze(n)}return this.#o}#u(e){this.#o=void 0,this.request=this.#f(e)}#f(e,n){return!this.#e.onUploadProgress||!e.body?e:G0(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const So=t=>{const e=(n,r)=>Yr.create(n,Xs(t,r));for(const n of Su)e[n]=(r,s)=>Yr.create(r,Xs(t,s,{method:n}));return e.create=n=>So(Xs(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),So(Xs(t,n))),e.stop=Tu,e.retry=D0,e},ep=So(),Xe={ARBITRUM:"ARBITRUM_MAINNET",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE_MAINNET",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE_MAINNET",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC_MAINNET",ETHEREUM:"ETHEREUM_MAINNET",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM_MAINNET",LISK:"LISK_MAINNET",MONAD:"MONAD_MAINNET",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM_MAINNET",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON_MAINNET",STARKNET:"STARKNET_MAINNET",STARKNET_TESTNET:"STARKNET_TESTNET"},Bu={ARBITRUM:"ARBITRUM",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC",ETHEREUM:"ETHEREUM",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM",LISK:"LISK",MONAD:"MONAD",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON",STARKNET:"STARKNET",STARKNET_TESTNET:"STARKNET_TESTNET"};function To(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function ku(t){return To(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Lu="2.43.4";let Oo={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${Lu}`},Jr=class bu extends Error{constructor(e,n={}){const r=n.cause instanceof bu?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof bu&&n.cause.docsPath||n.docsPath,i=Oo.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...Oo.version?[`Version: ${Oo.version}`]:[]].join(`
3
+ `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=Lu}walk(e){return Pu(this,e)}};function Pu(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Pu(t.cause,e):e?null:t}let Uu=class extends Jr{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}};function ei(t,{dir:e,size:n=32}={}){return typeof t=="string"?tp(t,{dir:e,size:n}):np(t,{dir:e,size:n})}function tp(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new Uu({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function np(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new Uu({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=e==="right";r[i?s:n-s-1]=t[i?s:t.length-s-1]}return r}class rp extends Jr{constructor({max:e,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class sp extends Jr{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Io(t,{size:e}){if(ku(t)>e)throw new sp({givenSize:ku(t),maxSize:e})}function ip(t,e={}){const{signed:n,size:r}=e,s=BigInt(t);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const d=typeof t=="bigint"?"n":"";throw new rp({max:i?`${i}${d}`:void 0,min:`${o}${d}`,signed:n,size:r,value:`${t}${d}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?ei(a,{size:r}):a}const op=new TextEncoder;function ap(t,e={}){return typeof t=="number"||typeof t=="bigint"?up(t,e):typeof t=="boolean"?cp(t,e):To(t)?Fu(t,e):$u(t,e)}function cp(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Io(n,{size:e.size}),ei(n,{size:e.size})):n}const gn={zero:48,nine:57,A:65,F:70,a:97,f:102};function Du(t){if(t>=gn.zero&&t<=gn.nine)return t-gn.zero;if(t>=gn.A&&t<=gn.F)return t-(gn.A-10);if(t>=gn.a&&t<=gn.f)return t-(gn.a-10)}function Fu(t,e={}){let n=t;e.size&&(Io(n,{size:e.size}),n=ei(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const d=Du(r.charCodeAt(a++)),m=Du(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new Jr(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function up(t,e){const n=ip(t,e);return Fu(n)}function $u(t,e={}){const n=op.encode(t);return typeof e.size=="number"?(Io(n,{size:e.size}),ei(n,{dir:"right",size:e.size})):n}const ti=BigInt(2**32-1),zu=BigInt(32);function dp(t,e=!1){return e?{h:Number(t&ti),l:Number(t>>zu&ti)}:{h:Number(t>>zu&ti)|0,l:Number(t&ti)|0}}function lp(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:o,l:a}=dp(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const fp=(t,e,n)=>t<<n|e>>>32-n,hp=(t,e,n)=>e<<n|t>>>32-n,pp=(t,e,n)=>e<<n-32|t>>>64-n,mp=(t,e,n)=>t<<n-32|e>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gp(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ju(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ni(t,...e){if(!gp(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Vu(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function yp(t,e){ni(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function bp(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Gu(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const _p=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function wp(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Ep(t){for(let e=0;e<t.length;e++)t[e]=wp(t[e]);return t}const Hu=_p?t=>t:Ep;function vp(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function qu(t){return typeof t=="string"&&(t=vp(t)),ni(t),t}let Rp=class{};function Ap(t){const e=r=>t().update(qu(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}const xp=BigInt(0),Xr=BigInt(1),Sp=BigInt(2),Tp=BigInt(7),Op=BigInt(256),Ip=BigInt(113),Ku=[],Wu=[],Zu=[];for(let t=0,e=Xr,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Ku.push(2*(5*r+n)),Wu.push((t+1)*(t+2)/2%64);let s=xp;for(let i=0;i<7;i++)e=(e<<Xr^(e>>Tp)*Ip)%Op,e&Sp&&(s^=Xr<<(Xr<<BigInt(i))-Xr);Zu.push(s)}const Yu=lp(Zu,!0),Np=Yu[0],Cp=Yu[1],Ju=(t,e,n)=>n>32?pp(t,e,n):fp(t,e,n),Xu=(t,e,n)=>n>32?mp(t,e,n):hp(t,e,n);function Mp(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=n[d],g=n[d+1],x=Ju(m,g,1)^n[a],O=Xu(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=x,t[o+N+1]^=O}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=Wu[o],d=Ju(s,i,a),m=Xu(s,i,a),g=Ku[o];s=t[g],i=t[g+1],t[g]=d,t[g+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=Np[r],t[1]^=Cp[r]}Gu(n)}let Bp=class N0 extends Rp{constructor(e,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,ju(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=bp(this.state)}clone(){return this._cloneInto()}keccak(){Hu(this.state32),Mp(this.state32,this.rounds),Hu(this.state32),this.posOut=0,this.pos=0}update(e){Vu(this),e=qu(e),ni(e);const{blockLen:n,state:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Vu(this,!1),ni(e),this.finish();const n=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(n.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 ju(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(yp(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,Gu(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new N0(n,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 kp=(t,e,n)=>Ap(()=>new Bp(e,t,n)),Lp=kp(1,136,256/8);function Pp(t,e){return Lp(To(t,{strict:!1})?ap(t):t)}let Up=class extends Jr{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}};class Qu extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const No=new Qu(8192);function ed(t,e){if(No.has(`${t}.${e}`))return No.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=Pp($u(n)),s=n.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const i=`0x${s.join("")}`;return No.set(`${t}.${e}`,i),i}function At(t,e){if(!Fp(t,{strict:!1}))throw new Up({address:t});return ed(t,e)}const Dp=/^0x[a-fA-F0-9]{40}$/,Co=new Qu(8192);function Fp(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(Co.has(r))return Co.get(r);const s=Dp.test(t)?t.toLowerCase()===t?!0:n?ed(t)===t:!0:!1;return Co.set(r,s),s}const X={USDC:"USDC",USDT:"USDT",DAI:"DAI",BUSD:"BUSD",EURC:"EURC",ETH:"ETH",WETH:"WETH",STRK:"STRK",BNB:"BNB",LORDS:"LORDS"};X.USDC;const td={[Xe.ARBITRUM]:{[X.DAI]:{address:At("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.USDC]:{address:At("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:At("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:At("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.ARBITRUM_TESTNET]:{[X.USDC]:{address:At("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Xe.AVALANCHE]:{[X.DAI]:{address:"0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.USDC]:{address:At("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.AVALANCHE_TESTNET]:{[X.USDC]:{address:At("0x5425890298aed601595a70AB815c96711a31Bc65"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Xe.BASE]:{[X.DAI]:{address:"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.EURC]:{address:"0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",symbol:X.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[X.USDC]:{address:At("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.WETH]:{address:At("0x4200000000000000000000000000000000000006"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.BASE_TESTNET]:{[X.USDC]:{address:At("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Xe.BSC]:{[X.BNB]:{address:"0x0000000000000000000000000000000000000000",symbol:X.BNB,name:"BNB",decimals:18,logoURI:"/images/chains/bsc.webp",nativeToken:!0},[X.BUSD]:{address:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",symbol:X.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[X.DAI]:{address:"0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[X.USDC]:{address:At("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:X.USDC,decimals:18,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:"0x55d398326f99059fF775485246999027B3197955",symbol:X.USDT,name:"Tether USD",decimals:18,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[Xe.ETHEREUM]:{[X.BUSD]:{address:"0x4Fabb145d64652a948d72533023f6E7A623C7C53",symbol:X.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[X.DAI]:{address:At("0x6B175474E89094C44Da98b954EedeAC495271d0F"),symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.EURC]:{address:"0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",symbol:X.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[X.STRK]:{address:"0xCa14007Eff0dB1f8135f4C25B34De49AB0d42766",symbol:X.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[X.USDC]:{address:At("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:At("0xdAC17F958D2ee523a2206206994597C13D831ec7"),symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:At("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.ETHEREUM_TESTNET]:{[X.USDC]:{address:At("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:X.USDC,decimals:6,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Xe.HYPEREVM]:{[X.USDC]:{address:"0xb88339CB7199b77E23DB6E890353E22632Ba630f",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.LISK]:{[X.USDC]:{address:"0xF242275d3a6527d877f2c927a82D9b057609cc71",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.MONAD]:{[X.USDC]:{address:"0x754704Bc059F8C67012fEd69BC8A327a5aafb603",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.MONAD_TESTNET]:{[X.USDC]:{address:"0x534b2f3A21130d7a60830c2Df862319e593943A3",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.OPTIMISM]:{[X.DAI]:{address:"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.USDC]:{address:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:"0x4200000000000000000000000000000000000006",symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.OPTIMISM_TESTNET]:{[X.USDC]:{address:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.POLYGON]:{[X.DAI]:{address:"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.USDC]:{address:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.STARKNET]:{[X.DAI]:{address:"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[X.LORDS]:{address:"0x0124aeb495b947201f5faC96fD1138E326AD86195B98df6DEc9009158A533B49",symbol:X.LORDS,name:"LORDS Token",decimals:18,logoURI:"/images/tokens/lords.png",nativeToken:!1},[X.STRK]:{address:"0x04718f5a0Fc34cC1AF16A1cdee98fFB20C31f5cD61D6Ab07201858f4287c938D",symbol:X.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[X.USDC]:{address:"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[Xe.STARKNET_TESTNET]:{[X.USDC]:{address:"0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}}},$p=new Set(Object.values(Xe));function Lt(t){if(zp(t))return t;const e=Xe[t];if(!e)throw new Error(`Invalid chain: ${t}. Chain must be a valid chain alias or internal chain value from Chains.`);return e}function zp(t){return $p.has(t)}function jp(t,e){const n=e.toLowerCase().trim(),r=td[t];if(!r)throw new Error(`Chain not found: ${t}. The chain key must be a valid chain identifier.`);let s;for(const i in r){const o=r[i];if(o&&o.address.toLowerCase()===n.toLowerCase()){s=o;break}}if(!s)throw new Error(`Token address mismatch: address ${e} does not exist on chain ${t}. The token address must be a valid token address on the specified chain.`);return s}function Mo(t,e,n){const r=jp(t,e);if(r.symbol!==n)throw new Error(`Token address and symbol mismatch: address ${e} on chain ${t} corresponds to token "${r.symbol}", but expected "${n}". The token address must correspond to a token with the expected symbol on the specified chain.`);return r}function Vp(t,e){return td[t]?.[e]}function nd(t,e){return Vp(t,e)?.address}var Bo=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(Bo||{});class Me{constructor({api_key:e,env:n,seesion_token:r,props:s}){this.api_key=e||"",this.sessionToken=r||"",this.env=n??Bo.PRODUCTION,this.props=s}static async config(e){if(!Me.app){if(!e)throw new Error("Please provide an api_key");Me.app=new Me(e)}return e&&(e.api_key!==void 0&&(Me.app.api_key=e.api_key),e.seesion_token!==void 0&&(Me.app.sessionToken=e.seesion_token),e.env!==void 0&&(Me.app.env=e.env),e.props!==void 0&&(Me.app.props=e.props)),Me.app}static getApiKey(){if(!Me.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Me.app.api_key}static getSessionToken(){if(!Me.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Me.app.sessionToken}static getProps(){if(!Me.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Me.app.props}static getEnv(){if(!Me.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Me.app.env==="internal"?"staging":Me.app.env}static getBaseUrl(){if(!Me.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(Me.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(e){if(!Me.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const n=Me.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",r=Number(e),s=e&&!isNaN(Number(e))&&r>0?"/pay/":"/deposit/",i=`${e&&!isNaN(Number(e))&&r>0?r*100:""}`;return n+s+i}}let ko=null;function Gp(){ko=ep.create({prefixUrl:Me.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=Me.getSessionToken()||Me.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,n)=>n]},retry:{limit:2}})}function ze(){return ko||Gp(),ko}let Hp=class{async getById(e){return await ze().get("intents/"+e).json()}async getForSender(e){return await ze().get("intents/user/"+e).json()}async getForAddress(e){return await ze().get("intents/address/"+e).json()}async getForSession(e){return await ze().get("modal/sessions/intents/"+e).json()}async getAll(e){return await ze().get("intents",{searchParams:e}).json()}async create(e){const n=Lt(e.source_chain),r=Lt(e.destination_chain);return await ze().post("intents",{json:{...e,source_chain:n,destination_chain:r}}).json()}async createForSession(e){const n=Lt(e.sourceChain);return await ze().post("modal/sessions/intents",{json:{...e,sourceChain:n}}).json()}async update(e,n){return await ze().post("intents",{json:n}).json()}async triggerProcessing(e){return await ze().post(`intents/${e}/trigger-processing`).json()}async triggerProcessingForSession(e){return await ze().post(`modal/sessions/intents/${e}/process`).json()}},qp=class{async getFromSpecificBridge(e){const n=Lt(e.sourceChain);Mo(n,e.tokenIn,e.amountSymbol);const r=Lt(e.destinationChain);return await ze().get("quotes/single",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getFromAllBridges(e){const n=Lt(e.sourceChain);Mo(n,e.tokenIn,e.amountSymbol);const r=Lt(e.destinationChain);return await ze().get("quotes/multiple",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getBestAcrossBridges(e){const n=Lt(e.sourceChain);Mo(n,e.tokenIn,e.amountSymbol);const r=Lt(e.destinationChain);return await ze().get("quotes/best",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getAll(e){const n=Lt(e.destinationChain);return await ze().get("quotes/multi-source",{searchParams:{...e,destinationChain:n}}).json()}async getAllForSession(e){return await ze().get("modal/sessions/quotes",{searchParams:e}).json()}},Kp=class{async getOptimalRoutes(e){const n=Lt(e.sourceChain),r=Lt(e.destinationChain);return await ze().get("router/optimal-route",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getAllSupportedBridges(){return await ze().get("router/supported-bridges/all").json()}async getSupportedBridges(e){const n=Lt(e.sourceChain),r=Lt(e.destinationChain);return await ze().get("router/supported-bridges/route",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getSupportedRoutes(e){return await ze().get("router/supported-routes/bridge/"+e).json()}},Wp=class{async getSupported(e){return await ze().get("chains",{searchParams:e}).json()}async getBalance(e){return await ze().get(`chains/balances/${e.address}`,{searchParams:e}).json()}},Zp=class{async getClientInfo(){return await ze().get("client/auth/client-info").json()}async getClientInfoForSession(){return await ze().get("modal/sessions/client").json()}},Yp=class{async getSessionToken(e){const n=Lt(e.destinationChain);let r=nd(n,e.token);r||(console.error(`${e.token} on ${e.destinationChain} is currently unsupported, defaulting to usdc`),r=nd(n,"USDC"));const s={recipient:e.recipient,tokenOut:r,destinationChain:n,amount:e.amount};return ze().post("modal/sessions",{json:s}).json().then(i=>({...i,amount:s.amount}))}};const Jp={router:new Kp,quotes:new qp,intents:new Hp,chains:new Wp,client:new Zp,auth:new Yp};function rd(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;e<s;e++)t[e]&&(n=rd(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Lo(){for(var t,e,n=0,r="",s=arguments.length;n<s;n++)(t=arguments[n])&&(e=rd(t))&&(r&&(r+=" "),r+=e);return r}const cn={CLOSED:"closed",COMPLETED:"completed",AUTH:"session",REQUEST_FARCASTER_CONNECT:"cr:request-farcaster-connect",REQUEST_FARCASTER_DISCONNECT:"cr:request-farcaster-disconnect",REQUEST_FARCASTER_SEND_TRANSACTION:"cr:request-farcaster-send-transaction",FARCASTER_SEND_TRANSACTION_RESULT:"cr:farcaster-send-transaction-result",FARCASTER_CONNECTED:"cr:farcaster-connected",FARCASTER_DISCONNECTED:"cr:farcaster-disconnected",IN_FARCASTER_MINI_APP:"cr:in-farcaster-mini-app"},Po="https://app.chainrails.io",Uo="https://chainrails-frontend-git-staging-horus-labs.vercel.app",Xp=[{type:"event",name:"Approval",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"event",name:"Transfer",inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}];function mr(t,{includeName:e=!1}={}){if(t.type!=="function"&&t.type!=="event"&&t.type!=="error")throw new cm(t.type);return`${t.name}(${Do(t.inputs,{includeName:e})})`}function Do(t,{includeName:e=!1}={}){return t?t.map(n=>Qp(n,{includeName:e})).join(e?", ":","):""}function Qp(t,{includeName:e}){return t.type.startsWith("tuple")?`(${Do(t.components,{includeName:e})})${t.type.slice(5)}`:t.type+(e&&t.name?` ${t.name}`:"")}function Cn(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function bt(t){return Cn(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const sd="2.43.4";let Fo={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${sd}`},ue=class _u extends Error{constructor(e,n={}){const r=n.cause instanceof _u?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof _u&&n.cause.docsPath||n.docsPath,i=Fo.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...Fo.version?[`Version: ${Fo.version}`]:[]].join(`
4
+ `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=sd}walk(e){return id(this,e)}};function id(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?id(t.cause,e):e?null:t}class em extends ue{constructor({data:e,params:n,size:r}){super([`Data size of ${r} bytes is too small for given parameters.`].join(`
5
+ `),{metaMessages:[`Params: (${Do(n,{includeName:!0})})`,`Data: ${e} (${r} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e,this.params=n,this.size=r}}class $o extends ue{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class tm extends ue{constructor({expectedLength:e,givenLength:n,type:r}){super([`ABI encoding array length mismatch for type ${r}.`,`Expected length: ${e}`,`Given length: ${n}`].join(`
6
+ `),{name:"AbiEncodingArrayLengthMismatchError"})}}class nm extends ue{constructor({expectedSize:e,value:n}){super(`Size of bytes "${n}" (bytes${bt(n)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class rm extends ue{constructor({expectedLength:e,givenLength:n}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${e}`,`Given length (values): ${n}`].join(`
7
+ `),{name:"AbiEncodingLengthMismatchError"})}}class od extends ue{constructor(e,{docsPath:n}){super([`Encoded error signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.`].join(`
8
+ `),{docsPath:n,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class ad extends ue{constructor(e,{docsPath:n}={}){super([`Function ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join(`
9
+ `),{docsPath:n,name:"AbiFunctionNotFoundError"})}}class sm extends ue{constructor(e,n){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${mr(e.abiItem)}\`, and`,`\`${n.type}\` in \`${mr(n.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}class im extends ue{constructor(e,{docsPath:n}){super([`Type "${e}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(`
10
+ `),{docsPath:n,name:"InvalidAbiEncodingType"})}}class om extends ue{constructor(e,{docsPath:n}){super([`Type "${e}" is not a valid decoding type.`,"Please provide a valid ABI type."].join(`
11
+ `),{docsPath:n,name:"InvalidAbiDecodingType"})}}class am extends ue{constructor(e){super([`Value "${e}" is not a valid array.`].join(`
12
+ `),{name:"InvalidArrayError"})}}class cm extends ue{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(`
13
+ `),{name:"InvalidDefinitionTypeError"})}}class Qr extends ue{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class cd extends ue{constructor({offset:e,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}class ud extends ue{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}class dd extends ue{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} is expected to be ${n} ${r} long, but is ${e} ${r} long.`,{name:"InvalidBytesLengthError"})}}function gr(t,{dir:e,size:n=32}={}){return typeof t=="string"?Mn(t,{dir:e,size:n}):um(t,{dir:e,size:n})}function Mn(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new ud({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function um(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new ud({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=e==="right";r[i?s:n-s-1]=t[i?s:t.length-s-1]}return r}class ld extends ue{constructor({max:e,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class dm extends ue{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class lm extends ue{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}class fm extends ue{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Yn(t,{dir:e="left"}={}){let n=typeof t=="string"?t.replace("0x",""):t,r=0;for(let s=0;s<n.length-1&&n[e==="left"?s:n.length-s-1].toString()==="0";s++)r++;return n=e==="left"?n.slice(r):n.slice(0,n.length-r),typeof t=="string"?(n.length===1&&e==="right"&&(n=`${n}0`),`0x${n.length%2===1?`0${n}`:n}`):n}function Xt(t,{size:e}){if(bt(t)>e)throw new fm({givenSize:bt(t),maxSize:e})}function hm(t,e){const n={to:e},r=n.to;return r==="number"?Jn(t,n):r==="bigint"?yr(t,n):r==="string"?mm(t,n):r==="boolean"?pm(t,n):en(t,n)}function yr(t,e={}){const{signed:n}=e;e.size&&Xt(t,{size:e.size});const r=BigInt(t);if(!n)return r;const s=(t.length-2)/2,i=(1n<<BigInt(s)*8n-1n)-1n;return r<=i?r:r-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function pm(t,e={}){let n=t;if(e.size&&(Xt(n,{size:e.size}),n=Yn(n)),Yn(n)==="0x00")return!1;if(Yn(n)==="0x01")return!0;throw new lm(n)}function Jn(t,e={}){return Number(yr(t,e))}function mm(t,e={}){let n=en(t);return e.size&&(Xt(n,{size:e.size}),n=Yn(n,{dir:"right"})),new TextDecoder().decode(n)}const gm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function zo(t,e={}){return typeof t=="number"||typeof t=="bigint"?ke(t,e):typeof t=="string"?jo(t,e):typeof t=="boolean"?fd(t,e):zt(t,e)}function fd(t,e={}){const n=`0x${Number(t)}`;return typeof e.size=="number"?(Xt(n,{size:e.size}),gr(n,{size:e.size})):n}function zt(t,e={}){let n="";for(let s=0;s<t.length;s++)n+=gm[t[s]];const r=`0x${n}`;return typeof e.size=="number"?(Xt(r,{size:e.size}),gr(r,{dir:"right",size:e.size})):r}function ke(t,e={}){const{signed:n,size:r}=e,s=BigInt(t);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const d=typeof t=="bigint"?"n":"";throw new ld({max:i?`${i}${d}`:void 0,min:`${o}${d}`,signed:n,size:r,value:`${t}${d}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?gr(a,{size:r}):a}const ym=new TextEncoder;function jo(t,e={}){const n=ym.encode(t);return zt(n,e)}const bm=new TextEncoder;function Vo(t,e={}){return typeof t=="number"||typeof t=="bigint"?wm(t,e):typeof t=="boolean"?_m(t,e):Cn(t)?en(t,e):pd(t,e)}function _m(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Xt(n,{size:e.size}),gr(n,{size:e.size})):n}const yn={zero:48,nine:57,A:65,F:70,a:97,f:102};function hd(t){if(t>=yn.zero&&t<=yn.nine)return t-yn.zero;if(t>=yn.A&&t<=yn.F)return t-(yn.A-10);if(t>=yn.a&&t<=yn.f)return t-(yn.a-10)}function en(t,e={}){let n=t;e.size&&(Xt(n,{size:e.size}),n=gr(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const d=hd(r.charCodeAt(a++)),m=hd(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new ue(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function wm(t,e){const n=ke(t,e);return en(n)}function pd(t,e={}){const n=bm.encode(t);return typeof e.size=="number"?(Xt(n,{size:e.size}),gr(n,{dir:"right",size:e.size})):n}const ri=BigInt(2**32-1),md=BigInt(32);function Em(t,e=!1){return e?{h:Number(t&ri),l:Number(t>>md&ri)}:{h:Number(t>>md&ri)|0,l:Number(t&ri)|0}}function gd(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:o,l:a}=Em(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const yd=(t,e,n)=>t>>>n,bd=(t,e,n)=>t<<32-n|e>>>n,br=(t,e,n)=>t>>>n|e<<32-n,_r=(t,e,n)=>t<<32-n|e>>>n,si=(t,e,n)=>t<<64-n|e>>>n-32,ii=(t,e,n)=>t>>>n-32|e<<64-n,vm=(t,e,n)=>t<<n|e>>>32-n,Rm=(t,e,n)=>e<<n|t>>>32-n,Am=(t,e,n)=>e<<n-32|t>>>64-n,xm=(t,e,n)=>t<<n-32|e>>>64-n;function bn(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const Sm=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Tm=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Om=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Im=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,Nm=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0),Cm=(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0,wr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Mm(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function es(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Xn(t,...e){if(!Mm(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Bm(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");es(t.outputLen),es(t.blockLen)}function Er(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function _d(t,e){Xn(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function km(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Bn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Go(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function un(t,e){return t<<32-e|t>>>e}const Lm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Pm(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Um(t){for(let e=0;e<t.length;e++)t[e]=Pm(t[e]);return t}const wd=Lm?t=>t:Um;function Dm(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function oi(t){return typeof t=="string"&&(t=Dm(t)),Xn(t),t}function Fm(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];Xn(s),e+=s.length}const n=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const i=t[r];n.set(i,s),s+=i.length}return n}class Ho{}function qo(t){const e=r=>t().update(oi(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Ed(t=32){if(wr&&typeof wr.getRandomValues=="function")return wr.getRandomValues(new Uint8Array(t));if(wr&&typeof wr.randomBytes=="function")return Uint8Array.from(wr.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const $m=BigInt(0),ts=BigInt(1),zm=BigInt(2),jm=BigInt(7),Vm=BigInt(256),Gm=BigInt(113),vd=[],Rd=[],Ad=[];for(let t=0,e=ts,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],vd.push(2*(5*r+n)),Rd.push((t+1)*(t+2)/2%64);let s=$m;for(let i=0;i<7;i++)e=(e<<ts^(e>>jm)*Gm)%Vm,e&zm&&(s^=ts<<(ts<<BigInt(i))-ts);Ad.push(s)}const xd=gd(Ad,!0),Hm=xd[0],qm=xd[1],Sd=(t,e,n)=>n>32?Am(t,e,n):vm(t,e,n),Td=(t,e,n)=>n>32?xm(t,e,n):Rm(t,e,n);function Km(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=n[d],g=n[d+1],x=Sd(m,g,1)^n[a],O=Td(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=x,t[o+N+1]^=O}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=Rd[o],d=Sd(s,i,a),m=Td(s,i,a),g=vd[o];s=t[g],i=t[g+1],t[g]=d,t[g+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=Hm[r],t[1]^=qm[r]}Bn(n)}class Ko extends Ho{constructor(e,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,es(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=km(this.state)}clone(){return this._cloneInto()}keccak(){wd(this.state32),Km(this.state32,this.rounds),wd(this.state32),this.posOut=0,this.pos=0}update(e){Er(this),e=oi(e),Xn(e);const{blockLen:n,state:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Er(this,!1),Xn(e),this.finish();const n=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(n.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 es(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(_d(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,Bn(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Ko(n,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 Wm=(t,e,n)=>qo(()=>new Ko(e,t,n)),Zm=Wm(1,136,256/8);function ai(t,e){const n=e||"hex",r=Zm(Cn(t,{strict:!1})?Vo(t):t);return n==="bytes"?r:zo(r)}class ns extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const Ym=/^0x[a-fA-F0-9]{40}$/,Wo=new ns(8192);function kn(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(Wo.has(r))return Wo.get(r);const s=Ym.test(t)?t.toLowerCase()===t?!0:n?ci(t)===t:!0:!1;return Wo.set(r,s),s}const Zo=new ns(8192);function ci(t,e){if(Zo.has(`${t}.${e}`))return Zo.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=ai(pd(n),"bytes"),s=n.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const i=`0x${s.join("")}`;return Zo.set(`${t}.${e}`,i),i}function ui(t,e){if(!kn(t,{strict:!1}))throw new Qr({address:t});return ci(t,e)}class Od extends ue{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class Jm extends ue{constructor({length:e,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class Xm extends ue{constructor({count:e,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const Qm={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Xm({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new Jm({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new Od({offset:t});const e=this.position-t;this.assertPosition(e),this.position=e},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new Od({offset:t});const e=this.position+t;this.assertPosition(e),this.position=e},inspectByte(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectBytes(t,e){const n=e??this.position;return this.assertPosition(n+t-1),this.bytes.subarray(n,n+t)},inspectUint8(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectUint16(t){const e=t??this.position;return this.assertPosition(e+1),this.dataView.getUint16(e)},inspectUint24(t){const e=t??this.position;return this.assertPosition(e+2),(this.dataView.getUint16(e)<<8)+this.dataView.getUint8(e+2)},inspectUint32(t){const e=t??this.position;return this.assertPosition(e+3),this.dataView.getUint32(e)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,e){this.assertReadLimit(),this._touch();const n=this.inspectBytes(t);return this.position+=e??t,n},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const e=this.position;return this.assertPosition(t),this.position=t,()=>this.position=e},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function Yo(t,{recursiveReadLimit:e=8192}={}){const n=Object.create(Qm);return n.bytes=t,n.dataView=new DataView(t.buffer??t,t.byteOffset,t.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=e,n}function di(t,e,n,{strict:r}={}){return Cn(t,{strict:!1})?eg(t,e,n,{strict:r}):Cd(t,e,n,{strict:r})}function Id(t,e){if(typeof e=="number"&&e>0&&e>bt(t)-1)throw new cd({offset:e,position:"start",size:bt(t)})}function Nd(t,e,n){if(typeof e=="number"&&typeof n=="number"&&bt(t)!==n-e)throw new cd({offset:n,position:"end",size:bt(t)})}function Cd(t,e,n,{strict:r}={}){Id(t,e);const s=t.slice(e,n);return r&&Nd(s,e,n),s}function eg(t,e,n,{strict:r}={}){Id(t,e);const s=`0x${t.replace("0x","").slice((e??0)*2,(n??t.length)*2)}`;return r&&Nd(s,e,n),s}function tg(t,e={}){typeof e.size<"u"&&Xt(t,{size:e.size});const n=zt(t,e);return yr(n,e)}function ng(t,e={}){let n=t;if(typeof e.size<"u"&&(Xt(n,{size:e.size}),n=Yn(n)),n.length>1||n[0]>1)throw new dm(n);return!!n[0]}function _n(t,e={}){typeof e.size<"u"&&Xt(t,{size:e.size});const n=zt(t,e);return Jn(n,e)}function rg(t,e={}){let n=t;return typeof e.size<"u"&&(Xt(n,{size:e.size}),n=Yn(n,{dir:"right"})),new TextDecoder().decode(n)}function vr(t){return typeof t[0]=="string"?Jo(t):sg(t)}function sg(t){let e=0;for(const s of t)e+=s.length;const n=new Uint8Array(e);let r=0;for(const s of t)n.set(s,r),r+=s.length;return n}function Jo(t){return`0x${t.reduce((e,n)=>e+n.replace("0x",""),"")}`}const ig=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function og(t,e){if(t.length!==e.length)throw new rm({expectedLength:t.length,givenLength:e.length});const n=ag({params:t,values:e}),r=Qo(n);return r.length===0?"0x":r}function ag({params:t,values:e}){const n=[];for(let r=0;r<t.length;r++)n.push(Xo({param:t[r],value:e[r]}));return n}function Xo({param:t,value:e}){const n=ea(t.type);if(n){const[r,s]=n;return ug(e,{length:r,param:{...t,type:s}})}if(t.type==="tuple")return pg(e,{param:t});if(t.type==="address")return cg(e);if(t.type==="bool")return lg(e);if(t.type.startsWith("uint")||t.type.startsWith("int")){const r=t.type.startsWith("int"),[,,s="256"]=ig.exec(t.type)??[];return fg(e,{signed:r,size:Number(s)})}if(t.type.startsWith("bytes"))return dg(e,{param:t});if(t.type==="string")return hg(e);throw new im(t.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function Qo(t){let e=0;for(let i=0;i<t.length;i++){const{dynamic:o,encoded:a}=t[i];o?e+=32:e+=bt(a)}const n=[],r=[];let s=0;for(let i=0;i<t.length;i++){const{dynamic:o,encoded:a}=t[i];o?(n.push(ke(e+s,{size:32})),r.push(a),s+=bt(a)):n.push(a)}return vr([...n,...r])}function cg(t){if(!kn(t))throw new Qr({address:t});return{dynamic:!1,encoded:Mn(t.toLowerCase())}}function ug(t,{length:e,param:n}){const r=e===null;if(!Array.isArray(t))throw new am(t);if(!r&&t.length!==e)throw new tm({expectedLength:e,givenLength:t.length,type:`${n.type}[${e}]`});let s=!1;const i=[];for(let o=0;o<t.length;o++){const a=Xo({param:n,value:t[o]});a.dynamic&&(s=!0),i.push(a)}if(r||s){const o=Qo(i);if(r){const a=ke(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?vr([a,o]):a}}if(s)return{dynamic:!0,encoded:o}}return{dynamic:!1,encoded:vr(i.map(({encoded:o})=>o))}}function dg(t,{param:e}){const[,n]=e.type.split("bytes"),r=bt(t);if(!n){let s=t;return r%32!==0&&(s=Mn(s,{dir:"right",size:Math.ceil((t.length-2)/2/32)*32})),{dynamic:!0,encoded:vr([Mn(ke(r,{size:32})),s])}}if(r!==Number.parseInt(n,10))throw new nm({expectedSize:Number.parseInt(n,10),value:t});return{dynamic:!1,encoded:Mn(t,{dir:"right"})}}function lg(t){if(typeof t!="boolean")throw new ue(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Mn(fd(t))}}function fg(t,{signed:e,size:n=256}){if(typeof n=="number"){const r=2n**(BigInt(n)-(e?1n:0n))-1n,s=e?-r-1n:0n;if(t>r||t<s)throw new ld({max:r.toString(),min:s.toString(),signed:e,size:n/8,value:t.toString()})}return{dynamic:!1,encoded:ke(t,{size:32,signed:e})}}function hg(t){const e=jo(t),n=Math.ceil(bt(e)/32),r=[];for(let s=0;s<n;s++)r.push(Mn(di(e,s*32,(s+1)*32),{dir:"right"}));return{dynamic:!0,encoded:vr([Mn(ke(bt(e),{size:32})),...r])}}function pg(t,{param:e}){let n=!1;const r=[];for(let s=0;s<e.components.length;s++){const i=e.components[s],o=Array.isArray(t)?s:i.name,a=Xo({param:i,value:t[o]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?Qo(r):vr(r.map(({encoded:s})=>s))}}function ea(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}function mg(t,e){const n=typeof e=="string"?en(e):e,r=Yo(n);if(bt(n)===0&&t.length>0)throw new $o;if(bt(e)&&bt(e)<32)throw new em({data:typeof e=="string"?e:zt(e),params:t,size:bt(e)});let s=0;const i=[];for(let o=0;o<t.length;++o){const a=t[o];r.setPosition(s);const[d,m]=Rr(r,a,{staticPosition:0});s+=m,i.push(d)}return i}function Rr(t,e,{staticPosition:n}){const r=ea(e.type);if(r){const[s,i]=r;return yg(t,{...e,type:i},{length:s,staticPosition:n})}if(e.type==="tuple")return Eg(t,e,{staticPosition:n});if(e.type==="address")return gg(t);if(e.type==="bool")return bg(t);if(e.type.startsWith("bytes"))return _g(t,e,{staticPosition:n});if(e.type.startsWith("uint")||e.type.startsWith("int"))return wg(t,e);if(e.type==="string")return vg(t,{staticPosition:n});throw new om(e.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Md=32,ta=32;function gg(t){const e=t.readBytes(32);return[ci(zt(Cd(e,-20))),32]}function yg(t,e,{length:n,staticPosition:r}){if(!n){const o=_n(t.readBytes(ta)),a=r+o,d=a+Md;t.setPosition(a);const m=_n(t.readBytes(Md)),g=rs(e);let x=0;const O=[];for(let N=0;N<m;++N){t.setPosition(d+(g?N*32:x));const[F,C]=Rr(t,e,{staticPosition:d});x+=C,O.push(F)}return t.setPosition(r+32),[O,32]}if(rs(e)){const o=_n(t.readBytes(ta)),a=r+o,d=[];for(let m=0;m<n;++m){t.setPosition(a+m*32);const[g]=Rr(t,e,{staticPosition:a});d.push(g)}return t.setPosition(r+32),[d,32]}let s=0;const i=[];for(let o=0;o<n;++o){const[a,d]=Rr(t,e,{staticPosition:r+s});s+=d,i.push(a)}return[i,s]}function bg(t){return[ng(t.readBytes(32),{size:32}),32]}function _g(t,e,{staticPosition:n}){const[r,s]=e.type.split("bytes");if(!s){const o=_n(t.readBytes(32));t.setPosition(n+o);const a=_n(t.readBytes(32));if(a===0)return t.setPosition(n+32),["0x",32];const d=t.readBytes(a);return t.setPosition(n+32),[zt(d),32]}return[zt(t.readBytes(Number.parseInt(s,10),32)),32]}function wg(t,e){const n=e.type.startsWith("int"),r=Number.parseInt(e.type.split("int")[1]||"256",10),s=t.readBytes(32);return[r>48?tg(s,{signed:n}):_n(s,{signed:n}),32]}function Eg(t,e,{staticPosition:n}){const r=e.components.length===0||e.components.some(({name:o})=>!o),s=r?[]:{};let i=0;if(rs(e)){const o=_n(t.readBytes(ta)),a=n+o;for(let d=0;d<e.components.length;++d){const m=e.components[d];t.setPosition(a+i);const[g,x]=Rr(t,m,{staticPosition:a});i+=x,s[r?d:m?.name]=g}return t.setPosition(n+32),[s,32]}for(let o=0;o<e.components.length;++o){const a=e.components[o],[d,m]=Rr(t,a,{staticPosition:n});s[r?o:a?.name]=d,i+=m}return[s,i]}function vg(t,{staticPosition:e}){const n=_n(t.readBytes(32)),r=e+n;t.setPosition(r);const s=_n(t.readBytes(32));if(s===0)return t.setPosition(e+32),["",32];const i=t.readBytes(s,32),o=rg(Yn(i));return t.setPosition(e+32),[o,32]}function rs(t){const{type:e}=t;if(e==="string"||e==="bytes"||e.endsWith("[]"))return!0;if(e==="tuple")return t.components?.some(rs);const n=ea(t.type);return!!(n&&rs({...t,type:n[1]}))}const Rg=t=>ai(Vo(t));function Ag(t){return Rg(t)}function xg(t,e){return t.exec(e)?.groups}const Bd=/^tuple(?<array>(\[(\d*)\])*)$/;function na(t){let e=t.type;if(Bd.test(t.type)&&"components"in t){e="(";const n=t.components.length;for(let s=0;s<n;s++){const i=t.components[s];e+=na(i),s<n-1&&(e+=", ")}const r=xg(Bd,t.type);return e+=`)${r?.array||""}`,na({...t,type:e})}return"indexed"in t&&t.indexed&&(e=`${e} indexed`),t.name?`${e} ${t.name}`:e}function ss(t){let e="";const n=t.length;for(let r=0;r<n;r++){const s=t[r];e+=na(s),r!==n-1&&(e+=", ")}return e}function Sg(t){return t.type==="function"?`function ${t.name}(${ss(t.inputs)})${t.stateMutability&&t.stateMutability!=="nonpayable"?` ${t.stateMutability}`:""}${t.outputs?.length?` returns (${ss(t.outputs)})`:""}`:t.type==="event"?`event ${t.name}(${ss(t.inputs)})`:t.type==="error"?`error ${t.name}(${ss(t.inputs)})`:t.type==="constructor"?`constructor(${ss(t.inputs)})${t.stateMutability==="payable"?" payable":""}`:t.type==="fallback"?`fallback() external${t.stateMutability==="payable"?" payable":""}`:"receive() external payable"}function Tg(t){let e=!0,n="",r=0,s="",i=!1;for(let o=0;o<t.length;o++){const a=t[o];if(["(",")",","].includes(a)&&(e=!0),a==="("&&r++,a===")"&&r--,!!e){if(r===0){if(a===" "&&["event","function",""].includes(s))s="";else if(s+=a,a===")"){i=!0;break}continue}if(a===" "){t[o-1]!==","&&n!==","&&n!==",("&&(n="",e=!1);continue}s+=a,n+=a}}if(!i)throw new ue("Unable to normalize signature.");return s}const Og=t=>{const e=typeof t=="string"?t:Sg(t);return Tg(e)};function kd(t){return Ag(Og(t))}const Ig=kd,ra=t=>di(kd(t),0,4);function Ld(t){const{abi:e,args:n=[],name:r}=t,s=Cn(r,{strict:!1}),i=e.filter(a=>s?a.type==="function"?ra(a)===r:a.type==="event"?Ig(a)===r:!1:"name"in a&&a.name===r);if(i.length===0)return;if(i.length===1)return i[0];let o;for(const a of i){if(!("inputs"in a))continue;if(!n||n.length===0){if(!a.inputs||a.inputs.length===0)return a;continue}if(!a.inputs||a.inputs.length===0||a.inputs.length!==n.length)continue;if(n.every((m,g)=>{const x="inputs"in a&&a.inputs[g];return x?sa(m,x):!1})){if(o&&"inputs"in o&&o.inputs){const m=Pd(a.inputs,o.inputs,n);if(m)throw new sm({abiItem:a,type:m[0]},{abiItem:o,type:m[1]})}o=a}}return o||i[0]}function sa(t,e){const n=typeof t,r=e.type;switch(r){case"address":return kn(t,{strict:!1});case"bool":return n==="boolean";case"function":return n==="string";case"string":return n==="string";default:return r==="tuple"&&"components"in e?Object.values(e.components).every((s,i)=>n==="object"&&sa(Object.values(t)[i],s)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?n==="number"||n==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?n==="string"||t instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)?Array.isArray(t)&&t.every(s=>sa(s,{...e,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Pd(t,e,n){for(const r in t){const s=t[r],i=e[r];if(s.type==="tuple"&&i.type==="tuple"&&"components"in s&&"components"in i)return Pd(s.components,i.components,n[r]);const o=[s.type,i.type];if(o.includes("address")&&o.includes("bytes20")?!0:o.includes("address")&&o.includes("string")?kn(n[r],{strict:!1}):o.includes("address")&&o.includes("bytes")?kn(n[r],{strict:!1}):!1)return o}}const Ud="/docs/contract/encodeFunctionData";function Ng(t){const{abi:e,args:n,functionName:r}=t;let s=e[0];if(r){const i=Ld({abi:e,args:n,name:r});if(!i)throw new ad(r,{docsPath:Ud});s=i}if(s.type!=="function")throw new ad(void 0,{docsPath:Ud});return{abi:[s],functionName:ra(mr(s))}}function Cg(t){const{args:e}=t,{abi:n,functionName:r}=t.abi.length===1&&t.functionName?.startsWith("0x")?t:Ng(t),s=n[0],i=r,o="inputs"in s&&s.inputs?og(s.inputs,e??[]):void 0;return Jo([i,o??"0x"])}class Mg extends ue{constructor({chain:e,currentChainId:n}){super(`The current chain of the wallet (id: ${n}) does not match the target chain for the transaction (id: ${e.id} – ${e.name}).`,{metaMessages:[`Current Chain ID: ${n}`,`Expected Chain ID: ${e.id} – ${e.name}`],name:"ChainMismatchError"})}}class Bg extends ue{constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(`
14
+ `),{name:"ChainNotFoundError"})}}function wn(t){return typeof t=="string"?{address:t,type:"json-rpc"}:t}const kg={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},Lg={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},Pg={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};function Ug(t){const{abi:e,data:n}=t,r=di(n,0,4);if(r==="0x")throw new $o;const i=[...e||[],Lg,Pg].find(o=>o.type==="error"&&r===ra(mr(o)));if(!i)throw new od(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:i,args:"inputs"in i&&i.inputs&&i.inputs.length>0?mg(i.inputs,di(n,4)):void 0,errorName:i.name}}const li=(t,e,n)=>JSON.stringify(t,(r,s)=>typeof s=="bigint"?s.toString():s,n);function Dd({abiItem:t,args:e,includeFunctionName:n=!0,includeName:r=!1}){if("name"in t&&"inputs"in t&&t.inputs)return`${n?t.name:""}(${t.inputs.map((s,i)=>`${r&&s.name?`${s.name}: `:""}${typeof e[i]=="object"?li(e[i]):e[i]}`).join(", ")})`}const Dg={gwei:9,wei:18},Fg={ether:-9,wei:9};function Fd(t,e){let n=t.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(e,"0");let[s,i]=[n.slice(0,n.length-e),n.slice(n.length-e)];return i=i.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${i?`.${i}`:""}`}function $d(t,e="wei"){return Fd(t,Dg[e])}function tn(t,e="wei"){return Fd(t,Fg[e])}class $g extends ue{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class zg extends ue{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function fi(t){const e=Object.entries(t).map(([r,s])=>s===void 0||s===!1?null:[r,s]).filter(Boolean),n=e.reduce((r,[s])=>Math.max(r,s.length),0);return e.map(([r,s])=>` ${`${r}:`.padEnd(n+1)} ${s}`).join(`
15
+ `)}class jg extends ue{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",fi(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class Vg extends ue{constructor(e,{account:n,docsPath:r,chain:s,data:i,gas:o,gasPrice:a,maxFeePerGas:d,maxPriorityFeePerGas:m,nonce:g,to:x,value:O}){const N=fi({chain:s&&`${s?.name} (id: ${s?.id})`,from:n?.address,to:x,value:typeof O<"u"&&`${$d(O)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:o,gasPrice:typeof a<"u"&&`${tn(a)} gwei`,maxFeePerGas:typeof d<"u"&&`${tn(d)} gwei`,maxPriorityFeePerGas:typeof m<"u"&&`${tn(m)} gwei`,nonce:g});super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Request Arguments:",N].filter(Boolean),name:"TransactionExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}const Gg=t=>t,zd=t=>t;class Hg extends ue{constructor(e,{abi:n,args:r,contractAddress:s,docsPath:i,functionName:o,sender:a}){const d=Ld({abi:n,args:r,name:o}),m=d?Dd({abiItem:d,args:r,includeFunctionName:!1,includeName:!1}):void 0,g=d?mr(d,{includeName:!0}):void 0,x=fi({address:s&&Gg(s),function:g,args:m&&m!=="()"&&`${[...Array(o?.length??0).keys()].map(()=>" ").join("")}${m}`,sender:a});super(e.shortMessage||`An unknown error occurred while executing the contract function "${o}".`,{cause:e,docsPath:i,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],x&&"Contract Call:",x].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=n,this.args=r,this.cause=e,this.contractAddress=s,this.functionName=o,this.sender=a}}class qg extends ue{constructor({abi:e,data:n,functionName:r,message:s}){let i,o,a,d;if(n&&n!=="0x")try{o=Ug({abi:e,data:n});const{abiItem:g,errorName:x,args:O}=o;if(x==="Error")d=O[0];else if(x==="Panic"){const[N]=O;d=kg[N]}else{const N=g?mr(g,{includeName:!0}):void 0,F=g&&O?Dd({abiItem:g,args:O,includeFunctionName:!1,includeName:!1}):void 0;a=[N?`Error: ${N}`:"",F&&F!=="()"?` ${[...Array(x?.length??0).keys()].map(()=>" ").join("")}${F}`:""]}}catch(g){i=g}else s&&(d=s);let m;i instanceof od&&(m=i.signature,a=[`Unable to decode signature "${m}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${m}.`]),super(d&&d!=="execution reverted"||m?[`The contract function "${r}" reverted with the following ${m?"signature":"reason"}:`,d||m].join(`
16
+ `):`The contract function "${r}" reverted.`,{cause:i,metaMessages:a,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=o,this.raw=n,this.reason=d,this.signature=m}}class Kg extends ue{constructor({functionName:e}){super(`The contract function "${e}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${e}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class Wg extends ue{constructor({data:e,message:n}){super(n||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e}}function xt(t,e,n){const r=t[e.name];if(typeof r=="function")return r;const s=t[n];return typeof s=="function"?s:i=>e(t,i)}class jd extends ue{constructor({body:e,cause:n,details:r,headers:s,status:i,url:o}){super("HTTP request failed.",{cause:n,details:r,metaMessages:[i&&`Status: ${i}`,`URL: ${zd(o)}`,e&&`Request body: ${li(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=s,this.status=i,this.url=o}}class Vd extends ue{constructor({body:e,error:n,url:r}){super("RPC Request failed.",{cause:n,details:n.message,metaMessages:[`URL: ${zd(r)}`,`Request body: ${li(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=n.code,this.data=n.data,this.url=r}}const Zg=-1;class jt extends ue{constructor(e,{code:n,docsPath:r,metaMessages:s,name:i,shortMessage:o}){super(o,{cause:e,docsPath:r,metaMessages:s||e?.metaMessages,name:i||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=i||e.name,this.code=e instanceof Vd?e.code:n??Zg}}let Ht=class extends jt{constructor(e,n){super(e,n),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n.data}};class is extends jt{constructor(e){super(e,{code:is.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(is,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class os extends jt{constructor(e){super(e,{code:os.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(os,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class as extends jt{constructor(e,{method:n}={}){super(e,{code:as.code,name:"MethodNotFoundRpcError",shortMessage:`The method${n?` "${n}"`:""} does not exist / is not available.`})}}Object.defineProperty(as,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class cs extends jt{constructor(e){super(e,{code:cs.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
17
+ `)})}}Object.defineProperty(cs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class Qn extends jt{constructor(e){super(e,{code:Qn.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(Qn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Ar extends jt{constructor(e){super(e,{code:Ar.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
18
+ `)})}}Object.defineProperty(Ar,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class us extends jt{constructor(e){super(e,{code:us.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(us,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class ds extends jt{constructor(e){super(e,{code:ds.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(ds,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class ls extends jt{constructor(e){super(e,{code:ls.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(ls,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class er extends jt{constructor(e,{method:n}={}){super(e,{code:er.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${n?` "${n}"`:""} is not supported.`})}}Object.defineProperty(er,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class xr extends jt{constructor(e){super(e,{code:xr.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(xr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class fs extends jt{constructor(e){super(e,{code:fs.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(fs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});let hi=class C0 extends Ht{constructor(e){super(e,{code:C0.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}};Object.defineProperty(hi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class hs extends Ht{constructor(e){super(e,{code:hs.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class ps extends Ht{constructor(e,{method:n}={}){super(e,{code:ps.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${n?` " ${n}"`:""}.`})}}Object.defineProperty(ps,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class ms extends Ht{constructor(e){super(e,{code:ms.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(ms,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});let ia=class M0 extends Ht{constructor(e){super(e,{code:M0.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}};Object.defineProperty(ia,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Sr extends Ht{constructor(e){super(e,{code:Sr.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Sr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class gs extends Ht{constructor(e){super(e,{code:gs.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class ys extends Ht{constructor(e){super(e,{code:ys.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(ys,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class bs extends Ht{constructor(e){super(e,{code:bs.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(bs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class _s extends Ht{constructor(e){super(e,{code:_s.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(_s,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class ws extends Ht{constructor(e){super(e,{code:ws.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(ws,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Es extends Ht{constructor(e){super(e,{code:Es.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(Es,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class vs extends Ht{constructor(e){super(e,{code:vs.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Yg extends jt{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Jg=3;function Xg(t,{abi:e,address:n,args:r,docsPath:s,functionName:i,sender:o}){const a=t instanceof Wg?t:t instanceof ue?t.walk(F=>"data"in F)||t.walk():{},{code:d,data:m,details:g,message:x,shortMessage:O}=a,N=t instanceof $o?new Kg({functionName:i}):[Jg,Qn.code].includes(d)&&(m||g||x||O)||d===Ar.code&&g==="execution reverted"&&m?new qg({abi:e,data:typeof m=="object"?m.data:m,functionName:i,message:a instanceof Vd?g:O??x}):t;return new Hg(N,{abi:e,args:r,contractAddress:n,docsPath:s,functionName:i,sender:o})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const oa=BigInt(0),aa=BigInt(1);function Rs(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ca(t){if(!Rs(t))throw new Error("Uint8Array expected")}function Ln(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function pi(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Gd(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?oa:BigInt("0x"+t)}const Hd=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Qg=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Tr(t){if(ca(t),Hd)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=Qg[t[n]];return e}const En={_0:48,_9:57,A:65,F:70,a:97,f:102};function qd(t){if(t>=En._0&&t<=En._9)return t-En._0;if(t>=En.A&&t<=En.F)return t-(En.A-10);if(t>=En.a&&t<=En.f)return t-(En.a-10)}function mi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Hd)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let s=0,i=0;s<n;s++,i+=2){const o=qd(t.charCodeAt(i)),a=qd(t.charCodeAt(i+1));if(o===void 0||a===void 0){const d=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+i)}r[s]=o*16+a}return r}function tr(t){return Gd(Tr(t))}function As(t){return ca(t),Gd(Tr(Uint8Array.from(t).reverse()))}function xs(t,e){return mi(t.toString(16).padStart(e*2,"0"))}function gi(t,e){return xs(t,e).reverse()}function Je(t,e,n){let r;if(typeof e=="string")try{r=mi(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(Rs(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(t+" of length "+n+" expected, got "+s);return r}function Or(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];ca(s),e+=s.length}const n=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const i=t[r];n.set(i,s),s+=i.length}return n}const ua=t=>typeof t=="bigint"&&oa<=t;function da(t,e,n){return ua(t)&&ua(e)&&ua(n)&&e<=t&&t<n}function nn(t,e,n,r){if(!da(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function ey(t){let e;for(e=0;t>oa;t>>=aa,e+=1);return e}const yi=t=>(aa<<BigInt(t))-aa,la=t=>new Uint8Array(t),Kd=t=>Uint8Array.from(t);function ty(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=la(t),s=la(t),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...x)=>n(s,r,...x),d=(x=la(0))=>{s=a(Kd([0]),x),r=a(),x.length!==0&&(s=a(Kd([1]),x),r=a())},m=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let x=0;const O=[];for(;x<e;){r=a();const N=r.slice();O.push(N),x+=r.length}return Or(...O)};return(x,O)=>{o(),d(x);let N;for(;!(N=O(m()));)d();return o(),N}}const ny={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Rs(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Ss(t,e,n={}){const r=(s,i,o)=>{const a=ny[i];if(typeof a!="function")throw new Error("invalid validator function");const d=t[s];if(!(o&&d===void 0)&&!a(d,t))throw new Error("param "+String(s)+" is invalid. Expected "+i+", got "+d)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(n))r(s,i,!0);return t}function bi(t){const e=new WeakMap;return(n,...r)=>{const s=e.get(n);if(s!==void 0)return s;const i=t(n,...r);return e.set(n,i),i}}class Ir extends ue{constructor({cause:e,message:n}={}){const r=n?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${r?`with reason: ${r}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Ir,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Ir,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class _i extends ue{constructor({cause:e,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${tn(n)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(_i,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class fa extends ue{constructor({cause:e,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${tn(n)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(fa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class ha extends ue{constructor({cause:e,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(ha,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class pa extends ue{constructor({cause:e,nonce:n}={}){super([`Nonce provided for the transaction ${n?`(${n}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
19
+ `),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(pa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class ma extends ue{constructor({cause:e,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(ma,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class ga extends ue{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
20
+ `),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(ga,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class ya extends ue{constructor({cause:e,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(ya,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class ba extends ue{constructor({cause:e,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(ba,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class _a extends ue{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(_a,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class wi extends ue{constructor({cause:e,maxPriorityFeePerGas:n,maxFeePerGas:r}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${n?` = ${tn(n)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r?` = ${tn(r)} gwei`:""}).`].join(`
21
+ `),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(wi,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class wa extends ue{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Wd(t,e){const n=(t.details||"").toLowerCase(),r=t instanceof ue?t.walk(s=>s?.code===Ir.code):t;return r instanceof ue?new Ir({cause:t,message:r.details}):Ir.nodeMessage.test(n)?new Ir({cause:t,message:t.details}):_i.nodeMessage.test(n)?new _i({cause:t,maxFeePerGas:e?.maxFeePerGas}):fa.nodeMessage.test(n)?new fa({cause:t,maxFeePerGas:e?.maxFeePerGas}):ha.nodeMessage.test(n)?new ha({cause:t,nonce:e?.nonce}):pa.nodeMessage.test(n)?new pa({cause:t,nonce:e?.nonce}):ma.nodeMessage.test(n)?new ma({cause:t,nonce:e?.nonce}):ga.nodeMessage.test(n)?new ga({cause:t}):ya.nodeMessage.test(n)?new ya({cause:t,gas:e?.gas}):ba.nodeMessage.test(n)?new ba({cause:t,gas:e?.gas}):_a.nodeMessage.test(n)?new _a({cause:t}):wi.nodeMessage.test(n)?new wi({cause:t,maxFeePerGas:e?.maxFeePerGas,maxPriorityFeePerGas:e?.maxPriorityFeePerGas}):new wa({cause:t})}function Ea(t,{format:e}){if(!e)return{};const n={};function r(i){const o=Object.keys(i);for(const a of o)a in t&&(n[a]=t[a]),i[a]&&typeof i[a]=="object"&&!Array.isArray(i[a])&&r(i[a])}const s=e(t||{});return r(s),n}const ry={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function va(t,e){const n={};return typeof t.authorizationList<"u"&&(n.authorizationList=sy(t.authorizationList)),typeof t.accessList<"u"&&(n.accessList=t.accessList),typeof t.blobVersionedHashes<"u"&&(n.blobVersionedHashes=t.blobVersionedHashes),typeof t.blobs<"u"&&(typeof t.blobs[0]!="string"?n.blobs=t.blobs.map(r=>zt(r)):n.blobs=t.blobs),typeof t.data<"u"&&(n.data=t.data),t.account&&(n.from=t.account.address),typeof t.from<"u"&&(n.from=t.from),typeof t.gas<"u"&&(n.gas=ke(t.gas)),typeof t.gasPrice<"u"&&(n.gasPrice=ke(t.gasPrice)),typeof t.maxFeePerBlobGas<"u"&&(n.maxFeePerBlobGas=ke(t.maxFeePerBlobGas)),typeof t.maxFeePerGas<"u"&&(n.maxFeePerGas=ke(t.maxFeePerGas)),typeof t.maxPriorityFeePerGas<"u"&&(n.maxPriorityFeePerGas=ke(t.maxPriorityFeePerGas)),typeof t.nonce<"u"&&(n.nonce=ke(t.nonce)),typeof t.to<"u"&&(n.to=t.to),typeof t.type<"u"&&(n.type=ry[t.type]),typeof t.value<"u"&&(n.value=ke(t.value)),n}function sy(t){return t.map(e=>({address:e.address,r:e.r?ke(BigInt(e.r)):e.r,s:e.s?ke(BigInt(e.s)):e.s,chainId:ke(e.chainId),nonce:ke(e.nonce),...typeof e.yParity<"u"?{yParity:ke(e.yParity)}:{},...typeof e.v<"u"&&typeof e.yParity>"u"?{v:ke(e.v)}:{}}))}function Zd(t){if(!(!t||t.length===0))return t.reduce((e,{slot:n,value:r})=>{if(n.length!==66)throw new dd({size:n.length,targetSize:66,type:"hex"});if(r.length!==66)throw new dd({size:r.length,targetSize:66,type:"hex"});return e[n]=r,e},{})}function iy(t){const{balance:e,nonce:n,state:r,stateDiff:s,code:i}=t,o={};if(i!==void 0&&(o.code=i),e!==void 0&&(o.balance=ke(e)),n!==void 0&&(o.nonce=ke(n)),r!==void 0&&(o.state=Zd(r)),s!==void 0){if(o.state)throw new zg;o.stateDiff=Zd(s)}return o}function oy(t){if(!t)return;const e={};for(const{address:n,...r}of t){if(!kn(n,{strict:!1}))throw new Qr({address:n});if(e[n])throw new $g({address:n});e[n]=iy(r)}return e}const ay=2n**256n-1n;function Ei(t){const{account:e,maxFeePerGas:n,maxPriorityFeePerGas:r,to:s}=t,i=e?wn(e):void 0;if(i&&!kn(i.address))throw new Qr({address:i.address});if(s&&!kn(s))throw new Qr({address:s});if(n&&n>ay)throw new _i({maxFeePerGas:n});if(r&&n&&r>n)throw new wi({maxFeePerGas:n,maxPriorityFeePerGas:r})}function cy(t){const e=ai(`0x${t.substring(4)}`).substring(26);return ci(`0x${e}`)}async function uy({hash:t,signature:e}){const n=Cn(t)?t:zo(t),{secp256k1:r}=await Promise.resolve().then(()=>y1);return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:m,s:g,v:x,yParity:O}=e,N=Number(O??x),F=Yd(N);return new r.Signature(yr(m),yr(g)).addRecoveryBit(F)}const o=Cn(e)?e:zo(e);if(bt(o)!==65)throw new Error("invalid signature length");const a=Jn(`0x${o.slice(130)}`),d=Yd(a);return r.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(d)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}function Yd(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function dy({hash:t,signature:e}){return cy(await uy({hash:t,signature:e}))}function ly(t,e="hex"){const n=Jd(t),r=Yo(new Uint8Array(n.length));return n.encode(r),e==="hex"?zt(r.bytes):r.bytes}function Jd(t){return Array.isArray(t)?fy(t.map(e=>Jd(e))):hy(t)}function fy(t){const e=t.reduce((s,i)=>s+i.length,0),n=Xd(e);return{length:e<=55?1+e:1+n+e,encode(s){e<=55?s.pushByte(192+e):(s.pushByte(247+n),n===1?s.pushUint8(e):n===2?s.pushUint16(e):n===3?s.pushUint24(e):s.pushUint32(e));for(const{encode:i}of t)i(s)}}}function hy(t){const e=typeof t=="string"?en(t):t,n=Xd(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+n+e.length,encode(s){e.length===1&&e[0]<128?s.pushBytes(e):e.length<=55?(s.pushByte(128+e.length),s.pushBytes(e)):(s.pushByte(183+n),n===1?s.pushUint8(e.length):n===2?s.pushUint16(e.length):n===3?s.pushUint24(e.length):s.pushUint32(e.length),s.pushBytes(e))}}}function Xd(t){if(t<2**8)return 1;if(t<2**16)return 2;if(t<2**24)return 3;if(t<2**32)return 4;throw new ue("Length is too large.")}function py(t){const{chainId:e,nonce:n,to:r}=t,s=t.contractAddress??t.address,i=ai(Jo(["0x05",ly([e?ke(e):"0x",s,n?ke(n):"0x"])]));return r==="bytes"?en(i):i}async function Qd(t){const{authorization:e,signature:n}=t;return dy({hash:py(e),signature:n??e})}class my extends ue{constructor(e,{account:n,docsPath:r,chain:s,data:i,gas:o,gasPrice:a,maxFeePerGas:d,maxPriorityFeePerGas:m,nonce:g,to:x,value:O}){const N=fi({from:n?.address,to:x,value:typeof O<"u"&&`${$d(O)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:o,gasPrice:typeof a<"u"&&`${tn(a)} gwei`,maxFeePerGas:typeof d<"u"&&`${tn(d)} gwei`,maxPriorityFeePerGas:typeof m<"u"&&`${tn(m)} gwei`,nonce:g});super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Estimate Gas Arguments:",N].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}function gy(t,{docsPath:e,...n}){const r=(()=>{const s=Wd(t,n);return s instanceof wa?t:s})();return new my(r,{docsPath:e,...n})}class el extends ue{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class Ra extends ue{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class yy extends ue{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${tn(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class by extends ue{constructor({blockHash:e,blockNumber:n}){let r="Block";e&&(r=`Block at hash "${e}"`),n&&(r=`Block at number "${n}"`),super(`${r} could not be found.`,{name:"BlockNotFoundError"})}}const _y={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function tl(t,e){const n={...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,chainId:t.chainId?Jn(t.chainId):void 0,gas:t.gas?BigInt(t.gas):void 0,gasPrice:t.gasPrice?BigInt(t.gasPrice):void 0,maxFeePerBlobGas:t.maxFeePerBlobGas?BigInt(t.maxFeePerBlobGas):void 0,maxFeePerGas:t.maxFeePerGas?BigInt(t.maxFeePerGas):void 0,maxPriorityFeePerGas:t.maxPriorityFeePerGas?BigInt(t.maxPriorityFeePerGas):void 0,nonce:t.nonce?Jn(t.nonce):void 0,to:t.to?t.to:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,type:t.type?_y[t.type]:void 0,typeHex:t.type?t.type:void 0,value:t.value?BigInt(t.value):void 0,v:t.v?BigInt(t.v):void 0};return t.authorizationList&&(n.authorizationList=wy(t.authorizationList)),n.yParity=(()=>{if(t.yParity)return Number(t.yParity);if(typeof n.v=="bigint"){if(n.v===0n||n.v===27n)return 0;if(n.v===1n||n.v===28n)return 1;if(n.v>=35n)return n.v%2n===0n?1:0}})(),n.type==="legacy"&&(delete n.accessList,delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas,delete n.yParity),n.type==="eip2930"&&(delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas),n.type==="eip1559"&&delete n.maxFeePerBlobGas,n}function wy(t){return t.map(e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))}function Ey(t,e){const n=(t.transactions??[]).map(r=>typeof r=="string"?r:tl(r));return{...t,baseFeePerGas:t.baseFeePerGas?BigInt(t.baseFeePerGas):null,blobGasUsed:t.blobGasUsed?BigInt(t.blobGasUsed):void 0,difficulty:t.difficulty?BigInt(t.difficulty):void 0,excessBlobGas:t.excessBlobGas?BigInt(t.excessBlobGas):void 0,gasLimit:t.gasLimit?BigInt(t.gasLimit):void 0,gasUsed:t.gasUsed?BigInt(t.gasUsed):void 0,hash:t.hash?t.hash:null,logsBloom:t.logsBloom?t.logsBloom:null,nonce:t.nonce?t.nonce:null,number:t.number?BigInt(t.number):null,size:t.size?BigInt(t.size):void 0,timestamp:t.timestamp?BigInt(t.timestamp):void 0,transactions:n,totalDifficulty:t.totalDifficulty?BigInt(t.totalDifficulty):null}}async function Ts(t,{blockHash:e,blockNumber:n,blockTag:r=t.experimental_blockTag??"latest",includeTransactions:s}={}){const i=s??!1,o=n!==void 0?ke(n):void 0;let a=null;if(e?a=await t.request({method:"eth_getBlockByHash",params:[e,i]},{dedupe:!0}):a=await t.request({method:"eth_getBlockByNumber",params:[o||r,i]},{dedupe:!!o}),!a)throw new by({blockHash:e,blockNumber:n});return(t.chain?.formatters?.block?.format||Ey)(a,"getBlock")}async function nl(t){const e=await t.request({method:"eth_gasPrice"});return BigInt(e)}async function vy(t,e){const{block:n,chain:r=t.chain,request:s}=e||{};try{const i=r?.fees?.maxPriorityFeePerGas??r?.fees?.defaultPriorityFee;if(typeof i=="function"){const a=n||await xt(t,Ts,"getBlock")({}),d=await i({block:a,client:t,request:s});if(d===null)throw new Error;return d}if(typeof i<"u")return i;const o=await t.request({method:"eth_maxPriorityFeePerGas"});return yr(o)}catch{const[i,o]=await Promise.all([n?Promise.resolve(n):xt(t,Ts,"getBlock")({}),xt(t,nl,"getGasPrice")({})]);if(typeof i.baseFeePerGas!="bigint")throw new Ra;const a=o-i.baseFeePerGas;return a<0n?0n:a}}async function rl(t,e){const{block:n,chain:r=t.chain,request:s,type:i="eip1559"}=e||{},o=await(async()=>typeof r?.fees?.baseFeeMultiplier=="function"?r.fees.baseFeeMultiplier({block:n,client:t,request:s}):r?.fees?.baseFeeMultiplier??1.2)();if(o<1)throw new el;const d=10**(o.toString().split(".")[1]?.length??0),m=O=>O*BigInt(Math.ceil(o*d))/BigInt(d),g=n||await xt(t,Ts,"getBlock")({});if(typeof r?.fees?.estimateFeesPerGas=="function"){const O=await r.fees.estimateFeesPerGas({block:n,client:t,multiply:m,request:s,type:i});if(O!==null)return O}if(i==="eip1559"){if(typeof g.baseFeePerGas!="bigint")throw new Ra;const O=typeof s?.maxPriorityFeePerGas=="bigint"?s.maxPriorityFeePerGas:await vy(t,{block:g,chain:r,request:s}),N=m(g.baseFeePerGas);return{maxFeePerGas:s?.maxFeePerGas??N+O,maxPriorityFeePerGas:O}}return{gasPrice:s?.gasPrice??m(await xt(t,nl,"getGasPrice")({}))}}async function Ry(t,{address:e,blockTag:n="latest",blockNumber:r}){const s=await t.request({method:"eth_getTransactionCount",params:[e,typeof r=="bigint"?ke(r):n]},{dedupe:!!r});return Jn(s)}function sl(t){const{kzg:e}=t,n=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),r=typeof t.blobs[0]=="string"?t.blobs.map(i=>en(i)):t.blobs,s=[];for(const i of r)s.push(Uint8Array.from(e.blobToKzgCommitment(i)));return n==="bytes"?s:s.map(i=>zt(i))}function il(t){const{kzg:e}=t,n=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),r=typeof t.blobs[0]=="string"?t.blobs.map(o=>en(o)):t.blobs,s=typeof t.commitments[0]=="string"?t.commitments.map(o=>en(o)):t.commitments,i=[];for(let o=0;o<r.length;o++){const a=r[o],d=s[o];i.push(Uint8Array.from(e.computeBlobKzgProof(a,d)))}return n==="bytes"?i:i.map(o=>zt(o))}function Ay(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),d=r?4:0,m=r?0:4;t.setUint32(e+d,o,r),t.setUint32(e+m,a,r)}function xy(t,e,n){return t&e^~t&n}function Sy(t,e,n){return t&e^t&n^e&n}class ol extends Ho{constructor(e,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(e),this.view=Go(this.buffer)}update(e){Er(this),e=oi(e),Xn(e);const{view:n,buffer:r,blockLen:s}=this,i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const d=Go(e);for(;s<=i-o;o+=s)this.process(d,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Er(this),_d(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;n[o++]=128,Bn(this.buffer.subarray(o)),this.padOffset>s-o&&(this.process(r,0),o=0);for(let x=o;x<s;x++)n[x]=0;Ay(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Go(e),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const m=d/4,g=this.get();if(m>g.length)throw new Error("_sha2: outputLen bigger than state");for(let x=0;x<m;x++)a.setUint32(4*x,g[x],i)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=i,e.length=s,e.pos=a,s%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const Pn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),St=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Ty=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Un=new Uint32Array(64);class Oy extends ol{constructor(e=32){super(64,e,8,!1),this.A=Pn[0]|0,this.B=Pn[1]|0,this.C=Pn[2]|0,this.D=Pn[3]|0,this.E=Pn[4]|0,this.F=Pn[5]|0,this.G=Pn[6]|0,this.H=Pn[7]|0}get(){const{A:e,B:n,C:r,D:s,E:i,F:o,G:a,H:d}=this;return[e,n,r,s,i,o,a,d]}set(e,n,r,s,i,o,a,d){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=d|0}process(e,n){for(let x=0;x<16;x++,n+=4)Un[x]=e.getUint32(n,!1);for(let x=16;x<64;x++){const O=Un[x-15],N=Un[x-2],F=un(O,7)^un(O,18)^O>>>3,C=un(N,17)^un(N,19)^N>>>10;Un[x]=C+Un[x-7]+F+Un[x-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:d,G:m,H:g}=this;for(let x=0;x<64;x++){const O=un(a,6)^un(a,11)^un(a,25),N=g+O+xy(a,d,m)+Ty[x]+Un[x]|0,C=(un(r,2)^un(r,13)^un(r,22))+Sy(r,s,i)|0;g=m,m=d,d=a,a=o+N|0,o=i,i=s,s=r,r=N+C|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,d=d+this.F|0,m=m+this.G|0,g=g+this.H|0,this.set(r,s,i,o,a,d,m,g)}roundClean(){Bn(Un)}destroy(){this.set(0,0,0,0,0,0,0,0),Bn(this.buffer)}}const al=gd(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Iy=al[0],Ny=al[1],Dn=new Uint32Array(80),Fn=new Uint32Array(80);class Cy extends ol{constructor(e=64){super(128,e,16,!1),this.Ah=St[0]|0,this.Al=St[1]|0,this.Bh=St[2]|0,this.Bl=St[3]|0,this.Ch=St[4]|0,this.Cl=St[5]|0,this.Dh=St[6]|0,this.Dl=St[7]|0,this.Eh=St[8]|0,this.El=St[9]|0,this.Fh=St[10]|0,this.Fl=St[11]|0,this.Gh=St[12]|0,this.Gl=St[13]|0,this.Hh=St[14]|0,this.Hl=St[15]|0}get(){const{Ah:e,Al:n,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:d,Eh:m,El:g,Fh:x,Fl:O,Gh:N,Gl:F,Hh:C,Hl:k}=this;return[e,n,r,s,i,o,a,d,m,g,x,O,N,F,C,k]}set(e,n,r,s,i,o,a,d,m,g,x,O,N,F,C,k){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=d|0,this.Eh=m|0,this.El=g|0,this.Fh=x|0,this.Fl=O|0,this.Gh=N|0,this.Gl=F|0,this.Hh=C|0,this.Hl=k|0}process(e,n){for(let V=0;V<16;V++,n+=4)Dn[V]=e.getUint32(n),Fn[V]=e.getUint32(n+=4);for(let V=16;V<80;V++){const L=Dn[V-15]|0,z=Fn[V-15]|0,J=br(L,z,1)^br(L,z,8)^yd(L,z,7),te=_r(L,z,1)^_r(L,z,8)^bd(L,z,7),ne=Dn[V-2]|0,q=Fn[V-2]|0,B=br(ne,q,19)^si(ne,q,61)^yd(ne,q,6),P=_r(ne,q,19)^ii(ne,q,61)^bd(ne,q,6),j=Om(te,P,Fn[V-7],Fn[V-16]),E=Im(j,J,B,Dn[V-7],Dn[V-16]);Dn[V]=E|0,Fn[V]=j|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:d,Dh:m,Dl:g,Eh:x,El:O,Fh:N,Fl:F,Gh:C,Gl:k,Hh:K,Hl:Y}=this;for(let V=0;V<80;V++){const L=br(x,O,14)^br(x,O,18)^si(x,O,41),z=_r(x,O,14)^_r(x,O,18)^ii(x,O,41),J=x&N^~x&C,te=O&F^~O&k,ne=Nm(Y,z,te,Ny[V],Fn[V]),q=Cm(ne,K,L,J,Iy[V],Dn[V]),B=ne|0,P=br(r,s,28)^si(r,s,34)^si(r,s,39),j=_r(r,s,28)^ii(r,s,34)^ii(r,s,39),E=r&i^r&a^i&a,c=s&o^s&d^o&d;K=C|0,Y=k|0,C=N|0,k=F|0,N=x|0,F=O|0,{h:x,l:O}=bn(m|0,g|0,q|0,B|0),m=a|0,g=d|0,a=i|0,d=o|0,i=r|0,o=s|0;const p=Sm(B,j,c);r=Tm(p,q,P,E),s=p|0}({h:r,l:s}=bn(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=bn(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:d}=bn(this.Ch|0,this.Cl|0,a|0,d|0),{h:m,l:g}=bn(this.Dh|0,this.Dl|0,m|0,g|0),{h:x,l:O}=bn(this.Eh|0,this.El|0,x|0,O|0),{h:N,l:F}=bn(this.Fh|0,this.Fl|0,N|0,F|0),{h:C,l:k}=bn(this.Gh|0,this.Gl|0,C|0,k|0),{h:K,l:Y}=bn(this.Hh|0,this.Hl|0,K|0,Y|0),this.set(r,s,i,o,a,d,m,g,x,O,N,F,C,k,K,Y)}roundClean(){Bn(Dn,Fn)}destroy(){Bn(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const cl=qo(()=>new Oy),My=qo(()=>new Cy),Aa=cl;function By(t,e){return Aa(Cn(t,{strict:!1})?Vo(t):t)}function ky(t){const{commitment:e,version:n=1}=t,r=t.to??(typeof e=="string"?"hex":"bytes"),s=By(e);return s.set([n],0),r==="bytes"?s:zt(s)}function Ly(t){const{commitments:e,version:n}=t,r=t.to,s=[];for(const i of e)s.push(ky({commitment:i,to:r,version:n}));return s}const ul=6,dl=32,xa=4096,ll=dl*xa,fl=ll*ul-1-1*xa*ul;class Py extends ue{constructor({maxSize:e,size:n}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${n} bytes`],name:"BlobSizeTooLargeError"})}}class Uy extends ue{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function Dy(t){const e=typeof t.data=="string"?en(t.data):t.data,n=bt(e);if(!n)throw new Uy;if(n>fl)throw new Py({maxSize:fl,size:n});const r=[];let s=!0,i=0;for(;s;){const o=Yo(new Uint8Array(ll));let a=0;for(;a<xa;){const d=e.slice(i,i+(dl-1));if(o.pushByte(0),o.pushBytes(d),d.length<31){o.pushByte(128),s=!1;break}a++,i+=31}r.push(o)}return r.map(o=>zt(o.bytes))}function Fy(t){const{data:e,kzg:n,to:r}=t,s=t.blobs??Dy({data:e}),i=t.commitments??sl({blobs:s,kzg:n,to:r}),o=t.proofs??il({blobs:s,commitments:i,kzg:n,to:r}),a=[];for(let d=0;d<s.length;d++)a.push({blob:s[d],commitment:i[d],proof:o[d]});return a}function $y(t){if(t.type)return t.type;if(typeof t.authorizationList<"u")return"eip7702";if(typeof t.blobs<"u"||typeof t.blobVersionedHashes<"u"||typeof t.maxFeePerBlobGas<"u"||typeof t.sidecars<"u")return"eip4844";if(typeof t.maxFeePerGas<"u"||typeof t.maxPriorityFeePerGas<"u")return"eip1559";if(typeof t.gasPrice<"u")return typeof t.accessList<"u"?"eip2930":"legacy";throw new jg({transaction:t})}function hl(t,{docsPath:e,...n}){const r=(()=>{const s=Wd(t,n);return s instanceof wa?t:s})();return new Vg(r,{docsPath:e,...n})}async function Sa(t){const e=await t.request({method:"eth_chainId"},{dedupe:!0});return Jn(e)}async function zy(t,e){const{account:n=t.account,accessList:r,authorizationList:s,chain:i=t.chain,blobVersionedHashes:o,blobs:a,data:d,gas:m,gasPrice:g,maxFeePerBlobGas:x,maxFeePerGas:O,maxPriorityFeePerGas:N,nonce:F,nonceManager:C,to:k,type:K,value:Y,...V}=e,L=await(async()=>{if(!n||!C||typeof F<"u")return F;const ne=wn(n),q=i?i.id:await xt(t,Sa,"getChainId")({});return await C.consume({address:ne.address,chainId:q,client:t})})();Ei(e);const z=i?.formatters?.transactionRequest?.format,te=(z||va)({...Ea(V,{format:z}),account:n?wn(n):void 0,accessList:r,authorizationList:s,blobs:a,blobVersionedHashes:o,data:d,gas:m,gasPrice:g,maxFeePerBlobGas:x,maxFeePerGas:O,maxPriorityFeePerGas:N,nonce:L,to:k,type:K,value:Y},"fillTransaction");try{const ne=await t.request({method:"eth_fillTransaction",params:[te]}),B=(i?.formatters?.transaction?.format||tl)(ne.tx);delete B.blockHash,delete B.blockNumber,delete B.r,delete B.s,delete B.transactionIndex,delete B.v,delete B.yParity,B.data=B.input,B.gas&&(B.gas=e.gas??B.gas),B.gasPrice&&(B.gasPrice=e.gasPrice??B.gasPrice),B.maxFeePerBlobGas&&(B.maxFeePerBlobGas=e.maxFeePerBlobGas??B.maxFeePerBlobGas),B.maxFeePerGas&&(B.maxFeePerGas=e.maxFeePerGas??B.maxFeePerGas),B.maxPriorityFeePerGas&&(B.maxPriorityFeePerGas=e.maxPriorityFeePerGas??B.maxPriorityFeePerGas),B.nonce&&(B.nonce=e.nonce??B.nonce);const P=await(async()=>{if(typeof i?.fees?.baseFeeMultiplier=="function"){const p=await xt(t,Ts,"getBlock")({});return i.fees.baseFeeMultiplier({block:p,client:t,request:e})}return i?.fees?.baseFeeMultiplier??1.2})();if(P<1)throw new el;const E=10**(P.toString().split(".")[1]?.length??0),c=p=>p*BigInt(Math.ceil(P*E))/BigInt(E);return B.maxFeePerGas&&!e.maxFeePerGas&&(B.maxFeePerGas=c(B.maxFeePerGas)),B.gasPrice&&!e.gasPrice&&(B.gasPrice=c(B.gasPrice)),{raw:ne.raw,transaction:{from:te.from,...B}}}catch(ne){throw hl(ne,{...e,chain:t.chain})}}const pl=["blobVersionedHashes","chainId","fees","gas","nonce","type"],ml=new Map,Ta=new ns(128);async function gl(t,e){let n=e;n.account??=t.account,n.parameters??=pl;const{account:r,chain:s=t.chain,nonceManager:i,parameters:o}=n,a=(()=>{if(typeof s?.prepareTransactionRequest=="function")return{fn:s.prepareTransactionRequest,runAt:["beforeFillTransaction"]};if(Array.isArray(s?.prepareTransactionRequest))return{fn:s.prepareTransactionRequest[0],runAt:s.prepareTransactionRequest[1].runAt}})();let d;async function m(){return d||(typeof n.chainId<"u"?n.chainId:s?s.id:(d=await xt(t,Sa,"getChainId")({}),d))}const g=r&&wn(r);let x=n.nonce;if(o.includes("nonce")&&typeof x>"u"&&g&&i){const L=await m();x=await i.consume({address:g.address,chainId:L,client:t})}a?.fn&&a.runAt?.includes("beforeFillTransaction")&&(n=await a.fn({...n,chain:s},{phase:"beforeFillTransaction"}),x??=n.nonce);const N=((o.includes("blobVersionedHashes")||o.includes("sidecars"))&&n.kzg&&n.blobs||Ta.get(t.uid)===!1||!["fees","gas"].some(z=>o.includes(z))?!1:!!(o.includes("chainId")&&typeof n.chainId!="number"||o.includes("nonce")&&typeof x!="number"||o.includes("fees")&&typeof n.gasPrice!="bigint"&&(typeof n.maxFeePerGas!="bigint"||typeof n.maxPriorityFeePerGas!="bigint")||o.includes("gas")&&typeof n.gas!="bigint"))?await xt(t,zy,"fillTransaction")({...n,nonce:x}).then(L=>{const{chainId:z,from:J,gas:te,gasPrice:ne,nonce:q,maxFeePerBlobGas:B,maxFeePerGas:P,maxPriorityFeePerGas:j,type:E,...c}=L.transaction;return Ta.set(t.uid,!0),{...n,...J?{from:J}:{},...E?{type:E}:{},...typeof z<"u"?{chainId:z}:{},...typeof te<"u"?{gas:te}:{},...typeof ne<"u"?{gasPrice:ne}:{},...typeof q<"u"?{nonce:q}:{},...typeof B<"u"?{maxFeePerBlobGas:B}:{},...typeof P<"u"?{maxFeePerGas:P}:{},...typeof j<"u"?{maxPriorityFeePerGas:j}:{},..."nonceKey"in c&&typeof c.nonceKey<"u"?{nonceKey:c.nonceKey}:{}}}).catch(L=>{const z=L;return z.name!=="TransactionExecutionError"||z.walk?.(te=>{const ne=te;return ne.name==="MethodNotFoundRpcError"||ne.name==="MethodNotSupportedRpcError"})&&Ta.set(t.uid,!1),n}):n;x??=N.nonce,n={...N,...g?{from:g?.address}:{},...x?{nonce:x}:{}};const{blobs:F,gas:C,kzg:k,type:K}=n;a?.fn&&a.runAt?.includes("beforeFillParameters")&&(n=await a.fn({...n,chain:s},{phase:"beforeFillParameters"}));let Y;async function V(){return Y||(Y=await xt(t,Ts,"getBlock")({blockTag:"latest"}),Y)}if(o.includes("nonce")&&typeof x>"u"&&g&&!i&&(n.nonce=await xt(t,Ry,"getTransactionCount")({address:g.address,blockTag:"pending"})),(o.includes("blobVersionedHashes")||o.includes("sidecars"))&&F&&k){const L=sl({blobs:F,kzg:k});if(o.includes("blobVersionedHashes")){const z=Ly({commitments:L,to:"hex"});n.blobVersionedHashes=z}if(o.includes("sidecars")){const z=il({blobs:F,commitments:L,kzg:k}),J=Fy({blobs:F,commitments:L,proofs:z,to:"hex"});n.sidecars=J}}if(o.includes("chainId")&&(n.chainId=await m()),(o.includes("fees")||o.includes("type"))&&typeof K>"u")try{n.type=$y(n)}catch{let L=ml.get(t.uid);typeof L>"u"&&(L=typeof(await V())?.baseFeePerGas=="bigint",ml.set(t.uid,L)),n.type=L?"eip1559":"legacy"}if(o.includes("fees"))if(n.type!=="legacy"&&n.type!=="eip2930"){if(typeof n.maxFeePerGas>"u"||typeof n.maxPriorityFeePerGas>"u"){const L=await V(),{maxFeePerGas:z,maxPriorityFeePerGas:J}=await rl(t,{block:L,chain:s,request:n});if(typeof n.maxPriorityFeePerGas>"u"&&n.maxFeePerGas&&n.maxFeePerGas<J)throw new yy({maxPriorityFeePerGas:J});n.maxPriorityFeePerGas=J,n.maxFeePerGas=z}}else{if(typeof n.maxFeePerGas<"u"||typeof n.maxPriorityFeePerGas<"u")throw new Ra;if(typeof n.gasPrice>"u"){const L=await V(),{gasPrice:z}=await rl(t,{block:L,chain:s,request:n,type:"legacy"});n.gasPrice=z}}return o.includes("gas")&&typeof C>"u"&&(n.gas=await xt(t,jy,"estimateGas")({...n,account:g,prepare:g?.type==="local"?[]:["blobVersionedHashes"]})),a?.fn&&a.runAt?.includes("afterFillParameters")&&(n=await a.fn({...n,chain:s},{phase:"afterFillParameters"})),Ei(n),delete n.parameters,n}async function jy(t,e){const{account:n=t.account,prepare:r=!0}=e,s=n?wn(n):void 0,i=(()=>{if(Array.isArray(r))return r;if(s?.type!=="local")return["blobVersionedHashes"]})();try{const o=await(async()=>{if(e.to)return e.to;if(e.authorizationList&&e.authorizationList.length>0)return await Qd({authorization:e.authorizationList[0]}).catch(()=>{throw new ue("`to` is required. Could not infer from `authorizationList`")})})(),{accessList:a,authorizationList:d,blobs:m,blobVersionedHashes:g,blockNumber:x,blockTag:O,data:N,gas:F,gasPrice:C,maxFeePerBlobGas:k,maxFeePerGas:K,maxPriorityFeePerGas:Y,nonce:V,value:L,stateOverride:z,...J}=r?await gl(t,{...e,parameters:i,to:o}):e;if(F&&e.gas!==F)return F;const ne=(typeof x=="bigint"?ke(x):void 0)||O,q=oy(z);Ei(e);const B=t.chain?.formatters?.transactionRequest?.format,j=(B||va)({...Ea(J,{format:B}),account:s,accessList:a,authorizationList:d,blobs:m,blobVersionedHashes:g,data:N,gasPrice:C,maxFeePerBlobGas:k,maxFeePerGas:K,maxPriorityFeePerGas:Y,nonce:V,to:o,value:L},"estimateGas");return BigInt(await t.request({method:"eth_estimateGas",params:q?[j,ne??t.experimental_blockTag??"latest",q]:ne?[j,ne]:[j]}))}catch(o){throw gy(o,{...e,account:s,chain:t.chain})}}const vi=new ns(8192);function Vy(t,{enabled:e=!0,id:n}){if(!e||!n)return t();if(vi.get(n))return vi.get(n);const r=t().finally(()=>vi.delete(n));return vi.set(n,r),r}async function Gy(t){return new Promise(e=>setTimeout(e,t))}function Hy(t,{delay:e=100,retryCount:n=2,shouldRetry:r=()=>!0}={}){return new Promise((s,i)=>{const o=async({count:a=0}={})=>{const d=async({error:m})=>{const g=typeof e=="function"?e({count:a,error:m}):e;g&&await Gy(g),o({count:a+1})};try{const m=await t();s(m)}catch(m){if(a<n&&await r({count:a,error:m}))return d({error:m});i(m)}};o()})}function qy(t,e={}){return async(n,r={})=>{const{dedupe:s=!1,methods:i,retryDelay:o=150,retryCount:a=3,uid:d}={...e,...r},{method:m}=n;if(i?.exclude?.includes(m))throw new er(new Error("method not supported"),{method:m});if(i?.include&&!i.include.includes(m))throw new er(new Error("method not supported"),{method:m});const g=s?jo(`${d}.${li(n)}`):void 0;return Vy(()=>Hy(async()=>{try{return await t(n)}catch(x){const O=x;switch(O.code){case is.code:throw new is(O);case os.code:throw new os(O);case as.code:throw new as(O,{method:n.method});case cs.code:throw new cs(O);case Qn.code:throw new Qn(O);case Ar.code:throw new Ar(O);case us.code:throw new us(O);case ds.code:throw new ds(O);case ls.code:throw new ls(O);case er.code:throw new er(O,{method:n.method});case xr.code:throw new xr(O);case fs.code:throw new fs(O);case hi.code:throw new hi(O);case hs.code:throw new hs(O);case ps.code:throw new ps(O);case ms.code:throw new ms(O);case ia.code:throw new ia(O);case Sr.code:throw new Sr(O);case gs.code:throw new gs(O);case ys.code:throw new ys(O);case bs.code:throw new bs(O);case _s.code:throw new _s(O);case ws.code:throw new ws(O);case Es.code:throw new Es(O);case vs.code:throw new vs(O);case 5e3:throw new hi(O);default:throw x instanceof ue?x:new Yg(O)}}},{delay:({count:x,error:O})=>{if(O&&O instanceof jd){const N=O?.headers?.get("Retry-After");if(N?.match(/\d/))return Number.parseInt(N,10)*1e3}return~~(1<<x)*o},retryCount:a,shouldRetry:({error:x})=>Ky(x)}),{enabled:s,id:g})}}function Ky(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===xr.code||t.code===Qn.code:t instanceof jd&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function Wy({chain:t,currentChainId:e}){if(!t)throw new Bg;if(e!==t.id)throw new Mg({chain:t,currentChainId:e})}class yl extends Ho{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Bm(e);const r=oi(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),Bn(i)}update(e){return Er(this),this.iHash.update(e),this}digestInto(e){Er(this),Xn(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const bl=(t,e,n)=>new yl(t,e).update(n).digest();bl.create=(t,e)=>new yl(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Vt=BigInt(0),wt=BigInt(1),nr=BigInt(2),Zy=BigInt(3),_l=BigInt(4),wl=BigInt(5),El=BigInt(8);function je(t,e){const n=t%e;return n>=Vt?n:e+n}function qe(t,e,n){let r=t;for(;e-- >Vt;)r*=r,r%=n;return r}function Oa(t,e){if(t===Vt)throw new Error("invert: expected non-zero number");if(e<=Vt)throw new Error("invert: expected positive modulus, got "+e);let n=je(t,e),r=e,s=Vt,i=wt;for(;n!==Vt;){const a=r/n,d=r%n,m=s-i*a;r=n,n=d,s=i,i=m}if(r!==wt)throw new Error("invert: does not exist");return je(s,e)}function vl(t,e){const n=(t.ORDER+wt)/_l,r=t.pow(e,n);if(!t.eql(t.sqr(r),e))throw new Error("Cannot find square root");return r}function Yy(t,e){const n=(t.ORDER-wl)/El,r=t.mul(e,nr),s=t.pow(r,n),i=t.mul(e,s),o=t.mul(t.mul(i,nr),s),a=t.mul(i,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),e))throw new Error("Cannot find square root");return a}function Jy(t){if(t<BigInt(3))throw new Error("sqrt is not defined for small field");let e=t-wt,n=0;for(;e%nr===Vt;)e/=nr,n++;let r=nr;const s=Os(t);for(;Rl(s,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return vl;let i=s.pow(r,e);const o=(e+wt)/nr;return function(d,m){if(d.is0(m))return m;if(Rl(d,m)!==1)throw new Error("Cannot find square root");let g=n,x=d.mul(d.ONE,i),O=d.pow(m,e),N=d.pow(m,o);for(;!d.eql(O,d.ONE);){if(d.is0(O))return d.ZERO;let F=1,C=d.sqr(O);for(;!d.eql(C,d.ONE);)if(F++,C=d.sqr(C),F===g)throw new Error("Cannot find square root");const k=wt<<BigInt(g-F-1),K=d.pow(x,k);g=F,x=d.sqr(K),O=d.mul(O,x),N=d.mul(N,K)}return N}}function Xy(t){return t%_l===Zy?vl:t%El===wl?Yy:Jy(t)}const Qy=(t,e)=>(je(t,e)&wt)===wt,e1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function t1(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=e1.reduce((r,s)=>(r[s]="function",r),e);return Ss(t,n)}function n1(t,e,n){if(n<Vt)throw new Error("invalid exponent, negatives unsupported");if(n===Vt)return t.ONE;if(n===wt)return e;let r=t.ONE,s=e;for(;n>Vt;)n&wt&&(r=t.mul(r,s)),s=t.sqr(s),n>>=wt;return r}function Ia(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),s=e.reduce((o,a,d)=>t.is0(a)?o:(r[d]=o,t.mul(o,a)),t.ONE),i=t.inv(s);return e.reduceRight((o,a,d)=>t.is0(a)?o:(r[d]=t.mul(o,r[d]),t.mul(o,a)),i),r}function Rl(t,e){const n=(t.ORDER-wt)/nr,r=t.pow(e,n),s=t.eql(r,t.ONE),i=t.eql(r,t.ZERO),o=t.eql(r,t.neg(t.ONE));if(!s&&!i&&!o)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function Al(t,e){e!==void 0&&es(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Os(t,e,n=!1,r={}){if(t<=Vt)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:i}=Al(t,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:n,BITS:s,BYTES:i,MASK:yi(s),ZERO:Vt,ONE:wt,create:d=>je(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return Vt<=d&&d<t},is0:d=>d===Vt,isOdd:d=>(d&wt)===wt,neg:d=>je(-d,t),eql:(d,m)=>d===m,sqr:d=>je(d*d,t),add:(d,m)=>je(d+m,t),sub:(d,m)=>je(d-m,t),mul:(d,m)=>je(d*m,t),pow:(d,m)=>n1(a,d,m),div:(d,m)=>je(d*Oa(m,t),t),sqrN:d=>d*d,addN:(d,m)=>d+m,subN:(d,m)=>d-m,mulN:(d,m)=>d*m,inv:d=>Oa(d,t),sqrt:r.sqrt||(d=>(o||(o=Xy(t)),o(a,d))),toBytes:d=>n?gi(d,i):xs(d,i),fromBytes:d=>{if(d.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+d.length);return n?As(d):tr(d)},invertBatch:d=>Ia(a,d),cmov:(d,m,g)=>g?m:d});return Object.freeze(a)}function xl(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Sl(t){const e=xl(t);return e+Math.ceil(e/2)}function r1(t,e,n=!1){const r=t.length,s=xl(e),i=Sl(e);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const o=n?As(t):tr(t),a=je(o,e-wt)+wt;return n?gi(a,s):xs(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Tl=BigInt(0),Na=BigInt(1);function Ca(t,e){const n=e.negate();return t?n:e}function Ol(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ma(t,e){Ol(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),s=2**t,i=yi(t),o=BigInt(t);return{windows:n,windowSize:r,mask:i,maxNumber:s,shiftBy:o}}function Il(t,e,n){const{windowSize:r,mask:s,maxNumber:i,shiftBy:o}=n;let a=Number(t&s),d=t>>o;a>r&&(a-=i,d+=Na);const m=e*r,g=m+Math.abs(a)-1,x=a===0,O=a<0,N=e%2!==0;return{nextN:d,offset:g,isZero:x,isNeg:O,isNegF:N,offsetF:m}}function s1(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function i1(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)})}const Ba=new WeakMap,Nl=new WeakMap;function ka(t){return Nl.get(t)||1}function Cl(t,e){return{constTimeNegate:Ca,hasPrecomputes(n){return ka(n)!==1},unsafeLadder(n,r,s=t.ZERO){let i=n;for(;r>Tl;)r&Na&&(s=s.add(i)),i=i.double(),r>>=Na;return s},precomputeWindow(n,r){const{windows:s,windowSize:i}=Ma(r,e),o=[];let a=n,d=a;for(let m=0;m<s;m++){d=a,o.push(d);for(let g=1;g<i;g++)d=d.add(a),o.push(d);a=d.double()}return o},wNAF(n,r,s){let i=t.ZERO,o=t.BASE;const a=Ma(n,e);for(let d=0;d<a.windows;d++){const{nextN:m,offset:g,isZero:x,isNeg:O,isNegF:N,offsetF:F}=Il(s,d,a);s=m,x?o=o.add(Ca(N,r[F])):i=i.add(Ca(O,r[g]))}return{p:i,f:o}},wNAFUnsafe(n,r,s,i=t.ZERO){const o=Ma(n,e);for(let a=0;a<o.windows&&s!==Tl;a++){const{nextN:d,offset:m,isZero:g,isNeg:x}=Il(s,a,o);if(s=d,!g){const O=r[m];i=i.add(x?O.negate():O)}}return i},getPrecomputes(n,r,s){let i=Ba.get(r);return i||(i=this.precomputeWindow(r,n),n!==1&&Ba.set(r,s(i))),i},wNAFCached(n,r,s){const i=ka(n);return this.wNAF(i,this.getPrecomputes(i,n,s),r)},wNAFCachedUnsafe(n,r,s,i){const o=ka(n);return o===1?this.unsafeLadder(n,r,i):this.wNAFUnsafe(o,this.getPrecomputes(o,n,s),r,i)},setWindowSize(n,r){Ol(r,e),Nl.set(n,r),Ba.delete(n)}}}function Ml(t,e,n,r){s1(n,t),i1(r,e);const s=n.length,i=r.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=ey(BigInt(s));let d=1;a>12?d=a-3:a>4?d=a-2:a>0&&(d=2);const m=yi(d),g=new Array(Number(m)+1).fill(o),x=Math.floor((e.BITS-1)/d)*d;let O=o;for(let N=x;N>=0;N-=d){g.fill(o);for(let C=0;C<i;C++){const k=r[C],K=Number(k>>BigInt(N)&m);g[K]=g[K].add(n[C])}let F=o;for(let C=g.length-1,k=o;C>0;C--)k=k.add(g[C]),F=F.add(k);if(O=O.add(F),N!==0)for(let C=0;C<d;C++)O=O.double()}return O}function La(t){return t1(t.Fp),Ss(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Al(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Bl(t){t.lowS!==void 0&&Ln("lowS",t.lowS),t.prehash!==void 0&&Ln("prehash",t.prehash)}function o1(t){const e=La(t);Ss(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:s}=e;if(n){if(!r.eql(s,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class a1 extends Error{constructor(e=""){super(e)}}const vn={Err:a1,_tlv:{encode:(t,e)=>{const{Err:n}=vn;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length&1)throw new n("tlv.encode: unpadded data");const r=e.length/2,s=pi(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?pi(s.length/2|128):"";return pi(t)+i+s+e},decode(t,e){const{Err:n}=vn;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const s=e[r++],i=!!(s&128);let o=0;if(!i)o=s;else{const d=s&127;if(!d)throw new n("tlv.decode(long): indefinite length not supported");if(d>4)throw new n("tlv.decode(long): byte length is too big");const m=e.subarray(r,r+d);if(m.length!==d)throw new n("tlv.decode: length bytes not complete");if(m[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const g of m)o=o<<8|g;if(r+=d,o<128)throw new n("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+o);if(a.length!==o)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=vn;if(t<Rn)throw new e("integer: negative integers are not allowed");let n=pi(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=vn;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return tr(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=vn,s=Je("signature",t),{v:i,l:o}=r.decode(48,s);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:d}=r.decode(2,i),{v:m,l:g}=r.decode(2,d);if(g.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(m)}},hexFromSig(t){const{_tlv:e,_int:n}=vn,r=e.encode(2,n.encode(t.r)),s=e.encode(2,n.encode(t.s)),i=r+s;return e.encode(48,i)}};function Pa(t,e){return Tr(xs(t,e))}const Rn=BigInt(0),_t=BigInt(1);BigInt(2);const Ua=BigInt(3),c1=BigInt(4);function u1(t){const e=o1(t),{Fp:n}=e,r=Os(e.n,e.nBitLength),s=e.toBytes||((V,L,z)=>{const J=L.toAffine();return Or(Uint8Array.from([4]),n.toBytes(J.x),n.toBytes(J.y))}),i=e.fromBytes||(V=>{const L=V.subarray(1),z=n.fromBytes(L.subarray(0,n.BYTES)),J=n.fromBytes(L.subarray(n.BYTES,2*n.BYTES));return{x:z,y:J}});function o(V){const{a:L,b:z}=e,J=n.sqr(V),te=n.mul(J,V);return n.add(n.add(te,n.mul(V,L)),z)}function a(V,L){const z=n.sqr(L),J=o(V);return n.eql(z,J)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const d=n.mul(n.pow(e.a,Ua),c1),m=n.mul(n.sqr(e.b),BigInt(27));if(n.is0(n.add(d,m)))throw new Error("bad curve params: a or b");function g(V){return da(V,_t,e.n)}function x(V){const{allowedPrivateKeyLengths:L,nByteLength:z,wrapPrivateKey:J,n:te}=e;if(L&&typeof V!="bigint"){if(Rs(V)&&(V=Tr(V)),typeof V!="string"||!L.includes(V.length))throw new Error("invalid private key");V=V.padStart(z*2,"0")}let ne;try{ne=typeof V=="bigint"?V:tr(Je("private key",V,z))}catch{throw new Error("invalid private key, expected hex or "+z+" bytes, got "+typeof V)}return J&&(ne=je(ne,te)),nn("private key",ne,_t,te),ne}function O(V){if(!(V instanceof C))throw new Error("ProjectivePoint expected")}const N=bi((V,L)=>{const{px:z,py:J,pz:te}=V;if(n.eql(te,n.ONE))return{x:z,y:J};const ne=V.is0();L==null&&(L=ne?n.ONE:n.inv(te));const q=n.mul(z,L),B=n.mul(J,L),P=n.mul(te,L);if(ne)return{x:n.ZERO,y:n.ZERO};if(!n.eql(P,n.ONE))throw new Error("invZ was invalid");return{x:q,y:B}}),F=bi(V=>{if(V.is0()){if(e.allowInfinityPoint&&!n.is0(V.py))return;throw new Error("bad point: ZERO")}const{x:L,y:z}=V.toAffine();if(!n.isValid(L)||!n.isValid(z))throw new Error("bad point: x or y not FE");if(!a(L,z))throw new Error("bad point: equation left != right");if(!V.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class C{constructor(L,z,J){if(L==null||!n.isValid(L))throw new Error("x required");if(z==null||!n.isValid(z)||n.is0(z))throw new Error("y required");if(J==null||!n.isValid(J))throw new Error("z required");this.px=L,this.py=z,this.pz=J,Object.freeze(this)}static fromAffine(L){const{x:z,y:J}=L||{};if(!L||!n.isValid(z)||!n.isValid(J))throw new Error("invalid affine point");if(L instanceof C)throw new Error("projective point not allowed");const te=ne=>n.eql(ne,n.ZERO);return te(z)&&te(J)?C.ZERO:new C(z,J,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(L){const z=Ia(n,L.map(J=>J.pz));return L.map((J,te)=>J.toAffine(z[te])).map(C.fromAffine)}static fromHex(L){const z=C.fromAffine(i(Je("pointHex",L)));return z.assertValidity(),z}static fromPrivateKey(L){return C.BASE.multiply(x(L))}static msm(L,z){return Ml(C,r,L,z)}_setWindowSize(L){Y.setWindowSize(this,L)}assertValidity(){F(this)}hasEvenY(){const{y:L}=this.toAffine();if(n.isOdd)return!n.isOdd(L);throw new Error("Field doesn't support isOdd")}equals(L){O(L);const{px:z,py:J,pz:te}=this,{px:ne,py:q,pz:B}=L,P=n.eql(n.mul(z,B),n.mul(ne,te)),j=n.eql(n.mul(J,B),n.mul(q,te));return P&&j}negate(){return new C(this.px,n.neg(this.py),this.pz)}double(){const{a:L,b:z}=e,J=n.mul(z,Ua),{px:te,py:ne,pz:q}=this;let B=n.ZERO,P=n.ZERO,j=n.ZERO,E=n.mul(te,te),c=n.mul(ne,ne),p=n.mul(q,q),y=n.mul(te,ne);return y=n.add(y,y),j=n.mul(te,q),j=n.add(j,j),B=n.mul(L,j),P=n.mul(J,p),P=n.add(B,P),B=n.sub(c,P),P=n.add(c,P),P=n.mul(B,P),B=n.mul(y,B),j=n.mul(J,j),p=n.mul(L,p),y=n.sub(E,p),y=n.mul(L,y),y=n.add(y,j),j=n.add(E,E),E=n.add(j,E),E=n.add(E,p),E=n.mul(E,y),P=n.add(P,E),p=n.mul(ne,q),p=n.add(p,p),E=n.mul(p,y),B=n.sub(B,E),j=n.mul(p,c),j=n.add(j,j),j=n.add(j,j),new C(B,P,j)}add(L){O(L);const{px:z,py:J,pz:te}=this,{px:ne,py:q,pz:B}=L;let P=n.ZERO,j=n.ZERO,E=n.ZERO;const c=e.a,p=n.mul(e.b,Ua);let y=n.mul(z,ne),A=n.mul(J,q),v=n.mul(te,B),R=n.add(z,J),I=n.add(ne,q);R=n.mul(R,I),I=n.add(y,A),R=n.sub(R,I),I=n.add(z,te);let _=n.add(ne,B);return I=n.mul(I,_),_=n.add(y,v),I=n.sub(I,_),_=n.add(J,te),P=n.add(q,B),_=n.mul(_,P),P=n.add(A,v),_=n.sub(_,P),E=n.mul(c,I),P=n.mul(p,v),E=n.add(P,E),P=n.sub(A,E),E=n.add(A,E),j=n.mul(P,E),A=n.add(y,y),A=n.add(A,y),v=n.mul(c,v),I=n.mul(p,I),A=n.add(A,v),v=n.sub(y,v),v=n.mul(c,v),I=n.add(I,v),y=n.mul(A,I),j=n.add(j,y),y=n.mul(_,I),P=n.mul(R,P),P=n.sub(P,y),y=n.mul(R,A),E=n.mul(_,E),E=n.add(E,y),new C(P,j,E)}subtract(L){return this.add(L.negate())}is0(){return this.equals(C.ZERO)}wNAF(L){return Y.wNAFCached(this,L,C.normalizeZ)}multiplyUnsafe(L){const{endo:z,n:J}=e;nn("scalar",L,Rn,J);const te=C.ZERO;if(L===Rn)return te;if(this.is0()||L===_t)return this;if(!z||Y.hasPrecomputes(this))return Y.wNAFCachedUnsafe(this,L,C.normalizeZ);let{k1neg:ne,k1:q,k2neg:B,k2:P}=z.splitScalar(L),j=te,E=te,c=this;for(;q>Rn||P>Rn;)q&_t&&(j=j.add(c)),P&_t&&(E=E.add(c)),c=c.double(),q>>=_t,P>>=_t;return ne&&(j=j.negate()),B&&(E=E.negate()),E=new C(n.mul(E.px,z.beta),E.py,E.pz),j.add(E)}multiply(L){const{endo:z,n:J}=e;nn("scalar",L,_t,J);let te,ne;if(z){const{k1neg:q,k1:B,k2neg:P,k2:j}=z.splitScalar(L);let{p:E,f:c}=this.wNAF(B),{p,f:y}=this.wNAF(j);E=Y.constTimeNegate(q,E),p=Y.constTimeNegate(P,p),p=new C(n.mul(p.px,z.beta),p.py,p.pz),te=E.add(p),ne=c.add(y)}else{const{p:q,f:B}=this.wNAF(L);te=q,ne=B}return C.normalizeZ([te,ne])[0]}multiplyAndAddUnsafe(L,z,J){const te=C.BASE,ne=(B,P)=>P===Rn||P===_t||!B.equals(te)?B.multiplyUnsafe(P):B.multiply(P),q=ne(this,z).add(ne(L,J));return q.is0()?void 0:q}toAffine(L){return N(this,L)}isTorsionFree(){const{h:L,isTorsionFree:z}=e;if(L===_t)return!0;if(z)return z(C,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:L,clearCofactor:z}=e;return L===_t?this:z?z(C,this):this.multiplyUnsafe(e.h)}toRawBytes(L=!0){return Ln("isCompressed",L),this.assertValidity(),s(C,this,L)}toHex(L=!0){return Ln("isCompressed",L),Tr(this.toRawBytes(L))}}C.BASE=new C(e.Gx,e.Gy,n.ONE),C.ZERO=new C(n.ZERO,n.ONE,n.ZERO);const{endo:k,nBitLength:K}=e,Y=Cl(C,k?Math.ceil(K/2):K);return{CURVE:e,ProjectivePoint:C,normPrivateKeyToScalar:x,weierstrassEquation:o,isWithinCurveOrder:g}}function d1(t){const e=La(t);return Ss(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function l1(t){const e=d1(t),{Fp:n,n:r,nByteLength:s,nBitLength:i}=e,o=n.BYTES+1,a=2*n.BYTES+1;function d(p){return je(p,r)}function m(p){return Oa(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:x,weierstrassEquation:O,isWithinCurveOrder:N}=u1({...e,toBytes(p,y,A){const v=y.toAffine(),R=n.toBytes(v.x),I=Or;return Ln("isCompressed",A),A?I(Uint8Array.from([y.hasEvenY()?2:3]),R):I(Uint8Array.from([4]),R,n.toBytes(v.y))},fromBytes(p){const y=p.length,A=p[0],v=p.subarray(1);if(y===o&&(A===2||A===3)){const R=tr(v);if(!da(R,_t,n.ORDER))throw new Error("Point is not on curve");const I=O(R);let _;try{_=n.sqrt(I)}catch(w){const T=w instanceof Error?": "+w.message:"";throw new Error("Point is not on curve"+T)}const u=(_&_t)===_t;return(A&1)===1!==u&&(_=n.neg(_)),{x:R,y:_}}else if(y===a&&A===4){const R=n.fromBytes(v.subarray(0,n.BYTES)),I=n.fromBytes(v.subarray(n.BYTES,2*n.BYTES));return{x:R,y:I}}else{const R=o,I=a;throw new Error("invalid Point, expected length of "+R+", or uncompressed "+I+", got "+y)}}});function F(p){const y=r>>_t;return p>y}function C(p){return F(p)?d(-p):p}const k=(p,y,A)=>tr(p.slice(y,A));class K{constructor(y,A,v){nn("r",y,_t,r),nn("s",A,_t,r),this.r=y,this.s=A,v!=null&&(this.recovery=v),Object.freeze(this)}static fromCompact(y){const A=s;return y=Je("compactSignature",y,A*2),new K(k(y,0,A),k(y,A,2*A))}static fromDER(y){const{r:A,s:v}=vn.toSig(Je("DER",y));return new K(A,v)}assertValidity(){}addRecoveryBit(y){return new K(this.r,this.s,y)}recoverPublicKey(y){const{r:A,s:v,recovery:R}=this,I=te(Je("msgHash",y));if(R==null||![0,1,2,3].includes(R))throw new Error("recovery id invalid");const _=R===2||R===3?A+e.n:A;if(_>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=(R&1)===0?"02":"03",l=g.fromHex(u+Pa(_,n.BYTES)),w=m(_),T=d(-I*w),D=d(v*w),W=g.BASE.multiplyAndAddUnsafe(l,T,D);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return F(this.s)}normalizeS(){return this.hasHighS()?new K(this.r,d(-this.s),this.recovery):this}toDERRawBytes(){return mi(this.toDERHex())}toDERHex(){return vn.hexFromSig(this)}toCompactRawBytes(){return mi(this.toCompactHex())}toCompactHex(){const y=s;return Pa(this.r,y)+Pa(this.s,y)}}const Y={isValidPrivateKey(p){try{return x(p),!0}catch{return!1}},normPrivateKeyToScalar:x,randomPrivateKey:()=>{const p=Sl(e.n);return r1(e.randomBytes(p),e.n)},precompute(p=8,y=g.BASE){return y._setWindowSize(p),y.multiply(BigInt(3)),y}};function V(p,y=!0){return g.fromPrivateKey(p).toRawBytes(y)}function L(p){if(typeof p=="bigint")return!1;if(p instanceof g)return!0;const A=Je("key",p).length,v=n.BYTES,R=v+1,I=2*v+1;if(!(e.allowedPrivateKeyLengths||s===R))return A===R||A===I}function z(p,y,A=!0){if(L(p)===!0)throw new Error("first arg must be private key");if(L(y)===!1)throw new Error("second arg must be public key");return g.fromHex(y).multiply(x(p)).toRawBytes(A)}const J=e.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const y=tr(p),A=p.length*8-i;return A>0?y>>BigInt(A):y},te=e.bits2int_modN||function(p){return d(J(p))},ne=yi(i);function q(p){return nn("num < 2^"+i,p,Rn,ne),xs(p,s)}function B(p,y,A=P){if(["recovered","canonical"].some(oe=>oe in A))throw new Error("sign() legacy options not supported");const{hash:v,randomBytes:R}=e;let{lowS:I,prehash:_,extraEntropy:u}=A;I==null&&(I=!0),p=Je("msgHash",p),Bl(A),_&&(p=Je("prehashed msgHash",v(p)));const l=te(p),w=x(y),T=[q(w),q(l)];if(u!=null&&u!==!1){const oe=u===!0?R(n.BYTES):u;T.push(Je("extraEntropy",oe))}const D=Or(...T),W=l;function re(oe){const Ce=J(oe);if(!N(Ce))return;const Ee=m(Ce),we=g.BASE.multiply(Ce).toAffine(),De=d(we.x);if(De===Rn)return;const ve=d(Ee*d(W+De*w));if(ve===Rn)return;let Oe=(we.x===De?0:2)|Number(we.y&_t),mn=ve;return I&&F(ve)&&(mn=C(ve),Oe^=1),new K(De,mn,Oe)}return{seed:D,k2sig:re}}const P={lowS:e.lowS,prehash:!1},j={lowS:e.lowS,prehash:!1};function E(p,y,A=P){const{seed:v,k2sig:R}=B(p,y,A),I=e;return ty(I.hash.outputLen,I.nByteLength,I.hmac)(v,R)}g.BASE._setWindowSize(8);function c(p,y,A,v=j){const R=p;y=Je("msgHash",y),A=Je("publicKey",A);const{lowS:I,prehash:_,format:u}=v;if(Bl(v),"strict"in v)throw new Error("options.strict was renamed to lowS");if(u!==void 0&&u!=="compact"&&u!=="der")throw new Error("format must be compact or der");const l=typeof R=="string"||Rs(R),w=!l&&!u&&typeof R=="object"&&R!==null&&typeof R.r=="bigint"&&typeof R.s=="bigint";if(!l&&!w)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let T,D;try{if(w&&(T=new K(R.r,R.s)),l){try{u!=="compact"&&(T=K.fromDER(R))}catch(Oe){if(!(Oe instanceof vn.Err))throw Oe}!T&&u!=="der"&&(T=K.fromCompact(R))}D=g.fromHex(A)}catch{return!1}if(!T||I&&T.hasHighS())return!1;_&&(y=e.hash(y));const{r:W,s:re}=T,oe=te(y),Ce=m(re),Ee=d(oe*Ce),we=d(W*Ce),De=g.BASE.multiplyAndAddUnsafe(D,Ee,we)?.toAffine();return De?d(De.x)===W:!1}return{CURVE:e,getPublicKey:V,getSharedSecret:z,sign:E,verify:c,ProjectivePoint:g,Signature:K,utils:Y}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function f1(t){return{hash:t,hmac:(e,...n)=>bl(t,e,Fm(...n)),randomBytes:Ed}}function h1(t,e){const n=r=>l1({...t,...f1(r)});return{...n(e),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const kl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ll=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),p1=BigInt(0),m1=BigInt(1),Da=BigInt(2),Pl=(t,e)=>(t+e/Da)/e;function g1(t){const e=kl,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),d=BigInt(88),m=t*t*t%e,g=m*m*t%e,x=qe(g,n,e)*g%e,O=qe(x,n,e)*g%e,N=qe(O,Da,e)*m%e,F=qe(N,s,e)*N%e,C=qe(F,i,e)*F%e,k=qe(C,a,e)*C%e,K=qe(k,d,e)*k%e,Y=qe(K,a,e)*C%e,V=qe(Y,n,e)*g%e,L=qe(V,o,e)*F%e,z=qe(L,r,e)*m%e,J=qe(z,Da,e);if(!Fa.eql(Fa.sqr(J),t))throw new Error("Cannot find square root");return J}const Fa=Os(kl,void 0,void 0,{sqrt:g1}),$a=h1({a:p1,b:BigInt(7),Fp:Fa,n:Ll,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Ll,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-m1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,o=BigInt("0x100000000000000000000000000000000"),a=Pl(i*t,e),d=Pl(-r*t,e);let m=je(t-a*n-d*s,e),g=je(-a*r-d*i,e);const x=m>o,O=g>o;if(x&&(m=e-m),O&&(g=e-g),m>o||g>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:x,k1:m,k2neg:O,k2:g}}}},cl),y1=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:$a},Symbol.toStringTag,{value:"Module"}));class Ul extends ue{constructor({docsPath:e}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(`
22
+ `),{docsPath:e,docsSlug:"account",name:"AccountNotFoundError"})}}class za extends ue{constructor({docsPath:e,metaMessages:n,type:r}){super(`Account type "${r}" is not supported.`,{docsPath:e,metaMessages:n,name:"AccountTypeNotSupportedError"})}}async function b1(t,{serializedTransaction:e}){return t.request({method:"eth_sendRawTransaction",params:[e]},{retryCount:0})}const ja=new ns(128);async function Dl(t,e){const{account:n=t.account,chain:r=t.chain,accessList:s,authorizationList:i,blobs:o,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:x,maxPriorityFeePerGas:O,nonce:N,type:F,value:C,...k}=e;if(typeof n>"u")throw new Ul({docsPath:"/docs/actions/wallet/sendTransaction"});const K=n?wn(n):null;try{Ei(e);const Y=await(async()=>{if(e.to)return e.to;if(e.to!==null&&i&&i.length>0)return await Qd({authorization:i[0]}).catch(()=>{throw new ue("`to` is required. Could not infer from `authorizationList`.")})})();if(K?.type==="json-rpc"||K===null){let V;r!==null&&(V=await xt(t,Sa,"getChainId")({}),Wy({currentChainId:V,chain:r}));const L=t.chain?.formatters?.transactionRequest?.format,J=(L||va)({...Ea(k,{format:L}),accessList:s,account:K,authorizationList:i,blobs:o,chainId:V,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:x,maxPriorityFeePerGas:O,nonce:N,to:Y,type:F,value:C},"sendTransaction"),te=ja.get(t.uid),ne=te?"wallet_sendTransaction":"eth_sendTransaction";try{return await t.request({method:ne,params:[J]},{retryCount:0})}catch(q){if(te===!1)throw q;const B=q;if(B.name==="InvalidInputRpcError"||B.name==="InvalidParamsRpcError"||B.name==="MethodNotFoundRpcError"||B.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[J]},{retryCount:0}).then(P=>(ja.set(t.uid,!0),P)).catch(P=>{const j=P;throw j.name==="MethodNotFoundRpcError"||j.name==="MethodNotSupportedRpcError"?(ja.set(t.uid,!1),B):j});throw B}}if(K?.type==="local"){const V=await xt(t,gl,"prepareTransactionRequest")({account:K,accessList:s,authorizationList:i,blobs:o,chain:r,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:x,maxPriorityFeePerGas:O,nonce:N,nonceManager:K.nonceManager,parameters:[...pl,"sidecars"],type:F,value:C,...k,to:Y}),L=r?.serializers?.transaction,z=await K.signTransaction(V,{serializer:L});return await xt(t,b1,"sendRawTransaction")({serializedTransaction:z})}throw K?.type==="smart"?new za({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new za({docsPath:"/docs/actions/wallet/sendTransaction",type:K?.type})}catch(Y){throw Y instanceof za?Y:hl(Y,{...e,account:K,chain:e.chain||void 0})}}async function Ri(t,e){return Ri.internal(t,Dl,"sendTransaction",e)}(function(t){async function e(n,r,s,i){const{abi:o,account:a=n.account,address:d,args:m,dataSuffix:g,functionName:x,...O}=i;if(typeof a>"u")throw new Ul({docsPath:"/docs/contract/writeContract"});const N=a?wn(a):null,F=Cg({abi:o,args:m,functionName:x});try{return await xt(n,r,s)({data:`${F}${g?g.replace("0x",""):""}`,to:d,account:N,...O})}catch(C){throw Xg(C,{abi:o,address:d,args:m,docsPath:"/docs/contract/writeContract",functionName:x,sender:N?.address})}}t.internal=e})(Ri||(Ri={}));function Fl(t,e,n){const r=t[e.name];if(typeof r=="function")return r;const s=t[n];return typeof s=="function"?s:i=>e(t,i)}const _1="3.4.0",w1=()=>`@wagmi/core@${_1}`;var $l=function(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)},Ai,zl;let rr=class wu extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return w1()}constructor(e,n={}){super(),Ai.add(this),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiCoreError"});const r=n.cause instanceof wu?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof wu&&n.cause.docsPath||n.docsPath;this.message=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${this.docsBaseUrl}${s}.html${n.docsSlug?`#${n.docsSlug}`:""}`]:[],...r?[`Details: ${r}`]:[],`Version: ${this.version}`].join(`
23
+ `),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.shortMessage=e}walk(e){return $l(this,Ai,"m",zl).call(this,this,e)}};Ai=new WeakSet,zl=function t(e,n){return n?.(e)?e:e.cause?$l(this,Ai,"m",t).call(this,e.cause,n):e};class jl extends rr{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class E1 extends rr{constructor(){super("Connector already connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAlreadyConnectedError"})}}class v1 extends rr{constructor(){super("Connector not connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorNotConnectedError"})}}class R1 extends rr{constructor({address:e,connector:n}){super(`Account "${e}" not found for connector "${n.name}".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAccountNotFoundError"})}}class A1 extends rr{constructor({connectionChainId:e,connectorChainId:n}){super(`The current chain of the connector (id: ${n}) does not match the connection's chain (id: ${e}).`,{metaMessages:[`Current Chain ID: ${n}`,`Expected Chain ID: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorChainMismatchError"})}}class x1 extends rr{constructor({connector:e}){super(`Connector "${e.name}" unavailable while reconnecting.`,{details:["During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.","All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.","This error commonly occurs for connectors that asynchronously inject after reconnection has already started."].join(" ")}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorUnavailableReconnectingError"})}}async function S1(t,e){let n;if(typeof e.connector=="function"?n=t._internal.connectors.setup(e.connector):n=e.connector,n.uid===t.state.current)throw new E1;try{t.setState(o=>({...o,status:"connecting"})),n.emitter.emit("message",{type:"connecting"});const{connector:r,...s}=e,i=await n.connect(s);return n.emitter.off("connect",t._internal.events.connect),n.emitter.on("change",t._internal.events.change),n.emitter.on("disconnect",t._internal.events.disconnect),await t.storage?.setItem("recentConnectorId",n.id),t.setState(o=>({...o,connections:new Map(o.connections).set(n.uid,{accounts:s.withCapabilities?i.accounts.map(a=>typeof a=="object"?a.address:a):i.accounts,chainId:i.chainId,connector:n}),current:n.uid,status:"connected"})),{accounts:s.withCapabilities?i.accounts.map(o=>typeof o=="object"?o:{address:o,capabilities:{}}):i.accounts,chainId:i.chainId}}catch(r){throw t.setState(s=>({...s,status:s.current?"connected":"disconnected"})),r}}const Va=256;let xi=Va,Si;function Vl(t=11){if(!Si||xi+t>Va*2){Si="",xi=0;for(let e=0;e<Va;e++)Si+=(256+Math.random()*256|0).toString(16).substring(1)}return Si.substring(xi,xi+++t)}function T1(t){const{batch:e,chain:n,ccipRead:r,key:s="base",name:i="Base Client",type:o="base"}=t,a=t.experimental_blockTag??(typeof n?.experimental_preconfirmationTime=="number"?"pending":void 0),d=n?.blockTime??12e3,m=Math.min(Math.max(Math.floor(d/2),500),4e3),g=t.pollingInterval??m,x=t.cacheTime??g,O=t.account?wn(t.account):void 0,{config:N,request:F,value:C}=t.transport({account:O,chain:n,pollingInterval:g}),k={...N,...C},K={account:O,batch:e,cacheTime:x,ccipRead:r,chain:n,key:s,name:i,pollingInterval:g,request:F,transport:k,type:o,uid:Vl(),...a?{experimental_blockTag:a}:{}};function Y(V){return L=>{const z=L(V);for(const te in K)delete z[te];const J={...V,...z};return Object.assign(J,{extend:Y(J)})}}return Object.assign(K,{extend:Y(K)})}function O1({key:t,methods:e,name:n,request:r,retryCount:s=3,retryDelay:i=150,timeout:o,type:a},d){const m=Vl();return{config:{key:t,methods:e,name:n,request:r,retryCount:s,retryDelay:i,timeout:o,type:a},request:qy(r,{methods:e,retryCount:s,retryDelay:i,uid:m}),value:d}}function I1(t,e={}){const{key:n="custom",methods:r,name:s="Custom Provider",retryDelay:i}=e;return({retryCount:o})=>O1({key:n,methods:r,name:s,request:t.request.bind(t),retryCount:e.retryCount??o,retryDelay:i,type:"custom"})}async function Gl(t,e={}){const{assertChainId:n=!0}=e;let r;if(e.connector){const{connector:g}=e;if(t.state.status==="reconnecting"&&!g.getAccounts&&!g.getChainId)throw new x1({connector:g});const[x,O]=await Promise.all([g.getAccounts().catch(N=>{if(e.account===null)return[];throw N}),g.getChainId()]);r={accounts:x,chainId:O,connector:g}}else r=t.state.connections.get(t.state.current);if(!r)throw new v1;const s=e.chainId??r.chainId,i=await r.connector.getChainId();if(n&&i!==s)throw new A1({connectionChainId:s,connectorChainId:i});const o=r.connector;if(o.getClient)return o.getClient({chainId:s});const a=wn(e.account??r.accounts[0]);if(a&&(a.address=ui(a.address)),e.account&&!r.accounts.some(g=>g.toLowerCase()===a.address.toLowerCase()))throw new R1({address:a.address,connector:o});const d=t.chains.find(g=>g.id===s),m=await r.connector.getProvider({chainId:s});return T1({account:a,chain:d,name:"Connector Client",transport:g=>I1(m)({...g,retryCount:0})})}async function N1(t,e={}){let n;if(e.connector)n=e.connector;else{const{connections:s,current:i}=t.state;n=s.get(i)?.connector}const r=t.state.connections;n&&(await n.disconnect(),n.emitter.off("change",t._internal.events.change),n.emitter.off("disconnect",t._internal.events.disconnect),n.emitter.on("connect",t._internal.events.connect),r.delete(n.uid)),t.setState(s=>{if(r.size===0)return{...s,connections:new Map,current:null,status:"disconnected"};const i=r.values().next().value;return{...s,connections:new Map(r),current:i.connector.uid}});{const s=t.state.current;if(!s)return;const i=t.state.connections.get(s)?.connector;if(!i)return;await t.storage?.setItem("recentConnectorId",i.id)}}async function C1(t,e){const{account:n,chainId:r,connector:s,...i}=e;let o;typeof n=="object"&&n?.type==="local"?o=t.getClient({chainId:r}):o=await Gl(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:s});const a=!r||o.chain?.id===r?o.chain:{id:r};return await Fl(o,Dl,"sendTransaction")({...i,...n?{account:n}:{},assertChainId:!!r,chain:a,gas:i.gas??void 0})}class M1 extends rr{constructor({connector:e}){super(`"${e.name}" does not support programmatic chain switching.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SwitchChainNotSupportedError"})}}async function B1(t,e){const{addEthereumChainParameter:n,chainId:r}=e,s=t.state.connections.get(e.connector?.uid??t.state.current);if(s){const o=s.connector;if(!o.switchChain)throw new M1({connector:o});return await o.switchChain({addEthereumChainParameter:n,chainId:r})}const i=t.chains.find(o=>o.id===r);if(!i)throw new jl;return t.setState(o=>({...o,chainId:r})),i}async function k1(t,e){const{account:n,chainId:r,connector:s,...i}=e;let o;typeof n=="object"&&n?.type==="local"?o=t.getClient({chainId:r}):o=await Gl(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:s});const a=!r||o.chain?.id===r?o.chain:{id:r};return await Fl(o,Ri,"writeContract")({...i,...n?{account:n}:{},assertChainId:!!r,chain:a})}function AT(t){return t}function Ga(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Ha(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){var s=!1;try{s=this instanceof r}catch{}return s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var qa={exports:{}},Hl;function L1(){return Hl||(Hl=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function s(d,m,g){this.fn=d,this.context=m,this.once=g||!1}function i(d,m,g,x,O){if(typeof g!="function")throw new TypeError("The listener must be a function");var N=new s(g,x||d,O),F=n?n+m:m;return d._events[F]?d._events[F].fn?d._events[F]=[d._events[F],N]:d._events[F].push(N):(d._events[F]=N,d._eventsCount++),d}function o(d,m){--d._eventsCount===0?d._events=new r:delete d._events[m]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var m=[],g,x;if(this._eventsCount===0)return m;for(x in g=this._events)e.call(g,x)&&m.push(n?x.slice(1):x);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(g)):m},a.prototype.listeners=function(m){var g=n?n+m:m,x=this._events[g];if(!x)return[];if(x.fn)return[x.fn];for(var O=0,N=x.length,F=new Array(N);O<N;O++)F[O]=x[O].fn;return F},a.prototype.listenerCount=function(m){var g=n?n+m:m,x=this._events[g];return x?x.fn?1:x.length:0},a.prototype.emit=function(m,g,x,O,N,F){var C=n?n+m:m;if(!this._events[C])return!1;var k=this._events[C],K=arguments.length,Y,V;if(k.fn){switch(k.once&&this.removeListener(m,k.fn,void 0,!0),K){case 1:return k.fn.call(k.context),!0;case 2:return k.fn.call(k.context,g),!0;case 3:return k.fn.call(k.context,g,x),!0;case 4:return k.fn.call(k.context,g,x,O),!0;case 5:return k.fn.call(k.context,g,x,O,N),!0;case 6:return k.fn.call(k.context,g,x,O,N,F),!0}for(V=1,Y=new Array(K-1);V<K;V++)Y[V-1]=arguments[V];k.fn.apply(k.context,Y)}else{var L=k.length,z;for(V=0;V<L;V++)switch(k[V].once&&this.removeListener(m,k[V].fn,void 0,!0),K){case 1:k[V].fn.call(k[V].context);break;case 2:k[V].fn.call(k[V].context,g);break;case 3:k[V].fn.call(k[V].context,g,x);break;case 4:k[V].fn.call(k[V].context,g,x,O);break;default:if(!Y)for(z=1,Y=new Array(K-1);z<K;z++)Y[z-1]=arguments[z];k[V].fn.apply(k[V].context,Y)}}return!0},a.prototype.on=function(m,g,x){return i(this,m,g,x,!1)},a.prototype.once=function(m,g,x){return i(this,m,g,x,!0)},a.prototype.removeListener=function(m,g,x,O){var N=n?n+m:m;if(!this._events[N])return this;if(!g)return o(this,N),this;var F=this._events[N];if(F.fn)F.fn===g&&(!O||F.once)&&(!x||F.context===x)&&o(this,N);else{for(var C=0,k=[],K=F.length;C<K;C++)(F[C].fn!==g||O&&!F[C].once||x&&F[C].context!==x)&&k.push(F[C]);k.length?this._events[N]=k.length===1?k[0]:k:o(this,N)}return this},a.prototype.removeAllListeners=function(m){var g;return m?(g=n?n+m:m,this._events[g]&&o(this,g)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a})(qa)),qa.exports}var P1=L1();const ql=Ga(P1);let Nr=class extends Error{name="BaseError";cause;constructor(e,n={}){super(e,n.cause?{cause:n.cause}:void 0),this.cause=n.cause}};class U1 extends Nr{name="AddMiniApp.InvalidDomainManifest";constructor(){super("Invalid domain manifest")}}let D1=class extends Nr{name="AddMiniApp.RejectedByUser";constructor(){super("Add miniapp rejected by user")}},Kl=class extends Nr{name="SignIn.RejectedByUser";constructor(){super("Sign in rejected by user")}};class F1 extends Nr{name="SignManifest.RejectedByUser";constructor(){super("Sign manifest rejected by user")}}class $1 extends Nr{name="SignManifest.InvalidDomain";constructor(){super("Invalid domain provided")}}class z1 extends Nr{name="SignManifest.GenericError";constructor(e="Manifest signing failed"){super(e)}}var Ne;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(const o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Ne||(Ne={}));var Wl;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Wl||(Wl={}));const de=Ne.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$n=t=>{switch(typeof t){case"undefined":return de.undefined;case"string":return de.string;case"number":return Number.isNaN(t)?de.nan:de.number;case"boolean":return de.boolean;case"function":return de.function;case"bigint":return de.bigint;case"symbol":return de.symbol;case"object":return Array.isArray(t)?de.array:t===null?de.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?de.promise:typeof Map<"u"&&t instanceof Map?de.map:typeof Set<"u"&&t instanceof Set?de.set:typeof Date<"u"&&t instanceof Date?de.date:de.object;default:return de.unknown}},ee=Ne.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class An extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,d=0;for(;d<o.path.length;){const m=o.path[d];d===o.path.length-1?(a[m]=a[m]||{_errors:[]},a[m]._errors.push(n(o))):a[m]=a[m]||{_errors:[]},a=a[m],d++}}};return s(this),r}static assert(e){if(!(e instanceof An))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ne.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}An.create=t=>new An(t);const Ka=(t,e)=>{let n;switch(t.code){case ee.invalid_type:t.received===de.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case ee.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Ne.jsonStringifyReplacer)}`;break;case ee.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ne.joinValues(t.keys,", ")}`;break;case ee.invalid_union:n="Invalid input";break;case ee.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ne.joinValues(t.options)}`;break;case ee.invalid_enum_value:n=`Invalid enum value. Expected ${Ne.joinValues(t.options)}, received '${t.received}'`;break;case ee.invalid_arguments:n="Invalid function arguments";break;case ee.invalid_return_type:n="Invalid function return type";break;case ee.invalid_date:n="Invalid date";break;case ee.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Ne.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case ee.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case ee.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case ee.custom:n="Invalid input";break;case ee.invalid_intersection_types:n="Intersection results could not be merged";break;case ee.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case ee.not_finite:n="Number must be finite";break;default:n=e.defaultError,Ne.assertNever(t)}return{message:n}};let j1=Ka;function V1(){return j1}const G1=t=>{const{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="";const d=r.filter(m=>!!m).slice().reverse();for(const m of d)a=m(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}};function ie(t,e){const n=V1(),r=G1({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Ka?void 0:Ka].filter(s=>!!s)});t.common.issues.push(r)}class qt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const s of n){if(s.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const s of n){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return qt.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}}const pe=Object.freeze({status:"aborted"}),Is=t=>({status:"dirty",value:t}),Qt=t=>({status:"valid",value:t}),Zl=t=>t.status==="aborted",Yl=t=>t.status==="dirty",Cr=t=>t.status==="valid",Ti=t=>typeof Promise<"u"&&t instanceof Promise;var le;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(le||(le={}));class zn{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Jl=(t,e)=>{if(Cr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new An(t.common.issues);return this._error=n,this._error}}};function Ae(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{const{message:d}=t;return o.code==="invalid_enum_value"?{message:d??a.defaultError}:typeof a.data>"u"?{message:d??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:d??n??a.defaultError}},description:s}}class Te{get description(){return this._def.description}_getType(e){return $n(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:$n(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new qt,ctx:{common:e.parent.common,data:e.data,parsedType:$n(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Ti(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$n(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Jl(r,s)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$n(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:n});return Cr(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Cr(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$n(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Ti(s)?s:Promise.resolve(s));return Jl(r,i)}refine(e,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=e(s),a=()=>i.addIssue({code:ee.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new or({schema:this,typeName:me.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Sn.create(this,this._def)}nullable(){return ar.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dn.create(this)}promise(){return Mi.create(this,this._def)}or(e){return Ii.create([this,e],this._def)}and(e){return Ni.create(this,e,this._def)}transform(e){return new or({...Ae(this._def),schema:this,typeName:me.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new Bi({...Ae(this._def),innerType:this,defaultValue:n,typeName:me.ZodDefault})}brand(){return new cf({typeName:me.ZodBranded,type:this,...Ae(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new ki({...Ae(this._def),innerType:this,catchValue:n,typeName:me.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return nc.create(this,e)}readonly(){return Li.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const H1=/^c[^\s-]{8,}$/i,q1=/^[0-9a-z]+$/,K1=/^[0-9A-HJKMNP-TV-Z]{26}$/i,W1=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Z1=/^[a-z0-9_-]{21}$/i,Y1=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,J1=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,X1=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Q1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Wa;const eb=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,tb=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,nb=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,rb=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,sb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ib=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Xl="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ob=new RegExp(`^${Xl}$`);function Ql(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function ab(t){return new RegExp(`^${Ql(t)}$`)}function cb(t){let e=`${Xl}T${Ql(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function ub(t,e){return!!((e==="v4"||!e)&&eb.test(t)||(e==="v6"||!e)&&nb.test(t))}function db(t,e){if(!Y1.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function lb(t,e){return!!((e==="v4"||!e)&&tb.test(t)||(e==="v6"||!e)&&rb.test(t))}class jn extends Te{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==de.string){const i=this._getOrReturnCtx(e);return ie(i,{code:ee.invalid_type,expected:de.string,received:i.parsedType}),pe}const r=new qt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?ie(s,{code:ee.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&ie(s,{code:ee.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")X1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"email",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Wa||(Wa=new RegExp(Q1,"u")),Wa.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"emoji",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")W1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"uuid",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Z1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"nanoid",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")H1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"cuid",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")q1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"cuid2",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")K1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"ulid",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),ie(s,{validation:"url",code:ee.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"regex",code:ee.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?cb(i).test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?ob.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?ab(i).test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?J1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"duration",code:ee.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?ub(e.data,i.version)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"ip",code:ee.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?db(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"jwt",code:ee.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?lb(e.data,i.version)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"cidr",code:ee.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?sb.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"base64",code:ee.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?ib.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"base64url",code:ee.invalid_string,message:i.message}),r.dirty()):Ne.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:ee.invalid_string,...le.errToObj(r)})}_addCheck(e){return new jn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...le.errToObj(e)})}url(e){return this._addCheck({kind:"url",...le.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...le.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...le.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...le.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...le.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...le.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...le.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...le.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...le.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...le.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...le.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...le.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...le.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...le.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...le.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...le.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...le.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...le.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...le.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...le.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...le.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...le.errToObj(n)})}nonempty(e){return this.min(1,le.errToObj(e))}trim(){return new jn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new jn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new jn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}jn.create=t=>new jn({checks:[],typeName:me.ZodString,coerce:t?.coerce??!1,...Ae(t)});function fb(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}class Mr extends Te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==de.number){const i=this._getOrReturnCtx(e);return ie(i,{code:ee.invalid_type,expected:de.number,received:i.parsedType}),pe}let r;const s=new qt;for(const i of this._def.checks)i.kind==="int"?Ne.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?fb(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.not_finite,message:i.message}),s.dirty()):Ne.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,le.toString(n))}gt(e,n){return this.setLimit("min",e,!1,le.toString(n))}lte(e,n){return this.setLimit("max",e,!0,le.toString(n))}lt(e,n){return this.setLimit("max",e,!1,le.toString(n))}setLimit(e,n,r,s){return new Mr({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:le.toString(s)}]})}_addCheck(e){return new Mr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:le.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:le.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:le.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:le.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:le.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:le.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Ne.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Mr.create=t=>new Mr({checks:[],typeName:me.ZodNumber,coerce:t?.coerce||!1,...Ae(t)});class Ns extends Te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==de.bigint)return this._getInvalidInput(e);let r;const s=new qt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Ne.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return ie(n,{code:ee.invalid_type,expected:de.bigint,received:n.parsedType}),pe}gte(e,n){return this.setLimit("min",e,!0,le.toString(n))}gt(e,n){return this.setLimit("min",e,!1,le.toString(n))}lte(e,n){return this.setLimit("max",e,!0,le.toString(n))}lt(e,n){return this.setLimit("max",e,!1,le.toString(n))}setLimit(e,n,r,s){return new Ns({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:le.toString(s)}]})}_addCheck(e){return new Ns({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:le.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:le.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Ns.create=t=>new Ns({checks:[],typeName:me.ZodBigInt,coerce:t?.coerce??!1,...Ae(t)});class Za extends Te{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==de.boolean){const r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:de.boolean,received:r.parsedType}),pe}return Qt(e.data)}}Za.create=t=>new Za({typeName:me.ZodBoolean,coerce:t?.coerce||!1,...Ae(t)});class Oi extends Te{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==de.date){const i=this._getOrReturnCtx(e);return ie(i,{code:ee.invalid_type,expected:de.date,received:i.parsedType}),pe}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return ie(i,{code:ee.invalid_date}),pe}const r=new qt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Ne.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Oi({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:le.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:le.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}Oi.create=t=>new Oi({checks:[],coerce:t?.coerce||!1,typeName:me.ZodDate,...Ae(t)});class ef extends Te{_parse(e){if(this._getType(e)!==de.symbol){const r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:de.symbol,received:r.parsedType}),pe}return Qt(e.data)}}ef.create=t=>new ef({typeName:me.ZodSymbol,...Ae(t)});class Ya extends Te{_parse(e){if(this._getType(e)!==de.undefined){const r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:de.undefined,received:r.parsedType}),pe}return Qt(e.data)}}Ya.create=t=>new Ya({typeName:me.ZodUndefined,...Ae(t)});class Ja extends Te{_parse(e){if(this._getType(e)!==de.null){const r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:de.null,received:r.parsedType}),pe}return Qt(e.data)}}Ja.create=t=>new Ja({typeName:me.ZodNull,...Ae(t)});class tf extends Te{constructor(){super(...arguments),this._any=!0}_parse(e){return Qt(e.data)}}tf.create=t=>new tf({typeName:me.ZodAny,...Ae(t)});class nf extends Te{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Qt(e.data)}}nf.create=t=>new nf({typeName:me.ZodUnknown,...Ae(t)});class Vn extends Te{_parse(e){const n=this._getOrReturnCtx(e);return ie(n,{code:ee.invalid_type,expected:de.never,received:n.parsedType}),pe}}Vn.create=t=>new Vn({typeName:me.ZodNever,...Ae(t)});class rf extends Te{_parse(e){if(this._getType(e)!==de.undefined){const r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:de.void,received:r.parsedType}),pe}return Qt(e.data)}}rf.create=t=>new rf({typeName:me.ZodVoid,...Ae(t)});class dn extends Te{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==de.array)return ie(n,{code:ee.invalid_type,expected:de.array,received:n.parsedType}),pe;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(ie(n,{code:o?ee.too_big:ee.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(ie(n,{code:ee.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(ie(n,{code:ee.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new zn(n,o,n.path,a)))).then(o=>qt.mergeArray(r,o));const i=[...n.data].map((o,a)=>s.type._parseSync(new zn(n,o,n.path,a)));return qt.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new dn({...this._def,minLength:{value:e,message:le.toString(n)}})}max(e,n){return new dn({...this._def,maxLength:{value:e,message:le.toString(n)}})}length(e,n){return new dn({...this._def,exactLength:{value:e,message:le.toString(n)}})}nonempty(e){return this.min(1,e)}}dn.create=(t,e)=>new dn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:me.ZodArray,...Ae(e)});function Br(t){if(t instanceof Qe){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Sn.create(Br(r))}return new Qe({...t._def,shape:()=>e})}else return t instanceof dn?new dn({...t._def,type:Br(t.element)}):t instanceof Sn?Sn.create(Br(t.unwrap())):t instanceof ar?ar.create(Br(t.unwrap())):t instanceof sr?sr.create(t.items.map(e=>Br(e))):t}class Qe extends Te{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=Ne.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==de.object){const m=this._getOrReturnCtx(e);return ie(m,{code:ee.invalid_type,expected:de.object,received:m.parsedType}),pe}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Vn&&this._def.unknownKeys==="strip"))for(const m in s.data)o.includes(m)||a.push(m);const d=[];for(const m of o){const g=i[m],x=s.data[m];d.push({key:{status:"valid",value:m},value:g._parse(new zn(s,x,s.path,m)),alwaysSet:m in s.data})}if(this._def.catchall instanceof Vn){const m=this._def.unknownKeys;if(m==="passthrough")for(const g of a)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(m==="strict")a.length>0&&(ie(s,{code:ee.unrecognized_keys,keys:a}),r.dirty());else if(m!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const m=this._def.catchall;for(const g of a){const x=s.data[g];d.push({key:{status:"valid",value:g},value:m._parse(new zn(s,x,s.path,g)),alwaysSet:g in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const m=[];for(const g of d){const x=await g.key,O=await g.value;m.push({key:x,value:O,alwaysSet:g.alwaysSet})}return m}).then(m=>qt.mergeObjectSync(r,m)):qt.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return le.errToObj,new Qe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{const s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:le.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Qe({...this._def,unknownKeys:"strip"})}passthrough(){return new Qe({...this._def,unknownKeys:"passthrough"})}extend(e){return new Qe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Qe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:me.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Qe({...this._def,catchall:e})}pick(e){const n={};for(const r of Ne.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Qe({...this._def,shape:()=>n})}omit(e){const n={};for(const r of Ne.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new Qe({...this._def,shape:()=>n})}deepPartial(){return Br(this)}partial(e){const n={};for(const r of Ne.objectKeys(this.shape)){const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new Qe({...this._def,shape:()=>n})}required(e){const n={};for(const r of Ne.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Sn;)i=i._def.innerType;n[r]=i}return new Qe({...this._def,shape:()=>n})}keyof(){return of(Ne.objectKeys(this.shape))}}Qe.create=(t,e)=>new Qe({shape:()=>t,unknownKeys:"strip",catchall:Vn.create(),typeName:me.ZodObject,...Ae(e)}),Qe.strictCreate=(t,e)=>new Qe({shape:()=>t,unknownKeys:"strict",catchall:Vn.create(),typeName:me.ZodObject,...Ae(e)}),Qe.lazycreate=(t,e)=>new Qe({shape:t,unknownKeys:"strip",catchall:Vn.create(),typeName:me.ZodObject,...Ae(e)});class Ii extends Te{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new An(a.ctx.common.issues));return ie(n,{code:ee.invalid_union,unionErrors:o}),pe}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const d of r){const m={...n,common:{...n.common,issues:[]},parent:null},g=d._parseSync({data:n.data,path:n.path,parent:m});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:m}),m.common.issues.length&&o.push(m.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(d=>new An(d));return ie(n,{code:ee.invalid_union,unionErrors:a}),pe}}get options(){return this._def.options}}Ii.create=(t,e)=>new Ii({options:t,typeName:me.ZodUnion,...Ae(e)});const xn=t=>t instanceof ec?xn(t.schema):t instanceof or?xn(t.innerType()):t instanceof Ci?[t.value]:t instanceof ir?t.options:t instanceof tc?Ne.objectValues(t.enum):t instanceof Bi?xn(t._def.innerType):t instanceof Ya?[void 0]:t instanceof Ja?[null]:t instanceof Sn?[void 0,...xn(t.unwrap())]:t instanceof ar?[null,...xn(t.unwrap())]:t instanceof cf||t instanceof Li?xn(t.unwrap()):t instanceof ki?xn(t._def.innerType):[];class Xa extends Te{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==de.object)return ie(n,{code:ee.invalid_type,expected:de.object,received:n.parsedType}),pe;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(ie(n,{code:ee.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){const s=new Map;for(const i of n){const o=xn(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new Xa({typeName:me.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...Ae(r)})}}function Qa(t,e){const n=$n(t),r=$n(e);if(t===e)return{valid:!0,data:t};if(n===de.object&&r===de.object){const s=Ne.objectKeys(e),i=Ne.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(const a of i){const d=Qa(t[a],e[a]);if(!d.valid)return{valid:!1};o[a]=d.data}return{valid:!0,data:o}}else if(n===de.array&&r===de.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const o=t[i],a=e[i],d=Qa(o,a);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return n===de.date&&r===de.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Ni extends Te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Zl(i)||Zl(o))return pe;const a=Qa(i.value,o.value);return a.valid?((Yl(i)||Yl(o))&&n.dirty(),{status:n.value,value:a.data}):(ie(r,{code:ee.invalid_intersection_types}),pe)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ni.create=(t,e,n)=>new Ni({left:t,right:e,typeName:me.ZodIntersection,...Ae(n)});class sr extends Te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==de.array)return ie(r,{code:ee.invalid_type,expected:de.array,received:r.parsedType}),pe;if(r.data.length<this._def.items.length)return ie(r,{code:ee.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&r.data.length>this._def.items.length&&(ie(r,{code:ee.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,a)=>{const d=this._def.items[a]||this._def.rest;return d?d._parse(new zn(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>qt.mergeArray(n,o)):qt.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new sr({...this._def,rest:e})}}sr.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new sr({items:t,typeName:me.ZodTuple,rest:null,...Ae(e)})};class sf extends Te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==de.map)return ie(r,{code:ee.invalid_type,expected:de.map,received:r.parsedType}),pe;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,d],m)=>({key:s._parse(new zn(r,a,r.path,[m,"key"])),value:i._parse(new zn(r,d,r.path,[m,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const d of o){const m=await d.key,g=await d.value;if(m.status==="aborted"||g.status==="aborted")return pe;(m.status==="dirty"||g.status==="dirty")&&n.dirty(),a.set(m.value,g.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const d of o){const m=d.key,g=d.value;if(m.status==="aborted"||g.status==="aborted")return pe;(m.status==="dirty"||g.status==="dirty")&&n.dirty(),a.set(m.value,g.value)}return{status:n.value,value:a}}}}sf.create=(t,e,n)=>new sf({valueType:e,keyType:t,typeName:me.ZodMap,...Ae(n)});class Cs extends Te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==de.set)return ie(r,{code:ee.invalid_type,expected:de.set,received:r.parsedType}),pe;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(ie(r,{code:ee.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(ie(r,{code:ee.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(d){const m=new Set;for(const g of d){if(g.status==="aborted")return pe;g.status==="dirty"&&n.dirty(),m.add(g.value)}return{status:n.value,value:m}}const a=[...r.data.values()].map((d,m)=>i._parse(new zn(r,d,r.path,m)));return r.common.async?Promise.all(a).then(d=>o(d)):o(a)}min(e,n){return new Cs({...this._def,minSize:{value:e,message:le.toString(n)}})}max(e,n){return new Cs({...this._def,maxSize:{value:e,message:le.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Cs.create=(t,e)=>new Cs({valueType:t,minSize:null,maxSize:null,typeName:me.ZodSet,...Ae(e)});class ec extends Te{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}ec.create=(t,e)=>new ec({getter:t,typeName:me.ZodLazy,...Ae(e)});class Ci extends Te{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return ie(n,{received:n.data,code:ee.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ci.create=(t,e)=>new Ci({value:t,typeName:me.ZodLiteral,...Ae(e)});function of(t,e){return new ir({values:t,typeName:me.ZodEnum,...Ae(e)})}class ir extends Te{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return ie(n,{expected:Ne.joinValues(r),received:n.parsedType,code:ee.invalid_type}),pe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return ie(n,{received:n.data,code:ee.invalid_enum_value,options:r}),pe}return Qt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return ir.create(e,{...this._def,...n})}exclude(e,n=this._def){return ir.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}ir.create=of;class tc extends Te{_parse(e){const n=Ne.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==de.string&&r.parsedType!==de.number){const s=Ne.objectValues(n);return ie(r,{expected:Ne.joinValues(s),received:r.parsedType,code:ee.invalid_type}),pe}if(this._cache||(this._cache=new Set(Ne.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=Ne.objectValues(n);return ie(r,{received:r.data,code:ee.invalid_enum_value,options:s}),pe}return Qt(e.data)}get enum(){return this._def.values}}tc.create=(t,e)=>new tc({values:t,typeName:me.ZodNativeEnum,...Ae(e)});class Mi extends Te{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==de.promise&&n.common.async===!1)return ie(n,{code:ee.invalid_type,expected:de.promise,received:n.parsedType}),pe;const r=n.parsedType===de.promise?n.data:Promise.resolve(n.data);return Qt(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Mi.create=(t,e)=>new Mi({type:t,typeName:me.ZodPromise,...Ae(e)});class or extends Te{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===me.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{ie(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return pe;const d=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return d.status==="aborted"?pe:d.status==="dirty"||n.value==="dirty"?Is(d.value):d});{if(n.value==="aborted")return pe;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?pe:a.status==="dirty"||n.value==="dirty"?Is(a.value):a}}if(s.type==="refinement"){const o=a=>{const d=s.refinement(a,i);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?pe:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?pe:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Cr(o))return pe;const a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Cr(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):pe);Ne.assertNever(s)}}or.create=(t,e,n)=>new or({schema:t,typeName:me.ZodEffects,effect:e,...Ae(n)}),or.createWithPreprocess=(t,e,n)=>new or({schema:e,effect:{type:"preprocess",transform:t},typeName:me.ZodEffects,...Ae(n)});class Sn extends Te{_parse(e){return this._getType(e)===de.undefined?Qt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Sn.create=(t,e)=>new Sn({innerType:t,typeName:me.ZodOptional,...Ae(e)});class ar extends Te{_parse(e){return this._getType(e)===de.null?Qt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ar.create=(t,e)=>new ar({innerType:t,typeName:me.ZodNullable,...Ae(e)});class Bi extends Te{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===de.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Bi.create=(t,e)=>new Bi({innerType:t,typeName:me.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ae(e)});class ki extends Te{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ti(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new An(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new An(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ki.create=(t,e)=>new ki({innerType:t,typeName:me.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ae(e)});class af extends Te{_parse(e){if(this._getType(e)!==de.nan){const r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:de.nan,received:r.parsedType}),pe}return{status:"valid",value:e.data}}}af.create=t=>new af({typeName:me.ZodNaN,...Ae(t)});class cf extends Te{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class nc extends Te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?pe:i.status==="dirty"?(n.dirty(),Is(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?pe:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new nc({in:e,out:n,typeName:me.ZodPipeline})}}class Li extends Te{_parse(e){const n=this._def.innerType._parse(e),r=s=>(Cr(s)&&(s.value=Object.freeze(s.value)),s);return Ti(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}Li.create=(t,e)=>new Li({innerType:t,typeName:me.ZodReadonly,...Ae(e)});var me;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(me||(me={}));const Ke=jn.create,uf=Mr.create,hb=Za.create;Vn.create;const cr=dn.create,Et=Qe.create,Pi=Ii.create,df=Xa.create;Ni.create,sr.create;const Tt=Ci.create,rc=ir.create;Mi.create,Sn.create,ar.create;const pb=/[@#$%^&*+=/\\|~«»]/,mb=/(!{2,}|\?{2,}|-{2,})/,gb=/[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u,kr=({max:t,noSpaces:e}={})=>(e?Ke().max(t??Number.POSITIVE_INFINITY).regex(/^\S*$/,"Spaces are not allowed"):Ke().max(t??Number.POSITIVE_INFINITY)).refine(r=>!gb.test(r),{message:"Emojis and symbols are not allowed"}).refine(r=>!pb.test(r),{message:"Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, «, ») are not allowed"}).refine(r=>!mb.test(r),{message:"Repeated punctuations (!!, ??, --) are not allowed"}),Pt=Ke().url().startsWith("https://",{message:"Must be an https url"}).max(1024).refine(t=>!t.includes(" "),{message:"URL must not contain spaces"}).refine(t=>{try{const e=new URL(t).hostname;return!(e==="localhost"||e.endsWith(".localhost")||/^(\d{1,3}\.){3}\d{1,3}$/.test(e)||e.startsWith("[")&&e.endsWith("]"))}catch{return!1}},{message:"URL must not use IP addresses or localhost"}),sc=Ke().max(32),lf=Ke().max(32),yb=/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/(?:[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}(?:\/[-.%a-zA-Z0-9]{1,78})?|native)$/,bb=Ke().regex(yb,{message:"Invalid CAIP-19 asset ID"}),ic=Ke().regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i,{message:"Invalid hex color code. It should be in the format #RRGGBB or #RGB."}),_b=/^(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,wb=Ke().max(1024).regex(_b,{message:"Must be a valid domain name (e.g., example.com, sub.example.com)"}).refine(t=>!t.includes("://"),{message:"Domain must not include protocol (http://, https://, etc.)"}).refine(t=>!t.includes("/"),{message:"Domain must not include path separators"}).refine(t=>!t.includes("@"),{message:"Domain must not include @ symbol"}).refine(t=>!t.includes(":"),{message:"Domain must not include port numbers"}),Eb=Pi([Tt("1:1"),Tt("3:2")]),vb=Et({header:Ke(),payload:Ke(),signature:Ke()});Et({fid:uf(),type:Tt("app_key"),key:Ke().startsWith("0x")});const Rb=Et({type:Tt("launch_frame"),name:sc,url:Pt.optional(),splashImageUrl:Pt.optional(),splashBackgroundColor:ic.optional()}),Ab=Et({type:Tt("launch_miniapp"),name:sc,url:Pt.optional(),splashImageUrl:Pt.optional(),splashBackgroundColor:ic.optional()}),xb=Et({type:Tt("view_token"),token:bb}),Sb=df("type",[Ab,xb,Rb]),Tb=Et({title:lf,action:Sb});Et({version:Pi([Ke(),uf()]).transform(t=>String(t)).pipe(Pi([Tt("next"),Tt("1")])),imageUrl:Pt,aspectRatio:Eb.optional(),button:Tb});const ff=Et({url:Ke(),token:Ke()});Et({notificationId:Ke().max(128),title:Ke().max(32),body:Ke().max(128),targetUrl:Pt,tokens:Ke().array().max(100)}),Et({result:Et({successfulTokens:cr(Ke()),invalidTokens:cr(Ke()),rateLimitedTokens:cr(Ke())})});const Ob=Et({event:Tt("miniapp_added"),notificationDetails:ff.optional()}),Ib=Et({event:Tt("miniapp_removed")}),Nb=Et({event:Tt("notifications_enabled"),notificationDetails:ff.required()}),Cb=Et({event:Tt("notifications_disabled")});df("event",[Ob,Ib,Nb,Cb]);const Mb=["wallet.getEthereumProvider","wallet.getSolanaProvider","actions.ready","actions.openUrl","actions.close","actions.setPrimaryButton","actions.addMiniApp","actions.signIn","actions.viewCast","actions.viewProfile","actions.composeCast","actions.viewToken","actions.sendToken","actions.swapToken","actions.openMiniApp","actions.requestCameraAndMicrophoneAccess","experimental.signManifest","haptics.impactOccurred","haptics.notificationOccurred","haptics.selectionChanged","back"],Bb=rc(["games","social","finance","utility","productivity","health-fitness","news-media","music","shopping","education","developer-tools","entertainment","art-creativity"]),kb=Pi([Tt("0.0.0"),Tt("0.0.1"),Tt("1"),Tt("next")]),Lb=kr({max:30}),Pb=kr({max:170}),Ub=cr(Pt).max(3),Db=cr(kr({max:20,noSpaces:!0})).max(5),Fb=kr({max:30}),$b=kr({max:30}),zb=kr({max:100}),jb=hb(),Vb=["eip155:1","eip155:8453","eip155:42161","eip155:421614","eip155:84532","eip155:666666666","eip155:100","eip155:10","eip155:11155420","eip155:137","eip155:11155111","eip155:7777777","eip155:130","eip155:10143","eip155:42220","eip155:999","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"];function hf(t){const e=new Set(t);return Array.from(e)}const Gb=cr(rc(Vb)).transform(hf),Hb=cr(rc(Mb)).transform(hf),pf=Et({version:kb,name:sc,iconUrl:Pt,homeUrl:Pt,imageUrl:Pt.optional(),buttonTitle:lf.optional(),splashImageUrl:Pt.optional(),splashBackgroundColor:ic.optional(),webhookUrl:Pt.optional(),subtitle:Lb.optional(),description:Pb.optional(),screenshotUrls:Ub.optional(),primaryCategory:Bb.optional(),tags:Db.optional(),heroImageUrl:Pt.optional(),tagline:Fb.optional(),ogTitle:$b.optional(),ogDescription:zb.optional(),ogImageUrl:Pt.optional(),noindex:jb.optional(),requiredChains:Gb.optional(),requiredCapabilities:Hb.optional(),castShareUrl:Pt.optional(),canonicalDomain:wb.optional()}).refine(t=>{if(t.castShareUrl===void 0)return!0;try{const e=new URL(t.homeUrl).hostname,n=new URL(t.castShareUrl).hostname;return e===n}catch{return!1}},{message:"castShareUrl must have the same domain as homeUrl",path:["castShareUrl"]});Et({accountAssociation:vb,miniapp:pf.optional(),frame:pf.optional()}).refine(t=>t.frame&&t.miniapp?JSON.stringify(t.frame)===JSON.stringify(t.miniapp):!0,{message:'If both "frame" and "miniapp" are provided, they must be identical',path:["frame","miniapp"]}).transform(t=>({...t,frame:t.frame??t.miniapp}));var oc={},Ms={},mf;function qb(){if(mf)return Ms;mf=1,Ms.byteLength=a,Ms.toByteArray=m,Ms.fromByteArray=O;for(var t=[],e=[],n=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,i=r.length;s<i;++s)t[s]=r[s],e[r.charCodeAt(s)]=s;e[45]=62,e[95]=63;function o(N){var F=N.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var C=N.indexOf("=");C===-1&&(C=F);var k=C===F?0:4-C%4;return[C,k]}function a(N){var F=o(N),C=F[0],k=F[1];return(C+k)*3/4-k}function d(N,F,C){return(F+C)*3/4-C}function m(N){var F,C=o(N),k=C[0],K=C[1],Y=new n(d(N,k,K)),V=0,L=K>0?k-4:k,z;for(z=0;z<L;z+=4)F=e[N.charCodeAt(z)]<<18|e[N.charCodeAt(z+1)]<<12|e[N.charCodeAt(z+2)]<<6|e[N.charCodeAt(z+3)],Y[V++]=F>>16&255,Y[V++]=F>>8&255,Y[V++]=F&255;return K===2&&(F=e[N.charCodeAt(z)]<<2|e[N.charCodeAt(z+1)]>>4,Y[V++]=F&255),K===1&&(F=e[N.charCodeAt(z)]<<10|e[N.charCodeAt(z+1)]<<4|e[N.charCodeAt(z+2)]>>2,Y[V++]=F>>8&255,Y[V++]=F&255),Y}function g(N){return t[N>>18&63]+t[N>>12&63]+t[N>>6&63]+t[N&63]}function x(N,F,C){for(var k,K=[],Y=F;Y<C;Y+=3)k=(N[Y]<<16&16711680)+(N[Y+1]<<8&65280)+(N[Y+2]&255),K.push(g(k));return K.join("")}function O(N){for(var F,C=N.length,k=C%3,K=[],Y=16383,V=0,L=C-k;V<L;V+=Y)K.push(x(N,V,V+Y>L?L:V+Y));return k===1?(F=N[C-1],K.push(t[F>>2]+t[F<<4&63]+"==")):k===2&&(F=(N[C-2]<<8)+N[C-1],K.push(t[F>>10]+t[F>>4&63]+t[F<<2&63]+"=")),K.join("")}return Ms}var Ui={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var gf;function Kb(){return gf||(gf=1,Ui.read=function(t,e,n,r,s){var i,o,a=s*8-r-1,d=(1<<a)-1,m=d>>1,g=-7,x=n?s-1:0,O=n?-1:1,N=t[e+x];for(x+=O,i=N&(1<<-g)-1,N>>=-g,g+=a;g>0;i=i*256+t[e+x],x+=O,g-=8);for(o=i&(1<<-g)-1,i>>=-g,g+=r;g>0;o=o*256+t[e+x],x+=O,g-=8);if(i===0)i=1-m;else{if(i===d)return o?NaN:(N?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-m}return(N?-1:1)*o*Math.pow(2,i-r)},Ui.write=function(t,e,n,r,s,i){var o,a,d,m=i*8-s-1,g=(1<<m)-1,x=g>>1,O=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=r?0:i-1,F=r?1:-1,C=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=g):(o=Math.floor(Math.log(e)/Math.LN2),e*(d=Math.pow(2,-o))<1&&(o--,d*=2),o+x>=1?e+=O/d:e+=O*Math.pow(2,1-x),e*d>=2&&(o++,d/=2),o+x>=g?(a=0,o=g):o+x>=1?(a=(e*d-1)*Math.pow(2,s),o=o+x):(a=e*Math.pow(2,x-1)*Math.pow(2,s),o=0));s>=8;t[n+N]=a&255,N+=F,a/=256,s-=8);for(o=o<<s|a,m+=s;m>0;t[n+N]=o&255,N+=F,o/=256,m-=8);t[n+N-F]|=C*128}),Ui}/*!
24
24
  * The buffer module from node.js, for the browser.
25
25
  *
26
26
  * @author Feross Aboukhadijeh <https://feross.org>
27
27
  * @license MIT
28
- */var wf;function lc(){return wf||(wf=1,(function(t){const e=Xb(),n=Qb(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=Y,t.INSPECT_MAX_BYTES=50;const s=2147483647;t.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const b=new Uint8Array(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,Uint8Array.prototype),Object.setPrototypeOf(b,f),b.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(b){if(b>s)throw new RangeError('The value "'+b+'" is invalid for option "size"');const f=new Uint8Array(b);return Object.setPrototypeOf(f,a.prototype),f}function a(b,f,h){if(typeof b=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return S(b)}return d(b,f,h)}a.poolSize=8192;function d(b,f,h){if(typeof b=="string")return I(b,f);if(ArrayBuffer.isView(b))return F(b);if(b==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b);if(Qt(b,ArrayBuffer)||b&&Qt(b.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Qt(b,SharedArrayBuffer)||b&&Qt(b.buffer,SharedArrayBuffer)))return M(b,f,h);if(typeof b=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const x=b.valueOf&&b.valueOf();if(x!=null&&x!==b)return a.from(x,f,h);const D=B(b);if(D)return D;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof b[Symbol.toPrimitive]=="function")return a.from(b[Symbol.toPrimitive]("string"),f,h);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b)}a.from=function(b,f,h){return d(b,f,h)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function m(b){if(typeof b!="number")throw new TypeError('"size" argument must be of type number');if(b<0)throw new RangeError('The value "'+b+'" is invalid for option "size"')}function g(b,f,h){return m(b),b<=0?o(b):f!==void 0?typeof h=="string"?o(b).fill(f,h):o(b).fill(f):o(b)}a.alloc=function(b,f,h){return g(b,f,h)};function S(b){return m(b),o(b<0?0:K(b)|0)}a.allocUnsafe=function(b){return S(b)},a.allocUnsafeSlow=function(b){return S(b)};function I(b,f){if((typeof f!="string"||f==="")&&(f="utf8"),!a.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const h=z(b,f)|0;let x=o(h);const D=x.write(b,f);return D!==h&&(x=x.slice(0,D)),x}function N(b){const f=b.length<0?0:K(b.length)|0,h=o(f);for(let x=0;x<f;x+=1)h[x]=b[x]&255;return h}function F(b){if(Qt(b,Uint8Array)){const f=new Uint8Array(b);return M(f.buffer,f.byteOffset,f.byteLength)}return N(b)}function M(b,f,h){if(f<0||b.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(b.byteLength<f+(h||0))throw new RangeError('"length" is outside of buffer bounds');let x;return f===void 0&&h===void 0?x=new Uint8Array(b):h===void 0?x=new Uint8Array(b,f):x=new Uint8Array(b,f,h),Object.setPrototypeOf(x,a.prototype),x}function B(b){if(a.isBuffer(b)){const f=K(b.length)|0,h=o(f);return h.length===0||b.copy(h,0,0,f),h}if(b.length!==void 0)return typeof b.length!="number"||Ge(b.length)?o(0):N(b);if(b.type==="Buffer"&&Array.isArray(b.data))return N(b.data)}function K(b){if(b>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return b|0}function Y(b){return+b!=b&&(b=0),a.alloc(+b)}a.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==a.prototype},a.compare=function(f,h){if(Qt(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),Qt(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),!a.isBuffer(f)||!a.isBuffer(h))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===h)return 0;let x=f.length,D=h.length;for(let $=0,Z=Math.min(x,D);$<Z;++$)if(f[$]!==h[$]){x=f[$],D=h[$];break}return x<D?-1:D<x?1:0},a.isEncoding=function(f){switch(String(f).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(f,h){if(!Array.isArray(f))throw new TypeError('"list" argument must be an Array of Buffers');if(f.length===0)return a.alloc(0);let x;if(h===void 0)for(h=0,x=0;x<f.length;++x)h+=f[x].length;const D=a.allocUnsafe(h);let $=0;for(x=0;x<f.length;++x){let Z=f[x];if(Qt(Z,Uint8Array))$+Z.length>D.length?(a.isBuffer(Z)||(Z=a.from(Z)),Z.copy(D,$)):Uint8Array.prototype.set.call(D,Z,$);else if(a.isBuffer(Z))Z.copy(D,$);else throw new TypeError('"list" argument must be an Array of Buffers');$+=Z.length}return D};function z(b,f){if(a.isBuffer(b))return b.length;if(ArrayBuffer.isView(b)||Qt(b,ArrayBuffer))return b.byteLength;if(typeof b!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof b);const h=b.length,x=arguments.length>2&&arguments[2]===!0;if(!x&&h===0)return 0;let D=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return h;case"utf8":case"utf-8":return Le(b).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h*2;case"hex":return h>>>1;case"base64":return $e(b).length;default:if(D)return x?-1:Le(b).length;f=(""+f).toLowerCase(),D=!0}}a.byteLength=z;function U(b,f,h){let x=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((h===void 0||h>this.length)&&(h=this.length),h<=0)||(h>>>=0,f>>>=0,h<=f))return"";for(b||(b="utf8");;)switch(b){case"hex":return R(this,f,h);case"utf8":case"utf-8":return c(this,f,h);case"ascii":return A(this,f,h);case"latin1":case"binary":return v(this,f,h);case"base64":return w(this,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,f,h);default:if(x)throw new TypeError("Unknown encoding: "+b);b=(b+"").toLowerCase(),x=!0}}a.prototype._isBuffer=!0;function j(b,f,h){const x=b[f];b[f]=b[h],b[h]=x}a.prototype.swap16=function(){const f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let h=0;h<f;h+=2)j(this,h,h+1);return this},a.prototype.swap32=function(){const f=this.length;if(f%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let h=0;h<f;h+=4)j(this,h,h+3),j(this,h+1,h+2);return this},a.prototype.swap64=function(){const f=this.length;if(f%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let h=0;h<f;h+=8)j(this,h,h+7),j(this,h+1,h+6),j(this,h+2,h+5),j(this,h+3,h+4);return this},a.prototype.toString=function(){const f=this.length;return f===0?"":arguments.length===0?c(this,0,f):U.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(f){if(!a.isBuffer(f))throw new TypeError("Argument must be a Buffer");return this===f?!0:a.compare(this,f)===0},a.prototype.inspect=function(){let f="";const h=t.INSPECT_MAX_BYTES;return f=this.toString("hex",0,h).replace(/(.{2})/g,"$1 ").trim(),this.length>h&&(f+=" ... "),"<Buffer "+f+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(f,h,x,D,$){if(Qt(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),!a.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(h===void 0&&(h=0),x===void 0&&(x=f?f.length:0),D===void 0&&(D=0),$===void 0&&($=this.length),h<0||x>f.length||D<0||$>this.length)throw new RangeError("out of range index");if(D>=$&&h>=x)return 0;if(D>=$)return-1;if(h>=x)return 1;if(h>>>=0,x>>>=0,D>>>=0,$>>>=0,this===f)return 0;let Z=$-D,Ae=x-h;const Ee=Math.min(Z,Ae),ye=this.slice(D,$),ze=f.slice(h,x);for(let pe=0;pe<Ee;++pe)if(ye[pe]!==ze[pe]){Z=ye[pe],Ae=ze[pe];break}return Z<Ae?-1:Ae<Z?1:0};function J(b,f,h,x,D){if(b.length===0)return-1;if(typeof h=="string"?(x=h,h=0):h>2147483647?h=2147483647:h<-2147483648&&(h=-2147483648),h=+h,Ge(h)&&(h=D?0:b.length-1),h<0&&(h=b.length+h),h>=b.length){if(D)return-1;h=b.length-1}else if(h<0)if(D)h=0;else return-1;if(typeof f=="string"&&(f=a.from(f,x)),a.isBuffer(f))return f.length===0?-1:ne(b,f,h,x,D);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?D?Uint8Array.prototype.indexOf.call(b,f,h):Uint8Array.prototype.lastIndexOf.call(b,f,h):ne(b,[f],h,x,D);throw new TypeError("val must be string, number or Buffer")}function ne(b,f,h,x,D){let $=1,Z=b.length,Ae=f.length;if(x!==void 0&&(x=String(x).toLowerCase(),x==="ucs2"||x==="ucs-2"||x==="utf16le"||x==="utf-16le")){if(b.length<2||f.length<2)return-1;$=2,Z/=2,Ae/=2,h/=2}function Ee(ze,pe){return $===1?ze[pe]:ze.readUInt16BE(pe*$)}let ye;if(D){let ze=-1;for(ye=h;ye<Z;ye++)if(Ee(b,ye)===Ee(f,ze===-1?0:ye-ze)){if(ze===-1&&(ze=ye),ye-ze+1===Ae)return ze*$}else ze!==-1&&(ye-=ye-ze),ze=-1}else for(h+Ae>Z&&(h=Z-Ae),ye=h;ye>=0;ye--){let ze=!0;for(let pe=0;pe<Ae;pe++)if(Ee(b,ye+pe)!==Ee(f,pe)){ze=!1;break}if(ze)return ye}return-1}a.prototype.includes=function(f,h,x){return this.indexOf(f,h,x)!==-1},a.prototype.indexOf=function(f,h,x){return J(this,f,h,x,!0)},a.prototype.lastIndexOf=function(f,h,x){return J(this,f,h,x,!1)};function te(b,f,h,x){h=Number(h)||0;const D=b.length-h;x?(x=Number(x),x>D&&(x=D)):x=D;const $=f.length;x>$/2&&(x=$/2);let Z;for(Z=0;Z<x;++Z){const Ae=parseInt(f.substr(Z*2,2),16);if(Ge(Ae))return Z;b[h+Z]=Ae}return Z}function V(b,f,h,x){return De(Le(f,b.length-h),b,h,x)}function C(b,f,h,x){return De(He(f),b,h,x)}function L(b,f,h,x){return De($e(f),b,h,x)}function q(b,f,h,x){return De(Xr(f,b.length-h),b,h,x)}a.prototype.write=function(f,h,x,D){if(h===void 0)D="utf8",x=this.length,h=0;else if(x===void 0&&typeof h=="string")D=h,x=this.length,h=0;else if(isFinite(h))h=h>>>0,isFinite(x)?(x=x>>>0,D===void 0&&(D="utf8")):(D=x,x=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const $=this.length-h;if((x===void 0||x>$)&&(x=$),f.length>0&&(x<0||h<0)||h>this.length)throw new RangeError("Attempt to write outside buffer bounds");D||(D="utf8");let Z=!1;for(;;)switch(D){case"hex":return te(this,f,h,x);case"utf8":case"utf-8":return V(this,f,h,x);case"ascii":case"latin1":case"binary":return C(this,f,h,x);case"base64":return L(this,f,h,x);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q(this,f,h,x);default:if(Z)throw new TypeError("Unknown encoding: "+D);D=(""+D).toLowerCase(),Z=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function w(b,f,h){return f===0&&h===b.length?e.fromByteArray(b):e.fromByteArray(b.slice(f,h))}function c(b,f,h){h=Math.min(b.length,h);const x=[];let D=f;for(;D<h;){const $=b[D];let Z=null,Ae=$>239?4:$>223?3:$>191?2:1;if(D+Ae<=h){let Ee,ye,ze,pe;switch(Ae){case 1:$<128&&(Z=$);break;case 2:Ee=b[D+1],(Ee&192)===128&&(pe=($&31)<<6|Ee&63,pe>127&&(Z=pe));break;case 3:Ee=b[D+1],ye=b[D+2],(Ee&192)===128&&(ye&192)===128&&(pe=($&15)<<12|(Ee&63)<<6|ye&63,pe>2047&&(pe<55296||pe>57343)&&(Z=pe));break;case 4:Ee=b[D+1],ye=b[D+2],ze=b[D+3],(Ee&192)===128&&(ye&192)===128&&(ze&192)===128&&(pe=($&15)<<18|(Ee&63)<<12|(ye&63)<<6|ze&63,pe>65535&&pe<1114112&&(Z=pe))}}Z===null?(Z=65533,Ae=1):Z>65535&&(Z-=65536,x.push(Z>>>10&1023|55296),Z=56320|Z&1023),x.push(Z),D+=Ae}return y(x)}const p=4096;function y(b){const f=b.length;if(f<=p)return String.fromCharCode.apply(String,b);let h="",x=0;for(;x<f;)h+=String.fromCharCode.apply(String,b.slice(x,x+=p));return h}function A(b,f,h){let x="";h=Math.min(b.length,h);for(let D=f;D<h;++D)x+=String.fromCharCode(b[D]&127);return x}function v(b,f,h){let x="";h=Math.min(b.length,h);for(let D=f;D<h;++D)x+=String.fromCharCode(b[D]);return x}function R(b,f,h){const x=b.length;(!f||f<0)&&(f=0),(!h||h<0||h>x)&&(h=x);let D="";for(let $=f;$<h;++$)D+=Ye[b[$]];return D}function O(b,f,h){const x=b.slice(f,h);let D="";for(let $=0;$<x.length-1;$+=2)D+=String.fromCharCode(x[$]+x[$+1]*256);return D}a.prototype.slice=function(f,h){const x=this.length;f=~~f,h=h===void 0?x:~~h,f<0?(f+=x,f<0&&(f=0)):f>x&&(f=x),h<0?(h+=x,h<0&&(h=0)):h>x&&(h=x),h<f&&(h=f);const D=this.subarray(f,h);return Object.setPrototypeOf(D,a.prototype),D};function _(b,f,h){if(b%1!==0||b<0)throw new RangeError("offset is not uint");if(b+f>h)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(f,h,x){f=f>>>0,h=h>>>0,x||_(f,h,this.length);let D=this[f],$=1,Z=0;for(;++Z<h&&($*=256);)D+=this[f+Z]*$;return D},a.prototype.readUintBE=a.prototype.readUIntBE=function(f,h,x){f=f>>>0,h=h>>>0,x||_(f,h,this.length);let D=this[f+--h],$=1;for(;h>0&&($*=256);)D+=this[f+--h]*$;return D},a.prototype.readUint8=a.prototype.readUInt8=function(f,h){return f=f>>>0,h||_(f,1,this.length),this[f]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(f,h){return f=f>>>0,h||_(f,2,this.length),this[f]|this[f+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(f,h){return f=f>>>0,h||_(f,2,this.length),this[f]<<8|this[f+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(f,h){return f=f>>>0,h||_(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(f,h){return f=f>>>0,h||_(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},a.prototype.readBigUInt64LE=cn(function(f){f=f>>>0,Fe(f,"offset");const h=this[f],x=this[f+7];(h===void 0||x===void 0)&&Re(f,this.length-8);const D=h+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24,$=this[++f]+this[++f]*2**8+this[++f]*2**16+x*2**24;return BigInt(D)+(BigInt($)<<BigInt(32))}),a.prototype.readBigUInt64BE=cn(function(f){f=f>>>0,Fe(f,"offset");const h=this[f],x=this[f+7];(h===void 0||x===void 0)&&Re(f,this.length-8);const D=h*2**24+this[++f]*2**16+this[++f]*2**8+this[++f],$=this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+x;return(BigInt(D)<<BigInt(32))+BigInt($)}),a.prototype.readIntLE=function(f,h,x){f=f>>>0,h=h>>>0,x||_(f,h,this.length);let D=this[f],$=1,Z=0;for(;++Z<h&&($*=256);)D+=this[f+Z]*$;return $*=128,D>=$&&(D-=Math.pow(2,8*h)),D},a.prototype.readIntBE=function(f,h,x){f=f>>>0,h=h>>>0,x||_(f,h,this.length);let D=h,$=1,Z=this[f+--D];for(;D>0&&($*=256);)Z+=this[f+--D]*$;return $*=128,Z>=$&&(Z-=Math.pow(2,8*h)),Z},a.prototype.readInt8=function(f,h){return f=f>>>0,h||_(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},a.prototype.readInt16LE=function(f,h){f=f>>>0,h||_(f,2,this.length);const x=this[f]|this[f+1]<<8;return x&32768?x|4294901760:x},a.prototype.readInt16BE=function(f,h){f=f>>>0,h||_(f,2,this.length);const x=this[f+1]|this[f]<<8;return x&32768?x|4294901760:x},a.prototype.readInt32LE=function(f,h){return f=f>>>0,h||_(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},a.prototype.readInt32BE=function(f,h){return f=f>>>0,h||_(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},a.prototype.readBigInt64LE=cn(function(f){f=f>>>0,Fe(f,"offset");const h=this[f],x=this[f+7];(h===void 0||x===void 0)&&Re(f,this.length-8);const D=this[f+4]+this[f+5]*2**8+this[f+6]*2**16+(x<<24);return(BigInt(D)<<BigInt(32))+BigInt(h+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24)}),a.prototype.readBigInt64BE=cn(function(f){f=f>>>0,Fe(f,"offset");const h=this[f],x=this[f+7];(h===void 0||x===void 0)&&Re(f,this.length-8);const D=(h<<24)+this[++f]*2**16+this[++f]*2**8+this[++f];return(BigInt(D)<<BigInt(32))+BigInt(this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+x)}),a.prototype.readFloatLE=function(f,h){return f=f>>>0,h||_(f,4,this.length),n.read(this,f,!0,23,4)},a.prototype.readFloatBE=function(f,h){return f=f>>>0,h||_(f,4,this.length),n.read(this,f,!1,23,4)},a.prototype.readDoubleLE=function(f,h){return f=f>>>0,h||_(f,8,this.length),n.read(this,f,!0,52,8)},a.prototype.readDoubleBE=function(f,h){return f=f>>>0,h||_(f,8,this.length),n.read(this,f,!1,52,8)};function u(b,f,h,x,D,$){if(!a.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>D||f<$)throw new RangeError('"value" argument is out of bounds');if(h+x>b.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(f,h,x,D){if(f=+f,h=h>>>0,x=x>>>0,!D){const Ae=Math.pow(2,8*x)-1;u(this,f,h,x,Ae,0)}let $=1,Z=0;for(this[h]=f&255;++Z<x&&($*=256);)this[h+Z]=f/$&255;return h+x},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(f,h,x,D){if(f=+f,h=h>>>0,x=x>>>0,!D){const Ae=Math.pow(2,8*x)-1;u(this,f,h,x,Ae,0)}let $=x-1,Z=1;for(this[h+$]=f&255;--$>=0&&(Z*=256);)this[h+$]=f/Z&255;return h+x},a.prototype.writeUint8=a.prototype.writeUInt8=function(f,h,x){return f=+f,h=h>>>0,x||u(this,f,h,1,255,0),this[h]=f&255,h+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(f,h,x){return f=+f,h=h>>>0,x||u(this,f,h,2,65535,0),this[h]=f&255,this[h+1]=f>>>8,h+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(f,h,x){return f=+f,h=h>>>0,x||u(this,f,h,2,65535,0),this[h]=f>>>8,this[h+1]=f&255,h+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(f,h,x){return f=+f,h=h>>>0,x||u(this,f,h,4,4294967295,0),this[h+3]=f>>>24,this[h+2]=f>>>16,this[h+1]=f>>>8,this[h]=f&255,h+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(f,h,x){return f=+f,h=h>>>0,x||u(this,f,h,4,4294967295,0),this[h]=f>>>24,this[h+1]=f>>>16,this[h+2]=f>>>8,this[h+3]=f&255,h+4};function l(b,f,h,x,D){we(f,x,D,b,h,7);let $=Number(f&BigInt(4294967295));b[h++]=$,$=$>>8,b[h++]=$,$=$>>8,b[h++]=$,$=$>>8,b[h++]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return b[h++]=Z,Z=Z>>8,b[h++]=Z,Z=Z>>8,b[h++]=Z,Z=Z>>8,b[h++]=Z,h}function E(b,f,h,x,D){we(f,x,D,b,h,7);let $=Number(f&BigInt(4294967295));b[h+7]=$,$=$>>8,b[h+6]=$,$=$>>8,b[h+5]=$,$=$>>8,b[h+4]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return b[h+3]=Z,Z=Z>>8,b[h+2]=Z,Z=Z>>8,b[h+1]=Z,Z=Z>>8,b[h]=Z,h+8}a.prototype.writeBigUInt64LE=cn(function(f,h=0){return l(this,f,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=cn(function(f,h=0){return E(this,f,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(f,h,x,D){if(f=+f,h=h>>>0,!D){const Ee=Math.pow(2,8*x-1);u(this,f,h,x,Ee-1,-Ee)}let $=0,Z=1,Ae=0;for(this[h]=f&255;++$<x&&(Z*=256);)f<0&&Ae===0&&this[h+$-1]!==0&&(Ae=1),this[h+$]=(f/Z>>0)-Ae&255;return h+x},a.prototype.writeIntBE=function(f,h,x,D){if(f=+f,h=h>>>0,!D){const Ee=Math.pow(2,8*x-1);u(this,f,h,x,Ee-1,-Ee)}let $=x-1,Z=1,Ae=0;for(this[h+$]=f&255;--$>=0&&(Z*=256);)f<0&&Ae===0&&this[h+$+1]!==0&&(Ae=1),this[h+$]=(f/Z>>0)-Ae&255;return h+x},a.prototype.writeInt8=function(f,h,x){return f=+f,h=h>>>0,x||u(this,f,h,1,127,-128),f<0&&(f=255+f+1),this[h]=f&255,h+1},a.prototype.writeInt16LE=function(f,h,x){return f=+f,h=h>>>0,x||u(this,f,h,2,32767,-32768),this[h]=f&255,this[h+1]=f>>>8,h+2},a.prototype.writeInt16BE=function(f,h,x){return f=+f,h=h>>>0,x||u(this,f,h,2,32767,-32768),this[h]=f>>>8,this[h+1]=f&255,h+2},a.prototype.writeInt32LE=function(f,h,x){return f=+f,h=h>>>0,x||u(this,f,h,4,2147483647,-2147483648),this[h]=f&255,this[h+1]=f>>>8,this[h+2]=f>>>16,this[h+3]=f>>>24,h+4},a.prototype.writeInt32BE=function(f,h,x){return f=+f,h=h>>>0,x||u(this,f,h,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[h]=f>>>24,this[h+1]=f>>>16,this[h+2]=f>>>8,this[h+3]=f&255,h+4},a.prototype.writeBigInt64LE=cn(function(f,h=0){return l(this,f,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=cn(function(f,h=0){return E(this,f,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function T(b,f,h,x,D,$){if(h+x>b.length)throw new RangeError("Index out of range");if(h<0)throw new RangeError("Index out of range")}function P(b,f,h,x,D){return f=+f,h=h>>>0,D||T(b,f,h,4),n.write(b,f,h,x,23,4),h+4}a.prototype.writeFloatLE=function(f,h,x){return P(this,f,h,!0,x)},a.prototype.writeFloatBE=function(f,h,x){return P(this,f,h,!1,x)};function W(b,f,h,x,D){return f=+f,h=h>>>0,D||T(b,f,h,8),n.write(b,f,h,x,52,8),h+8}a.prototype.writeDoubleLE=function(f,h,x){return W(this,f,h,!0,x)},a.prototype.writeDoubleBE=function(f,h,x){return W(this,f,h,!1,x)},a.prototype.copy=function(f,h,x,D){if(!a.isBuffer(f))throw new TypeError("argument should be a Buffer");if(x||(x=0),!D&&D!==0&&(D=this.length),h>=f.length&&(h=f.length),h||(h=0),D>0&&D<x&&(D=x),D===x||f.length===0||this.length===0)return 0;if(h<0)throw new RangeError("targetStart out of bounds");if(x<0||x>=this.length)throw new RangeError("Index out of range");if(D<0)throw new RangeError("sourceEnd out of bounds");D>this.length&&(D=this.length),f.length-h<D-x&&(D=f.length-h+x);const $=D-x;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(h,x,D):Uint8Array.prototype.set.call(f,this.subarray(x,D),h),$},a.prototype.fill=function(f,h,x,D){if(typeof f=="string"){if(typeof h=="string"?(D=h,h=0,x=this.length):typeof x=="string"&&(D=x,x=this.length),D!==void 0&&typeof D!="string")throw new TypeError("encoding must be a string");if(typeof D=="string"&&!a.isEncoding(D))throw new TypeError("Unknown encoding: "+D);if(f.length===1){const Z=f.charCodeAt(0);(D==="utf8"&&Z<128||D==="latin1")&&(f=Z)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(h<0||this.length<h||this.length<x)throw new RangeError("Out of range index");if(x<=h)return this;h=h>>>0,x=x===void 0?this.length:x>>>0,f||(f=0);let $;if(typeof f=="number")for($=h;$<x;++$)this[$]=f;else{const Z=a.isBuffer(f)?f:a.from(f,D),Ae=Z.length;if(Ae===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for($=0;$<x-h;++$)this[$+h]=Z[$%Ae]}return this};const se={};function ae(b,f,h){se[b]=class extends h{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${b}]`,this.stack,delete this.name}get code(){return b}set code(D){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:D,writable:!0})}toString(){return`${this.name} [${b}]: ${this.message}`}}}ae("ERR_BUFFER_OUT_OF_BOUNDS",function(b){return b?`${b} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ae("ERR_INVALID_ARG_TYPE",function(b,f){return`The "${b}" argument must be of type number. Received type ${typeof f}`},TypeError),ae("ERR_OUT_OF_RANGE",function(b,f,h){let x=`The value of "${b}" is out of range.`,D=h;return Number.isInteger(h)&&Math.abs(h)>2**32?D=Me(String(h)):typeof h=="bigint"&&(D=String(h),(h>BigInt(2)**BigInt(32)||h<-(BigInt(2)**BigInt(32)))&&(D=Me(D)),D+="n"),x+=` It must be ${f}. Received ${D}`,x},RangeError);function Me(b){let f="",h=b.length;const x=b[0]==="-"?1:0;for(;h>=x+4;h-=3)f=`_${b.slice(h-3,h)}${f}`;return`${b.slice(0,h)}${f}`}function ve(b,f,h){Fe(f,"offset"),(b[f]===void 0||b[f+h]===void 0)&&Re(f,b.length-(h+1))}function we(b,f,h,x,D,$){if(b>h||b<f){const Z=typeof f=="bigint"?"n":"";let Ae;throw f===0||f===BigInt(0)?Ae=`>= 0${Z} and < 2${Z} ** ${($+1)*8}${Z}`:Ae=`>= -(2${Z} ** ${($+1)*8-1}${Z}) and < 2 ** ${($+1)*8-1}${Z}`,new se.ERR_OUT_OF_RANGE("value",Ae,b)}ve(x,D,$)}function Fe(b,f){if(typeof b!="number")throw new se.ERR_INVALID_ARG_TYPE(f,"number",b)}function Re(b,f,h){throw Math.floor(b)!==b?(Fe(b,h),new se.ERR_OUT_OF_RANGE("offset","an integer",b)):f<0?new se.ERR_BUFFER_OUT_OF_BOUNDS:new se.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${f}`,b)}const Ne=/[^+/0-9A-Za-z-_]/g;function gn(b){if(b=b.split("=")[0],b=b.trim().replace(Ne,""),b.length<2)return"";for(;b.length%4!==0;)b=b+"=";return b}function Le(b,f){f=f||1/0;let h;const x=b.length;let D=null;const $=[];for(let Z=0;Z<x;++Z){if(h=b.charCodeAt(Z),h>55295&&h<57344){if(!D){if(h>56319){(f-=3)>-1&&$.push(239,191,189);continue}else if(Z+1===x){(f-=3)>-1&&$.push(239,191,189);continue}D=h;continue}if(h<56320){(f-=3)>-1&&$.push(239,191,189),D=h;continue}h=(D-55296<<10|h-56320)+65536}else D&&(f-=3)>-1&&$.push(239,191,189);if(D=null,h<128){if((f-=1)<0)break;$.push(h)}else if(h<2048){if((f-=2)<0)break;$.push(h>>6|192,h&63|128)}else if(h<65536){if((f-=3)<0)break;$.push(h>>12|224,h>>6&63|128,h&63|128)}else if(h<1114112){if((f-=4)<0)break;$.push(h>>18|240,h>>12&63|128,h>>6&63|128,h&63|128)}else throw new Error("Invalid code point")}return $}function He(b){const f=[];for(let h=0;h<b.length;++h)f.push(b.charCodeAt(h)&255);return f}function Xr(b,f){let h,x,D;const $=[];for(let Z=0;Z<b.length&&!((f-=2)<0);++Z)h=b.charCodeAt(Z),x=h>>8,D=h%256,$.push(D),$.push(x);return $}function $e(b){return e.toByteArray(gn(b))}function De(b,f,h,x){let D;for(D=0;D<x&&!(D+h>=f.length||D>=b.length);++D)f[D+h]=b[D];return D}function Qt(b,f){return b instanceof f||b!=null&&b.constructor!=null&&b.constructor.name!=null&&b.constructor.name===f.name}function Ge(b){return b!==b}const Ye=(function(){const b="0123456789abcdef",f=new Array(256);for(let h=0;h<16;++h){const x=h*16;for(let D=0;D<16;++D)f[x+D]=b[h]+b[D]}return f})();function cn(b){return typeof BigInt>"u"?Je:b}function Je(){throw new Error("BigInt not supported")}})(dc)),dc}var Te=lc();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fn=BigInt(0),$t=BigInt(1),vf=BigInt(2),e_=BigInt(8),t_={zip215:!0};function n_(t){const e=Da(t);return Os(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function r_(t){const e=n_(t),{Fp:n,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:d}=e,m=vf<<BigInt(a*8)-$t,g=n.create,S=Cs(e.n,e.nBitLength);function I(v,R){const O=n.sqr(v),_=n.sqr(R),u=n.add(n.mul(e.a,O),_),l=n.add(n.ONE,n.mul(e.d,n.mul(O,_)));return n.eql(u,l)}if(!I(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const N=e.uvRatio||((v,R)=>{try{return{isValid:!0,value:n.sqrt(v*n.inv(R))}}catch{return{isValid:!1,value:fn}}}),F=e.adjustScalarBytes||(v=>v),M=e.domain||((v,R,O)=>{if(Dn("phflag",O),R.length||O)throw new Error("Contexts/pre-hash are not supported");return v});function B(v,R,O=!1){const _=O?$t:fn;sn("coordinate "+v,R,_,m)}function K(v){if(!(v instanceof U))throw new Error("ExtendedPoint expected")}const Y=wi((v,R)=>{const{ex:O,ey:_,ez:u}=v,l=v.is0();R==null&&(R=l?e_:n.inv(u));const E=g(O*R),T=g(_*R),P=g(u*R);if(l)return{x:fn,y:$t};if(P!==$t)throw new Error("invZ was invalid");return{x:E,y:T}}),z=wi(v=>{const{a:R,d:O}=e;if(v.is0())throw new Error("bad point: ZERO");const{ex:_,ey:u,ez:l,et:E}=v,T=g(_*_),P=g(u*u),W=g(l*l),se=g(W*W),ae=g(T*R),Me=g(W*g(ae+P)),ve=g(se+g(O*g(T*P)));if(Me!==ve)throw new Error("bad point: equation left != right (1)");const we=g(_*u),Fe=g(l*E);if(we!==Fe)throw new Error("bad point: equation left != right (2)");return!0});class U{constructor(R,O,_,u){B("x",R),B("y",O),B("z",_,!0),B("t",u),this.ex=R,this.ey=O,this.ez=_,this.et=u,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(R){if(R instanceof U)throw new Error("extended point not allowed");const{x:O,y:_}=R||{};return B("x",O),B("y",_),new U(O,_,$t,g(O*_))}static normalizeZ(R){const O=Ca(n,R.map(_=>_.ez));return R.map((_,u)=>_.toAffine(O[u])).map(U.fromAffine)}static msm(R,O){return Ll(U,S,R,O)}_setWindowSize(R){ne.setWindowSize(this,R)}assertValidity(){z(this)}equals(R){K(R);const{ex:O,ey:_,ez:u}=this,{ex:l,ey:E,ez:T}=R,P=g(O*T),W=g(l*u),se=g(_*T),ae=g(E*u);return P===W&&se===ae}is0(){return this.equals(U.ZERO)}negate(){return new U(g(-this.ex),this.ey,this.ez,g(-this.et))}double(){const{a:R}=e,{ex:O,ey:_,ez:u}=this,l=g(O*O),E=g(_*_),T=g(vf*g(u*u)),P=g(R*l),W=O+_,se=g(g(W*W)-l-E),ae=P+E,Me=ae-T,ve=P-E,we=g(se*Me),Fe=g(ae*ve),Re=g(se*ve),Ne=g(Me*ae);return new U(we,Fe,Ne,Re)}add(R){K(R);const{a:O,d:_}=e,{ex:u,ey:l,ez:E,et:T}=this,{ex:P,ey:W,ez:se,et:ae}=R,Me=g(u*P),ve=g(l*W),we=g(T*_*ae),Fe=g(E*se),Re=g((u+l)*(P+W)-Me-ve),Ne=Fe-we,gn=Fe+we,Le=g(ve-O*Me),He=g(Re*Ne),Xr=g(gn*Le),$e=g(Re*Le),De=g(Ne*gn);return new U(He,Xr,De,$e)}subtract(R){return this.add(R.negate())}wNAF(R){return ne.wNAFCached(this,R,U.normalizeZ)}multiply(R){const O=R;sn("scalar",O,$t,r);const{p:_,f:u}=this.wNAF(O);return U.normalizeZ([_,u])[0]}multiplyUnsafe(R,O=U.ZERO){const _=R;return sn("scalar",_,fn,r),_===fn?J:this.is0()||_===$t?this:ne.wNAFCachedUnsafe(this,_,U.normalizeZ,O)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return ne.unsafeLadder(this,r).is0()}toAffine(R){return Y(this,R)}clearCofactor(){const{h:R}=e;return R===$t?this:this.multiplyUnsafe(R)}static fromHex(R,O=!1){const{d:_,a:u}=e,l=n.BYTES;R=Qe("pointHex",R,l),Dn("zip215",O);const E=R.slice(),T=R[l-1];E[l-1]=T&-129;const P=Ts(E),W=O?m:n.ORDER;sn("pointHex.y",P,fn,W);const se=g(P*P),ae=g(se-$t),Me=g(_*se-u);let{isValid:ve,value:we}=N(ae,Me);if(!ve)throw new Error("Point.fromHex: invalid y coordinate");const Fe=(we&$t)===$t,Re=(T&128)!==0;if(!O&&we===fn&&Re)throw new Error("Point.fromHex: x=0 and x_0=1");return Re!==Fe&&(we=g(-we)),U.fromAffine({x:we,y:P})}static fromPrivateKey(R){const{scalar:O}=C(R);return j.multiply(O)}toRawBytes(){const{x:R,y:O}=this.toAffine(),_=_i(O,n.BYTES);return _[_.length-1]|=R&$t?128:0,_}toHex(){return Nr(this.toRawBytes())}}U.BASE=new U(e.Gx,e.Gy,$t,g(e.Gx*e.Gy)),U.ZERO=new U(fn,$t,$t,fn);const{BASE:j,ZERO:J}=U,ne=Ul(U,a*8);function te(v){return Ve(v,r)}function V(v){return te(Ts(v))}function C(v){const R=n.BYTES;v=Qe("private key",v,R);const O=Qe("hashed private key",i(v),2*R),_=F(O.slice(0,R)),u=O.slice(R,2*R),l=V(_);return{head:_,prefix:u,scalar:l}}function L(v){const{head:R,prefix:O,scalar:_}=C(v),u=j.multiply(_),l=u.toRawBytes();return{head:R,prefix:O,scalar:_,point:u,pointBytes:l}}function q(v){return L(v).pointBytes}function w(v=Uint8Array.of(),...R){const O=Cr(...R);return V(i(M(O,Qe("context",v),!!s)))}function c(v,R,O={}){v=Qe("message",v),s&&(v=s(v));const{prefix:_,scalar:u,pointBytes:l}=L(R),E=w(O.context,_,v),T=j.multiply(E).toRawBytes(),P=w(O.context,T,l,v),W=te(E+P*u);sn("signature.s",W,fn,r);const se=Cr(T,_i(W,n.BYTES));return Qe("result",se,n.BYTES*2)}const p=t_;function y(v,R,O,_=p){const{context:u,zip215:l}=_,E=n.BYTES;v=Qe("signature",v,2*E),R=Qe("message",R),O=Qe("publicKey",O,E),l!==void 0&&Dn("zip215",l),s&&(R=s(R));const T=Ts(v.slice(E,2*E));let P,W,se;try{P=U.fromHex(O,l),W=U.fromHex(v.slice(0,E),l),se=j.multiplyUnsafe(T)}catch{return!1}if(!l&&P.isSmallOrder())return!1;const ae=w(u,W.toRawBytes(),P.toRawBytes(),R);return W.add(P.multiplyUnsafe(ae)).subtract(se).clearCofactor().equals(U.ZERO)}return j._setWindowSize(8),{CURVE:e,getPublicKey:q,sign:c,verify:y,ExtendedPoint:U,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>o(n.BYTES),precompute(v=8,R=U.BASE){return R._setWindowSize(v),R.multiply(BigInt(3)),R}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Rf=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const s_=BigInt(1),Af=BigInt(2);BigInt(3);const i_=BigInt(5),o_=BigInt(8);function a_(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),s=BigInt(80),i=fc,a=t*t%i*t%i,d=Ke(a,Af,i)*a%i,m=Ke(d,s_,i)*t%i,g=Ke(m,i_,i)*m%i,S=Ke(g,e,i)*g%i,I=Ke(S,n,i)*S%i,N=Ke(I,r,i)*I%i,F=Ke(N,s,i)*N%i,M=Ke(F,s,i)*N%i,B=Ke(M,e,i)*g%i;return{pow_p_5_8:Ke(B,Af,i)*t%i,b2:a}}function c_(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function u_(t,e){const n=fc,r=Ve(e*e*e,n),s=Ve(r*r*e,n),i=a_(t*s).pow_p_5_8;let o=Ve(t*r*i,n);const a=Ve(e*o*o,n),d=o,m=Ve(o*Rf,n),g=a===t,S=a===Ve(-t,n),I=a===Ve(-t*Rf,n);return g&&(o=d),(S||I)&&(o=m),s1(o,n)&&(o=Ve(-o,n)),{isValid:g||S,value:o}}const Sf=Cs(fc,void 0,!0),d_={a:Sf.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Sf,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:o_,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Dy,randomBytes:Sd,adjustScalarBytes:c_,uvRatio:u_},hc=r_(d_);var zi={exports:{}};const l_=Za(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var f_=zi.exports,xf;function Tf(){return xf||(xf=1,(function(t){(function(e,n){function r(w,c){if(!w)throw new Error(c||"Assertion failed")}function s(w,c){w.super_=c;var p=function(){};p.prototype=c.prototype,w.prototype=new p,w.prototype.constructor=w}function i(w,c,p){if(i.isBN(w))return w;this.negative=0,this.words=null,this.length=0,this.red=null,w!==null&&((c==="le"||c==="be")&&(p=c,c=10),this._init(w||0,c||10,p||"be"))}typeof e=="object"?e.exports=i:n.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=l_.Buffer}catch{}i.isBN=function(c){return c instanceof i?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===i.wordSize&&Array.isArray(c.words)},i.max=function(c,p){return c.cmp(p)>0?c:p},i.min=function(c,p){return c.cmp(p)<0?c:p},i.prototype._init=function(c,p,y){if(typeof c=="number")return this._initNumber(c,p,y);if(typeof c=="object")return this._initArray(c,p,y);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),c=c.toString().replace(/\s+/g,"");var A=0;c[0]==="-"&&(A++,this.negative=1),A<c.length&&(p===16?this._parseHex(c,A,y):(this._parseBase(c,p,A),y==="le"&&this._initArray(this.toArray(),p,y)))},i.prototype._initNumber=function(c,p,y){c<0&&(this.negative=1,c=-c),c<67108864?(this.words=[c&67108863],this.length=1):c<4503599627370496?(this.words=[c&67108863,c/67108864&67108863],this.length=2):(r(c<9007199254740992),this.words=[c&67108863,c/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),p,y)},i.prototype._initArray=function(c,p,y){if(r(typeof c.length=="number"),c.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(c.length/3),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var v,R,O=0;if(y==="be")for(A=c.length-1,v=0;A>=0;A-=3)R=c[A]|c[A-1]<<8|c[A-2]<<16,this.words[v]|=R<<O&67108863,this.words[v+1]=R>>>26-O&67108863,O+=24,O>=26&&(O-=26,v++);else if(y==="le")for(A=0,v=0;A<c.length;A+=3)R=c[A]|c[A+1]<<8|c[A+2]<<16,this.words[v]|=R<<O&67108863,this.words[v+1]=R>>>26-O&67108863,O+=24,O>=26&&(O-=26,v++);return this._strip()};function a(w,c){var p=w.charCodeAt(c);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;r(!1,"Invalid character in "+w)}function d(w,c,p){var y=a(w,p);return p-1>=c&&(y|=a(w,p-1)<<4),y}i.prototype._parseHex=function(c,p,y){this.length=Math.ceil((c.length-p)/6),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var v=0,R=0,O;if(y==="be")for(A=c.length-1;A>=p;A-=2)O=d(c,p,A)<<v,this.words[R]|=O&67108863,v>=18?(v-=18,R+=1,this.words[R]|=O>>>26):v+=8;else{var _=c.length-p;for(A=_%2===0?p+1:p;A<c.length;A+=2)O=d(c,p,A)<<v,this.words[R]|=O&67108863,v>=18?(v-=18,R+=1,this.words[R]|=O>>>26):v+=8}this._strip()};function m(w,c,p,y){for(var A=0,v=0,R=Math.min(w.length,p),O=c;O<R;O++){var _=w.charCodeAt(O)-48;A*=y,_>=49?v=_-49+10:_>=17?v=_-17+10:v=_,r(_>=0&&v<y,"Invalid character"),A+=v}return A}i.prototype._parseBase=function(c,p,y){this.words=[0],this.length=1;for(var A=0,v=1;v<=67108863;v*=p)A++;A--,v=v/p|0;for(var R=c.length-y,O=R%A,_=Math.min(R,R-O)+y,u=0,l=y;l<_;l+=A)u=m(c,l,l+A,p),this.imuln(v),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(O!==0){var E=1;for(u=m(c,l,c.length,p),l=0;l<O;l++)E*=p;this.imuln(E),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},i.prototype.copy=function(c){c.words=new Array(this.length);for(var p=0;p<this.length;p++)c.words[p]=this.words[p];c.length=this.length,c.negative=this.negative,c.red=this.red};function g(w,c){w.words=c.words,w.length=c.length,w.negative=c.negative,w.red=c.red}if(i.prototype._move=function(c){g(c,this)},i.prototype.clone=function(){var c=new i(null);return this.copy(c),c},i.prototype._expand=function(c){for(;this.length<c;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=S}catch{i.prototype.inspect=S}else i.prototype.inspect=S;function S(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var I=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],N=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],F=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(c,p){c=c||10,p=p|0||1;var y;if(c===16||c==="hex"){y="";for(var A=0,v=0,R=0;R<this.length;R++){var O=this.words[R],_=((O<<A|v)&16777215).toString(16);v=O>>>24-A&16777215,A+=2,A>=26&&(A-=26,R--),v!==0||R!==this.length-1?y=I[6-_.length]+_+y:y=_+y}for(v!==0&&(y=v.toString(16)+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(c===(c|0)&&c>=2&&c<=36){var u=N[c],l=F[c];y="";var E=this.clone();for(E.negative=0;!E.isZero();){var T=E.modrn(l).toString(c);E=E.idivn(l),E.isZero()?y=T+y:y=I[u-T.length]+T+y}for(this.isZero()&&(y="0"+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(c,p){return this.toArrayLike(o,c,p)}),i.prototype.toArray=function(c,p){return this.toArrayLike(Array,c,p)};var M=function(c,p){return c.allocUnsafe?c.allocUnsafe(p):new c(p)};i.prototype.toArrayLike=function(c,p,y){this._strip();var A=this.byteLength(),v=y||Math.max(1,A);r(A<=v,"byte array longer than desired length"),r(v>0,"Requested array length <= 0");var R=M(c,v),O=p==="le"?"LE":"BE";return this["_toArrayLike"+O](R,A),R},i.prototype._toArrayLikeLE=function(c,p){for(var y=0,A=0,v=0,R=0;v<this.length;v++){var O=this.words[v]<<R|A;c[y++]=O&255,y<c.length&&(c[y++]=O>>8&255),y<c.length&&(c[y++]=O>>16&255),R===6?(y<c.length&&(c[y++]=O>>24&255),A=0,R=0):(A=O>>>24,R+=2)}if(y<c.length)for(c[y++]=A;y<c.length;)c[y++]=0},i.prototype._toArrayLikeBE=function(c,p){for(var y=c.length-1,A=0,v=0,R=0;v<this.length;v++){var O=this.words[v]<<R|A;c[y--]=O&255,y>=0&&(c[y--]=O>>8&255),y>=0&&(c[y--]=O>>16&255),R===6?(y>=0&&(c[y--]=O>>24&255),A=0,R=0):(A=O>>>24,R+=2)}if(y>=0)for(c[y--]=A;y>=0;)c[y--]=0},Math.clz32?i.prototype._countBits=function(c){return 32-Math.clz32(c)}:i.prototype._countBits=function(c){var p=c,y=0;return p>=4096&&(y+=13,p>>>=13),p>=64&&(y+=7,p>>>=7),p>=8&&(y+=4,p>>>=4),p>=2&&(y+=2,p>>>=2),y+p},i.prototype._zeroBits=function(c){if(c===0)return 26;var p=c,y=0;return(p&8191)===0&&(y+=13,p>>>=13),(p&127)===0&&(y+=7,p>>>=7),(p&15)===0&&(y+=4,p>>>=4),(p&3)===0&&(y+=2,p>>>=2),(p&1)===0&&y++,y},i.prototype.bitLength=function(){var c=this.words[this.length-1],p=this._countBits(c);return(this.length-1)*26+p};function B(w){for(var c=new Array(w.bitLength()),p=0;p<c.length;p++){var y=p/26|0,A=p%26;c[p]=w.words[y]>>>A&1}return c}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,p=0;p<this.length;p++){var y=this._zeroBits(this.words[p]);if(c+=y,y!==26)break}return c},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(c){return this.negative!==0?this.abs().inotn(c).iaddn(1):this.clone()},i.prototype.fromTwos=function(c){return this.testn(c-1)?this.notn(c).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(c){for(;this.length<c.length;)this.words[this.length++]=0;for(var p=0;p<c.length;p++)this.words[p]=this.words[p]|c.words[p];return this._strip()},i.prototype.ior=function(c){return r((this.negative|c.negative)===0),this.iuor(c)},i.prototype.or=function(c){return this.length>c.length?this.clone().ior(c):c.clone().ior(this)},i.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},i.prototype.iuand=function(c){var p;this.length>c.length?p=c:p=this;for(var y=0;y<p.length;y++)this.words[y]=this.words[y]&c.words[y];return this.length=p.length,this._strip()},i.prototype.iand=function(c){return r((this.negative|c.negative)===0),this.iuand(c)},i.prototype.and=function(c){return this.length>c.length?this.clone().iand(c):c.clone().iand(this)},i.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},i.prototype.iuxor=function(c){var p,y;this.length>c.length?(p=this,y=c):(p=c,y=this);for(var A=0;A<y.length;A++)this.words[A]=p.words[A]^y.words[A];if(this!==p)for(;A<p.length;A++)this.words[A]=p.words[A];return this.length=p.length,this._strip()},i.prototype.ixor=function(c){return r((this.negative|c.negative)===0),this.iuxor(c)},i.prototype.xor=function(c){return this.length>c.length?this.clone().ixor(c):c.clone().ixor(this)},i.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},i.prototype.inotn=function(c){r(typeof c=="number"&&c>=0);var p=Math.ceil(c/26)|0,y=c%26;this._expand(p),y>0&&p--;for(var A=0;A<p;A++)this.words[A]=~this.words[A]&67108863;return y>0&&(this.words[A]=~this.words[A]&67108863>>26-y),this._strip()},i.prototype.notn=function(c){return this.clone().inotn(c)},i.prototype.setn=function(c,p){r(typeof c=="number"&&c>=0);var y=c/26|0,A=c%26;return this._expand(y+1),p?this.words[y]=this.words[y]|1<<A:this.words[y]=this.words[y]&~(1<<A),this._strip()},i.prototype.iadd=function(c){var p;if(this.negative!==0&&c.negative===0)return this.negative=0,p=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,p=this.isub(c),c.negative=1,p._normSign();var y,A;this.length>c.length?(y=this,A=c):(y=c,A=this);for(var v=0,R=0;R<A.length;R++)p=(y.words[R]|0)+(A.words[R]|0)+v,this.words[R]=p&67108863,v=p>>>26;for(;v!==0&&R<y.length;R++)p=(y.words[R]|0)+v,this.words[R]=p&67108863,v=p>>>26;if(this.length=y.length,v!==0)this.words[this.length]=v,this.length++;else if(y!==this)for(;R<y.length;R++)this.words[R]=y.words[R];return this},i.prototype.add=function(c){var p;return c.negative!==0&&this.negative===0?(c.negative=0,p=this.sub(c),c.negative^=1,p):c.negative===0&&this.negative!==0?(this.negative=0,p=c.sub(this),this.negative=1,p):this.length>c.length?this.clone().iadd(c):c.clone().iadd(this)},i.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var p=this.iadd(c);return c.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var y=this.cmp(c);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var A,v;y>0?(A=this,v=c):(A=c,v=this);for(var R=0,O=0;O<v.length;O++)p=(A.words[O]|0)-(v.words[O]|0)+R,R=p>>26,this.words[O]=p&67108863;for(;R!==0&&O<A.length;O++)p=(A.words[O]|0)+R,R=p>>26,this.words[O]=p&67108863;if(R===0&&O<A.length&&A!==this)for(;O<A.length;O++)this.words[O]=A.words[O];return this.length=Math.max(this.length,O),A!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(c){return this.clone().isub(c)};function K(w,c,p){p.negative=c.negative^w.negative;var y=w.length+c.length|0;p.length=y,y=y-1|0;var A=w.words[0]|0,v=c.words[0]|0,R=A*v,O=R&67108863,_=R/67108864|0;p.words[0]=O;for(var u=1;u<y;u++){for(var l=_>>>26,E=_&67108863,T=Math.min(u,c.length-1),P=Math.max(0,u-w.length+1);P<=T;P++){var W=u-P|0;A=w.words[W]|0,v=c.words[P]|0,R=A*v+E,l+=R/67108864|0,E=R&67108863}p.words[u]=E|0,_=l|0}return _!==0?p.words[u]=_|0:p.length--,p._strip()}var Y=function(c,p,y){var A=c.words,v=p.words,R=y.words,O=0,_,u,l,E=A[0]|0,T=E&8191,P=E>>>13,W=A[1]|0,se=W&8191,ae=W>>>13,Me=A[2]|0,ve=Me&8191,we=Me>>>13,Fe=A[3]|0,Re=Fe&8191,Ne=Fe>>>13,gn=A[4]|0,Le=gn&8191,He=gn>>>13,Xr=A[5]|0,$e=Xr&8191,De=Xr>>>13,Qt=A[6]|0,Ge=Qt&8191,Ye=Qt>>>13,cn=A[7]|0,Je=cn&8191,b=cn>>>13,f=A[8]|0,h=f&8191,x=f>>>13,D=A[9]|0,$=D&8191,Z=D>>>13,Ae=v[0]|0,Ee=Ae&8191,ye=Ae>>>13,ze=v[1]|0,pe=ze&8191,nt=ze>>>13,x0=v[2]|0,rt=x0&8191,st=x0>>>13,T0=v[3]|0,it=T0&8191,ot=T0>>>13,I0=v[4]|0,at=I0&8191,ct=I0>>>13,O0=v[5]|0,ut=O0&8191,dt=O0>>>13,N0=v[6]|0,lt=N0&8191,ft=N0>>>13,C0=v[7]|0,ht=C0&8191,pt=C0>>>13,M0=v[8]|0,mt=M0&8191,gt=M0>>>13,k0=v[9]|0,yt=k0&8191,bt=k0>>>13;y.negative=c.negative^p.negative,y.length=19,_=Math.imul(T,Ee),u=Math.imul(T,ye),u=u+Math.imul(P,Ee)|0,l=Math.imul(P,ye);var ru=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(ru>>>26)|0,ru&=67108863,_=Math.imul(se,Ee),u=Math.imul(se,ye),u=u+Math.imul(ae,Ee)|0,l=Math.imul(ae,ye),_=_+Math.imul(T,pe)|0,u=u+Math.imul(T,nt)|0,u=u+Math.imul(P,pe)|0,l=l+Math.imul(P,nt)|0;var su=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(su>>>26)|0,su&=67108863,_=Math.imul(ve,Ee),u=Math.imul(ve,ye),u=u+Math.imul(we,Ee)|0,l=Math.imul(we,ye),_=_+Math.imul(se,pe)|0,u=u+Math.imul(se,nt)|0,u=u+Math.imul(ae,pe)|0,l=l+Math.imul(ae,nt)|0,_=_+Math.imul(T,rt)|0,u=u+Math.imul(T,st)|0,u=u+Math.imul(P,rt)|0,l=l+Math.imul(P,st)|0;var iu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(iu>>>26)|0,iu&=67108863,_=Math.imul(Re,Ee),u=Math.imul(Re,ye),u=u+Math.imul(Ne,Ee)|0,l=Math.imul(Ne,ye),_=_+Math.imul(ve,pe)|0,u=u+Math.imul(ve,nt)|0,u=u+Math.imul(we,pe)|0,l=l+Math.imul(we,nt)|0,_=_+Math.imul(se,rt)|0,u=u+Math.imul(se,st)|0,u=u+Math.imul(ae,rt)|0,l=l+Math.imul(ae,st)|0,_=_+Math.imul(T,it)|0,u=u+Math.imul(T,ot)|0,u=u+Math.imul(P,it)|0,l=l+Math.imul(P,ot)|0;var ou=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(ou>>>26)|0,ou&=67108863,_=Math.imul(Le,Ee),u=Math.imul(Le,ye),u=u+Math.imul(He,Ee)|0,l=Math.imul(He,ye),_=_+Math.imul(Re,pe)|0,u=u+Math.imul(Re,nt)|0,u=u+Math.imul(Ne,pe)|0,l=l+Math.imul(Ne,nt)|0,_=_+Math.imul(ve,rt)|0,u=u+Math.imul(ve,st)|0,u=u+Math.imul(we,rt)|0,l=l+Math.imul(we,st)|0,_=_+Math.imul(se,it)|0,u=u+Math.imul(se,ot)|0,u=u+Math.imul(ae,it)|0,l=l+Math.imul(ae,ot)|0,_=_+Math.imul(T,at)|0,u=u+Math.imul(T,ct)|0,u=u+Math.imul(P,at)|0,l=l+Math.imul(P,ct)|0;var au=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(au>>>26)|0,au&=67108863,_=Math.imul($e,Ee),u=Math.imul($e,ye),u=u+Math.imul(De,Ee)|0,l=Math.imul(De,ye),_=_+Math.imul(Le,pe)|0,u=u+Math.imul(Le,nt)|0,u=u+Math.imul(He,pe)|0,l=l+Math.imul(He,nt)|0,_=_+Math.imul(Re,rt)|0,u=u+Math.imul(Re,st)|0,u=u+Math.imul(Ne,rt)|0,l=l+Math.imul(Ne,st)|0,_=_+Math.imul(ve,it)|0,u=u+Math.imul(ve,ot)|0,u=u+Math.imul(we,it)|0,l=l+Math.imul(we,ot)|0,_=_+Math.imul(se,at)|0,u=u+Math.imul(se,ct)|0,u=u+Math.imul(ae,at)|0,l=l+Math.imul(ae,ct)|0,_=_+Math.imul(T,ut)|0,u=u+Math.imul(T,dt)|0,u=u+Math.imul(P,ut)|0,l=l+Math.imul(P,dt)|0;var cu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(cu>>>26)|0,cu&=67108863,_=Math.imul(Ge,Ee),u=Math.imul(Ge,ye),u=u+Math.imul(Ye,Ee)|0,l=Math.imul(Ye,ye),_=_+Math.imul($e,pe)|0,u=u+Math.imul($e,nt)|0,u=u+Math.imul(De,pe)|0,l=l+Math.imul(De,nt)|0,_=_+Math.imul(Le,rt)|0,u=u+Math.imul(Le,st)|0,u=u+Math.imul(He,rt)|0,l=l+Math.imul(He,st)|0,_=_+Math.imul(Re,it)|0,u=u+Math.imul(Re,ot)|0,u=u+Math.imul(Ne,it)|0,l=l+Math.imul(Ne,ot)|0,_=_+Math.imul(ve,at)|0,u=u+Math.imul(ve,ct)|0,u=u+Math.imul(we,at)|0,l=l+Math.imul(we,ct)|0,_=_+Math.imul(se,ut)|0,u=u+Math.imul(se,dt)|0,u=u+Math.imul(ae,ut)|0,l=l+Math.imul(ae,dt)|0,_=_+Math.imul(T,lt)|0,u=u+Math.imul(T,ft)|0,u=u+Math.imul(P,lt)|0,l=l+Math.imul(P,ft)|0;var uu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(uu>>>26)|0,uu&=67108863,_=Math.imul(Je,Ee),u=Math.imul(Je,ye),u=u+Math.imul(b,Ee)|0,l=Math.imul(b,ye),_=_+Math.imul(Ge,pe)|0,u=u+Math.imul(Ge,nt)|0,u=u+Math.imul(Ye,pe)|0,l=l+Math.imul(Ye,nt)|0,_=_+Math.imul($e,rt)|0,u=u+Math.imul($e,st)|0,u=u+Math.imul(De,rt)|0,l=l+Math.imul(De,st)|0,_=_+Math.imul(Le,it)|0,u=u+Math.imul(Le,ot)|0,u=u+Math.imul(He,it)|0,l=l+Math.imul(He,ot)|0,_=_+Math.imul(Re,at)|0,u=u+Math.imul(Re,ct)|0,u=u+Math.imul(Ne,at)|0,l=l+Math.imul(Ne,ct)|0,_=_+Math.imul(ve,ut)|0,u=u+Math.imul(ve,dt)|0,u=u+Math.imul(we,ut)|0,l=l+Math.imul(we,dt)|0,_=_+Math.imul(se,lt)|0,u=u+Math.imul(se,ft)|0,u=u+Math.imul(ae,lt)|0,l=l+Math.imul(ae,ft)|0,_=_+Math.imul(T,ht)|0,u=u+Math.imul(T,pt)|0,u=u+Math.imul(P,ht)|0,l=l+Math.imul(P,pt)|0;var du=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(du>>>26)|0,du&=67108863,_=Math.imul(h,Ee),u=Math.imul(h,ye),u=u+Math.imul(x,Ee)|0,l=Math.imul(x,ye),_=_+Math.imul(Je,pe)|0,u=u+Math.imul(Je,nt)|0,u=u+Math.imul(b,pe)|0,l=l+Math.imul(b,nt)|0,_=_+Math.imul(Ge,rt)|0,u=u+Math.imul(Ge,st)|0,u=u+Math.imul(Ye,rt)|0,l=l+Math.imul(Ye,st)|0,_=_+Math.imul($e,it)|0,u=u+Math.imul($e,ot)|0,u=u+Math.imul(De,it)|0,l=l+Math.imul(De,ot)|0,_=_+Math.imul(Le,at)|0,u=u+Math.imul(Le,ct)|0,u=u+Math.imul(He,at)|0,l=l+Math.imul(He,ct)|0,_=_+Math.imul(Re,ut)|0,u=u+Math.imul(Re,dt)|0,u=u+Math.imul(Ne,ut)|0,l=l+Math.imul(Ne,dt)|0,_=_+Math.imul(ve,lt)|0,u=u+Math.imul(ve,ft)|0,u=u+Math.imul(we,lt)|0,l=l+Math.imul(we,ft)|0,_=_+Math.imul(se,ht)|0,u=u+Math.imul(se,pt)|0,u=u+Math.imul(ae,ht)|0,l=l+Math.imul(ae,pt)|0,_=_+Math.imul(T,mt)|0,u=u+Math.imul(T,gt)|0,u=u+Math.imul(P,mt)|0,l=l+Math.imul(P,gt)|0;var lu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(lu>>>26)|0,lu&=67108863,_=Math.imul($,Ee),u=Math.imul($,ye),u=u+Math.imul(Z,Ee)|0,l=Math.imul(Z,ye),_=_+Math.imul(h,pe)|0,u=u+Math.imul(h,nt)|0,u=u+Math.imul(x,pe)|0,l=l+Math.imul(x,nt)|0,_=_+Math.imul(Je,rt)|0,u=u+Math.imul(Je,st)|0,u=u+Math.imul(b,rt)|0,l=l+Math.imul(b,st)|0,_=_+Math.imul(Ge,it)|0,u=u+Math.imul(Ge,ot)|0,u=u+Math.imul(Ye,it)|0,l=l+Math.imul(Ye,ot)|0,_=_+Math.imul($e,at)|0,u=u+Math.imul($e,ct)|0,u=u+Math.imul(De,at)|0,l=l+Math.imul(De,ct)|0,_=_+Math.imul(Le,ut)|0,u=u+Math.imul(Le,dt)|0,u=u+Math.imul(He,ut)|0,l=l+Math.imul(He,dt)|0,_=_+Math.imul(Re,lt)|0,u=u+Math.imul(Re,ft)|0,u=u+Math.imul(Ne,lt)|0,l=l+Math.imul(Ne,ft)|0,_=_+Math.imul(ve,ht)|0,u=u+Math.imul(ve,pt)|0,u=u+Math.imul(we,ht)|0,l=l+Math.imul(we,pt)|0,_=_+Math.imul(se,mt)|0,u=u+Math.imul(se,gt)|0,u=u+Math.imul(ae,mt)|0,l=l+Math.imul(ae,gt)|0,_=_+Math.imul(T,yt)|0,u=u+Math.imul(T,bt)|0,u=u+Math.imul(P,yt)|0,l=l+Math.imul(P,bt)|0;var fu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(fu>>>26)|0,fu&=67108863,_=Math.imul($,pe),u=Math.imul($,nt),u=u+Math.imul(Z,pe)|0,l=Math.imul(Z,nt),_=_+Math.imul(h,rt)|0,u=u+Math.imul(h,st)|0,u=u+Math.imul(x,rt)|0,l=l+Math.imul(x,st)|0,_=_+Math.imul(Je,it)|0,u=u+Math.imul(Je,ot)|0,u=u+Math.imul(b,it)|0,l=l+Math.imul(b,ot)|0,_=_+Math.imul(Ge,at)|0,u=u+Math.imul(Ge,ct)|0,u=u+Math.imul(Ye,at)|0,l=l+Math.imul(Ye,ct)|0,_=_+Math.imul($e,ut)|0,u=u+Math.imul($e,dt)|0,u=u+Math.imul(De,ut)|0,l=l+Math.imul(De,dt)|0,_=_+Math.imul(Le,lt)|0,u=u+Math.imul(Le,ft)|0,u=u+Math.imul(He,lt)|0,l=l+Math.imul(He,ft)|0,_=_+Math.imul(Re,ht)|0,u=u+Math.imul(Re,pt)|0,u=u+Math.imul(Ne,ht)|0,l=l+Math.imul(Ne,pt)|0,_=_+Math.imul(ve,mt)|0,u=u+Math.imul(ve,gt)|0,u=u+Math.imul(we,mt)|0,l=l+Math.imul(we,gt)|0,_=_+Math.imul(se,yt)|0,u=u+Math.imul(se,bt)|0,u=u+Math.imul(ae,yt)|0,l=l+Math.imul(ae,bt)|0;var hu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(hu>>>26)|0,hu&=67108863,_=Math.imul($,rt),u=Math.imul($,st),u=u+Math.imul(Z,rt)|0,l=Math.imul(Z,st),_=_+Math.imul(h,it)|0,u=u+Math.imul(h,ot)|0,u=u+Math.imul(x,it)|0,l=l+Math.imul(x,ot)|0,_=_+Math.imul(Je,at)|0,u=u+Math.imul(Je,ct)|0,u=u+Math.imul(b,at)|0,l=l+Math.imul(b,ct)|0,_=_+Math.imul(Ge,ut)|0,u=u+Math.imul(Ge,dt)|0,u=u+Math.imul(Ye,ut)|0,l=l+Math.imul(Ye,dt)|0,_=_+Math.imul($e,lt)|0,u=u+Math.imul($e,ft)|0,u=u+Math.imul(De,lt)|0,l=l+Math.imul(De,ft)|0,_=_+Math.imul(Le,ht)|0,u=u+Math.imul(Le,pt)|0,u=u+Math.imul(He,ht)|0,l=l+Math.imul(He,pt)|0,_=_+Math.imul(Re,mt)|0,u=u+Math.imul(Re,gt)|0,u=u+Math.imul(Ne,mt)|0,l=l+Math.imul(Ne,gt)|0,_=_+Math.imul(ve,yt)|0,u=u+Math.imul(ve,bt)|0,u=u+Math.imul(we,yt)|0,l=l+Math.imul(we,bt)|0;var pu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(pu>>>26)|0,pu&=67108863,_=Math.imul($,it),u=Math.imul($,ot),u=u+Math.imul(Z,it)|0,l=Math.imul(Z,ot),_=_+Math.imul(h,at)|0,u=u+Math.imul(h,ct)|0,u=u+Math.imul(x,at)|0,l=l+Math.imul(x,ct)|0,_=_+Math.imul(Je,ut)|0,u=u+Math.imul(Je,dt)|0,u=u+Math.imul(b,ut)|0,l=l+Math.imul(b,dt)|0,_=_+Math.imul(Ge,lt)|0,u=u+Math.imul(Ge,ft)|0,u=u+Math.imul(Ye,lt)|0,l=l+Math.imul(Ye,ft)|0,_=_+Math.imul($e,ht)|0,u=u+Math.imul($e,pt)|0,u=u+Math.imul(De,ht)|0,l=l+Math.imul(De,pt)|0,_=_+Math.imul(Le,mt)|0,u=u+Math.imul(Le,gt)|0,u=u+Math.imul(He,mt)|0,l=l+Math.imul(He,gt)|0,_=_+Math.imul(Re,yt)|0,u=u+Math.imul(Re,bt)|0,u=u+Math.imul(Ne,yt)|0,l=l+Math.imul(Ne,bt)|0;var mu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(mu>>>26)|0,mu&=67108863,_=Math.imul($,at),u=Math.imul($,ct),u=u+Math.imul(Z,at)|0,l=Math.imul(Z,ct),_=_+Math.imul(h,ut)|0,u=u+Math.imul(h,dt)|0,u=u+Math.imul(x,ut)|0,l=l+Math.imul(x,dt)|0,_=_+Math.imul(Je,lt)|0,u=u+Math.imul(Je,ft)|0,u=u+Math.imul(b,lt)|0,l=l+Math.imul(b,ft)|0,_=_+Math.imul(Ge,ht)|0,u=u+Math.imul(Ge,pt)|0,u=u+Math.imul(Ye,ht)|0,l=l+Math.imul(Ye,pt)|0,_=_+Math.imul($e,mt)|0,u=u+Math.imul($e,gt)|0,u=u+Math.imul(De,mt)|0,l=l+Math.imul(De,gt)|0,_=_+Math.imul(Le,yt)|0,u=u+Math.imul(Le,bt)|0,u=u+Math.imul(He,yt)|0,l=l+Math.imul(He,bt)|0;var gu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(gu>>>26)|0,gu&=67108863,_=Math.imul($,ut),u=Math.imul($,dt),u=u+Math.imul(Z,ut)|0,l=Math.imul(Z,dt),_=_+Math.imul(h,lt)|0,u=u+Math.imul(h,ft)|0,u=u+Math.imul(x,lt)|0,l=l+Math.imul(x,ft)|0,_=_+Math.imul(Je,ht)|0,u=u+Math.imul(Je,pt)|0,u=u+Math.imul(b,ht)|0,l=l+Math.imul(b,pt)|0,_=_+Math.imul(Ge,mt)|0,u=u+Math.imul(Ge,gt)|0,u=u+Math.imul(Ye,mt)|0,l=l+Math.imul(Ye,gt)|0,_=_+Math.imul($e,yt)|0,u=u+Math.imul($e,bt)|0,u=u+Math.imul(De,yt)|0,l=l+Math.imul(De,bt)|0;var yu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(yu>>>26)|0,yu&=67108863,_=Math.imul($,lt),u=Math.imul($,ft),u=u+Math.imul(Z,lt)|0,l=Math.imul(Z,ft),_=_+Math.imul(h,ht)|0,u=u+Math.imul(h,pt)|0,u=u+Math.imul(x,ht)|0,l=l+Math.imul(x,pt)|0,_=_+Math.imul(Je,mt)|0,u=u+Math.imul(Je,gt)|0,u=u+Math.imul(b,mt)|0,l=l+Math.imul(b,gt)|0,_=_+Math.imul(Ge,yt)|0,u=u+Math.imul(Ge,bt)|0,u=u+Math.imul(Ye,yt)|0,l=l+Math.imul(Ye,bt)|0;var bu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(bu>>>26)|0,bu&=67108863,_=Math.imul($,ht),u=Math.imul($,pt),u=u+Math.imul(Z,ht)|0,l=Math.imul(Z,pt),_=_+Math.imul(h,mt)|0,u=u+Math.imul(h,gt)|0,u=u+Math.imul(x,mt)|0,l=l+Math.imul(x,gt)|0,_=_+Math.imul(Je,yt)|0,u=u+Math.imul(Je,bt)|0,u=u+Math.imul(b,yt)|0,l=l+Math.imul(b,bt)|0;var _u=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(_u>>>26)|0,_u&=67108863,_=Math.imul($,mt),u=Math.imul($,gt),u=u+Math.imul(Z,mt)|0,l=Math.imul(Z,gt),_=_+Math.imul(h,yt)|0,u=u+Math.imul(h,bt)|0,u=u+Math.imul(x,yt)|0,l=l+Math.imul(x,bt)|0;var Eu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(Eu>>>26)|0,Eu&=67108863,_=Math.imul($,yt),u=Math.imul($,bt),u=u+Math.imul(Z,yt)|0,l=Math.imul(Z,bt);var wu=(O+_|0)+((u&8191)<<13)|0;return O=(l+(u>>>13)|0)+(wu>>>26)|0,wu&=67108863,R[0]=ru,R[1]=su,R[2]=iu,R[3]=ou,R[4]=au,R[5]=cu,R[6]=uu,R[7]=du,R[8]=lu,R[9]=fu,R[10]=hu,R[11]=pu,R[12]=mu,R[13]=gu,R[14]=yu,R[15]=bu,R[16]=_u,R[17]=Eu,R[18]=wu,O!==0&&(R[19]=O,y.length++),y};Math.imul||(Y=K);function z(w,c,p){p.negative=c.negative^w.negative,p.length=w.length+c.length;for(var y=0,A=0,v=0;v<p.length-1;v++){var R=A;A=0;for(var O=y&67108863,_=Math.min(v,c.length-1),u=Math.max(0,v-w.length+1);u<=_;u++){var l=v-u,E=w.words[l]|0,T=c.words[u]|0,P=E*T,W=P&67108863;R=R+(P/67108864|0)|0,W=W+O|0,O=W&67108863,R=R+(W>>>26)|0,A+=R>>>26,R&=67108863}p.words[v]=O,y=R,R=A}return y!==0?p.words[v]=y:p.length--,p._strip()}function U(w,c,p){return z(w,c,p)}i.prototype.mulTo=function(c,p){var y,A=this.length+c.length;return this.length===10&&c.length===10?y=Y(this,c,p):A<63?y=K(this,c,p):A<1024?y=z(this,c,p):y=U(this,c,p),y},i.prototype.mul=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),this.mulTo(c,p)},i.prototype.mulf=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),U(this,c,p)},i.prototype.imul=function(c){return this.clone().mulTo(c,this)},i.prototype.imuln=function(c){var p=c<0;p&&(c=-c),r(typeof c=="number"),r(c<67108864);for(var y=0,A=0;A<this.length;A++){var v=(this.words[A]|0)*c,R=(v&67108863)+(y&67108863);y>>=26,y+=v/67108864|0,y+=R>>>26,this.words[A]=R&67108863}return y!==0&&(this.words[A]=y,this.length++),this.length=c===0?1:this.length,p?this.ineg():this},i.prototype.muln=function(c){return this.clone().imuln(c)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(c){var p=B(c);if(p.length===0)return new i(1);for(var y=this,A=0;A<p.length&&p[A]===0;A++,y=y.sqr());if(++A<p.length)for(var v=y.sqr();A<p.length;A++,v=v.sqr())p[A]!==0&&(y=y.mul(v));return y},i.prototype.iushln=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,A=67108863>>>26-p<<26-p,v;if(p!==0){var R=0;for(v=0;v<this.length;v++){var O=this.words[v]&A,_=(this.words[v]|0)-O<<p;this.words[v]=_|R,R=O>>>26-p}R&&(this.words[v]=R,this.length++)}if(y!==0){for(v=this.length-1;v>=0;v--)this.words[v+y]=this.words[v];for(v=0;v<y;v++)this.words[v]=0;this.length+=y}return this._strip()},i.prototype.ishln=function(c){return r(this.negative===0),this.iushln(c)},i.prototype.iushrn=function(c,p,y){r(typeof c=="number"&&c>=0);var A;p?A=(p-p%26)/26:A=0;var v=c%26,R=Math.min((c-v)/26,this.length),O=67108863^67108863>>>v<<v,_=y;if(A-=R,A=Math.max(0,A),_){for(var u=0;u<R;u++)_.words[u]=this.words[u];_.length=R}if(R!==0)if(this.length>R)for(this.length-=R,u=0;u<this.length;u++)this.words[u]=this.words[u+R];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(l!==0||u>=A);u--){var E=this.words[u]|0;this.words[u]=l<<26-v|E>>>v,l=E&O}return _&&l!==0&&(_.words[_.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(c,p,y){return r(this.negative===0),this.iushrn(c,p,y)},i.prototype.shln=function(c){return this.clone().ishln(c)},i.prototype.ushln=function(c){return this.clone().iushln(c)},i.prototype.shrn=function(c){return this.clone().ishrn(c)},i.prototype.ushrn=function(c){return this.clone().iushrn(c)},i.prototype.testn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,A=1<<p;if(this.length<=y)return!1;var v=this.words[y];return!!(v&A)},i.prototype.imaskn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(p!==0&&y++,this.length=Math.min(y,this.length),p!==0){var A=67108863^67108863>>>p<<p;this.words[this.length-1]&=A}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.maskn=function(c){return this.clone().imaskn(c)},i.prototype.iaddn=function(c){return r(typeof c=="number"),r(c<67108864),c<0?this.isubn(-c):this.negative!==0?this.length===1&&(this.words[0]|0)<=c?(this.words[0]=c-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(c),this.negative=1,this):this._iaddn(c)},i.prototype._iaddn=function(c){this.words[0]+=c;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},i.prototype.isubn=function(c){if(r(typeof c=="number"),r(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this._strip()},i.prototype.addn=function(c){return this.clone().iaddn(c)},i.prototype.subn=function(c){return this.clone().isubn(c)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(c,p,y){var A=c.length+y,v;this._expand(A);var R,O=0;for(v=0;v<c.length;v++){R=(this.words[v+y]|0)+O;var _=(c.words[v]|0)*p;R-=_&67108863,O=(R>>26)-(_/67108864|0),this.words[v+y]=R&67108863}for(;v<this.length-y;v++)R=(this.words[v+y]|0)+O,O=R>>26,this.words[v+y]=R&67108863;if(O===0)return this._strip();for(r(O===-1),O=0,v=0;v<this.length;v++)R=-(this.words[v]|0)+O,O=R>>26,this.words[v]=R&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(c,p){var y=this.length-c.length,A=this.clone(),v=c,R=v.words[v.length-1]|0,O=this._countBits(R);y=26-O,y!==0&&(v=v.ushln(y),A.iushln(y),R=v.words[v.length-1]|0);var _=A.length-v.length,u;if(p!=="mod"){u=new i(null),u.length=_+1,u.words=new Array(u.length);for(var l=0;l<u.length;l++)u.words[l]=0}var E=A.clone()._ishlnsubmul(v,1,_);E.negative===0&&(A=E,u&&(u.words[_]=1));for(var T=_-1;T>=0;T--){var P=(A.words[v.length+T]|0)*67108864+(A.words[v.length+T-1]|0);for(P=Math.min(P/R|0,67108863),A._ishlnsubmul(v,P,T);A.negative!==0;)P--,A.negative=0,A._ishlnsubmul(v,1,T),A.isZero()||(A.negative^=1);u&&(u.words[T]=P)}return u&&u._strip(),A._strip(),p!=="div"&&y!==0&&A.iushrn(y),{div:u||null,mod:A}},i.prototype.divmod=function(c,p,y){if(r(!c.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var A,v,R;return this.negative!==0&&c.negative===0?(R=this.neg().divmod(c,p),p!=="mod"&&(A=R.div.neg()),p!=="div"&&(v=R.mod.neg(),y&&v.negative!==0&&v.iadd(c)),{div:A,mod:v}):this.negative===0&&c.negative!==0?(R=this.divmod(c.neg(),p),p!=="mod"&&(A=R.div.neg()),{div:A,mod:R.mod}):(this.negative&c.negative)!==0?(R=this.neg().divmod(c.neg(),p),p!=="div"&&(v=R.mod.neg(),y&&v.negative!==0&&v.isub(c)),{div:R.div,mod:v}):c.length>this.length||this.cmp(c)<0?{div:new i(0),mod:this}:c.length===1?p==="div"?{div:this.divn(c.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new i(this.modrn(c.words[0]))}:this._wordDiv(c,p)},i.prototype.div=function(c){return this.divmod(c,"div",!1).div},i.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},i.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},i.prototype.divRound=function(c){var p=this.divmod(c);if(p.mod.isZero())return p.div;var y=p.div.negative!==0?p.mod.isub(c):p.mod,A=c.ushrn(1),v=c.andln(1),R=y.cmp(A);return R<0||v===1&&R===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},i.prototype.modrn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var y=(1<<26)%c,A=0,v=this.length-1;v>=0;v--)A=(y*A+(this.words[v]|0))%c;return p?-A:A},i.prototype.modn=function(c){return this.modrn(c)},i.prototype.idivn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var y=0,A=this.length-1;A>=0;A--){var v=(this.words[A]|0)+y*67108864;this.words[A]=v/c|0,y=v%c}return this._strip(),p?this.ineg():this},i.prototype.divn=function(c){return this.clone().idivn(c)},i.prototype.egcd=function(c){r(c.negative===0),r(!c.isZero());var p=this,y=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var A=new i(1),v=new i(0),R=new i(0),O=new i(1),_=0;p.isEven()&&y.isEven();)p.iushrn(1),y.iushrn(1),++_;for(var u=y.clone(),l=p.clone();!p.isZero();){for(var E=0,T=1;(p.words[0]&T)===0&&E<26;++E,T<<=1);if(E>0)for(p.iushrn(E);E-- >0;)(A.isOdd()||v.isOdd())&&(A.iadd(u),v.isub(l)),A.iushrn(1),v.iushrn(1);for(var P=0,W=1;(y.words[0]&W)===0&&P<26;++P,W<<=1);if(P>0)for(y.iushrn(P);P-- >0;)(R.isOdd()||O.isOdd())&&(R.iadd(u),O.isub(l)),R.iushrn(1),O.iushrn(1);p.cmp(y)>=0?(p.isub(y),A.isub(R),v.isub(O)):(y.isub(p),R.isub(A),O.isub(v))}return{a:R,b:O,gcd:y.iushln(_)}},i.prototype._invmp=function(c){r(c.negative===0),r(!c.isZero());var p=this,y=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var A=new i(1),v=new i(0),R=y.clone();p.cmpn(1)>0&&y.cmpn(1)>0;){for(var O=0,_=1;(p.words[0]&_)===0&&O<26;++O,_<<=1);if(O>0)for(p.iushrn(O);O-- >0;)A.isOdd()&&A.iadd(R),A.iushrn(1);for(var u=0,l=1;(y.words[0]&l)===0&&u<26;++u,l<<=1);if(u>0)for(y.iushrn(u);u-- >0;)v.isOdd()&&v.iadd(R),v.iushrn(1);p.cmp(y)>=0?(p.isub(y),A.isub(v)):(y.isub(p),v.isub(A))}var E;return p.cmpn(1)===0?E=A:E=v,E.cmpn(0)<0&&E.iadd(c),E},i.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var p=this.clone(),y=c.clone();p.negative=0,y.negative=0;for(var A=0;p.isEven()&&y.isEven();A++)p.iushrn(1),y.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;y.isEven();)y.iushrn(1);var v=p.cmp(y);if(v<0){var R=p;p=y,y=R}else if(v===0||y.cmpn(1)===0)break;p.isub(y)}while(!0);return y.iushln(A)},i.prototype.invm=function(c){return this.egcd(c).a.umod(c)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(c){return this.words[0]&c},i.prototype.bincn=function(c){r(typeof c=="number");var p=c%26,y=(c-p)/26,A=1<<p;if(this.length<=y)return this._expand(y+1),this.words[y]|=A,this;for(var v=A,R=y;v!==0&&R<this.length;R++){var O=this.words[R]|0;O+=v,v=O>>>26,O&=67108863,this.words[R]=O}return v!==0&&(this.words[R]=v,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(c){var p=c<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var y;if(this.length>1)y=1;else{p&&(c=-c),r(c<=67108863,"Number is too big");var A=this.words[0]|0;y=A===c?0:A<c?-1:1}return this.negative!==0?-y|0:y},i.prototype.cmp=function(c){if(this.negative!==0&&c.negative===0)return-1;if(this.negative===0&&c.negative!==0)return 1;var p=this.ucmp(c);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(c){if(this.length>c.length)return 1;if(this.length<c.length)return-1;for(var p=0,y=this.length-1;y>=0;y--){var A=this.words[y]|0,v=c.words[y]|0;if(A!==v){A<v?p=-1:A>v&&(p=1);break}}return p},i.prototype.gtn=function(c){return this.cmpn(c)===1},i.prototype.gt=function(c){return this.cmp(c)===1},i.prototype.gten=function(c){return this.cmpn(c)>=0},i.prototype.gte=function(c){return this.cmp(c)>=0},i.prototype.ltn=function(c){return this.cmpn(c)===-1},i.prototype.lt=function(c){return this.cmp(c)===-1},i.prototype.lten=function(c){return this.cmpn(c)<=0},i.prototype.lte=function(c){return this.cmp(c)<=0},i.prototype.eqn=function(c){return this.cmpn(c)===0},i.prototype.eq=function(c){return this.cmp(c)===0},i.red=function(c){return new L(c)},i.prototype.toRed=function(c){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(c){return this.red=c,this},i.prototype.forceRed=function(c){return r(!this.red,"Already a number in reduction context"),this._forceRed(c)},i.prototype.redAdd=function(c){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},i.prototype.redIAdd=function(c){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},i.prototype.redSub=function(c){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},i.prototype.redISub=function(c){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},i.prototype.redShl=function(c){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},i.prototype.redMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},i.prototype.redIMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(c){return r(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var j={k256:null,p224:null,p192:null,p25519:null};function J(w,c){this.name=w,this.p=new i(c,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}J.prototype._tmp=function(){var c=new i(null);return c.words=new Array(Math.ceil(this.n/13)),c},J.prototype.ireduce=function(c){var p=c,y;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),y=p.bitLength();while(y>this.n);var A=y<this.n?-1:p.ucmp(this.p);return A===0?(p.words[0]=0,p.length=1):A>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},J.prototype.split=function(c,p){c.iushrn(this.n,0,p)},J.prototype.imulK=function(c){return c.imul(this.k)};function ne(){J.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(ne,J),ne.prototype.split=function(c,p){for(var y=4194303,A=Math.min(c.length,9),v=0;v<A;v++)p.words[v]=c.words[v];if(p.length=A,c.length<=9){c.words[0]=0,c.length=1;return}var R=c.words[9];for(p.words[p.length++]=R&y,v=10;v<c.length;v++){var O=c.words[v]|0;c.words[v-10]=(O&y)<<4|R>>>22,R=O}R>>>=22,c.words[v-10]=R,R===0&&c.length>10?c.length-=10:c.length-=9},ne.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var p=0,y=0;y<c.length;y++){var A=c.words[y]|0;p+=A*977,c.words[y]=p&67108863,p=A*64+(p/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};function te(){J.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(te,J);function V(){J.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(V,J);function C(){J.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(C,J),C.prototype.imulK=function(c){for(var p=0,y=0;y<c.length;y++){var A=(c.words[y]|0)*19+p,v=A&67108863;A>>>=26,c.words[y]=v,p=A}return p!==0&&(c.words[c.length++]=p),c},i._prime=function(c){if(j[c])return j[c];var p;if(c==="k256")p=new ne;else if(c==="p224")p=new te;else if(c==="p192")p=new V;else if(c==="p25519")p=new C;else throw new Error("Unknown prime "+c);return j[c]=p,p};function L(w){if(typeof w=="string"){var c=i._prime(w);this.m=c.p,this.prime=c}else r(w.gtn(1),"modulus must be greater than 1"),this.m=w,this.prime=null}L.prototype._verify1=function(c){r(c.negative===0,"red works only with positives"),r(c.red,"red works only with red numbers")},L.prototype._verify2=function(c,p){r((c.negative|p.negative)===0,"red works only with positives"),r(c.red&&c.red===p.red,"red works only with red numbers")},L.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(g(c,c.umod(this.m)._forceRed(this)),c)},L.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},L.prototype.add=function(c,p){this._verify2(c,p);var y=c.add(p);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},L.prototype.iadd=function(c,p){this._verify2(c,p);var y=c.iadd(p);return y.cmp(this.m)>=0&&y.isub(this.m),y},L.prototype.sub=function(c,p){this._verify2(c,p);var y=c.sub(p);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},L.prototype.isub=function(c,p){this._verify2(c,p);var y=c.isub(p);return y.cmpn(0)<0&&y.iadd(this.m),y},L.prototype.shl=function(c,p){return this._verify1(c),this.imod(c.ushln(p))},L.prototype.imul=function(c,p){return this._verify2(c,p),this.imod(c.imul(p))},L.prototype.mul=function(c,p){return this._verify2(c,p),this.imod(c.mul(p))},L.prototype.isqr=function(c){return this.imul(c,c.clone())},L.prototype.sqr=function(c){return this.mul(c,c)},L.prototype.sqrt=function(c){if(c.isZero())return c.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var y=this.m.add(new i(1)).iushrn(2);return this.pow(c,y)}for(var A=this.m.subn(1),v=0;!A.isZero()&&A.andln(1)===0;)v++,A.iushrn(1);r(!A.isZero());var R=new i(1).toRed(this),O=R.redNeg(),_=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,_).cmp(O)!==0;)u.redIAdd(O);for(var l=this.pow(u,A),E=this.pow(c,A.addn(1).iushrn(1)),T=this.pow(c,A),P=v;T.cmp(R)!==0;){for(var W=T,se=0;W.cmp(R)!==0;se++)W=W.redSqr();r(se<P);var ae=this.pow(l,new i(1).iushln(P-se-1));E=E.redMul(ae),l=ae.redSqr(),T=T.redMul(l),P=se}return E},L.prototype.invm=function(c){var p=c._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},L.prototype.pow=function(c,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return c.clone();var y=4,A=new Array(1<<y);A[0]=new i(1).toRed(this),A[1]=c;for(var v=2;v<A.length;v++)A[v]=this.mul(A[v-1],c);var R=A[0],O=0,_=0,u=p.bitLength()%26;for(u===0&&(u=26),v=p.length-1;v>=0;v--){for(var l=p.words[v],E=u-1;E>=0;E--){var T=l>>E&1;if(R!==A[0]&&(R=this.sqr(R)),T===0&&O===0){_=0;continue}O<<=1,O|=T,_++,!(_!==y&&(v!==0||E!==0))&&(R=this.mul(R,A[O]),_=0,O=0)}u=26}return R},L.prototype.convertTo=function(c){var p=c.umod(this.m);return p===c?p.clone():p},L.prototype.convertFrom=function(c){var p=c.clone();return p.red=null,p},i.mont=function(c){return new q(c)};function q(w){L.call(this,w),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}s(q,L),q.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},q.prototype.convertFrom=function(c){var p=this.imod(c.mul(this.rinv));return p.red=null,p},q.prototype.imul=function(c,p){if(c.isZero()||p.isZero())return c.words[0]=0,c.length=1,c;var y=c.imul(p),A=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=y.isub(A).iushrn(this.shift),R=v;return v.cmp(this.m)>=0?R=v.isub(this.m):v.cmpn(0)<0&&(R=v.iadd(this.m)),R._forceRed(this)},q.prototype.mul=function(c,p){if(c.isZero()||p.isZero())return new i(0)._forceRed(this);var y=c.mul(p),A=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=y.isub(A).iushrn(this.shift),R=v;return v.cmp(this.m)>=0?R=v.isub(this.m):v.cmpn(0)<0&&(R=v.iadd(this.m)),R._forceRed(this)},q.prototype.invm=function(c){var p=this.imod(c._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,f_)})(zi)),zi.exports}var h_=Tf();const If=Wa(h_);var ji={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Of;function p_(){return Of||(Of=1,(function(t,e){var n=lc(),r=n.Buffer;function s(o,a){for(var d in o)a[d]=o[d]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(s(n,e),e.Buffer=i);function i(o,a,d){return r(o,a,d)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,a,d){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,d)},i.alloc=function(o,a,d){if(typeof o!="number")throw new TypeError("Argument must be a number");var m=r(o);return a!==void 0?typeof d=="string"?m.fill(a,d):m.fill(a):m.fill(0),m},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(o)}})(ji,ji.exports)),ji.exports}var pc,Nf;function m_(){if(Nf)return pc;Nf=1;var t=p_().Buffer;function e(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var i=0;i<n.length;i++){var o=n.charAt(i),a=o.charCodeAt(0);if(r[a]!==255)throw new TypeError(o+" is ambiguous");r[a]=i}var d=n.length,m=n.charAt(0),g=Math.log(d)/Math.log(256),S=Math.log(256)/Math.log(d);function I(M){if((Array.isArray(M)||M instanceof Uint8Array)&&(M=t.from(M)),!t.isBuffer(M))throw new TypeError("Expected Buffer");if(M.length===0)return"";for(var B=0,K=0,Y=0,z=M.length;Y!==z&&M[Y]===0;)Y++,B++;for(var U=(z-Y)*S+1>>>0,j=new Uint8Array(U);Y!==z;){for(var J=M[Y],ne=0,te=U-1;(J!==0||ne<K)&&te!==-1;te--,ne++)J+=256*j[te]>>>0,j[te]=J%d>>>0,J=J/d>>>0;if(J!==0)throw new Error("Non-zero carry");K=ne,Y++}for(var V=U-K;V!==U&&j[V]===0;)V++;for(var C=m.repeat(B);V<U;++V)C+=n.charAt(j[V]);return C}function N(M){if(typeof M!="string")throw new TypeError("Expected String");if(M.length===0)return t.alloc(0);for(var B=0,K=0,Y=0;M[B]===m;)K++,B++;for(var z=(M.length-B)*g+1>>>0,U=new Uint8Array(z);B<M.length;){var j=M.charCodeAt(B);if(j>255)return;var J=r[j];if(J===255)return;for(var ne=0,te=z-1;(J!==0||ne<Y)&&te!==-1;te--,ne++)J+=d*U[te]>>>0,U[te]=J%256>>>0,J=J/256>>>0;if(J!==0)throw new Error("Non-zero carry");Y=ne,B++}for(var V=z-Y;V!==z&&U[V]===0;)V++;var C=t.allocUnsafe(K+(z-V));C.fill(0,0,K);for(var L=K;V!==z;)C[L++]=U[V++];return C}function F(M){var B=N(M);if(B)return B;throw new Error("Non-base"+d+" character")}return{encode:I,decodeUnsafe:N,decode:F}}return pc=e,pc}var mc,Cf;function Mf(){if(Cf)return mc;Cf=1;var t=m_(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return mc=t(e),mc}var g_=Mf();const zt=Wa(g_);var ke={};function In(t,e,n){return e<=t&&t<=n}function Vi(t){if(t===void 0)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function y_(t){for(var e=String(t),n=e.length,r=0,s=[];r<n;){var i=e.charCodeAt(r);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(r===n-1)s.push(65533);else{var o=t.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=i&1023,d=o&1023;s.push(65536+(a<<10)+d),r+=1}else s.push(65533)}r+=1}return s}function b_(t){for(var e="",n=0;n<t.length;++n){var r=t[n];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}var Hi=-1;function gc(t){this.tokens=[].slice.call(t)}gc.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Hi},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var Pr=-1;function yc(t,e){if(t)throw TypeError("Decoder error");return e||65533}var Gi="utf-8";function qi(t,e){if(!(this instanceof qi))return new qi(t,e);if(t=t!==void 0?String(t).toLowerCase():Gi,t!==Gi)throw new Error("Encoding not supported. Only utf-8 is supported");e=Vi(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}qi.prototype={decode:function(e,n){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),n=Vi(n),this._streaming||(this._decoder=new __({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!n.stream;for(var s=new gc(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==Pr);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===Pr)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),b_(i)}};function Ki(t,e){if(!(this instanceof Ki))return new Ki(t,e);if(t=t!==void 0?String(t).toLowerCase():Gi,t!==Gi)throw new Error("Encoding not supported. Only utf-8 is supported");e=Vi(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Ki.prototype={encode:function(e,n){e=e?String(e):"",n=Vi(n),this._streaming||(this._encoder=new E_(this._options)),this._streaming=!!n.stream;for(var r=[],s=new gc(y_(e)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==Pr);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==Pr;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function __(t){var e=t.fatal,n=0,r=0,s=0,i=128,o=191;this.handler=function(a,d){if(d===Hi&&s!==0)return s=0,yc(e);if(d===Hi)return Pr;if(s===0){if(In(d,0,127))return d;if(In(d,194,223))s=1,n=d-192;else if(In(d,224,239))d===224&&(i=160),d===237&&(o=159),s=2,n=d-224;else if(In(d,240,244))d===240&&(i=144),d===244&&(o=143),s=3,n=d-240;else return yc(e);return n=n<<6*s,null}if(!In(d,i,o))return n=s=r=0,i=128,o=191,a.prepend(d),yc(e);if(i=128,o=191,r+=1,n+=d-128<<6*(s-r),r!==s)return null;var m=n;return n=s=r=0,m}}function E_(t){t.fatal,this.handler=function(e,n){if(n===Hi)return Pr;if(In(n,0,127))return n;var r,s;In(n,128,2047)?(r=1,s=192):In(n,2048,65535)?(r=2,s=224):In(n,65536,1114111)&&(r=3,s=240);for(var i=[(n>>6*r)+s];r>0;){var o=n>>6*(r-1);i.push(128|o&63),r-=1}return i}}const w_=Za(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:qi,TextEncoder:Ki},Symbol.toStringTag,{value:"Module"})));var kf;function v_(){if(kf)return ke;kf=1;var t=ke&&ke.__createBinding||(Object.create?(function(V,C,L,q){q===void 0&&(q=L),Object.defineProperty(V,q,{enumerable:!0,get:function(){return C[L]}})}):(function(V,C,L,q){q===void 0&&(q=L),V[q]=C[L]})),e=ke&&ke.__setModuleDefault||(Object.create?(function(V,C){Object.defineProperty(V,"default",{enumerable:!0,value:C})}):function(V,C){V.default=C}),n=ke&&ke.__decorate||function(V,C,L,q){var w=arguments.length,c=w<3?C:q===null?q=Object.getOwnPropertyDescriptor(C,L):q,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(V,C,L,q);else for(var y=V.length-1;y>=0;y--)(p=V[y])&&(c=(w<3?p(c):w>3?p(C,L,c):p(C,L))||c);return w>3&&c&&Object.defineProperty(C,L,c),c},r=ke&&ke.__importStar||function(V){if(V&&V.__esModule)return V;var C={};if(V!=null)for(var L in V)L!=="default"&&Object.hasOwnProperty.call(V,L)&&t(C,V,L);return e(C,V),C},s=ke&&ke.__importDefault||function(V){return V&&V.__esModule?V:{default:V}};Object.defineProperty(ke,"__esModule",{value:!0}),ke.deserializeUnchecked=ke.deserialize=ke.serialize=ke.BinaryReader=ke.BinaryWriter=ke.BorshError=ke.baseDecode=ke.baseEncode=void 0;const i=s(Tf()),o=s(Mf()),a=r(w_),d=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,m=new d("utf-8",{fatal:!0});function g(V){return typeof V=="string"&&(V=Buffer.from(V,"utf8")),o.default.encode(Buffer.from(V))}ke.baseEncode=g;function S(V){return Buffer.from(o.default.decode(V))}ke.baseDecode=S;const I=1024;class N extends Error{constructor(C){super(C),this.fieldPath=[],this.originalMessage=C}addToFieldPath(C){this.fieldPath.splice(0,0,C),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}ke.BorshError=N;class F{constructor(){this.buf=Buffer.alloc(I),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(I)]))}writeU8(C){this.maybeResize(),this.buf.writeUInt8(C,this.length),this.length+=1}writeU16(C){this.maybeResize(),this.buf.writeUInt16LE(C,this.length),this.length+=2}writeU32(C){this.maybeResize(),this.buf.writeUInt32LE(C,this.length),this.length+=4}writeU64(C){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(C).toArray("le",8)))}writeU128(C){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(C).toArray("le",16)))}writeU256(C){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(C).toArray("le",32)))}writeU512(C){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(C).toArray("le",64)))}writeBuffer(C){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),C,Buffer.alloc(I)]),this.length+=C.length}writeString(C){this.maybeResize();const L=Buffer.from(C,"utf8");this.writeU32(L.length),this.writeBuffer(L)}writeFixedArray(C){this.writeBuffer(Buffer.from(C))}writeArray(C,L){this.maybeResize(),this.writeU32(C.length);for(const q of C)this.maybeResize(),L(q)}toArray(){return this.buf.subarray(0,this.length)}}ke.BinaryWriter=F;function M(V,C,L){const q=L.value;L.value=function(...w){try{return q.apply(this,w)}catch(c){if(c instanceof RangeError){const p=c.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(p)>=0)throw new N("Reached the end of buffer when deserializing")}throw c}}}class B{constructor(C){this.buf=C,this.offset=0}readU8(){const C=this.buf.readUInt8(this.offset);return this.offset+=1,C}readU16(){const C=this.buf.readUInt16LE(this.offset);return this.offset+=2,C}readU32(){const C=this.buf.readUInt32LE(this.offset);return this.offset+=4,C}readU64(){const C=this.readBuffer(8);return new i.default(C,"le")}readU128(){const C=this.readBuffer(16);return new i.default(C,"le")}readU256(){const C=this.readBuffer(32);return new i.default(C,"le")}readU512(){const C=this.readBuffer(64);return new i.default(C,"le")}readBuffer(C){if(this.offset+C>this.buf.length)throw new N(`Expected buffer length ${C} isn't within bounds`);const L=this.buf.slice(this.offset,this.offset+C);return this.offset+=C,L}readString(){const C=this.readU32(),L=this.readBuffer(C);try{return m.decode(L)}catch(q){throw new N(`Error decoding UTF-8 string: ${q}`)}}readFixedArray(C){return new Uint8Array(this.readBuffer(C))}readArray(C){const L=this.readU32(),q=Array();for(let w=0;w<L;++w)q.push(C());return q}}n([M],B.prototype,"readU8",null),n([M],B.prototype,"readU16",null),n([M],B.prototype,"readU32",null),n([M],B.prototype,"readU64",null),n([M],B.prototype,"readU128",null),n([M],B.prototype,"readU256",null),n([M],B.prototype,"readU512",null),n([M],B.prototype,"readString",null),n([M],B.prototype,"readFixedArray",null),n([M],B.prototype,"readArray",null),ke.BinaryReader=B;function K(V){return V.charAt(0).toUpperCase()+V.slice(1)}function Y(V,C,L,q,w){try{if(typeof q=="string")w[`write${K(q)}`](L);else if(q instanceof Array)if(typeof q[0]=="number"){if(L.length!==q[0])throw new N(`Expecting byte array of length ${q[0]}, but got ${L.length} bytes`);w.writeFixedArray(L)}else if(q.length===2&&typeof q[1]=="number"){if(L.length!==q[1])throw new N(`Expecting byte array of length ${q[1]}, but got ${L.length} bytes`);for(let c=0;c<q[1];c++)Y(V,null,L[c],q[0],w)}else w.writeArray(L,c=>{Y(V,C,c,q[0],w)});else if(q.kind!==void 0)switch(q.kind){case"option":{L==null?w.writeU8(0):(w.writeU8(1),Y(V,C,L,q.type,w));break}case"map":{w.writeU32(L.size),L.forEach((c,p)=>{Y(V,C,p,q.key,w),Y(V,C,c,q.value,w)});break}default:throw new N(`FieldType ${q} unrecognized`)}else z(V,L,w)}catch(c){throw c instanceof N&&c.addToFieldPath(C),c}}function z(V,C,L){if(typeof C.borshSerialize=="function"){C.borshSerialize(L);return}const q=V.get(C.constructor);if(!q)throw new N(`Class ${C.constructor.name} is missing in schema`);if(q.kind==="struct")q.fields.map(([w,c])=>{Y(V,w,C[w],c,L)});else if(q.kind==="enum"){const w=C[q.field];for(let c=0;c<q.values.length;++c){const[p,y]=q.values[c];if(p===w){L.writeU8(c),Y(V,p,C[p],y,L);break}}}else throw new N(`Unexpected schema kind: ${q.kind} for ${C.constructor.name}`)}function U(V,C,L=F){const q=new L;return z(V,C,q),q.toArray()}ke.serialize=U;function j(V,C,L,q){try{if(typeof L=="string")return q[`read${K(L)}`]();if(L instanceof Array){if(typeof L[0]=="number")return q.readFixedArray(L[0]);if(typeof L[1]=="number"){const w=[];for(let c=0;c<L[1];c++)w.push(j(V,null,L[0],q));return w}else return q.readArray(()=>j(V,C,L[0],q))}if(L.kind==="option")return q.readU8()?j(V,C,L.type,q):void 0;if(L.kind==="map"){let w=new Map;const c=q.readU32();for(let p=0;p<c;p++){const y=j(V,C,L.key,q),A=j(V,C,L.value,q);w.set(y,A)}return w}return J(V,L,q)}catch(w){throw w instanceof N&&w.addToFieldPath(C),w}}function J(V,C,L){if(typeof C.borshDeserialize=="function")return C.borshDeserialize(L);const q=V.get(C);if(!q)throw new N(`Class ${C.name} is missing in schema`);if(q.kind==="struct"){const w={};for(const[c,p]of V.get(C).fields)w[c]=j(V,c,p,L);return new C(w)}if(q.kind==="enum"){const w=L.readU8();if(w>=q.values.length)throw new N(`Enum index: ${w} is out of range`);const[c,p]=q.values[w],y=j(V,c,p,L);return new C({[c]:y})}throw new N(`Unexpected schema kind: ${q.kind} for ${C.constructor.name}`)}function ne(V,C,L,q=B){const w=new q(L),c=J(V,C,w);if(w.offset<L.length)throw new N(`Unexpected ${L.length-w.offset} bytes after deserialized data`);return c}ke.deserialize=ne;function te(V,C,L,q=B){const w=new q(L);return J(V,C,w)}return ke.deserializeUnchecked=te,ke}var bc=v_(),G={},Bf;function R_(){if(Bf)return G;Bf=1,Object.defineProperty(G,"__esModule",{value:!0}),G.s16=G.s8=G.nu64be=G.u48be=G.u40be=G.u32be=G.u24be=G.u16be=G.nu64=G.u48=G.u40=G.u32=G.u24=G.u16=G.u8=G.offset=G.greedy=G.Constant=G.UTF8=G.CString=G.Blob=G.Boolean=G.BitField=G.BitStructure=G.VariantLayout=G.Union=G.UnionLayoutDiscriminator=G.UnionDiscriminator=G.Structure=G.Sequence=G.DoubleBE=G.Double=G.FloatBE=G.Float=G.NearInt64BE=G.NearInt64=G.NearUInt64BE=G.NearUInt64=G.IntBE=G.Int=G.UIntBE=G.UInt=G.OffsetLayout=G.GreedyCount=G.ExternalLayout=G.bindConstructorLayout=G.nameWithProperty=G.Layout=G.uint8ArrayToBuffer=G.checkUint8Array=void 0,G.constant=G.utf8=G.cstr=G.blob=G.unionLayoutDiscriminator=G.union=G.seq=G.bits=G.struct=G.f64be=G.f64=G.f32be=G.f32=G.ns64be=G.s48be=G.s40be=G.s32be=G.s24be=G.s16be=G.ns64=G.s48=G.s40=G.s32=G.s24=void 0;const t=lc();function e(u){if(!(u instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}G.checkUint8Array=e;function n(u){return e(u),t.Buffer.from(u.buffer,u.byteOffset,u.length)}G.uint8ArrayToBuffer=n;let r=class{constructor(l,E){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=E}makeDestinationObject(){return{}}getSpan(l,E){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const E=Object.create(this.constructor.prototype);return Object.assign(E,this),E.property=l,E}fromArray(l){}};G.Layout=r;function s(u,l){return l.property?u+"["+l.property+"]":u}G.nameWithProperty=s;function i(u,l){if(typeof u!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(u,"layout_"))throw new Error("Class is already bound to a layout");if(!(l&&l instanceof r))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(l,"boundConstructor_"))throw new Error("layout is already bound to a constructor");u.layout_=l,l.boundConstructor_=u,l.makeDestinationObject=(()=>new u),Object.defineProperty(u.prototype,"encode",{value(E,T){return l.encode(this,E,T)},writable:!0}),Object.defineProperty(u,"decode",{value(E,T){return l.decode(E,T)},writable:!0})}G.bindConstructorLayout=i;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}G.ExternalLayout=o;class a extends o{constructor(l=1,E){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,E),this.elementSpan=l}isCount(){return!0}decode(l,E=0){e(l);const T=l.length-E;return Math.floor(T/this.elementSpan)}encode(l,E,T){return 0}}G.GreedyCount=a;class d extends o{constructor(l,E=0,T){if(!(l instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(E))throw new TypeError("offset must be integer or undefined");super(l.span,T||l.property),this.layout=l,this.offset=E}isCount(){return this.layout instanceof m||this.layout instanceof g}decode(l,E=0){return this.layout.decode(l,E+this.offset)}encode(l,E,T=0){return this.layout.encode(l,E,T+this.offset)}}G.OffsetLayout=d;class m extends r{constructor(l,E){if(super(l,E),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,E=0){return n(l).readUIntLE(E,this.span)}encode(l,E,T=0){return n(E).writeUIntLE(l,T,this.span),this.span}}G.UInt=m;class g extends r{constructor(l,E){if(super(l,E),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,E=0){return n(l).readUIntBE(E,this.span)}encode(l,E,T=0){return n(E).writeUIntBE(l,T,this.span),this.span}}G.UIntBE=g;class S extends r{constructor(l,E){if(super(l,E),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,E=0){return n(l).readIntLE(E,this.span)}encode(l,E,T=0){return n(E).writeIntLE(l,T,this.span),this.span}}G.Int=S;class I extends r{constructor(l,E){if(super(l,E),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,E=0){return n(l).readIntBE(E,this.span)}encode(l,E,T=0){return n(E).writeIntBE(l,T,this.span),this.span}}G.IntBE=I;const N=Math.pow(2,32);function F(u){const l=Math.floor(u/N),E=u-l*N;return{hi32:l,lo32:E}}function M(u,l){return u*N+l}class B extends r{constructor(l){super(8,l)}decode(l,E=0){const T=n(l),P=T.readUInt32LE(E),W=T.readUInt32LE(E+4);return M(W,P)}encode(l,E,T=0){const P=F(l),W=n(E);return W.writeUInt32LE(P.lo32,T),W.writeUInt32LE(P.hi32,T+4),8}}G.NearUInt64=B;class K extends r{constructor(l){super(8,l)}decode(l,E=0){const T=n(l),P=T.readUInt32BE(E),W=T.readUInt32BE(E+4);return M(P,W)}encode(l,E,T=0){const P=F(l),W=n(E);return W.writeUInt32BE(P.hi32,T),W.writeUInt32BE(P.lo32,T+4),8}}G.NearUInt64BE=K;class Y extends r{constructor(l){super(8,l)}decode(l,E=0){const T=n(l),P=T.readUInt32LE(E),W=T.readInt32LE(E+4);return M(W,P)}encode(l,E,T=0){const P=F(l),W=n(E);return W.writeUInt32LE(P.lo32,T),W.writeInt32LE(P.hi32,T+4),8}}G.NearInt64=Y;class z extends r{constructor(l){super(8,l)}decode(l,E=0){const T=n(l),P=T.readInt32BE(E),W=T.readUInt32BE(E+4);return M(P,W)}encode(l,E,T=0){const P=F(l),W=n(E);return W.writeInt32BE(P.hi32,T),W.writeUInt32BE(P.lo32,T+4),8}}G.NearInt64BE=z;class U extends r{constructor(l){super(4,l)}decode(l,E=0){return n(l).readFloatLE(E)}encode(l,E,T=0){return n(E).writeFloatLE(l,T),4}}G.Float=U;class j extends r{constructor(l){super(4,l)}decode(l,E=0){return n(l).readFloatBE(E)}encode(l,E,T=0){return n(E).writeFloatBE(l,T),4}}G.FloatBE=j;class J extends r{constructor(l){super(8,l)}decode(l,E=0){return n(l).readDoubleLE(E)}encode(l,E,T=0){return n(E).writeDoubleLE(l,T),8}}G.Double=J;class ne extends r{constructor(l){super(8,l)}decode(l,E=0){return n(l).readDoubleBE(E)}encode(l,E,T=0){return n(E).writeDoubleBE(l,T),8}}G.DoubleBE=ne;class te extends r{constructor(l,E,T){if(!(l instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(E instanceof o&&E.isCount()||Number.isInteger(E)&&0<=E))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let P=-1;!(E instanceof o)&&0<l.span&&(P=E*l.span),super(P,T),this.elementLayout=l,this.count=E}getSpan(l,E=0){if(0<=this.span)return this.span;let T=0,P=this.count;if(P instanceof o&&(P=P.decode(l,E)),0<this.elementLayout.span)T=P*this.elementLayout.span;else{let W=0;for(;W<P;)T+=this.elementLayout.getSpan(l,E+T),++W}return T}decode(l,E=0){const T=[];let P=0,W=this.count;for(W instanceof o&&(W=W.decode(l,E));P<W;)T.push(this.elementLayout.decode(l,E)),E+=this.elementLayout.getSpan(l,E),P+=1;return T}encode(l,E,T=0){const P=this.elementLayout,W=l.reduce((se,ae)=>se+P.encode(ae,E,T+se),0);return this.count instanceof o&&this.count.encode(l.length,E,T),W}}G.Sequence=te;class V extends r{constructor(l,E,T){if(!(Array.isArray(l)&&l.reduce((W,se)=>W&&se instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof E=="boolean"&&T===void 0&&(T=E,E=void 0);for(const W of l)if(0>W.span&&W.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let P=-1;try{P=l.reduce((W,se)=>W+se.getSpan(),0)}catch{}super(P,E),this.fields=l,this.decodePrefixes=!!T}getSpan(l,E=0){if(0<=this.span)return this.span;let T=0;try{T=this.fields.reduce((P,W)=>{const se=W.getSpan(l,E);return E+=se,P+se},0)}catch{throw new RangeError("indeterminate span")}return T}decode(l,E=0){e(l);const T=this.makeDestinationObject();for(const P of this.fields)if(P.property!==void 0&&(T[P.property]=P.decode(l,E)),E+=P.getSpan(l,E),this.decodePrefixes&&l.length===E)break;return T}encode(l,E,T=0){const P=T;let W=0,se=0;for(const ae of this.fields){let Me=ae.span;if(se=0<Me?Me:0,ae.property!==void 0){const ve=l[ae.property];ve!==void 0&&(se=ae.encode(ve,E,T),0>Me&&(Me=ae.getSpan(E,T)))}W=T,T+=Me}return W+se-P}fromArray(l){const E=this.makeDestinationObject();for(const T of this.fields)T.property!==void 0&&0<l.length&&(E[T.property]=l.shift());return E}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const E of this.fields)if(E.property===l)return E}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let E=0;for(const T of this.fields){if(T.property===l)return E;0>T.span?E=-1:0<=E&&(E+=T.span)}}}G.Structure=V;class C{constructor(l){this.property=l}decode(l,E){throw new Error("UnionDiscriminator is abstract")}encode(l,E,T){throw new Error("UnionDiscriminator is abstract")}}G.UnionDiscriminator=C;class L extends C{constructor(l,E){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(E||l.property||"variant"),this.layout=l}decode(l,E){return this.layout.decode(l,E)}encode(l,E,T){return this.layout.encode(l,E,T)}}G.UnionLayoutDiscriminator=L;class q extends r{constructor(l,E,T){let P;if(l instanceof m||l instanceof g)P=new L(new d(l));else if(l instanceof o&&l.isCount())P=new L(l);else if(l instanceof C)P=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(E===void 0&&(E=null),!(E===null||E instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(E!==null){if(0>E.span)throw new Error("defaultLayout must have constant span");E.property===void 0&&(E=E.replicate("content"))}let W=-1;E&&(W=E.span,0<=W&&(l instanceof m||l instanceof g)&&(W+=P.layout.span)),super(W,T),this.discriminator=P,this.usesPrefixDiscriminator=l instanceof m||l instanceof g,this.defaultLayout=E,this.registry={};let se=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(ae){return se(ae)},this.configGetSourceVariant=function(ae){se=ae.bind(this)}}getSpan(l,E=0){if(0<=this.span)return this.span;const T=this.getVariant(l,E);if(!T)throw new Error("unable to determine span for unrecognized variant");return T.getSpan(l,E)}defaultGetSourceVariant(l){if(Object.prototype.hasOwnProperty.call(l,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(l,this.defaultLayout.property))return;const E=this.registry[l[this.discriminator.property]];if(E&&(!E.layout||E.property&&Object.prototype.hasOwnProperty.call(l,E.property)))return E}else for(const E in this.registry){const T=this.registry[E];if(T.property&&Object.prototype.hasOwnProperty.call(l,T.property))return T}throw new Error("unable to infer src variant")}decode(l,E=0){let T;const P=this.discriminator,W=P.decode(l,E),se=this.registry[W];if(se===void 0){const ae=this.defaultLayout;let Me=0;this.usesPrefixDiscriminator&&(Me=P.layout.span),T=this.makeDestinationObject(),T[P.property]=W,T[ae.property]=ae.decode(l,E+Me)}else T=se.decode(l,E);return T}encode(l,E,T=0){const P=this.getSourceVariant(l);if(P===void 0){const W=this.discriminator,se=this.defaultLayout;let ae=0;return this.usesPrefixDiscriminator&&(ae=W.layout.span),W.encode(l[W.property],E,T),ae+se.encode(l[se.property],E,T+ae)}return P.encode(l,E,T)}addVariant(l,E,T){const P=new w(this,l,E,T);return this.registry[l]=P,P}getVariant(l,E=0){let T;return l instanceof Uint8Array?T=this.discriminator.decode(l,E):T=l,this.registry[T]}}G.Union=q;class w extends r{constructor(l,E,T,P){if(!(l instanceof q))throw new TypeError("union must be a Union");if(!Number.isInteger(E)||0>E)throw new TypeError("variant must be a (non-negative) integer");if(typeof T=="string"&&P===void 0&&(P=T,T=null),T){if(!(T instanceof r))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=T.span&&T.span>l.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof P!="string")throw new TypeError("variant must have a String property")}let W=l.span;0>l.span&&(W=T?T.span:0,0<=W&&l.usesPrefixDiscriminator&&(W+=l.discriminator.layout.span)),super(W,P),this.union=l,this.variant=E,this.layout=T||null}getSpan(l,E=0){if(0<=this.span)return this.span;let T=0;this.union.usesPrefixDiscriminator&&(T=this.union.discriminator.layout.span);let P=0;return this.layout&&(P=this.layout.getSpan(l,E+T)),T+P}decode(l,E=0){const T=this.makeDestinationObject();if(this!==this.union.getVariant(l,E))throw new Error("variant mismatch");let P=0;return this.union.usesPrefixDiscriminator&&(P=this.union.discriminator.layout.span),this.layout?T[this.property]=this.layout.decode(l,E+P):this.property?T[this.property]=!0:this.union.usesPrefixDiscriminator&&(T[this.union.discriminator.property]=this.variant),T}encode(l,E,T=0){let P=0;if(this.union.usesPrefixDiscriminator&&(P=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(l,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,E,T);let W=P;if(this.layout&&(this.layout.encode(l[this.property],E,T+P),W+=this.layout.getSpan(E,T+P),0<=this.union.span&&W>this.union.span))throw new Error("encoded variant overruns containing union");return W}fromArray(l){if(this.layout)return this.layout.fromArray(l)}}G.VariantLayout=w;function c(u){return 0>u&&(u+=4294967296),u}class p extends r{constructor(l,E,T){if(!(l instanceof m||l instanceof g))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof E=="string"&&T===void 0&&(T=E,E=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,T),this.word=l,this.msb=!!E,this.fields=[];let P=0;this._packedSetValue=function(W){return P=c(W),this},this._packedGetValue=function(){return P}}decode(l,E=0){const T=this.makeDestinationObject(),P=this.word.decode(l,E);this._packedSetValue(P);for(const W of this.fields)W.property!==void 0&&(T[W.property]=W.decode(l));return T}encode(l,E,T=0){const P=this.word.decode(E,T);this._packedSetValue(P);for(const W of this.fields)if(W.property!==void 0){const se=l[W.property];se!==void 0&&W.encode(se)}return this.word.encode(this._packedGetValue(),E,T)}addField(l,E){const T=new y(this,l,E);return this.fields.push(T),T}addBoolean(l){const E=new A(this,l);return this.fields.push(E),E}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const E of this.fields)if(E.property===l)return E}}G.BitStructure=p;class y{constructor(l,E,T){if(!(l instanceof p))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(E)||0>=E)throw new TypeError("bits must be positive integer");const P=8*l.span,W=l.fields.reduce((se,ae)=>se+ae.bits,0);if(E+W>P)throw new Error("bits too long for span remainder ("+(P-W)+" of "+P+" remain)");this.container=l,this.bits=E,this.valueMask=(1<<E)-1,E===32&&(this.valueMask=4294967295),this.start=W,this.container.msb&&(this.start=P-W-E),this.wordMask=c(this.valueMask<<this.start),this.property=T}decode(l,E){const T=this.container._packedGetValue();return c(T&this.wordMask)>>>this.start}encode(l){if(typeof l!="number"||!Number.isInteger(l)||l!==c(l&this.valueMask))throw new TypeError(s("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const E=this.container._packedGetValue(),T=c(l<<this.start);this.container._packedSetValue(c(E&~this.wordMask)|T)}}G.BitField=y;class A extends y{constructor(l,E){super(l,1,E)}decode(l,E){return!!super.decode(l,E)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}G.Boolean=A;class v extends r{constructor(l,E){if(!(l instanceof o&&l.isCount()||Number.isInteger(l)&&0<=l))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let T=-1;l instanceof o||(T=l),super(T,E),this.length=l}getSpan(l,E){let T=this.span;return 0>T&&(T=this.length.decode(l,E)),T}decode(l,E=0){let T=this.span;return 0>T&&(T=this.length.decode(l,E)),n(l).slice(E,E+T)}encode(l,E,T){let P=this.length;if(this.length instanceof o&&(P=l.length),!(l instanceof Uint8Array&&P===l.length))throw new TypeError(s("Blob.encode",this)+" requires (length "+P+") Uint8Array as src");if(T+P>E.length)throw new RangeError("encoding overruns Uint8Array");const W=n(l);return n(E).write(W.toString("hex"),T,P,"hex"),this.length instanceof o&&this.length.encode(P,E,T),P}}G.Blob=v;class R extends r{constructor(l){super(-1,l)}getSpan(l,E=0){e(l);let T=E;for(;T<l.length&&l[T]!==0;)T+=1;return 1+T-E}decode(l,E=0){const T=this.getSpan(l,E);return n(l).slice(E,E+T-1).toString("utf-8")}encode(l,E,T=0){typeof l!="string"&&(l=String(l));const P=t.Buffer.from(l,"utf8"),W=P.length;if(T+W>E.length)throw new RangeError("encoding overruns Buffer");const se=n(E);return P.copy(se,T),se[T+W]=0,W+1}}G.CString=R;class O extends r{constructor(l,E){if(typeof l=="string"&&E===void 0&&(E=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,E),this.maxSpan=l}getSpan(l,E=0){return e(l),l.length-E}decode(l,E=0){const T=this.getSpan(l,E);if(0<=this.maxSpan&&this.maxSpan<T)throw new RangeError("text length exceeds maxSpan");return n(l).slice(E,E+T).toString("utf-8")}encode(l,E,T=0){typeof l!="string"&&(l=String(l));const P=t.Buffer.from(l,"utf8"),W=P.length;if(0<=this.maxSpan&&this.maxSpan<W)throw new RangeError("text length exceeds maxSpan");if(T+W>E.length)throw new RangeError("encoding overruns Buffer");return P.copy(n(E),T),W}}G.UTF8=O;class _ extends r{constructor(l,E){super(0,E),this.value=l}decode(l,E){return this.value}encode(l,E,T){return 0}}return G.Constant=_,G.greedy=((u,l)=>new a(u,l)),G.offset=((u,l,E)=>new d(u,l,E)),G.u8=(u=>new m(1,u)),G.u16=(u=>new m(2,u)),G.u24=(u=>new m(3,u)),G.u32=(u=>new m(4,u)),G.u40=(u=>new m(5,u)),G.u48=(u=>new m(6,u)),G.nu64=(u=>new B(u)),G.u16be=(u=>new g(2,u)),G.u24be=(u=>new g(3,u)),G.u32be=(u=>new g(4,u)),G.u40be=(u=>new g(5,u)),G.u48be=(u=>new g(6,u)),G.nu64be=(u=>new K(u)),G.s8=(u=>new S(1,u)),G.s16=(u=>new S(2,u)),G.s24=(u=>new S(3,u)),G.s32=(u=>new S(4,u)),G.s40=(u=>new S(5,u)),G.s48=(u=>new S(6,u)),G.ns64=(u=>new Y(u)),G.s16be=(u=>new I(2,u)),G.s24be=(u=>new I(3,u)),G.s32be=(u=>new I(4,u)),G.s40be=(u=>new I(5,u)),G.s48be=(u=>new I(6,u)),G.ns64be=(u=>new z(u)),G.f32=(u=>new U(u)),G.f32be=(u=>new j(u)),G.f64=(u=>new J(u)),G.f64be=(u=>new ne(u)),G.struct=((u,l,E)=>new V(u,l,E)),G.bits=((u,l,E)=>new p(u,l,E)),G.seq=((u,l,E)=>new te(u,l,E)),G.union=((u,l,E)=>new q(u,l,E)),G.unionLayoutDiscriminator=((u,l)=>new L(u,l)),G.blob=((u,l)=>new v(u,l)),G.cstr=(u=>new R(u)),G.utf8=((u,l)=>new O(u,l)),G.constant=((u,l)=>new _(u,l)),G}var k=R_(),A_=1,S_=2,x_=3,T_=4,I_=5,O_=6,N_=7,C_=8,M_=9,k_=10,B_=-32700,U_=-32603,L_=-32602,D_=-32601,P_=-32600,F_=-32016,$_=-32015,z_=-32014,j_=-32013,V_=-32012,H_=-32011,G_=-32010,q_=-32009,K_=-32008,W_=-32007,Z_=-32006,Y_=-32005,J_=-32004,X_=-32003,Q_=-32002,eE=-32001,tE=28e5,nE=2800001,rE=2800002,sE=2800003,iE=2800004,oE=2800005,aE=2800006,cE=2800007,uE=2800008,dE=2800009,lE=2800010,fE=2800011,hE=323e4,pE=32300001,mE=3230002,gE=3230003,yE=3230004,bE=361e4,_E=3610001,EE=3610002,wE=3610003,vE=3610004,RE=3610005,AE=3610006,SE=3610007,xE=3611e3,TE=3704e3,IE=3704001,OE=3704002,NE=3704003,CE=3704004,ME=4128e3,kE=4128001,BE=4128002,UE=4615e3,LE=4615001,DE=4615002,PE=4615003,FE=4615004,$E=4615005,zE=4615006,jE=4615007,VE=4615008,HE=4615009,GE=4615010,qE=4615011,KE=4615012,WE=4615013,ZE=4615014,YE=4615015,JE=4615016,XE=4615017,QE=4615018,ew=4615019,tw=4615020,nw=4615021,rw=4615022,sw=4615023,iw=4615024,ow=4615025,aw=4615026,cw=4615027,uw=4615028,dw=4615029,lw=4615030,fw=4615031,hw=4615032,pw=4615033,mw=4615034,gw=4615035,yw=4615036,bw=4615037,_w=4615038,Ew=4615039,ww=4615040,vw=4615041,Rw=4615042,Aw=4615043,Sw=4615044,xw=4615045,Tw=4615046,Iw=4615047,Ow=4615048,Nw=4615049,Cw=4615050,Mw=4615051,kw=4615052,Bw=4615053,Uw=4615054,Lw=5508e3,Dw=5508001,Pw=5508002,Fw=5508003,$w=5508004,zw=5508005,jw=5508006,Vw=5508007,Hw=5508008,Gw=5508009,qw=5508010,Kw=5508011,Ww=5663e3,Zw=5663001,Yw=5663002,Jw=5663003,Xw=5663004,Qw=5663005,ev=5663006,tv=5663007,nv=5663008,rv=5663009,sv=5663010,iv=5663011,ov=5663012,av=5663013,cv=5663014,uv=5663015,dv=5663016,lv=5663017,fv=5663018,hv=5663019,pv=5663020,mv=705e4,gv=7050001,yv=7050002,bv=7050003,_v=7050004,Ev=7050005,wv=7050006,vv=7050007,Rv=7050008,Av=7050009,Sv=7050010,xv=7050011,Tv=7050012,Iv=7050013,Ov=7050014,Nv=7050015,Cv=7050016,Mv=7050017,kv=7050018,Bv=7050019,Uv=7050020,Lv=7050021,Dv=7050022,Pv=7050023,Fv=7050024,$v=7050025,zv=7050026,jv=7050027,Vv=7050028,Hv=7050029,Gv=7050030,qv=7050031,Kv=7050032,Wv=7050033,Zv=7050034,Yv=7050035,Jv=7050036,Uf=8078e3,Lf=8078001,Xv=8078002,Qv=8078003,Df=8078004,Pf=8078005,Ff=8078006,eR=8078007,tR=8078008,nR=8078009,rR=8078010,$f=8078011,sR=8078012,iR=8078013,oR=8078014,aR=8078015,cR=8078016,uR=8078017,dR=8078018,lR=8078019,fR=8078020,hR=8078021,pR=8078022,mR=81e5,gR=8100001,yR=8100002,bR=8100003,_R=819e4,ER=8190001,wR=8190002,vR=8190003,RR=8190004,AR=99e5,SR=9900001,xR=9900002,TR=9900003,IR=9900004;function zf(t){return Array.isArray(t)?"%5B"+t.map(zf).join("%2C%20")+"%5D":typeof t=="bigint"?`${t}n`:encodeURIComponent(String(t!=null&&Object.getPrototypeOf(t)===null?{...t}:t))}function OR([t,e]){return`${t}=${zf(e)}`}function NR(t){const e=Object.entries(t).map(OR).join("&");return btoa(e)}var CR={[hE]:"Account not found at address: $address",[yE]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[gE]:"Expected decoded account at address: $address",[mE]:"Failed to decode account data at address: $address",[pE]:"Accounts not found at addresses: $addresses",[dE]:"Unable to find a viable program address bump seed.",[rE]:"$putativeAddress is not a base58-encoded address.",[tE]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[sE]:"The `CryptoKey` must be an `Ed25519` public key.",[fE]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[uE]:"Invalid seeds; point must fall off the Ed25519 curve.",[iE]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[aE]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[cE]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[oE]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[lE]:"Program address cannot end with PDA marker.",[nE]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[T_]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[A_]:"The network has progressed past the last block for which this transaction could have been committed.",[Uf]:"Codec [$codecDescription] cannot decode empty byte arrays.",[pR]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[fR]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Pf]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Ff]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[Df]:"Encoder and decoder must either both be fixed-size or variable-size.",[tR]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Xv]:"Expected a fixed-size codec, got a variable-size one.",[iR]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Qv]:"Expected a variable-size codec, got a fixed-size one.",[lR]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Lf]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[dR]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[nR]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[rR]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[aR]:"Invalid literal union variant. Expected one of [$variants], got $value.",[eR]:"Expected [$codecDescription] to have $expected items, got $actual.",[sR]:"Invalid value $value for base $base with alphabet $alphabet.",[cR]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[$f]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[oR]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[hR]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[uR]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[xE]:"No random values implementation could be found.",[HE]:"instruction requires an uninitialized account",[sw]:"instruction tries to borrow reference for an account which is already borrowed",[iw]:"instruction left account with an outstanding borrowed reference",[nw]:"program other than the account's owner changed the size of the account data",[$E]:"account data too small for instruction",[rw]:"instruction expected an executable account",[Tw]:"An account does not have enough lamports to be rent-exempt",[Ow]:"Program arithmetic overflowed",[xw]:"Failed to serialize or deserialize account data: $encodedData",[Uw]:"Builtin programs must consume compute units",[hw]:"Cross-program invocation call depth too deep",[_w]:"Computational budget exceeded",[aw]:"custom program error: #$code",[XE]:"instruction contains duplicate accounts",[ow]:"instruction modifications of multiply-passed account differ",[lw]:"executable accounts must be rent exempt",[uw]:"instruction changed executable accounts data",[dw]:"instruction changed the balance of an executable account",[QE]:"instruction changed executable bit of an account",[ZE]:"instruction modified data of an account it does not own",[WE]:"instruction spent from the balance of an account it does not own",[LE]:"generic instruction error",[Cw]:"Provided owner is not allowed",[Aw]:"Account is immutable",[Sw]:"Incorrect authority provided",[jE]:"incorrect program id for instruction",[zE]:"insufficient funds for instruction",[FE]:"invalid account data for instruction",[Iw]:"Invalid account owner",[DE]:"invalid program argument",[cw]:"program returned invalid error code",[PE]:"invalid instruction data",[bw]:"Failed to reallocate account data",[yw]:"Provided seeds do not result in a valid address",[Mw]:"Accounts data allocations exceeded the maximum allowed per transaction",[kw]:"Max accounts exceeded",[Bw]:"Max instruction trace length exceeded",[gw]:"Length of the seed is too long for address generation",[pw]:"An account required by the instruction is missing",[VE]:"missing required signature for instruction",[KE]:"instruction illegally modified the program id of an account",[tw]:"insufficient account keys for instruction",[Ew]:"Cross-program invocation with unauthorized signer or writable account",[ww]:"Failed to create program execution environment",[Rw]:"Program failed to compile",[vw]:"Program failed to complete",[JE]:"instruction modified data of a read-only account",[YE]:"instruction changed the balance of a read-only account",[mw]:"Cross-program invocation reentrancy not allowed for this instruction",[ew]:"instruction modified rent epoch of an account",[qE]:"sum of account balances before and after instruction do not match",[GE]:"instruction requires an initialized account",[UE]:"",[fw]:"Unsupported program id",[Nw]:"Unsupported sysvar",[ME]:"The instruction does not have any accounts.",[kE]:"The instruction does not have any data.",[BE]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[I_]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[S_]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[xR]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[IR]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[SR]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[AR]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[TR]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[U_]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[L_]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[P_]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[D_]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[B_]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[V_]:"$__serverMessage",[eE]:"$__serverMessage",[J_]:"$__serverMessage",[z_]:"$__serverMessage",[G_]:"$__serverMessage",[q_]:"$__serverMessage",[F_]:"Minimum context slot has not been reached",[Y_]:"Node is unhealthy; behind by $numSlotsBehind slots",[K_]:"No snapshot",[Q_]:"Transaction simulation failed",[W_]:"$__serverMessage",[H_]:"Transaction history is not available from this node",[Z_]:"$__serverMessage",[j_]:"Transaction signature length mismatch",[X_]:"Transaction signature verification failure",[$_]:"$__serverMessage",[TE]:"Key pair bytes must be of length 64, got $byteLength.",[IE]:"Expected private key bytes with length 32. Actual length: $actualLength.",[OE]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[CE]:"The provided private key does not match the provided public key.",[NE]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[O_]:"Lamports value must be in the range [0, 2e64-1]",[N_]:"`$value` cannot be parsed as a `BigInt`",[k_]:"$message",[C_]:"`$value` cannot be parsed as a `Number`",[x_]:"No nonce account could be found at address `$nonceAccountAddress`",[_R]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[wR]:"WebSocket was closed before payload could be added to the send buffer",[vR]:"WebSocket connection closed",[RR]:"WebSocket failed to connect",[ER]:"Failed to obtain a subscription id from the server",[bR]:"Could not find an API plan for RPC method: `$method`",[mR]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[yR]:"HTTP error ($statusCode): $message",[gR]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Lw]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Dw]:"The provided value does not implement the `KeyPairSigner` interface",[Fw]:"The provided value does not implement the `MessageModifyingSigner` interface",[$w]:"The provided value does not implement the `MessagePartialSigner` interface",[Pw]:"The provided value does not implement any of the `MessageSigner` interfaces",[jw]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Vw]:"The provided value does not implement the `TransactionPartialSigner` interface",[Hw]:"The provided value does not implement the `TransactionSendingSigner` interface",[zw]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Gw]:"More than one `TransactionSendingSigner` was identified.",[qw]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[Kw]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[SE]:"Cannot export a non-extractable key.",[_E]:"No digest implementation could be found.",[bE]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[EE]:`This runtime does not support the generation of Ed25519 key pairs.
28
+ */var yf;function ac(){return yf||(yf=1,(function(t){const e=qb(),n=Kb(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=Y,t.INSPECT_MAX_BYTES=50;const s=2147483647;t.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const b=new Uint8Array(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,Uint8Array.prototype),Object.setPrototypeOf(b,f),b.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(b){if(b>s)throw new RangeError('The value "'+b+'" is invalid for option "size"');const f=new Uint8Array(b);return Object.setPrototypeOf(f,a.prototype),f}function a(b,f,h){if(typeof b=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return x(b)}return d(b,f,h)}a.poolSize=8192;function d(b,f,h){if(typeof b=="string")return O(b,f);if(ArrayBuffer.isView(b))return F(b);if(b==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b);if(Yt(b,ArrayBuffer)||b&&Yt(b.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Yt(b,SharedArrayBuffer)||b&&Yt(b.buffer,SharedArrayBuffer)))return C(b,f,h);if(typeof b=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const S=b.valueOf&&b.valueOf();if(S!=null&&S!==b)return a.from(S,f,h);const U=k(b);if(U)return U;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof b[Symbol.toPrimitive]=="function")return a.from(b[Symbol.toPrimitive]("string"),f,h);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b)}a.from=function(b,f,h){return d(b,f,h)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function m(b){if(typeof b!="number")throw new TypeError('"size" argument must be of type number');if(b<0)throw new RangeError('The value "'+b+'" is invalid for option "size"')}function g(b,f,h){return m(b),b<=0?o(b):f!==void 0?typeof h=="string"?o(b).fill(f,h):o(b).fill(f):o(b)}a.alloc=function(b,f,h){return g(b,f,h)};function x(b){return m(b),o(b<0?0:K(b)|0)}a.allocUnsafe=function(b){return x(b)},a.allocUnsafeSlow=function(b){return x(b)};function O(b,f){if((typeof f!="string"||f==="")&&(f="utf8"),!a.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const h=V(b,f)|0;let S=o(h);const U=S.write(b,f);return U!==h&&(S=S.slice(0,U)),S}function N(b){const f=b.length<0?0:K(b.length)|0,h=o(f);for(let S=0;S<f;S+=1)h[S]=b[S]&255;return h}function F(b){if(Yt(b,Uint8Array)){const f=new Uint8Array(b);return C(f.buffer,f.byteOffset,f.byteLength)}return N(b)}function C(b,f,h){if(f<0||b.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(b.byteLength<f+(h||0))throw new RangeError('"length" is outside of buffer bounds');let S;return f===void 0&&h===void 0?S=new Uint8Array(b):h===void 0?S=new Uint8Array(b,f):S=new Uint8Array(b,f,h),Object.setPrototypeOf(S,a.prototype),S}function k(b){if(a.isBuffer(b)){const f=K(b.length)|0,h=o(f);return h.length===0||b.copy(h,0,0,f),h}if(b.length!==void 0)return typeof b.length!="number"||Ge(b.length)?o(0):N(b);if(b.type==="Buffer"&&Array.isArray(b.data))return N(b.data)}function K(b){if(b>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return b|0}function Y(b){return+b!=b&&(b=0),a.alloc(+b)}a.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==a.prototype},a.compare=function(f,h){if(Yt(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),Yt(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),!a.isBuffer(f)||!a.isBuffer(h))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===h)return 0;let S=f.length,U=h.length;for(let $=0,Z=Math.min(S,U);$<Z;++$)if(f[$]!==h[$]){S=f[$],U=h[$];break}return S<U?-1:U<S?1:0},a.isEncoding=function(f){switch(String(f).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(f,h){if(!Array.isArray(f))throw new TypeError('"list" argument must be an Array of Buffers');if(f.length===0)return a.alloc(0);let S;if(h===void 0)for(h=0,S=0;S<f.length;++S)h+=f[S].length;const U=a.allocUnsafe(h);let $=0;for(S=0;S<f.length;++S){let Z=f[S];if(Yt(Z,Uint8Array))$+Z.length>U.length?(a.isBuffer(Z)||(Z=a.from(Z)),Z.copy(U,$)):Uint8Array.prototype.set.call(U,Z,$);else if(a.isBuffer(Z))Z.copy(U,$);else throw new TypeError('"list" argument must be an Array of Buffers');$+=Z.length}return U};function V(b,f){if(a.isBuffer(b))return b.length;if(ArrayBuffer.isView(b)||Yt(b,ArrayBuffer))return b.byteLength;if(typeof b!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof b);const h=b.length,S=arguments.length>2&&arguments[2]===!0;if(!S&&h===0)return 0;let U=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return h;case"utf8":case"utf-8":return Le(b).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h*2;case"hex":return h>>>1;case"base64":return Fe(b).length;default:if(U)return S?-1:Le(b).length;f=(""+f).toLowerCase(),U=!0}}a.byteLength=V;function L(b,f,h){let S=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((h===void 0||h>this.length)&&(h=this.length),h<=0)||(h>>>=0,f>>>=0,h<=f))return"";for(b||(b="utf8");;)switch(b){case"hex":return R(this,f,h);case"utf8":case"utf-8":return c(this,f,h);case"ascii":return A(this,f,h);case"latin1":case"binary":return v(this,f,h);case"base64":return E(this,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,f,h);default:if(S)throw new TypeError("Unknown encoding: "+b);b=(b+"").toLowerCase(),S=!0}}a.prototype._isBuffer=!0;function z(b,f,h){const S=b[f];b[f]=b[h],b[h]=S}a.prototype.swap16=function(){const f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let h=0;h<f;h+=2)z(this,h,h+1);return this},a.prototype.swap32=function(){const f=this.length;if(f%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let h=0;h<f;h+=4)z(this,h,h+3),z(this,h+1,h+2);return this},a.prototype.swap64=function(){const f=this.length;if(f%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let h=0;h<f;h+=8)z(this,h,h+7),z(this,h+1,h+6),z(this,h+2,h+5),z(this,h+3,h+4);return this},a.prototype.toString=function(){const f=this.length;return f===0?"":arguments.length===0?c(this,0,f):L.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(f){if(!a.isBuffer(f))throw new TypeError("Argument must be a Buffer");return this===f?!0:a.compare(this,f)===0},a.prototype.inspect=function(){let f="";const h=t.INSPECT_MAX_BYTES;return f=this.toString("hex",0,h).replace(/(.{2})/g,"$1 ").trim(),this.length>h&&(f+=" ... "),"<Buffer "+f+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(f,h,S,U,$){if(Yt(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),!a.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(h===void 0&&(h=0),S===void 0&&(S=f?f.length:0),U===void 0&&(U=0),$===void 0&&($=this.length),h<0||S>f.length||U<0||$>this.length)throw new RangeError("out of range index");if(U>=$&&h>=S)return 0;if(U>=$)return-1;if(h>=S)return 1;if(h>>>=0,S>>>=0,U>>>=0,$>>>=0,this===f)return 0;let Z=$-U,Re=S-h;const _e=Math.min(Z,Re),ge=this.slice(U,$),$e=f.slice(h,S);for(let he=0;he<_e;++he)if(ge[he]!==$e[he]){Z=ge[he],Re=$e[he];break}return Z<Re?-1:Re<Z?1:0};function J(b,f,h,S,U){if(b.length===0)return-1;if(typeof h=="string"?(S=h,h=0):h>2147483647?h=2147483647:h<-2147483648&&(h=-2147483648),h=+h,Ge(h)&&(h=U?0:b.length-1),h<0&&(h=b.length+h),h>=b.length){if(U)return-1;h=b.length-1}else if(h<0)if(U)h=0;else return-1;if(typeof f=="string"&&(f=a.from(f,S)),a.isBuffer(f))return f.length===0?-1:te(b,f,h,S,U);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?U?Uint8Array.prototype.indexOf.call(b,f,h):Uint8Array.prototype.lastIndexOf.call(b,f,h):te(b,[f],h,S,U);throw new TypeError("val must be string, number or Buffer")}function te(b,f,h,S,U){let $=1,Z=b.length,Re=f.length;if(S!==void 0&&(S=String(S).toLowerCase(),S==="ucs2"||S==="ucs-2"||S==="utf16le"||S==="utf-16le")){if(b.length<2||f.length<2)return-1;$=2,Z/=2,Re/=2,h/=2}function _e($e,he){return $===1?$e[he]:$e.readUInt16BE(he*$)}let ge;if(U){let $e=-1;for(ge=h;ge<Z;ge++)if(_e(b,ge)===_e(f,$e===-1?0:ge-$e)){if($e===-1&&($e=ge),ge-$e+1===Re)return $e*$}else $e!==-1&&(ge-=ge-$e),$e=-1}else for(h+Re>Z&&(h=Z-Re),ge=h;ge>=0;ge--){let $e=!0;for(let he=0;he<Re;he++)if(_e(b,ge+he)!==_e(f,he)){$e=!1;break}if($e)return ge}return-1}a.prototype.includes=function(f,h,S){return this.indexOf(f,h,S)!==-1},a.prototype.indexOf=function(f,h,S){return J(this,f,h,S,!0)},a.prototype.lastIndexOf=function(f,h,S){return J(this,f,h,S,!1)};function ne(b,f,h,S){h=Number(h)||0;const U=b.length-h;S?(S=Number(S),S>U&&(S=U)):S=U;const $=f.length;S>$/2&&(S=$/2);let Z;for(Z=0;Z<S;++Z){const Re=parseInt(f.substr(Z*2,2),16);if(Ge(Re))return Z;b[h+Z]=Re}return Z}function q(b,f,h,S){return Pe(Le(f,b.length-h),b,h,S)}function B(b,f,h,S){return Pe(Ve(f),b,h,S)}function P(b,f,h,S){return Pe(Fe(f),b,h,S)}function j(b,f,h,S){return Pe(Zr(f,b.length-h),b,h,S)}a.prototype.write=function(f,h,S,U){if(h===void 0)U="utf8",S=this.length,h=0;else if(S===void 0&&typeof h=="string")U=h,S=this.length,h=0;else if(isFinite(h))h=h>>>0,isFinite(S)?(S=S>>>0,U===void 0&&(U="utf8")):(U=S,S=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const $=this.length-h;if((S===void 0||S>$)&&(S=$),f.length>0&&(S<0||h<0)||h>this.length)throw new RangeError("Attempt to write outside buffer bounds");U||(U="utf8");let Z=!1;for(;;)switch(U){case"hex":return ne(this,f,h,S);case"utf8":case"utf-8":return q(this,f,h,S);case"ascii":case"latin1":case"binary":return B(this,f,h,S);case"base64":return P(this,f,h,S);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,f,h,S);default:if(Z)throw new TypeError("Unknown encoding: "+U);U=(""+U).toLowerCase(),Z=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(b,f,h){return f===0&&h===b.length?e.fromByteArray(b):e.fromByteArray(b.slice(f,h))}function c(b,f,h){h=Math.min(b.length,h);const S=[];let U=f;for(;U<h;){const $=b[U];let Z=null,Re=$>239?4:$>223?3:$>191?2:1;if(U+Re<=h){let _e,ge,$e,he;switch(Re){case 1:$<128&&(Z=$);break;case 2:_e=b[U+1],(_e&192)===128&&(he=($&31)<<6|_e&63,he>127&&(Z=he));break;case 3:_e=b[U+1],ge=b[U+2],(_e&192)===128&&(ge&192)===128&&(he=($&15)<<12|(_e&63)<<6|ge&63,he>2047&&(he<55296||he>57343)&&(Z=he));break;case 4:_e=b[U+1],ge=b[U+2],$e=b[U+3],(_e&192)===128&&(ge&192)===128&&($e&192)===128&&(he=($&15)<<18|(_e&63)<<12|(ge&63)<<6|$e&63,he>65535&&he<1114112&&(Z=he))}}Z===null?(Z=65533,Re=1):Z>65535&&(Z-=65536,S.push(Z>>>10&1023|55296),Z=56320|Z&1023),S.push(Z),U+=Re}return y(S)}const p=4096;function y(b){const f=b.length;if(f<=p)return String.fromCharCode.apply(String,b);let h="",S=0;for(;S<f;)h+=String.fromCharCode.apply(String,b.slice(S,S+=p));return h}function A(b,f,h){let S="";h=Math.min(b.length,h);for(let U=f;U<h;++U)S+=String.fromCharCode(b[U]&127);return S}function v(b,f,h){let S="";h=Math.min(b.length,h);for(let U=f;U<h;++U)S+=String.fromCharCode(b[U]);return S}function R(b,f,h){const S=b.length;(!f||f<0)&&(f=0),(!h||h<0||h>S)&&(h=S);let U="";for(let $=f;$<h;++$)U+=Ze[b[$]];return U}function I(b,f,h){const S=b.slice(f,h);let U="";for(let $=0;$<S.length-1;$+=2)U+=String.fromCharCode(S[$]+S[$+1]*256);return U}a.prototype.slice=function(f,h){const S=this.length;f=~~f,h=h===void 0?S:~~h,f<0?(f+=S,f<0&&(f=0)):f>S&&(f=S),h<0?(h+=S,h<0&&(h=0)):h>S&&(h=S),h<f&&(h=f);const U=this.subarray(f,h);return Object.setPrototypeOf(U,a.prototype),U};function _(b,f,h){if(b%1!==0||b<0)throw new RangeError("offset is not uint");if(b+f>h)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let U=this[f],$=1,Z=0;for(;++Z<h&&($*=256);)U+=this[f+Z]*$;return U},a.prototype.readUintBE=a.prototype.readUIntBE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let U=this[f+--h],$=1;for(;h>0&&($*=256);)U+=this[f+--h]*$;return U},a.prototype.readUint8=a.prototype.readUInt8=function(f,h){return f=f>>>0,h||_(f,1,this.length),this[f]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(f,h){return f=f>>>0,h||_(f,2,this.length),this[f]|this[f+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(f,h){return f=f>>>0,h||_(f,2,this.length),this[f]<<8|this[f+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(f,h){return f=f>>>0,h||_(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(f,h){return f=f>>>0,h||_(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},a.prototype.readBigUInt64LE=an(function(f){f=f>>>0,De(f,"offset");const h=this[f],S=this[f+7];(h===void 0||S===void 0)&&ve(f,this.length-8);const U=h+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24,$=this[++f]+this[++f]*2**8+this[++f]*2**16+S*2**24;return BigInt(U)+(BigInt($)<<BigInt(32))}),a.prototype.readBigUInt64BE=an(function(f){f=f>>>0,De(f,"offset");const h=this[f],S=this[f+7];(h===void 0||S===void 0)&&ve(f,this.length-8);const U=h*2**24+this[++f]*2**16+this[++f]*2**8+this[++f],$=this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+S;return(BigInt(U)<<BigInt(32))+BigInt($)}),a.prototype.readIntLE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let U=this[f],$=1,Z=0;for(;++Z<h&&($*=256);)U+=this[f+Z]*$;return $*=128,U>=$&&(U-=Math.pow(2,8*h)),U},a.prototype.readIntBE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let U=h,$=1,Z=this[f+--U];for(;U>0&&($*=256);)Z+=this[f+--U]*$;return $*=128,Z>=$&&(Z-=Math.pow(2,8*h)),Z},a.prototype.readInt8=function(f,h){return f=f>>>0,h||_(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},a.prototype.readInt16LE=function(f,h){f=f>>>0,h||_(f,2,this.length);const S=this[f]|this[f+1]<<8;return S&32768?S|4294901760:S},a.prototype.readInt16BE=function(f,h){f=f>>>0,h||_(f,2,this.length);const S=this[f+1]|this[f]<<8;return S&32768?S|4294901760:S},a.prototype.readInt32LE=function(f,h){return f=f>>>0,h||_(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},a.prototype.readInt32BE=function(f,h){return f=f>>>0,h||_(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},a.prototype.readBigInt64LE=an(function(f){f=f>>>0,De(f,"offset");const h=this[f],S=this[f+7];(h===void 0||S===void 0)&&ve(f,this.length-8);const U=this[f+4]+this[f+5]*2**8+this[f+6]*2**16+(S<<24);return(BigInt(U)<<BigInt(32))+BigInt(h+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24)}),a.prototype.readBigInt64BE=an(function(f){f=f>>>0,De(f,"offset");const h=this[f],S=this[f+7];(h===void 0||S===void 0)&&ve(f,this.length-8);const U=(h<<24)+this[++f]*2**16+this[++f]*2**8+this[++f];return(BigInt(U)<<BigInt(32))+BigInt(this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+S)}),a.prototype.readFloatLE=function(f,h){return f=f>>>0,h||_(f,4,this.length),n.read(this,f,!0,23,4)},a.prototype.readFloatBE=function(f,h){return f=f>>>0,h||_(f,4,this.length),n.read(this,f,!1,23,4)},a.prototype.readDoubleLE=function(f,h){return f=f>>>0,h||_(f,8,this.length),n.read(this,f,!0,52,8)},a.prototype.readDoubleBE=function(f,h){return f=f>>>0,h||_(f,8,this.length),n.read(this,f,!1,52,8)};function u(b,f,h,S,U,$){if(!a.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>U||f<$)throw new RangeError('"value" argument is out of bounds');if(h+S>b.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(f,h,S,U){if(f=+f,h=h>>>0,S=S>>>0,!U){const Re=Math.pow(2,8*S)-1;u(this,f,h,S,Re,0)}let $=1,Z=0;for(this[h]=f&255;++Z<S&&($*=256);)this[h+Z]=f/$&255;return h+S},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(f,h,S,U){if(f=+f,h=h>>>0,S=S>>>0,!U){const Re=Math.pow(2,8*S)-1;u(this,f,h,S,Re,0)}let $=S-1,Z=1;for(this[h+$]=f&255;--$>=0&&(Z*=256);)this[h+$]=f/Z&255;return h+S},a.prototype.writeUint8=a.prototype.writeUInt8=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,1,255,0),this[h]=f&255,h+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,2,65535,0),this[h]=f&255,this[h+1]=f>>>8,h+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,2,65535,0),this[h]=f>>>8,this[h+1]=f&255,h+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,4,4294967295,0),this[h+3]=f>>>24,this[h+2]=f>>>16,this[h+1]=f>>>8,this[h]=f&255,h+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,4,4294967295,0),this[h]=f>>>24,this[h+1]=f>>>16,this[h+2]=f>>>8,this[h+3]=f&255,h+4};function l(b,f,h,S,U){we(f,S,U,b,h,7);let $=Number(f&BigInt(4294967295));b[h++]=$,$=$>>8,b[h++]=$,$=$>>8,b[h++]=$,$=$>>8,b[h++]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return b[h++]=Z,Z=Z>>8,b[h++]=Z,Z=Z>>8,b[h++]=Z,Z=Z>>8,b[h++]=Z,h}function w(b,f,h,S,U){we(f,S,U,b,h,7);let $=Number(f&BigInt(4294967295));b[h+7]=$,$=$>>8,b[h+6]=$,$=$>>8,b[h+5]=$,$=$>>8,b[h+4]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return b[h+3]=Z,Z=Z>>8,b[h+2]=Z,Z=Z>>8,b[h+1]=Z,Z=Z>>8,b[h]=Z,h+8}a.prototype.writeBigUInt64LE=an(function(f,h=0){return l(this,f,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=an(function(f,h=0){return w(this,f,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(f,h,S,U){if(f=+f,h=h>>>0,!U){const _e=Math.pow(2,8*S-1);u(this,f,h,S,_e-1,-_e)}let $=0,Z=1,Re=0;for(this[h]=f&255;++$<S&&(Z*=256);)f<0&&Re===0&&this[h+$-1]!==0&&(Re=1),this[h+$]=(f/Z>>0)-Re&255;return h+S},a.prototype.writeIntBE=function(f,h,S,U){if(f=+f,h=h>>>0,!U){const _e=Math.pow(2,8*S-1);u(this,f,h,S,_e-1,-_e)}let $=S-1,Z=1,Re=0;for(this[h+$]=f&255;--$>=0&&(Z*=256);)f<0&&Re===0&&this[h+$+1]!==0&&(Re=1),this[h+$]=(f/Z>>0)-Re&255;return h+S},a.prototype.writeInt8=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,1,127,-128),f<0&&(f=255+f+1),this[h]=f&255,h+1},a.prototype.writeInt16LE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,2,32767,-32768),this[h]=f&255,this[h+1]=f>>>8,h+2},a.prototype.writeInt16BE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,2,32767,-32768),this[h]=f>>>8,this[h+1]=f&255,h+2},a.prototype.writeInt32LE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,4,2147483647,-2147483648),this[h]=f&255,this[h+1]=f>>>8,this[h+2]=f>>>16,this[h+3]=f>>>24,h+4},a.prototype.writeInt32BE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[h]=f>>>24,this[h+1]=f>>>16,this[h+2]=f>>>8,this[h+3]=f&255,h+4},a.prototype.writeBigInt64LE=an(function(f,h=0){return l(this,f,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=an(function(f,h=0){return w(this,f,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function T(b,f,h,S,U,$){if(h+S>b.length)throw new RangeError("Index out of range");if(h<0)throw new RangeError("Index out of range")}function D(b,f,h,S,U){return f=+f,h=h>>>0,U||T(b,f,h,4),n.write(b,f,h,S,23,4),h+4}a.prototype.writeFloatLE=function(f,h,S){return D(this,f,h,!0,S)},a.prototype.writeFloatBE=function(f,h,S){return D(this,f,h,!1,S)};function W(b,f,h,S,U){return f=+f,h=h>>>0,U||T(b,f,h,8),n.write(b,f,h,S,52,8),h+8}a.prototype.writeDoubleLE=function(f,h,S){return W(this,f,h,!0,S)},a.prototype.writeDoubleBE=function(f,h,S){return W(this,f,h,!1,S)},a.prototype.copy=function(f,h,S,U){if(!a.isBuffer(f))throw new TypeError("argument should be a Buffer");if(S||(S=0),!U&&U!==0&&(U=this.length),h>=f.length&&(h=f.length),h||(h=0),U>0&&U<S&&(U=S),U===S||f.length===0||this.length===0)return 0;if(h<0)throw new RangeError("targetStart out of bounds");if(S<0||S>=this.length)throw new RangeError("Index out of range");if(U<0)throw new RangeError("sourceEnd out of bounds");U>this.length&&(U=this.length),f.length-h<U-S&&(U=f.length-h+S);const $=U-S;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(h,S,U):Uint8Array.prototype.set.call(f,this.subarray(S,U),h),$},a.prototype.fill=function(f,h,S,U){if(typeof f=="string"){if(typeof h=="string"?(U=h,h=0,S=this.length):typeof S=="string"&&(U=S,S=this.length),U!==void 0&&typeof U!="string")throw new TypeError("encoding must be a string");if(typeof U=="string"&&!a.isEncoding(U))throw new TypeError("Unknown encoding: "+U);if(f.length===1){const Z=f.charCodeAt(0);(U==="utf8"&&Z<128||U==="latin1")&&(f=Z)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(h<0||this.length<h||this.length<S)throw new RangeError("Out of range index");if(S<=h)return this;h=h>>>0,S=S===void 0?this.length:S>>>0,f||(f=0);let $;if(typeof f=="number")for($=h;$<S;++$)this[$]=f;else{const Z=a.isBuffer(f)?f:a.from(f,U),Re=Z.length;if(Re===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for($=0;$<S-h;++$)this[$+h]=Z[$%Re]}return this};const re={};function oe(b,f,h){re[b]=class extends h{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${b}]`,this.stack,delete this.name}get code(){return b}set code(U){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:U,writable:!0})}toString(){return`${this.name} [${b}]: ${this.message}`}}}oe("ERR_BUFFER_OUT_OF_BOUNDS",function(b){return b?`${b} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),oe("ERR_INVALID_ARG_TYPE",function(b,f){return`The "${b}" argument must be of type number. Received type ${typeof f}`},TypeError),oe("ERR_OUT_OF_RANGE",function(b,f,h){let S=`The value of "${b}" is out of range.`,U=h;return Number.isInteger(h)&&Math.abs(h)>2**32?U=Ce(String(h)):typeof h=="bigint"&&(U=String(h),(h>BigInt(2)**BigInt(32)||h<-(BigInt(2)**BigInt(32)))&&(U=Ce(U)),U+="n"),S+=` It must be ${f}. Received ${U}`,S},RangeError);function Ce(b){let f="",h=b.length;const S=b[0]==="-"?1:0;for(;h>=S+4;h-=3)f=`_${b.slice(h-3,h)}${f}`;return`${b.slice(0,h)}${f}`}function Ee(b,f,h){De(f,"offset"),(b[f]===void 0||b[f+h]===void 0)&&ve(f,b.length-(h+1))}function we(b,f,h,S,U,$){if(b>h||b<f){const Z=typeof f=="bigint"?"n":"";let Re;throw f===0||f===BigInt(0)?Re=`>= 0${Z} and < 2${Z} ** ${($+1)*8}${Z}`:Re=`>= -(2${Z} ** ${($+1)*8-1}${Z}) and < 2 ** ${($+1)*8-1}${Z}`,new re.ERR_OUT_OF_RANGE("value",Re,b)}Ee(S,U,$)}function De(b,f){if(typeof b!="number")throw new re.ERR_INVALID_ARG_TYPE(f,"number",b)}function ve(b,f,h){throw Math.floor(b)!==b?(De(b,h),new re.ERR_OUT_OF_RANGE("offset","an integer",b)):f<0?new re.ERR_BUFFER_OUT_OF_BOUNDS:new re.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${f}`,b)}const Oe=/[^+/0-9A-Za-z-_]/g;function mn(b){if(b=b.split("=")[0],b=b.trim().replace(Oe,""),b.length<2)return"";for(;b.length%4!==0;)b=b+"=";return b}function Le(b,f){f=f||1/0;let h;const S=b.length;let U=null;const $=[];for(let Z=0;Z<S;++Z){if(h=b.charCodeAt(Z),h>55295&&h<57344){if(!U){if(h>56319){(f-=3)>-1&&$.push(239,191,189);continue}else if(Z+1===S){(f-=3)>-1&&$.push(239,191,189);continue}U=h;continue}if(h<56320){(f-=3)>-1&&$.push(239,191,189),U=h;continue}h=(U-55296<<10|h-56320)+65536}else U&&(f-=3)>-1&&$.push(239,191,189);if(U=null,h<128){if((f-=1)<0)break;$.push(h)}else if(h<2048){if((f-=2)<0)break;$.push(h>>6|192,h&63|128)}else if(h<65536){if((f-=3)<0)break;$.push(h>>12|224,h>>6&63|128,h&63|128)}else if(h<1114112){if((f-=4)<0)break;$.push(h>>18|240,h>>12&63|128,h>>6&63|128,h&63|128)}else throw new Error("Invalid code point")}return $}function Ve(b){const f=[];for(let h=0;h<b.length;++h)f.push(b.charCodeAt(h)&255);return f}function Zr(b,f){let h,S,U;const $=[];for(let Z=0;Z<b.length&&!((f-=2)<0);++Z)h=b.charCodeAt(Z),S=h>>8,U=h%256,$.push(U),$.push(S);return $}function Fe(b){return e.toByteArray(mn(b))}function Pe(b,f,h,S){let U;for(U=0;U<S&&!(U+h>=f.length||U>=b.length);++U)f[U+h]=b[U];return U}function Yt(b,f){return b instanceof f||b!=null&&b.constructor!=null&&b.constructor.name!=null&&b.constructor.name===f.name}function Ge(b){return b!==b}const Ze=(function(){const b="0123456789abcdef",f=new Array(256);for(let h=0;h<16;++h){const S=h*16;for(let U=0;U<16;++U)f[S+U]=b[h]+b[U]}return f})();function an(b){return typeof BigInt>"u"?Ye:b}function Ye(){throw new Error("BigInt not supported")}})(oc)),oc}var xe=ac();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ln=BigInt(0),Ut=BigInt(1),bf=BigInt(2),Wb=BigInt(8),Zb={zip215:!0};function Yb(t){const e=La(t);return Ss(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Jb(t){const e=Yb(t),{Fp:n,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:d}=e,m=bf<<BigInt(a*8)-Ut,g=n.create,x=Os(e.n,e.nBitLength);function O(v,R){const I=n.sqr(v),_=n.sqr(R),u=n.add(n.mul(e.a,I),_),l=n.add(n.ONE,n.mul(e.d,n.mul(I,_)));return n.eql(u,l)}if(!O(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const N=e.uvRatio||((v,R)=>{try{return{isValid:!0,value:n.sqrt(v*n.inv(R))}}catch{return{isValid:!1,value:ln}}}),F=e.adjustScalarBytes||(v=>v),C=e.domain||((v,R,I)=>{if(Ln("phflag",I),R.length||I)throw new Error("Contexts/pre-hash are not supported");return v});function k(v,R,I=!1){const _=I?Ut:ln;nn("coordinate "+v,R,_,m)}function K(v){if(!(v instanceof L))throw new Error("ExtendedPoint expected")}const Y=bi((v,R)=>{const{ex:I,ey:_,ez:u}=v,l=v.is0();R==null&&(R=l?Wb:n.inv(u));const w=g(I*R),T=g(_*R),D=g(u*R);if(l)return{x:ln,y:Ut};if(D!==Ut)throw new Error("invZ was invalid");return{x:w,y:T}}),V=bi(v=>{const{a:R,d:I}=e;if(v.is0())throw new Error("bad point: ZERO");const{ex:_,ey:u,ez:l,et:w}=v,T=g(_*_),D=g(u*u),W=g(l*l),re=g(W*W),oe=g(T*R),Ce=g(W*g(oe+D)),Ee=g(re+g(I*g(T*D)));if(Ce!==Ee)throw new Error("bad point: equation left != right (1)");const we=g(_*u),De=g(l*w);if(we!==De)throw new Error("bad point: equation left != right (2)");return!0});class L{constructor(R,I,_,u){k("x",R),k("y",I),k("z",_,!0),k("t",u),this.ex=R,this.ey=I,this.ez=_,this.et=u,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(R){if(R instanceof L)throw new Error("extended point not allowed");const{x:I,y:_}=R||{};return k("x",I),k("y",_),new L(I,_,Ut,g(I*_))}static normalizeZ(R){const I=Ia(n,R.map(_=>_.ez));return R.map((_,u)=>_.toAffine(I[u])).map(L.fromAffine)}static msm(R,I){return Ml(L,x,R,I)}_setWindowSize(R){te.setWindowSize(this,R)}assertValidity(){V(this)}equals(R){K(R);const{ex:I,ey:_,ez:u}=this,{ex:l,ey:w,ez:T}=R,D=g(I*T),W=g(l*u),re=g(_*T),oe=g(w*u);return D===W&&re===oe}is0(){return this.equals(L.ZERO)}negate(){return new L(g(-this.ex),this.ey,this.ez,g(-this.et))}double(){const{a:R}=e,{ex:I,ey:_,ez:u}=this,l=g(I*I),w=g(_*_),T=g(bf*g(u*u)),D=g(R*l),W=I+_,re=g(g(W*W)-l-w),oe=D+w,Ce=oe-T,Ee=D-w,we=g(re*Ce),De=g(oe*Ee),ve=g(re*Ee),Oe=g(Ce*oe);return new L(we,De,Oe,ve)}add(R){K(R);const{a:I,d:_}=e,{ex:u,ey:l,ez:w,et:T}=this,{ex:D,ey:W,ez:re,et:oe}=R,Ce=g(u*D),Ee=g(l*W),we=g(T*_*oe),De=g(w*re),ve=g((u+l)*(D+W)-Ce-Ee),Oe=De-we,mn=De+we,Le=g(Ee-I*Ce),Ve=g(ve*Oe),Zr=g(mn*Le),Fe=g(ve*Le),Pe=g(Oe*mn);return new L(Ve,Zr,Pe,Fe)}subtract(R){return this.add(R.negate())}wNAF(R){return te.wNAFCached(this,R,L.normalizeZ)}multiply(R){const I=R;nn("scalar",I,Ut,r);const{p:_,f:u}=this.wNAF(I);return L.normalizeZ([_,u])[0]}multiplyUnsafe(R,I=L.ZERO){const _=R;return nn("scalar",_,ln,r),_===ln?J:this.is0()||_===Ut?this:te.wNAFCachedUnsafe(this,_,L.normalizeZ,I)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return te.unsafeLadder(this,r).is0()}toAffine(R){return Y(this,R)}clearCofactor(){const{h:R}=e;return R===Ut?this:this.multiplyUnsafe(R)}static fromHex(R,I=!1){const{d:_,a:u}=e,l=n.BYTES;R=Je("pointHex",R,l),Ln("zip215",I);const w=R.slice(),T=R[l-1];w[l-1]=T&-129;const D=As(w),W=I?m:n.ORDER;nn("pointHex.y",D,ln,W);const re=g(D*D),oe=g(re-Ut),Ce=g(_*re-u);let{isValid:Ee,value:we}=N(oe,Ce);if(!Ee)throw new Error("Point.fromHex: invalid y coordinate");const De=(we&Ut)===Ut,ve=(T&128)!==0;if(!I&&we===ln&&ve)throw new Error("Point.fromHex: x=0 and x_0=1");return ve!==De&&(we=g(-we)),L.fromAffine({x:we,y:D})}static fromPrivateKey(R){const{scalar:I}=B(R);return z.multiply(I)}toRawBytes(){const{x:R,y:I}=this.toAffine(),_=gi(I,n.BYTES);return _[_.length-1]|=R&Ut?128:0,_}toHex(){return Tr(this.toRawBytes())}}L.BASE=new L(e.Gx,e.Gy,Ut,g(e.Gx*e.Gy)),L.ZERO=new L(ln,Ut,Ut,ln);const{BASE:z,ZERO:J}=L,te=Cl(L,a*8);function ne(v){return je(v,r)}function q(v){return ne(As(v))}function B(v){const R=n.BYTES;v=Je("private key",v,R);const I=Je("hashed private key",i(v),2*R),_=F(I.slice(0,R)),u=I.slice(R,2*R),l=q(_);return{head:_,prefix:u,scalar:l}}function P(v){const{head:R,prefix:I,scalar:_}=B(v),u=z.multiply(_),l=u.toRawBytes();return{head:R,prefix:I,scalar:_,point:u,pointBytes:l}}function j(v){return P(v).pointBytes}function E(v=Uint8Array.of(),...R){const I=Or(...R);return q(i(C(I,Je("context",v),!!s)))}function c(v,R,I={}){v=Je("message",v),s&&(v=s(v));const{prefix:_,scalar:u,pointBytes:l}=P(R),w=E(I.context,_,v),T=z.multiply(w).toRawBytes(),D=E(I.context,T,l,v),W=ne(w+D*u);nn("signature.s",W,ln,r);const re=Or(T,gi(W,n.BYTES));return Je("result",re,n.BYTES*2)}const p=Zb;function y(v,R,I,_=p){const{context:u,zip215:l}=_,w=n.BYTES;v=Je("signature",v,2*w),R=Je("message",R),I=Je("publicKey",I,w),l!==void 0&&Ln("zip215",l),s&&(R=s(R));const T=As(v.slice(w,2*w));let D,W,re;try{D=L.fromHex(I,l),W=L.fromHex(v.slice(0,w),l),re=z.multiplyUnsafe(T)}catch{return!1}if(!l&&D.isSmallOrder())return!1;const oe=E(u,W.toRawBytes(),D.toRawBytes(),R);return W.add(D.multiplyUnsafe(oe)).subtract(re).clearCofactor().equals(L.ZERO)}return z._setWindowSize(8),{CURVE:e,getPublicKey:j,sign:c,verify:y,ExtendedPoint:L,utils:{getExtendedPublicKey:P,randomPrivateKey:()=>o(n.BYTES),precompute(v=8,R=L.BASE){return R._setWindowSize(v),R.multiply(BigInt(3)),R}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const cc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),_f=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Xb=BigInt(1),wf=BigInt(2);BigInt(3);const Qb=BigInt(5),e_=BigInt(8);function t_(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),s=BigInt(80),i=cc,a=t*t%i*t%i,d=qe(a,wf,i)*a%i,m=qe(d,Xb,i)*t%i,g=qe(m,Qb,i)*m%i,x=qe(g,e,i)*g%i,O=qe(x,n,i)*x%i,N=qe(O,r,i)*O%i,F=qe(N,s,i)*N%i,C=qe(F,s,i)*N%i,k=qe(C,e,i)*g%i;return{pow_p_5_8:qe(k,wf,i)*t%i,b2:a}}function n_(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function r_(t,e){const n=cc,r=je(e*e*e,n),s=je(r*r*e,n),i=t_(t*s).pow_p_5_8;let o=je(t*r*i,n);const a=je(e*o*o,n),d=o,m=je(o*_f,n),g=a===t,x=a===je(-t,n),O=a===je(-t*_f,n);return g&&(o=d),(x||O)&&(o=m),Qy(o,n)&&(o=je(-o,n)),{isValid:g||x,value:o}}const Ef=Os(cc,void 0,!0),s_={a:Ef.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ef,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:e_,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:My,randomBytes:Ed,adjustScalarBytes:n_,uvRatio:r_},uc=Jb(s_);var Di={exports:{}};const i_=Ha(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var o_=Di.exports,vf;function Rf(){return vf||(vf=1,(function(t){(function(e,n){function r(E,c){if(!E)throw new Error(c||"Assertion failed")}function s(E,c){E.super_=c;var p=function(){};p.prototype=c.prototype,E.prototype=new p,E.prototype.constructor=E}function i(E,c,p){if(i.isBN(E))return E;this.negative=0,this.words=null,this.length=0,this.red=null,E!==null&&((c==="le"||c==="be")&&(p=c,c=10),this._init(E||0,c||10,p||"be"))}typeof e=="object"?e.exports=i:n.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=i_.Buffer}catch{}i.isBN=function(c){return c instanceof i?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===i.wordSize&&Array.isArray(c.words)},i.max=function(c,p){return c.cmp(p)>0?c:p},i.min=function(c,p){return c.cmp(p)<0?c:p},i.prototype._init=function(c,p,y){if(typeof c=="number")return this._initNumber(c,p,y);if(typeof c=="object")return this._initArray(c,p,y);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),c=c.toString().replace(/\s+/g,"");var A=0;c[0]==="-"&&(A++,this.negative=1),A<c.length&&(p===16?this._parseHex(c,A,y):(this._parseBase(c,p,A),y==="le"&&this._initArray(this.toArray(),p,y)))},i.prototype._initNumber=function(c,p,y){c<0&&(this.negative=1,c=-c),c<67108864?(this.words=[c&67108863],this.length=1):c<4503599627370496?(this.words=[c&67108863,c/67108864&67108863],this.length=2):(r(c<9007199254740992),this.words=[c&67108863,c/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),p,y)},i.prototype._initArray=function(c,p,y){if(r(typeof c.length=="number"),c.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(c.length/3),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var v,R,I=0;if(y==="be")for(A=c.length-1,v=0;A>=0;A-=3)R=c[A]|c[A-1]<<8|c[A-2]<<16,this.words[v]|=R<<I&67108863,this.words[v+1]=R>>>26-I&67108863,I+=24,I>=26&&(I-=26,v++);else if(y==="le")for(A=0,v=0;A<c.length;A+=3)R=c[A]|c[A+1]<<8|c[A+2]<<16,this.words[v]|=R<<I&67108863,this.words[v+1]=R>>>26-I&67108863,I+=24,I>=26&&(I-=26,v++);return this._strip()};function a(E,c){var p=E.charCodeAt(c);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;r(!1,"Invalid character in "+E)}function d(E,c,p){var y=a(E,p);return p-1>=c&&(y|=a(E,p-1)<<4),y}i.prototype._parseHex=function(c,p,y){this.length=Math.ceil((c.length-p)/6),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var v=0,R=0,I;if(y==="be")for(A=c.length-1;A>=p;A-=2)I=d(c,p,A)<<v,this.words[R]|=I&67108863,v>=18?(v-=18,R+=1,this.words[R]|=I>>>26):v+=8;else{var _=c.length-p;for(A=_%2===0?p+1:p;A<c.length;A+=2)I=d(c,p,A)<<v,this.words[R]|=I&67108863,v>=18?(v-=18,R+=1,this.words[R]|=I>>>26):v+=8}this._strip()};function m(E,c,p,y){for(var A=0,v=0,R=Math.min(E.length,p),I=c;I<R;I++){var _=E.charCodeAt(I)-48;A*=y,_>=49?v=_-49+10:_>=17?v=_-17+10:v=_,r(_>=0&&v<y,"Invalid character"),A+=v}return A}i.prototype._parseBase=function(c,p,y){this.words=[0],this.length=1;for(var A=0,v=1;v<=67108863;v*=p)A++;A--,v=v/p|0;for(var R=c.length-y,I=R%A,_=Math.min(R,R-I)+y,u=0,l=y;l<_;l+=A)u=m(c,l,l+A,p),this.imuln(v),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(I!==0){var w=1;for(u=m(c,l,c.length,p),l=0;l<I;l++)w*=p;this.imuln(w),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},i.prototype.copy=function(c){c.words=new Array(this.length);for(var p=0;p<this.length;p++)c.words[p]=this.words[p];c.length=this.length,c.negative=this.negative,c.red=this.red};function g(E,c){E.words=c.words,E.length=c.length,E.negative=c.negative,E.red=c.red}if(i.prototype._move=function(c){g(c,this)},i.prototype.clone=function(){var c=new i(null);return this.copy(c),c},i.prototype._expand=function(c){for(;this.length<c;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=x}catch{i.prototype.inspect=x}else i.prototype.inspect=x;function x(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var O=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],N=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],F=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(c,p){c=c||10,p=p|0||1;var y;if(c===16||c==="hex"){y="";for(var A=0,v=0,R=0;R<this.length;R++){var I=this.words[R],_=((I<<A|v)&16777215).toString(16);v=I>>>24-A&16777215,A+=2,A>=26&&(A-=26,R--),v!==0||R!==this.length-1?y=O[6-_.length]+_+y:y=_+y}for(v!==0&&(y=v.toString(16)+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(c===(c|0)&&c>=2&&c<=36){var u=N[c],l=F[c];y="";var w=this.clone();for(w.negative=0;!w.isZero();){var T=w.modrn(l).toString(c);w=w.idivn(l),w.isZero()?y=T+y:y=O[u-T.length]+T+y}for(this.isZero()&&(y="0"+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(c,p){return this.toArrayLike(o,c,p)}),i.prototype.toArray=function(c,p){return this.toArrayLike(Array,c,p)};var C=function(c,p){return c.allocUnsafe?c.allocUnsafe(p):new c(p)};i.prototype.toArrayLike=function(c,p,y){this._strip();var A=this.byteLength(),v=y||Math.max(1,A);r(A<=v,"byte array longer than desired length"),r(v>0,"Requested array length <= 0");var R=C(c,v),I=p==="le"?"LE":"BE";return this["_toArrayLike"+I](R,A),R},i.prototype._toArrayLikeLE=function(c,p){for(var y=0,A=0,v=0,R=0;v<this.length;v++){var I=this.words[v]<<R|A;c[y++]=I&255,y<c.length&&(c[y++]=I>>8&255),y<c.length&&(c[y++]=I>>16&255),R===6?(y<c.length&&(c[y++]=I>>24&255),A=0,R=0):(A=I>>>24,R+=2)}if(y<c.length)for(c[y++]=A;y<c.length;)c[y++]=0},i.prototype._toArrayLikeBE=function(c,p){for(var y=c.length-1,A=0,v=0,R=0;v<this.length;v++){var I=this.words[v]<<R|A;c[y--]=I&255,y>=0&&(c[y--]=I>>8&255),y>=0&&(c[y--]=I>>16&255),R===6?(y>=0&&(c[y--]=I>>24&255),A=0,R=0):(A=I>>>24,R+=2)}if(y>=0)for(c[y--]=A;y>=0;)c[y--]=0},Math.clz32?i.prototype._countBits=function(c){return 32-Math.clz32(c)}:i.prototype._countBits=function(c){var p=c,y=0;return p>=4096&&(y+=13,p>>>=13),p>=64&&(y+=7,p>>>=7),p>=8&&(y+=4,p>>>=4),p>=2&&(y+=2,p>>>=2),y+p},i.prototype._zeroBits=function(c){if(c===0)return 26;var p=c,y=0;return(p&8191)===0&&(y+=13,p>>>=13),(p&127)===0&&(y+=7,p>>>=7),(p&15)===0&&(y+=4,p>>>=4),(p&3)===0&&(y+=2,p>>>=2),(p&1)===0&&y++,y},i.prototype.bitLength=function(){var c=this.words[this.length-1],p=this._countBits(c);return(this.length-1)*26+p};function k(E){for(var c=new Array(E.bitLength()),p=0;p<c.length;p++){var y=p/26|0,A=p%26;c[p]=E.words[y]>>>A&1}return c}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,p=0;p<this.length;p++){var y=this._zeroBits(this.words[p]);if(c+=y,y!==26)break}return c},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(c){return this.negative!==0?this.abs().inotn(c).iaddn(1):this.clone()},i.prototype.fromTwos=function(c){return this.testn(c-1)?this.notn(c).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(c){for(;this.length<c.length;)this.words[this.length++]=0;for(var p=0;p<c.length;p++)this.words[p]=this.words[p]|c.words[p];return this._strip()},i.prototype.ior=function(c){return r((this.negative|c.negative)===0),this.iuor(c)},i.prototype.or=function(c){return this.length>c.length?this.clone().ior(c):c.clone().ior(this)},i.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},i.prototype.iuand=function(c){var p;this.length>c.length?p=c:p=this;for(var y=0;y<p.length;y++)this.words[y]=this.words[y]&c.words[y];return this.length=p.length,this._strip()},i.prototype.iand=function(c){return r((this.negative|c.negative)===0),this.iuand(c)},i.prototype.and=function(c){return this.length>c.length?this.clone().iand(c):c.clone().iand(this)},i.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},i.prototype.iuxor=function(c){var p,y;this.length>c.length?(p=this,y=c):(p=c,y=this);for(var A=0;A<y.length;A++)this.words[A]=p.words[A]^y.words[A];if(this!==p)for(;A<p.length;A++)this.words[A]=p.words[A];return this.length=p.length,this._strip()},i.prototype.ixor=function(c){return r((this.negative|c.negative)===0),this.iuxor(c)},i.prototype.xor=function(c){return this.length>c.length?this.clone().ixor(c):c.clone().ixor(this)},i.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},i.prototype.inotn=function(c){r(typeof c=="number"&&c>=0);var p=Math.ceil(c/26)|0,y=c%26;this._expand(p),y>0&&p--;for(var A=0;A<p;A++)this.words[A]=~this.words[A]&67108863;return y>0&&(this.words[A]=~this.words[A]&67108863>>26-y),this._strip()},i.prototype.notn=function(c){return this.clone().inotn(c)},i.prototype.setn=function(c,p){r(typeof c=="number"&&c>=0);var y=c/26|0,A=c%26;return this._expand(y+1),p?this.words[y]=this.words[y]|1<<A:this.words[y]=this.words[y]&~(1<<A),this._strip()},i.prototype.iadd=function(c){var p;if(this.negative!==0&&c.negative===0)return this.negative=0,p=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,p=this.isub(c),c.negative=1,p._normSign();var y,A;this.length>c.length?(y=this,A=c):(y=c,A=this);for(var v=0,R=0;R<A.length;R++)p=(y.words[R]|0)+(A.words[R]|0)+v,this.words[R]=p&67108863,v=p>>>26;for(;v!==0&&R<y.length;R++)p=(y.words[R]|0)+v,this.words[R]=p&67108863,v=p>>>26;if(this.length=y.length,v!==0)this.words[this.length]=v,this.length++;else if(y!==this)for(;R<y.length;R++)this.words[R]=y.words[R];return this},i.prototype.add=function(c){var p;return c.negative!==0&&this.negative===0?(c.negative=0,p=this.sub(c),c.negative^=1,p):c.negative===0&&this.negative!==0?(this.negative=0,p=c.sub(this),this.negative=1,p):this.length>c.length?this.clone().iadd(c):c.clone().iadd(this)},i.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var p=this.iadd(c);return c.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var y=this.cmp(c);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var A,v;y>0?(A=this,v=c):(A=c,v=this);for(var R=0,I=0;I<v.length;I++)p=(A.words[I]|0)-(v.words[I]|0)+R,R=p>>26,this.words[I]=p&67108863;for(;R!==0&&I<A.length;I++)p=(A.words[I]|0)+R,R=p>>26,this.words[I]=p&67108863;if(R===0&&I<A.length&&A!==this)for(;I<A.length;I++)this.words[I]=A.words[I];return this.length=Math.max(this.length,I),A!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(c){return this.clone().isub(c)};function K(E,c,p){p.negative=c.negative^E.negative;var y=E.length+c.length|0;p.length=y,y=y-1|0;var A=E.words[0]|0,v=c.words[0]|0,R=A*v,I=R&67108863,_=R/67108864|0;p.words[0]=I;for(var u=1;u<y;u++){for(var l=_>>>26,w=_&67108863,T=Math.min(u,c.length-1),D=Math.max(0,u-E.length+1);D<=T;D++){var W=u-D|0;A=E.words[W]|0,v=c.words[D]|0,R=A*v+w,l+=R/67108864|0,w=R&67108863}p.words[u]=w|0,_=l|0}return _!==0?p.words[u]=_|0:p.length--,p._strip()}var Y=function(c,p,y){var A=c.words,v=p.words,R=y.words,I=0,_,u,l,w=A[0]|0,T=w&8191,D=w>>>13,W=A[1]|0,re=W&8191,oe=W>>>13,Ce=A[2]|0,Ee=Ce&8191,we=Ce>>>13,De=A[3]|0,ve=De&8191,Oe=De>>>13,mn=A[4]|0,Le=mn&8191,Ve=mn>>>13,Zr=A[5]|0,Fe=Zr&8191,Pe=Zr>>>13,Yt=A[6]|0,Ge=Yt&8191,Ze=Yt>>>13,an=A[7]|0,Ye=an&8191,b=an>>>13,f=A[8]|0,h=f&8191,S=f>>>13,U=A[9]|0,$=U&8191,Z=U>>>13,Re=v[0]|0,_e=Re&8191,ge=Re>>>13,$e=v[1]|0,he=$e&8191,et=$e>>>13,v0=v[2]|0,tt=v0&8191,nt=v0>>>13,R0=v[3]|0,rt=R0&8191,st=R0>>>13,A0=v[4]|0,it=A0&8191,ot=A0>>>13,x0=v[5]|0,at=x0&8191,ct=x0>>>13,S0=v[6]|0,ut=S0&8191,dt=S0>>>13,T0=v[7]|0,lt=T0&8191,ft=T0>>>13,O0=v[8]|0,ht=O0&8191,pt=O0>>>13,I0=v[9]|0,mt=I0&8191,gt=I0>>>13;y.negative=c.negative^p.negative,y.length=19,_=Math.imul(T,_e),u=Math.imul(T,ge),u=u+Math.imul(D,_e)|0,l=Math.imul(D,ge);var Qc=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(Qc>>>26)|0,Qc&=67108863,_=Math.imul(re,_e),u=Math.imul(re,ge),u=u+Math.imul(oe,_e)|0,l=Math.imul(oe,ge),_=_+Math.imul(T,he)|0,u=u+Math.imul(T,et)|0,u=u+Math.imul(D,he)|0,l=l+Math.imul(D,et)|0;var eu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(eu>>>26)|0,eu&=67108863,_=Math.imul(Ee,_e),u=Math.imul(Ee,ge),u=u+Math.imul(we,_e)|0,l=Math.imul(we,ge),_=_+Math.imul(re,he)|0,u=u+Math.imul(re,et)|0,u=u+Math.imul(oe,he)|0,l=l+Math.imul(oe,et)|0,_=_+Math.imul(T,tt)|0,u=u+Math.imul(T,nt)|0,u=u+Math.imul(D,tt)|0,l=l+Math.imul(D,nt)|0;var tu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(tu>>>26)|0,tu&=67108863,_=Math.imul(ve,_e),u=Math.imul(ve,ge),u=u+Math.imul(Oe,_e)|0,l=Math.imul(Oe,ge),_=_+Math.imul(Ee,he)|0,u=u+Math.imul(Ee,et)|0,u=u+Math.imul(we,he)|0,l=l+Math.imul(we,et)|0,_=_+Math.imul(re,tt)|0,u=u+Math.imul(re,nt)|0,u=u+Math.imul(oe,tt)|0,l=l+Math.imul(oe,nt)|0,_=_+Math.imul(T,rt)|0,u=u+Math.imul(T,st)|0,u=u+Math.imul(D,rt)|0,l=l+Math.imul(D,st)|0;var nu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(nu>>>26)|0,nu&=67108863,_=Math.imul(Le,_e),u=Math.imul(Le,ge),u=u+Math.imul(Ve,_e)|0,l=Math.imul(Ve,ge),_=_+Math.imul(ve,he)|0,u=u+Math.imul(ve,et)|0,u=u+Math.imul(Oe,he)|0,l=l+Math.imul(Oe,et)|0,_=_+Math.imul(Ee,tt)|0,u=u+Math.imul(Ee,nt)|0,u=u+Math.imul(we,tt)|0,l=l+Math.imul(we,nt)|0,_=_+Math.imul(re,rt)|0,u=u+Math.imul(re,st)|0,u=u+Math.imul(oe,rt)|0,l=l+Math.imul(oe,st)|0,_=_+Math.imul(T,it)|0,u=u+Math.imul(T,ot)|0,u=u+Math.imul(D,it)|0,l=l+Math.imul(D,ot)|0;var ru=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(ru>>>26)|0,ru&=67108863,_=Math.imul(Fe,_e),u=Math.imul(Fe,ge),u=u+Math.imul(Pe,_e)|0,l=Math.imul(Pe,ge),_=_+Math.imul(Le,he)|0,u=u+Math.imul(Le,et)|0,u=u+Math.imul(Ve,he)|0,l=l+Math.imul(Ve,et)|0,_=_+Math.imul(ve,tt)|0,u=u+Math.imul(ve,nt)|0,u=u+Math.imul(Oe,tt)|0,l=l+Math.imul(Oe,nt)|0,_=_+Math.imul(Ee,rt)|0,u=u+Math.imul(Ee,st)|0,u=u+Math.imul(we,rt)|0,l=l+Math.imul(we,st)|0,_=_+Math.imul(re,it)|0,u=u+Math.imul(re,ot)|0,u=u+Math.imul(oe,it)|0,l=l+Math.imul(oe,ot)|0,_=_+Math.imul(T,at)|0,u=u+Math.imul(T,ct)|0,u=u+Math.imul(D,at)|0,l=l+Math.imul(D,ct)|0;var su=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(su>>>26)|0,su&=67108863,_=Math.imul(Ge,_e),u=Math.imul(Ge,ge),u=u+Math.imul(Ze,_e)|0,l=Math.imul(Ze,ge),_=_+Math.imul(Fe,he)|0,u=u+Math.imul(Fe,et)|0,u=u+Math.imul(Pe,he)|0,l=l+Math.imul(Pe,et)|0,_=_+Math.imul(Le,tt)|0,u=u+Math.imul(Le,nt)|0,u=u+Math.imul(Ve,tt)|0,l=l+Math.imul(Ve,nt)|0,_=_+Math.imul(ve,rt)|0,u=u+Math.imul(ve,st)|0,u=u+Math.imul(Oe,rt)|0,l=l+Math.imul(Oe,st)|0,_=_+Math.imul(Ee,it)|0,u=u+Math.imul(Ee,ot)|0,u=u+Math.imul(we,it)|0,l=l+Math.imul(we,ot)|0,_=_+Math.imul(re,at)|0,u=u+Math.imul(re,ct)|0,u=u+Math.imul(oe,at)|0,l=l+Math.imul(oe,ct)|0,_=_+Math.imul(T,ut)|0,u=u+Math.imul(T,dt)|0,u=u+Math.imul(D,ut)|0,l=l+Math.imul(D,dt)|0;var iu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(iu>>>26)|0,iu&=67108863,_=Math.imul(Ye,_e),u=Math.imul(Ye,ge),u=u+Math.imul(b,_e)|0,l=Math.imul(b,ge),_=_+Math.imul(Ge,he)|0,u=u+Math.imul(Ge,et)|0,u=u+Math.imul(Ze,he)|0,l=l+Math.imul(Ze,et)|0,_=_+Math.imul(Fe,tt)|0,u=u+Math.imul(Fe,nt)|0,u=u+Math.imul(Pe,tt)|0,l=l+Math.imul(Pe,nt)|0,_=_+Math.imul(Le,rt)|0,u=u+Math.imul(Le,st)|0,u=u+Math.imul(Ve,rt)|0,l=l+Math.imul(Ve,st)|0,_=_+Math.imul(ve,it)|0,u=u+Math.imul(ve,ot)|0,u=u+Math.imul(Oe,it)|0,l=l+Math.imul(Oe,ot)|0,_=_+Math.imul(Ee,at)|0,u=u+Math.imul(Ee,ct)|0,u=u+Math.imul(we,at)|0,l=l+Math.imul(we,ct)|0,_=_+Math.imul(re,ut)|0,u=u+Math.imul(re,dt)|0,u=u+Math.imul(oe,ut)|0,l=l+Math.imul(oe,dt)|0,_=_+Math.imul(T,lt)|0,u=u+Math.imul(T,ft)|0,u=u+Math.imul(D,lt)|0,l=l+Math.imul(D,ft)|0;var ou=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(ou>>>26)|0,ou&=67108863,_=Math.imul(h,_e),u=Math.imul(h,ge),u=u+Math.imul(S,_e)|0,l=Math.imul(S,ge),_=_+Math.imul(Ye,he)|0,u=u+Math.imul(Ye,et)|0,u=u+Math.imul(b,he)|0,l=l+Math.imul(b,et)|0,_=_+Math.imul(Ge,tt)|0,u=u+Math.imul(Ge,nt)|0,u=u+Math.imul(Ze,tt)|0,l=l+Math.imul(Ze,nt)|0,_=_+Math.imul(Fe,rt)|0,u=u+Math.imul(Fe,st)|0,u=u+Math.imul(Pe,rt)|0,l=l+Math.imul(Pe,st)|0,_=_+Math.imul(Le,it)|0,u=u+Math.imul(Le,ot)|0,u=u+Math.imul(Ve,it)|0,l=l+Math.imul(Ve,ot)|0,_=_+Math.imul(ve,at)|0,u=u+Math.imul(ve,ct)|0,u=u+Math.imul(Oe,at)|0,l=l+Math.imul(Oe,ct)|0,_=_+Math.imul(Ee,ut)|0,u=u+Math.imul(Ee,dt)|0,u=u+Math.imul(we,ut)|0,l=l+Math.imul(we,dt)|0,_=_+Math.imul(re,lt)|0,u=u+Math.imul(re,ft)|0,u=u+Math.imul(oe,lt)|0,l=l+Math.imul(oe,ft)|0,_=_+Math.imul(T,ht)|0,u=u+Math.imul(T,pt)|0,u=u+Math.imul(D,ht)|0,l=l+Math.imul(D,pt)|0;var au=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(au>>>26)|0,au&=67108863,_=Math.imul($,_e),u=Math.imul($,ge),u=u+Math.imul(Z,_e)|0,l=Math.imul(Z,ge),_=_+Math.imul(h,he)|0,u=u+Math.imul(h,et)|0,u=u+Math.imul(S,he)|0,l=l+Math.imul(S,et)|0,_=_+Math.imul(Ye,tt)|0,u=u+Math.imul(Ye,nt)|0,u=u+Math.imul(b,tt)|0,l=l+Math.imul(b,nt)|0,_=_+Math.imul(Ge,rt)|0,u=u+Math.imul(Ge,st)|0,u=u+Math.imul(Ze,rt)|0,l=l+Math.imul(Ze,st)|0,_=_+Math.imul(Fe,it)|0,u=u+Math.imul(Fe,ot)|0,u=u+Math.imul(Pe,it)|0,l=l+Math.imul(Pe,ot)|0,_=_+Math.imul(Le,at)|0,u=u+Math.imul(Le,ct)|0,u=u+Math.imul(Ve,at)|0,l=l+Math.imul(Ve,ct)|0,_=_+Math.imul(ve,ut)|0,u=u+Math.imul(ve,dt)|0,u=u+Math.imul(Oe,ut)|0,l=l+Math.imul(Oe,dt)|0,_=_+Math.imul(Ee,lt)|0,u=u+Math.imul(Ee,ft)|0,u=u+Math.imul(we,lt)|0,l=l+Math.imul(we,ft)|0,_=_+Math.imul(re,ht)|0,u=u+Math.imul(re,pt)|0,u=u+Math.imul(oe,ht)|0,l=l+Math.imul(oe,pt)|0,_=_+Math.imul(T,mt)|0,u=u+Math.imul(T,gt)|0,u=u+Math.imul(D,mt)|0,l=l+Math.imul(D,gt)|0;var cu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(cu>>>26)|0,cu&=67108863,_=Math.imul($,he),u=Math.imul($,et),u=u+Math.imul(Z,he)|0,l=Math.imul(Z,et),_=_+Math.imul(h,tt)|0,u=u+Math.imul(h,nt)|0,u=u+Math.imul(S,tt)|0,l=l+Math.imul(S,nt)|0,_=_+Math.imul(Ye,rt)|0,u=u+Math.imul(Ye,st)|0,u=u+Math.imul(b,rt)|0,l=l+Math.imul(b,st)|0,_=_+Math.imul(Ge,it)|0,u=u+Math.imul(Ge,ot)|0,u=u+Math.imul(Ze,it)|0,l=l+Math.imul(Ze,ot)|0,_=_+Math.imul(Fe,at)|0,u=u+Math.imul(Fe,ct)|0,u=u+Math.imul(Pe,at)|0,l=l+Math.imul(Pe,ct)|0,_=_+Math.imul(Le,ut)|0,u=u+Math.imul(Le,dt)|0,u=u+Math.imul(Ve,ut)|0,l=l+Math.imul(Ve,dt)|0,_=_+Math.imul(ve,lt)|0,u=u+Math.imul(ve,ft)|0,u=u+Math.imul(Oe,lt)|0,l=l+Math.imul(Oe,ft)|0,_=_+Math.imul(Ee,ht)|0,u=u+Math.imul(Ee,pt)|0,u=u+Math.imul(we,ht)|0,l=l+Math.imul(we,pt)|0,_=_+Math.imul(re,mt)|0,u=u+Math.imul(re,gt)|0,u=u+Math.imul(oe,mt)|0,l=l+Math.imul(oe,gt)|0;var uu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(uu>>>26)|0,uu&=67108863,_=Math.imul($,tt),u=Math.imul($,nt),u=u+Math.imul(Z,tt)|0,l=Math.imul(Z,nt),_=_+Math.imul(h,rt)|0,u=u+Math.imul(h,st)|0,u=u+Math.imul(S,rt)|0,l=l+Math.imul(S,st)|0,_=_+Math.imul(Ye,it)|0,u=u+Math.imul(Ye,ot)|0,u=u+Math.imul(b,it)|0,l=l+Math.imul(b,ot)|0,_=_+Math.imul(Ge,at)|0,u=u+Math.imul(Ge,ct)|0,u=u+Math.imul(Ze,at)|0,l=l+Math.imul(Ze,ct)|0,_=_+Math.imul(Fe,ut)|0,u=u+Math.imul(Fe,dt)|0,u=u+Math.imul(Pe,ut)|0,l=l+Math.imul(Pe,dt)|0,_=_+Math.imul(Le,lt)|0,u=u+Math.imul(Le,ft)|0,u=u+Math.imul(Ve,lt)|0,l=l+Math.imul(Ve,ft)|0,_=_+Math.imul(ve,ht)|0,u=u+Math.imul(ve,pt)|0,u=u+Math.imul(Oe,ht)|0,l=l+Math.imul(Oe,pt)|0,_=_+Math.imul(Ee,mt)|0,u=u+Math.imul(Ee,gt)|0,u=u+Math.imul(we,mt)|0,l=l+Math.imul(we,gt)|0;var du=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(du>>>26)|0,du&=67108863,_=Math.imul($,rt),u=Math.imul($,st),u=u+Math.imul(Z,rt)|0,l=Math.imul(Z,st),_=_+Math.imul(h,it)|0,u=u+Math.imul(h,ot)|0,u=u+Math.imul(S,it)|0,l=l+Math.imul(S,ot)|0,_=_+Math.imul(Ye,at)|0,u=u+Math.imul(Ye,ct)|0,u=u+Math.imul(b,at)|0,l=l+Math.imul(b,ct)|0,_=_+Math.imul(Ge,ut)|0,u=u+Math.imul(Ge,dt)|0,u=u+Math.imul(Ze,ut)|0,l=l+Math.imul(Ze,dt)|0,_=_+Math.imul(Fe,lt)|0,u=u+Math.imul(Fe,ft)|0,u=u+Math.imul(Pe,lt)|0,l=l+Math.imul(Pe,ft)|0,_=_+Math.imul(Le,ht)|0,u=u+Math.imul(Le,pt)|0,u=u+Math.imul(Ve,ht)|0,l=l+Math.imul(Ve,pt)|0,_=_+Math.imul(ve,mt)|0,u=u+Math.imul(ve,gt)|0,u=u+Math.imul(Oe,mt)|0,l=l+Math.imul(Oe,gt)|0;var lu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(lu>>>26)|0,lu&=67108863,_=Math.imul($,it),u=Math.imul($,ot),u=u+Math.imul(Z,it)|0,l=Math.imul(Z,ot),_=_+Math.imul(h,at)|0,u=u+Math.imul(h,ct)|0,u=u+Math.imul(S,at)|0,l=l+Math.imul(S,ct)|0,_=_+Math.imul(Ye,ut)|0,u=u+Math.imul(Ye,dt)|0,u=u+Math.imul(b,ut)|0,l=l+Math.imul(b,dt)|0,_=_+Math.imul(Ge,lt)|0,u=u+Math.imul(Ge,ft)|0,u=u+Math.imul(Ze,lt)|0,l=l+Math.imul(Ze,ft)|0,_=_+Math.imul(Fe,ht)|0,u=u+Math.imul(Fe,pt)|0,u=u+Math.imul(Pe,ht)|0,l=l+Math.imul(Pe,pt)|0,_=_+Math.imul(Le,mt)|0,u=u+Math.imul(Le,gt)|0,u=u+Math.imul(Ve,mt)|0,l=l+Math.imul(Ve,gt)|0;var fu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(fu>>>26)|0,fu&=67108863,_=Math.imul($,at),u=Math.imul($,ct),u=u+Math.imul(Z,at)|0,l=Math.imul(Z,ct),_=_+Math.imul(h,ut)|0,u=u+Math.imul(h,dt)|0,u=u+Math.imul(S,ut)|0,l=l+Math.imul(S,dt)|0,_=_+Math.imul(Ye,lt)|0,u=u+Math.imul(Ye,ft)|0,u=u+Math.imul(b,lt)|0,l=l+Math.imul(b,ft)|0,_=_+Math.imul(Ge,ht)|0,u=u+Math.imul(Ge,pt)|0,u=u+Math.imul(Ze,ht)|0,l=l+Math.imul(Ze,pt)|0,_=_+Math.imul(Fe,mt)|0,u=u+Math.imul(Fe,gt)|0,u=u+Math.imul(Pe,mt)|0,l=l+Math.imul(Pe,gt)|0;var hu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(hu>>>26)|0,hu&=67108863,_=Math.imul($,ut),u=Math.imul($,dt),u=u+Math.imul(Z,ut)|0,l=Math.imul(Z,dt),_=_+Math.imul(h,lt)|0,u=u+Math.imul(h,ft)|0,u=u+Math.imul(S,lt)|0,l=l+Math.imul(S,ft)|0,_=_+Math.imul(Ye,ht)|0,u=u+Math.imul(Ye,pt)|0,u=u+Math.imul(b,ht)|0,l=l+Math.imul(b,pt)|0,_=_+Math.imul(Ge,mt)|0,u=u+Math.imul(Ge,gt)|0,u=u+Math.imul(Ze,mt)|0,l=l+Math.imul(Ze,gt)|0;var pu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(pu>>>26)|0,pu&=67108863,_=Math.imul($,lt),u=Math.imul($,ft),u=u+Math.imul(Z,lt)|0,l=Math.imul(Z,ft),_=_+Math.imul(h,ht)|0,u=u+Math.imul(h,pt)|0,u=u+Math.imul(S,ht)|0,l=l+Math.imul(S,pt)|0,_=_+Math.imul(Ye,mt)|0,u=u+Math.imul(Ye,gt)|0,u=u+Math.imul(b,mt)|0,l=l+Math.imul(b,gt)|0;var mu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(mu>>>26)|0,mu&=67108863,_=Math.imul($,ht),u=Math.imul($,pt),u=u+Math.imul(Z,ht)|0,l=Math.imul(Z,pt),_=_+Math.imul(h,mt)|0,u=u+Math.imul(h,gt)|0,u=u+Math.imul(S,mt)|0,l=l+Math.imul(S,gt)|0;var gu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(gu>>>26)|0,gu&=67108863,_=Math.imul($,mt),u=Math.imul($,gt),u=u+Math.imul(Z,mt)|0,l=Math.imul(Z,gt);var yu=(I+_|0)+((u&8191)<<13)|0;return I=(l+(u>>>13)|0)+(yu>>>26)|0,yu&=67108863,R[0]=Qc,R[1]=eu,R[2]=tu,R[3]=nu,R[4]=ru,R[5]=su,R[6]=iu,R[7]=ou,R[8]=au,R[9]=cu,R[10]=uu,R[11]=du,R[12]=lu,R[13]=fu,R[14]=hu,R[15]=pu,R[16]=mu,R[17]=gu,R[18]=yu,I!==0&&(R[19]=I,y.length++),y};Math.imul||(Y=K);function V(E,c,p){p.negative=c.negative^E.negative,p.length=E.length+c.length;for(var y=0,A=0,v=0;v<p.length-1;v++){var R=A;A=0;for(var I=y&67108863,_=Math.min(v,c.length-1),u=Math.max(0,v-E.length+1);u<=_;u++){var l=v-u,w=E.words[l]|0,T=c.words[u]|0,D=w*T,W=D&67108863;R=R+(D/67108864|0)|0,W=W+I|0,I=W&67108863,R=R+(W>>>26)|0,A+=R>>>26,R&=67108863}p.words[v]=I,y=R,R=A}return y!==0?p.words[v]=y:p.length--,p._strip()}function L(E,c,p){return V(E,c,p)}i.prototype.mulTo=function(c,p){var y,A=this.length+c.length;return this.length===10&&c.length===10?y=Y(this,c,p):A<63?y=K(this,c,p):A<1024?y=V(this,c,p):y=L(this,c,p),y},i.prototype.mul=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),this.mulTo(c,p)},i.prototype.mulf=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),L(this,c,p)},i.prototype.imul=function(c){return this.clone().mulTo(c,this)},i.prototype.imuln=function(c){var p=c<0;p&&(c=-c),r(typeof c=="number"),r(c<67108864);for(var y=0,A=0;A<this.length;A++){var v=(this.words[A]|0)*c,R=(v&67108863)+(y&67108863);y>>=26,y+=v/67108864|0,y+=R>>>26,this.words[A]=R&67108863}return y!==0&&(this.words[A]=y,this.length++),this.length=c===0?1:this.length,p?this.ineg():this},i.prototype.muln=function(c){return this.clone().imuln(c)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(c){var p=k(c);if(p.length===0)return new i(1);for(var y=this,A=0;A<p.length&&p[A]===0;A++,y=y.sqr());if(++A<p.length)for(var v=y.sqr();A<p.length;A++,v=v.sqr())p[A]!==0&&(y=y.mul(v));return y},i.prototype.iushln=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,A=67108863>>>26-p<<26-p,v;if(p!==0){var R=0;for(v=0;v<this.length;v++){var I=this.words[v]&A,_=(this.words[v]|0)-I<<p;this.words[v]=_|R,R=I>>>26-p}R&&(this.words[v]=R,this.length++)}if(y!==0){for(v=this.length-1;v>=0;v--)this.words[v+y]=this.words[v];for(v=0;v<y;v++)this.words[v]=0;this.length+=y}return this._strip()},i.prototype.ishln=function(c){return r(this.negative===0),this.iushln(c)},i.prototype.iushrn=function(c,p,y){r(typeof c=="number"&&c>=0);var A;p?A=(p-p%26)/26:A=0;var v=c%26,R=Math.min((c-v)/26,this.length),I=67108863^67108863>>>v<<v,_=y;if(A-=R,A=Math.max(0,A),_){for(var u=0;u<R;u++)_.words[u]=this.words[u];_.length=R}if(R!==0)if(this.length>R)for(this.length-=R,u=0;u<this.length;u++)this.words[u]=this.words[u+R];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(l!==0||u>=A);u--){var w=this.words[u]|0;this.words[u]=l<<26-v|w>>>v,l=w&I}return _&&l!==0&&(_.words[_.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(c,p,y){return r(this.negative===0),this.iushrn(c,p,y)},i.prototype.shln=function(c){return this.clone().ishln(c)},i.prototype.ushln=function(c){return this.clone().iushln(c)},i.prototype.shrn=function(c){return this.clone().ishrn(c)},i.prototype.ushrn=function(c){return this.clone().iushrn(c)},i.prototype.testn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,A=1<<p;if(this.length<=y)return!1;var v=this.words[y];return!!(v&A)},i.prototype.imaskn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(p!==0&&y++,this.length=Math.min(y,this.length),p!==0){var A=67108863^67108863>>>p<<p;this.words[this.length-1]&=A}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.maskn=function(c){return this.clone().imaskn(c)},i.prototype.iaddn=function(c){return r(typeof c=="number"),r(c<67108864),c<0?this.isubn(-c):this.negative!==0?this.length===1&&(this.words[0]|0)<=c?(this.words[0]=c-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(c),this.negative=1,this):this._iaddn(c)},i.prototype._iaddn=function(c){this.words[0]+=c;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},i.prototype.isubn=function(c){if(r(typeof c=="number"),r(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this._strip()},i.prototype.addn=function(c){return this.clone().iaddn(c)},i.prototype.subn=function(c){return this.clone().isubn(c)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(c,p,y){var A=c.length+y,v;this._expand(A);var R,I=0;for(v=0;v<c.length;v++){R=(this.words[v+y]|0)+I;var _=(c.words[v]|0)*p;R-=_&67108863,I=(R>>26)-(_/67108864|0),this.words[v+y]=R&67108863}for(;v<this.length-y;v++)R=(this.words[v+y]|0)+I,I=R>>26,this.words[v+y]=R&67108863;if(I===0)return this._strip();for(r(I===-1),I=0,v=0;v<this.length;v++)R=-(this.words[v]|0)+I,I=R>>26,this.words[v]=R&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(c,p){var y=this.length-c.length,A=this.clone(),v=c,R=v.words[v.length-1]|0,I=this._countBits(R);y=26-I,y!==0&&(v=v.ushln(y),A.iushln(y),R=v.words[v.length-1]|0);var _=A.length-v.length,u;if(p!=="mod"){u=new i(null),u.length=_+1,u.words=new Array(u.length);for(var l=0;l<u.length;l++)u.words[l]=0}var w=A.clone()._ishlnsubmul(v,1,_);w.negative===0&&(A=w,u&&(u.words[_]=1));for(var T=_-1;T>=0;T--){var D=(A.words[v.length+T]|0)*67108864+(A.words[v.length+T-1]|0);for(D=Math.min(D/R|0,67108863),A._ishlnsubmul(v,D,T);A.negative!==0;)D--,A.negative=0,A._ishlnsubmul(v,1,T),A.isZero()||(A.negative^=1);u&&(u.words[T]=D)}return u&&u._strip(),A._strip(),p!=="div"&&y!==0&&A.iushrn(y),{div:u||null,mod:A}},i.prototype.divmod=function(c,p,y){if(r(!c.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var A,v,R;return this.negative!==0&&c.negative===0?(R=this.neg().divmod(c,p),p!=="mod"&&(A=R.div.neg()),p!=="div"&&(v=R.mod.neg(),y&&v.negative!==0&&v.iadd(c)),{div:A,mod:v}):this.negative===0&&c.negative!==0?(R=this.divmod(c.neg(),p),p!=="mod"&&(A=R.div.neg()),{div:A,mod:R.mod}):(this.negative&c.negative)!==0?(R=this.neg().divmod(c.neg(),p),p!=="div"&&(v=R.mod.neg(),y&&v.negative!==0&&v.isub(c)),{div:R.div,mod:v}):c.length>this.length||this.cmp(c)<0?{div:new i(0),mod:this}:c.length===1?p==="div"?{div:this.divn(c.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new i(this.modrn(c.words[0]))}:this._wordDiv(c,p)},i.prototype.div=function(c){return this.divmod(c,"div",!1).div},i.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},i.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},i.prototype.divRound=function(c){var p=this.divmod(c);if(p.mod.isZero())return p.div;var y=p.div.negative!==0?p.mod.isub(c):p.mod,A=c.ushrn(1),v=c.andln(1),R=y.cmp(A);return R<0||v===1&&R===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},i.prototype.modrn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var y=(1<<26)%c,A=0,v=this.length-1;v>=0;v--)A=(y*A+(this.words[v]|0))%c;return p?-A:A},i.prototype.modn=function(c){return this.modrn(c)},i.prototype.idivn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var y=0,A=this.length-1;A>=0;A--){var v=(this.words[A]|0)+y*67108864;this.words[A]=v/c|0,y=v%c}return this._strip(),p?this.ineg():this},i.prototype.divn=function(c){return this.clone().idivn(c)},i.prototype.egcd=function(c){r(c.negative===0),r(!c.isZero());var p=this,y=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var A=new i(1),v=new i(0),R=new i(0),I=new i(1),_=0;p.isEven()&&y.isEven();)p.iushrn(1),y.iushrn(1),++_;for(var u=y.clone(),l=p.clone();!p.isZero();){for(var w=0,T=1;(p.words[0]&T)===0&&w<26;++w,T<<=1);if(w>0)for(p.iushrn(w);w-- >0;)(A.isOdd()||v.isOdd())&&(A.iadd(u),v.isub(l)),A.iushrn(1),v.iushrn(1);for(var D=0,W=1;(y.words[0]&W)===0&&D<26;++D,W<<=1);if(D>0)for(y.iushrn(D);D-- >0;)(R.isOdd()||I.isOdd())&&(R.iadd(u),I.isub(l)),R.iushrn(1),I.iushrn(1);p.cmp(y)>=0?(p.isub(y),A.isub(R),v.isub(I)):(y.isub(p),R.isub(A),I.isub(v))}return{a:R,b:I,gcd:y.iushln(_)}},i.prototype._invmp=function(c){r(c.negative===0),r(!c.isZero());var p=this,y=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var A=new i(1),v=new i(0),R=y.clone();p.cmpn(1)>0&&y.cmpn(1)>0;){for(var I=0,_=1;(p.words[0]&_)===0&&I<26;++I,_<<=1);if(I>0)for(p.iushrn(I);I-- >0;)A.isOdd()&&A.iadd(R),A.iushrn(1);for(var u=0,l=1;(y.words[0]&l)===0&&u<26;++u,l<<=1);if(u>0)for(y.iushrn(u);u-- >0;)v.isOdd()&&v.iadd(R),v.iushrn(1);p.cmp(y)>=0?(p.isub(y),A.isub(v)):(y.isub(p),v.isub(A))}var w;return p.cmpn(1)===0?w=A:w=v,w.cmpn(0)<0&&w.iadd(c),w},i.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var p=this.clone(),y=c.clone();p.negative=0,y.negative=0;for(var A=0;p.isEven()&&y.isEven();A++)p.iushrn(1),y.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;y.isEven();)y.iushrn(1);var v=p.cmp(y);if(v<0){var R=p;p=y,y=R}else if(v===0||y.cmpn(1)===0)break;p.isub(y)}while(!0);return y.iushln(A)},i.prototype.invm=function(c){return this.egcd(c).a.umod(c)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(c){return this.words[0]&c},i.prototype.bincn=function(c){r(typeof c=="number");var p=c%26,y=(c-p)/26,A=1<<p;if(this.length<=y)return this._expand(y+1),this.words[y]|=A,this;for(var v=A,R=y;v!==0&&R<this.length;R++){var I=this.words[R]|0;I+=v,v=I>>>26,I&=67108863,this.words[R]=I}return v!==0&&(this.words[R]=v,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(c){var p=c<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var y;if(this.length>1)y=1;else{p&&(c=-c),r(c<=67108863,"Number is too big");var A=this.words[0]|0;y=A===c?0:A<c?-1:1}return this.negative!==0?-y|0:y},i.prototype.cmp=function(c){if(this.negative!==0&&c.negative===0)return-1;if(this.negative===0&&c.negative!==0)return 1;var p=this.ucmp(c);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(c){if(this.length>c.length)return 1;if(this.length<c.length)return-1;for(var p=0,y=this.length-1;y>=0;y--){var A=this.words[y]|0,v=c.words[y]|0;if(A!==v){A<v?p=-1:A>v&&(p=1);break}}return p},i.prototype.gtn=function(c){return this.cmpn(c)===1},i.prototype.gt=function(c){return this.cmp(c)===1},i.prototype.gten=function(c){return this.cmpn(c)>=0},i.prototype.gte=function(c){return this.cmp(c)>=0},i.prototype.ltn=function(c){return this.cmpn(c)===-1},i.prototype.lt=function(c){return this.cmp(c)===-1},i.prototype.lten=function(c){return this.cmpn(c)<=0},i.prototype.lte=function(c){return this.cmp(c)<=0},i.prototype.eqn=function(c){return this.cmpn(c)===0},i.prototype.eq=function(c){return this.cmp(c)===0},i.red=function(c){return new P(c)},i.prototype.toRed=function(c){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(c){return this.red=c,this},i.prototype.forceRed=function(c){return r(!this.red,"Already a number in reduction context"),this._forceRed(c)},i.prototype.redAdd=function(c){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},i.prototype.redIAdd=function(c){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},i.prototype.redSub=function(c){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},i.prototype.redISub=function(c){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},i.prototype.redShl=function(c){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},i.prototype.redMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},i.prototype.redIMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(c){return r(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var z={k256:null,p224:null,p192:null,p25519:null};function J(E,c){this.name=E,this.p=new i(c,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}J.prototype._tmp=function(){var c=new i(null);return c.words=new Array(Math.ceil(this.n/13)),c},J.prototype.ireduce=function(c){var p=c,y;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),y=p.bitLength();while(y>this.n);var A=y<this.n?-1:p.ucmp(this.p);return A===0?(p.words[0]=0,p.length=1):A>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},J.prototype.split=function(c,p){c.iushrn(this.n,0,p)},J.prototype.imulK=function(c){return c.imul(this.k)};function te(){J.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(te,J),te.prototype.split=function(c,p){for(var y=4194303,A=Math.min(c.length,9),v=0;v<A;v++)p.words[v]=c.words[v];if(p.length=A,c.length<=9){c.words[0]=0,c.length=1;return}var R=c.words[9];for(p.words[p.length++]=R&y,v=10;v<c.length;v++){var I=c.words[v]|0;c.words[v-10]=(I&y)<<4|R>>>22,R=I}R>>>=22,c.words[v-10]=R,R===0&&c.length>10?c.length-=10:c.length-=9},te.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var p=0,y=0;y<c.length;y++){var A=c.words[y]|0;p+=A*977,c.words[y]=p&67108863,p=A*64+(p/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};function ne(){J.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(ne,J);function q(){J.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(q,J);function B(){J.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(B,J),B.prototype.imulK=function(c){for(var p=0,y=0;y<c.length;y++){var A=(c.words[y]|0)*19+p,v=A&67108863;A>>>=26,c.words[y]=v,p=A}return p!==0&&(c.words[c.length++]=p),c},i._prime=function(c){if(z[c])return z[c];var p;if(c==="k256")p=new te;else if(c==="p224")p=new ne;else if(c==="p192")p=new q;else if(c==="p25519")p=new B;else throw new Error("Unknown prime "+c);return z[c]=p,p};function P(E){if(typeof E=="string"){var c=i._prime(E);this.m=c.p,this.prime=c}else r(E.gtn(1),"modulus must be greater than 1"),this.m=E,this.prime=null}P.prototype._verify1=function(c){r(c.negative===0,"red works only with positives"),r(c.red,"red works only with red numbers")},P.prototype._verify2=function(c,p){r((c.negative|p.negative)===0,"red works only with positives"),r(c.red&&c.red===p.red,"red works only with red numbers")},P.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(g(c,c.umod(this.m)._forceRed(this)),c)},P.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},P.prototype.add=function(c,p){this._verify2(c,p);var y=c.add(p);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},P.prototype.iadd=function(c,p){this._verify2(c,p);var y=c.iadd(p);return y.cmp(this.m)>=0&&y.isub(this.m),y},P.prototype.sub=function(c,p){this._verify2(c,p);var y=c.sub(p);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},P.prototype.isub=function(c,p){this._verify2(c,p);var y=c.isub(p);return y.cmpn(0)<0&&y.iadd(this.m),y},P.prototype.shl=function(c,p){return this._verify1(c),this.imod(c.ushln(p))},P.prototype.imul=function(c,p){return this._verify2(c,p),this.imod(c.imul(p))},P.prototype.mul=function(c,p){return this._verify2(c,p),this.imod(c.mul(p))},P.prototype.isqr=function(c){return this.imul(c,c.clone())},P.prototype.sqr=function(c){return this.mul(c,c)},P.prototype.sqrt=function(c){if(c.isZero())return c.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var y=this.m.add(new i(1)).iushrn(2);return this.pow(c,y)}for(var A=this.m.subn(1),v=0;!A.isZero()&&A.andln(1)===0;)v++,A.iushrn(1);r(!A.isZero());var R=new i(1).toRed(this),I=R.redNeg(),_=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,_).cmp(I)!==0;)u.redIAdd(I);for(var l=this.pow(u,A),w=this.pow(c,A.addn(1).iushrn(1)),T=this.pow(c,A),D=v;T.cmp(R)!==0;){for(var W=T,re=0;W.cmp(R)!==0;re++)W=W.redSqr();r(re<D);var oe=this.pow(l,new i(1).iushln(D-re-1));w=w.redMul(oe),l=oe.redSqr(),T=T.redMul(l),D=re}return w},P.prototype.invm=function(c){var p=c._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},P.prototype.pow=function(c,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return c.clone();var y=4,A=new Array(1<<y);A[0]=new i(1).toRed(this),A[1]=c;for(var v=2;v<A.length;v++)A[v]=this.mul(A[v-1],c);var R=A[0],I=0,_=0,u=p.bitLength()%26;for(u===0&&(u=26),v=p.length-1;v>=0;v--){for(var l=p.words[v],w=u-1;w>=0;w--){var T=l>>w&1;if(R!==A[0]&&(R=this.sqr(R)),T===0&&I===0){_=0;continue}I<<=1,I|=T,_++,!(_!==y&&(v!==0||w!==0))&&(R=this.mul(R,A[I]),_=0,I=0)}u=26}return R},P.prototype.convertTo=function(c){var p=c.umod(this.m);return p===c?p.clone():p},P.prototype.convertFrom=function(c){var p=c.clone();return p.red=null,p},i.mont=function(c){return new j(c)};function j(E){P.call(this,E),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}s(j,P),j.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},j.prototype.convertFrom=function(c){var p=this.imod(c.mul(this.rinv));return p.red=null,p},j.prototype.imul=function(c,p){if(c.isZero()||p.isZero())return c.words[0]=0,c.length=1,c;var y=c.imul(p),A=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=y.isub(A).iushrn(this.shift),R=v;return v.cmp(this.m)>=0?R=v.isub(this.m):v.cmpn(0)<0&&(R=v.iadd(this.m)),R._forceRed(this)},j.prototype.mul=function(c,p){if(c.isZero()||p.isZero())return new i(0)._forceRed(this);var y=c.mul(p),A=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=y.isub(A).iushrn(this.shift),R=v;return v.cmp(this.m)>=0?R=v.isub(this.m):v.cmpn(0)<0&&(R=v.iadd(this.m)),R._forceRed(this)},j.prototype.invm=function(c){var p=this.imod(c._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,o_)})(Di)),Di.exports}var a_=Rf();const Af=Ga(a_);var Fi={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var xf;function c_(){return xf||(xf=1,(function(t,e){var n=ac(),r=n.Buffer;function s(o,a){for(var d in o)a[d]=o[d]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(s(n,e),e.Buffer=i);function i(o,a,d){return r(o,a,d)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,a,d){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,d)},i.alloc=function(o,a,d){if(typeof o!="number")throw new TypeError("Argument must be a number");var m=r(o);return a!==void 0?typeof d=="string"?m.fill(a,d):m.fill(a):m.fill(0),m},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(o)}})(Fi,Fi.exports)),Fi.exports}var dc,Sf;function u_(){if(Sf)return dc;Sf=1;var t=c_().Buffer;function e(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var i=0;i<n.length;i++){var o=n.charAt(i),a=o.charCodeAt(0);if(r[a]!==255)throw new TypeError(o+" is ambiguous");r[a]=i}var d=n.length,m=n.charAt(0),g=Math.log(d)/Math.log(256),x=Math.log(256)/Math.log(d);function O(C){if((Array.isArray(C)||C instanceof Uint8Array)&&(C=t.from(C)),!t.isBuffer(C))throw new TypeError("Expected Buffer");if(C.length===0)return"";for(var k=0,K=0,Y=0,V=C.length;Y!==V&&C[Y]===0;)Y++,k++;for(var L=(V-Y)*x+1>>>0,z=new Uint8Array(L);Y!==V;){for(var J=C[Y],te=0,ne=L-1;(J!==0||te<K)&&ne!==-1;ne--,te++)J+=256*z[ne]>>>0,z[ne]=J%d>>>0,J=J/d>>>0;if(J!==0)throw new Error("Non-zero carry");K=te,Y++}for(var q=L-K;q!==L&&z[q]===0;)q++;for(var B=m.repeat(k);q<L;++q)B+=n.charAt(z[q]);return B}function N(C){if(typeof C!="string")throw new TypeError("Expected String");if(C.length===0)return t.alloc(0);for(var k=0,K=0,Y=0;C[k]===m;)K++,k++;for(var V=(C.length-k)*g+1>>>0,L=new Uint8Array(V);k<C.length;){var z=C.charCodeAt(k);if(z>255)return;var J=r[z];if(J===255)return;for(var te=0,ne=V-1;(J!==0||te<Y)&&ne!==-1;ne--,te++)J+=d*L[ne]>>>0,L[ne]=J%256>>>0,J=J/256>>>0;if(J!==0)throw new Error("Non-zero carry");Y=te,k++}for(var q=V-Y;q!==V&&L[q]===0;)q++;var B=t.allocUnsafe(K+(V-q));B.fill(0,0,K);for(var P=K;q!==V;)B[P++]=L[q++];return B}function F(C){var k=N(C);if(k)return k;throw new Error("Non-base"+d+" character")}return{encode:O,decodeUnsafe:N,decode:F}}return dc=e,dc}var lc,Tf;function Of(){if(Tf)return lc;Tf=1;var t=u_(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return lc=t(e),lc}var d_=Of();const Dt=Ga(d_);var Be={};function Tn(t,e,n){return e<=t&&t<=n}function $i(t){if(t===void 0)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function l_(t){for(var e=String(t),n=e.length,r=0,s=[];r<n;){var i=e.charCodeAt(r);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(r===n-1)s.push(65533);else{var o=t.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=i&1023,d=o&1023;s.push(65536+(a<<10)+d),r+=1}else s.push(65533)}r+=1}return s}function f_(t){for(var e="",n=0;n<t.length;++n){var r=t[n];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}var zi=-1;function fc(t){this.tokens=[].slice.call(t)}fc.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():zi},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var Lr=-1;function hc(t,e){if(t)throw TypeError("Decoder error");return e||65533}var ji="utf-8";function Vi(t,e){if(!(this instanceof Vi))return new Vi(t,e);if(t=t!==void 0?String(t).toLowerCase():ji,t!==ji)throw new Error("Encoding not supported. Only utf-8 is supported");e=$i(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}Vi.prototype={decode:function(e,n){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),n=$i(n),this._streaming||(this._decoder=new h_({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!n.stream;for(var s=new fc(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==Lr);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===Lr)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),f_(i)}};function Gi(t,e){if(!(this instanceof Gi))return new Gi(t,e);if(t=t!==void 0?String(t).toLowerCase():ji,t!==ji)throw new Error("Encoding not supported. Only utf-8 is supported");e=$i(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Gi.prototype={encode:function(e,n){e=e?String(e):"",n=$i(n),this._streaming||(this._encoder=new p_(this._options)),this._streaming=!!n.stream;for(var r=[],s=new fc(l_(e)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==Lr);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==Lr;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function h_(t){var e=t.fatal,n=0,r=0,s=0,i=128,o=191;this.handler=function(a,d){if(d===zi&&s!==0)return s=0,hc(e);if(d===zi)return Lr;if(s===0){if(Tn(d,0,127))return d;if(Tn(d,194,223))s=1,n=d-192;else if(Tn(d,224,239))d===224&&(i=160),d===237&&(o=159),s=2,n=d-224;else if(Tn(d,240,244))d===240&&(i=144),d===244&&(o=143),s=3,n=d-240;else return hc(e);return n=n<<6*s,null}if(!Tn(d,i,o))return n=s=r=0,i=128,o=191,a.prepend(d),hc(e);if(i=128,o=191,r+=1,n+=d-128<<6*(s-r),r!==s)return null;var m=n;return n=s=r=0,m}}function p_(t){t.fatal,this.handler=function(e,n){if(n===zi)return Lr;if(Tn(n,0,127))return n;var r,s;Tn(n,128,2047)?(r=1,s=192):Tn(n,2048,65535)?(r=2,s=224):Tn(n,65536,1114111)&&(r=3,s=240);for(var i=[(n>>6*r)+s];r>0;){var o=n>>6*(r-1);i.push(128|o&63),r-=1}return i}}const m_=Ha(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Vi,TextEncoder:Gi},Symbol.toStringTag,{value:"Module"})));var If;function g_(){if(If)return Be;If=1;var t=Be&&Be.__createBinding||(Object.create?(function(q,B,P,j){j===void 0&&(j=P),Object.defineProperty(q,j,{enumerable:!0,get:function(){return B[P]}})}):(function(q,B,P,j){j===void 0&&(j=P),q[j]=B[P]})),e=Be&&Be.__setModuleDefault||(Object.create?(function(q,B){Object.defineProperty(q,"default",{enumerable:!0,value:B})}):function(q,B){q.default=B}),n=Be&&Be.__decorate||function(q,B,P,j){var E=arguments.length,c=E<3?B:j===null?j=Object.getOwnPropertyDescriptor(B,P):j,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(q,B,P,j);else for(var y=q.length-1;y>=0;y--)(p=q[y])&&(c=(E<3?p(c):E>3?p(B,P,c):p(B,P))||c);return E>3&&c&&Object.defineProperty(B,P,c),c},r=Be&&Be.__importStar||function(q){if(q&&q.__esModule)return q;var B={};if(q!=null)for(var P in q)P!=="default"&&Object.hasOwnProperty.call(q,P)&&t(B,q,P);return e(B,q),B},s=Be&&Be.__importDefault||function(q){return q&&q.__esModule?q:{default:q}};Object.defineProperty(Be,"__esModule",{value:!0}),Be.deserializeUnchecked=Be.deserialize=Be.serialize=Be.BinaryReader=Be.BinaryWriter=Be.BorshError=Be.baseDecode=Be.baseEncode=void 0;const i=s(Rf()),o=s(Of()),a=r(m_),d=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,m=new d("utf-8",{fatal:!0});function g(q){return typeof q=="string"&&(q=Buffer.from(q,"utf8")),o.default.encode(Buffer.from(q))}Be.baseEncode=g;function x(q){return Buffer.from(o.default.decode(q))}Be.baseDecode=x;const O=1024;class N extends Error{constructor(B){super(B),this.fieldPath=[],this.originalMessage=B}addToFieldPath(B){this.fieldPath.splice(0,0,B),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Be.BorshError=N;class F{constructor(){this.buf=Buffer.alloc(O),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(O)]))}writeU8(B){this.maybeResize(),this.buf.writeUInt8(B,this.length),this.length+=1}writeU16(B){this.maybeResize(),this.buf.writeUInt16LE(B,this.length),this.length+=2}writeU32(B){this.maybeResize(),this.buf.writeUInt32LE(B,this.length),this.length+=4}writeU64(B){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(B).toArray("le",8)))}writeU128(B){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(B).toArray("le",16)))}writeU256(B){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(B).toArray("le",32)))}writeU512(B){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(B).toArray("le",64)))}writeBuffer(B){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),B,Buffer.alloc(O)]),this.length+=B.length}writeString(B){this.maybeResize();const P=Buffer.from(B,"utf8");this.writeU32(P.length),this.writeBuffer(P)}writeFixedArray(B){this.writeBuffer(Buffer.from(B))}writeArray(B,P){this.maybeResize(),this.writeU32(B.length);for(const j of B)this.maybeResize(),P(j)}toArray(){return this.buf.subarray(0,this.length)}}Be.BinaryWriter=F;function C(q,B,P){const j=P.value;P.value=function(...E){try{return j.apply(this,E)}catch(c){if(c instanceof RangeError){const p=c.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(p)>=0)throw new N("Reached the end of buffer when deserializing")}throw c}}}class k{constructor(B){this.buf=B,this.offset=0}readU8(){const B=this.buf.readUInt8(this.offset);return this.offset+=1,B}readU16(){const B=this.buf.readUInt16LE(this.offset);return this.offset+=2,B}readU32(){const B=this.buf.readUInt32LE(this.offset);return this.offset+=4,B}readU64(){const B=this.readBuffer(8);return new i.default(B,"le")}readU128(){const B=this.readBuffer(16);return new i.default(B,"le")}readU256(){const B=this.readBuffer(32);return new i.default(B,"le")}readU512(){const B=this.readBuffer(64);return new i.default(B,"le")}readBuffer(B){if(this.offset+B>this.buf.length)throw new N(`Expected buffer length ${B} isn't within bounds`);const P=this.buf.slice(this.offset,this.offset+B);return this.offset+=B,P}readString(){const B=this.readU32(),P=this.readBuffer(B);try{return m.decode(P)}catch(j){throw new N(`Error decoding UTF-8 string: ${j}`)}}readFixedArray(B){return new Uint8Array(this.readBuffer(B))}readArray(B){const P=this.readU32(),j=Array();for(let E=0;E<P;++E)j.push(B());return j}}n([C],k.prototype,"readU8",null),n([C],k.prototype,"readU16",null),n([C],k.prototype,"readU32",null),n([C],k.prototype,"readU64",null),n([C],k.prototype,"readU128",null),n([C],k.prototype,"readU256",null),n([C],k.prototype,"readU512",null),n([C],k.prototype,"readString",null),n([C],k.prototype,"readFixedArray",null),n([C],k.prototype,"readArray",null),Be.BinaryReader=k;function K(q){return q.charAt(0).toUpperCase()+q.slice(1)}function Y(q,B,P,j,E){try{if(typeof j=="string")E[`write${K(j)}`](P);else if(j instanceof Array)if(typeof j[0]=="number"){if(P.length!==j[0])throw new N(`Expecting byte array of length ${j[0]}, but got ${P.length} bytes`);E.writeFixedArray(P)}else if(j.length===2&&typeof j[1]=="number"){if(P.length!==j[1])throw new N(`Expecting byte array of length ${j[1]}, but got ${P.length} bytes`);for(let c=0;c<j[1];c++)Y(q,null,P[c],j[0],E)}else E.writeArray(P,c=>{Y(q,B,c,j[0],E)});else if(j.kind!==void 0)switch(j.kind){case"option":{P==null?E.writeU8(0):(E.writeU8(1),Y(q,B,P,j.type,E));break}case"map":{E.writeU32(P.size),P.forEach((c,p)=>{Y(q,B,p,j.key,E),Y(q,B,c,j.value,E)});break}default:throw new N(`FieldType ${j} unrecognized`)}else V(q,P,E)}catch(c){throw c instanceof N&&c.addToFieldPath(B),c}}function V(q,B,P){if(typeof B.borshSerialize=="function"){B.borshSerialize(P);return}const j=q.get(B.constructor);if(!j)throw new N(`Class ${B.constructor.name} is missing in schema`);if(j.kind==="struct")j.fields.map(([E,c])=>{Y(q,E,B[E],c,P)});else if(j.kind==="enum"){const E=B[j.field];for(let c=0;c<j.values.length;++c){const[p,y]=j.values[c];if(p===E){P.writeU8(c),Y(q,p,B[p],y,P);break}}}else throw new N(`Unexpected schema kind: ${j.kind} for ${B.constructor.name}`)}function L(q,B,P=F){const j=new P;return V(q,B,j),j.toArray()}Be.serialize=L;function z(q,B,P,j){try{if(typeof P=="string")return j[`read${K(P)}`]();if(P instanceof Array){if(typeof P[0]=="number")return j.readFixedArray(P[0]);if(typeof P[1]=="number"){const E=[];for(let c=0;c<P[1];c++)E.push(z(q,null,P[0],j));return E}else return j.readArray(()=>z(q,B,P[0],j))}if(P.kind==="option")return j.readU8()?z(q,B,P.type,j):void 0;if(P.kind==="map"){let E=new Map;const c=j.readU32();for(let p=0;p<c;p++){const y=z(q,B,P.key,j),A=z(q,B,P.value,j);E.set(y,A)}return E}return J(q,P,j)}catch(E){throw E instanceof N&&E.addToFieldPath(B),E}}function J(q,B,P){if(typeof B.borshDeserialize=="function")return B.borshDeserialize(P);const j=q.get(B);if(!j)throw new N(`Class ${B.name} is missing in schema`);if(j.kind==="struct"){const E={};for(const[c,p]of q.get(B).fields)E[c]=z(q,c,p,P);return new B(E)}if(j.kind==="enum"){const E=P.readU8();if(E>=j.values.length)throw new N(`Enum index: ${E} is out of range`);const[c,p]=j.values[E],y=z(q,c,p,P);return new B({[c]:y})}throw new N(`Unexpected schema kind: ${j.kind} for ${B.constructor.name}`)}function te(q,B,P,j=k){const E=new j(P),c=J(q,B,E);if(E.offset<P.length)throw new N(`Unexpected ${P.length-E.offset} bytes after deserialized data`);return c}Be.deserialize=te;function ne(q,B,P,j=k){const E=new j(P);return J(q,B,E)}return Be.deserializeUnchecked=ne,Be}var pc=g_(),H={},Nf;function y_(){if(Nf)return H;Nf=1,Object.defineProperty(H,"__esModule",{value:!0}),H.s16=H.s8=H.nu64be=H.u48be=H.u40be=H.u32be=H.u24be=H.u16be=H.nu64=H.u48=H.u40=H.u32=H.u24=H.u16=H.u8=H.offset=H.greedy=H.Constant=H.UTF8=H.CString=H.Blob=H.Boolean=H.BitField=H.BitStructure=H.VariantLayout=H.Union=H.UnionLayoutDiscriminator=H.UnionDiscriminator=H.Structure=H.Sequence=H.DoubleBE=H.Double=H.FloatBE=H.Float=H.NearInt64BE=H.NearInt64=H.NearUInt64BE=H.NearUInt64=H.IntBE=H.Int=H.UIntBE=H.UInt=H.OffsetLayout=H.GreedyCount=H.ExternalLayout=H.bindConstructorLayout=H.nameWithProperty=H.Layout=H.uint8ArrayToBuffer=H.checkUint8Array=void 0,H.constant=H.utf8=H.cstr=H.blob=H.unionLayoutDiscriminator=H.union=H.seq=H.bits=H.struct=H.f64be=H.f64=H.f32be=H.f32=H.ns64be=H.s48be=H.s40be=H.s32be=H.s24be=H.s16be=H.ns64=H.s48=H.s40=H.s32=H.s24=void 0;const t=ac();function e(u){if(!(u instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}H.checkUint8Array=e;function n(u){return e(u),t.Buffer.from(u.buffer,u.byteOffset,u.length)}H.uint8ArrayToBuffer=n;let r=class{constructor(l,w){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=w}makeDestinationObject(){return{}}getSpan(l,w){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const w=Object.create(this.constructor.prototype);return Object.assign(w,this),w.property=l,w}fromArray(l){}};H.Layout=r;function s(u,l){return l.property?u+"["+l.property+"]":u}H.nameWithProperty=s;function i(u,l){if(typeof u!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(u,"layout_"))throw new Error("Class is already bound to a layout");if(!(l&&l instanceof r))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(l,"boundConstructor_"))throw new Error("layout is already bound to a constructor");u.layout_=l,l.boundConstructor_=u,l.makeDestinationObject=(()=>new u),Object.defineProperty(u.prototype,"encode",{value(w,T){return l.encode(this,w,T)},writable:!0}),Object.defineProperty(u,"decode",{value(w,T){return l.decode(w,T)},writable:!0})}H.bindConstructorLayout=i;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}H.ExternalLayout=o;class a extends o{constructor(l=1,w){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,w),this.elementSpan=l}isCount(){return!0}decode(l,w=0){e(l);const T=l.length-w;return Math.floor(T/this.elementSpan)}encode(l,w,T){return 0}}H.GreedyCount=a;class d extends o{constructor(l,w=0,T){if(!(l instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(w))throw new TypeError("offset must be integer or undefined");super(l.span,T||l.property),this.layout=l,this.offset=w}isCount(){return this.layout instanceof m||this.layout instanceof g}decode(l,w=0){return this.layout.decode(l,w+this.offset)}encode(l,w,T=0){return this.layout.encode(l,w,T+this.offset)}}H.OffsetLayout=d;class m extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return n(l).readUIntLE(w,this.span)}encode(l,w,T=0){return n(w).writeUIntLE(l,T,this.span),this.span}}H.UInt=m;class g extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return n(l).readUIntBE(w,this.span)}encode(l,w,T=0){return n(w).writeUIntBE(l,T,this.span),this.span}}H.UIntBE=g;class x extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return n(l).readIntLE(w,this.span)}encode(l,w,T=0){return n(w).writeIntLE(l,T,this.span),this.span}}H.Int=x;class O extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return n(l).readIntBE(w,this.span)}encode(l,w,T=0){return n(w).writeIntBE(l,T,this.span),this.span}}H.IntBE=O;const N=Math.pow(2,32);function F(u){const l=Math.floor(u/N),w=u-l*N;return{hi32:l,lo32:w}}function C(u,l){return u*N+l}class k extends r{constructor(l){super(8,l)}decode(l,w=0){const T=n(l),D=T.readUInt32LE(w),W=T.readUInt32LE(w+4);return C(W,D)}encode(l,w,T=0){const D=F(l),W=n(w);return W.writeUInt32LE(D.lo32,T),W.writeUInt32LE(D.hi32,T+4),8}}H.NearUInt64=k;class K extends r{constructor(l){super(8,l)}decode(l,w=0){const T=n(l),D=T.readUInt32BE(w),W=T.readUInt32BE(w+4);return C(D,W)}encode(l,w,T=0){const D=F(l),W=n(w);return W.writeUInt32BE(D.hi32,T),W.writeUInt32BE(D.lo32,T+4),8}}H.NearUInt64BE=K;class Y extends r{constructor(l){super(8,l)}decode(l,w=0){const T=n(l),D=T.readUInt32LE(w),W=T.readInt32LE(w+4);return C(W,D)}encode(l,w,T=0){const D=F(l),W=n(w);return W.writeUInt32LE(D.lo32,T),W.writeInt32LE(D.hi32,T+4),8}}H.NearInt64=Y;class V extends r{constructor(l){super(8,l)}decode(l,w=0){const T=n(l),D=T.readInt32BE(w),W=T.readUInt32BE(w+4);return C(D,W)}encode(l,w,T=0){const D=F(l),W=n(w);return W.writeInt32BE(D.hi32,T),W.writeUInt32BE(D.lo32,T+4),8}}H.NearInt64BE=V;class L extends r{constructor(l){super(4,l)}decode(l,w=0){return n(l).readFloatLE(w)}encode(l,w,T=0){return n(w).writeFloatLE(l,T),4}}H.Float=L;class z extends r{constructor(l){super(4,l)}decode(l,w=0){return n(l).readFloatBE(w)}encode(l,w,T=0){return n(w).writeFloatBE(l,T),4}}H.FloatBE=z;class J extends r{constructor(l){super(8,l)}decode(l,w=0){return n(l).readDoubleLE(w)}encode(l,w,T=0){return n(w).writeDoubleLE(l,T),8}}H.Double=J;class te extends r{constructor(l){super(8,l)}decode(l,w=0){return n(l).readDoubleBE(w)}encode(l,w,T=0){return n(w).writeDoubleBE(l,T),8}}H.DoubleBE=te;class ne extends r{constructor(l,w,T){if(!(l instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(w instanceof o&&w.isCount()||Number.isInteger(w)&&0<=w))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let D=-1;!(w instanceof o)&&0<l.span&&(D=w*l.span),super(D,T),this.elementLayout=l,this.count=w}getSpan(l,w=0){if(0<=this.span)return this.span;let T=0,D=this.count;if(D instanceof o&&(D=D.decode(l,w)),0<this.elementLayout.span)T=D*this.elementLayout.span;else{let W=0;for(;W<D;)T+=this.elementLayout.getSpan(l,w+T),++W}return T}decode(l,w=0){const T=[];let D=0,W=this.count;for(W instanceof o&&(W=W.decode(l,w));D<W;)T.push(this.elementLayout.decode(l,w)),w+=this.elementLayout.getSpan(l,w),D+=1;return T}encode(l,w,T=0){const D=this.elementLayout,W=l.reduce((re,oe)=>re+D.encode(oe,w,T+re),0);return this.count instanceof o&&this.count.encode(l.length,w,T),W}}H.Sequence=ne;class q extends r{constructor(l,w,T){if(!(Array.isArray(l)&&l.reduce((W,re)=>W&&re instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof w=="boolean"&&T===void 0&&(T=w,w=void 0);for(const W of l)if(0>W.span&&W.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let D=-1;try{D=l.reduce((W,re)=>W+re.getSpan(),0)}catch{}super(D,w),this.fields=l,this.decodePrefixes=!!T}getSpan(l,w=0){if(0<=this.span)return this.span;let T=0;try{T=this.fields.reduce((D,W)=>{const re=W.getSpan(l,w);return w+=re,D+re},0)}catch{throw new RangeError("indeterminate span")}return T}decode(l,w=0){e(l);const T=this.makeDestinationObject();for(const D of this.fields)if(D.property!==void 0&&(T[D.property]=D.decode(l,w)),w+=D.getSpan(l,w),this.decodePrefixes&&l.length===w)break;return T}encode(l,w,T=0){const D=T;let W=0,re=0;for(const oe of this.fields){let Ce=oe.span;if(re=0<Ce?Ce:0,oe.property!==void 0){const Ee=l[oe.property];Ee!==void 0&&(re=oe.encode(Ee,w,T),0>Ce&&(Ce=oe.getSpan(w,T)))}W=T,T+=Ce}return W+re-D}fromArray(l){const w=this.makeDestinationObject();for(const T of this.fields)T.property!==void 0&&0<l.length&&(w[T.property]=l.shift());return w}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const w of this.fields)if(w.property===l)return w}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let w=0;for(const T of this.fields){if(T.property===l)return w;0>T.span?w=-1:0<=w&&(w+=T.span)}}}H.Structure=q;class B{constructor(l){this.property=l}decode(l,w){throw new Error("UnionDiscriminator is abstract")}encode(l,w,T){throw new Error("UnionDiscriminator is abstract")}}H.UnionDiscriminator=B;class P extends B{constructor(l,w){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(w||l.property||"variant"),this.layout=l}decode(l,w){return this.layout.decode(l,w)}encode(l,w,T){return this.layout.encode(l,w,T)}}H.UnionLayoutDiscriminator=P;class j extends r{constructor(l,w,T){let D;if(l instanceof m||l instanceof g)D=new P(new d(l));else if(l instanceof o&&l.isCount())D=new P(l);else if(l instanceof B)D=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(w===void 0&&(w=null),!(w===null||w instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(w!==null){if(0>w.span)throw new Error("defaultLayout must have constant span");w.property===void 0&&(w=w.replicate("content"))}let W=-1;w&&(W=w.span,0<=W&&(l instanceof m||l instanceof g)&&(W+=D.layout.span)),super(W,T),this.discriminator=D,this.usesPrefixDiscriminator=l instanceof m||l instanceof g,this.defaultLayout=w,this.registry={};let re=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(oe){return re(oe)},this.configGetSourceVariant=function(oe){re=oe.bind(this)}}getSpan(l,w=0){if(0<=this.span)return this.span;const T=this.getVariant(l,w);if(!T)throw new Error("unable to determine span for unrecognized variant");return T.getSpan(l,w)}defaultGetSourceVariant(l){if(Object.prototype.hasOwnProperty.call(l,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(l,this.defaultLayout.property))return;const w=this.registry[l[this.discriminator.property]];if(w&&(!w.layout||w.property&&Object.prototype.hasOwnProperty.call(l,w.property)))return w}else for(const w in this.registry){const T=this.registry[w];if(T.property&&Object.prototype.hasOwnProperty.call(l,T.property))return T}throw new Error("unable to infer src variant")}decode(l,w=0){let T;const D=this.discriminator,W=D.decode(l,w),re=this.registry[W];if(re===void 0){const oe=this.defaultLayout;let Ce=0;this.usesPrefixDiscriminator&&(Ce=D.layout.span),T=this.makeDestinationObject(),T[D.property]=W,T[oe.property]=oe.decode(l,w+Ce)}else T=re.decode(l,w);return T}encode(l,w,T=0){const D=this.getSourceVariant(l);if(D===void 0){const W=this.discriminator,re=this.defaultLayout;let oe=0;return this.usesPrefixDiscriminator&&(oe=W.layout.span),W.encode(l[W.property],w,T),oe+re.encode(l[re.property],w,T+oe)}return D.encode(l,w,T)}addVariant(l,w,T){const D=new E(this,l,w,T);return this.registry[l]=D,D}getVariant(l,w=0){let T;return l instanceof Uint8Array?T=this.discriminator.decode(l,w):T=l,this.registry[T]}}H.Union=j;class E extends r{constructor(l,w,T,D){if(!(l instanceof j))throw new TypeError("union must be a Union");if(!Number.isInteger(w)||0>w)throw new TypeError("variant must be a (non-negative) integer");if(typeof T=="string"&&D===void 0&&(D=T,T=null),T){if(!(T instanceof r))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=T.span&&T.span>l.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof D!="string")throw new TypeError("variant must have a String property")}let W=l.span;0>l.span&&(W=T?T.span:0,0<=W&&l.usesPrefixDiscriminator&&(W+=l.discriminator.layout.span)),super(W,D),this.union=l,this.variant=w,this.layout=T||null}getSpan(l,w=0){if(0<=this.span)return this.span;let T=0;this.union.usesPrefixDiscriminator&&(T=this.union.discriminator.layout.span);let D=0;return this.layout&&(D=this.layout.getSpan(l,w+T)),T+D}decode(l,w=0){const T=this.makeDestinationObject();if(this!==this.union.getVariant(l,w))throw new Error("variant mismatch");let D=0;return this.union.usesPrefixDiscriminator&&(D=this.union.discriminator.layout.span),this.layout?T[this.property]=this.layout.decode(l,w+D):this.property?T[this.property]=!0:this.union.usesPrefixDiscriminator&&(T[this.union.discriminator.property]=this.variant),T}encode(l,w,T=0){let D=0;if(this.union.usesPrefixDiscriminator&&(D=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(l,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,w,T);let W=D;if(this.layout&&(this.layout.encode(l[this.property],w,T+D),W+=this.layout.getSpan(w,T+D),0<=this.union.span&&W>this.union.span))throw new Error("encoded variant overruns containing union");return W}fromArray(l){if(this.layout)return this.layout.fromArray(l)}}H.VariantLayout=E;function c(u){return 0>u&&(u+=4294967296),u}class p extends r{constructor(l,w,T){if(!(l instanceof m||l instanceof g))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof w=="string"&&T===void 0&&(T=w,w=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,T),this.word=l,this.msb=!!w,this.fields=[];let D=0;this._packedSetValue=function(W){return D=c(W),this},this._packedGetValue=function(){return D}}decode(l,w=0){const T=this.makeDestinationObject(),D=this.word.decode(l,w);this._packedSetValue(D);for(const W of this.fields)W.property!==void 0&&(T[W.property]=W.decode(l));return T}encode(l,w,T=0){const D=this.word.decode(w,T);this._packedSetValue(D);for(const W of this.fields)if(W.property!==void 0){const re=l[W.property];re!==void 0&&W.encode(re)}return this.word.encode(this._packedGetValue(),w,T)}addField(l,w){const T=new y(this,l,w);return this.fields.push(T),T}addBoolean(l){const w=new A(this,l);return this.fields.push(w),w}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const w of this.fields)if(w.property===l)return w}}H.BitStructure=p;class y{constructor(l,w,T){if(!(l instanceof p))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(w)||0>=w)throw new TypeError("bits must be positive integer");const D=8*l.span,W=l.fields.reduce((re,oe)=>re+oe.bits,0);if(w+W>D)throw new Error("bits too long for span remainder ("+(D-W)+" of "+D+" remain)");this.container=l,this.bits=w,this.valueMask=(1<<w)-1,w===32&&(this.valueMask=4294967295),this.start=W,this.container.msb&&(this.start=D-W-w),this.wordMask=c(this.valueMask<<this.start),this.property=T}decode(l,w){const T=this.container._packedGetValue();return c(T&this.wordMask)>>>this.start}encode(l){if(typeof l!="number"||!Number.isInteger(l)||l!==c(l&this.valueMask))throw new TypeError(s("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const w=this.container._packedGetValue(),T=c(l<<this.start);this.container._packedSetValue(c(w&~this.wordMask)|T)}}H.BitField=y;class A extends y{constructor(l,w){super(l,1,w)}decode(l,w){return!!super.decode(l,w)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}H.Boolean=A;class v extends r{constructor(l,w){if(!(l instanceof o&&l.isCount()||Number.isInteger(l)&&0<=l))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let T=-1;l instanceof o||(T=l),super(T,w),this.length=l}getSpan(l,w){let T=this.span;return 0>T&&(T=this.length.decode(l,w)),T}decode(l,w=0){let T=this.span;return 0>T&&(T=this.length.decode(l,w)),n(l).slice(w,w+T)}encode(l,w,T){let D=this.length;if(this.length instanceof o&&(D=l.length),!(l instanceof Uint8Array&&D===l.length))throw new TypeError(s("Blob.encode",this)+" requires (length "+D+") Uint8Array as src");if(T+D>w.length)throw new RangeError("encoding overruns Uint8Array");const W=n(l);return n(w).write(W.toString("hex"),T,D,"hex"),this.length instanceof o&&this.length.encode(D,w,T),D}}H.Blob=v;class R extends r{constructor(l){super(-1,l)}getSpan(l,w=0){e(l);let T=w;for(;T<l.length&&l[T]!==0;)T+=1;return 1+T-w}decode(l,w=0){const T=this.getSpan(l,w);return n(l).slice(w,w+T-1).toString("utf-8")}encode(l,w,T=0){typeof l!="string"&&(l=String(l));const D=t.Buffer.from(l,"utf8"),W=D.length;if(T+W>w.length)throw new RangeError("encoding overruns Buffer");const re=n(w);return D.copy(re,T),re[T+W]=0,W+1}}H.CString=R;class I extends r{constructor(l,w){if(typeof l=="string"&&w===void 0&&(w=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,w),this.maxSpan=l}getSpan(l,w=0){return e(l),l.length-w}decode(l,w=0){const T=this.getSpan(l,w);if(0<=this.maxSpan&&this.maxSpan<T)throw new RangeError("text length exceeds maxSpan");return n(l).slice(w,w+T).toString("utf-8")}encode(l,w,T=0){typeof l!="string"&&(l=String(l));const D=t.Buffer.from(l,"utf8"),W=D.length;if(0<=this.maxSpan&&this.maxSpan<W)throw new RangeError("text length exceeds maxSpan");if(T+W>w.length)throw new RangeError("encoding overruns Buffer");return D.copy(n(w),T),W}}H.UTF8=I;class _ extends r{constructor(l,w){super(0,w),this.value=l}decode(l,w){return this.value}encode(l,w,T){return 0}}return H.Constant=_,H.greedy=((u,l)=>new a(u,l)),H.offset=((u,l,w)=>new d(u,l,w)),H.u8=(u=>new m(1,u)),H.u16=(u=>new m(2,u)),H.u24=(u=>new m(3,u)),H.u32=(u=>new m(4,u)),H.u40=(u=>new m(5,u)),H.u48=(u=>new m(6,u)),H.nu64=(u=>new k(u)),H.u16be=(u=>new g(2,u)),H.u24be=(u=>new g(3,u)),H.u32be=(u=>new g(4,u)),H.u40be=(u=>new g(5,u)),H.u48be=(u=>new g(6,u)),H.nu64be=(u=>new K(u)),H.s8=(u=>new x(1,u)),H.s16=(u=>new x(2,u)),H.s24=(u=>new x(3,u)),H.s32=(u=>new x(4,u)),H.s40=(u=>new x(5,u)),H.s48=(u=>new x(6,u)),H.ns64=(u=>new Y(u)),H.s16be=(u=>new O(2,u)),H.s24be=(u=>new O(3,u)),H.s32be=(u=>new O(4,u)),H.s40be=(u=>new O(5,u)),H.s48be=(u=>new O(6,u)),H.ns64be=(u=>new V(u)),H.f32=(u=>new L(u)),H.f32be=(u=>new z(u)),H.f64=(u=>new J(u)),H.f64be=(u=>new te(u)),H.struct=((u,l,w)=>new q(u,l,w)),H.bits=((u,l,w)=>new p(u,l,w)),H.seq=((u,l,w)=>new ne(u,l,w)),H.union=((u,l,w)=>new j(u,l,w)),H.unionLayoutDiscriminator=((u,l)=>new P(u,l)),H.blob=((u,l)=>new v(u,l)),H.cstr=(u=>new R(u)),H.utf8=((u,l)=>new I(u,l)),H.constant=((u,l)=>new _(u,l)),H}var M=y_(),b_=1,__=2,w_=3,E_=4,v_=5,R_=6,A_=7,x_=8,S_=9,T_=10,O_=-32700,I_=-32603,N_=-32602,C_=-32601,M_=-32600,B_=-32016,k_=-32015,L_=-32014,P_=-32013,U_=-32012,D_=-32011,F_=-32010,$_=-32009,z_=-32008,j_=-32007,V_=-32006,G_=-32005,H_=-32004,q_=-32003,K_=-32002,W_=-32001,Z_=28e5,Y_=2800001,J_=2800002,X_=2800003,Q_=2800004,ew=2800005,tw=2800006,nw=2800007,rw=2800008,sw=2800009,iw=2800010,ow=2800011,aw=323e4,cw=32300001,uw=3230002,dw=3230003,lw=3230004,fw=361e4,hw=3610001,pw=3610002,mw=3610003,gw=3610004,yw=3610005,bw=3610006,_w=3610007,ww=3611e3,Ew=3704e3,vw=3704001,Rw=3704002,Aw=3704003,xw=3704004,Sw=4128e3,Tw=4128001,Ow=4128002,Iw=4615e3,Nw=4615001,Cw=4615002,Mw=4615003,Bw=4615004,kw=4615005,Lw=4615006,Pw=4615007,Uw=4615008,Dw=4615009,Fw=4615010,$w=4615011,zw=4615012,jw=4615013,Vw=4615014,Gw=4615015,Hw=4615016,qw=4615017,Kw=4615018,Ww=4615019,Zw=4615020,Yw=4615021,Jw=4615022,Xw=4615023,Qw=4615024,eE=4615025,tE=4615026,nE=4615027,rE=4615028,sE=4615029,iE=4615030,oE=4615031,aE=4615032,cE=4615033,uE=4615034,dE=4615035,lE=4615036,fE=4615037,hE=4615038,pE=4615039,mE=4615040,gE=4615041,yE=4615042,bE=4615043,_E=4615044,wE=4615045,EE=4615046,vE=4615047,RE=4615048,AE=4615049,xE=4615050,SE=4615051,TE=4615052,OE=4615053,IE=4615054,NE=5508e3,CE=5508001,ME=5508002,BE=5508003,kE=5508004,LE=5508005,PE=5508006,UE=5508007,DE=5508008,FE=5508009,$E=5508010,zE=5508011,jE=5663e3,VE=5663001,GE=5663002,HE=5663003,qE=5663004,KE=5663005,WE=5663006,ZE=5663007,YE=5663008,JE=5663009,XE=5663010,QE=5663011,ev=5663012,tv=5663013,nv=5663014,rv=5663015,sv=5663016,iv=5663017,ov=5663018,av=5663019,cv=5663020,uv=705e4,dv=7050001,lv=7050002,fv=7050003,hv=7050004,pv=7050005,mv=7050006,gv=7050007,yv=7050008,bv=7050009,_v=7050010,wv=7050011,Ev=7050012,vv=7050013,Rv=7050014,Av=7050015,xv=7050016,Sv=7050017,Tv=7050018,Ov=7050019,Iv=7050020,Nv=7050021,Cv=7050022,Mv=7050023,Bv=7050024,kv=7050025,Lv=7050026,Pv=7050027,Uv=7050028,Dv=7050029,Fv=7050030,$v=7050031,zv=7050032,jv=7050033,Vv=7050034,Gv=7050035,Hv=7050036,Cf=8078e3,Mf=8078001,qv=8078002,Kv=8078003,Bf=8078004,kf=8078005,Lf=8078006,Wv=8078007,Zv=8078008,Yv=8078009,Jv=8078010,Pf=8078011,Xv=8078012,Qv=8078013,eR=8078014,tR=8078015,nR=8078016,rR=8078017,sR=8078018,iR=8078019,oR=8078020,aR=8078021,cR=8078022,uR=81e5,dR=8100001,lR=8100002,fR=8100003,hR=819e4,pR=8190001,mR=8190002,gR=8190003,yR=8190004,bR=99e5,_R=9900001,wR=9900002,ER=9900003,vR=9900004;function Uf(t){return Array.isArray(t)?"%5B"+t.map(Uf).join("%2C%20")+"%5D":typeof t=="bigint"?`${t}n`:encodeURIComponent(String(t!=null&&Object.getPrototypeOf(t)===null?{...t}:t))}function RR([t,e]){return`${t}=${Uf(e)}`}function AR(t){const e=Object.entries(t).map(RR).join("&");return btoa(e)}var xR={[aw]:"Account not found at address: $address",[lw]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[dw]:"Expected decoded account at address: $address",[uw]:"Failed to decode account data at address: $address",[cw]:"Accounts not found at addresses: $addresses",[sw]:"Unable to find a viable program address bump seed.",[J_]:"$putativeAddress is not a base58-encoded address.",[Z_]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[X_]:"The `CryptoKey` must be an `Ed25519` public key.",[ow]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[rw]:"Invalid seeds; point must fall off the Ed25519 curve.",[Q_]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[tw]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[nw]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[ew]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[iw]:"Program address cannot end with PDA marker.",[Y_]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[E_]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[b_]:"The network has progressed past the last block for which this transaction could have been committed.",[Cf]:"Codec [$codecDescription] cannot decode empty byte arrays.",[cR]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[oR]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[kf]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Lf]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[Bf]:"Encoder and decoder must either both be fixed-size or variable-size.",[Zv]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[qv]:"Expected a fixed-size codec, got a variable-size one.",[Qv]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Kv]:"Expected a variable-size codec, got a fixed-size one.",[iR]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Mf]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[sR]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Yv]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Jv]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[tR]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Wv]:"Expected [$codecDescription] to have $expected items, got $actual.",[Xv]:"Invalid value $value for base $base with alphabet $alphabet.",[nR]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Pf]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[eR]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[aR]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[rR]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[ww]:"No random values implementation could be found.",[Dw]:"instruction requires an uninitialized account",[Xw]:"instruction tries to borrow reference for an account which is already borrowed",[Qw]:"instruction left account with an outstanding borrowed reference",[Yw]:"program other than the account's owner changed the size of the account data",[kw]:"account data too small for instruction",[Jw]:"instruction expected an executable account",[EE]:"An account does not have enough lamports to be rent-exempt",[RE]:"Program arithmetic overflowed",[wE]:"Failed to serialize or deserialize account data: $encodedData",[IE]:"Builtin programs must consume compute units",[aE]:"Cross-program invocation call depth too deep",[hE]:"Computational budget exceeded",[tE]:"custom program error: #$code",[qw]:"instruction contains duplicate accounts",[eE]:"instruction modifications of multiply-passed account differ",[iE]:"executable accounts must be rent exempt",[rE]:"instruction changed executable accounts data",[sE]:"instruction changed the balance of an executable account",[Kw]:"instruction changed executable bit of an account",[Vw]:"instruction modified data of an account it does not own",[jw]:"instruction spent from the balance of an account it does not own",[Nw]:"generic instruction error",[xE]:"Provided owner is not allowed",[bE]:"Account is immutable",[_E]:"Incorrect authority provided",[Pw]:"incorrect program id for instruction",[Lw]:"insufficient funds for instruction",[Bw]:"invalid account data for instruction",[vE]:"Invalid account owner",[Cw]:"invalid program argument",[nE]:"program returned invalid error code",[Mw]:"invalid instruction data",[fE]:"Failed to reallocate account data",[lE]:"Provided seeds do not result in a valid address",[SE]:"Accounts data allocations exceeded the maximum allowed per transaction",[TE]:"Max accounts exceeded",[OE]:"Max instruction trace length exceeded",[dE]:"Length of the seed is too long for address generation",[cE]:"An account required by the instruction is missing",[Uw]:"missing required signature for instruction",[zw]:"instruction illegally modified the program id of an account",[Zw]:"insufficient account keys for instruction",[pE]:"Cross-program invocation with unauthorized signer or writable account",[mE]:"Failed to create program execution environment",[yE]:"Program failed to compile",[gE]:"Program failed to complete",[Hw]:"instruction modified data of a read-only account",[Gw]:"instruction changed the balance of a read-only account",[uE]:"Cross-program invocation reentrancy not allowed for this instruction",[Ww]:"instruction modified rent epoch of an account",[$w]:"sum of account balances before and after instruction do not match",[Fw]:"instruction requires an initialized account",[Iw]:"",[oE]:"Unsupported program id",[AE]:"Unsupported sysvar",[Sw]:"The instruction does not have any accounts.",[Tw]:"The instruction does not have any data.",[Ow]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[v_]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[__]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[wR]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[vR]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[_R]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[bR]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[ER]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[I_]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[N_]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[M_]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[C_]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[O_]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[U_]:"$__serverMessage",[W_]:"$__serverMessage",[H_]:"$__serverMessage",[L_]:"$__serverMessage",[F_]:"$__serverMessage",[$_]:"$__serverMessage",[B_]:"Minimum context slot has not been reached",[G_]:"Node is unhealthy; behind by $numSlotsBehind slots",[z_]:"No snapshot",[K_]:"Transaction simulation failed",[j_]:"$__serverMessage",[D_]:"Transaction history is not available from this node",[V_]:"$__serverMessage",[P_]:"Transaction signature length mismatch",[q_]:"Transaction signature verification failure",[k_]:"$__serverMessage",[Ew]:"Key pair bytes must be of length 64, got $byteLength.",[vw]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Rw]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[xw]:"The provided private key does not match the provided public key.",[Aw]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[R_]:"Lamports value must be in the range [0, 2e64-1]",[A_]:"`$value` cannot be parsed as a `BigInt`",[T_]:"$message",[x_]:"`$value` cannot be parsed as a `Number`",[w_]:"No nonce account could be found at address `$nonceAccountAddress`",[hR]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[mR]:"WebSocket was closed before payload could be added to the send buffer",[gR]:"WebSocket connection closed",[yR]:"WebSocket failed to connect",[pR]:"Failed to obtain a subscription id from the server",[fR]:"Could not find an API plan for RPC method: `$method`",[uR]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[lR]:"HTTP error ($statusCode): $message",[dR]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[NE]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[CE]:"The provided value does not implement the `KeyPairSigner` interface",[BE]:"The provided value does not implement the `MessageModifyingSigner` interface",[kE]:"The provided value does not implement the `MessagePartialSigner` interface",[ME]:"The provided value does not implement any of the `MessageSigner` interfaces",[PE]:"The provided value does not implement the `TransactionModifyingSigner` interface",[UE]:"The provided value does not implement the `TransactionPartialSigner` interface",[DE]:"The provided value does not implement the `TransactionSendingSigner` interface",[LE]:"The provided value does not implement any of the `TransactionSigner` interfaces",[FE]:"More than one `TransactionSendingSigner` was identified.",[$E]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[zE]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[_w]:"Cannot export a non-extractable key.",[hw]:"No digest implementation could be found.",[fw]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[pw]:`This runtime does not support the generation of Ed25519 key pairs.
29
29
 
30
30
  Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
31
31
 
32
- For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[wE]:"No signature verification implementation could be found.",[vE]:"No key generation implementation could be found.",[RE]:"No signing implementation could be found.",[AE]:"No key export implementation could be found.",[M_]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Cv]:"Transaction processing left an account with an outstanding borrowed reference",[gv]:"Account in use",[yv]:"Account loaded twice",[bv]:"Attempt to debit an account but found no record of a prior credit.",[Pv]:"Transaction loads an address table account that doesn't exist",[vv]:"This transaction has already been processed",[Rv]:"Blockhash not found",[Av]:"Loader call chain is too deep",[Nv]:"Transactions are currently disabled due to cluster maintenance",[Gv]:"Transaction contains a duplicate instruction ($index) that is not allowed",[Ev]:"Insufficient funds for fee",[qv]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[wv]:"This account may not be used to pay transaction fees",[xv]:"Transaction contains an invalid account reference",[$v]:"Transaction loads an address table account with invalid data",[zv]:"Transaction address table lookup uses an invalid index",[Fv]:"Transaction loads an address table account with an invalid owner",[Wv]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Iv]:"This program may not be used for executing instructions",[jv]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Bv]:"Transaction loads a writable account that cannot be written",[Kv]:"Transaction exceeded max loaded accounts data size cap",[Sv]:"Transaction requires a fee but has no signature present",[_v]:"Attempt to load a program that does not exist",[Yv]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Zv]:"ResanitizationNeeded",[Ov]:"Transaction failed to sanitize accounts offsets correctly",[Tv]:"Transaction did not pass signature verification",[Dv]:"Transaction locked too many accounts",[Jv]:"Sum of account balances before and after transaction do not match",[mv]:"The transaction failed with the error `$errorName`",[kv]:"Transaction version is unsupported",[Lv]:"Transaction would exceed account data limit within the block",[Hv]:"Transaction would exceed total account data limit",[Uv]:"Transaction would exceed max account limit within the block",[Mv]:"Transaction would exceed max Block Cost Limit",[Vv]:"Transaction would exceed max Vote Cost Limit",[uv]:"Attempted to sign a transaction with an address that is not a signer for it",[sv]:"Transaction is missing an address at index: $index.",[dv]:"Transaction has no expected signers therefore it cannot be encoded",[pv]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[Yw]:"Transaction does not have a blockhash lifetime",[Jw]:"Transaction is not a durable nonce transaction",[Qw]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[ev]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[nv]:"No fee payer set in CompiledTransaction",[tv]:"Could not find program address at index $index",[fv]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[hv]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[iv]:"Transaction is missing a fee payer.",[ov]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[cv]:"Transaction first instruction is not advance nonce account instruction.",[av]:"Transaction with no instructions cannot be durable nonce transaction.",[Ww]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Zw]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[lv]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[rv]:"Transaction is missing signatures for addresses: $addresses.",[Xw]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},On="i",hn="t";function MR(t,e={}){const n=CR[t];if(n.length===0)return"";let r;function s(o){if(r[hn]===2){const a=n.slice(r[On]+1,o);i.push(a in e?`${e[a]}`:`$${a}`)}else r[hn]===1&&i.push(n.slice(r[On],o))}const i=[];return n.split("").forEach((o,a)=>{if(a===0){r={[On]:0,[hn]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let d;switch(r[hn]){case 0:d={[On]:a,[hn]:1};break;case 1:o==="\\"?d={[On]:a,[hn]:0}:o==="$"&&(d={[On]:a,[hn]:2});break;case 2:o==="\\"?d={[On]:a,[hn]:0}:o==="$"?d={[On]:a,[hn]:2}:o.match(/\w/)||(d={[On]:a,[hn]:1});break}d&&(r!==d&&s(a),r=d)}),s(),i.join("")}function kR(t,e={}){if(process.env.NODE_ENV!=="production")return MR(t,e);{let n=`Solana error #${t}; Decode this error by running \`npx @solana/errors decode -- ${t}`;return Object.keys(e).length&&(n+=` '${NR(e)}'`),`${n}\``}}var Fr=class extends Error{cause=this.cause;context;constructor(...[t,e]){let n,r;if(e){const{cause:i,...o}=e;i&&(r={cause:i}),Object.keys(o).length>0&&(n=o)}const s=kR(t,n);super(s,r),this.context={__code:t,...n},this.name="SolanaError"}};function BR(t,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(t)}function UR(t){return Object.freeze({...t,encode:e=>{const n=new Uint8Array(BR(e,t));return t.write(e,n,0),n}})}function LR(t){return Object.freeze({...t,decode:(e,n=0)=>t.read(e,n)[0]})}function $r(t){return"fixedSize"in t&&typeof t.fixedSize=="number"}function DR(t,e){if($r(t)!==$r(e))throw new Fr(Df);if($r(t)&&$r(e)&&t.fixedSize!==e.fixedSize)throw new Fr(Pf,{decoderFixedSize:e.fixedSize,encoderFixedSize:t.fixedSize});if(!$r(t)&&!$r(e)&&t.maxSize!==e.maxSize)throw new Fr(Ff,{decoderMaxSize:e.maxSize,encoderMaxSize:t.maxSize});return{...e,...t,decode:e.decode,encode:t.encode,read:e.read,write:t.write}}function PR(t,e,n=0){if(e.length-n<=0)throw new Fr(Uf,{codecDescription:t})}function FR(t,e,n,r=0){const s=n.length-r;if(s<e)throw new Fr(Lf,{bytesLength:s,codecDescription:t,expected:e})}function $R(t,e,n,r){if(r<e||r>n)throw new Fr($f,{codecDescription:t,max:n,min:e,value:r})}function jf(t){return t?.endian!==1}function zR(t){return UR({fixedSize:t.size,write(e,n,r){t.range&&$R(t.name,t.range[0],t.range[1],e);const s=new ArrayBuffer(t.size);return t.set(new DataView(s),e,jf(t.config)),n.set(new Uint8Array(s),r),r+t.size}})}function jR(t){return LR({fixedSize:t.size,read(e,n=0){PR(t.name,e,n),FR(t.name,t.size,e,n);const r=new DataView(VR(e,n,t.size));return[t.get(r,jf(t.config)),n+t.size]}})}function VR(t,e,n){const r=t.byteOffset+(e??0),s=n??t.byteLength;return t.buffer.slice(r,r+s)}var HR=(t={})=>zR({config:t,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,n,r)=>e.setBigUint64(0,BigInt(n),r),size:8}),GR=(t={})=>jR({config:t,get:(e,n)=>e.getBigUint64(0,n),name:"u64",size:8}),qR=(t={})=>DR(HR(t),GR(t));class KR extends TypeError{constructor(e,n){let r;const{message:s,explanation:i,...o}=e,{path:a}=e,d=a.length===0?s:`At path: ${a.join(".")} -- ${s}`;super(i??d),i!=null&&(this.cause=d),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...n()])}}function WR(t){return Ls(t)&&typeof t[Symbol.iterator]=="function"}function Ls(t){return typeof t=="object"&&t!=null}function Wi(t){return Ls(t)&&!Array.isArray(t)}function on(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function ZR(t){const{done:e,value:n}=t.next();return e?void 0:n}function YR(t,e,n,r){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:s,branch:i}=e,{type:o}=n,{refinement:a,message:d=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${on(r)}\``}=t;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...t,message:d}}function*Vf(t,e,n,r){WR(t)||(t=[t]);for(const s of t){const i=YR(s,e,n,r);i&&(yield i)}}function*_c(t,e,n={}){const{path:r=[],branch:s=[t],coerce:i=!1,mask:o=!1}=n,a={path:r,branch:s,mask:o};i&&(t=e.coercer(t,a));let d="valid";for(const m of e.validator(t,a))m.explanation=n.message,d="not_valid",yield[m,void 0];for(let[m,g,S]of e.entries(t,a)){const I=_c(g,S,{path:m===void 0?r:[...r,m],branch:m===void 0?s:[...s,g],coerce:i,mask:o,message:n.message});for(const N of I)N[0]?(d=N[0].refinement!=null?"not_refined":"not_valid",yield[N[0],void 0]):i&&(g=N[1],m===void 0?t=g:t instanceof Map?t.set(m,g):t instanceof Set?t.add(g):Ls(t)&&(g!==void 0||m in t)&&(t[m]=g))}if(d!=="not_valid")for(const m of e.refiner(t,a))m.explanation=n.message,d="not_refined",yield[m,void 0];d==="valid"&&(yield[void 0,t])}let pn=class{constructor(e){const{type:n,schema:r,validator:s,refiner:i,coercer:o=d=>d,entries:a=function*(){}}=e;this.type=n,this.schema=r,this.entries=a,this.coercer=o,s?this.validator=(d,m)=>{const g=s(d,m);return Vf(g,m,this,d)}:this.validator=()=>[],i?this.refiner=(d,m)=>{const g=i(d,m);return Vf(g,m,this,d)}:this.refiner=()=>[]}assert(e,n){return JR(e,this,n)}create(e,n){return Ds(e,this,n)}is(e){return Hf(e,this)}mask(e,n){return XR(e,this,n)}validate(e,n={}){return Ps(e,this,n)}};function JR(t,e,n){const r=Ps(t,e,{message:n});if(r[0])throw r[0]}function Ds(t,e,n){const r=Ps(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function XR(t,e,n){const r=Ps(t,e,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function Hf(t,e){return!Ps(t,e)[0]}function Ps(t,e,n={}){const r=_c(t,e,n),s=ZR(r);return s[0]?[new KR(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function fr(t,e){return new pn({type:t,schema:null,validator:e})}function QR(){return fr("any",()=>!0)}function ce(t){return new pn({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[n,r]of e.entries())yield[n,r,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${on(e)}`}})}function mn(){return fr("boolean",t=>typeof t=="boolean")}function Ec(t){return fr("instance",e=>e instanceof t||`Expected a \`${t.name}\` instance, but received: ${on(e)}`)}function qe(t){const e=on(t),n=typeof t;return new pn({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?t:null,validator(r){return r===t||`Expected the literal \`${e}\`, but received: ${on(r)}`}})}function eA(){return fr("never",()=>!1)}function ue(t){return new pn({...t,validator:(e,n)=>e===null||t.validator(e,n),refiner:(e,n)=>e===null||t.refiner(e,n)})}function H(){return fr("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${on(t)}`)}function he(t){return new pn({...t,validator:(e,n)=>e===void 0||t.validator(e,n),refiner:(e,n)=>e===void 0||t.refiner(e,n)})}function Gf(t,e){return new pn({type:"record",schema:null,*entries(n){if(Ls(n))for(const r in n){const s=n[r];yield[r,r,t],yield[r,s,e]}},validator(n){return Wi(n)||`Expected an object, but received: ${on(n)}`},coercer(n){return Wi(n)?{...n}:n}})}function ie(){return fr("string",t=>typeof t=="string"||`Expected a string, but received: ${on(t)}`)}function wc(t){const e=eA();return new pn({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){const r=Math.max(t.length,n.length);for(let s=0;s<r;s++)yield[s,n[s],t[s]||e]}},validator(n){return Array.isArray(n)||`Expected an array, but received: ${on(n)}`},coercer(n){return Array.isArray(n)?n.slice():n}})}function ee(t){const e=Object.keys(t);return new pn({type:"type",schema:t,*entries(n){if(Ls(n))for(const r of e)yield[r,n[r],t[r]]},validator(n){return Wi(n)||`Expected an object, but received: ${on(n)}`},coercer(n){return Wi(n)?{...n}:n}})}function jt(t){const e=t.map(n=>n.type).join(" | ");return new pn({type:"union",schema:null,coercer(n,r){for(const s of t){const[i,o]=s.validate(n,{coerce:!0,mask:r.mask});if(!i)return o}return n},validator(n,r){const s=[];for(const i of t){const[...o]=_c(n,i,r),[a]=o;if(a[0])for(const[d]of o)d&&s.push(d);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${on(n)}`,...s]}})}function zr(){return fr("unknown",()=>!0)}function Fs(t,e,n){return new pn({...t,coercer:(r,s)=>Hf(r,e)?t.coercer(n(r,s),s):t.coercer(r,s)})}var Zi,tA=new Uint8Array(16);function qf(){if(!Zi&&(Zi=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Zi))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Zi(tA)}const nA=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Yi(t){return typeof t=="string"&&nA.test(t)}for(var xt=[],vc=0;vc<256;++vc)xt.push((vc+256).toString(16).substr(1));function Ji(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(xt[t[e+0]]+xt[t[e+1]]+xt[t[e+2]]+xt[t[e+3]]+"-"+xt[t[e+4]]+xt[t[e+5]]+"-"+xt[t[e+6]]+xt[t[e+7]]+"-"+xt[t[e+8]]+xt[t[e+9]]+"-"+xt[t[e+10]]+xt[t[e+11]]+xt[t[e+12]]+xt[t[e+13]]+xt[t[e+14]]+xt[t[e+15]]).toLowerCase();if(!Yi(n))throw TypeError("Stringified UUID is invalid");return n}var Kf,Rc,Ac=0,Sc=0;function rA(t,e,n){var r=e&&n||0,s=e||new Array(16);t=t||{};var i=t.node||Kf,o=t.clockseq!==void 0?t.clockseq:Rc;if(i==null||o==null){var a=t.random||(t.rng||qf)();i==null&&(i=Kf=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=Rc=(a[6]<<8|a[7])&16383)}var d=t.msecs!==void 0?t.msecs:Date.now(),m=t.nsecs!==void 0?t.nsecs:Sc+1,g=d-Ac+(m-Sc)/1e4;if(g<0&&t.clockseq===void 0&&(o=o+1&16383),(g<0||d>Ac)&&t.nsecs===void 0&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ac=d,Sc=m,Rc=o,d+=122192928e5;var S=((d&268435455)*1e4+m)%4294967296;s[r++]=S>>>24&255,s[r++]=S>>>16&255,s[r++]=S>>>8&255,s[r++]=S&255;var I=d/4294967296*1e4&268435455;s[r++]=I>>>8&255,s[r++]=I&255,s[r++]=I>>>24&15|16,s[r++]=I>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var N=0;N<6;++N)s[r+N]=i[N];return e||Ji(s)}function Wf(t){if(!Yi(t))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(t.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=e&255,n[4]=(e=parseInt(t.slice(9,13),16))>>>8,n[5]=e&255,n[6]=(e=parseInt(t.slice(14,18),16))>>>8,n[7]=e&255,n[8]=(e=parseInt(t.slice(19,23),16))>>>8,n[9]=e&255,n[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=e&255,n}function sA(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}var iA="6ba7b810-9dad-11d1-80b4-00c04fd430c8",oA="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Zf(t,e,n){function r(s,i,o,a){if(typeof s=="string"&&(s=sA(s)),typeof i=="string"&&(i=Wf(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var d=new Uint8Array(16+s.length);if(d.set(i),d.set(s,i.length),d=n(d),d[6]=d[6]&15|e,d[8]=d[8]&63|128,o){a=a||0;for(var m=0;m<16;++m)o[a+m]=d[m];return o}return Ji(d)}try{r.name=t}catch{}return r.DNS=iA,r.URL=oA,r}function aA(t){if(typeof t=="string"){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)}return cA(uA(dA(t),t.length*8))}function cA(t){for(var e=[],n=t.length*32,r="0123456789abcdef",s=0;s<n;s+=8){var i=t[s>>5]>>>s%32&255,o=parseInt(r.charAt(i>>>4&15)+r.charAt(i&15),16);e.push(o)}return e}function Yf(t){return(t+64>>>9<<4)+14+1}function uA(t,e){t[e>>5]|=128<<e%32,t[Yf(e)-1]=e;for(var n=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<t.length;o+=16){var a=n,d=r,m=s,g=i;n=Mt(n,r,s,i,t[o],7,-680876936),i=Mt(i,n,r,s,t[o+1],12,-389564586),s=Mt(s,i,n,r,t[o+2],17,606105819),r=Mt(r,s,i,n,t[o+3],22,-1044525330),n=Mt(n,r,s,i,t[o+4],7,-176418897),i=Mt(i,n,r,s,t[o+5],12,1200080426),s=Mt(s,i,n,r,t[o+6],17,-1473231341),r=Mt(r,s,i,n,t[o+7],22,-45705983),n=Mt(n,r,s,i,t[o+8],7,1770035416),i=Mt(i,n,r,s,t[o+9],12,-1958414417),s=Mt(s,i,n,r,t[o+10],17,-42063),r=Mt(r,s,i,n,t[o+11],22,-1990404162),n=Mt(n,r,s,i,t[o+12],7,1804603682),i=Mt(i,n,r,s,t[o+13],12,-40341101),s=Mt(s,i,n,r,t[o+14],17,-1502002290),r=Mt(r,s,i,n,t[o+15],22,1236535329),n=kt(n,r,s,i,t[o+1],5,-165796510),i=kt(i,n,r,s,t[o+6],9,-1069501632),s=kt(s,i,n,r,t[o+11],14,643717713),r=kt(r,s,i,n,t[o],20,-373897302),n=kt(n,r,s,i,t[o+5],5,-701558691),i=kt(i,n,r,s,t[o+10],9,38016083),s=kt(s,i,n,r,t[o+15],14,-660478335),r=kt(r,s,i,n,t[o+4],20,-405537848),n=kt(n,r,s,i,t[o+9],5,568446438),i=kt(i,n,r,s,t[o+14],9,-1019803690),s=kt(s,i,n,r,t[o+3],14,-187363961),r=kt(r,s,i,n,t[o+8],20,1163531501),n=kt(n,r,s,i,t[o+13],5,-1444681467),i=kt(i,n,r,s,t[o+2],9,-51403784),s=kt(s,i,n,r,t[o+7],14,1735328473),r=kt(r,s,i,n,t[o+12],20,-1926607734),n=Bt(n,r,s,i,t[o+5],4,-378558),i=Bt(i,n,r,s,t[o+8],11,-2022574463),s=Bt(s,i,n,r,t[o+11],16,1839030562),r=Bt(r,s,i,n,t[o+14],23,-35309556),n=Bt(n,r,s,i,t[o+1],4,-1530992060),i=Bt(i,n,r,s,t[o+4],11,1272893353),s=Bt(s,i,n,r,t[o+7],16,-155497632),r=Bt(r,s,i,n,t[o+10],23,-1094730640),n=Bt(n,r,s,i,t[o+13],4,681279174),i=Bt(i,n,r,s,t[o],11,-358537222),s=Bt(s,i,n,r,t[o+3],16,-722521979),r=Bt(r,s,i,n,t[o+6],23,76029189),n=Bt(n,r,s,i,t[o+9],4,-640364487),i=Bt(i,n,r,s,t[o+12],11,-421815835),s=Bt(s,i,n,r,t[o+15],16,530742520),r=Bt(r,s,i,n,t[o+2],23,-995338651),n=Ut(n,r,s,i,t[o],6,-198630844),i=Ut(i,n,r,s,t[o+7],10,1126891415),s=Ut(s,i,n,r,t[o+14],15,-1416354905),r=Ut(r,s,i,n,t[o+5],21,-57434055),n=Ut(n,r,s,i,t[o+12],6,1700485571),i=Ut(i,n,r,s,t[o+3],10,-1894986606),s=Ut(s,i,n,r,t[o+10],15,-1051523),r=Ut(r,s,i,n,t[o+1],21,-2054922799),n=Ut(n,r,s,i,t[o+8],6,1873313359),i=Ut(i,n,r,s,t[o+15],10,-30611744),s=Ut(s,i,n,r,t[o+6],15,-1560198380),r=Ut(r,s,i,n,t[o+13],21,1309151649),n=Ut(n,r,s,i,t[o+4],6,-145523070),i=Ut(i,n,r,s,t[o+11],10,-1120210379),s=Ut(s,i,n,r,t[o+2],15,718787259),r=Ut(r,s,i,n,t[o+9],21,-343485551),n=qn(n,a),r=qn(r,d),s=qn(s,m),i=qn(i,g)}return[n,r,s,i]}function dA(t){if(t.length===0)return[];for(var e=t.length*8,n=new Uint32Array(Yf(e)),r=0;r<e;r+=8)n[r>>5]|=(t[r/8]&255)<<r%32;return n}function qn(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function lA(t,e){return t<<e|t>>>32-e}function Xi(t,e,n,r,s,i){return qn(lA(qn(qn(e,t),qn(r,i)),s),n)}function Mt(t,e,n,r,s,i,o){return Xi(e&n|~e&r,t,e,s,i,o)}function kt(t,e,n,r,s,i,o){return Xi(e&r|n&~r,t,e,s,i,o)}function Bt(t,e,n,r,s,i,o){return Xi(e^n^r,t,e,s,i,o)}function Ut(t,e,n,r,s,i,o){return Xi(n^(e|~r),t,e,s,i,o)}var fA=Zf("v3",48,aA);function hA(t,e,n){t=t||{};var r=t.random||(t.rng||qf)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(var s=0;s<16;++s)e[n+s]=r[s];return e}return Ji(r)}function pA(t,e,n,r){switch(t){case 0:return e&n^~e&r;case 1:return e^n^r;case 2:return e&n^e&r^n&r;case 3:return e^n^r}}function xc(t,e){return t<<e|t>>>32-e}function mA(t){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var r=unescape(encodeURIComponent(t));t=[];for(var s=0;s<r.length;++s)t.push(r.charCodeAt(s))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var i=t.length/4+2,o=Math.ceil(i/16),a=new Array(o),d=0;d<o;++d){for(var m=new Uint32Array(16),g=0;g<16;++g)m[g]=t[d*64+g*4]<<24|t[d*64+g*4+1]<<16|t[d*64+g*4+2]<<8|t[d*64+g*4+3];a[d]=m}a[o-1][14]=(t.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(t.length-1)*8&4294967295;for(var S=0;S<o;++S){for(var I=new Uint32Array(80),N=0;N<16;++N)I[N]=a[S][N];for(var F=16;F<80;++F)I[F]=xc(I[F-3]^I[F-8]^I[F-14]^I[F-16],1);for(var M=n[0],B=n[1],K=n[2],Y=n[3],z=n[4],U=0;U<80;++U){var j=Math.floor(U/20),J=xc(M,5)+pA(j,B,K,Y)+z+e[j]+I[U]>>>0;z=Y,Y=K,K=xc(B,30)>>>0,B=M,M=J}n[0]=n[0]+M>>>0,n[1]=n[1]+B>>>0,n[2]=n[2]+K>>>0,n[3]=n[3]+Y>>>0,n[4]=n[4]+z>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var gA=Zf("v5",80,mA);const yA="00000000-0000-0000-0000-000000000000";function bA(t){if(!Yi(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}const Jf=Za(Object.freeze(Object.defineProperty({__proto__:null,NIL:yA,parse:Wf,stringify:Ji,v1:rA,v3:fA,v4:hA,v5:gA,validate:Yi,version:bA},Symbol.toStringTag,{value:"Module"})));var Tc,Xf;function _A(){if(Xf)return Tc;Xf=1;const t=Jf.v4;return Tc=function(n,r,s,i){if(typeof n!="string")throw new TypeError(n+" must be a string");i=i||{};const o=typeof i.version=="number"?i.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");const a={method:n};if(o===2&&(a.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");a.params=r}if(typeof s>"u"){const d=typeof i.generator=="function"?i.generator:function(){return t()};a.id=d(a,i)}else o===2&&s===null?i.notificationIdNull&&(a.id=null):a.id=s;return a},Tc}var Ic,Qf;function EA(){if(Qf)return Ic;Qf=1;const t=Jf.v4,e=_A(),n=function(r,s){if(!(this instanceof n))return new n(r,s);s||(s={}),this.options={reviver:typeof s.reviver<"u"?s.reviver:null,replacer:typeof s.replacer<"u"?s.replacer:null,generator:typeof s.generator<"u"?s.generator:function(){return t()},version:typeof s.version<"u"?s.version:2,notificationIdNull:typeof s.notificationIdNull=="boolean"?s.notificationIdNull:!1},this.callServer=r};return Ic=n,n.prototype.request=function(r,s,i,o){const a=this;let d=null;const m=Array.isArray(r)&&typeof s=="function";if(this.options.version===1&&m)throw new TypeError("JSON-RPC 1.0 does not support batching");if(m||!m&&r&&typeof r=="object"&&typeof s=="function")o=s,d=r;else{typeof i=="function"&&(o=i,i=void 0);const I=typeof o=="function";try{d=e(r,s,i,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(N){if(I){o(N);return}throw N}if(!I)return d}let S;try{S=JSON.stringify(d,this.options.replacer)}catch(I){o(I);return}return this.callServer(S,function(I,N){a._parseResponse(I,N,o)}),d},n.prototype._parseResponse=function(r,s,i){if(r){i(r);return}if(!s){i();return}let o;try{o=JSON.parse(s,this.options.reviver)}catch(a){i(a);return}if(i.length===3)if(Array.isArray(o)){const a=function(m){return typeof m.error<"u"},d=function(m){return!a(m)};i(null,o.filter(a),o.filter(d));return}else{i(null,o.error,o.result);return}i(null,o)},Ic}EA();function eh(t){try{return hc.ExtendedPoint.fromHex(t),!0}catch{return!1}}const th=(t,e)=>hc.sign(t,e.slice(0,32)),wA=hc.verify,Oc=t=>Te.Buffer.isBuffer(t)?t:t instanceof Uint8Array?Te.Buffer.from(t.buffer,t.byteOffset,t.byteLength):Te.Buffer.from(t);class vA{constructor(e){Object.assign(this,e)}encode(){return Te.Buffer.from(bc.serialize(Qi,this))}static decode(e){return bc.deserialize(Qi,this,e)}static decodeUnchecked(e){return bc.deserializeUnchecked(Qi,this,e)}}const Qi=new Map;var nh;const RA=32,Kn=32;function AA(t){return t._bn!==void 0}let rh=1;class be extends vA{constructor(e){if(super({}),this._bn=void 0,AA(e))this._bn=e._bn;else{if(typeof e=="string"){const n=zt.decode(e);if(n.length!=Kn)throw new Error("Invalid public key input");this._bn=new If(n)}else this._bn=new If(e);if(this._bn.byteLength()>Kn)throw new Error("Invalid public key input")}}static unique(){const e=new be(rh);return rh+=1,new be(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return zt.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(Te.Buffer);if(e.length===Kn)return e;const n=Te.Buffer.alloc(32);return e.copy(n,32-e.length),n}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,n,r){const s=Te.Buffer.concat([e.toBuffer(),Te.Buffer.from(n),r.toBuffer()]),i=xa(s);return new be(i)}static createProgramAddressSync(e,n){let r=Te.Buffer.alloc(0);e.forEach(function(i){if(i.length>RA)throw new TypeError("Max seed length exceeded");r=Te.Buffer.concat([r,Oc(i)])}),r=Te.Buffer.concat([r,n.toBuffer(),Te.Buffer.from("ProgramDerivedAddress")]);const s=xa(r);if(eh(s))throw new Error("Invalid seeds, address must fall off the curve");return new be(s)}static async createProgramAddress(e,n){return this.createProgramAddressSync(e,n)}static findProgramAddressSync(e,n){let r=255,s;for(;r!=0;){try{const i=e.concat(Te.Buffer.from([r]));s=this.createProgramAddressSync(i,n)}catch(i){if(i instanceof TypeError)throw i;r--;continue}return[s,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,n){return this.findProgramAddressSync(e,n)}static isOnCurve(e){const n=new be(e);return eh(n.toBytes())}}nh=be,be.default=new nh("11111111111111111111111111111111"),Qi.set(be,{kind:"struct",fields:[["_bn","u256"]]}),new be("BPFLoader1111111111111111111111111111111111");const jr=1232,Nc=127,eo=64;class to{constructor(e,n){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=n}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const n of this.keySegments()){if(e<n.length)return n[e];e-=n.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const r=new Map;this.keySegments().flat().forEach((i,o)=>{r.set(i.toBase58(),o)});const s=i=>{const o=r.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const Ie=(t="publicKey")=>k.blob(32,t),SA=(t="signature")=>k.blob(64,t),Vr=(t="string")=>{const e=k.struct([k.u32("length"),k.u32("lengthPadding"),k.blob(k.offset(k.u32(),-8),"chars")],t),n=e.decode.bind(e),r=e.encode.bind(e),s=e;return s.decode=(i,o)=>n(i,o).chars.toString(),s.encode=(i,o,a)=>{const d={chars:Te.Buffer.from(i,"utf8")};return r(d,o,a)},s.alloc=i=>k.u32().span+k.u32().span+Te.Buffer.from(i,"utf8").length,s},xA=(t="authorized")=>k.struct([Ie("staker"),Ie("withdrawer")],t),TA=(t="lockup")=>k.struct([k.ns64("unixTimestamp"),k.ns64("epoch"),Ie("custodian")],t),IA=(t="voteInit")=>k.struct([Ie("nodePubkey"),Ie("authorizedVoter"),Ie("authorizedWithdrawer"),k.u8("commission")],t),OA=(t="voteAuthorizeWithSeedArgs")=>k.struct([k.u32("voteAuthorizationType"),Ie("currentAuthorityDerivedKeyOwnerPubkey"),Vr("currentAuthorityDerivedKeySeed"),Ie("newAuthorized")],t);function Yt(t){let e=0,n=0;for(;;){let r=t.shift();if(e|=(r&127)<<n*7,n+=1,(r&128)===0)break}return e}function Jt(t,e){let n=e;for(;;){let r=n&127;if(n>>=7,n==0){t.push(r);break}else r|=128,t.push(r)}}function _t(t,e){if(!t)throw new Error(e||"Assertion failed")}class no{constructor(e,n){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=n}static compile(e,n){const r=new Map,s=o=>{const a=o.toBase58();let d=r.get(a);return d===void 0&&(d={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,d)),d},i=s(n);i.isSigner=!0,i.isWritable=!0;for(const o of e){s(o.programId).isInvoked=!0;for(const a of o.keys){const d=s(a.pubkey);d.isSigner||=a.isSigner,d.isWritable||=a.isWritable}}return new no(n,r)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];_t(e.length<=256,"Max static account keys length exceeded");const n=e.filter(([,d])=>d.isSigner&&d.isWritable),r=e.filter(([,d])=>d.isSigner&&!d.isWritable),s=e.filter(([,d])=>!d.isSigner&&d.isWritable),i=e.filter(([,d])=>!d.isSigner&&!d.isWritable),o={numRequiredSignatures:n.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{_t(n.length>0,"Expected at least one writable signer key");const[d]=n[0];_t(d===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...n.map(([d])=>new be(d)),...r.map(([d])=>new be(d)),...s.map(([d])=>new be(d)),...i.map(([d])=>new be(d))];return[o,a]}extractTableLookup(e){const[n,r]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(n.length===0&&s.length===0))return[{accountKey:e.key,writableIndexes:n,readonlyIndexes:s},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(e,n){const r=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(n(o)){const a=new be(i),d=e.findIndex(m=>m.equals(a));d>=0&&(_t(d<256,"Max lookup table index exceeded"),r.push(d),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const sh="Reached end of buffer unexpectedly";function Nn(t){if(t.length===0)throw new Error(sh);return t.shift()}function Xt(t,...e){const[n]=e;if(e.length===2?n+(e[1]??0)>t.length:n>=t.length)throw new Error(sh);return t.splice(...e)}class Hr{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(n=>new be(n)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(n=>this.indexToProgramIds.set(n.programIdIndex,this.accountKeys[n.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:zt.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new to(this.staticAccountKeys)}static compile(e){const n=no.compile(e.instructions,e.payerKey),[r,s]=n.getMessageComponents(),o=new to(s).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:zt.encode(a.data)}));return new Hr({header:r,accountKeys:s,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const n=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const r=e-n,i=this.accountKeys.length-n-this.header.numReadonlyUnsignedAccounts;return r<i}else{const r=n-this.header.numReadonlySignedAccounts;return e<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,n)=>!this.isProgramId(n))}serialize(){const e=this.accountKeys.length;let n=[];Jt(n,e);const r=this.instructions.map(S=>{const{accounts:I,programIdIndex:N}=S,F=Array.from(zt.decode(S.data));let M=[];Jt(M,I.length);let B=[];return Jt(B,F.length),{programIdIndex:N,keyIndicesCount:Te.Buffer.from(M),keyIndices:I,dataLength:Te.Buffer.from(B),data:F}});let s=[];Jt(s,r.length);let i=Te.Buffer.alloc(jr);Te.Buffer.from(s).copy(i);let o=s.length;r.forEach(S=>{const N=k.struct([k.u8("programIdIndex"),k.blob(S.keyIndicesCount.length,"keyIndicesCount"),k.seq(k.u8("keyIndex"),S.keyIndices.length,"keyIndices"),k.blob(S.dataLength.length,"dataLength"),k.seq(k.u8("userdatum"),S.data.length,"data")]).encode(S,i,o);o+=N}),i=i.slice(0,o);const a=k.struct([k.blob(1,"numRequiredSignatures"),k.blob(1,"numReadonlySignedAccounts"),k.blob(1,"numReadonlyUnsignedAccounts"),k.blob(n.length,"keyCount"),k.seq(Ie("key"),e,"keys"),Ie("recentBlockhash")]),d={numRequiredSignatures:Te.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Te.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Te.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Te.Buffer.from(n),keys:this.accountKeys.map(S=>Oc(S.toBytes())),recentBlockhash:zt.decode(this.recentBlockhash)};let m=Te.Buffer.alloc(2048);const g=a.encode(d,m);return i.copy(m,g),m.slice(0,g+i.length)}static from(e){let n=[...e];const r=Nn(n);if(r!==(r&Nc))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=Nn(n),i=Nn(n),o=Yt(n);let a=[];for(let I=0;I<o;I++){const N=Xt(n,0,Kn);a.push(new be(Te.Buffer.from(N)))}const d=Xt(n,0,Kn),m=Yt(n);let g=[];for(let I=0;I<m;I++){const N=Nn(n),F=Yt(n),M=Xt(n,0,F),B=Yt(n),K=Xt(n,0,B),Y=zt.encode(Te.Buffer.from(K));g.push({programIdIndex:N,accounts:M,data:Y})}const S={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:zt.encode(Te.Buffer.from(d)),accountKeys:a,instructions:g};return new Hr(S)}}class ro{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const n of this.addressTableLookups)e+=n.readonlyIndexes.length+n.writableIndexes.length;return e}getAccountKeys(e){let n;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");n=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)n=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new to(this.staticAccountKeys,n)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const n=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r){const s=e-r,i=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return s<i}else if(e>=this.header.numRequiredSignatures){const s=e-n,o=r-n-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=n-this.header.numReadonlySignedAccounts;return e<s}}resolveAddressTableLookups(e){const n={writable:[],readonly:[]};for(const r of this.addressTableLookups){const s=e.find(i=>i.key.equals(r.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const i of r.writableIndexes)if(i<s.state.addresses.length)n.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`);for(const i of r.readonlyIndexes)if(i<s.state.addresses.length)n.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`)}return n}static compile(e){const n=no.compile(e.instructions,e.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=e.addressLookupTableAccounts||[];for(const g of i){const S=n.extractTableLookup(g);if(S!==void 0){const[I,{writable:N,readonly:F}]=S;r.push(I),s.writable.push(...N),s.readonly.push(...F)}}const[o,a]=n.getMessageComponents(),m=new to(a,s).compileInstructions(e.instructions);return new ro({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:m,addressTableLookups:r})}serialize(){const e=Array();Jt(e,this.staticAccountKeys.length);const n=this.serializeInstructions(),r=Array();Jt(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Jt(i,this.addressTableLookups.length);const o=k.struct([k.u8("prefix"),k.struct([k.u8("numRequiredSignatures"),k.u8("numReadonlySignedAccounts"),k.u8("numReadonlyUnsignedAccounts")],"header"),k.blob(e.length,"staticAccountKeysLength"),k.seq(Ie(),this.staticAccountKeys.length,"staticAccountKeys"),Ie("recentBlockhash"),k.blob(r.length,"instructionsLength"),k.blob(n.length,"serializedInstructions"),k.blob(i.length,"addressTableLookupsLength"),k.blob(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(jr),m=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(g=>g.toBytes()),recentBlockhash:zt.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:n,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},a);return a.slice(0,m)}serializeInstructions(){let e=0;const n=new Uint8Array(jr);for(const r of this.compiledInstructions){const s=Array();Jt(s,r.accountKeyIndexes.length);const i=Array();Jt(i,r.data.length);const o=k.struct([k.u8("programIdIndex"),k.blob(s.length,"encodedAccountKeyIndexesLength"),k.seq(k.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),k.blob(i.length,"encodedDataLength"),k.blob(r.data.length,"data")]);e+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},n,e)}return n.slice(0,e)}serializeAddressTableLookups(){let e=0;const n=new Uint8Array(jr);for(const r of this.addressTableLookups){const s=Array();Jt(s,r.writableIndexes.length);const i=Array();Jt(i,r.readonlyIndexes.length);const o=k.struct([Ie("accountKey"),k.blob(s.length,"encodedWritableIndexesLength"),k.seq(k.u8(),r.writableIndexes.length,"writableIndexes"),k.blob(i.length,"encodedReadonlyIndexesLength"),k.seq(k.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},n,e)}return n.slice(0,e)}static deserialize(e){let n=[...e];const r=Nn(n),s=r&Nc;_t(r!==s,"Expected versioned message but received legacy message");const i=s;_t(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:Nn(n),numReadonlySignedAccounts:Nn(n),numReadonlyUnsignedAccounts:Nn(n)},a=[],d=Yt(n);for(let F=0;F<d;F++)a.push(new be(Xt(n,0,Kn)));const m=zt.encode(Xt(n,0,Kn)),g=Yt(n),S=[];for(let F=0;F<g;F++){const M=Nn(n),B=Yt(n),K=Xt(n,0,B),Y=Yt(n),z=new Uint8Array(Xt(n,0,Y));S.push({programIdIndex:M,accountKeyIndexes:K,data:z})}const I=Yt(n),N=[];for(let F=0;F<I;F++){const M=new be(Xt(n,0,Kn)),B=Yt(n),K=Xt(n,0,B),Y=Yt(n),z=Xt(n,0,Y);N.push({accountKey:M,writableIndexes:K,readonlyIndexes:z})}return new ro({header:o,staticAccountKeys:a,recentBlockhash:m,compiledInstructions:S,addressTableLookups:N})}}const Cc={deserializeMessageVersion(t){const e=t[0],n=e&Nc;return n===e?"legacy":n},deserialize:t=>{const e=Cc.deserializeMessageVersion(t);if(e==="legacy")return Hr.from(t);if(e===0)return ro.deserialize(t);throw new Error(`Transaction message version ${e} deserialization is not supported`)}},NA=Te.Buffer.alloc(eo).fill(0);class ih{constructor(e){this.keys=void 0,this.programId=void 0,this.data=Te.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:n,isWritable:r})=>({pubkey:e.toJSON(),isSigner:n,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class so{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:n,nonceInfo:r}=e;this.minNonceContextSlot=n,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:n,lastValidBlockHeight:r}=e;this.recentBlockhash=n,this.lastValidBlockHeight=r}else{const{recentBlockhash:n,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=n}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.forEach(n=>{"instructions"in n?this.instructions=this.instructions.concat(n.instructions):"data"in n&&"programId"in n&&"keys"in n?this.instructions.push(n):this.instructions.push(new ih(n))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,n;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?n=[this.nonceInfo.nonceInstruction,...this.instructions]:n=this.instructions):(e=this.recentBlockhash,n=this.instructions),!e)throw new Error("Transaction recentBlockhash required");n.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let M=0;M<n.length;M++)if(n[M].programId===void 0)throw new Error(`Transaction instruction index ${M} has undefined program id`);const s=[],i=[];n.forEach(M=>{M.keys.forEach(K=>{i.push({...K})});const B=M.programId.toString();s.includes(B)||s.push(B)}),s.forEach(M=>{i.push({pubkey:new be(M),isSigner:!1,isWritable:!1})});const o=[];i.forEach(M=>{const B=M.pubkey.toString(),K=o.findIndex(Y=>Y.pubkey.toString()===B);K>-1?(o[K].isWritable=o[K].isWritable||M.isWritable,o[K].isSigner=o[K].isSigner||M.isSigner):o.push(M)}),o.sort(function(M,B){if(M.isSigner!==B.isSigner)return M.isSigner?-1:1;if(M.isWritable!==B.isWritable)return M.isWritable?-1:1;const K={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return M.pubkey.toBase58().localeCompare(B.pubkey.toBase58(),"en",K)});const a=o.findIndex(M=>M.pubkey.equals(r));if(a>-1){const[M]=o.splice(a,1);M.isSigner=!0,M.isWritable=!0,o.unshift(M)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const M of this.signatures){const B=o.findIndex(K=>K.pubkey.equals(M.publicKey));if(B>-1)o[B].isSigner||(o[B].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${M.publicKey.toString()}`)}let d=0,m=0,g=0;const S=[],I=[];o.forEach(({pubkey:M,isSigner:B,isWritable:K})=>{B?(S.push(M.toString()),d+=1,K||(m+=1)):(I.push(M.toString()),K||(g+=1))});const N=S.concat(I),F=n.map(M=>{const{data:B,programId:K}=M;return{programIdIndex:N.indexOf(K.toString()),accounts:M.keys.map(Y=>N.indexOf(Y.pubkey.toString())),data:zt.encode(B)}});return F.forEach(M=>{_t(M.programIdIndex>=0),M.accounts.forEach(B=>_t(B>=0))}),new Hr({header:{numRequiredSignatures:d,numReadonlySignedAccounts:m,numReadonlyUnsignedAccounts:g},accountKeys:N,recentBlockhash:e,instructions:F})}_compile(){const e=this.compileMessage(),n=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===n.length&&this.signatures.every((s,i)=>n[i].equals(s.publicKey))||(this.signatures=n.map(r=>({signature:null,publicKey:r}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const n=new Set;this.signatures=e.filter(r=>{const s=r.toString();return n.has(s)?!1:(n.add(s),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...e){if(e.length===0)throw new Error("No signers");const n=new Set,r=[];for(const i of e){const o=i.publicKey.toString();n.has(o)||(n.add(o),r.push(i))}this.signatures=r.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...r)}partialSign(...e){if(e.length===0)throw new Error("No signers");const n=new Set,r=[];for(const i of e){const o=i.publicKey.toString();n.has(o)||(n.add(o),r.push(i))}const s=this._compile();this._partialSign(s,...r)}_partialSign(e,...n){const r=e.serialize();n.forEach(s=>{const i=th(r,s.secretKey);this._addSignature(s.publicKey,Oc(i))})}addSignature(e,n){this._compile(),this._addSignature(e,n)}_addSignature(e,n){_t(n.length===64);const r=this.signatures.findIndex(s=>e.equals(s.publicKey));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=Te.Buffer.from(n)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,n){const r={};for(const{signature:s,publicKey:i}of this.signatures)s===null?n&&(r.missing||=[]).push(i):wA(s,e,i.toBytes())||(r.invalid||=[]).push(i);return r.invalid||r.missing?r:void 0}serialize(e){const{requireAllSignatures:n,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),s=this.serializeMessage();if(r){const i=this._getMessageSignednessErrors(s,n);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
32
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[mw]:"No signature verification implementation could be found.",[gw]:"No key generation implementation could be found.",[yw]:"No signing implementation could be found.",[bw]:"No key export implementation could be found.",[S_]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[xv]:"Transaction processing left an account with an outstanding borrowed reference",[dv]:"Account in use",[lv]:"Account loaded twice",[fv]:"Attempt to debit an account but found no record of a prior credit.",[Mv]:"Transaction loads an address table account that doesn't exist",[gv]:"This transaction has already been processed",[yv]:"Blockhash not found",[bv]:"Loader call chain is too deep",[Av]:"Transactions are currently disabled due to cluster maintenance",[Fv]:"Transaction contains a duplicate instruction ($index) that is not allowed",[pv]:"Insufficient funds for fee",[$v]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[mv]:"This account may not be used to pay transaction fees",[wv]:"Transaction contains an invalid account reference",[kv]:"Transaction loads an address table account with invalid data",[Lv]:"Transaction address table lookup uses an invalid index",[Bv]:"Transaction loads an address table account with an invalid owner",[jv]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[vv]:"This program may not be used for executing instructions",[Pv]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Ov]:"Transaction loads a writable account that cannot be written",[zv]:"Transaction exceeded max loaded accounts data size cap",[_v]:"Transaction requires a fee but has no signature present",[hv]:"Attempt to load a program that does not exist",[Gv]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Vv]:"ResanitizationNeeded",[Rv]:"Transaction failed to sanitize accounts offsets correctly",[Ev]:"Transaction did not pass signature verification",[Cv]:"Transaction locked too many accounts",[Hv]:"Sum of account balances before and after transaction do not match",[uv]:"The transaction failed with the error `$errorName`",[Tv]:"Transaction version is unsupported",[Nv]:"Transaction would exceed account data limit within the block",[Dv]:"Transaction would exceed total account data limit",[Iv]:"Transaction would exceed max account limit within the block",[Sv]:"Transaction would exceed max Block Cost Limit",[Uv]:"Transaction would exceed max Vote Cost Limit",[rv]:"Attempted to sign a transaction with an address that is not a signer for it",[XE]:"Transaction is missing an address at index: $index.",[sv]:"Transaction has no expected signers therefore it cannot be encoded",[cv]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[GE]:"Transaction does not have a blockhash lifetime",[HE]:"Transaction is not a durable nonce transaction",[KE]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[WE]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[YE]:"No fee payer set in CompiledTransaction",[ZE]:"Could not find program address at index $index",[ov]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[av]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[QE]:"Transaction is missing a fee payer.",[ev]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[nv]:"Transaction first instruction is not advance nonce account instruction.",[tv]:"Transaction with no instructions cannot be durable nonce transaction.",[jE]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[VE]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[iv]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[JE]:"Transaction is missing signatures for addresses: $addresses.",[qE]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},On="i",fn="t";function SR(t,e={}){const n=xR[t];if(n.length===0)return"";let r;function s(o){if(r[fn]===2){const a=n.slice(r[On]+1,o);i.push(a in e?`${e[a]}`:`$${a}`)}else r[fn]===1&&i.push(n.slice(r[On],o))}const i=[];return n.split("").forEach((o,a)=>{if(a===0){r={[On]:0,[fn]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let d;switch(r[fn]){case 0:d={[On]:a,[fn]:1};break;case 1:o==="\\"?d={[On]:a,[fn]:0}:o==="$"&&(d={[On]:a,[fn]:2});break;case 2:o==="\\"?d={[On]:a,[fn]:0}:o==="$"?d={[On]:a,[fn]:2}:o.match(/\w/)||(d={[On]:a,[fn]:1});break}d&&(r!==d&&s(a),r=d)}),s(),i.join("")}function TR(t,e={}){if(process.env.NODE_ENV!=="production")return SR(t,e);{let n=`Solana error #${t}; Decode this error by running \`npx @solana/errors decode -- ${t}`;return Object.keys(e).length&&(n+=` '${AR(e)}'`),`${n}\``}}var Pr=class extends Error{cause=this.cause;context;constructor(...[t,e]){let n,r;if(e){const{cause:i,...o}=e;i&&(r={cause:i}),Object.keys(o).length>0&&(n=o)}const s=TR(t,n);super(s,r),this.context={__code:t,...n},this.name="SolanaError"}};function OR(t,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(t)}function IR(t){return Object.freeze({...t,encode:e=>{const n=new Uint8Array(OR(e,t));return t.write(e,n,0),n}})}function NR(t){return Object.freeze({...t,decode:(e,n=0)=>t.read(e,n)[0]})}function Ur(t){return"fixedSize"in t&&typeof t.fixedSize=="number"}function CR(t,e){if(Ur(t)!==Ur(e))throw new Pr(Bf);if(Ur(t)&&Ur(e)&&t.fixedSize!==e.fixedSize)throw new Pr(kf,{decoderFixedSize:e.fixedSize,encoderFixedSize:t.fixedSize});if(!Ur(t)&&!Ur(e)&&t.maxSize!==e.maxSize)throw new Pr(Lf,{decoderMaxSize:e.maxSize,encoderMaxSize:t.maxSize});return{...e,...t,decode:e.decode,encode:t.encode,read:e.read,write:t.write}}function MR(t,e,n=0){if(e.length-n<=0)throw new Pr(Cf,{codecDescription:t})}function BR(t,e,n,r=0){const s=n.length-r;if(s<e)throw new Pr(Mf,{bytesLength:s,codecDescription:t,expected:e})}function kR(t,e,n,r){if(r<e||r>n)throw new Pr(Pf,{codecDescription:t,max:n,min:e,value:r})}function Df(t){return t?.endian!==1}function LR(t){return IR({fixedSize:t.size,write(e,n,r){t.range&&kR(t.name,t.range[0],t.range[1],e);const s=new ArrayBuffer(t.size);return t.set(new DataView(s),e,Df(t.config)),n.set(new Uint8Array(s),r),r+t.size}})}function PR(t){return NR({fixedSize:t.size,read(e,n=0){MR(t.name,e,n),BR(t.name,t.size,e,n);const r=new DataView(UR(e,n,t.size));return[t.get(r,Df(t.config)),n+t.size]}})}function UR(t,e,n){const r=t.byteOffset+(e??0),s=n??t.byteLength;return t.buffer.slice(r,r+s)}var DR=(t={})=>LR({config:t,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,n,r)=>e.setBigUint64(0,BigInt(n),r),size:8}),FR=(t={})=>PR({config:t,get:(e,n)=>e.getBigUint64(0,n),name:"u64",size:8}),$R=(t={})=>CR(DR(t),FR(t));class zR extends TypeError{constructor(e,n){let r;const{message:s,explanation:i,...o}=e,{path:a}=e,d=a.length===0?s:`At path: ${a.join(".")} -- ${s}`;super(i??d),i!=null&&(this.cause=d),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...n()])}}function jR(t){return Bs(t)&&typeof t[Symbol.iterator]=="function"}function Bs(t){return typeof t=="object"&&t!=null}function Hi(t){return Bs(t)&&!Array.isArray(t)}function rn(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function VR(t){const{done:e,value:n}=t.next();return e?void 0:n}function GR(t,e,n,r){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:s,branch:i}=e,{type:o}=n,{refinement:a,message:d=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${rn(r)}\``}=t;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...t,message:d}}function*Ff(t,e,n,r){jR(t)||(t=[t]);for(const s of t){const i=GR(s,e,n,r);i&&(yield i)}}function*mc(t,e,n={}){const{path:r=[],branch:s=[t],coerce:i=!1,mask:o=!1}=n,a={path:r,branch:s,mask:o};i&&(t=e.coercer(t,a));let d="valid";for(const m of e.validator(t,a))m.explanation=n.message,d="not_valid",yield[m,void 0];for(let[m,g,x]of e.entries(t,a)){const O=mc(g,x,{path:m===void 0?r:[...r,m],branch:m===void 0?s:[...s,g],coerce:i,mask:o,message:n.message});for(const N of O)N[0]?(d=N[0].refinement!=null?"not_refined":"not_valid",yield[N[0],void 0]):i&&(g=N[1],m===void 0?t=g:t instanceof Map?t.set(m,g):t instanceof Set?t.add(g):Bs(t)&&(g!==void 0||m in t)&&(t[m]=g))}if(d!=="not_valid")for(const m of e.refiner(t,a))m.explanation=n.message,d="not_refined",yield[m,void 0];d==="valid"&&(yield[void 0,t])}let hn=class{constructor(e){const{type:n,schema:r,validator:s,refiner:i,coercer:o=d=>d,entries:a=function*(){}}=e;this.type=n,this.schema=r,this.entries=a,this.coercer=o,s?this.validator=(d,m)=>{const g=s(d,m);return Ff(g,m,this,d)}:this.validator=()=>[],i?this.refiner=(d,m)=>{const g=i(d,m);return Ff(g,m,this,d)}:this.refiner=()=>[]}assert(e,n){return HR(e,this,n)}create(e,n){return ks(e,this,n)}is(e){return $f(e,this)}mask(e,n){return qR(e,this,n)}validate(e,n={}){return Ls(e,this,n)}};function HR(t,e,n){const r=Ls(t,e,{message:n});if(r[0])throw r[0]}function ks(t,e,n){const r=Ls(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function qR(t,e,n){const r=Ls(t,e,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function $f(t,e){return!Ls(t,e)[0]}function Ls(t,e,n={}){const r=mc(t,e,n),s=VR(r);return s[0]?[new zR(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function ur(t,e){return new hn({type:t,schema:null,validator:e})}function KR(){return ur("any",()=>!0)}function ae(t){return new hn({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[n,r]of e.entries())yield[n,r,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${rn(e)}`}})}function pn(){return ur("boolean",t=>typeof t=="boolean")}function gc(t){return ur("instance",e=>e instanceof t||`Expected a \`${t.name}\` instance, but received: ${rn(e)}`)}function He(t){const e=rn(t),n=typeof t;return new hn({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?t:null,validator(r){return r===t||`Expected the literal \`${e}\`, but received: ${rn(r)}`}})}function WR(){return ur("never",()=>!1)}function ce(t){return new hn({...t,validator:(e,n)=>e===null||t.validator(e,n),refiner:(e,n)=>e===null||t.refiner(e,n)})}function G(){return ur("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${rn(t)}`)}function fe(t){return new hn({...t,validator:(e,n)=>e===void 0||t.validator(e,n),refiner:(e,n)=>e===void 0||t.refiner(e,n)})}function zf(t,e){return new hn({type:"record",schema:null,*entries(n){if(Bs(n))for(const r in n){const s=n[r];yield[r,r,t],yield[r,s,e]}},validator(n){return Hi(n)||`Expected an object, but received: ${rn(n)}`},coercer(n){return Hi(n)?{...n}:n}})}function se(){return ur("string",t=>typeof t=="string"||`Expected a string, but received: ${rn(t)}`)}function yc(t){const e=WR();return new hn({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){const r=Math.max(t.length,n.length);for(let s=0;s<r;s++)yield[s,n[s],t[s]||e]}},validator(n){return Array.isArray(n)||`Expected an array, but received: ${rn(n)}`},coercer(n){return Array.isArray(n)?n.slice():n}})}function Q(t){const e=Object.keys(t);return new hn({type:"type",schema:t,*entries(n){if(Bs(n))for(const r of e)yield[r,n[r],t[r]]},validator(n){return Hi(n)||`Expected an object, but received: ${rn(n)}`},coercer(n){return Hi(n)?{...n}:n}})}function Ft(t){const e=t.map(n=>n.type).join(" | ");return new hn({type:"union",schema:null,coercer(n,r){for(const s of t){const[i,o]=s.validate(n,{coerce:!0,mask:r.mask});if(!i)return o}return n},validator(n,r){const s=[];for(const i of t){const[...o]=mc(n,i,r),[a]=o;if(a[0])for(const[d]of o)d&&s.push(d);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${rn(n)}`,...s]}})}function Dr(){return ur("unknown",()=>!0)}function Ps(t,e,n){return new hn({...t,coercer:(r,s)=>$f(r,e)?t.coercer(n(r,s),s):t.coercer(r,s)})}var qi,ZR=new Uint8Array(16);function jf(){if(!qi&&(qi=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!qi))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return qi(ZR)}const YR=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Ki(t){return typeof t=="string"&&YR.test(t)}for(var vt=[],bc=0;bc<256;++bc)vt.push((bc+256).toString(16).substr(1));function Wi(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(vt[t[e+0]]+vt[t[e+1]]+vt[t[e+2]]+vt[t[e+3]]+"-"+vt[t[e+4]]+vt[t[e+5]]+"-"+vt[t[e+6]]+vt[t[e+7]]+"-"+vt[t[e+8]]+vt[t[e+9]]+"-"+vt[t[e+10]]+vt[t[e+11]]+vt[t[e+12]]+vt[t[e+13]]+vt[t[e+14]]+vt[t[e+15]]).toLowerCase();if(!Ki(n))throw TypeError("Stringified UUID is invalid");return n}var Vf,_c,wc=0,Ec=0;function JR(t,e,n){var r=e&&n||0,s=e||new Array(16);t=t||{};var i=t.node||Vf,o=t.clockseq!==void 0?t.clockseq:_c;if(i==null||o==null){var a=t.random||(t.rng||jf)();i==null&&(i=Vf=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=_c=(a[6]<<8|a[7])&16383)}var d=t.msecs!==void 0?t.msecs:Date.now(),m=t.nsecs!==void 0?t.nsecs:Ec+1,g=d-wc+(m-Ec)/1e4;if(g<0&&t.clockseq===void 0&&(o=o+1&16383),(g<0||d>wc)&&t.nsecs===void 0&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");wc=d,Ec=m,_c=o,d+=122192928e5;var x=((d&268435455)*1e4+m)%4294967296;s[r++]=x>>>24&255,s[r++]=x>>>16&255,s[r++]=x>>>8&255,s[r++]=x&255;var O=d/4294967296*1e4&268435455;s[r++]=O>>>8&255,s[r++]=O&255,s[r++]=O>>>24&15|16,s[r++]=O>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var N=0;N<6;++N)s[r+N]=i[N];return e||Wi(s)}function Gf(t){if(!Ki(t))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(t.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=e&255,n[4]=(e=parseInt(t.slice(9,13),16))>>>8,n[5]=e&255,n[6]=(e=parseInt(t.slice(14,18),16))>>>8,n[7]=e&255,n[8]=(e=parseInt(t.slice(19,23),16))>>>8,n[9]=e&255,n[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=e&255,n}function XR(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}var QR="6ba7b810-9dad-11d1-80b4-00c04fd430c8",eA="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Hf(t,e,n){function r(s,i,o,a){if(typeof s=="string"&&(s=XR(s)),typeof i=="string"&&(i=Gf(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var d=new Uint8Array(16+s.length);if(d.set(i),d.set(s,i.length),d=n(d),d[6]=d[6]&15|e,d[8]=d[8]&63|128,o){a=a||0;for(var m=0;m<16;++m)o[a+m]=d[m];return o}return Wi(d)}try{r.name=t}catch{}return r.DNS=QR,r.URL=eA,r}function tA(t){if(typeof t=="string"){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)}return nA(rA(sA(t),t.length*8))}function nA(t){for(var e=[],n=t.length*32,r="0123456789abcdef",s=0;s<n;s+=8){var i=t[s>>5]>>>s%32&255,o=parseInt(r.charAt(i>>>4&15)+r.charAt(i&15),16);e.push(o)}return e}function qf(t){return(t+64>>>9<<4)+14+1}function rA(t,e){t[e>>5]|=128<<e%32,t[qf(e)-1]=e;for(var n=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<t.length;o+=16){var a=n,d=r,m=s,g=i;n=Ot(n,r,s,i,t[o],7,-680876936),i=Ot(i,n,r,s,t[o+1],12,-389564586),s=Ot(s,i,n,r,t[o+2],17,606105819),r=Ot(r,s,i,n,t[o+3],22,-1044525330),n=Ot(n,r,s,i,t[o+4],7,-176418897),i=Ot(i,n,r,s,t[o+5],12,1200080426),s=Ot(s,i,n,r,t[o+6],17,-1473231341),r=Ot(r,s,i,n,t[o+7],22,-45705983),n=Ot(n,r,s,i,t[o+8],7,1770035416),i=Ot(i,n,r,s,t[o+9],12,-1958414417),s=Ot(s,i,n,r,t[o+10],17,-42063),r=Ot(r,s,i,n,t[o+11],22,-1990404162),n=Ot(n,r,s,i,t[o+12],7,1804603682),i=Ot(i,n,r,s,t[o+13],12,-40341101),s=Ot(s,i,n,r,t[o+14],17,-1502002290),r=Ot(r,s,i,n,t[o+15],22,1236535329),n=It(n,r,s,i,t[o+1],5,-165796510),i=It(i,n,r,s,t[o+6],9,-1069501632),s=It(s,i,n,r,t[o+11],14,643717713),r=It(r,s,i,n,t[o],20,-373897302),n=It(n,r,s,i,t[o+5],5,-701558691),i=It(i,n,r,s,t[o+10],9,38016083),s=It(s,i,n,r,t[o+15],14,-660478335),r=It(r,s,i,n,t[o+4],20,-405537848),n=It(n,r,s,i,t[o+9],5,568446438),i=It(i,n,r,s,t[o+14],9,-1019803690),s=It(s,i,n,r,t[o+3],14,-187363961),r=It(r,s,i,n,t[o+8],20,1163531501),n=It(n,r,s,i,t[o+13],5,-1444681467),i=It(i,n,r,s,t[o+2],9,-51403784),s=It(s,i,n,r,t[o+7],14,1735328473),r=It(r,s,i,n,t[o+12],20,-1926607734),n=Nt(n,r,s,i,t[o+5],4,-378558),i=Nt(i,n,r,s,t[o+8],11,-2022574463),s=Nt(s,i,n,r,t[o+11],16,1839030562),r=Nt(r,s,i,n,t[o+14],23,-35309556),n=Nt(n,r,s,i,t[o+1],4,-1530992060),i=Nt(i,n,r,s,t[o+4],11,1272893353),s=Nt(s,i,n,r,t[o+7],16,-155497632),r=Nt(r,s,i,n,t[o+10],23,-1094730640),n=Nt(n,r,s,i,t[o+13],4,681279174),i=Nt(i,n,r,s,t[o],11,-358537222),s=Nt(s,i,n,r,t[o+3],16,-722521979),r=Nt(r,s,i,n,t[o+6],23,76029189),n=Nt(n,r,s,i,t[o+9],4,-640364487),i=Nt(i,n,r,s,t[o+12],11,-421815835),s=Nt(s,i,n,r,t[o+15],16,530742520),r=Nt(r,s,i,n,t[o+2],23,-995338651),n=Ct(n,r,s,i,t[o],6,-198630844),i=Ct(i,n,r,s,t[o+7],10,1126891415),s=Ct(s,i,n,r,t[o+14],15,-1416354905),r=Ct(r,s,i,n,t[o+5],21,-57434055),n=Ct(n,r,s,i,t[o+12],6,1700485571),i=Ct(i,n,r,s,t[o+3],10,-1894986606),s=Ct(s,i,n,r,t[o+10],15,-1051523),r=Ct(r,s,i,n,t[o+1],21,-2054922799),n=Ct(n,r,s,i,t[o+8],6,1873313359),i=Ct(i,n,r,s,t[o+15],10,-30611744),s=Ct(s,i,n,r,t[o+6],15,-1560198380),r=Ct(r,s,i,n,t[o+13],21,1309151649),n=Ct(n,r,s,i,t[o+4],6,-145523070),i=Ct(i,n,r,s,t[o+11],10,-1120210379),s=Ct(s,i,n,r,t[o+2],15,718787259),r=Ct(r,s,i,n,t[o+9],21,-343485551),n=Gn(n,a),r=Gn(r,d),s=Gn(s,m),i=Gn(i,g)}return[n,r,s,i]}function sA(t){if(t.length===0)return[];for(var e=t.length*8,n=new Uint32Array(qf(e)),r=0;r<e;r+=8)n[r>>5]|=(t[r/8]&255)<<r%32;return n}function Gn(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function iA(t,e){return t<<e|t>>>32-e}function Zi(t,e,n,r,s,i){return Gn(iA(Gn(Gn(e,t),Gn(r,i)),s),n)}function Ot(t,e,n,r,s,i,o){return Zi(e&n|~e&r,t,e,s,i,o)}function It(t,e,n,r,s,i,o){return Zi(e&r|n&~r,t,e,s,i,o)}function Nt(t,e,n,r,s,i,o){return Zi(e^n^r,t,e,s,i,o)}function Ct(t,e,n,r,s,i,o){return Zi(n^(e|~r),t,e,s,i,o)}var oA=Hf("v3",48,tA);function aA(t,e,n){t=t||{};var r=t.random||(t.rng||jf)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(var s=0;s<16;++s)e[n+s]=r[s];return e}return Wi(r)}function cA(t,e,n,r){switch(t){case 0:return e&n^~e&r;case 1:return e^n^r;case 2:return e&n^e&r^n&r;case 3:return e^n^r}}function vc(t,e){return t<<e|t>>>32-e}function uA(t){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var r=unescape(encodeURIComponent(t));t=[];for(var s=0;s<r.length;++s)t.push(r.charCodeAt(s))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var i=t.length/4+2,o=Math.ceil(i/16),a=new Array(o),d=0;d<o;++d){for(var m=new Uint32Array(16),g=0;g<16;++g)m[g]=t[d*64+g*4]<<24|t[d*64+g*4+1]<<16|t[d*64+g*4+2]<<8|t[d*64+g*4+3];a[d]=m}a[o-1][14]=(t.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(t.length-1)*8&4294967295;for(var x=0;x<o;++x){for(var O=new Uint32Array(80),N=0;N<16;++N)O[N]=a[x][N];for(var F=16;F<80;++F)O[F]=vc(O[F-3]^O[F-8]^O[F-14]^O[F-16],1);for(var C=n[0],k=n[1],K=n[2],Y=n[3],V=n[4],L=0;L<80;++L){var z=Math.floor(L/20),J=vc(C,5)+cA(z,k,K,Y)+V+e[z]+O[L]>>>0;V=Y,Y=K,K=vc(k,30)>>>0,k=C,C=J}n[0]=n[0]+C>>>0,n[1]=n[1]+k>>>0,n[2]=n[2]+K>>>0,n[3]=n[3]+Y>>>0,n[4]=n[4]+V>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var dA=Hf("v5",80,uA);const lA="00000000-0000-0000-0000-000000000000";function fA(t){if(!Ki(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}const Kf=Ha(Object.freeze(Object.defineProperty({__proto__:null,NIL:lA,parse:Gf,stringify:Wi,v1:JR,v3:oA,v4:aA,v5:dA,validate:Ki,version:fA},Symbol.toStringTag,{value:"Module"})));var Rc,Wf;function hA(){if(Wf)return Rc;Wf=1;const t=Kf.v4;return Rc=function(n,r,s,i){if(typeof n!="string")throw new TypeError(n+" must be a string");i=i||{};const o=typeof i.version=="number"?i.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");const a={method:n};if(o===2&&(a.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");a.params=r}if(typeof s>"u"){const d=typeof i.generator=="function"?i.generator:function(){return t()};a.id=d(a,i)}else o===2&&s===null?i.notificationIdNull&&(a.id=null):a.id=s;return a},Rc}var Ac,Zf;function pA(){if(Zf)return Ac;Zf=1;const t=Kf.v4,e=hA(),n=function(r,s){if(!(this instanceof n))return new n(r,s);s||(s={}),this.options={reviver:typeof s.reviver<"u"?s.reviver:null,replacer:typeof s.replacer<"u"?s.replacer:null,generator:typeof s.generator<"u"?s.generator:function(){return t()},version:typeof s.version<"u"?s.version:2,notificationIdNull:typeof s.notificationIdNull=="boolean"?s.notificationIdNull:!1},this.callServer=r};return Ac=n,n.prototype.request=function(r,s,i,o){const a=this;let d=null;const m=Array.isArray(r)&&typeof s=="function";if(this.options.version===1&&m)throw new TypeError("JSON-RPC 1.0 does not support batching");if(m||!m&&r&&typeof r=="object"&&typeof s=="function")o=s,d=r;else{typeof i=="function"&&(o=i,i=void 0);const O=typeof o=="function";try{d=e(r,s,i,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(N){if(O){o(N);return}throw N}if(!O)return d}let x;try{x=JSON.stringify(d,this.options.replacer)}catch(O){o(O);return}return this.callServer(x,function(O,N){a._parseResponse(O,N,o)}),d},n.prototype._parseResponse=function(r,s,i){if(r){i(r);return}if(!s){i();return}let o;try{o=JSON.parse(s,this.options.reviver)}catch(a){i(a);return}if(i.length===3)if(Array.isArray(o)){const a=function(m){return typeof m.error<"u"},d=function(m){return!a(m)};i(null,o.filter(a),o.filter(d));return}else{i(null,o.error,o.result);return}i(null,o)},Ac}pA();function Yf(t){try{return uc.ExtendedPoint.fromHex(t),!0}catch{return!1}}const Jf=(t,e)=>uc.sign(t,e.slice(0,32)),mA=uc.verify,xc=t=>xe.Buffer.isBuffer(t)?t:t instanceof Uint8Array?xe.Buffer.from(t.buffer,t.byteOffset,t.byteLength):xe.Buffer.from(t);class gA{constructor(e){Object.assign(this,e)}encode(){return xe.Buffer.from(pc.serialize(Yi,this))}static decode(e){return pc.deserialize(Yi,this,e)}static decodeUnchecked(e){return pc.deserializeUnchecked(Yi,this,e)}}const Yi=new Map;var Xf;const yA=32,Hn=32;function bA(t){return t._bn!==void 0}let Qf=1;class ye extends gA{constructor(e){if(super({}),this._bn=void 0,bA(e))this._bn=e._bn;else{if(typeof e=="string"){const n=Dt.decode(e);if(n.length!=Hn)throw new Error("Invalid public key input");this._bn=new Af(n)}else this._bn=new Af(e);if(this._bn.byteLength()>Hn)throw new Error("Invalid public key input")}}static unique(){const e=new ye(Qf);return Qf+=1,new ye(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Dt.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(xe.Buffer);if(e.length===Hn)return e;const n=xe.Buffer.alloc(32);return e.copy(n,32-e.length),n}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,n,r){const s=xe.Buffer.concat([e.toBuffer(),xe.Buffer.from(n),r.toBuffer()]),i=Aa(s);return new ye(i)}static createProgramAddressSync(e,n){let r=xe.Buffer.alloc(0);e.forEach(function(i){if(i.length>yA)throw new TypeError("Max seed length exceeded");r=xe.Buffer.concat([r,xc(i)])}),r=xe.Buffer.concat([r,n.toBuffer(),xe.Buffer.from("ProgramDerivedAddress")]);const s=Aa(r);if(Yf(s))throw new Error("Invalid seeds, address must fall off the curve");return new ye(s)}static async createProgramAddress(e,n){return this.createProgramAddressSync(e,n)}static findProgramAddressSync(e,n){let r=255,s;for(;r!=0;){try{const i=e.concat(xe.Buffer.from([r]));s=this.createProgramAddressSync(i,n)}catch(i){if(i instanceof TypeError)throw i;r--;continue}return[s,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,n){return this.findProgramAddressSync(e,n)}static isOnCurve(e){const n=new ye(e);return Yf(n.toBytes())}}Xf=ye,ye.default=new Xf("11111111111111111111111111111111"),Yi.set(ye,{kind:"struct",fields:[["_bn","u256"]]}),new ye("BPFLoader1111111111111111111111111111111111");const Fr=1232,Sc=127,Ji=64;class Xi{constructor(e,n){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=n}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const n of this.keySegments()){if(e<n.length)return n[e];e-=n.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const r=new Map;this.keySegments().flat().forEach((i,o)=>{r.set(i.toBase58(),o)});const s=i=>{const o=r.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const Se=(t="publicKey")=>M.blob(32,t),_A=(t="signature")=>M.blob(64,t),$r=(t="string")=>{const e=M.struct([M.u32("length"),M.u32("lengthPadding"),M.blob(M.offset(M.u32(),-8),"chars")],t),n=e.decode.bind(e),r=e.encode.bind(e),s=e;return s.decode=(i,o)=>n(i,o).chars.toString(),s.encode=(i,o,a)=>{const d={chars:xe.Buffer.from(i,"utf8")};return r(d,o,a)},s.alloc=i=>M.u32().span+M.u32().span+xe.Buffer.from(i,"utf8").length,s},wA=(t="authorized")=>M.struct([Se("staker"),Se("withdrawer")],t),EA=(t="lockup")=>M.struct([M.ns64("unixTimestamp"),M.ns64("epoch"),Se("custodian")],t),vA=(t="voteInit")=>M.struct([Se("nodePubkey"),Se("authorizedVoter"),Se("authorizedWithdrawer"),M.u8("commission")],t),RA=(t="voteAuthorizeWithSeedArgs")=>M.struct([M.u32("voteAuthorizationType"),Se("currentAuthorityDerivedKeyOwnerPubkey"),$r("currentAuthorityDerivedKeySeed"),Se("newAuthorized")],t);function Kt(t){let e=0,n=0;for(;;){let r=t.shift();if(e|=(r&127)<<n*7,n+=1,(r&128)===0)break}return e}function Wt(t,e){let n=e;for(;;){let r=n&127;if(n>>=7,n==0){t.push(r);break}else r|=128,t.push(r)}}function yt(t,e){if(!t)throw new Error(e||"Assertion failed")}class Qi{constructor(e,n){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=n}static compile(e,n){const r=new Map,s=o=>{const a=o.toBase58();let d=r.get(a);return d===void 0&&(d={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,d)),d},i=s(n);i.isSigner=!0,i.isWritable=!0;for(const o of e){s(o.programId).isInvoked=!0;for(const a of o.keys){const d=s(a.pubkey);d.isSigner||=a.isSigner,d.isWritable||=a.isWritable}}return new Qi(n,r)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];yt(e.length<=256,"Max static account keys length exceeded");const n=e.filter(([,d])=>d.isSigner&&d.isWritable),r=e.filter(([,d])=>d.isSigner&&!d.isWritable),s=e.filter(([,d])=>!d.isSigner&&d.isWritable),i=e.filter(([,d])=>!d.isSigner&&!d.isWritable),o={numRequiredSignatures:n.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{yt(n.length>0,"Expected at least one writable signer key");const[d]=n[0];yt(d===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...n.map(([d])=>new ye(d)),...r.map(([d])=>new ye(d)),...s.map(([d])=>new ye(d)),...i.map(([d])=>new ye(d))];return[o,a]}extractTableLookup(e){const[n,r]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(n.length===0&&s.length===0))return[{accountKey:e.key,writableIndexes:n,readonlyIndexes:s},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(e,n){const r=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(n(o)){const a=new ye(i),d=e.findIndex(m=>m.equals(a));d>=0&&(yt(d<256,"Max lookup table index exceeded"),r.push(d),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const eh="Reached end of buffer unexpectedly";function In(t){if(t.length===0)throw new Error(eh);return t.shift()}function Zt(t,...e){const[n]=e;if(e.length===2?n+(e[1]??0)>t.length:n>=t.length)throw new Error(eh);return t.splice(...e)}class zr{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(n=>new ye(n)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(n=>this.indexToProgramIds.set(n.programIdIndex,this.accountKeys[n.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Dt.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Xi(this.staticAccountKeys)}static compile(e){const n=Qi.compile(e.instructions,e.payerKey),[r,s]=n.getMessageComponents(),o=new Xi(s).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:Dt.encode(a.data)}));return new zr({header:r,accountKeys:s,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const n=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const r=e-n,i=this.accountKeys.length-n-this.header.numReadonlyUnsignedAccounts;return r<i}else{const r=n-this.header.numReadonlySignedAccounts;return e<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,n)=>!this.isProgramId(n))}serialize(){const e=this.accountKeys.length;let n=[];Wt(n,e);const r=this.instructions.map(x=>{const{accounts:O,programIdIndex:N}=x,F=Array.from(Dt.decode(x.data));let C=[];Wt(C,O.length);let k=[];return Wt(k,F.length),{programIdIndex:N,keyIndicesCount:xe.Buffer.from(C),keyIndices:O,dataLength:xe.Buffer.from(k),data:F}});let s=[];Wt(s,r.length);let i=xe.Buffer.alloc(Fr);xe.Buffer.from(s).copy(i);let o=s.length;r.forEach(x=>{const N=M.struct([M.u8("programIdIndex"),M.blob(x.keyIndicesCount.length,"keyIndicesCount"),M.seq(M.u8("keyIndex"),x.keyIndices.length,"keyIndices"),M.blob(x.dataLength.length,"dataLength"),M.seq(M.u8("userdatum"),x.data.length,"data")]).encode(x,i,o);o+=N}),i=i.slice(0,o);const a=M.struct([M.blob(1,"numRequiredSignatures"),M.blob(1,"numReadonlySignedAccounts"),M.blob(1,"numReadonlyUnsignedAccounts"),M.blob(n.length,"keyCount"),M.seq(Se("key"),e,"keys"),Se("recentBlockhash")]),d={numRequiredSignatures:xe.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:xe.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:xe.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:xe.Buffer.from(n),keys:this.accountKeys.map(x=>xc(x.toBytes())),recentBlockhash:Dt.decode(this.recentBlockhash)};let m=xe.Buffer.alloc(2048);const g=a.encode(d,m);return i.copy(m,g),m.slice(0,g+i.length)}static from(e){let n=[...e];const r=In(n);if(r!==(r&Sc))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=In(n),i=In(n),o=Kt(n);let a=[];for(let O=0;O<o;O++){const N=Zt(n,0,Hn);a.push(new ye(xe.Buffer.from(N)))}const d=Zt(n,0,Hn),m=Kt(n);let g=[];for(let O=0;O<m;O++){const N=In(n),F=Kt(n),C=Zt(n,0,F),k=Kt(n),K=Zt(n,0,k),Y=Dt.encode(xe.Buffer.from(K));g.push({programIdIndex:N,accounts:C,data:Y})}const x={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:Dt.encode(xe.Buffer.from(d)),accountKeys:a,instructions:g};return new zr(x)}}class eo{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const n of this.addressTableLookups)e+=n.readonlyIndexes.length+n.writableIndexes.length;return e}getAccountKeys(e){let n;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");n=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)n=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Xi(this.staticAccountKeys,n)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const n=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r){const s=e-r,i=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return s<i}else if(e>=this.header.numRequiredSignatures){const s=e-n,o=r-n-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=n-this.header.numReadonlySignedAccounts;return e<s}}resolveAddressTableLookups(e){const n={writable:[],readonly:[]};for(const r of this.addressTableLookups){const s=e.find(i=>i.key.equals(r.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const i of r.writableIndexes)if(i<s.state.addresses.length)n.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`);for(const i of r.readonlyIndexes)if(i<s.state.addresses.length)n.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`)}return n}static compile(e){const n=Qi.compile(e.instructions,e.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=e.addressLookupTableAccounts||[];for(const g of i){const x=n.extractTableLookup(g);if(x!==void 0){const[O,{writable:N,readonly:F}]=x;r.push(O),s.writable.push(...N),s.readonly.push(...F)}}const[o,a]=n.getMessageComponents(),m=new Xi(a,s).compileInstructions(e.instructions);return new eo({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:m,addressTableLookups:r})}serialize(){const e=Array();Wt(e,this.staticAccountKeys.length);const n=this.serializeInstructions(),r=Array();Wt(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Wt(i,this.addressTableLookups.length);const o=M.struct([M.u8("prefix"),M.struct([M.u8("numRequiredSignatures"),M.u8("numReadonlySignedAccounts"),M.u8("numReadonlyUnsignedAccounts")],"header"),M.blob(e.length,"staticAccountKeysLength"),M.seq(Se(),this.staticAccountKeys.length,"staticAccountKeys"),Se("recentBlockhash"),M.blob(r.length,"instructionsLength"),M.blob(n.length,"serializedInstructions"),M.blob(i.length,"addressTableLookupsLength"),M.blob(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(Fr),m=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(g=>g.toBytes()),recentBlockhash:Dt.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:n,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},a);return a.slice(0,m)}serializeInstructions(){let e=0;const n=new Uint8Array(Fr);for(const r of this.compiledInstructions){const s=Array();Wt(s,r.accountKeyIndexes.length);const i=Array();Wt(i,r.data.length);const o=M.struct([M.u8("programIdIndex"),M.blob(s.length,"encodedAccountKeyIndexesLength"),M.seq(M.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),M.blob(i.length,"encodedDataLength"),M.blob(r.data.length,"data")]);e+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},n,e)}return n.slice(0,e)}serializeAddressTableLookups(){let e=0;const n=new Uint8Array(Fr);for(const r of this.addressTableLookups){const s=Array();Wt(s,r.writableIndexes.length);const i=Array();Wt(i,r.readonlyIndexes.length);const o=M.struct([Se("accountKey"),M.blob(s.length,"encodedWritableIndexesLength"),M.seq(M.u8(),r.writableIndexes.length,"writableIndexes"),M.blob(i.length,"encodedReadonlyIndexesLength"),M.seq(M.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},n,e)}return n.slice(0,e)}static deserialize(e){let n=[...e];const r=In(n),s=r&Sc;yt(r!==s,"Expected versioned message but received legacy message");const i=s;yt(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:In(n),numReadonlySignedAccounts:In(n),numReadonlyUnsignedAccounts:In(n)},a=[],d=Kt(n);for(let F=0;F<d;F++)a.push(new ye(Zt(n,0,Hn)));const m=Dt.encode(Zt(n,0,Hn)),g=Kt(n),x=[];for(let F=0;F<g;F++){const C=In(n),k=Kt(n),K=Zt(n,0,k),Y=Kt(n),V=new Uint8Array(Zt(n,0,Y));x.push({programIdIndex:C,accountKeyIndexes:K,data:V})}const O=Kt(n),N=[];for(let F=0;F<O;F++){const C=new ye(Zt(n,0,Hn)),k=Kt(n),K=Zt(n,0,k),Y=Kt(n),V=Zt(n,0,Y);N.push({accountKey:C,writableIndexes:K,readonlyIndexes:V})}return new eo({header:o,staticAccountKeys:a,recentBlockhash:m,compiledInstructions:x,addressTableLookups:N})}}const Tc={deserializeMessageVersion(t){const e=t[0],n=e&Sc;return n===e?"legacy":n},deserialize:t=>{const e=Tc.deserializeMessageVersion(t);if(e==="legacy")return zr.from(t);if(e===0)return eo.deserialize(t);throw new Error(`Transaction message version ${e} deserialization is not supported`)}},AA=xe.Buffer.alloc(Ji).fill(0);class th{constructor(e){this.keys=void 0,this.programId=void 0,this.data=xe.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:n,isWritable:r})=>({pubkey:e.toJSON(),isSigner:n,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class to{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:n,nonceInfo:r}=e;this.minNonceContextSlot=n,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:n,lastValidBlockHeight:r}=e;this.recentBlockhash=n,this.lastValidBlockHeight=r}else{const{recentBlockhash:n,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=n}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.forEach(n=>{"instructions"in n?this.instructions=this.instructions.concat(n.instructions):"data"in n&&"programId"in n&&"keys"in n?this.instructions.push(n):this.instructions.push(new th(n))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,n;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?n=[this.nonceInfo.nonceInstruction,...this.instructions]:n=this.instructions):(e=this.recentBlockhash,n=this.instructions),!e)throw new Error("Transaction recentBlockhash required");n.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let C=0;C<n.length;C++)if(n[C].programId===void 0)throw new Error(`Transaction instruction index ${C} has undefined program id`);const s=[],i=[];n.forEach(C=>{C.keys.forEach(K=>{i.push({...K})});const k=C.programId.toString();s.includes(k)||s.push(k)}),s.forEach(C=>{i.push({pubkey:new ye(C),isSigner:!1,isWritable:!1})});const o=[];i.forEach(C=>{const k=C.pubkey.toString(),K=o.findIndex(Y=>Y.pubkey.toString()===k);K>-1?(o[K].isWritable=o[K].isWritable||C.isWritable,o[K].isSigner=o[K].isSigner||C.isSigner):o.push(C)}),o.sort(function(C,k){if(C.isSigner!==k.isSigner)return C.isSigner?-1:1;if(C.isWritable!==k.isWritable)return C.isWritable?-1:1;const K={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return C.pubkey.toBase58().localeCompare(k.pubkey.toBase58(),"en",K)});const a=o.findIndex(C=>C.pubkey.equals(r));if(a>-1){const[C]=o.splice(a,1);C.isSigner=!0,C.isWritable=!0,o.unshift(C)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const C of this.signatures){const k=o.findIndex(K=>K.pubkey.equals(C.publicKey));if(k>-1)o[k].isSigner||(o[k].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${C.publicKey.toString()}`)}let d=0,m=0,g=0;const x=[],O=[];o.forEach(({pubkey:C,isSigner:k,isWritable:K})=>{k?(x.push(C.toString()),d+=1,K||(m+=1)):(O.push(C.toString()),K||(g+=1))});const N=x.concat(O),F=n.map(C=>{const{data:k,programId:K}=C;return{programIdIndex:N.indexOf(K.toString()),accounts:C.keys.map(Y=>N.indexOf(Y.pubkey.toString())),data:Dt.encode(k)}});return F.forEach(C=>{yt(C.programIdIndex>=0),C.accounts.forEach(k=>yt(k>=0))}),new zr({header:{numRequiredSignatures:d,numReadonlySignedAccounts:m,numReadonlyUnsignedAccounts:g},accountKeys:N,recentBlockhash:e,instructions:F})}_compile(){const e=this.compileMessage(),n=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===n.length&&this.signatures.every((s,i)=>n[i].equals(s.publicKey))||(this.signatures=n.map(r=>({signature:null,publicKey:r}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const n=new Set;this.signatures=e.filter(r=>{const s=r.toString();return n.has(s)?!1:(n.add(s),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...e){if(e.length===0)throw new Error("No signers");const n=new Set,r=[];for(const i of e){const o=i.publicKey.toString();n.has(o)||(n.add(o),r.push(i))}this.signatures=r.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...r)}partialSign(...e){if(e.length===0)throw new Error("No signers");const n=new Set,r=[];for(const i of e){const o=i.publicKey.toString();n.has(o)||(n.add(o),r.push(i))}const s=this._compile();this._partialSign(s,...r)}_partialSign(e,...n){const r=e.serialize();n.forEach(s=>{const i=Jf(r,s.secretKey);this._addSignature(s.publicKey,xc(i))})}addSignature(e,n){this._compile(),this._addSignature(e,n)}_addSignature(e,n){yt(n.length===64);const r=this.signatures.findIndex(s=>e.equals(s.publicKey));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=xe.Buffer.from(n)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,n){const r={};for(const{signature:s,publicKey:i}of this.signatures)s===null?n&&(r.missing||=[]).push(i):mA(s,e,i.toBytes())||(r.invalid||=[]).push(i);return r.invalid||r.missing?r:void 0}serialize(e){const{requireAllSignatures:n,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),s=this.serializeMessage();if(r){const i=this._getMessageSignednessErrors(s,n);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
33
33
  Invalid signature for public key${i.invalid.length===1?"":"(s)"} [\`${i.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),i.missing&&(o+=`
34
- Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(e){const{signatures:n}=this,r=[];Jt(r,n.length);const s=r.length+n.length*64+e.length,i=Te.Buffer.alloc(s);return _t(n.length<256),Te.Buffer.from(r).copy(i,0),n.forEach(({signature:o},a)=>{o!==null&&(_t(o.length===64,"signature has invalid length"),Te.Buffer.from(o).copy(i,r.length+a*64))}),e.copy(i,r.length+n.length*64),_t(i.length<=jr,`Transaction too large: ${i.length} > ${jr}`),i}get keys(){return _t(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return _t(this.instructions.length===1),this.instructions[0].programId}get data(){return _t(this.instructions.length===1),this.instructions[0].data}static from(e){let n=[...e];const r=Yt(n);let s=[];for(let i=0;i<r;i++){const o=Xt(n,0,eo);s.push(zt.encode(Te.Buffer.from(o)))}return so.populate(Hr.from(n),s)}static populate(e,n=[]){const r=new so;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),n.forEach((s,i)=>{const o={signature:s==zt.encode(NA)?null:zt.decode(s),publicKey:e.accountKeys[i]};r.signatures.push(o)}),e.instructions.forEach(s=>{const i=s.accounts.map(o=>{const a=e.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(d=>d.publicKey.toString()===a.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});r.instructions.push(new ih({keys:i,programId:e.accountKeys[s.programIdIndex],data:zt.decode(s.data)}))}),r._message=e,r._json=r.toJSON(),r}}class Mc{get version(){return this.message.version}constructor(e,n){if(this.signatures=void 0,this.message=void 0,n!==void 0)_t(n.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=n;else{const r=[];for(let s=0;s<e.header.numRequiredSignatures;s++)r.push(new Uint8Array(eo));this.signatures=r}this.message=e}serialize(){const e=this.message.serialize(),n=Array();Jt(n,this.signatures.length);const r=k.struct([k.blob(n.length,"encodedSignaturesLength"),k.seq(SA(),this.signatures.length,"signatures"),k.blob(e.length,"serializedMessage")]),s=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(n),signatures:this.signatures,serializedMessage:e},s);return s.slice(0,i)}static deserialize(e){let n=[...e];const r=[],s=Yt(n);for(let o=0;o<s;o++)r.push(new Uint8Array(Xt(n,0,eo)));const i=Cc.deserialize(new Uint8Array(n));return new Mc(i,r)}sign(e){const n=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of e){const i=r.findIndex(o=>o.equals(s.publicKey));_t(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=th(n,s.secretKey)}}addSignature(e,n){_t(n.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(e));_t(s>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=n}}new be("SysvarC1ock11111111111111111111111111111111"),new be("SysvarEpochSchedu1e111111111111111111111111"),new be("Sysvar1nstructions1111111111111111111111111"),new be("SysvarRecentB1ockHashes11111111111111111111"),new be("SysvarRent111111111111111111111111111111111"),new be("SysvarRewards111111111111111111111111111111"),new be("SysvarS1otHashes111111111111111111111111111"),new be("SysvarS1otHistory11111111111111111111111111"),new be("SysvarStakeHistory1111111111111111111111111");const CA=k.nu64("lamportsPerSignature");k.struct([k.u32("version"),k.u32("state"),Ie("authorizedPubkey"),Ie("nonce"),k.struct([CA],"feeCalculator")]).span;function Gr(t){const e=k.blob(8,t),n=e.decode.bind(e),r=e.encode.bind(e),s=e,i=qR();return s.decode=(o,a)=>{const d=n(o,a);return i.decode(d)},s.encode=(o,a,d)=>{const m=i.encode(o);return r(m,a,d)},s}Object.freeze({Create:{index:0,layout:k.struct([k.u32("instruction"),k.ns64("lamports"),k.ns64("space"),Ie("programId")])},Assign:{index:1,layout:k.struct([k.u32("instruction"),Ie("programId")])},Transfer:{index:2,layout:k.struct([k.u32("instruction"),Gr("lamports")])},CreateWithSeed:{index:3,layout:k.struct([k.u32("instruction"),Ie("base"),Vr("seed"),k.ns64("lamports"),k.ns64("space"),Ie("programId")])},AdvanceNonceAccount:{index:4,layout:k.struct([k.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:k.struct([k.u32("instruction"),k.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:k.struct([k.u32("instruction"),Ie("authorized")])},AuthorizeNonceAccount:{index:7,layout:k.struct([k.u32("instruction"),Ie("authorized")])},Allocate:{index:8,layout:k.struct([k.u32("instruction"),k.ns64("space")])},AllocateWithSeed:{index:9,layout:k.struct([k.u32("instruction"),Ie("base"),Vr("seed"),k.ns64("space"),Ie("programId")])},AssignWithSeed:{index:10,layout:k.struct([k.u32("instruction"),Ie("base"),Vr("seed"),Ie("programId")])},TransferWithSeed:{index:11,layout:k.struct([k.u32("instruction"),Gr("lamports"),Vr("seed"),Ie("programId")])},UpgradeNonceAccount:{index:12,layout:k.struct([k.u32("instruction")])}}),new be("11111111111111111111111111111111"),new be("BPFLoader2111111111111111111111111111111111"),k.struct([k.u32("typeIndex"),Gr("deactivationSlot"),k.nu64("lastExtendedSlot"),k.u8("lastExtendedStartIndex"),k.u8(),k.seq(Ie(),k.offset(k.u8(),-1),"authority")]);const Ze=Fs(Ec(be),ie(),t=>new be(t)),oh=wc([ie(),qe("base64")]),kc=Fs(Ec(Te.Buffer),oh,t=>Te.Buffer.from(t[0],"base64"));function ah(t){return jt([ee({jsonrpc:qe("2.0"),id:ie(),result:t}),ee({jsonrpc:qe("2.0"),id:ie(),error:ee({code:zr(),message:ie(),data:he(QR())})})])}const MA=ah(zr());function Pe(t){return Fs(ah(t),MA,e=>"error"in e?e:{...e,result:Ds(e.result,t)})}function an(t){return Pe(ee({context:ee({slot:H()}),value:t}))}function io(t){return ee({context:ee({slot:H()}),value:t})}const kA=ee({foundation:H(),foundationTerm:H(),initial:H(),taper:H(),terminal:H()});Pe(ce(ue(ee({epoch:H(),effectiveSlot:H(),amount:H(),postBalance:H(),commission:he(ue(H()))}))));const BA=ce(ee({slot:H(),prioritizationFee:H()})),UA=ee({total:H(),validator:H(),foundation:H(),epoch:H()}),LA=ee({epoch:H(),slotIndex:H(),slotsInEpoch:H(),absoluteSlot:H(),blockHeight:he(H()),transactionCount:he(H())}),DA=ee({slotsPerEpoch:H(),leaderScheduleSlotOffset:H(),warmup:mn(),firstNormalEpoch:H(),firstNormalSlot:H()}),PA=Gf(ie(),ce(H())),hr=ue(jt([ee({}),ie()])),FA=ee({err:hr}),$A=qe("receivedSignature");ee({"solana-core":ie(),"feature-set":he(H())});const zA=ee({program:ie(),programId:Ze,parsed:zr()}),jA=ee({programId:Ze,accounts:ce(Ze),data:ie()});an(ee({err:ue(jt([ee({}),ie()])),logs:ue(ce(ie())),accounts:he(ue(ce(ue(ee({executable:mn(),owner:ie(),lamports:H(),data:ce(ie()),rentEpoch:he(H())}))))),unitsConsumed:he(H()),returnData:he(ue(ee({programId:ie(),data:wc([ie(),qe("base64")])}))),innerInstructions:he(ue(ce(ee({index:H(),instructions:ce(jt([zA,jA]))}))))})),an(ee({byIdentity:Gf(ie(),ce(H())),range:ee({firstSlot:H(),lastSlot:H()})})),Pe(kA),Pe(UA),Pe(BA),Pe(LA),Pe(DA),Pe(PA),Pe(H()),an(ee({total:H(),circulating:H(),nonCirculating:H(),nonCirculatingAccounts:ce(Ze)}));const VA=ee({amount:ie(),uiAmount:ue(H()),decimals:H(),uiAmountString:he(ie())});an(ce(ee({address:Ze,amount:ie(),uiAmount:ue(H()),decimals:H(),uiAmountString:he(ie())}))),an(ce(ee({pubkey:Ze,account:ee({executable:mn(),owner:Ze,lamports:H(),data:kc,rentEpoch:H()})})));const Bc=ee({program:ie(),parsed:zr(),space:H()});an(ce(ee({pubkey:Ze,account:ee({executable:mn(),owner:Ze,lamports:H(),data:Bc,rentEpoch:H()})}))),an(ce(ee({lamports:H(),address:Ze})));const Uc=ee({executable:mn(),owner:Ze,lamports:H(),data:kc,rentEpoch:H()});ee({pubkey:Ze,account:Uc});const HA=Fs(jt([Ec(Te.Buffer),Bc]),jt([oh,Bc]),t=>Array.isArray(t)?Ds(t,kc):t),GA=ee({executable:mn(),owner:Ze,lamports:H(),data:HA,rentEpoch:H()});ee({pubkey:Ze,account:GA}),ee({state:jt([qe("active"),qe("inactive"),qe("activating"),qe("deactivating")]),active:H(),inactive:H()}),Pe(ce(ee({signature:ie(),slot:H(),err:hr,memo:ue(ie()),blockTime:he(ue(H()))}))),Pe(ce(ee({signature:ie(),slot:H(),err:hr,memo:ue(ie()),blockTime:he(ue(H()))}))),ee({subscription:H(),result:io(Uc)});const qA=ee({pubkey:Ze,account:Uc});ee({subscription:H(),result:io(qA)});const KA=ee({parent:H(),slot:H(),root:H()});ee({subscription:H(),result:KA});const WA=jt([ee({type:jt([qe("firstShredReceived"),qe("completed"),qe("optimisticConfirmation"),qe("root")]),slot:H(),timestamp:H()}),ee({type:qe("createdBank"),parent:H(),slot:H(),timestamp:H()}),ee({type:qe("frozen"),slot:H(),timestamp:H(),stats:ee({numTransactionEntries:H(),numSuccessfulTransactions:H(),numFailedTransactions:H(),maxTransactionsPerEntry:H()})}),ee({type:qe("dead"),slot:H(),timestamp:H(),err:ie()})]);ee({subscription:H(),result:WA}),ee({subscription:H(),result:io(jt([FA,$A]))}),ee({subscription:H(),result:H()}),ee({pubkey:ie(),gossip:ue(ie()),tpu:ue(ie()),rpc:ue(ie()),version:ue(ie())});const ch=ee({votePubkey:ie(),nodePubkey:ie(),activatedStake:H(),epochVoteAccount:mn(),epochCredits:ce(wc([H(),H(),H()])),commission:H(),lastVote:H(),rootSlot:ue(H())});Pe(ee({current:ce(ch),delinquent:ce(ch)}));const ZA=jt([qe("processed"),qe("confirmed"),qe("finalized")]),YA=ee({slot:H(),confirmations:ue(H()),err:hr,confirmationStatus:he(ZA)});an(ce(ue(YA))),Pe(H());const uh=ee({accountKey:Ze,writableIndexes:ce(H()),readonlyIndexes:ce(H())}),Lc=ee({signatures:ce(ie()),message:ee({accountKeys:ce(ie()),header:ee({numRequiredSignatures:H(),numReadonlySignedAccounts:H(),numReadonlyUnsignedAccounts:H()}),instructions:ce(ee({accounts:ce(H()),data:ie(),programIdIndex:H()})),recentBlockhash:ie(),addressTableLookups:he(ce(uh))})}),dh=ee({pubkey:Ze,signer:mn(),writable:mn(),source:he(jt([qe("transaction"),qe("lookupTable")]))}),lh=ee({accountKeys:ce(dh),signatures:ce(ie())}),fh=ee({parsed:zr(),program:ie(),programId:Ze}),hh=ee({accounts:ce(Ze),data:ie(),programId:Ze}),JA=jt([hh,fh]),XA=jt([ee({parsed:zr(),program:ie(),programId:ie()}),ee({accounts:ce(ie()),data:ie(),programId:ie()})]),ph=Fs(JA,XA,t=>"accounts"in t?Ds(t,hh):Ds(t,fh)),mh=ee({signatures:ce(ie()),message:ee({accountKeys:ce(dh),instructions:ce(ph),recentBlockhash:ie(),addressTableLookups:he(ue(ce(uh)))})}),oo=ee({accountIndex:H(),mint:ie(),owner:he(ie()),programId:he(ie()),uiTokenAmount:VA}),gh=ee({writable:ce(Ze),readonly:ce(Ze)}),ao=ee({err:hr,fee:H(),innerInstructions:he(ue(ce(ee({index:H(),instructions:ce(ee({accounts:ce(H()),data:ie(),programIdIndex:H()}))})))),preBalances:ce(H()),postBalances:ce(H()),logMessages:he(ue(ce(ie()))),preTokenBalances:he(ue(ce(oo))),postTokenBalances:he(ue(ce(oo))),loadedAddresses:he(gh),computeUnitsConsumed:he(H()),costUnits:he(H())}),Dc=ee({err:hr,fee:H(),innerInstructions:he(ue(ce(ee({index:H(),instructions:ce(ph)})))),preBalances:ce(H()),postBalances:ce(H()),logMessages:he(ue(ce(ie()))),preTokenBalances:he(ue(ce(oo))),postTokenBalances:he(ue(ce(oo))),loadedAddresses:he(gh),computeUnitsConsumed:he(H()),costUnits:he(H())}),qr=jt([qe(0),qe("legacy")]),pr=ee({pubkey:ie(),lamports:H(),postBalance:ue(H()),rewardType:ue(ie()),commission:he(ue(H()))});Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),transactions:ce(ee({transaction:Lc,meta:ue(ao),version:he(qr)})),rewards:he(ce(pr)),blockTime:ue(H()),blockHeight:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),rewards:he(ce(pr)),blockTime:ue(H()),blockHeight:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),transactions:ce(ee({transaction:lh,meta:ue(ao),version:he(qr)})),rewards:he(ce(pr)),blockTime:ue(H()),blockHeight:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),transactions:ce(ee({transaction:mh,meta:ue(Dc),version:he(qr)})),rewards:he(ce(pr)),blockTime:ue(H()),blockHeight:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),transactions:ce(ee({transaction:lh,meta:ue(Dc),version:he(qr)})),rewards:he(ce(pr)),blockTime:ue(H()),blockHeight:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),rewards:he(ce(pr)),blockTime:ue(H()),blockHeight:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),transactions:ce(ee({transaction:Lc,meta:ue(ao)})),rewards:he(ce(pr)),blockTime:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),signatures:ce(ie()),blockTime:ue(H())}))),Pe(ue(ee({slot:H(),meta:ue(ao),blockTime:he(ue(H())),transaction:Lc,version:he(qr)}))),Pe(ue(ee({slot:H(),transaction:mh,meta:ue(Dc),blockTime:he(ue(H())),version:he(qr)}))),an(ee({blockhash:ie(),lastValidBlockHeight:H()})),an(mn());const QA=ee({slot:H(),numTransactions:H(),numSlots:H(),samplePeriodSecs:H()});Pe(ce(QA)),an(ue(ee({feeCalculator:ee({lamportsPerSignature:H()})}))),Pe(ie()),Pe(ie());const eS=ee({err:hr,logs:ce(ie()),signature:ie()});ee({result:io(eS),subscription:H()}),Object.freeze({CreateLookupTable:{index:0,layout:k.struct([k.u32("instruction"),Gr("recentSlot"),k.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:k.struct([k.u32("instruction")])},ExtendLookupTable:{index:2,layout:k.struct([k.u32("instruction"),Gr(),k.seq(Ie(),k.offset(k.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:k.struct([k.u32("instruction")])},CloseLookupTable:{index:4,layout:k.struct([k.u32("instruction")])}}),new be("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:k.struct([k.u8("instruction"),k.u32("units"),k.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:k.struct([k.u8("instruction"),k.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:k.struct([k.u8("instruction"),k.u32("units")])},SetComputeUnitPrice:{index:3,layout:k.struct([k.u8("instruction"),Gr("microLamports")])}}),new be("ComputeBudget111111111111111111111111111111"),k.struct([k.u8("numSignatures"),k.u8("padding"),k.u16("signatureOffset"),k.u16("signatureInstructionIndex"),k.u16("publicKeyOffset"),k.u16("publicKeyInstructionIndex"),k.u16("messageDataOffset"),k.u16("messageDataSize"),k.u16("messageInstructionIndex")]),new be("Ed25519SigVerify111111111111111111111111111"),ja.utils.isValidPrivateKey,ja.getPublicKey,k.struct([k.u8("numSignatures"),k.u16("signatureOffset"),k.u8("signatureInstructionIndex"),k.u16("ethAddressOffset"),k.u8("ethAddressInstructionIndex"),k.u16("messageDataOffset"),k.u16("messageDataSize"),k.u8("messageInstructionIndex"),k.blob(20,"ethAddress"),k.blob(64,"signature"),k.u8("recoveryId")]),new be("KeccakSecp256k11111111111111111111111111111");var yh;new be("StakeConfig11111111111111111111111111111111");class bh{constructor(e,n,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=n,this.custodian=r}}yh=bh,bh.default=new yh(0,0,be.default),Object.freeze({Initialize:{index:0,layout:k.struct([k.u32("instruction"),xA(),TA()])},Authorize:{index:1,layout:k.struct([k.u32("instruction"),Ie("newAuthorized"),k.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:k.struct([k.u32("instruction")])},Split:{index:3,layout:k.struct([k.u32("instruction"),k.ns64("lamports")])},Withdraw:{index:4,layout:k.struct([k.u32("instruction"),k.ns64("lamports")])},Deactivate:{index:5,layout:k.struct([k.u32("instruction")])},Merge:{index:7,layout:k.struct([k.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:k.struct([k.u32("instruction"),Ie("newAuthorized"),k.u32("stakeAuthorizationType"),Vr("authoritySeed"),Ie("authorityOwner")])}}),new be("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:k.struct([k.u32("instruction"),IA()])},Authorize:{index:1,layout:k.struct([k.u32("instruction"),Ie("newAuthorized"),k.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:k.struct([k.u32("instruction"),k.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:k.struct([k.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:k.struct([k.u32("instruction"),OA()])}}),new be("Vote111111111111111111111111111111111111111"),new be("Va1idator1nfo111111111111111111111111111111"),ee({name:ie(),website:he(ie()),details:he(ie()),iconUrl:he(ie()),keybaseUsername:he(ie())}),new be("Vote111111111111111111111111111111111111111"),k.struct([Ie("nodePubkey"),Ie("authorizedWithdrawer"),k.u8("commission"),k.nu64(),k.seq(k.struct([k.nu64("slot"),k.u32("confirmationCount")]),k.offset(k.u32(),-8),"votes"),k.u8("rootSlotValid"),k.nu64("rootSlot"),k.nu64(),k.seq(k.struct([k.nu64("epoch"),Ie("authorizedVoter")]),k.offset(k.u32(),-8),"authorizedVoters"),k.struct([k.seq(k.struct([Ie("authorizedPubkey"),k.nu64("epochOfLastAuthorizedSwitch"),k.nu64("targetEpoch")]),32,"buf"),k.nu64("idx"),k.u8("isEmpty")],"priorVoters"),k.nu64(),k.seq(k.struct([k.nu64("epoch"),k.nu64("credits"),k.nu64("prevCredits")]),k.offset(k.u32(),-8),"epochCredits"),k.struct([k.nu64("slot"),k.nu64("timestamp")],"lastTimestamp")]);const tS=t=>({request:t,signMessage:e=>t({method:"signMessage",params:{message:e}}),signTransaction:e=>t({method:"signTransaction",params:{transaction:e}}),signAndSendTransaction:e=>t({method:"signAndSendTransaction",params:e})});function _h(t){return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64")}function nS(t){const e=Buffer.from(t,"base64");return Cc.deserializeMessageVersion(e)==="legacy"?Mc.deserialize(e):so.from(e)}function rS(t){return async n=>{if(n.method==="connect")return await t(n);if(n.method==="signMessage")return await t(n);if(n.method==="signAndSendTransaction"){const{transaction:r}=n.params,s={transaction:_h(r)};return await t({method:"signAndSendTransaction",params:s})}if(n.method==="signTransaction"){const{transaction:r}=n.params,s={transaction:_h(r)},{signedTransaction:i}=await t({method:"signTransaction",params:s});return{signedTransaction:nS(i)}}}}const sS=({miniAppHost:t,emitter:e})=>{let n,r=null;return{visible:!1,get onback(){return r},set onback(s){r&&e.removeListener("backNavigationTriggered",r),r=s,s&&e.addListener("backNavigationTriggered",s)},async show(){await t.updateBackState({visible:!0}),this.visible=!0},async hide(){await t.updateBackState({visible:!1}),this.visible=!1},async enableWebNavigation(){n=iS({back:this,emitter:e})},async disableWebNavigation(){n?.(),n=void 0}}};function iS({emitter:t,back:e}){const n=oS();if(n)return aS({emitter:t,back:e,navigation:n});if(typeof window<"u")return cS({emitter:t,back:e,window})}function oS(){if(typeof window<"u"&&window.navigation!==void 0)return window.navigation}function aS({emitter:t,back:e,navigation:n}){function r(){n.canGoBack?e.show():e.hide()}function s(){e.visible&&n.canGoBack&&n.back()}return n.addEventListener("navigatesuccess",r),t.addListener("backNavigationTriggered",s),()=>{n.removeEventListener("navigatesuccess",r),t.removeListener("backNavigationTriggered",s)}}function cS({emitter:t,back:e,window:n}){e.show();function r(){e.visible&&n.history.back()}return t.addListener("backNavigationTriggered",r),()=>{t.removeListener("backNavigationTriggered",r)}}const uS="0.1.1";function dS(){return uS}let lS=class Su extends Error{constructor(e,n={}){const r=(()=>{if(n.cause instanceof Su){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause?.message?n.cause.message:n.details})(),s=n.cause instanceof Su&&n.cause.docsPath||n.docsPath,o=`https://oxlib.sh${s??""}`,a=[e||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||s?["",r?`Details: ${r}`:void 0,s?`See: ${o}`:void 0]:[]].filter(d=>typeof d=="string").join(`
35
- `);super(a,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${dS()}`}),this.cause=n.cause,this.details=r,this.docs=o,this.docsPath=s,this.shortMessage=e}walk(e){return Eh(this,e)}};function Eh(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?Eh(t.cause,e):e?null:t}function wh(t,e={}){const{raw:n=!1}=e,r=t;if(n)return t;if(r.error){const{code:s}=r.error,i=s===Kr.code?Kr:s===$s.code?$s:s===Zs.code?Zs:s===Ks.code?Ks:s===Gs.code?Gs:s===Ws.code?Ws:s===Hs.code?Hs:s===Ys.code?Ys:s===zs.code?zs:s===js.code?js:s===Vs.code?Vs:s===qs.code?qs:Kt;throw new i(r.error)}return r.result}let Kt=class extends Error{constructor(e){const{code:n,message:r,data:s}=e;super(r),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.BaseError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=n,this.data=s}};class $s extends Kt{constructor(e={}){super({message:"Missing or invalid parameters.",...e,code:$s.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidInputError"})}}Object.defineProperty($s,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class zs extends Kt{constructor(e={}){super({message:"Requested resource not found.",...e,code:zs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceNotFoundError"})}}Object.defineProperty(zs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class js extends Kt{constructor(e={}){super({message:"Requested resource not available.",...e,code:js.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceUnavailableError"})}}Object.defineProperty(js,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class Vs extends Kt{constructor(e={}){super({message:"Transaction creation failed.",...e,code:Vs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.TransactionRejectedError"})}}Object.defineProperty(Vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class Hs extends Kt{constructor(e={}){super({message:"Method is not implemented.",...e,code:Hs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotSupportedError"})}}Object.defineProperty(Hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class Gs extends Kt{constructor(e={}){super({message:"Rate limit exceeded.",...e,code:Gs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.LimitExceededError"})}}Object.defineProperty(Gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class qs extends Kt{constructor(e={}){super({message:"JSON-RPC version not supported.",...e,code:qs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.VersionNotSupportedError"})}}Object.defineProperty(qs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class Ks extends Kt{constructor(e={}){super({message:"Input is not a valid JSON-RPC request.",...e,code:Ks.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidRequestError"})}}Object.defineProperty(Ks,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class Ws extends Kt{constructor(e={}){super({message:"Method does not exist.",...e,code:Ws.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotFoundError"})}}Object.defineProperty(Ws,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class Zs extends Kt{constructor(e={}){super({message:"Invalid method parameters.",...e,code:Zs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidParamsError"})}}Object.defineProperty(Zs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class Kr extends Kt{constructor(e={}){super({message:"Internal JSON-RPC error.",...e,code:Kr.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InternalErrorError"})}}Object.defineProperty(Kr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Ys extends Kt{constructor(e={}){super({message:"Failed to parse JSON-RPC response.",...e,code:Ys.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ParseError"})}}Object.defineProperty(Ys,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class mr extends Error{constructor(e,n){super(n),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderRpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=e,this.details=n}}class vh extends mr{constructor({message:e="The user rejected the request."}={}){super(4001,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UserRejectedRequestError"})}}Object.defineProperty(vh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class Rh extends mr{constructor({message:e="The requested method and/or account has not been authorized by the user."}={}){super(4100,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnauthorizedError"})}}Object.defineProperty(Rh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class Ah extends mr{constructor({message:e="The provider does not support the requested method."}={}){super(4200,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedMethodError"})}}Object.defineProperty(Ah,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class Sh extends mr{constructor({message:e="The provider is disconnected from all chains."}={}){super(4900,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.DisconnectedError"})}}Object.defineProperty(Sh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class xh extends mr{constructor({message:e="The provider is not connected to the requested chain."}={}){super(4901,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.ChainDisconnectedError"})}}Object.defineProperty(xh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});function fS(){const t=new Yl;return{get eventNames(){return t.eventNames.bind(t)},get listenerCount(){return t.listenerCount.bind(t)},get listeners(){return t.listeners.bind(t)},addListener:t.addListener.bind(t),emit:t.emit.bind(t),off:t.off.bind(t),on:t.on.bind(t),once:t.once.bind(t),removeAllListeners:t.removeAllListeners.bind(t),removeListener:t.removeListener.bind(t)}}function hS(t,e={}){const{includeEvents:n=!0}=e;if(!t)throw new pS;return{...n?{on:t.on?.bind(t),removeListener:t.removeListener?.bind(t)}:{},async request(r){const s=await t.request(r);return s&&typeof s=="object"&&"jsonrpc"in s?wh(s):s}}}class pS extends lS{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}}function mS(t={}){let e=t.id??0;return{prepare(n){return gS({id:e++,...n})},get id(){return e}}}function gS(t){return{...t,jsonrpc:"2.0"}}/**
34
+ Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(e){const{signatures:n}=this,r=[];Wt(r,n.length);const s=r.length+n.length*64+e.length,i=xe.Buffer.alloc(s);return yt(n.length<256),xe.Buffer.from(r).copy(i,0),n.forEach(({signature:o},a)=>{o!==null&&(yt(o.length===64,"signature has invalid length"),xe.Buffer.from(o).copy(i,r.length+a*64))}),e.copy(i,r.length+n.length*64),yt(i.length<=Fr,`Transaction too large: ${i.length} > ${Fr}`),i}get keys(){return yt(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return yt(this.instructions.length===1),this.instructions[0].programId}get data(){return yt(this.instructions.length===1),this.instructions[0].data}static from(e){let n=[...e];const r=Kt(n);let s=[];for(let i=0;i<r;i++){const o=Zt(n,0,Ji);s.push(Dt.encode(xe.Buffer.from(o)))}return to.populate(zr.from(n),s)}static populate(e,n=[]){const r=new to;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),n.forEach((s,i)=>{const o={signature:s==Dt.encode(AA)?null:Dt.decode(s),publicKey:e.accountKeys[i]};r.signatures.push(o)}),e.instructions.forEach(s=>{const i=s.accounts.map(o=>{const a=e.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(d=>d.publicKey.toString()===a.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});r.instructions.push(new th({keys:i,programId:e.accountKeys[s.programIdIndex],data:Dt.decode(s.data)}))}),r._message=e,r._json=r.toJSON(),r}}class Oc{get version(){return this.message.version}constructor(e,n){if(this.signatures=void 0,this.message=void 0,n!==void 0)yt(n.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=n;else{const r=[];for(let s=0;s<e.header.numRequiredSignatures;s++)r.push(new Uint8Array(Ji));this.signatures=r}this.message=e}serialize(){const e=this.message.serialize(),n=Array();Wt(n,this.signatures.length);const r=M.struct([M.blob(n.length,"encodedSignaturesLength"),M.seq(_A(),this.signatures.length,"signatures"),M.blob(e.length,"serializedMessage")]),s=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(n),signatures:this.signatures,serializedMessage:e},s);return s.slice(0,i)}static deserialize(e){let n=[...e];const r=[],s=Kt(n);for(let o=0;o<s;o++)r.push(new Uint8Array(Zt(n,0,Ji)));const i=Tc.deserialize(new Uint8Array(n));return new Oc(i,r)}sign(e){const n=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of e){const i=r.findIndex(o=>o.equals(s.publicKey));yt(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=Jf(n,s.secretKey)}}addSignature(e,n){yt(n.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(e));yt(s>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=n}}new ye("SysvarC1ock11111111111111111111111111111111"),new ye("SysvarEpochSchedu1e111111111111111111111111"),new ye("Sysvar1nstructions1111111111111111111111111"),new ye("SysvarRecentB1ockHashes11111111111111111111"),new ye("SysvarRent111111111111111111111111111111111"),new ye("SysvarRewards111111111111111111111111111111"),new ye("SysvarS1otHashes111111111111111111111111111"),new ye("SysvarS1otHistory11111111111111111111111111"),new ye("SysvarStakeHistory1111111111111111111111111");const xA=M.nu64("lamportsPerSignature");M.struct([M.u32("version"),M.u32("state"),Se("authorizedPubkey"),Se("nonce"),M.struct([xA],"feeCalculator")]).span;function jr(t){const e=M.blob(8,t),n=e.decode.bind(e),r=e.encode.bind(e),s=e,i=$R();return s.decode=(o,a)=>{const d=n(o,a);return i.decode(d)},s.encode=(o,a,d)=>{const m=i.encode(o);return r(m,a,d)},s}Object.freeze({Create:{index:0,layout:M.struct([M.u32("instruction"),M.ns64("lamports"),M.ns64("space"),Se("programId")])},Assign:{index:1,layout:M.struct([M.u32("instruction"),Se("programId")])},Transfer:{index:2,layout:M.struct([M.u32("instruction"),jr("lamports")])},CreateWithSeed:{index:3,layout:M.struct([M.u32("instruction"),Se("base"),$r("seed"),M.ns64("lamports"),M.ns64("space"),Se("programId")])},AdvanceNonceAccount:{index:4,layout:M.struct([M.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:M.struct([M.u32("instruction"),M.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:M.struct([M.u32("instruction"),Se("authorized")])},AuthorizeNonceAccount:{index:7,layout:M.struct([M.u32("instruction"),Se("authorized")])},Allocate:{index:8,layout:M.struct([M.u32("instruction"),M.ns64("space")])},AllocateWithSeed:{index:9,layout:M.struct([M.u32("instruction"),Se("base"),$r("seed"),M.ns64("space"),Se("programId")])},AssignWithSeed:{index:10,layout:M.struct([M.u32("instruction"),Se("base"),$r("seed"),Se("programId")])},TransferWithSeed:{index:11,layout:M.struct([M.u32("instruction"),jr("lamports"),$r("seed"),Se("programId")])},UpgradeNonceAccount:{index:12,layout:M.struct([M.u32("instruction")])}}),new ye("11111111111111111111111111111111"),new ye("BPFLoader2111111111111111111111111111111111"),M.struct([M.u32("typeIndex"),jr("deactivationSlot"),M.nu64("lastExtendedSlot"),M.u8("lastExtendedStartIndex"),M.u8(),M.seq(Se(),M.offset(M.u8(),-1),"authority")]);const We=Ps(gc(ye),se(),t=>new ye(t)),nh=yc([se(),He("base64")]),Ic=Ps(gc(xe.Buffer),nh,t=>xe.Buffer.from(t[0],"base64"));function rh(t){return Ft([Q({jsonrpc:He("2.0"),id:se(),result:t}),Q({jsonrpc:He("2.0"),id:se(),error:Q({code:Dr(),message:se(),data:fe(KR())})})])}const SA=rh(Dr());function Ue(t){return Ps(rh(t),SA,e=>"error"in e?e:{...e,result:ks(e.result,t)})}function sn(t){return Ue(Q({context:Q({slot:G()}),value:t}))}function no(t){return Q({context:Q({slot:G()}),value:t})}const TA=Q({foundation:G(),foundationTerm:G(),initial:G(),taper:G(),terminal:G()});Ue(ae(ce(Q({epoch:G(),effectiveSlot:G(),amount:G(),postBalance:G(),commission:fe(ce(G()))}))));const OA=ae(Q({slot:G(),prioritizationFee:G()})),IA=Q({total:G(),validator:G(),foundation:G(),epoch:G()}),NA=Q({epoch:G(),slotIndex:G(),slotsInEpoch:G(),absoluteSlot:G(),blockHeight:fe(G()),transactionCount:fe(G())}),CA=Q({slotsPerEpoch:G(),leaderScheduleSlotOffset:G(),warmup:pn(),firstNormalEpoch:G(),firstNormalSlot:G()}),MA=zf(se(),ae(G())),dr=ce(Ft([Q({}),se()])),BA=Q({err:dr}),kA=He("receivedSignature");Q({"solana-core":se(),"feature-set":fe(G())});const LA=Q({program:se(),programId:We,parsed:Dr()}),PA=Q({programId:We,accounts:ae(We),data:se()});sn(Q({err:ce(Ft([Q({}),se()])),logs:ce(ae(se())),accounts:fe(ce(ae(ce(Q({executable:pn(),owner:se(),lamports:G(),data:ae(se()),rentEpoch:fe(G())}))))),unitsConsumed:fe(G()),returnData:fe(ce(Q({programId:se(),data:yc([se(),He("base64")])}))),innerInstructions:fe(ce(ae(Q({index:G(),instructions:ae(Ft([LA,PA]))}))))})),sn(Q({byIdentity:zf(se(),ae(G())),range:Q({firstSlot:G(),lastSlot:G()})})),Ue(TA),Ue(IA),Ue(OA),Ue(NA),Ue(CA),Ue(MA),Ue(G()),sn(Q({total:G(),circulating:G(),nonCirculating:G(),nonCirculatingAccounts:ae(We)}));const UA=Q({amount:se(),uiAmount:ce(G()),decimals:G(),uiAmountString:fe(se())});sn(ae(Q({address:We,amount:se(),uiAmount:ce(G()),decimals:G(),uiAmountString:fe(se())}))),sn(ae(Q({pubkey:We,account:Q({executable:pn(),owner:We,lamports:G(),data:Ic,rentEpoch:G()})})));const Nc=Q({program:se(),parsed:Dr(),space:G()});sn(ae(Q({pubkey:We,account:Q({executable:pn(),owner:We,lamports:G(),data:Nc,rentEpoch:G()})}))),sn(ae(Q({lamports:G(),address:We})));const Cc=Q({executable:pn(),owner:We,lamports:G(),data:Ic,rentEpoch:G()});Q({pubkey:We,account:Cc});const DA=Ps(Ft([gc(xe.Buffer),Nc]),Ft([nh,Nc]),t=>Array.isArray(t)?ks(t,Ic):t),FA=Q({executable:pn(),owner:We,lamports:G(),data:DA,rentEpoch:G()});Q({pubkey:We,account:FA}),Q({state:Ft([He("active"),He("inactive"),He("activating"),He("deactivating")]),active:G(),inactive:G()}),Ue(ae(Q({signature:se(),slot:G(),err:dr,memo:ce(se()),blockTime:fe(ce(G()))}))),Ue(ae(Q({signature:se(),slot:G(),err:dr,memo:ce(se()),blockTime:fe(ce(G()))}))),Q({subscription:G(),result:no(Cc)});const $A=Q({pubkey:We,account:Cc});Q({subscription:G(),result:no($A)});const zA=Q({parent:G(),slot:G(),root:G()});Q({subscription:G(),result:zA});const jA=Ft([Q({type:Ft([He("firstShredReceived"),He("completed"),He("optimisticConfirmation"),He("root")]),slot:G(),timestamp:G()}),Q({type:He("createdBank"),parent:G(),slot:G(),timestamp:G()}),Q({type:He("frozen"),slot:G(),timestamp:G(),stats:Q({numTransactionEntries:G(),numSuccessfulTransactions:G(),numFailedTransactions:G(),maxTransactionsPerEntry:G()})}),Q({type:He("dead"),slot:G(),timestamp:G(),err:se()})]);Q({subscription:G(),result:jA}),Q({subscription:G(),result:no(Ft([BA,kA]))}),Q({subscription:G(),result:G()}),Q({pubkey:se(),gossip:ce(se()),tpu:ce(se()),rpc:ce(se()),version:ce(se())});const sh=Q({votePubkey:se(),nodePubkey:se(),activatedStake:G(),epochVoteAccount:pn(),epochCredits:ae(yc([G(),G(),G()])),commission:G(),lastVote:G(),rootSlot:ce(G())});Ue(Q({current:ae(sh),delinquent:ae(sh)}));const VA=Ft([He("processed"),He("confirmed"),He("finalized")]),GA=Q({slot:G(),confirmations:ce(G()),err:dr,confirmationStatus:fe(VA)});sn(ae(ce(GA))),Ue(G());const ih=Q({accountKey:We,writableIndexes:ae(G()),readonlyIndexes:ae(G())}),Mc=Q({signatures:ae(se()),message:Q({accountKeys:ae(se()),header:Q({numRequiredSignatures:G(),numReadonlySignedAccounts:G(),numReadonlyUnsignedAccounts:G()}),instructions:ae(Q({accounts:ae(G()),data:se(),programIdIndex:G()})),recentBlockhash:se(),addressTableLookups:fe(ae(ih))})}),oh=Q({pubkey:We,signer:pn(),writable:pn(),source:fe(Ft([He("transaction"),He("lookupTable")]))}),ah=Q({accountKeys:ae(oh),signatures:ae(se())}),ch=Q({parsed:Dr(),program:se(),programId:We}),uh=Q({accounts:ae(We),data:se(),programId:We}),HA=Ft([uh,ch]),qA=Ft([Q({parsed:Dr(),program:se(),programId:se()}),Q({accounts:ae(se()),data:se(),programId:se()})]),dh=Ps(HA,qA,t=>"accounts"in t?ks(t,uh):ks(t,ch)),lh=Q({signatures:ae(se()),message:Q({accountKeys:ae(oh),instructions:ae(dh),recentBlockhash:se(),addressTableLookups:fe(ce(ae(ih)))})}),ro=Q({accountIndex:G(),mint:se(),owner:fe(se()),programId:fe(se()),uiTokenAmount:UA}),fh=Q({writable:ae(We),readonly:ae(We)}),so=Q({err:dr,fee:G(),innerInstructions:fe(ce(ae(Q({index:G(),instructions:ae(Q({accounts:ae(G()),data:se(),programIdIndex:G()}))})))),preBalances:ae(G()),postBalances:ae(G()),logMessages:fe(ce(ae(se()))),preTokenBalances:fe(ce(ae(ro))),postTokenBalances:fe(ce(ae(ro))),loadedAddresses:fe(fh),computeUnitsConsumed:fe(G()),costUnits:fe(G())}),Bc=Q({err:dr,fee:G(),innerInstructions:fe(ce(ae(Q({index:G(),instructions:ae(dh)})))),preBalances:ae(G()),postBalances:ae(G()),logMessages:fe(ce(ae(se()))),preTokenBalances:fe(ce(ae(ro))),postTokenBalances:fe(ce(ae(ro))),loadedAddresses:fe(fh),computeUnitsConsumed:fe(G()),costUnits:fe(G())}),Vr=Ft([He(0),He("legacy")]),lr=Q({pubkey:se(),lamports:G(),postBalance:ce(G()),rewardType:ce(se()),commission:fe(ce(G()))});Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:Mc,meta:ce(so),version:fe(Vr)})),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:ah,meta:ce(so),version:fe(Vr)})),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:lh,meta:ce(Bc),version:fe(Vr)})),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:ah,meta:ce(Bc),version:fe(Vr)})),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:Mc,meta:ce(so)})),rewards:fe(ae(lr)),blockTime:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),signatures:ae(se()),blockTime:ce(G())}))),Ue(ce(Q({slot:G(),meta:ce(so),blockTime:fe(ce(G())),transaction:Mc,version:fe(Vr)}))),Ue(ce(Q({slot:G(),transaction:lh,meta:ce(Bc),blockTime:fe(ce(G())),version:fe(Vr)}))),sn(Q({blockhash:se(),lastValidBlockHeight:G()})),sn(pn());const KA=Q({slot:G(),numTransactions:G(),numSlots:G(),samplePeriodSecs:G()});Ue(ae(KA)),sn(ce(Q({feeCalculator:Q({lamportsPerSignature:G()})}))),Ue(se()),Ue(se());const WA=Q({err:dr,logs:ae(se()),signature:se()});Q({result:no(WA),subscription:G()}),Object.freeze({CreateLookupTable:{index:0,layout:M.struct([M.u32("instruction"),jr("recentSlot"),M.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:M.struct([M.u32("instruction")])},ExtendLookupTable:{index:2,layout:M.struct([M.u32("instruction"),jr(),M.seq(Se(),M.offset(M.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:M.struct([M.u32("instruction")])},CloseLookupTable:{index:4,layout:M.struct([M.u32("instruction")])}}),new ye("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:M.struct([M.u8("instruction"),M.u32("units"),M.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:M.struct([M.u8("instruction"),M.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:M.struct([M.u8("instruction"),M.u32("units")])},SetComputeUnitPrice:{index:3,layout:M.struct([M.u8("instruction"),jr("microLamports")])}}),new ye("ComputeBudget111111111111111111111111111111"),M.struct([M.u8("numSignatures"),M.u8("padding"),M.u16("signatureOffset"),M.u16("signatureInstructionIndex"),M.u16("publicKeyOffset"),M.u16("publicKeyInstructionIndex"),M.u16("messageDataOffset"),M.u16("messageDataSize"),M.u16("messageInstructionIndex")]),new ye("Ed25519SigVerify111111111111111111111111111"),$a.utils.isValidPrivateKey,$a.getPublicKey,M.struct([M.u8("numSignatures"),M.u16("signatureOffset"),M.u8("signatureInstructionIndex"),M.u16("ethAddressOffset"),M.u8("ethAddressInstructionIndex"),M.u16("messageDataOffset"),M.u16("messageDataSize"),M.u8("messageInstructionIndex"),M.blob(20,"ethAddress"),M.blob(64,"signature"),M.u8("recoveryId")]),new ye("KeccakSecp256k11111111111111111111111111111");var hh;new ye("StakeConfig11111111111111111111111111111111");class ph{constructor(e,n,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=n,this.custodian=r}}hh=ph,ph.default=new hh(0,0,ye.default),Object.freeze({Initialize:{index:0,layout:M.struct([M.u32("instruction"),wA(),EA()])},Authorize:{index:1,layout:M.struct([M.u32("instruction"),Se("newAuthorized"),M.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:M.struct([M.u32("instruction")])},Split:{index:3,layout:M.struct([M.u32("instruction"),M.ns64("lamports")])},Withdraw:{index:4,layout:M.struct([M.u32("instruction"),M.ns64("lamports")])},Deactivate:{index:5,layout:M.struct([M.u32("instruction")])},Merge:{index:7,layout:M.struct([M.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:M.struct([M.u32("instruction"),Se("newAuthorized"),M.u32("stakeAuthorizationType"),$r("authoritySeed"),Se("authorityOwner")])}}),new ye("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:M.struct([M.u32("instruction"),vA()])},Authorize:{index:1,layout:M.struct([M.u32("instruction"),Se("newAuthorized"),M.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:M.struct([M.u32("instruction"),M.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:M.struct([M.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:M.struct([M.u32("instruction"),RA()])}}),new ye("Vote111111111111111111111111111111111111111"),new ye("Va1idator1nfo111111111111111111111111111111"),Q({name:se(),website:fe(se()),details:fe(se()),iconUrl:fe(se()),keybaseUsername:fe(se())}),new ye("Vote111111111111111111111111111111111111111"),M.struct([Se("nodePubkey"),Se("authorizedWithdrawer"),M.u8("commission"),M.nu64(),M.seq(M.struct([M.nu64("slot"),M.u32("confirmationCount")]),M.offset(M.u32(),-8),"votes"),M.u8("rootSlotValid"),M.nu64("rootSlot"),M.nu64(),M.seq(M.struct([M.nu64("epoch"),Se("authorizedVoter")]),M.offset(M.u32(),-8),"authorizedVoters"),M.struct([M.seq(M.struct([Se("authorizedPubkey"),M.nu64("epochOfLastAuthorizedSwitch"),M.nu64("targetEpoch")]),32,"buf"),M.nu64("idx"),M.u8("isEmpty")],"priorVoters"),M.nu64(),M.seq(M.struct([M.nu64("epoch"),M.nu64("credits"),M.nu64("prevCredits")]),M.offset(M.u32(),-8),"epochCredits"),M.struct([M.nu64("slot"),M.nu64("timestamp")],"lastTimestamp")]);const ZA=t=>({request:t,signMessage:e=>t({method:"signMessage",params:{message:e}}),signTransaction:e=>t({method:"signTransaction",params:{transaction:e}}),signAndSendTransaction:e=>t({method:"signAndSendTransaction",params:e})});function mh(t){return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64")}function YA(t){const e=Buffer.from(t,"base64");return Tc.deserializeMessageVersion(e)==="legacy"?Oc.deserialize(e):to.from(e)}function JA(t){return async n=>{if(n.method==="connect")return await t(n);if(n.method==="signMessage")return await t(n);if(n.method==="signAndSendTransaction"){const{transaction:r}=n.params,s={transaction:mh(r)};return await t({method:"signAndSendTransaction",params:s})}if(n.method==="signTransaction"){const{transaction:r}=n.params,s={transaction:mh(r)},{signedTransaction:i}=await t({method:"signTransaction",params:s});return{signedTransaction:YA(i)}}}}const XA=({miniAppHost:t,emitter:e})=>{let n,r=null;return{visible:!1,get onback(){return r},set onback(s){r&&e.removeListener("backNavigationTriggered",r),r=s,s&&e.addListener("backNavigationTriggered",s)},async show(){await t.updateBackState({visible:!0}),this.visible=!0},async hide(){await t.updateBackState({visible:!1}),this.visible=!1},async enableWebNavigation(){n=QA({back:this,emitter:e})},async disableWebNavigation(){n?.(),n=void 0}}};function QA({emitter:t,back:e}){const n=ex();if(n)return tx({emitter:t,back:e,navigation:n});if(typeof window<"u")return nx({emitter:t,back:e,window})}function ex(){if(typeof window<"u"&&window.navigation!==void 0)return window.navigation}function tx({emitter:t,back:e,navigation:n}){function r(){n.canGoBack?e.show():e.hide()}function s(){e.visible&&n.canGoBack&&n.back()}return n.addEventListener("navigatesuccess",r),t.addListener("backNavigationTriggered",s),()=>{n.removeEventListener("navigatesuccess",r),t.removeListener("backNavigationTriggered",s)}}function nx({emitter:t,back:e,window:n}){e.show();function r(){e.visible&&n.history.back()}return t.addListener("backNavigationTriggered",r),()=>{t.removeListener("backNavigationTriggered",r)}}const rx="0.1.1";function sx(){return rx}let ix=class Eu extends Error{constructor(e,n={}){const r=(()=>{if(n.cause instanceof Eu){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause?.message?n.cause.message:n.details})(),s=n.cause instanceof Eu&&n.cause.docsPath||n.docsPath,o=`https://oxlib.sh${s??""}`,a=[e||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||s?["",r?`Details: ${r}`:void 0,s?`See: ${o}`:void 0]:[]].filter(d=>typeof d=="string").join(`
35
+ `);super(a,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${sx()}`}),this.cause=n.cause,this.details=r,this.docs=o,this.docsPath=s,this.shortMessage=e}walk(e){return gh(this,e)}};function gh(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?gh(t.cause,e):e?null:t}function yh(t,e={}){const{raw:n=!1}=e,r=t;if(n)return t;if(r.error){const{code:s}=r.error,i=s===Gr.code?Gr:s===Us.code?Us:s===qs.code?qs:s===Gs.code?Gs:s===js.code?js:s===Hs.code?Hs:s===zs.code?zs:s===Ks.code?Ks:s===Ds.code?Ds:s===Fs.code?Fs:s===$s.code?$s:s===Vs.code?Vs:Gt;throw new i(r.error)}return r.result}let Gt=class extends Error{constructor(e){const{code:n,message:r,data:s}=e;super(r),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.BaseError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=n,this.data=s}};class Us extends Gt{constructor(e={}){super({message:"Missing or invalid parameters.",...e,code:Us.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidInputError"})}}Object.defineProperty(Us,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class Ds extends Gt{constructor(e={}){super({message:"Requested resource not found.",...e,code:Ds.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceNotFoundError"})}}Object.defineProperty(Ds,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class Fs extends Gt{constructor(e={}){super({message:"Requested resource not available.",...e,code:Fs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceUnavailableError"})}}Object.defineProperty(Fs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class $s extends Gt{constructor(e={}){super({message:"Transaction creation failed.",...e,code:$s.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.TransactionRejectedError"})}}Object.defineProperty($s,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class zs extends Gt{constructor(e={}){super({message:"Method is not implemented.",...e,code:zs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotSupportedError"})}}Object.defineProperty(zs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class js extends Gt{constructor(e={}){super({message:"Rate limit exceeded.",...e,code:js.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.LimitExceededError"})}}Object.defineProperty(js,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class Vs extends Gt{constructor(e={}){super({message:"JSON-RPC version not supported.",...e,code:Vs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.VersionNotSupportedError"})}}Object.defineProperty(Vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class Gs extends Gt{constructor(e={}){super({message:"Input is not a valid JSON-RPC request.",...e,code:Gs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidRequestError"})}}Object.defineProperty(Gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class Hs extends Gt{constructor(e={}){super({message:"Method does not exist.",...e,code:Hs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotFoundError"})}}Object.defineProperty(Hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class qs extends Gt{constructor(e={}){super({message:"Invalid method parameters.",...e,code:qs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidParamsError"})}}Object.defineProperty(qs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class Gr extends Gt{constructor(e={}){super({message:"Internal JSON-RPC error.",...e,code:Gr.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InternalErrorError"})}}Object.defineProperty(Gr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Ks extends Gt{constructor(e={}){super({message:"Failed to parse JSON-RPC response.",...e,code:Ks.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ParseError"})}}Object.defineProperty(Ks,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class fr extends Error{constructor(e,n){super(n),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderRpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=e,this.details=n}}class bh extends fr{constructor({message:e="The user rejected the request."}={}){super(4001,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UserRejectedRequestError"})}}Object.defineProperty(bh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class _h extends fr{constructor({message:e="The requested method and/or account has not been authorized by the user."}={}){super(4100,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnauthorizedError"})}}Object.defineProperty(_h,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class wh extends fr{constructor({message:e="The provider does not support the requested method."}={}){super(4200,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedMethodError"})}}Object.defineProperty(wh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class Eh extends fr{constructor({message:e="The provider is disconnected from all chains."}={}){super(4900,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.DisconnectedError"})}}Object.defineProperty(Eh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class vh extends fr{constructor({message:e="The provider is not connected to the requested chain."}={}){super(4901,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.ChainDisconnectedError"})}}Object.defineProperty(vh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});function ox(){const t=new ql;return{get eventNames(){return t.eventNames.bind(t)},get listenerCount(){return t.listenerCount.bind(t)},get listeners(){return t.listeners.bind(t)},addListener:t.addListener.bind(t),emit:t.emit.bind(t),off:t.off.bind(t),on:t.on.bind(t),once:t.once.bind(t),removeAllListeners:t.removeAllListeners.bind(t),removeListener:t.removeListener.bind(t)}}function ax(t,e={}){const{includeEvents:n=!0}=e;if(!t)throw new cx;return{...n?{on:t.on?.bind(t),removeListener:t.removeListener?.bind(t)}:{},async request(r){const s=await t.request(r);return s&&typeof s=="object"&&"jsonrpc"in s?yh(s):s}}}class cx extends ix{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}}function ux(t={}){let e=t.id??0;return{prepare(n){return dx({id:e++,...n})},get id(){return e}}}function dx(t){return{...t,jsonrpc:"2.0"}}/**
36
36
  * @license
37
37
  * Copyright 2019 Google LLC
38
38
  * SPDX-License-Identifier: Apache-2.0
39
- */const Th=Symbol("Comlink.proxy"),yS=Symbol("Comlink.endpoint"),bS=Symbol("Comlink.releaseProxy"),Pc=Symbol("Comlink.finalizer"),co=Symbol("Comlink.thrown"),Ih=t=>typeof t=="object"&&t!==null||typeof t=="function",_S={canHandle:t=>Ih(t)&&t[Th],serialize(t){const{port1:e,port2:n}=new MessageChannel;return Nh(t,e),[n,[n]]},deserialize(t){return t.start(),Mh(t)}},ES={canHandle:t=>Ih(t)&&co in t,serialize({value:t}){let e;return t instanceof Error?e={isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:e={isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}},Oh=new Map([["proxy",_S],["throw",ES]]);function wS(t,e){for(const n of t)if(e===n||n==="*"||n instanceof RegExp&&n.test(e))return!0;return!1}function Nh(t,e=globalThis,n=["*"]){e.addEventListener("message",function r(s){if(!s||!s.data)return;if(!wS(n,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}const{id:i,type:o,path:a}=Object.assign({path:[]},s.data),d=(s.data.argumentList||[]).map(gr);let m;try{const g=a.slice(0,-1).reduce((I,N)=>I[N],t),S=a.reduce((I,N)=>I[N],t);switch(o){case"GET":m=S;break;case"SET":g[a.slice(-1)[0]]=gr(s.data.value),m=!0;break;case"APPLY":m=S.apply(g,d);break;case"CONSTRUCT":{const I=new S(...d);m=TS(I)}break;case"ENDPOINT":{const{port1:I,port2:N}=new MessageChannel;Nh(t,N),m=xS(I,[I])}break;case"RELEASE":m=void 0;break;default:return}}catch(g){m={value:g,[co]:0}}Promise.resolve(m).catch(g=>({value:g,[co]:0})).then(g=>{const[S,I]=ho(g);e.postMessage(Object.assign(Object.assign({},S),{id:i}),I),o==="RELEASE"&&(e.removeEventListener("message",r),Ch(e),Pc in t&&typeof t[Pc]=="function"&&t[Pc]())}).catch(g=>{const[S,I]=ho({value:new TypeError("Unserializable return value"),[co]:0});e.postMessage(Object.assign(Object.assign({},S),{id:i}),I)})}),e.start&&e.start()}function vS(t){return t.constructor.name==="MessagePort"}function Ch(t){vS(t)&&t.close()}function Mh(t,e){const n=new Map;return t.addEventListener("message",function(s){const{data:i}=s;if(!i||!i.id)return;const o=n.get(i.id);if(o)try{o(i)}finally{n.delete(i.id)}}),Fc(t,n,[],e)}function uo(t){if(t)throw new Error("Proxy has been released and is not useable")}function kh(t){return Wr(t,new Map,{type:"RELEASE"}).then(()=>{Ch(t)})}const lo=new WeakMap,fo="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(lo.get(t)||0)-1;lo.set(t,e),e===0&&kh(t)});function RS(t,e){const n=(lo.get(e)||0)+1;lo.set(e,n),fo&&fo.register(t,e,t)}function AS(t){fo&&fo.unregister(t)}function Fc(t,e,n=[],r=function(){}){let s=!1;const i=new Proxy(r,{get(o,a){if(uo(s),a===bS)return()=>{AS(i),kh(t),e.clear(),s=!0};if(a==="then"){if(n.length===0)return{then:()=>i};const d=Wr(t,e,{type:"GET",path:n.map(m=>m.toString())}).then(gr);return d.then.bind(d)}return Fc(t,e,[...n,a])},set(o,a,d){uo(s);const[m,g]=ho(d);return Wr(t,e,{type:"SET",path:[...n,a].map(S=>S.toString()),value:m},g).then(gr)},apply(o,a,d){uo(s);const m=n[n.length-1];if(m===yS)return Wr(t,e,{type:"ENDPOINT"}).then(gr);if(m==="bind")return Fc(t,e,n.slice(0,-1));const[g,S]=Bh(d);return Wr(t,e,{type:"APPLY",path:n.map(I=>I.toString()),argumentList:g},S).then(gr)},construct(o,a){uo(s);const[d,m]=Bh(a);return Wr(t,e,{type:"CONSTRUCT",path:n.map(g=>g.toString()),argumentList:d},m).then(gr)}});return RS(i,t),i}function SS(t){return Array.prototype.concat.apply([],t)}function Bh(t){const e=t.map(ho);return[e.map(n=>n[0]),SS(e.map(n=>n[1]))]}const Uh=new WeakMap;function xS(t,e){return Uh.set(t,e),t}function TS(t){return Object.assign(t,{[Th]:!0})}function IS(t,e=globalThis,n="*"){return{postMessage:(r,s)=>t.postMessage(r,n,s),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function ho(t){for(const[e,n]of Oh)if(n.canHandle(t)){const[r,s]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},s]}return[{type:"RAW",value:t},Uh.get(t)||[]]}function gr(t){switch(t.type){case"HANDLER":return Oh.get(t.name).deserialize(t.value);case"RAW":return t.value}}function Wr(t,e,n,r){return new Promise(s=>{const i=OS();e.set(i,s),t.start&&t.start(),t.postMessage(Object.assign({id:i},n),r)})}function OS(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const NS={postMessage(){},addEventListener:()=>{},removeEventListener:()=>{}},CS={postMessage:t=>{window.ReactNativeWebView.postMessage(JSON.stringify(t))},addEventListener:(t,e,...n)=>{document.addEventListener("FarcasterFrameCallback",e,...n)},removeEventListener:(t,e)=>{document.removeEventListener("FarcasterFrameCallback",e)}},MS=typeof window>"u"?NS:window?.ReactNativeWebView?CS:IS(window?.parent??window),_e=Mh(MS),$c=fS(),kS=mS();function BS({code:t,details:e}){switch(t){case 4001:return new vh;case 4100:return new Rh;case 4200:return new Ah;case 4900:return new Sh;case 4901:return new xh;default:return new mr(t,e??"Unknown provider RPC error")}}const Js=hS({...$c,async request(t){const e=kS.prepare(t);try{const n=await _e.ethProviderRequestV2(e).then(r=>wh(r,{request:e,raw:!0}));if(n.error)throw BS(n.error);return n.result}catch(n){if(n instanceof Error&&n.message.match(/cannot read property 'apply'/i))return await _e.ethProviderRequest(e);throw n instanceof mr||n instanceof Kt?n:new Kr({message:n instanceof Error?n.message:void 0})}}});async function US(){try{const t=await _e.getCapabilities();return!t.includes("wallet.getEthereumProvider")&&!t.includes("wallet.getEvmProvider")?void 0:Js}catch{return Js}}function Lh(t){const e=new CustomEvent("eip6963:announceProvider",{detail:Object.freeze(t)});window.dispatchEvent(e);const n=()=>window.dispatchEvent(e);return window.addEventListener("eip6963:requestProvider",n),()=>window.removeEventListener("eip6963:requestProvider",n)}typeof document<"u"&&(document.addEventListener("eip6963:requestProvider",()=>{_e.eip6963RequestProvider()}),document.addEventListener("FarcasterFrameEthProviderEvent",t=>{if(t instanceof MessageEvent){const e=t.data;$c.emit(e.event,...e.params)}}),document.addEventListener("FarcasterFrameEvent",t=>{if(t instanceof MessageEvent){const e=t.data;e.event==="eip6963:announceProvider"&&Lh({info:e.info,provider:Js})}})),typeof window<"u"&&(window.addEventListener("eip6963:requestProvider",()=>{_e.eip6963RequestProvider()}),window.addEventListener("message",t=>{if(t instanceof MessageEvent&&t.data.type==="frameEthProviderEvent"){const e=t.data;$c.emit(e.event,...e.params)}}),window.addEventListener("message",t=>{if(t instanceof MessageEvent&&t.data.type==="frameEvent"){const e=t.data.event;e.event==="eip6963:announceProvider"&&Lh({info:e.info,provider:Js})}})),new TextEncoder;const Dh=new TextDecoder,LS=t=>{const e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n},DS=t=>{let e=t;e instanceof Uint8Array&&(e=Dh.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return LS(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};function PS(t){return typeof t=="object"&&t!==null}function FS(t){if(!PS(t)||Object.prototype.toString.call(t)!=="[object Object]")return!1;if(Object.getPrototypeOf(t)===null)return!0;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}class Vt extends Error{constructor(e,n){super(e,n),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}Vt.code="ERR_JOSE_GENERIC";class $S extends Vt{constructor(e,n,r="unspecified",s="unspecified"){super(e,{cause:{claim:r,reason:s,payload:n}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=r,this.reason=s,this.payload=n}}$S.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class zS extends Vt{constructor(e,n,r="unspecified",s="unspecified"){super(e,{cause:{claim:r,reason:s,payload:n}}),this.code="ERR_JWT_EXPIRED",this.claim=r,this.reason=s,this.payload=n}}zS.code="ERR_JWT_EXPIRED";class jS extends Vt{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}jS.code="ERR_JOSE_ALG_NOT_ALLOWED";class VS extends Vt{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}VS.code="ERR_JOSE_NOT_SUPPORTED";class HS extends Vt{constructor(e="decryption operation failed",n){super(e,n),this.code="ERR_JWE_DECRYPTION_FAILED"}}HS.code="ERR_JWE_DECRYPTION_FAILED";class GS extends Vt{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}GS.code="ERR_JWE_INVALID";class qS extends Vt{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}qS.code="ERR_JWS_INVALID";class Wn extends Vt{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}Wn.code="ERR_JWT_INVALID";class KS extends Vt{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}KS.code="ERR_JWK_INVALID";class WS extends Vt{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}WS.code="ERR_JWKS_INVALID";class ZS extends Vt{constructor(e="no applicable key found in the JSON Web Key Set",n){super(e,n),this.code="ERR_JWKS_NO_MATCHING_KEY"}}ZS.code="ERR_JWKS_NO_MATCHING_KEY";class YS extends Vt{constructor(e="multiple matching keys found in the JSON Web Key Set",n){super(e,n),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}YS.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class JS extends Vt{constructor(e="request timed out",n){super(e,n),this.code="ERR_JWKS_TIMEOUT"}}JS.code="ERR_JWKS_TIMEOUT";class XS extends Vt{constructor(e="signature verification failed",n){super(e,n),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}XS.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function QS(t){if(typeof t!="string")throw new Wn("JWTs must use Compact JWS serialization, JWT must be a string");const{1:e,length:n}=t.split(".");if(n===5)throw new Wn("Only JWTs using Compact JWS serialization can be decoded");if(n!==3)throw new Wn("Invalid JWT");if(!e)throw new Wn("JWTs must contain a payload");let r;try{r=DS(e)}catch{throw new Wn("Failed to base64url decode the payload")}let s;try{s=JSON.parse(Dh.decode(r))}catch{throw new Wn("Failed to parse the decoded payload as JSON")}if(!FS(s))throw new Wn("Invalid JWT Claims Set");return s}function ex(t){return QS(t)}class po extends Error{constructor(e,n={}){const r=(()=>{if(n.cause instanceof po){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&"details"in n.cause&&typeof n.cause.details=="string"?n.cause.details:n.cause?.message?n.cause.message:n.details})(),s=[e||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r?["",r?`Details: ${r}`:void 0]:[]].filter(i=>typeof i=="string").join(`
40
- `);super(s,n.cause?{cause:n.cause}:void 0),this.name="BaseError",this.cause=n.cause,this.details=r,this.shortMessage=e}}class Ph extends po{constructor({status:e}){super(`Request failed with status ${e}`),this.name="RequestFailedError"}}class tx extends po{constructor(e){super(e),this.name="InvalidToken"}}async function nx({origin:t}){const e=await fetch(`${t}/nonce`,{method:"POST"});if(!e.ok)throw new Ph({status:e.status});return await e.json()}async function rx({origin:t},e){const n=await fetch(`${t}/verify-siwf`,{method:"POST",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(e)});if(!n.ok)throw new Ph({status:n.status});const r=await n.json();if(r.valid===!1)throw new tx(r.message??"unknown");return{token:r.token}}function sx(t={}){return{origin:t.origin??"https://auth.farcaster.xyz"}}function ix(t={}){const e=sx(t);return{generateNonce:()=>nx(e),verifySiwf:n=>rx(e,n)}}const ox=/^(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+-.]*):\/\/)?(?<domain>[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\n)(?<address>0x[a-fA-F0-9]{40})\n\n(?:(?<statement>.*)\n\n)?/,ax=/(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.+))?/;function cx(t){const{scheme:e,statement:n,...r}=t.match(ox)?.groups??{},{chainId:s,expirationTime:i,issuedAt:o,notBefore:a,requestId:d,...m}=t.match(ax)?.groups??{},g=t.split("Resources:")[1]?.split(`
41
- - `).slice(1);return{...r,...m,...s?{chainId:Number(s)}:{},...i?{expirationTime:new Date(i)}:{},...o?{issuedAt:new Date(o)}:{},...a?{notBefore:new Date(a)}:{},...d?{requestId:d}:{},...g?{resources:g}:{},...e?{scheme:e}:{},...n?{statement:n}:{}}}const Fh=(()=>{let t,e;async function n(r){const s=ix({origin:r.quickAuthServerOrigin}),{nonce:i}=await s.generateNonce(),o=await _e.signIn({nonce:i,acceptAuthAddress:!0});if(o.result){const a=cx(o.result.message);if(!a.domain)throw new Error("Missing domain on SIWE message");const d=await s.verifySiwf({domain:a.domain,message:o.result.message,signature:o.result.signature});return t={token:d.token,payload:ex(d.token)},d}throw o.error.type==="rejected_by_user"?new Jl:new Error("Unreachable")}return{get token(){if(t&&new Date(t.payload.exp*1e3)>new Date(Date.now()+15e3))return t.token},async getToken(r={}){const s=r.force??!1;return t&&!s&&new Date(t.payload.exp*1e3)>new Date(Date.now()+15e3)?{token:t.token}:(e||(e=n(r)),e.finally(()=>{e=void 0}),e)},async fetch(r,s){const{token:i}=await this.getToken(),o=new Headers(s?.headers);return o.set("Authorization",`Bearer ${i}`),fetch(r,{...s,headers:o})}}})();function ux(){const t=new Yl;return{get eventNames(){return t.eventNames.bind(t)},get listenerCount(){return t.listenerCount.bind(t)},get listeners(){return t.listeners.bind(t)},addListener:t.addListener.bind(t),emit:t.emit.bind(t),off:t.off.bind(t),on:t.on.bind(t),once:t.once.bind(t),removeAllListeners:t.removeAllListeners.bind(t),removeListener:t.removeListener.bind(t)}}const Lt=ux(),{solanaProviderRequest:$h}=_e;let zh;$h&&(zh=tS(rS($h)));async function jh(){let t;try{t=await _e.getCapabilities()}catch{}if(t?.includes("wallet.getSolanaProvider"))return zh}let Vh=null;async function dx(t=1e3){if(Vh===!0)return!0;if(typeof window>"u"||!window.ReactNativeWebView&&window===window.parent)return!1;const e=await Promise.race([_e.context.then(n=>!!n),new Promise(n=>{setTimeout(()=>n(!1),t)})]).catch(()=>!1);return e&&(Vh=!0),e}const Hh=async()=>{const t=await _e.addFrame();if(t.result)return t.result;throw t.error.type==="invalid_domain_manifest"?new V1:t.error.type==="rejected_by_user"?new H1:new Error("Unreachable")},Gh={...Lt,getCapabilities:_e.getCapabilities,getChains:_e.getChains,isInMiniApp:dx,context:_e.context,back:sS({miniAppHost:_e,emitter:Lt}),quickAuth:Fh,actions:{setPrimaryButton:_e.setPrimaryButton.bind(_e),ready:async(t={})=>await _e.ready(t),close:_e.close.bind(_e),viewCast:_e.viewCast.bind(_e),viewProfile:_e.viewProfile.bind(_e),openMiniApp:_e.openMiniApp.bind(_e),signIn:async t=>{const e=await _e.signIn({...t,acceptAuthAddress:t.acceptAuthAddress??!0});if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new Jl:new Error("Unreachable")},openUrl:t=>{const e=typeof t=="string"?t:t.url;return _e.openUrl(e.trim())},addFrame:Hh,addMiniApp:Hh,composeCast(t={}){return _e.composeCast(t)},viewToken:_e.viewToken.bind(_e),sendToken:_e.sendToken.bind(_e),swapToken:_e.swapToken.bind(_e),requestCameraAndMicrophoneAccess:_e.requestCameraAndMicrophoneAccess.bind(_e)},experimental:{getSolanaProvider:jh,signManifest:async t=>{const e=await _e.signManifest(t);if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new G1:e.error.type==="invalid_domain"?new q1:e.error.type==="generic_error"?new K1(e.error.message):new Error("Unreachable")},quickAuth(t){return Fh.getToken(t)}},wallet:{ethProvider:Js,getEthereumProvider:US,getSolanaProvider:jh},haptics:{impactOccurred:_e.impactOccurred.bind(_e),notificationOccurred:_e.notificationOccurred.bind(_e),selectionChanged:_e.selectionChanged.bind(_e)}};typeof document<"u"&&document.addEventListener("FarcasterFrameEvent",t=>{if(t instanceof MessageEvent){const e=t.data;e.event==="primary_button_clicked"?Lt.emit("primaryButtonClicked"):e.event==="miniapp_added"?Lt.emit("miniAppAdded",{notificationDetails:e.notificationDetails}):e.event==="miniapp_add_rejected"?Lt.emit("miniAppAddRejected",{reason:e.reason}):e.event==="miniapp_removed"?Lt.emit("miniAppRemoved"):e.event==="notifications_enabled"?Lt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?Lt.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&Lt.emit("backNavigationTriggered")}}),typeof window<"u"&&window.addEventListener("message",t=>{if(t instanceof MessageEvent&&t.data.type==="frameEvent"){const e=t.data.event;e.event==="primary_button_clicked"?Lt.emit("primaryButtonClicked"):e.event==="miniapp_added"?Lt.emit("miniAppAdded",{notificationDetails:e.notificationDetails}):e.event==="miniapp_add_rejected"?Lt.emit("miniAppAddRejected",{reason:e.reason}):e.event==="miniapp_removed"?Lt.emit("miniAppRemoved"):e.event==="notifications_enabled"?Lt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?Lt.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&Lt.emit("backNavigationTriggered")}}),mo.type="farcasterMiniApp";let Zr,Yr,Jr;function mo(){return t=>({id:"farcaster",name:"Farcaster",rdns:"xyz.farcaster.MiniAppWallet",icon:"https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/055c25d6-7fe7-4a49-abf9-49772021cf00/original",type:mo.type,async connect({chainId:e}={}){const n=await this.getProvider(),r=await n.request({method:"eth_requestAccounts"});let s=e;if(!s){const o=await t.storage?.getItem("state")??{};t.chains.some(d=>d.id===o.chainId)?s=o.chainId:s=t.chains[0]?.id}if(!s)throw new Error("No chains found on connector.");Zr||(Zr=this.onAccountsChanged.bind(this),n.on("accountsChanged",Zr)),Yr||(Yr=this.onChainChanged.bind(this),n.on("chainChanged",Yr)),Jr||(Jr=this.onDisconnect.bind(this),n.on("disconnect",Jr));let i=await this.getChainId();return s&&i!==s&&(i=(await this.switchChain({chainId:s})).id),{accounts:r.map(o=>fi(o)),chainId:i}},async disconnect(){const e=await this.getProvider();Zr&&(e.removeListener("accountsChanged",Zr),Zr=void 0),Yr&&(e.removeListener("chainChanged",Yr),Yr=void 0),Jr&&(e.removeListener("disconnect",Jr),Jr=void 0)},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(r=>fi(r))},async getChainId(){const n=await(await this.getProvider()).request({method:"eth_chainId"});return bm(n,"number")},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({chainId:e}){const n=await this.getProvider(),r=t.chains.find(s=>s.id===e);if(!r)throw new Or(new ql);return await n.request({method:"wallet_switchEthereumChain",params:[{chainId:Ue(e)}]}),t.emitter.emit("change",{chainId:e}),r},onAccountsChanged(e){e.length===0?this.onDisconnect():t.emitter.emit("change",{accounts:e.map(n=>fi(n))})},onChainChanged(e){const n=Number(e);t.emitter.emit("change",{chainId:n})},async onDisconnect(){t.emitter.emit("disconnect")},async getProvider(){return Gh.wallet.ethProvider}})}const lx=mo;lx.type="farcasterFrame";const vt={EVM:"EVM",STARKNET:"STARKNET"},xe={ARBITRUM:"ARBITRUM_MAINNET",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE_MAINNET",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE_MAINNET",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC_MAINNET",ETHEREUM:"ETHEREUM_MAINNET",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM_MAINNET",LISK:"LISK_MAINNET",MONAD:"MONAD_MAINNET",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM_MAINNET",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON_MAINNET",STARKNET:"STARKNET_MAINNET",STARKNET_TESTNET:"STARKNET_TESTNET"},fx={type:vt.EVM,chainId:42161,name:"Arbitrum",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg",explorer:"https://arbiscan.io"},hx={type:vt.EVM,chainId:421614,name:"Arbitrum Sepolia",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg",explorer:"https://sepolia.arbiscan.io"},px={type:vt.EVM,chainId:43114,name:"Avalanche",cctpDomain:1,logoURI:"/images/chains/avalanche.svg",explorer:"https://snowtrace.io"},mx={type:vt.EVM,chainId:43113,name:"Avalanche Fuji",cctpDomain:1,logoURI:"/images/chains/avalanche.svg",explorer:"https://testnet.snowtrace.io"},gx={type:vt.EVM,chainId:8453,name:"Base",cctpDomain:6,logoURI:"/images/chains/base.webp",explorer:"https://basescan.org"},yx={type:vt.EVM,chainId:84532,name:"Base Sepolia",cctpDomain:6,logoURI:"/images/chains/base.webp",explorer:"https://sepolia.basescan.org"},bx={type:vt.EVM,chainId:56,name:"BNB Chain",cctpDomain:null,logoURI:"/images/chains/bsc.webp",explorer:"https://bscscan.com"},_x={type:vt.EVM,chainId:1,name:"Ethereum",cctpDomain:0,logoURI:"/images/chains/ethereum.svg",explorer:"https://etherscan.io"},Ex={type:vt.EVM,chainId:11155111,name:"Ethereum Sepolia",cctpDomain:0,logoURI:"/images/chains/ethereum.svg",explorer:"https://sepolia.etherscan.io"},wx={type:vt.EVM,chainId:999,name:"HyperEVM",cctpDomain:19,logoURI:"/images/chains/hyperevm.webp",explorer:"https://liquidscan.io"},vx={type:vt.EVM,chainId:1135,name:"Lisk",cctpDomain:null,logoURI:"/images/chains/lisk.png",explorer:"https://blockscout.lisk.com"},Rx={type:vt.EVM,chainId:143,name:"Monad",cctpDomain:7,logoURI:"/images/chains/monad.png",explorer:"https://monadvision.com"},Ax={type:vt.EVM,chainId:10143,name:"Monad Testnet",cctpDomain:null,logoURI:"/images/chains/monad.png",explorer:"https://testnet.monadvision.com"},Sx={type:vt.EVM,chainId:10,name:"Optimism",cctpDomain:2,logoURI:"/images/chains/optimism.svg",explorer:"https://optimistic.etherscan.io"},xx={type:vt.EVM,chainId:11155420,name:"Optimism Testnet",cctpDomain:2,logoURI:"/images/chains/optimism.svg",explorer:"https://testnet-explorer.optimism.io"},Tx={type:vt.EVM,chainId:137,name:"Polygon",cctpDomain:7,logoURI:"/images/chains/polygon.svg",explorer:"https://polygonscan.com"},Ix={type:vt.STARKNET,chainId:"0x534e5f4d41494e",name:"Starknet",cctpDomain:25,logoURI:"/images/chains/starknet.svg",explorer:""},Ox={type:vt.STARKNET,chainId:"0x534e5f5345504f4c4941",name:"Starknet Testnet",cctpDomain:null,logoURI:"/images/chains/starknet.svg",explorer:""};function zc(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function qh(t){return zc(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Kh="2.43.4";let jc={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${Kh}`};class Zn extends Error{constructor(e,n={}){const r=n.cause instanceof Zn?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof Zn&&n.cause.docsPath||n.docsPath,i=jc.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...jc.version?[`Version: ${jc.version}`]:[]].join(`
42
- `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=Kh}walk(e){return Wh(this,e)}}function Wh(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Wh(t.cause,e):e?null:t}class Zh extends Zn{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}function go(t,{dir:e,size:n=32}={}){return typeof t=="string"?Nx(t,{dir:e,size:n}):Cx(t,{dir:e,size:n})}function Nx(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new Zh({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function Cx(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new Zh({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=e==="right";r[i?s:n-s-1]=t[i?s:t.length-s-1]}return r}class Mx extends Zn{constructor({max:e,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class kx extends Zn{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Vc(t,{size:e}){if(qh(t)>e)throw new kx({givenSize:qh(t),maxSize:e})}function Bx(t,e={}){const{signed:n,size:r}=e,s=BigInt(t);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const d=typeof t=="bigint"?"n":"";throw new Mx({max:i?`${i}${d}`:void 0,min:`${o}${d}`,signed:n,size:r,value:`${t}${d}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?go(a,{size:r}):a}const Ux=new TextEncoder;function Lx(t,e={}){return typeof t=="number"||typeof t=="bigint"?Px(t,e):typeof t=="boolean"?Dx(t,e):zc(t)?Jh(t,e):Xh(t,e)}function Dx(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Vc(n,{size:e.size}),go(n,{size:e.size})):n}const Cn={zero:48,nine:57,A:65,F:70,a:97,f:102};function Yh(t){if(t>=Cn.zero&&t<=Cn.nine)return t-Cn.zero;if(t>=Cn.A&&t<=Cn.F)return t-(Cn.A-10);if(t>=Cn.a&&t<=Cn.f)return t-(Cn.a-10)}function Jh(t,e={}){let n=t;e.size&&(Vc(n,{size:e.size}),n=go(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const d=Yh(r.charCodeAt(a++)),m=Yh(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new Zn(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function Px(t,e){const n=Bx(t,e);return Jh(n)}function Xh(t,e={}){const n=Ux.encode(t);return typeof e.size=="number"?(Vc(n,{size:e.size}),go(n,{dir:"right",size:e.size})):n}const yo=BigInt(2**32-1),Qh=BigInt(32);function Fx(t,e=!1){return e?{h:Number(t&yo),l:Number(t>>Qh&yo)}:{h:Number(t>>Qh&yo)|0,l:Number(t&yo)|0}}function $x(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:o,l:a}=Fx(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const zx=(t,e,n)=>t<<n|e>>>32-n,jx=(t,e,n)=>e<<n|t>>>32-n,Vx=(t,e,n)=>e<<n-32|t>>>64-n,Hx=(t,e,n)=>t<<n-32|e>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Gx(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function e0(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function bo(t,...e){if(!Gx(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function t0(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function qx(t,e){bo(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Kx(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function n0(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Wx=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Zx(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Yx(t){for(let e=0;e<t.length;e++)t[e]=Zx(t[e]);return t}const r0=Wx?t=>t:Yx;function Jx(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function s0(t){return typeof t=="string"&&(t=Jx(t)),bo(t),t}class Xx{}function Qx(t){const e=r=>t().update(s0(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}const eT=BigInt(0),Xs=BigInt(1),tT=BigInt(2),nT=BigInt(7),rT=BigInt(256),sT=BigInt(113),i0=[],o0=[],a0=[];for(let t=0,e=Xs,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],i0.push(2*(5*r+n)),o0.push((t+1)*(t+2)/2%64);let s=eT;for(let i=0;i<7;i++)e=(e<<Xs^(e>>nT)*sT)%rT,e&tT&&(s^=Xs<<(Xs<<BigInt(i))-Xs);a0.push(s)}const c0=$x(a0,!0),iT=c0[0],oT=c0[1],u0=(t,e,n)=>n>32?Vx(t,e,n):zx(t,e,n),d0=(t,e,n)=>n>32?Hx(t,e,n):jx(t,e,n);function aT(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=n[d],g=n[d+1],S=u0(m,g,1)^n[a],I=d0(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=S,t[o+N+1]^=I}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=o0[o],d=u0(s,i,a),m=d0(s,i,a),g=i0[o];s=t[g],i=t[g+1],t[g]=d,t[g+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=iT[r],t[1]^=oT[r]}n0(n)}class Hc extends Xx{constructor(e,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,e0(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Kx(this.state)}clone(){return this._cloneInto()}keccak(){r0(this.state32),aT(this.state32,this.rounds),r0(this.state32),this.posOut=0,this.pos=0}update(e){t0(this),e=s0(e),bo(e);const{blockLen:n,state:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){t0(this,!1),bo(e),this.finish();const n=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(n.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 e0(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(qx(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,n0(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Hc(n,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 cT=(t,e,n)=>Qx(()=>new Hc(e,t,n)),uT=cT(1,136,256/8);function dT(t,e){return uT(zc(t,{strict:!1})?Lx(t):t)}class lT extends Zn{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class l0 extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const Gc=new l0(8192);function f0(t,e){if(Gc.has(`${t}.${e}`))return Gc.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=dT(Xh(n)),s=n.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const i=`0x${s.join("")}`;return Gc.set(`${t}.${e}`,i),i}function Dt(t,e){if(!hT(t,{strict:!1}))throw new lT({address:t});return f0(t,e)}const fT=/^0x[a-fA-F0-9]{40}$/,qc=new l0(8192);function hT(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(qc.has(r))return qc.get(r);const s=fT.test(t)?t.toLowerCase()===t?!0:n?f0(t)===t:!0:!1;return qc.set(r,s),s}const Q={USDC:"USDC",USDT:"USDT",DAI:"DAI",BUSD:"BUSD",EURC:"EURC",ETH:"ETH",WETH:"WETH",STRK:"STRK",BNB:"BNB",LORDS:"LORDS"},Rt={[xe.ARBITRUM]:{[Q.DAI]:{address:Dt("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:Q.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[Q.USDC]:{address:Dt("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[Q.USDT]:{address:Dt("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),symbol:Q.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[Q.WETH]:{address:Dt("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),symbol:Q.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[xe.ARBITRUM_TESTNET]:{[Q.USDC]:{address:Dt("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:Q.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[xe.AVALANCHE]:{[Q.DAI]:{address:"0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.USDC]:{address:Dt("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:Q.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[Q.USDT]:{address:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",symbol:Q.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[Q.WETH]:{address:"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",symbol:Q.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[xe.AVALANCHE_TESTNET]:{[Q.USDC]:{address:Dt("0x5425890298aed601595a70AB815c96711a31Bc65"),symbol:Q.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[xe.BASE]:{[Q.DAI]:{address:"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:Q.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[Q.EURC]:{address:"0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",symbol:Q.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[Q.USDC]:{address:Dt("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:Q.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[Q.WETH]:{address:Dt("0x4200000000000000000000000000000000000006"),symbol:Q.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[xe.BASE_TESTNET]:{[Q.USDC]:{address:Dt("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:Q.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[xe.BSC]:{[Q.BNB]:{address:"0x0000000000000000000000000000000000000000",symbol:Q.BNB,name:"BNB",decimals:18,logoURI:"/images/chains/bsc.webp",nativeToken:!0},[Q.BUSD]:{address:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",symbol:Q.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[Q.DAI]:{address:"0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3",symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.ETH]:{address:"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",symbol:Q.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[Q.USDC]:{address:Dt("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:Q.USDC,decimals:18,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[Q.USDT]:{address:"0x55d398326f99059fF775485246999027B3197955",symbol:Q.USDT,name:"Tether USD",decimals:18,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[xe.ETHEREUM]:{[Q.BUSD]:{address:"0x4Fabb145d64652a948d72533023f6E7A623C7C53",symbol:Q.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[Q.DAI]:{address:Dt("0x6B175474E89094C44Da98b954EedeAC495271d0F"),symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:Q.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[Q.EURC]:{address:"0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",symbol:Q.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[Q.STRK]:{address:"0xCa14007Eff0dB1f8135f4C25B34De49AB0d42766",symbol:Q.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[Q.USDC]:{address:Dt("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[Q.USDT]:{address:Dt("0xdAC17F958D2ee523a2206206994597C13D831ec7"),symbol:Q.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[Q.WETH]:{address:Dt("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),symbol:Q.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[xe.ETHEREUM_TESTNET]:{[Q.USDC]:{address:Dt("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:Q.USDC,decimals:6,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[xe.HYPEREVM]:{[Q.USDC]:{address:"0xb88339CB7199b77E23DB6E890353E22632Ba630f",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[xe.LISK]:{[Q.USDC]:{address:"0xF242275d3a6527d877f2c927a82D9b057609cc71",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[xe.MONAD]:{[Q.USDC]:{address:"0x754704Bc059F8C67012fEd69BC8A327a5aafb603",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[xe.MONAD_TESTNET]:{[Q.USDC]:{address:"0x534b2f3A21130d7a60830c2Df862319e593943A3",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[xe.OPTIMISM]:{[Q.DAI]:{address:"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:Q.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[Q.USDC]:{address:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[Q.USDT]:{address:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",symbol:Q.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[Q.WETH]:{address:"0x4200000000000000000000000000000000000006",symbol:Q.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[xe.OPTIMISM_TESTNET]:{[Q.USDC]:{address:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[xe.POLYGON]:{[Q.DAI]:{address:"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.USDC]:{address:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[Q.USDT]:{address:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",symbol:Q.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[Q.WETH]:{address:"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",symbol:Q.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[xe.STARKNET]:{[Q.DAI]:{address:"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.ETH]:{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",symbol:Q.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[Q.LORDS]:{address:"0x0124aeb495b947201f5faC96fD1138E326AD86195B98df6DEc9009158A533B49",symbol:Q.LORDS,name:"LORDS Token",decimals:18,logoURI:"/images/tokens/lords.png",nativeToken:!1},[Q.STRK]:{address:"0x04718f5a0Fc34cC1AF16A1cdee98fFB20C31f5cD61D6Ab07201858f4287c938D",symbol:Q.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[Q.USDC]:{address:"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[Q.USDT]:{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",symbol:Q.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[xe.STARKNET_TESTNET]:{[Q.USDC]:{address:"0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}}},pT={ARBITRUM_MAINNET:{...fx,tokens:Rt[xe.ARBITRUM]},ARBITRUM_TESTNET:{...hx,tokens:Rt[xe.ARBITRUM_TESTNET]},AVALANCHE_MAINNET:{...px,tokens:Rt[xe.AVALANCHE]},AVALANCHE_TESTNET:{...mx,tokens:Rt[xe.AVALANCHE_TESTNET]},BASE_MAINNET:{...gx,tokens:Rt[xe.BASE]},BASE_TESTNET:{...yx,tokens:Rt[xe.BASE_TESTNET]},BSC_MAINNET:{...bx,tokens:Rt[xe.BSC]},ETHEREUM_MAINNET:{..._x,tokens:Rt[xe.ETHEREUM]},ETHEREUM_TESTNET:{...Ex,tokens:Rt[xe.ETHEREUM_TESTNET]},HYPEREVM_MAINNET:{...wx,tokens:Rt[xe.HYPEREVM]},LISK_MAINNET:{...vx,tokens:Rt[xe.LISK]},MONAD_MAINNET:{...Rx,tokens:Rt[xe.MONAD]},MONAD_TESTNET:{...Ax,tokens:Rt[xe.MONAD_TESTNET]},OPTIMISM_MAINNET:{...Sx,tokens:Rt[xe.OPTIMISM]},OPTIMISM_TESTNET:{...xx,tokens:Rt[xe.OPTIMISM_TESTNET]},POLYGON_MAINNET:{...Tx,tokens:Rt[xe.POLYGON]},STARKNET_MAINNET:{...Ix,tokens:Rt[xe.STARKNET]},STARKNET_TESTNET:{...Ox,tokens:Rt[xe.STARKNET_TESTNET]}},mT=new Set(Object.values(xe));function gT(t){if(yT(t))return t;const e=xe[t];if(!e)throw new Error(`Invalid chain: ${t}. Chain must be a valid chain alias or internal chain value from Chains.`);return e}function yT(t){return mT.has(t)}async function bT(t,e,n){if(!n||!e)throw new Error("Wagmi config not found");const r=await C1(e,{connector:mo()});if(r?.accounts?.length){const s={type:un.FARCASTER_CONNECTED,isConnected:!0,address:r.accounts[0],chainId:r.chainId};[Po,Fo].forEach(i=>{t.current?.contentWindow?.postMessage(s,i)})}}async function _T(t,e,n){if(!n||!e)throw new Error("Wagmi config not found");await U1(e);const r={type:un.FARCASTER_DISCONNECTED,isConnected:!1,address:null,chainId:null};[Po,Fo].forEach(s=>{t.current?.contentWindow?.postMessage(r,s)})}async function ET(t,e,n,r,s){if(!n||!e)throw new Error("Wagmi config not found");let i=null;try{return await F1(e,{chainId:t.chainId}),t.nativeToken?(i=await D1(e,{to:t.to,value:t.value,chainId:t.chainId}),i):(i=await $1(e,{abi:rm,address:t.token,functionName:"transfer",args:[t.to,t.value]}),i)}catch{[Po,Fo].forEach(a=>{r?.contentWindow?.postMessage({type:un.FARCASTER_SEND_TRANSACTION_RESULT,requestId:s.params,error:"an error occurred"},a)})}return i}async function wT(t){if(!t)throw new Error("Wagmi config not found");const e=new Set(L1(t).map(r=>r.id));return Object.entries(pT).filter(([,r])=>!e.has(r.chainId)).map(([r])=>r)}function vT(){return Jn.jsx("div",{role:"status",className:"payment-modal-loader",children:Jn.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Jn.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),Jn.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})})}const RT=["light","dark","system"],_o="https://app.chainrails.io",Eo="https://chainrails-frontend-git-staging-horus-labs.vercel.app";function AT(t){const{amount:e,styles:n,excludeChains:r,isOpen:s,isPending:i,open:o,close:a,onCancel:d,onSuccess:m,session_url:g,sessionToken:S,farcasterMiniApp:I,wagmiConfig:N}=t,[F,M]=Be.useState(0),[B,K]=Be.useState(""),[Y,z]=Be.useState(null),U=Be.useRef(null);Mn.config({api_key:"",env:t.env==="internal"?"internal":"production"}),Be.useEffect(()=>{K(Mn.getPayModalUrl(e))},[e]),Be.useEffect(()=>{const J=n?.theme;if(!J||RT.includes(J)){z(null);return}let ne=!1;return(async()=>{try{const V=Mn.getBaseUrl(),C=await fetch(`${V}/themes/${J}`);if(!C.ok)return;const L=await C.json();!ne&&L.status==="approved"&&L.cssContent&&z(L.cssContent)}catch(V){console.error("Failed to fetch theme:",V)}})(),()=>{ne=!0}},[n?.theme]),Be.useEffect(()=>{const J=document.body.style.overflow;s?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=J||"";const ne=async te=>{if(te.data===un.CLOSED&&(a(),d?.()),te?.data?.type===un.COMPLETED){window.setTimeout(a,2e3);const L=te?.data?.transactionHash?{transactionHash:te.data.transactionHash}:void 0;m?.(L)}if(te.data===un.REQUEST_FARCASTER_CONNECT)try{await bT(U,N,I)}catch(L){console.error(L)}if(te.data===un.REQUEST_FARCASTER_DISCONNECT)try{await _T(U,N,I)}catch(L){console.error(L)}const C=te.data;if(C?.type===un.REQUEST_FARCASTER_SEND_TRANSACTION&&typeof C.requestId=="string"&&C.params)try{const L=await ET(C.params,N,I,U.current,C.requestId);L?[_o,Eo].forEach(q=>{U.current?.contentWindow?.postMessage({type:un.FARCASTER_SEND_TRANSACTION_RESULT,requestId:C.requestId,hash:L},q)}):[_o,Eo].forEach(q=>{U.current?.contentWindow?.postMessage({type:un.FARCASTER_SEND_TRANSACTION_RESULT,requestId:C.requestId,error:"sendTransaction not configured or returned no hash"},q)})}catch(L){console.log(L)}};return window.addEventListener("message",ne),()=>{document.body.style.overflow=J||"",window.removeEventListener("message",ne)}},[s,d,m,a,I,N]),Be.useEffect(()=>{if(!S)return;const J=t.css||Y||void 0,ne=async()=>{const V=await Gh.isInMiniApp(),C=V?await wT(N):[],q=[...r?.map(gT)||[],...C];return{type:"session",session_token:S,environment:Mn.getEnv()||Lo.PRODUCTION,styles:n,props:{excludeChains:q.join(","),isFarcasterMiniApp:V},...J?{css:J}:{}}};let te=!1;return ne().then(V=>{te||([_o,Eo].forEach(C=>{U.current?.contentWindow?.postMessage(V,C)}),window.setTimeout(()=>{te||[_o,Eo].forEach(C=>{U.current?.contentWindow?.postMessage(V,C)})},1e3))}),()=>{te=!0}},[S,F,s,n,Y]);function j(){M(Math.random())}return Jn.jsxs("div",{className:nm("payment-modal-wrapper",F===0||i?"loading":"not-loading",s?"open":"closed"),children:[(F===0||i)&&Jn.jsx(vT,{}),Jn.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:B||void 0,onLoad:j,className:`payment-modal ${F===0||i?"invisible":"visible"}`,"data-id":e,ref:U},e)]})}const ST=Symbol(),Kc=Symbol(),Qs="a",h0="f",p0="p",m0="c",g0="t",Wc="h",ei="w",Zc="o",Yc="k";let xT=(t,e)=>new Proxy(t,e);const Jc=Object.getPrototypeOf,Xc=new WeakMap,y0=t=>t&&(Xc.has(t)?Xc.get(t):Jc(t)===Object.prototype||Jc(t)===Array.prototype),wo=t=>typeof t=="object"&&t!==null,TT=t=>Object.values(Object.getOwnPropertyDescriptors(t)).some(e=>!e.configurable&&!e.writable),IT=t=>{if(Array.isArray(t))return Array.from(t);const e=Object.getOwnPropertyDescriptors(t);return Object.values(e).forEach(n=>{n.configurable=!0}),Object.create(Jc(t),e)},OT=(t,e)=>{const n={[h0]:e};let r=!1;const s=(a,d)=>{if(!r){let m=n[Qs].get(t);if(m||(m={},n[Qs].set(t,m)),a===ei)m[ei]=!0;else{let g=m[a];g||(g=new Set,m[a]=g),g.add(d)}}},i=()=>{r=!0,n[Qs].delete(t)},o={get(a,d){return d===Kc?t:(s(Yc,d),b0(Reflect.get(a,d),n[Qs],n[m0],n[g0]))},has(a,d){return d===ST?(i(),!0):(s(Wc,d),Reflect.has(a,d))},getOwnPropertyDescriptor(a,d){return s(Zc,d),Reflect.getOwnPropertyDescriptor(a,d)},ownKeys(a){return s(ei),Reflect.ownKeys(a)}};return e&&(o.set=o.deleteProperty=()=>!1),[o,n]},Qc=t=>t[Kc]||t,b0=(t,e,n,r)=>{if(!y0(t))return t;let s=r&&r.get(t);if(!s){const d=Qc(t);TT(d)?s=[d,IT(d)]:s=[d],r?.set(t,s)}const[i,o]=s;let a=n&&n.get(i);return(!a||a[1][h0]!==!!o)&&(a=OT(i,!!o),a[1][p0]=xT(o||i,a[0]),n&&n.set(i,a)),a[1][Qs]=e,a[1][m0]=n,a[1][g0]=r,a[1][p0]},NT=(t,e)=>{const n=Reflect.ownKeys(t),r=Reflect.ownKeys(e);return n.length!==r.length||n.some((s,i)=>s!==r[i])},_0=(t,e,n,r,s=Object.is)=>{if(s(t,e))return!1;if(!wo(t)||!wo(e))return!0;const i=n.get(Qc(t));if(!i)return!0;if(r){if(r.get(t)===e)return!1;r.set(t,e)}let o=null;for(const a of i[Wc]||[])if(o=Reflect.has(t,a)!==Reflect.has(e,a),o)return o;if(i[ei]===!0){if(o=NT(t,e),o)return o}else for(const a of i[Zc]||[]){const d=!!Reflect.getOwnPropertyDescriptor(t,a),m=!!Reflect.getOwnPropertyDescriptor(e,a);if(o=d!==m,o)return o}for(const a of i[Yc]||[])if(o=_0(t[a],e[a],n,r,s),o)return o;if(o===null)throw new Error("invalid used");return o},CT=t=>y0(t)&&t[Kc]||null,E0=(t,e=!0)=>{Xc.set(t,e)},MT=(t,e,n)=>{const r=[],s=new WeakSet,i=(o,a)=>{var d,m,g;if(s.has(o))return;wo(o)&&s.add(o);const S=wo(o)&&e.get(Qc(o));if(S){if((d=S[Wc])===null||d===void 0||d.forEach(I=>{const N=`:has(${String(I)})`;r.push(a?[...a,N]:[N])}),S[ei]===!0){const I=":ownKeys";r.push(a?[...a,I]:[I])}else(m=S[Zc])===null||m===void 0||m.forEach(I=>{const N=`:hasOwn(${String(I)})`;r.push(a?[...a,N]:[N])});(g=S[Yc])===null||g===void 0||g.forEach(I=>{"value"in(Object.getOwnPropertyDescriptor(o,I)||{})&&i(o[I],a?[...a,I]:[I])})}else a&&r.push(a)};return i(t),r},vo={},eu=t=>typeof t=="object"&&t!==null,kT=t=>eu(t)&&!tu.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),w0=(t,e)=>{const n=v0.get(t);if(n?.[0]===e)return n[1];const r=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return E0(r,!0),v0.set(t,[e,r]),Reflect.ownKeys(t).forEach(s=>{if(Object.getOwnPropertyDescriptor(r,s))return;const i=Reflect.get(t,s),{enumerable:o}=Reflect.getOwnPropertyDescriptor(t,s),a={value:i,enumerable:o,configurable:!0};if(tu.has(i))E0(i,!1);else if(yr.has(i)){const[d,m]=yr.get(i);a.value=w0(d,m())}Object.defineProperty(r,s,a)}),Object.preventExtensions(r)},BT=(t,e,n,r)=>({deleteProperty(s,i){const o=Reflect.get(s,i);n(i);const a=Reflect.deleteProperty(s,i);return a&&r(["delete",[i],o]),a},set(s,i,o,a){const d=!t()&&Reflect.has(s,i),m=Reflect.get(s,i,a);if(d&&(R0(m,o)||Ro.has(o)&&R0(m,Ro.get(o))))return!0;n(i),eu(o)&&(o=CT(o)||o);const g=!yr.has(o)&&LT(o)?A0(o):o;return e(i,g),Reflect.set(s,i,g,a),r(["set",[i],o,m]),!0}}),yr=new WeakMap,tu=new WeakSet,v0=new WeakMap,nu=[1],Ro=new WeakMap;let R0=Object.is,UT=(t,e)=>new Proxy(t,e),LT=kT,DT=w0,PT=BT;function A0(t={}){if(!eu(t))throw new Error("object required");const e=Ro.get(t);if(e)return e;let n=nu[0];const r=new Set,s=(B,K=++nu[0])=>{n!==K&&(i=n=K,r.forEach(Y=>Y(B,K)))};let i=n;const o=(B=nu[0])=>(i!==B&&(i=B,d.forEach(([K])=>{const Y=K[1](B);Y>n&&(n=Y)})),n),a=B=>(K,Y)=>{const z=[...K];z[1]=[B,...z[1]],s(z,Y)},d=new Map,m=(B,K)=>{const Y=!tu.has(K)&&yr.get(K);if(Y){if((vo?"production":void 0)!=="production"&&d.has(B))throw new Error("prop listener already exists");if(r.size){const z=Y[2](a(B));d.set(B,[Y,z])}else d.set(B,[Y])}},g=B=>{var K;const Y=d.get(B);Y&&(d.delete(B),(K=Y[1])==null||K.call(Y))},S=B=>(r.add(B),r.size===1&&d.forEach(([Y,z],U)=>{if((vo?"production":void 0)!=="production"&&z)throw new Error("remove already exists");const j=Y[2](a(U));d.set(U,[Y,j])}),()=>{r.delete(B),r.size===0&&d.forEach(([Y,z],U)=>{z&&(z(),d.set(U,[Y]))})});let I=!0;const N=PT(()=>I,m,g,s),F=UT(t,N);Ro.set(t,F);const M=[t,o,S];return yr.set(F,M),Reflect.ownKeys(t).forEach(B=>{const K=Object.getOwnPropertyDescriptor(t,B);"value"in K&&K.writable&&(F[B]=t[B])}),I=!1,F}function FT(t,e,n){const r=yr.get(t);(vo?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let s;const i=[],o=r[2];let a=!1;const m=o(g=>{i.push(g),s||(s=Promise.resolve().then(()=>{s=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,m()}}function S0(t){const e=yr.get(t);(vo?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[n,r]=e;return DT(n,r())}const $T={},zT=(t,e)=>{const n=Be.useRef(void 0);Be.useEffect(()=>{n.current=MT(t,e)}),Be.useDebugValue(n.current)},jT=new WeakMap;function VT(t,e){const r=Be.useMemo(()=>t&&new WeakMap,[t]),s=Be.useRef(void 0);let i=!0;const o=Be.useSyncExternalStore(Be.useCallback(d=>{const m=FT(t,d);return d(),m},[t,void 0]),()=>{const d=S0(t);try{if(!i&&s.current&&!_0(s.current,d,r,new WeakMap))return s.current}catch{}return d},()=>S0(t));i=!1,Be.useLayoutEffect(()=>{s.current=o}),($T?"production":void 0)!=="production"&&zT(o,r);const a=Be.useMemo(()=>new WeakMap,[]);return b0(o,r,a,jT)}const Yn=A0({data:null,isPending:!1,error:null});function HT({session_url:t,onCancel:e,onSuccess:n,farcasterMiniApp:r,wagmiConfig:s}){const i=VT(Yn),[o,a]=Be.useState(!1),[d,m]=Be.useState(Date.now()),g=i?.data?.sessionToken,S=i?.data?.amount;function I(){g||window.setTimeout(()=>{g&&a(!0)},200),a(!0)}function N(){a(!1)}const F=()=>{const M=Date.now();Yn.isPending=!0,Yn.error=null,Yn.data=null,fetch(t,{headers:{"Content-Type":"application/json"}}).then(B=>B.json()).then(B=>{M<d||(Yn.data=B,Yn.isPending=!1,m(M))}).catch(B=>{M<d||(Yn.error=B?.toString(),Yn.isPending=!1,m(M),setInterval(F,5e3))})};return Be.useEffect(()=>{F()},[t]),{sessionToken:g,amount:S,isOpen:o,session_url:t,open:I,close:N,isPending:i.isPending,error:i.error,refetch:F,onSuccess:n,onCancel:e,farcasterMiniApp:r,wagmiConfig:s}}function GT({sessionToken:t,amount:e,onCancel:n,onSuccess:r,farcasterMiniApp:s,wagmiConfig:i}){const[o,a]=Be.useState(!1),[d,m]=Be.useState(t),[g,S]=Be.useState(e);function I({sessionToken:M,amount:B}){m(M),S(B)}Be.useEffect(()=>{m(t)},[t]);function N(){d||window.setTimeout(()=>{d&&a(!0)},200),a(!0)}function F(){a(!1)}return{sessionToken:d,updateSession:I,amount:g,isOpen:o,open:N,close:F,onSuccess:r,onCancel:n,farcasterMiniApp:s,wagmiConfig:i}}Tt.AmountSymbols=X,Tt.Chainrails=Mn,Tt.Chains=Du,Tt.PaymentModal=AT,Tt.chains=Du,Tt.crapi=tm,Tt.tokens=X,Tt.usePaymentModal=GT,Tt.usePaymentSession=HT,Object.defineProperty(Tt,Symbol.toStringTag,{value:"Module"})}));
39
+ */const Rh=Symbol("Comlink.proxy"),lx=Symbol("Comlink.endpoint"),fx=Symbol("Comlink.releaseProxy"),kc=Symbol("Comlink.finalizer"),io=Symbol("Comlink.thrown"),Ah=t=>typeof t=="object"&&t!==null||typeof t=="function",hx={canHandle:t=>Ah(t)&&t[Rh],serialize(t){const{port1:e,port2:n}=new MessageChannel;return Sh(t,e),[n,[n]]},deserialize(t){return t.start(),Oh(t)}},px={canHandle:t=>Ah(t)&&io in t,serialize({value:t}){let e;return t instanceof Error?e={isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:e={isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}},xh=new Map([["proxy",hx],["throw",px]]);function mx(t,e){for(const n of t)if(e===n||n==="*"||n instanceof RegExp&&n.test(e))return!0;return!1}function Sh(t,e=globalThis,n=["*"]){e.addEventListener("message",function r(s){if(!s||!s.data)return;if(!mx(n,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}const{id:i,type:o,path:a}=Object.assign({path:[]},s.data),d=(s.data.argumentList||[]).map(hr);let m;try{const g=a.slice(0,-1).reduce((O,N)=>O[N],t),x=a.reduce((O,N)=>O[N],t);switch(o){case"GET":m=x;break;case"SET":g[a.slice(-1)[0]]=hr(s.data.value),m=!0;break;case"APPLY":m=x.apply(g,d);break;case"CONSTRUCT":{const O=new x(...d);m=Ex(O)}break;case"ENDPOINT":{const{port1:O,port2:N}=new MessageChannel;Sh(t,N),m=wx(O,[O])}break;case"RELEASE":m=void 0;break;default:return}}catch(g){m={value:g,[io]:0}}Promise.resolve(m).catch(g=>({value:g,[io]:0})).then(g=>{const[x,O]=uo(g);e.postMessage(Object.assign(Object.assign({},x),{id:i}),O),o==="RELEASE"&&(e.removeEventListener("message",r),Th(e),kc in t&&typeof t[kc]=="function"&&t[kc]())}).catch(g=>{const[x,O]=uo({value:new TypeError("Unserializable return value"),[io]:0});e.postMessage(Object.assign(Object.assign({},x),{id:i}),O)})}),e.start&&e.start()}function gx(t){return t.constructor.name==="MessagePort"}function Th(t){gx(t)&&t.close()}function Oh(t,e){const n=new Map;return t.addEventListener("message",function(s){const{data:i}=s;if(!i||!i.id)return;const o=n.get(i.id);if(o)try{o(i)}finally{n.delete(i.id)}}),Lc(t,n,[],e)}function oo(t){if(t)throw new Error("Proxy has been released and is not useable")}function Ih(t){return Hr(t,new Map,{type:"RELEASE"}).then(()=>{Th(t)})}const ao=new WeakMap,co="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(ao.get(t)||0)-1;ao.set(t,e),e===0&&Ih(t)});function yx(t,e){const n=(ao.get(e)||0)+1;ao.set(e,n),co&&co.register(t,e,t)}function bx(t){co&&co.unregister(t)}function Lc(t,e,n=[],r=function(){}){let s=!1;const i=new Proxy(r,{get(o,a){if(oo(s),a===fx)return()=>{bx(i),Ih(t),e.clear(),s=!0};if(a==="then"){if(n.length===0)return{then:()=>i};const d=Hr(t,e,{type:"GET",path:n.map(m=>m.toString())}).then(hr);return d.then.bind(d)}return Lc(t,e,[...n,a])},set(o,a,d){oo(s);const[m,g]=uo(d);return Hr(t,e,{type:"SET",path:[...n,a].map(x=>x.toString()),value:m},g).then(hr)},apply(o,a,d){oo(s);const m=n[n.length-1];if(m===lx)return Hr(t,e,{type:"ENDPOINT"}).then(hr);if(m==="bind")return Lc(t,e,n.slice(0,-1));const[g,x]=Nh(d);return Hr(t,e,{type:"APPLY",path:n.map(O=>O.toString()),argumentList:g},x).then(hr)},construct(o,a){oo(s);const[d,m]=Nh(a);return Hr(t,e,{type:"CONSTRUCT",path:n.map(g=>g.toString()),argumentList:d},m).then(hr)}});return yx(i,t),i}function _x(t){return Array.prototype.concat.apply([],t)}function Nh(t){const e=t.map(uo);return[e.map(n=>n[0]),_x(e.map(n=>n[1]))]}const Ch=new WeakMap;function wx(t,e){return Ch.set(t,e),t}function Ex(t){return Object.assign(t,{[Rh]:!0})}function vx(t,e=globalThis,n="*"){return{postMessage:(r,s)=>t.postMessage(r,n,s),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function uo(t){for(const[e,n]of xh)if(n.canHandle(t)){const[r,s]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},s]}return[{type:"RAW",value:t},Ch.get(t)||[]]}function hr(t){switch(t.type){case"HANDLER":return xh.get(t.name).deserialize(t.value);case"RAW":return t.value}}function Hr(t,e,n,r){return new Promise(s=>{const i=Rx();e.set(i,s),t.start&&t.start(),t.postMessage(Object.assign({id:i},n),r)})}function Rx(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const Ax={postMessage(){},addEventListener:()=>{},removeEventListener:()=>{}},xx={postMessage:t=>{window.ReactNativeWebView.postMessage(JSON.stringify(t))},addEventListener:(t,e,...n)=>{document.addEventListener("FarcasterFrameCallback",e,...n)},removeEventListener:(t,e)=>{document.removeEventListener("FarcasterFrameCallback",e)}},Sx=typeof window>"u"?Ax:window?.ReactNativeWebView?xx:vx(window?.parent??window),be=Oh(Sx),Pc=ox(),Tx=ux();function Ox({code:t,details:e}){switch(t){case 4001:return new bh;case 4100:return new _h;case 4200:return new wh;case 4900:return new Eh;case 4901:return new vh;default:return new fr(t,e??"Unknown provider RPC error")}}const Ws=ax({...Pc,async request(t){const e=Tx.prepare(t);try{const n=await be.ethProviderRequestV2(e).then(r=>yh(r,{request:e,raw:!0}));if(n.error)throw Ox(n.error);return n.result}catch(n){if(n instanceof Error&&n.message.match(/cannot read property 'apply'/i))return await be.ethProviderRequest(e);throw n instanceof fr||n instanceof Gt?n:new Gr({message:n instanceof Error?n.message:void 0})}}});async function Ix(){try{const t=await be.getCapabilities();return!t.includes("wallet.getEthereumProvider")&&!t.includes("wallet.getEvmProvider")?void 0:Ws}catch{return Ws}}function Mh(t){const e=new CustomEvent("eip6963:announceProvider",{detail:Object.freeze(t)});window.dispatchEvent(e);const n=()=>window.dispatchEvent(e);return window.addEventListener("eip6963:requestProvider",n),()=>window.removeEventListener("eip6963:requestProvider",n)}typeof document<"u"&&(document.addEventListener("eip6963:requestProvider",()=>{be.eip6963RequestProvider()}),document.addEventListener("FarcasterFrameEthProviderEvent",t=>{if(t instanceof MessageEvent){const e=t.data;Pc.emit(e.event,...e.params)}}),document.addEventListener("FarcasterFrameEvent",t=>{if(t instanceof MessageEvent){const e=t.data;e.event==="eip6963:announceProvider"&&Mh({info:e.info,provider:Ws})}})),typeof window<"u"&&(window.addEventListener("eip6963:requestProvider",()=>{be.eip6963RequestProvider()}),window.addEventListener("message",t=>{if(t instanceof MessageEvent&&t.data.type==="frameEthProviderEvent"){const e=t.data;Pc.emit(e.event,...e.params)}}),window.addEventListener("message",t=>{if(t instanceof MessageEvent&&t.data.type==="frameEvent"){const e=t.data.event;e.event==="eip6963:announceProvider"&&Mh({info:e.info,provider:Ws})}})),new TextEncoder;const Bh=new TextDecoder,Nx=t=>{const e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n},Cx=t=>{let e=t;e instanceof Uint8Array&&(e=Bh.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return Nx(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};function Mx(t){return typeof t=="object"&&t!==null}function Bx(t){if(!Mx(t)||Object.prototype.toString.call(t)!=="[object Object]")return!1;if(Object.getPrototypeOf(t)===null)return!0;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}class $t extends Error{constructor(e,n){super(e,n),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}$t.code="ERR_JOSE_GENERIC";class kx extends $t{constructor(e,n,r="unspecified",s="unspecified"){super(e,{cause:{claim:r,reason:s,payload:n}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=r,this.reason=s,this.payload=n}}kx.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class Lx extends $t{constructor(e,n,r="unspecified",s="unspecified"){super(e,{cause:{claim:r,reason:s,payload:n}}),this.code="ERR_JWT_EXPIRED",this.claim=r,this.reason=s,this.payload=n}}Lx.code="ERR_JWT_EXPIRED";class Px extends $t{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}Px.code="ERR_JOSE_ALG_NOT_ALLOWED";class Ux extends $t{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}Ux.code="ERR_JOSE_NOT_SUPPORTED";class Dx extends $t{constructor(e="decryption operation failed",n){super(e,n),this.code="ERR_JWE_DECRYPTION_FAILED"}}Dx.code="ERR_JWE_DECRYPTION_FAILED";class Fx extends $t{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}Fx.code="ERR_JWE_INVALID";class $x extends $t{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}$x.code="ERR_JWS_INVALID";class qn extends $t{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}qn.code="ERR_JWT_INVALID";class zx extends $t{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}zx.code="ERR_JWK_INVALID";class jx extends $t{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}jx.code="ERR_JWKS_INVALID";class Vx extends $t{constructor(e="no applicable key found in the JSON Web Key Set",n){super(e,n),this.code="ERR_JWKS_NO_MATCHING_KEY"}}Vx.code="ERR_JWKS_NO_MATCHING_KEY";class Gx extends $t{constructor(e="multiple matching keys found in the JSON Web Key Set",n){super(e,n),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Gx.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class Hx extends $t{constructor(e="request timed out",n){super(e,n),this.code="ERR_JWKS_TIMEOUT"}}Hx.code="ERR_JWKS_TIMEOUT";class qx extends $t{constructor(e="signature verification failed",n){super(e,n),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}qx.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function Kx(t){if(typeof t!="string")throw new qn("JWTs must use Compact JWS serialization, JWT must be a string");const{1:e,length:n}=t.split(".");if(n===5)throw new qn("Only JWTs using Compact JWS serialization can be decoded");if(n!==3)throw new qn("Invalid JWT");if(!e)throw new qn("JWTs must contain a payload");let r;try{r=Cx(e)}catch{throw new qn("Failed to base64url decode the payload")}let s;try{s=JSON.parse(Bh.decode(r))}catch{throw new qn("Failed to parse the decoded payload as JSON")}if(!Bx(s))throw new qn("Invalid JWT Claims Set");return s}function Wx(t){return Kx(t)}class lo extends Error{constructor(e,n={}){const r=(()=>{if(n.cause instanceof lo){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&"details"in n.cause&&typeof n.cause.details=="string"?n.cause.details:n.cause?.message?n.cause.message:n.details})(),s=[e||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r?["",r?`Details: ${r}`:void 0]:[]].filter(i=>typeof i=="string").join(`
40
+ `);super(s,n.cause?{cause:n.cause}:void 0),this.name="BaseError",this.cause=n.cause,this.details=r,this.shortMessage=e}}class kh extends lo{constructor({status:e}){super(`Request failed with status ${e}`),this.name="RequestFailedError"}}class Zx extends lo{constructor(e){super(e),this.name="InvalidToken"}}async function Yx({origin:t}){const e=await fetch(`${t}/nonce`,{method:"POST"});if(!e.ok)throw new kh({status:e.status});return await e.json()}async function Jx({origin:t},e){const n=await fetch(`${t}/verify-siwf`,{method:"POST",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(e)});if(!n.ok)throw new kh({status:n.status});const r=await n.json();if(r.valid===!1)throw new Zx(r.message??"unknown");return{token:r.token}}function Xx(t={}){return{origin:t.origin??"https://auth.farcaster.xyz"}}function Qx(t={}){const e=Xx(t);return{generateNonce:()=>Yx(e),verifySiwf:n=>Jx(e,n)}}const eS=/^(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+-.]*):\/\/)?(?<domain>[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\n)(?<address>0x[a-fA-F0-9]{40})\n\n(?:(?<statement>.*)\n\n)?/,tS=/(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.+))?/;function nS(t){const{scheme:e,statement:n,...r}=t.match(eS)?.groups??{},{chainId:s,expirationTime:i,issuedAt:o,notBefore:a,requestId:d,...m}=t.match(tS)?.groups??{},g=t.split("Resources:")[1]?.split(`
41
+ - `).slice(1);return{...r,...m,...s?{chainId:Number(s)}:{},...i?{expirationTime:new Date(i)}:{},...o?{issuedAt:new Date(o)}:{},...a?{notBefore:new Date(a)}:{},...d?{requestId:d}:{},...g?{resources:g}:{},...e?{scheme:e}:{},...n?{statement:n}:{}}}const Lh=(()=>{let t,e;async function n(r){const s=Qx({origin:r.quickAuthServerOrigin}),{nonce:i}=await s.generateNonce(),o=await be.signIn({nonce:i,acceptAuthAddress:!0});if(o.result){const a=nS(o.result.message);if(!a.domain)throw new Error("Missing domain on SIWE message");const d=await s.verifySiwf({domain:a.domain,message:o.result.message,signature:o.result.signature});return t={token:d.token,payload:Wx(d.token)},d}throw o.error.type==="rejected_by_user"?new Kl:new Error("Unreachable")}return{get token(){if(t&&new Date(t.payload.exp*1e3)>new Date(Date.now()+15e3))return t.token},async getToken(r={}){const s=r.force??!1;return t&&!s&&new Date(t.payload.exp*1e3)>new Date(Date.now()+15e3)?{token:t.token}:(e||(e=n(r)),e.finally(()=>{e=void 0}),e)},async fetch(r,s){const{token:i}=await this.getToken(),o=new Headers(s?.headers);return o.set("Authorization",`Bearer ${i}`),fetch(r,{...s,headers:o})}}})();function rS(){const t=new ql;return{get eventNames(){return t.eventNames.bind(t)},get listenerCount(){return t.listenerCount.bind(t)},get listeners(){return t.listeners.bind(t)},addListener:t.addListener.bind(t),emit:t.emit.bind(t),off:t.off.bind(t),on:t.on.bind(t),once:t.once.bind(t),removeAllListeners:t.removeAllListeners.bind(t),removeListener:t.removeListener.bind(t)}}const Mt=rS(),{solanaProviderRequest:Ph}=be;let Uh;Ph&&(Uh=ZA(JA(Ph)));async function Dh(){let t;try{t=await be.getCapabilities()}catch{}if(t?.includes("wallet.getSolanaProvider"))return Uh}let Fh=null;async function sS(t=1e3){if(Fh===!0)return!0;if(typeof window>"u"||!window.ReactNativeWebView&&window===window.parent)return!1;const e=await Promise.race([be.context.then(n=>!!n),new Promise(n=>{setTimeout(()=>n(!1),t)})]).catch(()=>!1);return e&&(Fh=!0),e}const $h=async()=>{const t=await be.addFrame();if(t.result)return t.result;throw t.error.type==="invalid_domain_manifest"?new U1:t.error.type==="rejected_by_user"?new D1:new Error("Unreachable")},zh={...Mt,getCapabilities:be.getCapabilities,getChains:be.getChains,isInMiniApp:sS,context:be.context,back:XA({miniAppHost:be,emitter:Mt}),quickAuth:Lh,actions:{setPrimaryButton:be.setPrimaryButton.bind(be),ready:async(t={})=>await be.ready(t),close:be.close.bind(be),viewCast:be.viewCast.bind(be),viewProfile:be.viewProfile.bind(be),openMiniApp:be.openMiniApp.bind(be),signIn:async t=>{const e=await be.signIn({...t,acceptAuthAddress:t.acceptAuthAddress??!0});if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new Kl:new Error("Unreachable")},openUrl:t=>{const e=typeof t=="string"?t:t.url;return be.openUrl(e.trim())},addFrame:$h,addMiniApp:$h,composeCast(t={}){return be.composeCast(t)},viewToken:be.viewToken.bind(be),sendToken:be.sendToken.bind(be),swapToken:be.swapToken.bind(be),requestCameraAndMicrophoneAccess:be.requestCameraAndMicrophoneAccess.bind(be)},experimental:{getSolanaProvider:Dh,signManifest:async t=>{const e=await be.signManifest(t);if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new F1:e.error.type==="invalid_domain"?new $1:e.error.type==="generic_error"?new z1(e.error.message):new Error("Unreachable")},quickAuth(t){return Lh.getToken(t)}},wallet:{ethProvider:Ws,getEthereumProvider:Ix,getSolanaProvider:Dh},haptics:{impactOccurred:be.impactOccurred.bind(be),notificationOccurred:be.notificationOccurred.bind(be),selectionChanged:be.selectionChanged.bind(be)}};typeof document<"u"&&document.addEventListener("FarcasterFrameEvent",t=>{if(t instanceof MessageEvent){const e=t.data;e.event==="primary_button_clicked"?Mt.emit("primaryButtonClicked"):e.event==="miniapp_added"?Mt.emit("miniAppAdded",{notificationDetails:e.notificationDetails}):e.event==="miniapp_add_rejected"?Mt.emit("miniAppAddRejected",{reason:e.reason}):e.event==="miniapp_removed"?Mt.emit("miniAppRemoved"):e.event==="notifications_enabled"?Mt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?Mt.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&Mt.emit("backNavigationTriggered")}}),typeof window<"u"&&window.addEventListener("message",t=>{if(t instanceof MessageEvent&&t.data.type==="frameEvent"){const e=t.data.event;e.event==="primary_button_clicked"?Mt.emit("primaryButtonClicked"):e.event==="miniapp_added"?Mt.emit("miniAppAdded",{notificationDetails:e.notificationDetails}):e.event==="miniapp_add_rejected"?Mt.emit("miniAppAddRejected",{reason:e.reason}):e.event==="miniapp_removed"?Mt.emit("miniAppRemoved"):e.event==="notifications_enabled"?Mt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?Mt.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&Mt.emit("backNavigationTriggered")}}),fo.type="farcasterMiniApp";let qr,Kr,Wr;function fo(){return t=>({id:"farcaster",name:"Farcaster",rdns:"xyz.farcaster.MiniAppWallet",icon:"https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/055c25d6-7fe7-4a49-abf9-49772021cf00/original",type:fo.type,async connect({chainId:e}={}){const n=await this.getProvider(),r=await n.request({method:"eth_requestAccounts"});let s=e;if(!s){const o=await t.storage?.getItem("state")??{};t.chains.some(d=>d.id===o.chainId)?s=o.chainId:s=t.chains[0]?.id}if(!s)throw new Error("No chains found on connector.");qr||(qr=this.onAccountsChanged.bind(this),n.on("accountsChanged",qr)),Kr||(Kr=this.onChainChanged.bind(this),n.on("chainChanged",Kr)),Wr||(Wr=this.onDisconnect.bind(this),n.on("disconnect",Wr));let i=await this.getChainId();return s&&i!==s&&(i=(await this.switchChain({chainId:s})).id),{accounts:r.map(o=>ui(o)),chainId:i}},async disconnect(){const e=await this.getProvider();qr&&(e.removeListener("accountsChanged",qr),qr=void 0),Kr&&(e.removeListener("chainChanged",Kr),Kr=void 0),Wr&&(e.removeListener("disconnect",Wr),Wr=void 0)},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(r=>ui(r))},async getChainId(){const n=await(await this.getProvider()).request({method:"eth_chainId"});return hm(n,"number")},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({chainId:e}){const n=await this.getProvider(),r=t.chains.find(s=>s.id===e);if(!r)throw new Sr(new jl);return await n.request({method:"wallet_switchEthereumChain",params:[{chainId:ke(e)}]}),t.emitter.emit("change",{chainId:e}),r},onAccountsChanged(e){e.length===0?this.onDisconnect():t.emitter.emit("change",{accounts:e.map(n=>ui(n))})},onChainChanged(e){const n=Number(e);t.emitter.emit("change",{chainId:n})},async onDisconnect(){t.emitter.emit("disconnect")},async getProvider(){return zh.wallet.ethProvider}})}const iS=fo;iS.type="farcasterFrame";const on={ARBITRUM:"ARBITRUM_MAINNET",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE_MAINNET",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE_MAINNET",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC_MAINNET",ETHEREUM:"ETHEREUM_MAINNET",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM_MAINNET",LISK:"LISK_MAINNET",MONAD:"MONAD_MAINNET",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM_MAINNET",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON_MAINNET",STARKNET:"STARKNET_MAINNET",STARKNET_TESTNET:"STARKNET_TESTNET"};function Uc(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function jh(t){return Uc(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Vh="2.43.4";let Dc={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${Vh}`};class Kn extends Error{constructor(e,n={}){const r=n.cause instanceof Kn?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof Kn&&n.cause.docsPath||n.docsPath,i=Dc.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...Dc.version?[`Version: ${Dc.version}`]:[]].join(`
42
+ `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=Vh}walk(e){return Gh(this,e)}}function Gh(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Gh(t.cause,e):e?null:t}class Hh extends Kn{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}function ho(t,{dir:e,size:n=32}={}){return typeof t=="string"?oS(t,{dir:e,size:n}):aS(t,{dir:e,size:n})}function oS(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new Hh({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function aS(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new Hh({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=e==="right";r[i?s:n-s-1]=t[i?s:t.length-s-1]}return r}class cS extends Kn{constructor({max:e,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class uS extends Kn{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Fc(t,{size:e}){if(jh(t)>e)throw new uS({givenSize:jh(t),maxSize:e})}function dS(t,e={}){const{signed:n,size:r}=e,s=BigInt(t);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const d=typeof t=="bigint"?"n":"";throw new cS({max:i?`${i}${d}`:void 0,min:`${o}${d}`,signed:n,size:r,value:`${t}${d}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?ho(a,{size:r}):a}const lS=new TextEncoder;function fS(t,e={}){return typeof t=="number"||typeof t=="bigint"?pS(t,e):typeof t=="boolean"?hS(t,e):Uc(t)?Kh(t,e):Wh(t,e)}function hS(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Fc(n,{size:e.size}),ho(n,{size:e.size})):n}const Nn={zero:48,nine:57,A:65,F:70,a:97,f:102};function qh(t){if(t>=Nn.zero&&t<=Nn.nine)return t-Nn.zero;if(t>=Nn.A&&t<=Nn.F)return t-(Nn.A-10);if(t>=Nn.a&&t<=Nn.f)return t-(Nn.a-10)}function Kh(t,e={}){let n=t;e.size&&(Fc(n,{size:e.size}),n=ho(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const d=qh(r.charCodeAt(a++)),m=qh(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new Kn(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function pS(t,e){const n=dS(t,e);return Kh(n)}function Wh(t,e={}){const n=lS.encode(t);return typeof e.size=="number"?(Fc(n,{size:e.size}),ho(n,{dir:"right",size:e.size})):n}const po=BigInt(2**32-1),Zh=BigInt(32);function mS(t,e=!1){return e?{h:Number(t&po),l:Number(t>>Zh&po)}:{h:Number(t>>Zh&po)|0,l:Number(t&po)|0}}function gS(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:o,l:a}=mS(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const yS=(t,e,n)=>t<<n|e>>>32-n,bS=(t,e,n)=>e<<n|t>>>32-n,_S=(t,e,n)=>e<<n-32|t>>>64-n,wS=(t,e,n)=>t<<n-32|e>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ES(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Yh(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function mo(t,...e){if(!ES(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Jh(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function vS(t,e){mo(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function RS(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Xh(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const AS=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function xS(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function SS(t){for(let e=0;e<t.length;e++)t[e]=xS(t[e]);return t}const Qh=AS?t=>t:SS;function TS(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function e0(t){return typeof t=="string"&&(t=TS(t)),mo(t),t}class OS{}function IS(t){const e=r=>t().update(e0(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}const NS=BigInt(0),Zs=BigInt(1),CS=BigInt(2),MS=BigInt(7),BS=BigInt(256),kS=BigInt(113),t0=[],n0=[],r0=[];for(let t=0,e=Zs,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],t0.push(2*(5*r+n)),n0.push((t+1)*(t+2)/2%64);let s=NS;for(let i=0;i<7;i++)e=(e<<Zs^(e>>MS)*kS)%BS,e&CS&&(s^=Zs<<(Zs<<BigInt(i))-Zs);r0.push(s)}const s0=gS(r0,!0),LS=s0[0],PS=s0[1],i0=(t,e,n)=>n>32?_S(t,e,n):yS(t,e,n),o0=(t,e,n)=>n>32?wS(t,e,n):bS(t,e,n);function US(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=n[d],g=n[d+1],x=i0(m,g,1)^n[a],O=o0(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=x,t[o+N+1]^=O}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=n0[o],d=i0(s,i,a),m=o0(s,i,a),g=t0[o];s=t[g],i=t[g+1],t[g]=d,t[g+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=LS[r],t[1]^=PS[r]}Xh(n)}class $c extends OS{constructor(e,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,Yh(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=RS(this.state)}clone(){return this._cloneInto()}keccak(){Qh(this.state32),US(this.state32,this.rounds),Qh(this.state32),this.posOut=0,this.pos=0}update(e){Jh(this),e=e0(e),mo(e);const{blockLen:n,state:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Jh(this,!1),mo(e),this.finish();const n=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(n.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 Yh(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(vS(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,Xh(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new $c(n,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 DS=(t,e,n)=>IS(()=>new $c(e,t,n)),FS=DS(1,136,256/8);function $S(t,e){return FS(Uc(t,{strict:!1})?fS(t):t)}class zS extends Kn{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class a0 extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const zc=new a0(8192);function c0(t,e){if(zc.has(`${t}.${e}`))return zc.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=$S(Wh(n)),s=n.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const i=`0x${s.join("")}`;return zc.set(`${t}.${e}`,i),i}function Bt(t,e){if(!VS(t,{strict:!1}))throw new zS({address:t});return c0(t,e)}const jS=/^0x[a-fA-F0-9]{40}$/,jc=new a0(8192);function VS(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(jc.has(r))return jc.get(r);const s=jS.test(t)?t.toLowerCase()===t?!0:n?c0(t)===t:!0:!1;return jc.set(r,s),s}const kt={USDC:"USDC",USDT:"USDT",DAI:"DAI",WETH:"WETH"};on.ARBITRUM+"",kt.DAI+"",Bt("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),kt.USDC+"",Bt("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),kt.USDT+"",Bt("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),kt.WETH+"",Bt("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),on.ARBITRUM_TESTNET+"",kt.USDC+"",Bt("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),on.AVALANCHE+"",kt.USDC+"",Bt("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),on.AVALANCHE_TESTNET+"",kt.USDC+"",Bt("0x5425890298aed601595a70AB815c96711a31Bc65"),on.BASE+"",kt.USDC+"",Bt("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),kt.WETH+"",Bt("0x4200000000000000000000000000000000000006"),on.BASE_TESTNET+"",kt.USDC+"",Bt("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),on.BSC+"",kt.USDC+"",Bt("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),on.ETHEREUM+"",kt.DAI+"",Bt("0x6B175474E89094C44Da98b954EedeAC495271d0F"),kt.USDC+"",Bt("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),kt.USDT+"",Bt("0xdAC17F958D2ee523a2206206994597C13D831ec7"),kt.WETH+"",Bt("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),on.ETHEREUM_TESTNET+"",kt.USDC+"",Bt("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238");const GS=new Set(Object.values(on));function HS(t){if(qS(t))return t;const e=on[t];if(!e)throw new Error(`Invalid chain: ${t}. Chain must be a valid chain alias or internal chain value from Chains.`);return e}function qS(t){return GS.has(t)}async function KS(t,e,n){if(!n||!e)throw new Error("Wagmi config not found");const r=await S1(e,{connector:fo()});if(r?.accounts?.length){const s={type:cn.FARCASTER_CONNECTED,isConnected:!0,address:r.accounts[0],chainId:r.chainId};[Po,Uo].forEach(i=>{t.current?.contentWindow?.postMessage(s,i)})}}async function WS(t,e,n){if(!n||!e)throw new Error("Wagmi config not found");await N1(e);const r={type:cn.FARCASTER_DISCONNECTED,isConnected:!1,address:null,chainId:null};[Po,Uo].forEach(s=>{t.current?.contentWindow?.postMessage(r,s)})}async function ZS(t,e,n,r,s){if(!n||!e)throw new Error("Wagmi config not found");let i=null;try{return await B1(e,{chainId:t.chainId}),t.nativeToken?(i=await C1(e,{to:t.to,value:t.value,chainId:t.chainId}),i):(i=await k1(e,{abi:Xp,address:t.token,functionName:"transfer",args:[t.to,t.value]}),i)}catch{[Po,Uo].forEach(a=>{r?.contentWindow?.postMessage({type:cn.FARCASTER_SEND_TRANSACTION_RESULT,requestId:s.params,error:"an error occurred"},a)})}return i}function YS(t){if(!t)throw new Error("Wagmi config not found");return t.chains.map(e=>e.id)}function JS(){return Jt.jsx("div",{role:"status",className:"payment-modal-loader",children:Jt.jsxs("svg",{className:"payment-modal-loader-logo",xmlns:"http://www.w3.org/2000/svg",width:"51",height:"30",viewBox:"0 0 34 20",fill:"none",children:[Jt.jsxs("g",{clipPath:"url(#clip0_9521_19796)",children:[Jt.jsx("path",{d:"M4.50445 9.38014C4.50445 12.0779 6.69067 14.2641 9.38839 14.2641H19.1532V19.0243H9.51214C5.98943 19.0243 2.91222 17.1103 1.27048 14.2641C0.461994 12.8698 0 11.2446 0 9.51213C0 7.77966 0.486744 6.05543 1.34473 4.63644C3.00296 1.85623 6.03893 0 9.51214 0H16.2012V4.48795H10.5269C10.0731 4.50445 9.78438 4.4962 9.38839 4.4962C8.99239 4.4962 8.6129 4.5457 8.2499 4.63644C6.09668 5.14794 4.50445 7.07841 4.50445 9.38014Z",fill:"currentColor"}),Jt.jsx("path",{d:"M32.163 14.2745V18.911C29.325 18.9027 26.7758 17.6405 25.0516 15.644C24.6804 15.2233 24.3421 14.7613 24.0616 14.2745C23.5831 13.4743 23.2201 12.608 22.9974 11.684C22.8571 11.0901 22.8489 10.4796 22.8901 9.87732C22.8901 9.76182 22.8984 9.64632 22.8984 9.52257C22.8984 9.15133 22.8571 8.78008 22.7746 8.43358C22.7746 8.35934 22.7499 8.29334 22.7251 8.22734C22.1559 6.09061 20.2089 4.52313 17.8989 4.52313C17.8494 4.52313 17.7917 4.52313 17.7422 4.53138V-0.0390625H17.8989C19.6644 -0.0390625 21.3144 0.439432 22.7251 1.28092C23.6079 1.80067 24.3916 2.46066 25.0516 3.2279C26.4706 4.85313 27.3368 6.9651 27.3781 9.27507C27.3781 11.9645 29.4983 14.1673 32.163 14.2745Z",fill:"currentColor"})]}),Jt.jsx("defs",{children:Jt.jsx("clipPath",{id:"clip0_9521_19796",children:Jt.jsx("rect",{width:"33.6761",height:"19.0243",fill:"white"})})})]})})}const XS=["light","dark","system"],go="https://app.chainrails.io",yo="https://chainrails-frontend-git-staging-horus-labs.vercel.app";function QS(t){const{amount:e,styles:n,excludeChains:r,isOpen:s,isPending:i,open:o,close:a,onCancel:d,onSuccess:m,session_url:g,sessionToken:x,farcasterMiniApp:O,wagmiConfig:N}=t,[F,C]=Ie.useState(0),[k,K]=Ie.useState(""),[Y,V]=Ie.useState(null),[L,z]=Ie.useState(!1),J=Ie.useRef(null),te=Ie.useRef(!1);Ie.useEffect(()=>{const P=n?.theme;if(P==="dark"){z(!0);return}if(P==="light"){z(!1);return}const j=window.matchMedia("(prefers-color-scheme: dark)"),E=()=>z(j.matches);return E(),j.addEventListener("change",E),()=>j.removeEventListener("change",E)},[n?.theme]),Me.config({api_key:"",env:t.env==="internal"?"internal":"production"}),Ie.useEffect(()=>{K(Me.getPayModalUrl(e))},[e]),Ie.useEffect(()=>{const P=n?.theme;if(!P||XS.includes(P)){V(null);return}let j=!1;return(async()=>{try{const c=Me.getBaseUrl(),p=await fetch(`${c}/themes/${P}`);if(!p.ok)return;const y=await p.json();!j&&y.status==="approved"&&y.cssContent&&V(y.cssContent)}catch(c){console.error("Failed to fetch theme:",c)}})(),()=>{j=!0}},[n?.theme]),Ie.useEffect(()=>{const P=document.body.style.overflow;s?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=P||"";const j=async E=>{if(E.data===cn.CLOSED&&(a(),d?.()),E?.data?.type===cn.COMPLETED){window.setTimeout(a,2e3);const y=E?.data?.transactionHash?{transactionHash:E.data.transactionHash}:void 0;m?.(y)}if(E.data===cn.REQUEST_FARCASTER_CONNECT)try{await KS(J,N,O)}catch(y){console.error(y)}if(E.data===cn.REQUEST_FARCASTER_DISCONNECT)try{await WS(J,N,O)}catch(y){console.error(y)}const p=E.data;if(p?.type===cn.REQUEST_FARCASTER_SEND_TRANSACTION&&typeof p.requestId=="string"&&p.params)try{const y=await ZS(p.params,N,O,J.current,p.requestId);y?[go,yo].forEach(A=>{J.current?.contentWindow?.postMessage({type:cn.FARCASTER_SEND_TRANSACTION_RESULT,requestId:p.requestId,hash:y},A)}):[go,yo].forEach(A=>{J.current?.contentWindow?.postMessage({type:cn.FARCASTER_SEND_TRANSACTION_RESULT,requestId:p.requestId,error:"sendTransaction not configured or returned no hash"},A)})}catch(y){console.log(y)}};return window.addEventListener("message",j),()=>{document.body.style.overflow=P||"",window.removeEventListener("message",j)}},[s,d,m,a,O,N]),Ie.useEffect(()=>{if(!x)return;const P=t.css||Y||void 0,j=async()=>{const c=await zh.isInMiniApp(),p=r?.map(HS)||[],y=N?YS(N):void 0;return{type:"session",session_token:x,environment:Me.getEnv()||Bo.PRODUCTION,styles:n,props:{excludeChains:p.join(","),isFarcasterMiniApp:c,...y?.length?{supportedChains:y}:{}},...P?{css:P}:{}}};let E=!1;return j().then(c=>{E||([go,yo].forEach(p=>{J.current?.contentWindow?.postMessage(c,p)}),window.setTimeout(()=>{E||[go,yo].forEach(p=>{J.current?.contentWindow?.postMessage(c,p)})},1e3))}),()=>{E=!0}},[x,F,s,n,Y]),Ie.useEffect(()=>{if(!s)return;const P=te.current;C(P?Math.random():0)},[s]);function ne(){te.current=!0,C(Math.random())}Ie.useEffect(()=>{const P=document.querySelector(".payment-modal-loader-container"),j=document.querySelector(".payment-modal-loader-logo");P.style.opacity="1",P.style.transform="translateX(-50%)",j.style.opacity="1",j.style.transform="scale(1)",j.style.filter="blur(0px)"},[]);const q=F===0||i,B=(Number(e)||0)>0;return Jt.jsxs("div",{className:Lo("payment-modal-wrapper",s?"open":"closed"),children:[Jt.jsx("div",{className:Lo("payment-modal-loader-container",L?"dark-mode":"light-mode",B?"has-amount":"no-amount"),children:Jt.jsx(JS,{})}),Jt.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:k||void 0,onLoad:ne,className:Lo(`payment-modal ${q?"invisible":"visible"}`),"data-id":e,ref:J},e)]})}const eT=Symbol(),Vc=Symbol(),Ys="a",u0="f",d0="p",l0="c",f0="t",Gc="h",Js="w",Hc="o",qc="k";let tT=(t,e)=>new Proxy(t,e);const Kc=Object.getPrototypeOf,Wc=new WeakMap,h0=t=>t&&(Wc.has(t)?Wc.get(t):Kc(t)===Object.prototype||Kc(t)===Array.prototype),bo=t=>typeof t=="object"&&t!==null,nT=t=>Object.values(Object.getOwnPropertyDescriptors(t)).some(e=>!e.configurable&&!e.writable),rT=t=>{if(Array.isArray(t))return Array.from(t);const e=Object.getOwnPropertyDescriptors(t);return Object.values(e).forEach(n=>{n.configurable=!0}),Object.create(Kc(t),e)},sT=(t,e)=>{const n={[u0]:e};let r=!1;const s=(a,d)=>{if(!r){let m=n[Ys].get(t);if(m||(m={},n[Ys].set(t,m)),a===Js)m[Js]=!0;else{let g=m[a];g||(g=new Set,m[a]=g),g.add(d)}}},i=()=>{r=!0,n[Ys].delete(t)},o={get(a,d){return d===Vc?t:(s(qc,d),p0(Reflect.get(a,d),n[Ys],n[l0],n[f0]))},has(a,d){return d===eT?(i(),!0):(s(Gc,d),Reflect.has(a,d))},getOwnPropertyDescriptor(a,d){return s(Hc,d),Reflect.getOwnPropertyDescriptor(a,d)},ownKeys(a){return s(Js),Reflect.ownKeys(a)}};return e&&(o.set=o.deleteProperty=()=>!1),[o,n]},Zc=t=>t[Vc]||t,p0=(t,e,n,r)=>{if(!h0(t))return t;let s=r&&r.get(t);if(!s){const d=Zc(t);nT(d)?s=[d,rT(d)]:s=[d],r?.set(t,s)}const[i,o]=s;let a=n&&n.get(i);return(!a||a[1][u0]!==!!o)&&(a=sT(i,!!o),a[1][d0]=tT(o||i,a[0]),n&&n.set(i,a)),a[1][Ys]=e,a[1][l0]=n,a[1][f0]=r,a[1][d0]},iT=(t,e)=>{const n=Reflect.ownKeys(t),r=Reflect.ownKeys(e);return n.length!==r.length||n.some((s,i)=>s!==r[i])},m0=(t,e,n,r,s=Object.is)=>{if(s(t,e))return!1;if(!bo(t)||!bo(e))return!0;const i=n.get(Zc(t));if(!i)return!0;if(r){if(r.get(t)===e)return!1;r.set(t,e)}let o=null;for(const a of i[Gc]||[])if(o=Reflect.has(t,a)!==Reflect.has(e,a),o)return o;if(i[Js]===!0){if(o=iT(t,e),o)return o}else for(const a of i[Hc]||[]){const d=!!Reflect.getOwnPropertyDescriptor(t,a),m=!!Reflect.getOwnPropertyDescriptor(e,a);if(o=d!==m,o)return o}for(const a of i[qc]||[])if(o=m0(t[a],e[a],n,r,s),o)return o;if(o===null)throw new Error("invalid used");return o},oT=t=>h0(t)&&t[Vc]||null,g0=(t,e=!0)=>{Wc.set(t,e)},aT=(t,e,n)=>{const r=[],s=new WeakSet,i=(o,a)=>{var d,m,g;if(s.has(o))return;bo(o)&&s.add(o);const x=bo(o)&&e.get(Zc(o));if(x){if((d=x[Gc])===null||d===void 0||d.forEach(O=>{const N=`:has(${String(O)})`;r.push(a?[...a,N]:[N])}),x[Js]===!0){const O=":ownKeys";r.push(a?[...a,O]:[O])}else(m=x[Hc])===null||m===void 0||m.forEach(O=>{const N=`:hasOwn(${String(O)})`;r.push(a?[...a,N]:[N])});(g=x[qc])===null||g===void 0||g.forEach(O=>{"value"in(Object.getOwnPropertyDescriptor(o,O)||{})&&i(o[O],a?[...a,O]:[O])})}else a&&r.push(a)};return i(t),r},_o={},Yc=t=>typeof t=="object"&&t!==null,cT=t=>Yc(t)&&!Jc.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),y0=(t,e)=>{const n=b0.get(t);if(n?.[0]===e)return n[1];const r=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return g0(r,!0),b0.set(t,[e,r]),Reflect.ownKeys(t).forEach(s=>{if(Object.getOwnPropertyDescriptor(r,s))return;const i=Reflect.get(t,s),{enumerable:o}=Reflect.getOwnPropertyDescriptor(t,s),a={value:i,enumerable:o,configurable:!0};if(Jc.has(i))g0(i,!1);else if(pr.has(i)){const[d,m]=pr.get(i);a.value=y0(d,m())}Object.defineProperty(r,s,a)}),Object.preventExtensions(r)},uT=(t,e,n,r)=>({deleteProperty(s,i){const o=Reflect.get(s,i);n(i);const a=Reflect.deleteProperty(s,i);return a&&r(["delete",[i],o]),a},set(s,i,o,a){const d=!t()&&Reflect.has(s,i),m=Reflect.get(s,i,a);if(d&&(_0(m,o)||wo.has(o)&&_0(m,wo.get(o))))return!0;n(i),Yc(o)&&(o=oT(o)||o);const g=!pr.has(o)&&lT(o)?w0(o):o;return e(i,g),Reflect.set(s,i,g,a),r(["set",[i],o,m]),!0}}),pr=new WeakMap,Jc=new WeakSet,b0=new WeakMap,Xc=[1],wo=new WeakMap;let _0=Object.is,dT=(t,e)=>new Proxy(t,e),lT=cT,fT=y0,hT=uT;function w0(t={}){if(!Yc(t))throw new Error("object required");const e=wo.get(t);if(e)return e;let n=Xc[0];const r=new Set,s=(k,K=++Xc[0])=>{n!==K&&(i=n=K,r.forEach(Y=>Y(k,K)))};let i=n;const o=(k=Xc[0])=>(i!==k&&(i=k,d.forEach(([K])=>{const Y=K[1](k);Y>n&&(n=Y)})),n),a=k=>(K,Y)=>{const V=[...K];V[1]=[k,...V[1]],s(V,Y)},d=new Map,m=(k,K)=>{const Y=!Jc.has(K)&&pr.get(K);if(Y){if((_o?"production":void 0)!=="production"&&d.has(k))throw new Error("prop listener already exists");if(r.size){const V=Y[2](a(k));d.set(k,[Y,V])}else d.set(k,[Y])}},g=k=>{var K;const Y=d.get(k);Y&&(d.delete(k),(K=Y[1])==null||K.call(Y))},x=k=>(r.add(k),r.size===1&&d.forEach(([Y,V],L)=>{if((_o?"production":void 0)!=="production"&&V)throw new Error("remove already exists");const z=Y[2](a(L));d.set(L,[Y,z])}),()=>{r.delete(k),r.size===0&&d.forEach(([Y,V],L)=>{V&&(V(),d.set(L,[Y]))})});let O=!0;const N=hT(()=>O,m,g,s),F=dT(t,N);wo.set(t,F);const C=[t,o,x];return pr.set(F,C),Reflect.ownKeys(t).forEach(k=>{const K=Object.getOwnPropertyDescriptor(t,k);"value"in K&&K.writable&&(F[k]=t[k])}),O=!1,F}function pT(t,e,n){const r=pr.get(t);(_o?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let s;const i=[],o=r[2];let a=!1;const m=o(g=>{i.push(g),s||(s=Promise.resolve().then(()=>{s=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,m()}}function E0(t){const e=pr.get(t);(_o?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[n,r]=e;return fT(n,r())}const mT={},gT=(t,e)=>{const n=Ie.useRef(void 0);Ie.useEffect(()=>{n.current=aT(t,e)}),Ie.useDebugValue(n.current)},yT=new WeakMap;function bT(t,e){const r=Ie.useMemo(()=>t&&new WeakMap,[t]),s=Ie.useRef(void 0);let i=!0;const o=Ie.useSyncExternalStore(Ie.useCallback(d=>{const m=pT(t,d);return d(),m},[t,void 0]),()=>{const d=E0(t);try{if(!i&&s.current&&!m0(s.current,d,r,new WeakMap))return s.current}catch{}return d},()=>E0(t));i=!1,Ie.useLayoutEffect(()=>{s.current=o}),(mT?"production":void 0)!=="production"&&gT(o,r);const a=Ie.useMemo(()=>new WeakMap,[]);return p0(o,r,a,yT)}const Wn=w0({data:null,isPending:!1,error:null});function _T({session_url:t,onCancel:e,onSuccess:n,farcasterMiniApp:r,wagmiConfig:s}){const i=bT(Wn),[o,a]=Ie.useState(!1),[d,m]=Ie.useState(Date.now()),g=i?.data?.sessionToken,x=i?.data?.amount;function O(){g||window.setTimeout(()=>{g&&a(!0)},200),a(!0)}function N(){a(!1)}const F=()=>{const C=Date.now();Wn.isPending=!0,Wn.error=null,Wn.data=null,fetch(t,{headers:{"Content-Type":"application/json"}}).then(k=>k.json()).then(k=>{C<d||(Wn.data=k,Wn.isPending=!1,m(C))}).catch(k=>{C<d||(Wn.error=k?.toString(),Wn.isPending=!1,m(C),setInterval(F,5e3))})};return Ie.useEffect(()=>{F()},[t]),{sessionToken:g,amount:x,isOpen:o,session_url:t,open:O,close:N,isPending:i.isPending,error:i.error,refetch:F,onSuccess:n,onCancel:e,farcasterMiniApp:r,wagmiConfig:s}}function wT({sessionToken:t,amount:e,onCancel:n,onSuccess:r,farcasterMiniApp:s,wagmiConfig:i}){const[o,a]=Ie.useState(!1),[d,m]=Ie.useState(t),[g,x]=Ie.useState(e);function O({sessionToken:C,amount:k}){m(C),x(k)}Ie.useEffect(()=>{m(t)},[t]);function N(){d||window.setTimeout(()=>{d&&a(!0)},200),a(!0)}function F(){a(!1)}return{sessionToken:d,updateSession:O,amount:g,isOpen:o,open:N,close:F,onSuccess:r,onCancel:n,farcasterMiniApp:s,wagmiConfig:i}}Rt.AmountSymbols=X,Rt.Chainrails=Me,Rt.Chains=Bu,Rt.PaymentModal=QS,Rt.chains=Bu,Rt.crapi=Jp,Rt.tokens=X,Rt.usePaymentModal=wT,Rt.usePaymentSession=_T,Object.defineProperty(Rt,Symbol.toStringTag,{value:"Module"})}));