@argent/x-shared 1.29.0 → 1.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("zod"),l=require("./schema-C-_pmcO7.js"),p=require("starknet"),L=require("react"),F=require("lodash-es"),Re=require("swr"),Ee=require("@scure/base"),$s=require("ua-parser-js"),js=require("@scure/bip39"),Vs=require("@scure/bip39/wordlists/english"),Ms=require("object-hash"),zn=i.z.object({name:i.z.string().optional(),address:i.z.string(),ownerAddress:i.z.string(),chain:i.z.enum(["ethereum","zksync","zksync2","starknet"]),deploymentStatus:i.z.enum(["notDeployed","deploying","deployed","deployError"]),application:i.z.enum(["mobile","webwallet","argentx"]),guardianAddresses:i.z.array(i.z.string()).optional(),enabledGuardianAddresses:i.z.array(i.z.string()).optional(),implClassHash:i.z.string().optional(),proxyClassHash:i.z.string().optional(),salt:i.z.string().optional(),created:i.z.string().optional(),contractVersion:i.z.string().optional(),contractName:i.z.string().optional(),version:i.z.number().optional(),owner:i.z.object({guid:i.z.string().optional(),signerType:i.z.enum(["StarknetKey","EthereumKey"]).optional()}).optional()}),qs=i.z.object({address:i.z.string(),guardianAddress:i.z.string().optional(),account:zn}),Gs=i.z.object({ownerAddress:i.z.string(),signature:i.z.object({r:i.z.string(),s:i.z.string()}),implClassHash:i.z.string().optional(),name:i.z.string().optional(),icon:i.z.string().optional()});function Ws(e){return"transactionVersion"in e}function Ks(e){return"simulateTransaction"in e}function Zs(e){return!("simulateTransaction"in e)}const Fn=i.z.object({value:i.z.string(),platform:i.z.enum(["ios","argentx","android","webwallet"]).nullable()}),Ys=i.z.object({preferences:i.z.record(Fn)}),Dn=i.z.enum(["mainnet-alpha","sepolia-alpha"]),Un=i.z.enum(["mainnet","sepolia"]);function Js(e){return Dn.safeParse(e).success}function Xs(e){return Un.safeParse(e).success}const Te=18;function $e({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 kt=(e,t)=>({decimals:t,value:t>=e.decimals?e.value*BigInt(10)**BigInt(t-e.decimals):e.value/BigInt(10)**BigInt(e.decimals-t)}),Ln=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 kt(e,r)},Hn=(e,t)=>{const n=Math.max(e.decimals,t.decimals),[r,s]=[e,t].map(o=>kt(o,n));return[r.value,s.value,n]},nt=e=>(t,n)=>{const[r,s,o]=Hn(t,n);return{decimals:o,value:e(r,s,o)}},je=e=>(t,n)=>{const[r,s]=Hn(t,n);return e(r,s)},Qs=nt((e,t)=>e+t),eo=nt((e,t)=>e-t),to=nt((e,t,n)=>{if(t===BigInt(0))throw new Error("Division by zero is not allowed");return e*BigInt(10)**BigInt(n)/t}),no=(e,t)=>Ln({decimals:e.decimals+t.decimals,value:e.value*t.value}),ro=nt((e,t)=>{if(t===BigInt(0))throw new Error("Modulus by zero is not allowed");return e%t}),Ot=e=>({decimals:e.decimals,value:e.value>=BigInt(0)?e.value:-e.value}),$n=je((e,t)=>e===t),so=je((e,t)=>e<t),oo=je((e,t)=>e>t),ao=je((e,t)=>e<=t),io=je((e,t)=>e>=t),co=(e,t)=>!$n(e,t);function me(e,t){let[n,r=""]=e.split(".");const s=n.startsWith("-");return s&&(n=n.slice(1)),r.length>t?Number(r[t])>=5?r=(BigInt(r.slice(0,t))+1n).toString().padStart(t,"0"):r=r.slice(0,t):r=r.padEnd(t,"0"),{value:BigInt(`${s?"-":""}${n}${r}`),decimals:t}}function lo(e){return $e({value:e,decimals:Te})}function uo(e){return me(e,Te)}function ho(e){return $e({value:e,decimals:Te})}function Rt(e){return me(e,Te)}function fo(e){return Ot({value:e,decimals:0}).value}function mo(e){return Ot(Rt(e))}function po(e,t){return{value:BigInt(e),decimals:t}}const go={value:1n,decimals:0};function yo(e){return i.z.string().refine(t=>/^-?\d+(\.\d+)?$/.test(t),{message:"Invalid number format"}).transform(t=>me(t,e))}const So=Object.freeze(Object.defineProperty({__proto__:null,ONE:go,abs:Ot,absBigInt:fo,add:Qs,createUnitsSchema:yo,div:to,eq:$n,formatCurrency:ho,formatEther:lo,formatUnits:$e,gt:oo,gte:io,lt:so,lte:ao,mod:ro,mul:no,not:co,parseCurrency:Rt,parseCurrencyAbs:mo,parseEther:uo,parseUnits:me,sub:eo,toBigDecimal:po,toFixedDecimals:kt,toTiniestPossibleDecimal:Ln},Symbol.toStringTag,{value:"Module"}));class wo{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 bo{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 rt{constructor(t,n="json"){this.requestInit=t,this.responseType=n}async get(t,n){const r=F.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 l.HttpError(l.HTTP_ERROR_MESSAGE.FAILED_TO_FETCH_URL,0)});if(this.responseType==="json"){if(!o.ok)throw new l.HttpError(o.statusText,o.status);return await o.json()}return o}async post(t,n,r){const s=F.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}},a=await fetch(t,o).catch(()=>{throw new l.HttpError(l.HTTP_ERROR_MESSAGE.FAILED_TO_POST_URL,0)});if(!a.ok)throw new l.HttpError(a.statusText,a.status,await a.json());const c=await a.json();if(r)try{return r.parse(c)}catch(u){throw new l.HttpError(u.message,0)}return c}async put(t,n){const r=F.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 l.HttpError("Failed to put url",0)});if(!o.ok)throw new l.HttpError(o.statusText,o.status);return await o.json()}async delete(t,n){const r=F.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 l.HttpError("Failed to delete url",0)});if(!o.ok)throw new l.HttpError(o.statusText,o.status)}}const Ge=e=>{process.env.NODE_ENV};function Eo(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 Ao{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")||""),a=s.getTime()-o.getTime();if(a<this.options.freshFor)return Ge("🟢 [SWR] Using fresh cache"),r;if(a<this.options.staleFor)return this.fetchAndCache(t,n),Ge("🟠 [SWR] Revalidating cache"),r;throw new Error("Cache too old")}catch(r){if(r instanceof l.HttpError)throw r;return Ge(),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 a=await this.dateService.now();return await this.cacheService.set(t,Eo(o,{date:a.toUTCString()})),o}).finally(()=>{this.inFlightRequests.delete(t)});return this.inFlightRequests.set(t,s),s}return Ge(),r}parseResponse(t){if(t.ok)return t.json();throw new l.HttpError(t.statusText,t.status)}}const Pe=(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},Pt=async(e,t)=>{const n=await fetch(e,t),r=await n.text();if(!n.ok)throw Pe("An error occurred while fetching",n,r);try{return JSON.parse(r)}catch{throw Pe("An error occurred while parsing",n,r)}},To=async(e,t)=>{const n=await fetch(e,{method:"POST",...t}),r=await n.text();if(!n.ok)throw Pe("An error occurred while fetching",n,r);try{return JSON.parse(r)}catch{throw Pe("An error occurred while parsing",n,r)}},vo=e=>({refreshInterval:e,dedupingInterval:e}),Io=e=>`${e.networkId}::${e.address}`,xo=()=>{};function jn(e,t,n,r){const{cache:s}=Re.useSWRConfig(),o=Re(e&&t,e?n:xo,r);return L.useEffect(()=>{e||(o.mutate(),s.delete(t))},[e]),o}const _o={revalidateOnFocus:!1,revalidateOnMount:!0,revalidateOnReconnect:!1,refreshWhenOffline:!1,refreshWhenHidden:!1,refreshInterval:0},Vn=async(e,t)=>{try{const{time:n}=await Pt(l.urlJoin(e,"time"),{headers:t});return n}catch{throw new Error("failed to request time")}},Co=async(e,t)=>{const n=await Vn(e,t);return Math.floor(n)};function Mn(e){switch(e){case"mainnet-alpha":case p.constants.NetworkName.SN_MAIN:return p.constants.StarknetChainId.SN_MAIN;case"sepolia-alpha":case p.constants.NetworkName.SN_SEPOLIA:return p.constants.StarknetChainId.SN_SEPOLIA;default:throw new l.NetworkError({code:"NOT_FOUND",message:`Unknown networkId: ${e}`})}}function qn(e){return e.replace(".stark","").split(".").map(r=>p.starknetId.useEncoded(r).toString(10))}function Gn(e){const t=Mn(e);return p.starknetId.getStarknetIdContract(t)}function Wn(e,t){const n=Gn(t),r=qn(e);try{const o={domain:r,hint:[]};return l.callSchema.parse({contractAddress:n,entrypoint:"domain_to_address",calldata:o})}catch(s){throw new l.CallError({code:"NOT_VALID",options:{error:s}})}}async function Kn(e,t,n){if(!t||!n)throw new l.NetworkError({code:"NO_NETWORK_OR_MULTICALL"});let r=null;try{r=Wn(e,t)}catch(c){throw new l.CallError({code:"NOT_VALID",options:{error:c}})}let s,o;try{s=await n.callContract(r),o=s[0]}catch{throw new l.AddressError({code:"STARKNAME_ERROR"})}if(l.isZeroAddress(o))throw new l.AddressError({code:"STARKNAME_NOT_FOUND",message:`${e} not found`});if(!l.isValidAddress(o))throw new l.AddressError({code:"STARKNAME_INVALID_ADDRESS",message:`${e} resolved to an invalid address (${o})`});return l.normalizeAddress(o)}class No{constructor(t,n,r){this.httpService=t,this.baseUrl=n,this.allowedArgentNameNetworkId=r}async parseAddressOrDomain(t,n,r){if(l.isAddress(t))return l.normalizeAddress(t);try{return await this.getAddressFromDomainName(t,n,r)}catch{throw new l.AddressError({code:"NOT_VALID"})}}async getAddressFromDomainName(t,n,r){if(l.isStarknetId(t))return Kn(t,n,r);if(l.isArgentName(t)){if(n!==this.allowedArgentNameNetworkId)throw new l.AddressError({code:"ARGENT_NAME_INVALID_NETWORK",message:`Argent name is only enabled on "${this.allowedArgentNameNetworkId}"`});return l.getAddressFromArgentName(t,this.httpService,this.baseUrl)}throw new l.AddressError({code:"NO_ADDRESS_FROM_DOMAIN"})}}const Zn=["0x25ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918"],X={"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"},ze={"0.1.1":"0x6e150953b26271a740bf2b6e9bca17cc52c68d765f761295de51ceb8526ee72","0.1.0":"0x737ee2f87ce571a58c6c8da558ec18a07ceb64a6172d5ec46171fbc80077a48"};var Bo=typeof global=="object"&&global&&global.Object===Object&&global,ko=typeof self=="object"&&self&&self.Object===Object&&self,st=Bo||ko||Function("return this")(),Je=st.Symbol,Yn=Object.prototype,Oo=Yn.hasOwnProperty,Ro=Yn.toString,Ce=Je?Je.toStringTag:void 0;function Po(e){var t=Oo.call(e,Ce),n=e[Ce];try{e[Ce]=void 0;var r=!0}catch{}var s=Ro.call(e);return r&&(t?e[Ce]=n:delete e[Ce]),s}var zo=Object.prototype,Fo=zo.toString;function Do(e){return Fo.call(e)}var Uo="[object Null]",Lo="[object Undefined]",cn=Je?Je.toStringTag:void 0;function Ho(e){return e==null?e===void 0?Lo:Uo:cn&&cn in Object(e)?Po(e):Do(e)}function Jn(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var $o="[object AsyncFunction]",jo="[object Function]",Vo="[object GeneratorFunction]",Mo="[object Proxy]";function qo(e){if(!Jn(e))return!1;var t=Ho(e);return t==jo||t==Vo||t==$o||t==Mo}var pt=st["__core-js_shared__"],ln=function(){var e=/[^.]+$/.exec(pt&&pt.keys&&pt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Go(e){return!!ln&&ln in e}var Wo=Function.prototype,Ko=Wo.toString;function Zo(e){if(e!=null){try{return Ko.call(e)}catch{}try{return e+""}catch{}}return""}var Yo=/[\\^$.*+?()[\]{}|]/g,Jo=/^\[object .+?Constructor\]$/,Xo=Function.prototype,Qo=Object.prototype,ea=Xo.toString,ta=Qo.hasOwnProperty,na=RegExp("^"+ea.call(ta).replace(Yo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ra(e){if(!Jn(e)||Go(e))return!1;var t=qo(e)?na:Jo;return t.test(Zo(e))}function sa(e,t){return e==null?void 0:e[t]}function zt(e,t){var n=sa(e,t);return ra(n)?n:void 0}var Fe=zt(Object,"create");function oa(){this.__data__=Fe?Fe(null):{},this.size=0}function aa(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var ia="__lodash_hash_undefined__",ca=Object.prototype,la=ca.hasOwnProperty;function ua(e){var t=this.__data__;if(Fe){var n=t[e];return n===ia?void 0:n}return la.call(t,e)?t[e]:void 0}var da=Object.prototype,ha=da.hasOwnProperty;function fa(e){var t=this.__data__;return Fe?t[e]!==void 0:ha.call(t,e)}var ma="__lodash_hash_undefined__";function pa(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Fe&&t===void 0?ma: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=oa;de.prototype.delete=aa;de.prototype.get=ua;de.prototype.has=fa;de.prototype.set=pa;function ga(){this.__data__=[],this.size=0}function ya(e,t){return e===t||e!==e&&t!==t}function ot(e,t){for(var n=e.length;n--;)if(ya(e[n][0],t))return n;return-1}var Sa=Array.prototype,wa=Sa.splice;function ba(e){var t=this.__data__,n=ot(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():wa.call(t,n,1),--this.size,!0}function Ea(e){var t=this.__data__,n=ot(t,e);return n<0?void 0:t[n][1]}function Aa(e){return ot(this.__data__,e)>-1}function Ta(e,t){var n=this.__data__,r=ot(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function ve(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])}}ve.prototype.clear=ga;ve.prototype.delete=ba;ve.prototype.get=Ea;ve.prototype.has=Aa;ve.prototype.set=Ta;var va=zt(st,"Map");function Ia(){this.size=0,this.__data__={hash:new de,map:new(va||ve),string:new de}}function xa(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function at(e,t){var n=e.__data__;return xa(t)?n[typeof t=="string"?"string":"hash"]:n.map}function _a(e){var t=at(this,e).delete(e);return this.size-=t?1:0,t}function Ca(e){return at(this,e).get(e)}function Na(e){return at(this,e).has(e)}function Ba(e,t){var n=at(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function Ie(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])}}Ie.prototype.clear=Ia;Ie.prototype.delete=_a;Ie.prototype.get=Ca;Ie.prototype.has=Na;Ie.prototype.set=Ba;var ka="__lodash_hash_undefined__";function Oa(e){return this.__data__.set(e,ka),this}function Ra(e){return this.__data__.has(e)}function Xe(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Ie;++t<n;)this.add(e[t])}Xe.prototype.add=Xe.prototype.push=Oa;Xe.prototype.has=Ra;function Pa(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 za(e){return e!==e}function Fa(e,t,n){for(var r=n-1,s=e.length;++r<s;)if(e[r]===t)return r;return-1}function Da(e,t,n){return t===t?Fa(e,t,n):Pa(e,za,n)}function Ua(e,t){var n=e==null?0:e.length;return!!n&&Da(e,t,0)>-1}function La(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 Ha(e,t){return e.has(t)}var gt=zt(st,"Set");function $a(){}function Xn(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var ja=1/0,Va=gt&&1/Xn(new gt([,-0]))[1]==ja?function(e){return new gt(e)}:$a,Ma=200;function qa(e,t,n){var r=-1,s=Ua,o=e.length,a=!0,c=[],u=c;if(n)a=!1,s=La;else if(o>=Ma){var d=Va(e);if(d)return Xn(d);a=!1,s=Ha,u=new Xe}else u=c;e:for(;++r<o;){var f=e[r],h=f;if(f=n||f!==0?f:0,a&&h===h){for(var S=u.length;S--;)if(u[S]===h)continue e;c.push(f)}else s(u,h,n)||(u!==c&&u.push(h),c.push(f))}return c}function Ga(e,t){return t=typeof t=="function"?t:void 0,e&&e.length?qa(e,void 0,t):[]}function Tt(e){const t=Object.entries(X),n=Object.entries(ze);switch(e){case"cairo0":return t.filter(([r])=>l.semver.lt(r,"0.3.0")).map(([,r])=>r);case"cairo1":return t.filter(([r])=>l.semver.gte(r,"0.3.0")).map(([,r])=>r);case"multisig":return n.map(([,r])=>r);default:return t.map(([,r])=>r)}}function Qn(){const e=l.semver.maxSatisfying(Object.keys(X),"*");if(!e)throw new Error(`No argent account contract found: v${e} `);return X[e]}function Wa(){const e=l.semver.maxSatisfying(Object.keys(ze),"*");if(!e)throw new Error(`No argent multisig contract found: v${e} `);return ze[e]}function er(){return Object.entries(X).filter(([e])=>l.semver.gte(e,"0.4.0")).map(([,e])=>e)}function Ka(){const e=l.semver.maxSatisfying(Object.keys(X),"<0.3.0");if(!e)throw new Error(`No argent account contract found: v${e} `);return X[e]}function tr(){const e=Object.entries(X).filter(([n])=>l.semver.gte(n,"0.3.1")).map(([,n])=>n),t=Object.entries(ze).filter(([n])=>l.semver.gte(n,"0.1.1")).map(([,n])=>n);return[...e,...t]}function Za(){return Object.entries(X).filter(([e])=>l.semver.gte(e,"0.4.0")).map(([,e])=>e)}function Ya(){const e=l.semver.maxSatisfying(Object.keys(X),">=0.4.0");if(!e)throw new Error(`No ledger account contract found: v${e}`);return X[e]}const nr=(e,t)=>e.cairoVersion===t.cairoVersion&&l.isEqualAddress(e.accountClassHash,t.accountClassHash);function Ja(e,t,n=[]){const r=l.implementationSchema.parse({cairoVersion:t.cairoVersion??"1",accountClassHash:t.classHash??Qn()}),s=i.z.array(l.implementationSchema).parse(n),o=[...Tt("cairo0").map(d=>({cairoVersion:"0",accountClassHash:d})),...Tt("cairo1").map(d=>({cairoVersion:"1",accountClassHash:d}))],u=Ga([r,...s,...o],nr).map(d=>({implementation:d,address:or(d.cairoVersion,d.accountClassHash,e,t.guardian,t.salt)})).find(d=>l.isEqualAddress(d.address,t.address));if(!u)throw new l.AccountError({code:"CALCULATED_ADDRESS_NO_MATCH"});return u.implementation}function rr(e,t,n,r,s,o=Zn[0]){const a=sr(e,t,n,r);return{classHash:e==="0"?o:t,constructorCalldata:p.CallData.compile(a),addressSalt:s||n}}function sr(e,t,n,r){const s=e!=="0"&&l.isEqualAddress(l.STANDARD_DEVNET_ACCOUNT_CLASS_HASH,t),o={pubkey:n,...s?{}:{guardian:r||"0"}};if(er().some(c=>l.isEqualAddress(c,t))){const c=l.getSignerForMultiSigner(n,l.MultiSigner.Starknet),u=r?new p.CairoOption(p.CairoOptionVariant.Some,l.getSignerForMultiSigner(r,l.MultiSigner.Starknet)):new p.CairoOption(p.CairoOptionVariant.None,null);return{ownerSigner:c,guardianAsOption:u}}return e==="0"?l.constructorCallDataSchemaC0.parse({implementation:t,selector:p.hash.getSelectorFromName("initialize"),calldata:p.CallData.compile(o)}):l.constructorCallDataSchemaC1V1.parse({owner:n,guardian:r})}function or(e,t,n,r,s){const o=rr(e,t,n,r,s);return p.hash.calculateContractAddressFromHash(o.addressSalt,o.classHash,o.constructorCalldata,0)}function Xa(e,t){const n=L.useRef(e),r=L.useRef();return L.useEffect(()=>{n.current=e},[e]),L.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]),(...s)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n.current(...s),t)}}function Qa(e,t){const[n,r]=L.useState(e);return L.useEffect(()=>{const s=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(s)}},[e,t]),n}const ar=i.z.object({name:i.z.enum(["dappland","discord","github","telegram","twitter","website"]),url:i.z.string(),position:i.z.number()}),ir=i.z.object({address:l.addressSchemaArgentBackend,chain:i.z.enum(["ethereum","starknet"])}),cr=i.z.object({dappId:i.z.string(),name:i.z.string(),description:i.z.string().optional(),logoUrl:i.z.string().optional(),dappUrl:i.z.string().optional(),inAppBrowserCompatible:i.z.boolean(),argentVerified:i.z.boolean(),links:i.z.array(ar).optional(),contracts:i.z.array(ir).optional(),categories:i.z.array(i.z.string()).optional(),supportedApps:i.z.array(i.z.string()).optional(),brandColor:i.z.string().optional()}),lr=i.z.array(cr);class ei{constructor(t,n){this.apiBase=t,this.httpService=new rt(n,"json")}async getAll(){const t=await this.httpService.get(`${this.apiBase}/tokens/dapps`),n=lr.safeParse(t);if(!n.success)throw new Error("Failed to parse known dapps");return n.data}}function ur(e){var t;return(t=e==null?void 0:e.links)==null?void 0:t.find(n=>n.name==="dappland")}function ti(e){var t;return(t=ur(e))==null?void 0:t.url}const Ft=i.object({domain:l.starknetIdSchema,address:l.addressSchema.optional(),avatar:i.string().optional(),status:i.union([i.literal("KNOWN"),i.literal("UNKNOWN")])}),dr=i.array(Ft),hr=i.object({provider:i.string(),name:i.string(),avatar:i.string().optional()}),fr=i.object({address:l.addressSchema,status:i.union([i.literal("KNOWN"),i.literal("UNKNOWN")]),resolutions:i.array(hr).optional()}),mr=i.array(i.string()),pr=fr.array();class ni{constructor(t,n){this.apiBase=t,this.headers=n,this.httpService=new rt(this.headers,"json")}async getAddressFromMultipleStarknetId(t,n,r){const s=new URLSearchParams(n.map(u=>["domain",u]));r&&s.set("includeAvatar","true");const o=l.urlJoin(this.apiBase,t,"starknet.id",`?${s}`),a=await this.httpService.get(o),c=dr.safeParse(a);if(!c.success)throw new Error("Failed to parse name resolution");return c.data}async getAddressFromStarknetId(t,n,r){const s=l.urlJoin(this.apiBase,t,"starknet.id",n,r?"?includeAvatar=true":""),o=await this.httpService.get(s),a=Ft.safeParse(o);if(!a.success)throw new Error("Failed to parse name resolution");return a.data}async getStarknetIdFromAddress(t,n,r){const s=new URLSearchParams(n.map(u=>["address",u]));r&&s.set("includeAvatar","true");const o=l.urlJoin(this.apiBase,t,"addresses",`?${s}`),a=await this.httpService.get(o),c=pr.safeParse(a);if(!c.success)throw new Error("Failed to parse name resolution");return c.data}async getProvidersNames(t){const n=l.urlJoin(this.apiBase,t,"providers","name"),r=await this.httpService.get(n),s=mr.safeParse(r);if(!s.success)throw new Error("Failed to parse name resolution");return s.data}}const Dt=e=>e.slice(0,6)+"..."+e.slice(-4);function un(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function ri(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function it(e,...t){if(!ri(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 dn(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 si(e,t){it(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const We=BigInt(2**32-1),hn=BigInt(32);function oi(e,t=!1){return t?{h:Number(e&We),l:Number(e>>hn&We)}:{h:Number(e>>hn&We)|0,l:Number(e&We)|0}}function ai(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:a}=oi(e[s],t);[n[s],r[s]]=[o,a]}return[n,r]}const ii=(e,t,n)=>e<<n|t>>>32-n,ci=(e,t,n)=>t<<n|e>>>32-n,li=(e,t,n)=>t<<n-32|e>>>64-n,ui=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const di=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),fn=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,hi=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function mn(e){for(let t=0;t<e.length;t++)e[t]=hi(e[t])}const fi=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function mi(e){it(e);let t="";for(let n=0;n<e.length;n++)t+=fi[e[n]];return t}function gr(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function yr(e){return typeof e=="string"&&(e=gr(e)),it(e),e}let pi=class{clone(){return this._cloneInto()}};function gi(e){const t=r=>e().update(yr(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const Sr=[],wr=[],br=[],yi=BigInt(0),Ne=BigInt(1),Si=BigInt(2),wi=BigInt(7),bi=BigInt(256),Ei=BigInt(113);for(let e=0,t=Ne,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Sr.push(2*(5*r+n)),wr.push((e+1)*(e+2)/2%64);let s=yi;for(let o=0;o<7;o++)t=(t<<Ne^(t>>wi)*Ei)%bi,t&Si&&(s^=Ne<<(Ne<<BigInt(o))-Ne);br.push(s)}const[Ai,Ti]=ai(br,!0),pn=(e,t,n)=>n>32?li(e,t,n):ii(e,t,n),gn=(e,t,n)=>n>32?ui(e,t,n):ci(e,t,n);function vi(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let a=0;a<10;a++)n[a]=e[a]^e[a+10]^e[a+20]^e[a+30]^e[a+40];for(let a=0;a<10;a+=2){const c=(a+8)%10,u=(a+2)%10,d=n[u],f=n[u+1],h=pn(d,f,1)^n[c],S=gn(d,f,1)^n[c+1];for(let y=0;y<50;y+=10)e[a+y]^=h,e[a+y+1]^=S}let s=e[2],o=e[3];for(let a=0;a<24;a++){const c=wr[a],u=pn(s,o,c),d=gn(s,o,c),f=Sr[a];s=e[f],o=e[f+1],e[f]=u,e[f+1]=d}for(let a=0;a<50;a+=10){for(let c=0;c<10;c++)n[c]=e[a+c];for(let c=0;c<10;c++)e[a+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=Ai[r],e[1]^=Ti[r]}n.fill(0)}let Ii=class Er extends pi{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,un(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=di(this.state)}keccak(){fn||mn(this.state32),vi(this.state32,this.rounds),fn||mn(this.state32),this.posOut=0,this.pos=0}update(t){dn(this);const{blockLen:n,state:r}=this;t=yr(t);const s=t.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);for(let c=0;c<a;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){dn(this,!1),it(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 a=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+a),s),this.posOut+=a,s+=a}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return un(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(si(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:a}=this;return t||(t=new Er(n,r,s,a,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=a,t.destroyed=this.destroyed,t}};const xi=(e,t,n)=>gi(()=>new Ii(t,e,n)),_i=xi(1,136,256/8);function Ar(e){return`0x${mi(_i(gr(e)))}`}const Ci=e=>{if(!F.isString(e))return;const t=/(\d+)$/,n=e.match(t);if(n)return n[1]},Tr=(e,t=!1)=>{if(!F.isString(e))return"";const n=t?e.replace(/[^0-9a-z ]/gi,""):e,s=F.upperCase(n).split(" "),o=Ci(n),a=s.map(c=>c[0]);return o&&o.length>1&&o.length<n.length?[a[0],o.substring(0,2)].join(""):s.length===1?s[0].substring(0,2):[a[0],a[a.length-1]].join("")},{toBigInt:Ni}=p.num,yn=e=>{const t=e.replace("#","");if(!/^[0-9A-F]{6}$/i.test(t))throw new Error(`Invalid color ${e}`);return`#${t}`},De=(e,t)=>{const n=yn(t.background),r=yn(t.color??"#ffffff"),s=Tr(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 i=require("zod"),l=require("./schema-C-_pmcO7.js"),p=require("starknet"),L=require("react"),F=require("lodash-es"),Re=require("swr"),Ee=require("@scure/base"),$s=require("ua-parser-js"),js=require("@scure/bip39"),Vs=require("@scure/bip39/wordlists/english"),Ms=require("object-hash"),zn=i.z.object({name:i.z.string().optional(),address:i.z.string(),ownerAddress:i.z.string(),chain:i.z.enum(["ethereum","zksync","zksync2","starknet"]),deploymentStatus:i.z.enum(["notDeployed","deploying","deployed","deployError"]),application:i.z.enum(["mobile","webwallet","argentx"]),guardianAddresses:i.z.array(i.z.string()).optional(),enabledGuardianAddresses:i.z.array(i.z.string()).optional(),implClassHash:i.z.string().optional(),proxyClassHash:i.z.string().optional(),salt:i.z.string().optional(),created:i.z.string().optional(),contractVersion:i.z.string().optional(),contractName:i.z.string().optional(),version:i.z.number().optional(),owner:i.z.object({guid:i.z.string().optional(),signerType:i.z.enum(["StarknetKey","EthereumKey"]).optional()}).optional()}),qs=i.z.object({address:i.z.string(),guardianAddress:i.z.string().optional(),account:zn}),Gs=i.z.object({ownerAddress:i.z.string(),signature:i.z.object({r:i.z.string(),s:i.z.string()}),implClassHash:i.z.string().optional(),name:i.z.string().optional(),icon:i.z.string().optional()});function Ws(e){return"transactionVersion"in e}function Ks(e){return"simulateTransaction"in e}function Zs(e){return!("simulateTransaction"in e)}const Fn=i.z.object({value:i.z.string(),platform:i.z.enum(["ios","argentx","android","webwallet"]).nullable()}),Ys=i.z.object({preferences:i.z.record(Fn)}),Dn=i.z.enum(["mainnet-alpha","sepolia-alpha"]),Un=i.z.enum(["mainnet","sepolia"]);function Js(e){return Dn.safeParse(e).success}function Xs(e){return Un.safeParse(e).success}const Te=18;function $e({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 kt=(e,t)=>({decimals:t,value:t>=e.decimals?e.value*BigInt(10)**BigInt(t-e.decimals):e.value/BigInt(10)**BigInt(e.decimals-t)}),Ln=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 kt(e,r)},Hn=(e,t)=>{const n=Math.max(e.decimals,t.decimals),[r,s]=[e,t].map(o=>kt(o,n));return[r.value,s.value,n]},nt=e=>(t,n)=>{const[r,s,o]=Hn(t,n);return{decimals:o,value:e(r,s,o)}},je=e=>(t,n)=>{const[r,s]=Hn(t,n);return e(r,s)},Qs=nt((e,t)=>e+t),eo=nt((e,t)=>e-t),to=nt((e,t,n)=>{if(t===BigInt(0))throw new Error("Division by zero is not allowed");return e*BigInt(10)**BigInt(n)/t}),no=(e,t)=>Ln({decimals:e.decimals+t.decimals,value:e.value*t.value}),ro=nt((e,t)=>{if(t===BigInt(0))throw new Error("Modulus by zero is not allowed");return e%t}),Ot=e=>({decimals:e.decimals,value:e.value>=BigInt(0)?e.value:-e.value}),$n=je((e,t)=>e===t),so=je((e,t)=>e<t),oo=je((e,t)=>e>t),ao=je((e,t)=>e<=t),io=je((e,t)=>e>=t),co=(e,t)=>!$n(e,t);function me(e,t){let[n,r=""]=e.split(".");const s=n.startsWith("-");return s&&(n=n.slice(1)),r.length>t?Number(r[t])>=5?r=(BigInt(r.slice(0,t))+1n).toString().padStart(t,"0"):r=r.slice(0,t):r=r.padEnd(t,"0"),{value:BigInt(`${s?"-":""}${n}${r}`),decimals:t}}function lo(e){return $e({value:e,decimals:Te})}function uo(e){return me(e,Te)}function ho(e){return $e({value:e,decimals:Te})}function Rt(e){return me(e,Te)}function fo(e){return Ot({value:e,decimals:0}).value}function mo(e){return Ot(Rt(e))}function po(e,t){return{value:BigInt(e),decimals:t}}const go={value:1n,decimals:0};function yo(e){return i.z.string().refine(t=>/^-?\d+(\.\d+)?$/.test(t),{message:"Invalid number format"}).transform(t=>me(t,e))}const So=Object.freeze(Object.defineProperty({__proto__:null,ONE:go,abs:Ot,absBigInt:fo,add:Qs,createUnitsSchema:yo,div:to,eq:$n,formatCurrency:ho,formatEther:lo,formatUnits:$e,gt:oo,gte:io,lt:so,lte:ao,mod:ro,mul:no,not:co,parseCurrency:Rt,parseCurrencyAbs:mo,parseEther:uo,parseUnits:me,sub:eo,toBigDecimal:po,toFixedDecimals:kt,toTiniestPossibleDecimal:Ln},Symbol.toStringTag,{value:"Module"}));class wo{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 bo{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 rt{constructor(t,n="json"){this.requestInit=t,this.responseType=n}async get(t,n){const r=F.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 l.HttpError(l.HTTP_ERROR_MESSAGE.FAILED_TO_FETCH_URL,0)});if(this.responseType==="json"){if(!o.ok)throw new l.HttpError(o.statusText,o.status);return await o.json()}return o}async post(t,n,r){const s=F.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}},a=await fetch(t,o).catch(()=>{throw new l.HttpError(l.HTTP_ERROR_MESSAGE.FAILED_TO_POST_URL,0)});if(!a.ok)throw new l.HttpError(a.statusText,a.status,await a.json());if(a.status===204)return{};const c=await a.json();if(r)try{return r.parse(c)}catch(u){throw new l.HttpError(u.message,0)}return c}async put(t,n){const r=F.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 l.HttpError("Failed to put url",0)});if(!o.ok)throw new l.HttpError(o.statusText,o.status);return await o.json()}async delete(t,n){const r=F.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 l.HttpError("Failed to delete url",0)});if(!o.ok)throw new l.HttpError(o.statusText,o.status)}}const Ge=e=>{process.env.NODE_ENV};function Eo(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 Ao{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")||""),a=s.getTime()-o.getTime();if(a<this.options.freshFor)return Ge("🟢 [SWR] Using fresh cache"),r;if(a<this.options.staleFor)return this.fetchAndCache(t,n),Ge("🟠 [SWR] Revalidating cache"),r;throw new Error("Cache too old")}catch(r){if(r instanceof l.HttpError)throw r;return Ge(),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 a=await this.dateService.now();return await this.cacheService.set(t,Eo(o,{date:a.toUTCString()})),o}).finally(()=>{this.inFlightRequests.delete(t)});return this.inFlightRequests.set(t,s),s}return Ge(),r}parseResponse(t){if(t.ok)return t.json();throw new l.HttpError(t.statusText,t.status)}}const Pe=(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},Pt=async(e,t)=>{const n=await fetch(e,t),r=await n.text();if(!n.ok)throw Pe("An error occurred while fetching",n,r);try{return JSON.parse(r)}catch{throw Pe("An error occurred while parsing",n,r)}},To=async(e,t)=>{const n=await fetch(e,{method:"POST",...t}),r=await n.text();if(!n.ok)throw Pe("An error occurred while fetching",n,r);try{return JSON.parse(r)}catch{throw Pe("An error occurred while parsing",n,r)}},vo=e=>({refreshInterval:e,dedupingInterval:e}),Io=e=>`${e.networkId}::${e.address}`,xo=()=>{};function jn(e,t,n,r){const{cache:s}=Re.useSWRConfig(),o=Re(e&&t,e?n:xo,r);return L.useEffect(()=>{e||(o.mutate(),s.delete(t))},[e]),o}const _o={revalidateOnFocus:!1,revalidateOnMount:!0,revalidateOnReconnect:!1,refreshWhenOffline:!1,refreshWhenHidden:!1,refreshInterval:0},Vn=async(e,t)=>{try{const{time:n}=await Pt(l.urlJoin(e,"time"),{headers:t});return n}catch{throw new Error("failed to request time")}},Co=async(e,t)=>{const n=await Vn(e,t);return Math.floor(n)};function Mn(e){switch(e){case"mainnet-alpha":case p.constants.NetworkName.SN_MAIN:return p.constants.StarknetChainId.SN_MAIN;case"sepolia-alpha":case p.constants.NetworkName.SN_SEPOLIA:return p.constants.StarknetChainId.SN_SEPOLIA;default:throw new l.NetworkError({code:"NOT_FOUND",message:`Unknown networkId: ${e}`})}}function qn(e){return e.replace(".stark","").split(".").map(r=>p.starknetId.useEncoded(r).toString(10))}function Gn(e){const t=Mn(e);return p.starknetId.getStarknetIdContract(t)}function Wn(e,t){const n=Gn(t),r=qn(e);try{const o={domain:r,hint:[]};return l.callSchema.parse({contractAddress:n,entrypoint:"domain_to_address",calldata:o})}catch(s){throw new l.CallError({code:"NOT_VALID",options:{error:s}})}}async function Kn(e,t,n){if(!t||!n)throw new l.NetworkError({code:"NO_NETWORK_OR_MULTICALL"});let r=null;try{r=Wn(e,t)}catch(c){throw new l.CallError({code:"NOT_VALID",options:{error:c}})}let s,o;try{s=await n.callContract(r),o=s[0]}catch{throw new l.AddressError({code:"STARKNAME_ERROR"})}if(l.isZeroAddress(o))throw new l.AddressError({code:"STARKNAME_NOT_FOUND",message:`${e} not found`});if(!l.isValidAddress(o))throw new l.AddressError({code:"STARKNAME_INVALID_ADDRESS",message:`${e} resolved to an invalid address (${o})`});return l.normalizeAddress(o)}class No{constructor(t,n,r){this.httpService=t,this.baseUrl=n,this.allowedArgentNameNetworkId=r}async parseAddressOrDomain(t,n,r){if(l.isAddress(t))return l.normalizeAddress(t);try{return await this.getAddressFromDomainName(t,n,r)}catch{throw new l.AddressError({code:"NOT_VALID"})}}async getAddressFromDomainName(t,n,r){if(l.isStarknetId(t))return Kn(t,n,r);if(l.isArgentName(t)){if(n!==this.allowedArgentNameNetworkId)throw new l.AddressError({code:"ARGENT_NAME_INVALID_NETWORK",message:`Argent name is only enabled on "${this.allowedArgentNameNetworkId}"`});return l.getAddressFromArgentName(t,this.httpService,this.baseUrl)}throw new l.AddressError({code:"NO_ADDRESS_FROM_DOMAIN"})}}const Zn=["0x25ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918"],X={"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"},ze={"0.1.1":"0x6e150953b26271a740bf2b6e9bca17cc52c68d765f761295de51ceb8526ee72","0.1.0":"0x737ee2f87ce571a58c6c8da558ec18a07ceb64a6172d5ec46171fbc80077a48"};var Bo=typeof global=="object"&&global&&global.Object===Object&&global,ko=typeof self=="object"&&self&&self.Object===Object&&self,st=Bo||ko||Function("return this")(),Je=st.Symbol,Yn=Object.prototype,Oo=Yn.hasOwnProperty,Ro=Yn.toString,Ce=Je?Je.toStringTag:void 0;function Po(e){var t=Oo.call(e,Ce),n=e[Ce];try{e[Ce]=void 0;var r=!0}catch{}var s=Ro.call(e);return r&&(t?e[Ce]=n:delete e[Ce]),s}var zo=Object.prototype,Fo=zo.toString;function Do(e){return Fo.call(e)}var Uo="[object Null]",Lo="[object Undefined]",cn=Je?Je.toStringTag:void 0;function Ho(e){return e==null?e===void 0?Lo:Uo:cn&&cn in Object(e)?Po(e):Do(e)}function Jn(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var $o="[object AsyncFunction]",jo="[object Function]",Vo="[object GeneratorFunction]",Mo="[object Proxy]";function qo(e){if(!Jn(e))return!1;var t=Ho(e);return t==jo||t==Vo||t==$o||t==Mo}var pt=st["__core-js_shared__"],ln=function(){var e=/[^.]+$/.exec(pt&&pt.keys&&pt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Go(e){return!!ln&&ln in e}var Wo=Function.prototype,Ko=Wo.toString;function Zo(e){if(e!=null){try{return Ko.call(e)}catch{}try{return e+""}catch{}}return""}var Yo=/[\\^$.*+?()[\]{}|]/g,Jo=/^\[object .+?Constructor\]$/,Xo=Function.prototype,Qo=Object.prototype,ea=Xo.toString,ta=Qo.hasOwnProperty,na=RegExp("^"+ea.call(ta).replace(Yo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ra(e){if(!Jn(e)||Go(e))return!1;var t=qo(e)?na:Jo;return t.test(Zo(e))}function sa(e,t){return e==null?void 0:e[t]}function zt(e,t){var n=sa(e,t);return ra(n)?n:void 0}var Fe=zt(Object,"create");function oa(){this.__data__=Fe?Fe(null):{},this.size=0}function aa(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var ia="__lodash_hash_undefined__",ca=Object.prototype,la=ca.hasOwnProperty;function ua(e){var t=this.__data__;if(Fe){var n=t[e];return n===ia?void 0:n}return la.call(t,e)?t[e]:void 0}var da=Object.prototype,ha=da.hasOwnProperty;function fa(e){var t=this.__data__;return Fe?t[e]!==void 0:ha.call(t,e)}var ma="__lodash_hash_undefined__";function pa(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Fe&&t===void 0?ma: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=oa;de.prototype.delete=aa;de.prototype.get=ua;de.prototype.has=fa;de.prototype.set=pa;function ga(){this.__data__=[],this.size=0}function ya(e,t){return e===t||e!==e&&t!==t}function ot(e,t){for(var n=e.length;n--;)if(ya(e[n][0],t))return n;return-1}var Sa=Array.prototype,wa=Sa.splice;function ba(e){var t=this.__data__,n=ot(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():wa.call(t,n,1),--this.size,!0}function Ea(e){var t=this.__data__,n=ot(t,e);return n<0?void 0:t[n][1]}function Aa(e){return ot(this.__data__,e)>-1}function Ta(e,t){var n=this.__data__,r=ot(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function ve(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])}}ve.prototype.clear=ga;ve.prototype.delete=ba;ve.prototype.get=Ea;ve.prototype.has=Aa;ve.prototype.set=Ta;var va=zt(st,"Map");function Ia(){this.size=0,this.__data__={hash:new de,map:new(va||ve),string:new de}}function xa(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function at(e,t){var n=e.__data__;return xa(t)?n[typeof t=="string"?"string":"hash"]:n.map}function _a(e){var t=at(this,e).delete(e);return this.size-=t?1:0,t}function Ca(e){return at(this,e).get(e)}function Na(e){return at(this,e).has(e)}function Ba(e,t){var n=at(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function Ie(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])}}Ie.prototype.clear=Ia;Ie.prototype.delete=_a;Ie.prototype.get=Ca;Ie.prototype.has=Na;Ie.prototype.set=Ba;var ka="__lodash_hash_undefined__";function Oa(e){return this.__data__.set(e,ka),this}function Ra(e){return this.__data__.has(e)}function Xe(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Ie;++t<n;)this.add(e[t])}Xe.prototype.add=Xe.prototype.push=Oa;Xe.prototype.has=Ra;function Pa(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 za(e){return e!==e}function Fa(e,t,n){for(var r=n-1,s=e.length;++r<s;)if(e[r]===t)return r;return-1}function Da(e,t,n){return t===t?Fa(e,t,n):Pa(e,za,n)}function Ua(e,t){var n=e==null?0:e.length;return!!n&&Da(e,t,0)>-1}function La(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 Ha(e,t){return e.has(t)}var gt=zt(st,"Set");function $a(){}function Xn(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var ja=1/0,Va=gt&&1/Xn(new gt([,-0]))[1]==ja?function(e){return new gt(e)}:$a,Ma=200;function qa(e,t,n){var r=-1,s=Ua,o=e.length,a=!0,c=[],u=c;if(n)a=!1,s=La;else if(o>=Ma){var d=Va(e);if(d)return Xn(d);a=!1,s=Ha,u=new Xe}else u=c;e:for(;++r<o;){var f=e[r],h=f;if(f=n||f!==0?f:0,a&&h===h){for(var S=u.length;S--;)if(u[S]===h)continue e;c.push(f)}else s(u,h,n)||(u!==c&&u.push(h),c.push(f))}return c}function Ga(e,t){return t=typeof t=="function"?t:void 0,e&&e.length?qa(e,void 0,t):[]}function Tt(e){const t=Object.entries(X),n=Object.entries(ze);switch(e){case"cairo0":return t.filter(([r])=>l.semver.lt(r,"0.3.0")).map(([,r])=>r);case"cairo1":return t.filter(([r])=>l.semver.gte(r,"0.3.0")).map(([,r])=>r);case"multisig":return n.map(([,r])=>r);default:return t.map(([,r])=>r)}}function Qn(){const e=l.semver.maxSatisfying(Object.keys(X),"*");if(!e)throw new Error(`No argent account contract found: v${e} `);return X[e]}function Wa(){const e=l.semver.maxSatisfying(Object.keys(ze),"*");if(!e)throw new Error(`No argent multisig contract found: v${e} `);return ze[e]}function er(){return Object.entries(X).filter(([e])=>l.semver.gte(e,"0.4.0")).map(([,e])=>e)}function Ka(){const e=l.semver.maxSatisfying(Object.keys(X),"<0.3.0");if(!e)throw new Error(`No argent account contract found: v${e} `);return X[e]}function tr(){const e=Object.entries(X).filter(([n])=>l.semver.gte(n,"0.3.1")).map(([,n])=>n),t=Object.entries(ze).filter(([n])=>l.semver.gte(n,"0.1.1")).map(([,n])=>n);return[...e,...t]}function Za(){return Object.entries(X).filter(([e])=>l.semver.gte(e,"0.4.0")).map(([,e])=>e)}function Ya(){const e=l.semver.maxSatisfying(Object.keys(X),">=0.4.0");if(!e)throw new Error(`No ledger account contract found: v${e}`);return X[e]}const nr=(e,t)=>e.cairoVersion===t.cairoVersion&&l.isEqualAddress(e.accountClassHash,t.accountClassHash);function Ja(e,t,n=[]){const r=l.implementationSchema.parse({cairoVersion:t.cairoVersion??"1",accountClassHash:t.classHash??Qn()}),s=i.z.array(l.implementationSchema).parse(n),o=[...Tt("cairo0").map(d=>({cairoVersion:"0",accountClassHash:d})),...Tt("cairo1").map(d=>({cairoVersion:"1",accountClassHash:d}))],u=Ga([r,...s,...o],nr).map(d=>({implementation:d,address:or(d.cairoVersion,d.accountClassHash,e,t.guardian,t.salt)})).find(d=>l.isEqualAddress(d.address,t.address));if(!u)throw new l.AccountError({code:"CALCULATED_ADDRESS_NO_MATCH"});return u.implementation}function rr(e,t,n,r,s,o=Zn[0]){const a=sr(e,t,n,r);return{classHash:e==="0"?o:t,constructorCalldata:p.CallData.compile(a),addressSalt:s||n}}function sr(e,t,n,r){const s=e!=="0"&&l.isEqualAddress(l.STANDARD_DEVNET_ACCOUNT_CLASS_HASH,t),o={pubkey:n,...s?{}:{guardian:r||"0"}};if(er().some(c=>l.isEqualAddress(c,t))){const c=l.getSignerForMultiSigner(n,l.MultiSigner.Starknet),u=r?new p.CairoOption(p.CairoOptionVariant.Some,l.getSignerForMultiSigner(r,l.MultiSigner.Starknet)):new p.CairoOption(p.CairoOptionVariant.None,null);return{ownerSigner:c,guardianAsOption:u}}return e==="0"?l.constructorCallDataSchemaC0.parse({implementation:t,selector:p.hash.getSelectorFromName("initialize"),calldata:p.CallData.compile(o)}):l.constructorCallDataSchemaC1V1.parse({owner:n,guardian:r})}function or(e,t,n,r,s){const o=rr(e,t,n,r,s);return p.hash.calculateContractAddressFromHash(o.addressSalt,o.classHash,o.constructorCalldata,0)}function Xa(e,t){const n=L.useRef(e),r=L.useRef();return L.useEffect(()=>{n.current=e},[e]),L.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]),(...s)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n.current(...s),t)}}function Qa(e,t){const[n,r]=L.useState(e);return L.useEffect(()=>{const s=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(s)}},[e,t]),n}const ar=i.z.object({name:i.z.enum(["dappland","discord","github","telegram","twitter","website"]),url:i.z.string(),position:i.z.number()}),ir=i.z.object({address:l.addressSchemaArgentBackend,chain:i.z.enum(["ethereum","starknet"])}),cr=i.z.object({dappId:i.z.string(),name:i.z.string(),description:i.z.string().optional(),logoUrl:i.z.string().optional(),dappUrl:i.z.string().optional(),inAppBrowserCompatible:i.z.boolean(),argentVerified:i.z.boolean(),links:i.z.array(ar).optional(),contracts:i.z.array(ir).optional(),categories:i.z.array(i.z.string()).optional(),supportedApps:i.z.array(i.z.string()).optional(),brandColor:i.z.string().optional()}),lr=i.z.array(cr);class ei{constructor(t,n){this.apiBase=t,this.httpService=new rt(n,"json")}async getAll(){const t=await this.httpService.get(`${this.apiBase}/tokens/dapps`),n=lr.safeParse(t);if(!n.success)throw new Error("Failed to parse known dapps");return n.data}}function ur(e){var t;return(t=e==null?void 0:e.links)==null?void 0:t.find(n=>n.name==="dappland")}function ti(e){var t;return(t=ur(e))==null?void 0:t.url}const Ft=i.object({domain:l.starknetIdSchema,address:l.addressSchema.optional(),avatar:i.string().optional(),status:i.union([i.literal("KNOWN"),i.literal("UNKNOWN")])}),dr=i.array(Ft),hr=i.object({provider:i.string(),name:i.string(),avatar:i.string().optional()}),fr=i.object({address:l.addressSchema,status:i.union([i.literal("KNOWN"),i.literal("UNKNOWN")]),resolutions:i.array(hr).optional()}),mr=i.array(i.string()),pr=fr.array();class ni{constructor(t,n){this.apiBase=t,this.headers=n,this.httpService=new rt(this.headers,"json")}async getAddressFromMultipleStarknetId(t,n,r){const s=new URLSearchParams(n.map(u=>["domain",u]));r&&s.set("includeAvatar","true");const o=l.urlJoin(this.apiBase,t,"starknet.id",`?${s}`),a=await this.httpService.get(o),c=dr.safeParse(a);if(!c.success)throw new Error("Failed to parse name resolution");return c.data}async getAddressFromStarknetId(t,n,r){const s=l.urlJoin(this.apiBase,t,"starknet.id",n,r?"?includeAvatar=true":""),o=await this.httpService.get(s),a=Ft.safeParse(o);if(!a.success)throw new Error("Failed to parse name resolution");return a.data}async getStarknetIdFromAddress(t,n,r){const s=new URLSearchParams(n.map(u=>["address",u]));r&&s.set("includeAvatar","true");const o=l.urlJoin(this.apiBase,t,"addresses",`?${s}`),a=await this.httpService.get(o),c=pr.safeParse(a);if(!c.success)throw new Error("Failed to parse name resolution");return c.data}async getProvidersNames(t){const n=l.urlJoin(this.apiBase,t,"providers","name"),r=await this.httpService.get(n),s=mr.safeParse(r);if(!s.success)throw new Error("Failed to parse name resolution");return s.data}}const Dt=e=>e.slice(0,6)+"..."+e.slice(-4);function un(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function ri(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function it(e,...t){if(!ri(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 dn(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 si(e,t){it(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const We=BigInt(2**32-1),hn=BigInt(32);function oi(e,t=!1){return t?{h:Number(e&We),l:Number(e>>hn&We)}:{h:Number(e>>hn&We)|0,l:Number(e&We)|0}}function ai(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:a}=oi(e[s],t);[n[s],r[s]]=[o,a]}return[n,r]}const ii=(e,t,n)=>e<<n|t>>>32-n,ci=(e,t,n)=>t<<n|e>>>32-n,li=(e,t,n)=>t<<n-32|e>>>64-n,ui=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const di=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),fn=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,hi=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function mn(e){for(let t=0;t<e.length;t++)e[t]=hi(e[t])}const fi=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function mi(e){it(e);let t="";for(let n=0;n<e.length;n++)t+=fi[e[n]];return t}function gr(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function yr(e){return typeof e=="string"&&(e=gr(e)),it(e),e}let pi=class{clone(){return this._cloneInto()}};function gi(e){const t=r=>e().update(yr(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const Sr=[],wr=[],br=[],yi=BigInt(0),Ne=BigInt(1),Si=BigInt(2),wi=BigInt(7),bi=BigInt(256),Ei=BigInt(113);for(let e=0,t=Ne,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Sr.push(2*(5*r+n)),wr.push((e+1)*(e+2)/2%64);let s=yi;for(let o=0;o<7;o++)t=(t<<Ne^(t>>wi)*Ei)%bi,t&Si&&(s^=Ne<<(Ne<<BigInt(o))-Ne);br.push(s)}const[Ai,Ti]=ai(br,!0),pn=(e,t,n)=>n>32?li(e,t,n):ii(e,t,n),gn=(e,t,n)=>n>32?ui(e,t,n):ci(e,t,n);function vi(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let a=0;a<10;a++)n[a]=e[a]^e[a+10]^e[a+20]^e[a+30]^e[a+40];for(let a=0;a<10;a+=2){const c=(a+8)%10,u=(a+2)%10,d=n[u],f=n[u+1],h=pn(d,f,1)^n[c],S=gn(d,f,1)^n[c+1];for(let y=0;y<50;y+=10)e[a+y]^=h,e[a+y+1]^=S}let s=e[2],o=e[3];for(let a=0;a<24;a++){const c=wr[a],u=pn(s,o,c),d=gn(s,o,c),f=Sr[a];s=e[f],o=e[f+1],e[f]=u,e[f+1]=d}for(let a=0;a<50;a+=10){for(let c=0;c<10;c++)n[c]=e[a+c];for(let c=0;c<10;c++)e[a+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=Ai[r],e[1]^=Ti[r]}n.fill(0)}let Ii=class Er extends pi{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,un(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=di(this.state)}keccak(){fn||mn(this.state32),vi(this.state32,this.rounds),fn||mn(this.state32),this.posOut=0,this.pos=0}update(t){dn(this);const{blockLen:n,state:r}=this;t=yr(t);const s=t.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);for(let c=0;c<a;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){dn(this,!1),it(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 a=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+a),s),this.posOut+=a,s+=a}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return un(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(si(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:a}=this;return t||(t=new Er(n,r,s,a,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=a,t.destroyed=this.destroyed,t}};const xi=(e,t,n)=>gi(()=>new Ii(t,e,n)),_i=xi(1,136,256/8);function Ar(e){return`0x${mi(_i(gr(e)))}`}const Ci=e=>{if(!F.isString(e))return;const t=/(\d+)$/,n=e.match(t);if(n)return n[1]},Tr=(e,t=!1)=>{if(!F.isString(e))return"";const n=t?e.replace(/[^0-9a-z ]/gi,""):e,s=F.upperCase(n).split(" "),o=Ci(n),a=s.map(c=>c[0]);return o&&o.length>1&&o.length<n.length?[a[0],o.substring(0,2)].join(""):s.length===1?s[0].substring(0,2):[a[0],a[a.length-1]].join("")},{toBigInt:Ni}=p.num,yn=e=>{const t=e.replace("#","");if(!/^[0-9A-F]{6}$/i.test(t))throw new Error(`Invalid color ${e}`);return`#${t}`},De=(e,t)=>{const n=yn(t.background),r=yn(t.color??"#ffffff"),s=Tr(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
- </svg>`;return`data:image/svg+xml;base64,${btoa(o)}`},Sn=["02BBA8","29C5FF","0078A4","FFBF3D","FFA85C","FF875B","FF675C","FF5C72"],vr=e=>{const t=Ar(e).slice(-2),n=parseInt(t,16)%Sn.length;return Sn[n]},Ir=e=>{try{return p.num.toHex(Ni(p.num.hexToDecimalString(e)))}catch{}return""},Bi=({accountName:e,networkId:t,accountAddress:n,backgroundColor:r})=>{const s=Ir(n),o=`${t}::${s}`,a=r||vr(o);return De(e,{background:a})},xr=e=>{const t=p.encode.removeHexPrefix(p.encode.sanitizeHex(p.num.toHex(e))),n=Ee.hex.decode(t);return Ee.base58.encode(n)},ki=e=>e.map(xr),_r=e=>{const t=Ee.base58.decode(e);return p.encode.sanitizeHex(Ee.hex.encode(t))},Oi=e=>e.map(_r);function Ri(e,t){const n=e.getTime(),r=t.getTime(),s=Math.abs(n-r);return Math.floor(s/(1e3*60*60*24))}const Pi=e=>(e||"false")==="true",zi=async(e,t)=>{try{return await e.getClassHashAt(t),!0}catch{return!1}};function Fi(e){return!F.isNil(e)}const Di=e=>{const t=/^(0|0x([a-f0-9A-F]+)?)$/;return!!(e===""||t.test(e))},K=e=>!isNaN(parseFloat(e))&&isFinite(Number(e)),Ui=(e,t=16)=>{const n=new RegExp(`^[0-9]*.?[0-9]{0,${t}}$`);return e===""?!0:K(e)?!!n.test(e):!1},ct={CURRENCY:{minDecimalPlaces:2,maxDecimalPlaces:10,minDecimalSignificantDigits:2,decimalPlacesWhenZero:2,allowLeadingZerosInDecimalPart:!0},TOKEN:{minDecimalPlaces:4,maxDecimalPlaces:16,minDecimalSignificantDigits:2,decimalPlacesWhenZero:1,allowLeadingZerosInDecimalPart:!0}},Cr=(e,t)=>Ut(e,{...ct.CURRENCY,...t||{}}),Nr=(e,t)=>Ut(e,{...ct.TOKEN,...t||{}}),Ut=(e,{minDecimalPlaces:t,maxDecimalPlaces:n,minDecimalSignificantDigits:r,decimalPlacesWhenZero:s,allowLeadingZerosInDecimalPart:o}=ct.CURRENCY)=>{if(!K(e))return null;const a=new l.BigNumber(typeof e=="bigint"?e.toString():e);let c;const u=`0.${"".padStart(s-1,"0")}1`;if(a.lt(new l.BigNumber(u))&&!o)c=`0.${"".padStart(s,"0")}`;else if(a.gte(1))c=a.toFormat(t);else{const y=a.toFormat(n).split(".")[1].match(/^0+/),A=o&&y&&y.length?y[0].length:0,m=Math.max(A+r,t);c=a.toFormat(m)}let d=c.replace(/0+$/,"");const f=1+c.indexOf(".")+s;return d.length<f&&(d=c.substring(0,f)),d},Br=(e,t=18)=>{const n=e.replace(",",".");return!e||!K(n)?0n:me(n,Number(t)).value};function Ae(e){return p.uint256.bnToUint256(e)}const Li=(e,t)=>`${e} ${t}${e===1?"":"s"}`,Hi=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 $i(e){try{return F.upperFirst(F.lowerCase(e))}catch{return e}}const ji=(e,t)=>{const n=new URLSearchParams(t),r=n.size?`?${n}`:"";return l.urlJoin(...l.ensureArray(e),r)};function Vi(e){return(...t)=>{e(...t)}}class Mi extends Error{constructor(t,n){super(`${t}::${n}`),this.name=t,this.code=n,this.name=t}}class wn extends Mi{constructor(t){super("BackendPaginationError",t)}}const bn=32;class qi{constructor(t,n,r){this.apiBase=t,this.headers=n,this.imageOptimizationUrl=r,this.httpService=new rt(this.headers,"json")}async getNfts(t,n,r,s=1){const o=this.normalizeAddress(r),a=l.urlJoin(this.apiBase,"pandora",t,n),c=this.pageToPageIndex(s),d=`${l.urlJoin(a,"profile",o,"nfts")}?page=${c}&size=${bn}`,f=await this.httpService.get(d),h=f.content.map(S=>this.mapItem(S,r));return{totalPages:f.totalPages,page:f.number+1,count:h.length,nfts:h}}async getCollection(t,n,r){const s=this.normalizeAddress(r),o=l.urlJoin(this.apiBase,"pandora",t,n),a=l.urlJoin(o,"collection",s),c=`${o}/collection/${s}`,[u,d]=await Promise.all([this.httpService.get(a),this.httpService.get(c)]),f=yt(u),h=d.content.map(S=>this.mapItem(S));return{...f,nfts:{totalPages:d.totalPages,page:d.number,count:h.length,data:h}}}async getNft(t,n,r,s){const o=this.normalizeAddress(r),a=l.urlJoin(this.apiBase,"pandora",t,n),c=l.urlJoin(a,"nft",o,s),u=await this.httpService.get(c);return this.mapItem(u)}async getProfileCollections(t,n,r,s=1,o=!1){const a=this.pageToPageIndex(s),c=this.normalizeAddress(r),u=l.urlJoin(this.apiBase,"pandora",t,n),d=l.urlJoin(u,"profile",c,"collections",`?page=${a}&size=${bn}`),f=await this.httpService.get(d),h=[];for(const S of f.content)if(o){const y=await this.getCollectionMetrics(t,n,S.contractAddress);h.push(yt(S,y))}else h.push(yt(S));return{totalPages:f.totalPages,page:f.number+1,count:h.length,collections:h}}async getCollectionMetrics(t,n,r){const s=this.normalizeAddress(r),o=l.urlJoin(this.apiBase,"pandora",t,n),a=l.urlJoin(o,"collection",s,"metrics");return this.httpService.get(a)}normalizeAddress(t){return l.addressSchemaArgentBackend.parse(t)}pageToPageIndex(t){if(!Number.isInteger(t))throw new wn("notANumber");const n=t-1;if(n<0)throw new wn("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?Gi(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)??De(r,{background:"#15192A",color:"#ffffff"}),image_url_copy:this.optimizeImage(t.imageUrls.full)??De(r,{background:"#15192A",color:"#ffffff"}),owner:{account_address:((s=t.owner)==null?void 0:s.address)||n},contract_name:Dt(t.contractAddress)}}}function Gi(e){switch(e){case"erc721":case"starknetErc721":return"ERC721";case"erc1155":case"starknetErc1155":return"ERC1155"}}function yt(e,t){return{contractAddress:l.addressSchema.parse(e.contractAddress),name:e.name||Dt(e.contractAddress),description:e.description??"",imageUri:e.imageUrls.preview??De(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 kr=async(e,t,n,r,s=1)=>{const o=await e.getNfts(t,n,r,s);if(s<o.totalPages){const a=await kr(e,t,n,r,o.page+1);return{...o,nfts:o.nfts.concat(a.nfts)}}return o},Wi=(e,t,n,r,s)=>{const{data:o,...a}=Re(r&&[r,"nfts"],()=>r&&kr(e,t,n,r),{refreshInterval:3e5,...s});return{nfts:o==null?void 0:o.nfts,...a}},Ki=(e,t,n,r,s)=>{const{data:o,...a}=Re(r&&[`${r}`,"nfts-collection"],()=>r&&e.getCollection(t,n,r),{refreshInterval:6e4,...s});return{collection:o,...a}},Zi=(e,t,n,r,s,o)=>{const{data:a,...c}=Re(s&&r&&[`${r}:${s}`,"nft"],()=>s&&r?e.getNft(t,n,r,s):void 0,{refreshInterval:6e4,revalidateOnFocus:!1,revalidateOnMount:!1,...o});return{nft:a,...c}},Yi=({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},Ji=(e,t)=>e.token_id===t.token_id&&l.isEqualAddress(e.contract_address,t.contract_address);function En(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Xi(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Or(e,...t){if(!Xi(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 Qe(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 Rr(e,t){Or(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Ke=BigInt(2**32-1),An=BigInt(32);function Qi(e,t=!1){return t?{h:Number(e&Ke),l:Number(e>>An&Ke)}:{h:Number(e>>An&Ke)|0,l:Number(e&Ke)|0}}function ec(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:a}=Qi(e[s],t);[n[s],r[s]]=[o,a]}return[n,r]}const tc=(e,t,n)=>e<<n|t>>>32-n,nc=(e,t,n)=>t<<n|e>>>32-n,rc=(e,t,n)=>t<<n-32|e>>>64-n,sc=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const oc=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));function ac(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}const St=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Q=(e,t)=>e<<32-t|e>>>t,ic=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!ic)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 Lt(e){if(typeof e=="string"&&(e=Pr(e)),!ac(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}let zr=class{clone(){return this._cloneInto()}};function Fr(e){const t=r=>e().update(Lt(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const[Dr,Ur,Lr]=[[],[],[]],cc=BigInt(0),Be=BigInt(1),lc=BigInt(2),uc=BigInt(7),dc=BigInt(256),hc=BigInt(113);for(let e=0,t=Be,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Dr.push(2*(5*r+n)),Ur.push((e+1)*(e+2)/2%64);let s=cc;for(let o=0;o<7;o++)t=(t<<Be^(t>>uc)*hc)%dc,t&lc&&(s^=Be<<(Be<<BigInt(o))-Be);Lr.push(s)}const[fc,mc]=ec(Lr,!0),Tn=(e,t,n)=>n>32?rc(e,t,n):tc(e,t,n),vn=(e,t,n)=>n>32?sc(e,t,n):nc(e,t,n);function pc(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let a=0;a<10;a++)n[a]=e[a]^e[a+10]^e[a+20]^e[a+30]^e[a+40];for(let a=0;a<10;a+=2){const c=(a+8)%10,u=(a+2)%10,d=n[u],f=n[u+1],h=Tn(d,f,1)^n[c],S=vn(d,f,1)^n[c+1];for(let y=0;y<50;y+=10)e[a+y]^=h,e[a+y+1]^=S}let s=e[2],o=e[3];for(let a=0;a<24;a++){const c=Ur[a],u=Tn(s,o,c),d=vn(s,o,c),f=Dr[a];s=e[f],o=e[f+1],e[f]=u,e[f+1]=d}for(let a=0;a<50;a+=10){for(let c=0;c<10;c++)n[c]=e[a+c];for(let c=0;c<10;c++)e[a+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=fc[r],e[1]^=mc[r]}n.fill(0)}class Ht extends zr{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,En(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=oc(this.state)}keccak(){pc(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Qe(this);const{blockLen:n,state:r}=this;t=Lt(t);const s=t.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);for(let c=0;c<a;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){Qe(this,!1),Or(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 a=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+a),s),this.posOut+=a,s+=a}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return En(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Rr(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:a}=this;return t||(t=new Ht(n,r,s,a,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=a,t.destroyed=this.destroyed,t}}const gc=(e,t,n)=>Fr(()=>new Ht(t,e,n)),yc=gc(1,136,256/8);function Sc(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),a=Number(n>>s&o),c=Number(n&o),u=r?4:0,d=r?0:4;e.setUint32(t+u,a,r),e.setUint32(t+d,c,r)}class wc extends zr{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=St(this.buffer)}update(t){Qe(this);const{view:n,buffer:r,blockLen:s}=this;t=Lt(t);const o=t.length;for(let a=0;a<o;){const c=Math.min(s-this.pos,o-a);if(c===s){const u=St(t);for(;s<=o-a;a+=s)this.process(u,a);continue}r.set(t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Qe(this),Rr(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:o}=this;let{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>s-a&&(this.process(r,0),a=0);for(let h=a;h<s;h++)n[h]=0;Sc(r,s-8,BigInt(this.length*8),o),this.process(r,0);const c=St(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=u/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<d;h++)c.setUint32(4*h,f[h],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:a,pos:c}=this;return t.length=s,t.pos=c,t.finished=o,t.destroyed=a,s%n&&t.buffer.set(r),t}}const bc=(e,t,n)=>e&t^~e&n,Ec=(e,t,n)=>e&t^e&n^t&n,Ac=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]),oe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ae=new Uint32Array(64);class Tc extends wc{constructor(){super(64,32,8,!1),this.A=oe[0]|0,this.B=oe[1]|0,this.C=oe[2]|0,this.D=oe[3]|0,this.E=oe[4]|0,this.F=oe[5]|0,this.G=oe[6]|0,this.H=oe[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:a,G:c,H:u}=this;return[t,n,r,s,o,a,c,u]}set(t,n,r,s,o,a,c,u){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=a|0,this.G=c|0,this.H=u|0}process(t,n){for(let h=0;h<16;h++,n+=4)ae[h]=t.getUint32(n,!1);for(let h=16;h<64;h++){const S=ae[h-15],y=ae[h-2],A=Q(S,7)^Q(S,18)^S>>>3,m=Q(y,17)^Q(y,19)^y>>>10;ae[h]=m+ae[h-7]+A+ae[h-16]|0}let{A:r,B:s,C:o,D:a,E:c,F:u,G:d,H:f}=this;for(let h=0;h<64;h++){const S=Q(c,6)^Q(c,11)^Q(c,25),y=f+S+bc(c,u,d)+Ac[h]+ae[h]|0,m=(Q(r,2)^Q(r,13)^Q(r,22))+Ec(r,s,o)|0;f=d,d=u,u=c,c=a+y|0,a=o,o=s,s=r,r=y+m|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,a=a+this.D|0,c=c+this.E|0,u=u+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(r,s,o,a,c,u,d,f)}roundClean(){ae.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Hr=Fr(()=>new Tc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $r=BigInt(0),lt=BigInt(1),vc=BigInt(2),ut=e=>e instanceof Uint8Array,Ic=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function he(e){if(!ut(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=Ic[e[n]];return t}function jr(e){const t=e.toString(16);return t.length&1?`0${t}`:t}function $t(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}function fe(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 J(e){return $t(he(e))}function jt(e){if(!ut(e))throw new Error("Uint8Array expected");return $t(he(Uint8Array.from(e).reverse()))}const we=(e,t)=>fe(e.toString(16).padStart(t*2,"0")),Vr=(e,t)=>we(e,t).reverse(),xc=e=>fe(jr(e));function V(e,t,n){let r;if(typeof t=="string")try{r=fe(t)}catch(o){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${o}`)}else if(ut(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 Ue(...e){const t=new Uint8Array(e.reduce((r,s)=>r+s.length,0));let n=0;return e.forEach(r=>{if(!ut(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}function _c(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 Cc(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function Nc(e){let t;for(t=0;e>$r;e>>=lt,t+=1);return t}const Bc=(e,t)=>e>>BigInt(t)&lt,kc=(e,t,n)=>e|(n?lt:$r)<<BigInt(t),dt=e=>(vc<<BigInt(e-1))-lt,wt=e=>new Uint8Array(e),In=e=>Uint8Array.from(e);function Mr(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=wt(e),s=wt(e),o=0;const a=()=>{r.fill(1),s.fill(0),o=0},c=(...h)=>n(s,r,...h),u=(h=wt())=>{s=c(In([0]),h),r=c(),h.length!==0&&(s=c(In([1]),h),r=c())},d=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const S=[];for(;h<t;){r=c();const y=r.slice();S.push(y),h+=r.length}return Ue(...S)};return(h,S)=>{a(),u(h);let y;for(;!(y=S(d()));)u();return a(),y}}const Oc={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 Ve(e,t,n={}){const r=(s,o,a)=>{const c=Oc[o];if(typeof c!="function")throw new Error(`Invalid validator "${o}", expected function`);const u=e[s];if(!(a&&u===void 0)&&!c(u,e))throw new Error(`Invalid param ${String(s)}=${u} (${typeof u}), 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 Rc=Object.freeze(Object.defineProperty({__proto__:null,bitGet:Bc,bitLen:Nc,bitMask:dt,bitSet:kc,bytesToHex:he,bytesToNumberBE:J,bytesToNumberLE:jt,concatBytes:Ue,createHmacDrbg:Mr,ensureBytes:V,equalBytes:_c,hexToBytes:fe,hexToNumber:$t,numberToBytesBE:we,numberToBytesLE:Vr,numberToHexUnpadded:jr,numberToVarBytesBE:xc,utf8ToBytes:Cc,validateObject:Ve},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const D=BigInt(0),z=BigInt(1),ce=BigInt(2),Pc=BigInt(3),vt=BigInt(4),xn=BigInt(5),_n=BigInt(8);BigInt(9);BigInt(16);function M(e,t){const n=e%t;return n>=D?n:t+n}function zc(e,t,n){if(n<=D||t<D)throw new Error("Expected power/modulo > 0");if(n===z)return D;let r=z;for(;t>D;)t&z&&(r=r*e%n),e=e*e%n,t>>=z;return r}function It(e,t){if(e===D||t<=D)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=M(e,t),r=t,s=D,o=z;for(;n!==D;){const c=r/n,u=r%n,d=s-o*c;r=n,n=u,s=o,o=d}if(r!==z)throw new Error("invert: does not exist");return M(s,t)}function Fc(e){const t=(e-z)/ce;let n,r,s;for(n=e-z,r=0;n%ce===D;n/=ce,r++);for(s=ce;s<e&&zc(s,t,e)!==e-z;s++);if(r===1){const a=(e+z)/vt;return function(u,d){const f=u.pow(d,a);if(!u.eql(u.sqr(f),d))throw new Error("Cannot find square root");return f}}const o=(n+z)/ce;return function(c,u){if(c.pow(u,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let d=r,f=c.pow(c.mul(c.ONE,s),n),h=c.pow(u,o),S=c.pow(u,n);for(;!c.eql(S,c.ONE);){if(c.eql(S,c.ZERO))return c.ZERO;let y=1;for(let m=c.sqr(S);y<d&&!c.eql(m,c.ONE);y++)m=c.sqr(m);const A=c.pow(f,z<<BigInt(d-y-1));f=c.sqr(A),h=c.mul(h,A),S=c.mul(S,f),d=y}return h}}function Dc(e){if(e%vt===Pc){const t=(e+z)/vt;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%_n===xn){const t=(e-xn)/_n;return function(r,s){const o=r.mul(s,ce),a=r.pow(o,t),c=r.mul(s,a),u=r.mul(r.mul(c,ce),a),d=r.mul(c,r.sub(u,r.ONE));if(!r.eql(r.sqr(d),s))throw new Error("Cannot find square root");return d}}return Fc(e)}const Uc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Vt(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=Uc.reduce((r,s)=>(r[s]="function",r),t);return Ve(e,n)}function qr(e,t,n){if(n<D)throw new Error("Expected power > 0");if(n===D)return e.ONE;if(n===z)return t;let r=e.ONE,s=t;for(;n>D;)n&z&&(r=e.mul(r,s)),s=e.sqr(s),n>>=z;return r}function Lc(e,t){const n=new Array(t.length),r=t.reduce((o,a,c)=>e.is0(a)?o:(n[c]=o,e.mul(o,a)),e.ONE),s=e.inv(r);return t.reduceRight((o,a,c)=>e.is0(a)?o:(n[c]=e.mul(o,n[c]),e.mul(o,a)),s),n}function Mt(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function qt(e,t,n=!1,r={}){if(e<=D)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:s,nByteLength:o}=Mt(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const a=Dc(e),c=Object.freeze({ORDER:e,BITS:s,BYTES:o,MASK:dt(s),ZERO:D,ONE:z,create:u=>M(u,e),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return D<=u&&u<e},is0:u=>u===D,isOdd:u=>(u&z)===z,neg:u=>M(-u,e),eql:(u,d)=>u===d,sqr:u=>M(u*u,e),add:(u,d)=>M(u+d,e),sub:(u,d)=>M(u-d,e),mul:(u,d)=>M(u*d,e),pow:(u,d)=>qr(c,u,d),div:(u,d)=>M(u*It(d,e),e),sqrN:u=>u*u,addN:(u,d)=>u+d,subN:(u,d)=>u-d,mulN:(u,d)=>u*d,inv:u=>It(u,e),sqrt:r.sqrt||(u=>a(c,u)),invertBatch:u=>Lc(c,u),cmov:(u,d,f)=>f?d:u,toBytes:u=>n?Vr(u,o):we(u,o),fromBytes:u=>{if(u.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${u.length}`);return n?jt(u):J(u)}});return Object.freeze(c)}function Hc(e,t,n=!1){e=V("privateHash",e);const r=e.length,s=Mt(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?jt(e):J(e);return M(o,t-z)+z}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $c(e){const{Fp:t}=e;Vt(t);for(const u of["t","roundsFull","roundsPartial"])if(typeof e[u]!="number"||!Number.isSafeInteger(e[u]))throw new Error(`Poseidon: invalid param ${u}=${e[u]} (${typeof e[u]})`);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=u=>qr(t,u,r);if(n===3?s=u=>t.mul(t.sqrN(u),u):n===5&&(s=u=>t.mul(t.sqrN(t.sqrN(u)),u)),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 a=e.roundConstants.map(u=>{if(!Array.isArray(u)||u.length!==e.t)throw new Error(`Poseidon wrong round constants: ${u}`);return u.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(u=>{if(!Array.isArray(u)||u.length!==e.t)throw new Error(`Poseidon MDS matrix row: ${u}`);return u.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:a,mds:c})}function jc(e){const{t,Fp:n,rounds:r,sboxFn:s,reversePartialPowIdx:o}=$c(e),a=Math.floor(e.roundsFull/2),c=o?t-1:0,u=(f,h,S)=>(f=f.map((y,A)=>n.add(y,e.roundConstants[S][A])),h?f=f.map(y=>s(y)):f[c]=s(f[c]),f=e.mds.map(y=>y.reduce((A,m,w)=>n.add(A,n.mulN(m,f[w])),n.ZERO)),f),d=function(h){if(!Array.isArray(h)||h.length!==t)throw new Error(`Poseidon: wrong values (expected array of bigints with length ${t})`);h=h.map(y=>{if(typeof y!="bigint")throw new Error(`Poseidon: wrong value=${y} (${typeof y})`);return n.create(y)});let S=0;for(let y=0;y<a;y++)h=u(h,!0,S++);for(let y=0;y<e.roundsPartial;y++)h=u(h,!1,S++);for(let y=0;y<a;y++)h=u(h,!0,S++);if(S!==r)throw new Error(`Poseidon: wrong number of rounds: last round=${S}, total=${r}`);return h};return d.roundConstants=e.roundConstants,d}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Vc=BigInt(0),bt=BigInt(1);function Mc(e,t){const n=(s,o)=>{const a=o.negate();return s?a:o},r=s=>{const o=Math.ceil(t/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:n,unsafeLadder(s,o){let a=e.ZERO,c=s;for(;o>Vc;)o&bt&&(a=a.add(c)),c=c.double(),o>>=bt;return a},precomputeWindow(s,o){const{windows:a,windowSize:c}=r(o),u=[];let d=s,f=d;for(let h=0;h<a;h++){f=d,u.push(f);for(let S=1;S<c;S++)f=f.add(d),u.push(f);d=f.double()}return u},wNAF(s,o,a){const{windows:c,windowSize:u}=r(s);let d=e.ZERO,f=e.BASE;const h=BigInt(2**s-1),S=2**s,y=BigInt(s);for(let A=0;A<c;A++){const m=A*u;let w=Number(a&h);a>>=y,w>u&&(w-=S,a+=bt);const E=m,T=m+Math.abs(w)-1,I=A%2!==0,B=w<0;w===0?f=f.add(n(I,o[E])):d=d.add(n(B,o[T]))}return{p:d,f}},wNAFCached(s,o,a,c){const u=s._WINDOW_SIZE||1;let d=o.get(s);return d||(d=this.precomputeWindow(s,u),u!==1&&o.set(s,c(d))),this.wNAF(u,d,a)}}}function Gr(e){return Vt(e.Fp),Ve(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Mt(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function qc(e){const t=Gr(e);Ve(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:Gc,hexToBytes:Wc}=Rc,le={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=le;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:Gc(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=le,n=typeof e=="string"?Wc(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}=le._parseInt(n.subarray(2)),{d:a,l:c}=le._parseInt(o);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:a}},hexFromSig(e){const t=d=>Number.parseInt(d[0],16)&8?"00"+d:d,n=d=>{const f=d.toString(16);return f.length&1?`0${f}`:f},r=t(n(e.s)),s=t(n(e.r)),o=r.length/2,a=s.length/2,c=n(o),u=n(a);return`30${n(a+o+4)}02${u}${s}02${c}${r}`}},ee=BigInt(0),W=BigInt(1);BigInt(2);const Cn=BigInt(3);BigInt(4);function Kc(e){const t=qc(e),{Fp:n}=t,r=t.toBytes||((A,m,w)=>{const E=m.toAffine();return Ue(Uint8Array.from([4]),n.toBytes(E.x),n.toBytes(E.y))}),s=t.fromBytes||(A=>{const m=A.subarray(1),w=n.fromBytes(m.subarray(0,n.BYTES)),E=n.fromBytes(m.subarray(n.BYTES,2*n.BYTES));return{x:w,y:E}});function o(A){const{a:m,b:w}=t,E=n.sqr(A),T=n.mul(E,A);return n.add(n.add(T,n.mul(A,m)),w)}if(!n.eql(n.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function a(A){return typeof A=="bigint"&&ee<A&&A<t.n}function c(A){if(!a(A))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(A){const{allowedPrivateKeyLengths:m,nByteLength:w,wrapPrivateKey:E,n:T}=t;if(m&&typeof A!="bigint"){if(A instanceof Uint8Array&&(A=he(A)),typeof A!="string"||!m.includes(A.length))throw new Error("Invalid key");A=A.padStart(w*2,"0")}let I;try{I=typeof A=="bigint"?A:J(V("private key",A,w))}catch{throw new Error(`private key must be ${w} bytes, hex or bigint, not ${typeof A}`)}return E&&(I=M(I,T)),c(I),I}const d=new Map;function f(A){if(!(A instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(m,w,E){if(this.px=m,this.py=w,this.pz=E,m==null||!n.isValid(m))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(m){const{x:w,y:E}=m||{};if(!m||!n.isValid(w)||!n.isValid(E))throw new Error("invalid affine point");if(m instanceof h)throw new Error("projective point not allowed");const T=I=>n.eql(I,n.ZERO);return T(w)&&T(E)?h.ZERO:new h(w,E,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){const w=n.invertBatch(m.map(E=>E.pz));return m.map((E,T)=>E.toAffine(w[T])).map(h.fromAffine)}static fromHex(m){const w=h.fromAffine(s(V("pointHex",m)));return w.assertValidity(),w}static fromPrivateKey(m){return h.BASE.multiply(u(m))}_setWindowSize(m){this._WINDOW_SIZE=m,d.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:m,y:w}=this.toAffine();if(!n.isValid(m)||!n.isValid(w))throw new Error("bad point: x or y not FE");const E=n.sqr(w),T=o(m);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:m}=this.toAffine();if(n.isOdd)return!n.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){f(m);const{px:w,py:E,pz:T}=this,{px:I,py:B,pz:N}=m,v=n.eql(n.mul(w,N),n.mul(I,T)),x=n.eql(n.mul(E,N),n.mul(B,T));return v&&x}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:m,b:w}=t,E=n.mul(w,Cn),{px:T,py:I,pz:B}=this;let N=n.ZERO,v=n.ZERO,x=n.ZERO,C=n.mul(T,T),q=n.mul(I,I),P=n.mul(B,B),k=n.mul(T,I);return k=n.add(k,k),x=n.mul(T,B),x=n.add(x,x),N=n.mul(m,x),v=n.mul(E,P),v=n.add(N,v),N=n.sub(q,v),v=n.add(q,v),v=n.mul(N,v),N=n.mul(k,N),x=n.mul(E,x),P=n.mul(m,P),k=n.sub(C,P),k=n.mul(m,k),k=n.add(k,x),x=n.add(C,C),C=n.add(x,C),C=n.add(C,P),C=n.mul(C,k),v=n.add(v,C),P=n.mul(I,B),P=n.add(P,P),C=n.mul(P,k),N=n.sub(N,C),x=n.mul(P,q),x=n.add(x,x),x=n.add(x,x),new h(N,v,x)}add(m){f(m);const{px:w,py:E,pz:T}=this,{px:I,py:B,pz:N}=m;let v=n.ZERO,x=n.ZERO,C=n.ZERO;const q=t.a,P=n.mul(t.b,Cn);let k=n.mul(w,I),H=n.mul(E,B),$=n.mul(T,N),te=n.add(w,E),g=n.add(I,B);te=n.mul(te,g),g=n.add(k,H),te=n.sub(te,g),g=n.add(w,T);let b=n.add(I,N);return g=n.mul(g,b),b=n.add(k,$),g=n.sub(g,b),b=n.add(E,T),v=n.add(B,N),b=n.mul(b,v),v=n.add(H,$),b=n.sub(b,v),C=n.mul(q,g),v=n.mul(P,$),C=n.add(v,C),v=n.sub(H,C),C=n.add(H,C),x=n.mul(v,C),H=n.add(k,k),H=n.add(H,k),$=n.mul(q,$),g=n.mul(P,g),H=n.add(H,$),$=n.sub(k,$),$=n.mul(q,$),g=n.add(g,$),k=n.mul(H,g),x=n.add(x,k),k=n.mul(b,g),v=n.mul(te,v),v=n.sub(v,k),k=n.mul(te,H),C=n.mul(b,C),C=n.add(C,k),new h(v,x,C)}subtract(m){return this.add(m.negate())}is0(){return this.equals(h.ZERO)}wNAF(m){return y.wNAFCached(this,d,m,w=>{const E=n.invertBatch(w.map(T=>T.pz));return w.map((T,I)=>T.toAffine(E[I])).map(h.fromAffine)})}multiplyUnsafe(m){const w=h.ZERO;if(m===ee)return w;if(c(m),m===W)return this;const{endo:E}=t;if(!E)return y.unsafeLadder(this,m);let{k1neg:T,k1:I,k2neg:B,k2:N}=E.splitScalar(m),v=w,x=w,C=this;for(;I>ee||N>ee;)I&W&&(v=v.add(C)),N&W&&(x=x.add(C)),C=C.double(),I>>=W,N>>=W;return T&&(v=v.negate()),B&&(x=x.negate()),x=new h(n.mul(x.px,E.beta),x.py,x.pz),v.add(x)}multiply(m){c(m);let w=m,E,T;const{endo:I}=t;if(I){const{k1neg:B,k1:N,k2neg:v,k2:x}=I.splitScalar(w);let{p:C,f:q}=this.wNAF(N),{p:P,f:k}=this.wNAF(x);C=y.constTimeNegate(B,C),P=y.constTimeNegate(v,P),P=new h(n.mul(P.px,I.beta),P.py,P.pz),E=C.add(P),T=q.add(k)}else{const{p:B,f:N}=this.wNAF(w);E=B,T=N}return h.normalizeZ([E,T])[0]}multiplyAndAddUnsafe(m,w,E){const T=h.BASE,I=(N,v)=>v===ee||v===W||!N.equals(T)?N.multiplyUnsafe(v):N.multiply(v),B=I(this,w).add(I(m,E));return B.is0()?void 0:B}toAffine(m){const{px:w,py:E,pz:T}=this,I=this.is0();m==null&&(m=I?n.ONE:n.inv(T));const B=n.mul(w,m),N=n.mul(E,m),v=n.mul(T,m);if(I)return{x:n.ZERO,y:n.ZERO};if(!n.eql(v,n.ONE))throw new Error("invZ was invalid");return{x:B,y:N}}isTorsionFree(){const{h:m,isTorsionFree:w}=t;if(m===W)return!0;if(w)return w(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:m,clearCofactor:w}=t;return m===W?this:w?w(h,this):this.multiplyUnsafe(t.h)}toRawBytes(m=!0){return this.assertValidity(),r(h,this,m)}toHex(m=!0){return he(this.toRawBytes(m))}}h.BASE=new h(t.Gx,t.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const S=t.nBitLength,y=Mc(h,t.endo?Math.ceil(S/2):S);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:a}}function Zc(e){const t=Gr(e);return Ve(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Yc(e){const t=Zc(e),{Fp:n,n:r}=t,s=n.BYTES+1,o=2*n.BYTES+1;function a(g){return ee<g&&g<n.ORDER}function c(g){return M(g,r)}function u(g){return It(g,r)}const{ProjectivePoint:d,normPrivateKeyToScalar:f,weierstrassEquation:h,isWithinCurveOrder:S}=Kc({...t,toBytes(g,b,_){const R=b.toAffine(),O=n.toBytes(R.x),U=Ue;return _?U(Uint8Array.from([b.hasEvenY()?2:3]),O):U(Uint8Array.from([4]),O,n.toBytes(R.y))},fromBytes(g){const b=g.length,_=g[0],R=g.subarray(1);if(b===s&&(_===2||_===3)){const O=J(R);if(!a(O))throw new Error("Point is not on curve");const U=h(O);let G=n.sqrt(U);const j=(G&W)===W;return(_&1)===1!==j&&(G=n.neg(G)),{x:O,y:G}}else if(b===o&&_===4){const O=n.fromBytes(R.subarray(0,n.BYTES)),U=n.fromBytes(R.subarray(n.BYTES,2*n.BYTES));return{x:O,y:U}}else throw new Error(`Point of length ${b} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),y=g=>he(we(g,t.nByteLength));function A(g){const b=r>>W;return g>b}function m(g){return A(g)?c(-g):g}const w=(g,b,_)=>J(g.slice(b,_));class E{constructor(b,_,R){this.r=b,this.s=_,this.recovery=R,this.assertValidity()}static fromCompact(b){const _=t.nByteLength;return b=V("compactSignature",b,_*2),new E(w(b,0,_),w(b,_,2*_))}static fromDER(b){const{r:_,s:R}=le.toSig(V("DER",b));return new E(_,R)}assertValidity(){if(!S(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!S(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:_,s:R,recovery:O}=this,U=x(V("msgHash",b));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const G=O===2||O===3?_+t.n:_;if(G>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const j=O&1?"03":"02",ne=d.fromHex(j+y(G)),re=u(G),pe=c(-U*re),_e=c(R*re),se=d.BASE.multiplyAndAddUnsafe(ne,pe,_e);if(!se)throw new Error("point at infinify");return se.assertValidity(),se}hasHighS(){return A(this.s)}normalizeS(){return this.hasHighS()?new E(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return fe(this.toDERHex())}toDERHex(){return le.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return fe(this.toCompactHex())}toCompactHex(){return y(this.r)+y(this.s)}}const T={isValidPrivateKey(g){try{return f(g),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const g=t.randomBytes(n.BYTES+8),b=Hc(g,r);return we(b,t.nByteLength)},precompute(g=8,b=d.BASE){return b._setWindowSize(g),b.multiply(BigInt(3)),b}};function I(g,b=!0){return d.fromPrivateKey(g).toRawBytes(b)}function B(g){const b=g instanceof Uint8Array,_=typeof g=="string",R=(b||_)&&g.length;return b?R===s||R===o:_?R===2*s||R===2*o:g instanceof d}function N(g,b,_=!0){if(B(g))throw new Error("first arg must be private key");if(!B(b))throw new Error("second arg must be public key");return d.fromHex(b).multiply(f(g)).toRawBytes(_)}const v=t.bits2int||function(g){const b=J(g),_=g.length*8-t.nBitLength;return _>0?b>>BigInt(_):b},x=t.bits2int_modN||function(g){return c(v(g))},C=dt(t.nBitLength);function q(g){if(typeof g!="bigint")throw new Error("bigint expected");if(!(ee<=g&&g<C))throw new Error(`bigint expected < 2^${t.nBitLength}`);return we(g,t.nByteLength)}function P(g,b,_=k){if(["recovered","canonical"].some(ie=>ie in _))throw new Error("sign() legacy options not supported");const{hash:R,randomBytes:O}=t;let{lowS:U,prehash:G,extraEntropy:j}=_;U==null&&(U=!0),g=V("msgHash",g),G&&(g=V("prehashed msgHash",R(g)));const ne=x(g),re=f(b),pe=[q(re),q(ne)];if(j!=null){const ie=j===!0?O(n.BYTES):j;pe.push(V("extraEntropy",ie,n.BYTES))}const _e=Ue(...pe),se=ne;function mt(ie){const ge=v(ie);if(!S(ge))return;const sn=u(ge),ye=d.BASE.multiply(ge).toAffine(),Y=c(ye.x);if(Y===ee)return;const Se=c(sn*c(se+Y*re));if(Se===ee)return;let on=(ye.x===Y?0:2)|Number(ye.y&W),an=Se;return U&&A(Se)&&(an=m(Se),on^=1),new E(Y,an,on)}return{seed:_e,k2sig:mt}}const k={lowS:t.lowS,prehash:!1},H={lowS:t.lowS,prehash:!1};function $(g,b,_=k){const{seed:R,k2sig:O}=P(g,b,_);return Mr(t.hash.outputLen,t.nByteLength,t.hmac)(R,O)}d.BASE._setWindowSize(8);function te(g,b,_,R=H){var ye;const O=g;if(b=V("msgHash",b),_=V("publicKey",_),"strict"in R)throw new Error("options.strict was renamed to lowS");const{lowS:U,prehash:G}=R;let j,ne;try{if(typeof O=="string"||O instanceof Uint8Array)try{j=E.fromDER(O)}catch(Y){if(!(Y instanceof le.Err))throw Y;j=E.fromCompact(O)}else if(typeof O=="object"&&typeof O.r=="bigint"&&typeof O.s=="bigint"){const{r:Y,s:Se}=O;j=new E(Y,Se)}else throw new Error("PARSE");ne=d.fromHex(_)}catch(Y){if(Y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(U&&j.hasHighS())return!1;G&&(b=t.hash(b));const{r:re,s:pe}=j,_e=x(b),se=u(pe),mt=c(_e*se),ie=c(re*se),ge=(ye=d.BASE.multiplyAndAddUnsafe(ne,mt,ie))==null?void 0:ye.toAffine();return ge?c(ge.x)===re:!1}return{CURVE:t,getPublicKey:I,getSharedSecret:N,sign:$,verify:te,ProjectivePoint:d,Signature:E,utils:T}}function xt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Jc(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function Wr(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 Xc(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");xt(e.outputLen),xt(e.blockLen)}function Qc(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 el(e,t){Wr(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Ze={number:xt,bool:Jc,bytes:Wr,hash:Xc,exists:Qc,output:el},Et=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const tl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!tl)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function nl(e){if(typeof e!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function rl(e){if(typeof e=="string"&&(e=nl(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}function sl(...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 ol{clone(){return this._cloneInto()}}function al(e=32){if(Et&&typeof Et.getRandomValues=="function")return Et.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}class Kr extends ol{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,Ze.hash(t);const r=rl(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 a=0;a<o.length;a++)o[a]^=54;this.iHash.update(o),this.oHash=t.create();for(let a=0;a<o.length;a++)o[a]^=106;this.oHash.update(o),o.fill(0)}update(t){return Ze.exists(this),this.iHash.update(t),this}digestInto(t){Ze.exists(this),Ze.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:a,outputLen:c}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=a,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 Zr=(e,t,n)=>new Kr(e,t).update(n).digest();Zr.create=(e,t)=>new Kr(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function il(e){return{hash:e,hmac:(t,...n)=>Zr(e,t,sl(...n)),randomBytes:al}}const Nn=BigInt("3618502788666131213697322783095070105526743751716087489154079457884512865583"),Yr=252;function Bn(e){for(;e[0]===0;)e=e.subarray(1);const t=e.length*8-Yr,n=J(e);return t>0?n>>BigInt(t):n}function Jr(e){return typeof e=="string"&&(e=ul(e),e.length&1&&(e="0"+e)),fe(e)}const Xr=Yc({a:BigInt(1),b:BigInt("3141592653589793238462643383279502884197169399375105820974944592307816406665"),Fp:qt(BigInt("0x800000000000011000000000000000000000000000000000000000000000001")),n:Nn,nBitLength:Yr,Gx:BigInt("874739451078007766457464989774322083649278607533249481151382481072868806602"),Gy:BigInt("152666792071518830868575557812948353041420400780739481342941381225525861407"),h:BigInt(1),lowS:!1,...il(Hr),bits2int:Bn,bits2int_modN:e=>{const t=J(e).toString(16);return t.length===63&&(e=Jr(t+"0")),M(Bn(e),Nn)}});function cl(e){return V("",typeof e=="string"?Jr(e):e)}const{CURVE:Ku,ProjectivePoint:ke,Signature:Zu,utils:Yu}=Xr;function ll(e){return`0x${he(e.subarray(1)).replace(/^0+/gm,"")}`}function ul(e){return e.replace(/^0x/i,"")}const Le=[new ke(2089986280348253421170679821480865132823066470938446095505822317253594081284n,1713931329540660377023406109199410414810705867260802078187082345529207694986n,1n),new ke(996781205833008774514500082376783249102396023663454813447423147977397232763n,1668503676786377725805489344771023921079126552019160156920634619255970485781n,1n),new ke(2251563274489750535117886426533222435294046428347329203627021249169616184184n,1798716007562728905295480679789526322175868328062420237419143593021674992973n,1n),new ke(2138414695194151160943305727036575959195309218611738193261179310511854807447n,113410276730064486255102093846540133784865286929052426931474106396135072156n,1n),new ke(2379962749567351885752724891227938183011949129833673362440656643086021394946n,776496453633298175483985398648758586525933812536653089401905292063708816422n,1n)];function Qr(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 dl=Qr(Le[1],Le[2]),hl=Qr(Le[3],Le[4]);function fl(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=J(cl(e));if(!(0n<=t&&t<Xr.CURVE.Fp.ORDER))throw new Error(`PedersenArg should be 0 <= value < CURVE.P: ${t}`);return t}function kn(e,t,n){let r=fl(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 On(e,t){let n=Le[0];return n=kn(n,e,dl),n=kn(n,t,hl),ll(n.toRawBytes(!0))}const ml=dt(250),Rn=e=>J(yc(e))&ml;qt(BigInt("14474011154664525231415395255581126252639794253786371766033694892385558855681"));const pl=qt(BigInt("3618502788666131213697322783095070105623107215331596699973092056135872020481"));function gl(e,t,n){const r=e.fromBytes(Hr(Pr(`${t}${n}`)));return e.create(r)}const yl=[[3,1,1],[1,-1,1],[1,1,-2]].map(e=>e.map(BigInt));function Sl(e,t){if(Vt(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 a=0;a<r;a++){const c=[];for(let u=0;u<n;u++)c.push(gl(e.Fp,"Hades",n*a+u));s.push(c)}const o=jc({...e,t:n,sboxPower:3,reversePartialPowIdx:!0,mds:t,roundConstants:s});return o.m=n,o.rate=e.rate,o.capacity=e.capacity,o}Sl({Fp:pl,rate:2,capacity:1,roundsFull:8,roundsPartial:83},yl);const es=i.z.object({recoveryId:i.z.number()}),wl=i.z.object({feeToken:l.addressSchema,signerSignature:i.z.object({type:i.z.literal("StarknetKey"),signer:i.z.object({publicKey:l.hexSchema,r:l.hexSchema,s:l.hexSchema})})}),ts=i.z.enum(["ONGOING","COMPLETED","ERROR","CANCELLED","AWAITING_FUNDS"]),bl=i.z.object({status:ts});class El{constructor(t,n){this.apiBase=t,this.httpService=n}async startRecovery(t,n,r,s){const{r:o,s:a}=p.ec.starkCurve.sign(On(Rn(Ee.stringToBytes("utf8","starknet:recovery")),r),s),c={feeToken:n,signerSignature:{type:"StarknetKey",signer:{publicKey:r,r:p.encode.addHexPrefix(o.toString(16)),s:p.encode.addHexPrefix(a.toString(16))}}};return await this.httpService.post(`${this.apiBase}/accounts/starknet/${t}/recovery`,{body:JSON.stringify(c)},es)}async getRecovery(t,n){return(await this.httpService.get(`${this.apiBase}/accounts/starknet/${t}/recovery/${n}`)).status}async cancelRecovery(t,n,r,s){const{r:o,s:a}=p.ec.starkCurve.sign(On(Rn(Ee.stringToBytes("utf8","starknet:cancel")),r),s),c={feeToken:n,signerSignature:{type:"StarknetKey",signer:{publicKey:r,r:p.encode.addHexPrefix(o.toString(16)),s:p.encode.addHexPrefix(a.toString(16))}}};await this.httpService.post(`${this.apiBase}/accounts/starknet/${t}/recovery/cancel`,{body:JSON.stringify(c)})}}async function Al(){if("brave"in navigator)try{return await navigator.brave.isBrave()}catch{}return!1}let At;function ns(){return At||(At=new $s.UAParser(navigator.userAgent).getResult()),At}function Me(e){return ns().browser.name===e}function Tl(){return Me("Firefox")}function vl(){return Me("Chrome")}function Il(){return Me("Safari")}function xl(){return Me("Edge")}const _l=i.z.string().refine(e=>js.validateMnemonic(e,Vs.wordlist),"Invalid seedphrase"),Gt=[{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"}],rs=async(e,t,n)=>{const r=await n.callContract({contractAddress:e,entrypoint:"balanceOf",calldata:[t]});return BigInt(p.num.toHex(p.uint256.uint256ToBN({low:r[0],high:r[1]})))},Cl=async(e,t,n)=>{const r=Gt.filter(o=>o.networkId===e);return(await Promise.allSettled(r.map(o=>t.callContract({contractAddress:o.address,entrypoint:"balanceOf",calldata:[n]})))).reduce((o,a,c)=>{if(a.status==="fulfilled"&&F.isUndefined(a.value)||a.status==="rejected"||a.value[0]==="0x0"&&a.value[1]==="0x0")return o;const u=BigInt(p.num.toHex(p.uint256.uint256ToBN({low:a.value[0],high:a.value[1]}))),d={...r[c],balance:u};return o.push(d),o},[])},Nl=async()=>Gt,Bl=({address:e,networkId:t})=>Gt.find(r=>r.address===e&&r.networkId===t),kl=({amount:e,decimals:t,unitCurrencyValue:n})=>{if(!K(e)||!K(t)||!K(n))return;const r=Number(t),s=BigInt(e)*Rt(n.toString()).value;return $e({value:s,decimals:r+Te})},Ol=({unitAmount:e,decimals:t})=>{if(e===void 0||!K(e)||t===void 0||!K(t))return;const n=Number(t);return me(e.toString(),n).value.toString()},Rl=e=>K(e)?Number(e):18,{UINT_256_MAX:Pl}=p.uint256,ss=e=>String(e)===String(Pl),zl=(e,t="$",n)=>{if(e===void 0||!K(e))return null;const r=Cr(e,n);return[t,r].filter(Boolean).join("")},os="Unlimited",Fl=({amount:e,decimals:t,symbol:n,showPlusSign:r=!1,withSymbol:s=!0,unlimitedText:o=os,prettyConfigOverrides:a})=>{if(!K(e))return null;let c,u=!1;if(ss(e))c=o;else{const f=Number(t),h=BigInt(e);u=h>0n;const S=f>0?$e({value:h,decimals:f}):h.toString();c=f>0?Nr(S,a):S}const d=[c,s&&n].filter(Boolean).join(" ");return r&&u?`+${d}`:d};var as={};function Z(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.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 Dl=Z;Z.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};Z.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};Z.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0};Z.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Z.prototype.try=function(e){this.attempt(e)};Z.prototype.start=function(e){this.attempt(e)};Z.prototype.start=Z.prototype.try;Z.prototype.errors=function(){return this._errors};Z.prototype.attempts=function(){return this._attempts};Z.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var s=this._errors[r],o=s.message,a=(e[o]||0)+1;e[o]=a,a>=n&&(t=s,n=a)}return t};(function(e){var t=Dl;e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(n){if(n instanceof Array)return[].concat(n);var r={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var s in n)r[s]=n[s];if(r.minTimeout>r.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],a=0;a<r.retries;a++)o.push(this.createTimeout(a,r));return n&&n.forever&&!o.length&&o.push(this.createTimeout(a,r)),o.sort(function(c,u){return c-u}),o},e.createTimeout=function(n,r){var s=r.randomize?Math.random()+1:1,o=Math.round(s*Math.max(r.minTimeout,1)*Math.pow(r.factor,n));return o=Math.min(o,r.maxTimeout),o},e.wrap=function(n,r,s){if(r instanceof Array&&(s=r,r=null),!s){s=[];for(var o in n)typeof n[o]=="function"&&s.push(o)}for(var a=0;a<s.length;a++){var c=s[a],u=n[c];n[c]=(function(f){var h=e.operation(r),S=Array.prototype.slice.call(arguments,1),y=S.pop();S.push(function(A){h.retry(A)||(A&&(arguments[0]=h.mainError()),y.apply(this,arguments))}),h.attempt(function(){f.apply(n,S)})}).bind(n,u),n[c].options=r}}})(as);var Ul=as,Ll=Ul;function Hl(e,t){function n(r,s){var o=t||{},a;"randomize"in o||(o.randomize=!0),a=Ll.operation(o);function c(f){s(f||new Error("Aborted"))}function u(f,h){if(f.bail){c(f);return}a.retry(f)?o.onRetry&&o.onRetry(f,h):s(a.mainError())}function d(f){var h;try{h=e(c,f)}catch(S){u(S,f);return}Promise.resolve(h).then(r).catch(function(y){u(y,f)})}a.attempt(d)}return new Promise(n)}var $l=Hl;const jl=l.getDefaultExportFromCjs($l);exports.TOKEN_ERROR_MESSAGES=void 0;(function(e){e.NO_TOKEN_API_URL="NO_TOKEN_API_URL is not defined",e.NO_TOKEN_PRICE_API_URL="NO_TOKEN_PRICE_API_URL is not defined",e.TOKENS_DEFI_DECOMPOSITION_URL="TOKENS_DEFI_DECOMPOSITION_URL is not defined",e.TOKENS_AIRDROPS_API_URL="TOKENS_AIRDROPS_API_URL is not defined",e.TOKEN_PARSING_ERROR="Unable to parse token data response",e.TOKEN_PRICE_PARSING_ERROR="Unable to parse token price response",e.TOKEN_DEFI_DECOMPOSITION_PARSING_ERROR="Unable to parse token defi decomposition response",e.TOKEN_PRICE_NOT_FOUND="Token price not found",e.TOKEN_NOT_FOUND="Token not found",e.TOKEN_DETAILS_NOT_FOUND="Token details not found",e.FEE_TOKEN_NOT_FOUND="Fee token not found",e.UNABLE_TO_CALCULATE_CURRENCY_VALUE="Unable to calculate currency value",e.UNSAFE_DECIMALS="Unsafe decimals in token"})(exports.TOKEN_ERROR_MESSAGES||(exports.TOKEN_ERROR_MESSAGES={}));class is extends l.BaseError{constructor(t){super(t,exports.TOKEN_ERROR_MESSAGES),this.name="TokenError"}}const Wt=i.z.union([i.z.literal("concentratedLiquidityPosition"),i.z.literal("collateralizedDebtPosition")]),cs=i.z.object({status:i.z.literal("initialising")}).or(i.z.object({status:i.z.literal("initialised"),balances:i.z.array(i.z.object({tokenAddress:l.addressSchemaArgentBackend,tokenBalance:i.z.string()}))})),xe=i.z.object({id:i.z.number(),address:l.addressSchema,brandColor:i.z.string().optional(),name:i.z.string(),symbol:i.z.string(),decimals:i.z.number(),iconUrl:i.z.string().optional(),sendable:i.z.boolean(),popular:i.z.boolean(),refundable:i.z.boolean(),listed:i.z.boolean(),tradable:i.z.boolean(),category:i.z.union([i.z.literal("tokens"),i.z.literal("currencies"),i.z.literal("savings")]),pricingId:i.z.number().optional(),dappId:i.z.string().optional(),marketData:i.z.object({marketCap:i.z.number(),marketCap24hChange:i.z.number(),dailyVolume:i.z.number(),rank:i.z.number()}).optional(),tags:i.z.array(i.z.string()).optional()}),ls=i.z.object({tokens:i.z.array(xe)}),us=xe,Kt=i.z.object({pricingId:i.z.number(),ethValue:i.z.string(),ccyValue:i.z.string(),ethDayChange:i.z.string(),ccyDayChange:i.z.string()}),Vl=i.z.object({prices:i.z.array(Kt)}),_t=i.z.object({tokenAddress:l.addressSchemaArgentBackend,principal:i.z.string(),accruedFees:i.z.string(),minPrice:i.z.string(),maxPrice:i.z.string(),currentPrice:i.z.string()}),ds=i.z.object({tokenAddress:l.addressSchema.optional(),totalBalances:i.z.record(i.z.string())}),Zt=ds.extend({tokenId:i.z.string(),data:i.z.object({poolFeePercentage:i.z.string(),tickSpacingPercentage:i.z.string().optional(),token0:_t,token1:_t})}),Ml=i.z.array(Zt),Yt=ds.extend({data:i.z.object({apy:i.z.string().optional(),group:i.z.number().optional(),collateral:i.z.boolean(),debt:i.z.boolean(),lending:i.z.boolean()})}),ql=i.z.array(Yt),hs=i.z.array(Zt.or(Yt)),fs=i.z.object({name:i.z.string(),manageUrl:i.z.string(),type:Wt,groups:i.z.record(i.z.object({name:i.z.string().optional(),healthRatio:i.z.string().optional()})).optional(),positions:hs}),ms=i.z.object({dappId:i.z.string(),products:i.z.array(fs)}),ps=i.z.object({dapps:i.z.array(ms)}),gs=i.z.object({name:i.z.string().optional(),tokenAddress:l.addressSchema,amount:i.z.string().optional(),claimUrl:i.z.string().optional(),claimStart:i.z.number(),claimEnd:i.z.number().optional()}),Gl=i.z.object({accountAddress:l.addressSchema,chain:i.z.string(),airdrops:i.z.array(gs)});class Wl{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=l.urlJoin(this.apiBase,this.TOKENS_INFO_URL,t??"","?chain=starknet"),r=await this.httpService.get(n),s=ls.safeParse(r);if(s.success)return s.data.tokens;const o=us.safeParse(r);if(o.success)return[o.data]}async fetchAddressTokenBalancesFromBackend(t,n,r){const s=l.urlJoin(this.apiBase,"activity","starknet",n,"account",t,"balance");return(await jl(async c=>{let u;try{u=await this.httpService.get(s)}catch{return c(new Error("Error fetching")),[]}const d=cs.safeParse(u);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=l.urlJoin(this.apiBase,this.TOKENS_DEFI_DECOMPOSITION_URL,t,"?chain=starknet"),r=await this.httpService.get(n);if(!ps.safeParse(r).success)throw new is({code:"TOKEN_DEFI_DECOMPOSITION_PARSING_ERROR"});return r.dapps}}const ht=i.z.object({address:l.addressSchema,networkId:i.z.string({required_error:"Network is required"})},{required_error:"BaseToken is required"});ht.required().extend({balance:i.z.string()});const ys=ht.required().extend({id:i.z.number().optional(),name:i.z.string().optional(),symbol:i.z.string().optional(),decimals:i.z.coerce.number().optional(),iconUrl:i.z.string().url("").optional().or(i.z.literal("")),pricingId:i.z.number().optional(),category:i.z.string().optional(),dappId:i.z.string().optional(),brandColor:i.z.string().optional()}),Kl=ys.extend({balance:i.z.string()}),Zl=ys.extend({currencyValue:i.z.string(),ccyDayChange:i.z.string().optional(),ethDayChange:i.z.string().optional(),unitCurrencyValue:i.z.string().optional()}),Jt=Zl.extend({...Kl.shape});i.z.array(Jt);ht.extend({...Kt.shape});ht.extend({...xe.shape});const Pn=Jt.extend({accruedFees:i.z.string(),currentPrice:i.z.string(),maxPrice:i.z.string(),minPrice:i.z.string(),principal:i.z.string()}),Ss=i.z.object({address:l.addressSchema.optional(),currencyValue:i.z.string().default("0")}),Xt=Ss.extend({poolFeePercentage:i.z.string(),tickSpacingPercentage:i.z.string().optional(),tokenId:i.z.string().optional(),unitCurrencyValueToken0:i.z.string().optional(),unitCurrencyValueToken1:i.z.string().optional(),token0:Pn,token1:Pn}),Yl=i.z.array(Xt),Jl=i.z.object({name:i.z.string().optional(),healthRatio:i.z.string().optional(),accountAddress:l.addressSchema.optional()}),Qt=Ss.extend({totalBalances:i.z.record(i.z.string()),collateral:i.z.boolean(),debt:i.z.boolean(),lending:i.z.boolean(),apy:i.z.string().optional(),group:i.z.string().optional(),unitCurrencyValue:i.z.string().optional(),positionToken:xe.or(i.z.undefined()),token:Jt.optional(),accountAddress:l.addressSchema.optional(),accountAddressGroup:i.z.string().optional()}),Xl=i.z.array(Qt),ws=Xt.or(Qt),bs=i.z.record(i.z.object({name:i.z.string().optional(),healthRatio:i.z.string().optional(),accountAddress:l.addressSchema.optional()})),Es=i.z.object({type:Wt,manageUrl:i.z.string().url().optional(),name:i.z.string(),positions:i.z.array(ws),positionsTotalValue:i.z.string(),brandColor:i.z.string().optional(),groups:bs.optional(),accountAddress:l.addressSchema}),As=i.z.array(Es),Ql=i.z.object({dappId:i.z.string(),products:As}),Ts=i.z.object({name:i.z.string().optional(),tokenAddress:l.addressSchema,token:xe.optional(),amount:i.z.string().optional(),claimUrl:i.z.string().optional(),claimStart:i.z.number(),claimEnd:i.z.number().optional()}),eu=i.z.array(Ts),vs=(e,t=18)=>me(e.replace(",","."),Number(t)),Is=i.z.string().trim().refine(e=>e!=="",{message:"Amount is required"}).refine(e=>{try{const t=vs(e).value;if(t<0n)throw new Error("Amount must be positive");if(t===0n)throw new Error("Amount can not be zero");if(t>p.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"}),tu=e=>!!Is.parse(e),nu=(e,t,n,r)=>({contractAddress:e,entrypoint:"transfer",calldata:p.CallData.compile({recipient:t,amount:Ae(Br(n,r))})}),ru=(e,t,n,r)=>({contractAddress:e,entrypoint:"transferFrom",calldata:p.CallData.compile({from_:t,to:n,tokenId:Ae(r)})}),su=(e,t,n,r)=>({contractAddress:e,entrypoint:"safeTransferFrom",calldata:p.CallData.compile({from_:t,to:n,tokenId:Ae(r),amount:Ae(1),data_len:"0"})}),xs=i.z.object({data:i.z.object({code:i.z.string().optional(),name:i.z.string().optional(),message:i.z.string()})}),ou=e=>{const t=xs.safeParse(e);if(t.success)return t.data.data.message},au=3,en=process.env.FEE_OVERHEAD?parseFloat(process.env.FEE_OVERHEAD):au,iu=1.5,et=10,tn=({estimatedFee:e,overheadMultiplier:t=en})=>{const r=p.num.toBigInt(e)*BigInt(t*et)/BigInt(et);return p.num.toHex(r)},cu=({suggestedMaxFee:e,overheadMultiplier:t=en,starknetJsOverheadMultiplier:n=iu})=>{const s=p.num.toBigInt(e)*BigInt(et)/BigInt(n*et);return tn({estimatedFee:s,overheadMultiplier:t})};exports.ESTIMATE_ERROR_MESSAGES=void 0;(function(e){e.SIMULATE_AND_REVIEW_FAILED="Missing simulation"})(exports.ESTIMATE_ERROR_MESSAGES||(exports.ESTIMATE_ERROR_MESSAGES={}));class _s extends l.BaseError{constructor(t){super(t,exports.ESTIMATE_ERROR_MESSAGES),this.name="EstimateError"}}const lu=i.z.object({type:i.z.enum(["DECLARE","DEPLOY","DEPLOY_ACCOUNT","INVOKE"]).default("INVOKE"),calls:i.z.array(l.callSchema).or(l.callSchema).optional(),calldata:i.z.array(i.z.string()).optional(),classHash:l.hexSchema.optional(),salt:l.hexSchema.optional(),signature:i.z.array(i.z.string()).optional()});function nn(e){return F.upperCase(e.unit)==="WEI"}function Cs(e){return F.upperCase(e.unit)==="FRI"}function ue(e,t){return nn(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 be(e){return nn(e)?{maxFee:e.maxFee}:{amount:e.maxAmount,pricePerUnit:e.maxPricePerUnit}}function Ye(e){return Cs({unit:e})?l.STRK_TOKEN_ADDRESS:l.ETH_TOKEN_ADDRESS}function uu(e,t,n=2){const r=BigInt(10**n),s=BigInt(Math.round(t*10**n));return e*s/r}const du=[l.STRK_TOKEN_ADDRESS],Ns=(e,t=Ps)=>{if(e.max&&"amount"in e.max)return{...e,...e.max};const n=10000n,{amount:r,pricePerUnit:s,dataGasConsumed:o=0n,dataGasPrice:a=0n}=e,c=r*s+o*a;if(c<0)throw Error("Cannot calculate max fee for negative fee");const u=p.num.toBigInt(tn({estimatedFee:c})),d=Number(u)/Number(c),f=t(d),h=BigInt(Math.trunc(f*Number(n)));return{...e,amount:r*h/n,pricePerUnit:s*h/n,dataGasConsumed:o*h/n,dataGasPrice:a*h/n}},He=e=>{const{amount:t,pricePerUnit:n,dataGasConsumed:r=0n,dataGasPrice:s=0n}=e;return t*n+r*s},Bs=e=>{if(e.max)return"maxFee"in e.max?e.max.maxFee:He(e.max)},tt=e=>{const t=Bs(e);return t||He(Ns(e))},hu=e=>{if(e.deployment&&!l.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=He(e.transactions),n=e.deployment?He(e.deployment):0n;return t+n},fu=e=>{if(e.deployment&&!l.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=e.deployment?tt(e.deployment):0n,n=tt(e.transactions);return t+n},mu=(e,t)=>[{contractAddress:e,entrypoint:"transfer",calldata:p.CallData.compile(l.transferCalldataSchema.parse({recipient:t,amount:p.uint256.bnToUint256(BigInt(1))}))}],ks=(e,t)=>{if(!e)return{transactions:{feeTokenAddress:t??l.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=l.feeEstimationSchema.parse(e[0].feeEstimation);return{transactions:{feeTokenAddress:Ye(n.unit),amount:p.num.toBigInt(n.gasUsage),pricePerUnit:p.num.toBigInt(n.gasPrice),max:be(ue(n,p.num.toBigInt)),dataGasConsumed:n.dataGasConsumed?p.num.toBigInt(n.dataGasConsumed):0n,dataGasPrice:n.dataGasPrice?p.num.toBigInt(n.dataGasPrice):0n}}}if(e.length===2){const n=l.feeEstimationSchema.parse(e[0].feeEstimation),r=l.feeEstimationSchema.parse(e[1].feeEstimation);return{deployment:{feeTokenAddress:Ye(n.unit),amount:p.num.toBigInt(n.gasUsage),pricePerUnit:p.num.toBigInt(n.gasPrice),max:be(ue(n,p.num.toBigInt)),dataGasConsumed:n.dataGasConsumed?p.num.toBigInt(n.dataGasConsumed):0n,dataGasPrice:n.dataGasPrice?p.num.toBigInt(n.dataGasPrice):0n},transactions:{feeTokenAddress:Ye(r.unit),amount:p.num.toBigInt(r.gasUsage),pricePerUnit:p.num.toBigInt(r.gasPrice),max:be(ue(r,p.num.toBigInt)),dataGasConsumed:r.dataGasConsumed?p.num.toBigInt(r.dataGasConsumed):0n,dataGasPrice:r.dataGasPrice?p.num.toBigInt(r.dataGasPrice):0n}}}throw Error("Unexpected simulation response length")},Os=({transaction:e,nonce:t,chainId:n,version:r,isDeploymentTransaction:s,cairoVersion:o,address:a,appDomain:c})=>{let u=t;s&&e.type!=="DEPLOY_ACCOUNT"&&(u=p.num.toHex(1));const d=l.ensureArray(e.calls);return{type:e.type,chainId:n,cairoVersion:o,nonce:u,version:r,account:a,calls:d,calldata:e.calldata,salt:e.salt,signature:e.signature,classHash:e.classHash,appDomain:c}},Rs=(e,t)=>{const{transactions:n}=e,r=n.map(u=>{if(!u.simulation)throw new _s({code:"SIMULATE_AND_REVIEW_FAILED"});return u}),s=r.map(u=>({...u.simulation,feeEstimation:ue(u.simulation.feeEstimation,Number)})),o=ks(s,t),[a,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:be(ue(a.simulation.feeEstimation,p.num.toBigInt))},deployment:o.deployment&&c?{...o.deployment,dataGasConsumed:o.deployment.dataGasConsumed??0n,dataGasPrice:o.deployment.dataGasPrice??0n,max:be(ue(c.simulation.feeEstimation,p.num.toBigInt))}:void 0}},pu=e=>{const t=Ns(e),n=tt(e);return{maxFee:n,resourceBounds:{l1_gas:{max_amount:p.num.toHex(n/e.pricePerUnit),max_price_per_unit:p.num.toHex(t.pricePerUnit)},l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"}}}},gu=e=>{const t=Math.sqrt(e);return isNaN(t)?Math.sqrt(2):t},Ps=e=>{const t=Math.cbrt(e);return isNaN(t)?Math.cbrt(2):t},yu=e=>e<1||isNaN(e)?1.1:Math.log(e+1)+1,Ct={Transfer:p.hash.getSelectorFromName("Transfer"),Approval:p.hash.getSelectorFromName("Approval")},zs=(e,t,n)=>{for(const r of e){const{events:s,internal_calls:o}=r;for(const a of s)for(const c of a.keys)c===Ct.Approval&&t.push({tokenAddress:l.addressSchema.parse(r.contract_address),owner:a.data[0],spender:a.data[1],value:p.uint256.uint256ToBN({low:a.data[2],high:a.data[3]}).toString()}),c===Ct.Transfer&&n.push({tokenAddress:l.addressSchema.parse(r.contract_address),from:a.data[0],to:a.data[1],value:p.uint256.uint256ToBN({low:a.data[2],high:a.data[3]}).toString()});o&&zs(o,t,n)}return{approvals:t,transfers:n}},Su=/(0x[a-fA-F0-9]+)\s*\('(.*?)'\)/,wu=e=>{if(!F.isString(e))return;const t=e.match(Su);if(t&&!F.isEmpty(t[2]))return t[2]},bu=[l.STRK_TOKEN_ADDRESS];function ft({address:e}){return bu.some(t=>l.isEqualAddress(e,t))}function Eu(e){return e?tr().some(t=>l.isEqualAddress(t,e)):!1}function Nt(e){return ft({address:e})?p.constants.TRANSACTION_VERSION.V3:p.constants.TRANSACTION_VERSION.V1}function Au(e){return ft({address:e})?p.constants.TRANSACTION_VERSION.F3:p.constants.TRANSACTION_VERSION.F1}function Tu(e,t){return p.isSierra(t.contract)?ft({address:e})?p.constants.TRANSACTION_VERSION.V3:p.constants.TRANSACTION_VERSION.V2:p.constants.TRANSACTION_VERSION.V1}var Bt;(function(e){e.SIMULATE_AND_REVIEW_FAILED="Something went wrong fetching review",e.NO_CALLS_FOUND="No calls found",e.ONCHAIN_FEE_ESTIMATION_FAILED="Failed to estimate fees onchain"})(Bt||(Bt={}));class Oe extends l.BaseError{constructor(t){super(t,Bt),this.name="ReviewError"}}class vu{constructor(t,n){this.apiBase=t,this.httpService=n}async getLabels(){const t=l.urlJoin(this.apiBase,"reviewer","labels");return await this.httpService.get(t)}async getWarnings(){const t=l.urlJoin(this.apiBase,"reviewer","warnings/reasons");return await this.httpService.get(t)}async simulateAndReview(t,n,r,s,o){const a=n.some(c=>c.type==="DEPLOY_ACCOUNT");try{if(!("getChainId"in t))throw new Error("MISSING_METHOD");const c=Nt(r),u=a?"0x0":await t.getNonce(),d=await t.getChainId(),f={transactions:n.map(m=>({...Os({transaction:m,nonce:u,version:c,chainId:d,isDeploymentTransaction:a,appDomain:s,cairoVersion:t.cairoVersion,address:t.address}),type:m.type}))},h=l.urlJoin(this.apiBase,"reviewer","transactions","v2","review","starknet"),S=await this.httpService.post(h,{headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(f)},l.simulateAndReviewSchema);if(S.transactions.some(m=>l.isTransactionSimulationError(m)))return S;const A=Rs(S,r);return{...S,enrichedFeeEstimation:A}}catch(c){return console.error(c),this.fallbackToOnchainFeeEstimation({transactions:n,account:t,isDeploymentTransaction:a,feeTokenAddress:r,accountDeployTransaction:o})}}getCallsFromTx(t){let n;return t.calls&&(n=l.ensureArray(t.calls)),n}async fallbackToOnchainFeeEstimation({transactions:t,account:n,isDeploymentTransaction:r,feeTokenAddress:s,accountDeployTransaction:o}){try{const a=r?this.getCallsFromTx(t[1]):this.getCallsFromTx(t[0]);if(!a)throw new Oe({code:"NO_CALLS_FOUND"});const c=await this.fetchFeesOnchain({starknetAccount:n,calls:a,isDeployed:!r,feeTokenAddress:s,accountDeployTransaction:o});return{transactions:[],enrichedFeeEstimation:c,isBackendDown:!0}}catch(a){throw console.error(a),new Oe({message:`${a}`,code:"SIMULATE_AND_REVIEW_FAILED"})}}async fetchFeesOnchain({starknetAccount:t,calls:n,isDeployed:r,feeTokenAddress:s,accountDeployTransaction:o}){try{const a=Nt(s),c={transactions:{feeTokenAddress:s,amount:0n,pricePerUnit:0n,dataGasConsumed:0n,dataGasPrice:0n}};if(!r&&o){if("estimateFeeBulk"in t){const u=[{type:p.TransactionType.DEPLOY_ACCOUNT,payload:{classHash:o.classHash,addressSalt:o.salt,constructorCalldata:o.calldata,contractAddress:t.address}},{type:p.TransactionType.INVOKE,payload:n}],[d,f]=await t.estimateFeeBulk(u,{version:a}).catch(h=>{throw console.error(h),h});if(!d.gas_consumed||!d.gas_price||!f.gas_consumed||!f.gas_price)throw new Oe({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:f.gas_consumed,pricePerUnit:f.gas_price,dataGasConsumed:f.data_gas_consumed,dataGasPrice:f.data_gas_price}}}else{const{gas_consumed:u,gas_price:d,data_gas_consumed:f,data_gas_price:h}=await t.estimateFee(n,{skipValidate:!0,version:a});if(!u||!d)throw new Oe({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:"Missing gas_consumed or gas_price"});c.transactions={feeTokenAddress:s,amount:u,pricePerUnit:d,dataGasConsumed:f,dataGasPrice:h}}return c}catch(a){throw new Oe({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:`${a}`})}}}const Iu=i.z.object({reason:i.z.string(),severity:i.z.string().optional(),title:i.z.string(),description:i.z.string().optional()}),xu=["account-upgrade","approve","set-approval-for-all","swap","transfer"],_u=Object.values(p.constants.TRANSACTION_VERSION),Cu=i.z.string().default("0x3").refine(e=>{const t=p.num.toBigInt(e);return _u.map(n=>p.num.toBigInt(n)).includes(t)}).transform(e=>p.num.toHex(e));function Nu(e){if(e===p.constants.TRANSACTION_VERSION.V3||e===p.constants.TRANSACTION_VERSION.F3)throw Error("Only txv1 is supported")}const Bu=e=>({showBalanceChange:L.useMemo(()=>{const n=e==null?void 0:e.some(s=>!F.isEmpty(s.transfers)),r=e==null?void 0:e.some(s=>!F.isEmpty(s.approvals));return e&&(n||r)},[e])}),qe=e=>e?e.filter(t=>t.token.type==="erc20"):[],ku=e=>L.useMemo(()=>qe(e),[e]),Ou=e=>qe(e).length>0,Ru=e=>qe(e).some(n=>n.amount>0n),Pu=e=>qe(e).some(n=>n.amount<0n),rn=e=>e?e.filter(t=>t.token.type==="erc721"):[],zu=e=>L.useMemo(()=>rn(e),[e]),Fs=e=>rn(e).length>0,Fu=e=>L.useMemo(()=>Fs(e),[e]),Du=(e,t)=>L.useMemo(()=>e&&t?[{contractAddress:e.address,entrypoint:"transfer",calldata:p.CallData.compile({recipient:t,amount:Ae(e.balance)})}]:[],[e,t]),Uu=({apiData:{apiBaseUrl:e,apiHeaders:t},address:n,network:r,transactionReviewEnabled:s=!0,transactions:o})=>{const a=L.useCallback(async()=>{if(!n||!r)return;if(!e)throw"Transaction review endpoint is not defined";const u=l.urlJoin(e,"reviewer/transactions/review/starknet"),d=F.isArray(o)?o:[o],f={network:r,account:n,calls:d};return Pt(u,{method:"POST",headers:{"Content-Type":"application/json",...t},body:JSON.stringify(f)})},[n,r,o]),c=L.useMemo(()=>Ms({transactions:o,address:n,network:r}),[o,n,r]);return jn(!!s,[c,"transactionReview"],a)},Lu=e=>{if(!e)return{};const t=e.assessment==="warn"&&e.reason!=="contract_is_not_verified",n=e.reason?` (Reason: ${F.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}},Ds=e=>{var t;if(e){for(const n of e.reviews)if(((t=n.activity)==null?void 0:t.type)==="swap")return n}},Hu=e=>{},$u=(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}},ju=e=>!!Ds(e),Vu=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}}},Us=async({feeTokenAddress:e,calls:t,selectedAccount:n,transactionReviewService:r,appDomain:s,accountDeployTransaction:o})=>{const a={type:"INVOKE",calls:l.ensureArray(t)};if(!n||!e)return;const c=o?[o,a]:[a];return{result:await r.simulateAndReview(n,c,e,s,o)}},Ls=async(e,t,n,r)=>{var S,y,A,m,w,E;let s=!1;const o=t.transactions.find(T=>{var I,B;return(B=(I=T==null?void 0:T.simulation)==null?void 0:I.summary)==null?void 0:B.find(N=>N.sent)});if(!o||!((S=o.simulation)!=null&&S.summary))return s;const a=o.simulation.summary.filter(T=>T.sent).map(T=>T.token.address);if(!(((y=t.enrichedFeeEstimation)==null?void 0:y.transactions.feeTokenAddress)&&a.includes((A=t.enrichedFeeEstimation)==null?void 0:A.transactions.feeTokenAddress))||!((w=(m=t.enrichedFeeEstimation)==null?void 0:m.transactions)!=null&&w.max))return s;const u="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(!u||!d)return s;const f=await rs(n,e,r)??0n;return BigInt(f)>u+BigInt(d)||(s=!0),s},Mu=()=>L.useCallback(async({feeTokenAddress:t,calls:n,selectedAccount:r,transactionReviewService:s,appDomain:o,accountDeployPayload:a,provider:c})=>{if(!r)return;const u=await Us({feeTokenAddress:t,calls:n,selectedAccount:r,transactionReviewService:s,appDomain:o,accountDeployTransaction:Hs(a)});if(!u||!u.result||!t)return;const d=await Ls(r.address,u.result,t,c);return{...u.result,isSendingMoreThanBalanceAndGas:d}},[]),Hs=e=>e?{type:"DEPLOY_ACCOUNT",calldata:e.calldata,classHash:l.hexSchema.parse(e.class_hash),salt:l.hexSchema.parse(e.salt),signature:[]}:void 0;exports.BaseError=l.BaseError;exports.ETH_TOKEN_ADDRESS=l.ETH_TOKEN_ADDRESS;exports.EventEmitterProvider=l.EventEmitterProvider;Object.defineProperty(exports,"HTTP_ERROR_MESSAGE",{enumerable:!0,get:()=>l.HTTP_ERROR_MESSAGE});exports.HttpError=l.HttpError;Object.defineProperty(exports,"MultiSigner",{enumerable:!0,get:()=>l.MultiSigner});exports.STANDARD_DEVNET_ACCOUNT_CLASS_HASH=l.STANDARD_DEVNET_ACCOUNT_CLASS_HASH;exports.STRK_TOKEN_ADDRESS=l.STRK_TOKEN_ADDRESS;exports.TXV1_ACCOUNT_CLASS_HASH=l.TXV1_ACCOUNT_CLASS_HASH;exports.TXV1_MULTISIG_CLASS_HASH=l.TXV1_MULTISIG_CLASS_HASH;exports.TXV3_ACCOUNT_CLASS_HASH=l.TXV3_ACCOUNT_CLASS_HASH;exports.TXV3_MULTISIG_CLASS_HASH=l.TXV3_MULTISIG_CLASS_HASH;exports.abiEntrySchema=l.abiEntrySchema;exports.abiSchema=l.abiSchema;exports.addOwnersCalldataSchema=l.addOwnersCalldataSchema;exports.addPluginCalldataSchema=l.addPluginCalldataSchema;exports.addressInputCharactersAndLengthSchema=l.addressInputCharactersAndLengthSchema;exports.addressInputSchema=l.addressInputSchema;exports.addressOrDomainInputSchema=l.addressOrDomainInputSchema;exports.addressOrDomainSchema=l.addressOrDomainSchema;exports.addressOrEmptyUndefinedSchema=l.addressOrEmptyUndefinedSchema;exports.addressSchema=l.addressSchema;exports.addressSchemaArgentBackend=l.addressSchemaArgentBackend;exports.addressSchemaBase=l.addressSchemaBase;exports.addressSchemaLooseLength=l.addressSchemaLooseLength;exports.addressSchemaStrictLength=l.addressSchemaStrictLength;exports.apiWalletResponseSchema=l.apiWalletResponseSchema;exports.argentNameSchema=l.argentNameSchema;exports.bigNumberSchema=l.bigNumberSchema;exports.bigNumberishSchema=l.bigNumberishSchema;exports.booleanToStringSchema=l.booleanToStringSchema;exports.builtinsSchema=l.builtinsSchema;exports.byteCodeSchema=l.byteCodeSchema;exports.cairo1EventSchema=l.cairo1EventSchema;exports.cairoAssemblySchema=l.cairoAssemblySchema;exports.cairoVersionSchema=l.cairoVersionSchema;exports.callDetailsSchema=l.callDetailsSchema;exports.callSchema=l.callSchema;exports.calldataSchema=l.calldataSchema;exports.changeGuardianCalldataSchema=l.changeGuardianCalldataSchema;exports.changeThresholdCalldataSchema=l.changeThresholdCalldataSchema;exports.compiledContractClassSchema=l.compiledContractClassSchema;exports.compiledSierraCasmSchema=l.compiledSierraCasmSchema;exports.compiledSierraSchema=l.compiledSierraSchema;exports.compressedProgramSchema=l.compressedProgramSchema;exports.constructorCallDataSchemaC0=l.constructorCallDataSchemaC0;exports.constructorCallDataSchemaC1V1=l.constructorCallDataSchemaC1V1;exports.contractEntryPointFieldsSchema=l.contractEntryPointFieldsSchema;exports.ensureArray=l.ensureArray;exports.entryPointsByTypeSchema=l.entryPointsByTypeSchema;exports.escapeGuardianCalldataSchema=l.escapeGuardianCalldataSchema;exports.eventAbiSchema=l.eventAbiSchema;exports.eventEntrySchema=l.eventEntrySchema;exports.executeOnPluginCalldataSchema=l.executeOnPluginCalldataSchema;exports.feltSchema=l.feltSchema;exports.formatFullAddress=l.formatFullAddress;exports.formatTruncatedAddress=l.formatTruncatedAddress;exports.formatTruncatedSignerKey=l.formatTruncatedSignerKey;exports.formatTruncatedString=l.formatTruncatedString;exports.functionAbiSchema=l.functionAbiSchema;exports.functionAbiTypeSchema=l.functionAbiTypeSchema;exports.getAddressFromArgentName=l.getAddressFromArgentName;exports.getSignerForMultiSigner=l.getSignerForMultiSigner;exports.hexSchema=l.hexSchema;exports.hexSchemaBase=l.hexSchemaBase;exports.implementationSchema=l.implementationSchema;exports.includesAddress=l.includesAddress;exports.isAddress=l.isAddress;exports.isArgentName=l.isArgentName;exports.isEqualAddress=l.isEqualAddress;exports.isEqualArgentName=l.isEqualArgentName;exports.isEqualStarknetDomainName=l.isEqualStarknetDomainName;exports.isEqualStarknetId=l.isEqualStarknetId;exports.isStarknetDomainName=l.isStarknetDomainName;exports.isStarknetId=l.isStarknetId;exports.isValidAddress=l.isValidAddress;exports.isZeroAddress=l.isZeroAddress;exports.legacyContractClassSchema=l.legacyContractClassSchema;exports.legacyEventSchema=l.legacyEventSchema;exports.multiTypeSchema=l.multiTypeSchema;exports.normalizeAddress=l.normalizeAddress;exports.normalizeAddressOrDomain=l.normalizeAddressOrDomain;exports.normalizeArgentName=l.normalizeArgentName;exports.normalizeStarknetId=l.normalizeStarknetId;exports.programSchema=l.programSchema;exports.pythonicHintsSchema=l.pythonicHintsSchema;exports.rawArgsArraySchema=l.rawArgsArraySchema;exports.rawArgsObjectSchema=l.rawArgsObjectSchema;exports.rawArgsSchema=l.rawArgsSchema;exports.removeOwnersCalldataSchema=l.removeOwnersCalldataSchema;exports.removePluginCalldataSchema=l.removePluginCalldataSchema;exports.replaceSignerCalldataSchema=l.replaceSignerCalldataSchema;exports.sierraContractEntryPointFieldsSchema=l.sierraContractEntryPointFieldsSchema;exports.sierraEntryPointsByTypeSchema=l.sierraEntryPointsByTypeSchema;exports.sierraProgramDebugInfoSchema=l.sierraProgramDebugInfoSchema;exports.starknetDomainNameSchema=l.starknetDomainNameSchema;exports.starknetIdSchema=l.starknetIdSchema;exports.stringToBooleanSchema=l.stringToBooleanSchema;exports.structAbiSchema=l.structAbiSchema;exports.transferCalldataSchema=l.transferCalldataSchema;exports.uint256Schema=l.uint256Schema;exports.useEmitEvent=l.useEmitEvent;exports.useEventEmitter=l.useEventEmitter;exports.useEventEmitterContext=l.useEventEmitterContext;exports.useEventListener=l.useEventListener;exports.useIsEventEmitterEnabled=l.useIsEventEmitterEnabled;exports.validChecksumAddressSchema=l.validChecksumAddressSchema;exports.validateAddressRangeSchema=l.validateAddressRangeSchema;exports.ARGENT_ACCOUNT_CONTRACT_CLASS_HASHES=X;exports.ARGENT_MULTISIG_CONTRACT_CLASS_HASHES=ze;exports.AddSmartAccountResponseSchema=qs;exports.AddSmartAcountRequestSchema=Gs;exports.BackendAccountSchema=zn;exports.BackendNftService=qi;exports.C0_PROXY_CONTRACT_CLASS_HASHES=Zn;exports.CacheService=wo;exports.DEFAULT_TOKEN_DECIMALS=Te;exports.DateService=bo;exports.EstimateError=_s;exports.EventsBySelector=Ct;exports.FEE_OVERHEAD=en;exports.HTTPService=rt;exports.KnownDappsBackendService=ei;exports.OnchainRecoveryService=El;exports.PRETTY_UNLIMITED=os;exports.ResolveNameService=ni;exports.SWRService=Ao;exports.StarknetAddressService=No;exports.TokenError=is;exports.TokenServiceWeb=Wl;exports.TransactionReviewServiceWeb=vu;exports.airdropSchema=Ts;exports.apiAccountTokenBalancesSchema=cs;exports.apiAirdropSchema=gs;exports.apiCollateralizedDebtPositionSchema=Yt;exports.apiCollateralizedDebtPositionsSchema=ql;exports.apiConcentratedLiquidityPositionSchema=Zt;exports.apiConcentratedLiquidityPositionsSchema=Ml;exports.apiDefiDecompositionProduct=fs;exports.apiDefiDecompositionProducts=hs;exports.apiDefiDecompositionSchema=ms;exports.apiDefiDecompositionToken=_t;exports.apiDefiPositionsSchema=ps;exports.apiPriceDataResponseSchema=Vl;exports.apiPriceDetailsSchema=Kt;exports.apiTokenInfoResponseSchema=us;exports.apiTokenInfoSchema=xe;exports.apiTokensInfoResponseSchema=ls;exports.apiTransactionReviewActivityType=xu;exports.apiUnclaimedRewardsSchema=Gl;exports.argentBackendNetworkIdSchema=Un;exports.argentMaxFee=tn;exports.argentNetworkIdSchema=Dn;exports.bigDecimal=So;exports.buildAccountDeployTransaction=Hs;exports.buildConstructorCalldata=sr;exports.buildDummyTx=mu;exports.calculateCubeRootAdjustment=Ps;exports.calculateNonLinearAdjustment=yu;exports.calculateSqrtAdjustment=gu;exports.castFeeEstimation=ue;exports.checkGasFeeBalance=Ls;exports.classHashSupportsTxV3=Eu;exports.collateralizedDebtGroupSchema=Jl;exports.collateralizedDebtPositionSchema=Qt;exports.collateralizedDebtPositionsSchema=Xl;exports.concentratedLiquidityPositionSchema=Xt;exports.concentratedLiquidityPositionsSchema=Yl;exports.convertTokenAmountToCurrencyValue=kl;exports.convertTokenUnitAmountWithDecimals=Ol;exports.dappContractSchema=ir;exports.dappLinkSchema=ar;exports.daysBetween=Ri;exports.decodeBase58=_r;exports.decodeBase58Array=Oi;exports.defiDappsProductsSchema=Ql;exports.defiPositionSchema=ws;exports.defiPositionTypeSchema=Wt;exports.defiProductSchema=Es;exports.defiProductsSchema=As;exports.denyTxV3=Nu;exports.encodeBase58=xr;exports.encodeBase58Array=ki;exports.ensureDecimals=Rl;exports.entryPointToHumanReadable=$i;exports.equalNft=Ji;exports.erc20TransferTransaction=nu;exports.erc721SafeTransferFromTransaction=su;exports.erc721TransferFromTransaction=ru;exports.estimatedFeeToMaxFeeTotal=tt;exports.estimatedFeeToMaxResourceBounds=pu;exports.estimatedFeeToTotal=He;exports.estimatedFeesToMaxFeeTotal=fu;exports.estimatedFeesToTotal=hu;exports.feeTokenNeedsTxV3Support=ft;exports.fetchData=Pt;exports.fetcherError=Pe;exports.findImplementationForAccount=Ja;exports.findTransfersAndApprovals=zs;exports.formatAddress=Dt;exports.generateAvatarImage=De;exports.getAccountContractAddress=or;exports.getAccountDeploymentPayload=rr;exports.getAccountIdentifier=Io;exports.getAddressFromStarkName=Kn;exports.getArgentAccountClassHashes=Tt;exports.getArgentAccountClassHashesWithTxV3Support=tr;exports.getArgentAccountWithMultiSignerClassHashes=er;exports.getBackendTimeNowSeconds=Co;exports.getBackendTimeSeconds=Vn;exports.getCallFromStarkName=Wn;exports.getChainIdFromNetworkId=Mn;exports.getColor=vr;exports.getDapplandLinkForDapp=ur;exports.getDapplandUrlForDapp=ti;exports.getDisplayWarnAndReasonForTransactionReview=Lu;exports.getERC20Transactions=qe;exports.getERC721Transactions=rn;exports.getEstimatedFeeFromBulkSimulation=ks;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFee=Rs;exports.getInitials=Tr;exports.getLastCairo0ArgentAccountClassHash=Ka;exports.getLatestArgentAccountClassHash=Qn;exports.getLatestArgentMultisigClassHash=Wa;exports.getLatestLedgerAccountClassHash=Ya;exports.getLedgerAccountClassHashes=Za;exports.getMessageFromTrpcError=ou;exports.getNFTTransferActivity=Hu;exports.getNetworkAccountImageUrl=Bi;exports.getNftPicture=Yi;exports.getPayloadFromTransaction=Os;exports.getPrettyRpcError=wu;exports.getRecoverySchema=bl;exports.getReviewForTransactions=Us;exports.getSimulationTxVersionFromFeeToken=Au;exports.getStarknetIdContractAddressFromNetworkId=Gn;exports.getTokenBalance=rs;exports.getTokens=Nl;exports.getTokensBalances=Cl;exports.getTransactionReviewActivityOfType=$u;exports.getTransactionReviewHasSwap=ju;exports.getTransactionReviewSwap=Ds;exports.getTransactionReviewWithType=Vu;exports.getTxVersionFromFeeToken=Nt;exports.getTxVersionFromFeeTokenForDeclareContract=Tu;exports.getUAParserResult=ns;exports.getUint256CalldataFromBN=Ae;exports.getWatermarkedMaxFeeTotal=Bs;exports.hasERC20Transactions=Ou;exports.hasERC721Transactions=Fs;exports.hasIncomingERC20Transactions=Ru;exports.hasOutgoingERC20Transactions=Pu;exports.id=Ar;exports.inputAmountSchema=Is;exports.isAccountV4=Zs;exports.isAccountV5=Ks;exports.isAccountV6=Ws;exports.isAllowedAddressHexInputValue=Di;exports.isAllowedNumericInputValue=Ui;exports.isArgentBackendNetworkId=Xs;exports.isArgentNetworkId=Js;exports.isBraveBrowser=Al;exports.isBrowser=Me;exports.isChromeBrowser=vl;exports.isContractDeployed=zi;exports.isEdgeBrowser=xl;exports.isEqualImplementation=nr;exports.isFRI=Cs;exports.isFeatureEnabled=Pi;exports.isFirefoxBrowser=Tl;exports.isNumeric=K;exports.isSafariBrowser=Il;exports.isUnlimitedAmount=ss;exports.isValidInputAmount=tu;exports.isWEI=nn;exports.knownDappSchema=cr;exports.knownDappsSchema=lr;exports.modifySnjsFeeOverhead=cu;exports.multiplyBigIntByFloat=uu;exports.nameProviderResolutionSchema=hr;exports.nameResolutionAddressSchema=fr;exports.nameResolutionAddressesSchema=pr;exports.nameResolutionStarknetIdSchema=Ft;exports.nameResolutionStarknetIdsSchema=dr;exports.nonNullable=Fi;exports.parseAmount=vs;exports.parseAmountValue=Br;exports.pluralise=Li;exports.postData=To;exports.preferencesEndpointPayload=Ys;exports.preferencesSchema=Fn;exports.prettifyCurrencyNumber=Cr;exports.prettifyCurrencyValue=zl;exports.prettifyNumber=Ut;exports.prettifyNumberConfig=ct;exports.prettifyTokenAmount=Fl;exports.prettifyTokenNumber=Nr;exports.productGroupsSchema=bs;exports.providersNamesSchema=mr;exports.readFileAsString=Hi;exports.recoveryBodySchema=wl;exports.recoveryStatusSchema=ts;exports.seedphraseSchema=_l;exports.starkNameToCallDataDomain=qn;exports.startRecoverySchema=es;exports.stripAddressZeroPadding=Ir;exports.swrRefetchDisabledConfig=_o;exports.toMax=be;exports.tokensRequireTxV3Support=du;exports.transactionReviewTransactionsSchema=lu;exports.transactionReviewWarningSchema=Iu;exports.trpcErrorSchema=xs;exports.txVersionSchema=Cu;exports.unclaimedRewardsSchema=eu;exports.unitToFeeTokenAddress=Ye;exports.urlWithQuery=ji;exports.useBalanceChange=Bu;exports.useCollection=Ki;exports.useConditionallyEnabledSWR=jn;exports.useDebounce=Xa;exports.useDebouncedValue=Qa;exports.useERC20Transactions=ku;exports.useERC721Transactions=zu;exports.useHasERC721Transaction=Fu;exports.useMaxAmountTransaction=Du;exports.useNft=Zi;exports.useNfts=Wi;exports.useToken=Bl;exports.useTransactionReview=Uu;exports.useTransactionReviewV2webFetcher=Mu;exports.voidify=Vi;exports.withPolling=vo;
4
+ </svg>`;return`data:image/svg+xml;base64,${btoa(o)}`},Sn=["02BBA8","29C5FF","0078A4","FFBF3D","FFA85C","FF875B","FF675C","FF5C72"],vr=e=>{const t=Ar(e).slice(-2),n=parseInt(t,16)%Sn.length;return Sn[n]},Ir=e=>{try{return p.num.toHex(Ni(p.num.hexToDecimalString(e)))}catch{}return""},Bi=({accountName:e,networkId:t,accountAddress:n,backgroundColor:r})=>{const s=Ir(n),o=`${t}::${s}`,a=r||vr(o);return De(e,{background:a})},xr=e=>{const t=p.encode.removeHexPrefix(p.encode.sanitizeHex(p.num.toHex(e))),n=Ee.hex.decode(t);return Ee.base58.encode(n)},ki=e=>e.map(xr),_r=e=>{const t=Ee.base58.decode(e);return p.encode.sanitizeHex(Ee.hex.encode(t))},Oi=e=>e.map(_r);function Ri(e,t){const n=e.getTime(),r=t.getTime(),s=Math.abs(n-r);return Math.floor(s/(1e3*60*60*24))}const Pi=e=>(e||"false")==="true",zi=async(e,t)=>{try{return await e.getClassHashAt(t),!0}catch{return!1}};function Fi(e){return!F.isNil(e)}const Di=e=>{const t=/^(0|0x([a-f0-9A-F]+)?)$/;return!!(e===""||t.test(e))},K=e=>!isNaN(parseFloat(e))&&isFinite(Number(e)),Ui=(e,t=16)=>{const n=new RegExp(`^[0-9]*.?[0-9]{0,${t}}$`);return e===""?!0:K(e)?!!n.test(e):!1},ct={CURRENCY:{minDecimalPlaces:2,maxDecimalPlaces:10,minDecimalSignificantDigits:2,decimalPlacesWhenZero:2,allowLeadingZerosInDecimalPart:!0},TOKEN:{minDecimalPlaces:4,maxDecimalPlaces:16,minDecimalSignificantDigits:2,decimalPlacesWhenZero:1,allowLeadingZerosInDecimalPart:!0}},Cr=(e,t)=>Ut(e,{...ct.CURRENCY,...t||{}}),Nr=(e,t)=>Ut(e,{...ct.TOKEN,...t||{}}),Ut=(e,{minDecimalPlaces:t,maxDecimalPlaces:n,minDecimalSignificantDigits:r,decimalPlacesWhenZero:s,allowLeadingZerosInDecimalPart:o}=ct.CURRENCY)=>{if(!K(e))return null;const a=new l.BigNumber(typeof e=="bigint"?e.toString():e);let c;const u=`0.${"".padStart(s-1,"0")}1`;if(a.lt(new l.BigNumber(u))&&!o)c=`0.${"".padStart(s,"0")}`;else if(a.gte(1))c=a.toFormat(t);else{const y=a.toFormat(n).split(".")[1].match(/^0+/),A=o&&y&&y.length?y[0].length:0,m=Math.max(A+r,t);c=a.toFormat(m)}let d=c.replace(/0+$/,"");const f=1+c.indexOf(".")+s;return d.length<f&&(d=c.substring(0,f)),d},Br=(e,t=18)=>{const n=e.replace(",",".");return!e||!K(n)?0n:me(n,Number(t)).value};function Ae(e){return p.uint256.bnToUint256(e)}const Li=(e,t)=>`${e} ${t}${e===1?"":"s"}`,Hi=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 $i(e){try{return F.upperFirst(F.lowerCase(e))}catch{return e}}const ji=(e,t)=>{const n=new URLSearchParams(t),r=n.size?`?${n}`:"";return l.urlJoin(...l.ensureArray(e),r)};function Vi(e){return(...t)=>{e(...t)}}class Mi extends Error{constructor(t,n){super(`${t}::${n}`),this.name=t,this.code=n,this.name=t}}class wn extends Mi{constructor(t){super("BackendPaginationError",t)}}const bn=32;class qi{constructor(t,n,r){this.apiBase=t,this.headers=n,this.imageOptimizationUrl=r,this.httpService=new rt(this.headers,"json")}async getNfts(t,n,r,s=1){const o=this.normalizeAddress(r),a=l.urlJoin(this.apiBase,"pandora",t,n),c=this.pageToPageIndex(s),d=`${l.urlJoin(a,"profile",o,"nfts")}?page=${c}&size=${bn}`,f=await this.httpService.get(d),h=f.content.map(S=>this.mapItem(S,r));return{totalPages:f.totalPages,page:f.number+1,count:h.length,nfts:h}}async getCollection(t,n,r){const s=this.normalizeAddress(r),o=l.urlJoin(this.apiBase,"pandora",t,n),a=l.urlJoin(o,"collection",s),c=`${o}/collection/${s}`,[u,d]=await Promise.all([this.httpService.get(a),this.httpService.get(c)]),f=yt(u),h=d.content.map(S=>this.mapItem(S));return{...f,nfts:{totalPages:d.totalPages,page:d.number,count:h.length,data:h}}}async getNft(t,n,r,s){const o=this.normalizeAddress(r),a=l.urlJoin(this.apiBase,"pandora",t,n),c=l.urlJoin(a,"nft",o,s),u=await this.httpService.get(c);return this.mapItem(u)}async getProfileCollections(t,n,r,s=1,o=!1){const a=this.pageToPageIndex(s),c=this.normalizeAddress(r),u=l.urlJoin(this.apiBase,"pandora",t,n),d=l.urlJoin(u,"profile",c,"collections",`?page=${a}&size=${bn}`),f=await this.httpService.get(d),h=[];for(const S of f.content)if(o){const y=await this.getCollectionMetrics(t,n,S.contractAddress);h.push(yt(S,y))}else h.push(yt(S));return{totalPages:f.totalPages,page:f.number+1,count:h.length,collections:h}}async getCollectionMetrics(t,n,r){const s=this.normalizeAddress(r),o=l.urlJoin(this.apiBase,"pandora",t,n),a=l.urlJoin(o,"collection",s,"metrics");return this.httpService.get(a)}normalizeAddress(t){return l.addressSchemaArgentBackend.parse(t)}pageToPageIndex(t){if(!Number.isInteger(t))throw new wn("notANumber");const n=t-1;if(n<0)throw new wn("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?Gi(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)??De(r,{background:"#15192A",color:"#ffffff"}),image_url_copy:this.optimizeImage(t.imageUrls.full)??De(r,{background:"#15192A",color:"#ffffff"}),owner:{account_address:((s=t.owner)==null?void 0:s.address)||n},contract_name:Dt(t.contractAddress)}}}function Gi(e){switch(e){case"erc721":case"starknetErc721":return"ERC721";case"erc1155":case"starknetErc1155":return"ERC1155"}}function yt(e,t){return{contractAddress:l.addressSchema.parse(e.contractAddress),name:e.name||Dt(e.contractAddress),description:e.description??"",imageUri:e.imageUrls.preview??De(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 kr=async(e,t,n,r,s=1)=>{const o=await e.getNfts(t,n,r,s);if(s<o.totalPages){const a=await kr(e,t,n,r,o.page+1);return{...o,nfts:o.nfts.concat(a.nfts)}}return o},Wi=(e,t,n,r,s)=>{const{data:o,...a}=Re(r&&[r,"nfts"],()=>r&&kr(e,t,n,r),{refreshInterval:3e5,...s});return{nfts:o==null?void 0:o.nfts,...a}},Ki=(e,t,n,r,s)=>{const{data:o,...a}=Re(r&&[`${r}`,"nfts-collection"],()=>r&&e.getCollection(t,n,r),{refreshInterval:6e4,...s});return{collection:o,...a}},Zi=(e,t,n,r,s,o)=>{const{data:a,...c}=Re(s&&r&&[`${r}:${s}`,"nft"],()=>s&&r?e.getNft(t,n,r,s):void 0,{refreshInterval:6e4,revalidateOnFocus:!1,revalidateOnMount:!1,...o});return{nft:a,...c}},Yi=({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},Ji=(e,t)=>e.token_id===t.token_id&&l.isEqualAddress(e.contract_address,t.contract_address);function En(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Xi(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Or(e,...t){if(!Xi(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 Qe(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 Rr(e,t){Or(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Ke=BigInt(2**32-1),An=BigInt(32);function Qi(e,t=!1){return t?{h:Number(e&Ke),l:Number(e>>An&Ke)}:{h:Number(e>>An&Ke)|0,l:Number(e&Ke)|0}}function ec(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:a}=Qi(e[s],t);[n[s],r[s]]=[o,a]}return[n,r]}const tc=(e,t,n)=>e<<n|t>>>32-n,nc=(e,t,n)=>t<<n|e>>>32-n,rc=(e,t,n)=>t<<n-32|e>>>64-n,sc=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const oc=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));function ac(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}const St=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Q=(e,t)=>e<<32-t|e>>>t,ic=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!ic)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 Lt(e){if(typeof e=="string"&&(e=Pr(e)),!ac(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}let zr=class{clone(){return this._cloneInto()}};function Fr(e){const t=r=>e().update(Lt(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const[Dr,Ur,Lr]=[[],[],[]],cc=BigInt(0),Be=BigInt(1),lc=BigInt(2),uc=BigInt(7),dc=BigInt(256),hc=BigInt(113);for(let e=0,t=Be,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Dr.push(2*(5*r+n)),Ur.push((e+1)*(e+2)/2%64);let s=cc;for(let o=0;o<7;o++)t=(t<<Be^(t>>uc)*hc)%dc,t&lc&&(s^=Be<<(Be<<BigInt(o))-Be);Lr.push(s)}const[fc,mc]=ec(Lr,!0),Tn=(e,t,n)=>n>32?rc(e,t,n):tc(e,t,n),vn=(e,t,n)=>n>32?sc(e,t,n):nc(e,t,n);function pc(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let a=0;a<10;a++)n[a]=e[a]^e[a+10]^e[a+20]^e[a+30]^e[a+40];for(let a=0;a<10;a+=2){const c=(a+8)%10,u=(a+2)%10,d=n[u],f=n[u+1],h=Tn(d,f,1)^n[c],S=vn(d,f,1)^n[c+1];for(let y=0;y<50;y+=10)e[a+y]^=h,e[a+y+1]^=S}let s=e[2],o=e[3];for(let a=0;a<24;a++){const c=Ur[a],u=Tn(s,o,c),d=vn(s,o,c),f=Dr[a];s=e[f],o=e[f+1],e[f]=u,e[f+1]=d}for(let a=0;a<50;a+=10){for(let c=0;c<10;c++)n[c]=e[a+c];for(let c=0;c<10;c++)e[a+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=fc[r],e[1]^=mc[r]}n.fill(0)}class Ht extends zr{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,En(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=oc(this.state)}keccak(){pc(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){Qe(this);const{blockLen:n,state:r}=this;t=Lt(t);const s=t.length;for(let o=0;o<s;){const a=Math.min(n-this.pos,s-o);for(let c=0;c<a;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){Qe(this,!1),Or(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 a=Math.min(r-this.posOut,o-s);t.set(n.subarray(this.posOut,this.posOut+a),s),this.posOut+=a,s+=a}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return En(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Rr(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:a}=this;return t||(t=new Ht(n,r,s,a,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=a,t.destroyed=this.destroyed,t}}const gc=(e,t,n)=>Fr(()=>new Ht(t,e,n)),yc=gc(1,136,256/8);function Sc(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),a=Number(n>>s&o),c=Number(n&o),u=r?4:0,d=r?0:4;e.setUint32(t+u,a,r),e.setUint32(t+d,c,r)}class wc extends zr{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=St(this.buffer)}update(t){Qe(this);const{view:n,buffer:r,blockLen:s}=this;t=Lt(t);const o=t.length;for(let a=0;a<o;){const c=Math.min(s-this.pos,o-a);if(c===s){const u=St(t);for(;s<=o-a;a+=s)this.process(u,a);continue}r.set(t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Qe(this),Rr(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:o}=this;let{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>s-a&&(this.process(r,0),a=0);for(let h=a;h<s;h++)n[h]=0;Sc(r,s-8,BigInt(this.length*8),o),this.process(r,0);const c=St(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=u/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<d;h++)c.setUint32(4*h,f[h],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:a,pos:c}=this;return t.length=s,t.pos=c,t.finished=o,t.destroyed=a,s%n&&t.buffer.set(r),t}}const bc=(e,t,n)=>e&t^~e&n,Ec=(e,t,n)=>e&t^e&n^t&n,Ac=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]),oe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ae=new Uint32Array(64);class Tc extends wc{constructor(){super(64,32,8,!1),this.A=oe[0]|0,this.B=oe[1]|0,this.C=oe[2]|0,this.D=oe[3]|0,this.E=oe[4]|0,this.F=oe[5]|0,this.G=oe[6]|0,this.H=oe[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:a,G:c,H:u}=this;return[t,n,r,s,o,a,c,u]}set(t,n,r,s,o,a,c,u){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=a|0,this.G=c|0,this.H=u|0}process(t,n){for(let h=0;h<16;h++,n+=4)ae[h]=t.getUint32(n,!1);for(let h=16;h<64;h++){const S=ae[h-15],y=ae[h-2],A=Q(S,7)^Q(S,18)^S>>>3,m=Q(y,17)^Q(y,19)^y>>>10;ae[h]=m+ae[h-7]+A+ae[h-16]|0}let{A:r,B:s,C:o,D:a,E:c,F:u,G:d,H:f}=this;for(let h=0;h<64;h++){const S=Q(c,6)^Q(c,11)^Q(c,25),y=f+S+bc(c,u,d)+Ac[h]+ae[h]|0,m=(Q(r,2)^Q(r,13)^Q(r,22))+Ec(r,s,o)|0;f=d,d=u,u=c,c=a+y|0,a=o,o=s,s=r,r=y+m|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,a=a+this.D|0,c=c+this.E|0,u=u+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(r,s,o,a,c,u,d,f)}roundClean(){ae.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Hr=Fr(()=>new Tc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $r=BigInt(0),lt=BigInt(1),vc=BigInt(2),ut=e=>e instanceof Uint8Array,Ic=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function he(e){if(!ut(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=Ic[e[n]];return t}function jr(e){const t=e.toString(16);return t.length&1?`0${t}`:t}function $t(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}function fe(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 J(e){return $t(he(e))}function jt(e){if(!ut(e))throw new Error("Uint8Array expected");return $t(he(Uint8Array.from(e).reverse()))}const we=(e,t)=>fe(e.toString(16).padStart(t*2,"0")),Vr=(e,t)=>we(e,t).reverse(),xc=e=>fe(jr(e));function V(e,t,n){let r;if(typeof t=="string")try{r=fe(t)}catch(o){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${o}`)}else if(ut(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 Ue(...e){const t=new Uint8Array(e.reduce((r,s)=>r+s.length,0));let n=0;return e.forEach(r=>{if(!ut(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}function _c(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 Cc(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function Nc(e){let t;for(t=0;e>$r;e>>=lt,t+=1);return t}const Bc=(e,t)=>e>>BigInt(t)&lt,kc=(e,t,n)=>e|(n?lt:$r)<<BigInt(t),dt=e=>(vc<<BigInt(e-1))-lt,wt=e=>new Uint8Array(e),In=e=>Uint8Array.from(e);function Mr(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=wt(e),s=wt(e),o=0;const a=()=>{r.fill(1),s.fill(0),o=0},c=(...h)=>n(s,r,...h),u=(h=wt())=>{s=c(In([0]),h),r=c(),h.length!==0&&(s=c(In([1]),h),r=c())},d=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const S=[];for(;h<t;){r=c();const y=r.slice();S.push(y),h+=r.length}return Ue(...S)};return(h,S)=>{a(),u(h);let y;for(;!(y=S(d()));)u();return a(),y}}const Oc={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 Ve(e,t,n={}){const r=(s,o,a)=>{const c=Oc[o];if(typeof c!="function")throw new Error(`Invalid validator "${o}", expected function`);const u=e[s];if(!(a&&u===void 0)&&!c(u,e))throw new Error(`Invalid param ${String(s)}=${u} (${typeof u}), 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 Rc=Object.freeze(Object.defineProperty({__proto__:null,bitGet:Bc,bitLen:Nc,bitMask:dt,bitSet:kc,bytesToHex:he,bytesToNumberBE:J,bytesToNumberLE:jt,concatBytes:Ue,createHmacDrbg:Mr,ensureBytes:V,equalBytes:_c,hexToBytes:fe,hexToNumber:$t,numberToBytesBE:we,numberToBytesLE:Vr,numberToHexUnpadded:jr,numberToVarBytesBE:xc,utf8ToBytes:Cc,validateObject:Ve},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const D=BigInt(0),z=BigInt(1),ce=BigInt(2),Pc=BigInt(3),vt=BigInt(4),xn=BigInt(5),_n=BigInt(8);BigInt(9);BigInt(16);function M(e,t){const n=e%t;return n>=D?n:t+n}function zc(e,t,n){if(n<=D||t<D)throw new Error("Expected power/modulo > 0");if(n===z)return D;let r=z;for(;t>D;)t&z&&(r=r*e%n),e=e*e%n,t>>=z;return r}function It(e,t){if(e===D||t<=D)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=M(e,t),r=t,s=D,o=z;for(;n!==D;){const c=r/n,u=r%n,d=s-o*c;r=n,n=u,s=o,o=d}if(r!==z)throw new Error("invert: does not exist");return M(s,t)}function Fc(e){const t=(e-z)/ce;let n,r,s;for(n=e-z,r=0;n%ce===D;n/=ce,r++);for(s=ce;s<e&&zc(s,t,e)!==e-z;s++);if(r===1){const a=(e+z)/vt;return function(u,d){const f=u.pow(d,a);if(!u.eql(u.sqr(f),d))throw new Error("Cannot find square root");return f}}const o=(n+z)/ce;return function(c,u){if(c.pow(u,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let d=r,f=c.pow(c.mul(c.ONE,s),n),h=c.pow(u,o),S=c.pow(u,n);for(;!c.eql(S,c.ONE);){if(c.eql(S,c.ZERO))return c.ZERO;let y=1;for(let m=c.sqr(S);y<d&&!c.eql(m,c.ONE);y++)m=c.sqr(m);const A=c.pow(f,z<<BigInt(d-y-1));f=c.sqr(A),h=c.mul(h,A),S=c.mul(S,f),d=y}return h}}function Dc(e){if(e%vt===Pc){const t=(e+z)/vt;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%_n===xn){const t=(e-xn)/_n;return function(r,s){const o=r.mul(s,ce),a=r.pow(o,t),c=r.mul(s,a),u=r.mul(r.mul(c,ce),a),d=r.mul(c,r.sub(u,r.ONE));if(!r.eql(r.sqr(d),s))throw new Error("Cannot find square root");return d}}return Fc(e)}const Uc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Vt(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=Uc.reduce((r,s)=>(r[s]="function",r),t);return Ve(e,n)}function qr(e,t,n){if(n<D)throw new Error("Expected power > 0");if(n===D)return e.ONE;if(n===z)return t;let r=e.ONE,s=t;for(;n>D;)n&z&&(r=e.mul(r,s)),s=e.sqr(s),n>>=z;return r}function Lc(e,t){const n=new Array(t.length),r=t.reduce((o,a,c)=>e.is0(a)?o:(n[c]=o,e.mul(o,a)),e.ONE),s=e.inv(r);return t.reduceRight((o,a,c)=>e.is0(a)?o:(n[c]=e.mul(o,n[c]),e.mul(o,a)),s),n}function Mt(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function qt(e,t,n=!1,r={}){if(e<=D)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:s,nByteLength:o}=Mt(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const a=Dc(e),c=Object.freeze({ORDER:e,BITS:s,BYTES:o,MASK:dt(s),ZERO:D,ONE:z,create:u=>M(u,e),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return D<=u&&u<e},is0:u=>u===D,isOdd:u=>(u&z)===z,neg:u=>M(-u,e),eql:(u,d)=>u===d,sqr:u=>M(u*u,e),add:(u,d)=>M(u+d,e),sub:(u,d)=>M(u-d,e),mul:(u,d)=>M(u*d,e),pow:(u,d)=>qr(c,u,d),div:(u,d)=>M(u*It(d,e),e),sqrN:u=>u*u,addN:(u,d)=>u+d,subN:(u,d)=>u-d,mulN:(u,d)=>u*d,inv:u=>It(u,e),sqrt:r.sqrt||(u=>a(c,u)),invertBatch:u=>Lc(c,u),cmov:(u,d,f)=>f?d:u,toBytes:u=>n?Vr(u,o):we(u,o),fromBytes:u=>{if(u.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${u.length}`);return n?jt(u):J(u)}});return Object.freeze(c)}function Hc(e,t,n=!1){e=V("privateHash",e);const r=e.length,s=Mt(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?jt(e):J(e);return M(o,t-z)+z}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $c(e){const{Fp:t}=e;Vt(t);for(const u of["t","roundsFull","roundsPartial"])if(typeof e[u]!="number"||!Number.isSafeInteger(e[u]))throw new Error(`Poseidon: invalid param ${u}=${e[u]} (${typeof e[u]})`);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=u=>qr(t,u,r);if(n===3?s=u=>t.mul(t.sqrN(u),u):n===5&&(s=u=>t.mul(t.sqrN(t.sqrN(u)),u)),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 a=e.roundConstants.map(u=>{if(!Array.isArray(u)||u.length!==e.t)throw new Error(`Poseidon wrong round constants: ${u}`);return u.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(u=>{if(!Array.isArray(u)||u.length!==e.t)throw new Error(`Poseidon MDS matrix row: ${u}`);return u.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:a,mds:c})}function jc(e){const{t,Fp:n,rounds:r,sboxFn:s,reversePartialPowIdx:o}=$c(e),a=Math.floor(e.roundsFull/2),c=o?t-1:0,u=(f,h,S)=>(f=f.map((y,A)=>n.add(y,e.roundConstants[S][A])),h?f=f.map(y=>s(y)):f[c]=s(f[c]),f=e.mds.map(y=>y.reduce((A,m,w)=>n.add(A,n.mulN(m,f[w])),n.ZERO)),f),d=function(h){if(!Array.isArray(h)||h.length!==t)throw new Error(`Poseidon: wrong values (expected array of bigints with length ${t})`);h=h.map(y=>{if(typeof y!="bigint")throw new Error(`Poseidon: wrong value=${y} (${typeof y})`);return n.create(y)});let S=0;for(let y=0;y<a;y++)h=u(h,!0,S++);for(let y=0;y<e.roundsPartial;y++)h=u(h,!1,S++);for(let y=0;y<a;y++)h=u(h,!0,S++);if(S!==r)throw new Error(`Poseidon: wrong number of rounds: last round=${S}, total=${r}`);return h};return d.roundConstants=e.roundConstants,d}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Vc=BigInt(0),bt=BigInt(1);function Mc(e,t){const n=(s,o)=>{const a=o.negate();return s?a:o},r=s=>{const o=Math.ceil(t/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:n,unsafeLadder(s,o){let a=e.ZERO,c=s;for(;o>Vc;)o&bt&&(a=a.add(c)),c=c.double(),o>>=bt;return a},precomputeWindow(s,o){const{windows:a,windowSize:c}=r(o),u=[];let d=s,f=d;for(let h=0;h<a;h++){f=d,u.push(f);for(let S=1;S<c;S++)f=f.add(d),u.push(f);d=f.double()}return u},wNAF(s,o,a){const{windows:c,windowSize:u}=r(s);let d=e.ZERO,f=e.BASE;const h=BigInt(2**s-1),S=2**s,y=BigInt(s);for(let A=0;A<c;A++){const m=A*u;let w=Number(a&h);a>>=y,w>u&&(w-=S,a+=bt);const E=m,T=m+Math.abs(w)-1,I=A%2!==0,B=w<0;w===0?f=f.add(n(I,o[E])):d=d.add(n(B,o[T]))}return{p:d,f}},wNAFCached(s,o,a,c){const u=s._WINDOW_SIZE||1;let d=o.get(s);return d||(d=this.precomputeWindow(s,u),u!==1&&o.set(s,c(d))),this.wNAF(u,d,a)}}}function Gr(e){return Vt(e.Fp),Ve(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Mt(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function qc(e){const t=Gr(e);Ve(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:Gc,hexToBytes:Wc}=Rc,le={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=le;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:Gc(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=le,n=typeof e=="string"?Wc(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}=le._parseInt(n.subarray(2)),{d:a,l:c}=le._parseInt(o);if(c.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:a}},hexFromSig(e){const t=d=>Number.parseInt(d[0],16)&8?"00"+d:d,n=d=>{const f=d.toString(16);return f.length&1?`0${f}`:f},r=t(n(e.s)),s=t(n(e.r)),o=r.length/2,a=s.length/2,c=n(o),u=n(a);return`30${n(a+o+4)}02${u}${s}02${c}${r}`}},ee=BigInt(0),W=BigInt(1);BigInt(2);const Cn=BigInt(3);BigInt(4);function Kc(e){const t=qc(e),{Fp:n}=t,r=t.toBytes||((A,m,w)=>{const E=m.toAffine();return Ue(Uint8Array.from([4]),n.toBytes(E.x),n.toBytes(E.y))}),s=t.fromBytes||(A=>{const m=A.subarray(1),w=n.fromBytes(m.subarray(0,n.BYTES)),E=n.fromBytes(m.subarray(n.BYTES,2*n.BYTES));return{x:w,y:E}});function o(A){const{a:m,b:w}=t,E=n.sqr(A),T=n.mul(E,A);return n.add(n.add(T,n.mul(A,m)),w)}if(!n.eql(n.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function a(A){return typeof A=="bigint"&&ee<A&&A<t.n}function c(A){if(!a(A))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(A){const{allowedPrivateKeyLengths:m,nByteLength:w,wrapPrivateKey:E,n:T}=t;if(m&&typeof A!="bigint"){if(A instanceof Uint8Array&&(A=he(A)),typeof A!="string"||!m.includes(A.length))throw new Error("Invalid key");A=A.padStart(w*2,"0")}let I;try{I=typeof A=="bigint"?A:J(V("private key",A,w))}catch{throw new Error(`private key must be ${w} bytes, hex or bigint, not ${typeof A}`)}return E&&(I=M(I,T)),c(I),I}const d=new Map;function f(A){if(!(A instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(m,w,E){if(this.px=m,this.py=w,this.pz=E,m==null||!n.isValid(m))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(m){const{x:w,y:E}=m||{};if(!m||!n.isValid(w)||!n.isValid(E))throw new Error("invalid affine point");if(m instanceof h)throw new Error("projective point not allowed");const T=I=>n.eql(I,n.ZERO);return T(w)&&T(E)?h.ZERO:new h(w,E,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){const w=n.invertBatch(m.map(E=>E.pz));return m.map((E,T)=>E.toAffine(w[T])).map(h.fromAffine)}static fromHex(m){const w=h.fromAffine(s(V("pointHex",m)));return w.assertValidity(),w}static fromPrivateKey(m){return h.BASE.multiply(u(m))}_setWindowSize(m){this._WINDOW_SIZE=m,d.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:m,y:w}=this.toAffine();if(!n.isValid(m)||!n.isValid(w))throw new Error("bad point: x or y not FE");const E=n.sqr(w),T=o(m);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:m}=this.toAffine();if(n.isOdd)return!n.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){f(m);const{px:w,py:E,pz:T}=this,{px:I,py:B,pz:N}=m,v=n.eql(n.mul(w,N),n.mul(I,T)),x=n.eql(n.mul(E,N),n.mul(B,T));return v&&x}negate(){return new h(this.px,n.neg(this.py),this.pz)}double(){const{a:m,b:w}=t,E=n.mul(w,Cn),{px:T,py:I,pz:B}=this;let N=n.ZERO,v=n.ZERO,x=n.ZERO,C=n.mul(T,T),q=n.mul(I,I),P=n.mul(B,B),k=n.mul(T,I);return k=n.add(k,k),x=n.mul(T,B),x=n.add(x,x),N=n.mul(m,x),v=n.mul(E,P),v=n.add(N,v),N=n.sub(q,v),v=n.add(q,v),v=n.mul(N,v),N=n.mul(k,N),x=n.mul(E,x),P=n.mul(m,P),k=n.sub(C,P),k=n.mul(m,k),k=n.add(k,x),x=n.add(C,C),C=n.add(x,C),C=n.add(C,P),C=n.mul(C,k),v=n.add(v,C),P=n.mul(I,B),P=n.add(P,P),C=n.mul(P,k),N=n.sub(N,C),x=n.mul(P,q),x=n.add(x,x),x=n.add(x,x),new h(N,v,x)}add(m){f(m);const{px:w,py:E,pz:T}=this,{px:I,py:B,pz:N}=m;let v=n.ZERO,x=n.ZERO,C=n.ZERO;const q=t.a,P=n.mul(t.b,Cn);let k=n.mul(w,I),H=n.mul(E,B),$=n.mul(T,N),te=n.add(w,E),g=n.add(I,B);te=n.mul(te,g),g=n.add(k,H),te=n.sub(te,g),g=n.add(w,T);let b=n.add(I,N);return g=n.mul(g,b),b=n.add(k,$),g=n.sub(g,b),b=n.add(E,T),v=n.add(B,N),b=n.mul(b,v),v=n.add(H,$),b=n.sub(b,v),C=n.mul(q,g),v=n.mul(P,$),C=n.add(v,C),v=n.sub(H,C),C=n.add(H,C),x=n.mul(v,C),H=n.add(k,k),H=n.add(H,k),$=n.mul(q,$),g=n.mul(P,g),H=n.add(H,$),$=n.sub(k,$),$=n.mul(q,$),g=n.add(g,$),k=n.mul(H,g),x=n.add(x,k),k=n.mul(b,g),v=n.mul(te,v),v=n.sub(v,k),k=n.mul(te,H),C=n.mul(b,C),C=n.add(C,k),new h(v,x,C)}subtract(m){return this.add(m.negate())}is0(){return this.equals(h.ZERO)}wNAF(m){return y.wNAFCached(this,d,m,w=>{const E=n.invertBatch(w.map(T=>T.pz));return w.map((T,I)=>T.toAffine(E[I])).map(h.fromAffine)})}multiplyUnsafe(m){const w=h.ZERO;if(m===ee)return w;if(c(m),m===W)return this;const{endo:E}=t;if(!E)return y.unsafeLadder(this,m);let{k1neg:T,k1:I,k2neg:B,k2:N}=E.splitScalar(m),v=w,x=w,C=this;for(;I>ee||N>ee;)I&W&&(v=v.add(C)),N&W&&(x=x.add(C)),C=C.double(),I>>=W,N>>=W;return T&&(v=v.negate()),B&&(x=x.negate()),x=new h(n.mul(x.px,E.beta),x.py,x.pz),v.add(x)}multiply(m){c(m);let w=m,E,T;const{endo:I}=t;if(I){const{k1neg:B,k1:N,k2neg:v,k2:x}=I.splitScalar(w);let{p:C,f:q}=this.wNAF(N),{p:P,f:k}=this.wNAF(x);C=y.constTimeNegate(B,C),P=y.constTimeNegate(v,P),P=new h(n.mul(P.px,I.beta),P.py,P.pz),E=C.add(P),T=q.add(k)}else{const{p:B,f:N}=this.wNAF(w);E=B,T=N}return h.normalizeZ([E,T])[0]}multiplyAndAddUnsafe(m,w,E){const T=h.BASE,I=(N,v)=>v===ee||v===W||!N.equals(T)?N.multiplyUnsafe(v):N.multiply(v),B=I(this,w).add(I(m,E));return B.is0()?void 0:B}toAffine(m){const{px:w,py:E,pz:T}=this,I=this.is0();m==null&&(m=I?n.ONE:n.inv(T));const B=n.mul(w,m),N=n.mul(E,m),v=n.mul(T,m);if(I)return{x:n.ZERO,y:n.ZERO};if(!n.eql(v,n.ONE))throw new Error("invZ was invalid");return{x:B,y:N}}isTorsionFree(){const{h:m,isTorsionFree:w}=t;if(m===W)return!0;if(w)return w(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:m,clearCofactor:w}=t;return m===W?this:w?w(h,this):this.multiplyUnsafe(t.h)}toRawBytes(m=!0){return this.assertValidity(),r(h,this,m)}toHex(m=!0){return he(this.toRawBytes(m))}}h.BASE=new h(t.Gx,t.Gy,n.ONE),h.ZERO=new h(n.ZERO,n.ONE,n.ZERO);const S=t.nBitLength,y=Mc(h,t.endo?Math.ceil(S/2):S);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:a}}function Zc(e){const t=Gr(e);return Ve(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Yc(e){const t=Zc(e),{Fp:n,n:r}=t,s=n.BYTES+1,o=2*n.BYTES+1;function a(g){return ee<g&&g<n.ORDER}function c(g){return M(g,r)}function u(g){return It(g,r)}const{ProjectivePoint:d,normPrivateKeyToScalar:f,weierstrassEquation:h,isWithinCurveOrder:S}=Kc({...t,toBytes(g,b,_){const R=b.toAffine(),O=n.toBytes(R.x),U=Ue;return _?U(Uint8Array.from([b.hasEvenY()?2:3]),O):U(Uint8Array.from([4]),O,n.toBytes(R.y))},fromBytes(g){const b=g.length,_=g[0],R=g.subarray(1);if(b===s&&(_===2||_===3)){const O=J(R);if(!a(O))throw new Error("Point is not on curve");const U=h(O);let G=n.sqrt(U);const j=(G&W)===W;return(_&1)===1!==j&&(G=n.neg(G)),{x:O,y:G}}else if(b===o&&_===4){const O=n.fromBytes(R.subarray(0,n.BYTES)),U=n.fromBytes(R.subarray(n.BYTES,2*n.BYTES));return{x:O,y:U}}else throw new Error(`Point of length ${b} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),y=g=>he(we(g,t.nByteLength));function A(g){const b=r>>W;return g>b}function m(g){return A(g)?c(-g):g}const w=(g,b,_)=>J(g.slice(b,_));class E{constructor(b,_,R){this.r=b,this.s=_,this.recovery=R,this.assertValidity()}static fromCompact(b){const _=t.nByteLength;return b=V("compactSignature",b,_*2),new E(w(b,0,_),w(b,_,2*_))}static fromDER(b){const{r:_,s:R}=le.toSig(V("DER",b));return new E(_,R)}assertValidity(){if(!S(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!S(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:_,s:R,recovery:O}=this,U=x(V("msgHash",b));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const G=O===2||O===3?_+t.n:_;if(G>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const j=O&1?"03":"02",ne=d.fromHex(j+y(G)),re=u(G),pe=c(-U*re),_e=c(R*re),se=d.BASE.multiplyAndAddUnsafe(ne,pe,_e);if(!se)throw new Error("point at infinify");return se.assertValidity(),se}hasHighS(){return A(this.s)}normalizeS(){return this.hasHighS()?new E(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return fe(this.toDERHex())}toDERHex(){return le.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return fe(this.toCompactHex())}toCompactHex(){return y(this.r)+y(this.s)}}const T={isValidPrivateKey(g){try{return f(g),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{const g=t.randomBytes(n.BYTES+8),b=Hc(g,r);return we(b,t.nByteLength)},precompute(g=8,b=d.BASE){return b._setWindowSize(g),b.multiply(BigInt(3)),b}};function I(g,b=!0){return d.fromPrivateKey(g).toRawBytes(b)}function B(g){const b=g instanceof Uint8Array,_=typeof g=="string",R=(b||_)&&g.length;return b?R===s||R===o:_?R===2*s||R===2*o:g instanceof d}function N(g,b,_=!0){if(B(g))throw new Error("first arg must be private key");if(!B(b))throw new Error("second arg must be public key");return d.fromHex(b).multiply(f(g)).toRawBytes(_)}const v=t.bits2int||function(g){const b=J(g),_=g.length*8-t.nBitLength;return _>0?b>>BigInt(_):b},x=t.bits2int_modN||function(g){return c(v(g))},C=dt(t.nBitLength);function q(g){if(typeof g!="bigint")throw new Error("bigint expected");if(!(ee<=g&&g<C))throw new Error(`bigint expected < 2^${t.nBitLength}`);return we(g,t.nByteLength)}function P(g,b,_=k){if(["recovered","canonical"].some(ie=>ie in _))throw new Error("sign() legacy options not supported");const{hash:R,randomBytes:O}=t;let{lowS:U,prehash:G,extraEntropy:j}=_;U==null&&(U=!0),g=V("msgHash",g),G&&(g=V("prehashed msgHash",R(g)));const ne=x(g),re=f(b),pe=[q(re),q(ne)];if(j!=null){const ie=j===!0?O(n.BYTES):j;pe.push(V("extraEntropy",ie,n.BYTES))}const _e=Ue(...pe),se=ne;function mt(ie){const ge=v(ie);if(!S(ge))return;const sn=u(ge),ye=d.BASE.multiply(ge).toAffine(),Y=c(ye.x);if(Y===ee)return;const Se=c(sn*c(se+Y*re));if(Se===ee)return;let on=(ye.x===Y?0:2)|Number(ye.y&W),an=Se;return U&&A(Se)&&(an=m(Se),on^=1),new E(Y,an,on)}return{seed:_e,k2sig:mt}}const k={lowS:t.lowS,prehash:!1},H={lowS:t.lowS,prehash:!1};function $(g,b,_=k){const{seed:R,k2sig:O}=P(g,b,_);return Mr(t.hash.outputLen,t.nByteLength,t.hmac)(R,O)}d.BASE._setWindowSize(8);function te(g,b,_,R=H){var ye;const O=g;if(b=V("msgHash",b),_=V("publicKey",_),"strict"in R)throw new Error("options.strict was renamed to lowS");const{lowS:U,prehash:G}=R;let j,ne;try{if(typeof O=="string"||O instanceof Uint8Array)try{j=E.fromDER(O)}catch(Y){if(!(Y instanceof le.Err))throw Y;j=E.fromCompact(O)}else if(typeof O=="object"&&typeof O.r=="bigint"&&typeof O.s=="bigint"){const{r:Y,s:Se}=O;j=new E(Y,Se)}else throw new Error("PARSE");ne=d.fromHex(_)}catch(Y){if(Y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(U&&j.hasHighS())return!1;G&&(b=t.hash(b));const{r:re,s:pe}=j,_e=x(b),se=u(pe),mt=c(_e*se),ie=c(re*se),ge=(ye=d.BASE.multiplyAndAddUnsafe(ne,mt,ie))==null?void 0:ye.toAffine();return ge?c(ge.x)===re:!1}return{CURVE:t,getPublicKey:I,getSharedSecret:N,sign:$,verify:te,ProjectivePoint:d,Signature:E,utils:T}}function xt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Jc(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function Wr(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 Xc(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");xt(e.outputLen),xt(e.blockLen)}function Qc(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 el(e,t){Wr(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Ze={number:xt,bool:Jc,bytes:Wr,hash:Xc,exists:Qc,output:el},Et=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const tl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!tl)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function nl(e){if(typeof e!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof e}`);return new TextEncoder().encode(e)}function rl(e){if(typeof e=="string"&&(e=nl(e)),!(e instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof e})`);return e}function sl(...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 ol{clone(){return this._cloneInto()}}function al(e=32){if(Et&&typeof Et.getRandomValues=="function")return Et.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}class Kr extends ol{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,Ze.hash(t);const r=rl(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 a=0;a<o.length;a++)o[a]^=54;this.iHash.update(o),this.oHash=t.create();for(let a=0;a<o.length;a++)o[a]^=106;this.oHash.update(o),o.fill(0)}update(t){return Ze.exists(this),this.iHash.update(t),this}digestInto(t){Ze.exists(this),Ze.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:a,outputLen:c}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=a,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 Zr=(e,t,n)=>new Kr(e,t).update(n).digest();Zr.create=(e,t)=>new Kr(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function il(e){return{hash:e,hmac:(t,...n)=>Zr(e,t,sl(...n)),randomBytes:al}}const Nn=BigInt("3618502788666131213697322783095070105526743751716087489154079457884512865583"),Yr=252;function Bn(e){for(;e[0]===0;)e=e.subarray(1);const t=e.length*8-Yr,n=J(e);return t>0?n>>BigInt(t):n}function Jr(e){return typeof e=="string"&&(e=ul(e),e.length&1&&(e="0"+e)),fe(e)}const Xr=Yc({a:BigInt(1),b:BigInt("3141592653589793238462643383279502884197169399375105820974944592307816406665"),Fp:qt(BigInt("0x800000000000011000000000000000000000000000000000000000000000001")),n:Nn,nBitLength:Yr,Gx:BigInt("874739451078007766457464989774322083649278607533249481151382481072868806602"),Gy:BigInt("152666792071518830868575557812948353041420400780739481342941381225525861407"),h:BigInt(1),lowS:!1,...il(Hr),bits2int:Bn,bits2int_modN:e=>{const t=J(e).toString(16);return t.length===63&&(e=Jr(t+"0")),M(Bn(e),Nn)}});function cl(e){return V("",typeof e=="string"?Jr(e):e)}const{CURVE:Ku,ProjectivePoint:ke,Signature:Zu,utils:Yu}=Xr;function ll(e){return`0x${he(e.subarray(1)).replace(/^0+/gm,"")}`}function ul(e){return e.replace(/^0x/i,"")}const Le=[new ke(2089986280348253421170679821480865132823066470938446095505822317253594081284n,1713931329540660377023406109199410414810705867260802078187082345529207694986n,1n),new ke(996781205833008774514500082376783249102396023663454813447423147977397232763n,1668503676786377725805489344771023921079126552019160156920634619255970485781n,1n),new ke(2251563274489750535117886426533222435294046428347329203627021249169616184184n,1798716007562728905295480679789526322175868328062420237419143593021674992973n,1n),new ke(2138414695194151160943305727036575959195309218611738193261179310511854807447n,113410276730064486255102093846540133784865286929052426931474106396135072156n,1n),new ke(2379962749567351885752724891227938183011949129833673362440656643086021394946n,776496453633298175483985398648758586525933812536653089401905292063708816422n,1n)];function Qr(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 dl=Qr(Le[1],Le[2]),hl=Qr(Le[3],Le[4]);function fl(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=J(cl(e));if(!(0n<=t&&t<Xr.CURVE.Fp.ORDER))throw new Error(`PedersenArg should be 0 <= value < CURVE.P: ${t}`);return t}function kn(e,t,n){let r=fl(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 On(e,t){let n=Le[0];return n=kn(n,e,dl),n=kn(n,t,hl),ll(n.toRawBytes(!0))}const ml=dt(250),Rn=e=>J(yc(e))&ml;qt(BigInt("14474011154664525231415395255581126252639794253786371766033694892385558855681"));const pl=qt(BigInt("3618502788666131213697322783095070105623107215331596699973092056135872020481"));function gl(e,t,n){const r=e.fromBytes(Hr(Pr(`${t}${n}`)));return e.create(r)}const yl=[[3,1,1],[1,-1,1],[1,1,-2]].map(e=>e.map(BigInt));function Sl(e,t){if(Vt(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 a=0;a<r;a++){const c=[];for(let u=0;u<n;u++)c.push(gl(e.Fp,"Hades",n*a+u));s.push(c)}const o=jc({...e,t:n,sboxPower:3,reversePartialPowIdx:!0,mds:t,roundConstants:s});return o.m=n,o.rate=e.rate,o.capacity=e.capacity,o}Sl({Fp:pl,rate:2,capacity:1,roundsFull:8,roundsPartial:83},yl);const es=i.z.object({recoveryId:i.z.number()}),wl=i.z.object({feeToken:l.addressSchema,signerSignature:i.z.object({type:i.z.literal("StarknetKey"),signer:i.z.object({publicKey:l.hexSchema,r:l.hexSchema,s:l.hexSchema})})}),ts=i.z.enum(["ONGOING","COMPLETED","ERROR","CANCELLED","AWAITING_FUNDS"]),bl=i.z.object({status:ts});class El{constructor(t,n){this.apiBase=t,this.httpService=n}async startRecovery(t,n,r,s){const{r:o,s:a}=p.ec.starkCurve.sign(On(Rn(Ee.stringToBytes("utf8","starknet:recovery")),r),s),c={feeToken:n,signerSignature:{type:"StarknetKey",signer:{publicKey:r,r:p.encode.addHexPrefix(o.toString(16)),s:p.encode.addHexPrefix(a.toString(16))}}};return await this.httpService.post(`${this.apiBase}/accounts/starknet/${t}/recovery`,{body:JSON.stringify(c)},es)}async getRecovery(t,n){return(await this.httpService.get(`${this.apiBase}/accounts/starknet/${t}/recovery/${n}`)).status}async cancelRecovery(t,n,r,s){const{r:o,s:a}=p.ec.starkCurve.sign(On(Rn(Ee.stringToBytes("utf8","starknet:recovery:cancel")),r),s),c={signerSignature:{type:"StarknetKey",signer:{publicKey:r,r:p.encode.addHexPrefix(o.toString(16)),s:p.encode.addHexPrefix(a.toString(16))}}};await this.httpService.post(`${this.apiBase}/accounts/starknet/${t}/recovery/cancel`,{body:JSON.stringify(c)})}}async function Al(){if("brave"in navigator)try{return await navigator.brave.isBrave()}catch{}return!1}let At;function ns(){return At||(At=new $s.UAParser(navigator.userAgent).getResult()),At}function Me(e){return ns().browser.name===e}function Tl(){return Me("Firefox")}function vl(){return Me("Chrome")}function Il(){return Me("Safari")}function xl(){return Me("Edge")}const _l=i.z.string().refine(e=>js.validateMnemonic(e,Vs.wordlist),"Invalid seedphrase"),Gt=[{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"}],rs=async(e,t,n)=>{const r=await n.callContract({contractAddress:e,entrypoint:"balanceOf",calldata:[t]});return BigInt(p.num.toHex(p.uint256.uint256ToBN({low:r[0],high:r[1]})))},Cl=async(e,t,n)=>{const r=Gt.filter(o=>o.networkId===e);return(await Promise.allSettled(r.map(o=>t.callContract({contractAddress:o.address,entrypoint:"balanceOf",calldata:[n]})))).reduce((o,a,c)=>{if(a.status==="fulfilled"&&F.isUndefined(a.value)||a.status==="rejected"||a.value[0]==="0x0"&&a.value[1]==="0x0")return o;const u=BigInt(p.num.toHex(p.uint256.uint256ToBN({low:a.value[0],high:a.value[1]}))),d={...r[c],balance:u};return o.push(d),o},[])},Nl=async()=>Gt,Bl=({address:e,networkId:t})=>Gt.find(r=>r.address===e&&r.networkId===t),kl=({amount:e,decimals:t,unitCurrencyValue:n})=>{if(!K(e)||!K(t)||!K(n))return;const r=Number(t),s=BigInt(e)*Rt(n.toString()).value;return $e({value:s,decimals:r+Te})},Ol=({unitAmount:e,decimals:t})=>{if(e===void 0||!K(e)||t===void 0||!K(t))return;const n=Number(t);return me(e.toString(),n).value.toString()},Rl=e=>K(e)?Number(e):18,{UINT_256_MAX:Pl}=p.uint256,ss=e=>String(e)===String(Pl),zl=(e,t="$",n)=>{if(e===void 0||!K(e))return null;const r=Cr(e,n);return[t,r].filter(Boolean).join("")},os="Unlimited",Fl=({amount:e,decimals:t,symbol:n,showPlusSign:r=!1,withSymbol:s=!0,unlimitedText:o=os,prettyConfigOverrides:a})=>{if(!K(e))return null;let c,u=!1;if(ss(e))c=o;else{const f=Number(t),h=BigInt(e);u=h>0n;const S=f>0?$e({value:h,decimals:f}):h.toString();c=f>0?Nr(S,a):S}const d=[c,s&&n].filter(Boolean).join(" ");return r&&u?`+${d}`:d};var as={};function Z(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.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 Dl=Z;Z.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};Z.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};Z.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0};Z.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Z.prototype.try=function(e){this.attempt(e)};Z.prototype.start=function(e){this.attempt(e)};Z.prototype.start=Z.prototype.try;Z.prototype.errors=function(){return this._errors};Z.prototype.attempts=function(){return this._attempts};Z.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var s=this._errors[r],o=s.message,a=(e[o]||0)+1;e[o]=a,a>=n&&(t=s,n=a)}return t};(function(e){var t=Dl;e.operation=function(n){var r=e.timeouts(n);return new t(r,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(n){if(n instanceof Array)return[].concat(n);var r={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var s in n)r[s]=n[s];if(r.minTimeout>r.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],a=0;a<r.retries;a++)o.push(this.createTimeout(a,r));return n&&n.forever&&!o.length&&o.push(this.createTimeout(a,r)),o.sort(function(c,u){return c-u}),o},e.createTimeout=function(n,r){var s=r.randomize?Math.random()+1:1,o=Math.round(s*Math.max(r.minTimeout,1)*Math.pow(r.factor,n));return o=Math.min(o,r.maxTimeout),o},e.wrap=function(n,r,s){if(r instanceof Array&&(s=r,r=null),!s){s=[];for(var o in n)typeof n[o]=="function"&&s.push(o)}for(var a=0;a<s.length;a++){var c=s[a],u=n[c];n[c]=(function(f){var h=e.operation(r),S=Array.prototype.slice.call(arguments,1),y=S.pop();S.push(function(A){h.retry(A)||(A&&(arguments[0]=h.mainError()),y.apply(this,arguments))}),h.attempt(function(){f.apply(n,S)})}).bind(n,u),n[c].options=r}}})(as);var Ul=as,Ll=Ul;function Hl(e,t){function n(r,s){var o=t||{},a;"randomize"in o||(o.randomize=!0),a=Ll.operation(o);function c(f){s(f||new Error("Aborted"))}function u(f,h){if(f.bail){c(f);return}a.retry(f)?o.onRetry&&o.onRetry(f,h):s(a.mainError())}function d(f){var h;try{h=e(c,f)}catch(S){u(S,f);return}Promise.resolve(h).then(r).catch(function(y){u(y,f)})}a.attempt(d)}return new Promise(n)}var $l=Hl;const jl=l.getDefaultExportFromCjs($l);exports.TOKEN_ERROR_MESSAGES=void 0;(function(e){e.NO_TOKEN_API_URL="NO_TOKEN_API_URL is not defined",e.NO_TOKEN_PRICE_API_URL="NO_TOKEN_PRICE_API_URL is not defined",e.TOKENS_DEFI_DECOMPOSITION_URL="TOKENS_DEFI_DECOMPOSITION_URL is not defined",e.TOKENS_AIRDROPS_API_URL="TOKENS_AIRDROPS_API_URL is not defined",e.TOKEN_PARSING_ERROR="Unable to parse token data response",e.TOKEN_PRICE_PARSING_ERROR="Unable to parse token price response",e.TOKEN_DEFI_DECOMPOSITION_PARSING_ERROR="Unable to parse token defi decomposition response",e.TOKEN_PRICE_NOT_FOUND="Token price not found",e.TOKEN_NOT_FOUND="Token not found",e.TOKEN_DETAILS_NOT_FOUND="Token details not found",e.FEE_TOKEN_NOT_FOUND="Fee token not found",e.UNABLE_TO_CALCULATE_CURRENCY_VALUE="Unable to calculate currency value",e.UNSAFE_DECIMALS="Unsafe decimals in token"})(exports.TOKEN_ERROR_MESSAGES||(exports.TOKEN_ERROR_MESSAGES={}));class is extends l.BaseError{constructor(t){super(t,exports.TOKEN_ERROR_MESSAGES),this.name="TokenError"}}const Wt=i.z.union([i.z.literal("concentratedLiquidityPosition"),i.z.literal("collateralizedDebtPosition")]),cs=i.z.object({status:i.z.literal("initialising")}).or(i.z.object({status:i.z.literal("initialised"),balances:i.z.array(i.z.object({tokenAddress:l.addressSchemaArgentBackend,tokenBalance:i.z.string()}))})),xe=i.z.object({id:i.z.number(),address:l.addressSchema,brandColor:i.z.string().optional(),name:i.z.string(),symbol:i.z.string(),decimals:i.z.number(),iconUrl:i.z.string().optional(),sendable:i.z.boolean(),popular:i.z.boolean(),refundable:i.z.boolean(),listed:i.z.boolean(),tradable:i.z.boolean(),category:i.z.union([i.z.literal("tokens"),i.z.literal("currencies"),i.z.literal("savings")]),pricingId:i.z.number().optional(),dappId:i.z.string().optional(),marketData:i.z.object({marketCap:i.z.number(),marketCap24hChange:i.z.number(),dailyVolume:i.z.number(),rank:i.z.number()}).optional(),tags:i.z.array(i.z.string()).optional()}),ls=i.z.object({tokens:i.z.array(xe)}),us=xe,Kt=i.z.object({pricingId:i.z.number(),ethValue:i.z.string(),ccyValue:i.z.string(),ethDayChange:i.z.string(),ccyDayChange:i.z.string()}),Vl=i.z.object({prices:i.z.array(Kt)}),_t=i.z.object({tokenAddress:l.addressSchemaArgentBackend,principal:i.z.string(),accruedFees:i.z.string(),minPrice:i.z.string(),maxPrice:i.z.string(),currentPrice:i.z.string()}),ds=i.z.object({tokenAddress:l.addressSchema.optional(),totalBalances:i.z.record(i.z.string())}),Zt=ds.extend({tokenId:i.z.string(),data:i.z.object({poolFeePercentage:i.z.string(),tickSpacingPercentage:i.z.string().optional(),token0:_t,token1:_t})}),Ml=i.z.array(Zt),Yt=ds.extend({data:i.z.object({apy:i.z.string().optional(),group:i.z.number().optional(),collateral:i.z.boolean(),debt:i.z.boolean(),lending:i.z.boolean()})}),ql=i.z.array(Yt),hs=i.z.array(Zt.or(Yt)),fs=i.z.object({name:i.z.string(),manageUrl:i.z.string(),type:Wt,groups:i.z.record(i.z.object({name:i.z.string().optional(),healthRatio:i.z.string().optional()})).optional(),positions:hs}),ms=i.z.object({dappId:i.z.string(),products:i.z.array(fs)}),ps=i.z.object({dapps:i.z.array(ms)}),gs=i.z.object({name:i.z.string().optional(),tokenAddress:l.addressSchema,amount:i.z.string().optional(),claimUrl:i.z.string().optional(),claimStart:i.z.number(),claimEnd:i.z.number().optional()}),Gl=i.z.object({accountAddress:l.addressSchema,chain:i.z.string(),airdrops:i.z.array(gs)});class Wl{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=l.urlJoin(this.apiBase,this.TOKENS_INFO_URL,t??"","?chain=starknet"),r=await this.httpService.get(n),s=ls.safeParse(r);if(s.success)return s.data.tokens;const o=us.safeParse(r);if(o.success)return[o.data]}async fetchAddressTokenBalancesFromBackend(t,n,r){const s=l.urlJoin(this.apiBase,"activity","starknet",n,"account",t,"balance");return(await jl(async c=>{let u;try{u=await this.httpService.get(s)}catch{return c(new Error("Error fetching")),[]}const d=cs.safeParse(u);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=l.urlJoin(this.apiBase,this.TOKENS_DEFI_DECOMPOSITION_URL,t,"?chain=starknet"),r=await this.httpService.get(n);if(!ps.safeParse(r).success)throw new is({code:"TOKEN_DEFI_DECOMPOSITION_PARSING_ERROR"});return r.dapps}}const ht=i.z.object({address:l.addressSchema,networkId:i.z.string({required_error:"Network is required"})},{required_error:"BaseToken is required"});ht.required().extend({balance:i.z.string()});const ys=ht.required().extend({id:i.z.number().optional(),name:i.z.string().optional(),symbol:i.z.string().optional(),decimals:i.z.coerce.number().optional(),iconUrl:i.z.string().url("").optional().or(i.z.literal("")),pricingId:i.z.number().optional(),category:i.z.string().optional(),dappId:i.z.string().optional(),brandColor:i.z.string().optional()}),Kl=ys.extend({balance:i.z.string()}),Zl=ys.extend({currencyValue:i.z.string(),ccyDayChange:i.z.string().optional(),ethDayChange:i.z.string().optional(),unitCurrencyValue:i.z.string().optional()}),Jt=Zl.extend({...Kl.shape});i.z.array(Jt);ht.extend({...Kt.shape});ht.extend({...xe.shape});const Pn=Jt.extend({accruedFees:i.z.string(),currentPrice:i.z.string(),maxPrice:i.z.string(),minPrice:i.z.string(),principal:i.z.string()}),Ss=i.z.object({address:l.addressSchema.optional(),currencyValue:i.z.string().default("0")}),Xt=Ss.extend({poolFeePercentage:i.z.string(),tickSpacingPercentage:i.z.string().optional(),tokenId:i.z.string().optional(),unitCurrencyValueToken0:i.z.string().optional(),unitCurrencyValueToken1:i.z.string().optional(),token0:Pn,token1:Pn}),Yl=i.z.array(Xt),Jl=i.z.object({name:i.z.string().optional(),healthRatio:i.z.string().optional(),accountAddress:l.addressSchema.optional()}),Qt=Ss.extend({totalBalances:i.z.record(i.z.string()),collateral:i.z.boolean(),debt:i.z.boolean(),lending:i.z.boolean(),apy:i.z.string().optional(),group:i.z.string().optional(),unitCurrencyValue:i.z.string().optional(),positionToken:xe.or(i.z.undefined()),token:Jt.optional(),accountAddress:l.addressSchema.optional(),accountAddressGroup:i.z.string().optional()}),Xl=i.z.array(Qt),ws=Xt.or(Qt),bs=i.z.record(i.z.object({name:i.z.string().optional(),healthRatio:i.z.string().optional(),accountAddress:l.addressSchema.optional()})),Es=i.z.object({type:Wt,manageUrl:i.z.string().url().optional(),name:i.z.string(),positions:i.z.array(ws),positionsTotalValue:i.z.string(),brandColor:i.z.string().optional(),groups:bs.optional(),accountAddress:l.addressSchema}),As=i.z.array(Es),Ql=i.z.object({dappId:i.z.string(),products:As}),Ts=i.z.object({name:i.z.string().optional(),tokenAddress:l.addressSchema,token:xe.optional(),amount:i.z.string().optional(),claimUrl:i.z.string().optional(),claimStart:i.z.number(),claimEnd:i.z.number().optional()}),eu=i.z.array(Ts),vs=(e,t=18)=>me(e.replace(",","."),Number(t)),Is=i.z.string().trim().refine(e=>e!=="",{message:"Amount is required"}).refine(e=>{try{const t=vs(e).value;if(t<0n)throw new Error("Amount must be positive");if(t===0n)throw new Error("Amount can not be zero");if(t>p.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"}),tu=e=>!!Is.parse(e),nu=(e,t,n,r)=>({contractAddress:e,entrypoint:"transfer",calldata:p.CallData.compile({recipient:t,amount:Ae(Br(n,r))})}),ru=(e,t,n,r)=>({contractAddress:e,entrypoint:"transferFrom",calldata:p.CallData.compile({from_:t,to:n,tokenId:Ae(r)})}),su=(e,t,n,r)=>({contractAddress:e,entrypoint:"safeTransferFrom",calldata:p.CallData.compile({from_:t,to:n,tokenId:Ae(r),amount:Ae(1),data_len:"0"})}),xs=i.z.object({data:i.z.object({code:i.z.string().optional(),name:i.z.string().optional(),message:i.z.string()})}),ou=e=>{const t=xs.safeParse(e);if(t.success)return t.data.data.message},au=3,en=process.env.FEE_OVERHEAD?parseFloat(process.env.FEE_OVERHEAD):au,iu=1.5,et=10,tn=({estimatedFee:e,overheadMultiplier:t=en})=>{const r=p.num.toBigInt(e)*BigInt(t*et)/BigInt(et);return p.num.toHex(r)},cu=({suggestedMaxFee:e,overheadMultiplier:t=en,starknetJsOverheadMultiplier:n=iu})=>{const s=p.num.toBigInt(e)*BigInt(et)/BigInt(n*et);return tn({estimatedFee:s,overheadMultiplier:t})};exports.ESTIMATE_ERROR_MESSAGES=void 0;(function(e){e.SIMULATE_AND_REVIEW_FAILED="Missing simulation"})(exports.ESTIMATE_ERROR_MESSAGES||(exports.ESTIMATE_ERROR_MESSAGES={}));class _s extends l.BaseError{constructor(t){super(t,exports.ESTIMATE_ERROR_MESSAGES),this.name="EstimateError"}}const lu=i.z.object({type:i.z.enum(["DECLARE","DEPLOY","DEPLOY_ACCOUNT","INVOKE"]).default("INVOKE"),calls:i.z.array(l.callSchema).or(l.callSchema).optional(),calldata:i.z.array(i.z.string()).optional(),classHash:l.hexSchema.optional(),salt:l.hexSchema.optional(),signature:i.z.array(i.z.string()).optional()});function nn(e){return F.upperCase(e.unit)==="WEI"}function Cs(e){return F.upperCase(e.unit)==="FRI"}function ue(e,t){return nn(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 be(e){return nn(e)?{maxFee:e.maxFee}:{amount:e.maxAmount,pricePerUnit:e.maxPricePerUnit}}function Ye(e){return Cs({unit:e})?l.STRK_TOKEN_ADDRESS:l.ETH_TOKEN_ADDRESS}function uu(e,t,n=2){const r=BigInt(10**n),s=BigInt(Math.round(t*10**n));return e*s/r}const du=[l.STRK_TOKEN_ADDRESS],Ns=(e,t=Ps)=>{if(e.max&&"amount"in e.max)return{...e,...e.max};const n=10000n,{amount:r,pricePerUnit:s,dataGasConsumed:o=0n,dataGasPrice:a=0n}=e,c=r*s+o*a;if(c<0)throw Error("Cannot calculate max fee for negative fee");const u=p.num.toBigInt(tn({estimatedFee:c})),d=Number(u)/Number(c),f=t(d),h=BigInt(Math.trunc(f*Number(n)));return{...e,amount:r*h/n,pricePerUnit:s*h/n,dataGasConsumed:o*h/n,dataGasPrice:a*h/n}},He=e=>{const{amount:t,pricePerUnit:n,dataGasConsumed:r=0n,dataGasPrice:s=0n}=e;return t*n+r*s},Bs=e=>{if(e.max)return"maxFee"in e.max?e.max.maxFee:He(e.max)},tt=e=>{const t=Bs(e);return t||He(Ns(e))},hu=e=>{if(e.deployment&&!l.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=He(e.transactions),n=e.deployment?He(e.deployment):0n;return t+n},fu=e=>{if(e.deployment&&!l.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=e.deployment?tt(e.deployment):0n,n=tt(e.transactions);return t+n},mu=(e,t)=>[{contractAddress:e,entrypoint:"transfer",calldata:p.CallData.compile(l.transferCalldataSchema.parse({recipient:t,amount:p.uint256.bnToUint256(BigInt(1))}))}],ks=(e,t)=>{if(!e)return{transactions:{feeTokenAddress:t??l.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=l.feeEstimationSchema.parse(e[0].feeEstimation);return{transactions:{feeTokenAddress:Ye(n.unit),amount:p.num.toBigInt(n.gasUsage),pricePerUnit:p.num.toBigInt(n.gasPrice),max:be(ue(n,p.num.toBigInt)),dataGasConsumed:n.dataGasConsumed?p.num.toBigInt(n.dataGasConsumed):0n,dataGasPrice:n.dataGasPrice?p.num.toBigInt(n.dataGasPrice):0n}}}if(e.length===2){const n=l.feeEstimationSchema.parse(e[0].feeEstimation),r=l.feeEstimationSchema.parse(e[1].feeEstimation);return{deployment:{feeTokenAddress:Ye(n.unit),amount:p.num.toBigInt(n.gasUsage),pricePerUnit:p.num.toBigInt(n.gasPrice),max:be(ue(n,p.num.toBigInt)),dataGasConsumed:n.dataGasConsumed?p.num.toBigInt(n.dataGasConsumed):0n,dataGasPrice:n.dataGasPrice?p.num.toBigInt(n.dataGasPrice):0n},transactions:{feeTokenAddress:Ye(r.unit),amount:p.num.toBigInt(r.gasUsage),pricePerUnit:p.num.toBigInt(r.gasPrice),max:be(ue(r,p.num.toBigInt)),dataGasConsumed:r.dataGasConsumed?p.num.toBigInt(r.dataGasConsumed):0n,dataGasPrice:r.dataGasPrice?p.num.toBigInt(r.dataGasPrice):0n}}}throw Error("Unexpected simulation response length")},Os=({transaction:e,nonce:t,chainId:n,version:r,isDeploymentTransaction:s,cairoVersion:o,address:a,appDomain:c})=>{let u=t;s&&e.type!=="DEPLOY_ACCOUNT"&&(u=p.num.toHex(1));const d=l.ensureArray(e.calls);return{type:e.type,chainId:n,cairoVersion:o,nonce:u,version:r,account:a,calls:d,calldata:e.calldata,salt:e.salt,signature:e.signature,classHash:e.classHash,appDomain:c}},Rs=(e,t)=>{const{transactions:n}=e,r=n.map(u=>{if(!u.simulation)throw new _s({code:"SIMULATE_AND_REVIEW_FAILED"});return u}),s=r.map(u=>({...u.simulation,feeEstimation:ue(u.simulation.feeEstimation,Number)})),o=ks(s,t),[a,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:be(ue(a.simulation.feeEstimation,p.num.toBigInt))},deployment:o.deployment&&c?{...o.deployment,dataGasConsumed:o.deployment.dataGasConsumed??0n,dataGasPrice:o.deployment.dataGasPrice??0n,max:be(ue(c.simulation.feeEstimation,p.num.toBigInt))}:void 0}},pu=e=>{const t=Ns(e),n=tt(e);return{maxFee:n,resourceBounds:{l1_gas:{max_amount:p.num.toHex(n/e.pricePerUnit),max_price_per_unit:p.num.toHex(t.pricePerUnit)},l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"}}}},gu=e=>{const t=Math.sqrt(e);return isNaN(t)?Math.sqrt(2):t},Ps=e=>{const t=Math.cbrt(e);return isNaN(t)?Math.cbrt(2):t},yu=e=>e<1||isNaN(e)?1.1:Math.log(e+1)+1,Ct={Transfer:p.hash.getSelectorFromName("Transfer"),Approval:p.hash.getSelectorFromName("Approval")},zs=(e,t,n)=>{for(const r of e){const{events:s,internal_calls:o}=r;for(const a of s)for(const c of a.keys)c===Ct.Approval&&t.push({tokenAddress:l.addressSchema.parse(r.contract_address),owner:a.data[0],spender:a.data[1],value:p.uint256.uint256ToBN({low:a.data[2],high:a.data[3]}).toString()}),c===Ct.Transfer&&n.push({tokenAddress:l.addressSchema.parse(r.contract_address),from:a.data[0],to:a.data[1],value:p.uint256.uint256ToBN({low:a.data[2],high:a.data[3]}).toString()});o&&zs(o,t,n)}return{approvals:t,transfers:n}},Su=/(0x[a-fA-F0-9]+)\s*\('(.*?)'\)/,wu=e=>{if(!F.isString(e))return;const t=e.match(Su);if(t&&!F.isEmpty(t[2]))return t[2]},bu=[l.STRK_TOKEN_ADDRESS];function ft({address:e}){return bu.some(t=>l.isEqualAddress(e,t))}function Eu(e){return e?tr().some(t=>l.isEqualAddress(t,e)):!1}function Nt(e){return ft({address:e})?p.constants.TRANSACTION_VERSION.V3:p.constants.TRANSACTION_VERSION.V1}function Au(e){return ft({address:e})?p.constants.TRANSACTION_VERSION.F3:p.constants.TRANSACTION_VERSION.F1}function Tu(e,t){return p.isSierra(t.contract)?ft({address:e})?p.constants.TRANSACTION_VERSION.V3:p.constants.TRANSACTION_VERSION.V2:p.constants.TRANSACTION_VERSION.V1}var Bt;(function(e){e.SIMULATE_AND_REVIEW_FAILED="Something went wrong fetching review",e.NO_CALLS_FOUND="No calls found",e.ONCHAIN_FEE_ESTIMATION_FAILED="Failed to estimate fees onchain"})(Bt||(Bt={}));class Oe extends l.BaseError{constructor(t){super(t,Bt),this.name="ReviewError"}}class vu{constructor(t,n){this.apiBase=t,this.httpService=n}async getLabels(){const t=l.urlJoin(this.apiBase,"reviewer","labels");return await this.httpService.get(t)}async getWarnings(){const t=l.urlJoin(this.apiBase,"reviewer","warnings/reasons");return await this.httpService.get(t)}async simulateAndReview(t,n,r,s,o){const a=n.some(c=>c.type==="DEPLOY_ACCOUNT");try{if(!("getChainId"in t))throw new Error("MISSING_METHOD");const c=Nt(r),u=a?"0x0":await t.getNonce(),d=await t.getChainId(),f={transactions:n.map(m=>({...Os({transaction:m,nonce:u,version:c,chainId:d,isDeploymentTransaction:a,appDomain:s,cairoVersion:t.cairoVersion,address:t.address}),type:m.type}))},h=l.urlJoin(this.apiBase,"reviewer","transactions","v2","review","starknet"),S=await this.httpService.post(h,{headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(f)},l.simulateAndReviewSchema);if(S.transactions.some(m=>l.isTransactionSimulationError(m)))return S;const A=Rs(S,r);return{...S,enrichedFeeEstimation:A}}catch(c){return console.error(c),this.fallbackToOnchainFeeEstimation({transactions:n,account:t,isDeploymentTransaction:a,feeTokenAddress:r,accountDeployTransaction:o})}}getCallsFromTx(t){let n;return t.calls&&(n=l.ensureArray(t.calls)),n}async fallbackToOnchainFeeEstimation({transactions:t,account:n,isDeploymentTransaction:r,feeTokenAddress:s,accountDeployTransaction:o}){try{const a=r?this.getCallsFromTx(t[1]):this.getCallsFromTx(t[0]);if(!a)throw new Oe({code:"NO_CALLS_FOUND"});const c=await this.fetchFeesOnchain({starknetAccount:n,calls:a,isDeployed:!r,feeTokenAddress:s,accountDeployTransaction:o});return{transactions:[],enrichedFeeEstimation:c,isBackendDown:!0}}catch(a){throw console.error(a),new Oe({message:`${a}`,code:"SIMULATE_AND_REVIEW_FAILED"})}}async fetchFeesOnchain({starknetAccount:t,calls:n,isDeployed:r,feeTokenAddress:s,accountDeployTransaction:o}){try{const a=Nt(s),c={transactions:{feeTokenAddress:s,amount:0n,pricePerUnit:0n,dataGasConsumed:0n,dataGasPrice:0n}};if(!r&&o){if("estimateFeeBulk"in t){const u=[{type:p.TransactionType.DEPLOY_ACCOUNT,payload:{classHash:o.classHash,addressSalt:o.salt,constructorCalldata:o.calldata,contractAddress:t.address}},{type:p.TransactionType.INVOKE,payload:n}],[d,f]=await t.estimateFeeBulk(u,{version:a}).catch(h=>{throw console.error(h),h});if(!d.gas_consumed||!d.gas_price||!f.gas_consumed||!f.gas_price)throw new Oe({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:f.gas_consumed,pricePerUnit:f.gas_price,dataGasConsumed:f.data_gas_consumed,dataGasPrice:f.data_gas_price}}}else{const{gas_consumed:u,gas_price:d,data_gas_consumed:f,data_gas_price:h}=await t.estimateFee(n,{skipValidate:!0,version:a});if(!u||!d)throw new Oe({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:"Missing gas_consumed or gas_price"});c.transactions={feeTokenAddress:s,amount:u,pricePerUnit:d,dataGasConsumed:f,dataGasPrice:h}}return c}catch(a){throw new Oe({code:"ONCHAIN_FEE_ESTIMATION_FAILED",message:`${a}`})}}}const Iu=i.z.object({reason:i.z.string(),severity:i.z.string().optional(),title:i.z.string(),description:i.z.string().optional()}),xu=["account-upgrade","approve","set-approval-for-all","swap","transfer"],_u=Object.values(p.constants.TRANSACTION_VERSION),Cu=i.z.string().default("0x3").refine(e=>{const t=p.num.toBigInt(e);return _u.map(n=>p.num.toBigInt(n)).includes(t)}).transform(e=>p.num.toHex(e));function Nu(e){if(e===p.constants.TRANSACTION_VERSION.V3||e===p.constants.TRANSACTION_VERSION.F3)throw Error("Only txv1 is supported")}const Bu=e=>({showBalanceChange:L.useMemo(()=>{const n=e==null?void 0:e.some(s=>!F.isEmpty(s.transfers)),r=e==null?void 0:e.some(s=>!F.isEmpty(s.approvals));return e&&(n||r)},[e])}),qe=e=>e?e.filter(t=>t.token.type==="erc20"):[],ku=e=>L.useMemo(()=>qe(e),[e]),Ou=e=>qe(e).length>0,Ru=e=>qe(e).some(n=>n.amount>0n),Pu=e=>qe(e).some(n=>n.amount<0n),rn=e=>e?e.filter(t=>t.token.type==="erc721"):[],zu=e=>L.useMemo(()=>rn(e),[e]),Fs=e=>rn(e).length>0,Fu=e=>L.useMemo(()=>Fs(e),[e]),Du=(e,t)=>L.useMemo(()=>e&&t?[{contractAddress:e.address,entrypoint:"transfer",calldata:p.CallData.compile({recipient:t,amount:Ae(e.balance)})}]:[],[e,t]),Uu=({apiData:{apiBaseUrl:e,apiHeaders:t},address:n,network:r,transactionReviewEnabled:s=!0,transactions:o})=>{const a=L.useCallback(async()=>{if(!n||!r)return;if(!e)throw"Transaction review endpoint is not defined";const u=l.urlJoin(e,"reviewer/transactions/review/starknet"),d=F.isArray(o)?o:[o],f={network:r,account:n,calls:d};return Pt(u,{method:"POST",headers:{"Content-Type":"application/json",...t},body:JSON.stringify(f)})},[n,r,o]),c=L.useMemo(()=>Ms({transactions:o,address:n,network:r}),[o,n,r]);return jn(!!s,[c,"transactionReview"],a)},Lu=e=>{if(!e)return{};const t=e.assessment==="warn"&&e.reason!=="contract_is_not_verified",n=e.reason?` (Reason: ${F.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}},Ds=e=>{var t;if(e){for(const n of e.reviews)if(((t=n.activity)==null?void 0:t.type)==="swap")return n}},Hu=e=>{},$u=(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}},ju=e=>!!Ds(e),Vu=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}}},Us=async({feeTokenAddress:e,calls:t,selectedAccount:n,transactionReviewService:r,appDomain:s,accountDeployTransaction:o})=>{const a={type:"INVOKE",calls:l.ensureArray(t)};if(!n||!e)return;const c=o?[o,a]:[a];return{result:await r.simulateAndReview(n,c,e,s,o)}},Ls=async(e,t,n,r)=>{var S,y,A,m,w,E;let s=!1;const o=t.transactions.find(T=>{var I,B;return(B=(I=T==null?void 0:T.simulation)==null?void 0:I.summary)==null?void 0:B.find(N=>N.sent)});if(!o||!((S=o.simulation)!=null&&S.summary))return s;const a=o.simulation.summary.filter(T=>T.sent).map(T=>T.token.address);if(!(((y=t.enrichedFeeEstimation)==null?void 0:y.transactions.feeTokenAddress)&&a.includes((A=t.enrichedFeeEstimation)==null?void 0:A.transactions.feeTokenAddress))||!((w=(m=t.enrichedFeeEstimation)==null?void 0:m.transactions)!=null&&w.max))return s;const u="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(!u||!d)return s;const f=await rs(n,e,r)??0n;return BigInt(f)>u+BigInt(d)||(s=!0),s},Mu=()=>L.useCallback(async({feeTokenAddress:t,calls:n,selectedAccount:r,transactionReviewService:s,appDomain:o,accountDeployPayload:a,provider:c})=>{if(!r)return;const u=await Us({feeTokenAddress:t,calls:n,selectedAccount:r,transactionReviewService:s,appDomain:o,accountDeployTransaction:Hs(a)});if(!u||!u.result||!t)return;const d=await Ls(r.address,u.result,t,c);return{...u.result,isSendingMoreThanBalanceAndGas:d}},[]),Hs=e=>e?{type:"DEPLOY_ACCOUNT",calldata:e.calldata,classHash:l.hexSchema.parse(e.class_hash),salt:l.hexSchema.parse(e.salt),signature:[]}:void 0;exports.BaseError=l.BaseError;exports.ETH_TOKEN_ADDRESS=l.ETH_TOKEN_ADDRESS;exports.EventEmitterProvider=l.EventEmitterProvider;Object.defineProperty(exports,"HTTP_ERROR_MESSAGE",{enumerable:!0,get:()=>l.HTTP_ERROR_MESSAGE});exports.HttpError=l.HttpError;Object.defineProperty(exports,"MultiSigner",{enumerable:!0,get:()=>l.MultiSigner});exports.STANDARD_DEVNET_ACCOUNT_CLASS_HASH=l.STANDARD_DEVNET_ACCOUNT_CLASS_HASH;exports.STRK_TOKEN_ADDRESS=l.STRK_TOKEN_ADDRESS;exports.TXV1_ACCOUNT_CLASS_HASH=l.TXV1_ACCOUNT_CLASS_HASH;exports.TXV1_MULTISIG_CLASS_HASH=l.TXV1_MULTISIG_CLASS_HASH;exports.TXV3_ACCOUNT_CLASS_HASH=l.TXV3_ACCOUNT_CLASS_HASH;exports.TXV3_MULTISIG_CLASS_HASH=l.TXV3_MULTISIG_CLASS_HASH;exports.abiEntrySchema=l.abiEntrySchema;exports.abiSchema=l.abiSchema;exports.addOwnersCalldataSchema=l.addOwnersCalldataSchema;exports.addPluginCalldataSchema=l.addPluginCalldataSchema;exports.addressInputCharactersAndLengthSchema=l.addressInputCharactersAndLengthSchema;exports.addressInputSchema=l.addressInputSchema;exports.addressOrDomainInputSchema=l.addressOrDomainInputSchema;exports.addressOrDomainSchema=l.addressOrDomainSchema;exports.addressOrEmptyUndefinedSchema=l.addressOrEmptyUndefinedSchema;exports.addressSchema=l.addressSchema;exports.addressSchemaArgentBackend=l.addressSchemaArgentBackend;exports.addressSchemaBase=l.addressSchemaBase;exports.addressSchemaLooseLength=l.addressSchemaLooseLength;exports.addressSchemaStrictLength=l.addressSchemaStrictLength;exports.apiWalletResponseSchema=l.apiWalletResponseSchema;exports.argentNameSchema=l.argentNameSchema;exports.bigNumberSchema=l.bigNumberSchema;exports.bigNumberishSchema=l.bigNumberishSchema;exports.booleanToStringSchema=l.booleanToStringSchema;exports.builtinsSchema=l.builtinsSchema;exports.byteCodeSchema=l.byteCodeSchema;exports.cairo1EventSchema=l.cairo1EventSchema;exports.cairoAssemblySchema=l.cairoAssemblySchema;exports.cairoVersionSchema=l.cairoVersionSchema;exports.callDetailsSchema=l.callDetailsSchema;exports.callSchema=l.callSchema;exports.calldataSchema=l.calldataSchema;exports.changeGuardianCalldataSchema=l.changeGuardianCalldataSchema;exports.changeThresholdCalldataSchema=l.changeThresholdCalldataSchema;exports.compiledContractClassSchema=l.compiledContractClassSchema;exports.compiledSierraCasmSchema=l.compiledSierraCasmSchema;exports.compiledSierraSchema=l.compiledSierraSchema;exports.compressedProgramSchema=l.compressedProgramSchema;exports.constructorCallDataSchemaC0=l.constructorCallDataSchemaC0;exports.constructorCallDataSchemaC1V1=l.constructorCallDataSchemaC1V1;exports.contractEntryPointFieldsSchema=l.contractEntryPointFieldsSchema;exports.ensureArray=l.ensureArray;exports.entryPointsByTypeSchema=l.entryPointsByTypeSchema;exports.escapeGuardianCalldataSchema=l.escapeGuardianCalldataSchema;exports.eventAbiSchema=l.eventAbiSchema;exports.eventEntrySchema=l.eventEntrySchema;exports.executeOnPluginCalldataSchema=l.executeOnPluginCalldataSchema;exports.feltSchema=l.feltSchema;exports.formatFullAddress=l.formatFullAddress;exports.formatTruncatedAddress=l.formatTruncatedAddress;exports.formatTruncatedSignerKey=l.formatTruncatedSignerKey;exports.formatTruncatedString=l.formatTruncatedString;exports.functionAbiSchema=l.functionAbiSchema;exports.functionAbiTypeSchema=l.functionAbiTypeSchema;exports.getAddressFromArgentName=l.getAddressFromArgentName;exports.getSignerForMultiSigner=l.getSignerForMultiSigner;exports.hexSchema=l.hexSchema;exports.hexSchemaBase=l.hexSchemaBase;exports.implementationSchema=l.implementationSchema;exports.includesAddress=l.includesAddress;exports.isAddress=l.isAddress;exports.isArgentName=l.isArgentName;exports.isEqualAddress=l.isEqualAddress;exports.isEqualArgentName=l.isEqualArgentName;exports.isEqualStarknetDomainName=l.isEqualStarknetDomainName;exports.isEqualStarknetId=l.isEqualStarknetId;exports.isStarknetDomainName=l.isStarknetDomainName;exports.isStarknetId=l.isStarknetId;exports.isValidAddress=l.isValidAddress;exports.isZeroAddress=l.isZeroAddress;exports.legacyContractClassSchema=l.legacyContractClassSchema;exports.legacyEventSchema=l.legacyEventSchema;exports.multiTypeSchema=l.multiTypeSchema;exports.normalizeAddress=l.normalizeAddress;exports.normalizeAddressOrDomain=l.normalizeAddressOrDomain;exports.normalizeArgentName=l.normalizeArgentName;exports.normalizeStarknetId=l.normalizeStarknetId;exports.programSchema=l.programSchema;exports.pythonicHintsSchema=l.pythonicHintsSchema;exports.rawArgsArraySchema=l.rawArgsArraySchema;exports.rawArgsObjectSchema=l.rawArgsObjectSchema;exports.rawArgsSchema=l.rawArgsSchema;exports.removeOwnersCalldataSchema=l.removeOwnersCalldataSchema;exports.removePluginCalldataSchema=l.removePluginCalldataSchema;exports.replaceSignerCalldataSchema=l.replaceSignerCalldataSchema;exports.sierraContractEntryPointFieldsSchema=l.sierraContractEntryPointFieldsSchema;exports.sierraEntryPointsByTypeSchema=l.sierraEntryPointsByTypeSchema;exports.sierraProgramDebugInfoSchema=l.sierraProgramDebugInfoSchema;exports.starknetDomainNameSchema=l.starknetDomainNameSchema;exports.starknetIdSchema=l.starknetIdSchema;exports.stringToBooleanSchema=l.stringToBooleanSchema;exports.structAbiSchema=l.structAbiSchema;exports.transferCalldataSchema=l.transferCalldataSchema;exports.uint256Schema=l.uint256Schema;exports.useEmitEvent=l.useEmitEvent;exports.useEventEmitter=l.useEventEmitter;exports.useEventEmitterContext=l.useEventEmitterContext;exports.useEventListener=l.useEventListener;exports.useIsEventEmitterEnabled=l.useIsEventEmitterEnabled;exports.validChecksumAddressSchema=l.validChecksumAddressSchema;exports.validateAddressRangeSchema=l.validateAddressRangeSchema;exports.ARGENT_ACCOUNT_CONTRACT_CLASS_HASHES=X;exports.ARGENT_MULTISIG_CONTRACT_CLASS_HASHES=ze;exports.AddSmartAccountResponseSchema=qs;exports.AddSmartAcountRequestSchema=Gs;exports.BackendAccountSchema=zn;exports.BackendNftService=qi;exports.C0_PROXY_CONTRACT_CLASS_HASHES=Zn;exports.CacheService=wo;exports.DEFAULT_TOKEN_DECIMALS=Te;exports.DateService=bo;exports.EstimateError=_s;exports.EventsBySelector=Ct;exports.FEE_OVERHEAD=en;exports.HTTPService=rt;exports.KnownDappsBackendService=ei;exports.OnchainRecoveryService=El;exports.PRETTY_UNLIMITED=os;exports.ResolveNameService=ni;exports.SWRService=Ao;exports.StarknetAddressService=No;exports.TokenError=is;exports.TokenServiceWeb=Wl;exports.TransactionReviewServiceWeb=vu;exports.airdropSchema=Ts;exports.apiAccountTokenBalancesSchema=cs;exports.apiAirdropSchema=gs;exports.apiCollateralizedDebtPositionSchema=Yt;exports.apiCollateralizedDebtPositionsSchema=ql;exports.apiConcentratedLiquidityPositionSchema=Zt;exports.apiConcentratedLiquidityPositionsSchema=Ml;exports.apiDefiDecompositionProduct=fs;exports.apiDefiDecompositionProducts=hs;exports.apiDefiDecompositionSchema=ms;exports.apiDefiDecompositionToken=_t;exports.apiDefiPositionsSchema=ps;exports.apiPriceDataResponseSchema=Vl;exports.apiPriceDetailsSchema=Kt;exports.apiTokenInfoResponseSchema=us;exports.apiTokenInfoSchema=xe;exports.apiTokensInfoResponseSchema=ls;exports.apiTransactionReviewActivityType=xu;exports.apiUnclaimedRewardsSchema=Gl;exports.argentBackendNetworkIdSchema=Un;exports.argentMaxFee=tn;exports.argentNetworkIdSchema=Dn;exports.bigDecimal=So;exports.buildAccountDeployTransaction=Hs;exports.buildConstructorCalldata=sr;exports.buildDummyTx=mu;exports.calculateCubeRootAdjustment=Ps;exports.calculateNonLinearAdjustment=yu;exports.calculateSqrtAdjustment=gu;exports.castFeeEstimation=ue;exports.checkGasFeeBalance=Ls;exports.classHashSupportsTxV3=Eu;exports.collateralizedDebtGroupSchema=Jl;exports.collateralizedDebtPositionSchema=Qt;exports.collateralizedDebtPositionsSchema=Xl;exports.concentratedLiquidityPositionSchema=Xt;exports.concentratedLiquidityPositionsSchema=Yl;exports.convertTokenAmountToCurrencyValue=kl;exports.convertTokenUnitAmountWithDecimals=Ol;exports.dappContractSchema=ir;exports.dappLinkSchema=ar;exports.daysBetween=Ri;exports.decodeBase58=_r;exports.decodeBase58Array=Oi;exports.defiDappsProductsSchema=Ql;exports.defiPositionSchema=ws;exports.defiPositionTypeSchema=Wt;exports.defiProductSchema=Es;exports.defiProductsSchema=As;exports.denyTxV3=Nu;exports.encodeBase58=xr;exports.encodeBase58Array=ki;exports.ensureDecimals=Rl;exports.entryPointToHumanReadable=$i;exports.equalNft=Ji;exports.erc20TransferTransaction=nu;exports.erc721SafeTransferFromTransaction=su;exports.erc721TransferFromTransaction=ru;exports.estimatedFeeToMaxFeeTotal=tt;exports.estimatedFeeToMaxResourceBounds=pu;exports.estimatedFeeToTotal=He;exports.estimatedFeesToMaxFeeTotal=fu;exports.estimatedFeesToTotal=hu;exports.feeTokenNeedsTxV3Support=ft;exports.fetchData=Pt;exports.fetcherError=Pe;exports.findImplementationForAccount=Ja;exports.findTransfersAndApprovals=zs;exports.formatAddress=Dt;exports.generateAvatarImage=De;exports.getAccountContractAddress=or;exports.getAccountDeploymentPayload=rr;exports.getAccountIdentifier=Io;exports.getAddressFromStarkName=Kn;exports.getArgentAccountClassHashes=Tt;exports.getArgentAccountClassHashesWithTxV3Support=tr;exports.getArgentAccountWithMultiSignerClassHashes=er;exports.getBackendTimeNowSeconds=Co;exports.getBackendTimeSeconds=Vn;exports.getCallFromStarkName=Wn;exports.getChainIdFromNetworkId=Mn;exports.getColor=vr;exports.getDapplandLinkForDapp=ur;exports.getDapplandUrlForDapp=ti;exports.getDisplayWarnAndReasonForTransactionReview=Lu;exports.getERC20Transactions=qe;exports.getERC721Transactions=rn;exports.getEstimatedFeeFromBulkSimulation=ks;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFee=Rs;exports.getInitials=Tr;exports.getLastCairo0ArgentAccountClassHash=Ka;exports.getLatestArgentAccountClassHash=Qn;exports.getLatestArgentMultisigClassHash=Wa;exports.getLatestLedgerAccountClassHash=Ya;exports.getLedgerAccountClassHashes=Za;exports.getMessageFromTrpcError=ou;exports.getNFTTransferActivity=Hu;exports.getNetworkAccountImageUrl=Bi;exports.getNftPicture=Yi;exports.getPayloadFromTransaction=Os;exports.getPrettyRpcError=wu;exports.getRecoverySchema=bl;exports.getReviewForTransactions=Us;exports.getSimulationTxVersionFromFeeToken=Au;exports.getStarknetIdContractAddressFromNetworkId=Gn;exports.getTokenBalance=rs;exports.getTokens=Nl;exports.getTokensBalances=Cl;exports.getTransactionReviewActivityOfType=$u;exports.getTransactionReviewHasSwap=ju;exports.getTransactionReviewSwap=Ds;exports.getTransactionReviewWithType=Vu;exports.getTxVersionFromFeeToken=Nt;exports.getTxVersionFromFeeTokenForDeclareContract=Tu;exports.getUAParserResult=ns;exports.getUint256CalldataFromBN=Ae;exports.getWatermarkedMaxFeeTotal=Bs;exports.hasERC20Transactions=Ou;exports.hasERC721Transactions=Fs;exports.hasIncomingERC20Transactions=Ru;exports.hasOutgoingERC20Transactions=Pu;exports.id=Ar;exports.inputAmountSchema=Is;exports.isAccountV4=Zs;exports.isAccountV5=Ks;exports.isAccountV6=Ws;exports.isAllowedAddressHexInputValue=Di;exports.isAllowedNumericInputValue=Ui;exports.isArgentBackendNetworkId=Xs;exports.isArgentNetworkId=Js;exports.isBraveBrowser=Al;exports.isBrowser=Me;exports.isChromeBrowser=vl;exports.isContractDeployed=zi;exports.isEdgeBrowser=xl;exports.isEqualImplementation=nr;exports.isFRI=Cs;exports.isFeatureEnabled=Pi;exports.isFirefoxBrowser=Tl;exports.isNumeric=K;exports.isSafariBrowser=Il;exports.isUnlimitedAmount=ss;exports.isValidInputAmount=tu;exports.isWEI=nn;exports.knownDappSchema=cr;exports.knownDappsSchema=lr;exports.modifySnjsFeeOverhead=cu;exports.multiplyBigIntByFloat=uu;exports.nameProviderResolutionSchema=hr;exports.nameResolutionAddressSchema=fr;exports.nameResolutionAddressesSchema=pr;exports.nameResolutionStarknetIdSchema=Ft;exports.nameResolutionStarknetIdsSchema=dr;exports.nonNullable=Fi;exports.parseAmount=vs;exports.parseAmountValue=Br;exports.pluralise=Li;exports.postData=To;exports.preferencesEndpointPayload=Ys;exports.preferencesSchema=Fn;exports.prettifyCurrencyNumber=Cr;exports.prettifyCurrencyValue=zl;exports.prettifyNumber=Ut;exports.prettifyNumberConfig=ct;exports.prettifyTokenAmount=Fl;exports.prettifyTokenNumber=Nr;exports.productGroupsSchema=bs;exports.providersNamesSchema=mr;exports.readFileAsString=Hi;exports.recoveryBodySchema=wl;exports.recoveryStatusSchema=ts;exports.seedphraseSchema=_l;exports.starkNameToCallDataDomain=qn;exports.startRecoverySchema=es;exports.stripAddressZeroPadding=Ir;exports.swrRefetchDisabledConfig=_o;exports.toMax=be;exports.tokensRequireTxV3Support=du;exports.transactionReviewTransactionsSchema=lu;exports.transactionReviewWarningSchema=Iu;exports.trpcErrorSchema=xs;exports.txVersionSchema=Cu;exports.unclaimedRewardsSchema=eu;exports.unitToFeeTokenAddress=Ye;exports.urlWithQuery=ji;exports.useBalanceChange=Bu;exports.useCollection=Ki;exports.useConditionallyEnabledSWR=jn;exports.useDebounce=Xa;exports.useDebouncedValue=Qa;exports.useERC20Transactions=ku;exports.useERC721Transactions=zu;exports.useHasERC721Transaction=Fu;exports.useMaxAmountTransaction=Du;exports.useNft=Zi;exports.useNfts=Wi;exports.useToken=Bl;exports.useTransactionReview=Uu;exports.useTransactionReviewV2webFetcher=Mu;exports.voidify=Vi;exports.withPolling=vo;
package/dist/index.mjs CHANGED
@@ -267,6 +267,8 @@ class Ye {
267
267
  });
268
268
  if (!a.ok)
269
269
  throw new X(a.statusText, a.status, await a.json());
270
+ if (a.status === 204)
271
+ return {};
270
272
  const i = await a.json();
271
273
  if (r)
272
274
  try {
@@ -3212,8 +3214,7 @@ class ld {
3212
3214
  return (await this.httpService.get(`${this.apiBase}/accounts/starknet/${e}/recovery/${n}`)).status;
3213
3215
  }
3214
3216
  async cancelRecovery(e, n, r, s) {
3215
- const { r: o, s: a } = Sn.starkCurve.sign(Zn(Yn(xn("utf8", "starknet:cancel")), r), s), i = {
3216
- feeToken: n,
3217
+ const { r: o, s: a } = Sn.starkCurve.sign(Zn(Yn(xn("utf8", "starknet:recovery:cancel")), r), s), i = {
3217
3218
  signerSignature: {
3218
3219
  type: "StarknetKey",
3219
3220
  signer: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@argent/x-shared",
3
- "version": "1.29.0",
3
+ "version": "1.29.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/argentlabs/x-shared.git"