@argent/x-shared 1.31.1 → 1.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/simulation/activity/schema.d.ts +52 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +2 -2
- package/dist/simulation.js +1 -1
- package/dist/simulation.mjs +2 -2
- package/dist/{transactionVersion-DpP30aO1.mjs → transactionVersion-ByCNdhj1.mjs} +4 -1
- package/dist/{transactionVersion-CnOPxZEg.js → transactionVersion-IV8urBdT.js} +1 -1
- package/package.json +1 -1
|
@@ -3013,6 +3013,13 @@ export declare const activitySchema: z.ZodObject<{
|
|
|
3013
3013
|
})[] | undefined;
|
|
3014
3014
|
}>, "many">>;
|
|
3015
3015
|
title: z.ZodOptional<z.ZodString>;
|
|
3016
|
+
multisigDetails: z.ZodOptional<z.ZodObject<{
|
|
3017
|
+
signers: z.ZodArray<z.ZodEffects<z.ZodString, `0x${string}`, string>, "many">;
|
|
3018
|
+
}, "strip", z.ZodTypeAny, {
|
|
3019
|
+
signers: `0x${string}`[];
|
|
3020
|
+
}, {
|
|
3021
|
+
signers: string[];
|
|
3022
|
+
}>>;
|
|
3016
3023
|
}, "strip", z.ZodTypeAny, {
|
|
3017
3024
|
status: "pending" | "success" | "failure";
|
|
3018
3025
|
type: "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
|
|
@@ -3356,6 +3363,9 @@ export declare const activitySchema: z.ZodObject<{
|
|
|
3356
3363
|
};
|
|
3357
3364
|
})[] | undefined;
|
|
3358
3365
|
}[] | undefined;
|
|
3366
|
+
multisigDetails?: {
|
|
3367
|
+
signers: `0x${string}`[];
|
|
3368
|
+
} | undefined;
|
|
3359
3369
|
}, {
|
|
3360
3370
|
status: "pending" | "success" | "failure";
|
|
3361
3371
|
type: "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
|
|
@@ -3699,6 +3709,9 @@ export declare const activitySchema: z.ZodObject<{
|
|
|
3699
3709
|
};
|
|
3700
3710
|
})[] | undefined;
|
|
3701
3711
|
}[] | undefined;
|
|
3712
|
+
multisigDetails?: {
|
|
3713
|
+
signers: string[];
|
|
3714
|
+
} | undefined;
|
|
3702
3715
|
}>;
|
|
3703
3716
|
export type Activity = z.infer<typeof activitySchema>;
|
|
3704
3717
|
/** 'native' is an activity originating within individual product, e.g. not created by dapp */
|
|
@@ -5601,6 +5614,13 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
|
|
|
5601
5614
|
})[] | undefined;
|
|
5602
5615
|
}>, "many">>;
|
|
5603
5616
|
title: z.ZodOptional<z.ZodString>;
|
|
5617
|
+
multisigDetails: z.ZodOptional<z.ZodObject<{
|
|
5618
|
+
signers: z.ZodArray<z.ZodEffects<z.ZodString, `0x${string}`, string>, "many">;
|
|
5619
|
+
}, "strip", z.ZodTypeAny, {
|
|
5620
|
+
signers: `0x${string}`[];
|
|
5621
|
+
}, {
|
|
5622
|
+
signers: string[];
|
|
5623
|
+
}>>;
|
|
5604
5624
|
}, "status" | "submitted" | "lastModified" | "fees" | "transferSummary" | "actions">, {
|
|
5605
5625
|
status: z.ZodUnion<[z.ZodEnum<["pending", "success", "failure"]>, z.ZodEnum<["rejected", "cancelled", "queued"]>]>;
|
|
5606
5626
|
type: z.ZodLiteral<"native">;
|
|
@@ -7916,6 +7936,13 @@ export declare const activitiesSchema: z.ZodArray<z.ZodObject<{
|
|
|
7916
7936
|
})[] | undefined;
|
|
7917
7937
|
}>, "many">>;
|
|
7918
7938
|
title: z.ZodOptional<z.ZodString>;
|
|
7939
|
+
multisigDetails: z.ZodOptional<z.ZodObject<{
|
|
7940
|
+
signers: z.ZodArray<z.ZodEffects<z.ZodString, `0x${string}`, string>, "many">;
|
|
7941
|
+
}, "strip", z.ZodTypeAny, {
|
|
7942
|
+
signers: `0x${string}`[];
|
|
7943
|
+
}, {
|
|
7944
|
+
signers: string[];
|
|
7945
|
+
}>>;
|
|
7919
7946
|
}, "strip", z.ZodTypeAny, {
|
|
7920
7947
|
status: "pending" | "success" | "failure";
|
|
7921
7948
|
type: "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
|
|
@@ -8259,6 +8286,9 @@ export declare const activitiesSchema: z.ZodArray<z.ZodObject<{
|
|
|
8259
8286
|
};
|
|
8260
8287
|
})[] | undefined;
|
|
8261
8288
|
}[] | undefined;
|
|
8289
|
+
multisigDetails?: {
|
|
8290
|
+
signers: `0x${string}`[];
|
|
8291
|
+
} | undefined;
|
|
8262
8292
|
}, {
|
|
8263
8293
|
status: "pending" | "success" | "failure";
|
|
8264
8294
|
type: "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
|
|
@@ -8602,6 +8632,9 @@ export declare const activitiesSchema: z.ZodArray<z.ZodObject<{
|
|
|
8602
8632
|
};
|
|
8603
8633
|
})[] | undefined;
|
|
8604
8634
|
}[] | undefined;
|
|
8635
|
+
multisigDetails?: {
|
|
8636
|
+
signers: string[];
|
|
8637
|
+
} | undefined;
|
|
8605
8638
|
}>, "many">;
|
|
8606
8639
|
export declare const activityResponseSchema: z.ZodObject<{
|
|
8607
8640
|
activities: z.ZodArray<z.ZodObject<{
|
|
@@ -10481,6 +10514,13 @@ export declare const activityResponseSchema: z.ZodObject<{
|
|
|
10481
10514
|
})[] | undefined;
|
|
10482
10515
|
}>, "many">>;
|
|
10483
10516
|
title: z.ZodOptional<z.ZodString>;
|
|
10517
|
+
multisigDetails: z.ZodOptional<z.ZodObject<{
|
|
10518
|
+
signers: z.ZodArray<z.ZodEffects<z.ZodString, `0x${string}`, string>, "many">;
|
|
10519
|
+
}, "strip", z.ZodTypeAny, {
|
|
10520
|
+
signers: `0x${string}`[];
|
|
10521
|
+
}, {
|
|
10522
|
+
signers: string[];
|
|
10523
|
+
}>>;
|
|
10484
10524
|
}, "strip", z.ZodTypeAny, {
|
|
10485
10525
|
status: "pending" | "success" | "failure";
|
|
10486
10526
|
type: "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
|
|
@@ -10824,6 +10864,9 @@ export declare const activityResponseSchema: z.ZodObject<{
|
|
|
10824
10864
|
};
|
|
10825
10865
|
})[] | undefined;
|
|
10826
10866
|
}[] | undefined;
|
|
10867
|
+
multisigDetails?: {
|
|
10868
|
+
signers: `0x${string}`[];
|
|
10869
|
+
} | undefined;
|
|
10827
10870
|
}, {
|
|
10828
10871
|
status: "pending" | "success" | "failure";
|
|
10829
10872
|
type: "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
|
|
@@ -11167,6 +11210,9 @@ export declare const activityResponseSchema: z.ZodObject<{
|
|
|
11167
11210
|
};
|
|
11168
11211
|
})[] | undefined;
|
|
11169
11212
|
}[] | undefined;
|
|
11213
|
+
multisigDetails?: {
|
|
11214
|
+
signers: string[];
|
|
11215
|
+
} | undefined;
|
|
11170
11216
|
}>, "many">;
|
|
11171
11217
|
page: z.ZodNumber;
|
|
11172
11218
|
pageSize: z.ZodNumber;
|
|
@@ -11518,6 +11564,9 @@ export declare const activityResponseSchema: z.ZodObject<{
|
|
|
11518
11564
|
};
|
|
11519
11565
|
})[] | undefined;
|
|
11520
11566
|
}[] | undefined;
|
|
11567
|
+
multisigDetails?: {
|
|
11568
|
+
signers: `0x${string}`[];
|
|
11569
|
+
} | undefined;
|
|
11521
11570
|
}[];
|
|
11522
11571
|
pageSize: number;
|
|
11523
11572
|
totalElements: number;
|
|
@@ -11867,6 +11916,9 @@ export declare const activityResponseSchema: z.ZodObject<{
|
|
|
11867
11916
|
};
|
|
11868
11917
|
})[] | undefined;
|
|
11869
11918
|
}[] | undefined;
|
|
11919
|
+
multisigDetails?: {
|
|
11920
|
+
signers: string[];
|
|
11921
|
+
} | undefined;
|
|
11870
11922
|
}[];
|
|
11871
11923
|
pageSize: number;
|
|
11872
11924
|
totalElements: number;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("zod"),a=require("./transactionVersion-CnOPxZEg.js"),g=require("starknet"),$=require("react"),D=require("lodash-es"),Be=require("swr"),ye=require("@scure/base"),es=require("ua-parser-js"),ts=require("@scure/bip39"),ns=require("@scure/bip39/wordlists/english"),rs=require("object-hash"),gn=m.z.object({name:m.z.string().optional(),address:m.z.string(),ownerAddress:m.z.string(),chain:m.z.enum(["ethereum","zksync","zksync2","starknet"]),deploymentStatus:m.z.enum(["notDeployed","deploying","deployed","deployError"]),application:m.z.enum(["mobile","webwallet","argentx"]),guardianAddresses:m.z.array(m.z.string()).optional(),enabledGuardianAddresses:m.z.array(m.z.string()).optional(),implClassHash:m.z.string().optional(),proxyClassHash:m.z.string().optional(),salt:m.z.string().optional(),created:m.z.string().optional(),contractVersion:m.z.string().optional(),contractName:m.z.string().optional(),version:m.z.number().optional(),owner:m.z.object({guid:m.z.string().optional(),signerType:m.z.enum(["StarknetKey","EthereumKey"]).optional()}).optional()}),ss=m.z.object({address:m.z.string(),guardianAddress:m.z.string().optional(),account:gn}),os=m.z.object({ownerAddress:m.z.string(),signature:m.z.object({r:m.z.string(),s:m.z.string()}),implClassHash:m.z.string().optional(),name:m.z.string().optional(),icon:m.z.string().optional()});function as(e){return"transactionVersion"in e}function is(e){return"simulateTransaction"in e}function cs(e){return!("simulateTransaction"in e)}const Sn=m.z.object({value:m.z.string(),platform:m.z.enum(["ios","argentx","android","webwallet"]).nullable()}),ls=m.z.object({preferences:m.z.record(Sn)}),wn=m.z.enum(["mainnet-alpha","sepolia-alpha"]),yn=m.z.enum(["mainnet","sepolia"]);function ds(e){return wn.safeParse(e).success}function us(e){return yn.safeParse(e).success}const Ee=18;function Ue({value:e,decimals:t}){if(t===0)return e.toString();const n=e<0n;e=n?-e:e;const r=e.toString().padStart(t,"0"),s=r.slice(0,-t)||"0",o=r.slice(-t).replace(/0+$/,"");return`${n?"-":""}${s}${o?`.${o}`:""}`}const At=(e,t)=>({decimals:t,value:t>=e.decimals?e.value*BigInt(10)**BigInt(t-e.decimals):e.value/BigInt(10)**BigInt(e.decimals-t)}),bn=e=>{const t=e.value.toString().split("").reverse();let n=0;for(let s=0;s<t.length&&t[s]==="0";s++)n++;const r=e.decimals-n;return At(e,r)},En=(e,t)=>{const n=Math.max(e.decimals,t.decimals),[r,s]=[e,t].map(o=>At(o,n));return[r.value,s.value,n]},Je=e=>(t,n)=>{const[r,s,o]=En(t,n);return{decimals:o,value:e(r,s,o)}},He=e=>(t,n)=>{const[r,s]=En(t,n);return e(r,s)},hs=Je((e,t)=>e+t),fs=Je((e,t)=>e-t),ms=Je((e,t,n)=>{if(t===BigInt(0))throw new Error("Division by zero is not allowed");return e*BigInt(10)**BigInt(n)/t}),ps=(e,t)=>bn({decimals:e.decimals+t.decimals,value:e.value*t.value}),gs=Je((e,t)=>{if(t===BigInt(0))throw new Error("Modulus by zero is not allowed");return e%t}),Tt=e=>({decimals:e.decimals,value:e.value>=BigInt(0)?e.value:-e.value}),An=He((e,t)=>e===t),Ss=He((e,t)=>e<t),ws=He((e,t)=>e>t),ys=He((e,t)=>e<=t),bs=He((e,t)=>e>=t),Es=(e,t)=>!An(e,t);function As(e){return Ue({value:e,decimals:Ee})}function Ts(e){return a.parseUnits(e,Ee)}function vs(e){return Ue({value:e,decimals:Ee})}function vt(e){return a.parseUnits(e,Ee)}function xs(e){return Tt({value:e,decimals:0}).value}function Is(e){return Tt(vt(e))}function Cs(e,t){return{value:BigInt(e),decimals:t}}const _s={value:1n,decimals:0};function Bs(e){return m.z.string().refine(t=>/^-?\d+(\.\d+)?$/.test(t),{message:"Invalid number format"}).transform(t=>a.parseUnits(t,e))}const Ns=Object.freeze(Object.defineProperty({__proto__:null,ONE:_s,abs:Tt,absBigInt:xs,add:hs,createUnitsSchema:Bs,div:ms,eq:An,formatCurrency:vs,formatEther:As,formatUnits:Ue,gt:ws,gte:bs,lt:Ss,lte:ys,mod:gs,mul:ps,not:Es,parseCurrency:vt,parseCurrencyAbs:Is,parseEther:Ts,parseUnits:a.parseUnits,sub:fs,toBigDecimal:Cs,toFixedDecimals:At,toTiniestPossibleDecimal:bn},Symbol.toStringTag,{value:"Module"}));class ks{constructor(t,n){this.cachePromise=n.open(t).catch(r=>(console.error(new Error("Failed to open cache",{cause:r})),null))}async get(t){const n=await this.cachePromise;if(!n)throw new Error("No cache available");const r=await n.match(t).catch(()=>{throw new Error("Failed to match cache")});if(!r)throw new Error("Failed to match cache");return r.clone()}async set(t,n){const r=await this.cachePromise;r&&await r.put(t,n).catch(()=>{throw new Error("Failed to match cache")})}async delete(t){const n=await this.cachePromise;return n?n.delete(t):!1}async flush(){const t=await this.cachePromise;if(!t)return;const n=await t.keys();await Promise.allSettled(n.map(r=>t.delete(r)))}}class Os{constructor(t,n){this.httpService=t,this.baseUrl=n,this.offsetInS=0,this.syncIntervalInMs=60*1e3,this.initialSync=this.syncWithServer(),setInterval(()=>void this.syncWithServer(),this.syncIntervalInMs)}async now(){return await this.initialSync,new Date(Date.now()+this.offsetInS*1e3)}async syncWithServer(){if(typeof window>"u")return;const{time:t}=await this.httpService.get(`${this.baseUrl}/time`),n=Math.floor(Date.now()/1e3),r=t-n;this.offsetInS=r}}class Xe{constructor(t,n="json"){this.requestInit=t,this.responseType=n}async get(t,n){const r=D.isFunction(this.requestInit)?await this.requestInit():this.requestInit,s={...r,...n,method:"GET",headers:{...r==null?void 0:r.headers,...n==null?void 0:n.headers}},o=await fetch(t,s).catch(()=>{throw new a.HttpError(a.HTTP_ERROR_MESSAGE.FAILED_TO_FETCH_URL,0)});if(this.responseType==="json"){if(!o.ok)throw new a.HttpError(o.statusText,o.status);return await o.json()}return o}async post(t,n,r){const s=D.isFunction(this.requestInit)?await this.requestInit():this.requestInit,o={...s,...n,method:"POST",headers:{...s==null?void 0:s.headers,...n==null?void 0:n.headers}},i=await fetch(t,o).catch(()=>{throw new a.HttpError(a.HTTP_ERROR_MESSAGE.FAILED_TO_POST_URL,0)});if(!i.ok)throw new a.HttpError(i.statusText,i.status,await i.json());if(i.status===204)return{};const c=await i.json();if(r)try{return r.parse(c)}catch(l){throw new a.HttpError(l.message,0)}return c}async put(t,n){const r=D.isFunction(this.requestInit)?await this.requestInit():this.requestInit,s={...r,...n,method:"PUT",headers:{...r==null?void 0:r.headers,...n==null?void 0:n.headers}},o=await fetch(t,s).catch(()=>{throw new a.HttpError("Failed to put url",0)});if(!o.ok)throw new a.HttpError(o.statusText,o.status);return await o.json()}async delete(t,n){const r=D.isFunction(this.requestInit)?await this.requestInit():this.requestInit,s={...r,...n,method:"DELETE",headers:{...r==null?void 0:r.headers,...n==null?void 0:n.headers}},o=await fetch(t,s).catch(()=>{throw new a.HttpError("Failed to delete url",0)});if(!o.ok)throw new a.HttpError(o.statusText,o.status)}}const ze=e=>{process.env.NODE_ENV};function Rs(e,t){const n=e.clone(),r=new Headers(n.headers);for(const[s,o]of Object.entries(t))r.set(s,o);return new Response(n.body,{status:n.status,statusText:e.statusText,headers:r})}class Ps{constructor(t,n,r,s){this.dateService=t,this.cacheService=n,this.httpService=r,this.options=s,this.inFlightRequests=new Map}async rawGet(t,n){try{const r=await this.cacheService.get(t),s=await this.dateService.now(),o=new Date(r.headers.get("date")||""),i=s.getTime()-o.getTime();if(i<this.options.freshFor)return ze("🟢 [SWR] Using fresh cache"),r;if(i<this.options.staleFor)return this.fetchAndCache(t,n),ze("🟠 [SWR] Revalidating cache"),r;throw new Error("Cache too old")}catch(r){if(r instanceof a.HttpError)throw r;return ze(),await this.fetchAndCache(t,n)}}async get(t,n){const r=await this.rawGet(t,n);return this.parseResponse(r)}async fetchAndCache(t,n){const r=this.inFlightRequests.get(t);if(!r){const s=this.httpService.get(t,n).then(async o=>{const i=await this.dateService.now();return await this.cacheService.set(t,Rs(o,{date:i.toUTCString()})),o}).finally(()=>{this.inFlightRequests.delete(t)});return this.inFlightRequests.set(t,s),s}return ze(),r}parseResponse(t){if(t.ok)return t.json();throw new a.HttpError(t.statusText,t.status)}}const Ne=(e,t,n)=>{const r=new Error(e);r.name="FetcherError",r.url=t.url,r.status=t.status,r.statusText=t.statusText,r.responseText=n;try{const s=JSON.parse(n);r.responseJson=s}catch{}return r},xt=async(e,t)=>{const n=await fetch(e,t),r=await n.text();if(!n.ok)throw Ne("An error occurred while fetching",n,r);try{return JSON.parse(r)}catch{throw Ne("An error occurred while parsing",n,r)}},Fs=async(e,t)=>{const n=await fetch(e,{method:"POST",...t}),r=await n.text();if(!n.ok)throw Ne("An error occurred while fetching",n,r);try{return JSON.parse(r)}catch{throw Ne("An error occurred while parsing",n,r)}},Ds=e=>({refreshInterval:e,dedupingInterval:e}),Us=e=>`${e.networkId}::${e.address}`,Hs=()=>{};function Tn(e,t,n,r){const{cache:s}=Be.useSWRConfig(),o=Be(e&&t,e?n:Hs,r);return $.useEffect(()=>{e||(o.mutate(),s.delete(t))},[e]),o}const $s={revalidateOnFocus:!1,revalidateOnMount:!0,revalidateOnReconnect:!1,refreshWhenOffline:!1,refreshWhenHidden:!1,refreshInterval:0},vn=async(e,t)=>{try{const{time:n}=await xt(a.urlJoin(e,"time"),{headers:t});return n}catch{throw new Error("failed to request time")}},Ls=async(e,t)=>{const n=await vn(e,t);return Math.floor(n)};function xn(e){switch(e){case"mainnet-alpha":case g.constants.NetworkName.SN_MAIN:return g.constants.StarknetChainId.SN_MAIN;case"sepolia-alpha":case g.constants.NetworkName.SN_SEPOLIA:return g.constants.StarknetChainId.SN_SEPOLIA;default:throw new a.NetworkError({code:"NOT_FOUND",message:`Unknown networkId: ${e}`})}}function In(e){return e.replace(".stark","").split(".").map(r=>g.starknetId.useEncoded(r).toString(10))}function Cn(e){const t=xn(e);return g.starknetId.getStarknetIdContract(t)}function _n(e,t){const n=Cn(t),r=In(e);try{const o={domain:r,hint:[]};return a.callSchema.parse({contractAddress:n,entrypoint:"domain_to_address",calldata:o})}catch(s){throw new a.CallError({code:"NOT_VALID",options:{error:s}})}}async function Bn(e,t,n){if(!t||!n)throw new a.NetworkError({code:"NO_NETWORK_OR_MULTICALL"});let r=null;try{r=_n(e,t)}catch(c){throw new a.CallError({code:"NOT_VALID",options:{error:c}})}let s,o;try{s=await n.callContract(r),o=s[0]}catch{throw new a.AddressError({code:"STARKNAME_ERROR"})}if(a.isZeroAddress(o))throw new a.AddressError({code:"STARKNAME_NOT_FOUND",message:`${e} not found`});if(!a.isValidAddress(o))throw new a.AddressError({code:"STARKNAME_INVALID_ADDRESS",message:`${e} resolved to an invalid address (${o})`});return a.normalizeAddress(o)}class js{constructor(t,n,r){this.httpService=t,this.baseUrl=n,this.allowedArgentNameNetworkId=r}async parseAddressOrDomain(t,n,r){if(a.isAddress(t))return a.normalizeAddress(t);try{return await this.getAddressFromDomainName(t,n,r)}catch{throw new a.AddressError({code:"NOT_VALID"})}}async getAddressFromDomainName(t,n,r){if(a.isStarknetId(t))return Bn(t,n,r);if(a.isArgentName(t)){if(n!==this.allowedArgentNameNetworkId)throw new a.AddressError({code:"ARGENT_NAME_INVALID_NETWORK",message:`Argent name is only enabled on "${this.allowedArgentNameNetworkId}"`});return a.getAddressFromArgentName(t,this.httpService,this.baseUrl)}throw new a.AddressError({code:"NO_ADDRESS_FROM_DOMAIN"})}}const Nn=["0x25ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918"],J={"0.2.4":"0x033434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2","0.2.3":"0x1a7820094feaf82d53f53f214b81292d717e7bb9a92bb2488092cd306f3993f","0.2.2":"0x3e327de1c40540b98d05cbcb13552008e36f0ec8d61d46956d2f9752c294328","0.2.1":"0x7e28fb0161d10d1cf7fe1f13e7ca57bce062731a3bd04494dfd2d0412699727","0.4.0":"0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f","0.3.1":"0x29927c8af6bccf3f6fda035981e765a7bdbf18a2dc0d630494f8758aa908e2b","0.3.0":"0x1a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003"},ke={"0.1.1":"0x6e150953b26271a740bf2b6e9bca17cc52c68d765f761295de51ceb8526ee72","0.1.0":"0x737ee2f87ce571a58c6c8da558ec18a07ceb64a6172d5ec46171fbc80077a48"};var zs=typeof global=="object"&&global&&global.Object===Object&&global,Vs=typeof self=="object"&&self&&self.Object===Object&&self,Qe=zs||Vs||Function("return this")(),We=Qe.Symbol,kn=Object.prototype,Ms=kn.hasOwnProperty,qs=kn.toString,xe=We?We.toStringTag:void 0;function Gs(e){var t=Ms.call(e,xe),n=e[xe];try{e[xe]=void 0;var r=!0}catch{}var s=qs.call(e);return r&&(t?e[xe]=n:delete e[xe]),s}var Ws=Object.prototype,Ks=Ws.toString;function Zs(e){return Ks.call(e)}var Ys="[object Null]",Js="[object Undefined]",Vt=We?We.toStringTag:void 0;function Xs(e){return e==null?e===void 0?Js:Ys:Vt&&Vt in Object(e)?Gs(e):Zs(e)}function On(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Qs="[object AsyncFunction]",eo="[object Function]",to="[object GeneratorFunction]",no="[object Proxy]";function ro(e){if(!On(e))return!1;var t=Xs(e);return t==eo||t==to||t==Qs||t==no}var lt=Qe["__core-js_shared__"],Mt=function(){var e=/[^.]+$/.exec(lt&<.keys&<.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function so(e){return!!Mt&&Mt in e}var oo=Function.prototype,ao=oo.toString;function io(e){if(e!=null){try{return ao.call(e)}catch{}try{return e+""}catch{}}return""}var co=/[\\^$.*+?()[\]{}|]/g,lo=/^\[object .+?Constructor\]$/,uo=Function.prototype,ho=Object.prototype,fo=uo.toString,mo=ho.hasOwnProperty,po=RegExp("^"+fo.call(mo).replace(co,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function go(e){if(!On(e)||so(e))return!1;var t=ro(e)?po:lo;return t.test(io(e))}function So(e,t){return e==null?void 0:e[t]}function It(e,t){var n=So(e,t);return go(n)?n:void 0}var Oe=It(Object,"create");function wo(){this.__data__=Oe?Oe(null):{},this.size=0}function yo(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var bo="__lodash_hash_undefined__",Eo=Object.prototype,Ao=Eo.hasOwnProperty;function To(e){var t=this.__data__;if(Oe){var n=t[e];return n===bo?void 0:n}return Ao.call(t,e)?t[e]:void 0}var vo=Object.prototype,xo=vo.hasOwnProperty;function Io(e){var t=this.__data__;return Oe?t[e]!==void 0:xo.call(t,e)}var Co="__lodash_hash_undefined__";function _o(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Oe&&t===void 0?Co:t,this}function de(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}de.prototype.clear=wo;de.prototype.delete=yo;de.prototype.get=To;de.prototype.has=Io;de.prototype.set=_o;function Bo(){this.__data__=[],this.size=0}function No(e,t){return e===t||e!==e&&t!==t}function et(e,t){for(var n=e.length;n--;)if(No(e[n][0],t))return n;return-1}var ko=Array.prototype,Oo=ko.splice;function Ro(e){var t=this.__data__,n=et(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Oo.call(t,n,1),--this.size,!0}function Po(e){var t=this.__data__,n=et(t,e);return n<0?void 0:t[n][1]}function Fo(e){return et(this.__data__,e)>-1}function Do(e,t){var n=this.__data__,r=et(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Ae(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Ae.prototype.clear=Bo;Ae.prototype.delete=Ro;Ae.prototype.get=Po;Ae.prototype.has=Fo;Ae.prototype.set=Do;var Uo=It(Qe,"Map");function Ho(){this.size=0,this.__data__={hash:new de,map:new(Uo||Ae),string:new de}}function $o(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function tt(e,t){var n=e.__data__;return $o(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Lo(e){var t=tt(this,e).delete(e);return this.size-=t?1:0,t}function jo(e){return tt(this,e).get(e)}function zo(e){return tt(this,e).has(e)}function Vo(e,t){var n=tt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function Te(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Te.prototype.clear=Ho;Te.prototype.delete=Lo;Te.prototype.get=jo;Te.prototype.has=zo;Te.prototype.set=Vo;var Mo="__lodash_hash_undefined__";function qo(e){return this.__data__.set(e,Mo),this}function Go(e){return this.__data__.has(e)}function Ke(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Te;++t<n;)this.add(e[t])}Ke.prototype.add=Ke.prototype.push=qo;Ke.prototype.has=Go;function Wo(e,t,n,r){for(var s=e.length,o=n+-1;++o<s;)if(t(e[o],o,e))return o;return-1}function Ko(e){return e!==e}function Zo(e,t,n){for(var r=n-1,s=e.length;++r<s;)if(e[r]===t)return r;return-1}function Yo(e,t,n){return t===t?Zo(e,t,n):Wo(e,Ko,n)}function Jo(e,t){var n=e==null?0:e.length;return!!n&&Yo(e,t,0)>-1}function Xo(e,t,n){for(var r=-1,s=e==null?0:e.length;++r<s;)if(n(t,e[r]))return!0;return!1}function Qo(e,t){return e.has(t)}var dt=It(Qe,"Set");function ea(){}function Rn(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var ta=1/0,na=dt&&1/Rn(new dt([,-0]))[1]==ta?function(e){return new dt(e)}:ea,ra=200;function sa(e,t,n){var r=-1,s=Jo,o=e.length,i=!0,c=[],l=c;if(n)i=!1,s=Xo;else if(o>=ra){var d=na(e);if(d)return Rn(d);i=!1,s=Qo,l=new Ke}else l=c;e:for(;++r<o;){var h=e[r],u=h;if(h=n||h!==0?h:0,i&&u===u){for(var y=l.length;y--;)if(l[y]===u)continue e;c.push(h)}else s(l,u,n)||(l!==c&&l.push(u),c.push(h))}return c}function oa(e,t){return t=typeof t=="function"?t:void 0,e&&e.length?sa(e,void 0,t):[]}function St(e){const t=Object.entries(J),n=Object.entries(ke);switch(e){case"cairo0":return t.filter(([r])=>a.semver.lt(r,"0.3.0")).map(([,r])=>r);case"cairo1":return t.filter(([r])=>a.semver.gte(r,"0.3.0")).map(([,r])=>r);case"multisig":return n.map(([,r])=>r);default:return t.map(([,r])=>r)}}function Pn(){const e=a.semver.maxSatisfying(Object.keys(J),"*");if(!e)throw new Error(`No argent account contract found: v${e} `);return J[e]}function aa(){const e=a.semver.maxSatisfying(Object.keys(ke),"*");if(!e)throw new Error(`No argent multisig contract found: v${e} `);return ke[e]}function Fn(){return Object.entries(J).filter(([e])=>a.semver.gte(e,"0.4.0")).map(([,e])=>e)}function ia(){const e=a.semver.maxSatisfying(Object.keys(J),"<0.3.0");if(!e)throw new Error(`No argent account contract found: v${e} `);return J[e]}function Dn(){const e=Object.entries(J).filter(([n])=>a.semver.gte(n,"0.3.1")).map(([,n])=>n),t=Object.entries(ke).filter(([n])=>a.semver.gte(n,"0.1.1")).map(([,n])=>n);return[...e,...t]}function ca(){return Object.entries(J).filter(([e])=>a.semver.gte(e,"0.4.0")).map(([,e])=>e)}function la(){const e=a.semver.maxSatisfying(Object.keys(J),">=0.4.0");if(!e)throw new Error(`No ledger account contract found: v${e}`);return J[e]}const Un=(e,t)=>e.cairoVersion===t.cairoVersion&&a.isEqualAddress(e.accountClassHash,t.accountClassHash);function da(e,t,n=[]){const r=a.implementationSchema.parse({cairoVersion:t.cairoVersion??"1",accountClassHash:t.classHash??Pn()}),s=m.z.array(a.implementationSchema).parse(n),o=[...St("cairo0").map(d=>({cairoVersion:"0",accountClassHash:d})),...St("cairo1").map(d=>({cairoVersion:"1",accountClassHash:d}))],l=oa([r,...s,...o],Un).map(d=>({implementation:d,address:Ln(d.cairoVersion,d.accountClassHash,e,t.guardian,t.salt)})).find(d=>a.isEqualAddress(d.address,t.address));if(!l)throw new a.AccountError({code:"CALCULATED_ADDRESS_NO_MATCH"});return l.implementation}function Hn(e,t,n,r,s,o=Nn[0]){const i=$n(e,t,n,r);return{classHash:e==="0"?o:t,constructorCalldata:g.CallData.compile(i),addressSalt:s||n}}function $n(e,t,n,r){const s=e!=="0"&&a.isEqualAddress(a.STANDARD_DEVNET_ACCOUNT_CLASS_HASH,t),o={pubkey:n,...s?{}:{guardian:r||"0"}};if(Fn().some(c=>a.isEqualAddress(c,t))){const c=a.getSignerForMultiSigner(n,a.MultiSigner.Starknet),l=r?new g.CairoOption(g.CairoOptionVariant.Some,a.getSignerForMultiSigner(r,a.MultiSigner.Starknet)):new g.CairoOption(g.CairoOptionVariant.None,null);return{ownerSigner:c,guardianAsOption:l}}return e==="0"?a.constructorCallDataSchemaC0.parse({implementation:t,selector:g.hash.getSelectorFromName("initialize"),calldata:g.CallData.compile(o)}):a.constructorCallDataSchemaC1V1.parse({owner:n,guardian:r})}function Ln(e,t,n,r,s){const o=Hn(e,t,n,r,s);return g.hash.calculateContractAddressFromHash(o.addressSalt,o.classHash,o.constructorCalldata,0)}function ua(e,t){const n=$.useRef(e),r=$.useRef();return $.useEffect(()=>{n.current=e},[e]),$.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]),(...s)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n.current(...s),t)}}function ha(e,t){const[n,r]=$.useState(e);return $.useEffect(()=>{const s=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(s)}},[e,t]),n}const jn=m.z.object({name:m.z.enum(["dappland","discord","github","telegram","twitter","website"]),url:m.z.string(),position:m.z.number()}),zn=m.z.object({address:a.addressSchemaArgentBackend,chain:m.z.enum(["ethereum","starknet"])}),Vn=m.z.object({dappId:m.z.string(),name:m.z.string(),description:m.z.string().optional(),logoUrl:m.z.string().optional(),dappUrl:m.z.string().optional(),inAppBrowserCompatible:m.z.boolean(),argentVerified:m.z.boolean(),links:m.z.array(jn).optional(),contracts:m.z.array(zn).optional(),categories:m.z.array(m.z.string()).optional(),supportedApps:m.z.array(m.z.string()).optional(),brandColor:m.z.string().optional()}),Mn=m.z.array(Vn);class fa{constructor(t,n){this.apiBase=t,this.httpService=new Xe(n,"json")}async getAll(){const t=await this.httpService.get(`${this.apiBase}/tokens/dapps`),n=Mn.safeParse(t);if(!n.success)throw new Error("Failed to parse known dapps");return n.data}}function qn(e){var t;return(t=e==null?void 0:e.links)==null?void 0:t.find(n=>n.name==="dappland")}function ma(e){var t;return(t=qn(e))==null?void 0:t.url}const Ct=m.object({domain:a.starknetIdSchema,address:a.addressSchema.optional(),avatar:m.string().optional(),status:m.union([m.literal("KNOWN"),m.literal("UNKNOWN")])}),Gn=m.array(Ct),Wn=m.object({provider:m.string(),name:m.string(),avatar:m.string().optional()}),Kn=m.object({address:a.addressSchema,status:m.union([m.literal("KNOWN"),m.literal("UNKNOWN")]),resolutions:m.array(Wn).optional()}),Zn=m.array(m.string()),Yn=Kn.array();class pa{constructor(t,n){this.apiBase=t,this.headers=n,this.httpService=new Xe(this.headers,"json")}async getAddressFromMultipleStarknetId(t,n,r){const s=new URLSearchParams(n.map(l=>["domain",l]));r&&s.set("includeAvatar","true");const o=a.urlJoin(this.apiBase,t,"starknet.id",`?${s}`),i=await this.httpService.get(o),c=Gn.safeParse(i);if(!c.success)throw new Error("Failed to parse name resolution");return c.data}async getAddressFromStarknetId(t,n,r){const s=a.urlJoin(this.apiBase,t,"starknet.id",n,r?"?includeAvatar=true":""),o=await this.httpService.get(s),i=Ct.safeParse(o);if(!i.success)throw new Error("Failed to parse name resolution");return i.data}async getStarknetIdFromAddress(t,n,r){const s=new URLSearchParams(n.map(l=>["address",l]));r&&s.set("includeAvatar","true");const o=a.urlJoin(this.apiBase,t,"addresses",`?${s}`),i=await this.httpService.get(o),c=Yn.safeParse(i);if(!c.success)throw new Error("Failed to parse name resolution");return c.data}async getProvidersNames(t){const n=a.urlJoin(this.apiBase,t,"providers","name"),r=await this.httpService.get(n),s=Zn.safeParse(r);if(!s.success)throw new Error("Failed to parse name resolution");return s.data}}const _t=e=>e.slice(0,6)+"..."+e.slice(-4);function qt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function ga(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function nt(e,...t){if(!ga(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Gt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Sa(e,t){nt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Ve=BigInt(2**32-1),Wt=BigInt(32);function wa(e,t=!1){return t?{h:Number(e&Ve),l:Number(e>>Wt&Ve)}:{h:Number(e>>Wt&Ve)|0,l:Number(e&Ve)|0}}function ya(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:i}=wa(e[s],t);[n[s],r[s]]=[o,i]}return[n,r]}const ba=(e,t,n)=>e<<n|t>>>32-n,Ea=(e,t,n)=>t<<n|e>>>32-n,Aa=(e,t,n)=>t<<n-32|e>>>64-n,Ta=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const va=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Kt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,xa=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function Zt(e){for(let t=0;t<e.length;t++)e[t]=xa(e[t])}const Ia=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ca(e){nt(e);let t="";for(let n=0;n<e.length;n++)t+=Ia[e[n]];return t}function Jn(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Xn(e){return typeof e=="string"&&(e=Jn(e)),nt(e),e}let _a=class{clone(){return this._cloneInto()}};function Ba(e){const t=r=>e().update(Xn(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const Qn=[],er=[],tr=[],Na=BigInt(0),Ie=BigInt(1),ka=BigInt(2),Oa=BigInt(7),Ra=BigInt(256),Pa=BigInt(113);for(let e=0,t=Ie,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Qn.push(2*(5*r+n)),er.push((e+1)*(e+2)/2%64);let s=Na;for(let o=0;o<7;o++)t=(t<<Ie^(t>>Oa)*Pa)%Ra,t&ka&&(s^=Ie<<(Ie<<BigInt(o))-Ie);tr.push(s)}const[Fa,Da]=ya(tr,!0),Yt=(e,t,n)=>n>32?Aa(e,t,n):ba(e,t,n),Jt=(e,t,n)=>n>32?Ta(e,t,n):Ea(e,t,n);function Ua(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,l=(i+2)%10,d=n[l],h=n[l+1],u=Yt(d,h,1)^n[c],y=Jt(d,h,1)^n[c+1];for(let S=0;S<50;S+=10)e[i+S]^=u,e[i+S+1]^=y}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=er[i],l=Yt(s,o,c),d=Jt(s,o,c),h=Qn[i];s=e[h],o=e[h+1],e[h]=l,e[h+1]=d}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=Fa[r],e[1]^=Da[r]}n.fill(0)}let Ha=class nr extends _a{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,qt(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=va(this.state)}keccak(){Kt||Zt(this.state32),Ua(this.state32,this.rounds),Kt||Zt(this.state32),this.posOut=0,this.pos=0}update(t){Gt(this);const{blockLen:n,state:r}=this;t=Xn(t);const s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let c=0;c<i;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,n&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Gt(this,!1),nt(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return qt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Sa(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new nr(n,r,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}};const $a=(e,t,n)=>Ba(()=>new Ha(t,e,n)),La=$a(1,136,256/8);function rr(e){return`0x${Ca(La(Jn(e)))}`}const ja=e=>{if(!D.isString(e))return;const t=/(\d+)$/,n=e.match(t);if(n)return n[1]},sr=(e,t=!1)=>{if(!D.isString(e))return"";const n=t?e.replace(/[^0-9a-z ]/gi,""):e,s=D.upperCase(n).split(" "),o=ja(n),i=s.map(c=>c[0]);return o&&o.length>1&&o.length<n.length?[i[0],o.substring(0,2)].join(""):s.length===1?s[0].substring(0,2):[i[0],i[i.length-1]].join("")},{toBigInt:za}=g.num,Xt=e=>{const t=e.replace("#","");if(!/^[0-9A-F]{6}$/i.test(t))throw new Error(`Invalid color ${e}`);return`#${t}`},Re=(e,t)=>{const n=Xt(t.background),r=Xt(t.color??"#ffffff"),s=sr(e,!0),o=`<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48">
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("zod"),a=require("./transactionVersion-IV8urBdT.js"),g=require("starknet"),$=require("react"),D=require("lodash-es"),Be=require("swr"),ye=require("@scure/base"),es=require("ua-parser-js"),ts=require("@scure/bip39"),ns=require("@scure/bip39/wordlists/english"),rs=require("object-hash"),gn=m.z.object({name:m.z.string().optional(),address:m.z.string(),ownerAddress:m.z.string(),chain:m.z.enum(["ethereum","zksync","zksync2","starknet"]),deploymentStatus:m.z.enum(["notDeployed","deploying","deployed","deployError"]),application:m.z.enum(["mobile","webwallet","argentx"]),guardianAddresses:m.z.array(m.z.string()).optional(),enabledGuardianAddresses:m.z.array(m.z.string()).optional(),implClassHash:m.z.string().optional(),proxyClassHash:m.z.string().optional(),salt:m.z.string().optional(),created:m.z.string().optional(),contractVersion:m.z.string().optional(),contractName:m.z.string().optional(),version:m.z.number().optional(),owner:m.z.object({guid:m.z.string().optional(),signerType:m.z.enum(["StarknetKey","EthereumKey"]).optional()}).optional()}),ss=m.z.object({address:m.z.string(),guardianAddress:m.z.string().optional(),account:gn}),os=m.z.object({ownerAddress:m.z.string(),signature:m.z.object({r:m.z.string(),s:m.z.string()}),implClassHash:m.z.string().optional(),name:m.z.string().optional(),icon:m.z.string().optional()});function as(e){return"transactionVersion"in e}function is(e){return"simulateTransaction"in e}function cs(e){return!("simulateTransaction"in e)}const Sn=m.z.object({value:m.z.string(),platform:m.z.enum(["ios","argentx","android","webwallet"]).nullable()}),ls=m.z.object({preferences:m.z.record(Sn)}),wn=m.z.enum(["mainnet-alpha","sepolia-alpha"]),yn=m.z.enum(["mainnet","sepolia"]);function ds(e){return wn.safeParse(e).success}function us(e){return yn.safeParse(e).success}const Ee=18;function Ue({value:e,decimals:t}){if(t===0)return e.toString();const n=e<0n;e=n?-e:e;const r=e.toString().padStart(t,"0"),s=r.slice(0,-t)||"0",o=r.slice(-t).replace(/0+$/,"");return`${n?"-":""}${s}${o?`.${o}`:""}`}const At=(e,t)=>({decimals:t,value:t>=e.decimals?e.value*BigInt(10)**BigInt(t-e.decimals):e.value/BigInt(10)**BigInt(e.decimals-t)}),bn=e=>{const t=e.value.toString().split("").reverse();let n=0;for(let s=0;s<t.length&&t[s]==="0";s++)n++;const r=e.decimals-n;return At(e,r)},En=(e,t)=>{const n=Math.max(e.decimals,t.decimals),[r,s]=[e,t].map(o=>At(o,n));return[r.value,s.value,n]},Je=e=>(t,n)=>{const[r,s,o]=En(t,n);return{decimals:o,value:e(r,s,o)}},He=e=>(t,n)=>{const[r,s]=En(t,n);return e(r,s)},hs=Je((e,t)=>e+t),fs=Je((e,t)=>e-t),ms=Je((e,t,n)=>{if(t===BigInt(0))throw new Error("Division by zero is not allowed");return e*BigInt(10)**BigInt(n)/t}),ps=(e,t)=>bn({decimals:e.decimals+t.decimals,value:e.value*t.value}),gs=Je((e,t)=>{if(t===BigInt(0))throw new Error("Modulus by zero is not allowed");return e%t}),Tt=e=>({decimals:e.decimals,value:e.value>=BigInt(0)?e.value:-e.value}),An=He((e,t)=>e===t),Ss=He((e,t)=>e<t),ws=He((e,t)=>e>t),ys=He((e,t)=>e<=t),bs=He((e,t)=>e>=t),Es=(e,t)=>!An(e,t);function As(e){return Ue({value:e,decimals:Ee})}function Ts(e){return a.parseUnits(e,Ee)}function vs(e){return Ue({value:e,decimals:Ee})}function vt(e){return a.parseUnits(e,Ee)}function xs(e){return Tt({value:e,decimals:0}).value}function Is(e){return Tt(vt(e))}function Cs(e,t){return{value:BigInt(e),decimals:t}}const _s={value:1n,decimals:0};function Bs(e){return m.z.string().refine(t=>/^-?\d+(\.\d+)?$/.test(t),{message:"Invalid number format"}).transform(t=>a.parseUnits(t,e))}const Ns=Object.freeze(Object.defineProperty({__proto__:null,ONE:_s,abs:Tt,absBigInt:xs,add:hs,createUnitsSchema:Bs,div:ms,eq:An,formatCurrency:vs,formatEther:As,formatUnits:Ue,gt:ws,gte:bs,lt:Ss,lte:ys,mod:gs,mul:ps,not:Es,parseCurrency:vt,parseCurrencyAbs:Is,parseEther:Ts,parseUnits:a.parseUnits,sub:fs,toBigDecimal:Cs,toFixedDecimals:At,toTiniestPossibleDecimal:bn},Symbol.toStringTag,{value:"Module"}));class ks{constructor(t,n){this.cachePromise=n.open(t).catch(r=>(console.error(new Error("Failed to open cache",{cause:r})),null))}async get(t){const n=await this.cachePromise;if(!n)throw new Error("No cache available");const r=await n.match(t).catch(()=>{throw new Error("Failed to match cache")});if(!r)throw new Error("Failed to match cache");return r.clone()}async set(t,n){const r=await this.cachePromise;r&&await r.put(t,n).catch(()=>{throw new Error("Failed to match cache")})}async delete(t){const n=await this.cachePromise;return n?n.delete(t):!1}async flush(){const t=await this.cachePromise;if(!t)return;const n=await t.keys();await Promise.allSettled(n.map(r=>t.delete(r)))}}class Os{constructor(t,n){this.httpService=t,this.baseUrl=n,this.offsetInS=0,this.syncIntervalInMs=60*1e3,this.initialSync=this.syncWithServer(),setInterval(()=>void this.syncWithServer(),this.syncIntervalInMs)}async now(){return await this.initialSync,new Date(Date.now()+this.offsetInS*1e3)}async syncWithServer(){if(typeof window>"u")return;const{time:t}=await this.httpService.get(`${this.baseUrl}/time`),n=Math.floor(Date.now()/1e3),r=t-n;this.offsetInS=r}}class Xe{constructor(t,n="json"){this.requestInit=t,this.responseType=n}async get(t,n){const r=D.isFunction(this.requestInit)?await this.requestInit():this.requestInit,s={...r,...n,method:"GET",headers:{...r==null?void 0:r.headers,...n==null?void 0:n.headers}},o=await fetch(t,s).catch(()=>{throw new a.HttpError(a.HTTP_ERROR_MESSAGE.FAILED_TO_FETCH_URL,0)});if(this.responseType==="json"){if(!o.ok)throw new a.HttpError(o.statusText,o.status);return await o.json()}return o}async post(t,n,r){const s=D.isFunction(this.requestInit)?await this.requestInit():this.requestInit,o={...s,...n,method:"POST",headers:{...s==null?void 0:s.headers,...n==null?void 0:n.headers}},i=await fetch(t,o).catch(()=>{throw new a.HttpError(a.HTTP_ERROR_MESSAGE.FAILED_TO_POST_URL,0)});if(!i.ok)throw new a.HttpError(i.statusText,i.status,await i.json());if(i.status===204)return{};const c=await i.json();if(r)try{return r.parse(c)}catch(l){throw new a.HttpError(l.message,0)}return c}async put(t,n){const r=D.isFunction(this.requestInit)?await this.requestInit():this.requestInit,s={...r,...n,method:"PUT",headers:{...r==null?void 0:r.headers,...n==null?void 0:n.headers}},o=await fetch(t,s).catch(()=>{throw new a.HttpError("Failed to put url",0)});if(!o.ok)throw new a.HttpError(o.statusText,o.status);return await o.json()}async delete(t,n){const r=D.isFunction(this.requestInit)?await this.requestInit():this.requestInit,s={...r,...n,method:"DELETE",headers:{...r==null?void 0:r.headers,...n==null?void 0:n.headers}},o=await fetch(t,s).catch(()=>{throw new a.HttpError("Failed to delete url",0)});if(!o.ok)throw new a.HttpError(o.statusText,o.status)}}const ze=e=>{process.env.NODE_ENV};function Rs(e,t){const n=e.clone(),r=new Headers(n.headers);for(const[s,o]of Object.entries(t))r.set(s,o);return new Response(n.body,{status:n.status,statusText:e.statusText,headers:r})}class Ps{constructor(t,n,r,s){this.dateService=t,this.cacheService=n,this.httpService=r,this.options=s,this.inFlightRequests=new Map}async rawGet(t,n){try{const r=await this.cacheService.get(t),s=await this.dateService.now(),o=new Date(r.headers.get("date")||""),i=s.getTime()-o.getTime();if(i<this.options.freshFor)return ze("🟢 [SWR] Using fresh cache"),r;if(i<this.options.staleFor)return this.fetchAndCache(t,n),ze("🟠 [SWR] Revalidating cache"),r;throw new Error("Cache too old")}catch(r){if(r instanceof a.HttpError)throw r;return ze(),await this.fetchAndCache(t,n)}}async get(t,n){const r=await this.rawGet(t,n);return this.parseResponse(r)}async fetchAndCache(t,n){const r=this.inFlightRequests.get(t);if(!r){const s=this.httpService.get(t,n).then(async o=>{const i=await this.dateService.now();return await this.cacheService.set(t,Rs(o,{date:i.toUTCString()})),o}).finally(()=>{this.inFlightRequests.delete(t)});return this.inFlightRequests.set(t,s),s}return ze(),r}parseResponse(t){if(t.ok)return t.json();throw new a.HttpError(t.statusText,t.status)}}const Ne=(e,t,n)=>{const r=new Error(e);r.name="FetcherError",r.url=t.url,r.status=t.status,r.statusText=t.statusText,r.responseText=n;try{const s=JSON.parse(n);r.responseJson=s}catch{}return r},xt=async(e,t)=>{const n=await fetch(e,t),r=await n.text();if(!n.ok)throw Ne("An error occurred while fetching",n,r);try{return JSON.parse(r)}catch{throw Ne("An error occurred while parsing",n,r)}},Fs=async(e,t)=>{const n=await fetch(e,{method:"POST",...t}),r=await n.text();if(!n.ok)throw Ne("An error occurred while fetching",n,r);try{return JSON.parse(r)}catch{throw Ne("An error occurred while parsing",n,r)}},Ds=e=>({refreshInterval:e,dedupingInterval:e}),Us=e=>`${e.networkId}::${e.address}`,Hs=()=>{};function Tn(e,t,n,r){const{cache:s}=Be.useSWRConfig(),o=Be(e&&t,e?n:Hs,r);return $.useEffect(()=>{e||(o.mutate(),s.delete(t))},[e]),o}const $s={revalidateOnFocus:!1,revalidateOnMount:!0,revalidateOnReconnect:!1,refreshWhenOffline:!1,refreshWhenHidden:!1,refreshInterval:0},vn=async(e,t)=>{try{const{time:n}=await xt(a.urlJoin(e,"time"),{headers:t});return n}catch{throw new Error("failed to request time")}},Ls=async(e,t)=>{const n=await vn(e,t);return Math.floor(n)};function xn(e){switch(e){case"mainnet-alpha":case g.constants.NetworkName.SN_MAIN:return g.constants.StarknetChainId.SN_MAIN;case"sepolia-alpha":case g.constants.NetworkName.SN_SEPOLIA:return g.constants.StarknetChainId.SN_SEPOLIA;default:throw new a.NetworkError({code:"NOT_FOUND",message:`Unknown networkId: ${e}`})}}function In(e){return e.replace(".stark","").split(".").map(r=>g.starknetId.useEncoded(r).toString(10))}function Cn(e){const t=xn(e);return g.starknetId.getStarknetIdContract(t)}function _n(e,t){const n=Cn(t),r=In(e);try{const o={domain:r,hint:[]};return a.callSchema.parse({contractAddress:n,entrypoint:"domain_to_address",calldata:o})}catch(s){throw new a.CallError({code:"NOT_VALID",options:{error:s}})}}async function Bn(e,t,n){if(!t||!n)throw new a.NetworkError({code:"NO_NETWORK_OR_MULTICALL"});let r=null;try{r=_n(e,t)}catch(c){throw new a.CallError({code:"NOT_VALID",options:{error:c}})}let s,o;try{s=await n.callContract(r),o=s[0]}catch{throw new a.AddressError({code:"STARKNAME_ERROR"})}if(a.isZeroAddress(o))throw new a.AddressError({code:"STARKNAME_NOT_FOUND",message:`${e} not found`});if(!a.isValidAddress(o))throw new a.AddressError({code:"STARKNAME_INVALID_ADDRESS",message:`${e} resolved to an invalid address (${o})`});return a.normalizeAddress(o)}class js{constructor(t,n,r){this.httpService=t,this.baseUrl=n,this.allowedArgentNameNetworkId=r}async parseAddressOrDomain(t,n,r){if(a.isAddress(t))return a.normalizeAddress(t);try{return await this.getAddressFromDomainName(t,n,r)}catch{throw new a.AddressError({code:"NOT_VALID"})}}async getAddressFromDomainName(t,n,r){if(a.isStarknetId(t))return Bn(t,n,r);if(a.isArgentName(t)){if(n!==this.allowedArgentNameNetworkId)throw new a.AddressError({code:"ARGENT_NAME_INVALID_NETWORK",message:`Argent name is only enabled on "${this.allowedArgentNameNetworkId}"`});return a.getAddressFromArgentName(t,this.httpService,this.baseUrl)}throw new a.AddressError({code:"NO_ADDRESS_FROM_DOMAIN"})}}const Nn=["0x25ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918"],J={"0.2.4":"0x033434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2","0.2.3":"0x1a7820094feaf82d53f53f214b81292d717e7bb9a92bb2488092cd306f3993f","0.2.2":"0x3e327de1c40540b98d05cbcb13552008e36f0ec8d61d46956d2f9752c294328","0.2.1":"0x7e28fb0161d10d1cf7fe1f13e7ca57bce062731a3bd04494dfd2d0412699727","0.4.0":"0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f","0.3.1":"0x29927c8af6bccf3f6fda035981e765a7bdbf18a2dc0d630494f8758aa908e2b","0.3.0":"0x1a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003"},ke={"0.1.1":"0x6e150953b26271a740bf2b6e9bca17cc52c68d765f761295de51ceb8526ee72","0.1.0":"0x737ee2f87ce571a58c6c8da558ec18a07ceb64a6172d5ec46171fbc80077a48"};var zs=typeof global=="object"&&global&&global.Object===Object&&global,Vs=typeof self=="object"&&self&&self.Object===Object&&self,Qe=zs||Vs||Function("return this")(),We=Qe.Symbol,kn=Object.prototype,Ms=kn.hasOwnProperty,qs=kn.toString,xe=We?We.toStringTag:void 0;function Gs(e){var t=Ms.call(e,xe),n=e[xe];try{e[xe]=void 0;var r=!0}catch{}var s=qs.call(e);return r&&(t?e[xe]=n:delete e[xe]),s}var Ws=Object.prototype,Ks=Ws.toString;function Zs(e){return Ks.call(e)}var Ys="[object Null]",Js="[object Undefined]",Vt=We?We.toStringTag:void 0;function Xs(e){return e==null?e===void 0?Js:Ys:Vt&&Vt in Object(e)?Gs(e):Zs(e)}function On(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Qs="[object AsyncFunction]",eo="[object Function]",to="[object GeneratorFunction]",no="[object Proxy]";function ro(e){if(!On(e))return!1;var t=Xs(e);return t==eo||t==to||t==Qs||t==no}var lt=Qe["__core-js_shared__"],Mt=function(){var e=/[^.]+$/.exec(lt&<.keys&<.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function so(e){return!!Mt&&Mt in e}var oo=Function.prototype,ao=oo.toString;function io(e){if(e!=null){try{return ao.call(e)}catch{}try{return e+""}catch{}}return""}var co=/[\\^$.*+?()[\]{}|]/g,lo=/^\[object .+?Constructor\]$/,uo=Function.prototype,ho=Object.prototype,fo=uo.toString,mo=ho.hasOwnProperty,po=RegExp("^"+fo.call(mo).replace(co,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function go(e){if(!On(e)||so(e))return!1;var t=ro(e)?po:lo;return t.test(io(e))}function So(e,t){return e==null?void 0:e[t]}function It(e,t){var n=So(e,t);return go(n)?n:void 0}var Oe=It(Object,"create");function wo(){this.__data__=Oe?Oe(null):{},this.size=0}function yo(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var bo="__lodash_hash_undefined__",Eo=Object.prototype,Ao=Eo.hasOwnProperty;function To(e){var t=this.__data__;if(Oe){var n=t[e];return n===bo?void 0:n}return Ao.call(t,e)?t[e]:void 0}var vo=Object.prototype,xo=vo.hasOwnProperty;function Io(e){var t=this.__data__;return Oe?t[e]!==void 0:xo.call(t,e)}var Co="__lodash_hash_undefined__";function _o(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Oe&&t===void 0?Co:t,this}function de(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}de.prototype.clear=wo;de.prototype.delete=yo;de.prototype.get=To;de.prototype.has=Io;de.prototype.set=_o;function Bo(){this.__data__=[],this.size=0}function No(e,t){return e===t||e!==e&&t!==t}function et(e,t){for(var n=e.length;n--;)if(No(e[n][0],t))return n;return-1}var ko=Array.prototype,Oo=ko.splice;function Ro(e){var t=this.__data__,n=et(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Oo.call(t,n,1),--this.size,!0}function Po(e){var t=this.__data__,n=et(t,e);return n<0?void 0:t[n][1]}function Fo(e){return et(this.__data__,e)>-1}function Do(e,t){var n=this.__data__,r=et(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Ae(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Ae.prototype.clear=Bo;Ae.prototype.delete=Ro;Ae.prototype.get=Po;Ae.prototype.has=Fo;Ae.prototype.set=Do;var Uo=It(Qe,"Map");function Ho(){this.size=0,this.__data__={hash:new de,map:new(Uo||Ae),string:new de}}function $o(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function tt(e,t){var n=e.__data__;return $o(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Lo(e){var t=tt(this,e).delete(e);return this.size-=t?1:0,t}function jo(e){return tt(this,e).get(e)}function zo(e){return tt(this,e).has(e)}function Vo(e,t){var n=tt(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function Te(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Te.prototype.clear=Ho;Te.prototype.delete=Lo;Te.prototype.get=jo;Te.prototype.has=zo;Te.prototype.set=Vo;var Mo="__lodash_hash_undefined__";function qo(e){return this.__data__.set(e,Mo),this}function Go(e){return this.__data__.has(e)}function Ke(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Te;++t<n;)this.add(e[t])}Ke.prototype.add=Ke.prototype.push=qo;Ke.prototype.has=Go;function Wo(e,t,n,r){for(var s=e.length,o=n+-1;++o<s;)if(t(e[o],o,e))return o;return-1}function Ko(e){return e!==e}function Zo(e,t,n){for(var r=n-1,s=e.length;++r<s;)if(e[r]===t)return r;return-1}function Yo(e,t,n){return t===t?Zo(e,t,n):Wo(e,Ko,n)}function Jo(e,t){var n=e==null?0:e.length;return!!n&&Yo(e,t,0)>-1}function Xo(e,t,n){for(var r=-1,s=e==null?0:e.length;++r<s;)if(n(t,e[r]))return!0;return!1}function Qo(e,t){return e.has(t)}var dt=It(Qe,"Set");function ea(){}function Rn(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var ta=1/0,na=dt&&1/Rn(new dt([,-0]))[1]==ta?function(e){return new dt(e)}:ea,ra=200;function sa(e,t,n){var r=-1,s=Jo,o=e.length,i=!0,c=[],l=c;if(n)i=!1,s=Xo;else if(o>=ra){var d=na(e);if(d)return Rn(d);i=!1,s=Qo,l=new Ke}else l=c;e:for(;++r<o;){var h=e[r],u=h;if(h=n||h!==0?h:0,i&&u===u){for(var y=l.length;y--;)if(l[y]===u)continue e;c.push(h)}else s(l,u,n)||(l!==c&&l.push(u),c.push(h))}return c}function oa(e,t){return t=typeof t=="function"?t:void 0,e&&e.length?sa(e,void 0,t):[]}function St(e){const t=Object.entries(J),n=Object.entries(ke);switch(e){case"cairo0":return t.filter(([r])=>a.semver.lt(r,"0.3.0")).map(([,r])=>r);case"cairo1":return t.filter(([r])=>a.semver.gte(r,"0.3.0")).map(([,r])=>r);case"multisig":return n.map(([,r])=>r);default:return t.map(([,r])=>r)}}function Pn(){const e=a.semver.maxSatisfying(Object.keys(J),"*");if(!e)throw new Error(`No argent account contract found: v${e} `);return J[e]}function aa(){const e=a.semver.maxSatisfying(Object.keys(ke),"*");if(!e)throw new Error(`No argent multisig contract found: v${e} `);return ke[e]}function Fn(){return Object.entries(J).filter(([e])=>a.semver.gte(e,"0.4.0")).map(([,e])=>e)}function ia(){const e=a.semver.maxSatisfying(Object.keys(J),"<0.3.0");if(!e)throw new Error(`No argent account contract found: v${e} `);return J[e]}function Dn(){const e=Object.entries(J).filter(([n])=>a.semver.gte(n,"0.3.1")).map(([,n])=>n),t=Object.entries(ke).filter(([n])=>a.semver.gte(n,"0.1.1")).map(([,n])=>n);return[...e,...t]}function ca(){return Object.entries(J).filter(([e])=>a.semver.gte(e,"0.4.0")).map(([,e])=>e)}function la(){const e=a.semver.maxSatisfying(Object.keys(J),">=0.4.0");if(!e)throw new Error(`No ledger account contract found: v${e}`);return J[e]}const Un=(e,t)=>e.cairoVersion===t.cairoVersion&&a.isEqualAddress(e.accountClassHash,t.accountClassHash);function da(e,t,n=[]){const r=a.implementationSchema.parse({cairoVersion:t.cairoVersion??"1",accountClassHash:t.classHash??Pn()}),s=m.z.array(a.implementationSchema).parse(n),o=[...St("cairo0").map(d=>({cairoVersion:"0",accountClassHash:d})),...St("cairo1").map(d=>({cairoVersion:"1",accountClassHash:d}))],l=oa([r,...s,...o],Un).map(d=>({implementation:d,address:Ln(d.cairoVersion,d.accountClassHash,e,t.guardian,t.salt)})).find(d=>a.isEqualAddress(d.address,t.address));if(!l)throw new a.AccountError({code:"CALCULATED_ADDRESS_NO_MATCH"});return l.implementation}function Hn(e,t,n,r,s,o=Nn[0]){const i=$n(e,t,n,r);return{classHash:e==="0"?o:t,constructorCalldata:g.CallData.compile(i),addressSalt:s||n}}function $n(e,t,n,r){const s=e!=="0"&&a.isEqualAddress(a.STANDARD_DEVNET_ACCOUNT_CLASS_HASH,t),o={pubkey:n,...s?{}:{guardian:r||"0"}};if(Fn().some(c=>a.isEqualAddress(c,t))){const c=a.getSignerForMultiSigner(n,a.MultiSigner.Starknet),l=r?new g.CairoOption(g.CairoOptionVariant.Some,a.getSignerForMultiSigner(r,a.MultiSigner.Starknet)):new g.CairoOption(g.CairoOptionVariant.None,null);return{ownerSigner:c,guardianAsOption:l}}return e==="0"?a.constructorCallDataSchemaC0.parse({implementation:t,selector:g.hash.getSelectorFromName("initialize"),calldata:g.CallData.compile(o)}):a.constructorCallDataSchemaC1V1.parse({owner:n,guardian:r})}function Ln(e,t,n,r,s){const o=Hn(e,t,n,r,s);return g.hash.calculateContractAddressFromHash(o.addressSalt,o.classHash,o.constructorCalldata,0)}function ua(e,t){const n=$.useRef(e),r=$.useRef();return $.useEffect(()=>{n.current=e},[e]),$.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]),(...s)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n.current(...s),t)}}function ha(e,t){const[n,r]=$.useState(e);return $.useEffect(()=>{const s=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(s)}},[e,t]),n}const jn=m.z.object({name:m.z.enum(["dappland","discord","github","telegram","twitter","website"]),url:m.z.string(),position:m.z.number()}),zn=m.z.object({address:a.addressSchemaArgentBackend,chain:m.z.enum(["ethereum","starknet"])}),Vn=m.z.object({dappId:m.z.string(),name:m.z.string(),description:m.z.string().optional(),logoUrl:m.z.string().optional(),dappUrl:m.z.string().optional(),inAppBrowserCompatible:m.z.boolean(),argentVerified:m.z.boolean(),links:m.z.array(jn).optional(),contracts:m.z.array(zn).optional(),categories:m.z.array(m.z.string()).optional(),supportedApps:m.z.array(m.z.string()).optional(),brandColor:m.z.string().optional()}),Mn=m.z.array(Vn);class fa{constructor(t,n){this.apiBase=t,this.httpService=new Xe(n,"json")}async getAll(){const t=await this.httpService.get(`${this.apiBase}/tokens/dapps`),n=Mn.safeParse(t);if(!n.success)throw new Error("Failed to parse known dapps");return n.data}}function qn(e){var t;return(t=e==null?void 0:e.links)==null?void 0:t.find(n=>n.name==="dappland")}function ma(e){var t;return(t=qn(e))==null?void 0:t.url}const Ct=m.object({domain:a.starknetIdSchema,address:a.addressSchema.optional(),avatar:m.string().optional(),status:m.union([m.literal("KNOWN"),m.literal("UNKNOWN")])}),Gn=m.array(Ct),Wn=m.object({provider:m.string(),name:m.string(),avatar:m.string().optional()}),Kn=m.object({address:a.addressSchema,status:m.union([m.literal("KNOWN"),m.literal("UNKNOWN")]),resolutions:m.array(Wn).optional()}),Zn=m.array(m.string()),Yn=Kn.array();class pa{constructor(t,n){this.apiBase=t,this.headers=n,this.httpService=new Xe(this.headers,"json")}async getAddressFromMultipleStarknetId(t,n,r){const s=new URLSearchParams(n.map(l=>["domain",l]));r&&s.set("includeAvatar","true");const o=a.urlJoin(this.apiBase,t,"starknet.id",`?${s}`),i=await this.httpService.get(o),c=Gn.safeParse(i);if(!c.success)throw new Error("Failed to parse name resolution");return c.data}async getAddressFromStarknetId(t,n,r){const s=a.urlJoin(this.apiBase,t,"starknet.id",n,r?"?includeAvatar=true":""),o=await this.httpService.get(s),i=Ct.safeParse(o);if(!i.success)throw new Error("Failed to parse name resolution");return i.data}async getStarknetIdFromAddress(t,n,r){const s=new URLSearchParams(n.map(l=>["address",l]));r&&s.set("includeAvatar","true");const o=a.urlJoin(this.apiBase,t,"addresses",`?${s}`),i=await this.httpService.get(o),c=Yn.safeParse(i);if(!c.success)throw new Error("Failed to parse name resolution");return c.data}async getProvidersNames(t){const n=a.urlJoin(this.apiBase,t,"providers","name"),r=await this.httpService.get(n),s=Zn.safeParse(r);if(!s.success)throw new Error("Failed to parse name resolution");return s.data}}const _t=e=>e.slice(0,6)+"..."+e.slice(-4);function qt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function ga(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function nt(e,...t){if(!ga(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Gt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Sa(e,t){nt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Ve=BigInt(2**32-1),Wt=BigInt(32);function wa(e,t=!1){return t?{h:Number(e&Ve),l:Number(e>>Wt&Ve)}:{h:Number(e>>Wt&Ve)|0,l:Number(e&Ve)|0}}function ya(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:i}=wa(e[s],t);[n[s],r[s]]=[o,i]}return[n,r]}const ba=(e,t,n)=>e<<n|t>>>32-n,Ea=(e,t,n)=>t<<n|e>>>32-n,Aa=(e,t,n)=>t<<n-32|e>>>64-n,Ta=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const va=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Kt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,xa=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function Zt(e){for(let t=0;t<e.length;t++)e[t]=xa(e[t])}const Ia=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ca(e){nt(e);let t="";for(let n=0;n<e.length;n++)t+=Ia[e[n]];return t}function Jn(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Xn(e){return typeof e=="string"&&(e=Jn(e)),nt(e),e}let _a=class{clone(){return this._cloneInto()}};function Ba(e){const t=r=>e().update(Xn(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const Qn=[],er=[],tr=[],Na=BigInt(0),Ie=BigInt(1),ka=BigInt(2),Oa=BigInt(7),Ra=BigInt(256),Pa=BigInt(113);for(let e=0,t=Ie,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Qn.push(2*(5*r+n)),er.push((e+1)*(e+2)/2%64);let s=Na;for(let o=0;o<7;o++)t=(t<<Ie^(t>>Oa)*Pa)%Ra,t&ka&&(s^=Ie<<(Ie<<BigInt(o))-Ie);tr.push(s)}const[Fa,Da]=ya(tr,!0),Yt=(e,t,n)=>n>32?Aa(e,t,n):ba(e,t,n),Jt=(e,t,n)=>n>32?Ta(e,t,n):Ea(e,t,n);function Ua(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,l=(i+2)%10,d=n[l],h=n[l+1],u=Yt(d,h,1)^n[c],y=Jt(d,h,1)^n[c+1];for(let S=0;S<50;S+=10)e[i+S]^=u,e[i+S+1]^=y}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=er[i],l=Yt(s,o,c),d=Jt(s,o,c),h=Qn[i];s=e[h],o=e[h+1],e[h]=l,e[h+1]=d}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=Fa[r],e[1]^=Da[r]}n.fill(0)}let Ha=class nr extends _a{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,qt(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=va(this.state)}keccak(){Kt||Zt(this.state32),Ua(this.state32,this.rounds),Kt||Zt(this.state32),this.posOut=0,this.pos=0}update(t){Gt(this);const{blockLen:n,state:r}=this;t=Xn(t);const s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let c=0;c<i;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,n&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Gt(this,!1),nt(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return qt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Sa(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new nr(n,r,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}};const $a=(e,t,n)=>Ba(()=>new Ha(t,e,n)),La=$a(1,136,256/8);function rr(e){return`0x${Ca(La(Jn(e)))}`}const ja=e=>{if(!D.isString(e))return;const t=/(\d+)$/,n=e.match(t);if(n)return n[1]},sr=(e,t=!1)=>{if(!D.isString(e))return"";const n=t?e.replace(/[^0-9a-z ]/gi,""):e,s=D.upperCase(n).split(" "),o=ja(n),i=s.map(c=>c[0]);return o&&o.length>1&&o.length<n.length?[i[0],o.substring(0,2)].join(""):s.length===1?s[0].substring(0,2):[i[0],i[i.length-1]].join("")},{toBigInt:za}=g.num,Xt=e=>{const t=e.replace("#","");if(!/^[0-9A-F]{6}$/i.test(t))throw new Error(`Invalid color ${e}`);return`#${t}`},Re=(e,t)=>{const n=Xt(t.background),r=Xt(t.color??"#ffffff"),s=sr(e,!0),o=`<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48">
|
|
2
2
|
<rect width="48" height="48" fill="${n}" />
|
|
3
3
|
<text x="50%" y="54%" dominant-baseline="middle" text-anchor="middle" font-size="16" font-family="Barlow, Helvetica, Arial, sans-serif" fill="${r}">${s}</text>
|
|
4
4
|
</svg>`;return`data:image/svg+xml;base64,${btoa(o)}`},Qt=["02BBA8","29C5FF","0078A4","FFBF3D","FFA85C","FF875B","FF675C","FF5C72"],or=e=>{const t=rr(e).slice(-2),n=parseInt(t,16)%Qt.length;return Qt[n]},ar=e=>{try{return g.num.toHex(za(g.num.hexToDecimalString(e)))}catch{}return""},Va=({accountName:e,networkId:t,accountAddress:n,backgroundColor:r})=>{const s=ar(n),o=`${t}::${s}`,i=r||or(o);return Re(e,{background:i})},ir=e=>{const t=g.encode.removeHexPrefix(g.encode.sanitizeHex(g.num.toHex(e))),n=ye.hex.decode(t);return ye.base58.encode(n)},Ma=e=>e.map(ir),cr=e=>{const t=ye.base58.decode(e);return g.encode.sanitizeHex(ye.hex.encode(t))},qa=e=>e.map(cr);function Ga(e,t){const n=e.getTime(),r=t.getTime(),s=Math.abs(n-r);return Math.floor(s/(1e3*60*60*24))}const Wa=e=>(e||"false")==="true",Ka=async(e,t)=>{try{return await e.getClassHashAt(t),!0}catch{return!1}};function Za(e){return!D.isNil(e)}const Ya=e=>{const t=/^(0|0x([a-f0-9A-F]+)?)$/;return!!(e===""||t.test(e))},K=e=>!isNaN(parseFloat(e))&&isFinite(Number(e)),Ja=(e,t=16)=>{const n=new RegExp(`^[0-9]*.?[0-9]{0,${t}}$`);return e===""?!0:K(e)?!!n.test(e):!1},rt={CURRENCY:{minDecimalPlaces:2,maxDecimalPlaces:10,minDecimalSignificantDigits:2,decimalPlacesWhenZero:2,allowLeadingZerosInDecimalPart:!0},TOKEN:{minDecimalPlaces:4,maxDecimalPlaces:16,minDecimalSignificantDigits:2,decimalPlacesWhenZero:1,allowLeadingZerosInDecimalPart:!0}},lr=(e,t)=>Bt(e,{...rt.CURRENCY,...t||{}}),dr=(e,t)=>Bt(e,{...rt.TOKEN,...t||{}}),Bt=(e,{minDecimalPlaces:t,maxDecimalPlaces:n,minDecimalSignificantDigits:r,decimalPlacesWhenZero:s,allowLeadingZerosInDecimalPart:o}=rt.CURRENCY)=>{if(!K(e))return null;const i=new a.BigNumber(typeof e=="bigint"?e.toString():e);let c;const l=`0.${"".padStart(s-1,"0")}1`;if(i.lt(new a.BigNumber(l))&&!o)c=`0.${"".padStart(s,"0")}`;else if(i.gte(1))c=i.toFormat(t);else{const S=i.toFormat(n).split(".")[1].match(/^0+/),A=o&&S&&S.length?S[0].length:0,f=Math.max(A+r,t);c=i.toFormat(f)}let d=c.replace(/0+$/,"");const h=1+c.indexOf(".")+s;return d.length<h&&(d=c.substring(0,h)),d},ur=(e,t=18)=>{const n=e.replace(",",".");return!e||!K(n)?0n:a.parseUnits(n,Number(t)).value};function be(e){return g.uint256.bnToUint256(e)}const Xa=(e,t)=>`${e} ${t}${e===1?"":"s"}`,Qa=e=>new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{var s;return r.result?t((s=r.result)==null?void 0:s.toString()):n(new Error("Could not read file"))},r.onerror=n,r.onabort=n.bind(null,new Error("User aborted")),r.readAsText(e)});function ei(e){try{return D.upperFirst(D.lowerCase(e))}catch{return e}}const ti=(e,t)=>{const n=new URLSearchParams(t),r=n.size?`?${n}`:"";return a.urlJoin(...a.ensureArray(e),r)};function ni(e){return(...t)=>{e(...t)}}class ri extends Error{constructor(t,n){super(`${t}::${n}`),this.name=t,this.code=n,this.name=t}}class en extends ri{constructor(t){super("BackendPaginationError",t)}}const tn=32;class si{constructor(t,n,r){this.apiBase=t,this.headers=n,this.imageOptimizationUrl=r,this.httpService=new Xe(this.headers,"json")}async getNfts(t,n,r,s=1){const o=this.normalizeAddress(r),i=a.urlJoin(this.apiBase,"pandora",t,n),c=this.pageToPageIndex(s),d=`${a.urlJoin(i,"profile",o,"nfts")}?page=${c}&size=${tn}`,h=await this.httpService.get(d),u=h.content.map(y=>this.mapItem(y,r));return{totalPages:h.totalPages,page:h.number+1,count:u.length,nfts:u}}async getCollection(t,n,r){const s=this.normalizeAddress(r),o=a.urlJoin(this.apiBase,"pandora",t,n),i=a.urlJoin(o,"collection",s),c=`${o}/collection/${s}`,[l,d]=await Promise.all([this.httpService.get(i),this.httpService.get(c)]),h=ut(l),u=d.content.map(y=>this.mapItem(y));return{...h,nfts:{totalPages:d.totalPages,page:d.number,count:u.length,data:u}}}async getNft(t,n,r,s){const o=this.normalizeAddress(r),i=a.urlJoin(this.apiBase,"pandora",t,n),c=a.urlJoin(i,"nft",o,s),l=await this.httpService.get(c);return this.mapItem(l)}async getProfileCollections(t,n,r,s=1,o=!1){const i=this.pageToPageIndex(s),c=this.normalizeAddress(r),l=a.urlJoin(this.apiBase,"pandora",t,n),d=a.urlJoin(l,"profile",c,"collections",`?page=${i}&size=${tn}`),h=await this.httpService.get(d),u=[];for(const y of h.content)if(o){const S=await this.getCollectionMetrics(t,n,y.contractAddress);u.push(ut(y,S))}else u.push(ut(y));return{totalPages:h.totalPages,page:h.number+1,count:u.length,collections:u}}async getCollectionMetrics(t,n,r){const s=this.normalizeAddress(r),o=a.urlJoin(this.apiBase,"pandora",t,n),i=a.urlJoin(o,"collection",s,"metrics");return this.httpService.get(i)}normalizeAddress(t){return a.addressSchemaArgentBackend.parse(t)}pageToPageIndex(t){if(!Number.isInteger(t))throw new en("notANumber");const n=t-1;if(n<0)throw new en("tooLow");return n}optimizeImage(t,n,r){if(!t)return;const s=new URLSearchParams({url:t,w:(n??400).toString(),h:(r??400).toString()});return`${this.imageOptimizationUrl}?${s.toString()}`}mapItem(t,n){var s;const r=t.name??t.tokenId;return{token_id:t.tokenId,contract_address:t.contractAddress,name:r,spec:"spec"in t?oi(t.spec):void 0,description:"",best_bid_order:{payment_amount:"bestListPrice"in t?BigInt(t.bestListPrice):void 0},properties:"properties"in t&&t.properties.map(o=>({key:o.key,value:o.value}))||[],image_uri:this.optimizeImage(t.imageUrls.preview)??Re(r,{background:"#15192A",color:"#ffffff"}),image_url_copy:this.optimizeImage(t.imageUrls.full)??Re(r,{background:"#15192A",color:"#ffffff"}),owner:{account_address:((s=t.owner)==null?void 0:s.address)||n},contract_name:_t(t.contractAddress)}}}function oi(e){switch(e){case"erc721":case"starknetErc721":return"ERC721";case"erc1155":case"starknetErc1155":return"ERC1155"}}function ut(e,t){return{contractAddress:a.addressSchema.parse(e.contractAddress),name:e.name||_t(e.contractAddress),description:e.description??"",imageUri:e.imageUrls.preview??Re(e.name||e.contractAddress.replace("0x",""),{background:"#15192A",color:"#ffffff"}),...t&&{owners:{total:t.numberOfItems,unique:t.uniqueOwners},...t.floorPrice&&{floorPrice:BigInt(t.floorPrice)}}}}const hr=async(e,t,n,r,s=1)=>{const o=await e.getNfts(t,n,r,s);if(s<o.totalPages){const i=await hr(e,t,n,r,o.page+1);return{...o,nfts:o.nfts.concat(i.nfts)}}return o},ai=(e,t,n,r,s)=>{const{data:o,...i}=Be(r&&[r,"nfts"],()=>r&&hr(e,t,n,r),{refreshInterval:3e5,...s});return{nfts:o==null?void 0:o.nfts,...i}},ii=(e,t,n,r,s)=>{const{data:o,...i}=Be(r&&[`${r}`,"nfts-collection"],()=>r&&e.getCollection(t,n,r),{refreshInterval:6e4,...s});return{collection:o,...i}},ci=(e,t,n,r,s,o)=>{const{data:i,...c}=Be(s&&r&&[`${r}:${s}`,"nft"],()=>s&&r?e.getNft(t,n,r,s):void 0,{refreshInterval:6e4,revalidateOnFocus:!1,revalidateOnMount:!1,...o});return{nft:i,...c}},li=({image_uri:e,image_url_copy:t})=>{if(e&&t){if(!t.startsWith("ipfs://"))return t;if(!e.startsWith("ipfs://"))return e}return t||e},di=(e,t)=>e.token_id===t.token_id&&a.isEqualAddress(e.contract_address,t.contract_address);function nn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function ui(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function fr(e,...t){if(!ui(e))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Ze(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function mr(e,t){fr(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Me=BigInt(2**32-1),rn=BigInt(32);function hi(e,t=!1){return t?{h:Number(e&Me),l:Number(e>>rn&Me)}:{h:Number(e>>rn&Me)|0,l:Number(e&Me)|0}}function fi(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let s=0;s<e.length;s++){const{h:o,l:i}=hi(e[s],t);[n[s],r[s]]=[o,i]}return[n,r]}const mi=(e,t,n)=>e<<n|t>>>32-n,pi=(e,t,n)=>t<<n|e>>>32-n,gi=(e,t,n)=>t<<n-32|e>>>64-n,Si=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const wi=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));function yi(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}const ht=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),X=(e,t)=>e<<32-t|e>>>t,bi=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!bi)throw new Error("Non little-endian hardware is not supported");function pr(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Nt(e){if(typeof e=="string"&&(e=pr(e)),!yi(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}let gr=class{clone(){return this._cloneInto()}};function Sr(e){const t=r=>e().update(Nt(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const[wr,yr,br]=[[],[],[]],Ei=BigInt(0),Ce=BigInt(1),Ai=BigInt(2),Ti=BigInt(7),vi=BigInt(256),xi=BigInt(113);for(let e=0,t=Ce,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],wr.push(2*(5*r+n)),yr.push((e+1)*(e+2)/2%64);let s=Ei;for(let o=0;o<7;o++)t=(t<<Ce^(t>>Ti)*xi)%vi,t&Ai&&(s^=Ce<<(Ce<<BigInt(o))-Ce);br.push(s)}const[Ii,Ci]=fi(br,!0),sn=(e,t,n)=>n>32?gi(e,t,n):mi(e,t,n),on=(e,t,n)=>n>32?Si(e,t,n):pi(e,t,n);function _i(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,l=(i+2)%10,d=n[l],h=n[l+1],u=sn(d,h,1)^n[c],y=on(d,h,1)^n[c+1];for(let S=0;S<50;S+=10)e[i+S]^=u,e[i+S+1]^=y}let s=e[2],o=e[3];for(let i=0;i<24;i++){const c=yr[i],l=sn(s,o,c),d=on(s,o,c),h=wr[i];s=e[h],o=e[h+1],e[h]=l,e[h+1]=d}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=Ii[r],e[1]^=Ci[r]}n.fill(0)}class kt extends gr{constructor(t,n,r,s=!1,o=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,nn(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=wi(this.state)}keccak(){_i(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Ze(this);const{blockLen:n,state:r}=this;t=Nt(t);const s=t.length;for(let o=0;o<s;){const i=Math.min(n-this.pos,s-o);for(let c=0;c<i;c++)r[this.pos++]^=t[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,n&128&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){Ze(this,!1),fr(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,o=t.length;s<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return nn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(mr(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:o,enableXOF:i}=this;return t||(t=new kt(n,r,s,i,o)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=o,t.suffix=r,t.outputLen=s,t.enableXOF=i,t.destroyed=this.destroyed,t}}const Bi=(e,t,n)=>Sr(()=>new kt(t,e,n)),Ni=Bi(1,136,256/8);function ki(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),c=Number(n&o),l=r?4:0,d=r?0:4;e.setUint32(t+l,i,r),e.setUint32(t+d,c,r)}class Oi extends gr{constructor(t,n,r,s){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ht(this.buffer)}update(t){Ze(this);const{view:n,buffer:r,blockLen:s}=this;t=Nt(t);const o=t.length;for(let i=0;i<o;){const c=Math.min(s-this.pos,o-i);if(c===s){const l=ht(t);for(;s<=o-i;i+=s)this.process(l,i);continue}r.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ze(this),mr(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:o}=this;let{pos:i}=this;n[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(r,0),i=0);for(let u=i;u<s;u++)n[u]=0;ki(r,s-8,BigInt(this.length*8),o),this.process(r,0);const c=ht(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=l/4,h=this.get();if(d>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<d;u++)c.setUint32(4*u,h[u],o)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:o,destroyed:i,pos:c}=this;return t.length=s,t.pos=c,t.finished=o,t.destroyed=i,s%n&&t.buffer.set(r),t}}const Ri=(e,t,n)=>e&t^~e&n,Pi=(e,t,n)=>e&t^e&n^t&n,Fi=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),se=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),oe=new Uint32Array(64);class Di extends Oi{constructor(){super(64,32,8,!1),this.A=se[0]|0,this.B=se[1]|0,this.C=se[2]|0,this.D=se[3]|0,this.E=se[4]|0,this.F=se[5]|0,this.G=se[6]|0,this.H=se[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:c,H:l}=this;return[t,n,r,s,o,i,c,l]}set(t,n,r,s,o,i,c,l){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=c|0,this.H=l|0}process(t,n){for(let u=0;u<16;u++,n+=4)oe[u]=t.getUint32(n,!1);for(let u=16;u<64;u++){const y=oe[u-15],S=oe[u-2],A=X(y,7)^X(y,18)^y>>>3,f=X(S,17)^X(S,19)^S>>>10;oe[u]=f+oe[u-7]+A+oe[u-16]|0}let{A:r,B:s,C:o,D:i,E:c,F:l,G:d,H:h}=this;for(let u=0;u<64;u++){const y=X(c,6)^X(c,11)^X(c,25),S=h+y+Ri(c,l,d)+Fi[u]+oe[u]|0,f=(X(r,2)^X(r,13)^X(r,22))+Pi(r,s,o)|0;h=d,d=l,l=c,c=i+S|0,i=o,o=s,s=r,r=S+f|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,c=c+this.E|0,l=l+this.F|0,d=d+this.G|0,h=h+this.H|0,this.set(r,s,o,i,c,l,d,h)}roundClean(){oe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Er=Sr(()=>new Di);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ar=BigInt(0),st=BigInt(1),Ui=BigInt(2),ot=e=>e instanceof Uint8Array,Hi=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ue(e){if(!ot(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=Hi[e[n]];return t}function Tr(e){const t=e.toString(16);return t.length&1?`0${t}`:t}function Ot(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}function he(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(e.length%2)throw new Error("hex string is invalid: unpadded "+e.length);const t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n++){const r=n*2,s=e.slice(r,r+2),o=Number.parseInt(s,16);if(Number.isNaN(o)||o<0)throw new Error("invalid byte sequence");t[n]=o}return t}function Y(e){return Ot(ue(e))}function Rt(e){if(!ot(e))throw new Error("Uint8Array expected");return Ot(ue(Uint8Array.from(e).reverse()))}const Se=(e,t)=>he(e.toString(16).padStart(t*2,"0")),vr=(e,t)=>Se(e,t).reverse(),$i=e=>he(Tr(e));function V(e,t,n){let r;if(typeof t=="string")try{r=he(t)}catch(o){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${o}`)}else if(ot(t))r=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(`${e} expected ${n} bytes, got ${s}`);return r}function Pe(...e){const t=new Uint8Array(e.reduce((r,s)=>r+s.length,0));let n=0;return e.forEach(r=>{if(!ot(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}function Li(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ji(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function zi(e){let t;for(t=0;e>Ar;e>>=st,t+=1);return t}const Vi=(e,t)=>e>>BigInt(t)&st,Mi=(e,t,n)=>e|(n?st:Ar)<<BigInt(t),at=e=>(Ui<<BigInt(e-1))-st,ft=e=>new Uint8Array(e),an=e=>Uint8Array.from(e);function xr(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=ft(e),s=ft(e),o=0;const i=()=>{r.fill(1),s.fill(0),o=0},c=(...u)=>n(s,r,...u),l=(u=ft())=>{s=c(an([0]),u),r=c(),u.length!==0&&(s=c(an([1]),u),r=c())},d=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const y=[];for(;u<t;){r=c();const S=r.slice();y.push(S),u+=r.length}return Pe(...y)};return(u,y)=>{i(),l(u);let S;for(;!(S=y(d()));)l();return i(),S}}const qi={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function $e(e,t,n={}){const r=(s,o,i)=>{const c=qi[o];if(typeof c!="function")throw new Error(`Invalid validator "${o}", expected function`);const l=e[s];if(!(i&&l===void 0)&&!c(l,e))throw new Error(`Invalid param ${String(s)}=${l} (${typeof l}), expected ${o}`)};for(const[s,o]of Object.entries(t))r(s,o,!1);for(const[s,o]of Object.entries(n))r(s,o,!0);return e}const Gi=Object.freeze(Object.defineProperty({__proto__:null,bitGet:Vi,bitLen:zi,bitMask:at,bitSet:Mi,bytesToHex:ue,bytesToNumberBE:Y,bytesToNumberLE:Rt,concatBytes:Pe,createHmacDrbg:xr,ensureBytes:V,equalBytes:Li,hexToBytes:he,hexToNumber:Ot,numberToBytesBE:Se,numberToBytesLE:vr,numberToHexUnpadded:Tr,numberToVarBytesBE:$i,utf8ToBytes:ji,validateObject:$e},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const U=BigInt(0),F=BigInt(1),ie=BigInt(2),Wi=BigInt(3),wt=BigInt(4),cn=BigInt(5),ln=BigInt(8);BigInt(9);BigInt(16);function M(e,t){const n=e%t;return n>=U?n:t+n}function Ki(e,t,n){if(n<=U||t<U)throw new Error("Expected power/modulo > 0");if(n===F)return U;let r=F;for(;t>U;)t&F&&(r=r*e%n),e=e*e%n,t>>=F;return r}function yt(e,t){if(e===U||t<=U)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=M(e,t),r=t,s=U,o=F;for(;n!==U;){const c=r/n,l=r%n,d=s-o*c;r=n,n=l,s=o,o=d}if(r!==F)throw new Error("invert: does not exist");return M(s,t)}function Zi(e){const t=(e-F)/ie;let n,r,s;for(n=e-F,r=0;n%ie===U;n/=ie,r++);for(s=ie;s<e&&Ki(s,t,e)!==e-F;s++);if(r===1){const i=(e+F)/wt;return function(l,d){const h=l.pow(d,i);if(!l.eql(l.sqr(h),d))throw new Error("Cannot find square root");return h}}const o=(n+F)/ie;return function(c,l){if(c.pow(l,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let d=r,h=c.pow(c.mul(c.ONE,s),n),u=c.pow(l,o),y=c.pow(l,n);for(;!c.eql(y,c.ONE);){if(c.eql(y,c.ZERO))return c.ZERO;let S=1;for(let f=c.sqr(y);S<d&&!c.eql(f,c.ONE);S++)f=c.sqr(f);const A=c.pow(h,F<<BigInt(d-S-1));h=c.sqr(A),u=c.mul(u,A),y=c.mul(y,h),d=S}return u}}function Yi(e){if(e%wt===Wi){const t=(e+F)/wt;return function(r,s){const o=r.pow(s,t);if(!r.eql(r.sqr(o),s))throw new Error("Cannot find square root");return o}}if(e%ln===cn){const t=(e-cn)/ln;return function(r,s){const o=r.mul(s,ie),i=r.pow(o,t),c=r.mul(s,i),l=r.mul(r.mul(c,ie),i),d=r.mul(c,r.sub(l,r.ONE));if(!r.eql(r.sqr(d),s))throw new Error("Cannot find square root");return d}}return Zi(e)}const Ji=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Pt(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=Ji.reduce((r,s)=>(r[s]="function",r),t);return $e(e,n)}function Ir(e,t,n){if(n<U)throw new Error("Expected power > 0");if(n===U)return e.ONE;if(n===F)return t;let r=e.ONE,s=t;for(;n>U;)n&F&&(r=e.mul(r,s)),s=e.sqr(s),n>>=F;return r}function Xi(e,t){const n=new Array(t.length),r=t.reduce((o,i,c)=>e.is0(i)?o:(n[c]=o,e.mul(o,i)),e.ONE),s=e.inv(r);return t.reduceRight((o,i,c)=>e.is0(i)?o:(n[c]=e.mul(o,n[c]),e.mul(o,i)),s),n}function Ft(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Dt(e,t,n=!1,r={}){if(e<=U)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:s,nByteLength:o}=Ft(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=Yi(e),c=Object.freeze({ORDER:e,BITS:s,BYTES:o,MASK:at(s),ZERO:U,ONE:F,create:l=>M(l,e),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return U<=l&&l<e},is0:l=>l===U,isOdd:l=>(l&F)===F,neg:l=>M(-l,e),eql:(l,d)=>l===d,sqr:l=>M(l*l,e),add:(l,d)=>M(l+d,e),sub:(l,d)=>M(l-d,e),mul:(l,d)=>M(l*d,e),pow:(l,d)=>Ir(c,l,d),div:(l,d)=>M(l*yt(d,e),e),sqrN:l=>l*l,addN:(l,d)=>l+d,subN:(l,d)=>l-d,mulN:(l,d)=>l*d,inv:l=>yt(l,e),sqrt:r.sqrt||(l=>i(c,l)),invertBatch:l=>Xi(c,l),cmov:(l,d,h)=>h?d:l,toBytes:l=>n?vr(l,o):Se(l,o),fromBytes:l=>{if(l.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${l.length}`);return n?Rt(l):Y(l)}});return Object.freeze(c)}function Qi(e,t,n=!1){e=V("privateHash",e);const r=e.length,s=Ft(t).nByteLength+8;if(s<24||r<s||r>1024)throw new Error(`hashToPrivateScalar: expected ${s}-1024 bytes of input, got ${r}`);const o=n?Rt(e):Y(e);return M(o,t-F)+F}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ec(e){const{Fp:t}=e;Pt(t);for(const l of["t","roundsFull","roundsPartial"])if(typeof e[l]!="number"||!Number.isSafeInteger(e[l]))throw new Error(`Poseidon: invalid param ${l}=${e[l]} (${typeof e[l]})`);if(e.reversePartialPowIdx!==void 0&&typeof e.reversePartialPowIdx!="boolean")throw new Error(`Poseidon: invalid param reversePartialPowIdx=${e.reversePartialPowIdx}`);let n=e.sboxPower;if(n===void 0&&(n=5),typeof n!="number"||!Number.isSafeInteger(n))throw new Error(`Poseidon wrong sboxPower=${n}`);const r=BigInt(n);let s=l=>Ir(t,l,r);if(n===3?s=l=>t.mul(t.sqrN(l),l):n===5&&(s=l=>t.mul(t.sqrN(t.sqrN(l)),l)),e.roundsFull%2!==0)throw new Error(`Poseidon roundsFull is not even: ${e.roundsFull}`);const o=e.roundsFull+e.roundsPartial;if(!Array.isArray(e.roundConstants)||e.roundConstants.length!==o)throw new Error("Poseidon: wrong round constants");const i=e.roundConstants.map(l=>{if(!Array.isArray(l)||l.length!==e.t)throw new Error(`Poseidon wrong round constants: ${l}`);return l.map(d=>{if(typeof d!="bigint"||!t.isValid(d))throw new Error(`Poseidon wrong round constant=${d}`);return t.create(d)})});if(!Array.isArray(e.mds)||e.mds.length!==e.t)throw new Error("Poseidon: wrong MDS matrix");const c=e.mds.map(l=>{if(!Array.isArray(l)||l.length!==e.t)throw new Error(`Poseidon MDS matrix row: ${l}`);return l.map(d=>{if(typeof d!="bigint")throw new Error(`Poseidon MDS matrix value=${d}`);return t.create(d)})});return Object.freeze({...e,rounds:o,sboxFn:s,roundConstants:i,mds:c})}function tc(e){const{t,Fp:n,rounds:r,sboxFn:s,reversePartialPowIdx:o}=ec(e),i=Math.floor(e.roundsFull/2),c=o?t-1:0,l=(h,u,y)=>(h=h.map((S,A)=>n.add(S,e.roundConstants[y][A])),u?h=h.map(S=>s(S)):h[c]=s(h[c]),h=e.mds.map(S=>S.reduce((A,f,w)=>n.add(A,n.mulN(f,h[w])),n.ZERO)),h),d=function(u){if(!Array.isArray(u)||u.length!==t)throw new Error(`Poseidon: wrong values (expected array of bigints with length ${t})`);u=u.map(S=>{if(typeof S!="bigint")throw new Error(`Poseidon: wrong value=${S} (${typeof S})`);return n.create(S)});let y=0;for(let S=0;S<i;S++)u=l(u,!0,y++);for(let S=0;S<e.roundsPartial;S++)u=l(u,!1,y++);for(let S=0;S<i;S++)u=l(u,!0,y++);if(y!==r)throw new Error(`Poseidon: wrong number of rounds: last round=${y}, total=${r}`);return u};return d.roundConstants=e.roundConstants,d}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const nc=BigInt(0),mt=BigInt(1);function rc(e,t){const n=(s,o)=>{const i=o.negate();return s?i:o},r=s=>{const o=Math.ceil(t/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:n,unsafeLadder(s,o){let i=e.ZERO,c=s;for(;o>nc;)o&mt&&(i=i.add(c)),c=c.double(),o>>=mt;return i},precomputeWindow(s,o){const{windows:i,windowSize:c}=r(o),l=[];let d=s,h=d;for(let u=0;u<i;u++){h=d,l.push(h);for(let y=1;y<c;y++)h=h.add(d),l.push(h);d=h.double()}return l},wNAF(s,o,i){const{windows:c,windowSize:l}=r(s);let d=e.ZERO,h=e.BASE;const u=BigInt(2**s-1),y=2**s,S=BigInt(s);for(let A=0;A<c;A++){const f=A*l;let w=Number(i&u);i>>=S,w>l&&(w-=y,i+=mt);const E=f,T=f+Math.abs(w)-1,x=A%2!==0,N=w<0;w===0?h=h.add(n(x,o[E])):d=d.add(n(N,o[T]))}return{p:d,f:h}},wNAFCached(s,o,i,c){const l=s._WINDOW_SIZE||1;let d=o.get(s);return d||(d=this.precomputeWindow(s,l),l!==1&&o.set(s,c(d))),this.wNAF(l,d,i)}}}function Cr(e){return Pt(e.Fp),$e(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ft(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function sc(e){const t=Cr(e);$e(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:s}=t;if(n){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:oc,hexToBytes:ac}=Gi,ce={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=ce;if(e.length<2||e[0]!==2)throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:oc(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=ce,n=typeof e=="string"?ac(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:s,l:o}=ce._parseInt(n.subarray(2)),{d:i,l:c}=ce._parseInt(o);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(e){const t=d=>Number.parseInt(d[0],16)&8?"00"+d:d,n=d=>{const h=d.toString(16);return h.length&1?`0${h}`:h},r=t(n(e.s)),s=t(n(e.r)),o=r.length/2,i=s.length/2,c=n(o),l=n(i);return`30${n(i+o+4)}02${l}${s}02${c}${r}`}},Q=BigInt(0),W=BigInt(1);BigInt(2);const dn=BigInt(3);BigInt(4);function ic(e){const t=sc(e),{Fp:n}=t,r=t.toBytes||((A,f,w)=>{const E=f.toAffine();return Pe(Uint8Array.from([4]),n.toBytes(E.x),n.toBytes(E.y))}),s=t.fromBytes||(A=>{const f=A.subarray(1),w=n.fromBytes(f.subarray(0,n.BYTES)),E=n.fromBytes(f.subarray(n.BYTES,2*n.BYTES));return{x:w,y:E}});function o(A){const{a:f,b:w}=t,E=n.sqr(A),T=n.mul(E,A);return n.add(n.add(T,n.mul(A,f)),w)}if(!n.eql(n.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function i(A){return typeof A=="bigint"&&Q<A&&A<t.n}function c(A){if(!i(A))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(A){const{allowedPrivateKeyLengths:f,nByteLength:w,wrapPrivateKey:E,n:T}=t;if(f&&typeof A!="bigint"){if(A instanceof Uint8Array&&(A=ue(A)),typeof A!="string"||!f.includes(A.length))throw new Error("Invalid key");A=A.padStart(w*2,"0")}let x;try{x=typeof A=="bigint"?A:Y(V("private key",A,w))}catch{throw new Error(`private key must be ${w} bytes, hex or bigint, not ${typeof A}`)}return E&&(x=M(x,T)),c(x),x}const d=new Map;function h(A){if(!(A instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(f,w,E){if(this.px=f,this.py=w,this.pz=E,f==null||!n.isValid(f))throw new Error("x required");if(w==null||!n.isValid(w))throw new Error("y required");if(E==null||!n.isValid(E))throw new Error("z required")}static fromAffine(f){const{x:w,y:E}=f||{};if(!f||!n.isValid(w)||!n.isValid(E))throw new Error("invalid affine point");if(f instanceof u)throw new Error("projective point not allowed");const T=x=>n.eql(x,n.ZERO);return T(w)&&T(E)?u.ZERO:new u(w,E,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(f){const w=n.invertBatch(f.map(E=>E.pz));return f.map((E,T)=>E.toAffine(w[T])).map(u.fromAffine)}static fromHex(f){const w=u.fromAffine(s(V("pointHex",f)));return w.assertValidity(),w}static fromPrivateKey(f){return u.BASE.multiply(l(f))}_setWindowSize(f){this._WINDOW_SIZE=f,d.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:f,y:w}=this.toAffine();if(!n.isValid(f)||!n.isValid(w))throw new Error("bad point: x or y not FE");const E=n.sqr(w),T=o(f);if(!n.eql(E,T))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:f}=this.toAffine();if(n.isOdd)return!n.isOdd(f);throw new Error("Field doesn't support isOdd")}equals(f){h(f);const{px:w,py:E,pz:T}=this,{px:x,py:N,pz:B}=f,v=n.eql(n.mul(w,B),n.mul(x,T)),I=n.eql(n.mul(E,B),n.mul(N,T));return v&&I}negate(){return new u(this.px,n.neg(this.py),this.pz)}double(){const{a:f,b:w}=t,E=n.mul(w,dn),{px:T,py:x,pz:N}=this;let B=n.ZERO,v=n.ZERO,I=n.ZERO,_=n.mul(T,T),q=n.mul(x,x),P=n.mul(N,N),k=n.mul(T,x);return k=n.add(k,k),I=n.mul(T,N),I=n.add(I,I),B=n.mul(f,I),v=n.mul(E,P),v=n.add(B,v),B=n.sub(q,v),v=n.add(q,v),v=n.mul(B,v),B=n.mul(k,B),I=n.mul(E,I),P=n.mul(f,P),k=n.sub(_,P),k=n.mul(f,k),k=n.add(k,I),I=n.add(_,_),_=n.add(I,_),_=n.add(_,P),_=n.mul(_,k),v=n.add(v,_),P=n.mul(x,N),P=n.add(P,P),_=n.mul(P,k),B=n.sub(B,_),I=n.mul(P,q),I=n.add(I,I),I=n.add(I,I),new u(B,v,I)}add(f){h(f);const{px:w,py:E,pz:T}=this,{px:x,py:N,pz:B}=f;let v=n.ZERO,I=n.ZERO,_=n.ZERO;const q=t.a,P=n.mul(t.b,dn);let k=n.mul(w,x),L=n.mul(E,N),j=n.mul(T,B),ee=n.add(w,E),p=n.add(x,N);ee=n.mul(ee,p),p=n.add(k,L),ee=n.sub(ee,p),p=n.add(w,T);let b=n.add(x,B);return p=n.mul(p,b),b=n.add(k,j),p=n.sub(p,b),b=n.add(E,T),v=n.add(N,B),b=n.mul(b,v),v=n.add(L,j),b=n.sub(b,v),_=n.mul(q,p),v=n.mul(P,j),_=n.add(v,_),v=n.sub(L,_),_=n.add(L,_),I=n.mul(v,_),L=n.add(k,k),L=n.add(L,k),j=n.mul(q,j),p=n.mul(P,p),L=n.add(L,j),j=n.sub(k,j),j=n.mul(q,j),p=n.add(p,j),k=n.mul(L,p),I=n.add(I,k),k=n.mul(b,p),v=n.mul(ee,v),v=n.sub(v,k),k=n.mul(ee,L),_=n.mul(b,_),_=n.add(_,k),new u(v,I,_)}subtract(f){return this.add(f.negate())}is0(){return this.equals(u.ZERO)}wNAF(f){return S.wNAFCached(this,d,f,w=>{const E=n.invertBatch(w.map(T=>T.pz));return w.map((T,x)=>T.toAffine(E[x])).map(u.fromAffine)})}multiplyUnsafe(f){const w=u.ZERO;if(f===Q)return w;if(c(f),f===W)return this;const{endo:E}=t;if(!E)return S.unsafeLadder(this,f);let{k1neg:T,k1:x,k2neg:N,k2:B}=E.splitScalar(f),v=w,I=w,_=this;for(;x>Q||B>Q;)x&W&&(v=v.add(_)),B&W&&(I=I.add(_)),_=_.double(),x>>=W,B>>=W;return T&&(v=v.negate()),N&&(I=I.negate()),I=new u(n.mul(I.px,E.beta),I.py,I.pz),v.add(I)}multiply(f){c(f);let w=f,E,T;const{endo:x}=t;if(x){const{k1neg:N,k1:B,k2neg:v,k2:I}=x.splitScalar(w);let{p:_,f:q}=this.wNAF(B),{p:P,f:k}=this.wNAF(I);_=S.constTimeNegate(N,_),P=S.constTimeNegate(v,P),P=new u(n.mul(P.px,x.beta),P.py,P.pz),E=_.add(P),T=q.add(k)}else{const{p:N,f:B}=this.wNAF(w);E=N,T=B}return u.normalizeZ([E,T])[0]}multiplyAndAddUnsafe(f,w,E){const T=u.BASE,x=(B,v)=>v===Q||v===W||!B.equals(T)?B.multiplyUnsafe(v):B.multiply(v),N=x(this,w).add(x(f,E));return N.is0()?void 0:N}toAffine(f){const{px:w,py:E,pz:T}=this,x=this.is0();f==null&&(f=x?n.ONE:n.inv(T));const N=n.mul(w,f),B=n.mul(E,f),v=n.mul(T,f);if(x)return{x:n.ZERO,y:n.ZERO};if(!n.eql(v,n.ONE))throw new Error("invZ was invalid");return{x:N,y:B}}isTorsionFree(){const{h:f,isTorsionFree:w}=t;if(f===W)return!0;if(w)return w(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:f,clearCofactor:w}=t;return f===W?this:w?w(u,this):this.multiplyUnsafe(t.h)}toRawBytes(f=!0){return this.assertValidity(),r(u,this,f)}toHex(f=!0){return ue(this.toRawBytes(f))}}u.BASE=new u(t.Gx,t.Gy,n.ONE),u.ZERO=new u(n.ZERO,n.ONE,n.ZERO);const y=t.nBitLength,S=rc(u,t.endo?Math.ceil(y/2):y);return{CURVE:t,ProjectivePoint:u,normPrivateKeyToScalar:l,weierstrassEquation:o,isWithinCurveOrder:i}}function cc(e){const t=Cr(e);return $e(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function lc(e){const t=cc(e),{Fp:n,n:r}=t,s=n.BYTES+1,o=2*n.BYTES+1;function i(p){return Q<p&&p<n.ORDER}function c(p){return M(p,r)}function l(p){return yt(p,r)}const{ProjectivePoint:d,normPrivateKeyToScalar:h,weierstrassEquation:u,isWithinCurveOrder:y}=ic({...t,toBytes(p,b,C){const R=b.toAffine(),O=n.toBytes(R.x),H=Pe;return C?H(Uint8Array.from([b.hasEvenY()?2:3]),O):H(Uint8Array.from([4]),O,n.toBytes(R.y))},fromBytes(p){const b=p.length,C=p[0],R=p.subarray(1);if(b===s&&(C===2||C===3)){const O=Y(R);if(!i(O))throw new Error("Point is not on curve");const H=u(O);let G=n.sqrt(H);const z=(G&W)===W;return(C&1)===1!==z&&(G=n.neg(G)),{x:O,y:G}}else if(b===o&&C===4){const O=n.fromBytes(R.subarray(0,n.BYTES)),H=n.fromBytes(R.subarray(n.BYTES,2*n.BYTES));return{x:O,y:H}}else throw new Error(`Point of length ${b} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),S=p=>ue(Se(p,t.nByteLength));function A(p){const b=r>>W;return p>b}function f(p){return A(p)?c(-p):p}const w=(p,b,C)=>Y(p.slice(b,C));class E{constructor(b,C,R){this.r=b,this.s=C,this.recovery=R,this.assertValidity()}static fromCompact(b){const C=t.nByteLength;return b=V("compactSignature",b,C*2),new E(w(b,0,C),w(b,C,2*C))}static fromDER(b){const{r:C,s:R}=ce.toSig(V("DER",b));return new E(C,R)}assertValidity(){if(!y(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!y(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(b){return new E(this.r,this.s,b)}recoverPublicKey(b){const{r:C,s:R,recovery:O}=this,H=I(V("msgHash",b));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const G=O===2||O===3?C+t.n:C;if(G>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const z=O&1?"03":"02",te=d.fromHex(z+S(G)),ne=l(G),fe=c(-H*ne),ve=c(R*ne),re=d.BASE.multiplyAndAddUnsafe(te,fe,ve);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return A(this.s)}normalizeS(){return this.hasHighS()?new E(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return he(this.toDERHex())}toDERHex(){return ce.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return he(this.toCompactHex())}toCompactHex(){return S(this.r)+S(this.s)}}const T={isValidPrivateKey(p){try{return h(p),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const p=t.randomBytes(n.BYTES+8),b=Qi(p,r);return Se(b,t.nByteLength)},precompute(p=8,b=d.BASE){return b._setWindowSize(p),b.multiply(BigInt(3)),b}};function x(p,b=!0){return d.fromPrivateKey(p).toRawBytes(b)}function N(p){const b=p instanceof Uint8Array,C=typeof p=="string",R=(b||C)&&p.length;return b?R===s||R===o:C?R===2*s||R===2*o:p instanceof d}function B(p,b,C=!0){if(N(p))throw new Error("first arg must be private key");if(!N(b))throw new Error("second arg must be public key");return d.fromHex(b).multiply(h(p)).toRawBytes(C)}const v=t.bits2int||function(p){const b=Y(p),C=p.length*8-t.nBitLength;return C>0?b>>BigInt(C):b},I=t.bits2int_modN||function(p){return c(v(p))},_=at(t.nBitLength);function q(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(Q<=p&&p<_))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Se(p,t.nByteLength)}function P(p,b,C=k){if(["recovered","canonical"].some(ae=>ae in C))throw new Error("sign() legacy options not supported");const{hash:R,randomBytes:O}=t;let{lowS:H,prehash:G,extraEntropy:z}=C;H==null&&(H=!0),p=V("msgHash",p),G&&(p=V("prehashed msgHash",R(p)));const te=I(p),ne=h(b),fe=[q(ne),q(te)];if(z!=null){const ae=z===!0?O(n.BYTES):z;fe.push(V("extraEntropy",ae,n.BYTES))}const ve=Pe(...fe),re=te;function ct(ae){const me=v(ae);if(!y(me))return;const Lt=l(me),pe=d.BASE.multiply(me).toAffine(),Z=c(pe.x);if(Z===Q)return;const ge=c(Lt*c(re+Z*ne));if(ge===Q)return;let jt=(pe.x===Z?0:2)|Number(pe.y&W),zt=ge;return H&&A(ge)&&(zt=f(ge),jt^=1),new E(Z,zt,jt)}return{seed:ve,k2sig:ct}}const k={lowS:t.lowS,prehash:!1},L={lowS:t.lowS,prehash:!1};function j(p,b,C=k){const{seed:R,k2sig:O}=P(p,b,C);return xr(t.hash.outputLen,t.nByteLength,t.hmac)(R,O)}d.BASE._setWindowSize(8);function ee(p,b,C,R=L){var pe;const O=p;if(b=V("msgHash",b),C=V("publicKey",C),"strict"in R)throw new Error("options.strict was renamed to lowS");const{lowS:H,prehash:G}=R;let z,te;try{if(typeof O=="string"||O instanceof Uint8Array)try{z=E.fromDER(O)}catch(Z){if(!(Z instanceof ce.Err))throw Z;z=E.fromCompact(O)}else if(typeof O=="object"&&typeof O.r=="bigint"&&typeof O.s=="bigint"){const{r:Z,s:ge}=O;z=new E(Z,ge)}else throw new Error("PARSE");te=d.fromHex(C)}catch(Z){if(Z.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(H&&z.hasHighS())return!1;G&&(b=t.hash(b));const{r:ne,s:fe}=z,ve=I(b),re=l(fe),ct=c(ve*re),ae=c(ne*re),me=(pe=d.BASE.multiplyAndAddUnsafe(te,ct,ae))==null?void 0:pe.toAffine();return me?c(me.x)===ne:!1}return{CURVE:t,getPublicKey:x,getSharedSecret:B,sign:j,verify:ee,ProjectivePoint:d,Signature:E,utils:T}}function bt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function dc(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function _r(e,...t){if(!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new TypeError(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function uc(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");bt(e.outputLen),bt(e.blockLen)}function hc(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function fc(e,t){_r(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const qe={number:bt,bool:dc,bytes:_r,hash:uc,exists:hc,output:fc},pt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const mc=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!mc)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function pc(e){if(typeof e!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function gc(e){if(typeof e=="string"&&(e=pc(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}function Sc(...e){if(!e.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(e.length===1)return e[0];const t=e.reduce((r,s)=>r+s.length,0),n=new Uint8Array(t);for(let r=0,s=0;r<e.length;r++){const o=e[r];n.set(o,s),s+=o.length}return n}class wc{clone(){return this._cloneInto()}}function yc(e=32){if(pt&&typeof pt.getRandomValues=="function")return pt.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}class Br extends wc{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,qe.hash(t);const r=gc(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(r.length>s?t.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(t){return qe.exists(this),this.iHash.update(t),this}digestInto(t){qe.exists(this),qe.bytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:s,destroyed:o,blockLen:i,outputLen:c}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=i,t.outputLen=c,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Nr=(e,t,n)=>new Br(e,t).update(n).digest();Nr.create=(e,t)=>new Br(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function bc(e){return{hash:e,hmac:(t,...n)=>Nr(e,t,Sc(...n)),randomBytes:yc}}const un=BigInt("3618502788666131213697322783095070105526743751716087489154079457884512865583"),kr=252;function hn(e){for(;e[0]===0;)e=e.subarray(1);const t=e.length*8-kr,n=Y(e);return t>0?n>>BigInt(t):n}function Or(e){return typeof e=="string"&&(e=Tc(e),e.length&1&&(e="0"+e)),he(e)}const Rr=lc({a:BigInt(1),b:BigInt("3141592653589793238462643383279502884197169399375105820974944592307816406665"),Fp:Dt(BigInt("0x800000000000011000000000000000000000000000000000000000000000001")),n:un,nBitLength:kr,Gx:BigInt("874739451078007766457464989774322083649278607533249481151382481072868806602"),Gy:BigInt("152666792071518830868575557812948353041420400780739481342941381225525861407"),h:BigInt(1),lowS:!1,...bc(Er),bits2int:hn,bits2int_modN:e=>{const t=Y(e).toString(16);return t.length===63&&(e=Or(t+"0")),M(hn(e),un)}});function Ec(e){return V("",typeof e=="string"?Or(e):e)}const{CURVE:Hl,ProjectivePoint:_e,Signature:$l,utils:Ll}=Rr;function Ac(e){return`0x${ue(e.subarray(1)).replace(/^0+/gm,"")}`}function Tc(e){return e.replace(/^0x/i,"")}const Fe=[new _e(2089986280348253421170679821480865132823066470938446095505822317253594081284n,1713931329540660377023406109199410414810705867260802078187082345529207694986n,1n),new _e(996781205833008774514500082376783249102396023663454813447423147977397232763n,1668503676786377725805489344771023921079126552019160156920634619255970485781n,1n),new _e(2251563274489750535117886426533222435294046428347329203627021249169616184184n,1798716007562728905295480679789526322175868328062420237419143593021674992973n,1n),new _e(2138414695194151160943305727036575959195309218611738193261179310511854807447n,113410276730064486255102093846540133784865286929052426931474106396135072156n,1n),new _e(2379962749567351885752724891227938183011949129833673362440656643086021394946n,776496453633298175483985398648758586525933812536653089401905292063708816422n,1n)];function Pr(e,t){const n=[];let r=e;for(let s=0;s<248;s++)n.push(r),r=r.double();r=t;for(let s=0;s<4;s++)n.push(r),r=r.double();return n}const vc=Pr(Fe[1],Fe[2]),xc=Pr(Fe[3],Fe[4]);function Ic(e){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"){if(!Number.isSafeInteger(e))throw new Error(`Invalid pedersenArg: ${e}`);t=BigInt(e)}else t=Y(Ec(e));if(!(0n<=t&&t<Rr.CURVE.Fp.ORDER))throw new Error(`PedersenArg should be 0 <= value < CURVE.P: ${t}`);return t}function fn(e,t,n){let r=Ic(t);for(let s=0;s<252;s++){const o=n[s];if(o.equals(e))throw new Error("Same point");(r&1n)!==0n&&(e=e.add(o)),r>>=1n}return e}function mn(e,t){let n=Fe[0];return n=fn(n,e,vc),n=fn(n,t,xc),Ac(n.toRawBytes(!0))}const Cc=at(250),pn=e=>Y(Ni(e))&Cc;Dt(BigInt("14474011154664525231415395255581126252639794253786371766033694892385558855681"));const _c=Dt(BigInt("3618502788666131213697322783095070105623107215331596699973092056135872020481"));function Bc(e,t,n){const r=e.fromBytes(Er(pr(`${t}${n}`)));return e.create(r)}const Nc=[[3,1,1],[1,-1,1],[1,1,-2]].map(e=>e.map(BigInt));function kc(e,t){if(Pt(e.Fp),!Number.isSafeInteger(e.rate)||!Number.isSafeInteger(e.capacity))throw new Error(`Wrong poseidon opts: ${e}`);const n=e.rate+e.capacity,r=e.roundsFull+e.roundsPartial,s=[];for(let i=0;i<r;i++){const c=[];for(let l=0;l<n;l++)c.push(Bc(e.Fp,"Hades",n*i+l));s.push(c)}const o=tc({...e,t:n,sboxPower:3,reversePartialPowIdx:!0,mds:t,roundConstants:s});return o.m=n,o.rate=e.rate,o.capacity=e.capacity,o}kc({Fp:_c,rate:2,capacity:1,roundsFull:8,roundsPartial:83},Nc);const Fr=m.z.object({recoveryId:m.z.number()}),Oc=m.z.object({feeToken:a.addressSchema,signerSignature:m.z.object({type:m.z.literal("StarknetKey"),signer:m.z.object({publicKey:a.hexSchema,r:a.hexSchema,s:a.hexSchema})})}),Dr=m.z.enum(["ONGOING","COMPLETED","ERROR","CANCELLED","AWAITING_FUNDS"]),Rc=m.z.object({status:Dr.optional(),recoveryId:m.z.number().optional(),completionTime:m.z.array(m.z.number()).optional()}),Ur=m.z.enum(["undeployedAccount","notEnoughToPayFees"]),Pc=m.z.object({status:Ur});class Fc{constructor(t,n){this.apiBase=t,this.httpService=n}async startRecovery(t,n,r,s){const{r:o,s:i}=g.ec.starkCurve.sign(mn(pn(ye.stringToBytes("utf8","starknet:recovery")),r),s),c={feeToken:n,signerSignature:{type:"StarknetKey",signer:{publicKey:r,r:g.encode.addHexPrefix(o.toString(16)),s:g.encode.addHexPrefix(i.toString(16))}}};return await this.httpService.post(`${this.apiBase}/accounts/starknet/${t}/recovery`,{body:JSON.stringify(c)},Fr)}async getRecovery(t,n){const r=a.urlJoin(this.apiBase,"accounts","starknet",t,"recovery",n?`${n}`:"");return await this.httpService.get(r)}async cancelRecovery(t,n,r){const{r:s,s:o}=g.ec.starkCurve.sign(mn(pn(ye.stringToBytes("utf8","starknet:recovery:cancel")),n),r),i={signerSignature:{type:"StarknetKey",signer:{publicKey:n,r:g.encode.addHexPrefix(s.toString(16)),s:g.encode.addHexPrefix(o.toString(16))}}};await this.httpService.post(`${this.apiBase}/accounts/starknet/${t}/recovery/cancel`,{body:JSON.stringify(i)})}}async function Dc(){if("brave"in navigator)try{return await navigator.brave.isBrave()}catch{}return!1}let gt;function Hr(){return gt||(gt=new es.UAParser(navigator.userAgent).getResult()),gt}function Le(e){return Hr().browser.name===e}function Uc(){return Le("Firefox")}function Hc(){return Le("Chrome")}function $c(){return Le("Safari")}function Lc(){return Le("Edge")}const jc=m.z.string().refine(e=>ts.validateMnemonic(e,ns.wordlist),"Invalid seedphrase"),Ut=[{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",name:"Ether",symbol:"ETH",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/eth.png"},{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",name:"Ether",symbol:"ETH",decimals:18,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/eth.png"},{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",name:"Ether",symbol:"ETH",decimals:18,networkId:"localhost",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/eth.png"},{address:"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",name:"Starknet",symbol:"STRK",decimals:"18",networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/strk.png"},{address:"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",name:"Starknet",symbol:"STRK",decimals:"18",networkId:"integration",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/strk.png"},{address:"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",name:"Starknet",symbol:"STRK",decimals:"18",networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/strk.png"},{address:"0x00da114221cb83fa859dbdb4c44beeaa0bb37c7537ad5ae66fe5e0efd20e6eb3",name:"DAI",symbol:"DAI",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/dai.png"},{address:"0x03e85bfbb8e2a42b7bead9e88e9a1b19dbccf661471061807292120462396ec9",name:"DAI",symbol:"DAI",decimals:18,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/dai.png"},{address:"0x06f2a0dfeff180133de890ad69c6ba294574c5f34a67890fd22464f348c4d03c",name:"DAI",symbol:"DAI",decimals:18,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/dai.png"},{address:"0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",name:"Wrapped BTC",symbol:"WBTC",decimals:8,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/wbtc.png"},{address:"0x12d537dc323c439dc65c976fad242d5610d27cfb5f31689a0a319b8be7f3d56",name:"Wrapped BTC",symbol:"WBTC",decimals:8,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/wbtc.png"},{address:"0x020d208b9e57a7f92bfa9f61135446e0961afc340378be97dbd317453c0950ae",name:"Wrapped BTC",symbol:"WBTC",decimals:8,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/wbtc.png"},{address:"0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",name:"USD Coin",symbol:"USDC",decimals:6,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdc.png"},{address:"0x005a643907b9a4bc6a55e9069c4fd5fd1f5c79a22470690f75556c4736e34426",name:"USD Coin",symbol:"USDC",decimals:6,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdc.png"},{address:"0x07ab0b8855a61f480b4423c46c32fa7c553f0aac3531bbddaa282d86244f7a23",name:"USD Coin",symbol:"USDC",decimals:6,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdc.png"},{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",name:"Tether USD",symbol:"USDT",decimals:6,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdt.png"},{address:"0x386e8d061177f19b3b485c20e31137e6f6bc497cc635ccdfcab96fadf5add6a",name:"Tether USD",symbol:"USDT",decimals:6,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/usdt.png"},{address:"0x00585c32b625999e6e5e78645ff8df7a9001cf5cf3eb6b80ccdd16cb64bd3a34",name:"zkLend Token",symbol:"ZEND",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/zend.png"},{address:"0x06ea04cd7e40bfef07c3625e2b3472839093d966bf601568128436466f962fcf",name:"Baby Laika",symbol:"BABYLAIKA",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/babylaika.png"},{address:"0x004a8ff6a7b121c55d5e21af478265c5798f574abaa41efadf569d6939705896",name:"Baby Laika",symbol:"BABYLAIKA",decimals:18,networkId:"sepolia-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/babylaika.png"},{address:"0x0782f0ddca11d9950bc3220e35ac82cf868778edb67a5e58b39838544bc4cd0f",name:"Starknet Voting Token",symbol:"vSTRK",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/vstrk.png"},{address:"0x075afe6402ad5a5c20dd25e10ec3b3986acaa647b77e4ae24b0cbc9a54a27a87",name:"Ekubo Protocol",symbol:"EKUBO",decimals:18,networkId:"mainnet-alpha",image:"https://dv3jj1unlp2jl.cloudfront.net/128/color/ekubo.png"}],$r=async(e,t,n)=>{const r=await n.callContract({contractAddress:e,entrypoint:"balanceOf",calldata:[t]});return BigInt(g.num.toHex(g.uint256.uint256ToBN({low:r[0],high:r[1]})))},zc=async(e,t,n)=>{const r=Ut.filter(o=>o.networkId===e);return(await Promise.allSettled(r.map(o=>t.callContract({contractAddress:o.address,entrypoint:"balanceOf",calldata:[n]})))).reduce((o,i,c)=>{if(i.status==="fulfilled"&&D.isUndefined(i.value)||i.status==="rejected"||i.value[0]==="0x0"&&i.value[1]==="0x0")return o;const l=BigInt(g.num.toHex(g.uint256.uint256ToBN({low:i.value[0],high:i.value[1]}))),d={...r[c],balance:l};return o.push(d),o},[])},Vc=async()=>Ut,Mc=({address:e,networkId:t})=>Ut.find(r=>r.address===e&&r.networkId===t),qc=({amount:e,decimals:t,unitCurrencyValue:n})=>{if(!K(e)||!K(t)||!K(n))return;const r=Number(t),s=BigInt(e)*vt(n.toString()).value;return Ue({value:s,decimals:r+Ee})},Gc=({unitAmount:e,decimals:t})=>{if(e===void 0||!K(e)||t===void 0||!K(t))return;const n=Number(t);return a.parseUnits(e.toString(),n).value.toString()},Wc=e=>K(e)?Number(e):18,{UINT_256_MAX:Kc}=g.uint256,Lr=e=>String(e)===String(Kc),Zc=(e,t="$",n)=>{if(e===void 0||!K(e))return null;const r=lr(e,n);return[t,r].filter(Boolean).join("")},jr="Unlimited",Yc=({amount:e,decimals:t,symbol:n,showPlusSign:r=!1,withSymbol:s=!0,unlimitedText:o=jr,prettyConfigOverrides:i})=>{if(!K(e))return null;let c,l=!1;if(Lr(e))c=o;else{const h=Number(t),u=BigInt(e);l=u>0n;const y=h>0?Ue({value:u,decimals:h}):u.toString();c=h>0?dr(y,i):y}const d=[c,s&&n].filter(Boolean).join(" ");return r&&l?`+${d}`:d};var Jc=a.retry,Xc=Jc;function Qc(e,t){function n(r,s){var o=t||{},i;"randomize"in o||(o.randomize=!0),i=Xc.operation(o);function c(h){s(h||new Error("Aborted"))}function l(h,u){if(h.bail){c(h);return}i.retry(h)?o.onRetry&&o.onRetry(h,u):s(i.mainError())}function d(h){var u;try{u=e(c,h)}catch(y){l(y,h);return}Promise.resolve(u).then(r).catch(function(S){l(S,h)})}i.attempt(d)}return new Promise(n)}var el=Qc;const tl=a.getDefaultExportFromCjs(el);class nl{constructor(t,n){this.apiBase=t,this.httpService=n,this.TOKENS_INFO_URL="/tokens/info",this.TOKENS_DEFI_DECOMPOSITION_URL="/tokens/defi/decomposition"}async fetchTokensInfoFromBackend(t){const n=a.urlJoin(this.apiBase,this.TOKENS_INFO_URL,t??"","?chain=starknet"),r=await this.httpService.get(n),s=a.apiTokensInfoResponseSchema.safeParse(r);if(s.success)return s.data.tokens;const o=a.apiTokenInfoResponseSchema.safeParse(r);if(o.success)return[o.data]}async fetchAddressTokenBalancesFromBackend(t,n,r){const s=a.urlJoin(this.apiBase,"activity","starknet",n,"account",t,"balance");return(await tl(async c=>{let l;try{l=await this.httpService.get(s)}catch{return c(new Error("Error fetching")),[]}const d=a.apiAccountTokenBalancesSchema.safeParse(l);if(!d.success)return c(new Error("Error parsing response")),[];if(d.data.status!=="initialised")throw new Error("Not initialised yet");return d.data.balances},{retries:5,minTimeout:5e3,...r})).map(c=>({address:c.tokenAddress,balance:c.tokenBalance,networkId:n}))}async fetchDefiDecomposition(t){const n=a.urlJoin(this.apiBase,this.TOKENS_DEFI_DECOMPOSITION_URL,t,"?chain=starknet"),r=await this.httpService.get(n);if(!a.apiDefiPositionsSchema.safeParse(r).success)throw new a.TokenError({code:"TOKEN_DEFI_DECOMPOSITION_PARSING_ERROR"});return r.dapps}}const rl=(e,t,n,r)=>({contractAddress:e,entrypoint:"transfer",calldata:g.CallData.compile({recipient:t,amount:be(ur(n,r))})}),sl=(e,t,n,r)=>({contractAddress:e,entrypoint:"transferFrom",calldata:g.CallData.compile({from_:t,to:n,tokenId:be(r)})}),ol=(e,t,n,r)=>({contractAddress:e,entrypoint:"safeTransferFrom",calldata:g.CallData.compile({from_:t,to:n,tokenId:be(r),amount:be(1),data_len:"0"})});function Ht(e){return D.upperCase(e.unit)==="WEI"}function zr(e){return D.upperCase(e.unit)==="FRI"}function le(e,t){return Ht(e)?{...e,maxFee:t(e.maxFee),overallFee:t(e.overallFee),gasPrice:t(e.gasPrice),gasUsage:t(e.gasUsage)}:{...e,overallFee:t(e.overallFee),gasPrice:t(e.gasPrice),gasUsage:t(e.gasUsage),maxAmount:t(e.maxAmount),maxPricePerUnit:t(e.maxPricePerUnit)}}function we(e){return Ht(e)?{maxFee:e.maxFee}:{amount:e.maxAmount,pricePerUnit:e.maxPricePerUnit}}function Ge(e){return zr({unit:e})?a.STRK_TOKEN_ADDRESS:a.ETH_TOKEN_ADDRESS}function al(e,t,n=2){const r=BigInt(10**n),s=BigInt(Math.round(t*10**n));return e*s/r}const il=[a.STRK_TOKEN_ADDRESS],Vr=(e,t=Kr)=>{if(e.max&&"amount"in e.max)return{...e,...e.max};const n=10000n,{amount:r,pricePerUnit:s,dataGasConsumed:o=0n,dataGasPrice:i=0n}=e,c=r*s+o*i;if(c<0)throw Error("Cannot calculate max fee for negative fee");const l=g.num.toBigInt(a.argentMaxFee({estimatedFee:c})),d=Number(l)/Number(c),h=t(d),u=BigInt(Math.trunc(h*Number(n)));return{...e,amount:r*u/n,pricePerUnit:s*u/n,dataGasConsumed:o*u/n,dataGasPrice:i*u/n}},De=e=>{const{amount:t,pricePerUnit:n,dataGasConsumed:r=0n,dataGasPrice:s=0n}=e;return t*n+r*s},Mr=e=>{if(e.max)return"maxFee"in e.max?e.max.maxFee:De(e.max)},Ye=e=>{const t=Mr(e);return t||De(Vr(e))},cl=e=>{if(e.deployment&&!a.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=De(e.transactions),n=e.deployment?De(e.deployment):0n;return t+n},ll=e=>{if(e.deployment&&!a.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=e.deployment?Ye(e.deployment):0n,n=Ye(e.transactions);return t+n},dl=(e,t)=>[{contractAddress:e,entrypoint:"transfer",calldata:g.CallData.compile(a.transferCalldataSchema.parse({recipient:t,amount:g.uint256.bnToUint256(BigInt(1))}))}],qr=(e,t)=>{if(!e)return{transactions:{feeTokenAddress:t??a.ETH_TOKEN_ADDRESS,amount:0n,pricePerUnit:0n,dataGasConsumed:0n,dataGasPrice:0n}};if(!Array.isArray(e))throw Error(`Unexpected simulation response. Expected array. Got ${typeof e}`);if(e.length===1){const n=a.feeEstimationSchema.parse(e[0].feeEstimation);return{transactions:{feeTokenAddress:Ge(n.unit),amount:g.num.toBigInt(n.gasUsage),pricePerUnit:g.num.toBigInt(n.gasPrice),max:we(le(n,g.num.toBigInt)),dataGasConsumed:n.dataGasConsumed?g.num.toBigInt(n.dataGasConsumed):0n,dataGasPrice:n.dataGasPrice?g.num.toBigInt(n.dataGasPrice):0n}}}if(e.length===2){const n=a.feeEstimationSchema.parse(e[0].feeEstimation),r=a.feeEstimationSchema.parse(e[1].feeEstimation);return{deployment:{feeTokenAddress:Ge(n.unit),amount:g.num.toBigInt(n.gasUsage),pricePerUnit:g.num.toBigInt(n.gasPrice),max:we(le(n,g.num.toBigInt)),dataGasConsumed:n.dataGasConsumed?g.num.toBigInt(n.dataGasConsumed):0n,dataGasPrice:n.dataGasPrice?g.num.toBigInt(n.dataGasPrice):0n},transactions:{feeTokenAddress:Ge(r.unit),amount:g.num.toBigInt(r.gasUsage),pricePerUnit:g.num.toBigInt(r.gasPrice),max:we(le(r,g.num.toBigInt)),dataGasConsumed:r.dataGasConsumed?g.num.toBigInt(r.dataGasConsumed):0n,dataGasPrice:r.dataGasPrice?g.num.toBigInt(r.dataGasPrice):0n}}}throw Error("Unexpected simulation response length")},Gr=({transaction:e,nonce:t,chainId:n,version:r,isDeploymentTransaction:s,cairoVersion:o,address:i,appDomain:c})=>{let l=t;s&&e.type!=="DEPLOY_ACCOUNT"&&(l=g.num.toHex(1));const d=a.ensureArray(e.calls);return{type:e.type,chainId:n,cairoVersion:o,nonce:l,version:r,account:i,calls:d,calldata:e.calldata,salt:e.salt,signature:e.signature,classHash:e.classHash,appDomain:c}},Wr=(e,t)=>{const{transactions:n}=e,r=n.map(l=>{if(!l.simulation)throw new a.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});return l}),s=r.map(l=>({...l.simulation,feeEstimation:le(l.simulation.feeEstimation,Number)})),o=qr(s,t),[i,c]=r.length===1?[r[0],void 0]:[r[1],r[0]];return{...o,transactions:{...o.transactions,dataGasConsumed:o.transactions.dataGasConsumed??0n,dataGasPrice:o.transactions.dataGasPrice??0n,max:we(le(i.simulation.feeEstimation,g.num.toBigInt))},deployment:o.deployment&&c?{...o.deployment,dataGasConsumed:o.deployment.dataGasConsumed??0n,dataGasPrice:o.deployment.dataGasPrice??0n,max:we(le(c.simulation.feeEstimation,g.num.toBigInt))}:void 0}},ul=e=>{const t=Vr(e),n=Ye(e);return{maxFee:n,resourceBounds:{l1_gas:{max_amount:g.num.toHex(n/e.pricePerUnit),max_price_per_unit:g.num.toHex(t.pricePerUnit)},l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"}}}},hl=e=>{const t=Math.sqrt(e);return isNaN(t)?Math.sqrt(2):t},Kr=e=>{const t=Math.cbrt(e);return isNaN(t)?Math.cbrt(2):t},fl=e=>e<1||isNaN(e)?1.1:Math.log(e+1)+1,ml=[a.STRK_TOKEN_ADDRESS];function it({address:e}){return ml.some(t=>a.isEqualAddress(e,t))}function pl(e){return e?Dn().some(t=>a.isEqualAddress(t,e)):!1}function Et(e){return it({address:e})?g.constants.TRANSACTION_VERSION.V3:g.constants.TRANSACTION_VERSION.V1}function gl(e){return it({address:e})?g.constants.TRANSACTION_VERSION.F3:g.constants.TRANSACTION_VERSION.F1}function Sl(e,t){return g.isSierra(t.contract)?it({address:e})?g.constants.TRANSACTION_VERSION.V3:g.constants.TRANSACTION_VERSION.V2:g.constants.TRANSACTION_VERSION.V1}class wl{constructor(t,n){this.apiBase=t,this.httpService=n}async getLabels(){const t=a.urlJoin(this.apiBase,"reviewer","labels");return await this.httpService.get(t)}async getWarnings(){const t=a.urlJoin(this.apiBase,"reviewer","warnings/reasons");return await this.httpService.get(t)}async simulateAndReview(t,n,r,s,o){const i=n.some(c=>c.type==="DEPLOY_ACCOUNT");try{if(!("getChainId"in t))throw new Error("MISSING_METHOD");const c=Et(r),l=i?"0x0":await t.getNonce(),d=await t.getChainId(),h={transactions:n.map(f=>({...Gr({transaction:f,nonce:l,version:c,chainId:d,isDeploymentTransaction:i,appDomain:s,cairoVersion:t.cairoVersion,address:t.address}),type:f.type}))},u=a.urlJoin(this.apiBase,"reviewer","transactions","v2","review","starknet"),y=await this.httpService.post(u,{headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(h)},a.simulateAndReviewSchema);if(y.transactions.some(f=>a.isTransactionSimulationError(f)))return y;const A=Wr(y,r);return{...y,enrichedFeeEstimation:A}}catch(c){return console.error(c),this.fallbackToOnchainFeeEstimation({transactions:n,account:t,isDeploymentTransaction:i,feeTokenAddress:r,accountDeployTransaction:o})}}getCallsFromTx(t){let n;return t.calls&&(n=a.ensureArray(t.calls)),n}async fallbackToOnchainFeeEstimation({transactions:t,account:n,isDeploymentTransaction:r,feeTokenAddress:s,accountDeployTransaction:o}){try{const i=r?this.getCallsFromTx(t[1]):this.getCallsFromTx(t[0]);if(!i)throw new a.ReviewError({code:"NO_CALLS_FOUND"});const c=await this.fetchFeesOnchain({starknetAccount:n,calls:i,isDeployed:!r,feeTokenAddress:s,accountDeployTransaction:o});return{transactions:[],enrichedFeeEstimation:c,isBackendDown:!0}}catch(i){throw console.error(i),new a.ReviewError({message:`${i}`,code:"SIMULATE_AND_REVIEW_FAILED"})}}async fetchFeesOnchain({starknetAccount:t,calls:n,isDeployed:r,feeTokenAddress:s,accountDeployTransaction:o}){try{const i=Et(s),c={transactions:{feeTokenAddress:s,amount:0n,pricePerUnit:0n,dataGasConsumed:0n,dataGasPrice:0n}};if(!r&&o){if("estimateFeeBulk"in t){const l=[{type:g.TransactionType.DEPLOY_ACCOUNT,payload:{classHash:o.classHash,addressSalt:o.salt,constructorCalldata:o.calldata,contractAddress:t.address}},{type:g.TransactionType.INVOKE,payload:n}],[d,h]=await t.estimateFeeBulk(l,{version:i}).catch(u=>{throw console.error(u),u});if(!d.gas_consumed||!d.gas_price||!h.gas_consumed||!h.gas_price)throw new a.ReviewError({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:"Missing gas_consumed or gas_price"});c.deployment={feeTokenAddress:s,amount:d.gas_consumed,pricePerUnit:d.gas_price,dataGasConsumed:d.data_gas_consumed,dataGasPrice:d.data_gas_price},c.transactions={feeTokenAddress:s,amount:h.gas_consumed,pricePerUnit:h.gas_price,dataGasConsumed:h.data_gas_consumed,dataGasPrice:h.data_gas_price}}}else{const{gas_consumed:l,gas_price:d,data_gas_consumed:h,data_gas_price:u}=await t.estimateFee(n,{skipValidate:!0,version:i});if(!l||!d)throw new a.ReviewError({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:"Missing gas_consumed or gas_price"});c.transactions={feeTokenAddress:s,amount:l,pricePerUnit:d,dataGasConsumed:h,dataGasPrice:u}}return c}catch(i){throw new a.ReviewError({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:`${i}`})}}}const yl=["account-upgrade","approve","set-approval-for-all","swap","transfer"],bl=e=>({showBalanceChange:$.useMemo(()=>{const n=e==null?void 0:e.some(s=>!D.isEmpty(s.transfers)),r=e==null?void 0:e.some(s=>!D.isEmpty(s.approvals));return e&&(n||r)},[e])}),je=e=>e?e.filter(t=>t.token.type==="erc20"):[],El=e=>$.useMemo(()=>je(e),[e]),Al=e=>je(e).length>0,Tl=e=>je(e).some(n=>n.amount>0n),vl=e=>je(e).some(n=>n.amount<0n),$t=e=>e?e.filter(t=>t.token.type==="erc721"):[],xl=e=>$.useMemo(()=>$t(e),[e]),Zr=e=>$t(e).length>0,Il=e=>$.useMemo(()=>Zr(e),[e]),Cl=(e,t)=>$.useMemo(()=>e&&t?[{contractAddress:e.address,entrypoint:"transfer",calldata:g.CallData.compile({recipient:t,amount:be(e.balance)})}]:[],[e,t]),_l=({apiData:{apiBaseUrl:e,apiHeaders:t},address:n,network:r,transactionReviewEnabled:s=!0,transactions:o})=>{const i=$.useCallback(async()=>{if(!n||!r)return;if(!e)throw"Transaction review endpoint is not defined";const l=a.urlJoin(e,"reviewer/transactions/review/starknet"),d=D.isArray(o)?o:[o],h={network:r,account:n,calls:d};return xt(l,{method:"POST",headers:{"Content-Type":"application/json",...t},body:JSON.stringify(h)})},[n,r,o]),c=$.useMemo(()=>rs({transactions:o,address:n,network:r}),[o,n,r]);return Tn(!!s,[c,"transactionReview"],i)},Bl=e=>{if(!e)return{};const t=e.assessment==="warn"&&e.reason!=="contract_is_not_verified",n=e.reason?` (Reason: ${D.lowerCase(e.reason)})`:"",r=t?e.reason==="recipient_is_token_address"?"You are sending tokens to their own address. This is likely to burn them.":`This transaction has been flagged as dangerous. We recommend you reject this transaction unless you are sure.${n}`:void 0;return{warn:t,reason:r}},Yr=e=>{var t;if(e){for(const n of e.reviews)if(((t=n.activity)==null?void 0:t.type)==="swap")return n}},Nl=e=>{},kl=(e,t)=>{var n;if(t){for(const r of t.reviews)if(((n=r.activity)==null?void 0:n.type)===e)return r.activity}},Ol=e=>!!Yr(e),Rl=e=>{var t,n;if(e){for(const r of e.reviews)if((t=r.activity)!=null&&t.type)return{...r,type:(n=r.activity)==null?void 0:n.type}}},Jr=async({feeTokenAddress:e,calls:t,selectedAccount:n,transactionReviewService:r,appDomain:s,accountDeployTransaction:o})=>{const i={type:"INVOKE",calls:a.ensureArray(t)};if(!n||!e)return;const c=o?[o,i]:[i];return{result:await r.simulateAndReview(n,c,e,s,o)}},Xr=async(e,t,n,r)=>{var y,S,A,f,w,E;let s=!1;const o=t.transactions.find(T=>{var x,N;return(N=(x=T==null?void 0:T.simulation)==null?void 0:x.summary)==null?void 0:N.find(B=>B.sent)});if(!o||!((y=o.simulation)!=null&&y.summary))return s;const i=o.simulation.summary.filter(T=>T.sent).map(T=>T.token.address);if(!(((S=t.enrichedFeeEstimation)==null?void 0:S.transactions.feeTokenAddress)&&i.includes((A=t.enrichedFeeEstimation)==null?void 0:A.transactions.feeTokenAddress))||!((w=(f=t.enrichedFeeEstimation)==null?void 0:f.transactions)!=null&&w.max))return s;const l="amount"in t.enrichedFeeEstimation.transactions.max?t.enrichedFeeEstimation.transactions.max.amount:"maxFee"in t.enrichedFeeEstimation.transactions.max?t.enrichedFeeEstimation.transactions.max.maxFee:void 0,d=(E=o.simulation.summary.find(T=>T.sent&&T.token.address===n))==null?void 0:E.value;if(!l||!d)return s;const h=await $r(n,e,r)??0n;return BigInt(h)>l+BigInt(d)||(s=!0),s},Pl=()=>$.useCallback(async({feeTokenAddress:t,calls:n,selectedAccount:r,transactionReviewService:s,appDomain:o,accountDeployPayload:i,provider:c})=>{if(!r)return;const l=await Jr({feeTokenAddress:t,calls:n,selectedAccount:r,transactionReviewService:s,appDomain:o,accountDeployTransaction:Qr(i)});if(!l||!l.result||!t)return;const d=await Xr(r.address,l.result,t,c);return{...l.result,isSendingMoreThanBalanceAndGas:d}},[]),Qr=e=>e?{type:"DEPLOY_ACCOUNT",calldata:e.calldata,classHash:a.hexSchema.parse(e.class_hash),salt:a.hexSchema.parse(e.salt),signature:[]}:void 0;exports.BaseError=a.BaseError;Object.defineProperty(exports,"ESTIMATE_ERROR_MESSAGES",{enumerable:!0,get:()=>a.ESTIMATE_ERROR_MESSAGES});exports.ETH_TOKEN_ADDRESS=a.ETH_TOKEN_ADDRESS;exports.EstimateError=a.EstimateError;exports.EventEmitterProvider=a.EventEmitterProvider;exports.EventsBySelector=a.EventsBySelector;exports.FEE_OVERHEAD=a.FEE_OVERHEAD;Object.defineProperty(exports,"HTTP_ERROR_MESSAGE",{enumerable:!0,get:()=>a.HTTP_ERROR_MESSAGE});exports.HttpError=a.HttpError;Object.defineProperty(exports,"MultiSigner",{enumerable:!0,get:()=>a.MultiSigner});exports.STANDARD_DEVNET_ACCOUNT_CLASS_HASH=a.STANDARD_DEVNET_ACCOUNT_CLASS_HASH;exports.STRK_TOKEN_ADDRESS=a.STRK_TOKEN_ADDRESS;Object.defineProperty(exports,"TOKEN_ERROR_MESSAGES",{enumerable:!0,get:()=>a.TOKEN_ERROR_MESSAGES});exports.TXV1_ACCOUNT_CLASS_HASH=a.TXV1_ACCOUNT_CLASS_HASH;exports.TXV1_MULTISIG_CLASS_HASH=a.TXV1_MULTISIG_CLASS_HASH;exports.TXV3_ACCOUNT_CLASS_HASH=a.TXV3_ACCOUNT_CLASS_HASH;exports.TXV3_MULTISIG_CLASS_HASH=a.TXV3_MULTISIG_CLASS_HASH;exports.TokenError=a.TokenError;exports.abiEntrySchema=a.abiEntrySchema;exports.abiSchema=a.abiSchema;exports.addOwnersCalldataSchema=a.addOwnersCalldataSchema;exports.addPluginCalldataSchema=a.addPluginCalldataSchema;exports.addressInputCharactersAndLengthSchema=a.addressInputCharactersAndLengthSchema;exports.addressInputSchema=a.addressInputSchema;exports.addressOrDomainInputSchema=a.addressOrDomainInputSchema;exports.addressOrDomainSchema=a.addressOrDomainSchema;exports.addressOrEmptyUndefinedSchema=a.addressOrEmptyUndefinedSchema;exports.addressSchema=a.addressSchema;exports.addressSchemaArgentBackend=a.addressSchemaArgentBackend;exports.addressSchemaBase=a.addressSchemaBase;exports.addressSchemaLooseLength=a.addressSchemaLooseLength;exports.addressSchemaStrictLength=a.addressSchemaStrictLength;exports.airdropSchema=a.airdropSchema;exports.apiAccountTokenBalancesSchema=a.apiAccountTokenBalancesSchema;exports.apiAirdropSchema=a.apiAirdropSchema;exports.apiCollateralizedDebtPositionSchema=a.apiCollateralizedDebtPositionSchema;exports.apiCollateralizedDebtPositionsSchema=a.apiCollateralizedDebtPositionsSchema;exports.apiConcentratedLiquidityPositionSchema=a.apiConcentratedLiquidityPositionSchema;exports.apiConcentratedLiquidityPositionsSchema=a.apiConcentratedLiquidityPositionsSchema;exports.apiDefiDecompositionProduct=a.apiDefiDecompositionProduct;exports.apiDefiDecompositionProducts=a.apiDefiDecompositionProducts;exports.apiDefiDecompositionSchema=a.apiDefiDecompositionSchema;exports.apiDefiDecompositionToken=a.apiDefiDecompositionToken;exports.apiDefiPositionsSchema=a.apiDefiPositionsSchema;exports.apiPriceDataResponseSchema=a.apiPriceDataResponseSchema;exports.apiPriceDetailsSchema=a.apiPriceDetailsSchema;exports.apiTokenInfoResponseSchema=a.apiTokenInfoResponseSchema;exports.apiTokenInfoSchema=a.apiTokenInfoSchema;exports.apiTokensInfoResponseSchema=a.apiTokensInfoResponseSchema;exports.apiUnclaimedRewardsSchema=a.apiUnclaimedRewardsSchema;exports.apiWalletResponseSchema=a.apiWalletResponseSchema;exports.argentMaxFee=a.argentMaxFee;exports.argentNameSchema=a.argentNameSchema;exports.bigNumberSchema=a.bigNumberSchema;exports.bigNumberishSchema=a.bigNumberishSchema;exports.booleanToStringSchema=a.booleanToStringSchema;exports.builtinsSchema=a.builtinsSchema;exports.byteCodeSchema=a.byteCodeSchema;exports.cairo1EventSchema=a.cairo1EventSchema;exports.cairoAssemblySchema=a.cairoAssemblySchema;exports.cairoVersionSchema=a.cairoVersionSchema;exports.callDetailsSchema=a.callDetailsSchema;exports.callSchema=a.callSchema;exports.calldataSchema=a.calldataSchema;exports.changeGuardianCalldataSchema=a.changeGuardianCalldataSchema;exports.changeThresholdCalldataSchema=a.changeThresholdCalldataSchema;exports.collateralizedDebtGroupSchema=a.collateralizedDebtGroupSchema;exports.collateralizedDebtPositionSchema=a.collateralizedDebtPositionSchema;exports.collateralizedDebtPositionsSchema=a.collateralizedDebtPositionsSchema;exports.compiledContractClassSchema=a.compiledContractClassSchema;exports.compiledSierraCasmSchema=a.compiledSierraCasmSchema;exports.compiledSierraSchema=a.compiledSierraSchema;exports.compressedProgramSchema=a.compressedProgramSchema;exports.concentratedLiquidityPositionSchema=a.concentratedLiquidityPositionSchema;exports.concentratedLiquidityPositionsSchema=a.concentratedLiquidityPositionsSchema;exports.constructorCallDataSchemaC0=a.constructorCallDataSchemaC0;exports.constructorCallDataSchemaC1V1=a.constructorCallDataSchemaC1V1;exports.contractEntryPointFieldsSchema=a.contractEntryPointFieldsSchema;exports.defiDappsProductsSchema=a.defiDappsProductsSchema;exports.defiPositionSchema=a.defiPositionSchema;exports.defiPositionTypeSchema=a.defiPositionTypeSchema;exports.defiProductSchema=a.defiProductSchema;exports.defiProductsSchema=a.defiProductsSchema;exports.denyTxV3=a.denyTxV3;exports.ensureArray=a.ensureArray;exports.entryPointsByTypeSchema=a.entryPointsByTypeSchema;exports.escapeGuardianCalldataSchema=a.escapeGuardianCalldataSchema;exports.eventAbiSchema=a.eventAbiSchema;exports.eventEntrySchema=a.eventEntrySchema;exports.executeOnPluginCalldataSchema=a.executeOnPluginCalldataSchema;exports.feltSchema=a.feltSchema;exports.findTransfersAndApprovals=a.findTransfersAndApprovals;exports.formatFullAddress=a.formatFullAddress;exports.formatTruncatedAddress=a.formatTruncatedAddress;exports.formatTruncatedSignerKey=a.formatTruncatedSignerKey;exports.formatTruncatedString=a.formatTruncatedString;exports.functionAbiSchema=a.functionAbiSchema;exports.functionAbiTypeSchema=a.functionAbiTypeSchema;exports.getAddressFromArgentName=a.getAddressFromArgentName;exports.getMessageFromTrpcError=a.getMessageFromTrpcError;exports.getPrettyRpcError=a.getPrettyRpcError;exports.getSignerForMultiSigner=a.getSignerForMultiSigner;exports.hexSchema=a.hexSchema;exports.hexSchemaBase=a.hexSchemaBase;exports.implementationSchema=a.implementationSchema;exports.includesAddress=a.includesAddress;exports.inputAmountSchema=a.inputAmountSchema;exports.isAddress=a.isAddress;exports.isArgentName=a.isArgentName;exports.isEqualAddress=a.isEqualAddress;exports.isEqualArgentName=a.isEqualArgentName;exports.isEqualStarknetDomainName=a.isEqualStarknetDomainName;exports.isEqualStarknetId=a.isEqualStarknetId;exports.isStarknetDomainName=a.isStarknetDomainName;exports.isStarknetId=a.isStarknetId;exports.isValidAddress=a.isValidAddress;exports.isValidInputAmount=a.isValidInputAmount;exports.isZeroAddress=a.isZeroAddress;exports.legacyContractClassSchema=a.legacyContractClassSchema;exports.legacyEventSchema=a.legacyEventSchema;exports.modifySnjsFeeOverhead=a.modifySnjsFeeOverhead;exports.multiTypeSchema=a.multiTypeSchema;exports.normalizeAddress=a.normalizeAddress;exports.normalizeAddressOrDomain=a.normalizeAddressOrDomain;exports.normalizeArgentName=a.normalizeArgentName;exports.normalizeStarknetId=a.normalizeStarknetId;exports.parseAmount=a.parseAmount;exports.productGroupsSchema=a.productGroupsSchema;exports.programSchema=a.programSchema;exports.pythonicHintsSchema=a.pythonicHintsSchema;exports.rawArgsArraySchema=a.rawArgsArraySchema;exports.rawArgsObjectSchema=a.rawArgsObjectSchema;exports.rawArgsSchema=a.rawArgsSchema;exports.removeOwnersCalldataSchema=a.removeOwnersCalldataSchema;exports.removePluginCalldataSchema=a.removePluginCalldataSchema;exports.replaceSignerCalldataSchema=a.replaceSignerCalldataSchema;exports.sierraContractEntryPointFieldsSchema=a.sierraContractEntryPointFieldsSchema;exports.sierraEntryPointsByTypeSchema=a.sierraEntryPointsByTypeSchema;exports.sierraProgramDebugInfoSchema=a.sierraProgramDebugInfoSchema;exports.starknetDomainNameSchema=a.starknetDomainNameSchema;exports.starknetIdSchema=a.starknetIdSchema;exports.stringToBooleanSchema=a.stringToBooleanSchema;exports.structAbiSchema=a.structAbiSchema;exports.transactionReviewTransactionsSchema=a.transactionReviewTransactionsSchema;exports.transactionReviewWarningSchema=a.transactionReviewWarningSchema;exports.transferCalldataSchema=a.transferCalldataSchema;exports.trpcErrorSchema=a.trpcErrorSchema;exports.txVersionSchema=a.txVersionSchema;exports.uint256Schema=a.uint256Schema;exports.unclaimedRewardsSchema=a.unclaimedRewardsSchema;exports.useEmitEvent=a.useEmitEvent;exports.useEventEmitter=a.useEventEmitter;exports.useEventEmitterContext=a.useEventEmitterContext;exports.useEventListener=a.useEventListener;exports.useIsEventEmitterEnabled=a.useIsEventEmitterEnabled;exports.validChecksumAddressSchema=a.validChecksumAddressSchema;exports.validateAddressRangeSchema=a.validateAddressRangeSchema;exports.ARGENT_ACCOUNT_CONTRACT_CLASS_HASHES=J;exports.ARGENT_MULTISIG_CONTRACT_CLASS_HASHES=ke;exports.AddSmartAccountResponseSchema=ss;exports.AddSmartAcountRequestSchema=os;exports.BackendAccountSchema=gn;exports.BackendNftService=si;exports.C0_PROXY_CONTRACT_CLASS_HASHES=Nn;exports.CacheService=ks;exports.DEFAULT_TOKEN_DECIMALS=Ee;exports.DateService=Os;exports.HTTPService=Xe;exports.KnownDappsBackendService=fa;exports.OnchainRecoveryService=Fc;exports.PRETTY_UNLIMITED=jr;exports.ResolveNameService=pa;exports.SWRService=Ps;exports.StarknetAddressService=js;exports.TokenServiceWeb=nl;exports.TransactionReviewServiceWeb=wl;exports.apiTransactionReviewActivityType=yl;exports.argentBackendNetworkIdSchema=yn;exports.argentNetworkIdSchema=wn;exports.bigDecimal=Ns;exports.buildAccountDeployTransaction=Qr;exports.buildConstructorCalldata=$n;exports.buildDummyTx=dl;exports.calculateCubeRootAdjustment=Kr;exports.calculateNonLinearAdjustment=fl;exports.calculateSqrtAdjustment=hl;exports.castFeeEstimation=le;exports.checkGasFeeBalance=Xr;exports.classHashSupportsTxV3=pl;exports.convertTokenAmountToCurrencyValue=qc;exports.convertTokenUnitAmountWithDecimals=Gc;exports.dappContractSchema=zn;exports.dappLinkSchema=jn;exports.daysBetween=Ga;exports.decodeBase58=cr;exports.decodeBase58Array=qa;exports.encodeBase58=ir;exports.encodeBase58Array=Ma;exports.ensureDecimals=Wc;exports.entryPointToHumanReadable=ei;exports.equalNft=di;exports.erc20TransferTransaction=rl;exports.erc721SafeTransferFromTransaction=ol;exports.erc721TransferFromTransaction=sl;exports.estimatedFeeToMaxFeeTotal=Ye;exports.estimatedFeeToMaxResourceBounds=ul;exports.estimatedFeeToTotal=De;exports.estimatedFeesToMaxFeeTotal=ll;exports.estimatedFeesToTotal=cl;exports.feeTokenNeedsTxV3Support=it;exports.fetchData=xt;exports.fetcherError=Ne;exports.findImplementationForAccount=da;exports.formatAddress=_t;exports.generateAvatarImage=Re;exports.getAccountContractAddress=Ln;exports.getAccountDeploymentPayload=Hn;exports.getAccountIdentifier=Us;exports.getAddressFromStarkName=Bn;exports.getArgentAccountClassHashes=St;exports.getArgentAccountClassHashesWithTxV3Support=Dn;exports.getArgentAccountWithMultiSignerClassHashes=Fn;exports.getBackendTimeNowSeconds=Ls;exports.getBackendTimeSeconds=vn;exports.getCallFromStarkName=_n;exports.getChainIdFromNetworkId=xn;exports.getColor=or;exports.getDapplandLinkForDapp=qn;exports.getDapplandUrlForDapp=ma;exports.getDisplayWarnAndReasonForTransactionReview=Bl;exports.getERC20Transactions=je;exports.getERC721Transactions=$t;exports.getEstimatedFeeFromBulkSimulation=qr;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFee=Wr;exports.getInitials=sr;exports.getLastCairo0ArgentAccountClassHash=ia;exports.getLatestArgentAccountClassHash=Pn;exports.getLatestArgentMultisigClassHash=aa;exports.getLatestLedgerAccountClassHash=la;exports.getLedgerAccountClassHashes=ca;exports.getNFTTransferActivity=Nl;exports.getNetworkAccountImageUrl=Va;exports.getNftPicture=li;exports.getPayloadFromTransaction=Gr;exports.getReviewForTransactions=Jr;exports.getSimulationTxVersionFromFeeToken=gl;exports.getStarknetIdContractAddressFromNetworkId=Cn;exports.getTokenBalance=$r;exports.getTokens=Vc;exports.getTokensBalances=zc;exports.getTransactionReviewActivityOfType=kl;exports.getTransactionReviewHasSwap=Ol;exports.getTransactionReviewSwap=Yr;exports.getTransactionReviewWithType=Rl;exports.getTxVersionFromFeeToken=Et;exports.getTxVersionFromFeeTokenForDeclareContract=Sl;exports.getUAParserResult=Hr;exports.getUint256CalldataFromBN=be;exports.getWatermarkedMaxFeeTotal=Mr;exports.hasERC20Transactions=Al;exports.hasERC721Transactions=Zr;exports.hasIncomingERC20Transactions=Tl;exports.hasOutgoingERC20Transactions=vl;exports.id=rr;exports.isAccountV4=cs;exports.isAccountV5=is;exports.isAccountV6=as;exports.isAllowedAddressHexInputValue=Ya;exports.isAllowedNumericInputValue=Ja;exports.isArgentBackendNetworkId=us;exports.isArgentNetworkId=ds;exports.isBraveBrowser=Dc;exports.isBrowser=Le;exports.isChromeBrowser=Hc;exports.isContractDeployed=Ka;exports.isEdgeBrowser=Lc;exports.isEqualImplementation=Un;exports.isFRI=zr;exports.isFeatureEnabled=Wa;exports.isFirefoxBrowser=Uc;exports.isNumeric=K;exports.isSafariBrowser=$c;exports.isUnlimitedAmount=Lr;exports.isWEI=Ht;exports.knownDappSchema=Vn;exports.knownDappsSchema=Mn;exports.multiplyBigIntByFloat=al;exports.nameProviderResolutionSchema=Wn;exports.nameResolutionAddressSchema=Kn;exports.nameResolutionAddressesSchema=Yn;exports.nameResolutionStarknetIdSchema=Ct;exports.nameResolutionStarknetIdsSchema=Gn;exports.nonNullable=Za;exports.onchainRecoverySchema=Rc;exports.parseAmountValue=ur;exports.pluralise=Xa;exports.postData=Fs;exports.preferencesEndpointPayload=ls;exports.preferencesSchema=Sn;exports.prettifyCurrencyNumber=lr;exports.prettifyCurrencyValue=Zc;exports.prettifyNumber=Bt;exports.prettifyNumberConfig=rt;exports.prettifyTokenAmount=Yc;exports.prettifyTokenNumber=dr;exports.providersNamesSchema=Zn;exports.readFileAsString=Qa;exports.recoveryBodySchema=Oc;exports.recoveryStatusSchema=Dr;exports.seedphraseSchema=jc;exports.starkNameToCallDataDomain=In;exports.startOnchainRecoveryErrorSchema=Pc;exports.startOnchainRecoveryErrorStatusSchema=Ur;exports.startOnchainRecoverySchema=Fr;exports.stripAddressZeroPadding=ar;exports.swrRefetchDisabledConfig=$s;exports.toMax=we;exports.tokensRequireTxV3Support=il;exports.unitToFeeTokenAddress=Ge;exports.urlWithQuery=ti;exports.useBalanceChange=bl;exports.useCollection=ii;exports.useConditionallyEnabledSWR=Tn;exports.useDebounce=ua;exports.useDebouncedValue=ha;exports.useERC20Transactions=El;exports.useERC721Transactions=xl;exports.useHasERC721Transaction=Il;exports.useMaxAmountTransaction=Cl;exports.useNft=ci;exports.useNfts=ai;exports.useToken=Mc;exports.useTransactionReview=_l;exports.useTransactionReviewV2webFetcher=Pl;exports.voidify=ni;exports.withPolling=Ds;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import F, { z as h } from "zod";
|
|
2
|
-
import { p as vt, H as K, a as Je, u as R, N as Ln, c as Lr, C as Dn, A as Et, i as Dr, b as Hr, n as Hn, d as Vr, e as Mr, f as Gr, g as zr, s as Q, h as nt, j as Qe, k as qr, S as Wr, l as tn, M as en, m as Kr, o as Zr, q as Vn, r as Yr, t as se, B as nn, v as oe, w as Rt, x as Xr, y as Jr, z as Qr, D as ts, E as es, F as ns, T as rs, G as ke, I as Mn, J as ss, K as ye, L as os, O as as, P as is, Q as cs, R as Nt } from "./transactionVersion-
|
|
3
|
-
import { am as yd, aV as bd, bN as Sd, aX as Ed, aT as Ad, an as xd, af as vd, ah as Id, ag as Td, ai as Bd, bs as _d, bA as Nd, bg as Cd, bk as Od, a9 as kd, aa as Pd, a5 as Rd, a4 as $d, Z as Fd, W as Ud, X as jd, Y as Ld, aM as Dd, az as Hd, au as Vd, av as Md, as as Gd, at as zd, ax as qd, aw as Wd, ay as Kd, ar as Zd, aq as Yd, ap as Xd, ao as Jd, aA as Qd, aj as tf, ab as ef, b1 as nf, b5 as rf, b3 as sf, bn as of, bC as af, bx as cf, bI as lf, ae as uf, bc as df, b7 as ff, be as hf, bj as pf, aD as mf, aE as gf, aF as wf, bK as yf, bJ as bf, bG as Sf, bq as Ef, aB as Af, aC as xf, bo as vf, aK as If, aG as Tf, aL as Bf, aI as _f, aJ as Nf, b0 as Cf, bp as Of, bf as kf, bz as Pf, bv as Rf, bm as $f, bd as Ff, aY as Uf, $ as jf, _ as Lf, a1 as Df, a2 as Hf, bu as Vf, bt as Mf, aS as Gf, aZ as zf, b2 as qf, a0 as Wf, aP as Kf, ac as Zf, a7 as Yf, ak as Xf, a6 as Jf, aQ as Qf, bB as th, bw as eh, aU as nh, b9 as rh, a8 as sh, ad as oh, al as ah, aO as ih, aH as ch, br as lh, bH as uh, b8 as dh, ba as fh, bb as hh, bh as ph, bl as mh, bi as gh, bE as wh, bF as yh, bD as bh, a3 as Sh, b4 as Eh, by as Ah, aW as xh, a_ as vh, aR as Ih, a$ as Th, b6 as Bh, aN as _h, bP as Nh, bO as Ch, bL as Oh, bQ as kh, bM as Ph, U as Rh, V as $h } from "./transactionVersion-
|
|
2
|
+
import { p as vt, H as K, a as Je, u as R, N as Ln, c as Lr, C as Dn, A as Et, i as Dr, b as Hr, n as Hn, d as Vr, e as Mr, f as Gr, g as zr, s as Q, h as nt, j as Qe, k as qr, S as Wr, l as tn, M as en, m as Kr, o as Zr, q as Vn, r as Yr, t as se, B as nn, v as oe, w as Rt, x as Xr, y as Jr, z as Qr, D as ts, E as es, F as ns, T as rs, G as ke, I as Mn, J as ss, K as ye, L as os, O as as, P as is, Q as cs, R as Nt } from "./transactionVersion-ByCNdhj1.mjs";
|
|
3
|
+
import { am as yd, aV as bd, bN as Sd, aX as Ed, aT as Ad, an as xd, af as vd, ah as Id, ag as Td, ai as Bd, bs as _d, bA as Nd, bg as Cd, bk as Od, a9 as kd, aa as Pd, a5 as Rd, a4 as $d, Z as Fd, W as Ud, X as jd, Y as Ld, aM as Dd, az as Hd, au as Vd, av as Md, as as Gd, at as zd, ax as qd, aw as Wd, ay as Kd, ar as Zd, aq as Yd, ap as Xd, ao as Jd, aA as Qd, aj as tf, ab as ef, b1 as nf, b5 as rf, b3 as sf, bn as of, bC as af, bx as cf, bI as lf, ae as uf, bc as df, b7 as ff, be as hf, bj as pf, aD as mf, aE as gf, aF as wf, bK as yf, bJ as bf, bG as Sf, bq as Ef, aB as Af, aC as xf, bo as vf, aK as If, aG as Tf, aL as Bf, aI as _f, aJ as Nf, b0 as Cf, bp as Of, bf as kf, bz as Pf, bv as Rf, bm as $f, bd as Ff, aY as Uf, $ as jf, _ as Lf, a1 as Df, a2 as Hf, bu as Vf, bt as Mf, aS as Gf, aZ as zf, b2 as qf, a0 as Wf, aP as Kf, ac as Zf, a7 as Yf, ak as Xf, a6 as Jf, aQ as Qf, bB as th, bw as eh, aU as nh, b9 as rh, a8 as sh, ad as oh, al as ah, aO as ih, aH as ch, br as lh, bH as uh, b8 as dh, ba as fh, bb as hh, bh as ph, bl as mh, bi as gh, bE as wh, bF as yh, bD as bh, a3 as Sh, b4 as Eh, by as Ah, aW as xh, a_ as vh, aR as Ih, a$ as Th, b6 as Bh, aN as _h, bP as Nh, bO as Ch, bL as Oh, bQ as kh, bM as Ph, U as Rh, V as $h } from "./transactionVersion-ByCNdhj1.mjs";
|
|
4
4
|
import { constants as Z, starknetId as Gn, CallData as gt, CairoOption as rn, CairoOptionVariant as sn, hash as zn, num as O, encode as dt, uint256 as Dt, ec as on, isSierra as ls, TransactionType as an } from "starknet";
|
|
5
5
|
import { useEffect as Yt, useRef as cn, useState as us, useMemo as It, useCallback as qn } from "react";
|
|
6
6
|
import { isFunction as zt, isString as Wn, upperCase as Pe, isNil as ds, upperFirst as fs, lowerCase as Kn, isUndefined as hs, isEmpty as ln, isArray as ps } from "lodash-es";
|
package/dist/simulation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./transactionVersion-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./transactionVersion-IV8urBdT.js"),h=require("lodash-es");require("starknet");require("zod");require("@scure/base");require("react");require("object-hash");require("swr");function d(e){return e.error?e.error:e.message&&e.code?`${e.code}: ${e.message}`:"Unknown error"}function p(e){if(!e)return;const n=e.transactions.flatMap(o=>i.isTransactionSimulationError(o)?o.simulationError:!1),t=n==null?void 0:n[n.length-1];if(!t)return;const s=d(t),a=t.message||t.error,r=i.getPrettyRpcError(a),u=r||t.label;return{message:r?a:s,label:u}}const l=e=>e.map(f),f=e=>{var s,a,r,u;if(i.isActivitySummary(e))return i.activitySummarySchema.parse(e);const n=!!e.sent;if(e.token.type!=="ERC20"){const c={asset:{type:"nft",tokenAddress:e.token.address,tokenId:e.tokenId?parseInt(e.tokenId):0,amount:e.value,collectionName:e.token.name,collectionPreviewImage:(s=e.token.imageUrls)==null?void 0:s.preview,nftName:(a=e.tokenIdDetails)==null?void 0:a.name,nftPreviewImage:(u=(r=e.tokenIdDetails)==null?void 0:r.imageUrls)==null?void 0:u.preview},sent:n};return i.activitySummarySchema.parse(c)}const t={asset:{type:"token",tokenAddress:e.token.address,amount:e.value,fiatAmount:{currency:"USD",currencyAmount:e.usdValue||"0"}},sent:n};return i.activitySummarySchema.parse(t)};function m(e){var s,a;const n=(a=(s=e.transactions)==null?void 0:s[0].reviewOfTransaction)==null?void 0:a.reviews;return n?n.map(r=>r.action):void 0}function g({simulateAndReview:e,...n}){var s,a;const t={type:i.NativeActivityTypeNative,...n};if(e&&!h.isEmpty(e.transactions)){const r=e.transactions[e.transactions.length-1],u=(s=r.simulation)==null?void 0:s.summary;if(u){const S=l(u);t.transferSummary=S}const c=(a=r.reviewOfTransaction)==null?void 0:a.targetedDapp;c&&(t.dapp=c);const o=m(e);o&&(t.actions=o)}return i.nativeActivitySchema.parse(t)}function A(e){const n=k(e),t=T(e);return n||t}const k=e=>{var u;if(!((u=e.actions)!=null&&u.length))return!1;const n=e.actions[0];if(n.name!=="ERC20_transfer")return!1;let t,s,a,r;return n.defaultProperties&&n.defaultProperties.forEach(c=>{c.type==="token_address"&&c.token.address===i.ETH_TOKEN_ADDRESS&&(s=!0),c.type==="calldata"&&(t=c.calldata[0])}),n.properties.length>1&&n.properties.forEach(c=>{c.type==="amount"&&c.label==="ERC20_transfer_amount"&&c.amount==="0"&&(a=!0),c.type==="address"&&c.label==="ERC20_transfer_recipient"&&i.isEqualAddress(c.address,t)&&(r=!0)}),s&&a&&r},T=e=>{var n,t;return!!("meta"in e&&(t=(n=e.meta)==null?void 0:n.title)!=null&&t.includes("On-chain rejection"))};function v(e,n=!1){var t,s;if(e.type===i.NativeActivityTypeNative){if(n&&((t=e.meta)!=null&&t.shortTitle))return e.meta.shortTitle;if((s=e.meta)!=null&&s.title)return e.meta.title}else{if(A(e))return"On-chain rejection";if(e.title)return e.title}return"Contract interaction"}function E(e){return v(e,!0)}function N(e){return e.map(s=>s.lastModified).sort().pop()}const O=e=>{var t,s;return!!((s=(t=e.details)==null?void 0:t.calls)==null?void 0:s.some(a=>{var r,u,c;return(u=(r=a==null?void 0:a.details)==null?void 0:r.function)!=null&&u.name?((c=a==null?void 0:a.details)==null?void 0:c.function.name)==="lock_and_delegate_by_sig":!1}))},y=e=>{var n;return e.type==="multicall"&&"calls"in e.details&&((n=e.details.calls)==null?void 0:n.some(t=>{var s;return((s=t==null?void 0:t.details)==null?void 0:s.type)==="deploy"&&i.isEqualAddress((t==null?void 0:t.details.contractAddress)||"",e.wallet)}))};function D(e){const n=M(e),t=R(e);return n||t}const M=e=>{var t;if(!((t=e.actions)!=null&&t.length))return!1;const n=e.actions[0];if(n.name!=="account_upgrade")return!1;n.defaultProperties&&n.defaultProperties.forEach(s=>{if(s.type==="calldata"&&s.entrypoint==="upgrade")return!0})},R=e=>{var n,t;return!!("meta"in e&&(t=(n=e.meta)==null?void 0:n.title)!=null&&t.includes("Upgrade account"))};function w({activities:e,accountAddressesOnNetwork:n}){const t={};return e.forEach(s=>{const a=s.wallet,r=s.type==="deploy"?s.type:s.details.type==="security"?s.details.action:void 0;s.group==="security"&&i.includesAddress(a,n)&&r&&(t[r]=t[r]||[],i.includesAddress(a,t[r])||(t[r]=i.ensureArray(t[r]).concat(a))),y(s)&&(t.deploy=i.ensureArray(t.deploy).concat(a))}),t}function _({activities:e,accountAddressesOnNetwork:n,tokenAddressesOnNetwork:t,nftAddressesOnNetwork:s}){const a={tokenActivity:{accountAddresses:[],tokenAddresses:[]},nftActivity:{accountAddresses:[],tokenAddresses:[]}};return e.forEach(r=>{if(r.group==="finance"&&r.relatedAddresses){const u=r.transfers.some(c=>c.asset.type==="token");r.relatedAddresses.forEach(({type:c,address:o})=>{c==="token"?(i.includesAddress(o,t)&&(i.includesAddress(o,a.tokenActivity.tokenAddresses)||a.tokenActivity.tokenAddresses.push(o)),i.includesAddress(o,s)&&(i.includesAddress(o,a.nftActivity.tokenAddresses)||a.nftActivity.tokenAddresses.push(o))):c==="wallet"&&i.includesAddress(o,n)&&(u?i.includesAddress(o,a.tokenActivity.accountAddresses)||a.tokenActivity.accountAddresses.push(o):i.includesAddress(o,a.nftActivity.accountAddresses)||a.nftActivity.accountAddresses.push(o))})}}),a}const j=e=>{if(e.length===0)return null;const n=["critical","high","caution","info"];return e.reduce((t,s)=>{const a=n.indexOf(s.severity),r=n.indexOf(t.severity);return a<r?s:t},e[0])};exports.NativeActivityStatusCancelled=i.NativeActivityStatusCancelled;exports.NativeActivityStatusQueued=i.NativeActivityStatusQueued;exports.NativeActivityStatusRejected=i.NativeActivityStatusRejected;exports.NativeActivityTypeNative=i.NativeActivityTypeNative;exports.actionSchema=i.actionSchema;exports.activitiesSchema=i.activitiesSchema;exports.activityDappSchema=i.activityDappSchema;exports.activityDetailsSchema=i.activityDetailsSchema;exports.activityResponseSchema=i.activityResponseSchema;exports.activitySchema=i.activitySchema;exports.activitySummarySchema=i.activitySummarySchema;exports.activityTransferSchema=i.activityTransferSchema;exports.assessmentSchema=i.assessmentSchema;exports.enrichedSimulateAndReviewSchema=i.enrichedSimulateAndReviewSchema;exports.estimatedFeeSchema=i.estimatedFeeSchema;exports.estimatedFeesSchema=i.estimatedFeesSchema;exports.feeEstimationSchema=i.feeEstimationSchema;exports.feeSchema=i.feeSchema;exports.isActivityDetailsAction=i.isActivityDetailsAction;exports.isActivitySummary=i.isActivitySummary;exports.isNftActivitySummary=i.isNftActivitySummary;exports.isNotTransactionSimulationError=i.isNotTransactionSimulationError;exports.isTokenActivitySummary=i.isTokenActivitySummary;exports.isTransactionSimulationError=i.isTransactionSimulationError;exports.nativeActivityMetaSchema=i.nativeActivityMetaSchema;exports.nativeActivitySchema=i.nativeActivitySchema;exports.propertySchema=i.propertySchema;exports.reasonsSchema=i.reasonsSchema;exports.reviewSchema=i.reviewSchema;exports.severitySchema=i.severitySchema;exports.simulateAndReviewSchema=i.simulateAndReviewSchema;exports.targetedDappSchema=i.targetedDappSchema;exports.warningDetailsSchema=i.warningDetailsSchema;exports.warningSchema=i.warningSchema;exports.createNativeActivity=g;exports.getAnyActivityShortTitle=E;exports.getAnyActivityTitle=v;exports.getErrorMessageAndLabelFromSimulation=p;exports.getHighestSeverity=j;exports.getMessageFromSimulationError=d;exports.getOverallLastModified=N;exports.hasDelegationActivity=O;exports.isMulticallWithDeploymentActivity=y;exports.isRejectOnChainActivity=A;exports.isUpgradeActivity=D;exports.normalizeActions=m;exports.normalizeActivitySummary=f;exports.normalizeActivitySummaryCollection=l;exports.parseAccountActivities=w;exports.parseFinanceActivities=_;
|
package/dist/simulation.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Q as m, aZ as h, bR as v, bS as u, bT as l, bU as S, I as g, h as p, a0 as f, v as d } from "./transactionVersion-
|
|
2
|
-
import { c0 as G, c1 as J, b$ as I, ca as ee, c2 as te, bX as se, bW as ne, c3 as ie, bZ as ae, bV as re, cb as oe, cg as ce, c7 as fe, c8 as ue, K as de, bY as le, c4 as pe, c6 as Ae, ch as me, c5 as he, b_ as ve, c9 as Se, cj as ge, ce as ye, ci as ke, P as Ee, cf as Oe, cc as Te, cd as be } from "./transactionVersion-
|
|
1
|
+
import { Q as m, aZ as h, bR as v, bS as u, bT as l, bU as S, I as g, h as p, a0 as f, v as d } from "./transactionVersion-ByCNdhj1.mjs";
|
|
2
|
+
import { c0 as G, c1 as J, b$ as I, ca as ee, c2 as te, bX as se, bW as ne, c3 as ie, bZ as ae, bV as re, cb as oe, cg as ce, c7 as fe, c8 as ue, K as de, bY as le, c4 as pe, c6 as Ae, ch as me, c5 as he, b_ as ve, c9 as Se, cj as ge, ce as ye, ci as ke, P as Ee, cf as Oe, cc as Te, cd as be } from "./transactionVersion-ByCNdhj1.mjs";
|
|
3
3
|
import { isEmpty as y } from "lodash-es";
|
|
4
4
|
import "starknet";
|
|
5
5
|
import "zod";
|
|
@@ -2346,7 +2346,10 @@ const or = e.object({
|
|
|
2346
2346
|
transferSummary: e.array(lr).optional(),
|
|
2347
2347
|
dapp: ga.optional(),
|
|
2348
2348
|
actions: e.array(Qt).optional(),
|
|
2349
|
-
title: e.string().optional()
|
|
2349
|
+
title: e.string().optional(),
|
|
2350
|
+
multisigDetails: e.object({
|
|
2351
|
+
signers: e.array(H)
|
|
2352
|
+
}).optional()
|
|
2350
2353
|
}), Ia = e.object({
|
|
2351
2354
|
title: e.string().optional(),
|
|
2352
2355
|
shortTitle: e.string().optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("zod"),W=require("starknet"),ke=require("lodash-es");require("@scure/base");const xn=require("react/jsx-runtime"),St=require("react");require("object-hash");require("swr");function Wt(t,o){let[g,N=""]=t.split(".");const A=g.startsWith("-");return A&&(g=g.slice(1)),N.length>o?Number(N[o])>=5?N=(BigInt(N.slice(0,o))+1n).toString().padStart(o,"0"):N=N.slice(0,o):N=N.padEnd(o,"0"),{value:BigInt(`${A?"-":""}${g}${N}`),decimals:o}}const At=e.z.string().refine(t=>{if(t.toLowerCase()===t)return!0;try{return W.validateChecksumAddress(t)&&Vn(t)}catch{}return!1},"Invalid address (checksum error)"),Kt=e.z.string().refine(t=>{try{return W.validateAndParseAddress(t)}catch{}return!1},"Invalid address (validation error)"),Fe=e.z.string().regex(/^0x[0-9a-fA-F]+$/,"Invalid address"),Yt=Fe.min(50,"Addresses must at least be 50 characters long").max(66,"Addresses must at most be 66 characters long"),Zt=Fe.length(66,"Address must be 66 characters long"),Y=Yt.pipe(At).transform(t=>`0x${(t.startsWith("0x")?t.slice(2):t).padStart(64,"0")}`),Bn=Y.or(e.z.literal("")).transform(t=>t===""?void 0:t).optional(),H=Fe.transform(t=>`0x${t.replace(/^0x/,"").toLowerCase().padStart(64,"0")}`),Jt=t=>Y.safeParse(t).success,Qt=Jt,xe=t=>W.getChecksumAddress(t),Mn=t=>{const o=xe(t),g=o.slice(0,2),N=o.slice(2,6),A=o.slice(-4);return`${g}${N}…${A}`},Gn=t=>{const o=xe(t),g=o.slice(0,2),A=o.slice(2).match(/.{1,4}/g)||[];return`${g} ${A.join(" ")}`},Vn=t=>!/^0x[0-9a-f]{63,64}$/.test(t),er=(t,o)=>{try{return!t||!o?!1:W.num.hexToDecimalString(t)===W.num.hexToDecimalString(o)}catch{}return!1},tr=t=>{try{return W.num.toBigInt(Fe.parse(t))===W.constants.ZERO}catch{}return!1},$n=(t,o)=>!!(o!=null&&o.some(g=>er(g,t))),Hn=ke.memoize(t=>{const o=t.slice(0,6),g=t.slice(-4);return`${o}…${g}`}),Xn=ke.memoize((t,o)=>{if(t.length<o)return t;const g=Math.floor((o-1)/2),N=t.slice(0,g),A=t.slice(-g);return`${N}…${A}`}),qn=e.z.string().regex(/^[a-zA-Z0-9.-]*$/g,"Invalid address character").max(66,"Address cannot be over 66 characters"),rr=Zt.pipe(At).pipe(Kt),Be=e.z.string().regex(/^([a-zA-Z0-9-]+\.)+argent.xyz$/,"Invalid Argent name").max(253,"Argent name cannot be over 253 characters"),nr=t=>Be.safeParse(t).success,ir=(t,o)=>{try{return o?Xe(t)===Xe(o):!1}catch{}return!1},Xe=t=>Be.parse(t).toLowerCase(),Ze=e.z.string().regex(/^([a-zA-Z0-9-]+\.)+stark$/,"Invalid Starknet ID").max(50,"Starknet ID cannot be over 50 characters"),ar=t=>Ze.safeParse(t).success,sr=(t,o)=>{try{return o?qe(t)===qe(o):!1}catch{}return!1},qe=t=>Ze.parse(t).toLowerCase(),Je=e.z.union([Be,Ze]),Wn=e.z.union([Y,Je]),Kn=e.z.union([rr,Je]),Yn=t=>Je.safeParse(t).success,Zn=(t,o)=>{try{return o?ir(t,o)||sr(t,o):!1}catch{}return!1},Jn=t=>ar(t)?qe(t):nr(t)?Xe(t):xe(t),or=e.z.union([e.z.literal("0"),e.z.literal("1")]),Qn="0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",ei="0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",ti="0x1a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003",ri="0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f",ni="0x737ee2f87ce571a58c6c8da558ec18a07ceb64a6172d5ec46171fbc80077a48",ii="0x6e150953b26271a740bf2b6e9bca17cc52c68d765f761295de51ceb8526ee72",ai="0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f";function si(t){var o=[];if(t.length===0)return"";if(typeof t[0]!="string")throw new TypeError("Url must be a string. Received "+t[0]);if(t[0].match(/^[^/:]+:\/*$/)&&t.length>1){var g=t.shift();t[0]=g+t[0]}t[0].match(/^file:\/\/\//)?t[0]=t[0].replace(/^([^/:]+):\/*/,"$1:///"):t[0]=t[0].replace(/^([^/:]+):\/*/,"$1://");for(var N=0;N<t.length;N++){var A=t[N];if(typeof A!="string")throw new TypeError("Url must be a string. Received "+A);A!==""&&(N>0&&(A=A.replace(/^[\/]+/,"")),N<t.length-1?A=A.replace(/[\/]+$/,""):A=A.replace(/[\/]+$/,"/"),o.push(A))}var C=o.join("/");C=C.replace(/\/(\?|&|#[^!])/g,"$1");var b=C.split("?");return C=b.shift()+(b.length>0?"?":"")+b.join("&"),C}function cr(){var t;return typeof arguments[0]=="object"?t=arguments[0]:t=[].slice.call(arguments),si(t)}class Oe extends Error{constructor({code:o,message:g,options:N={}},A){const{error:C,context:b}=N;super(g,{cause:C}),this.errorMessages=A,this.name="BaseError",this.context=b,this.code=o,this.setMessageByCode(o,g)}setMessageByCode(o,g){!o||!this.errorMessages||g||(this.message=this.errorMessages[o])}}var ot;(function(t){t.NOT_VALID="Invalid address",t.NOT_FOUND="Address not found",t.STARKNAME_NOT_FOUND="Stark name not found",t.STARKNAME_ERROR="Could not get address from stark name",t.STARKNAME_INVALID_ADDRESS="Stark name resolved to an invalid address",t.ARGENT_NAME_NOT_FOUND="Argent name not found",t.NO_ADDRESS_FROM_ARGENT_NAME="Could not get address from Argent name",t.ARGENT_NAME_INVALID_ADDRESS="Argent name resolved to an invalid address",t.NO_ADDRESS_FROM_DOMAIN="Could not get address from domain",t.ARGENT_NAME_INVALID_NETWORK="Argent name is not enabled on the requested network"})(ot||(ot={}));class De extends Oe{constructor(o){super(o,ot),this.name="AddressError"}}class Qe extends Error{constructor(o,g,N){super(o),this.status=g,this.data=N,Object.setPrototypeOf(this,Qe.prototype)}}exports.HTTP_ERROR_MESSAGE=void 0;(function(t){t.FAILED_TO_FETCH_URL="Failed to fetch url",t.FAILED_TO_POST_URL="Failed to post url"})(exports.HTTP_ERROR_MESSAGE||(exports.HTTP_ERROR_MESSAGE={}));const oi=e.z.object({walletAddress:H,ens:Be,chain:e.z.enum(["ethereum","starknet"]),deleted:e.z.boolean(),walletDeployed:e.z.boolean()}).or(e.z.object({status:e.z.string()}));async function ci(t,o,g,N="starknet"){const A={ens:t,chain:N},C=new URLSearchParams(A),b=cr(g,"wallet",`?${C}`);try{const k=await o.get(b),w=k&&"walletAddress"in k?k.walletAddress:void 0;if(!w)throw new De({code:"NO_ADDRESS_FROM_ARGENT_NAME"});if(tr(w))throw new De({code:"ARGENT_NAME_NOT_FOUND",message:`${t} not found`});if(!Qt(w))throw new De({code:"ARGENT_NAME_INVALID_ADDRESS",message:`${t} resolved to an invalid address (${w})`});return xe(w)}catch(k){throw k instanceof Qe&&k.status===404?new De({code:"ARGENT_NAME_NOT_FOUND",message:`${t} not found`}):k}}var ct;(function(t){t.NOT_VALID="Invalid call"})(ct||(ct={}));class li extends Oe{constructor(o){super(o,ct),this.name="CallError"}}var lt;(function(t){t.NO_NETWORK_OR_MULTICALL="Missing networkId or multicall",t.NOT_FOUND="Network not found"})(lt||(lt={}));class ui extends Oe{constructor(o){super(o,lt),this.name="NetworkError"}}const _e=e.z.union([e.z.string(),e.z.number(),e.z.bigint()]),lr=e.z.object({low:_e,high:_e}),ur=e.z.array(e.z.string()).and(e.z.object({__compiled__:e.z.boolean().optional()}).optional()),fr=e.z.lazy(()=>e.z.array(e.z.union([je,e.z.array(je),et]))),je=e.z.union([_e,lr,e.z.any(),e.z.boolean()]),mr=e.z.lazy(()=>e.z.record(e.z.union([je,e.z.array(je),et]))),et=e.z.lazy(()=>e.z.union([mr,fr])),hr=e.z.lazy(()=>e.z.object({contractAddress:e.z.string(),calldata:e.z.union([et,ur]).optional(),entrypoint:e.z.string().optional()})),ut=e.z.lazy(()=>hr.and(e.z.object({entrypoint:e.z.string()}))),fe=e.z.string().refine(t=>typeof parseInt(t)=="number"),fi=e.z.tuple([fe]),mi=e.z.tuple([fe]),hi=e.z.object({new_threshold:e.z.string().refine(t=>typeof parseInt(t)=="number"),signers_to_add:e.z.array(fe)}),di=e.z.object({new_threshold:e.z.string().refine(t=>typeof parseInt(t)=="number"),signers_to_remove:e.z.array(fe)}),pi=e.z.object({signer_to_remove:fe,signer_to_add:fe}),Ei=e.z.tuple([fe]),gi=e.z.tuple([fe]),zi=e.z.tuple([fe]),Si=e.z.tuple([fe]).rest(fe),Ai=e.z.object({recipient:Y,amount:e.z.object({low:_e,high:_e})}),dr=e.z.string().regex(/^(0x)?[0-9a-fA-F]+$/,"Invalid hex string"),Ue=dr.transform(t=>{const o=t.startsWith("0x")?t.slice(2):t;return`0x${o.length%2===0?o:`0${o}`}`}),Ii=e.z.object({cairoVersion:or,accountClassHash:Ue}),Ti=e.z.array(e.z.string()),Ni=e.z.object({implementation:e.z.string(),selector:Ue,calldata:Ti}),yi=e.z.object({owner:e.z.string(),guardian:e.z.string().optional().transform(t=>t??"0")});exports.MultiSigner=void 0;(function(t){t.Starknet="Starknet",t.Secp256k1="Secp256k1",t.Secp256r1="Secp256r1",t.Eip191="Eip191",t.Webauthn="Webauthn"})(exports.MultiSigner||(exports.MultiSigner={}));function vi(t,o){const g={Starknet:void 0,Secp256k1:void 0,Secp256r1:void 0,Eip191:void 0,Webauthn:void 0};return g[o]=t,new W.CairoCustomEnum(g)}var ft;(function(t){t.NOT_FOUND="Account not found",t.CALCULATED_ADDRESS_NO_MATCH="Calculated address does not match account address"})(ft||(ft={}));class Ri extends Oe{constructor(o){super(o,ft),this.name="AccountError"}}function pr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mt={exports:{}};(function(t,o){o=t.exports=P;var g;typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?g=function(){var r=Array.prototype.slice.call(arguments,0);r.unshift("SEMVER"),console.log.apply(console,r)}:g=function(){},o.SEMVER_SPEC_VERSION="2.0.0";var N=256,A=Number.MAX_SAFE_INTEGER||9007199254740991,C=16,b=N-6,k=o.re=[],w=o.safeRe=[],S=o.src=[],p=o.tokens={},Z=0;function D(r){p[r]=Z++}var he="[a-zA-Z0-9-]",te=[["\\s",1],["\\d",N],[he,b]];function Se(r){for(var s=0;s<te.length;s++){var l=te[s][0],I=te[s][1];r=r.split(l+"*").join(l+"{0,"+I+"}").split(l+"+").join(l+"{1,"+I+"}")}return r}D("NUMERICIDENTIFIER"),S[p.NUMERICIDENTIFIER]="0|[1-9]\\d*",D("NUMERICIDENTIFIERLOOSE"),S[p.NUMERICIDENTIFIERLOOSE]="\\d+",D("NONNUMERICIDENTIFIER"),S[p.NONNUMERICIDENTIFIER]="\\d*[a-zA-Z-]"+he+"*",D("MAINVERSION"),S[p.MAINVERSION]="("+S[p.NUMERICIDENTIFIER]+")\\.("+S[p.NUMERICIDENTIFIER]+")\\.("+S[p.NUMERICIDENTIFIER]+")",D("MAINVERSIONLOOSE"),S[p.MAINVERSIONLOOSE]="("+S[p.NUMERICIDENTIFIERLOOSE]+")\\.("+S[p.NUMERICIDENTIFIERLOOSE]+")\\.("+S[p.NUMERICIDENTIFIERLOOSE]+")",D("PRERELEASEIDENTIFIER"),S[p.PRERELEASEIDENTIFIER]="(?:"+S[p.NUMERICIDENTIFIER]+"|"+S[p.NONNUMERICIDENTIFIER]+")",D("PRERELEASEIDENTIFIERLOOSE"),S[p.PRERELEASEIDENTIFIERLOOSE]="(?:"+S[p.NUMERICIDENTIFIERLOOSE]+"|"+S[p.NONNUMERICIDENTIFIER]+")",D("PRERELEASE"),S[p.PRERELEASE]="(?:-("+S[p.PRERELEASEIDENTIFIER]+"(?:\\."+S[p.PRERELEASEIDENTIFIER]+")*))",D("PRERELEASELOOSE"),S[p.PRERELEASELOOSE]="(?:-?("+S[p.PRERELEASEIDENTIFIERLOOSE]+"(?:\\."+S[p.PRERELEASEIDENTIFIERLOOSE]+")*))",D("BUILDIDENTIFIER"),S[p.BUILDIDENTIFIER]=he+"+",D("BUILD"),S[p.BUILD]="(?:\\+("+S[p.BUILDIDENTIFIER]+"(?:\\."+S[p.BUILDIDENTIFIER]+")*))",D("FULL"),D("FULLPLAIN"),S[p.FULLPLAIN]="v?"+S[p.MAINVERSION]+S[p.PRERELEASE]+"?"+S[p.BUILD]+"?",S[p.FULL]="^"+S[p.FULLPLAIN]+"$",D("LOOSEPLAIN"),S[p.LOOSEPLAIN]="[v=\\s]*"+S[p.MAINVERSIONLOOSE]+S[p.PRERELEASELOOSE]+"?"+S[p.BUILD]+"?",D("LOOSE"),S[p.LOOSE]="^"+S[p.LOOSEPLAIN]+"$",D("GTLT"),S[p.GTLT]="((?:<|>)?=?)",D("XRANGEIDENTIFIERLOOSE"),S[p.XRANGEIDENTIFIERLOOSE]=S[p.NUMERICIDENTIFIERLOOSE]+"|x|X|\\*",D("XRANGEIDENTIFIER"),S[p.XRANGEIDENTIFIER]=S[p.NUMERICIDENTIFIER]+"|x|X|\\*",D("XRANGEPLAIN"),S[p.XRANGEPLAIN]="[v=\\s]*("+S[p.XRANGEIDENTIFIER]+")(?:\\.("+S[p.XRANGEIDENTIFIER]+")(?:\\.("+S[p.XRANGEIDENTIFIER]+")(?:"+S[p.PRERELEASE]+")?"+S[p.BUILD]+"?)?)?",D("XRANGEPLAINLOOSE"),S[p.XRANGEPLAINLOOSE]="[v=\\s]*("+S[p.XRANGEIDENTIFIERLOOSE]+")(?:\\.("+S[p.XRANGEIDENTIFIERLOOSE]+")(?:\\.("+S[p.XRANGEIDENTIFIERLOOSE]+")(?:"+S[p.PRERELEASELOOSE]+")?"+S[p.BUILD]+"?)?)?",D("XRANGE"),S[p.XRANGE]="^"+S[p.GTLT]+"\\s*"+S[p.XRANGEPLAIN]+"$",D("XRANGELOOSE"),S[p.XRANGELOOSE]="^"+S[p.GTLT]+"\\s*"+S[p.XRANGEPLAINLOOSE]+"$",D("COERCE"),S[p.COERCE]="(^|[^\\d])(\\d{1,"+C+"})(?:\\.(\\d{1,"+C+"}))?(?:\\.(\\d{1,"+C+"}))?(?:$|[^\\d])",D("COERCERTL"),k[p.COERCERTL]=new RegExp(S[p.COERCE],"g"),w[p.COERCERTL]=new RegExp(Se(S[p.COERCE]),"g"),D("LONETILDE"),S[p.LONETILDE]="(?:~>?)",D("TILDETRIM"),S[p.TILDETRIM]="(\\s*)"+S[p.LONETILDE]+"\\s+",k[p.TILDETRIM]=new RegExp(S[p.TILDETRIM],"g"),w[p.TILDETRIM]=new RegExp(Se(S[p.TILDETRIM]),"g");var Ae="$1~";D("TILDE"),S[p.TILDE]="^"+S[p.LONETILDE]+S[p.XRANGEPLAIN]+"$",D("TILDELOOSE"),S[p.TILDELOOSE]="^"+S[p.LONETILDE]+S[p.XRANGEPLAINLOOSE]+"$",D("LONECARET"),S[p.LONECARET]="(?:\\^)",D("CARETTRIM"),S[p.CARETTRIM]="(\\s*)"+S[p.LONECARET]+"\\s+",k[p.CARETTRIM]=new RegExp(S[p.CARETTRIM],"g"),w[p.CARETTRIM]=new RegExp(Se(S[p.CARETTRIM]),"g");var Le="$1^";D("CARET"),S[p.CARET]="^"+S[p.LONECARET]+S[p.XRANGEPLAIN]+"$",D("CARETLOOSE"),S[p.CARETLOOSE]="^"+S[p.LONECARET]+S[p.XRANGEPLAINLOOSE]+"$",D("COMPARATORLOOSE"),S[p.COMPARATORLOOSE]="^"+S[p.GTLT]+"\\s*("+S[p.LOOSEPLAIN]+")$|^$",D("COMPARATOR"),S[p.COMPARATOR]="^"+S[p.GTLT]+"\\s*("+S[p.FULLPLAIN]+")$|^$",D("COMPARATORTRIM"),S[p.COMPARATORTRIM]="(\\s*)"+S[p.GTLT]+"\\s*("+S[p.LOOSEPLAIN]+"|"+S[p.XRANGEPLAIN]+")",k[p.COMPARATORTRIM]=new RegExp(S[p.COMPARATORTRIM],"g"),w[p.COMPARATORTRIM]=new RegExp(Se(S[p.COMPARATORTRIM]),"g");var v="$1$2$3";D("HYPHENRANGE"),S[p.HYPHENRANGE]="^\\s*("+S[p.XRANGEPLAIN]+")\\s+-\\s+("+S[p.XRANGEPLAIN]+")\\s*$",D("HYPHENRANGELOOSE"),S[p.HYPHENRANGELOOSE]="^\\s*("+S[p.XRANGEPLAINLOOSE]+")\\s+-\\s+("+S[p.XRANGEPLAINLOOSE]+")\\s*$",D("STAR"),S[p.STAR]="(<|>)?=?\\s*\\*";for(var ae=0;ae<Z;ae++)g(ae,S[ae]),k[ae]||(k[ae]=new RegExp(S[ae]),w[ae]=new RegExp(Se(S[ae])));o.parse=pe;function pe(r,s){if((!s||typeof s!="object")&&(s={loose:!!s,includePrerelease:!1}),r instanceof P)return r;if(typeof r!="string"||r.length>N)return null;var l=s.loose?w[p.LOOSE]:w[p.FULL];if(!l.test(r))return null;try{return new P(r,s)}catch{return null}}o.valid=Ce;function Ce(r,s){var l=pe(r,s);return l?l.version:null}o.clean=re;function re(r,s){var l=pe(r.trim().replace(/^[=v]+/,""),s);return l?l.version:null}o.SemVer=P;function P(r,s){if((!s||typeof s!="object")&&(s={loose:!!s,includePrerelease:!1}),r instanceof P){if(r.loose===s.loose)return r;r=r.version}else if(typeof r!="string")throw new TypeError("Invalid Version: "+r);if(r.length>N)throw new TypeError("version is longer than "+N+" characters");if(!(this instanceof P))return new P(r,s);g("SemVer",r,s),this.options=s,this.loose=!!s.loose;var l=r.trim().match(s.loose?w[p.LOOSE]:w[p.FULL]);if(!l)throw new TypeError("Invalid Version: "+r);if(this.raw=r,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>A||this.major<0)throw new TypeError("Invalid major version");if(this.minor>A||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>A||this.patch<0)throw new TypeError("Invalid patch version");l[4]?this.prerelease=l[4].split(".").map(function(I){if(/^[0-9]+$/.test(I)){var y=+I;if(y>=0&&y<A)return y}return I}):this.prerelease=[],this.build=l[5]?l[5].split("."):[],this.format()}P.prototype.format=function(){return this.version=this.major+"."+this.minor+"."+this.patch,this.prerelease.length&&(this.version+="-"+this.prerelease.join(".")),this.version},P.prototype.toString=function(){return this.version},P.prototype.compare=function(r){return g("SemVer.compare",this.version,this.options,r),r instanceof P||(r=new P(r,this.options)),this.compareMain(r)||this.comparePre(r)},P.prototype.compareMain=function(r){return r instanceof P||(r=new P(r,this.options)),h(this.major,r.major)||h(this.minor,r.minor)||h(this.patch,r.patch)},P.prototype.comparePre=function(r){if(r instanceof P||(r=new P(r,this.options)),this.prerelease.length&&!r.prerelease.length)return-1;if(!this.prerelease.length&&r.prerelease.length)return 1;if(!this.prerelease.length&&!r.prerelease.length)return 0;var s=0;do{var l=this.prerelease[s],I=r.prerelease[s];if(g("prerelease compare",s,l,I),l===void 0&&I===void 0)return 0;if(I===void 0)return 1;if(l===void 0)return-1;if(l===I)continue;return h(l,I)}while(++s)},P.prototype.compareBuild=function(r){r instanceof P||(r=new P(r,this.options));var s=0;do{var l=this.build[s],I=r.build[s];if(g("prerelease compare",s,l,I),l===void 0&&I===void 0)return 0;if(I===void 0)return 1;if(l===void 0)return-1;if(l===I)continue;return h(l,I)}while(++s)},P.prototype.inc=function(r,s){switch(r){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",s);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",s);break;case"prepatch":this.prerelease.length=0,this.inc("patch",s),this.inc("pre",s);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",s),this.inc("pre",s);break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{for(var l=this.prerelease.length;--l>=0;)typeof this.prerelease[l]=="number"&&(this.prerelease[l]++,l=-2);l===-1&&this.prerelease.push(0)}s&&(this.prerelease[0]===s?isNaN(this.prerelease[1])&&(this.prerelease=[s,0]):this.prerelease=[s,0]);break;default:throw new Error("invalid increment argument: "+r)}return this.format(),this.raw=this.version,this},o.inc=n;function n(r,s,l,I){typeof l=="string"&&(I=l,l=void 0);try{return new P(r,l).inc(s,I).version}catch{return null}}o.diff=i;function i(r,s){if(X(r,s))return null;var l=pe(r),I=pe(s),y="";if(l.prerelease.length||I.prerelease.length){y="pre";var R="prerelease"}for(var O in l)if((O==="major"||O==="minor"||O==="patch")&&l[O]!==I[O])return y+O;return R}o.compareIdentifiers=h;var a=/^[0-9]+$/;function h(r,s){var l=a.test(r),I=a.test(s);return l&&I&&(r=+r,s=+s),r===s?0:l&&!I?-1:I&&!l?1:r<s?-1:1}o.rcompareIdentifiers=u;function u(r,s){return h(s,r)}o.major=m;function m(r,s){return new P(r,s).major}o.minor=z;function z(r,s){return new P(r,s).minor}o.patch=c;function c(r,s){return new P(r,s).patch}o.compare=f;function f(r,s,l){return new P(r,l).compare(new P(s,l))}o.compareLoose=E;function E(r,s){return f(r,s,!0)}o.compareBuild=d;function d(r,s,l){var I=new P(r,l),y=new P(s,l);return I.compare(y)||I.compareBuild(y)}o.rcompare=T;function T(r,s,l){return f(s,r,l)}o.sort=_;function _(r,s){return r.sort(function(l,I){return o.compareBuild(l,I,s)})}o.rsort=L;function L(r,s){return r.sort(function(l,I){return o.compareBuild(I,l,s)})}o.gt=F;function F(r,s,l){return f(r,s,l)>0}o.lt=$;function $(r,s,l){return f(r,s,l)<0}o.eq=X;function X(r,s,l){return f(r,s,l)===0}o.neq=B;function B(r,s,l){return f(r,s,l)!==0}o.gte=V;function V(r,s,l){return f(r,s,l)>=0}o.lte=K;function K(r,s,l){return f(r,s,l)<=0}o.cmp=Ie;function Ie(r,s,l,I){switch(s){case"===":return typeof r=="object"&&(r=r.version),typeof l=="object"&&(l=l.version),r===l;case"!==":return typeof r=="object"&&(r=r.version),typeof l=="object"&&(l=l.version),r!==l;case"":case"=":case"==":return X(r,l,I);case"!=":return B(r,l,I);case">":return F(r,l,I);case">=":return V(r,l,I);case"<":return $(r,l,I);case"<=":return K(r,l,I);default:throw new TypeError("Invalid operator: "+s)}}o.Comparator=ee;function ee(r,s){if((!s||typeof s!="object")&&(s={loose:!!s,includePrerelease:!1}),r instanceof ee){if(r.loose===!!s.loose)return r;r=r.value}if(!(this instanceof ee))return new ee(r,s);r=r.trim().split(/\s+/).join(" "),g("comparator",r,s),this.options=s,this.loose=!!s.loose,this.parse(r),this.semver===Ee?this.value="":this.value=this.operator+this.semver.version,g("comp",this)}var Ee={};ee.prototype.parse=function(r){var s=this.options.loose?w[p.COMPARATORLOOSE]:w[p.COMPARATOR],l=r.match(s);if(!l)throw new TypeError("Invalid comparator: "+r);this.operator=l[1]!==void 0?l[1]:"",this.operator==="="&&(this.operator=""),l[2]?this.semver=new P(l[2],this.options.loose):this.semver=Ee},ee.prototype.toString=function(){return this.value},ee.prototype.test=function(r){if(g("Comparator.test",r,this.options.loose),this.semver===Ee||r===Ee)return!0;if(typeof r=="string")try{r=new P(r,this.options)}catch{return!1}return Ie(r,this.operator,this.semver,this.options)},ee.prototype.intersects=function(r,s){if(!(r instanceof ee))throw new TypeError("a Comparator is required");(!s||typeof s!="object")&&(s={loose:!!s,includePrerelease:!1});var l;if(this.operator==="")return this.value===""?!0:(l=new M(r.value,s),Me(this.value,l,s));if(r.operator==="")return r.value===""?!0:(l=new M(this.value,s),Me(r.semver,l,s));var I=(this.operator===">="||this.operator===">")&&(r.operator===">="||r.operator===">"),y=(this.operator==="<="||this.operator==="<")&&(r.operator==="<="||r.operator==="<"),R=this.semver.version===r.semver.version,O=(this.operator===">="||this.operator==="<=")&&(r.operator===">="||r.operator==="<="),G=Ie(this.semver,"<",r.semver,s)&&(this.operator===">="||this.operator===">")&&(r.operator==="<="||r.operator==="<"),U=Ie(this.semver,">",r.semver,s)&&(this.operator==="<="||this.operator==="<")&&(r.operator===">="||r.operator===">");return I||y||R&&O||G||U},o.Range=M;function M(r,s){if((!s||typeof s!="object")&&(s={loose:!!s,includePrerelease:!1}),r instanceof M)return r.loose===!!s.loose&&r.includePrerelease===!!s.includePrerelease?r:new M(r.raw,s);if(r instanceof ee)return new M(r.value,s);if(!(this instanceof M))return new M(r,s);if(this.options=s,this.loose=!!s.loose,this.includePrerelease=!!s.includePrerelease,this.raw=r.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map(function(l){return this.parseRange(l.trim())},this).filter(function(l){return l.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+this.raw);this.format()}M.prototype.format=function(){return this.range=this.set.map(function(r){return r.join(" ").trim()}).join("||").trim(),this.range},M.prototype.toString=function(){return this.range},M.prototype.parseRange=function(r){var s=this.options.loose,l=s?w[p.HYPHENRANGELOOSE]:w[p.HYPHENRANGE];r=r.replace(l,bn),g("hyphen replace",r),r=r.replace(w[p.COMPARATORTRIM],v),g("comparator trim",r,w[p.COMPARATORTRIM]),r=r.replace(w[p.TILDETRIM],Ae),r=r.replace(w[p.CARETTRIM],Le),r=r.split(/\s+/).join(" ");var I=s?w[p.COMPARATORLOOSE]:w[p.COMPARATOR],y=r.split(" ").map(function(R){return Q(R,this.options)},this).join(" ").split(/\s+/);return this.options.loose&&(y=y.filter(function(R){return!!R.match(I)})),y=y.map(function(R){return new ee(R,this.options)},this),y},M.prototype.intersects=function(r,s){if(!(r instanceof M))throw new TypeError("a Range is required");return this.set.some(function(l){return Ne(l,s)&&r.set.some(function(I){return Ne(I,s)&&l.every(function(y){return I.every(function(R){return y.intersects(R,s)})})})})};function Ne(r,s){for(var l=!0,I=r.slice(),y=I.pop();l&&I.length;)l=I.every(function(R){return y.intersects(R,s)}),y=I.pop();return l}o.toComparators=ne;function ne(r,s){return new M(r,s).set.map(function(l){return l.map(function(I){return I.value}).join(" ").trim().split(" ")})}function Q(r,s){return g("comp",r,s),r=Nn(r,s),g("caret",r),r=In(r,s),g("tildes",r),r=vn(r,s),g("xrange",r),r=On(r,s),g("stars",r),r}function x(r){return!r||r.toLowerCase()==="x"||r==="*"}function In(r,s){return r.trim().split(/\s+/).map(function(l){return Tn(l,s)}).join(" ")}function Tn(r,s){var l=s.loose?w[p.TILDELOOSE]:w[p.TILDE];return r.replace(l,function(I,y,R,O,G){g("tilde",r,I,y,R,O,G);var U;return x(y)?U="":x(R)?U=">="+y+".0.0 <"+(+y+1)+".0.0":x(O)?U=">="+y+"."+R+".0 <"+y+"."+(+R+1)+".0":G?(g("replaceTilde pr",G),U=">="+y+"."+R+"."+O+"-"+G+" <"+y+"."+(+R+1)+".0"):U=">="+y+"."+R+"."+O+" <"+y+"."+(+R+1)+".0",g("tilde return",U),U})}function Nn(r,s){return r.trim().split(/\s+/).map(function(l){return yn(l,s)}).join(" ")}function yn(r,s){g("caret",r,s);var l=s.loose?w[p.CARETLOOSE]:w[p.CARET];return r.replace(l,function(I,y,R,O,G){g("caret",r,I,y,R,O,G);var U;return x(y)?U="":x(R)?U=">="+y+".0.0 <"+(+y+1)+".0.0":x(O)?y==="0"?U=">="+y+"."+R+".0 <"+y+"."+(+R+1)+".0":U=">="+y+"."+R+".0 <"+(+y+1)+".0.0":G?(g("replaceCaret pr",G),y==="0"?R==="0"?U=">="+y+"."+R+"."+O+"-"+G+" <"+y+"."+R+"."+(+O+1):U=">="+y+"."+R+"."+O+"-"+G+" <"+y+"."+(+R+1)+".0":U=">="+y+"."+R+"."+O+"-"+G+" <"+(+y+1)+".0.0"):(g("no pr"),y==="0"?R==="0"?U=">="+y+"."+R+"."+O+" <"+y+"."+R+"."+(+O+1):U=">="+y+"."+R+"."+O+" <"+y+"."+(+R+1)+".0":U=">="+y+"."+R+"."+O+" <"+(+y+1)+".0.0"),g("caret return",U),U})}function vn(r,s){return g("replaceXRanges",r,s),r.split(/\s+/).map(function(l){return Rn(l,s)}).join(" ")}function Rn(r,s){r=r.trim();var l=s.loose?w[p.XRANGELOOSE]:w[p.XRANGE];return r.replace(l,function(I,y,R,O,G,U){g("xRange",r,I,y,R,O,G,U);var ge=x(R),ze=ge||x(O),oe=ze||x(G),se=oe;return y==="="&&se&&(y=""),U=s.includePrerelease?"-0":"",ge?y===">"||y==="<"?I="<0.0.0-0":I="*":y&&se?(ze&&(O=0),G=0,y===">"?(y=">=",ze?(R=+R+1,O=0,G=0):(O=+O+1,G=0)):y==="<="&&(y="<",ze?R=+R+1:O=+O+1),I=y+R+"."+O+"."+G+U):ze?I=">="+R+".0.0"+U+" <"+(+R+1)+".0.0"+U:oe&&(I=">="+R+"."+O+".0"+U+" <"+R+"."+(+O+1)+".0"+U),g("xRange return",I),I})}function On(r,s){return g("replaceStars",r,s),r.trim().replace(w[p.STAR],"")}function bn(r,s,l,I,y,R,O,G,U,ge,ze,oe,se){return x(l)?s="":x(I)?s=">="+l+".0.0":x(y)?s=">="+l+"."+I+".0":s=">="+s,x(U)?G="":x(ge)?G="<"+(+U+1)+".0.0":x(ze)?G="<"+U+"."+(+ge+1)+".0":oe?G="<="+U+"."+ge+"."+ze+"-"+oe:G="<="+G,(s+" "+G).trim()}M.prototype.test=function(r){if(!r)return!1;if(typeof r=="string")try{r=new P(r,this.options)}catch{return!1}for(var s=0;s<this.set.length;s++)if(_n(this.set[s],r,this.options))return!0;return!1};function _n(r,s,l){for(var I=0;I<r.length;I++)if(!r[I].test(s))return!1;if(s.prerelease.length&&!l.includePrerelease){for(I=0;I<r.length;I++)if(g(r[I].semver),r[I].semver!==Ee&&r[I].semver.prerelease.length>0){var y=r[I].semver;if(y.major===s.major&&y.minor===s.minor&&y.patch===s.patch)return!0}return!1}return!0}o.satisfies=Me;function Me(r,s,l){try{s=new M(s,l)}catch{return!1}return s.test(r)}o.maxSatisfying=wn;function wn(r,s,l){var I=null,y=null;try{var R=new M(s,l)}catch{return null}return r.forEach(function(O){R.test(O)&&(!I||y.compare(O)===-1)&&(I=O,y=new P(I,l))}),I}o.minSatisfying=Ln;function Ln(r,s,l){var I=null,y=null;try{var R=new M(s,l)}catch{return null}return r.forEach(function(O){R.test(O)&&(!I||y.compare(O)===1)&&(I=O,y=new P(I,l))}),I}o.minVersion=Cn;function Cn(r,s){r=new M(r,s);var l=new P("0.0.0");if(r.test(l)||(l=new P("0.0.0-0"),r.test(l)))return l;l=null;for(var I=0;I<r.set.length;++I){var y=r.set[I];y.forEach(function(R){var O=new P(R.semver.version);switch(R.operator){case">":O.prerelease.length===0?O.patch++:O.prerelease.push(0),O.raw=O.format();case"":case">=":(!l||F(l,O))&&(l=O);break;case"<":case"<=":break;default:throw new Error("Unexpected operation: "+R.operator)}})}return l&&r.test(l)?l:null}o.validRange=Dn;function Dn(r,s){try{return new M(r,s).range||"*"}catch{return null}}o.ltr=Pn;function Pn(r,s,l){return rt(r,s,"<",l)}o.gtr=kn;function kn(r,s,l){return rt(r,s,">",l)}o.outside=rt;function rt(r,s,l,I){r=new P(r,I),s=new M(s,I);var y,R,O,G,U;switch(l){case">":y=F,R=K,O=$,G=">",U=">=";break;case"<":y=$,R=V,O=F,G="<",U="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(Me(r,s,I))return!1;for(var ge=0;ge<s.set.length;++ge){var ze=s.set[ge],oe=null,se=null;if(ze.forEach(function(ye){ye.semver===Ee&&(ye=new ee(">=0.0.0")),oe=oe||ye,se=se||ye,y(ye.semver,oe.semver,I)?oe=ye:O(ye.semver,se.semver,I)&&(se=ye)}),oe.operator===G||oe.operator===U||(!se.operator||se.operator===G)&&R(r,se.semver))return!1;if(se.operator===U&&O(r,se.semver))return!1}return!0}o.prerelease=jn;function jn(r,s){var l=pe(r,s);return l&&l.prerelease.length?l.prerelease:null}o.intersects=Un;function Un(r,s,l){return r=new M(r,l),s=new M(s,l),r.intersects(s)}o.coerce=Fn;function Fn(r,s){if(r instanceof P)return r;if(typeof r=="number"&&(r=String(r)),typeof r!="string")return null;s=s||{};var l=null;if(!s.rtl)l=r.match(w[p.COERCE]);else{for(var I;(I=w[p.COERCERTL].exec(r))&&(!l||l.index+l[0].length!==r.length);)(!l||I.index+I[0].length!==l.index+l[0].length)&&(l=I),w[p.COERCERTL].lastIndex=I.index+I[1].length+I[2].length;w[p.COERCERTL].lastIndex=-1}return l===null?null:pe(l[2]+"."+(l[3]||"0")+"."+(l[4]||"0"),s)}})(mt,mt.exports);var Oi=mt.exports;const bi=pr(Oi),_i=t=>t==null?[]:Array.isArray(t)?t:[t],wi=e.z.any().refine(t=>typeof t=="bigint",{message:"Value must be a BigInt"}).transform(t=>BigInt(t));var Li=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,nt=Math.ceil,le=Math.floor,ie="[BigNumber Error] ",Vt=ie+"Number primitive has more than 15 significant digits: ",de=1e14,j=14,it=9007199254740991,at=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],ve=1e7,J=1e9;function Er(t){var o,g,N,A=v.prototype={constructor:v,toString:null,valueOf:null},C=new v(1),b=20,k=4,w=-7,S=21,p=-1e7,Z=1e7,D=!1,he=1,te=0,Se={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},Ae="0123456789abcdefghijklmnopqrstuvwxyz",Le=!0;function v(n,i){var a,h,u,m,z,c,f,E,d=this;if(!(d instanceof v))return new v(n,i);if(i==null){if(n&&n._isBigNumber===!0){d.s=n.s,!n.c||n.e>Z?d.c=d.e=null:n.e<p?d.c=[d.e=0]:(d.e=n.e,d.c=n.c.slice());return}if((c=typeof n=="number")&&n*0==0){if(d.s=1/n<0?(n=-n,-1):1,n===~~n){for(m=0,z=n;z>=10;z/=10,m++);m>Z?d.c=d.e=null:(d.e=m,d.c=[n]);return}E=String(n)}else{if(!Li.test(E=String(n)))return N(d,E,c);d.s=E.charCodeAt(0)==45?(E=E.slice(1),-1):1}(m=E.indexOf("."))>-1&&(E=E.replace(".","")),(z=E.search(/e/i))>0?(m<0&&(m=z),m+=+E.slice(z+1),E=E.substring(0,z)):m<0&&(m=E.length)}else{if(q(i,2,Ae.length,"Base"),i==10&&Le)return d=new v(n),re(d,b+d.e+1,k);if(E=String(n),c=typeof n=="number"){if(n*0!=0)return N(d,E,c,i);if(d.s=1/n<0?(E=E.slice(1),-1):1,v.DEBUG&&E.replace(/^0\.0*|\./,"").length>15)throw Error(Vt+n)}else d.s=E.charCodeAt(0)===45?(E=E.slice(1),-1):1;for(a=Ae.slice(0,i),m=z=0,f=E.length;z<f;z++)if(a.indexOf(h=E.charAt(z))<0){if(h=="."){if(z>m){m=f;continue}}else if(!u&&(E==E.toUpperCase()&&(E=E.toLowerCase())||E==E.toLowerCase()&&(E=E.toUpperCase()))){u=!0,z=-1,m=0;continue}return N(d,String(n),c,i)}c=!1,E=g(E,i,10,d.s),(m=E.indexOf("."))>-1?E=E.replace(".",""):m=E.length}for(z=0;E.charCodeAt(z)===48;z++);for(f=E.length;E.charCodeAt(--f)===48;);if(E=E.slice(z,++f)){if(f-=z,c&&v.DEBUG&&f>15&&(n>it||n!==le(n)))throw Error(Vt+d.s*n);if((m=m-z-1)>Z)d.c=d.e=null;else if(m<p)d.c=[d.e=0];else{if(d.e=m,d.c=[],z=(m+1)%j,m<0&&(z+=j),z<f){for(z&&d.c.push(+E.slice(0,z)),f-=j;z<f;)d.c.push(+E.slice(z,z+=j));z=j-(E=E.slice(z)).length}else z-=f;for(;z--;E+="0");d.c.push(+E)}}else d.c=[d.e=0]}v.clone=Er,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(n){var i,a;if(n!=null)if(typeof n=="object"){if(n.hasOwnProperty(i="DECIMAL_PLACES")&&(a=n[i],q(a,0,J,i),b=a),n.hasOwnProperty(i="ROUNDING_MODE")&&(a=n[i],q(a,0,8,i),k=a),n.hasOwnProperty(i="EXPONENTIAL_AT")&&(a=n[i],a&&a.pop?(q(a[0],-J,0,i),q(a[1],0,J,i),w=a[0],S=a[1]):(q(a,-J,J,i),w=-(S=a<0?-a:a))),n.hasOwnProperty(i="RANGE"))if(a=n[i],a&&a.pop)q(a[0],-J,-1,i),q(a[1],1,J,i),p=a[0],Z=a[1];else if(q(a,-J,J,i),a)p=-(Z=a<0?-a:a);else throw Error(ie+i+" cannot be zero: "+a);if(n.hasOwnProperty(i="CRYPTO"))if(a=n[i],a===!!a)if(a)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))D=a;else throw D=!a,Error(ie+"crypto unavailable");else D=a;else throw Error(ie+i+" not true or false: "+a);if(n.hasOwnProperty(i="MODULO_MODE")&&(a=n[i],q(a,0,9,i),he=a),n.hasOwnProperty(i="POW_PRECISION")&&(a=n[i],q(a,0,J,i),te=a),n.hasOwnProperty(i="FORMAT"))if(a=n[i],typeof a=="object")Se=a;else throw Error(ie+i+" not an object: "+a);if(n.hasOwnProperty(i="ALPHABET"))if(a=n[i],typeof a=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(a))Le=a.slice(0,10)=="0123456789",Ae=a;else throw Error(ie+i+" invalid: "+a)}else throw Error(ie+"Object expected: "+n);return{DECIMAL_PLACES:b,ROUNDING_MODE:k,EXPONENTIAL_AT:[w,S],RANGE:[p,Z],CRYPTO:D,MODULO_MODE:he,POW_PRECISION:te,FORMAT:Se,ALPHABET:Ae}},v.isBigNumber=function(n){if(!n||n._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var i,a,h=n.c,u=n.e,m=n.s;e:if({}.toString.call(h)=="[object Array]"){if((m===1||m===-1)&&u>=-J&&u<=J&&u===le(u)){if(h[0]===0){if(u===0&&h.length===1)return!0;break e}if(i=(u+1)%j,i<1&&(i+=j),String(h[0]).length==i){for(i=0;i<h.length;i++)if(a=h[i],a<0||a>=de||a!==le(a))break e;if(a!==0)return!0}}}else if(h===null&&u===null&&(m===null||m===1||m===-1))return!0;throw Error(ie+"Invalid BigNumber: "+n)},v.maximum=v.max=function(){return pe(arguments,-1)},v.minimum=v.min=function(){return pe(arguments,1)},v.random=function(){var n=9007199254740992,i=Math.random()*n&2097151?function(){return le(Math.random()*n)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(a){var h,u,m,z,c,f=0,E=[],d=new v(C);if(a==null?a=b:q(a,0,J),z=nt(a/j),D)if(crypto.getRandomValues){for(h=crypto.getRandomValues(new Uint32Array(z*=2));f<z;)c=h[f]*131072+(h[f+1]>>>11),c>=9e15?(u=crypto.getRandomValues(new Uint32Array(2)),h[f]=u[0],h[f+1]=u[1]):(E.push(c%1e14),f+=2);f=z/2}else if(crypto.randomBytes){for(h=crypto.randomBytes(z*=7);f<z;)c=(h[f]&31)*281474976710656+h[f+1]*1099511627776+h[f+2]*4294967296+h[f+3]*16777216+(h[f+4]<<16)+(h[f+5]<<8)+h[f+6],c>=9e15?crypto.randomBytes(7).copy(h,f):(E.push(c%1e14),f+=7);f=z/7}else throw D=!1,Error(ie+"crypto unavailable");if(!D)for(;f<z;)c=i(),c<9e15&&(E[f++]=c%1e14);for(z=E[--f],a%=j,z&&a&&(c=at[j-a],E[f]=le(z/c)*c);E[f]===0;E.pop(),f--);if(f<0)E=[m=0];else{for(m=-1;E[0]===0;E.splice(0,1),m-=j);for(f=1,c=E[0];c>=10;c/=10,f++);f<j&&(m-=j-f)}return d.e=m,d.c=E,d}}(),v.sum=function(){for(var n=1,i=arguments,a=new v(i[0]);n<i.length;)a=a.plus(i[n++]);return a},g=function(){var n="0123456789";function i(a,h,u,m){for(var z,c=[0],f,E=0,d=a.length;E<d;){for(f=c.length;f--;c[f]*=h);for(c[0]+=m.indexOf(a.charAt(E++)),z=0;z<c.length;z++)c[z]>u-1&&(c[z+1]==null&&(c[z+1]=0),c[z+1]+=c[z]/u|0,c[z]%=u)}return c.reverse()}return function(a,h,u,m,z){var c,f,E,d,T,_,L,F,$=a.indexOf("."),X=b,B=k;for($>=0&&(d=te,te=0,a=a.replace(".",""),F=new v(h),_=F.pow(a.length-$),te=d,F.c=i(Te(ce(_.c),_.e,"0"),10,u,n),F.e=F.c.length),L=i(a,h,u,z?(c=Ae,n):(c=n,Ae)),E=d=L.length;L[--d]==0;L.pop());if(!L[0])return c.charAt(0);if($<0?--E:(_.c=L,_.e=E,_.s=m,_=o(_,F,X,B,u),L=_.c,T=_.r,E=_.e),f=E+X+1,$=L[f],d=u/2,T=T||f<0||L[f+1]!=null,T=B<4?($!=null||T)&&(B==0||B==(_.s<0?3:2)):$>d||$==d&&(B==4||T||B==6&&L[f-1]&1||B==(_.s<0?8:7)),f<1||!L[0])a=T?Te(c.charAt(1),-X,c.charAt(0)):c.charAt(0);else{if(L.length=f,T)for(--u;++L[--f]>u;)L[f]=0,f||(++E,L=[1].concat(L));for(d=L.length;!L[--d];);for($=0,a="";$<=d;a+=c.charAt(L[$++]));a=Te(a,E,c.charAt(0))}return a}}(),o=function(){function n(h,u,m){var z,c,f,E,d=0,T=h.length,_=u%ve,L=u/ve|0;for(h=h.slice();T--;)f=h[T]%ve,E=h[T]/ve|0,z=L*f+E*_,c=_*f+z%ve*ve+d,d=(c/m|0)+(z/ve|0)+L*E,h[T]=c%m;return d&&(h=[d].concat(h)),h}function i(h,u,m,z){var c,f;if(m!=z)f=m>z?1:-1;else for(c=f=0;c<m;c++)if(h[c]!=u[c]){f=h[c]>u[c]?1:-1;break}return f}function a(h,u,m,z){for(var c=0;m--;)h[m]-=c,c=h[m]<u[m]?1:0,h[m]=c*z+h[m]-u[m];for(;!h[0]&&h.length>1;h.splice(0,1));}return function(h,u,m,z,c){var f,E,d,T,_,L,F,$,X,B,V,K,Ie,ee,Ee,M,Ne,ne=h.s==u.s?1:-1,Q=h.c,x=u.c;if(!Q||!Q[0]||!x||!x[0])return new v(!h.s||!u.s||(Q?x&&Q[0]==x[0]:!x)?NaN:Q&&Q[0]==0||!x?ne*0:ne/0);for($=new v(ne),X=$.c=[],E=h.e-u.e,ne=m+E+1,c||(c=de,E=ue(h.e/j)-ue(u.e/j),ne=ne/j|0),d=0;x[d]==(Q[d]||0);d++);if(x[d]>(Q[d]||0)&&E--,ne<0)X.push(1),T=!0;else{for(ee=Q.length,M=x.length,d=0,ne+=2,_=le(c/(x[0]+1)),_>1&&(x=n(x,_,c),Q=n(Q,_,c),M=x.length,ee=Q.length),Ie=M,B=Q.slice(0,M),V=B.length;V<M;B[V++]=0);Ne=x.slice(),Ne=[0].concat(Ne),Ee=x[0],x[1]>=c/2&&Ee++;do{if(_=0,f=i(x,B,M,V),f<0){if(K=B[0],M!=V&&(K=K*c+(B[1]||0)),_=le(K/Ee),_>1)for(_>=c&&(_=c-1),L=n(x,_,c),F=L.length,V=B.length;i(L,B,F,V)==1;)_--,a(L,M<F?Ne:x,F,c),F=L.length,f=1;else _==0&&(f=_=1),L=x.slice(),F=L.length;if(F<V&&(L=[0].concat(L)),a(B,L,V,c),V=B.length,f==-1)for(;i(x,B,M,V)<1;)_++,a(B,M<V?Ne:x,V,c),V=B.length}else f===0&&(_++,B=[0]);X[d++]=_,B[0]?B[V++]=Q[Ie]||0:(B=[Q[Ie]],V=1)}while((Ie++<ee||B[0]!=null)&&ne--);T=B[0]!=null,X[0]||X.splice(0,1)}if(c==de){for(d=1,ne=X[0];ne>=10;ne/=10,d++);re($,m+($.e=d+E*j-1)+1,z,T)}else $.e=E,$.r=+T;return $}}();function ae(n,i,a,h){var u,m,z,c,f;if(a==null?a=k:q(a,0,8),!n.c)return n.toString();if(u=n.c[0],z=n.e,i==null)f=ce(n.c),f=h==1||h==2&&(z<=w||z>=S)?Ve(f,z):Te(f,z,"0");else if(n=re(new v(n),i,a),m=n.e,f=ce(n.c),c=f.length,h==1||h==2&&(i<=m||m<=w)){for(;c<i;f+="0",c++);f=Ve(f,m)}else if(i-=z,f=Te(f,m,"0"),m+1>c){if(--i>0)for(f+=".";i--;f+="0");}else if(i+=m-c,i>0)for(m+1==c&&(f+=".");i--;f+="0");return n.s<0&&u?"-"+f:f}function pe(n,i){for(var a,h,u=1,m=new v(n[0]);u<n.length;u++)h=new v(n[u]),(!h.s||(a=be(m,h))===i||a===0&&m.s===i)&&(m=h);return m}function Ce(n,i,a){for(var h=1,u=i.length;!i[--u];i.pop());for(u=i[0];u>=10;u/=10,h++);return(a=h+a*j-1)>Z?n.c=n.e=null:a<p?n.c=[n.e=0]:(n.e=a,n.c=i),n}N=function(){var n=/^(-?)0([xbo])(?=\w[\w.]*$)/i,i=/^([^.]+)\.$/,a=/^\.([^.]+)$/,h=/^-?(Infinity|NaN)$/,u=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(m,z,c,f){var E,d=c?z:z.replace(u,"");if(h.test(d))m.s=isNaN(d)?null:d<0?-1:1;else{if(!c&&(d=d.replace(n,function(T,_,L){return E=(L=L.toLowerCase())=="x"?16:L=="b"?2:8,!f||f==E?_:T}),f&&(E=f,d=d.replace(i,"$1").replace(a,"0.$1")),z!=d))return new v(d,E);if(v.DEBUG)throw Error(ie+"Not a"+(f?" base "+f:"")+" number: "+z);m.s=null}m.c=m.e=null}}();function re(n,i,a,h){var u,m,z,c,f,E,d,T=n.c,_=at;if(T){e:{for(u=1,c=T[0];c>=10;c/=10,u++);if(m=i-u,m<0)m+=j,z=i,f=T[E=0],d=le(f/_[u-z-1]%10);else if(E=nt((m+1)/j),E>=T.length)if(h){for(;T.length<=E;T.push(0));f=d=0,u=1,m%=j,z=m-j+1}else break e;else{for(f=c=T[E],u=1;c>=10;c/=10,u++);m%=j,z=m-j+u,d=z<0?0:le(f/_[u-z-1]%10)}if(h=h||i<0||T[E+1]!=null||(z<0?f:f%_[u-z-1]),h=a<4?(d||h)&&(a==0||a==(n.s<0?3:2)):d>5||d==5&&(a==4||h||a==6&&(m>0?z>0?f/_[u-z]:0:T[E-1])%10&1||a==(n.s<0?8:7)),i<1||!T[0])return T.length=0,h?(i-=n.e+1,T[0]=_[(j-i%j)%j],n.e=-i||0):T[0]=n.e=0,n;if(m==0?(T.length=E,c=1,E--):(T.length=E+1,c=_[j-m],T[E]=z>0?le(f/_[u-z]%_[z])*c:0),h)for(;;)if(E==0){for(m=1,z=T[0];z>=10;z/=10,m++);for(z=T[0]+=c,c=1;z>=10;z/=10,c++);m!=c&&(n.e++,T[0]==de&&(T[0]=1));break}else{if(T[E]+=c,T[E]!=de)break;T[E--]=0,c=1}for(m=T.length;T[--m]===0;T.pop());}n.e>Z?n.c=n.e=null:n.e<p&&(n.c=[n.e=0])}return n}function P(n){var i,a=n.e;return a===null?n.toString():(i=ce(n.c),i=a<=w||a>=S?Ve(i,a):Te(i,a,"0"),n.s<0?"-"+i:i)}return A.absoluteValue=A.abs=function(){var n=new v(this);return n.s<0&&(n.s=1),n},A.comparedTo=function(n,i){return be(this,new v(n,i))},A.decimalPlaces=A.dp=function(n,i){var a,h,u,m=this;if(n!=null)return q(n,0,J),i==null?i=k:q(i,0,8),re(new v(m),n+m.e+1,i);if(!(a=m.c))return null;if(h=((u=a.length-1)-ue(this.e/j))*j,u=a[u])for(;u%10==0;u/=10,h--);return h<0&&(h=0),h},A.dividedBy=A.div=function(n,i){return o(this,new v(n,i),b,k)},A.dividedToIntegerBy=A.idiv=function(n,i){return o(this,new v(n,i),0,1)},A.exponentiatedBy=A.pow=function(n,i){var a,h,u,m,z,c,f,E,d,T=this;if(n=new v(n),n.c&&!n.isInteger())throw Error(ie+"Exponent not an integer: "+P(n));if(i!=null&&(i=new v(i)),c=n.e>14,!T.c||!T.c[0]||T.c[0]==1&&!T.e&&T.c.length==1||!n.c||!n.c[0])return d=new v(Math.pow(+P(T),c?n.s*(2-Ge(n)):+P(n))),i?d.mod(i):d;if(f=n.s<0,i){if(i.c?!i.c[0]:!i.s)return new v(NaN);h=!f&&T.isInteger()&&i.isInteger(),h&&(T=T.mod(i))}else{if(n.e>9&&(T.e>0||T.e<-1||(T.e==0?T.c[0]>1||c&&T.c[1]>=24e7:T.c[0]<8e13||c&&T.c[0]<=9999975e7)))return m=T.s<0&&Ge(n)?-0:0,T.e>-1&&(m=1/m),new v(f?1/m:m);te&&(m=nt(te/j+2))}for(c?(a=new v(.5),f&&(n.s=1),E=Ge(n)):(u=Math.abs(+P(n)),E=u%2),d=new v(C);;){if(E){if(d=d.times(T),!d.c)break;m?d.c.length>m&&(d.c.length=m):h&&(d=d.mod(i))}if(u){if(u=le(u/2),u===0)break;E=u%2}else if(n=n.times(a),re(n,n.e+1,1),n.e>14)E=Ge(n);else{if(u=+P(n),u===0)break;E=u%2}T=T.times(T),m?T.c&&T.c.length>m&&(T.c.length=m):h&&(T=T.mod(i))}return h?d:(f&&(d=C.div(d)),i?d.mod(i):m?re(d,te,k,z):d)},A.integerValue=function(n){var i=new v(this);return n==null?n=k:q(n,0,8),re(i,i.e+1,n)},A.isEqualTo=A.eq=function(n,i){return be(this,new v(n,i))===0},A.isFinite=function(){return!!this.c},A.isGreaterThan=A.gt=function(n,i){return be(this,new v(n,i))>0},A.isGreaterThanOrEqualTo=A.gte=function(n,i){return(i=be(this,new v(n,i)))===1||i===0},A.isInteger=function(){return!!this.c&&ue(this.e/j)>this.c.length-2},A.isLessThan=A.lt=function(n,i){return be(this,new v(n,i))<0},A.isLessThanOrEqualTo=A.lte=function(n,i){return(i=be(this,new v(n,i)))===-1||i===0},A.isNaN=function(){return!this.s},A.isNegative=function(){return this.s<0},A.isPositive=function(){return this.s>0},A.isZero=function(){return!!this.c&&this.c[0]==0},A.minus=function(n,i){var a,h,u,m,z=this,c=z.s;if(n=new v(n,i),i=n.s,!c||!i)return new v(NaN);if(c!=i)return n.s=-i,z.plus(n);var f=z.e/j,E=n.e/j,d=z.c,T=n.c;if(!f||!E){if(!d||!T)return d?(n.s=-i,n):new v(T?z:NaN);if(!d[0]||!T[0])return T[0]?(n.s=-i,n):new v(d[0]?z:k==3?-0:0)}if(f=ue(f),E=ue(E),d=d.slice(),c=f-E){for((m=c<0)?(c=-c,u=d):(E=f,u=T),u.reverse(),i=c;i--;u.push(0));u.reverse()}else for(h=(m=(c=d.length)<(i=T.length))?c:i,c=i=0;i<h;i++)if(d[i]!=T[i]){m=d[i]<T[i];break}if(m&&(u=d,d=T,T=u,n.s=-n.s),i=(h=T.length)-(a=d.length),i>0)for(;i--;d[a++]=0);for(i=de-1;h>c;){if(d[--h]<T[h]){for(a=h;a&&!d[--a];d[a]=i);--d[a],d[h]+=de}d[h]-=T[h]}for(;d[0]==0;d.splice(0,1),--E);return d[0]?Ce(n,d,E):(n.s=k==3?-1:1,n.c=[n.e=0],n)},A.modulo=A.mod=function(n,i){var a,h,u=this;return n=new v(n,i),!u.c||!n.s||n.c&&!n.c[0]?new v(NaN):!n.c||u.c&&!u.c[0]?new v(u):(he==9?(h=n.s,n.s=1,a=o(u,n,0,3),n.s=h,a.s*=h):a=o(u,n,0,he),n=u.minus(a.times(n)),!n.c[0]&&he==1&&(n.s=u.s),n)},A.multipliedBy=A.times=function(n,i){var a,h,u,m,z,c,f,E,d,T,_,L,F,$,X,B=this,V=B.c,K=(n=new v(n,i)).c;if(!V||!K||!V[0]||!K[0])return!B.s||!n.s||V&&!V[0]&&!K||K&&!K[0]&&!V?n.c=n.e=n.s=null:(n.s*=B.s,!V||!K?n.c=n.e=null:(n.c=[0],n.e=0)),n;for(h=ue(B.e/j)+ue(n.e/j),n.s*=B.s,f=V.length,T=K.length,f<T&&(F=V,V=K,K=F,u=f,f=T,T=u),u=f+T,F=[];u--;F.push(0));for($=de,X=ve,u=T;--u>=0;){for(a=0,_=K[u]%X,L=K[u]/X|0,z=f,m=u+z;m>u;)E=V[--z]%X,d=V[z]/X|0,c=L*E+d*_,E=_*E+c%X*X+F[m]+a,a=(E/$|0)+(c/X|0)+L*d,F[m--]=E%$;F[m]=a}return a?++h:F.splice(0,1),Ce(n,F,h)},A.negated=function(){var n=new v(this);return n.s=-n.s||null,n},A.plus=function(n,i){var a,h=this,u=h.s;if(n=new v(n,i),i=n.s,!u||!i)return new v(NaN);if(u!=i)return n.s=-i,h.minus(n);var m=h.e/j,z=n.e/j,c=h.c,f=n.c;if(!m||!z){if(!c||!f)return new v(u/0);if(!c[0]||!f[0])return f[0]?n:new v(c[0]?h:u*0)}if(m=ue(m),z=ue(z),c=c.slice(),u=m-z){for(u>0?(z=m,a=f):(u=-u,a=c),a.reverse();u--;a.push(0));a.reverse()}for(u=c.length,i=f.length,u-i<0&&(a=f,f=c,c=a,i=u),u=0;i;)u=(c[--i]=c[i]+f[i]+u)/de|0,c[i]=de===c[i]?0:c[i]%de;return u&&(c=[u].concat(c),++z),Ce(n,c,z)},A.precision=A.sd=function(n,i){var a,h,u,m=this;if(n!=null&&n!==!!n)return q(n,1,J),i==null?i=k:q(i,0,8),re(new v(m),n,i);if(!(a=m.c))return null;if(u=a.length-1,h=u*j+1,u=a[u]){for(;u%10==0;u/=10,h--);for(u=a[0];u>=10;u/=10,h++);}return n&&m.e+1>h&&(h=m.e+1),h},A.shiftedBy=function(n){return q(n,-it,it),this.times("1e"+n)},A.squareRoot=A.sqrt=function(){var n,i,a,h,u,m=this,z=m.c,c=m.s,f=m.e,E=b+4,d=new v("0.5");if(c!==1||!z||!z[0])return new v(!c||c<0&&(!z||z[0])?NaN:z?m:1/0);if(c=Math.sqrt(+P(m)),c==0||c==1/0?(i=ce(z),(i.length+f)%2==0&&(i+="0"),c=Math.sqrt(+i),f=ue((f+1)/2)-(f<0||f%2),c==1/0?i="5e"+f:(i=c.toExponential(),i=i.slice(0,i.indexOf("e")+1)+f),a=new v(i)):a=new v(c+""),a.c[0]){for(f=a.e,c=f+E,c<3&&(c=0);;)if(u=a,a=d.times(u.plus(o(m,u,E,1))),ce(u.c).slice(0,c)===(i=ce(a.c)).slice(0,c))if(a.e<f&&--c,i=i.slice(c-3,c+1),i=="9999"||!h&&i=="4999"){if(!h&&(re(u,u.e+b+2,0),u.times(u).eq(m))){a=u;break}E+=4,c+=4,h=1}else{(!+i||!+i.slice(1)&&i.charAt(0)=="5")&&(re(a,a.e+b+2,1),n=!a.times(a).eq(m));break}}return re(a,a.e+b+1,k,n)},A.toExponential=function(n,i){return n!=null&&(q(n,0,J),n++),ae(this,n,i,1)},A.toFixed=function(n,i){return n!=null&&(q(n,0,J),n=n+this.e+1),ae(this,n,i)},A.toFormat=function(n,i,a){var h,u=this;if(a==null)n!=null&&i&&typeof i=="object"?(a=i,i=null):n&&typeof n=="object"?(a=n,n=i=null):a=Se;else if(typeof a!="object")throw Error(ie+"Argument not an object: "+a);if(h=u.toFixed(n,i),u.c){var m,z=h.split("."),c=+a.groupSize,f=+a.secondaryGroupSize,E=a.groupSeparator||"",d=z[0],T=z[1],_=u.s<0,L=_?d.slice(1):d,F=L.length;if(f&&(m=c,c=f,f=m,F-=m),c>0&&F>0){for(m=F%c||c,d=L.substr(0,m);m<F;m+=c)d+=E+L.substr(m,c);f>0&&(d+=E+L.slice(m)),_&&(d="-"+d)}h=T?d+(a.decimalSeparator||"")+((f=+a.fractionGroupSize)?T.replace(new RegExp("\\d{"+f+"}\\B","g"),"$&"+(a.fractionGroupSeparator||"")):T):d}return(a.prefix||"")+h+(a.suffix||"")},A.toFraction=function(n){var i,a,h,u,m,z,c,f,E,d,T,_,L=this,F=L.c;if(n!=null&&(c=new v(n),!c.isInteger()&&(c.c||c.s!==1)||c.lt(C)))throw Error(ie+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+P(c));if(!F)return new v(L);for(i=new v(C),E=a=new v(C),h=f=new v(C),_=ce(F),m=i.e=_.length-L.e-1,i.c[0]=at[(z=m%j)<0?j+z:z],n=!n||c.comparedTo(i)>0?m>0?i:E:c,z=Z,Z=1/0,c=new v(_),f.c[0]=0;d=o(c,i,0,1),u=a.plus(d.times(h)),u.comparedTo(n)!=1;)a=h,h=u,E=f.plus(d.times(u=E)),f=u,i=c.minus(d.times(u=i)),c=u;return u=o(n.minus(a),h,0,1),f=f.plus(u.times(E)),a=a.plus(u.times(h)),f.s=E.s=L.s,m=m*2,T=o(E,h,m,k).minus(L).abs().comparedTo(o(f,a,m,k).minus(L).abs())<1?[E,h]:[f,a],Z=z,T},A.toNumber=function(){return+P(this)},A.toPrecision=function(n,i){return n!=null&&q(n,1,J),ae(this,n,i,2)},A.toString=function(n){var i,a=this,h=a.s,u=a.e;return u===null?h?(i="Infinity",h<0&&(i="-"+i)):i="NaN":(n==null?i=u<=w||u>=S?Ve(ce(a.c),u):Te(ce(a.c),u,"0"):n===10&&Le?(a=re(new v(a),b+u+1,k),i=Te(ce(a.c),a.e,"0")):(q(n,2,Ae.length,"Base"),i=g(Te(ce(a.c),u,"0"),10,n,h,!0)),h<0&&a.c[0]&&(i="-"+i)),i},A.valueOf=A.toJSON=function(){return P(this)},A._isBigNumber=!0,A[Symbol.toStringTag]="BigNumber",A[Symbol.for("nodejs.util.inspect.custom")]=A.valueOf,t!=null&&v.set(t),v}function ue(t){var o=t|0;return t>0||t===o?o:o-1}function ce(t){for(var o,g,N=1,A=t.length,C=t[0]+"";N<A;){for(o=t[N++]+"",g=j-o.length;g--;o="0"+o);C+=o}for(A=C.length;C.charCodeAt(--A)===48;);return C.slice(0,A+1||1)}function be(t,o){var g,N,A=t.c,C=o.c,b=t.s,k=o.s,w=t.e,S=o.e;if(!b||!k)return null;if(g=A&&!A[0],N=C&&!C[0],g||N)return g?N?0:-k:b;if(b!=k)return b;if(g=b<0,N=w==S,!A||!C)return N?0:!A^g?1:-1;if(!N)return w>S^g?1:-1;for(k=(w=A.length)<(S=C.length)?w:S,b=0;b<k;b++)if(A[b]!=C[b])return A[b]>C[b]^g?1:-1;return w==S?0:w>S^g?1:-1}function q(t,o,g,N){if(t<o||t>g||t!==le(t))throw Error(ie+(N||"Argument")+(typeof t=="number"?t<o||t>g?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function Ge(t){var o=t.c.length-1;return ue(t.e/j)==o&&t.c[o]%2!=0}function Ve(t,o){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(o<0?"e":"e+")+o}function Te(t,o,g){var N,A;if(o<0){for(A=g+".";++o;A+=g);t=A+t}else if(N=t.length,++o>N){for(A=g,o-=N;--o;A+=g);t+=A}else o<N&&(t=t.slice(0,o)+"."+t.slice(o));return t}var Ci=Er();const Di=e.z.boolean().transform(t=>String(t)),Pi=e.z.string().transform(t=>t==="true");var ht;(function(t){t[t.function=0]="function",t[t.l1_handler=1]="l1_handler",t[t.constructor=2]="constructor"})(ht||(ht={}));const It=e.z.array(e.z.string()),$e=e.z.object({selector:e.z.string(),offset:e.z.string(),builtins:It.optional()}),Tt=e.z.object({CONSTRUCTOR:e.z.array($e),EXTERNAL:e.z.array($e),L1_HANDLER:e.z.array($e)}),ki=e.z.string(),gr=e.z.object({builtins:It,data:e.z.array(e.z.string())}),We=e.z.object({name:e.z.string(),type:e.z.union([e.z.literal("felt"),e.z.literal("felt*"),e.z.string()])}),zr=e.z.nativeEnum(ht),Sr=e.z.object({inputs:e.z.array(We),name:e.z.string(),outputs:e.z.array(We),stateMutability:e.z.literal("view").optional(),state_mutability:e.z.string().optional(),type:zr}),Ke=e.z.object({name:e.z.string(),type:e.z.union([e.z.literal("felt"),e.z.literal("felt*"),e.z.string()]),kind:e.z.union([e.z.literal("key"),e.z.literal("data")])}),Ar=e.z.object({name:e.z.string(),type:e.z.literal("event"),data:e.z.array(Ke),keys:e.z.array(Ke)}),Ir=e.z.object({name:e.z.string(),members:e.z.array(Ke),kind:e.z.literal("struct"),type:e.z.literal("event")}),Tr=e.z.object({members:e.z.array(We.and(e.z.object({offset:e.z.number()}))),name:e.z.string(),size:e.z.number(),type:e.z.literal("struct")}),Nr=e.z.union([Ir,Ar]),Nt=e.z.array(e.z.union([Sr,Nr,Tr,e.z.any()])),yr=e.z.object({program:gr,entry_points_by_type:Tt,abi:Nt}),yt=e.z.array(e.z.string()),vr=e.z.object({type_names:e.z.array(e.z.tuple([e.z.number(),e.z.string()])),libfunc_names:e.z.array(e.z.tuple([e.z.number(),e.z.string()])),user_func_names:e.z.array(e.z.tuple([e.z.number(),e.z.string()]))}),He=e.z.object({selector:e.z.string(),function_idx:e.z.number()}),Rr=e.z.object({CONSTRUCTOR:e.z.array(He),EXTERNAL:e.z.array(He),L1_HANDLER:e.z.array(He)}),Or=e.z.object({sierra_program:yt,sierra_program_debug_info:vr.optional(),contract_class_version:e.z.string(),entry_points_by_type:Rr,abi:Nt}),br=e.z.array(e.z.tuple([e.z.number(),e.z.array(e.z.string())])),_r=e.z.object({prime:e.z.string(),compiler_version:e.z.string(),bytecode:yt,hints:e.z.array(e.z.any()),pythonic_hints:br,entry_points_by_type:Tt}),ji=_r,Ui=e.z.union([yr,Or]),wr=St.createContext(null),vt=()=>St.useContext(wr),Fi=()=>{var t;return!!((t=vt())!=null&&t.emitter)},xi=({emitter:t,children:o})=>xn.jsx(wr.Provider,{value:{emitter:t},children:o});let $t=!1;const Rt=()=>{var g;const t=(g=vt())==null?void 0:g.emitter;if(!t&&!$t){$t=!0;return}return t},Bi=()=>{const t=Rt();return t?t.emit.bind(t):ke.noop},Mi=()=>{const t=Rt();return(g,N)=>{St.useEffect(()=>t?t.on(g,N):void 0,[g,N])}};var Lr={};function me(t,o){typeof o=="boolean"&&(o={forever:o}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=o||{},this._maxRetryTime=o&&o.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var Gi=me;me.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};me.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};me.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var o=new Date().getTime();if(t&&o-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var g=this._timeouts.shift();if(g===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),g=this._cachedTimeouts.slice(-1);else return!1;var N=this;return this._timer=setTimeout(function(){N._attempts++,N._operationTimeoutCb&&(N._timeout=setTimeout(function(){N._operationTimeoutCb(N._attempts)},N._operationTimeout),N._options.unref&&N._timeout.unref()),N._fn(N._attempts)},g),this._options.unref&&this._timer.unref(),!0};me.prototype.attempt=function(t,o){this._fn=t,o&&(o.timeout&&(this._operationTimeout=o.timeout),o.cb&&(this._operationTimeoutCb=o.cb));var g=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){g._operationTimeoutCb()},g._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};me.prototype.try=function(t){this.attempt(t)};me.prototype.start=function(t){this.attempt(t)};me.prototype.start=me.prototype.try;me.prototype.errors=function(){return this._errors};me.prototype.attempts=function(){return this._attempts};me.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},o=null,g=0,N=0;N<this._errors.length;N++){var A=this._errors[N],C=A.message,b=(t[C]||0)+1;t[C]=b,b>=g&&(o=A,g=b)}return o};(function(t){var o=Gi;t.operation=function(g){var N=t.timeouts(g);return new o(N,{forever:g&&(g.forever||g.retries===1/0),unref:g&&g.unref,maxRetryTime:g&&g.maxRetryTime})},t.timeouts=function(g){if(g instanceof Array)return[].concat(g);var N={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var A in g)N[A]=g[A];if(N.minTimeout>N.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var C=[],b=0;b<N.retries;b++)C.push(this.createTimeout(b,N));return g&&g.forever&&!C.length&&C.push(this.createTimeout(b,N)),C.sort(function(k,w){return k-w}),C},t.createTimeout=function(g,N){var A=N.randomize?Math.random()+1:1,C=Math.round(A*Math.max(N.minTimeout,1)*Math.pow(N.factor,g));return C=Math.min(C,N.maxTimeout),C},t.wrap=function(g,N,A){if(N instanceof Array&&(A=N,N=null),!A){A=[];for(var C in g)typeof g[C]=="function"&&A.push(C)}for(var b=0;b<A.length;b++){var k=A[b],w=g[k];g[k]=(function(p){var Z=t.operation(N),D=Array.prototype.slice.call(arguments,1),he=D.pop();D.push(function(te){Z.retry(te)||(te&&(arguments[0]=Z.mainError()),he.apply(this,arguments))}),Z.attempt(function(){p.apply(g,D)})}).bind(g,w),g[k].options=N}}})(Lr);exports.TOKEN_ERROR_MESSAGES=void 0;(function(t){t.NO_TOKEN_API_URL="NO_TOKEN_API_URL is not defined",t.NO_TOKEN_PRICE_API_URL="NO_TOKEN_PRICE_API_URL is not defined",t.TOKENS_DEFI_DECOMPOSITION_URL="TOKENS_DEFI_DECOMPOSITION_URL is not defined",t.TOKENS_AIRDROPS_API_URL="TOKENS_AIRDROPS_API_URL is not defined",t.TOKEN_PARSING_ERROR="Unable to parse token data response",t.TOKEN_PRICE_PARSING_ERROR="Unable to parse token price response",t.TOKEN_DEFI_DECOMPOSITION_PARSING_ERROR="Unable to parse token defi decomposition response",t.TOKEN_PRICE_NOT_FOUND="Token price not found",t.TOKEN_NOT_FOUND="Token not found",t.TOKEN_DETAILS_NOT_FOUND="Token details not found",t.FEE_TOKEN_NOT_FOUND="Fee token not found",t.UNABLE_TO_CALCULATE_CURRENCY_VALUE="Unable to calculate currency value",t.UNSAFE_DECIMALS="Unsafe decimals in token"})(exports.TOKEN_ERROR_MESSAGES||(exports.TOKEN_ERROR_MESSAGES={}));class Vi extends Oe{constructor(o){super(o,exports.TOKEN_ERROR_MESSAGES),this.name="TokenError"}}const Ot=e.z.union([e.z.literal("concentratedLiquidityPosition"),e.z.literal("collateralizedDebtPosition")]),$i=e.z.object({status:e.z.literal("initialising")}).or(e.z.object({status:e.z.literal("initialised"),balances:e.z.array(e.z.object({tokenAddress:H,tokenBalance:e.z.string()}))})),we=e.z.object({id:e.z.number(),address:Y,brandColor:e.z.string().optional(),name:e.z.string(),symbol:e.z.string(),decimals:e.z.number(),iconUrl:e.z.string().optional(),sendable:e.z.boolean(),popular:e.z.boolean(),refundable:e.z.boolean(),listed:e.z.boolean(),tradable:e.z.boolean(),category:e.z.union([e.z.literal("tokens"),e.z.literal("currencies"),e.z.literal("savings")]),pricingId:e.z.number().optional(),dappId:e.z.string().optional(),marketData:e.z.object({marketCap:e.z.number(),marketCap24hChange:e.z.number(),dailyVolume:e.z.number(),rank:e.z.number()}).optional(),tags:e.z.array(e.z.string()).optional()}),Hi=e.z.object({tokens:e.z.array(we)}),Xi=we,bt=e.z.object({pricingId:e.z.number(),ethValue:e.z.string(),ccyValue:e.z.string(),ethDayChange:e.z.string(),ccyDayChange:e.z.string()}),qi=e.z.object({prices:e.z.array(bt)}),dt=e.z.object({tokenAddress:H,principal:e.z.string(),accruedFees:e.z.string(),minPrice:e.z.string(),maxPrice:e.z.string(),currentPrice:e.z.string()}),Cr=e.z.object({tokenAddress:Y.optional(),totalBalances:e.z.record(e.z.string())}),_t=Cr.extend({tokenId:e.z.string(),data:e.z.object({poolFeePercentage:e.z.string(),tickSpacingPercentage:e.z.string().optional(),token0:dt,token1:dt})}),Wi=e.z.array(_t),wt=Cr.extend({data:e.z.object({apy:e.z.string().optional(),group:e.z.number().optional(),collateral:e.z.boolean(),debt:e.z.boolean(),lending:e.z.boolean()})}),Ki=e.z.array(wt),Dr=e.z.array(_t.or(wt)),Pr=e.z.object({name:e.z.string(),manageUrl:e.z.string(),type:Ot,groups:e.z.record(e.z.object({name:e.z.string().optional(),healthRatio:e.z.string().optional()})).optional(),positions:Dr}),kr=e.z.object({dappId:e.z.string(),products:e.z.array(Pr)}),Yi=e.z.object({dapps:e.z.array(kr)}),jr=e.z.object({name:e.z.string().optional(),tokenAddress:Y,amount:e.z.string().optional(),claimUrl:e.z.string().optional(),claimStart:e.z.number(),claimEnd:e.z.number().optional()}),Zi=e.z.object({accountAddress:Y,chain:e.z.string(),airdrops:e.z.array(jr)}),tt=e.z.object({address:Y,networkId:e.z.string({required_error:"Network is required"})},{required_error:"BaseToken is required"});tt.required().extend({balance:e.z.string()});const Ur=tt.required().extend({id:e.z.number().optional(),name:e.z.string().optional(),symbol:e.z.string().optional(),decimals:e.z.coerce.number().optional(),iconUrl:e.z.string().url("").optional().or(e.z.literal("")),pricingId:e.z.number().optional(),category:e.z.string().optional(),dappId:e.z.string().optional(),brandColor:e.z.string().optional()}),Ji=Ur.extend({balance:e.z.string()}),Qi=Ur.extend({currencyValue:e.z.string(),ccyDayChange:e.z.string().optional(),ethDayChange:e.z.string().optional(),unitCurrencyValue:e.z.string().optional()}),Lt=Qi.extend({...Ji.shape});e.z.array(Lt);tt.extend({...bt.shape});tt.extend({...we.shape});const Ht=Lt.extend({accruedFees:e.z.string(),currentPrice:e.z.string(),maxPrice:e.z.string(),minPrice:e.z.string(),principal:e.z.string()}),Fr=e.z.object({address:Y.optional(),currencyValue:e.z.string().default("0")}),Ct=Fr.extend({poolFeePercentage:e.z.string(),tickSpacingPercentage:e.z.string().optional(),tokenId:e.z.string().optional(),unitCurrencyValueToken0:e.z.string().optional(),unitCurrencyValueToken1:e.z.string().optional(),token0:Ht,token1:Ht}),ea=e.z.array(Ct),ta=e.z.object({name:e.z.string().optional(),healthRatio:e.z.string().optional(),accountAddress:Y.optional()}),Dt=Fr.extend({totalBalances:e.z.record(e.z.string()),collateral:e.z.boolean(),debt:e.z.boolean(),lending:e.z.boolean(),apy:e.z.string().optional(),group:e.z.string().optional(),unitCurrencyValue:e.z.string().optional(),positionToken:we.or(e.z.undefined()),token:Lt.optional(),accountAddress:Y.optional(),accountAddressGroup:e.z.string().optional()}),ra=e.z.array(Dt),xr=Ct.or(Dt),Br=e.z.record(e.z.object({name:e.z.string().optional(),healthRatio:e.z.string().optional(),accountAddress:Y.optional()})),Mr=e.z.object({type:Ot,manageUrl:e.z.string().url().optional(),name:e.z.string(),positions:e.z.array(xr),positionsTotalValue:e.z.string(),brandColor:e.z.string().optional(),groups:Br.optional(),accountAddress:Y}),Gr=e.z.array(Mr),na=e.z.object({dappId:e.z.string(),products:Gr}),Vr=e.z.object({name:e.z.string().optional(),tokenAddress:Y,token:we.optional(),amount:e.z.string().optional(),claimUrl:e.z.string().optional(),claimStart:e.z.number(),claimEnd:e.z.number().optional()}),ia=e.z.array(Vr),$r=(t,o=18)=>Wt(t.replace(",","."),Number(o)),Hr=e.z.string().trim().refine(t=>t!=="",{message:"Amount is required"}).refine(t=>{try{const o=$r(t).value;if(o<0n)throw new Error("Amount must be positive");if(o===0n)throw new Error("Amount can not be zero");if(o>W.uint256.UINT_256_MAX)throw new Error("Amount is too big")}catch{throw new Error("Amount should be a number")}return!0},{message:"Invalid amount"}),aa=t=>!!Hr.parse(t),Xr=e.z.object({data:e.z.object({code:e.z.string().optional(),name:e.z.string().optional(),message:e.z.string()})}),sa=t=>{const o=Xr.safeParse(t);if(o.success)return o.data.data.message},oa=3,Pt=process.env.FEE_OVERHEAD?parseFloat(process.env.FEE_OVERHEAD):oa,ca=1.5,Ye=10,qr=({estimatedFee:t,overheadMultiplier:o=Pt})=>{const N=W.num.toBigInt(t)*BigInt(o*Ye)/BigInt(Ye);return W.num.toHex(N)},la=({suggestedMaxFee:t,overheadMultiplier:o=Pt,starknetJsOverheadMultiplier:g=ca})=>{const A=W.num.toBigInt(t)*BigInt(Ye)/BigInt(g*Ye);return qr({estimatedFee:A,overheadMultiplier:o})};exports.ESTIMATE_ERROR_MESSAGES=void 0;(function(t){t.SIMULATE_AND_REVIEW_FAILED="Missing simulation"})(exports.ESTIMATE_ERROR_MESSAGES||(exports.ESTIMATE_ERROR_MESSAGES={}));class ua extends Oe{constructor(o){super(o,exports.ESTIMATE_ERROR_MESSAGES),this.name="EstimateError"}}const fa=e.z.object({type:e.z.enum(["DECLARE","DEPLOY","DEPLOY_ACCOUNT","INVOKE"]).default("INVOKE"),calls:e.z.array(ut).or(ut).optional(),calldata:e.z.array(e.z.string()).optional(),classHash:Ue.optional(),salt:Ue.optional(),signature:e.z.array(e.z.string()).optional()}),ma=e.z.object({amount:e.z.bigint(),pricePerUnit:e.z.bigint()}).or(e.z.object({maxFee:e.z.bigint()})),pt=e.z.object({feeTokenAddress:Y,amount:e.z.bigint(),pricePerUnit:e.z.bigint(),max:ma.optional(),dataGasConsumed:e.z.bigint().optional(),dataGasPrice:e.z.bigint().optional()}),Wr=e.z.object({deployment:pt.optional(),transactions:pt}),Kr=e.z.union([e.z.literal("critical"),e.z.literal("high"),e.z.literal("caution"),e.z.literal("info")]),Yr=e.z.string(),ha=e.z.object({name:e.z.string(),url:e.z.string(),position:e.z.number()}),st=e.z.object({address:e.z.string(),name:e.z.string(),symbol:e.z.string().optional(),decimals:e.z.number().optional(),unknown:e.z.boolean(),iconUrl:e.z.string().optional(),type:e.z.string()}),Et=e.z.discriminatedUnion("type",[e.z.object({type:e.z.literal("amount"),label:e.z.string(),token:st,amount:e.z.string(),usd:e.z.string(),editable:e.z.boolean()}),e.z.object({type:e.z.literal("address"),label:e.z.string(),address:e.z.string(),addressName:e.z.string().optional(),verified:e.z.boolean().optional()}),e.z.object({type:e.z.literal("timestamp"),label:e.z.string(),value:e.z.string()}),e.z.object({type:e.z.literal("token_address"),label:e.z.string(),token:st}),e.z.object({type:e.z.literal("calldata"),label:e.z.string(),entrypoint:e.z.string(),calldata:e.z.array(e.z.string())}),e.z.object({type:e.z.literal("text"),label:e.z.string(),text:e.z.string()}),e.z.object({type:e.z.literal("nft"),label:e.z.string(),token:st})]),kt=e.z.object({name:e.z.string(),properties:e.z.array(Et),defaultProperties:e.z.array(Et).optional()}),Zr=e.z.union([e.z.literal("verified"),e.z.literal("neutral"),e.z.literal("partial"),e.z.literal("warn")]),Jr=e.z.object({unknown_token:e.z.unknown().optional(),date_of_addition:e.z.string().optional(),contract_address:Y.optional(),reason:e.z.string().optional(),value:e.z.string().or(e.z.number()).optional()}),jt=e.z.object({reason:Yr,details:Jr.optional(),severity:Kr}),Qr=e.z.object({assessment:Zr,warnings:e.z.array(jt).optional(),assessmentReasons:e.z.array(e.z.string()).optional(),assessmentDetails:e.z.object({contract_address:e.z.string()}).optional(),action:kt}),Ut=e.z.object({name:e.z.string(),description:e.z.string(),logoUrl:e.z.string(),iconUrl:e.z.string(),argentVerified:e.z.boolean(),links:e.z.array(ha)}),en=e.z.object({assessment:e.z.union([e.z.literal("verified"),e.z.literal("neutral"),e.z.literal("partial"),e.z.literal("warn")]),warnings:e.z.array(jt).optional(),assessmentDetails:e.z.object({contract_address:e.z.string()}).optional(),targetedDapp:Ut.optional(),reviews:e.z.array(Qr)}).optional(),tn=e.z.object({banner:e.z.string().nullable().optional(),preview:e.z.string().nullable().optional(),full:e.z.string().nullable().optional(),original:e.z.string().nullable().optional()}),da=e.z.object({twitter:e.z.string().optional(),external:e.z.string().optional(),discord:e.z.string().optional()}),Ft=e.z.object({address:H,decimals:e.z.number().optional(),symbol:e.z.string().optional(),name:e.z.string(),description:e.z.string().optional(),type:e.z.string().optional(),usdValue:e.z.string().optional(),iconUrl:e.z.string().optional(),unknown:e.z.boolean().optional(),imageUrls:tn.optional(),links:da.optional()}),pa=e.z.object({tokenAddress:H,owner:H,spender:H,value:e.z.string().optional(),approvalForAll:e.z.boolean(),details:Ft.optional()}),Ea=e.z.object({tokenAddress:H,from:H,to:H,tokenId:e.z.string().optional(),value:e.z.string().optional(),details:Ft.optional()}),Re=e.z.union([e.z.string(),e.z.number(),e.z.bigint()]).transform(t=>parseInt(t.toString(),10)),Xt={overallFee:Re,gasPrice:Re,gasUsage:Re,dataGasPrice:Re.optional(),dataGasConsumed:Re.optional()},rn=e.z.object({...Xt,unit:e.z.string().transform(t=>t.toUpperCase()).pipe(e.z.literal("WEI")),maxFee:Re}).or(e.z.object({...Xt,unit:e.z.string().transform(t=>t.toUpperCase()).pipe(e.z.literal("FRI")),maxAmount:Re,maxPricePerUnit:Re})),ga=e.z.object({type:e.z.string(),label:e.z.string(),tokenId:e.z.string().optional(),value:e.z.string().optional(),usdValue:e.z.string().optional(),token:Ft,sent:e.z.boolean().optional(),tokenIdDetails:e.z.object({name:e.z.string().optional(),description:e.z.string().optional(),imageUrls:tn.optional()}).optional()}),za=e.z.object({approvals:e.z.array(pa).optional(),transfers:e.z.array(Ea).optional(),calculatedNonce:e.z.string().optional(),feeEstimation:rn,summary:e.z.array(ga).optional()}),Sa=e.z.object({label:e.z.string().optional(),code:e.z.number().optional(),message:e.z.string().optional(),error:e.z.string().optional()}),nn=e.z.object({reviewOfTransaction:en,simulation:za,simulationError:e.z.undefined()}),an=e.z.object({reviewOfTransaction:en,simulation:e.z.undefined(),simulationError:Sa}),sn=nn.or(an),Aa=e.z.object({transactions:e.z.array(sn)}),Ia=e.z.object({transactions:e.z.array(sn),enrichedFeeEstimation:Wr.optional(),isBackendDown:e.z.boolean().default(!1).optional()});function Ta(t){return nn.safeParse(t).success}function Na(t){return an.safeParse(t).success}const on=e.z.object({network:e.z.string(),hash:e.z.string(),status:e.z.string(),blockNumber:e.z.number().optional(),transactionIndex:e.z.number()}),Pe=e.z.object({type:e.z.enum(["token","nft"]),tokenAddress:H,amount:e.z.string().optional(),fiatAmount:e.z.object({currency:e.z.string(),currencyAmount:e.z.number()}).optional().nullable()}),xt=e.z.enum(["ethereum","starknet","zksync","zksync2"]),cn=e.z.object({type:e.z.enum(["payment","gasFee"]),leg:e.z.enum(["credit","debit"]),asset:Pe,counterParty:H.optional(),counterPartyNetwork:xt.optional()}),ya=e.z.object({address:H,network:xt,type:e.z.enum(["wallet","token"])}),va=e.z.object({chainId:e.z.enum(["TESTNET","MAINNET","SEPOLIA"]),ethereumNetwork:e.z.enum(["mainnet","sepolia"])}),Ra=e.z.enum(["approval","changePubKey","dappInteraction","deploy","gift","multicall","payment","security","trade"]),ln=e.z.enum(["triggerEscapeGuardian","triggerEscapeSigner","escapeGuardian","escapeSigner","guardianChanged","guardianBackupChanged","signerChanged","cancelEscape","accountUpgraded","multisigConfigurationUpdated"]),Oa=e.z.object({name:e.z.string(),parameters:e.z.array(e.z.unknown()).optional()}),ba=e.z.object({activeAt:e.z.string().optional(),newGuardian:e.z.string().optional(),newImplementation:e.z.string().optional(),newVersion:e.z.string().optional()}),qt=e.z.discriminatedUnion("type",[e.z.object({type:e.z.literal("deploy"),deployer:H,contractAddress:H}),e.z.object({type:e.z.literal("approval"),spender:H,asset:Pe,approvalType:e.z.string()}),e.z.object({type:e.z.literal("payment"),counterparty:H,leg:e.z.string(),asset:Pe,counterpartyNetwork:xt.optional()}),e.z.object({type:e.z.literal("trade"),srcAsset:Pe,destAsset:Pe}),e.z.object({type:e.z.literal("security"),action:ln,context:ba.optional()}),e.z.object({type:e.z.literal("dappInteraction"),dappAddress:H,function:Oa.optional().nullable()})]),un=e.z.union([qt,e.z.object({type:e.z.literal("multicall"),calls:e.z.array(e.z.object({details:qt}))})]),fn=e.z.object({dappId:e.z.string(),name:e.z.string().optional().nullable()}),Bt=e.z.object({sent:e.z.boolean(),asset:e.z.discriminatedUnion("type",[e.z.object({type:e.z.literal("nft"),tokenAddress:H,tokenId:e.z.coerce.number().optional(),amount:e.z.string().optional(),collectionName:e.z.string().optional(),collectionPreviewImage:e.z.string().optional().nullable(),nftName:e.z.string().optional().nullable(),nftPreviewImage:e.z.string().optional().nullable()}),e.z.object({type:e.z.literal("token"),tokenAddress:H,amount:e.z.string().optional(),fiatAmount:e.z.object({currency:e.z.string(),currencyAmount:e.z.coerce.string()}).optional().nullable()})])}),mn=e.z.object({type:e.z.string(),to:H,actualFee:e.z.object({type:e.z.string(),tokenAddress:H,amount:e.z.string().optional(),fiatAmount:e.z.object({currency:e.z.string(),currencyAmount:e.z.number()}).optional().nullable()})}),hn=e.z.enum(["pending","success","failure"]),Mt=e.z.object({compositeId:e.z.string(),id:e.z.string().uuid(),status:hn,wallet:H,txSender:H,source:e.z.string(),type:Ra,group:e.z.enum(["finance","security"]),submitted:e.z.number(),lastModified:e.z.number(),transaction:on,transfers:e.z.array(cn),fees:e.z.array(mn).optional(),relatedAddresses:e.z.array(ya).nullable(),network:e.z.string(),networkDetails:va.optional(),details:un,transferSummary:e.z.array(Bt).optional(),dapp:fn.optional(),actions:e.z.array(kt).optional(),title:e.z.string().optional()}),dn=e.z.object({title:e.z.string().optional(),shortTitle:e.z.string().optional(),subtitle:e.z.string().optional(),icon:e.z.string().optional()}),pn="native",En="rejected",gn="cancelled",zn="queued",_a=Mt.pick({status:!0,actions:!0,submitted:!0,lastModified:!0,transferSummary:!0,fees:!0}).extend({status:e.z.union([hn,e.z.enum([En,gn,zn])]),type:e.z.literal(pn),transaction:on.pick({hash:!0}),dapp:Ut.optional(),meta:dn.optional()}),Sn=e.z.array(Mt),wa=e.z.object({activities:Sn,page:e.z.number(),pageSize:e.z.number(),totalElements:e.z.number(),totalPages:e.z.number()});function La(t){return ln.safeParse(t).success}const Gt=t=>Bt.safeParse(t).success,Ca=t=>Gt(t)&&t.asset.type==="token",Da=t=>Gt(t)&&t.asset.type==="nft",gt={Transfer:W.hash.getSelectorFromName("Transfer"),Approval:W.hash.getSelectorFromName("Approval")},An=(t,o,g)=>{for(const N of t){const{events:A,internal_calls:C}=N;for(const b of A)for(const k of b.keys)k===gt.Approval&&o.push({tokenAddress:Y.parse(N.contract_address),owner:b.data[0],spender:b.data[1],value:W.uint256.uint256ToBN({low:b.data[2],high:b.data[3]}).toString()}),k===gt.Transfer&&g.push({tokenAddress:Y.parse(N.contract_address),from:b.data[0],to:b.data[1],value:W.uint256.uint256ToBN({low:b.data[2],high:b.data[3]}).toString()});C&&An(C,o,g)}return{approvals:o,transfers:g}},Pa=/(0x[a-fA-F0-9]+)\s*\('(.*?)'\)/,ka=t=>{if(!ke.isString(t))return;const o=t.match(Pa);if(o&&!ke.isEmpty(o[2]))return o[2]};var zt;(function(t){t.SIMULATE_AND_REVIEW_FAILED="Something went wrong fetching review",t.NO_CALLS_FOUND="No calls found",t.ONCHAIN_FEE_ESTIMATION_FAILED="Failed to estimate fees onchain"})(zt||(zt={}));class ja extends Oe{constructor(o){super(o,zt),this.name="ReviewError"}}const Ua=e.z.object({reason:e.z.string(),severity:e.z.string().optional(),title:e.z.string(),description:e.z.string().optional()}),Fa=Object.values(W.constants.TRANSACTION_VERSION),xa=e.z.string().default("0x3").refine(t=>{const o=W.num.toBigInt(t);return Fa.map(g=>W.num.toBigInt(g)).includes(o)}).transform(t=>W.num.toHex(t));function Ba(t){if(t===W.constants.TRANSACTION_VERSION.V3||t===W.constants.TRANSACTION_VERSION.F3)throw Error("Only txv1 is supported")}exports.AccountError=Ri;exports.AddressError=De;exports.BaseError=Oe;exports.BigNumber=Ci;exports.CallError=li;exports.ETH_TOKEN_ADDRESS=Qn;exports.EstimateError=ua;exports.EventEmitterProvider=xi;exports.EventsBySelector=gt;exports.FEE_OVERHEAD=Pt;exports.HttpError=Qe;exports.NativeActivityStatusCancelled=gn;exports.NativeActivityStatusQueued=zn;exports.NativeActivityStatusRejected=En;exports.NativeActivityTypeNative=pn;exports.NetworkError=ui;exports.ReviewError=ja;exports.STANDARD_DEVNET_ACCOUNT_CLASS_HASH=ai;exports.STRK_TOKEN_ADDRESS=ei;exports.TXV1_ACCOUNT_CLASS_HASH=ti;exports.TXV1_MULTISIG_CLASS_HASH=ni;exports.TXV3_ACCOUNT_CLASS_HASH=ri;exports.TXV3_MULTISIG_CLASS_HASH=ii;exports.TokenError=Vi;exports.abiEntrySchema=We;exports.abiSchema=Nt;exports.actionSchema=kt;exports.activitiesSchema=Sn;exports.activityDappSchema=fn;exports.activityDetailsSchema=un;exports.activityResponseSchema=wa;exports.activitySchema=Mt;exports.activitySummarySchema=Bt;exports.activityTransferSchema=cn;exports.addOwnersCalldataSchema=hi;exports.addPluginCalldataSchema=gi;exports.addressInputCharactersAndLengthSchema=qn;exports.addressInputSchema=rr;exports.addressOrDomainInputSchema=Kn;exports.addressOrDomainSchema=Wn;exports.addressOrEmptyUndefinedSchema=Bn;exports.addressSchema=Y;exports.addressSchemaArgentBackend=H;exports.addressSchemaBase=Fe;exports.addressSchemaLooseLength=Yt;exports.addressSchemaStrictLength=Zt;exports.airdropSchema=Vr;exports.apiAccountTokenBalancesSchema=$i;exports.apiAirdropSchema=jr;exports.apiCollateralizedDebtPositionSchema=wt;exports.apiCollateralizedDebtPositionsSchema=Ki;exports.apiConcentratedLiquidityPositionSchema=_t;exports.apiConcentratedLiquidityPositionsSchema=Wi;exports.apiDefiDecompositionProduct=Pr;exports.apiDefiDecompositionProducts=Dr;exports.apiDefiDecompositionSchema=kr;exports.apiDefiDecompositionToken=dt;exports.apiDefiPositionsSchema=Yi;exports.apiPriceDataResponseSchema=qi;exports.apiPriceDetailsSchema=bt;exports.apiTokenInfoResponseSchema=Xi;exports.apiTokenInfoSchema=we;exports.apiTokensInfoResponseSchema=Hi;exports.apiUnclaimedRewardsSchema=Zi;exports.apiWalletResponseSchema=oi;exports.argentMaxFee=qr;exports.argentNameSchema=Be;exports.assessmentSchema=Zr;exports.bigNumberSchema=wi;exports.bigNumberishSchema=_e;exports.booleanToStringSchema=Di;exports.builtinsSchema=It;exports.byteCodeSchema=yt;exports.cairo1EventSchema=Ir;exports.cairoAssemblySchema=_r;exports.cairoVersionSchema=or;exports.callDetailsSchema=hr;exports.callSchema=ut;exports.calldataSchema=ur;exports.changeGuardianCalldataSchema=fi;exports.changeThresholdCalldataSchema=Ei;exports.collateralizedDebtGroupSchema=ta;exports.collateralizedDebtPositionSchema=Dt;exports.collateralizedDebtPositionsSchema=ra;exports.compiledContractClassSchema=Ui;exports.compiledSierraCasmSchema=ji;exports.compiledSierraSchema=Or;exports.compressedProgramSchema=ki;exports.concentratedLiquidityPositionSchema=Ct;exports.concentratedLiquidityPositionsSchema=ea;exports.constructorCallDataSchemaC0=Ni;exports.constructorCallDataSchemaC1V1=yi;exports.contractEntryPointFieldsSchema=$e;exports.defiDappsProductsSchema=na;exports.defiPositionSchema=xr;exports.defiPositionTypeSchema=Ot;exports.defiProductSchema=Mr;exports.defiProductsSchema=Gr;exports.denyTxV3=Ba;exports.enrichedSimulateAndReviewSchema=Ia;exports.ensureArray=_i;exports.entryPointsByTypeSchema=Tt;exports.escapeGuardianCalldataSchema=mi;exports.estimatedFeeSchema=pt;exports.estimatedFeesSchema=Wr;exports.eventAbiSchema=Nr;exports.eventEntrySchema=Ke;exports.executeOnPluginCalldataSchema=Si;exports.feeEstimationSchema=rn;exports.feeSchema=mn;exports.feltSchema=fe;exports.findTransfersAndApprovals=An;exports.formatFullAddress=Gn;exports.formatTruncatedAddress=Mn;exports.formatTruncatedSignerKey=Hn;exports.formatTruncatedString=Xn;exports.functionAbiSchema=Sr;exports.functionAbiTypeSchema=zr;exports.getAddressFromArgentName=ci;exports.getDefaultExportFromCjs=pr;exports.getMessageFromTrpcError=sa;exports.getPrettyRpcError=ka;exports.getSignerForMultiSigner=vi;exports.hexSchema=Ue;exports.hexSchemaBase=dr;exports.implementationSchema=Ii;exports.includesAddress=$n;exports.inputAmountSchema=Hr;exports.isActivityDetailsAction=La;exports.isActivitySummary=Gt;exports.isAddress=Jt;exports.isArgentName=nr;exports.isEqualAddress=er;exports.isEqualArgentName=ir;exports.isEqualStarknetDomainName=Zn;exports.isEqualStarknetId=sr;exports.isNftActivitySummary=Da;exports.isNotTransactionSimulationError=Ta;exports.isStarknetDomainName=Yn;exports.isStarknetId=ar;exports.isTokenActivitySummary=Ca;exports.isTransactionSimulationError=Na;exports.isValidAddress=Qt;exports.isValidInputAmount=aa;exports.isZeroAddress=tr;exports.legacyContractClassSchema=yr;exports.legacyEventSchema=Ar;exports.modifySnjsFeeOverhead=la;exports.multiTypeSchema=je;exports.nativeActivityMetaSchema=dn;exports.nativeActivitySchema=_a;exports.normalizeAddress=xe;exports.normalizeAddressOrDomain=Jn;exports.normalizeArgentName=Xe;exports.normalizeStarknetId=qe;exports.parseAmount=$r;exports.parseUnits=Wt;exports.productGroupsSchema=Br;exports.programSchema=gr;exports.propertySchema=Et;exports.pythonicHintsSchema=br;exports.rawArgsArraySchema=fr;exports.rawArgsObjectSchema=mr;exports.rawArgsSchema=et;exports.reasonsSchema=Yr;exports.removeOwnersCalldataSchema=di;exports.removePluginCalldataSchema=zi;exports.replaceSignerCalldataSchema=pi;exports.retry=Lr;exports.reviewSchema=Qr;exports.semver=bi;exports.severitySchema=Kr;exports.sierraContractEntryPointFieldsSchema=He;exports.sierraEntryPointsByTypeSchema=Rr;exports.sierraProgramDebugInfoSchema=vr;exports.simulateAndReviewSchema=Aa;exports.starknetDomainNameSchema=Je;exports.starknetIdSchema=Ze;exports.stringToBooleanSchema=Pi;exports.structAbiSchema=Tr;exports.targetedDappSchema=Ut;exports.transactionReviewTransactionsSchema=fa;exports.transactionReviewWarningSchema=Ua;exports.transferCalldataSchema=Ai;exports.trpcErrorSchema=Xr;exports.txVersionSchema=xa;exports.uint256Schema=lr;exports.unclaimedRewardsSchema=ia;exports.urlJoin=cr;exports.useEmitEvent=Bi;exports.useEventEmitter=Rt;exports.useEventEmitterContext=vt;exports.useEventListener=Mi;exports.useIsEventEmitterEnabled=Fi;exports.validChecksumAddressSchema=At;exports.validateAddressRangeSchema=Kt;exports.warningDetailsSchema=Jr;exports.warningSchema=jt;
|
|
1
|
+
"use strict";const e=require("zod"),W=require("starknet"),ke=require("lodash-es");require("@scure/base");const xn=require("react/jsx-runtime"),St=require("react");require("object-hash");require("swr");function Wt(t,o){let[g,y=""]=t.split(".");const A=g.startsWith("-");return A&&(g=g.slice(1)),y.length>o?Number(y[o])>=5?y=(BigInt(y.slice(0,o))+1n).toString().padStart(o,"0"):y=y.slice(0,o):y=y.padEnd(o,"0"),{value:BigInt(`${A?"-":""}${g}${y}`),decimals:o}}const At=e.z.string().refine(t=>{if(t.toLowerCase()===t)return!0;try{return W.validateChecksumAddress(t)&&Vn(t)}catch{}return!1},"Invalid address (checksum error)"),Kt=e.z.string().refine(t=>{try{return W.validateAndParseAddress(t)}catch{}return!1},"Invalid address (validation error)"),Fe=e.z.string().regex(/^0x[0-9a-fA-F]+$/,"Invalid address"),Yt=Fe.min(50,"Addresses must at least be 50 characters long").max(66,"Addresses must at most be 66 characters long"),Zt=Fe.length(66,"Address must be 66 characters long"),Y=Yt.pipe(At).transform(t=>`0x${(t.startsWith("0x")?t.slice(2):t).padStart(64,"0")}`),Bn=Y.or(e.z.literal("")).transform(t=>t===""?void 0:t).optional(),H=Fe.transform(t=>`0x${t.replace(/^0x/,"").toLowerCase().padStart(64,"0")}`),Jt=t=>Y.safeParse(t).success,Qt=Jt,xe=t=>W.getChecksumAddress(t),Mn=t=>{const o=xe(t),g=o.slice(0,2),y=o.slice(2,6),A=o.slice(-4);return`${g}${y}…${A}`},Gn=t=>{const o=xe(t),g=o.slice(0,2),A=o.slice(2).match(/.{1,4}/g)||[];return`${g} ${A.join(" ")}`},Vn=t=>!/^0x[0-9a-f]{63,64}$/.test(t),er=(t,o)=>{try{return!t||!o?!1:W.num.hexToDecimalString(t)===W.num.hexToDecimalString(o)}catch{}return!1},tr=t=>{try{return W.num.toBigInt(Fe.parse(t))===W.constants.ZERO}catch{}return!1},$n=(t,o)=>!!(o!=null&&o.some(g=>er(g,t))),Hn=ke.memoize(t=>{const o=t.slice(0,6),g=t.slice(-4);return`${o}…${g}`}),Xn=ke.memoize((t,o)=>{if(t.length<o)return t;const g=Math.floor((o-1)/2),y=t.slice(0,g),A=t.slice(-g);return`${y}…${A}`}),qn=e.z.string().regex(/^[a-zA-Z0-9.-]*$/g,"Invalid address character").max(66,"Address cannot be over 66 characters"),rr=Zt.pipe(At).pipe(Kt),Be=e.z.string().regex(/^([a-zA-Z0-9-]+\.)+argent.xyz$/,"Invalid Argent name").max(253,"Argent name cannot be over 253 characters"),nr=t=>Be.safeParse(t).success,ir=(t,o)=>{try{return o?Xe(t)===Xe(o):!1}catch{}return!1},Xe=t=>Be.parse(t).toLowerCase(),Ze=e.z.string().regex(/^([a-zA-Z0-9-]+\.)+stark$/,"Invalid Starknet ID").max(50,"Starknet ID cannot be over 50 characters"),ar=t=>Ze.safeParse(t).success,sr=(t,o)=>{try{return o?qe(t)===qe(o):!1}catch{}return!1},qe=t=>Ze.parse(t).toLowerCase(),Je=e.z.union([Be,Ze]),Wn=e.z.union([Y,Je]),Kn=e.z.union([rr,Je]),Yn=t=>Je.safeParse(t).success,Zn=(t,o)=>{try{return o?ir(t,o)||sr(t,o):!1}catch{}return!1},Jn=t=>ar(t)?qe(t):nr(t)?Xe(t):xe(t),or=e.z.union([e.z.literal("0"),e.z.literal("1")]),Qn="0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",ei="0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",ti="0x1a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003",ri="0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f",ni="0x737ee2f87ce571a58c6c8da558ec18a07ceb64a6172d5ec46171fbc80077a48",ii="0x6e150953b26271a740bf2b6e9bca17cc52c68d765f761295de51ceb8526ee72",ai="0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f";function si(t){var o=[];if(t.length===0)return"";if(typeof t[0]!="string")throw new TypeError("Url must be a string. Received "+t[0]);if(t[0].match(/^[^/:]+:\/*$/)&&t.length>1){var g=t.shift();t[0]=g+t[0]}t[0].match(/^file:\/\/\//)?t[0]=t[0].replace(/^([^/:]+):\/*/,"$1:///"):t[0]=t[0].replace(/^([^/:]+):\/*/,"$1://");for(var y=0;y<t.length;y++){var A=t[y];if(typeof A!="string")throw new TypeError("Url must be a string. Received "+A);A!==""&&(y>0&&(A=A.replace(/^[\/]+/,"")),y<t.length-1?A=A.replace(/[\/]+$/,""):A=A.replace(/[\/]+$/,"/"),o.push(A))}var C=o.join("/");C=C.replace(/\/(\?|&|#[^!])/g,"$1");var b=C.split("?");return C=b.shift()+(b.length>0?"?":"")+b.join("&"),C}function cr(){var t;return typeof arguments[0]=="object"?t=arguments[0]:t=[].slice.call(arguments),si(t)}class Oe extends Error{constructor({code:o,message:g,options:y={}},A){const{error:C,context:b}=y;super(g,{cause:C}),this.errorMessages=A,this.name="BaseError",this.context=b,this.code=o,this.setMessageByCode(o,g)}setMessageByCode(o,g){!o||!this.errorMessages||g||(this.message=this.errorMessages[o])}}var ot;(function(t){t.NOT_VALID="Invalid address",t.NOT_FOUND="Address not found",t.STARKNAME_NOT_FOUND="Stark name not found",t.STARKNAME_ERROR="Could not get address from stark name",t.STARKNAME_INVALID_ADDRESS="Stark name resolved to an invalid address",t.ARGENT_NAME_NOT_FOUND="Argent name not found",t.NO_ADDRESS_FROM_ARGENT_NAME="Could not get address from Argent name",t.ARGENT_NAME_INVALID_ADDRESS="Argent name resolved to an invalid address",t.NO_ADDRESS_FROM_DOMAIN="Could not get address from domain",t.ARGENT_NAME_INVALID_NETWORK="Argent name is not enabled on the requested network"})(ot||(ot={}));class De extends Oe{constructor(o){super(o,ot),this.name="AddressError"}}class Qe extends Error{constructor(o,g,y){super(o),this.status=g,this.data=y,Object.setPrototypeOf(this,Qe.prototype)}}exports.HTTP_ERROR_MESSAGE=void 0;(function(t){t.FAILED_TO_FETCH_URL="Failed to fetch url",t.FAILED_TO_POST_URL="Failed to post url"})(exports.HTTP_ERROR_MESSAGE||(exports.HTTP_ERROR_MESSAGE={}));const oi=e.z.object({walletAddress:H,ens:Be,chain:e.z.enum(["ethereum","starknet"]),deleted:e.z.boolean(),walletDeployed:e.z.boolean()}).or(e.z.object({status:e.z.string()}));async function ci(t,o,g,y="starknet"){const A={ens:t,chain:y},C=new URLSearchParams(A),b=cr(g,"wallet",`?${C}`);try{const k=await o.get(b),w=k&&"walletAddress"in k?k.walletAddress:void 0;if(!w)throw new De({code:"NO_ADDRESS_FROM_ARGENT_NAME"});if(tr(w))throw new De({code:"ARGENT_NAME_NOT_FOUND",message:`${t} not found`});if(!Qt(w))throw new De({code:"ARGENT_NAME_INVALID_ADDRESS",message:`${t} resolved to an invalid address (${w})`});return xe(w)}catch(k){throw k instanceof Qe&&k.status===404?new De({code:"ARGENT_NAME_NOT_FOUND",message:`${t} not found`}):k}}var ct;(function(t){t.NOT_VALID="Invalid call"})(ct||(ct={}));class li extends Oe{constructor(o){super(o,ct),this.name="CallError"}}var lt;(function(t){t.NO_NETWORK_OR_MULTICALL="Missing networkId or multicall",t.NOT_FOUND="Network not found"})(lt||(lt={}));class ui extends Oe{constructor(o){super(o,lt),this.name="NetworkError"}}const _e=e.z.union([e.z.string(),e.z.number(),e.z.bigint()]),lr=e.z.object({low:_e,high:_e}),ur=e.z.array(e.z.string()).and(e.z.object({__compiled__:e.z.boolean().optional()}).optional()),fr=e.z.lazy(()=>e.z.array(e.z.union([je,e.z.array(je),et]))),je=e.z.union([_e,lr,e.z.any(),e.z.boolean()]),mr=e.z.lazy(()=>e.z.record(e.z.union([je,e.z.array(je),et]))),et=e.z.lazy(()=>e.z.union([mr,fr])),hr=e.z.lazy(()=>e.z.object({contractAddress:e.z.string(),calldata:e.z.union([et,ur]).optional(),entrypoint:e.z.string().optional()})),ut=e.z.lazy(()=>hr.and(e.z.object({entrypoint:e.z.string()}))),fe=e.z.string().refine(t=>typeof parseInt(t)=="number"),fi=e.z.tuple([fe]),mi=e.z.tuple([fe]),hi=e.z.object({new_threshold:e.z.string().refine(t=>typeof parseInt(t)=="number"),signers_to_add:e.z.array(fe)}),di=e.z.object({new_threshold:e.z.string().refine(t=>typeof parseInt(t)=="number"),signers_to_remove:e.z.array(fe)}),pi=e.z.object({signer_to_remove:fe,signer_to_add:fe}),Ei=e.z.tuple([fe]),gi=e.z.tuple([fe]),zi=e.z.tuple([fe]),Si=e.z.tuple([fe]).rest(fe),Ai=e.z.object({recipient:Y,amount:e.z.object({low:_e,high:_e})}),dr=e.z.string().regex(/^(0x)?[0-9a-fA-F]+$/,"Invalid hex string"),Ue=dr.transform(t=>{const o=t.startsWith("0x")?t.slice(2):t;return`0x${o.length%2===0?o:`0${o}`}`}),Ii=e.z.object({cairoVersion:or,accountClassHash:Ue}),Ti=e.z.array(e.z.string()),yi=e.z.object({implementation:e.z.string(),selector:Ue,calldata:Ti}),Ni=e.z.object({owner:e.z.string(),guardian:e.z.string().optional().transform(t=>t??"0")});exports.MultiSigner=void 0;(function(t){t.Starknet="Starknet",t.Secp256k1="Secp256k1",t.Secp256r1="Secp256r1",t.Eip191="Eip191",t.Webauthn="Webauthn"})(exports.MultiSigner||(exports.MultiSigner={}));function vi(t,o){const g={Starknet:void 0,Secp256k1:void 0,Secp256r1:void 0,Eip191:void 0,Webauthn:void 0};return g[o]=t,new W.CairoCustomEnum(g)}var ft;(function(t){t.NOT_FOUND="Account not found",t.CALCULATED_ADDRESS_NO_MATCH="Calculated address does not match account address"})(ft||(ft={}));class Ri extends Oe{constructor(o){super(o,ft),this.name="AccountError"}}function pr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mt={exports:{}};(function(t,o){o=t.exports=P;var g;typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?g=function(){var r=Array.prototype.slice.call(arguments,0);r.unshift("SEMVER"),console.log.apply(console,r)}:g=function(){},o.SEMVER_SPEC_VERSION="2.0.0";var y=256,A=Number.MAX_SAFE_INTEGER||9007199254740991,C=16,b=y-6,k=o.re=[],w=o.safeRe=[],S=o.src=[],p=o.tokens={},Z=0;function D(r){p[r]=Z++}var he="[a-zA-Z0-9-]",te=[["\\s",1],["\\d",y],[he,b]];function Se(r){for(var s=0;s<te.length;s++){var l=te[s][0],I=te[s][1];r=r.split(l+"*").join(l+"{0,"+I+"}").split(l+"+").join(l+"{1,"+I+"}")}return r}D("NUMERICIDENTIFIER"),S[p.NUMERICIDENTIFIER]="0|[1-9]\\d*",D("NUMERICIDENTIFIERLOOSE"),S[p.NUMERICIDENTIFIERLOOSE]="\\d+",D("NONNUMERICIDENTIFIER"),S[p.NONNUMERICIDENTIFIER]="\\d*[a-zA-Z-]"+he+"*",D("MAINVERSION"),S[p.MAINVERSION]="("+S[p.NUMERICIDENTIFIER]+")\\.("+S[p.NUMERICIDENTIFIER]+")\\.("+S[p.NUMERICIDENTIFIER]+")",D("MAINVERSIONLOOSE"),S[p.MAINVERSIONLOOSE]="("+S[p.NUMERICIDENTIFIERLOOSE]+")\\.("+S[p.NUMERICIDENTIFIERLOOSE]+")\\.("+S[p.NUMERICIDENTIFIERLOOSE]+")",D("PRERELEASEIDENTIFIER"),S[p.PRERELEASEIDENTIFIER]="(?:"+S[p.NUMERICIDENTIFIER]+"|"+S[p.NONNUMERICIDENTIFIER]+")",D("PRERELEASEIDENTIFIERLOOSE"),S[p.PRERELEASEIDENTIFIERLOOSE]="(?:"+S[p.NUMERICIDENTIFIERLOOSE]+"|"+S[p.NONNUMERICIDENTIFIER]+")",D("PRERELEASE"),S[p.PRERELEASE]="(?:-("+S[p.PRERELEASEIDENTIFIER]+"(?:\\."+S[p.PRERELEASEIDENTIFIER]+")*))",D("PRERELEASELOOSE"),S[p.PRERELEASELOOSE]="(?:-?("+S[p.PRERELEASEIDENTIFIERLOOSE]+"(?:\\."+S[p.PRERELEASEIDENTIFIERLOOSE]+")*))",D("BUILDIDENTIFIER"),S[p.BUILDIDENTIFIER]=he+"+",D("BUILD"),S[p.BUILD]="(?:\\+("+S[p.BUILDIDENTIFIER]+"(?:\\."+S[p.BUILDIDENTIFIER]+")*))",D("FULL"),D("FULLPLAIN"),S[p.FULLPLAIN]="v?"+S[p.MAINVERSION]+S[p.PRERELEASE]+"?"+S[p.BUILD]+"?",S[p.FULL]="^"+S[p.FULLPLAIN]+"$",D("LOOSEPLAIN"),S[p.LOOSEPLAIN]="[v=\\s]*"+S[p.MAINVERSIONLOOSE]+S[p.PRERELEASELOOSE]+"?"+S[p.BUILD]+"?",D("LOOSE"),S[p.LOOSE]="^"+S[p.LOOSEPLAIN]+"$",D("GTLT"),S[p.GTLT]="((?:<|>)?=?)",D("XRANGEIDENTIFIERLOOSE"),S[p.XRANGEIDENTIFIERLOOSE]=S[p.NUMERICIDENTIFIERLOOSE]+"|x|X|\\*",D("XRANGEIDENTIFIER"),S[p.XRANGEIDENTIFIER]=S[p.NUMERICIDENTIFIER]+"|x|X|\\*",D("XRANGEPLAIN"),S[p.XRANGEPLAIN]="[v=\\s]*("+S[p.XRANGEIDENTIFIER]+")(?:\\.("+S[p.XRANGEIDENTIFIER]+")(?:\\.("+S[p.XRANGEIDENTIFIER]+")(?:"+S[p.PRERELEASE]+")?"+S[p.BUILD]+"?)?)?",D("XRANGEPLAINLOOSE"),S[p.XRANGEPLAINLOOSE]="[v=\\s]*("+S[p.XRANGEIDENTIFIERLOOSE]+")(?:\\.("+S[p.XRANGEIDENTIFIERLOOSE]+")(?:\\.("+S[p.XRANGEIDENTIFIERLOOSE]+")(?:"+S[p.PRERELEASELOOSE]+")?"+S[p.BUILD]+"?)?)?",D("XRANGE"),S[p.XRANGE]="^"+S[p.GTLT]+"\\s*"+S[p.XRANGEPLAIN]+"$",D("XRANGELOOSE"),S[p.XRANGELOOSE]="^"+S[p.GTLT]+"\\s*"+S[p.XRANGEPLAINLOOSE]+"$",D("COERCE"),S[p.COERCE]="(^|[^\\d])(\\d{1,"+C+"})(?:\\.(\\d{1,"+C+"}))?(?:\\.(\\d{1,"+C+"}))?(?:$|[^\\d])",D("COERCERTL"),k[p.COERCERTL]=new RegExp(S[p.COERCE],"g"),w[p.COERCERTL]=new RegExp(Se(S[p.COERCE]),"g"),D("LONETILDE"),S[p.LONETILDE]="(?:~>?)",D("TILDETRIM"),S[p.TILDETRIM]="(\\s*)"+S[p.LONETILDE]+"\\s+",k[p.TILDETRIM]=new RegExp(S[p.TILDETRIM],"g"),w[p.TILDETRIM]=new RegExp(Se(S[p.TILDETRIM]),"g");var Ae="$1~";D("TILDE"),S[p.TILDE]="^"+S[p.LONETILDE]+S[p.XRANGEPLAIN]+"$",D("TILDELOOSE"),S[p.TILDELOOSE]="^"+S[p.LONETILDE]+S[p.XRANGEPLAINLOOSE]+"$",D("LONECARET"),S[p.LONECARET]="(?:\\^)",D("CARETTRIM"),S[p.CARETTRIM]="(\\s*)"+S[p.LONECARET]+"\\s+",k[p.CARETTRIM]=new RegExp(S[p.CARETTRIM],"g"),w[p.CARETTRIM]=new RegExp(Se(S[p.CARETTRIM]),"g");var Le="$1^";D("CARET"),S[p.CARET]="^"+S[p.LONECARET]+S[p.XRANGEPLAIN]+"$",D("CARETLOOSE"),S[p.CARETLOOSE]="^"+S[p.LONECARET]+S[p.XRANGEPLAINLOOSE]+"$",D("COMPARATORLOOSE"),S[p.COMPARATORLOOSE]="^"+S[p.GTLT]+"\\s*("+S[p.LOOSEPLAIN]+")$|^$",D("COMPARATOR"),S[p.COMPARATOR]="^"+S[p.GTLT]+"\\s*("+S[p.FULLPLAIN]+")$|^$",D("COMPARATORTRIM"),S[p.COMPARATORTRIM]="(\\s*)"+S[p.GTLT]+"\\s*("+S[p.LOOSEPLAIN]+"|"+S[p.XRANGEPLAIN]+")",k[p.COMPARATORTRIM]=new RegExp(S[p.COMPARATORTRIM],"g"),w[p.COMPARATORTRIM]=new RegExp(Se(S[p.COMPARATORTRIM]),"g");var v="$1$2$3";D("HYPHENRANGE"),S[p.HYPHENRANGE]="^\\s*("+S[p.XRANGEPLAIN]+")\\s+-\\s+("+S[p.XRANGEPLAIN]+")\\s*$",D("HYPHENRANGELOOSE"),S[p.HYPHENRANGELOOSE]="^\\s*("+S[p.XRANGEPLAINLOOSE]+")\\s+-\\s+("+S[p.XRANGEPLAINLOOSE]+")\\s*$",D("STAR"),S[p.STAR]="(<|>)?=?\\s*\\*";for(var ae=0;ae<Z;ae++)g(ae,S[ae]),k[ae]||(k[ae]=new RegExp(S[ae]),w[ae]=new RegExp(Se(S[ae])));o.parse=pe;function pe(r,s){if((!s||typeof s!="object")&&(s={loose:!!s,includePrerelease:!1}),r instanceof P)return r;if(typeof r!="string"||r.length>y)return null;var l=s.loose?w[p.LOOSE]:w[p.FULL];if(!l.test(r))return null;try{return new P(r,s)}catch{return null}}o.valid=Ce;function Ce(r,s){var l=pe(r,s);return l?l.version:null}o.clean=re;function re(r,s){var l=pe(r.trim().replace(/^[=v]+/,""),s);return l?l.version:null}o.SemVer=P;function P(r,s){if((!s||typeof s!="object")&&(s={loose:!!s,includePrerelease:!1}),r instanceof P){if(r.loose===s.loose)return r;r=r.version}else if(typeof r!="string")throw new TypeError("Invalid Version: "+r);if(r.length>y)throw new TypeError("version is longer than "+y+" characters");if(!(this instanceof P))return new P(r,s);g("SemVer",r,s),this.options=s,this.loose=!!s.loose;var l=r.trim().match(s.loose?w[p.LOOSE]:w[p.FULL]);if(!l)throw new TypeError("Invalid Version: "+r);if(this.raw=r,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>A||this.major<0)throw new TypeError("Invalid major version");if(this.minor>A||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>A||this.patch<0)throw new TypeError("Invalid patch version");l[4]?this.prerelease=l[4].split(".").map(function(I){if(/^[0-9]+$/.test(I)){var N=+I;if(N>=0&&N<A)return N}return I}):this.prerelease=[],this.build=l[5]?l[5].split("."):[],this.format()}P.prototype.format=function(){return this.version=this.major+"."+this.minor+"."+this.patch,this.prerelease.length&&(this.version+="-"+this.prerelease.join(".")),this.version},P.prototype.toString=function(){return this.version},P.prototype.compare=function(r){return g("SemVer.compare",this.version,this.options,r),r instanceof P||(r=new P(r,this.options)),this.compareMain(r)||this.comparePre(r)},P.prototype.compareMain=function(r){return r instanceof P||(r=new P(r,this.options)),h(this.major,r.major)||h(this.minor,r.minor)||h(this.patch,r.patch)},P.prototype.comparePre=function(r){if(r instanceof P||(r=new P(r,this.options)),this.prerelease.length&&!r.prerelease.length)return-1;if(!this.prerelease.length&&r.prerelease.length)return 1;if(!this.prerelease.length&&!r.prerelease.length)return 0;var s=0;do{var l=this.prerelease[s],I=r.prerelease[s];if(g("prerelease compare",s,l,I),l===void 0&&I===void 0)return 0;if(I===void 0)return 1;if(l===void 0)return-1;if(l===I)continue;return h(l,I)}while(++s)},P.prototype.compareBuild=function(r){r instanceof P||(r=new P(r,this.options));var s=0;do{var l=this.build[s],I=r.build[s];if(g("prerelease compare",s,l,I),l===void 0&&I===void 0)return 0;if(I===void 0)return 1;if(l===void 0)return-1;if(l===I)continue;return h(l,I)}while(++s)},P.prototype.inc=function(r,s){switch(r){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",s);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",s);break;case"prepatch":this.prerelease.length=0,this.inc("patch",s),this.inc("pre",s);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",s),this.inc("pre",s);break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":if(this.prerelease.length===0)this.prerelease=[0];else{for(var l=this.prerelease.length;--l>=0;)typeof this.prerelease[l]=="number"&&(this.prerelease[l]++,l=-2);l===-1&&this.prerelease.push(0)}s&&(this.prerelease[0]===s?isNaN(this.prerelease[1])&&(this.prerelease=[s,0]):this.prerelease=[s,0]);break;default:throw new Error("invalid increment argument: "+r)}return this.format(),this.raw=this.version,this},o.inc=n;function n(r,s,l,I){typeof l=="string"&&(I=l,l=void 0);try{return new P(r,l).inc(s,I).version}catch{return null}}o.diff=i;function i(r,s){if(X(r,s))return null;var l=pe(r),I=pe(s),N="";if(l.prerelease.length||I.prerelease.length){N="pre";var R="prerelease"}for(var O in l)if((O==="major"||O==="minor"||O==="patch")&&l[O]!==I[O])return N+O;return R}o.compareIdentifiers=h;var a=/^[0-9]+$/;function h(r,s){var l=a.test(r),I=a.test(s);return l&&I&&(r=+r,s=+s),r===s?0:l&&!I?-1:I&&!l?1:r<s?-1:1}o.rcompareIdentifiers=u;function u(r,s){return h(s,r)}o.major=m;function m(r,s){return new P(r,s).major}o.minor=z;function z(r,s){return new P(r,s).minor}o.patch=c;function c(r,s){return new P(r,s).patch}o.compare=f;function f(r,s,l){return new P(r,l).compare(new P(s,l))}o.compareLoose=E;function E(r,s){return f(r,s,!0)}o.compareBuild=d;function d(r,s,l){var I=new P(r,l),N=new P(s,l);return I.compare(N)||I.compareBuild(N)}o.rcompare=T;function T(r,s,l){return f(s,r,l)}o.sort=_;function _(r,s){return r.sort(function(l,I){return o.compareBuild(l,I,s)})}o.rsort=L;function L(r,s){return r.sort(function(l,I){return o.compareBuild(I,l,s)})}o.gt=F;function F(r,s,l){return f(r,s,l)>0}o.lt=$;function $(r,s,l){return f(r,s,l)<0}o.eq=X;function X(r,s,l){return f(r,s,l)===0}o.neq=B;function B(r,s,l){return f(r,s,l)!==0}o.gte=V;function V(r,s,l){return f(r,s,l)>=0}o.lte=K;function K(r,s,l){return f(r,s,l)<=0}o.cmp=Ie;function Ie(r,s,l,I){switch(s){case"===":return typeof r=="object"&&(r=r.version),typeof l=="object"&&(l=l.version),r===l;case"!==":return typeof r=="object"&&(r=r.version),typeof l=="object"&&(l=l.version),r!==l;case"":case"=":case"==":return X(r,l,I);case"!=":return B(r,l,I);case">":return F(r,l,I);case">=":return V(r,l,I);case"<":return $(r,l,I);case"<=":return K(r,l,I);default:throw new TypeError("Invalid operator: "+s)}}o.Comparator=ee;function ee(r,s){if((!s||typeof s!="object")&&(s={loose:!!s,includePrerelease:!1}),r instanceof ee){if(r.loose===!!s.loose)return r;r=r.value}if(!(this instanceof ee))return new ee(r,s);r=r.trim().split(/\s+/).join(" "),g("comparator",r,s),this.options=s,this.loose=!!s.loose,this.parse(r),this.semver===Ee?this.value="":this.value=this.operator+this.semver.version,g("comp",this)}var Ee={};ee.prototype.parse=function(r){var s=this.options.loose?w[p.COMPARATORLOOSE]:w[p.COMPARATOR],l=r.match(s);if(!l)throw new TypeError("Invalid comparator: "+r);this.operator=l[1]!==void 0?l[1]:"",this.operator==="="&&(this.operator=""),l[2]?this.semver=new P(l[2],this.options.loose):this.semver=Ee},ee.prototype.toString=function(){return this.value},ee.prototype.test=function(r){if(g("Comparator.test",r,this.options.loose),this.semver===Ee||r===Ee)return!0;if(typeof r=="string")try{r=new P(r,this.options)}catch{return!1}return Ie(r,this.operator,this.semver,this.options)},ee.prototype.intersects=function(r,s){if(!(r instanceof ee))throw new TypeError("a Comparator is required");(!s||typeof s!="object")&&(s={loose:!!s,includePrerelease:!1});var l;if(this.operator==="")return this.value===""?!0:(l=new M(r.value,s),Me(this.value,l,s));if(r.operator==="")return r.value===""?!0:(l=new M(this.value,s),Me(r.semver,l,s));var I=(this.operator===">="||this.operator===">")&&(r.operator===">="||r.operator===">"),N=(this.operator==="<="||this.operator==="<")&&(r.operator==="<="||r.operator==="<"),R=this.semver.version===r.semver.version,O=(this.operator===">="||this.operator==="<=")&&(r.operator===">="||r.operator==="<="),G=Ie(this.semver,"<",r.semver,s)&&(this.operator===">="||this.operator===">")&&(r.operator==="<="||r.operator==="<"),U=Ie(this.semver,">",r.semver,s)&&(this.operator==="<="||this.operator==="<")&&(r.operator===">="||r.operator===">");return I||N||R&&O||G||U},o.Range=M;function M(r,s){if((!s||typeof s!="object")&&(s={loose:!!s,includePrerelease:!1}),r instanceof M)return r.loose===!!s.loose&&r.includePrerelease===!!s.includePrerelease?r:new M(r.raw,s);if(r instanceof ee)return new M(r.value,s);if(!(this instanceof M))return new M(r,s);if(this.options=s,this.loose=!!s.loose,this.includePrerelease=!!s.includePrerelease,this.raw=r.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map(function(l){return this.parseRange(l.trim())},this).filter(function(l){return l.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+this.raw);this.format()}M.prototype.format=function(){return this.range=this.set.map(function(r){return r.join(" ").trim()}).join("||").trim(),this.range},M.prototype.toString=function(){return this.range},M.prototype.parseRange=function(r){var s=this.options.loose,l=s?w[p.HYPHENRANGELOOSE]:w[p.HYPHENRANGE];r=r.replace(l,bn),g("hyphen replace",r),r=r.replace(w[p.COMPARATORTRIM],v),g("comparator trim",r,w[p.COMPARATORTRIM]),r=r.replace(w[p.TILDETRIM],Ae),r=r.replace(w[p.CARETTRIM],Le),r=r.split(/\s+/).join(" ");var I=s?w[p.COMPARATORLOOSE]:w[p.COMPARATOR],N=r.split(" ").map(function(R){return Q(R,this.options)},this).join(" ").split(/\s+/);return this.options.loose&&(N=N.filter(function(R){return!!R.match(I)})),N=N.map(function(R){return new ee(R,this.options)},this),N},M.prototype.intersects=function(r,s){if(!(r instanceof M))throw new TypeError("a Range is required");return this.set.some(function(l){return ye(l,s)&&r.set.some(function(I){return ye(I,s)&&l.every(function(N){return I.every(function(R){return N.intersects(R,s)})})})})};function ye(r,s){for(var l=!0,I=r.slice(),N=I.pop();l&&I.length;)l=I.every(function(R){return N.intersects(R,s)}),N=I.pop();return l}o.toComparators=ne;function ne(r,s){return new M(r,s).set.map(function(l){return l.map(function(I){return I.value}).join(" ").trim().split(" ")})}function Q(r,s){return g("comp",r,s),r=yn(r,s),g("caret",r),r=In(r,s),g("tildes",r),r=vn(r,s),g("xrange",r),r=On(r,s),g("stars",r),r}function x(r){return!r||r.toLowerCase()==="x"||r==="*"}function In(r,s){return r.trim().split(/\s+/).map(function(l){return Tn(l,s)}).join(" ")}function Tn(r,s){var l=s.loose?w[p.TILDELOOSE]:w[p.TILDE];return r.replace(l,function(I,N,R,O,G){g("tilde",r,I,N,R,O,G);var U;return x(N)?U="":x(R)?U=">="+N+".0.0 <"+(+N+1)+".0.0":x(O)?U=">="+N+"."+R+".0 <"+N+"."+(+R+1)+".0":G?(g("replaceTilde pr",G),U=">="+N+"."+R+"."+O+"-"+G+" <"+N+"."+(+R+1)+".0"):U=">="+N+"."+R+"."+O+" <"+N+"."+(+R+1)+".0",g("tilde return",U),U})}function yn(r,s){return r.trim().split(/\s+/).map(function(l){return Nn(l,s)}).join(" ")}function Nn(r,s){g("caret",r,s);var l=s.loose?w[p.CARETLOOSE]:w[p.CARET];return r.replace(l,function(I,N,R,O,G){g("caret",r,I,N,R,O,G);var U;return x(N)?U="":x(R)?U=">="+N+".0.0 <"+(+N+1)+".0.0":x(O)?N==="0"?U=">="+N+"."+R+".0 <"+N+"."+(+R+1)+".0":U=">="+N+"."+R+".0 <"+(+N+1)+".0.0":G?(g("replaceCaret pr",G),N==="0"?R==="0"?U=">="+N+"."+R+"."+O+"-"+G+" <"+N+"."+R+"."+(+O+1):U=">="+N+"."+R+"."+O+"-"+G+" <"+N+"."+(+R+1)+".0":U=">="+N+"."+R+"."+O+"-"+G+" <"+(+N+1)+".0.0"):(g("no pr"),N==="0"?R==="0"?U=">="+N+"."+R+"."+O+" <"+N+"."+R+"."+(+O+1):U=">="+N+"."+R+"."+O+" <"+N+"."+(+R+1)+".0":U=">="+N+"."+R+"."+O+" <"+(+N+1)+".0.0"),g("caret return",U),U})}function vn(r,s){return g("replaceXRanges",r,s),r.split(/\s+/).map(function(l){return Rn(l,s)}).join(" ")}function Rn(r,s){r=r.trim();var l=s.loose?w[p.XRANGELOOSE]:w[p.XRANGE];return r.replace(l,function(I,N,R,O,G,U){g("xRange",r,I,N,R,O,G,U);var ge=x(R),ze=ge||x(O),oe=ze||x(G),se=oe;return N==="="&&se&&(N=""),U=s.includePrerelease?"-0":"",ge?N===">"||N==="<"?I="<0.0.0-0":I="*":N&&se?(ze&&(O=0),G=0,N===">"?(N=">=",ze?(R=+R+1,O=0,G=0):(O=+O+1,G=0)):N==="<="&&(N="<",ze?R=+R+1:O=+O+1),I=N+R+"."+O+"."+G+U):ze?I=">="+R+".0.0"+U+" <"+(+R+1)+".0.0"+U:oe&&(I=">="+R+"."+O+".0"+U+" <"+R+"."+(+O+1)+".0"+U),g("xRange return",I),I})}function On(r,s){return g("replaceStars",r,s),r.trim().replace(w[p.STAR],"")}function bn(r,s,l,I,N,R,O,G,U,ge,ze,oe,se){return x(l)?s="":x(I)?s=">="+l+".0.0":x(N)?s=">="+l+"."+I+".0":s=">="+s,x(U)?G="":x(ge)?G="<"+(+U+1)+".0.0":x(ze)?G="<"+U+"."+(+ge+1)+".0":oe?G="<="+U+"."+ge+"."+ze+"-"+oe:G="<="+G,(s+" "+G).trim()}M.prototype.test=function(r){if(!r)return!1;if(typeof r=="string")try{r=new P(r,this.options)}catch{return!1}for(var s=0;s<this.set.length;s++)if(_n(this.set[s],r,this.options))return!0;return!1};function _n(r,s,l){for(var I=0;I<r.length;I++)if(!r[I].test(s))return!1;if(s.prerelease.length&&!l.includePrerelease){for(I=0;I<r.length;I++)if(g(r[I].semver),r[I].semver!==Ee&&r[I].semver.prerelease.length>0){var N=r[I].semver;if(N.major===s.major&&N.minor===s.minor&&N.patch===s.patch)return!0}return!1}return!0}o.satisfies=Me;function Me(r,s,l){try{s=new M(s,l)}catch{return!1}return s.test(r)}o.maxSatisfying=wn;function wn(r,s,l){var I=null,N=null;try{var R=new M(s,l)}catch{return null}return r.forEach(function(O){R.test(O)&&(!I||N.compare(O)===-1)&&(I=O,N=new P(I,l))}),I}o.minSatisfying=Ln;function Ln(r,s,l){var I=null,N=null;try{var R=new M(s,l)}catch{return null}return r.forEach(function(O){R.test(O)&&(!I||N.compare(O)===1)&&(I=O,N=new P(I,l))}),I}o.minVersion=Cn;function Cn(r,s){r=new M(r,s);var l=new P("0.0.0");if(r.test(l)||(l=new P("0.0.0-0"),r.test(l)))return l;l=null;for(var I=0;I<r.set.length;++I){var N=r.set[I];N.forEach(function(R){var O=new P(R.semver.version);switch(R.operator){case">":O.prerelease.length===0?O.patch++:O.prerelease.push(0),O.raw=O.format();case"":case">=":(!l||F(l,O))&&(l=O);break;case"<":case"<=":break;default:throw new Error("Unexpected operation: "+R.operator)}})}return l&&r.test(l)?l:null}o.validRange=Dn;function Dn(r,s){try{return new M(r,s).range||"*"}catch{return null}}o.ltr=Pn;function Pn(r,s,l){return rt(r,s,"<",l)}o.gtr=kn;function kn(r,s,l){return rt(r,s,">",l)}o.outside=rt;function rt(r,s,l,I){r=new P(r,I),s=new M(s,I);var N,R,O,G,U;switch(l){case">":N=F,R=K,O=$,G=">",U=">=";break;case"<":N=$,R=V,O=F,G="<",U="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(Me(r,s,I))return!1;for(var ge=0;ge<s.set.length;++ge){var ze=s.set[ge],oe=null,se=null;if(ze.forEach(function(Ne){Ne.semver===Ee&&(Ne=new ee(">=0.0.0")),oe=oe||Ne,se=se||Ne,N(Ne.semver,oe.semver,I)?oe=Ne:O(Ne.semver,se.semver,I)&&(se=Ne)}),oe.operator===G||oe.operator===U||(!se.operator||se.operator===G)&&R(r,se.semver))return!1;if(se.operator===U&&O(r,se.semver))return!1}return!0}o.prerelease=jn;function jn(r,s){var l=pe(r,s);return l&&l.prerelease.length?l.prerelease:null}o.intersects=Un;function Un(r,s,l){return r=new M(r,l),s=new M(s,l),r.intersects(s)}o.coerce=Fn;function Fn(r,s){if(r instanceof P)return r;if(typeof r=="number"&&(r=String(r)),typeof r!="string")return null;s=s||{};var l=null;if(!s.rtl)l=r.match(w[p.COERCE]);else{for(var I;(I=w[p.COERCERTL].exec(r))&&(!l||l.index+l[0].length!==r.length);)(!l||I.index+I[0].length!==l.index+l[0].length)&&(l=I),w[p.COERCERTL].lastIndex=I.index+I[1].length+I[2].length;w[p.COERCERTL].lastIndex=-1}return l===null?null:pe(l[2]+"."+(l[3]||"0")+"."+(l[4]||"0"),s)}})(mt,mt.exports);var Oi=mt.exports;const bi=pr(Oi),_i=t=>t==null?[]:Array.isArray(t)?t:[t],wi=e.z.any().refine(t=>typeof t=="bigint",{message:"Value must be a BigInt"}).transform(t=>BigInt(t));var Li=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,nt=Math.ceil,le=Math.floor,ie="[BigNumber Error] ",Vt=ie+"Number primitive has more than 15 significant digits: ",de=1e14,j=14,it=9007199254740991,at=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],ve=1e7,J=1e9;function Er(t){var o,g,y,A=v.prototype={constructor:v,toString:null,valueOf:null},C=new v(1),b=20,k=4,w=-7,S=21,p=-1e7,Z=1e7,D=!1,he=1,te=0,Se={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},Ae="0123456789abcdefghijklmnopqrstuvwxyz",Le=!0;function v(n,i){var a,h,u,m,z,c,f,E,d=this;if(!(d instanceof v))return new v(n,i);if(i==null){if(n&&n._isBigNumber===!0){d.s=n.s,!n.c||n.e>Z?d.c=d.e=null:n.e<p?d.c=[d.e=0]:(d.e=n.e,d.c=n.c.slice());return}if((c=typeof n=="number")&&n*0==0){if(d.s=1/n<0?(n=-n,-1):1,n===~~n){for(m=0,z=n;z>=10;z/=10,m++);m>Z?d.c=d.e=null:(d.e=m,d.c=[n]);return}E=String(n)}else{if(!Li.test(E=String(n)))return y(d,E,c);d.s=E.charCodeAt(0)==45?(E=E.slice(1),-1):1}(m=E.indexOf("."))>-1&&(E=E.replace(".","")),(z=E.search(/e/i))>0?(m<0&&(m=z),m+=+E.slice(z+1),E=E.substring(0,z)):m<0&&(m=E.length)}else{if(q(i,2,Ae.length,"Base"),i==10&&Le)return d=new v(n),re(d,b+d.e+1,k);if(E=String(n),c=typeof n=="number"){if(n*0!=0)return y(d,E,c,i);if(d.s=1/n<0?(E=E.slice(1),-1):1,v.DEBUG&&E.replace(/^0\.0*|\./,"").length>15)throw Error(Vt+n)}else d.s=E.charCodeAt(0)===45?(E=E.slice(1),-1):1;for(a=Ae.slice(0,i),m=z=0,f=E.length;z<f;z++)if(a.indexOf(h=E.charAt(z))<0){if(h=="."){if(z>m){m=f;continue}}else if(!u&&(E==E.toUpperCase()&&(E=E.toLowerCase())||E==E.toLowerCase()&&(E=E.toUpperCase()))){u=!0,z=-1,m=0;continue}return y(d,String(n),c,i)}c=!1,E=g(E,i,10,d.s),(m=E.indexOf("."))>-1?E=E.replace(".",""):m=E.length}for(z=0;E.charCodeAt(z)===48;z++);for(f=E.length;E.charCodeAt(--f)===48;);if(E=E.slice(z,++f)){if(f-=z,c&&v.DEBUG&&f>15&&(n>it||n!==le(n)))throw Error(Vt+d.s*n);if((m=m-z-1)>Z)d.c=d.e=null;else if(m<p)d.c=[d.e=0];else{if(d.e=m,d.c=[],z=(m+1)%j,m<0&&(z+=j),z<f){for(z&&d.c.push(+E.slice(0,z)),f-=j;z<f;)d.c.push(+E.slice(z,z+=j));z=j-(E=E.slice(z)).length}else z-=f;for(;z--;E+="0");d.c.push(+E)}}else d.c=[d.e=0]}v.clone=Er,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(n){var i,a;if(n!=null)if(typeof n=="object"){if(n.hasOwnProperty(i="DECIMAL_PLACES")&&(a=n[i],q(a,0,J,i),b=a),n.hasOwnProperty(i="ROUNDING_MODE")&&(a=n[i],q(a,0,8,i),k=a),n.hasOwnProperty(i="EXPONENTIAL_AT")&&(a=n[i],a&&a.pop?(q(a[0],-J,0,i),q(a[1],0,J,i),w=a[0],S=a[1]):(q(a,-J,J,i),w=-(S=a<0?-a:a))),n.hasOwnProperty(i="RANGE"))if(a=n[i],a&&a.pop)q(a[0],-J,-1,i),q(a[1],1,J,i),p=a[0],Z=a[1];else if(q(a,-J,J,i),a)p=-(Z=a<0?-a:a);else throw Error(ie+i+" cannot be zero: "+a);if(n.hasOwnProperty(i="CRYPTO"))if(a=n[i],a===!!a)if(a)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))D=a;else throw D=!a,Error(ie+"crypto unavailable");else D=a;else throw Error(ie+i+" not true or false: "+a);if(n.hasOwnProperty(i="MODULO_MODE")&&(a=n[i],q(a,0,9,i),he=a),n.hasOwnProperty(i="POW_PRECISION")&&(a=n[i],q(a,0,J,i),te=a),n.hasOwnProperty(i="FORMAT"))if(a=n[i],typeof a=="object")Se=a;else throw Error(ie+i+" not an object: "+a);if(n.hasOwnProperty(i="ALPHABET"))if(a=n[i],typeof a=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(a))Le=a.slice(0,10)=="0123456789",Ae=a;else throw Error(ie+i+" invalid: "+a)}else throw Error(ie+"Object expected: "+n);return{DECIMAL_PLACES:b,ROUNDING_MODE:k,EXPONENTIAL_AT:[w,S],RANGE:[p,Z],CRYPTO:D,MODULO_MODE:he,POW_PRECISION:te,FORMAT:Se,ALPHABET:Ae}},v.isBigNumber=function(n){if(!n||n._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var i,a,h=n.c,u=n.e,m=n.s;e:if({}.toString.call(h)=="[object Array]"){if((m===1||m===-1)&&u>=-J&&u<=J&&u===le(u)){if(h[0]===0){if(u===0&&h.length===1)return!0;break e}if(i=(u+1)%j,i<1&&(i+=j),String(h[0]).length==i){for(i=0;i<h.length;i++)if(a=h[i],a<0||a>=de||a!==le(a))break e;if(a!==0)return!0}}}else if(h===null&&u===null&&(m===null||m===1||m===-1))return!0;throw Error(ie+"Invalid BigNumber: "+n)},v.maximum=v.max=function(){return pe(arguments,-1)},v.minimum=v.min=function(){return pe(arguments,1)},v.random=function(){var n=9007199254740992,i=Math.random()*n&2097151?function(){return le(Math.random()*n)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(a){var h,u,m,z,c,f=0,E=[],d=new v(C);if(a==null?a=b:q(a,0,J),z=nt(a/j),D)if(crypto.getRandomValues){for(h=crypto.getRandomValues(new Uint32Array(z*=2));f<z;)c=h[f]*131072+(h[f+1]>>>11),c>=9e15?(u=crypto.getRandomValues(new Uint32Array(2)),h[f]=u[0],h[f+1]=u[1]):(E.push(c%1e14),f+=2);f=z/2}else if(crypto.randomBytes){for(h=crypto.randomBytes(z*=7);f<z;)c=(h[f]&31)*281474976710656+h[f+1]*1099511627776+h[f+2]*4294967296+h[f+3]*16777216+(h[f+4]<<16)+(h[f+5]<<8)+h[f+6],c>=9e15?crypto.randomBytes(7).copy(h,f):(E.push(c%1e14),f+=7);f=z/7}else throw D=!1,Error(ie+"crypto unavailable");if(!D)for(;f<z;)c=i(),c<9e15&&(E[f++]=c%1e14);for(z=E[--f],a%=j,z&&a&&(c=at[j-a],E[f]=le(z/c)*c);E[f]===0;E.pop(),f--);if(f<0)E=[m=0];else{for(m=-1;E[0]===0;E.splice(0,1),m-=j);for(f=1,c=E[0];c>=10;c/=10,f++);f<j&&(m-=j-f)}return d.e=m,d.c=E,d}}(),v.sum=function(){for(var n=1,i=arguments,a=new v(i[0]);n<i.length;)a=a.plus(i[n++]);return a},g=function(){var n="0123456789";function i(a,h,u,m){for(var z,c=[0],f,E=0,d=a.length;E<d;){for(f=c.length;f--;c[f]*=h);for(c[0]+=m.indexOf(a.charAt(E++)),z=0;z<c.length;z++)c[z]>u-1&&(c[z+1]==null&&(c[z+1]=0),c[z+1]+=c[z]/u|0,c[z]%=u)}return c.reverse()}return function(a,h,u,m,z){var c,f,E,d,T,_,L,F,$=a.indexOf("."),X=b,B=k;for($>=0&&(d=te,te=0,a=a.replace(".",""),F=new v(h),_=F.pow(a.length-$),te=d,F.c=i(Te(ce(_.c),_.e,"0"),10,u,n),F.e=F.c.length),L=i(a,h,u,z?(c=Ae,n):(c=n,Ae)),E=d=L.length;L[--d]==0;L.pop());if(!L[0])return c.charAt(0);if($<0?--E:(_.c=L,_.e=E,_.s=m,_=o(_,F,X,B,u),L=_.c,T=_.r,E=_.e),f=E+X+1,$=L[f],d=u/2,T=T||f<0||L[f+1]!=null,T=B<4?($!=null||T)&&(B==0||B==(_.s<0?3:2)):$>d||$==d&&(B==4||T||B==6&&L[f-1]&1||B==(_.s<0?8:7)),f<1||!L[0])a=T?Te(c.charAt(1),-X,c.charAt(0)):c.charAt(0);else{if(L.length=f,T)for(--u;++L[--f]>u;)L[f]=0,f||(++E,L=[1].concat(L));for(d=L.length;!L[--d];);for($=0,a="";$<=d;a+=c.charAt(L[$++]));a=Te(a,E,c.charAt(0))}return a}}(),o=function(){function n(h,u,m){var z,c,f,E,d=0,T=h.length,_=u%ve,L=u/ve|0;for(h=h.slice();T--;)f=h[T]%ve,E=h[T]/ve|0,z=L*f+E*_,c=_*f+z%ve*ve+d,d=(c/m|0)+(z/ve|0)+L*E,h[T]=c%m;return d&&(h=[d].concat(h)),h}function i(h,u,m,z){var c,f;if(m!=z)f=m>z?1:-1;else for(c=f=0;c<m;c++)if(h[c]!=u[c]){f=h[c]>u[c]?1:-1;break}return f}function a(h,u,m,z){for(var c=0;m--;)h[m]-=c,c=h[m]<u[m]?1:0,h[m]=c*z+h[m]-u[m];for(;!h[0]&&h.length>1;h.splice(0,1));}return function(h,u,m,z,c){var f,E,d,T,_,L,F,$,X,B,V,K,Ie,ee,Ee,M,ye,ne=h.s==u.s?1:-1,Q=h.c,x=u.c;if(!Q||!Q[0]||!x||!x[0])return new v(!h.s||!u.s||(Q?x&&Q[0]==x[0]:!x)?NaN:Q&&Q[0]==0||!x?ne*0:ne/0);for($=new v(ne),X=$.c=[],E=h.e-u.e,ne=m+E+1,c||(c=de,E=ue(h.e/j)-ue(u.e/j),ne=ne/j|0),d=0;x[d]==(Q[d]||0);d++);if(x[d]>(Q[d]||0)&&E--,ne<0)X.push(1),T=!0;else{for(ee=Q.length,M=x.length,d=0,ne+=2,_=le(c/(x[0]+1)),_>1&&(x=n(x,_,c),Q=n(Q,_,c),M=x.length,ee=Q.length),Ie=M,B=Q.slice(0,M),V=B.length;V<M;B[V++]=0);ye=x.slice(),ye=[0].concat(ye),Ee=x[0],x[1]>=c/2&&Ee++;do{if(_=0,f=i(x,B,M,V),f<0){if(K=B[0],M!=V&&(K=K*c+(B[1]||0)),_=le(K/Ee),_>1)for(_>=c&&(_=c-1),L=n(x,_,c),F=L.length,V=B.length;i(L,B,F,V)==1;)_--,a(L,M<F?ye:x,F,c),F=L.length,f=1;else _==0&&(f=_=1),L=x.slice(),F=L.length;if(F<V&&(L=[0].concat(L)),a(B,L,V,c),V=B.length,f==-1)for(;i(x,B,M,V)<1;)_++,a(B,M<V?ye:x,V,c),V=B.length}else f===0&&(_++,B=[0]);X[d++]=_,B[0]?B[V++]=Q[Ie]||0:(B=[Q[Ie]],V=1)}while((Ie++<ee||B[0]!=null)&&ne--);T=B[0]!=null,X[0]||X.splice(0,1)}if(c==de){for(d=1,ne=X[0];ne>=10;ne/=10,d++);re($,m+($.e=d+E*j-1)+1,z,T)}else $.e=E,$.r=+T;return $}}();function ae(n,i,a,h){var u,m,z,c,f;if(a==null?a=k:q(a,0,8),!n.c)return n.toString();if(u=n.c[0],z=n.e,i==null)f=ce(n.c),f=h==1||h==2&&(z<=w||z>=S)?Ve(f,z):Te(f,z,"0");else if(n=re(new v(n),i,a),m=n.e,f=ce(n.c),c=f.length,h==1||h==2&&(i<=m||m<=w)){for(;c<i;f+="0",c++);f=Ve(f,m)}else if(i-=z,f=Te(f,m,"0"),m+1>c){if(--i>0)for(f+=".";i--;f+="0");}else if(i+=m-c,i>0)for(m+1==c&&(f+=".");i--;f+="0");return n.s<0&&u?"-"+f:f}function pe(n,i){for(var a,h,u=1,m=new v(n[0]);u<n.length;u++)h=new v(n[u]),(!h.s||(a=be(m,h))===i||a===0&&m.s===i)&&(m=h);return m}function Ce(n,i,a){for(var h=1,u=i.length;!i[--u];i.pop());for(u=i[0];u>=10;u/=10,h++);return(a=h+a*j-1)>Z?n.c=n.e=null:a<p?n.c=[n.e=0]:(n.e=a,n.c=i),n}y=function(){var n=/^(-?)0([xbo])(?=\w[\w.]*$)/i,i=/^([^.]+)\.$/,a=/^\.([^.]+)$/,h=/^-?(Infinity|NaN)$/,u=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(m,z,c,f){var E,d=c?z:z.replace(u,"");if(h.test(d))m.s=isNaN(d)?null:d<0?-1:1;else{if(!c&&(d=d.replace(n,function(T,_,L){return E=(L=L.toLowerCase())=="x"?16:L=="b"?2:8,!f||f==E?_:T}),f&&(E=f,d=d.replace(i,"$1").replace(a,"0.$1")),z!=d))return new v(d,E);if(v.DEBUG)throw Error(ie+"Not a"+(f?" base "+f:"")+" number: "+z);m.s=null}m.c=m.e=null}}();function re(n,i,a,h){var u,m,z,c,f,E,d,T=n.c,_=at;if(T){e:{for(u=1,c=T[0];c>=10;c/=10,u++);if(m=i-u,m<0)m+=j,z=i,f=T[E=0],d=le(f/_[u-z-1]%10);else if(E=nt((m+1)/j),E>=T.length)if(h){for(;T.length<=E;T.push(0));f=d=0,u=1,m%=j,z=m-j+1}else break e;else{for(f=c=T[E],u=1;c>=10;c/=10,u++);m%=j,z=m-j+u,d=z<0?0:le(f/_[u-z-1]%10)}if(h=h||i<0||T[E+1]!=null||(z<0?f:f%_[u-z-1]),h=a<4?(d||h)&&(a==0||a==(n.s<0?3:2)):d>5||d==5&&(a==4||h||a==6&&(m>0?z>0?f/_[u-z]:0:T[E-1])%10&1||a==(n.s<0?8:7)),i<1||!T[0])return T.length=0,h?(i-=n.e+1,T[0]=_[(j-i%j)%j],n.e=-i||0):T[0]=n.e=0,n;if(m==0?(T.length=E,c=1,E--):(T.length=E+1,c=_[j-m],T[E]=z>0?le(f/_[u-z]%_[z])*c:0),h)for(;;)if(E==0){for(m=1,z=T[0];z>=10;z/=10,m++);for(z=T[0]+=c,c=1;z>=10;z/=10,c++);m!=c&&(n.e++,T[0]==de&&(T[0]=1));break}else{if(T[E]+=c,T[E]!=de)break;T[E--]=0,c=1}for(m=T.length;T[--m]===0;T.pop());}n.e>Z?n.c=n.e=null:n.e<p&&(n.c=[n.e=0])}return n}function P(n){var i,a=n.e;return a===null?n.toString():(i=ce(n.c),i=a<=w||a>=S?Ve(i,a):Te(i,a,"0"),n.s<0?"-"+i:i)}return A.absoluteValue=A.abs=function(){var n=new v(this);return n.s<0&&(n.s=1),n},A.comparedTo=function(n,i){return be(this,new v(n,i))},A.decimalPlaces=A.dp=function(n,i){var a,h,u,m=this;if(n!=null)return q(n,0,J),i==null?i=k:q(i,0,8),re(new v(m),n+m.e+1,i);if(!(a=m.c))return null;if(h=((u=a.length-1)-ue(this.e/j))*j,u=a[u])for(;u%10==0;u/=10,h--);return h<0&&(h=0),h},A.dividedBy=A.div=function(n,i){return o(this,new v(n,i),b,k)},A.dividedToIntegerBy=A.idiv=function(n,i){return o(this,new v(n,i),0,1)},A.exponentiatedBy=A.pow=function(n,i){var a,h,u,m,z,c,f,E,d,T=this;if(n=new v(n),n.c&&!n.isInteger())throw Error(ie+"Exponent not an integer: "+P(n));if(i!=null&&(i=new v(i)),c=n.e>14,!T.c||!T.c[0]||T.c[0]==1&&!T.e&&T.c.length==1||!n.c||!n.c[0])return d=new v(Math.pow(+P(T),c?n.s*(2-Ge(n)):+P(n))),i?d.mod(i):d;if(f=n.s<0,i){if(i.c?!i.c[0]:!i.s)return new v(NaN);h=!f&&T.isInteger()&&i.isInteger(),h&&(T=T.mod(i))}else{if(n.e>9&&(T.e>0||T.e<-1||(T.e==0?T.c[0]>1||c&&T.c[1]>=24e7:T.c[0]<8e13||c&&T.c[0]<=9999975e7)))return m=T.s<0&&Ge(n)?-0:0,T.e>-1&&(m=1/m),new v(f?1/m:m);te&&(m=nt(te/j+2))}for(c?(a=new v(.5),f&&(n.s=1),E=Ge(n)):(u=Math.abs(+P(n)),E=u%2),d=new v(C);;){if(E){if(d=d.times(T),!d.c)break;m?d.c.length>m&&(d.c.length=m):h&&(d=d.mod(i))}if(u){if(u=le(u/2),u===0)break;E=u%2}else if(n=n.times(a),re(n,n.e+1,1),n.e>14)E=Ge(n);else{if(u=+P(n),u===0)break;E=u%2}T=T.times(T),m?T.c&&T.c.length>m&&(T.c.length=m):h&&(T=T.mod(i))}return h?d:(f&&(d=C.div(d)),i?d.mod(i):m?re(d,te,k,z):d)},A.integerValue=function(n){var i=new v(this);return n==null?n=k:q(n,0,8),re(i,i.e+1,n)},A.isEqualTo=A.eq=function(n,i){return be(this,new v(n,i))===0},A.isFinite=function(){return!!this.c},A.isGreaterThan=A.gt=function(n,i){return be(this,new v(n,i))>0},A.isGreaterThanOrEqualTo=A.gte=function(n,i){return(i=be(this,new v(n,i)))===1||i===0},A.isInteger=function(){return!!this.c&&ue(this.e/j)>this.c.length-2},A.isLessThan=A.lt=function(n,i){return be(this,new v(n,i))<0},A.isLessThanOrEqualTo=A.lte=function(n,i){return(i=be(this,new v(n,i)))===-1||i===0},A.isNaN=function(){return!this.s},A.isNegative=function(){return this.s<0},A.isPositive=function(){return this.s>0},A.isZero=function(){return!!this.c&&this.c[0]==0},A.minus=function(n,i){var a,h,u,m,z=this,c=z.s;if(n=new v(n,i),i=n.s,!c||!i)return new v(NaN);if(c!=i)return n.s=-i,z.plus(n);var f=z.e/j,E=n.e/j,d=z.c,T=n.c;if(!f||!E){if(!d||!T)return d?(n.s=-i,n):new v(T?z:NaN);if(!d[0]||!T[0])return T[0]?(n.s=-i,n):new v(d[0]?z:k==3?-0:0)}if(f=ue(f),E=ue(E),d=d.slice(),c=f-E){for((m=c<0)?(c=-c,u=d):(E=f,u=T),u.reverse(),i=c;i--;u.push(0));u.reverse()}else for(h=(m=(c=d.length)<(i=T.length))?c:i,c=i=0;i<h;i++)if(d[i]!=T[i]){m=d[i]<T[i];break}if(m&&(u=d,d=T,T=u,n.s=-n.s),i=(h=T.length)-(a=d.length),i>0)for(;i--;d[a++]=0);for(i=de-1;h>c;){if(d[--h]<T[h]){for(a=h;a&&!d[--a];d[a]=i);--d[a],d[h]+=de}d[h]-=T[h]}for(;d[0]==0;d.splice(0,1),--E);return d[0]?Ce(n,d,E):(n.s=k==3?-1:1,n.c=[n.e=0],n)},A.modulo=A.mod=function(n,i){var a,h,u=this;return n=new v(n,i),!u.c||!n.s||n.c&&!n.c[0]?new v(NaN):!n.c||u.c&&!u.c[0]?new v(u):(he==9?(h=n.s,n.s=1,a=o(u,n,0,3),n.s=h,a.s*=h):a=o(u,n,0,he),n=u.minus(a.times(n)),!n.c[0]&&he==1&&(n.s=u.s),n)},A.multipliedBy=A.times=function(n,i){var a,h,u,m,z,c,f,E,d,T,_,L,F,$,X,B=this,V=B.c,K=(n=new v(n,i)).c;if(!V||!K||!V[0]||!K[0])return!B.s||!n.s||V&&!V[0]&&!K||K&&!K[0]&&!V?n.c=n.e=n.s=null:(n.s*=B.s,!V||!K?n.c=n.e=null:(n.c=[0],n.e=0)),n;for(h=ue(B.e/j)+ue(n.e/j),n.s*=B.s,f=V.length,T=K.length,f<T&&(F=V,V=K,K=F,u=f,f=T,T=u),u=f+T,F=[];u--;F.push(0));for($=de,X=ve,u=T;--u>=0;){for(a=0,_=K[u]%X,L=K[u]/X|0,z=f,m=u+z;m>u;)E=V[--z]%X,d=V[z]/X|0,c=L*E+d*_,E=_*E+c%X*X+F[m]+a,a=(E/$|0)+(c/X|0)+L*d,F[m--]=E%$;F[m]=a}return a?++h:F.splice(0,1),Ce(n,F,h)},A.negated=function(){var n=new v(this);return n.s=-n.s||null,n},A.plus=function(n,i){var a,h=this,u=h.s;if(n=new v(n,i),i=n.s,!u||!i)return new v(NaN);if(u!=i)return n.s=-i,h.minus(n);var m=h.e/j,z=n.e/j,c=h.c,f=n.c;if(!m||!z){if(!c||!f)return new v(u/0);if(!c[0]||!f[0])return f[0]?n:new v(c[0]?h:u*0)}if(m=ue(m),z=ue(z),c=c.slice(),u=m-z){for(u>0?(z=m,a=f):(u=-u,a=c),a.reverse();u--;a.push(0));a.reverse()}for(u=c.length,i=f.length,u-i<0&&(a=f,f=c,c=a,i=u),u=0;i;)u=(c[--i]=c[i]+f[i]+u)/de|0,c[i]=de===c[i]?0:c[i]%de;return u&&(c=[u].concat(c),++z),Ce(n,c,z)},A.precision=A.sd=function(n,i){var a,h,u,m=this;if(n!=null&&n!==!!n)return q(n,1,J),i==null?i=k:q(i,0,8),re(new v(m),n,i);if(!(a=m.c))return null;if(u=a.length-1,h=u*j+1,u=a[u]){for(;u%10==0;u/=10,h--);for(u=a[0];u>=10;u/=10,h++);}return n&&m.e+1>h&&(h=m.e+1),h},A.shiftedBy=function(n){return q(n,-it,it),this.times("1e"+n)},A.squareRoot=A.sqrt=function(){var n,i,a,h,u,m=this,z=m.c,c=m.s,f=m.e,E=b+4,d=new v("0.5");if(c!==1||!z||!z[0])return new v(!c||c<0&&(!z||z[0])?NaN:z?m:1/0);if(c=Math.sqrt(+P(m)),c==0||c==1/0?(i=ce(z),(i.length+f)%2==0&&(i+="0"),c=Math.sqrt(+i),f=ue((f+1)/2)-(f<0||f%2),c==1/0?i="5e"+f:(i=c.toExponential(),i=i.slice(0,i.indexOf("e")+1)+f),a=new v(i)):a=new v(c+""),a.c[0]){for(f=a.e,c=f+E,c<3&&(c=0);;)if(u=a,a=d.times(u.plus(o(m,u,E,1))),ce(u.c).slice(0,c)===(i=ce(a.c)).slice(0,c))if(a.e<f&&--c,i=i.slice(c-3,c+1),i=="9999"||!h&&i=="4999"){if(!h&&(re(u,u.e+b+2,0),u.times(u).eq(m))){a=u;break}E+=4,c+=4,h=1}else{(!+i||!+i.slice(1)&&i.charAt(0)=="5")&&(re(a,a.e+b+2,1),n=!a.times(a).eq(m));break}}return re(a,a.e+b+1,k,n)},A.toExponential=function(n,i){return n!=null&&(q(n,0,J),n++),ae(this,n,i,1)},A.toFixed=function(n,i){return n!=null&&(q(n,0,J),n=n+this.e+1),ae(this,n,i)},A.toFormat=function(n,i,a){var h,u=this;if(a==null)n!=null&&i&&typeof i=="object"?(a=i,i=null):n&&typeof n=="object"?(a=n,n=i=null):a=Se;else if(typeof a!="object")throw Error(ie+"Argument not an object: "+a);if(h=u.toFixed(n,i),u.c){var m,z=h.split("."),c=+a.groupSize,f=+a.secondaryGroupSize,E=a.groupSeparator||"",d=z[0],T=z[1],_=u.s<0,L=_?d.slice(1):d,F=L.length;if(f&&(m=c,c=f,f=m,F-=m),c>0&&F>0){for(m=F%c||c,d=L.substr(0,m);m<F;m+=c)d+=E+L.substr(m,c);f>0&&(d+=E+L.slice(m)),_&&(d="-"+d)}h=T?d+(a.decimalSeparator||"")+((f=+a.fractionGroupSize)?T.replace(new RegExp("\\d{"+f+"}\\B","g"),"$&"+(a.fractionGroupSeparator||"")):T):d}return(a.prefix||"")+h+(a.suffix||"")},A.toFraction=function(n){var i,a,h,u,m,z,c,f,E,d,T,_,L=this,F=L.c;if(n!=null&&(c=new v(n),!c.isInteger()&&(c.c||c.s!==1)||c.lt(C)))throw Error(ie+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+P(c));if(!F)return new v(L);for(i=new v(C),E=a=new v(C),h=f=new v(C),_=ce(F),m=i.e=_.length-L.e-1,i.c[0]=at[(z=m%j)<0?j+z:z],n=!n||c.comparedTo(i)>0?m>0?i:E:c,z=Z,Z=1/0,c=new v(_),f.c[0]=0;d=o(c,i,0,1),u=a.plus(d.times(h)),u.comparedTo(n)!=1;)a=h,h=u,E=f.plus(d.times(u=E)),f=u,i=c.minus(d.times(u=i)),c=u;return u=o(n.minus(a),h,0,1),f=f.plus(u.times(E)),a=a.plus(u.times(h)),f.s=E.s=L.s,m=m*2,T=o(E,h,m,k).minus(L).abs().comparedTo(o(f,a,m,k).minus(L).abs())<1?[E,h]:[f,a],Z=z,T},A.toNumber=function(){return+P(this)},A.toPrecision=function(n,i){return n!=null&&q(n,1,J),ae(this,n,i,2)},A.toString=function(n){var i,a=this,h=a.s,u=a.e;return u===null?h?(i="Infinity",h<0&&(i="-"+i)):i="NaN":(n==null?i=u<=w||u>=S?Ve(ce(a.c),u):Te(ce(a.c),u,"0"):n===10&&Le?(a=re(new v(a),b+u+1,k),i=Te(ce(a.c),a.e,"0")):(q(n,2,Ae.length,"Base"),i=g(Te(ce(a.c),u,"0"),10,n,h,!0)),h<0&&a.c[0]&&(i="-"+i)),i},A.valueOf=A.toJSON=function(){return P(this)},A._isBigNumber=!0,A[Symbol.toStringTag]="BigNumber",A[Symbol.for("nodejs.util.inspect.custom")]=A.valueOf,t!=null&&v.set(t),v}function ue(t){var o=t|0;return t>0||t===o?o:o-1}function ce(t){for(var o,g,y=1,A=t.length,C=t[0]+"";y<A;){for(o=t[y++]+"",g=j-o.length;g--;o="0"+o);C+=o}for(A=C.length;C.charCodeAt(--A)===48;);return C.slice(0,A+1||1)}function be(t,o){var g,y,A=t.c,C=o.c,b=t.s,k=o.s,w=t.e,S=o.e;if(!b||!k)return null;if(g=A&&!A[0],y=C&&!C[0],g||y)return g?y?0:-k:b;if(b!=k)return b;if(g=b<0,y=w==S,!A||!C)return y?0:!A^g?1:-1;if(!y)return w>S^g?1:-1;for(k=(w=A.length)<(S=C.length)?w:S,b=0;b<k;b++)if(A[b]!=C[b])return A[b]>C[b]^g?1:-1;return w==S?0:w>S^g?1:-1}function q(t,o,g,y){if(t<o||t>g||t!==le(t))throw Error(ie+(y||"Argument")+(typeof t=="number"?t<o||t>g?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function Ge(t){var o=t.c.length-1;return ue(t.e/j)==o&&t.c[o]%2!=0}function Ve(t,o){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(o<0?"e":"e+")+o}function Te(t,o,g){var y,A;if(o<0){for(A=g+".";++o;A+=g);t=A+t}else if(y=t.length,++o>y){for(A=g,o-=y;--o;A+=g);t+=A}else o<y&&(t=t.slice(0,o)+"."+t.slice(o));return t}var Ci=Er();const Di=e.z.boolean().transform(t=>String(t)),Pi=e.z.string().transform(t=>t==="true");var ht;(function(t){t[t.function=0]="function",t[t.l1_handler=1]="l1_handler",t[t.constructor=2]="constructor"})(ht||(ht={}));const It=e.z.array(e.z.string()),$e=e.z.object({selector:e.z.string(),offset:e.z.string(),builtins:It.optional()}),Tt=e.z.object({CONSTRUCTOR:e.z.array($e),EXTERNAL:e.z.array($e),L1_HANDLER:e.z.array($e)}),ki=e.z.string(),gr=e.z.object({builtins:It,data:e.z.array(e.z.string())}),We=e.z.object({name:e.z.string(),type:e.z.union([e.z.literal("felt"),e.z.literal("felt*"),e.z.string()])}),zr=e.z.nativeEnum(ht),Sr=e.z.object({inputs:e.z.array(We),name:e.z.string(),outputs:e.z.array(We),stateMutability:e.z.literal("view").optional(),state_mutability:e.z.string().optional(),type:zr}),Ke=e.z.object({name:e.z.string(),type:e.z.union([e.z.literal("felt"),e.z.literal("felt*"),e.z.string()]),kind:e.z.union([e.z.literal("key"),e.z.literal("data")])}),Ar=e.z.object({name:e.z.string(),type:e.z.literal("event"),data:e.z.array(Ke),keys:e.z.array(Ke)}),Ir=e.z.object({name:e.z.string(),members:e.z.array(Ke),kind:e.z.literal("struct"),type:e.z.literal("event")}),Tr=e.z.object({members:e.z.array(We.and(e.z.object({offset:e.z.number()}))),name:e.z.string(),size:e.z.number(),type:e.z.literal("struct")}),yr=e.z.union([Ir,Ar]),yt=e.z.array(e.z.union([Sr,yr,Tr,e.z.any()])),Nr=e.z.object({program:gr,entry_points_by_type:Tt,abi:yt}),Nt=e.z.array(e.z.string()),vr=e.z.object({type_names:e.z.array(e.z.tuple([e.z.number(),e.z.string()])),libfunc_names:e.z.array(e.z.tuple([e.z.number(),e.z.string()])),user_func_names:e.z.array(e.z.tuple([e.z.number(),e.z.string()]))}),He=e.z.object({selector:e.z.string(),function_idx:e.z.number()}),Rr=e.z.object({CONSTRUCTOR:e.z.array(He),EXTERNAL:e.z.array(He),L1_HANDLER:e.z.array(He)}),Or=e.z.object({sierra_program:Nt,sierra_program_debug_info:vr.optional(),contract_class_version:e.z.string(),entry_points_by_type:Rr,abi:yt}),br=e.z.array(e.z.tuple([e.z.number(),e.z.array(e.z.string())])),_r=e.z.object({prime:e.z.string(),compiler_version:e.z.string(),bytecode:Nt,hints:e.z.array(e.z.any()),pythonic_hints:br,entry_points_by_type:Tt}),ji=_r,Ui=e.z.union([Nr,Or]),wr=St.createContext(null),vt=()=>St.useContext(wr),Fi=()=>{var t;return!!((t=vt())!=null&&t.emitter)},xi=({emitter:t,children:o})=>xn.jsx(wr.Provider,{value:{emitter:t},children:o});let $t=!1;const Rt=()=>{var g;const t=(g=vt())==null?void 0:g.emitter;if(!t&&!$t){$t=!0;return}return t},Bi=()=>{const t=Rt();return t?t.emit.bind(t):ke.noop},Mi=()=>{const t=Rt();return(g,y)=>{St.useEffect(()=>t?t.on(g,y):void 0,[g,y])}};var Lr={};function me(t,o){typeof o=="boolean"&&(o={forever:o}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=o||{},this._maxRetryTime=o&&o.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var Gi=me;me.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};me.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};me.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var o=new Date().getTime();if(t&&o-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var g=this._timeouts.shift();if(g===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),g=this._cachedTimeouts.slice(-1);else return!1;var y=this;return this._timer=setTimeout(function(){y._attempts++,y._operationTimeoutCb&&(y._timeout=setTimeout(function(){y._operationTimeoutCb(y._attempts)},y._operationTimeout),y._options.unref&&y._timeout.unref()),y._fn(y._attempts)},g),this._options.unref&&this._timer.unref(),!0};me.prototype.attempt=function(t,o){this._fn=t,o&&(o.timeout&&(this._operationTimeout=o.timeout),o.cb&&(this._operationTimeoutCb=o.cb));var g=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){g._operationTimeoutCb()},g._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};me.prototype.try=function(t){this.attempt(t)};me.prototype.start=function(t){this.attempt(t)};me.prototype.start=me.prototype.try;me.prototype.errors=function(){return this._errors};me.prototype.attempts=function(){return this._attempts};me.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},o=null,g=0,y=0;y<this._errors.length;y++){var A=this._errors[y],C=A.message,b=(t[C]||0)+1;t[C]=b,b>=g&&(o=A,g=b)}return o};(function(t){var o=Gi;t.operation=function(g){var y=t.timeouts(g);return new o(y,{forever:g&&(g.forever||g.retries===1/0),unref:g&&g.unref,maxRetryTime:g&&g.maxRetryTime})},t.timeouts=function(g){if(g instanceof Array)return[].concat(g);var y={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var A in g)y[A]=g[A];if(y.minTimeout>y.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var C=[],b=0;b<y.retries;b++)C.push(this.createTimeout(b,y));return g&&g.forever&&!C.length&&C.push(this.createTimeout(b,y)),C.sort(function(k,w){return k-w}),C},t.createTimeout=function(g,y){var A=y.randomize?Math.random()+1:1,C=Math.round(A*Math.max(y.minTimeout,1)*Math.pow(y.factor,g));return C=Math.min(C,y.maxTimeout),C},t.wrap=function(g,y,A){if(y instanceof Array&&(A=y,y=null),!A){A=[];for(var C in g)typeof g[C]=="function"&&A.push(C)}for(var b=0;b<A.length;b++){var k=A[b],w=g[k];g[k]=(function(p){var Z=t.operation(y),D=Array.prototype.slice.call(arguments,1),he=D.pop();D.push(function(te){Z.retry(te)||(te&&(arguments[0]=Z.mainError()),he.apply(this,arguments))}),Z.attempt(function(){p.apply(g,D)})}).bind(g,w),g[k].options=y}}})(Lr);exports.TOKEN_ERROR_MESSAGES=void 0;(function(t){t.NO_TOKEN_API_URL="NO_TOKEN_API_URL is not defined",t.NO_TOKEN_PRICE_API_URL="NO_TOKEN_PRICE_API_URL is not defined",t.TOKENS_DEFI_DECOMPOSITION_URL="TOKENS_DEFI_DECOMPOSITION_URL is not defined",t.TOKENS_AIRDROPS_API_URL="TOKENS_AIRDROPS_API_URL is not defined",t.TOKEN_PARSING_ERROR="Unable to parse token data response",t.TOKEN_PRICE_PARSING_ERROR="Unable to parse token price response",t.TOKEN_DEFI_DECOMPOSITION_PARSING_ERROR="Unable to parse token defi decomposition response",t.TOKEN_PRICE_NOT_FOUND="Token price not found",t.TOKEN_NOT_FOUND="Token not found",t.TOKEN_DETAILS_NOT_FOUND="Token details not found",t.FEE_TOKEN_NOT_FOUND="Fee token not found",t.UNABLE_TO_CALCULATE_CURRENCY_VALUE="Unable to calculate currency value",t.UNSAFE_DECIMALS="Unsafe decimals in token"})(exports.TOKEN_ERROR_MESSAGES||(exports.TOKEN_ERROR_MESSAGES={}));class Vi extends Oe{constructor(o){super(o,exports.TOKEN_ERROR_MESSAGES),this.name="TokenError"}}const Ot=e.z.union([e.z.literal("concentratedLiquidityPosition"),e.z.literal("collateralizedDebtPosition")]),$i=e.z.object({status:e.z.literal("initialising")}).or(e.z.object({status:e.z.literal("initialised"),balances:e.z.array(e.z.object({tokenAddress:H,tokenBalance:e.z.string()}))})),we=e.z.object({id:e.z.number(),address:Y,brandColor:e.z.string().optional(),name:e.z.string(),symbol:e.z.string(),decimals:e.z.number(),iconUrl:e.z.string().optional(),sendable:e.z.boolean(),popular:e.z.boolean(),refundable:e.z.boolean(),listed:e.z.boolean(),tradable:e.z.boolean(),category:e.z.union([e.z.literal("tokens"),e.z.literal("currencies"),e.z.literal("savings")]),pricingId:e.z.number().optional(),dappId:e.z.string().optional(),marketData:e.z.object({marketCap:e.z.number(),marketCap24hChange:e.z.number(),dailyVolume:e.z.number(),rank:e.z.number()}).optional(),tags:e.z.array(e.z.string()).optional()}),Hi=e.z.object({tokens:e.z.array(we)}),Xi=we,bt=e.z.object({pricingId:e.z.number(),ethValue:e.z.string(),ccyValue:e.z.string(),ethDayChange:e.z.string(),ccyDayChange:e.z.string()}),qi=e.z.object({prices:e.z.array(bt)}),dt=e.z.object({tokenAddress:H,principal:e.z.string(),accruedFees:e.z.string(),minPrice:e.z.string(),maxPrice:e.z.string(),currentPrice:e.z.string()}),Cr=e.z.object({tokenAddress:Y.optional(),totalBalances:e.z.record(e.z.string())}),_t=Cr.extend({tokenId:e.z.string(),data:e.z.object({poolFeePercentage:e.z.string(),tickSpacingPercentage:e.z.string().optional(),token0:dt,token1:dt})}),Wi=e.z.array(_t),wt=Cr.extend({data:e.z.object({apy:e.z.string().optional(),group:e.z.number().optional(),collateral:e.z.boolean(),debt:e.z.boolean(),lending:e.z.boolean()})}),Ki=e.z.array(wt),Dr=e.z.array(_t.or(wt)),Pr=e.z.object({name:e.z.string(),manageUrl:e.z.string(),type:Ot,groups:e.z.record(e.z.object({name:e.z.string().optional(),healthRatio:e.z.string().optional()})).optional(),positions:Dr}),kr=e.z.object({dappId:e.z.string(),products:e.z.array(Pr)}),Yi=e.z.object({dapps:e.z.array(kr)}),jr=e.z.object({name:e.z.string().optional(),tokenAddress:Y,amount:e.z.string().optional(),claimUrl:e.z.string().optional(),claimStart:e.z.number(),claimEnd:e.z.number().optional()}),Zi=e.z.object({accountAddress:Y,chain:e.z.string(),airdrops:e.z.array(jr)}),tt=e.z.object({address:Y,networkId:e.z.string({required_error:"Network is required"})},{required_error:"BaseToken is required"});tt.required().extend({balance:e.z.string()});const Ur=tt.required().extend({id:e.z.number().optional(),name:e.z.string().optional(),symbol:e.z.string().optional(),decimals:e.z.coerce.number().optional(),iconUrl:e.z.string().url("").optional().or(e.z.literal("")),pricingId:e.z.number().optional(),category:e.z.string().optional(),dappId:e.z.string().optional(),brandColor:e.z.string().optional()}),Ji=Ur.extend({balance:e.z.string()}),Qi=Ur.extend({currencyValue:e.z.string(),ccyDayChange:e.z.string().optional(),ethDayChange:e.z.string().optional(),unitCurrencyValue:e.z.string().optional()}),Lt=Qi.extend({...Ji.shape});e.z.array(Lt);tt.extend({...bt.shape});tt.extend({...we.shape});const Ht=Lt.extend({accruedFees:e.z.string(),currentPrice:e.z.string(),maxPrice:e.z.string(),minPrice:e.z.string(),principal:e.z.string()}),Fr=e.z.object({address:Y.optional(),currencyValue:e.z.string().default("0")}),Ct=Fr.extend({poolFeePercentage:e.z.string(),tickSpacingPercentage:e.z.string().optional(),tokenId:e.z.string().optional(),unitCurrencyValueToken0:e.z.string().optional(),unitCurrencyValueToken1:e.z.string().optional(),token0:Ht,token1:Ht}),ea=e.z.array(Ct),ta=e.z.object({name:e.z.string().optional(),healthRatio:e.z.string().optional(),accountAddress:Y.optional()}),Dt=Fr.extend({totalBalances:e.z.record(e.z.string()),collateral:e.z.boolean(),debt:e.z.boolean(),lending:e.z.boolean(),apy:e.z.string().optional(),group:e.z.string().optional(),unitCurrencyValue:e.z.string().optional(),positionToken:we.or(e.z.undefined()),token:Lt.optional(),accountAddress:Y.optional(),accountAddressGroup:e.z.string().optional()}),ra=e.z.array(Dt),xr=Ct.or(Dt),Br=e.z.record(e.z.object({name:e.z.string().optional(),healthRatio:e.z.string().optional(),accountAddress:Y.optional()})),Mr=e.z.object({type:Ot,manageUrl:e.z.string().url().optional(),name:e.z.string(),positions:e.z.array(xr),positionsTotalValue:e.z.string(),brandColor:e.z.string().optional(),groups:Br.optional(),accountAddress:Y}),Gr=e.z.array(Mr),na=e.z.object({dappId:e.z.string(),products:Gr}),Vr=e.z.object({name:e.z.string().optional(),tokenAddress:Y,token:we.optional(),amount:e.z.string().optional(),claimUrl:e.z.string().optional(),claimStart:e.z.number(),claimEnd:e.z.number().optional()}),ia=e.z.array(Vr),$r=(t,o=18)=>Wt(t.replace(",","."),Number(o)),Hr=e.z.string().trim().refine(t=>t!=="",{message:"Amount is required"}).refine(t=>{try{const o=$r(t).value;if(o<0n)throw new Error("Amount must be positive");if(o===0n)throw new Error("Amount can not be zero");if(o>W.uint256.UINT_256_MAX)throw new Error("Amount is too big")}catch{throw new Error("Amount should be a number")}return!0},{message:"Invalid amount"}),aa=t=>!!Hr.parse(t),Xr=e.z.object({data:e.z.object({code:e.z.string().optional(),name:e.z.string().optional(),message:e.z.string()})}),sa=t=>{const o=Xr.safeParse(t);if(o.success)return o.data.data.message},oa=3,Pt=process.env.FEE_OVERHEAD?parseFloat(process.env.FEE_OVERHEAD):oa,ca=1.5,Ye=10,qr=({estimatedFee:t,overheadMultiplier:o=Pt})=>{const y=W.num.toBigInt(t)*BigInt(o*Ye)/BigInt(Ye);return W.num.toHex(y)},la=({suggestedMaxFee:t,overheadMultiplier:o=Pt,starknetJsOverheadMultiplier:g=ca})=>{const A=W.num.toBigInt(t)*BigInt(Ye)/BigInt(g*Ye);return qr({estimatedFee:A,overheadMultiplier:o})};exports.ESTIMATE_ERROR_MESSAGES=void 0;(function(t){t.SIMULATE_AND_REVIEW_FAILED="Missing simulation"})(exports.ESTIMATE_ERROR_MESSAGES||(exports.ESTIMATE_ERROR_MESSAGES={}));class ua extends Oe{constructor(o){super(o,exports.ESTIMATE_ERROR_MESSAGES),this.name="EstimateError"}}const fa=e.z.object({type:e.z.enum(["DECLARE","DEPLOY","DEPLOY_ACCOUNT","INVOKE"]).default("INVOKE"),calls:e.z.array(ut).or(ut).optional(),calldata:e.z.array(e.z.string()).optional(),classHash:Ue.optional(),salt:Ue.optional(),signature:e.z.array(e.z.string()).optional()}),ma=e.z.object({amount:e.z.bigint(),pricePerUnit:e.z.bigint()}).or(e.z.object({maxFee:e.z.bigint()})),pt=e.z.object({feeTokenAddress:Y,amount:e.z.bigint(),pricePerUnit:e.z.bigint(),max:ma.optional(),dataGasConsumed:e.z.bigint().optional(),dataGasPrice:e.z.bigint().optional()}),Wr=e.z.object({deployment:pt.optional(),transactions:pt}),Kr=e.z.union([e.z.literal("critical"),e.z.literal("high"),e.z.literal("caution"),e.z.literal("info")]),Yr=e.z.string(),ha=e.z.object({name:e.z.string(),url:e.z.string(),position:e.z.number()}),st=e.z.object({address:e.z.string(),name:e.z.string(),symbol:e.z.string().optional(),decimals:e.z.number().optional(),unknown:e.z.boolean(),iconUrl:e.z.string().optional(),type:e.z.string()}),Et=e.z.discriminatedUnion("type",[e.z.object({type:e.z.literal("amount"),label:e.z.string(),token:st,amount:e.z.string(),usd:e.z.string(),editable:e.z.boolean()}),e.z.object({type:e.z.literal("address"),label:e.z.string(),address:e.z.string(),addressName:e.z.string().optional(),verified:e.z.boolean().optional()}),e.z.object({type:e.z.literal("timestamp"),label:e.z.string(),value:e.z.string()}),e.z.object({type:e.z.literal("token_address"),label:e.z.string(),token:st}),e.z.object({type:e.z.literal("calldata"),label:e.z.string(),entrypoint:e.z.string(),calldata:e.z.array(e.z.string())}),e.z.object({type:e.z.literal("text"),label:e.z.string(),text:e.z.string()}),e.z.object({type:e.z.literal("nft"),label:e.z.string(),token:st})]),kt=e.z.object({name:e.z.string(),properties:e.z.array(Et),defaultProperties:e.z.array(Et).optional()}),Zr=e.z.union([e.z.literal("verified"),e.z.literal("neutral"),e.z.literal("partial"),e.z.literal("warn")]),Jr=e.z.object({unknown_token:e.z.unknown().optional(),date_of_addition:e.z.string().optional(),contract_address:Y.optional(),reason:e.z.string().optional(),value:e.z.string().or(e.z.number()).optional()}),jt=e.z.object({reason:Yr,details:Jr.optional(),severity:Kr}),Qr=e.z.object({assessment:Zr,warnings:e.z.array(jt).optional(),assessmentReasons:e.z.array(e.z.string()).optional(),assessmentDetails:e.z.object({contract_address:e.z.string()}).optional(),action:kt}),Ut=e.z.object({name:e.z.string(),description:e.z.string(),logoUrl:e.z.string(),iconUrl:e.z.string(),argentVerified:e.z.boolean(),links:e.z.array(ha)}),en=e.z.object({assessment:e.z.union([e.z.literal("verified"),e.z.literal("neutral"),e.z.literal("partial"),e.z.literal("warn")]),warnings:e.z.array(jt).optional(),assessmentDetails:e.z.object({contract_address:e.z.string()}).optional(),targetedDapp:Ut.optional(),reviews:e.z.array(Qr)}).optional(),tn=e.z.object({banner:e.z.string().nullable().optional(),preview:e.z.string().nullable().optional(),full:e.z.string().nullable().optional(),original:e.z.string().nullable().optional()}),da=e.z.object({twitter:e.z.string().optional(),external:e.z.string().optional(),discord:e.z.string().optional()}),Ft=e.z.object({address:H,decimals:e.z.number().optional(),symbol:e.z.string().optional(),name:e.z.string(),description:e.z.string().optional(),type:e.z.string().optional(),usdValue:e.z.string().optional(),iconUrl:e.z.string().optional(),unknown:e.z.boolean().optional(),imageUrls:tn.optional(),links:da.optional()}),pa=e.z.object({tokenAddress:H,owner:H,spender:H,value:e.z.string().optional(),approvalForAll:e.z.boolean(),details:Ft.optional()}),Ea=e.z.object({tokenAddress:H,from:H,to:H,tokenId:e.z.string().optional(),value:e.z.string().optional(),details:Ft.optional()}),Re=e.z.union([e.z.string(),e.z.number(),e.z.bigint()]).transform(t=>parseInt(t.toString(),10)),Xt={overallFee:Re,gasPrice:Re,gasUsage:Re,dataGasPrice:Re.optional(),dataGasConsumed:Re.optional()},rn=e.z.object({...Xt,unit:e.z.string().transform(t=>t.toUpperCase()).pipe(e.z.literal("WEI")),maxFee:Re}).or(e.z.object({...Xt,unit:e.z.string().transform(t=>t.toUpperCase()).pipe(e.z.literal("FRI")),maxAmount:Re,maxPricePerUnit:Re})),ga=e.z.object({type:e.z.string(),label:e.z.string(),tokenId:e.z.string().optional(),value:e.z.string().optional(),usdValue:e.z.string().optional(),token:Ft,sent:e.z.boolean().optional(),tokenIdDetails:e.z.object({name:e.z.string().optional(),description:e.z.string().optional(),imageUrls:tn.optional()}).optional()}),za=e.z.object({approvals:e.z.array(pa).optional(),transfers:e.z.array(Ea).optional(),calculatedNonce:e.z.string().optional(),feeEstimation:rn,summary:e.z.array(ga).optional()}),Sa=e.z.object({label:e.z.string().optional(),code:e.z.number().optional(),message:e.z.string().optional(),error:e.z.string().optional()}),nn=e.z.object({reviewOfTransaction:en,simulation:za,simulationError:e.z.undefined()}),an=e.z.object({reviewOfTransaction:en,simulation:e.z.undefined(),simulationError:Sa}),sn=nn.or(an),Aa=e.z.object({transactions:e.z.array(sn)}),Ia=e.z.object({transactions:e.z.array(sn),enrichedFeeEstimation:Wr.optional(),isBackendDown:e.z.boolean().default(!1).optional()});function Ta(t){return nn.safeParse(t).success}function ya(t){return an.safeParse(t).success}const on=e.z.object({network:e.z.string(),hash:e.z.string(),status:e.z.string(),blockNumber:e.z.number().optional(),transactionIndex:e.z.number()}),Pe=e.z.object({type:e.z.enum(["token","nft"]),tokenAddress:H,amount:e.z.string().optional(),fiatAmount:e.z.object({currency:e.z.string(),currencyAmount:e.z.number()}).optional().nullable()}),xt=e.z.enum(["ethereum","starknet","zksync","zksync2"]),cn=e.z.object({type:e.z.enum(["payment","gasFee"]),leg:e.z.enum(["credit","debit"]),asset:Pe,counterParty:H.optional(),counterPartyNetwork:xt.optional()}),Na=e.z.object({address:H,network:xt,type:e.z.enum(["wallet","token"])}),va=e.z.object({chainId:e.z.enum(["TESTNET","MAINNET","SEPOLIA"]),ethereumNetwork:e.z.enum(["mainnet","sepolia"])}),Ra=e.z.enum(["approval","changePubKey","dappInteraction","deploy","gift","multicall","payment","security","trade"]),ln=e.z.enum(["triggerEscapeGuardian","triggerEscapeSigner","escapeGuardian","escapeSigner","guardianChanged","guardianBackupChanged","signerChanged","cancelEscape","accountUpgraded","multisigConfigurationUpdated"]),Oa=e.z.object({name:e.z.string(),parameters:e.z.array(e.z.unknown()).optional()}),ba=e.z.object({activeAt:e.z.string().optional(),newGuardian:e.z.string().optional(),newImplementation:e.z.string().optional(),newVersion:e.z.string().optional()}),qt=e.z.discriminatedUnion("type",[e.z.object({type:e.z.literal("deploy"),deployer:H,contractAddress:H}),e.z.object({type:e.z.literal("approval"),spender:H,asset:Pe,approvalType:e.z.string()}),e.z.object({type:e.z.literal("payment"),counterparty:H,leg:e.z.string(),asset:Pe,counterpartyNetwork:xt.optional()}),e.z.object({type:e.z.literal("trade"),srcAsset:Pe,destAsset:Pe}),e.z.object({type:e.z.literal("security"),action:ln,context:ba.optional()}),e.z.object({type:e.z.literal("dappInteraction"),dappAddress:H,function:Oa.optional().nullable()})]),un=e.z.union([qt,e.z.object({type:e.z.literal("multicall"),calls:e.z.array(e.z.object({details:qt}))})]),fn=e.z.object({dappId:e.z.string(),name:e.z.string().optional().nullable()}),Bt=e.z.object({sent:e.z.boolean(),asset:e.z.discriminatedUnion("type",[e.z.object({type:e.z.literal("nft"),tokenAddress:H,tokenId:e.z.coerce.number().optional(),amount:e.z.string().optional(),collectionName:e.z.string().optional(),collectionPreviewImage:e.z.string().optional().nullable(),nftName:e.z.string().optional().nullable(),nftPreviewImage:e.z.string().optional().nullable()}),e.z.object({type:e.z.literal("token"),tokenAddress:H,amount:e.z.string().optional(),fiatAmount:e.z.object({currency:e.z.string(),currencyAmount:e.z.coerce.string()}).optional().nullable()})])}),mn=e.z.object({type:e.z.string(),to:H,actualFee:e.z.object({type:e.z.string(),tokenAddress:H,amount:e.z.string().optional(),fiatAmount:e.z.object({currency:e.z.string(),currencyAmount:e.z.number()}).optional().nullable()})}),hn=e.z.enum(["pending","success","failure"]),Mt=e.z.object({compositeId:e.z.string(),id:e.z.string().uuid(),status:hn,wallet:H,txSender:H,source:e.z.string(),type:Ra,group:e.z.enum(["finance","security"]),submitted:e.z.number(),lastModified:e.z.number(),transaction:on,transfers:e.z.array(cn),fees:e.z.array(mn).optional(),relatedAddresses:e.z.array(Na).nullable(),network:e.z.string(),networkDetails:va.optional(),details:un,transferSummary:e.z.array(Bt).optional(),dapp:fn.optional(),actions:e.z.array(kt).optional(),title:e.z.string().optional(),multisigDetails:e.z.object({signers:e.z.array(H)}).optional()}),dn=e.z.object({title:e.z.string().optional(),shortTitle:e.z.string().optional(),subtitle:e.z.string().optional(),icon:e.z.string().optional()}),pn="native",En="rejected",gn="cancelled",zn="queued",_a=Mt.pick({status:!0,actions:!0,submitted:!0,lastModified:!0,transferSummary:!0,fees:!0}).extend({status:e.z.union([hn,e.z.enum([En,gn,zn])]),type:e.z.literal(pn),transaction:on.pick({hash:!0}),dapp:Ut.optional(),meta:dn.optional()}),Sn=e.z.array(Mt),wa=e.z.object({activities:Sn,page:e.z.number(),pageSize:e.z.number(),totalElements:e.z.number(),totalPages:e.z.number()});function La(t){return ln.safeParse(t).success}const Gt=t=>Bt.safeParse(t).success,Ca=t=>Gt(t)&&t.asset.type==="token",Da=t=>Gt(t)&&t.asset.type==="nft",gt={Transfer:W.hash.getSelectorFromName("Transfer"),Approval:W.hash.getSelectorFromName("Approval")},An=(t,o,g)=>{for(const y of t){const{events:A,internal_calls:C}=y;for(const b of A)for(const k of b.keys)k===gt.Approval&&o.push({tokenAddress:Y.parse(y.contract_address),owner:b.data[0],spender:b.data[1],value:W.uint256.uint256ToBN({low:b.data[2],high:b.data[3]}).toString()}),k===gt.Transfer&&g.push({tokenAddress:Y.parse(y.contract_address),from:b.data[0],to:b.data[1],value:W.uint256.uint256ToBN({low:b.data[2],high:b.data[3]}).toString()});C&&An(C,o,g)}return{approvals:o,transfers:g}},Pa=/(0x[a-fA-F0-9]+)\s*\('(.*?)'\)/,ka=t=>{if(!ke.isString(t))return;const o=t.match(Pa);if(o&&!ke.isEmpty(o[2]))return o[2]};var zt;(function(t){t.SIMULATE_AND_REVIEW_FAILED="Something went wrong fetching review",t.NO_CALLS_FOUND="No calls found",t.ONCHAIN_FEE_ESTIMATION_FAILED="Failed to estimate fees onchain"})(zt||(zt={}));class ja extends Oe{constructor(o){super(o,zt),this.name="ReviewError"}}const Ua=e.z.object({reason:e.z.string(),severity:e.z.string().optional(),title:e.z.string(),description:e.z.string().optional()}),Fa=Object.values(W.constants.TRANSACTION_VERSION),xa=e.z.string().default("0x3").refine(t=>{const o=W.num.toBigInt(t);return Fa.map(g=>W.num.toBigInt(g)).includes(o)}).transform(t=>W.num.toHex(t));function Ba(t){if(t===W.constants.TRANSACTION_VERSION.V3||t===W.constants.TRANSACTION_VERSION.F3)throw Error("Only txv1 is supported")}exports.AccountError=Ri;exports.AddressError=De;exports.BaseError=Oe;exports.BigNumber=Ci;exports.CallError=li;exports.ETH_TOKEN_ADDRESS=Qn;exports.EstimateError=ua;exports.EventEmitterProvider=xi;exports.EventsBySelector=gt;exports.FEE_OVERHEAD=Pt;exports.HttpError=Qe;exports.NativeActivityStatusCancelled=gn;exports.NativeActivityStatusQueued=zn;exports.NativeActivityStatusRejected=En;exports.NativeActivityTypeNative=pn;exports.NetworkError=ui;exports.ReviewError=ja;exports.STANDARD_DEVNET_ACCOUNT_CLASS_HASH=ai;exports.STRK_TOKEN_ADDRESS=ei;exports.TXV1_ACCOUNT_CLASS_HASH=ti;exports.TXV1_MULTISIG_CLASS_HASH=ni;exports.TXV3_ACCOUNT_CLASS_HASH=ri;exports.TXV3_MULTISIG_CLASS_HASH=ii;exports.TokenError=Vi;exports.abiEntrySchema=We;exports.abiSchema=yt;exports.actionSchema=kt;exports.activitiesSchema=Sn;exports.activityDappSchema=fn;exports.activityDetailsSchema=un;exports.activityResponseSchema=wa;exports.activitySchema=Mt;exports.activitySummarySchema=Bt;exports.activityTransferSchema=cn;exports.addOwnersCalldataSchema=hi;exports.addPluginCalldataSchema=gi;exports.addressInputCharactersAndLengthSchema=qn;exports.addressInputSchema=rr;exports.addressOrDomainInputSchema=Kn;exports.addressOrDomainSchema=Wn;exports.addressOrEmptyUndefinedSchema=Bn;exports.addressSchema=Y;exports.addressSchemaArgentBackend=H;exports.addressSchemaBase=Fe;exports.addressSchemaLooseLength=Yt;exports.addressSchemaStrictLength=Zt;exports.airdropSchema=Vr;exports.apiAccountTokenBalancesSchema=$i;exports.apiAirdropSchema=jr;exports.apiCollateralizedDebtPositionSchema=wt;exports.apiCollateralizedDebtPositionsSchema=Ki;exports.apiConcentratedLiquidityPositionSchema=_t;exports.apiConcentratedLiquidityPositionsSchema=Wi;exports.apiDefiDecompositionProduct=Pr;exports.apiDefiDecompositionProducts=Dr;exports.apiDefiDecompositionSchema=kr;exports.apiDefiDecompositionToken=dt;exports.apiDefiPositionsSchema=Yi;exports.apiPriceDataResponseSchema=qi;exports.apiPriceDetailsSchema=bt;exports.apiTokenInfoResponseSchema=Xi;exports.apiTokenInfoSchema=we;exports.apiTokensInfoResponseSchema=Hi;exports.apiUnclaimedRewardsSchema=Zi;exports.apiWalletResponseSchema=oi;exports.argentMaxFee=qr;exports.argentNameSchema=Be;exports.assessmentSchema=Zr;exports.bigNumberSchema=wi;exports.bigNumberishSchema=_e;exports.booleanToStringSchema=Di;exports.builtinsSchema=It;exports.byteCodeSchema=Nt;exports.cairo1EventSchema=Ir;exports.cairoAssemblySchema=_r;exports.cairoVersionSchema=or;exports.callDetailsSchema=hr;exports.callSchema=ut;exports.calldataSchema=ur;exports.changeGuardianCalldataSchema=fi;exports.changeThresholdCalldataSchema=Ei;exports.collateralizedDebtGroupSchema=ta;exports.collateralizedDebtPositionSchema=Dt;exports.collateralizedDebtPositionsSchema=ra;exports.compiledContractClassSchema=Ui;exports.compiledSierraCasmSchema=ji;exports.compiledSierraSchema=Or;exports.compressedProgramSchema=ki;exports.concentratedLiquidityPositionSchema=Ct;exports.concentratedLiquidityPositionsSchema=ea;exports.constructorCallDataSchemaC0=yi;exports.constructorCallDataSchemaC1V1=Ni;exports.contractEntryPointFieldsSchema=$e;exports.defiDappsProductsSchema=na;exports.defiPositionSchema=xr;exports.defiPositionTypeSchema=Ot;exports.defiProductSchema=Mr;exports.defiProductsSchema=Gr;exports.denyTxV3=Ba;exports.enrichedSimulateAndReviewSchema=Ia;exports.ensureArray=_i;exports.entryPointsByTypeSchema=Tt;exports.escapeGuardianCalldataSchema=mi;exports.estimatedFeeSchema=pt;exports.estimatedFeesSchema=Wr;exports.eventAbiSchema=yr;exports.eventEntrySchema=Ke;exports.executeOnPluginCalldataSchema=Si;exports.feeEstimationSchema=rn;exports.feeSchema=mn;exports.feltSchema=fe;exports.findTransfersAndApprovals=An;exports.formatFullAddress=Gn;exports.formatTruncatedAddress=Mn;exports.formatTruncatedSignerKey=Hn;exports.formatTruncatedString=Xn;exports.functionAbiSchema=Sr;exports.functionAbiTypeSchema=zr;exports.getAddressFromArgentName=ci;exports.getDefaultExportFromCjs=pr;exports.getMessageFromTrpcError=sa;exports.getPrettyRpcError=ka;exports.getSignerForMultiSigner=vi;exports.hexSchema=Ue;exports.hexSchemaBase=dr;exports.implementationSchema=Ii;exports.includesAddress=$n;exports.inputAmountSchema=Hr;exports.isActivityDetailsAction=La;exports.isActivitySummary=Gt;exports.isAddress=Jt;exports.isArgentName=nr;exports.isEqualAddress=er;exports.isEqualArgentName=ir;exports.isEqualStarknetDomainName=Zn;exports.isEqualStarknetId=sr;exports.isNftActivitySummary=Da;exports.isNotTransactionSimulationError=Ta;exports.isStarknetDomainName=Yn;exports.isStarknetId=ar;exports.isTokenActivitySummary=Ca;exports.isTransactionSimulationError=ya;exports.isValidAddress=Qt;exports.isValidInputAmount=aa;exports.isZeroAddress=tr;exports.legacyContractClassSchema=Nr;exports.legacyEventSchema=Ar;exports.modifySnjsFeeOverhead=la;exports.multiTypeSchema=je;exports.nativeActivityMetaSchema=dn;exports.nativeActivitySchema=_a;exports.normalizeAddress=xe;exports.normalizeAddressOrDomain=Jn;exports.normalizeArgentName=Xe;exports.normalizeStarknetId=qe;exports.parseAmount=$r;exports.parseUnits=Wt;exports.productGroupsSchema=Br;exports.programSchema=gr;exports.propertySchema=Et;exports.pythonicHintsSchema=br;exports.rawArgsArraySchema=fr;exports.rawArgsObjectSchema=mr;exports.rawArgsSchema=et;exports.reasonsSchema=Yr;exports.removeOwnersCalldataSchema=di;exports.removePluginCalldataSchema=zi;exports.replaceSignerCalldataSchema=pi;exports.retry=Lr;exports.reviewSchema=Qr;exports.semver=bi;exports.severitySchema=Kr;exports.sierraContractEntryPointFieldsSchema=He;exports.sierraEntryPointsByTypeSchema=Rr;exports.sierraProgramDebugInfoSchema=vr;exports.simulateAndReviewSchema=Aa;exports.starknetDomainNameSchema=Je;exports.starknetIdSchema=Ze;exports.stringToBooleanSchema=Pi;exports.structAbiSchema=Tr;exports.targetedDappSchema=Ut;exports.transactionReviewTransactionsSchema=fa;exports.transactionReviewWarningSchema=Ua;exports.transferCalldataSchema=Ai;exports.trpcErrorSchema=Xr;exports.txVersionSchema=xa;exports.uint256Schema=lr;exports.unclaimedRewardsSchema=ia;exports.urlJoin=cr;exports.useEmitEvent=Bi;exports.useEventEmitter=Rt;exports.useEventEmitterContext=vt;exports.useEventListener=Mi;exports.useIsEventEmitterEnabled=Fi;exports.validChecksumAddressSchema=At;exports.validateAddressRangeSchema=Kt;exports.warningDetailsSchema=Jr;exports.warningSchema=jt;
|