@initia/interwovenkit-react 2.4.1 → 2.4.3
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.cjs +3 -3
- package/dist/index.js +4903 -4373
- package/dist/styles.css +1 -1
- package/dist/styles.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ir=require("@privy-io/cross-app-connect/rainbow-kit"),De=require("wagmi"),T=require("@tanstack/react-query"),b=require("@initia/utils"),V=require("bignumber.js"),$=require("ramda"),ve=require("@lukemorales/query-key-factory"),G=require("ky"),x=require("react"),ae=require("@cosmjs/encoding"),Gc=require("@mysten/bcs"),H=require("jotai"),Ar=require("@amplitude/analytics-browser"),t=require("react/jsx-runtime"),Vn=require("@cosmjs/amino/build/signdoc"),nt=require("@cosmjs/crypto"),ft=require("ethers"),Zo=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),Kn=require("@cosmjs/amino"),Us=require("@cosmjs/proto-signing"),Do=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Qc=require("cosmjs-types/google/protobuf/any"),Kt=require("viem"),qa=require("@cosmjs/math"),Ce=require("@cosmjs/stargate"),Pa=require("@cosmjs/tendermint-rpc"),Sr=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Ue=require("cosmjs-types/cosmos/tx/v1beta1/tx"),sn=require("@initia/amino-converter"),Yc=require("cosmjs-types/cosmos/auth/v1beta1/auth"),Zt=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),Da=require("cosmjs-types/cosmos/tx/v1beta1/service"),Ve=require("date-fns"),Ra=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),Tr=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),J=require("radix-ui"),Be=require("usehooks-ts"),$r=require("react-error-boundary"),q=require("clsx"),we=require("react-hook-form"),Te=require("@base-ui/react/dialog"),Zc=require("xss"),S=require("@initia/icons-react"),gt=require("@react-spring/web"),Os=require("change-case"),wt=require("@base-ui/react/select"),ho=require("@base-ui/react/collapsible"),Ba=require("nanoid"),Jc=require("react-dom"),Xc=require("psl"),el=require("jotai/utils"),Er=require("react-merge-refs"),tl=require("react-number-format"),nl=require("react-intersection-observer"),sl=require("@noble/hashes/sha3"),Jt=require("@noble/hashes/utils"),ol=require("qr-code-styling"),vt=require("@base-ui/react"),$t=require("@base-ui/react/tabs"),fn=require("@base-ui/react/popover"),Fa=require("cosmjs-types/cosmos/bank/v1beta1/tx");function al(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return n.default=e,Object.freeze(n)}const Jo=al(Ar),on=1.4,Mr=1.05,Lr={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",glyphUrl:"https://glyph.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",lockStakeModuleAddress:"0x3a886b32a802582f2e446e74d4a24d1d7ed01adf46d2a8f65c5723887e708789",minityUrl:"https://portfolio-api.minity.xyz",dexUrl:"https://dex-api.initia.xyz",vipUrl:"https://vip-api.initia.xyz",civitiaUrl:"https://api.civitia.org",theme:"dark"},rl={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",glyphUrl:"https://glyph.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",lockStakeModuleAddress:"0x81c3ea419d2fd3a27971021d9dd3cc708def05e5d6a09d39b2f1f9ba18312264",minityUrl:"https://portfolio-api.minity.xyz",dexUrl:"https://dex-api.initiation-2.initia.xyz",vipUrl:"https://vip-api.testnet.initia.xyz",civitiaUrl:"https://api.civitia.org",theme:"dark",disableAnalytics:!0},Xo="cmbq1ozyc006al70lx4uciz0q",Wn={id:Xo,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},il=Ir.toPrivyWalletConnector(Wn),cl=Ir.toPrivyWallet(Wn),qr=x.createContext(null);function se(){const e=x.useContext(qr);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const z={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function ll(e){if(e instanceof G.HTTPError){const{response:n}=e,s=n.headers.get("content-type")??"";if($.includes("application/json",s))try{const o=await n.json();if(o.message)return o.message}catch{return e.message}try{return await n.text()}catch{return e.message}}if(e instanceof Error){if($.path(["code"],e)===4001||$.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const n=$.path(["error","message"],e),s=$.path(["cause","message"],e),o=$.path(["shortMessage"],e);return n||s||o||e.message}return String(e)}async function Ct(e){return new Error(await ll(e))}const Vs=ve.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function fs(e){const n=$.path([0,"address"],e);if(!n)throw new Error("URL not found");return n}function dl(e){const{chain_id:n,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,c=o||s,l=a?.png??"",{rpc:d,rest:m,["json-rpc"]:u,indexer:h}=r,f=fs(d),g=fs(m),p=fs(h),_=i?.minitia?.type==="minievm"?fs(u):void 0;return{...e,chainId:n,name:c,logoUrl:l,rpcUrl:f,restUrl:g,indexerUrl:p,jsonRpcUrl:_}}function ue(){const{defaultChainId:e,registryUrl:n,customChain:s}=se(),{data:o}=T.useSuspenseQuery({queryKey:Vs.list(n).queryKey,queryFn:()=>G.create({prefixUrl:n}).get("chains.json").json(),select:a=>(s?[s,...a.filter(i=>i.chain_id!==s.chain_id)]:a).map(dl).toSorted($.descend(i=>i.chainId===e)),staleTime:z.MINUTE});return o}function Pr(){const{registryUrl:e}=se(),{data:n}=T.useSuspenseQuery({queryKey:Vs.profiles(e).queryKey,queryFn:()=>G.create({prefixUrl:e}).get("profiles.json").json(),staleTime:z.MINUTE});return n}function Ke(){const e=oe(),n=ue(),s=Pr();return o=>{const a=n.find(i=>i.chain_id===o);if(a)return a;const r=s.find(i=>i.chain_id===o);if(!r)throw new Error(`Chain not found: ${o}`);return{chain_id:r.chain_id,chain_name:r.name,pretty_name:r.pretty_name,network_type:e.network_type,bech32_prefix:"init",fees:{fee_tokens:[]},apis:{rpc:[],rest:[],indexer:[]},chainId:o,name:r.pretty_name,logoUrl:r.logo,rpcUrl:"",restUrl:"",indexerUrl:"",jsonRpcUrl:""}}}function rt(e){return Ke()(e)}function cn(){const{defaultChainId:e}=se();return rt(e)}function oe(){const n=ue().find(s=>s.metadata?.is_l1);if(!n)throw new Error("Layer 1 not found");return n}function Dr(){return({chainId:e})=>T.queryOptions({queryKey:Vs.prices(e).queryKey,queryFn:()=>G.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:z.SECOND})}function Nt(e){const n=Dr();return T.useQuery(n(e))}function ea(){const e=ue(),n=Dr();return T.useQueries({queries:e.map(s=>n(s))})}const ul=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
|
|
2
2
|
<circle fill="#2F3337" cx="30" cy="30" r="30"/>
|
|
3
3
|
<path fill="#757C82" d="M26.328 34.288v-.48c0-2.048 1.024-2.816 4.128-4.16 3.104-1.28 3.712-1.952 3.712-3.488v-.128c0-1.664-1.344-2.464-4.224-2.464-2.816 0-4.416.736-4.768 3.296h-5.248c.416-5.536 4.416-7.584 9.888-7.584h.352c6.208 0 9.28 2.496 9.28 6.24v.352c0 3.392-1.28 4.96-5.376 6.592-1.504.64-2.048 1.024-2.208 1.824h-5.536ZM26.168 42v-5.152h5.792V42h-5.792Z"/>
|
|
4
|
-
</svg>`,
|
|
4
|
+
</svg>`,ml=encodeURIComponent(ul),ta=`data:image/svg+xml;utf8,${ml}`,zn=ve.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,n)=>[e,n],resource:(e,n)=>[e.chainId,n.denom],denom:(e,n)=>[e,n],metadata:(e,n)=>[e,n]});function hl(e){const{base:n,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:c,traces:l}=e,d=o.find(u=>u.denom===a)?.exponent??o.find(u=>u.denom===n)?.exponent??$.head(o)?.exponent??0,m=r?.png??"";return{denom:n,symbol:s,decimals:d,logoUrl:m,name:i,address:c,traces:l}}function Rr(){const e=T.useQueryClient();return n=>{const s=n?.metadata?.assetlist;return T.queryOptions({queryKey:zn.list(s).queryKey,queryFn:async()=>s?G.get(s).json():{assets:[]},select:({assets:o})=>{if(!n)return[];const a=o.map(hl);for(const r of a)e.setQueryData(zn.item(n.chainId,r.denom).queryKey,r);return a},staleTime:z.MINUTE})}}function Dt(e){const n=Rr(),{data:s}=T.useSuspenseQuery(n(e));return s}function Xn(){const e=ue(),n=Rr();return T.useQueries({queries:e.map(s=>n(s))})}function xt(e){const n=Dt(e),s=oe(),o=Dt(s),a=Fr(e);return r=>{const i=n.find(l=>l.denom===r);if(i)return i;const c=o.find(l=>l.denom===a(r));return c?{...c,denom:r}:{denom:r,symbol:"",decimals:0,logoUrl:ta}}}function Br(e,n){const s=xt(n),a=T.useQueryClient().getQueryData(zn.item(n.chainId,e).queryKey);return a||s(e)}function Fr(e){const n=oe(),s=Dt(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const r=s.find(i=>i.denom===o)??s.find(i=>i.traces?.some(c=>c.counterparty.base_denom===o));if(r?.traces){for(const i of r.traces)if(i.counterparty.chain_name===n.chain_name)return i.counterparty.base_denom}}const a=n.metadata?.ibc_channels?.find(({chain_id:r,version:i})=>r===e.chain_id&&i==="ics20-1")?.channel_id;return a?b.getIbcDenom(a,o):""}}function Ts(e,n){const s=oe(),o=G.create({prefixUrl:s.restUrl}),a=n?.failSoft??!1,r=T.useSuspenseQueries({queries:e.map(i=>({queryFn:async()=>{try{return await o.get("initia/move/v1/denom",{searchParams:{metadata:i}}).json()}catch(c){if(a)return{denom:""};throw c}},queryKey:[...zn.denom(s.restUrl,i).queryKey,a],select:c=>[i,c.denom],staleTime:z.INFINITY}))});return new Map(r.map(({data:i})=>i))}function fl(e){return e.pagination?.next_key??null}async function Ks(e,n,s){const o=G.create(n),a=async(r,i)=>{const c=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),l=c[s]??[],d=fl(c),m=[...r,...l];return d?a(m,d):m};return a([],null)}const Ua="usernames";function gl({restUrl:e,moduleAddress:n}){const{viewFunction:s}=b.createMoveClient(e);async function o(i){if(!b.InitiaAddress.validate(i))return null;const c=await s({moduleAddress:n,moduleName:Ua,functionName:"get_name_from_address",typeArgs:[],args:[ae.toBase64(b.InitiaAddress(i,32).bytes)]});return c?c+".init":null}function a(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function r(i){if(!a(i))return null;const c=await s({moduleAddress:n,moduleName:Ua,functionName:"get_address_from_name",typeArgs:[],args:[Gc.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return c?b.InitiaAddress(c).bech32:null}return{restUrl:e,getUsername:o,getAddress:r,validateUsername:a}}const Ws=ve.createQueryKeys("interwovenkit:account",{username:(e,n)=>[e,n],address:(e,n)=>[e,n],balances:(e,n)=>[e,n],txs:(e,n)=>[e,n]});function Ur(){const{restUrl:e}=oe(),{usernamesModuleAddress:n}=se();return gl({restUrl:e,moduleAddress:n})}function Or(){const e=te();return n=>T.queryOptions({queryKey:Ws.balances(n.restUrl,e||"").queryKey,queryFn:()=>e?Ks(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:n.restUrl},"balances"):[],staleTime:z.SECOND})}function es(e){const n=Or(),{data:s}=T.useSuspenseQuery(n(e));return s}function pl(){const e=ue(),n=Or();return T.useQueries({queries:e.map(s=>n(s))})}function _l(e){const n=es(e),s=Dt(e),o=xt(e),a=Fr(e),{data:r}=Nt(e),i=l=>e.fees.fee_tokens.some(d=>d.denom===l),c=l=>s.some(d=>d.denom===l);return $.sortWith([$.descend(({denom:l})=>a(l)==="uinit"),$.descend(({denom:l})=>i(l)),$.descend(({value:l})=>l),$.descend(({denom:l})=>c(l)),({balance:l},{balance:d})=>V(d).comparedTo(l)??0,$.descend(({symbol:l})=>l.toLowerCase())],n.filter(({amount:l})=>!V(l).isZero()).map(({amount:l,denom:d})=>{const m=o(d),u=r?.find(({id:f})=>f===m?.denom)?.price??0,h=V(l).times(u).div(V(10).pow(m.decimals)).toNumber();return{...m,balance:l,price:u,value:h}}))}const Vr=x.createContext(null);function zs(){return x.useContext(Vr)}function Kr(){const{location:e}=zs();return e}function Hs(){const{path:e}=Kr();return e}function it(){const{state:e={}}=Kr();return e}function Wr(){const{history:e}=zs();return e}function Ie(){const{navigate:e}=zs();return e}function na(){const{reset:e}=zs();return e}const jn=({to:e,state:n,shouldReset:s,children:o,onClick:a,...r})=>{const i=Ie(),c=na(),l=d=>{d.preventDefault(),a?.(d),s?c(e,n):i(e,n)};return t.jsx("button",{type:"button",...r,onClick:l,children:o})},zr=({children:e,initialEntry:n})=>{const[s,o]=x.useState([n??{path:"/"}]),a=s[s.length-1],r=x.useCallback((c,l)=>{o(d=>{if(typeof c=="string")return[...d,{path:c,state:l}];const m=d.length+c;if(m<1)return d;const u=$.take(m,d);return l!==void 0?$.adjust(m-1,h=>({...h,state:l}),u):u})},[]),i=x.useCallback((c,l)=>{o([{path:c,state:l}])},[]);return t.jsx(Vr.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},xl="c33b940c24c17e95f7d9d525d508ac61";function yl(){const{disableAnalytics:e}=se();x.useEffect(()=>{e||Jo.init(xl,{autocapture:!1})},[e])}function bl(){const{connector:e}=De.useAccount(),{defaultChainId:n,disableAnalytics:s}=se();x.useEffect(()=>{const o=new Ar.Identify;e?.name&&o.set("connector",e.name),n&&o.set("defaultChainId",n),Jo.identify(o)},[n,e?.name,s])}function kn(){const e=Hs();return x.useCallback((s,o)=>{Jo.track(s,{path:e,...o})},[e])}function wl(e){return e.type==="initia/PubKeyEthSecp256k1"}const jl={...Kn.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function Hr(e){if(wl(e)){const n=Do.PubKey.fromPartial({key:ae.fromBase64(e.value)});return Qc.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(Do.PubKey.encode(n).finish())})}return Us.encodePubkey(e)}function sa(e){if(e.length!==33||e[0]!==2&&e[0]!==3)throw new Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03");return{type:jl.ethsecp256k1,value:ae.toBase64(e)}}function Gr(e,n){if(n.length!==64)throw new Error("Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s.");return{pub_key:sa(e),signature:ae.toBase64(n)}}function vl(e){return`Enable Auto-Sign for InterwovenKit
|
|
5
5
|
|
|
6
6
|
Origin: ${e}
|
|
7
7
|
|
|
8
|
-
Sign this message to create a dedicated signing wallet for auto-sign transactions. This wallet will only be used to sign transactions on your behalf when auto-sign is enabled.`}async function el(e,n){const s=Et.hexToBytes(e);if(s.length!==65)throw new Error(`Invalid signature length: expected 65 bytes (r: 32, s: 32, v: 1), got ${s.length}`);const o=s.slice(0,64),a=Et.hexToBytes(Et.keccak256(Et.bytesToHex(o))),r=Qe.Bip39.encode(a),i=await Qe.Bip39.mnemonicToSeed(r),c=Qe.stringToPath("m/44'/60'/0'/0/0"),{privkey:l}=Qe.Slip10.derivePath(Qe.Slip10Curve.Secp256k1,i,c),d=await Qe.Secp256k1.makeKeypair(l),m=Qe.Secp256k1.compressPubkey(d.pubkey),h=d.pubkey.slice(1),f=Et.bytesToHex(h),p=Et.keccak256(f),g=Et.hexToBytes(p).slice(-20),_=se.toBech32(n,g);return{privateKey:l,publicKey:m,address:_}}function es(e,n){return`${e}:${n}`}const Pn=U.atom(null),An=U.atom({}),Sn=U.atom({}),$s=U.atom({}),Na=U.atom(0),tl="autosign:";function nl(e,n){const s=e.get(Na)+1;return e.set(Na,s),`${n}:${s}`}function ps(e,n){return e.get($s)[n]}function sl(e,n,s){e.set($s,o=>({...o,[n]:s}))}function kr(e,n){e.set($s,s=>{const o={...s};return delete o[n],o})}function ol(e,n,s){const o=ps(e,n);!o||o.token!==s||kr(e,n)}function al(e,n,s){const o=ps(e,n);return!!o&&o.token===s}function ts(e,n){return e.get(Sn)[n]}function rl(e,n,s){e.set(Sn,o=>({...o,[n]:s}))}function il(e,n){e.set(Sn,s=>{const o={...s};return delete o[n],o})}function cl(e,n,s){e.set(An,o=>({...o,[n]:s}))}function ll(e,n){e.set(An,s=>{const o={...s};return delete o[n],o})}function Ir(e,n){return`${tl}${e}:${n}`}function dl(e,n,s){try{return e.getItem(Ir(n,s))}catch{return null}}function ul(e,n,s,o){try{e.setItem(Ir(n,s),o)}catch{}}function Ar(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function Uo(e,n){const s=Ar();if(s)return dl(s,e,n)}function ml(e,n,s){const o=Ar();o&&ul(o,e,n,s)}function hl(e){return{publicKey:e.publicKey,address:e.address}}function gs(e){e&&e.fill(0)}function Sr(e){e.set($s,{});const n=e.get(Sn);for(const s of Object.values(n))gs(s);e.set(Sn,{}),e.set(An,{})}function fl(e,n){return e!==""&&e!==n}function pl(){const e=X(),n=U.useStore(),s=x.useRef(e);x.useEffect(()=>{const o=s.current;fl(o,e)&&Sr(n),s.current=e},[n,e])}class gl{constructor(n,s){this.wallet=n,this.privateKey=s}async getAccounts(){return[{address:this.wallet.address,algo:"ethsecp256k1",pubkey:this.wallet.publicKey}]}async signAmino(n,s){if(this.wallet.address!==n)throw new Error("Signer address does not match the derived wallet address");const o=Cn.escapeCharacters(Cn.sortedJsonStringify(s)),a=ct.ethers.hashMessage(o),r=se.fromHex(a.replace("0x","")),i=await Qe.Secp256k1.createSignature(r,this.privateKey),c=new Uint8Array([...i.r(32),...i.s(32)]),l=Nr(this.wallet.publicKey,c);return{signed:s,signature:l}}}function Es(){const e=U.useStore(),{signMessageAsync:n}=Ee.useSignMessage(),s=Fe(),o=X();return{deriveWallet:async d=>{if(!o)throw new Error("User address not available");const m=s(d),u=es(o,m.bech32_prefix),h=e.get(An)[u];if(h&&ts(e,u))return h;const f=ps(e,u);if(f)return f.promise;const p=nl(e,u),g=(async()=>{try{const _=window.location.origin,y=Xc(_),j=await n({message:y}),b=await el(j,m.bech32_prefix),w=hl(b);if(al(e,u,p))return rl(e,u,b.privateKey),cl(e,u,w),w;throw gs(b.privateKey),new Error("Wallet derivation was cancelled")}finally{ol(e,u,p)}})();return sl(e,u,{promise:g,token:p}),g},getWallet:d=>{if(!o)return;const m=s(d),u=es(o,m.bech32_prefix);if(ts(e,u))return e.get(An)[u]},getWalletPrivateKey:d=>{if(!o)return;const m=s(d),u=es(o,m.bech32_prefix);return ts(e,u)},clearWallet:d=>{if(!o)return;const m=s(d),u=es(o,m.bech32_prefix),h=ts(e,u);ps(e,u)&&kr(e,u),gs(h),il(e,u),ll(e,u)},clearAllWallets:()=>{Sr(e)}}}function Tr({granteeAddress:e,messages:n,encoder:s}){return[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:Mo.MsgExec.fromPartial({grantee:e,msgs:n.map(o=>({typeUrl:o.typeUrl,value:s.encode(o)}))})}]}async function _l({chainId:e,granterAddress:n,messages:s,fee:o,memo:a,derivedWallet:r,privateKey:i,encoder:c,signWithEthSecp256k1:l}){const d=Tr({granteeAddress:r.address,messages:s,encoder:c}),m={...o,granter:n},u=new Uint8Array(i),h=new gl(r,u);try{return await l(e,r.address,d,m,a,{customSigner:h})}finally{gs(u)}}const at="interwovenkit",Ie="uinit",Ye="INIT",Be=6,xl="uoinit",yl="omniINIT",$r="https://app.initia.xyz",Oo=`${$r}/liquidity/my`,jl=`${$r}/vip/my`,wl=1e3,Er=60*wl,Mr=60*Er,ka=24*Mr,ae={PUBLIC_KEY:`${at}:public-key`,BRIDGE_SRC_CHAIN_ID:`${at}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${at}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${at}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${at}:bridge:dst-denom`,BRIDGE_QUANTITY:`${at}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${at}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${at}:bridge:route-type`,BRIDGE_HISTORY:`${at}:bridge:history`,OP_REMINDER:`${at}:op:reminder`},Lr=U.atom(!1),qr=U.atom(!1);function jt(){const e=Ro(),[n,s]=U.useAtom(Lr),o=U.useSetAtom(qr),a=un();return{isDrawerOpen:n,openDrawer:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function mn(){const e=Ro(),[n,s]=U.useAtom(qr),o=U.useSetAtom(Lr),a=un();return{isModalOpen:n,openModal:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function Pr(){const e=Ce(),{closeDrawer:n}=jt(),{closeModal:s}=mn(),{disconnect:o}=Ee.useDisconnect(),{clearAllWallets:a}=Es();return()=>{e("/blank"),n(),s(),o(),a(),localStorage.removeItem(ae.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(ae.BRIDGE_SRC_DENOM),localStorage.removeItem(ae.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(ae.BRIDGE_DST_DENOM),localStorage.removeItem(ae.BRIDGE_QUANTITY),localStorage.removeItem(ae.BRIDGE_SLIPPAGE_PERCENT)}}function bl(){const e=At(),n=Gt(),{openModal:s}=mn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,srcOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??n.chainId,d=a.map(m=>({denom:m,chainId:l}));s("/deposit",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function vl(){const e=At(),n=Gt(),{openModal:s}=mn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,dstOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??n.chainId,d=a.map(m=>({denom:m,chainId:l}));s("/withdraw",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function Cl(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:n}=yo.PubKey.decode(e.value);return Nn.encodeSecp256k1Pubkey(n)}return Cs.decodeOptionalPubkey(e)}function Nl({typeUrl:e,value:n}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=kc.BaseAccount.decode(n),i=Cl(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return je.accountFromAny({typeUrl:e,value:n})}const Dr="/cosmos.feegrant.v1beta1.MsgGrantAllowance",Br="/cosmos.feegrant.v1beta1.AllowedMsgAllowance",Rr="cosmos-sdk/AllowedMsgAllowance";function kl(){const e=Wt.aminoConverters[Dr];if(!e)throw new Error("Missing base converter for MsgGrantAllowance");return e}const _s=kl();function Fr(e){if(e.typeUrl===Br){const n=Rt.AllowedMsgAllowance.decode(e.value);if(!n.allowance)throw new Error("AllowedMsgAllowance is missing nested allowance");return{type:Rr,value:{allowance:Fr(n.allowance),allowed_messages:n.allowedMessages}}}return _s.toAmino({granter:"",grantee:"",allowance:e}).allowance}function Ur(e){if(e.type===Rr){const n=e.value;if(!n.allowance)throw new Error("AllowedMsgAllowance amino value is missing nested allowance");const s=Ur(n.allowance);return{typeUrl:Br,value:Rt.AllowedMsgAllowance.encode(Rt.AllowedMsgAllowance.fromPartial({allowance:s,allowedMessages:n.allowed_messages??n.allowedMessages??[]})).finish()}}return _s.fromAmino({granter:"",grantee:"",allowance:e}).allowance}const Il={...Wt.aminoConverters,[Dr]:{..._s,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:Fr(e.allowance)}:_s.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:Ur(e.allowance)})}},Dn=()=>{const e=ee();return new Cs.Registry([...Wt.protoRegistry,...e.protoTypes??[]])},Bn=()=>{const e=ee();return new je.AminoTypes({...Il,...e.aminoConverters})};class Al{constructor(n,s,o){this.address=n,this.signMessage=s,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const n=`${ae.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(n);if(s)return this.cachedPublicKey=se.fromHex(s),se.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(n,se.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(n,se.toHex(a)),a}async getPublicKeyFromRestApi(){try{const s=(await z.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return s?se.fromBase64(s):null}catch{return null}}async getPublicKey(){const n="Sign this message to identify your Initia account.",s=await this.signMessage(n),o=ct.ethers.hashMessage(n),a=ct.ethers.SigningKey.recoverPublicKey(o,s);return Qe.Secp256k1.compressPubkey(se.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(n,s){if(this.address!==n)throw new Error("Signer address does not match the provided address");const o=Cn.escapeCharacters(Cn.sortedJsonStringify(s)),a=await this.signMessage(o),r=se.fromHex(a.replace("0x","")).subarray(0,-1),c=Qe.Secp256k1Signature.fromFixedLength(r).toFixedLength(),l=Nr(await this.getCachedPublicKey(),c);return{signed:s,signature:l}}}function Or(){const e=Dn(),n=Bn(),s=Rn(),o=Ms();return async function(a,r,i,c,l,d){const m=d?.customSigner??s;if(!m)throw new Error("Signer not initialized");const u=await o(a),{accountNumber:h,sequence:f}=await Vr({getSequence:N=>u.getSequence(N),signerAddress:r,incrementSequence:d?.incrementSequence??0,allowMissingAccount:!!d?.customSigner}),[p]=await m.getAccounts(),g=Cr(Fo(p.pubkey)),_=rr.SignMode.SIGN_MODE_EIP_191,y=i.map(N=>n.toAmino(N)),j=Cn.makeSignDoc(y,c,a,l,h,f),{signature:b,signed:w}=await m.signAmino(r,j),I={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:w.msgs.map(N=>n.fromAmino(N)),memo:l}},E=e.encode(I),M=xa.Int53.fromString(w.fee.gas).toNumber(),A=xa.Int53.fromString(w.sequence).toNumber(),L=Cs.makeAuthInfoBytes([{pubkey:g,sequence:A}],w.fee.amount,M,w.fee.granter,w.fee.payer,_);return De.TxRaw.fromPartial({bodyBytes:E,authInfoBytes:L,signatures:[se.fromBase64(b.signature)]})}}function Sl(e,n){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(n):!1}async function Vr({getSequence:e,signerAddress:n,incrementSequence:s,allowMissingAccount:o}){try{const{accountNumber:a,sequence:r}=await e(n);return{accountNumber:a,sequence:r+s}}catch(a){if(o&&Sl(a,n))return{accountNumber:0,sequence:s};throw a}}function Rn(){const e=X(),{signMessageAsync:n}=Ee.useSignMessage(),s=re();return x.useMemo(()=>new Al(e,o=>n({message:o}),s.restUrl),[e,n,s.restUrl])}const Zs=new Map,us=new Map;function Tl(e,n){const s=`${e}:${n}`;us.delete(s)}function Vo(){const e=Fe();return async n=>{if(Zs.has(n))return Zs.get(n);const{rpcUrl:s}=e(n),o=await ya.Comet38Client.create(new ya.HttpClient(s));return Zs.set(n,o),o}}function Ms(){const e=Dn(),n=Bn(),s=Rn(),o=X(),a=Vo();return async r=>{const i=`${o}:${r}`;if(us.has(i))return us.get(i);if(!s)throw new Error("Signer not initialized");const c=await a(r),l=await je.SigningStargateClient.createWithSigner(c,s,{registry:e,aminoTypes:n,accountParser:Nl,broadcastPollIntervalMs:500});return us.set(i,l),l}}function Kr(){const{connector:e}=Ee.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new ct.BrowserProvider(await e.getProvider())}}function Wr(e){return e.filter(n=>n.authorization["@type"].includes("GenericAuthorization")).filter(n=>!!n.authorization.msg)}function zr(e){return e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance"?e.allowance?.expiration:e.expiration}function $l(e){if(e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance")return e.allowedMessages??e.allowed_messages??[]}function Hr(){const e=X(),n=Fe();return{fetchFeegrant:async(r,i)=>{if(!e)return null;const c=n(r),l=z.create({prefixUrl:c.restUrl});try{const{allowance:d}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${i}`).json();return d}catch(d){if(d instanceof z.HTTPError&&[404,500].includes(d.response.status))return null;throw d}},fetchGrants:async(r,i)=>{if(!e)return[];const c=n(r),l=z.create({prefixUrl:c.restUrl}),{grants:d}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:i}}).json();return d},fetchAllGrants:async r=>{const i=n(r),c=e;if(!c)return[];const l=`cosmos/authz/v1beta1/grants/granter/${c}`,d=await Is(l,{prefixUrl:i.restUrl},"grants");return Wr(d)}}}const xs=ye.createQueryKeys("interwovenkit:autosign",{expirations:(e,n,s)=>[e,n,s],grants:(e,n)=>[e,n]}),El=4,Gr=4;function Ml(e){return Object.entries(e).sort(([n],[s])=>n.localeCompare(s)).map(([n,s])=>`${n}:${[...s].sort().join(",")}`).join("|")}function Ko(){const e=ee(),n=Gt(),{enableAutoSign:s,defaultChainId:o}=e;if(!s)return{[o]:[]};if(typeof s!="boolean")return s;switch(n.metadata?.minitia?.type){case"minievm":return{[o]:["/minievm.evm.v1.MsgCall"]};case"miniwasm":return{[o]:["/cosmwasm.wasm.v1.MsgExecuteContract"]};default:return{[o]:["/initia.move.v1.MsgExecute"]}}}function Ll(){const{data:e}=Ls(),n=Ko();return(s,o)=>{const a=o.every(i=>{const c=n[s];return c?c.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function Ls(){const e=X(),n=Ko(),s=Ml(n),{fetchFeegrant:o,fetchAllGrants:a}=Hr();return $.useQuery({queryKey:xs.expirations(e,s,n).queryKey,queryFn:()=>ql({initiaAddress:e,messageTypes:n,fetchAllGrants:a,fetchFeegrant:o}),staleTime:K.MINUTE,retry:1})}async function ql(e){const{initiaAddress:n,messageTypes:s,fetchAllGrants:o,fetchFeegrant:a}=e;if(!n)return{expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}};const r={},i={},c={},l={},d=[];for(const[u,h]of Object.entries(s))r[u]=null,i[u]=void 0,c[u]=!1,h.length>0&&d.push([u,h]);if(d.length===0)return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i};const m=await Qr(d,El,async([u,h])=>{const f=Uo(n,u);try{const p=await o(u),g=f===void 0?p:f===null?[]:p.filter(I=>I.grantee===f),_=Bl(g,h);if(_.length===0)return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0};const y=await Dl({chainId:u,candidates:_,fetchFeegrant:a,concurrency:Gr});if(!y)return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0};const j=y.grantee.grants.filter(I=>h.includes(I.authorization.msg)).map(I=>I.expiration),b=zr(y.feegrant.allowance),w=[...j,b],C=Wo(w);return{chainId:u,expectedAddress:f,expiration:C?new Date(C):void 0,grantee:y.grantee.grantee}}catch{return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0}}});for(const u of m)l[u.chainId]=u.expectedAddress,r[u.chainId]=u.expiration,i[u.chainId]=u.grantee;for(const[u]of d)c[u]=Rl({expiration:r[u],grantee:i[u],expectedAddress:l[u]});return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i}}async function Qr(e,n,s){const o=new Array(e.length),a=Math.max(1,n);let r=0;const i=Array.from({length:Math.min(a,e.length)},async()=>{for(;;){const c=r;if(r+=1,c>=e.length)return;o[c]=await s(e[c],c)}});return await Promise.all(i),o}function Pl(e){const n=$l(e.allowance);if(!(!n||n.includes("/cosmos.authz.v1beta1.MsgExec")))return!1;const o=zr(e.allowance);if(!o)return!0;const a=new Date(o);return!Number.isNaN(a.getTime())&&Re.isFuture(a)}async function Dl(e){const{chainId:n,candidates:s,fetchFeegrant:o,concurrency:a=Gr}=e,r=await Qr(s,a,async i=>{const c=await o(n,i.grantee);return c&&Pl(c)?{grantee:i,feegrant:c}:null});for(const i of r)if(i)return i;return null}function Bl(e,n){if(n.length===0)return[];const s=new Map;for(const a of e){const r=s.get(a.grantee)||[];r.push({authorization:a.authorization,expiration:a.expiration}),s.set(a.grantee,r)}const o=[];for(const[a,r]of s){const i=r.filter(d=>!d.expiration||Re.isFuture(new Date(d.expiration))),c=i.map(d=>d.authorization.msg);n.every(d=>c.includes(d))&&o.push({grantee:a,grants:i})}return o}function Rl(e){const{expiration:n,grantee:s,expectedAddress:o}=e,a=o===void 0?!!s:!!s&&o===s;switch(n){case null:return!1;case void 0:return a;default:return a&&Re.isFuture(n)}}function Fl(){const{data:e,refetch:n}=Ls();x.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&Re.isFuture(c));if(o.length===0)return;const a=Wo(o);if(!a)return;const r=a.getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{n()},r+100);return()=>clearTimeout(i)},[e,n])}function Wo(e){const n=e.filter(s=>s!==void 0);if(n.length!==0)return[...n].sort((s,o)=>new Date(s).getTime()-new Date(o).getTime())[0]}const Yr=x.createContext(null),qs=()=>x.useContext(Yr);class Zr extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(n,s,o,a,r,i,c){super(n),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=c}}const Ul=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Js=new Map;function Ol(e){const n=e.match(Ul);if(!n)return null;const[,s,o,a]=n;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:a.replace(/^0+/,"")||"0"}}async function Vl(e,n,s){const o=`${e}:${n}`;if(Js.has(o))return Js.get(o);try{const a=n==="0x1"?"0x1.json":`${e}/${n}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await z.get(r).json();return Js.set(o,i),i}catch{return null}}function Kl(e,n,s,o,a,r,i){return new Zr(e,n,s,o,a,r,i)}async function nn(e,n,s){if(!n.metadata?.is_l1&&n.metadata?.minitia?.type!=="minimove")return await _t(e);const o=Ol(e.message);if(!o)return await _t(e);const a=await Vl(n.chain_name,o.moduleAddress,s),r=`0x${parseInt(o.errorCode,10).toString(16)}`,i=`Failed with code ${r} in module ${o.moduleName} at ${o.moduleAddress}`,c=a?.[o.moduleName]?.[o.errorCode],l=c||i,d=!!c;return Kl(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const Wl=10;function Jr(){const e=X();return(n,s)=>$.queryOptions({queryKey:As.txs(n.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Wl},{txs:a}=await z.create({prefixUrl:n.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:K.SECOND})}function zl(e,n){const s=Jr();return $.useSuspenseQuery(s(e,n))}function Hl(e,n){const s=e.flatMap((o,a)=>(n[a]??[]).map(i=>({...i,chain:o})));return T.sortWith([T.descend(o=>new Date(o.timestamp).getTime())])(s)}const Gl=()=>{const e=de(),n=Jr(),s=$.useQueries({queries:e.map(i=>n(i,{enabled:!0}))}),o=s.map(T.prop("data")),a=Hl(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};async function Xr(e){if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:s}=await z.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return s.toSorted(T.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const r=o==="uinit"?1:dr;return{amount:B(a).times(r).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:s})=>{if(T.isNil(s))throw new Error(`${n} has no price`);return{amount:String(s),denom:n}})}function zo(e){const{data:n}=$.useSuspenseQuery({queryKey:ks.gasPrices(e).queryKey,queryFn:()=>Xr(e),staleTime:K.SECOND});return n}function Ho(e){const n=X(),{data:s}=zl(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const o=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return o;try{return s.find(({tx:r})=>r.auth_info.signer_infos.some(i=>v.InitiaAddress.equals(n,ct.computeAddress(`0x${se.toHex(Qe.Secp256k1.uncompressPubkey(se.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const ei="approve",Ps=U.atom(),ti=U.atom(null),Ql=zt,Yl=1.5;function Zl({gasPrices:e,preferredFeeDenom:n,fallbackFeeDenom:s,allowedFeeDenoms:o}){const a=o?.length?e.filter(({denom:i})=>o.includes(i)):e;if(a.length===0)throw new Error("No allowed gas price tokens available for auto-sign");const r=i=>i?a.find(c=>c.denom===i):void 0;return r(n)??r(s)??a[0]}function Jl({simulatedGas:e,gasPrices:n,preferredFeeDenom:s,fallbackFeeDenom:o,policy:a}){if(!Number.isFinite(e)||e<=0)throw new Error("Auto-sign gas simulation failed");const{gasMultiplier:r,maxGasMultiplierFromSim:i,allowedFeeDenoms:c}=a;if(r<=0||i<=0||r>i)throw new Error("Invalid auto-sign gas multiplier policy");const l=Math.ceil(e*r),d=Zl({gasPrices:n,preferredFeeDenom:s,fallbackFeeDenom:o,allowedFeeDenoms:c});return je.calculateFee(l,je.GasPrice.fromString(`${d.amount}${d.denom}`))}function Xl({derivedAddress:e,messages:n,encoder:s}){return{messages:Tr({granteeAddress:e,messages:n,encoder:s})}}function ed(e){if(!(e instanceof Error))return!1;const n=e.message.toLowerCase(),s=e.code,o=e.cause?.code,a=n.includes("user rejected")||n.includes("rejected the request")||n.includes("user denied")||n.includes("denied by user")||n.includes("user cancelled")||n.includes("user canceled")||n.includes("cancelled by user")||n.includes("canceled by user");return s===4001||s==="ACTION_REJECTED"||o===4001||o==="ACTION_REJECTED"||a}async function td({queryClient:e,messages:n,memo:s,pubkey:o,sequence:a}){const r=je.createProtobufRpcClient(e),i=new ja.ServiceClientImpl(r),c=De.Tx.fromPartial({authInfo:De.AuthInfo.fromPartial({fee:De.Fee.fromPartial({}),signerInfos:[{publicKey:o,sequence:BigInt(a),modeInfo:{single:{mode:rr.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:De.TxBody.fromPartial({messages:Array.from(n),memo:s}),signatures:[new Uint8Array]});return await i.Simulate(ja.SimulateRequest.fromPartial({txBytes:De.Tx.encode(c).finish()}))}function nd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e}async function sd({address:e,chainId:n,messages:s,memo:o,fee:a,preferredFeeDenom:r,client:i,allowAutoSign:c=!0,allowWalletDerivation:l=!1},d){const m=async()=>d.signWithEthSecp256k1(n,e,s,a,o),u=(_,y)=>{d.onAutoSignFallback?.({chainId:n,reason:_,errorMessage:nd(y)})};if(!c)return m();if(!d.validateAutoSign(n,s))return u("validation_failed"),m();let f=d.getWallet(n),p=!1;if(!f&&l)try{f=await d.deriveWallet(n)}catch(_){if(ed(_))throw _;u("derive_wallet_failed",_),p=!0,f=void 0}if(!f)return p||u("missing_derived_wallet"),m();let g;try{const _=i??await d.getSigningClient(n);g=await d.computeAutoSignFee({chainId:n,messages:s,memo:o,derivedWallet:f,preferredFeeDenom:r,fallbackFeeDenom:a.amount[0]?.denom,client:_})}catch(_){return u("fee_computation_failed",_),m()}try{return await d.signWithDerivedWallet(n,e,s,g,o,f)}catch(_){return u("derived_wallet_sign_failed",_),m()}}function ni(){const e=X(),{autoSignFeePolicy:n}=ee(),s=Fe(),o=Vo(),a=Ms(),r=Dn(),i=Ll(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:d}=Es(),m=Or(),u=un(),h=g=>{const _=n?.[g];return{gasMultiplier:_?.gasMultiplier??Ql,maxGasMultiplierFromSim:_?.maxGasMultiplierFromSim??Yl,allowedFeeDenoms:_?.allowedFeeDenoms}},f=async({chainId:g,messages:_,memo:y,derivedWallet:j,preferredFeeDenom:b,fallbackFeeDenom:w,client:C})=>{const I=s(g),E=await Xr(I),A=Xl({derivedAddress:j.address,messages:_,encoder:r}).messages.map(H=>r.encodeAsAny(H)),L=Cr(Fo(j.publicKey)),{sequence:N}=await Vr({getSequence:H=>C.getSequence(H),signerAddress:j.address,incrementSequence:0,allowMissingAccount:!0}),k=await o(g),P=je.QueryClient.withExtensions(k,je.setupTxExtension),{gasInfo:R}=await td({queryClient:P,messages:A,memo:y,pubkey:L,sequence:N}),O=R?Number(R.gasUsed.toString()):0,V=h(g);return Jl({simulatedGas:O,gasPrices:E,preferredFeeDenom:b,fallbackFeeDenom:w,policy:V})},p=async(g,_,y,j,b,w)=>{let C=w??c(g);C||(C=await l(g));const I=d(g);if(!I)throw new Error("Derived wallet key not initialized");return await _l({chainId:g,granterAddress:_,messages:y,fee:j,memo:b,derivedWallet:C,privateKey:I,encoder:r,signWithEthSecp256k1:m})};return g=>sd({...g,address:e},{validateAutoSign:i,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:f,signWithDerivedWallet:p,signWithEthSecp256k1:m,onAutoSignFallback:({chainId:_,reason:y,errorMessage:j})=>{u("AutoSign Fallback",{chainId:_,reason:y,errorMessage:j})}})}function si(){const e=U.useAtomValue(Ps);if(!e)throw new Error("Tx request not found");return e}function Ds(){const e=Ce(),n=X(),{defaultChainId:s,registryUrl:o}=ee(),a=Fe(),{openDrawer:r,closeDrawer:i}=jt(),{openModal:c,closeModal:l}=qs(),d=U.useSetAtom(Ps),m=U.useSetAtom(ti),u=Vo(),h=Ms(),f=Rn(),p=Dn(),g=ni(),_=async({messages:A,memo:L,chainId:N=s})=>{try{return await(await h(N)).simulate(n,A,L)}catch(k){throw await nn(k,a(N),o)}},y=async({messages:A,memo:L,chainId:N=s})=>{const k=await u(N),P=je.QueryClient.withExtensions(k,je.setupTxExtension),R=A.map(F=>p.encodeAsAny(F)),[O]=await f.getAccounts(),V=Nn.encodeSecp256k1Pubkey(O.pubkey),H=await h(N),{sequence:Q}=await H.getSequence(n);return P.tx.simulate(R,L,V,Q)},j=async({txRequest:A,broadcaster:L})=>{const k={...{memo:"",chainId:s,gas:A.gas||await _(A),gasAdjustment:zt,gasPrices:null,spendCoins:[],internal:!1},...A};return new Promise((P,R)=>{d({txRequest:k,resolve:async V=>{try{const H=await h(k.chainId),Q=await L(H,De.TxRaw.encode(V).finish());P(Q),typeof k.internal=="string"&&e(k.internal)}catch(H){R(await nn(H,a(k.chainId),o))}finally{O()}},reject:V=>{R(V),O()}}),k.internal?c({path:"/tx"}):r("/tx");const O=()=>{if(!k.internal){e("/blank"),i();return}l()}})},b=async A=>{const L=A.chainId??s;try{const N=await j({txRequest:A,broadcaster:async(k,P)=>await k.broadcastTxSync(P)});return A.internal&&typeof A.internal!="number"&&(m({txHash:N,chainId:L,status:"loading"}),M({txHash:N,chainId:A.chainId}).then(k=>{m({status:k.code===0?"success":"error",chainId:L,txHash:N})}).catch(()=>{m({status:"error",chainId:L,txHash:N})})),N}catch(N){throw A.internal&&typeof A.internal!="number"&&m({status:"error",chainId:L,error:N}),N}},w=(A,L=30*1e3,N=.5*1e3)=>j({txRequest:A,broadcaster:async(k,P)=>{const R=await k.broadcastTx(P,L,N);if(R.code!==0)throw new Error(R.rawLog);return R}}),C=async({chainId:A,messages:L,memo:N="",fee:k,preferredFeeDenom:P})=>{const R=await h(A),O=await g({chainId:A,messages:L,memo:N,fee:k,preferredFeeDenom:P,client:R,allowWalletDerivation:!1});return{client:R,signedTx:O}},I=async A=>{const L=A.chainId??s;try{const{client:N,signedTx:k}=await C({...A,chainId:L});return await N.broadcastTxSync(De.TxRaw.encode(k).finish())}catch(N){throw await nn(N,a(L),o)}},E=async(A,L=30*1e3,N=.5*1e3)=>{const k=A.chainId??s;try{const{client:P,signedTx:R}=await C({...A,chainId:k}),O=await P.broadcastTx(De.TxRaw.encode(R).finish(),L,N);if(O.code!==0)throw new Error(O.rawLog);return O}catch(P){throw await nn(P,a(k),o)}},M=async({chainId:A=s,...L})=>{try{const N=await h(A);return await oi({...L,client:N})}catch(N){throw await nn(N,a(A),o)}};return{estimateGas:_,simulateTx:y,requestTxSync:b,requestTxBlock:w,submitTxSync:I,submitTxBlock:E,waitForTxConfirmation:M}}async function oi({txHash:e,client:n,timeoutMs:s=30*1e3,intervalMs:o=.5*1e3}){const a=Date.now();for(;;){const r=await n.getTx(e);if(r){if(r.code!==0)throw new Error(r.rawLog);return r}if(Date.now()-a>=s)throw new Error(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const od="/cosmos.authz.v1beta1.MsgExec";function ad(e){if(e.explicitGrantee)return[e.explicitGrantee];const n=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(s=>!!s);return[...new Set(n)]}function rd(e){const n=[e.currentGrantee,e.expectedGrantee].filter(s=>!!s);return[...new Set(n)]}function id(e){const{isEnabledOnTargetChain:n,hasEnabledSibling:s,didBroadcast:o,hasExplicitGrantee:a}=e;return s?!1:n===!1?!0:n===void 0&&o&&!a}function cd(e){return[...new Set(e.map(n=>n.authorization.msg))].filter(n=>!!n)}async function ai(e){const n=[xs.expirations._def,xs.grants._def];for(const s of n)await e.invalidateQueries({queryKey:s})}function ri(){const e=X(),{fetchFeegrant:n,fetchGrants:s}=Hr();return async o=>{const{chainId:a,grantee:r}=o;if(!e)throw new Error("Granter wallet not initialized");const i=await n(a,r),c=await s(a,r),l=i?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:ir.MsgRevokeAllowance.fromPartial({granter:e,grantee:r})}]:[],m=cd(c).map(u=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:Mo.MsgRevoke.fromPartial({granter:e,grantee:r,msgTypeUrl:u})}));return[...l,...m]}}function ld(){const e=X(),n=Ko(),{requestTxBlock:s}=Ds(),o=$.useQueryClient(),[a,r]=U.useAtom(Pn),{closeDrawer:i}=jt(),c=ri(),{deriveWallet:l}=Es();return $.useMutation({mutationFn:async d=>{if(!a)throw new Error("No pending request");const{chainId:m}=a;if(!e)throw new Error("Wallet not connected");const u=n[m];if(!u||u.length===0)throw new Error(`No message types configured for chain ${m}`);const h=await l(m);Tl(e,m);const f=Uo(e,m),p=rd({currentGrantee:h.address,expectedGrantee:f}),_=(await Promise.all(p.map(I=>c({chainId:m,grantee:I})))).flat(),y=d===0?void 0:Re.addMilliseconds(new Date,d),j={typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:Rt.BasicAllowance.encode(Rt.BasicAllowance.fromPartial({expiration:y})).finish()},b={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:ir.MsgGrantAllowance.fromPartial({granter:e,grantee:h.address,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.AllowedMsgAllowance",value:Rt.AllowedMsgAllowance.encode(Rt.AllowedMsgAllowance.fromPartial({allowance:j,allowedMessages:[od]})).finish()}})},w=u.map(I=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:Mo.MsgGrant.fromPartial({granter:e,grantee:h.address,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:wa.GenericAuthorization.encode(wa.GenericAuthorization.fromPartial({msg:I})).finish()},expiration:y}})})),C=[..._,b,...w];return await s({messages:C,chainId:m,internal:!0}),{chainId:m,derivedWallet:h}},onSuccess:async({chainId:d,derivedWallet:m})=>{e&&ml(e,d,m.address),await ai(o),a?.resolve()},onError:d=>{a?.reject(d)},onSettled:()=>{r(null),i()}})}function ii(e){const n=ee(),s=de(),o=Fe(),{getWallet:a,clearWallet:r}=Es(),{requestTxBlock:i}=Ds(),c=$.useQueryClient(),l=ri(),{data:d,refetch:m}=Ls();return $.useMutation({mutationFn:async(u=n.defaultChainId)=>{const h=a(u),f=d?.granteeByChain[u];let p;e?.grantee||(p=(await m()).data?.granteeByChain[u]);const g=ad({explicitGrantee:e?.grantee,cachedDerivedAddress:h?.address,statusGrantee:f,refetchedStatusGrantee:p});if(g.length===0)throw new Error("No grantee address available");const y=(await Promise.all(g.map(j=>l({chainId:u,grantee:j})))).flat();return y.length===0?{chainId:u,didBroadcast:!1}:(await i({messages:y,chainId:u,internal:e?.internal}),{chainId:u,didBroadcast:!0})},onSuccess:async({chainId:u,didBroadcast:h})=>{await ai(c);const f=o(u),p=s.filter(w=>w.bech32_prefix===f.bech32_prefix).map(w=>w.chain_id).filter(w=>w!==u);let g;try{g=(await m()).data}catch{g=void 0}const _=g??d;let y=!1;p.length>0&&_&&(y=p.some(w=>_?.isEnabledByChain[w]));const j=h?g?.isEnabledByChain[u]:(g??d)?.isEnabledByChain[u];id({isEnabledOnTargetChain:j,hasEnabledSibling:y,didBroadcast:h,hasExplicitGrantee:!!e?.grantee})&&r(u)}})}function dd(){const{defaultChainId:e}=ee(),{openDrawer:n}=jt(),s=U.useSetAtom(Pn),o=ii(),{data:a={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:r}=Ls();return{...a,isLoading:r,enable:async(l=e)=>new Promise((d,m)=>{s({chainId:l,resolve:d,reject:m}),n("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}function ci(e){return e.assets.reduce((n,{value:s})=>n+(s??0),0)}function ud(e){return e.assets.reduce((n,{quantity:s})=>n.plus(s),B(0)).toString()}function md(e,n){return{symbol:n?.symbol??e,logoUrl:n?.logoUrl??Do}}function Ia(e){return T.pick(["chainId","name","logoUrl"],e)}function hd(e){return T.sortWith([T.descend(({symbol:n})=>n===Ye),T.descend(ci),T.descend(({assets:n})=>n.length),T.ascend(({symbol:n})=>n)])(e)}function fd(e){return T.sortWith([T.descend(({value:n})=>n??0),T.descend(({quantity:n})=>Number(n)),T.ascend(({chain:n})=>n.name)])(e)}function pd(e,n){return T.sortWith([T.descend(({chain:s})=>s.chainId===n),T.ascend(({chain:s})=>s.name),T.ascend(({denom:s})=>s)])(e)}function gd(e,n){return T.sortWith([T.descend(({chainId:s})=>s===n),T.descend(T.prop("value"))])(e)}function _d(e,n,s,o,a){const r=e.find(u=>u.metadata?.is_l1)?.chainId,i={};for(const u of e){const h=u.chainId,f=n[h]??[],p=s[h],g=o[h],_=[];for(const{amount:y,denom:j}of f){if(!B(y).gt(0))continue;const b=p?.find(M=>M.denom===j),w=g?.find(M=>M.id===j)?.price,C=b?.decimals??0,I=v.fromBaseUnit(y,{decimals:C}),E=w?B(I).times(w).toNumber():void 0;_.push({...md(j,b),amount:y,denom:j,decimals:C,quantity:I,price:w,value:E,address:b?.address,unlisted:!b,chain:Ia(u)})}i[h]=_}const c=new Map;for(const[u,h]of Object.entries(i)){if(h.length===0)continue;const f=e.find(g=>g.chainId===u);if(!f)continue;const p=h.reduce((g,{value:_})=>g+(_??0),0);c.set(u,{...Ia(f),value:p})}const l=new Map;for(const u of Object.values(i))for(const h of u)if(!h.unlisted){const{symbol:f}=h,p=l.get(f)??[];l.set(f,[...p,h])}const d=[];for(const[u,h]of l){const f=T.head(h);if(!f)continue;const p=fd(h),g=p.reduce((y,{value:j})=>y+(j??0),0),_=p.reduce((y,{quantity:j})=>y.plus(j),B(0)).toNumber();d.push({symbol:u,logoUrl:f.logoUrl,assets:p,totalValue:g,totalAmount:_})}const m=[];for(const u of Object.values(i))for(const h of u)h.unlisted&&m.push(h);return{chainsByValue:gd(Array.from(c.values()),a),assetGroups:hd(d),unlistedAssets:pd(m,r),totalValue:d.reduce((u,h)=>u+h.totalValue,0)}}function Go(){const{defaultChainId:e}=ee(),n=de(),s=zc(),o=Ln(),a=Po(),r=n.map(h=>h.chainId),i=T.zipObj(r,s.map(T.prop("data"))),c=T.zipObj(r,o.map(T.prop("data"))),l=T.zipObj(r,a.map(T.prop("data"))),d=_d(n,i,c,l,e),m=[s,o,a].flat().some(({isLoading:h})=>h);return{...d,isLoading:m,refetch:()=>{s.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),a.forEach(({refetch:h})=>h())}}}function X(){const e=hn();return e?v.InitiaAddress(e).bech32:""}function hn(){const{address:e}=Ee.useAccount();return e?v.InitiaAddress(e).hex:""}function At(){const e=Gt(),n=X(),s=hn();return e.metadata?.minitia?.type==="minievm"?s:n}function li(){const e=At(),n=xr();return $.useQuery({queryKey:As.username(n.restUrl,e).queryKey,queryFn:()=>n.getUsername(e),enabled:!!e,staleTime:K.MINUTE})}function Ue(){const e=At(),n=X(),s=hn(),{data:o}=li(),a=Rn(),r=Pr(),i=dd(),{isDrawerOpen:c,openDrawer:l}=jt(),{isModalOpen:d}=mn(),m=()=>{l("/")},u=()=>{l("/connect")},h=j=>{l("/bridge",j)},f=bl(),p=vl(),g=Ds();return{address:e,initiaAddress:n,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:c||d,openConnect:u,openWallet:m,openBridge:h,openDeposit:f,openWithdraw:p,disconnect:r,autoSign:i,...g}}const xd="_status_tn9m1_1",yd="_error_tn9m1_9",Aa={status:xd,error:yd},he=({error:e,children:n})=>t.jsx("p",{className:q(Aa.status,{[Aa.error]:e}),children:n}),me=({errorBoundaryProps:e={fallbackRender:({error:o})=>t.jsx(he,{error:!0,children:o.message})},suspenseFallback:n=t.jsx(he,{children:"Loading..."}),children:s})=>t.jsx(cr.ErrorBoundary,{...e,children:t.jsx(x.Suspense,{fallback:n,children:s})}),jd="lock_staking";function di(e,n){const s=`${n}::lock_staking::StakingAccount`,o=v.createObjectAddress(e,s);return v.InitiaAddress(o).bech32}const Fn=ye.createQueryKeys("interwovenkit:initia-staking",{delegations:(e,n)=>[e,n],undelegations:(e,n,s)=>[e,n,s],lockStaking:(e,n,s)=>[e,n,s],stakingRewards:(e,n)=>[e,n],lockStakingRewards:(e,n,s)=>[e,n,s]});function Qo(){const{restUrl:e}=re(),n=X();return $.useSuspenseQuery({queryKey:Fn.delegations(e,n||"").queryKey,queryFn:async()=>n?(await z.get(`${e}/initia/mstaking/v1/delegations/${n}`).json()).delegation_responses:[],select:s=>{const o=new Map;for(const a of s){const r=a.delegation.validator_address;for(const i of a.balance){const c=v.denomToMetadata(i.denom),l={denom:i.denom,metadata:c,amount:i.amount,validator:r},d=o.get(c)??[];d.push(l),o.set(c,d)}}return o},staleTime:K.MINUTE})}function Yo(){const{restUrl:e}=re(),{lockStakeModuleAddress:n}=ee(),s=X(),o=s?di(s,n):"";return $.useSuspenseQuery({queryKey:Fn.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await z.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await z.get(`${e}/initia/mstaking/v1/delegators/${o}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...a.unbonding_responses,...r.unbonding_responses]},select:a=>{const r=new Map;for(const i of a){const c=i.validator_address;for(const l of i.entries)for(const d of l.balance){const m=v.denomToMetadata(d.denom),u={denom:d.denom,metadata:m,amount:d.amount,validator:c,completionTime:l.completion_time},h=r.get(m)??[];h.push(u),r.set(m,h)}}return r},staleTime:K.MINUTE})}function Zo(){const{restUrl:e}=re(),{lockStakeModuleAddress:n}=ee(),s=X();return $.useSuspenseQuery({queryKey:Fn.lockStaking(e,s||"",n).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=v.createMoveClient(e);return await o({moduleAddress:n,moduleName:jd,functionName:"get_locked_delegations",typeArgs:[],args:[se.toBase64(v.InitiaAddress(s,32).bytes)]})??[]},select:o=>{const a=new Map;for(const r of o){const i={metadata:r.metadata,amount:r.amount,validator:r.validator,releaseTime:r.release_time},c=a.get(r.metadata)??[];c.push(i),a.set(r.metadata,c)}return a},staleTime:K.MINUTE})}function ui(e){const n=new Map;if(!e.total||!Array.isArray(e.total))return n;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=v.denomToMetadata(s.denom);let a=new B(0);for(const i of s.dec_coins)i?.amount&&(a=a.plus(i.amount));const r=n.get(o);if(r){const i=new B(r.amount);a=a.plus(i)}n.set(o,{denom:s.denom,amount:a.toString()})}return n}function mi(){const{restUrl:e}=re(),n=X();return $.useSuspenseQuery({queryKey:Fn.stakingRewards(e,n||"").queryKey,queryFn:async()=>n?await z.get(`${e}/initia/distribution/v1/delegators/${n}/rewards`).json():{rewards:[],total:[]},select:ui,staleTime:K.MINUTE})}function hi(){const{restUrl:e}=re(),{lockStakeModuleAddress:n}=ee(),s=X(),o=s?di(s,n):"";return $.useSuspenseQuery({queryKey:Fn.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await z.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:ui,staleTime:K.MINUTE})}function Jo(){const e=re(),n=xt(e),{data:s,isLoading:o}=yt(e),{data:a}=Qo(),{data:r}=Yo(),{data:i}=Zo(),c=x.useMemo(()=>{const f=new Set;for(const p of a.keys())f.add(p);for(const p of i.keys())f.add(p);for(const p of r.keys())f.add(p);return Array.from(f)},[a,i,r]),l=Bo(c),d=x.useMemo(()=>{const f=new Map;if(s)for(const p of s)f.set(p.id,p.price);return f},[s]),m=x.useMemo(()=>{const f=new Map;for(const p of n)f.set(p.denom,p);return f},[n]),u=x.useMemo(()=>{const f=[],p=g=>{const _=m.get(g);return _?{symbol:_.symbol,decimals:_.decimals}:null};for(const[g,_]of a){const y=l.get(g)??_[0]?.denom;if(!y)continue;const j=p(y);if(!j)continue;const b=d.get(y)??0;for(const w of _){const{symbol:C,decimals:I}=j,E=Number(v.fromBaseUnit(w.amount,{decimals:I})),M={type:"asset",denom:y,symbol:C,amount:w.amount,formattedAmount:E,decimals:I,value:E*b};f.push({type:"staking",validator:w.validator,balance:M})}}for(const[g,_]of i){const y=l.get(g);if(!y)continue;const j=p(y);if(!j)continue;const b=d.get(y)??0;for(const w of _){const{symbol:C,decimals:I}=j,E=Number(v.fromBaseUnit(w.amount,{decimals:I})),M={type:"asset",denom:y,symbol:C,amount:w.amount,formattedAmount:E,decimals:I,value:E*b},A=Number(w.releaseTime);f.push({type:"lockstaking",validator:w.validator,releaseTime:Number.isNaN(A)?0:A,balance:M})}}for(const[g,_]of r){const y=l.get(g)??_[0]?.denom;if(!y)continue;const j=p(y);if(!j)continue;const b=d.get(y)??0;for(const w of _){const{symbol:C,decimals:I}=j,E=Number(v.fromBaseUnit(w.amount,{decimals:I})),M={type:"asset",denom:y,symbol:C,amount:w.amount,formattedAmount:E,decimals:I,value:E*b},A=new Date(w.completionTime).getTime(),L=Number.isNaN(A)?0:Math.floor(A/1e3);f.push({type:"unstaking",validator:w.validator,completionTime:L,balance:M})}}return f.filter(g=>g.type!=="fungible-position"&&g.balance.denom===Ie)},[a,i,r,l,m,d]),h=x.useMemo(()=>u.reduce((f,p)=>p.type==="fungible-position"||p.balance.type==="unknown"?f:f+(p.balance.value??0),0),[u]);return{positions:u,totalValue:h,isLoading:o}}const Xo=ye.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,n)=>[e,n],lpPrices:(e,n)=>[e,n],pool:(e,n)=>[e,n]});function wd(e){const n=new Map;for(const s of e){const o=v.denomToMetadata(s.denom),a={...s,metadata:o},r=n.get(o)??[];r.push(a),n.set(o,r)}return n}function bd(e){const{dexUrl:n}=ee();return $.useSuspenseQuery({queryKey:Xo.checkLpTokens(n,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.post(`${n}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:K.MINUTE})}function fi(){const e=re(),n=qn(e),s=x.useMemo(()=>n.map(a=>a.denom),[n]),{data:o}=bd(s);return x.useMemo(()=>{const a=n.filter(r=>o.get(r.denom)===!0);return wd(a)},[n,o])}function pi(e){const{dexUrl:n}=ee();return $.useSuspenseQuery({queryKey:Xo.lpPrices(n,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.get(`${n}/indexer/price/v1/lp_prices/${encodeURIComponent(e.join(","))}`).json(),{prices:o}=s;return Array.isArray(o)?new Map(o.map(({denom:a,price:r})=>[a,r])):new Map(Object.entries(o))},staleTime:K.MINUTE})}function vd(e){const{dexUrl:n}=ee(),s=re(),o=xt(s),a=x.useMemo(()=>{const c=new Map;for(const l of o)c.set(l.denom,l);return c},[o]),i=$.useSuspenseQueries({queries:e.map(c=>({queryKey:Xo.pool(n,c).queryKey,queryFn:async()=>{try{const l=v.denomToMetadata(c);return(await z.get(`${n}/indexer/dex/v2/pools/${encodeURIComponent(l)}`).json()).pool}catch{return null}},staleTime:K.MINUTE}))}).map(c=>c.data);return x.useMemo(()=>{const c=new Map;return e.forEach((l,d)=>{const m=i[d];if(!m){c.set(l,null);return}if(l===xl){c.set(l,{...m,symbol:yl});return}const u=m.coins.map(h=>a.get(h.denom)?.symbol||h.denom).join("-");c.set(l,{...m,symbol:u})}),c},[e,i,a])}function Cd(e,n,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of n){const c=i[0]?.denom;c&&c!==Ie&&a.add(r)}for(const r of s.keys())a.add(r);for(const[r,i]of o){const c=i[0]?.denom;c&&c!==Ie&&a.add(r)}return Array.from(a)}function Nd(e){const n=[];for(const[,s]of e)s&&s!==Ie&&n.push(s);return n}function kd(e,n){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>n.get(s.denom)?.logoUrl||"")}function Id(e,n,s){const o=n.get(e)??null,a=o?.symbol||e,r=kd(o,s),i=r.length>0&&r.some(l=>l),c=i?void 0:s.get(e)?.logoUrl;return{denom:e,symbol:a,totalAmount:0,totalValue:0,decimals:s.get(e)?.decimals??6,poolType:o?.pool_type,logoUrl:c,coinLogos:i?r:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0}}}function Xs(e,n,s,o,a){for(const[r,i]of e){const c=n.get(r)??i[0]?.denom;if(!c||c===Ie)continue;const l=o.get(c);if(l)for(const d of i){const m=String(d.amount),u=l.decimals,h=Number(v.fromBaseUnit(m,{decimals:u})),f=s.get(c)??0,p=h*f;l.breakdown[a]+=h,l.totalAmount+=h,l.totalValue+=p}}}function Ad(e,n,s,o,a){for(const[r,i]of e){const c=n.get(r);if(!c||c===Ie)continue;const l=o.get(c);if(l)for(const d of i){const m=String(d.amount),u=l.decimals,h=Number(v.fromBaseUnit(m,{decimals:u})),f=s.get(c)??0,p=h*f;l.breakdown[a]+=h,l.totalAmount+=h,l.totalValue+=p}}}function Sd(e,n,s,o){for(const[a,r]of e){const i=v.denomToMetadata(a),c=n?.get(i),l=c?v.fromBaseUnit(c.amount,{decimals:Be}):"0",d=s?.get(i),m=d?v.fromBaseUnit(d.amount,{decimals:Be}):"0",u=Number(l)+Number(m);u>0&&(r.claimableInit={staking:l,lockStaking:m,total:String(u),totalValue:u*o})}}function ea(){const e=re(),n=xt(e),s=fi(),{data:o}=Qo(),{data:a}=Zo(),{data:r}=Yo(),{data:i}=mi(),{data:c}=hi(),{data:l}=yt(e),d=x.useMemo(()=>{const y=new Map;for(const j of n)y.set(j.denom,j);return y},[n]),m=x.useMemo(()=>Cd(s,o,a,r),[s,o,a,r]),u=Bo(m),h=x.useMemo(()=>Nd(u),[u]),{data:f}=pi(h),p=vd(h),{rows:g,totalValue:_}=x.useMemo(()=>{const y=l?.find(C=>C.id===Ie)?.price??0,j=new Map;for(const C of h)j.set(C,Id(C,p,d));Xs(s,u,f,j,"deposit"),Xs(o,u,f,j,"staking"),Ad(a,u,f,j,"lockStaking"),Xs(r,u,f,j,"unstaking"),Sd(j,i,c,y);const b=Array.from(j.values()).filter(C=>C.totalAmount>0).sort((C,I)=>I.totalValue-C.totalValue),w=b.reduce((C,I)=>C+I.totalValue,0);return{rows:b,totalValue:w}},[h,p,d,s,o,a,r,u,f,i,c,l]);return{totalValue:_,rows:g}}const Td=ye.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,n)=>[e,n]});function $d(e){return e.filter(n=>n.data.length>0).map(n=>{const s=n.data[0].bridge_id,o=n.data[0].version,a=n.data.reduce((r,i)=>r+i.claimed_reward,0);return{claimableReward:n.total_claimable_reward,claimedReward:a,initialReward:n.total_vesting_reward,lockedReward:n.total_locked_reward,requiredScore:n.required_score,rollup:{bridgeId:s,version:o}}}).filter(n=>n.initialReward>0).toSorted((n,s)=>s.initialReward-n.initialReward)}function gi(){const{vipUrl:e}=ee(),n=X();return $.useQuery({queryKey:Td.allVestingPositions(e,n).queryKey,queryFn:async()=>(await z.get(`${e}/vesting/positions/${n}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:K.MINUTE,enabled:!!n})}function Ed(){const e=de();return x.useCallback(n=>e.find(({metadata:s})=>s?.op_bridge_id===String(n)),[e])}function Bs(){const{data:e}=gi(),n=re(),{data:s}=yt(n),o=Ed(),a=x.useMemo(()=>s?.find(l=>l.id===Ie)?.price??0,[s]),r=x.useMemo(()=>e?$d(e).map(l=>{const d=o(l.rollup.bridgeId),m=Number(v.fromBaseUnit(String(l.lockedReward),{decimals:Be})),u=Number(v.fromBaseUnit(String(l.claimableReward),{decimals:Be})),h=B(v.fromBaseUnit(String(l.lockedReward),{decimals:Be})).times(a).toNumber(),f=B(v.fromBaseUnit(String(l.claimableReward),{decimals:Be})).times(a).toNumber();return{bridgeId:l.rollup.bridgeId,version:l.rollup.version,name:d?.name??"",logoUrl:d?.logoUrl,lockedReward:m,lockedRewardValue:h,claimableReward:u,claimableRewardValue:f}}):[],[e,a,o]),i=x.useMemo(()=>r.reduce((c,l)=>c+l.lockedRewardValue+l.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function _i(){const e=fi(),{data:n}=Qo(),{data:s}=Zo(),{data:o}=Yo(),{data:a}=gi(),r=re(),{data:i}=yt(r),c=x.useMemo(()=>i?.find(g=>g.id===Ie)?.price??0,[i]),l=x.useMemo(()=>{const p=new Set;for(const[g]of e)p.add(g);for(const[g]of n)p.add(g);for(const[g]of s)p.add(g);for(const[g]of o)p.add(g);return Array.from(p)},[e,n,s,o]),d=Bo(l),m=x.useMemo(()=>Array.from(d.values()).filter(p=>p!==Ie),[d]),{data:u}=pi(m),h=xt(r),f=x.useMemo(()=>{const p=new Map;for(const g of h)p.set(g.denom,{decimals:g.decimals});return p},[h]);return x.useMemo(()=>{let p=0,g=0;const _=c??0,y=(b,w)=>{const C=d.get(b)??b;if(C===Ie)return 0;const I=f.get(C)?.decimals??Be;return Number(v.fromBaseUnit(w,{decimals:I}))*(u.get(C)??0)};for(const[,b]of n)for(const{denom:w,metadata:C,amount:I}of b)w===Ie?p+=Number(v.fromBaseUnit(I,{decimals:Be}))*_:g+=y(C,I);for(const[b,w]of s){const I=(d.get(b)??b)===Ie;for(const{amount:E}of w)I?p+=Number(v.fromBaseUnit(E,{decimals:Be}))*_:g+=y(b,E)}for(const[,b]of o)for(const{denom:w,metadata:C,amount:I}of b)w===Ie?p+=Number(v.fromBaseUnit(I,{decimals:Be}))*_:g+=y(C,I);for(const[b,w]of e)for(const{amount:C}of w)g+=y(b,String(C));let j=0;if(a)for(const b of a){const w=b.total_locked_reward??0,C=b.total_claimable_reward??0;j+=Number(v.fromBaseUnit(String(w+C),{decimals:Be}))*_}return p+g+j},[n,s,o,e,a,c,d,u,f])}function Md(){const e=["initia-wallet-widget:last-connected-wallet","initia-wallet-widget:fee-denoms","initia-wallet-widget:chain-ids","initia-wallet-widget:opened-layers-assets","initia-wallet-widget:opened-layers-nft"],n={"initia-wallet-widget:ethereum-public-keys":{prefix:ae.PUBLIC_KEY,getSuffix:s=>v.InitiaAddress(s).bech32}};for(const s of e)localStorage.removeItem(s);for(const[s,{prefix:o,getSuffix:a}]of Object.entries(n)){const r=localStorage.getItem(s);if(r)try{const i=JSON.parse(r);for(const[c,l]of Object.entries(i)){const d=`${o}:${a(c)}`;localStorage.setItem(d,l)}localStorage.removeItem(s)}catch{}}}const jo=ye.createQueryKeys("interwovenkit:minity",{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,n)=>[e,n],balances:(e,n,s)=>[e,n,s],initiaPositions:(e,n)=>[e,"initia",n],echelonPositions:(e,n)=>[e,"echelon",n],inertiaPositions:(e,n)=>[e,"inertia",n],ravePositions:(e,n,s)=>[e,"rave",n,s],civitiaPositions:(e,n)=>[e,"civitia",n],yominetPositions:(e,n)=>[e,"yominet",n],chainPositions:(e,n,s)=>[e,n,s]});function ta(e,n){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=n[a],c=r.data;if(!(!i||!c)){for(const l of c)if(l.logoUrl&&!l.logoUrl.includes("undefined")){const d=`${i.chainId}:${l.denom}`;s.has(d)||s.set(d,l.logoUrl);const m=l.symbol.toUpperCase();o.has(m)||o.set(m,l.logoUrl)}}}return{denomLogos:s,symbolLogos:o}}function ln(e){if(e.type==="fungible-position")return e.value??0;if(e.balance.type==="unknown")return 0;const n=e.balance.value??0;return e.type==="lending"&&e.direction==="borrow"?-n:n}function Ld(e){return e.type==="fungible-position"?null:e.type==="staking"||e.type==="unstaking"||e.type==="lockstaking"?"staking":e.type==="lending"?e.direction==="supply"?"lending":"borrowing":null}function qd(e,n=!1){switch(e){case"staking":return n?"INIT staking":"Staking";case"borrowing":return"Borrowing";case"lending":return"Lending";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function Pd(e){const n=new Map;for(const d of e){const m=Ld(d);if(!m)continue;const u=n.get(m)??[];u.push(d),n.set(m,u)}const s=new Map,o=new Map;for(const[d,m]of n){const u=m.reduce((f,p)=>f+ln(p),0),h=m.reduce((f,p)=>f+Math.abs(ln(p)),0);s.set(d,u),o.set(d,h)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,c=[...n.keys()].sort((d,m)=>{const u=d==="lending"||d==="borrowing"?i:o.get(d)??0,h=m==="lending"||m==="borrowing"?i:o.get(m)??0;return(d==="lending"||d==="borrowing")&&(m==="lending"||m==="borrowing")?d==="lending"?-1:1:h-u}),l=new Map;for(const d of c)l.set(d,{positions:n.get(d),totalValue:s.get(d)??0});return l}function Dd(e){return e.type==="fungible-position"?e.title:e.balance.denom}function Bd(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function Rd(e){return e.type==="fungible-position"?null:e.balance}function Fd(e){switch(e){case"staking":return"Staking";case"unstaking":return"Unstaking";case"lockstaking":return"Lock staking";case"lending":return"Lending";case"fungible-position":return"Position";default:return""}}function Ud(e){const n=new Map;for(const s of e){const o=n.get(s.type)??[];o.push(s),n.set(s.type,o)}return n}function Od(e,n){return e.symbol===Ye&&n.symbol===Ye?0:e.symbol===Ye?-1:n.symbol===Ye?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function Vd(e){const n=new Map;for(const o of e){const a=Dd(o),r=n.get(a)??[];r.push(o),n.set(a,r)}return Array.from(n.entries()).map(([o,a])=>{const r=Rd(a[0]);let i=0;for(const c of a)c.type!=="fungible-position"&&c.balance.type!=="unknown"&&(i+=c.balance.formattedAmount);return{denom:o,symbol:Bd(a[0]),positions:a,totalValue:a.reduce((c,l)=>c+ln(l),0),totalAmount:i,balance:r}}).toSorted(Od)}function xi(e,n){const s=new Map;return e.forEach((o,a)=>{const r=n[a]?.data;if(r&&r.length>0){const i=new Map(r.map(c=>[c.id,c.price]));s.set(o.chainId,i)}}),s}function Kd(e,n){return e.map(s=>({...s,balances:s.balances.map(o=>{if(o.type==="unknown"||o.value!=null&&o.value>0)return o;const a=n.get(s.chainId);if(a){const r=a.get(o.denom)??0;if(r>0)return{...o,value:o.formattedAmount*r}}return o})}))}function Wd(e,n){return e.symbol===Ye&&n.symbol===Ye?0:e.symbol===Ye?-1:n.symbol===Ye?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function zd(e,n,s){return e.map(o=>{const a=o.assets.map(i=>{const c=i.symbol.toUpperCase(),l=`${i.chain.chainId}:${i.denom}`,d=n.get(l)??s.get(c)??"";return d!==i.logoUrl?{...i,logoUrl:d}:i});let r="";for(const i of a)if(i.logoUrl){r=i.logoUrl;break}return r||(r=s.get(o.symbol.toUpperCase())??""),r!==o.logoUrl||a!==o.assets?{...o,logoUrl:r,assets:a}:o})}function Hd(e,n,s){const o=n?e.filter(i=>{const{symbol:c,assets:l}=i,d=n.toLowerCase();return c.toLowerCase().includes(d)||l.some(({denom:m})=>m.toLowerCase().includes(d))}):e,a=s?o.map(i=>{const c=i.assets.filter(({chain:l})=>l.chainId===s);return{...i,assets:c,totalValue:c.reduce((l,d)=>l+(d.value??0),0),totalAmount:c.reduce((l,d)=>l+Number(d.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,c)=>i+c.assets.reduce((l,d)=>l+(d.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Gd(e,n,s){const o=n?e.filter(({denom:a,address:r})=>{const i=n.toLowerCase();return a.toLowerCase().includes(i)||r?.toLowerCase().includes(i)}):e;return s?o.filter(({chain:a})=>a.chainId===s):o}function Qd(e,n,s,o){const{filteredAssets:a,totalAssetsValue:r}=Hd(e,s,o),i=Gd(n,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function Yd(e,n,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const c of e){const{chainName:l,chainId:d,balances:m}=c;if(!Array.isArray(m))continue;const u=n.get(l.toLowerCase()),h=u?.chainId??d??l,f=u?.prettyName??l,p=u?.logoUrl??"",g=s.get(h);for(const _ of m){if(_.type==="unknown"){if(!_.amount||_.amount==="0")continue;r.push({symbol:_.denom,logoUrl:"",denom:_.denom,amount:_.amount,decimals:0,quantity:_.amount,value:void 0,unlisted:!0,chain:{chainId:h,name:f,logoUrl:p}});continue}if(_.type==="lp"||(_.value??0)<=0&&(_.formattedAmount??0)<=0)continue;let y=_.value;if((y==null||y<=0)&&g){const w=g.get(_.denom)??0;w>0&&(y=_.formattedAmount*w)}const j={symbol:_.symbol,logoUrl:"",denom:_.denom,amount:_.amount,decimals:_.decimals,quantity:String(_.formattedAmount),value:y,chain:{chainId:h,name:f,logoUrl:p}},b=a.get(_.symbol);b?b.push(j):a.set(_.symbol,[j])}}r.sort((c,l)=>{const d=c.chain.chainId===o,m=l.chain.chainId===o;if(d&&!m)return-1;if(!d&&m)return 1;const u=c.chain.name.localeCompare(l.chain.name);if(u!==0)return u;try{const h=BigInt(c.amount),f=BigInt(l.amount);if(h>f)return-1;if(h<f)return 1}catch{const h=c.amount.localeCompare(l.amount);if(h!==0)return-h}return c.denom.localeCompare(l.denom)});const i=[];for(const[c,l]of a){l.sort((u,h)=>(h.value??0)-(u.value??0));let d=0,m=0;for(const u of l)d+=u.value??0,m+=Number(u.quantity);i.push({symbol:c,logoUrl:"",assets:l,totalValue:d,totalAmount:m})}return i.sort(Wd),{listedGroups:i,unlistedAssets:r}}function na(){return re().network_type==="testnet"}function St(){return _e.useFormContext()}function Zd(){const e=et(),n=na(),s={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},o={...s,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},a={...s,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},r=T.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(ae.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(ae.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(ae.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(ae.BRIDGE_DST_DENOM),quantity:localStorage.getItem(ae.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(ae.BRIDGE_SLIPPAGE_PERCENT)});return{...n?o:a,...r,...e}}const Jd={balances:[],positions:[],isLoading:!0,isComplete:!1},yi=U.atom(0),Xd=1e3;let Sa=0;function eu(){const e=U.useSetAtom(yi);x.useEffect(()=>{const n=Date.now();n-Sa>=Xd&&(Sa=n,e(s=>s+1))},[e])}function tu(){const e=$.useQueryClient(),n=X(),{minityUrl:s}=ee(),o=na(),a=U.useAtomValue(yi),r=x.useEffectEvent((l,d)=>{const m=Array.isArray(l.balances)?l.balances:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,balances:m})}),i=x.useEffectEvent((l,d)=>{const m=Array.isArray(l.positions)?l.positions:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,positions:m})}),c=x.useEffectEvent((l,d)=>{const m=jo.ssePortfolio(n??"",s).queryKey,u=e.getQueryData(m)??Jd,h=l.size>0||d.size>0;e.setQueryData(m,{...u,balances:Array.from(l.values()),positions:Array.from(d.values()),isLoading:h?!1:u.isLoading,isComplete:!1})});x.useEffect(()=>{if(!n||o)return;const l=jo.ssePortfolio(n,s).queryKey,d=e.getQueryData(l),m=new Map,u=new Map;for(const _ of d?.balances??[])m.set(_.chainName,_);for(const _ of d?.positions??[])u.set(_.chainName,_);const f=`${s}/v1/chain/all/${encodeURIComponent(n)}`;let p=null,g=!1;return e.setQueryData(l,{balances:d?.balances??[],positions:d?.positions??[],isLoading:!0,isComplete:!1}),p=new EventSource(f),p.onmessage=_=>{if(!g)try{const y=JSON.parse(_.data);y.type==="balances"?r(y,m):y.type==="positions"&&i(y,u),c(m,u)}catch{}},p.onerror=()=>{p?.close()},()=>{g=!0,p?.close()}},[n,o,a])}const Ta={balances:[],positions:[],isLoading:!0,isComplete:!1};function Un(){const e=X(),{minityUrl:n}=ee(),s=jo.ssePortfolio(e??"",n).queryKey,{data:o}=$.useQuery({queryKey:s,queryFn:()=>Ta,enabled:!!e,staleTime:K.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??Ta}function nu(){const e=de();return x.useMemo(()=>{const n=new Map;for(const s of e){const o=s.chain_name.toLowerCase();n.set(o,{chainId:s.chainId,chainName:s.chain_name,prettyName:s.name||s.chain_name,logoUrl:s.logoUrl||""})}return n},[e])}function su(){const{balances:e,positions:n}=Un(),s=de(),o=x.useMemo(()=>{const r=new Map;for(const i of s)r.set(i.chain_name.toLowerCase(),i);return r},[s]);return x.useMemo(()=>{const r=f=>f.type==="unknown"?0:f.value??0,i=f=>f.positions.reduce((p,g)=>{if(g.type==="fungible-position")return p+(g.value??0);if(g.balance.type==="unknown")return p;const _=g.balance.value??0;return g.type==="lending"&&g.direction==="borrow"?p-_:p+_},0),c=new Map,l=Array.isArray(e)?e:[],d=Array.isArray(n)?n:[];for(const{chainName:f,balances:p}of l){if(!Array.isArray(p))continue;const g=p.reduce((_,y)=>_+r(y),0);c.set(f,(c.get(f)||0)+g)}for(const{chainName:f,positions:p}of d){if(!Array.isArray(p))continue;const g=p.reduce((_,y)=>_+i(y),0);c.set(f,(c.get(f)||0)+g)}const m=Array.from(c.values()).reduce((f,p)=>f+p,0),u=Array.from(c.entries()).filter(([,f])=>f>0).map(([f,p])=>{const g=o.get(f.toLowerCase());return{chainId:g?.chainId||"",chainName:g?.name||f,logoUrl:g?.logoUrl||"",totalBalance:p,percentage:m>0?p/m:0}}).filter(f=>f.chainId!==""),h=f=>f.chainName.toLowerCase()==="initia";return T.sortWith([T.descend(h),T.descend(T.prop("totalBalance"))],u)},[e,n,o])}function ou(){const{balances:e}=Un(),n=de(),s=Po(),o=x.useMemo(()=>xi(n,s),[n,s]);return x.useMemo(()=>{const a=l=>l.type==="unknown"?0:l.value??0;let r=0;const i=Array.isArray(e)?e:[],c=Kd(i,o);for(const{balances:l}of c)if(Array.isArray(l))for(const d of l)d.type!=="lp"&&(r+=a(d));return r},[e,o])}function au(){const{positions:e}=Un();return x.useMemo(()=>{const n=r=>r.positions.reduce((i,c)=>{if(c.type==="fungible-position")return i+(c.value??0);if(c.balance.type==="unknown")return i;const l=c.balance.value??0;return c.type==="lending"&&c.direction==="borrow"?i-l:i+l},0),s=["initia","civitia","yominet"];let o=0;const a=Array.isArray(e)?e:[];for(const{chainName:r,positions:i}of a){const c=r.toLowerCase();s.includes(c)||Array.isArray(i)&&(o+=i.reduce((l,d)=>l+n(d),0))}return o},[e])}const Me=ye.createQueryKeys("interwovenkit:skip",{chains:null,allAssets:()=>["allAssets"],assets:e=>[e],asset:(e,n)=>[e,n],allBalances:(e,n)=>[e,n],balances:(e,n)=>[e,n],route:(e,n)=>[{...e,quantity:B(e.quantity||0).toString()},n],routeErrorInfo:e=>[e],txTrack:(e,n)=>[e,n],txStatus:(e,n)=>[e,n]});function tt(){const{routerApiUrl:e}=ee();return x.useMemo(()=>z.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.4.1"}}),[e])}function ji(){const e=de();return n=>e.some(s=>s.chain_id===n)}function On(){const e=ji();return n=>e(n.chain_id)?"initia":n.chain_type}function Tn(e){return On()(e)}function Vn(){const e=tt(),{data:n}=$.useSuspenseQuery({queryKey:Me.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>T.sortWith([T.descend(({chain_name:o})=>o==="initia"),T.ascend(({pretty_name:o})=>o)],s),staleTime:K.MINUTE});return n}function wt(){const e=Vn(),n=hr();return s=>{const o=e.find(r=>r.chain_id===s);if(o)return o;const a=n.find(r=>r.chain_id===s);if(!a)throw new Error(`Chain not found: ${s}`);return{chain_id:a.chain_id,chain_name:a.name,pretty_name:a.pretty_name,logo_uri:a.logo,chain_type:"cosmos",rpc:"",rest:""}}}function Ge(e){return wt()(e)}function Qt(){const e=tt(),n=Vn(),s=$.useQueryClient(),{data:o}=$.useSuspenseQuery({queryKey:Me.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),select:({chain_to_assets_map:a})=>{const r=[];for(const i in a){if(!n.find(l=>l.chain_id===i))continue;const{assets:c}=a[i]??{assets:[]};s.setQueryData(Me.assets(i).queryKey,{chain_to_assets_map:a}),r.push(...c);for(const l of c)s.setQueryData(Me.asset(i,l.denom).queryKey,l)}return r},staleTime:K.MINUTE});return o}function ys(e){const n=tt(),s=$.useQueryClient(),{data:o}=$.useSuspenseQuery({queryKey:Me.assets(e).queryKey,queryFn:()=>n.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:a})=>{const{assets:r}=a[e]??{assets:[]};for(const i of r)s.setQueryData(Me.asset(e,i.denom).queryKey,i);return r.toSorted(T.descend(i=>i.symbol==="INIT"))},staleTime:K.MINUTE});return o}function wi(e){const n=ys(e);return s=>{const o=n.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function dt(e,n){return wi(n)(e)}const ru=()=>(Qc(),Yc(),null),iu="_loader_1vxch_1",cu={loader:iu},ut=({size:e=24,color:n="currentColor",border:s=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${n} ${n} transparent ${n}`,borderWidth:`${s}px`};return t.jsx("div",{className:cu.loader,style:o})},lu="_button_1q027_1",du="_outline_1q027_28",uu="_sm_1q027_46",mu="_full_1q027_53",hu="_small_1q027_57",fu="_unpadded_1q027_88",Ut={button:lu,outline:du,sm:uu,full:mu,small:hu,unpadded:fu},bi=e=>{const{sm:n,fullWidth:s,loading:o,className:a,children:r,disabled:i,...c}=e;return t.jsx("button",{...c,className:q(Ut.button,{[Ut.sm]:n,[Ut.full]:s},a),disabled:!!o||i,children:o?t.jsxs(t.Fragment,{children:[t.jsx(ut,{color:"currentColor",size:16}),typeof o=="string"&&t.jsx("span",{className:Ut.loading,children:o})]}):r})},pu=({className:e,...n})=>t.jsx(bi,{...n,className:q(Ut.outline,e)}),gu=({className:e,unpadded:n,...s})=>t.jsx("button",{...s,className:q(Ut.small,{[Ut.unpadded]:n},e)}),le={White:bi,Outline:pu,Small:gu},_u="_footer_1vp4h_1",xu="_actions_1vp4h_10",$a={footer:_u,actions:xu},xe=({extra:e,className:n,children:s})=>t.jsxs("footer",{className:q($a.footer,n),children:[e,t.jsx("div",{className:$a.actions,children:s})]}),yu="_scrollable_13su7_1",ju={scrollable:yu},nt=({className:e,children:n,ref:s})=>t.jsx("div",{ref:s,className:q(ju.scrollable,e),children:n});function Rs(){return Le.useMediaQuery("(max-width: 576px)")}const wo="interwoven-kit";function vi(){const e=document.querySelector(wo)||document.body.appendChild(document.createElement(wo));return e.shadowRoot||e.attachShadow({mode:"open"})}function Ci(){const{theme:e,container:n}=ee();return x.useEffect(()=>{document.querySelector(wo)?.setAttribute("data-theme",e)},[e]),n??vi()}function wu(e){const n=vi(),s=document.createElement("style");s.textContent=e,n.appendChild(s)}const Fs=x.createContext(null);function Ht(){const{container:e}=x.useContext(Fs);return e}function Ni(e){const n=Ht();return n?getComputedStyle(n).getPropertyValue(e):""}function bu(){return Le.useScrollLock(),null}function vu(e){return/^[A-F0-9]{64}$/i.test(e)}function Cu(e,n){const{txHash:s,accountAddress:o,pathSuffix:a}=n;if(s)return vu(s)?T.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!v.InitiaAddress.validate(o))return;const i=T.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function Nu(e){try{const n=new URL(e,window.location.href);if(!["http:","https:"].includes(n.protocol))throw new Error("Invalid protocol");return n.toString()}catch{return"#"}}const ku="_link_j1lkz_1",Ea={link:ku},Us=({chainId:e,txHash:n,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:c,onClick:l,...d}=a,m=Xe(e),u=Cu(m,{txHash:n,accountAddress:s,pathSuffix:o}),h=n?v.truncate(n):s?v.truncate(s):"",f=c??h;return u?t.jsxs("a",{...d,href:Ic(Nu(u)),className:q(Ea.link,i),onClick:l,target:"_blank",children:[f,r&&t.jsx(S.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:q(Ea.link,i),children:f})},ki=x.createContext(null),Os=()=>x.useContext(ki),Iu=()=>{const[e,n]=U.useAtom(ti),{showNotification:s,updateNotification:o,hideNotification:a}=Os();return x.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:c,error:l}=e,d=l?l.message:c?t.jsx(Us,{txHash:c,chainId:i,onClick:a,showIcon:!0,children:"View on Initia Scan"}):null;switch(r){case"loading":s({type:"loading",title:"Transaction is pending..."});break;case"error":o({type:"error",title:"Transaction failed",description:d}),n(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),n(null);break}},[e,n,s,o,a]),null},js=({value:e,children:n})=>{const[s,o]=x.useState(!1);return n({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},Au="_placeholder_10r3x_1",Su="_logo_10r3x_5",Ma={placeholder:Au,logo:Su},J=({src:e,alt:n,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[c,l]=x.useState(void 0),{width:d,height:m}=i,u=s??t.jsx("div",{className:q(Ma.placeholder,o?.placeholder),style:{width:d,height:m,...a}});return!e||c===e?u:t.jsx("img",{...i,className:q(i.className,{[Ma.logo]:r}),style:{width:d,height:m,...a},src:e,alt:n,loading:"lazy",onError:()=>l(e)})};function Ii(){const{connector:e}=Ee.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const Tu="_header_1q8ju_1",$u="_account_1q8ju_17",Eu="_name_1q8ju_28",Mu="_address_1q8ju_32",Lu="_icon_1q8ju_36",qu="_copied_1q8ju_43",Pu="_button_1q8ju_58",Du="_settings_1q8ju_69",Bu="_disconnect_1q8ju_73",Ru="_label_1q8ju_83",Fu="_expanded_1q8ju_91",Ke={header:Tu,account:$u,name:Eu,address:Mu,icon:Lu,copied:qu,button:Pu,settings:Du,disconnect:Bu,label:Ru,expanded:Fu},Uu=()=>{const e=Pr(),{address:n,username:s}=Ue(),o=Ii(),a=s??n,[r,i]=x.useState(!1),c=x.useRef(null),l=lt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{r?e():i(!0)},m=()=>{r&&(c.current=setTimeout(()=>{i(!1)},500))},u=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return x.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),n?t.jsxs("header",{className:Ke.header,children:[t.jsx(js,{value:n,children:({copy:h,copied:f})=>t.jsxs("button",{className:q(Ke.account,{[Ke.copied]:f}),onClick:h,children:[t.jsx(J,{src:o,width:18,height:18}),t.jsx("div",{className:Ke.address,children:v.truncate(n)}),t.jsx("div",{className:Ke.name,children:v.truncate(a)}),t.jsx(S.IconCopy,{className:Ke.icon,size:12}),f?"Copied!":""]})}),t.jsx(cn,{to:"/settings",className:q(Ke.button,Ke.settings),"aria-label":"Open settings",children:t.jsx(S.IconSettingFilled,{size:16})}),t.jsxs(lt.animated.button,{className:q(Ke.button,Ke.disconnect,{[Ke.expanded]:r}),style:l,onClick:d,onMouseLeave:m,onMouseEnter:u,children:[t.jsx(S.IconSignOut,{size:16}),t.jsx("span",{className:Ke.label,children:"Disconnect"})]})]}):null},Ou="_overlay_jij9g_1",Vu="_content_jij9g_28",Ku="_inner_jij9g_60",eo={overlay:Ou,content:Vu,inner:Ku},Wu=({children:e})=>{const{isDrawerOpen:n,closeDrawer:s}=jt(),{setContainer:o}=x.useContext(Fs),a=Rs(),r=Ci(),i=U.useAtomValue(Ps),c=U.useAtomValue(Pn),l=$.useIsMutating({mutationKey:[ei]}),d=()=>{const p=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),i?.reject(new Error(p)),c?.reject(new Error("User rejected"))},m=Ts(),u=Ce(),h=$.useQueryClient(),f={fallbackRender:({error:p,resetErrorBoundary:g})=>{const _=()=>{m==="/bridge"&&(localStorage.removeItem(ae.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(ae.BRIDGE_SRC_DENOM),localStorage.removeItem(ae.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(ae.BRIDGE_DST_DENOM)),u("/"),h.clear(),g()};return t.jsxs(nt,{children:[t.jsx(he,{error:!0,children:p.message}),t.jsx(xe,{children:t.jsx(le.White,{onClick:_,children:"Retry"})})]})}};return t.jsx(ke.Dialog.Root,{open:n,onOpenChange:p=>!p&&d(),modal:!1,children:t.jsxs(ke.Dialog.Portal,{container:r,children:[a&&t.jsx(ke.Dialog.Backdrop,{className:eo.overlay,onClick:d,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[t.jsx("path",{d:"M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z"}),t.jsx("path",{d:"M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z"})]})}),t.jsx(ke.Dialog.Popup,{className:eo.content,children:t.jsxs("div",{className:q(eo.inner,"body"),ref:o,children:[a&&t.jsx(bu,{}),t.jsx(Iu,{}),t.jsx(Uu,{}),t.jsx(me,{errorBoundaryProps:f,children:e})]})})]})})},zu="_backdrop_1bqx9_1",Hu="_modal_1bqx9_12",Gu="_closeButton_1bqx9_44",to={backdrop:zu,modal:Hu,closeButton:Gu},Qu=({children:e})=>{const{isModalOpen:n,closeModal:s}=mn(),{setContainer:o}=x.useContext(Fs),a=Ci();return t.jsx(ke.Dialog.Root,{open:n,onOpenChange:r=>!r&&s(),children:t.jsxs(ke.Dialog.Portal,{container:a,children:[t.jsx(ke.Dialog.Backdrop,{className:to.backdrop,onClick:s}),t.jsxs(ke.Dialog.Popup,{className:q(to.modal),ref:o,children:[t.jsx("button",{className:to.closeButton,onClick:s,"aria-label":"Close",children:t.jsx(S.IconClose,{size:20})}),e]})]})})},Ai=x.createContext(!1),Yu="_overlay_1iyfl_1",Zu="_fullscreen_1iyfl_15",Ju="_content_1iyfl_19",Xu="_header_1iyfl_56",em="_title_1iyfl_65",tm="_close_1iyfl_70",Mt={overlay:Yu,fullscreen:Zu,content:Ju,header:Xu,title:em,close:tm},Si=({title:e,children:n,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=Ht(),c=x.useContext(Ai);return i?t.jsxs(ke.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&t.jsx(ke.Dialog.Trigger,{className:o,children:s}),t.jsxs(ke.Dialog.Portal,{container:i,children:[t.jsx(ke.Dialog.Backdrop,{className:q(Mt.overlay,{[Mt.fullscreen]:c}),onClick:()=>r(!1),forceRender:!0}),t.jsxs(ke.Dialog.Popup,{className:q(Mt.content,{[Mt.fullscreen]:c}),children:[e&&t.jsxs("header",{className:Mt.header,children:[t.jsx(ke.Dialog.Title,{className:Mt.title,children:e}),t.jsx(ke.Dialog.Close,{className:Mt.close,children:t.jsx(S.IconClose,{size:20})})]}),n]})]})]}):null},$n=({children:e})=>{const n=x.useRef(null),[s,o]=x.useState(0),[a,r]=x.useState(!1),i=lt.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return x.useEffect(()=>{const c=n.current;if(!c)return;const l=()=>{const{height:m}=c.getBoundingClientRect();o(m),r(!0)};l();const d=new ResizeObserver(l);return d.observe(c),()=>d.disconnect()},[e]),e?t.jsx(lt.animated.div,{style:{overflow:"hidden",...i},children:t.jsx("div",{ref:n,children:e})}):null},nm="_help_qcmtq_1",sm="_icon_qcmtq_10",om="_info_qcmtq_19",am="_warning_qcmtq_23",rm="_error_qcmtq_27",im="_success_qcmtq_33",no={help:nm,icon:sm,info:om,warning:am,error:rm,success:im},sn=({level:e,className:n,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return t.jsx(ut,{size:12});case"info":return t.jsx(S.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(S.IconWarningFilled,{size:12});default:return t.jsx(S.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:q(no.help,e&&no[e],n),style:{marginTop:s},children:[t.jsx("div",{className:no.icon,children:a()}),o]})},cm="_stack_a6m7u_1",lm="_help_a6m7u_6",dm="_info_a6m7u_14",um="_warning_a6m7u_19",mm="_error_a6m7u_24",hm="_success_a6m7u_29",bo={stack:cm,help:lm,info:dm,warning:um,error:mm,success:hm},fm=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx($n,{children:t.jsx("div",{className:bo.stack,children:e})}),fe=({mt:e=0,...n})=>t.jsx(sn,{...n,className:q(bo.help,bo[n.level]),mt:e});fe.Stack=fm;const pm="_root_16p5j_1",gm="_item_16p5j_10",_m="_chevron_16p5j_14",xm="_trigger_16p5j_19",ym="_content_16p5j_39",gn={root:pm,item:gm,chevron:_m,trigger:xm,content:ym};function jm(e){const{list:n,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return t.jsxs(Z.Accordion.Root,{className:gn.root,type:"multiple",...i,children:[n.map((c,l)=>t.jsxs(Z.Accordion.Item,{className:gn.item,value:s?.(c)??String(l),children:[t.jsx(Z.Accordion.Header,{children:t.jsxs(Z.Accordion.Trigger,{className:gn.trigger,children:[o(c),t.jsx(S.IconChevronDown,{className:gn.chevron,size:16})]})}),t.jsx(Z.Accordion.Content,{className:gn.content,children:a(c)})]},s?.(c)??l)),r]})}const wm="_trigger_u613p_1",bm="_icon_u613p_18",vm="_content_u613p_27",Cm="_item_u613p_36",Nm="_itemText_u613p_52",km="_itemIndicator_u613p_57",Im="_active_u613p_60",Nt={trigger:wm,icon:bm,content:vm,item:Cm,itemText:Nm,itemIndicator:km,active:Im};function sa({options:e,value:n,onChange:s,classNames:o}){const a=Ht(),r=e.find(c=>c.value===n);if(!r)throw new Error("Selected option not found");const i=c=>{const l=e.find(d=>String(d.value)===c);if(!l)throw new Error(`Option not found: ${c}`);s(l.value)};return t.jsxs(ft.Select.Root,{value:String(n),onValueChange:i,modal:!1,children:[t.jsxs(ft.Select.Trigger,{className:q(Nt.trigger,o?.trigger),children:[t.jsx(ft.Select.Value,{children:r.triggerLabel||r.label}),t.jsx(ft.Select.Icon,{className:Nt.icon,children:t.jsx(S.IconChevronDown,{size:12})})]}),t.jsx(ft.Select.Portal,{container:a,children:t.jsx(ft.Select.Positioner,{className:Nt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(ft.Select.Popup,{className:Nt.popup,children:e.map(c=>t.jsxs(ft.Select.Item,{className:q(Nt.item,o?.item),value:String(c.value),children:[t.jsx(ft.Select.ItemText,{className:q(Nt.itemText,o?.itemText),children:c.label}),t.jsx(S.IconCheck,{size:12,className:q(Nt.itemIndicator,{[Nt.active]:c.value===n})})]},String(c.value)))})})})]})}const Am="_root_1t37n_1",Sm="_trigger_1t37n_7",Tm="_item_1t37n_11",$m="_itemText_1t37n_17",La={root:Am,trigger:Sm,item:Tm,itemText:$m},Em=({options:e,value:n,onChange:s})=>{const{txRequest:o}=si(),a=Xe(o.chainId),r=mt(a),i=(p,g)=>{if(v.formatAmount(p,{decimals:g})==="0.000000")return 8},c=({amount:[{amount:p,denom:g}]})=>{if(B(p).isZero())return"0";const{symbol:_,decimals:y}=r(g),j=i(p,y);return`${v.formatAmount(p,{decimals:y,dp:j})} ${_}`},l=e.map(p=>{const[{denom:g}]=p.amount,{symbol:_}=r(g);return{value:g,label:c(p),triggerLabel:_}});if(e.length===1)return t.jsx("span",{className:"monospace",children:c(e[0])});const d=e.find(p=>p.amount[0].denom===n);if(!d)throw new Error("Fee option not found");const[{amount:m,denom:u}]=d.amount,{decimals:h}=r(u),f=i(m,h);return t.jsxs("div",{className:La.root,children:[t.jsx("span",{className:"monospace",children:v.formatAmount(m,{decimals:h,dp:f})}),t.jsx(sa,{options:l,value:n,onChange:s,classNames:La})]})},Mm="_root_16nr2_1",Lm="_trigger_16nr2_5",qm="_chevron_16nr2_13",Pm="_panel_16nr2_27",Dm="_details_16nr2_39",Bm="_row_16nr2_48",en={root:Mm,trigger:Lm,chevron:qm,panel:Pm,details:Dm,row:Bm},Rm=({spend:e,fee:n,total:s,balance:o,symbol:a,decimals:r})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:n},e&&{label:"Required (spend + fee)",value:s},{label:"Balance",value:o}].filter(Boolean),c=r===6?void 0:8;return t.jsxs(Ys.Collapsible.Root,{className:en.root,children:[t.jsxs(Ys.Collapsible.Trigger,{className:en.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(S.IconChevronDown,{className:en.chevron,size:16})]}),t.jsx(Ys.Collapsible.Panel,{className:en.panel,children:t.jsx("div",{className:en.details,children:i.map(({label:l,value:d})=>t.jsxs("div",{className:en.row,children:[t.jsx("span",{children:l}),t.jsxs("span",{children:[v.formatAmount(d,{decimals:r,dp:c})," ",a]})]},l))})})]})};function ws(e){switch(typeof e){case"string":return e;case"number":case"bigint":return e.toString();case"boolean":return e?"true":"false";case"object":return e===null?"null":e instanceof Uint8Array?se.toBase64(e):Array.isArray(e)?`[${e.map(ws).join(",")}]`:JSON.stringify(e,(n,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const Fm="_container_1xzyq_1",Um="_toggle_1xzyq_5",Om="_list_1xzyq_11",Vm="_arg_1xzyq_16",Km="_type_1xzyq_21",_n={container:Fm,toggle:Um,list:Om,arg:Vm,type:Km},Wm=ye.createQueryKeys("interwovenkit:move",{abi:(e,n,s,o)=>[e,n,s,o]}),zm=({type:e,arg:n})=>ws(v.resolveBcsType(e).parse(n)),Hm=({msg:e,chainId:n,fallback:s})=>{const[o,a]=Le.useToggle(!1),{restUrl:r}=Xe(n),{moduleAddress:i,moduleName:c,functionName:l,args:d}=e,{data:m}=$.useQuery({queryKey:Wm.abi(r,i,c,l).queryKey,queryFn:async()=>{const h=await z.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),p=JSON.parse(h.module.abi).exposed_functions.find(({name:g})=>g===l);if(!p)throw new Error(`Function ${l} not found in module ${c}`);return p.params.filter(g=>!g.startsWith("&"))},staleTime:K.INFINITY});if(!m)return s;const u=(h,f)=>{const p=m[f];return t.jsxs("div",{className:_n.arg,children:[t.jsx("div",{className:_n.type,children:p}),t.jsx(cr.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(zm,{type:p,arg:h})})]},f)};return t.jsxs("div",{className:_n.container,children:[t.jsx(le.Small,{className:_n.toggle,onClick:a,disabled:!m,children:o?"Encode":"Decode"}),o?t.jsx("div",{className:_n.list,children:d.map(u)}):s]})},Gm="_list_oip9m_1",Qm="_key_oip9m_9",Ym="_value_oip9m_14",so={list:Gm,key:Qm,value:Ym},Zm=({message:e,chainId:n})=>{const{typeUrl:s,value:o}=e;return t.jsx("div",{className:so.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{children:[t.jsx("div",{className:so.key,children:a}),t.jsx("div",{className:so.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?t.jsx(Hm,{msg:o,chainId:n,fallback:ws(r)}):ws(r)})]},a))})},Jm="_item_1n572_1",Xm="_title_1n572_10",eh="_content_1n572_14",oo={item:Jm,title:Xm,content:eh},ao=({title:e,content:n})=>t.jsxs("div",{className:oo.item,children:[t.jsx("div",{className:oo.title,children:e}),t.jsx("div",{className:oo.content,children:n})]});function te(e){const n=e?B(e).abs():void 0;if(n&&n.gt(0)&&n.lt(.01))return"< $0.01";const s=e&&B(e).lt(0),o=v.formatNumber(n?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function Ti(e,n){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")){if(o.type==="coin_spent"){const r=o.attributes.find(c=>c.key==="spender")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===n&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=s[l]||BigInt(0);s[l]=d-BigInt(c)}}}if(o.type==="coin_received"){const r=o.attributes.find(c=>c.key==="receiver")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===n&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=s[l]||BigInt(0);s[l]=d+BigInt(c)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),denom:o}))}function $i(e,n){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")&&o.type==="move"){const r=o.attributes.find(l=>l.key==="type_tag")?.value,i=o.attributes.find(l=>l.key==="data")?.value;if(!r||!i)continue;let c;try{c=JSON.parse(i)}catch{continue}if(r==="0x1::fungible_asset::WithdrawEvent"){const l=c.store_addr,d=c.amount,m=c.metadata_addr;if(l&&d&&m&&v.createUserDerivedObjectAddress(n,m)===l){const h=s[m]||BigInt(0);s[m]=h-BigInt(d)}}if(r==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,d=c.amount,m=c.metadata_addr;if(l&&d&&m&&v.createUserDerivedObjectAddress(n,m)===l){const h=s[m]||BigInt(0);s[m]=h+BigInt(d)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const Ei=({metadata:e,chain:n,children:s})=>{const{restUrl:o}=n,{data:a}=$.useSuspenseQuery({queryKey:In.denom(o,e).queryKey,queryFn:()=>z.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:K.INFINITY});return s(a)},th="_root_1p8a4_1",nh="_title_1p8a4_8",sh="_changes_1p8a4_14",oh="_change_1p8a4_14",ah="_amount_1p8a4_35",rh="_text_1p8a4_42",ih="_value_1p8a4_49",Ot={root:th,title:nh,changes:sh,change:oh,amount:ah,text:rh,value:ih},Mi=({amount:e,asset:n,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=n,c=v.formatAmount(e,{decimals:r}),l=s&&B(v.fromBaseUnit(e,{decimals:r})).times(s).abs();return t.jsxs("div",{className:Ot.change,children:[t.jsxs("div",{className:Ot.amount,children:[t.jsx(J,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:Ot.text,children:[c," ",a||o]})]}),l&&t.jsx("div",{className:Ot.value,children:te(l)})]})},ch=({changes:e,chain:n})=>{const s=mt(n),{data:o}=yt(n);return e.map(({amount:a,denom:r},i)=>{const c=s(r),l=o?.find(({id:d})=>d===r)?.price;return t.jsx(Mi,{amount:a,asset:c,price:l},i)})},lh=({changes:e,chain:n})=>{const s=mt(n),{data:o}=yt(n);return e.map(({amount:a,metadata:r},i)=>t.jsx(Ei,{metadata:r,chain:n,children:c=>{const l=o?.find(({id:d})=>d===c)?.price;return t.jsx(Mi,{amount:a,asset:s(c),price:l})}},i))};function dh(e,n){return typeof n=="bigint"?n.toString():n}const uh=ye.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,dh)]}),mh=({messages:e,memo:n,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=Ue(),r=Xe(s),{simulateTx:i}=Ds(),{data:c}=$.useSuspenseQuery({queryKey:uh.simulate({messages:e,memo:n,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:n,chainId:s}),staleTime:K.SECOND}),l=h=>t.jsxs("div",{className:Ot.root,children:[t.jsx("h2",{className:Ot.title,children:"Estimated changes"}),t.jsx("div",{className:Ot.changes,children:h})]});if(!c)return null;const d=c.result?.events??[];if(d.length===0)return null;if(r.metadata?.is_l1||r.metadata?.minitia?.type==="minimove"){const h=$i(d,a),[f]=qa(h);return f.length===0?null:l(t.jsx(lh,{changes:f,chain:r}))}const m=Ti(d,o),[u]=qa(m);return u.length===0?null:l(t.jsx(ch,{changes:u,chain:r}))};function qa(e){return T.partition(n=>new B(n.amount).isNegative(),e)}const hh="_title_1d032_1",fh="_meta_1d032_7",ph="_footer_1d032_14",gh="_rejectButton_1d032_19",ns={title:hh,meta:fh,footer:ph,rejectButton:gh},Li=()=>{const{txRequest:e,resolve:n,reject:s}=si(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:c,spendCoins:l}=e,d=Xe(r),m=qn(d),u=zo(d),h=Ho(d),f=mt(d),p=ni(),g=(e.gasPrices??u).map(({amount:A,denom:L})=>je.calculateFee(Math.ceil(i*c),je.GasPrice.fromString(A+L))),_=g.map(A=>A.amount[0]),y=A=>{const L=m.find(H=>H.denom===A)?.amount??"0",N=_.find(H=>H.denom===A)?.amount??"0",k=l.filter(H=>H.denom===A).reduce((H,Q)=>B(H).plus(Q.amount),B("0")),P=B(N).plus(k),R=B(L).gte(P),{symbol:O,decimals:V}=f(A);return{symbol:O,decimals:V,spend:k.gt(0)?k.toFixed():null,fee:N,total:P.toFixed(),balance:L,isSufficient:R}},j=()=>{if(h&&y(h).isSufficient)return h;for(const{denom:A}of _)if(y(A).isSufficient)return A;return _[0]?.denom},[b,w]=x.useState(j),{mutate:C,isPending:I}=$.useMutation({mutationKey:[ei],mutationFn:async()=>{const A=g.find(N=>N.amount[0].denom===b);if(!A)throw new Error("Fee not found");const L=await p({chainId:r,messages:o,memo:a||"",fee:A,preferredFeeDenom:b,allowAutoSign:!e.internal,allowWalletDerivation:!0});await n(L)},onError:async A=>{s(A)}}),E=y(b),M=!E.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(nt,{children:[t.jsx("h1",{className:ns.title,children:"Confirm tx"}),t.jsxs("div",{className:ns.meta,children:[t.jsx(ao,{title:"Chain",content:r}),t.jsx(ao,{title:"Tx fee",content:t.jsx(Em,{options:g,value:b,onChange:w})}),a&&t.jsx(ao,{title:"Memo",content:a}),M&&t.jsx(fe,{level:"error",children:t.jsx(Rm,{...E})})]}),t.jsx(mh,{messages:o,memo:a,chainId:r}),t.jsx(jm,{list:o,renderHeader:({typeUrl:A})=>Ns.sentenceCase(A.split(".").pop().replace(/^Msg/,"")),renderContent:A=>t.jsx(Zm,{message:A,chainId:r})})]}),t.jsxs(xe,{className:ns.footer,children:[t.jsx(le.Outline,{onClick:()=>s(new Error("User rejected")),disabled:I,className:ns.rejectButton,"aria-label":"Reject",children:t.jsx(S.IconClose,{size:16})}),t.jsx(le.White,{onClick:()=>C(),disabled:M,loading:I,children:"Approve"})]})]})},_h=({children:e})=>{const[{title:n,content:s,path:o},a]=x.useState({}),[r,i]=x.useState(!1),c=U.useAtomValue(Ps),l=x.useCallback(u=>{a(u),i(!0)},[]),d=x.useCallback(()=>{a({}),i(!1)},[]),m=x.useCallback(u=>{u||(c?.reject(new Error("User rejected")),a({})),i(u)},[c]);return t.jsxs(Yr.Provider,{value:{openModal:l,closeModal:d},children:[e,t.jsx(Si,{title:n,open:r,onOpenChange:m,children:t.jsx(me,{children:o==="/tx"?t.jsx(Li,{}):s})})]})},xh="_container_1w1hx_1",yh="_toast_1w1hx_11",jh="_info_1w1hx_24",wh="_success_1w1hx_28",bh="_error_1w1hx_32",vh="_icon_1w1hx_37",Ch="_content_1w1hx_45",Nh="_title_1w1hx_48",kh="_description_1w1hx_53",Ih="_close_1w1hx_75",kt={container:xh,toast:yh,info:jh,success:wh,error:bh,icon:vh,content:Ch,title:Nh,description:kh,close:Ih},Ah=({notification:e,onClose:n,...s})=>{const o=lt.useTransition(e,{keys:r=>r?.id||"empty",from:{transform:"translateY(-52px)",opacity:0},enter:{transform:"translateY(0px)",opacity:1},leave:{transform:"translateY(-52px)",opacity:0},config:{tension:500,friction:30,clamp:!0}}),a=r=>{switch(r){case"loading":return t.jsx(ut,{size:16});case"info":case"success":return t.jsx(S.IconCheckCircleFilled,{size:16});case"error":return t.jsx(S.IconCloseCircleFilled,{size:16});default:return null}};return o((r,i)=>{if(!i)return null;const{type:c,title:l,description:d}=i,m=a(c);return t.jsx(lt.animated.div,{style:r,className:kt.container,children:t.jsxs("div",{className:q(kt.toast,c&&kt[c]),...s,children:[m&&t.jsx("div",{className:kt.icon,children:m}),t.jsxs("div",{className:kt.content,children:[t.jsx("p",{className:kt.title,children:l}),d&&t.jsx("div",{className:kt.description,children:d})]}),t.jsx("button",{className:kt.close,onClick:n,children:t.jsx(S.IconClose,{size:14})})]})})})},ro=5e3,Sh=({children:e})=>{const n=Ht(),[s,o]=x.useState(null),a=x.useRef(null),r=x.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},c=x.useCallback(()=>{i(),o(null)},[]),l=x.useCallback(h=>{i(),o({...h,id:ba.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),ro))},[c]),d=x.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:ba.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),ro))},[c]),m=()=>{i(),r.current=!0},u=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>c(),ro))};return x.useEffect(()=>()=>i(),[]),t.jsxs(ki.Provider,{value:{showNotification:l,updateNotification:d,hideNotification:c},children:[e,n&&Ac.createPortal(t.jsx(Ah,{notification:s,onClose:c,onMouseEnter:m,onMouseLeave:u}),n)]})},Th=({children:e})=>{const[n,s]=x.useState(null);return t.jsx(Fs.Provider,{value:{container:n,setContainer:s},children:e})},qi=[{value:10*Er,label:"for 10 minutes"},{value:Mr,label:"for 1 hour"},{value:ka,label:"for 1 day"},{value:7*ka,label:"for 7 days"},{value:0,label:"until revoked"}],$h=qi[0].value;function Eh(e){const n=e.split(".");return n.length!==4?!1:n.every(s=>{if(!/^\d+$/.test(s))return!1;const o=Number(s);return o>=0&&o<=255})}function Pi(e){return Eh(e)||e.includes(":")}function vo(e){const n=Sc.parse(e);return"error"in n?null:n.domain}function Mh(e,n){return e===n||e===`www.${n}`}function Lh(e){if(e.protocol!=="https:")return!1;const n=e.hostname.toLowerCase();return!n||!n.includes(".")||n==="localhost"||Pi(n)?!1:vo(n)!==null}function qh(e,n){try{const s=new URL(e);if(!Lh(s))return!1;const o=s.hostname.toLowerCase(),a=n.toLowerCase();if(!o||!a||Pi(a)||a==="localhost")return!1;const r=vo(o);if(!r)return!1;const i=vo(a);return!i||i!==r?!1:Mh(o,r)?a===r||a.endsWith(`.${r}`):a===o||a.endsWith(`.${o}`)}catch{return!1}}const Ph="_container_1422v_1",Dh="_title_1422v_7",Bh="_description_1422v_14",Rh="_sectionTitle_1422v_20",Fh="_websiteInfo_1422v_27",Uh="_favicon_1422v_37",Oh="_websiteTitle_1422v_42",Vh="_websiteHost_1422v_48",Kh="_warningContent_1422v_54",Wh="_ignoreButton_1422v_61",zh="_infoList_1422v_65",Hh="_infoItem_1422v_75",Gh="_label_1422v_84",Qh="_infoValue_1422v_94",Yh="_durationTrigger_1422v_100",Zh="_durationItem_1422v_101",Jh="_featureList_1422v_105",Xh="_featureItem_1422v_113",ef="_checkIcon_1422v_123",tf="_learnMoreLink_1422v_127",nf="_feedbackContainer_1422v_140",sf="_footer_1422v_146",ie={container:Ph,title:Dh,description:Bh,sectionTitle:Rh,websiteInfo:Fh,favicon:Uh,websiteTitle:Oh,websiteHost:Vh,warningContent:Kh,ignoreButton:Wh,infoList:zh,infoItem:Hh,label:Gh,infoValue:Qh,durationTrigger:Yh,durationItem:Zh,featureList:Jh,featureItem:Xh,checkIcon:ef,learnMoreLink:tf,feedbackContainer:nf,footer:sf};function of(e){return e instanceof z.HTTPError&&e.response.status===404}const af=ye.createQueryKeys("interwovenkit:account",{info:(e,n)=>({queryKey:[e,n],queryFn:async()=>{const s=z.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${n}`;try{return await s.get(o).json(),!0}catch(a){if(of(a))return!1;throw a}}})}),rf=()=>{const[e,n]=x.useState($h),[s,o]=U.useAtom(Pn),[a,r]=x.useState(!1),i=Fe(),c=de(),{address:l,username:d}=Ue(),{mutate:m,isPending:u}=ld(),{closeDrawer:h}=jt();if(!s)throw new Error("Pending request not found");const{logoUrl:f,name:p,restUrl:g}=i(s.chainId),{data:_,isLoading:y,isError:j}=$.useQuery(af.info(g,l)),b={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},w=c.find(k=>k.chainId===s.chainId),C=w?.website?qh(w.website,window.location.hostname):!1,I=()=>{m(e)},E=()=>{s?.reject(new Error("User cancelled")),o(null),h()},M=!C&&!a,A=!y&&!j&&_===!1,L=!y&&j,N=M||y||j||_===!1;return t.jsxs(t.Fragment,{children:[t.jsxs(nt,{className:ie.container,children:[t.jsxs("header",{children:[t.jsx("h1",{className:ie.title,children:"Enable auto-signing"}),t.jsx("p",{className:ie.description,children:"An application is requesting to enable auto-signing"})]}),t.jsxs("section",{children:[t.jsx("h2",{className:ie.sectionTitle,children:"Requested by"}),t.jsxs("div",{className:ie.websiteInfo,children:[t.jsx("img",{src:b.favicon,alt:"",className:ie.favicon}),t.jsxs("div",{children:[t.jsx("div",{className:ie.websiteTitle,children:b.title}),t.jsx("div",{className:ie.websiteHost,children:b.hostname})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:ie.sectionTitle,children:"Applies to"}),t.jsxs("div",{className:ie.infoList,children:[t.jsxs("div",{className:ie.infoItem,children:[t.jsx("div",{className:ie.label,children:"Address"}),t.jsxs("div",{className:ie.infoValue,children:[t.jsx(S.IconWallet,{size:14}),t.jsx("span",{className:"monospace",children:v.truncate(d??l)})]})]}),t.jsxs("div",{className:ie.infoItem,children:[t.jsx("div",{className:ie.label,children:"Chain"}),t.jsxs("div",{className:ie.infoValue,children:[t.jsx(J,{src:f,width:14,height:14,logo:!0}),t.jsx("span",{children:p})]})]}),t.jsxs("div",{className:ie.infoItem,children:[t.jsx("div",{className:ie.label,children:"Duration"}),t.jsx(sa,{options:qi,value:e,onChange:n,classNames:{trigger:ie.durationTrigger,item:ie.durationItem}})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:ie.sectionTitle,children:"About auto-signing"}),t.jsx("ul",{className:ie.featureList,children:["Send transactions without confirmation pop-ups","Secured by your wallet signature","Revoke permissions any time in settings"].map(k=>t.jsxs("li",{className:ie.featureItem,children:[t.jsx(S.IconCheckCircle,{size:12,className:ie.checkIcon}),t.jsx("span",{children:k})]},k))}),t.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",rel:"noopener noreferrer",className:ie.learnMoreLink,children:["Learn more ",t.jsx(S.IconExternalLink,{size:12})]})]})]}),t.jsxs(xe,{className:ie.footer,extra:t.jsxs("div",{className:ie.feedbackContainer,children:[A&&t.jsx(fe,{level:"error",children:"Insufficient balance for fee"}),L&&t.jsx(fe,{level:"warning",children:"Unable to verify account status. Try again."}),!C&&!a&&t.jsx(fe,{level:"warning",children:t.jsxs("div",{className:ie.warningContent,children:[t.jsx("span",{children:"You are on an unverified website"}),t.jsx("button",{onClick:()=>r(!0),className:ie.ignoreButton,children:"Ignore"})]})})]}),children:[t.jsx(le.Outline,{onClick:E,children:"Cancel"}),t.jsx(le.White,{onClick:I,disabled:N,loading:u,children:"Enable"})]})]})},cf=()=>U.useAtomValue(Pn)?t.jsx(rf,{}):null,lf="_container_mqvhs_1",df="_badge_mqvhs_5",Pa={container:lf,badge:df},Di=e=>{const{offset:n=-4,disabled:s,children:o,className:a}=e;return t.jsxs("div",{className:q(Pa.container,a),children:[o,!s&&t.jsx("div",{className:Pa.badge,style:{right:n,top:n}})]})},uf="_header_s7mee_1",mf="_back_s7mee_12",hf="_title_s7mee_24",io={header:uf,back:mf,title:hf},ht=({title:e,backButton:n,extra:s,children:o})=>{const a=br();return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:io.header,children:[t.jsx(cn,{to:n??(a.length>1?-1:"/"),className:io.back,shouldReset:!!n,children:t.jsx(S.IconBack,{size:16})}),t.jsx("h1",{className:io.title,children:e}),s]}),t.jsx(nt,{children:o})]})};function Bi(){const{initiaAddress:e,hexAddress:n}=Ue(),s=wt(),o=On();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return n;default:return""}}}function Ri(){const e=wt(),n=On();return(s,o)=>{const a=e(o);switch(n(a)){case"initia":return v.InitiaAddress.validate(s);case"evm":return ct.isAddress(s);case"cosmos":try{return se.fromBech32(s).prefix===a.bech32_prefix}catch{return!1}default:return!1}}}function ff(){const e=wt(),n=On();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),c=n(i),l=e(a),d=n(l);if(c==="evm"&&d==="initia")return v.InitiaAddress(s).bech32;if(c==="initia"&&d==="evm")return v.InitiaAddress(s).hex;if(c===d)return s;if(r){if(d==="initia")return v.InitiaAddress(r).bech32;if(d==="evm")return v.InitiaAddress(r).hex}return""}}const pf="_root_ekn9t_1",gf="_header_ekn9t_6",_f="_title_ekn9t_12",xf="_warning_ekn9t_18",yf="_content_ekn9t_22",jf="_footer_ekn9t_26",wf="_secondary_ekn9t_36",Lt={root:pf,header:gf,title:_f,warning:xf,content:yf,footer:jf,secondary:wf},Fi=e=>{const{type:n,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return t.jsxs(nt,{className:Lt.root,children:[t.jsxs("header",{className:q(Lt.header,n&&Lt[n]),children:[s,t.jsx("h1",{className:Lt.title,children:o})]}),t.jsx("div",{className:Lt.content,children:a}),t.jsxs("footer",{className:Lt.footer,children:[t.jsx(le.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),t.jsxs("button",{className:Lt.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(S.IconChevronRight,{size:14})]})]})]})},bf="_list_k4n3k_1",vf="_row_k4n3k_9",Cf="_dt_k4n3k_20",Nf="_asset_k4n3k_26",ss={list:bf,row:vf,dt:Cf,asset:Nf},kf=({list:e,onNavigate:n,onDismiss:s})=>{const o=re(),a=Fe(),r=mt(o);return t.jsx(Fi,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:n},secondaryButton:{label:"Do not show again",onClick:s},children:t.jsx("div",{className:ss.list,children:e.toSorted((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:d})=>{const m=a(c),{decimals:u,symbol:h}=r(d),f=v.formatAmount(l,{decimals:u});return t.jsxs("div",{className:ss.row,children:[t.jsxs("div",{className:ss.dt,children:[t.jsx(J,{src:m.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:m.name})]}),t.jsxs("span",{className:ss.asset,children:[f," ",h]})]},i)})})})};function co(e,n){return e.chainId===n.chainId&&e.txHash===n.txHash}const os=({chainId:e,txHash:n})=>`${ae.OP_REMINDER}:${e}:${n}`,If=Tc.atomWithStorage(ae.OP_REMINDER,[]);function fn(){const e=X(),[n=[],s]=U.useAtom(If),o=x.useMemo(()=>n.map(l=>{const d=localStorage.getItem(os(l));return d?JSON.parse(d):null}).filter(l=>{if(!l)return!1;const{recipient:d,claimableAt:m}=l;return d!==e?!1:Re.isPast(m)}),[e,n]),a=x.useCallback((l,d)=>{n.some(m=>co(m,l))||(s((m=[])=>[...m,l]),localStorage.setItem(os(l),JSON.stringify(d)))},[n,s]),r=x.useCallback(l=>{s((d=[])=>d.filter(m=>!co(m,l))),localStorage.removeItem(os(l))},[s]),i=x.useCallback(l=>{const d=l.filter(m=>!n.some(u=>co(u,m)));d.length!==0&&s((m=[])=>[...m,...d])},[n,s]),c=x.useCallback((l,d)=>{localStorage.setItem(os(l),JSON.stringify(d)),s((m=[])=>[...m])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:c}}function Ui(){const e=Ce(),{openModal:n,closeModal:s}=qs(),{reminders:o,setReminder:a}=fn();x.useEffect(()=>{const r=o.filter(l=>!l.dismissed);if(r.length===0)return;const i=()=>{const l=r.every(d=>d.chainId===r[0].chainId)?r[0].chainId:void 0;e("/op/withdrawals",{chainId:l}),c()},c=()=>{s();for(const l of r)a(l,{...l,dismissed:!0})};n({content:x.createElement(kf,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,n,a])}const Af="_wrapper_5ssm8_1",Sf="_balance_5ssm8_11",Tf="_button_5ssm8_15",lo={wrapper:Af,balance:Sf,button:Tf},Oi=({onClick:e,children:n,disabled:s})=>t.jsxs("div",{className:lo.wrapper,children:[t.jsx(S.IconWallet,{size:16}),t.jsx("span",{className:lo.balance,children:n}),t.jsx("button",{type:"button",tabIndex:-1,className:lo.button,onClick:()=>e(),disabled:s,children:"MAX"})]}),$f="_fieldset_up6fh_1",Ef="_upper_up6fh_9",Mf="_select_up6fh_14",Lf="_account_up6fh_20",qf="_lower_up6fh_25",Pf="_wrapper_up6fh_26",Df="_balance_up6fh_33",Bf="_value_up6fh_37",Rf="_error_up6fh_50",pt={fieldset:$f,upper:Ef,select:Mf,account:Lf,lower:qf,wrapper:Pf,balance:Df,value:Bf,error:Rf},Co=e=>{const{selectButton:n,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:c}=e;return t.jsxs("div",{className:pt.fieldset,children:[t.jsxs("div",{className:pt.upper,children:[t.jsx("div",{className:pt.select,children:n}),t.jsx("div",{className:pt.account,children:s})]}),!c&&t.jsxs("div",{className:pt.lower,children:[o,t.jsxs("div",{className:pt.wrapper,children:[t.jsx("div",{className:pt.balance,children:a}),r&&t.jsx("div",{className:pt.value,children:r})]}),i&&t.jsxs("footer",{className:pt.error,children:[t.jsx(S.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function Kn(){const e=x.useRef(null),n=Rs();return x.useEffect(()=>{n||e.current?.focus()},[n]),e}const Ff="_input_h8073_1",Uf={input:Ff};function Vi(e){const{name:n,control:s,dp:o=6,className:a,rules:r,...i}=e,c=Kn();return t.jsx(_e.Controller,{name:n,control:s,rules:r,render:({field:l})=>t.jsx($c.NumericFormat,{value:l.value,getInputRef:lr.mergeRefs([l.ref,c]),className:q(Uf.input,a),onValueChange:d=>{l.onChange(d.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const Of="_input_19r9r_1",Vf="_placeholder_19r9r_18",No={input:Of,placeholder:Vf},Kf=({children:e})=>t.jsx("p",{className:q(No.input,{[No.placeholder]:B(e).isZero()}),children:e}),En=({balance:e,decimals:n,className:s})=>{const{control:o}=_e.useFormContext(),a={required:"Enter amount",validate:r=>B(r).isZero()?"Enter amount":B(v.toBaseUnit(r,{decimals:n})).gt(e??0)?"Insufficient balance":!0};return t.jsx(Vi,{name:"quantity",control:o,className:q(No.input,s),rules:a})};En.ReadOnly=Kf;const dn=({title:e,content:n,children:s,className:o})=>{const[a,r]=x.useState(!1),i=()=>r(!1);return t.jsx(Si,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:n(i)})},Wf="_tooltip_19kvs_1",zf="_arrow_19kvs_44",Da={tooltip:Wf,arrow:zf},Wn=({label:e,children:n,small:s,...o})=>t.jsxs(Z.Tooltip.Root,{...o,children:[t.jsx(Z.Tooltip.Trigger,{asChild:!0,children:n}),t.jsx(Z.Tooltip.Portal,{container:Ht(),children:t.jsxs(Z.Tooltip.Content,{className:q(Da.tooltip,{small:s}),collisionBoundary:Ht(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(Z.Tooltip.Arrow,{className:Da.arrow})]})})]});function oa(e,n){const s=tt();return $.useQuery({queryKey:Me.balances(n,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[n]:{address:e,denoms:[]}}}}).json(),select:({chains:o})=>e?o?o[n].denoms??{}:{}:{},enabled:!!e,staleTime:K.SECOND})}function Hf(e,n,s){const{data:o={}}=oa(e,n);return T.path([s],o)}const Gf=[["d",1440*60],["h",3600],["m",60],["s",1]];function Mn(e){if(!e)return;const{formattedParts:n}=Gf.reduce(({remainingSeconds:s,formattedParts:o},[a,r])=>{const i=Math.floor(s/r);return{remainingSeconds:s-i*r,formattedParts:i>0?[...o,`${i}${a}`]:o}},{remainingSeconds:e,formattedParts:[]});return n.join(" ")}function aa(e){return e?.map(n=>{const{amount:s,origin_asset:o}=n;return`${v.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function ko(e,n){const{watch:s}=St(),o=s(),a=tt(),r=un(),i={...o,quantity:e},c=!o.srcChainId||!o.srcDenom||!o.dstChainId||!o.dstDenom,l=B(i.quantity||0),d=l.isFinite()&&l.gt(0),m=$.useQueryClient();return $.useQuery({queryKey:Me.route(i,n?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:u,srcDenom:h,quantity:f,dstChainId:p,dstDenom:g}=i,{decimals:_}=m.getQueryData(Me.asset(u,h).queryKey)??{decimals:0},y={amount_in:v.toBaseUnit(f,{decimals:_}),source_asset_chain_id:u,source_asset_denom:h,dest_asset_chain_id:p,dest_asset_denom:g,is_op_withdraw:n?.isOpWithdraw},j=await a.post("v2/fungible/route",{json:y}).json(),b={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return r("Bridge Simulation Success",b),j},enabled:d&&!n?.disabled&&!c,staleTime:K.MINUTE})}function Qf(e){return $.useQuery({queryKey:Me.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof z.HTTPError))return null;const{response:n}=e;return(n.headers.get("content-type")??"").includes("application/json")?(await n.json()).info??null:null},enabled:!!e})}function Yf(){const{watch:e}=St(),{srcChainId:n,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=Ge(n),i=Tn(r),c=dt(s,n),l=dt(a,o),d=re(),m=de();return i==="initia"&&o===d.chainId&&c.symbol===l.symbol&&m.find(u=>u.chainId===n)?.metadata?.op_denoms?.includes(l.denom)}const Zf="_label_t93ix_1",Jf="_wrapper_t93ix_7",Xf="_input_t93ix_10",ep="_clear_t93ix_18",as={label:Zf,wrapper:Jf,input:Xf,clear:ep},ra=({mode:e="onChange",myAddress:n,...s})=>{const{validate:o=v.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,c=Kn(),{control:l,getValues:d,setValue:m,formState:u}=_e.useFormContext(),h=d("recipient"),[f,p]=x.useState(h),g=xr(),{data:_,isLoading:y,error:j}=$.useQuery({queryKey:As.address(g.restUrl,f).queryKey,queryFn:()=>g.getAddress(f),staleTime:K.MINUTE,enabled:g.validateUsername(f)}),b=_??(o(f)?f:""),w=n&&v.InitiaAddress.equals(b,n),C=async()=>{try{const M=await navigator.clipboard.readText();p(M.trim())}catch{}};x.useEffect(()=>{e==="onChange"&&(!f&&!u.dirtyFields.recipient||m("recipient",_??f,{shouldValidate:!0,shouldDirty:!0}))},[u.dirtyFields.recipient,f,e,m,_]);const I=()=>{y||j||(m("recipient",b,{shouldValidate:!0,shouldDirty:!0}),r?.())},E=()=>{if(y)return t.jsx(sn,{level:"loading",children:"Resolving username..."});if(j)return t.jsx(sn,{level:"error",children:j.message});if(_)return t.jsx(sn,{level:"success",className:"monospace",children:_});if(e==="onSubmit"&&f&&!b)return t.jsx(sn,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:as.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(le.Small,{type:"button",tabIndex:-1,onClick:C,children:"Paste"})]}),t.jsxs("div",{className:as.wrapper,children:[t.jsx(_e.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:M=>o(M)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:q(as.input,"monospace"),value:f,onChange:M=>p(M.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?lr.mergeRefs([i,c]):i})}),!!f&&t.jsx("button",{type:"button",className:as.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:t.jsx(S.IconCloseCircleFilled,{size:16})})]}),E(),w&&t.jsx(sn,{children:"This is my address"}),e==="onSubmit"&&t.jsx(xe,{extra:(!n||!!b&&!w)&&t.jsx(fe,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:t.jsx(le.White,{type:"button",onClick:I,disabled:y||!!j||!b,children:"Apply"})})]})},tp="_scrollable_vgj3r_1",np="_list_vgj3r_5",sp="_item_vgj3r_9",op="_name_vgj3r_22",rs={scrollable:tp,list:np,item:sp,name:op};function Ki({onSelect:e,list:n,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:c}=s;return t.jsx(nt,{className:rs.scrollable,children:t.jsx("div",{className:rs.list,children:n.map(l=>t.jsxs("button",{className:rs.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),children:[t.jsx(J,{src:o(l),width:28,height:28}),t.jsx("span",{className:rs.name,children:a(l)}),i?.(l)&&t.jsx(ut,{size:16})]},r(l)))})})}function Vs(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:s=>e.find(o=>o.name===s)}}const ap="_account_h04x1_8",rp="_clear_h04x1_28",ip="_white_h04x1_39",xn={account:ap,clear:rp,white:ip},Ba=({type:e})=>{const{watch:n,setValue:s}=St(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=n(),c=n(e==="src"?"sender":"recipient"),l=Tn(Ge(a)),{list:d,find:m}=Vs(),u=m(r),h=Bi(),f=Ri(),p=h(a),g=v.InitiaAddress.equals(c,p),_=()=>t.jsx(dn,{title:"Connect wallet",content:b=>t.jsx(Ki,{onSelect:async w=>{const C=w.getProvider();if(!C)return window.open(w.fallbackUrl,"_blank");const I=C.getOfflineSigner(o),[{address:E}]=await I.getAccounts();s("sender",E),s("cosmosWalletName",w.name),b()},list:d,getImage:w=>w.image,getName:w=>w.name,getKey:w=>w.name}),className:q(xn.account,{[xn.white]:!c}),children:c?t.jsxs(t.Fragment,{children:[u&&t.jsx(J,{src:u.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:v.truncate(c)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(S.IconChevronRight,{size:14})]})}),y=b=>t.jsx(dn,{title:"Recipient",content:w=>t.jsx(nt,{children:t.jsx(ra,{mode:"onSubmit",myAddress:p,chainType:l,validate:C=>f(C,a),onApply:w})}),className:xn.account,children:b}),j=()=>{switch(l){case"initia":case"evm":return g?y(t.jsx(S.IconWallet,{size:14})):t.jsxs("div",{className:xn.account,children:[t.jsx("span",{className:"monospace",children:v.truncate(c)}),t.jsx("button",{type:"button",className:xn.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(S.IconCloseCircleFilled,{size:14})})]});case"cosmos":return y(t.jsxs(t.Fragment,{children:[c?t.jsx("span",{className:"monospace",children:v.truncate(c)}):t.jsx("span",{children:"Recipient"}),t.jsx(S.IconEdit,{size:14})]}))}};switch(e){case"src":return _();case"dst":return j()}},cp="_images_cj4xz_1",uo={images:cp},Ks=({assetLogoUrl:e,assetLogoSize:n=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>t.jsxs("div",{className:q(uo.images,r),style:{position:"relative"},children:[t.jsx(J,{src:e,width:n,height:n,className:uo.asset,logo:!0}),t.jsx(J,{src:s,width:o,height:o,className:uo.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),lp="_root_6187w_1",dp="_content_6187w_10",up="_details_6187w_20",mp="_symbol_6187w_26",hp="_chain_6187w_34",fp="_chevron_6187w_43",qt={root:lp,content:dp,details:up,symbol:mp,chain:hp,chevron:fp},Wi=({asset:e,chain:n,readOnly:s})=>{const o=t.jsxs("div",{className:qt.content,children:[t.jsx(Ks,{assetLogoUrl:e.logoUrl,chainLogoUrl:n.logoUrl}),t.jsxs("div",{className:qt.details,children:[t.jsx("div",{className:qt.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:qt.chain,children:["on ",n.name]})]})]});return s?t.jsx("div",{className:qt.root,children:o}):t.jsxs("div",{className:qt.root,children:[o,t.jsx(S.IconChevronDown,{size:16,className:qt.chevron})]})};function pp(e,n,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return T.any(T.includes(n.toLowerCase()),a)})}const gp="_root_1sh27_1",_p="_label_1sh27_8",xp="_input_1sh27_21",yp="_hasValue_1sh27_31",jp="_clear_1sh27_35",yn={root:gp,label:_p,input:xp,hasValue:yp,clear:jp},zn=e=>{const{rootClassName:n,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return t.jsxs("div",{className:q(yn.root,n,{[yn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[t.jsx("label",{htmlFor:"search",className:yn.label,children:t.jsx(S.IconSearch,{size:o})}),t.jsx("input",{className:yn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&t.jsx("button",{type:"button",className:yn.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:a,children:t.jsx(S.IconCloseCircleFilled,{size:o})})]})},wp="_container_5tajg_1",bp="_search_5tajg_7",vp="_list_5tajg_11",Cp="_item_5tajg_15",Np="_logo_5tajg_37",kp="_info_5tajg_41",Ip="_symbol_5tajg_47",Ap="_name_5tajg_56",Sp="_balance_5tajg_62",Tp="_value_5tajg_69",He={container:wp,search:bp,list:vp,item:Cp,logo:Np,info:kp,symbol:Ip,name:Ap,balance:Sp,value:Tp},Hn=e=>{const{assets:n,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=x.useState(""),i=pp(["symbol"],a,n);return t.jsxs("div",{className:He.container,children:[t.jsx(zn,{value:a,onChange:c=>r(c.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:He.search,padding:20,ref:Kn()}),i.length===0?t.jsx(he,{children:"No assets"}):t.jsx("div",{className:He.list,children:i.map(c=>t.jsx("button",{type:"button",className:He.item,onClick:()=>s(c.denom),children:o(c,l=>{const{denom:d,logoUrl:m,symbol:u,name:h,balance:f,decimals:p,value:g=0}=l;return t.jsxs(t.Fragment,{children:[t.jsx(J,{src:m,width:32,height:32,className:He.logo,logo:!0}),t.jsxs("div",{className:He.info,children:[t.jsx("div",{className:He.symbol,children:u||d}),t.jsx("div",{className:He.name,children:h})]}),t.jsxs("div",{className:He.balance,children:[f&&t.jsx("div",{children:v.formatAmount(f,{decimals:p})}),g>0&&t.jsx("div",{className:He.value,children:te(g)})]})]})})},c.denom))})]})},$p=()=>t.jsxs("div",{className:He.container,children:[t.jsx(zn,{rootClassName:He.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(he,{children:"Loading..."})]});Hn.Placeholder=$p;const Ep="_stack_16oqn_1",Mp="_title_16oqn_9",Lp="_grid_16oqn_16",qp="_item_16oqn_22",Pp="_button_16oqn_26",Dp="_active_16oqn_44",on={stack:Ep,title:Mp,grid:Lp,item:qp,button:Pp,active:Dp},Vt=({label:e,chains:n,value:s,onSelect:o,getShowIndicator:a})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:on.title,children:e}),t.jsx("div",{className:on.grid,children:n.map(({chainId:r,name:i,logoUrl:c})=>t.jsx(Di,{offset:-2,disabled:!a?.(r),className:on.item,children:t.jsx(Wn,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:q(on.button,{[on.active]:r===s}),onClick:()=>o(r),children:t.jsx(J,{src:c,width:28,height:28,logo:!0})})})},r))})]}),Bp=({children:e})=>t.jsx("div",{className:on.stack,children:e});Vt.Stack=Bp;const Rp=({address:e,chain:n,onSelect:s})=>{const o=ys(n.chain_id),{data:a={}}=oa(e,n.chain_id);return t.jsx(Hn,{assets:T.sortWith([T.descend(r=>r.symbol==="INIT"),T.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>B(i).comparedTo(r)??0,T.ascend(r=>r.symbol.toLowerCase())],o.filter(r=>!r.hidden).map(r=>{const{denom:i,symbol:c=v.truncate(i),logo_uri:l}=r,d=a[i]??{};return{...r,symbol:c,decimals:r.decimals??0,logoUrl:l??"",name:r.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:s})},Fp=({type:e,afterSelect:n})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=At(),i=Vn(),{watch:c,setValue:l}=St(),d=c(a),m=c(s),u=c(o),[h,f]=x.useState(m),p=Ge(h),g=ff(),_=ji(),[y,j]=T.partition(w=>_(w.chain_id),i.filter(w=>!w.hidden)),b=w=>{if(m===h&&u===w){n();return}l(s,h),l(o,w),n()};return t.jsxs(t.Fragment,{children:[t.jsxs(Vt.Stack,{children:[t.jsx(Vt,{label:"Interwoven Economy",chains:y.map(({chain_id:w,chain_name:C,pretty_name:I,logo_uri:E})=>({chainId:w,name:I||C,logoUrl:E??""})),value:h,onSelect:f}),t.jsx(Vt,{label:"Chains",chains:j.map(({chain_id:w,chain_name:C,pretty_name:I,logo_uri:E})=>({chainId:w,name:I||C,logoUrl:E??""})),value:h,onSelect:f})]}),t.jsx(me,{suspenseFallback:t.jsx(Hn.Placeholder,{}),children:t.jsx(Rp,{address:g({initialAddress:d,initialChainId:m,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:p,onSelect:b})},h)]})},Ra=({type:e})=>{const n=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=St(),r=a(n),i=a(s),c=Ge(r),l=dt(i,r);return t.jsx(dn,{title:o,content:d=>t.jsx(Fp,{type:e,afterSelect:d}),children:t.jsx(Wi,{asset:{denom:l.denom,decimals:l.decimals??0,symbol:l.symbol,logoUrl:l.logo_uri??""},chain:{chainId:c.chain_id,name:c.pretty_name||c.chain_name,logoUrl:c.logo_uri??""}})})},Up="_skeleton_1l4jn_1",Op={skeleton:Up},Kt=({width:e="100%",height:n})=>t.jsx("div",{className:Op.skeleton,style:{width:e,height:n}}),Vp="_stack_oq1ir_1",Kp="_button_oq1ir_6",Wp="_isLoading_oq1ir_19",zp="_disabled_oq1ir_19",Hp="_checked_oq1ir_23",Gp="_header_oq1ir_37",Qp="_title_oq1ir_43",Yp="_duration_oq1ir_52",Zp="_warning_oq1ir_62",Jp="_amount_oq1ir_66",Xp="_value_oq1ir_67",ze={stack:Vp,button:Kp,isLoading:Wp,disabled:zp,checked:Hp,header:Gp,title:Qp,duration:Yp,warning:Zp,amount:Jp,value:Xp},eg=({children:e})=>t.jsx("div",{className:ze.stack,children:e}),ms=({label:e,query:n,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=n,{watch:c}=St(),{dstChainId:l,dstDenom:d}=c(),m=dt(d,l),u=!i&&a.checked,h=!i&&!r;return t.jsxs("button",{type:"button",className:q(ze.button,{[ze.isLoading]:i,[ze.disabled]:h,[ze.checked]:u}),onClick:()=>{i||h||o(s)},children:[t.jsxs("div",{className:ze.header,children:[t.jsxs("div",{className:ze.title,children:[t.jsx("span",{children:e}),u&&t.jsx(S.IconCheck,{size:14})]}),i?t.jsx(Kt,{width:80,height:16}):r?t.jsxs("div",{className:q(ze.duration,{[ze.warning]:s==="op"}),children:[t.jsx(S.IconClockFilled,{size:12}),t.jsx("span",{children:Mn(r.estimated_route_duration_seconds)})]}):t.jsx("div",{className:ze.duration,children:"Not available"})]}),(i||r)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ze.amount,children:i?t.jsx(Kt,{width:260,height:40}):r?v.formatAmount(r.amount_out,{decimals:m.decimals}):null}),t.jsx("div",{className:ze.value,children:i?t.jsx(Kt,{width:120,height:16}):r?r.usd_amount_out?te(r.usd_amount_out):"$-":null})]})]})};ms.Stack=eg;const tg="_description_nuyvt_1",ng="_presets_nuyvt_8",sg="_preset_nuyvt_8",og="_active_nuyvt_29",ag="_custom_nuyvt_40",rg="_wrapper_nuyvt_47",ig="_percent_nuyvt_58",rt={description:tg,presets:ng,preset:sg,active:og,custom:ag,wrapper:rg,percent:ig},Fa=["0.1","0.5","1.0"],cg=({afterConfirm:e})=>{const n=St(),s=n.getValues("slippagePercent"),[o,a]=x.useState(null),{control:r,watch:i,getValues:c,setValue:l}=_e.useForm({defaultValues:{value:s}}),d=i("value");x.useEffect(()=>{const g=Fa.findIndex(_=>_===s);a(g>=0?g:null)},[s]);const m=(g,_)=>{l("value",g),a(_)},u=()=>{a(null)},h=x.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),f=h?.type==="error",p=({value:g})=>{n.setValue("slippagePercent",g),e()};return t.jsxs(nt,{children:[t.jsx("p",{className:rt.description,children:"Slippage is how much price movement you can tolerate between the time you send out a transaction and the time it's executed."}),t.jsxs("div",{className:rt.presets,children:[Fa.map((g,_)=>t.jsxs("button",{type:"button",className:q(rt.preset,{[rt.active]:o===_}),onClick:()=>m(g,_),children:[g,"%"]},g)),o!==null?t.jsx("button",{type:"button",className:q(rt.preset,rt.custom),onClick:()=>a(null),children:"Custom"}):t.jsxs("div",{className:rt.wrapper,children:[t.jsx(Vi,{name:"value",control:r,dp:2,onFocus:u,placeholder:"",className:q(rt.preset,rt.active)}),t.jsx("span",{className:rt.percent,children:"%"})]})]}),h&&t.jsx(fe,{level:h.type,children:h.text}),t.jsx(xe,{children:t.jsx(le.White,{type:"button",onClick:()=>p(c()),disabled:f,children:"Confirm"})})]})},lg="_form_1owk5_1",dg="_arrow_1owk5_5",ug="_divider_1owk5_14",mg="_flip_1owk5_23",hg="_meta_1owk5_41",fg="_row_1owk5_54",pg="_title_1owk5_60",gg="_description_1owk5_64",_g="_icon_1owk5_71",xg="_edit_1owk5_76",yg="_warning_1owk5_99",Pe={form:lg,arrow:dg,divider:ug,flip:mg,meta:hg,row:fg,title:pg,description:gg,icon:_g,edit:xg,warning:yg},jg=()=>{const e=Ce(),n=Rs(),[s,o]=Le.useLocalStorage(ae.BRIDGE_ROUTE_TYPE,"default"),{watch:a,setValue:r,handleSubmit:i,formState:c}=St(),l=a(),{srcChainId:d,srcDenom:m,dstChainId:u,dstDenom:h,quantity:f,sender:p,slippagePercent:g}=l,_=Fe(),y=Ge(d),j=Tn(y),b=Ge(u),w=Tn(b),C=dt(m,d),I=dt(h,u),{data:E}=oa(p,d),M=Hf(p,d,m),A=!M?.amount||B(M.amount).isZero(),[L]=Le.useDebounceValue(f,300),N=j!=="initia"&&w!=="initia",k=Yf(),P=ko(L,{disabled:N}),R=ko(L,{isOpWithdraw:!0,disabled:!k}),O=k&&s==="op",V=O?R:P,H=O?P:R,Q=O?!N:k,F=V.error&&Q?H:V,{data:W,isLoading:qe,isFetching:we,error:st}=F,{data:Oe}=Qf(st),Zt=L&&(qe||we),pn=()=>{r("srcChainId",u),r("srcDenom",h),r("dstChainId",d),r("dstDenom",m),r("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:Qn,closeModal:Yn}=qs(),ot=i(ne=>{if(W?.warning){const{type:$t="",message:Qs}=W.warning??{};Qn({content:t.jsx(Fi,{type:"warning",icon:t.jsx(S.IconWarningFilled,{size:40}),title:Ns.sentenceCase($t),primaryButton:{label:"Cancel",onClick:Yn},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:W,values:ne}),Yn()}},children:t.jsx("p",{className:Pe.warning,children:Qs})})});return}e("/bridge/preview",{route:W,values:ne})}),Ve=x.useMemo(()=>W?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_DEDUCTED")??[],[W]),vt=x.useMemo(()=>W?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_ADDITIONAL")??[],[W]),Jt=x.useMemo(()=>{for(const ne of vt){const $t=E?.[ne.origin_asset.denom]?.amount??"0",Qs=W?.source_asset_denom===ne.origin_asset.denom?W.amount_in:"0";if(B($t).lt(B(Qs).plus(ne.amount??"0")))return`Insufficient ${ne.origin_asset.symbol} for fees`}},[E,W,vt]),Zn=x.useMemo(()=>{if(!l.sender)return"Connect wallet";if(!l.quantity||!L)return"Enter amount";if(!l.recipient)return"Enter recipient address";if(c.errors.quantity)return c.errors.quantity.message;if(!W)return"Route not found";if(Jt)return Jt},[L,Jt,c,W,l]),wc=W?v.formatAmount(W.amount_out,{decimals:I.decimals}):"0",bc=B(f).gt(0)&&B(f).isEqualTo(v.fromBaseUnit(M?.amount,{decimals:M?.decimals??0})),vc=(()=>{switch(j){case"initia":return _(d).fees.fee_tokens.some(({denom:ne})=>ne===m);case"cosmos":return y.fee_assets.some(({denom:ne})=>ne===m);case"evm":return!ct.isAddress(m);default:return!1}})(),Gs=x.useCallback((ne,$t)=>ne.length?t.jsxs("div",{className:Pe.description,children:[aa(ne),!n&&t.jsx(Wn,{label:$t,children:t.jsx("span",{className:Pe.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]}):null,[n]),Jn=B(f).gt(0)&&k&&P.data&&R.data&&R.data.estimated_route_duration_seconds>P.data.estimated_route_duration_seconds,_a=x.useMemo(()=>W?[{condition:!!W.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Gs(Ve,"Fee deducted from the amount you receive"),Gs(vt,"Fee charged in addition to the amount you enter")]})},{condition:!Jn&&!!Mn(W.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:Pe.description,children:Mn(W.estimated_route_duration_seconds)})},{condition:W.does_swap,title:"Slippage",content:t.jsxs("span",{className:Pe.description,children:[t.jsxs("span",{children:[g,"%"]}),t.jsx(dn,{title:"Slippage tolerance",content:ne=>t.jsx(cg,{afterConfirm:ne}),className:Pe.edit,children:t.jsx(S.IconSettingFilled,{size:12})})]})}].filter(ne=>ne.condition):[],[vt,Ve,Gs,W,Jn,g]);return t.jsxs("form",{className:Pe.form,onSubmit:ot,children:[t.jsx(Co,{selectButton:t.jsx(Ra,{type:"src"}),accountButton:j==="cosmos"&&t.jsx(Ba,{type:"src"}),quantityInput:t.jsx(En,{balance:M?.amount,decimals:C?.decimals}),balanceButton:t.jsx(Oi,{onClick:()=>r("quantity",v.fromBaseUnit(M?.amount,{decimals:C?.decimals??0}),{shouldValidate:!0}),disabled:A,children:v.formatAmount(M?.amount??"0",{decimals:C.decimals})}),value:W?te(W.usd_amount_in):"$-"}),t.jsxs("div",{className:Pe.arrow,children:[t.jsx("div",{className:Pe.divider}),t.jsx("button",{type:"button",className:Pe.flip,onClick:()=>pn(),children:t.jsx(S.IconChevronDown,{size:16})})]}),t.jsx(Co,{selectButton:t.jsx(Ra,{type:"dst"}),accountButton:t.jsx(Ba,{type:"dst"}),quantityInput:t.jsx(En.ReadOnly,{children:wc}),value:W?te(W.usd_amount_out):"$-",hideNumbers:Jn}),t.jsx($n,{children:Jn?t.jsxs(ms.Stack,{children:[t.jsx(ms,{label:"Fast",query:P,value:"default",onSelect:o,checked:s==="default"}),t.jsx(ms,{label:"Lossless",query:R,value:"op",onSelect:o,checked:s==="op"})]}):null}),t.jsx(xe,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(fe.Stack,{children:[W?.extra_infos?.map(ne=>t.jsx(fe,{level:"info",children:ne},ne)),Oe&&t.jsx(fe,{level:"info",children:Oe}),bc&&vc&&t.jsx(fe,{level:"warning",children:"Make sure to leave enough for transaction fee"}),W?.warning&&t.jsx(fe,{level:"warning",children:W.warning.message}),W?.extra_warnings?.map(ne=>t.jsx(fe,{level:"warning",children:ne},ne))]}),t.jsx($n,{children:_a.length>0&&t.jsx("div",{className:Pe.meta,children:_a.map((ne,$t)=>t.jsxs("div",{className:Pe.row,children:[t.jsx("span",{className:Pe.title,children:ne.title}),ne.content]},$t))})})]}),children:t.jsx(le.White,{loading:Zt&&"Simulating...",disabled:!!Zn,children:Zn??"Preview route"})})]})},wg=()=>{Ui();const e=br(),n=Ce(),s=At(),o=Zd(),a=_e.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:c,dstChainId:l,srcDenom:d,dstDenom:m,quantity:u,slippagePercent:h,recipient:f}=r();r((k,{name:P})=>{(P==="srcChainId"||P==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=Bi(),g=p(c),_=p(l),j=Ri()(f,l);x.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",g)},[c,g,i]),x.useEffect(()=>{j||i("recipient",_)},[_,j,i]);const{showNotification:b}=Os(),w=Ge(c),C=Ge(l),I=ys(c),E=ys(l),M=I.some(k=>k.denom===d),A=E.some(k=>k.denom===m);x.useEffect(()=>{I.length>0&&!M&&(i("srcDenom",I[0].denom),b({type:"info",title:`Switched to ${I[0].symbol}`,description:`The selected asset is not available on ${w.pretty_name}.`,autoHide:!0}))},[I,M,i,b,w.pretty_name]),x.useEffect(()=>{E.length>0&&!A&&(i("dstDenom",E[0].denom),b({type:"info",title:`Switched to ${E[0].symbol}`,description:`The selected asset is not available on ${C.pretty_name}.`,autoHide:!0}))},[E,A,i,b,C.pretty_name]),x.useEffect(()=>{!M||!A||(localStorage.setItem(ae.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(ae.BRIDGE_SRC_DENOM,d),localStorage.setItem(ae.BRIDGE_DST_CHAIN_ID,l),localStorage.setItem(ae.BRIDGE_DST_DENOM,m),localStorage.setItem(ae.BRIDGE_QUANTITY,u),localStorage.setItem(ae.BRIDGE_SLIPPAGE_PERCENT,h))},[c,d,l,m,u,h,M,A]);const L=e[0].path==="/bridge",{reminders:N}=fn();return t.jsx(ht,{title:"Bridge/Swap",backButton:L?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(le.Small,{onClick:()=>n("/bridge/history"),unpadded:!0,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[t.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),t.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),t.jsx(Di,{offset:0,disabled:N.length===0,children:t.jsx(le.Small,{onClick:()=>n("/op/withdrawals"),disabled:!s,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:M&&A&&t.jsx(_e.FormProvider,{...a,children:t.jsx(me,{children:t.jsx(jg,{})})})})},bg="_button_1crvp_1",vg="_checkbox_1crvp_11",Cg="_checked_1crvp_25",is={button:bg,checkbox:vg,checked:Cg},Ng=({checked:e,onClick:n,label:s,className:o})=>t.jsxs("button",{type:"button",className:q(is.button,o),onClick:n,children:[t.jsx("div",{className:q(is.checkbox,{[is.checked]:e}),children:e&&t.jsx(S.IconCheck,{size:12})}),t.jsx("span",{className:is.label,children:s})]}),kg="_button_aoxv2_1",Ig={button:kg},zi=({onClick:e,disabled:n})=>{const{ref:s,inView:o}=Ec.useInView();return x.useEffect(()=>{o&&e()},[o,e]),t.jsxs("button",{className:Ig.button,onClick:e,disabled:n,ref:s,children:[t.jsx("span",{children:"Load more"}),t.jsx(S.IconChevronDown,{size:12})]})};function Hi(e,n){return e.reduce((s,o)=>{const a=n(o);if(!a)return s;const r=a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=s[r]||[];return{...s,[r]:[...i,o]}},{})}const hs=({chainId:e,txHash:n})=>`${ae.BRIDGE_HISTORY}:${e}:${n}`,bs=100,Ua=10;function Gi(){const[e,n]=Le.useLocalStorage(ae.BRIDGE_HISTORY,[]),s=x.useCallback((a,r)=>{localStorage.setItem(hs(a),JSON.stringify(r));for(const i of e.slice(bs-1))localStorage.removeItem(hs(i));n((i=[])=>[a,...i.slice(0,bs-1)])},[e,n]),o=x.useCallback(a=>{const r=localStorage.getItem(hs(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function Qi(e){return Le.useLocalStorage(hs(e),null)}const Yt=ye.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,n)=>[e,n],latestOutput:e=>[e],output:(e,n)=>[e,n],outputResponse:(e,n)=>[e,n],withdrawalClaimed:(e,n)=>[e,n]});function Ws(){const{restUrl:e}=re();return x.useMemo(()=>z.create({prefixUrl:e}),[e])}function Ag(e){const n=Ws(),{data:s}=$.useSuspenseQuery({queryKey:Yt.bridge(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:K.INFINITY});return s}const Oa=20;function Sg(e){const n=X();return $.useSuspenseInfiniteQuery({queryKey:Yt.withdrawals(e,n).queryKey,queryFn:async({pageParam:s})=>{if(!n)return[];const o={limit:Oa,offset:s,order:"desc"},{withdrawals:a}=await z.create({prefixUrl:e}).get(`withdrawals/${n}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=T.last(s)?.sequence;return s.length<Oa||!o||o<=1?null:o-1},initialPageParam:0,staleTime:K.SECOND})}function Tg(e){const n=Ws(),{data:s}=$.useSuspenseQuery({queryKey:Yt.latestOutput(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:o})=>{const[a]=o;return a||null},staleTime:K.SECOND});return s}function $g({bridge_id:e,output_index:n}){const s=Ws(),{data:o}=$.useSuspenseQuery({queryKey:Yt.output(e,n).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${n}`).json()}catch{return null}},staleTime:K.SECOND});return o}function Eg({bridge_id:e,sequence:n}){const o=de().find(({metadata:l})=>l?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const r=Fe()(o);if(!r)throw new Error(`Chain not found: ${o}`);const i=r.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${o}`);const{data:c}=$.useSuspenseQuery({queryKey:Yt.outputResponse(i,n).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${n}`).json(),staleTime:K.SECOND});return c}function Yi(e,n){const{bridge_id:s}=e,o=Ws(),{data:a}=$.useSuspenseQuery({queryKey:Yt.withdrawalClaimed(s,n).queryKey,queryFn:()=>o.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:n}}).json(),select:({claimed:r})=>r,staleTime:({state:{data:r}})=>r?.claimed?1/0:K.SECOND});return a}function jn(e){return Mc.sha3_256.create().update(e).digest()}function mo(e,n){const s=new ArrayBuffer(n);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function Zi(e){const{bridge_id:n,sequence:s,amount:o,from:a,to:r}=e,i=mo(n.toString(),8),c=mo(s.toString(),8),l=mo(o.amount,8),d=Ft.concatBytes(i,c,jn(Ft.utf8ToBytes(a)),jn(Ft.utf8ToBytes(r)),jn(Ft.utf8ToBytes(o.denom)),l);return jn(jn(d))}async function Mg(e,n,s){try{return await z.get(`${e}/opinit/ophost/v1/bridges/${n}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function Lg(e,n){const s=z.create({prefixUrl:n}),o=`cosmos/auth/v1beta1/account_info/${e}`;for(let a=1;a<=24;a++)try{return await s.get(o).json()}catch{await new Promise(r=>setTimeout(r,5e3))}throw new Error(`Timeout: ${e} not found`)}async function Io(e,n){const{chain_type:s,chain_id:o,chain_name:a,evm_fee_asset:r,rpc:i}=n;if(s!=="evm")throw new Error(`Chain is not an EVM chain: ${a}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}catch(c){if(T.path(["error","code"],c)!==4902)throw c;if(!r)throw new Error(`Fee asset is not defined for chain: ${a}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(o).toString(16)}`,chainName:a,nativeCurrency:r,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}}function bt(){return et()}function qg(e,n){const{customFee:s,onCompleted:o}=n??{},a=Ce(),{showNotification:r,updateNotification:i,hideNotification:c}=Os(),{addHistoryItem:l}=Gi(),d=un(),{route:m,values:u}=bt(),{srcChainId:h,sender:f,recipient:p,cosmosWalletName:g}=u,_=Kr(),{requestTxSync:y,submitTxSync:j,waitForTxConfirmation:b}=Ue(),{find:w}=Vs(),C=Dn(),I=Bn(),E=Ge(h),M=Tn(E),A=wi(h),L=$.useQueryClient(),{registryUrl:N}=ee(),k=Fe(),P=re(),{addReminder:R}=fn(),O=tt();return $.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const V=e.cosmos_tx.msgs.map(({msg_type_url:ot,msg:Ve})=>{if(!(ot&&Ve))throw new Error("Invalid transaction data");return I.fromAmino({type:Wt.aminoConverters[ot].aminoType,value:JSON.parse(Ve)})});if(M==="initia"){const{srcDenom:ot,quantity:Ve}=u,{decimals:vt}=A(ot),Jt=s?await j({messages:V,chainId:h,fee:s}):await y({messages:V,chainId:h,internal:1,spendCoins:[{denom:ot,amount:v.toBaseUnit(Ve,{decimals:vt})}]}),Zn=b({txHash:Jt,chainId:h});return{txHash:Jt,wait:Zn}}const H=w(g)?.getProvider();if(!H)throw new Error("Wallet not connected");const Q=H.getOfflineSignerOnlyAmino(h),F=await je.SigningStargateClient.connectWithSigner(E.rpc,Q,{registry:C,aminoTypes:I}),W=await F.getAllBalances(f),qe=E.fee_assets.find(ot=>W.some(Ve=>Ve.denom===ot.denom&&B(Ve.amount).gt(0)));if(!qe){const Ve=["Insufficient balance for fees.",`Available fee assets: ${E.fee_assets.map(vt=>A(vt.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Ve)}const{denom:we,gas_price:st}=qe;if(!st)throw new Error(`Gas price not found for ${we}`);const Oe=await F.simulate(f,V,""),Zt=je.GasPrice.fromString(st.average+we),pn=je.calculateFee(Math.ceil(Oe*zt),Zt),Qn=await F.signAndBroadcastSync(f,V,pn),Yn=oi({txHash:Qn,client:F});return{txHash:Qn,wait:Yn}}if("evm_tx"in e){const{chain_id:V,to:H,value:Q,data:F}=e.evm_tx,W=await _(),qe=await W.getSigner();await Io(W,E);const we=await qe.sendTransaction({chainId:V,to:H,value:Q,data:`0x${F}`});return{txHash:we.hash,wait:we.wait()}}throw new Error("Unlisted chain type")}catch(V){throw await _t(V)}},onSuccess:async({txHash:V,wait:H})=>{localStorage.removeItem(ae.BRIDGE_QUANTITY),o?o({txhash:V,chainId:h,timestamp:Date.now(),success:!0,route:m,values:u}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await H;const Q=ia(m)==="OP Bridge withdrawal",F=Q?{success:!0,error:null}:await Fg(O,V,h);if(!o&&!F.success&&F.error){const Oe=F.error instanceof Error?F.error.message:String(F.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${Oe}. The transaction may still be processing.`,autoHide:!0})}const W=F.success,we=Bg({txHash:V,srcChainId:h,route:m,values:u,recipient:p},W);l(we.tx,we.details),o||i(Dg(c));const st=ho(u,V);if(d("Bridge Transaction Success",st),Q){const Oe=k(h).metadata?.op_bridge_id;if(Oe&&!await Mg(P.restUrl,Number(Oe),m.dest_asset_denom)){const pn=Rg(we.tx,m,p);R(we.tx,pn)}}}catch(Q){const F=Q instanceof Error?Q.message:String(Q);o?o({success:!1,error:F,route:m,values:u}):i({type:"error",title:"Transaction not confirmed",description:F});const W={...ho(u,V),error:F};d("Bridge Confirmation Failed",W)}finally{L.invalidateQueries({queryKey:Me.balances(h,f).queryKey})}},onError:async V=>{const H=M==="initia"?await nn(V,k(h),N):V;o?o({success:!1,error:H.message,route:m,values:u}):r({type:"error",title:"Transaction failed",description:H.message});const Q=ho(u);d("Bridge Transaction Failed",{...Q,error:H.message})}})}function Pg(){const e=tt(),n=X(),s=Or(),{route:o,values:a}=bt(),r=wt();return $.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:c}=await e.post("op-hook",{json:{source_address:n,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:v.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await Lg(n,r(o.dest_asset_chain_id).rest);const l=c.map(({msg_type_url:u,msg:h})=>Wt.aminoTypes.fromAmino({type:Wt.aminoConverters[u].aminoType,value:JSON.parse(h)})),d=await s(i,n,l,{amount:[],gas:"1"},"",{incrementSequence:i===a.srcChainId?2:0}),m=De.Tx.fromPartial({body:De.TxBody.decode(d.bodyBytes),authInfo:De.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:n,hook:se.toBase64(De.Tx.encode(m).finish())}}catch(i){throw await _t(i)}}})}function Dg(e){return{type:"info",title:"Transaction submitted",description:x.createElement(x.Fragment,null,"Check ",x.createElement(cn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function ho(e,n){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:n}}function Bg(e,n){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},c=ia(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:c?"success":void 0,tracked:n},isOpWithdraw:c}}function Rg(e,n,s){return{...e,recipient:v.InitiaAddress(s).bech32,claimableAt:Date.now()+n.estimated_route_duration_seconds*1e3,amount:n.amount_out,denom:n.dest_asset_denom}}async function Fg(e,n,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await _t(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Ji(e){const{chainId:n,txHash:s,tracked:o}=e,a=tt();return $.useQuery({queryKey:Me.txTrack(n,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:n}}).json()}catch(r){throw await _t(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:K.INFINITY,enabled:!o})}function Xi(e){const{timestamp:n,chainId:s,txHash:o,tracked:a,state:r}=e,i=tt();return $.useQuery({queryKey:Me.txStatus(s,o).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:o,chain_id:s}}).json(),enabled:!!o&&a&&!r,refetchInterval:({state:{data:c}})=>{if(!c)return!1;const{status:l}=c;if(l==="STATE_COMPLETED")return!1;const d=n+e.route.estimated_route_duration_seconds*1e3,m=Date.now(),u=Math.floor((d-m)/1e3);return u<=0?1e3:u<=300?5e3:60*1e3},staleTime:K.INFINITY})}var fs=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(fs||{});function ia(e){const{operations:n,dest_asset_denom:s}=e;return T.has("op_init_transfer",T.head(n))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const Ug="_success_t4dfk_1",Og="_error_t4dfk_5",Va={success:Ug,error:Og},Vg=({tx:e})=>{const[n,s]=Qi(e);if(!n)throw new Error("Bridge history details not found");const{data:o}=Xi(n),a=n.state??Kg(o);switch(x.useEffect(()=>{a!=="loading"&&s(r=>{if(!r)throw new Error("Bridge history details not found");return{...r,tracked:!0,state:a}})},[s,a]),a){case"error":return t.jsx("div",{className:Va.error,children:t.jsx(S.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:Va.success,children:t.jsx(S.IconCheckCircleFilled,{size:14})});default:return t.jsx(ut,{size:14})}};function Kg(e){if(!e)return"loading";switch(e.state){case"STATE_ABANDONED":case"STATE_COMPLETED_ERROR":case"STATE_PENDING_ERROR":return"error";case"STATE_COMPLETED_SUCCESS":return"success";default:return"loading"}}const Wg="_link_104m3_1",zg="_header_104m3_23",Hg="_title_104m3_31",Gg="_date_104m3_37",Qg="_explorer_104m3_41",Yg="_fees_104m3_57",Zg="_label_104m3_65",Jg="_content_104m3_69",Xg="_route_104m3_75",e_="_row_104m3_80",t_="_asset_104m3_86",n_="_amount_104m3_94",s_="_chain_104m3_99",o_="_account_104m3_108",a_="_arrow_104m3_115",be={link:Wg,header:zg,title:Hg,date:Gg,explorer:Qg,fees:Yg,label:Zg,content:Jg,route:Xg,row:e_,asset:t_,amount:n_,chain:s_,account:o_,arrow:a_},r_=({tx:e})=>{const[n,s]=Qi(e);if(!n)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:c,tracked:l}=n,{data:d}=Ji(n),{address:m="",connector:u}=Ee.useAccount(),{find:h}=Vs();x.useEffect(()=>{d&&s(O=>{if(!O)throw new Error("Bridge history details not found");return{...O,tracked:!0}})},[s,d]);const{amount_in:f,amount_out:p,source_asset_chain_id:g,source_asset_denom:_,dest_asset_chain_id:y,dest_asset_denom:j,estimated_fees:b=[]}=r,w=Ge(g),C=Ge(y),I=dt(_,g),E=dt(j,y),M=(O,V)=>V?t.jsx(J,{src:V,width:12,height:12}):v.InitiaAddress.equals(O,m)?t.jsx(J,{src:u?.icon,width:12,height:12}):t.jsx(S.IconWallet,{size:12}),A=(O,{symbol:V,decimals:H,logo_uri:Q},{chain_name:F,pretty_name:W,...qe},we,st)=>t.jsxs("div",{className:be.row,children:[t.jsx(Ks,{assetLogoUrl:Q,chainLogoUrl:qe.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:be.asset,children:[t.jsx("span",{className:be.amount,children:v.formatAmount(O,{decimals:H})}),t.jsx("span",{children:V})]}),t.jsxs("div",{className:be.chain,children:[t.jsxs("span",{children:["on ",W||F]}),t.jsxs("div",{className:be.account,children:[st,t.jsx("span",{className:"monospace",children:v.truncate(we)})]})]})]})]}),L=ia(r),N=x.useMemo(()=>{switch(L){case fs.SKIP:return"Skip Explorer";case fs.OP_WITHDRAW:return"Initia Scan"}},[L]),k=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:be.header,children:[t.jsxs("div",{className:be.title,children:[l?t.jsx(Vg,{tx:e}):t.jsx(ut,{size:14}),t.jsx("div",{className:be.date,children:Re.format(new Date(c),"h:mm a")})]}),t.jsxs("div",{className:be.explorer,children:[t.jsx("span",{children:N}),t.jsx(S.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:be.route,children:[A(f,I,w,i.sender,M(i.sender,h(i.cosmosWalletName)?.image)),t.jsx("div",{className:be.arrow,children:t.jsx(S.IconArrowDown,{size:12})}),A(p,E,C,i.recipient,M(i.recipient))]}),b.length>0&&t.jsxs("div",{className:be.fees,children:[t.jsx("span",{className:be.label,children:"Fees"}),t.jsx("span",{className:be.content,children:aa(b)})]})]});if(L===fs.OP_WITHDRAW)return t.jsx(Us,{chainId:o,txHash:a,className:be.link,children:k});const P=new URLSearchParams({tx_hash:a,chain_id:o}),R=new URL(`?${P.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:R.toString(),className:be.link,target:"_blank",children:k})},i_="_history_13u9z_1",c_="_header_13u9z_5",l_="_checkbox_13u9z_9",d_="_groups_13u9z_13",u_="_dateGroup_13u9z_21",m_="_dateHeader_13u9z_26",h_="_list_13u9z_32",Pt={history:i_,header:c_,checkbox:l_,groups:d_,dateGroup:u_,dateHeader:m_,list:h_},f_=()=>{const{initiaAddress:e,hexAddress:n}=Ue(),{history:s,getHistoryDetails:o}=Gi(),a=s.filter(f=>o(f)),r=a.filter(f=>{const p=o(f);if(!p)return!1;const{values:g}=p,{sender:_,recipient:y}=g;return[_,y].some(j=>[e,n].includes(j))}),[i,c]=x.useState(1),[l,d]=Le.useToggle(!r.length),m=l?a:r,u=m.slice(0,i*Ua),h=x.useMemo(()=>Hi(u,f=>{const p=o(f);if(p)return new Date(p.timestamp)}),[u,o]);return t.jsx(ht,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:Pt.history,children:[a.length>0&&a.length!==r.length&&t.jsx("header",{className:Pt.header,children:t.jsx(Ng,{checked:l,onClick:d,label:"Show all transactions stored in this browser",className:Pt.checkbox})}),m.length===0?t.jsx(he,{children:"No bridge/swap activity"}):t.jsx("div",{className:Pt.groups,children:Object.entries(h).map(([f,p])=>t.jsxs("div",{className:Pt.dateGroup,children:[t.jsx("div",{className:Pt.dateHeader,children:f}),t.jsx("div",{className:Pt.list,children:p.map(g=>t.jsx(me,{children:t.jsx(r_,{tx:g})},g.txHash))})]},f))}),m.length>i*Ua?t.jsx(zi,{onClick:()=>c(f=>f+1)}):s.length>=bs&&t.jsxs(he,{children:["Only the latest ",bs," items are stored. Older entries will be removed automatically."]})]})})},ca=({tx:e,fee:n,onCompleted:s,confirmMessage:o,error:a})=>{const{mutate:r,isPending:i}=qg(e,{customFee:n,onCompleted:s});return t.jsx(xe,{children:t.jsx(le.White,{onClick:()=>r(),loading:i&&"Signing transaction...",disabled:!!a,children:a||o||"Confirm"})})},p_="_content_1hzj2_1",g_="_info_1hzj2_6",__="_arrow_1hzj2_11",x_="_divider_1hzj2_19",y_="_type_1hzj2_27",j_="_asset_1hzj2_47",w_="_amount_1hzj2_55",b_="_lower_1hzj2_60",v_="_chain_1hzj2_66",C_="_address_1hzj2_72",We={content:p_,info:g_,arrow:__,divider:x_,type:y_,asset:j_,amount:w_,lower:b_,chain:v_,address:C_},ec=e=>{const{source:n,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:c}=e,{symbol:l=v.truncate(a),decimals:d=0,logo_uri:m=Do}=e,{chain_name:u,pretty_name:h,...f}=Ge(r);return t.jsxs("div",{children:[!n&&t.jsxs("div",{className:We.arrow,children:[t.jsx("div",{className:We.divider}),s?t.jsx(Wn,{label:s,children:t.jsx("button",{className:We.type,children:t.jsx(S.IconArrowDown,{size:12})})}):t.jsx("span",{className:We.type,children:t.jsx(S.IconArrowDown,{size:12})}),t.jsx("div",{className:We.divider})]}),t.jsxs("div",{className:We.content,children:[t.jsx(Ks,{assetLogoUrl:m,chainLogoUrl:f.logo_uri??void 0}),t.jsxs("div",{className:We.info,children:[t.jsxs("div",{className:We.asset,children:[t.jsx("span",{className:We.amount,children:v.formatAmount(o,{decimals:d})}),t.jsx("span",{children:l})]}),t.jsxs("div",{className:We.lower,children:[t.jsxs("div",{className:We.chain,children:["on ",h||u]}),i&&t.jsx(js,{value:i,children:({copy:p,copied:g})=>t.jsxs("button",{className:We.address,onClick:p,children:[c,g?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:v.truncate(i)})]})})]})]})]})]})},an=e=>{const n=dt(e.denom,e.chainId);return t.jsx(ec,{...e,...n})};an.Placeholder=ec;const N_="_root_1hbar_1",k_="_flexEnd_1hbar_6",I_="_toggle_1hbar_11",A_="_route_1hbar_36",S_="_content_1hbar_43",wn={root:N_,flexEnd:k_,toggle:I_,route:A_,content:S_};function T_(e){const n=({name:s})=>s==="initia-dex"?"Initia DEX":Ns.capitalCase(T.head(s?.split("-")??[])??"");if("transfer"in e)return{label:"Bridge via IBC",...e,...e.transfer};if("bank_send"in e)return{label:"Send",...e,...e.bank_send};if("swap"in e){const s=e.swap?.swap_venues?.map(n).join(", ");return{label:s?`Swap on ${s}`:"Swap",...e,...e.swap}}if("axelar_transfer"in e)return{label:"Bridge via Axelar",...e,...e.axelar_transfer};if("cctp_transfer"in e)return{label:"Bridge via CCTP",...e,...e.cctp_transfer};if("hyperlane_transfer"in e)return{label:"Bridge via Hyperlane",...e,...e.hyperlane_transfer};if("evm_swap"in e){const s=e.evm_swap?.swap_venues?.map(n).join(", ");return{label:s?`Swap on ${s}`:"Swap",...e,...e.evm_swap}}if("op_init_transfer"in e)return{label:"Bridge via OP Bridge",...e,...e.op_init_transfer};if("go_fast_transfer"in e)return{label:"Bridge via Go Fast",...e,...e.go_fast_transfer};if("eureka_transfer"in e)return{label:"Bridge via Eureka",...e,...e.eureka_transfer};if("stargate_transfer"in e)return{label:"Bridge via Stargate",...e,...e.stargate_transfer};if("layer_zero_transfer"in e)return{label:"Bridge via LayerZero",...e,...e.layer_zero_transfer};throw new Error("Unknown operation type")}const $_=({addressList:e})=>{const{values:n,route:s}=bt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,c=T.zipObj(s.required_chain_addresses,e),{find:l}=Vs(),{connector:d,address:m=""}=Ee.useAccount(),[u,h]=Le.useToggle(!1),f=i.length>1,p=t.jsx(J,{src:n.cosmosWalletName?l(n.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:r,denom:o,chainId:a,address:n.sender,walletIcon:p},_=C=>v.InitiaAddress.equals(C,m)?p:t.jsx(S.IconWallet,{size:11}),y=C=>{const{label:I,amount_out:E,denom:M,denom_out:A=M,chain_id:L,from_chain_id:N,to_chain_id:k=L??N}=C,P=c[k];return{label:f&&!u?void 0:I,amount:E,denom:A,chainId:k,address:P,walletIcon:_(P)}},j=i.map(T_).map(y),b=j.slice(0,-1),w=j[j.length-1];return t.jsxs(Z.Collapsible.Root,{className:wn.root,open:u,onOpenChange:h,children:[f&&t.jsx("div",{className:wn.flexEnd,children:t.jsx(Z.Collapsible.Trigger,{className:wn.toggle,children:u?t.jsxs(t.Fragment,{children:[t.jsx(S.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(S.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:wn.route,children:[t.jsx(an,{...g,source:!0}),t.jsx(Z.Collapsible.Content,{className:wn.content,children:b.map((C,I)=>t.jsx(me,{suspenseFallback:t.jsx(an.Placeholder,{...C}),errorBoundaryProps:{fallback:t.jsx(an.Placeholder,{...C})},children:t.jsx(an,{...C})},I))}),t.jsx(an,{...w})]})]})},tc=({error:e})=>{const n=Ce();return t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:e.message}),children:t.jsx(le.White,{onClick:()=>n("/bridge"),children:"Home"})})},nc=({children:e})=>{const n=bt(),{route:s,values:o}=n,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:d,hexAddress:m}=Ue(),u=Rn(),h=wt(),f=On(),p=h(r),g=f(p),_=a.slice(0,-1).some(E=>{const M=h(E);return f(M)==="cosmos"})&&g!=="cosmos",[y,j]=x.useState(void 0),[b,w]=x.useState(!1),[C,I]=x.useState(null);if(x.useEffect(()=>{(async()=>{try{if(!_)return;if(!u)throw new Error("Wallet not connected");w(!0),I(null);const[{pubkey:M}]=await u.getAccounts();j(M)}catch(M){I(await _t(M))}finally{w(!1)}})()},[_,u]),C)return t.jsx(tc,{error:C});if(b)return t.jsx(xe,{children:t.jsx(le.White,{loading:b&&"Generating intermediary addresses..."})});if(!_||y){const E=a.map((M,A)=>{if(A===a.length-1){const R=h(i);return f(R)==="initia"?v.InitiaAddress(l).bech32:l}const L=h(M),N=f(L),k=h(r),P=f(k);switch(N){case"initia":return d;case"evm":return m;case"cosmos":{if(P==="cosmos")return se.toBech32(L.bech32_prefix,se.fromBech32(c).data);if(!y)throw new Error("Pubkey not found");return Nn.pubkeyToAddress(Nn.encodeSecp256k1Pubkey(y),L.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(E)}return null},la=({tx:e,children:n})=>{const s=Kr(),o=wt(),{data:a,isLoading:r}=$.useQuery({queryKey:["erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:m,signer_address:u}=e.evm_tx,h=await s();await Io(h,o(m));const f=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async g=>{const{token_contract:_,spender:y}=g,b=await new ct.ethers.Contract(_,f,h).allowance(u,y);return{approval:g,currentAllowance:BigInt(b.toString())}}))).filter(({approval:g,currentAllowance:_})=>_<BigInt(g.amount)).map(({approval:g})=>g)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:c,isPending:l,error:d}=$.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!a||a.length===0)throw new Error("No approvals needed");const{chain_id:m}=e.evm_tx,u=await s(),h=await u.getSigner();await Io(u,o(m));for(const f of a){const{token_contract:p,spender:g,amount:_}=f,y=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new ct.ethers.Contract(p,y,h).approve(g,_)).wait()}return!0}catch(m){throw await _t(m)}}});return r?t.jsx(xe,{children:t.jsx(le.White,{loading:"Checking approvals..."})}):a&&a.length>0&&!c?t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:d?.message}),children:t.jsx(le.White,{onClick:()=>i(),loading:l&&"Approving tokens...",children:"Approve tokens"})}):n},sc=({addressList:e,signedOpHook:n,children:s})=>{const o=tt(),{route:a,values:r}=bt(),[i,c]=x.useState(void 0),[l,d]=x.useState(!1),[m,u]=x.useState(null);return x.useEffect(()=>{(async()=>{try{if(a.required_op_hook&&!n)throw new Error("Op hook is required");d(!0),u(null);const f={address_list:e,amount_in:a.amount_in,amount_out:a.amount_out,source_asset_chain_id:a.source_asset_chain_id,source_asset_denom:a.source_asset_denom,dest_asset_chain_id:a.dest_asset_chain_id,dest_asset_denom:a.dest_asset_denom,slippage_tolerance_percent:r.slippagePercent,operations:a.operations,signed_op_hook:n},{txs:p}=await o.post("v2/fungible/msgs",{json:f}).json();if(!p||p.length===0)throw new Error("No transaction data found");const[g]=p;c(g)}catch(f){u(f)}finally{d(!1)}})()},[a,r,JSON.stringify(e),n,o]),m?t.jsx(tc,{error:m}):l||!i?t.jsx(xe,{children:t.jsx(le.White,{loading:"Fetching messages..."})}):s(i)},oc=({children:e})=>{const{route:n}=bt(),s=Pg();return n.required_op_hook&&!s.data?t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:s.error?.message}),children:t.jsx(le.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)},E_=()=>t.jsx(ht,{title:"Route preview",children:t.jsx(nc,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx($_,{addressList:e}),t.jsx(oc,{children:n=>t.jsx(sc,{addressList:e,signedOpHook:n,children:s=>t.jsx(la,{tx:s,children:t.jsx(ca,{tx:s})})})})]})})}),ac=x.createContext(null);function zs(){return x.useContext(ac)}const M_="_button_17r1o_1",L_="_claimed_17r1o_24",Ka={button:M_,claimed:L_},q_=()=>{const{withdrawalTx:e}=zs(),{bridge_id:n,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:c,to:l,version:d}=e,m=re(),u=X(),{requestTxSync:h,waitForTxConfirmation:f}=Ue(),p=Eg(e),g=se.toBase64(Zi(e)),_=Yi(e,g),y=$.useQueryClient(),{mutate:j,isPending:b}=$.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:w}=p;return h({chainId:m.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:u,bridgeId:BigInt(n),outputIndex:BigInt(a),withdrawalProofs:r.map(se.fromBase64),from:c,to:l,sequence:BigInt(s),amount:o,version:se.fromBase64(d),storageRoot:se.fromBase64(i),lastBlockHash:se.fromBase64(w)}}],internal:!0})},onSuccess:async w=>{await f({chainId:m.chain_id,txHash:w}),y.invalidateQueries({queryKey:Yt.withdrawalClaimed(n,g).queryKey})}});return _?t.jsxs("div",{className:Ka.claimed,children:[t.jsx(S.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:Ka.button,onClick:()=>j(),disabled:b,children:"Claim"})},P_=({children:e})=>{const{withdrawalTx:n}=zs(),s=Ag(n.bridge_id),o=$g(n),a=x.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Re.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},rc=1e3,D_=60,B_=60,R_=24,Ao=rc*D_,So=Ao*B_,Wa=So*R_,F_=({date:e})=>{const n=x.useCallback(()=>{const d=new Date().getTime(),u=e.getTime()-d;if(u<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(u/Wa),f=Math.floor(u%Wa/So),p=Math.floor(u%So/Ao),g=Math.floor(u%Ao/rc);return{days:h,hours:f,minutes:p,seconds:g}},[e]),[s,o]=x.useState(n());x.useEffect(()=>{const d=window.setInterval(()=>{o(n())},1e3);return()=>window.clearInterval(d)},[n,e]);const a=d=>d.toString().padStart(2,"0"),{days:r,hours:i,minutes:c,seconds:l}=s;return t.jsx(Wn,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(c),"m ",a(l),"s"]})})},U_="_container_1lz3w_1",O_="_title_1lz3w_5",za={container:U_,title:O_},V_=({date:e})=>t.jsxs("div",{className:za.container,children:[t.jsx("div",{className:za.title,children:"Claimable in"}),t.jsx(F_,{date:e})]}),K_="_container_1oldz_1",W_="_icon_1oldz_7",Ha={container:K_,icon:W_},z_="Withdrawal will begin within an hour",Ga=()=>{const e=Rs();return t.jsxs("div",{className:Ha.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Wn,{label:z_,children:t.jsx("span",{className:Ha.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]})},H_=({children:e})=>{const{withdrawalTx:n}=zs(),s=Tg(n.bridge_id),o=n.output_index>Number(s?.output_index);return e(o)},G_=({date:e,children:n})=>{const{chainId:s,withdrawalTx:o}=zs(),a=se.toBase64(Zi(o)),r=Yi(o,a),{setReminder:i,removeReminder:c}=fn();return x.useEffect(()=>{const l={chainId:s,txHash:o.tx_hash};r?c(l):i(l,{...l,recipient:o.to,claimableAt:e.getTime(),amount:o.amount.amount,denom:o.amount.denom,dismissed:Re.isPast(e.getTime())?!0:void 0})},[s,r,e,c,i,o]),n},Q_=()=>t.jsx(H_,{children:e=>e?t.jsx(Ga,{}):t.jsx(P_,{children:n=>n?t.jsx(G_,{date:n,children:Re.isFuture(n)?t.jsx(V_,{date:n}):t.jsx(q_,{})}):t.jsx(Ga,{})})}),Y_="_asset_6h8u2_1",Z_="_info_6h8u2_7",J_="_symbol_6h8u2_11",fo={asset:Y_,info:Z_,symbol:J_},X_=({amount:e,denom:n})=>{const s=re(),o=gr(n,s),{symbol:a,logoUrl:r,decimals:i}=o;return t.jsxs("div",{className:fo.asset,children:[t.jsx(J,{src:r,width:32,height:32,logo:!0}),t.jsxs("div",{className:fo.info,children:[t.jsx("span",{className:"monospace",children:v.formatAmount(e,{decimals:i})}),t.jsx("span",{className:fo.symbol,children:a})]})]})},ex="_item_km5w2_1",tx={item:ex},nx=({chain:e})=>{const n=e.metadata?.executor_uri;if(!n)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:o,hasNextPage:a,isFetching:r}=Sg(n),i=x.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:c}=fn();return x.useEffect(()=>{const l=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));c(l)},[e.chainId,i,c]),i.length?t.jsxs(t.Fragment,{children:[i.map(l=>{const{amount:d}=l;return t.jsxs("div",{className:tx.item,children:[t.jsx(X_,{...d}),t.jsx(me,{suspenseFallback:null,children:t.jsx(ac.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:t.jsx(Q_,{})})})]},l.sequence)}),a&&t.jsx(zi,{onClick:()=>o(),disabled:r})]}):t.jsx(he,{children:"No withdrawals"})},sx="_content_dj1qm_1",ox="_title_dj1qm_5",Qa={content:sx,title:ox},ax=()=>{const{chainId:e}=et(),n=de(),s=Gt(),[o,a]=x.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=Fe(),{reminders:i}=fn(),c=o?r(o):void 0;return t.jsxs(ht,{title:"OP Bridge withdrawals",children:[t.jsx(Vt,{chains:n.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:l=>i.some(d=>d.chainId===l)}),t.jsx("div",{className:Qa.content,children:c?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:Qa.title,children:c.name}),t.jsx(me,{children:t.jsx(nx,{chain:c})},o)]}):t.jsx(fe,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},vs=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),rx="5722e7dffb709492cf5312446ceeff73",ix=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${rx}`,ic=["walletconnect-wallets"],cx=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",cc=async e=>{const n=await z.get(ix,{signal:e}).json(),s=n!==null&&typeof n=="object"&&"listings"in n?n.listings:n;return Object.values(s??{}).filter(cx)},lx=()=>$.useQuery({queryKey:ic,queryFn:({signal:e})=>cc(e),staleTime:K.INFINITY,gcTime:K.INFINITY,retry:2}),dx="_page_13y8q_1",ux="_pageTop_13y8q_19",mx="_backButtonFixed_13y8q_63",hx="_listItem_13y8q_64",fx="_socialButton_13y8q_65",px="_arrowIcon_13y8q_66",gx="_searchInputUnderline_13y8q_67",_x="_header_13y8q_72",xx="_title_13y8q_81",yx="_headerSpacer_13y8q_116",jx="_icon_13y8q_120",wx="_installedText_13y8q_124",bx="_divider_13y8q_131",vx="_dividerText_13y8q_152",Cx="_loading_13y8q_193",Nx="_socialIcons_13y8q_198",kx="_socialText_13y8q_204",Ix="_searchWrapper_13y8q_214",Ax="_scrollable_13y8q_248",Sx="_list_13y8q_64",Tx="_listIconWrapper_13y8q_332",$x="_moreIconSmall_13y8q_342",Ex="_externalLinkIcon_13y8q_364",Mx="_listName_13y8q_368",Lx="_listNameMuted_13y8q_381",qx="_recentBadge_13y8q_394",Px="_learnMoreLink_13y8q_408",D={page:dx,pageTop:ux,backButtonFixed:mx,listItem:hx,socialButton:fx,arrowIcon:px,searchInputUnderline:gx,header:_x,title:xx,headerSpacer:yx,icon:jx,installedText:wx,divider:bx,dividerText:vx,loading:Cx,socialIcons:Nx,socialText:kx,searchWrapper:Ix,scrollable:Ax,list:Sx,listIconWrapper:Tx,moreIconSmall:$x,externalLinkIcon:Ex,listName:Mx,listNameMuted:Lx,recentBadge:qx,learnMoreLink:Px},Dx=e=>{try{const n=new URL(e.trim());return n.protocol==="https:"&&!n.username&&!n.password}catch{return!1}},Bx=({walletConnectors:e,isPending:n,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,c]=x.useState(""),{data:l=[],isError:d,isLoading:m,isFetching:u}=lx(),h=m||u&&l.length===0,f=x.useMemo(()=>{if(!i)return e;const g=i.toLowerCase();return e.filter(_=>_.name.toLowerCase().includes(g))},[e,i]),p=x.useMemo(()=>{const g=new Set(e.map(y=>vs(y.name))),_=i.toLowerCase();return l.filter(y=>!g.has(vs(y.name))).filter(y=>!i||y.name.toLowerCase().includes(_)).sort((y,j)=>y.name.localeCompare(j.name))},[l,e,i]);return t.jsxs("div",{className:D.pageTop,children:[t.jsx("button",{type:"button",className:D.backButtonFixed,onClick:r,"aria-label":"Back",children:t.jsx(S.IconBack,{size:16,"aria-hidden":"true"})}),t.jsxs("header",{className:D.header,children:[t.jsx("div",{className:D.headerSpacer}),t.jsx("h1",{className:D.title,children:"All Wallets"}),t.jsx("div",{className:D.headerSpacer})]}),t.jsx("div",{className:D.searchWrapper,children:t.jsx(zn,{rootClassName:D.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:g=>c(g.target.value),onClear:()=>c("")})}),t.jsx(nt,{className:D.scrollable,children:t.jsxs("div",{className:D.list,children:[f.map(g=>{const{name:_,icon:y,id:j}=g,b=o===j,w=s===j,C="ready"in g?!!g.ready:!0;return t.jsxs("button",{type:"button",className:q(D.listItem,{[D.loading]:w}),onClick:()=>a(g),disabled:n||!C,"aria-busy":w,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(J,{src:y,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listName,children:_}),w?t.jsx(ut,{size:16}):b?t.jsx("span",{className:D.recentBadge,children:"Recent"}):C?t.jsx("span",{className:D.installedText,children:"Installed"}):null]},`connector:${j}`)}),h&&t.jsxs("div",{className:q(D.listItem,D.loading),role:"status","aria-live":"polite",children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(ut,{size:16})}),t.jsx("span",{className:D.listNameMuted,children:"Loading more wallets..."})]}),p.map(g=>{const _=g.image_url?.sm||g.image_url?.md||g.image_url?.lg,y=_&&Dx(_)?_:void 0;return t.jsxs("button",{type:"button",className:D.listItem,disabled:!0,"aria-label":`${g.name} (not installed)`,children:[t.jsx("div",{className:D.listIconWrapper,children:y&&t.jsx(J,{src:y,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listNameMuted,children:g.name})]},`wc:${g.id}`)}),d&&t.jsx(fe,{level:"error",children:"Couldn't load additional wallets."})]})})]})},Rx=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[t.jsx("circle",{cx:"4",cy:"8",r:"1.5"}),t.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),t.jsx("circle",{cx:"12",cy:"8",r:"1.5"})]}),Fx=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),t.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),t.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),t.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),Ux=()=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),Ox=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),Vx=[{id:"io.rabby",name:"Rabby",icon:"https://assets.initia.xyz/images/wallets/Rabby.webp",url:"https://rabby.io"},{id:"app.phantom",name:"Phantom",icon:"https://assets.initia.xyz/images/wallets/Phantom.webp",url:"https://phantom.com"},{id:"app.keplr",name:"Keplr",icon:"https://assets.initia.xyz/images/wallets/Keplr.webp",url:"https://keplr.app"},{id:"io.leapwallet",name:"Leap",icon:"https://assets.initia.xyz/images/wallets/Leap.webp",url:"https://leapwallet.io"},{id:"io.metamask",name:"MetaMask",icon:"https://assets.initia.xyz/images/wallets/MetaMask.webp",url:"https://metamask.io"}],Kx=({walletConnectors:e,privyConnector:n,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:c})=>{const l=e.filter(p=>!("ready"in p)||!!p.ready),d=l.slice(0,5),m=new Set(l.map(p=>p.id)),u=new Set(l.map(p=>vs(p.name))),h=Math.max(0,5-d.length),f=Vx.filter(p=>!m.has(p.id)&&!u.has(vs(p.name))).slice(0,h);return t.jsxs("div",{className:D.page,children:[t.jsxs("header",{className:D.header,children:[t.jsx("div",{className:D.headerSpacer}),t.jsx("h1",{className:D.title,children:"Sign In"}),t.jsx("div",{className:D.headerSpacer})]}),n&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:q(D.socialButton,{[D.loading]:o===n.id}),onClick:()=>r(n),disabled:s,"aria-busy":o===n.id,children:[t.jsx("span",{className:D.socialText,children:"Email / Socials"}),o===n.id?t.jsx(ut,{size:16}):t.jsxs("div",{className:D.socialIcons,children:[t.jsx(Fx,{}),t.jsx(Ox,{}),t.jsx(Ux,{})]})]}),t.jsx("div",{className:D.divider,children:t.jsx("span",{className:D.dividerText,children:"or"})})]}),t.jsx(nt,{className:D.scrollable,children:t.jsxs("div",{className:D.list,children:[d.map(p=>{const{name:g,icon:_,id:y}=p,j=o===y,b=a===y;return t.jsxs("button",{type:"button",className:q(D.listItem,{[D.loading]:j}),onClick:()=>r(p),disabled:s,"aria-busy":j,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(J,{src:_,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listName,children:g}),j?t.jsx(ut,{size:16}):b?t.jsx("span",{className:D.recentBadge,children:"Recent"}):t.jsx("span",{className:D.installedText,children:"Installed"})]},y)}),f.map(p=>t.jsxs("a",{className:D.listItem,href:p.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${p.name} (opens in new tab)`,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(J,{src:p.icon,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listNameMuted,children:p.name}),t.jsx(S.IconExternalLink,{size:10,className:D.externalLinkIcon,"aria-hidden":"true"})]},p.id)),t.jsxs("button",{type:"button",className:D.listItem,onClick:i,onMouseEnter:c,onFocus:c,disabled:s,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx("div",{className:D.moreIconSmall,children:t.jsx(Rx,{})})}),t.jsx("span",{className:D.listNameMuted,children:"More wallets"}),t.jsx("span",{className:D.arrowIcon,"aria-hidden":"true",children:"→"})]})]})}),t.jsxs("a",{className:D.learnMoreLink,href:"https://docs.initia.xyz/home/tools/wallet",target:"_blank",rel:"noopener noreferrer","aria-label":"Learn more (opens in new tab)",children:["Learn more",t.jsx(S.IconExternalLink,{size:14,"aria-hidden":"true"})]})]})},Ya=({onSuccess:e})=>{const{connectors:n,connectAsync:s}=Ee.useConnect(),o=Le.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=x.useState(null),[i,c]=x.useState("signin"),l=$.useQueryClient(),d=()=>l.prefetchQuery({queryKey:ic,queryFn:({signal:g})=>cc(g),staleTime:K.INFINITY,gcTime:K.INFINITY}),{mutate:m,isPending:u}=$.useMutation({mutationFn:async g=>{try{await s({connector:g})}catch(_){throw await _t(_)}},onMutate:g=>{r(g.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),h=x.useMemo(()=>[...n].sort((g,_)=>g.id===o?-1:_.id===o?1:g.name.localeCompare(_.name)),[n,o]),f=x.useMemo(()=>h.find(g=>g.id===kn.id),[h]),p=x.useMemo(()=>h.filter(g=>g.id!==kn.id),[h]);return i==="all"?t.jsx(Bx,{walletConnectors:p,isPending:u,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onBack:()=>c("signin")}):t.jsx(Kx,{walletConnectors:p,privyConnector:f,isPending:u,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onShowAll:()=>c("all"),onPrefetchWallets:d})},Wx={deposit:{mode:"deposit",label:"Deposit",local:{denomKey:"dstDenom",chainIdKey:"dstChainId"},external:{denomKey:"srcDenom",chainIdKey:"srcChainId"}},withdraw:{mode:"withdraw",label:"Withdraw",local:{denomKey:"srcDenom",chainIdKey:"srcChainId"},external:{denomKey:"dstDenom",chainIdKey:"dstChainId"}}};function Gn(e){return Wx[e]}function da(){const e=tt(),n=hn(),s=X(),o=Vn(),a=Object.fromEntries(o.filter(({chain_type:r,bech32_prefix:i})=>r==="evm"||r==="cosmos"&&i==="init").map(r=>[r.chain_id,{address:r.chain_type==="evm"?n:s,denoms:[]}]));return $.useQuery({queryKey:Me.allBalances(Object.keys(a),[n,s]).queryKey,queryFn:()=>e.post("v2/info/balances",{json:{chains:a}}).json(),select:({chains:r})=>r?Object.fromEntries(Object.entries(r).map(([i,{denoms:c}])=>[i,c||{}])):{},enabled:!!s,staleTime:K.SECOND})}function ua(){const{localOptions:e=[]}=et();return Qt().filter(({denom:s,chain_id:o})=>e.some(a=>a.denom===s&&a.chainId===o))}function ma(e){const{local:n}=Gn(e),s=Qt(),{watch:o}=Tt(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function zx(e){const{external:n}=Gn(e),s=Qt(),{watch:o}=Tt(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function Hx(e){const n=Qt(),s=wt(),{data:o,isLoading:a}=da(),{remoteOptions:r=[]}=et(),i=ma(e);return i?{data:n.filter(({symbol:l,denom:d,chain_id:m})=>r.length?r.some(u=>u.denom===d&&u.chainId===m):l===i.symbol).map(l=>{if(l.hidden||l.chain_id===i.chain_id)return null;const d=s(l.chain_id);if(!d||d.chain_type==="cosmos"&&d.bech32_prefix!=="init")return null;const m=o?.[d.chain_id]?.[l.denom];return e==="deposit"&&(!m||!Number(m.amount))?null:{asset:l,chain:d,balance:m}}).filter(l=>l!==null),isLoading:a}:{data:[],isLoading:a}}function Tt(){return _e.useFormContext()}const Gx="data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23242629'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%23585F67'/%3e%3cpath%20d='M47.7916%2037.0445C47.7916%2035.2783%2049.2313%2033.8464%2051.0071%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.0071C49.2313%2082.8837%2047.7916%2081.4519%2047.7916%2079.6854V37.0445Z'%20fill='%23585F67'/%3e%3cpath%20d='M91.7372%2056.2323C91.7372%2052.6999%2094.6166%2049.8362%2098.1681%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1681C94.6166%2066.8927%2091.7372%2064.0289%2091.7372%2060.4965V56.2323Z'%20fill='%23242629'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.24%2061.5626C97.4642%2061.5626%2096.0245%2060.1308%2096.0245%2058.3646C96.0245%2056.5984%2097.4642%2055.1665%2099.24%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%23585F67'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%232F3337'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23757C82'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23757C82'/%3e%3c/svg%3e",Qx="data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M47.7915%2037.0445C47.7915%2035.2783%2049.2312%2033.8464%2051.007%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.007C49.2312%2082.8837%2047.7915%2081.4519%2047.7915%2079.6854V37.0445Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M91.7373%2056.2323C91.7373%2052.6999%2094.6167%2049.8362%2098.1682%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1682C94.6167%2066.8927%2091.7373%2064.0289%2091.7373%2060.4965V56.2323Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.2399%2061.5626C97.4641%2061.5626%2096.0244%2060.1308%2096.0244%2058.3646C96.0244%2056.5984%2097.4641%2055.1665%2099.2399%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%23E9EBED'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23797D81'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23797D81'/%3e%3c/svg%3e",Yx="_container_uxgnj_1",Zx="_title_uxgnj_5",Jx="_close_uxgnj_12",Xx="_emptyIcon_uxgnj_24",ey="_empty_uxgnj_24",ty="_list_uxgnj_51",ny="_asset_uxgnj_66",sy="_placeholder_uxgnj_82",oy="_activeAsset_uxgnj_95",ay="_iconContainer_uxgnj_99",ry="_assetIcon_uxgnj_109",iy="_chainIcon_uxgnj_119",cy="_assetPlaceholder_uxgnj_133",ly="_assetName_uxgnj_154",dy="_assetChain_uxgnj_169",uy="_balance_uxgnj_177",my="_value_uxgnj_186",ue={container:Yx,title:Zx,close:Jx,emptyIcon:Xx,empty:ey,list:ty,asset:ny,placeholder:sy,activeAsset:oy,iconContainer:ay,assetIcon:ry,chainIcon:iy,assetPlaceholder:cy,assetName:ly,assetChain:dy,balance:uy,value:my},hy=({mode:e})=>{const{external:n}=Gn(e),{data:s,isLoading:o}=Hx(e),{setValue:a,watch:r}=Tt(),i=ma(e),c=ua(),{theme:l}=ee(),d=r(),m=d[n.denomKey],u=d[n.chainIdKey];function h(){const f=m&&u;return!f&&c.length<=1&&e==="deposit"?null:t.jsx("button",{className:ue.close,onClick:()=>{e==="withdraw"||f?a("page","fields"):a("page","select-local")},children:t.jsx(S.IconBack,{size:20})})}return i?!o&&!s.length?t.jsxs("div",{className:ue.container,children:[h(),t.jsx("h4",{className:ue.title,children:"No available assets"}),t.jsx("img",{src:l==="dark"?Gx:Qx,alt:"No assets",className:ue.emptyIcon}),t.jsx("p",{className:ue.empty,children:e==="withdraw"?`No supported destinations to withdraw ${i.symbol}.`:`No supported assets to deposit ${i.symbol}.`})]}):t.jsxs("div",{className:ue.container,children:[h(),t.jsxs("h4",{className:ue.title,children:[e==="withdraw"?"Select destination":`Deposit ${i.symbol}`," "]}),t.jsxs("div",{className:ue.list,children:[o&&Array.from({length:5}).map((f,p)=>t.jsxs("div",{className:q(ue.asset,ue.placeholder),children:[t.jsxs("div",{className:ue.iconContainer,children:[t.jsx("div",{className:ue.assetIcon}),t.jsx("div",{className:ue.chainIcon})]}),t.jsx("div",{className:ue.assetPlaceholder})]},p)),!o&&s.sort(({balance:f},{balance:p})=>Number(p?.value_usd??0)-Number(f?.value_usd??0)).map(({asset:f,chain:p,balance:g})=>{const _=m===f.denom&&u===p.chain_id;return t.jsxs("button",{className:q(ue.asset,_&&ue.activeAsset),onClick:()=>{a(n.denomKey,f.denom),a(n.chainIdKey,p.chain_id),e==="deposit"&&a("quantity",""),a("page","fields")},children:[t.jsxs("div",{className:ue.iconContainer,children:[t.jsx("img",{src:f.logo_uri,alt:f.symbol,className:ue.assetIcon}),t.jsx("img",{src:p.logo_uri||"",alt:p.chain_name,className:ue.chainIcon})]}),t.jsxs("p",{className:ue.assetName,children:[f.symbol," ",_&&t.jsx("span",{children:t.jsx(S.IconCheck,{size:16})})]}),t.jsxs("p",{className:ue.assetChain,children:["on ",p.pretty_name]}),g&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:ue.balance,children:v.formatAmount(g.amount,{decimals:g.decimals||6})}),t.jsx("p",{className:ue.value,children:te(g.value_usd||0)})]})]},`${f.chain_id}-${f.denom}`)})]})]}):t.jsx("div",{children:"No assets found"})},fy="_title_9ovji_1",py="_list_9ovji_7",gy="_asset_9ovji_15",po={title:fy,list:py,asset:gy},_y=({mode:e})=>{const{local:n,external:s}=Gn(e),{setValue:o}=Tt(),a=ua(),r=(c,l)=>{o(n.denomKey,c),o(n.chainIdKey,l),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),o("page",e==="withdraw"?"fields":"select-external")},i=x.useEffectEvent(()=>{const{denom:c,chain_id:l}=a[0];r(c,l)});return x.useEffect(()=>{a.length===1&&i()},[a]),a.length?t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:po.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),t.jsx("div",{className:po.list,children:a.map(({denom:c,chain_id:l,symbol:d,logo_uri:m})=>t.jsxs("button",{className:po.asset,onClick:()=>r(c,l),children:[t.jsx("img",{src:m,alt:d}),d]},`${c}-${l}`))})]}):t.jsx("div",{children:"No assets found"})},xy="data:image/svg+xml,%3csvg%20width='58'%20height='58'%20viewBox='0%200%2058%2058'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M29%202.71875C43.5%202.71875%2055.2812%2014.5%2055.2812%2029C55.2812%2043.5%2043.5%2055.2812%2029%2055.2812C14.5%2055.2812%202.71875%2043.5%202.71875%2029C2.71875%2014.5%2014.5%202.71875%2029%202.71875ZM29%206.34375C16.4937%206.34375%206.34375%2016.4937%206.34375%2029C6.34375%2041.5062%2016.4937%2051.6562%2029%2051.6562C41.5062%2051.6562%2051.6562%2041.5062%2051.6562%2029C51.6562%2016.4937%2041.5062%206.34375%2029%206.34375Z'%20fill='%23F85454'/%3e%3cpath%20d='M36.1616%2018.7623C37.0109%2017.9129%2038.3885%2017.9129%2039.2378%2018.7623C40.087%2019.6117%2040.0871%2020.9893%2039.2378%2021.8386L32.0763%2029.0001L39.2378%2036.1616L39.3865%2036.3279C40.083%2037.1822%2040.034%2038.4417%2039.2378%2039.2378C38.4417%2040.034%2037.1822%2040.083%2036.3279%2039.3865L36.1616%2039.2378L29.0001%2032.0763L21.8386%2039.2378C20.9893%2040.0871%2019.6117%2040.087%2018.7623%2039.2378C17.9129%2038.3885%2017.9129%2037.0109%2018.7623%2036.1616L25.9238%2029.0001L18.7623%2021.8386C17.9129%2020.9892%2017.9129%2019.6116%2018.7623%2018.7623C19.6116%2017.9129%2020.9892%2017.9129%2021.8386%2018.7623L29.0001%2025.9238L36.1616%2018.7623Z'%20fill='%23F85454'/%3e%3c/svg%3e",yy="data:image/svg+xml,%3csvg%20width='72'%20height='72'%20viewBox='0%200%2072%2072'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M36%209.71875C50.5%209.71875%2062.2812%2021.5%2062.2812%2036C62.2812%2050.5%2050.5%2062.2812%2036%2062.2812C21.5%2062.2812%209.71875%2050.5%209.71875%2036C9.71875%2021.5%2021.5%209.71875%2036%209.71875ZM36%2013.3438C23.4937%2013.3438%2013.3438%2023.4937%2013.3438%2036C13.3438%2048.5062%2023.4937%2058.6562%2036%2058.6562C48.5062%2058.6562%2058.6562%2048.5062%2058.6562%2036C58.6562%2023.4937%2048.5062%2013.3438%2036%2013.3438Z'%20fill='%23D1242F'/%3e%3cpath%20d='M43.1616%2025.7623C44.0109%2024.9129%2045.3885%2024.9129%2046.2378%2025.7623C47.087%2026.6117%2047.0871%2027.9893%2046.2378%2028.8386L39.0763%2036.0001L46.2378%2043.1616L46.3865%2043.3279C47.083%2044.1822%2047.034%2045.4417%2046.2378%2046.2378C45.4417%2047.034%2044.1822%2047.083%2043.3279%2046.3865L43.1616%2046.2378L36.0001%2039.0763L28.8386%2046.2378C27.9893%2047.0871%2026.6117%2047.087%2025.7623%2046.2378C24.9129%2045.3885%2024.9129%2044.0109%2025.7623%2043.1616L32.9238%2036.0001L25.7623%2028.8386C24.9129%2027.9892%2024.9129%2026.6116%2025.7623%2025.7623C26.6116%2024.9129%2027.9892%2024.9129%2028.8386%2025.7623L36.0001%2032.9238L43.1616%2025.7623Z'%20fill='%23D1242F'/%3e%3c/svg%3e",jy="_container_9k4hs_1",wy="_title_9k4hs_8",by="_subtitle_9k4hs_14",vy="_linkContainer_9k4hs_30",Cy="_link_9k4hs_30",Ny="_separator_9k4hs_51",ky="_errorIcon_9k4hs_62",Iy="_error_9k4hs_62",ve={container:jy,title:wy,subtitle:by,linkContainer:vy,link:Cy,separator:Ny,errorIcon:ky,error:Iy};function Ay(e){if(!e)return"pending";const n=e.state;return n==="STATE_COMPLETED_SUCCESS"?"success":n==="STATE_ABANDONED"||n==="STATE_COMPLETED_ERROR"||n==="STATE_PENDING_ERROR"?"failed":"pending"}function To({type:e}){const{closeModal:n}=mn(),{theme:s}=ee(),{watch:o}=Tt(),{result:a}=o(),{openDrawer:r}=jt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,c=i?"":a.txhash,l=i?"":a.chainId,d=i?0:a.timestamp??0,{route:m,values:u}=a,{srcDenom:h,srcChainId:f,quantity:p}=u,g=dt(h,f),_=e==="deposit"?"Deposit":"Withdraw",{data:y}=Ji({chainId:l,txHash:c,tracked:!1}),{data:j}=Xi({chainId:l,txHash:c,tracked:!!y,timestamp:d,route:m}),b=Ay(j),w=s==="dark"?xy:yy,C=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,I=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return t.jsxs("div",{className:ve.container,children:[t.jsxs("h3",{className:ve.title,children:[_," failed"]}),t.jsx("img",{src:w,alt:"Failed",className:ve.errorIcon}),t.jsx("p",{className:ve.error,children:a?.error}),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]});const E=Mn(m.estimated_route_duration_seconds),M=new URLSearchParams({tx_hash:c,chain_id:l}),A=new URL(`?${M.toString()}`,"https://explorer.skip.build"),L=()=>t.jsxs("div",{className:ve.linkContainer,children:[t.jsx("a",{href:A.toString(),target:"_blank",rel:"noopener noreferrer",className:ve.link,children:"View transaction"}),t.jsx("div",{className:ve.separator}),t.jsx("button",{className:ve.link,onClick:()=>{n(),r("/bridge/history")},children:"Go to history"})]});return t.jsxs("div",{className:ve.container,children:[b==="pending"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ve.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",p," ",g.symbol]}),t.jsx("video",{src:C,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),t.jsxs("p",{className:ve.subtitle,children:["Estimated time: ",t.jsx("span",{children:E})]}),L(),t.jsx("p",{className:ve.subtitle,children:"Your transaction will continue even if you close this"})]}),b==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ve.title,children:[_," complete"]}),t.jsx("video",{src:I,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:N=>{const k=N.currentTarget;k.duration-k.currentTime<.1&&k.pause()}}),L(),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]}),b==="failed"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ve.title,children:[_," failed"]}),t.jsx("img",{src:w,alt:"Failed",className:ve.errorIcon}),t.jsx("p",{className:ve.error,children:"Your transaction could not be completed"}),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]})]})}const Sy=ye.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),Ty=({tx:e,children:n})=>{const{values:s}=bt(),{srcChainId:o}=s,a=X(),r=Bn(),i=Ms(),{data:c,isLoading:l}=$.useQuery({queryKey:Sy.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const m=e.cosmos_tx.msgs.map(({msg_type_url:f,msg:p})=>{if(!(f&&p))throw new Error("Invalid transaction data");return r.fromAmino({type:Wt.aminoConverters[f].aminoType,value:JSON.parse(p)})});return{estimatedGas:await(await i(o)).simulate(a,m,""),messages:m}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if(l)return t.jsx(xe,{children:t.jsx(le.White,{loading:"Estimating gas..."})});const d=c?.estimatedGas??null;return t.jsx(t.Fragment,{children:n(d)})},$y="_container_eg177_1",Ey="_back_eg177_6",My="_title_eg177_18",Ly="_divider_eg177_26",qy="_label_eg177_30",Py="_asset_eg177_37",Dy="_assetIcon_eg177_55",By="_chainIcon_eg177_67",Ry="_assetName_eg177_80",Fy="_chevron_eg177_92",Uy="_input_eg177_96",Oy="_balanceContainer_eg177_108",Vy="_value_eg177_116",Ky="_maxButton_eg177_126",Wy="_detail_eg177_142",zy="_detailsContainer_eg177_153",Hy="_detailsButton_eg177_163",Gy="_detailValue_eg177_180",Qy="_detailToken_eg177_190",Yy="_minimumReceived_eg177_198",G={container:$y,back:Ey,title:My,divider:Ly,label:qy,asset:Py,assetIcon:Dy,chainIcon:By,assetName:Ry,chevron:Fy,input:Uy,balanceContainer:Oy,value:Vy,maxButton:Ky,detail:Wy,detailsContainer:zy,detailsButton:Hy,detailValue:Gy,detailToken:Qy,minimumReceived:Yy},lc=({renderFee:e})=>{const{route:n}=et(),{values:s}=bt(),{dstDenom:o,dstChainId:a}=s,i=Qt().find(({denom:f,chain_id:p})=>f===o&&p===a),c=X(),l=Ii(),[d,m]=Le.useToggle(!1),u=n&&n.estimated_route_duration_seconds>60;if(!n||!i)return null;const h=n.does_swap?BigInt(n.amount_out||n.estimated_amount_out)*BigInt(1e4-Number(s.slippagePercent)*100)/BigInt(1e4):BigInt(n.amount_out||n.estimated_amount_out);return t.jsx($n,{children:t.jsxs("div",{className:G.detailsContainer,children:[t.jsxs("button",{className:G.detailsButton,onClick:m,children:["Transaction details"," ",t.jsx(S.IconChevronDown,{size:12,style:{transform:d?"rotate(180deg)":"rotate(0deg)"}})]}),d&&t.jsxs(t.Fragment,{children:[n.does_swap&&t.jsxs("div",{className:G.detail,children:[t.jsx("p",{className:G.detailLabel,children:"Slippage"}),t.jsxs("p",{className:G.detailValue,children:[s.slippagePercent,"%"]})]}),!!n.estimated_fees?.length&&t.jsxs("div",{className:G.detail,children:[t.jsx("p",{className:G.detailLabel,children:"Bridge fee"}),t.jsx("div",{className:G.detailValue,children:aa(n.estimated_fees)})]}),e&&t.jsxs("div",{className:G.detail,children:[t.jsx("p",{className:G.detailLabel,children:"Tx fee"}),t.jsx("div",{className:G.detailValue,children:e()})]}),c&&t.jsxs("div",{className:G.detail,children:[t.jsx("p",{className:G.detailLabel,children:"Receiving address"}),t.jsxs("p",{className:G.detailValue,children:[t.jsx("img",{src:l,alt:"Wallet",height:12,width:12})," ",v.truncate(c)]})]})]}),t.jsxs("div",{className:G.detail,children:[t.jsx("p",{className:G.detailLabel,children:"Estimated time"}),t.jsx("p",{className:q(G.detailValue),style:u?{color:"var(--warning)"}:void 0,children:Mn(n.estimated_route_duration_seconds)})]}),t.jsxs("div",{className:q(G.detail,G.minimumReceived),children:[t.jsx("p",{className:G.detailLabel,children:"Minimum received"}),t.jsxs("p",{className:G.detailValue,children:[t.jsx("img",{src:i.logo_uri,alt:i.symbol,className:G.detailToken})," ",v.formatAmount(h,{decimals:i.decimals})," ",i.symbol]})]})]})})},Zy="_trigger_1c7d7_1",Jy="_item_1c7d7_5",Xy="_itemText_1c7d7_13",e1={trigger:Zy,item:Jy,itemText:Xy},t1=({tx:e,gas:n,confirmMessage:s,onCompleted:o})=>{const{values:a}=bt(),{srcChainId:r,srcDenom:i,quantity:c}=a,d=Qt().find(({denom:N,chain_id:k})=>N===i&&k===r),m=Xe(r),u=qn(m),h=zo(m),f=Ho(m),p=mt(m),g=h.map(({amount:N,denom:k})=>je.calculateFee(Math.ceil(n*zt),je.GasPrice.fromString(N+k))),_=g.map(N=>N.amount[0]),y=N=>{const k=u.find(F=>F.denom===N)?.amount??"0",P=_.find(F=>F.denom===N)?.amount??"0",R=d&&i===N?B(c||"0").times(B(10).pow(d.decimals)).toFixed(0):"0",O=B(P).plus(R),V=B(k).gte(O),{symbol:H,decimals:Q}=p(N);return{symbol:H,decimals:Q,spend:B(R).gt(0)?R:null,fee:P,total:O.toFixed(),balance:k,isSufficient:V}},j=()=>{if(!_.length)return null;if(f&&y(f).isSufficient)return f;for(const{denom:N}of _)if(y(N).isSufficient)return N;return _[0]?.denom},[b,w]=x.useState(j),C=g.find(N=>N.amount[0].denom===b)??void 0,I=b?y(b):null,E=I&&!I.isSufficient?"Insufficient balance":void 0,M=(N,k)=>{if(v.formatAmount(N,{decimals:k})==="0.000000")return 8},A=N=>{const[{amount:k,denom:P}]=N.amount;if(B(k).isZero())return"0";const{symbol:R,decimals:O}=p(P),V=M(k,O);return`${v.formatAmount(k,{decimals:O,dp:V})} ${R}`},L=()=>{if(g.length===0)return null;if(g.length===1)return t.jsx("span",{className:"monospace",children:A(g[0])});if(!C||!b)return null;const N=g.map(V=>{const[{denom:H}]=V.amount,{symbol:Q}=p(H);return{value:H,label:A(V),triggerLabel:Q}}),[{amount:k,denom:P}]=C.amount,{decimals:R}=p(P),O=M(k,R);return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{className:"monospace",children:v.formatAmount(k,{decimals:R,dp:O})}),t.jsx(sa,{options:N,value:b,onChange:w,classNames:e1})]})};return t.jsxs(t.Fragment,{children:[t.jsx(lc,{renderFee:g.length>0?L:void 0}),t.jsx(la,{tx:e,children:t.jsx(ca,{tx:e,fee:C,onCompleted:o,confirmMessage:s,error:E})})]})},n1=({tx:e,confirmMessage:n,onCompleted:s})=>t.jsxs(t.Fragment,{children:[t.jsx(lc,{}),t.jsx(la,{tx:e,children:t.jsx(ca,{tx:e,fee:void 0,onCompleted:s,confirmMessage:n})})]}),s1=({tx:e,gas:n,mode:s})=>{const{setValue:o}=Tt(),a=i=>{o("page","completed"),o("result",i)},r=s==="withdraw"?"Withdraw":"Deposit";return!n||!("cosmos_tx"in e)?t.jsx(n1,{tx:e,onCompleted:a,confirmMessage:r}):t.jsx(t1,{tx:e,gas:n,onCompleted:a,confirmMessage:r})},o1=({mode:e})=>{const n=Gn(e),s=Ce(),o=et(),a=ua(),r=wt(),{data:i}=da(),c=hn(),{watch:l,setValue:d,getValues:m}=Tt(),u=l(),{srcChainId:h,srcDenom:f,quantity:p=""}=u,g=ma(e),_=zx(e),y=u[n.external.chainIdKey],j=y?r(y):null,b=i?.[h]?.[f]?.amount,w=i?.[h]?.[f]?.price||0,C=B(w||0).times(p||0),[I]=Le.useDebounceValue(p,300),E=e==="withdraw"?g:_,M=x.useMemo(()=>{if(e==="deposit"&&!_)return"Select asset";const Q=B(p||0);if(!Q.isFinite()||Q.lte(0))return"Enter amount";const F=v.fromBaseUnit(b??"0",{decimals:E?.decimals||6});if(Q.gt(F))return"Insufficient balance";if(e==="withdraw"&&!_)return"Select destination"},[e,p,b,E,_]),{data:A,error:L}=ko(I,{disabled:!!M}),N=!L&&!M?A:void 0,k=x.useEffectEvent(()=>{s(0,{...o,route:N,values:{sender:c,recipient:o.recipientAddress?v.InitiaAddress(o.recipientAddress).hex:c,slippagePercent:"1",...m()}})});if(x.useEffect(()=>{k()},[N,c]),!g||e==="deposit"&&!_)return null;const P=E?.decimals||6,R=e==="withdraw"?"Select chain":"Select asset",O=()=>{d("quantity",""),d(n.external.denomKey,""),d(n.external.chainIdKey,""),e==="withdraw"&&(d(n.local.denomKey,""),d(n.local.chainIdKey,"")),d("page",e==="withdraw"?"select-local":"select-external")},V=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:G.label,children:e==="withdraw"?"Destination":"From"}),t.jsxs("button",{className:G.asset,onClick:()=>{d("page","select-external")},children:[t.jsx("div",{className:G.assetIcon,children:_?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:_.logo_uri,alt:_.symbol}),t.jsx("img",{src:j?.logo_uri||"",alt:j?.pretty_name,className:G.chainIcon})]}):e==="withdraw"&&t.jsx("div",{className:G.chainIcon})}),t.jsx("p",{className:G.assetName,children:_?t.jsxs(t.Fragment,{children:[_.symbol,t.jsx("br",{}),t.jsxs("span",{children:["on ",j?.pretty_name]})]}):R}),t.jsx(S.IconChevronDown,{className:G.chevron,size:16})]})]}),H=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:G.label,children:"Amount"}),t.jsx(En,{balance:b,decimals:P,className:G.input}),Number(b)>0&&t.jsxs("div",{className:G.balanceContainer,children:[t.jsx("p",{className:G.value,children:C.gt(0)?te(C.toString()):"$-"}),t.jsxs("button",{className:G.maxButton,onClick:()=>{const Q=v.fromBaseUnit(b??"0",{decimals:P});B(p||0).eq(Q)||d("quantity",Q)},children:[t.jsx(S.IconWallet,{size:16})," ",v.formatAmount(b,{decimals:P})," ",t.jsx("span",{children:"MAX"})]})]})]});return t.jsxs("div",{className:G.container,children:[a.length>1&&t.jsx("button",{type:"button","aria-label":"Back",className:G.back,onClick:O,children:t.jsx(S.IconBack,{size:20})}),t.jsxs("h3",{className:G.title,children:[n.label," ",g.symbol]}),e==="withdraw"?t.jsxs(t.Fragment,{children:[H,t.jsx("div",{className:G.divider}),V]}):t.jsxs(t.Fragment,{children:[V,t.jsx("div",{className:G.divider}),H]}),!o.route||M?t.jsx(xe,{children:t.jsx(le.White,{type:"submit",loading:!L&&!M&&"Fetching route...",disabled:!0,fullWidth:!0,children:L?"No route found":M})}):t.jsx(nc,{children:Q=>t.jsx(oc,{children:F=>t.jsx(sc,{addressList:Q,signedOpHook:F,children:W=>t.jsx(Ty,{tx:W,children:qe=>t.jsx(s1,{tx:W,gas:qe,mode:e})})})})})]})},a1="_container_7nl9j_1",r1="_page_7nl9j_5",Za={container:a1,page:r1},dc=({mode:e})=>{const n=_e.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return da(),t.jsx(_e.FormProvider,{...n,children:t.jsx(i1,{mode:e})})},i1=({mode:e})=>{const{watch:n}=Tt(),s=n("page"),o=lt.useTransition(s,{keys:s,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:"absolute",inset:0},config:{tension:500,friction:30,clamp:!0,duration:150}}),a=r=>{switch(r){case"select-local":return t.jsx(_y,{mode:e});case"select-external":return t.jsx(hy,{mode:e});case"fields":return t.jsx(o1,{mode:e});case"completed":return t.jsx(To,{type:e})}};return t.jsx($n,{children:t.jsx("div",{className:Za.container,children:o((r,i)=>t.jsx(lt.animated.div,{style:r,className:Za.page,children:a(i)}))})})},c1=()=>t.jsx(dc,{mode:"deposit"}),l1=()=>t.jsx(dc,{mode:"withdraw"}),d1="_root_1lo0i_1",u1="_address_1lo0i_9",m1="_copy_1lo0i_19",h1="_labelWrapper_1lo0i_33",f1="_labelCopy_1lo0i_43",p1="_labelCopied_1lo0i_47",g1="_copied_1lo0i_55",_1="_derived_1lo0i_65",x1="_derivedLabel_1lo0i_79",y1="_derivedAddress_1lo0i_83",j1="_hexAddress_1lo0i_89",w1="_derivedCopy_1lo0i_94",Ae={root:d1,address:u1,copy:m1,labelWrapper:h1,labelCopy:f1,labelCopied:p1,copied:g1,derived:_1,derivedLabel:x1,derivedAddress:y1,hexAddress:j1,derivedCopy:w1},b1=()=>{const e=x.useRef(null),n=x.useRef(null),{initiaAddress:s,hexAddress:o}=Ue(),a=Ni("--gray-0");return x.useEffect(()=>{e.current&&(n.current?n.current.update({data:s}):(n.current=new Lc({type:"canvas",width:400,height:400,margin:0,data:s,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:a},cornersSquareOptions:{type:"extra-rounded",color:a},cornersDotOptions:{type:"dot",color:a},backgroundOptions:{color:"transparent"}}),n.current.append(e.current)))},[s,a]),t.jsx(ht,{title:"Receive",children:t.jsxs("div",{className:Ae.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:Ae.address,children:s}),t.jsx(js,{value:s,children:({copy:r,copied:i})=>t.jsxs("button",{className:q(Ae.copy,{[Ae.copied]:i}),onClick:r,children:[t.jsx(S.IconCopy,{size:12}),t.jsxs("div",{className:Ae.labelWrapper,children:[t.jsx("span",{className:Ae.labelCopy,children:"Copy address"}),t.jsx("span",{className:Ae.labelCopied,children:"Copied!"})]})]})}),t.jsx(js,{value:o,children:({copy:r,copied:i})=>t.jsxs("button",{className:q(Ae.derived,{[Ae.copied]:i}),onClick:r,children:[t.jsx("span",{className:Ae.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:Ae.derivedAddress,children:[t.jsx("span",{className:Ae.hexAddress,children:v.truncate(o)}),t.jsx(S.IconCopy,{size:12,className:Ae.derivedCopy}),i&&t.jsx("span",{className:Ae.copiedText,children:"Copied!"})]})]})})]})})};function v1(e,n){return n==null?e:e.filter(s=>s.grantee===n)}function C1(){const e=X(),n=de();return $.useQueries({queries:n.map(s=>({queryKey:xs.grants(s.chainId,e).queryKey,queryFn:async()=>{const o=await Is(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:s.restUrl},"grants"),a=Wr(o),r=e?Uo(e,s.chainId):null,i=v1(a,r);return{chainId:s.chainId,grants:i}},enabled:!!e,staleTime:K.SECOND,retry:!1}))})}const N1="_countdown_vfms8_1",k1={countdown:N1},I1=({expiration:e})=>{const n=()=>{const a=new Date,r=Re.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),c=Math.floor(r%(1440*60)/3600),l=Math.floor(r%3600/60),d=r%60,m=[];return i>0&&m.push(`${i}d`),(c>0||i>0)&&m.push(`${c}h`),(l>0||c>0||i>0)&&m.push(`${l}m`),m.push(`${d}s`),m.join(" ")},[s,o]=x.useState(n());return Le.useInterval(()=>{o(n())},1e3),Re.isPast(e)?"Expired":t.jsxs(t.Fragment,{children:["Expires in ",t.jsx("span",{className:k1.countdown,children:s})]})},A1="_container_1l528_1",S1="_info_1l528_11",T1="_header_1l528_17",$1="_chainName_1l528_23",E1="_expiration_1l528_29",M1="_revokeButton_1l528_35",tn={container:A1,info:S1,header:T1,chainName:$1,expiration:E1,revokeButton:M1},L1=({chainId:e,grantee:n,expiration:s})=>{const o=Xe(e),{mutate:a,isPending:r}=ii({grantee:n,internal:!0});return t.jsxs("div",{className:tn.container,children:[t.jsxs("div",{className:tn.info,children:[t.jsxs("div",{className:tn.header,children:[t.jsx(J,{src:o.logoUrl,width:16,height:16,logo:!0}),t.jsx("div",{className:tn.chainName,children:o.name})]}),t.jsx("div",{className:tn.expiration,children:s?t.jsx(I1,{expiration:s}):"Until revoked"})]}),t.jsx("button",{className:tn.revokeButton,onClick:()=>a(e),disabled:r,children:r?"Revoking...":"Revoke"})]})},q1=({chainId:e,grants:n})=>{const s=new Map;for(const a of n){const r=s.get(a.grantee),i=a.expiration?new Date(a.expiration):void 0;if(!r){s.set(a.grantee,{grantee:a.grantee,expiration:i});continue}r.expiration=Wo([r.expiration,i])}return[...s.values()].map(a=>x.createElement(L1,{...a,chainId:e,key:a.grantee}))},P1="_content_q36qs_1",D1={content:P1},B1=()=>{const e=C1(),n=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?t.jsx(he,{children:"No permissions found"}):t.jsx("div",{className:D1.content,children:s.map(({chainId:o,grants:a})=>t.jsx(q1,{chainId:o,grants:a},o))})};return t.jsx(ht,{title:"Manage auto-signing",backButton:"/settings",children:n()})},R1="_version_1sf5y_1",F1={version:R1},U1=()=>t.jsxs("aside",{className:F1.version,children:["v","2.4.1"]}),O1="_link_se23z_1",V1="_title_se23z_17",K1="_subtitle_se23z_23",W1="_icon_se23z_30",cs={link:O1,title:V1,subtitle:K1,icon:W1},uc=({title:e,subtitle:n,rightSection:s,onClick:o})=>t.jsxs("button",{className:cs.link,onClick:o,children:[t.jsxs("div",{children:[t.jsx("p",{className:cs.title,children:e}),n&&t.jsx("p",{className:cs.subtitle,children:n})]}),t.jsx("div",{className:cs.icon,children:s??t.jsx(S.IconChevronRight,{size:16})})]}),z1="https://export.initia.xyz/",H1=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return t.jsx(uc,{title:"Export private key",rightSection:t.jsx(S.IconExternalLink,{size:16}),onClick:()=>window.open(z1,"_blank",e)})},G1="_container_1vxr7_1",Q1="_separator_1vxr7_7",Ja={container:G1,separator:Q1},Y1=()=>{const e=Ce(),{connector:n}=Ee.useAccount();return t.jsx(ht,{title:"Settings",backButton:"/",children:t.jsxs("div",{className:Ja.container,children:[t.jsx(uc,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),n?.id===qo&&t.jsx(H1,{}),t.jsx(gt.Separator,{className:Ja.separator}),t.jsx(U1,{})]})})},Z1="_trigger_1yjkd_1",J1="_icon_1yjkd_23",X1="_full_1yjkd_27",e2="_triggerContent_1yjkd_32",t2="_triggerText_1yjkd_40",n2="_popoverBackdrop_1yjkd_51",s2="_popoverPositioner_1yjkd_70",o2="_popoverPopup_1yjkd_74",a2="_search_1yjkd_99",r2="_viewport_1yjkd_105",i2="_item_1yjkd_111",c2="_highlighted_1yjkd_127",l2="_active_1yjkd_131",d2="_itemContent_1yjkd_136",u2="_extra_1yjkd_142",m2="_connectedTag_1yjkd_149",ge={trigger:Z1,icon:J1,full:X1,triggerContent:e2,triggerText:t2,popoverBackdrop:n2,popoverPositioner:s2,popoverPopup:o2,search:a2,viewport:r2,item:i2,highlighted:c2,active:l2,itemContent:d2,extra:u2,connectedTag:m2},Hs=({value:e,onChange:n,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=ee(),[i,c]=x.useState(""),[l,d]=x.useState(!1),[m,u]=x.useState(0),[h,f]=x.useState(),p=x.useRef([]),g=x.useRef(null),_=de(),y=s.map(N=>_.find(k=>k.chainId===N)).filter(Boolean),j=N=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:N,height:N,viewBox:"0 0 14 14",children:[t.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),t.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),b=x.useMemo(()=>({chainId:"",name:"All",logoUrl:j}),[]),w=x.useMemo(()=>{const N=[b,...y];if(!i)return N;const k=i.toLowerCase();return N.filter(P=>P.name.toLowerCase().includes(k)||P.chainId.toLowerCase().includes(k))},[y,i,b]),C=y.find(N=>N.chainId===e)||b,I=parseInt(Ni("--drawer-offset")),E=6,M=()=>{if(c(""),u(-1),g.current){const k=g.current.getBoundingClientRect().bottom+E,P=window.innerHeight-k-2*I;f(P)}d(!0)};x.useEffect(()=>{m>=0&&m<p.current.length&&p.current[m]?.scrollIntoView({block:"nearest",behavior:"auto"})},[m]);const A=x.useCallback(N=>{switch(N.key){case"ArrowDown":N.preventDefault(),u(k=>(k+1)%w.length);break;case"ArrowUp":N.preventDefault(),u(k=>(k-1+w.length)%w.length);break;case"Enter":N.preventDefault(),w[m]&&(n(w[m].chainId),d(!1));break;case"Escape":N.preventDefault(),d(!1);break}},[w,m,n,d]),L=N=>{n(N),d(!1)};return t.jsxs(Xt.Popover.Root,{open:l,onOpenChange:M,modal:"trap-focus",children:[t.jsx(Xt.Popover.Trigger,{render:t.jsxs("button",{className:q(ge.trigger,{[ge.full]:a}),"aria-expanded":l,role:"listbox",ref:g,children:[t.jsxs("div",{className:ge.triggerContent,children:[typeof C.logoUrl=="string"?t.jsx(J,{src:C.logoUrl,width:14,height:14,logo:!0}):C.logoUrl(14),t.jsx("span",{className:ge.triggerText,children:C.name})]}),t.jsx(S.IconChevronDown,{size:16,className:ge.icon})]})}),t.jsxs(Xt.Popover.Portal,{container:Ht(),children:[t.jsx(Xt.Popover.Backdrop,{className:ge.popoverBackdrop,onClick:()=>d(!1)}),t.jsx(Xt.Popover.Positioner,{className:ge.popoverPositioner,align:"end",side:"bottom",sideOffset:E,collisionAvoidance:{side:"none"},children:t.jsxs(Xt.Popover.Popup,{className:q(ge.popoverPopup,{[ge.full]:a}),style:{maxHeight:h},children:[t.jsx(zn,{value:i,onChange:N=>{c(N.target.value),u(0)},onClear:()=>c(""),onKeyDown:A,placeholder:"Search appchains",rootClassName:ge.search,ref:Kn()}),t.jsx("div",{className:ge.viewport,role:"listbox",children:w.length===0?t.jsx(he,{children:"No appchains found"}):w.map(({chainId:N,name:k,logoUrl:P},R)=>t.jsxs("div",{className:q(ge.item,{[ge.highlighted]:R===m,[ge.active]:e===N}),onClick:()=>L(N),onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),L(N))},onMouseEnter:()=>u(R),role:"option","aria-selected":e===N,tabIndex:-1,ref:O=>{O&&(p.current[R]=O)},children:[t.jsxs("div",{className:ge.itemContent,children:[typeof P=="string"?t.jsx(J,{src:P,width:16,height:16,logo:!0}):P(16),t.jsx("span",{className:ge.name,children:k}),N===r&&t.jsx("span",{className:ge.connectedTag,children:"Connected"})]}),o&&t.jsx("span",{className:ge.extra,children:o(N)})]},N))})]})})]})]})},h2="_container_1nap1_1",f2="_controls_1nap1_7",p2="_search_1nap1_13",ha={container:h2,controls:f2,search:p2},g2=({children:e})=>t.jsx("div",{className:ha.container,children:e}),_2=({children:e})=>t.jsx("div",{className:ha.controls,children:e}),x2=e=>t.jsx(zn,{...e,rootClassName:ha.search}),Je={Root:g2,Controls:_2,SearchInput:x2},mc=U.atom(""),hc=U.atom(""),y2=U.atom(""),j2=U.atom(""),w2=U.atom(""),b2="_change_1x9v4_1",v2="_positive_1x9v4_10",C2="_negative_1x9v4_14",go={change:b2,positive:v2,negative:C2},fc=({amount:e,asset:n})=>{const{denom:s,symbol:o,decimals:a}=n,r=new B(e).isPositive(),i=new B(e).abs().toString();return t.jsxs("div",{className:q(go.change,r?go.positive:go.negative),children:[r?"+":"-",v.formatAmount(i,{decimals:a})," ",o||s]})},N2=({changes:e,chain:n})=>{const s=mt(n);return e.map(({amount:o,denom:a},r)=>t.jsx(fc,{amount:o,asset:s(a)},r))},k2=({changes:e,chain:n})=>{const s=mt(n);return e.map(({amount:o,metadata:a},r)=>t.jsx(Ei,{metadata:a,chain:n,children:i=>t.jsx(fc,{amount:o,asset:s(i)})},r))},I2=({events:e,chain:n})=>{const{initiaAddress:s,hexAddress:o}=Ue();return n.metadata?.is_l1||n.metadata?.minitia?.type==="minimove"?t.jsx(k2,{changes:$i(e,o),chain:n}):t.jsx(N2,{changes:Ti(e,s),chain:n})},A2="_message_1g2hc_1",S2="_more_1g2hc_8",Xa={message:A2,more:S2},T2=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((n,s)=>t.jsx("p",{className:Xa.message,children:Ns.sentenceCase(n["@type"].split("Msg")[1])},s)),e.length>3&&t.jsx("footer",{className:Xa.more,children:`+${e.length-3} more`})]}),$2="_link_fuhbt_1",E2="_inner_fuhbt_16",M2="_header_fuhbt_21",L2="_time_fuhbt_30",q2="_error_fuhbt_36",P2="_timestamp_fuhbt_40",D2="_chainInfo_fuhbt_45",B2="_content_fuhbt_53",R2="_messages_fuhbt_61",F2="_changes_fuhbt_67",it={link:$2,inner:E2,header:M2,time:L2,error:q2,timestamp:P2,chainInfo:D2,content:B2,messages:R2,changes:F2},U2=({txItem:e,chain:n})=>t.jsx(Us,{txHash:e.txhash,chainId:n.chainId,className:it.link,children:t.jsxs("div",{className:it.inner,children:[t.jsxs("div",{className:it.header,children:[t.jsxs("div",{className:it.time,children:[e.code!==0&&t.jsx(S.IconWarningFilled,{size:14,className:it.error}),t.jsx("span",{className:it.timestamp,children:Re.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:it.chainInfo,children:[t.jsx(J,{src:n.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:n.name})]})]}),t.jsxs("div",{className:it.content,children:[t.jsx("div",{className:it.messages,children:t.jsx(T2,{messages:e.tx.body.messages})}),t.jsx("div",{className:it.changes,children:t.jsx(me,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(I2,{...e,chain:n})})})]})]})}),O2="_list_1mv55_1",V2="_dateGroup_1mv55_7",K2="_dateHeader_1mv55_12",W2="_more_1mv55_18",ls={list:O2,dateGroup:V2,dateHeader:K2,more:W2},z2=({list:e,chainId:n})=>{const s=X(),o=x.useMemo(()=>Hi(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?t.jsx(he,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ls.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{className:ls.dateGroup,children:[t.jsx("div",{className:ls.dateHeader,children:a}),r.map(i=>t.jsx(me,{errorBoundaryProps:{fallback:null},children:t.jsx(U2,{txItem:i,chain:i.chain})},i.txhash))]},a))}),t.jsx(Us,{chainId:n,accountAddress:s,pathSuffix:"/txs",className:ls.more,showIcon:!0,children:"View more on Initia Scan"})]})},H2=()=>{const{activities:e,isLoading:n}=Gl(),[s,o]=U.useAtom(w2),a=re(),r=x.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=x.useMemo(()=>s?e.filter(c=>c.chain.chainId===s):e,[e,s]);return n&&e.length===0?t.jsx(he,{children:"Loading activities..."}):!e.length&&!n?t.jsx(he,{children:"No activity yet"}):t.jsxs(Je.Root,{children:[t.jsx(Je.Controls,{children:t.jsx(Hs,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),t.jsx(z2,{list:i,chainId:s||a.chainId})]})},G2="_thumbnail_1xyqw_1",Q2="_placeholder_1xyqw_18",Y2="_clickable_1xyqw_24",bn={thumbnail:G2,placeholder:Q2,clickable:Y2},Z2=({nftInfo:e,size:n,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:c}=ee(),l=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,c).toString();return s?t.jsx("button",{className:q(bn.thumbnail,bn.clickable),onClick:s,style:{width:n,height:n},children:t.jsx(J,{src:l,classNames:{placeholder:bn.placeholder}})}):t.jsx("div",{className:bn.thumbnail,style:{width:n,height:n},children:t.jsx(J,{src:l,classNames:{placeholder:bn.placeholder}})})},J2="_collectionName_qs5tw_1",X2="_nftName_qs5tw_6",e0="_chainInfo_qs5tw_10",_o={collectionName:J2,nftName:X2,chainInfo:e0},fa=({normalizedNft:e,onThumbnailClick:n,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:c}=e;return t.jsxs("div",{className:a?.root,children:[t.jsx(Z2,{nftInfo:e,onClick:n,size:s}),t.jsxs("div",{children:[t.jsx("div",{className:q(_o.collectionName,a?.collectionName),children:r}),t.jsx("div",{className:q(_o.nftName,a?.nftName),children:i}),t.jsxs("div",{className:q(_o.chainInfo,a?.chainInfo),children:[t.jsx(J,{src:c.logoUrl,width:o,height:o,logo:!0}),t.jsx("span",{children:c.name})]})]})]})},pa=ye.createQueryKeys("interwovenkit:nft",{nfts:(e,n)=>[e,n],metadata:e=>[e]});function t0(e,n){const{nft:s}=e,o=n.name??s.token_id;return{...e,...s,...n,name:o}}function n0(e,n){return e.flatMap((s,o)=>(n[o]??[]).map(r=>({...r,chain:s})))}const s0=()=>{const e=X(),n=de(),s=$.useQueries({queries:n.map(l=>({queryKey:pa.nfts(l.indexerUrl,e).queryKey,queryFn:()=>Is(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:K.SECOND}))}),o=s.map(T.prop("data")),a=n0(n,o),r=a.reduce((l,{chain:d})=>({...l,[d.chainId]:(l[d.chainId]||0)+1}),{}),i=Object.values(r).reduce((l,d)=>l+d,0),c=s.some(l=>l.isLoading);return{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}};function o0(e){const n=er(e);return $.useQuery({queryKey:pa.metadata(n).queryKey,queryFn:async()=>{try{if(!n)return{};const s=await z.get(n).json();return{...s,image:er(s.image)}}catch{return{}}},staleTime:K.INFINITY})}function er(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const a0=({nftInfo:e,children:n})=>{const{data:s={}}=o0(e.nft.uri),o=t0(e,s);return n(o)},r0="_grid_1wwdn_1",i0="_root_1wwdn_7",c0="_collectionName_1wwdn_15",l0="_nftName_1wwdn_23",d0="_chainInfo_1wwdn_32",tr={grid:r0,root:i0,collectionName:c0,nftName:l0,chainInfo:d0},u0=()=>{const[e,n]=U.useAtom(y2),[s,o]=U.useAtom(j2),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=s0(),l=Ce(),d=x.useMemo(()=>a.filter(({collection_addr:u,collection_name:h,nft:f,object_addr:p,chain:g})=>{if(s&&g.chainId!==s)return!1;if(e){const _=e.trim().toLowerCase();return u.toLowerCase().includes(_)||h.toLowerCase().includes(_)||f.token_id.toLowerCase().includes(_)||p.toLowerCase().includes(_)}return!0}),[a,s,e]),m=x.useMemo(()=>Array.from(new Set(a.map(({chain:u})=>u.chainId))),[a]);return c&&a.length===0?t.jsx(he,{children:"Loading NFTs..."}):!a.length&&!e&&!c?t.jsx(he,{children:"No NFTs"}):t.jsxs(Je.Root,{children:[t.jsxs(Je.Controls,{children:[t.jsx(Je.SearchInput,{value:e,onChange:u=>n(u.target.value),onClear:()=>n(""),placeholder:"Search NFTs"}),t.jsx(Hs,{value:s,onChange:o,chainIds:m,renderExtra:u=>u?r[u]||0:i})]}),d.length===0?t.jsx(he,{children:"No NFTs found"}):t.jsx("div",{className:tr.grid,children:d.map(u=>{const{collection_addr:h,nft:f}=u;return t.jsx(a0,{nftInfo:u,children:p=>t.jsx(fa,{normalizedNft:p,onThumbnailClick:()=>l("/nft",p),classNames:tr})},h+f.token_id)})})]})},pc=x.createContext(null);function gc(){return x.useContext(pc)}const m0="_popup_nbecp_1",h0="_item_nbecp_19",ds={popup:m0,item:h0},_c=({asset:e,children:n})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:c,chain:l}=e,{chainId:d}=l,[m,u]=x.useState(!1),h=Ce(),f=gc(),{showNotification:p}=Os(),{defaultChainId:g}=ee(),{evm_chain_id:_}=Gt(),y=Ee.useChainId(),{switchChainAsync:j}=Ee.useSwitchChain(),{watchAssetAsync:b}=Ee.useWatchAsset(),w=()=>{u(!1),h("/send",{denom:s,chain:l})},C=()=>{u(!1),h("/bridge",{srcChainId:d,srcDenom:s,quantity:""})},I=$.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const E=r;return await j({chainId:Number(_)}),b({type:"ERC20",options:{address:c,symbol:a,decimals:o,image:E}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:E=>{p({type:"error",title:"Asset addition failed",description:E.message})}});return t.jsxs(gt.Menu.Root,{open:m,onOpenChange:u,modal:!1,children:[t.jsx(gt.Menu.Trigger,{render:n}),t.jsx(gt.Menu.Portal,{container:f,children:t.jsx(gt.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(gt.Menu.Popup,{className:ds.popup,children:[t.jsxs(gt.Menu.Item,{className:ds.item,onClick:w,children:[t.jsx(S.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(gt.Menu.Item,{className:ds.item,onClick:C,disabled:i,children:[t.jsx(S.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===g&&_===y&&!!c&&t.jsxs(gt.Menu.Item,{className:ds.item,onClick:()=>I.mutate(),disabled:I.isPending||I.data,children:[I.data?t.jsx(S.IconCheck,{size:16}):t.jsx(S.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},f0="_item_38qhm_1",p0="_info_38qhm_23",g0="_images_38qhm_29",_0="_name_38qhm_33",x0="_value_38qhm_39",y0="_amount_38qhm_47",j0="_usd_38qhm_53",Dt={item:f0,info:p0,images:g0,name:_0,value:x0,amount:y0,usd:j0},w0=({asset:e})=>{const{amount:n,value:s,logoUrl:o,chain:a}=e,r=v.formatAmount(n,{decimals:e.decimals});return t.jsx(_c,{asset:e,children:t.jsxs("button",{className:Dt.item,children:[t.jsxs("div",{className:Dt.info,children:[t.jsx(Ks,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:Dt.images}),t.jsx("span",{className:Dt.name,children:a.name})]}),t.jsxs("div",{className:Dt.value,children:[t.jsx("span",{className:Dt.amount,children:r}),Number(s)>0&&t.jsx("span",{className:Dt.usd,children:te(s)})]})]})})},b0="_container_ytg3p_1",v0="_assetItem_ytg3p_6",C0="_expandIcon_ytg3p_22",N0="_assetInfo_ytg3p_27",k0="_logo_ytg3p_33",I0="_details_ytg3p_37",A0="_symbol_ytg3p_42",S0="_chainName_ytg3p_53",T0="_chainInfos_ytg3p_59",$0="_chainLogos_ytg3p_65",E0="_chainLogo_ytg3p_65",M0="_moreChains_ytg3p_76",L0="_expanded_ytg3p_93",q0="_valueColumn_ytg3p_98",P0="_amount_ytg3p_108",D0="_value_ytg3p_98",B0="_collapsibleContent_ytg3p_121",R0="_chainsList_ytg3p_151",pe={container:b0,assetItem:v0,expandIcon:C0,assetInfo:N0,logo:k0,details:I0,symbol:A0,chainName:S0,chainInfos:T0,chainLogos:$0,chainLogo:E0,moreChains:M0,expanded:L0,valueColumn:q0,amount:P0,value:D0,collapsibleContent:B0,chainsList:R0},F0=U.atom([]),ga=({assetGroup:e})=>{const{symbol:n,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=U.useAtom(F0),c=x.useMemo(()=>ud(e),[e]),l=x.useMemo(()=>ci(e),[e]),d=r.includes(n),m=()=>{i(h=>d?h.filter(f=>f!==n):[...new Set([...h,n])])},u=()=>t.jsxs("button",{className:pe.assetItem,children:[t.jsxs("div",{className:pe.assetInfo,children:[s&&t.jsx(J,{src:s,width:32,height:32,className:pe.logo,logo:!0}),t.jsxs("div",{className:pe.details,children:[t.jsx("div",{className:pe.symbol,children:n}),a?t.jsx("div",{className:pe.chainName,children:o[0].chain.name}):t.jsxs("div",{className:pe.chainInfos,children:[t.jsx("div",{className:pe.chainLogos,children:o.slice(0,5).map(({chain:h})=>t.jsx(J,{src:h.logoUrl,width:16,height:16,className:pe.chainLogo,logo:!0},h.chainId))}),o.length>5&&t.jsxs("span",{className:pe.moreChains,children:["+",o.length-5]}),t.jsx(S.IconChevronDown,{size:16,className:q(pe.expandIcon,{[pe.expanded]:d})})]})]})]}),t.jsxs("div",{className:pe.valueColumn,children:[t.jsx("div",{className:pe.amount,children:v.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&t.jsx("div",{className:pe.value,children:te(l)})]})]});if(a){const[h]=o;return t.jsx("div",{className:pe.container,children:t.jsx(_c,{asset:h,children:u()})})}return t.jsx("div",{className:pe.container,children:t.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:m,children:[t.jsx(Z.Collapsible.Trigger,{asChild:!0,children:u()}),t.jsx(Z.Collapsible.Content,{className:pe.collapsibleContent,children:t.jsx("div",{className:pe.chainsList,children:o.map(h=>t.jsx(w0,{asset:h},h.chain.chainId))})})]})})},U0="_collapsible_1g7rh_1",O0="_trigger_1g7rh_5",V0="_divider_1g7rh_20",K0="_label_1g7rh_28",W0="_chevron_1g7rh_33",z0="_content_1g7rh_41",H0="_list_1g7rh_45",It={collapsible:U0,trigger:O0,divider:V0,label:K0,chevron:W0,content:z0,list:H0},xc=({unlistedAssets:e})=>{const[n,s]=x.useState(!1),o=gc(),a=x.useRef(null),[r,i]=x.useState(0);x.useEffect(()=>{if(a.current){const u=a.current.scrollHeight;i(u)}},[e]);const c=x.useRef(null),l=u=>{s(u),u&&c.current&&o?.current&&window.setTimeout(()=>{if(!c.current||!a.current||!o?.current)return;const h=o.current,f=h.getBoundingClientRect(),p=c.current.getBoundingClientRect(),g=a.current.scrollHeight;if(p.bottom+g>f.bottom){const y=p.top-f.top+h.scrollTop-16;h.scrollTo({top:y,behavior:"smooth"})}},50)},d=lt.useSpring({height:n?r:0,opacity:n?1:0,config:{tension:500,friction:30,clamp:!0}}),m=x.useMemo(()=>e.map(u=>({...u,assets:[u],totalValue:u.value??0,totalAmount:Number(u.quantity)})),[e]);return e.length===0?null:t.jsxs(Z.Collapsible.Root,{open:n,onOpenChange:l,className:It.collapsible,children:[t.jsxs(Z.Collapsible.Trigger,{ref:c,className:It.trigger,children:[t.jsx("div",{className:It.divider}),t.jsxs("span",{className:It.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(S.IconChevronDown,{className:It.chevron,size:12,"data-state":n?"open":"closed"}),t.jsx("div",{className:It.divider})]}),t.jsx(Z.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(lt.animated.div,{className:It.content,style:d,children:t.jsx("div",{className:It.list,ref:a,children:m.map(u=>t.jsx(ga,{assetGroup:u},u.assets[0].denom))})})})]})},G0="_container_15xfg_1",Q0="_header_15xfg_7",Y0="_title_15xfg_13",Z0="_totalValue_15xfg_19",J0="_list_15xfg_26",rn={container:G0,header:Q0,title:Y0,totalValue:Z0,list:J0},X0=()=>{const[e,n]=U.useAtom(mc),[s,o]=U.useAtom(hc),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:c,isLoading:l}=Go(),d=i.map(({chainId:h})=>h),m=x.useMemo(()=>{const h=e?a.filter(p=>{const{symbol:g,assets:_}=p;return g.toLowerCase().includes(e.toLowerCase())||_.some(({denom:y,address:j})=>y.toLowerCase().includes(e.toLowerCase())||j?.toLowerCase().includes(e.toLowerCase()))}):a;return s?h.map(p=>({...p,assets:p.assets.filter(({chain:g})=>g.chainId===s)})).filter(p=>p.assets.length>0):h},[a,e,s]),u=x.useMemo(()=>{const h=e?r.filter(({denom:p,address:g})=>p.toLowerCase().includes(e.toLowerCase())||g?.toLowerCase().includes(e.toLowerCase())):r;return s?h.filter(({chain:p})=>p.chainId===s):h},[r,e,s]);return l&&a.length===0?t.jsx(he,{children:"Loading assets..."}):!m.length&&!u.length&&!e&&!s&&!l?t.jsx(he,{children:"No assets"}):t.jsxs(Je.Root,{children:[t.jsxs(Je.Controls,{children:[t.jsx(Je.SearchInput,{value:e,onChange:h=>n(h.target.value),onClear:()=>n(""),placeholder:"Search assets"}),t.jsx(Hs,{value:s,onChange:o,chainIds:d,renderExtra:h=>{if(!h)return te(c);const f=i.find(p=>p.chainId===h);return f?te(f.value):null}})]}),t.jsx("div",{children:m.length===0&&u.length===0?t.jsx(he,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:rn.list,children:m.map(h=>t.jsx(ga,{assetGroup:h},h.symbol))}),t.jsx(xc,{unlistedAssets:u})]})})]})},ej="_container_11k2x_1",tj={container:ej},Ze=({height:e,length:n=1,width:s="100%"})=>{const o=Array.from({length:n},(a,r)=>r);return n===1?t.jsx(Kt,{height:e,width:s}):t.jsx("div",{className:tj.container,children:o.map(a=>t.jsx(Kt,{height:e,width:s},a))})},nj=x.memo(({searchQuery:e,selectedChain:n,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:c}=Un(),l=re(),{listedGroups:d,unlistedAssets:m}=x.useMemo(()=>Yd(i,a,r,l.chainId),[i,a,r,l.chainId]),u=x.useMemo(()=>zd(d,s,o),[d,s,o]),{filteredAssets:h,totalAssetsValue:f,filteredUnlistedAssets:p}=x.useMemo(()=>Qd(u,m,e,n),[u,m,e,n]);return t.jsxs("div",{className:rn.container,children:[t.jsxs("div",{className:rn.header,children:[t.jsx("span",{className:rn.title,children:"Assets"}),h.length>0&&t.jsx("span",{className:rn.totalValue,children:te(f)})]}),h.length>0?t.jsxs("div",{children:[t.jsx("div",{className:rn.list,children:h.map(g=>t.jsx(ga,{assetGroup:g},g.symbol))}),t.jsx(xc,{unlistedAssets:p})]}):u.length===0&&c?t.jsx(Ze,{height:56,length:3}):t.jsx(he,{children:"No liquid assets"})]})}),sj=ye.createQueryKeys("interwovenkit:civitia",{player:(e,n)=>[e,n]});function yc(){const{civitiaUrl:e}=ee(),n=X();return $.useQuery({enabled:!!n,queryKey:sj.player(e,n??"").queryKey,queryFn:async()=>{if(!n)throw new Error("address is not available");return z.get(`${e}/players/${n}`).json()},staleTime:K.MINUTE,throwOnError:!1})}const oj="_section_xdyfz_2",aj="_row_xdyfz_15",rj="_rowLeft_xdyfz_23",ij="_rowIcon_xdyfz_29",cj="_goldIcon_xdyfz_38",lj="_silverIcon_xdyfz_46",dj="_rowTitle_xdyfz_54",uj="_rowValue_xdyfz_60",mj="_rowSubtitle_xdyfz_67",Ne={section:oj,row:aj,rowLeft:rj,rowIcon:ij,goldIcon:cj,silverIcon:lj,rowTitle:dj,rowValue:uj,rowSubtitle:mj},hj=()=>{const{data:e,isLoading:n}=yc();if(n)return t.jsx(Ze,{height:36,length:2});const s=e?.gold_balance??0,o=e?.silver_balance??0;return t.jsxs("div",{className:Ne.section,children:[t.jsxs("div",{className:Ne.row,children:[t.jsxs("div",{className:Ne.rowLeft,children:[t.jsx("div",{className:q(Ne.rowIcon,Ne.goldIcon)}),t.jsx("span",{className:Ne.rowTitle,children:"Gold"})]}),t.jsx("span",{className:q(Ne.rowValue,s===0&&Ne.rowSubtitle),children:s===0?"—":v.formatNumber(s,{dp:6})})]}),t.jsxs("div",{className:Ne.row,children:[t.jsxs("div",{className:Ne.rowLeft,children:[t.jsx("div",{className:q(Ne.rowIcon,Ne.silverIcon)}),t.jsx("span",{className:Ne.rowTitle,children:"Silver"})]}),t.jsx("span",{className:q(Ne.rowValue,o===0&&Ne.rowSubtitle),children:o===0?"—":v.formatNumber(o,{dp:6})})]})]})},fj="_container_1n61l_1",pj="_section_1n61l_7",gj="_sectionHeader_1n61l_19",_j="_sectionTitle_1n61l_25",xj="_sectionLabel_1n61l_31",yj="_externalLink_1n61l_37",jj="_sectionValue_1n61l_49",wj="_tokenList_1n61l_56",bj="_stakingTokenList_1n61l_62",vj="_tokenRow_1n61l_72",Cj="_tokenMain_1n61l_78",Nj="_tokenTrigger_1n61l_84",kj="_tokenChevron_1n61l_100",Ij="_expanded_1n61l_111",Aj="_triggerValue_1n61l_115",Sj="_tokenInfo_1n61l_122",Tj="_tokenInfoLabel_1n61l_128",$j="_tokenLogo_1n61l_134",Ej="_tokenSymbol_1n61l_138",Mj="_tokenValues_1n61l_144",Lj="_tokenAmount_1n61l_150",qj="_tokenValue_1n61l_144",Pj="_typeBreakdown_1n61l_164",Dj="_typeRow_1n61l_172",Bj="_typeLabel_1n61l_180",Rj="_typeValues_1n61l_186",Fj="_typeAmount_1n61l_192",Uj="_typeValue_1n61l_186",Oj="_collapsibleContent_1n61l_206",Y={container:fj,section:pj,sectionHeader:gj,sectionTitle:_j,sectionLabel:xj,externalLink:yj,sectionValue:jj,tokenList:wj,stakingTokenList:bj,tokenRow:vj,tokenMain:Cj,tokenTrigger:Nj,tokenChevron:kj,expanded:Ij,triggerValue:Aj,tokenInfo:Sj,tokenInfoLabel:Tj,tokenLogo:$j,tokenSymbol:Ej,tokenValues:Mj,tokenAmount:Lj,tokenValue:qj,typeBreakdown:Pj,typeRow:Dj,typeLabel:Bj,typeValues:Rj,typeAmount:Fj,typeValue:Uj,collapsibleContent:Oj},jc=({protocols:e,denomLogoMap:n,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=x.useMemo(()=>{const c=e.flatMap(l=>l.positions);return Pd(c)},[e]);return i.size===0?null:t.jsx("div",{className:Y.container,children:Array.from(i.entries()).map(([c,l])=>t.jsx(Vj,{sectionKey:c,sectionGroup:l,denomLogoMap:n,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},c))})},Vj=({sectionKey:e,sectionGroup:n,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:c,totalValue:l}=n,d=qd(e,o),m=x.useMemo(()=>Vd(c),[c]),u=e==="staking";return t.jsxs("div",{className:Y.section,children:[t.jsxs("div",{className:Y.sectionHeader,children:[t.jsxs("div",{className:Y.sectionTitle,children:[t.jsx("span",{className:Y.sectionLabel,children:d}),u&&a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:Y.externalLink,onClick:h=>h.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:Y.sectionValue,children:te(l)})]}),t.jsx("div",{className:q(Y.tokenList,{[Y.stakingTokenList]:u}),children:m.map(h=>t.jsx(Kj,{group:h,showTypeBreakdown:u,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},h.denom))})]})},Kj=({group:e,showTypeBreakdown:n,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:c,totalValue:l,positions:d}=e,m=s.get(r),[u,h]=x.useState(!1),f=x.useMemo(()=>{if(!n)return null;const p=Ud(d);return p.size>0?p:null},[d,n]);return f?t.jsxs(Z.Collapsible.Root,{open:u,onOpenChange:h,children:[t.jsx(Z.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Y.tokenTrigger,children:[t.jsxs("div",{className:Y.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:q(Y.tokenChevron,{[Y.expanded]:u})}),t.jsxs("div",{className:Y.tokenInfoLabel,children:[m?.assetLogo&&t.jsx(J,{src:m.assetLogo,width:20,height:20,className:Y.tokenLogo}),t.jsx("span",{className:Y.tokenSymbol,children:i})]})]}),t.jsx("span",{className:Y.triggerValue,children:te(l)})]})}),t.jsx(Z.Collapsible.Content,{className:Y.collapsibleContent,children:t.jsx(Wj,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):t.jsx("div",{className:Y.tokenRow,children:t.jsxs("div",{className:Y.tokenMain,children:[t.jsxs("div",{className:Y.tokenInfo,children:[m?.assetLogo&&t.jsx(J,{src:m.assetLogo,width:20,height:20,className:Y.tokenLogo}),t.jsx("span",{className:Y.tokenSymbol,children:i})]}),t.jsxs("div",{className:Y.tokenValues,children:[t.jsx("span",{className:Y.tokenAmount,children:v.formatNumber(c,{dp:6})}),t.jsx("span",{className:Y.tokenValue,children:te(l)})]})]})})},Wj=({typeGroups:e,symbol:n,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=x.useMemo(()=>Array.from(e.entries()).map(([l,d])=>{const m=d.reduce((h,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?h:h+f.balance.formattedAmount,0),u=d.reduce((h,f)=>h+ln(f),0);return{type:l,typeAmount:m,typeValue:u}}),[e]),i=x.useMemo(()=>{if(!o)return 0;let l=0;for(const{type:d}of r){const m=o(s,d);l+=Number(m)}return l},[s,o,r]),c=i>0;return t.jsxs("div",{className:Y.typeBreakdown,children:[r.map(({type:l,typeAmount:d,typeValue:m})=>t.jsxs("div",{className:Y.typeRow,children:[t.jsx("span",{className:Y.typeLabel,children:Fd(l)}),t.jsxs("div",{className:Y.typeValues,children:[t.jsxs("span",{className:Y.typeAmount,children:[v.formatNumber(d,{dp:6})," ",n]}),t.jsx("span",{className:Y.typeValue,children:te(m)})]})]},l)),c&&t.jsxs("div",{className:Y.typeRow,children:[t.jsx("span",{className:Y.typeLabel,children:"Claimable"}),t.jsxs("div",{className:Y.typeValues,children:[t.jsxs("span",{className:Y.typeAmount,children:[v.formatNumber(i,{dp:6})," ",Ye]}),t.jsx("span",{className:Y.typeValue,children:te(i*(a??0))})]})]})]})},zj="_container_ymkoc_1",Hj="_trigger_ymkoc_6",Gj="_expandIcon_ymkoc_22",Qj="_chainInfo_ymkoc_27",Yj="_logo_ymkoc_33",Zj="_chainNameContainer_ymkoc_37",Jj="_chainName_ymkoc_37",Xj="_externalLink_ymkoc_49",ew="_externalIcon_ymkoc_53",tw="_valueColumn_ymkoc_63",nw="_value_ymkoc_63",sw="_expanded_ymkoc_80",ow="_collapsibleContent_ymkoc_85",aw="_content_ymkoc_97",Se={container:zj,trigger:Hj,expandIcon:Gj,chainInfo:Qj,logo:Yj,chainNameContainer:Zj,chainName:Jj,externalLink:Xj,externalIcon:ew,valueColumn:tw,value:nw,expanded:sw,collapsibleContent:ow,content:aw},rw=U.atom([]),iw=({chainGroup:e})=>{const{chainId:n,chainLogo:s,protocols:o}=e,a=de(),r=Ln(),{denomLogos:i,symbolLogos:c}=x.useMemo(()=>ta(r,a),[r,a]),l=x.useMemo(()=>{const d=new Map;for(const m of o)for(const u of m.positions){if(u.type==="fungible-position"||u.balance.type==="unknown")continue;const{denom:h,symbol:f}=u.balance,p=f.toUpperCase(),g=`${n}:${h}`,_=i.get(g)??c.get(p);_&&d.set(h,{assetLogo:_,chainLogo:s??""})}return d},[o,i,c,n,s]);return t.jsx(jc,{protocols:o,denomLogoMap:l})},cw=({chainGroup:e})=>{const{chainName:n,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=U.useAtom(rw),c=x.useMemo(()=>o.reduce((p,g)=>p+g.positions.reduce((_,y)=>_+ln(y),0),0),[o]),l=["civitia","yominet"],d=r.includes(n),m=n?.toLowerCase(),u=m==="civitia",h=l.includes(m),f=()=>{i(p=>d?p.filter(g=>g!==n):[...new Set([...p,n])])};return t.jsx("div",{className:Se.container,children:t.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:f,children:[t.jsx(Z.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Se.trigger,children:[t.jsxs("div",{className:Se.chainInfo,children:[s&&t.jsx(J,{src:s,width:32,height:32,className:Se.logo,logo:!0}),t.jsxs("div",{className:Se.chainNameContainer,children:[t.jsx("span",{className:Se.chainName,children:n}),a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:Se.externalLink,onClick:p=>p.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:Se.externalIcon})})]})]}),t.jsxs("div",{className:Se.valueColumn,children:[!h&&t.jsx("span",{className:Se.value,children:te(c)}),t.jsx(S.IconChevronDown,{size:16,className:q(Se.expandIcon,{[Se.expanded]:d})})]})]})}),t.jsx(Z.Collapsible.Content,{className:Se.collapsibleContent,children:t.jsxs("div",{className:Se.content,children:[t.jsx(iw,{chainGroup:e}),u&&t.jsx(hj,{})]})})]})})},lw="_container_1gqx9_1",dw="_section_1gqx9_6",uw="_sectionHeader_1gqx9_14",mw="_sectionTitle_1gqx9_20",hw="_sectionLabel_1gqx9_26",fw="_externalLink_1gqx9_32",pw="_sectionValue_1gqx9_44",gw="_tokenList_1gqx9_51",_w="_tokenTrigger_1gqx9_63",xw="_tokenChevron_1gqx9_79",yw="_expanded_1gqx9_90",jw="_tokenInfo_1gqx9_94",ww="_tokenInfoLabel_1gqx9_100",bw="_tokenLogo_1gqx9_106",vw="_pairedLogos_1gqx9_110",Cw="_coinLogo_1gqx9_115",Nw="_tokenSymbol_1gqx9_133",kw="_triggerValue_1gqx9_139",Iw="_breakdownContent_1gqx9_146",Aw="_breakdownRow_1gqx9_154",Sw="_breakdownLabel_1gqx9_162",Tw="_breakdownValues_1gqx9_168",$w="_breakdownAmount_1gqx9_174",Ew="_breakdownValue_1gqx9_168",Mw="_collapsibleContent_1gqx9_195",oe={container:lw,section:dw,sectionHeader:uw,sectionTitle:mw,sectionLabel:hw,externalLink:fw,sectionValue:pw,tokenList:gw,tokenTrigger:_w,tokenChevron:xw,expanded:yw,tokenInfo:jw,tokenInfoLabel:ww,tokenLogo:bw,pairedLogos:vw,coinLogo:Cw,tokenSymbol:Nw,triggerValue:kw,breakdownContent:Iw,breakdownRow:Aw,breakdownLabel:Sw,breakdownValues:Tw,breakdownAmount:$w,breakdownValue:Ew,collapsibleContent:Mw},Lw=({data:e,denomLogoMap:n})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:t.jsx("div",{className:oe.container,children:t.jsxs("div",{className:oe.section,children:[t.jsxs("div",{className:oe.sectionHeader,children:[t.jsxs("div",{className:oe.sectionTitle,children:[t.jsx("span",{className:oe.sectionLabel,children:"Liquidity"}),t.jsx("a",{href:Oo,target:"_blank",rel:"noopener noreferrer",className:oe.externalLink,onClick:a=>a.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:oe.sectionValue,children:te(s)})]}),t.jsx("div",{className:oe.tokenList,children:o.map(a=>t.jsx(Pw,{row:a,denomLogoMap:n},a.denom))})]})})},qw={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"},Pw=({row:e,denomLogoMap:n})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:c,claimableInit:l}=e,[d,m]=x.useState(!1),u=n.get(s),h=i||u?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,p=x.useMemo(()=>Object.entries(r).filter(([,y])=>y>0),[r]),g=c&&c.length>0&&c.some(y=>y),_=l&&Number(l.total)>0;return t.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:m,children:[t.jsx(Z.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:oe.tokenTrigger,children:[t.jsxs("div",{className:oe.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:q(oe.tokenChevron,{[oe.expanded]:d})}),t.jsxs("div",{className:oe.tokenInfoLabel,children:[g?t.jsx("div",{className:oe.pairedLogos,children:c.map((y,j)=>t.jsx(J,{src:y,width:20,height:20,className:oe.coinLogo,logo:!0},j))}):h&&t.jsx(J,{src:h,width:20,height:20,className:oe.tokenLogo}),t.jsx("span",{className:oe.tokenSymbol,children:o})]})]}),t.jsx("span",{className:oe.triggerValue,children:te(a)})]})}),t.jsx(Z.Collapsible.Content,{className:oe.collapsibleContent,children:t.jsxs("div",{className:oe.breakdownContent,children:[p.map(([y,j])=>{const b=j*f;return t.jsxs("div",{className:oe.breakdownRow,children:[t.jsx("span",{className:oe.breakdownLabel,children:qw[y]}),t.jsxs("div",{className:oe.breakdownValues,children:[t.jsxs("span",{className:oe.breakdownAmount,children:[v.formatNumber(j,{dp:6})," LP"]}),t.jsx("span",{className:oe.breakdownValue,children:te(b)})]})]},y)}),_&&t.jsxs("div",{className:oe.breakdownRow,children:[t.jsx("span",{className:oe.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:oe.breakdownValues,children:[t.jsxs("span",{className:oe.breakdownAmount,children:[v.formatNumber(Number(l.total),{dp:6})," ",Ye]}),t.jsx("span",{className:oe.breakdownValue,children:te(l.totalValue)})]})]})]})})]})},Dw="_container_1nijk_1",Bw="_section_1nijk_6",Rw="_sectionHeader_1nijk_14",Fw="_sectionTitle_1nijk_20",Uw="_sectionLabel_1nijk_26",Ow="_externalLink_1nijk_32",Vw="_sectionValue_1nijk_44",Kw="_tokenList_1nijk_51",Ww="_tokenTrigger_1nijk_63",zw="_tokenChevron_1nijk_79",Hw="_expanded_1nijk_90",Gw="_tokenInfo_1nijk_94",Qw="_tokenInfoLabel_1nijk_100",Yw="_tokenLogo_1nijk_106",Zw="_tokenName_1nijk_110",Jw="_triggerValue_1nijk_116",Xw="_breakdownContent_1nijk_123",eb="_breakdownRow_1nijk_131",tb="_breakdownLabel_1nijk_139",nb="_breakdownValues_1nijk_145",sb="_breakdownAmount_1nijk_151",ob="_breakdownValue_1nijk_145",ab="_collapsibleContent_1nijk_165",ce={container:Dw,section:Bw,sectionHeader:Rw,sectionTitle:Fw,sectionLabel:Uw,externalLink:Ow,sectionValue:Vw,tokenList:Kw,tokenTrigger:Ww,tokenChevron:zw,expanded:Hw,tokenInfo:Gw,tokenInfoLabel:Qw,tokenLogo:Yw,tokenName:Zw,triggerValue:Jw,breakdownContent:Xw,breakdownRow:eb,breakdownLabel:tb,breakdownValues:nb,breakdownAmount:sb,breakdownValue:ob,collapsibleContent:ab},rb=({data:e})=>{const{totalValue:n,rows:s}=e;return s.length===0?null:t.jsx("div",{className:ce.container,children:t.jsxs("div",{className:ce.section,children:[t.jsxs("div",{className:ce.sectionHeader,children:[t.jsxs("div",{className:ce.sectionTitle,children:[t.jsx("span",{className:ce.sectionLabel,children:"VIP"}),t.jsx("a",{href:jl,target:"_blank",rel:"noopener noreferrer",className:ce.externalLink,onClick:o=>o.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:ce.sectionValue,children:te(n)})]}),t.jsx("div",{className:ce.tokenList,children:s.map(o=>t.jsx(ib,{row:o},`${o.bridgeId}-${o.version}`))})]})})},ib=({row:e})=>{const{name:n,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[c,l]=x.useState(!1),d=a+i;return t.jsxs(Z.Collapsible.Root,{open:c,onOpenChange:l,children:[t.jsx(Z.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:ce.tokenTrigger,children:[t.jsxs("div",{className:ce.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:q(ce.tokenChevron,{[ce.expanded]:c})}),t.jsxs("div",{className:ce.tokenInfoLabel,children:[s&&t.jsx(J,{src:s,width:20,height:20,className:ce.tokenLogo,logo:!0}),t.jsx("span",{className:ce.tokenName,children:n})]})]}),t.jsx("span",{className:ce.triggerValue,children:te(d)})]})}),t.jsx(Z.Collapsible.Content,{className:ce.collapsibleContent,children:t.jsxs("div",{className:ce.breakdownContent,children:[o>0&&t.jsxs("div",{className:ce.breakdownRow,children:[t.jsx("span",{className:ce.breakdownLabel,children:"Locked"}),t.jsxs("div",{className:ce.breakdownValues,children:[t.jsxs("span",{className:ce.breakdownAmount,children:[v.formatNumber(o,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:te(a)})]})]}),r>0&&t.jsxs("div",{className:ce.breakdownRow,children:[t.jsx("span",{className:ce.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:ce.breakdownValues,children:[t.jsxs("span",{className:ce.breakdownAmount,children:[v.formatNumber(r,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:te(i)})]})]})]})})]})},cb="_container_ymkoc_1",lb="_trigger_ymkoc_6",db="_expandIcon_ymkoc_22",ub="_chainInfo_ymkoc_27",mb="_logo_ymkoc_33",hb="_chainNameContainer_ymkoc_37",fb="_chainName_ymkoc_37",pb="_externalLink_ymkoc_49",gb="_externalIcon_ymkoc_53",_b="_valueColumn_ymkoc_63",xb="_value_ymkoc_63",yb="_expanded_ymkoc_80",jb="_collapsibleContent_ymkoc_85",wb="_content_ymkoc_97",Te={container:cb,trigger:lb,expandIcon:db,chainInfo:ub,logo:mb,chainNameContainer:hb,chainName:fb,externalLink:pb,externalIcon:gb,valueColumn:_b,value:xb,expanded:yb,collapsibleContent:jb,content:wb},bb=U.atom(!1),vb=()=>{const{totalValue:e}=Jo(),{totalValue:n}=ea(),{totalValue:s}=Bs(),o=e+n+s;return t.jsx("span",{className:Te.value,children:te(o)})},Cb=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Jo(),{data:i}=mi(),{data:c}=hi(),l=x.useMemo(()=>{const u=new Map;for(const h of r){if(h.type==="fungible-position"||h.balance.type==="unknown")continue;const{denom:f,symbol:p}=h.balance,g=p.toUpperCase(),_=`${e}:${f}`,y=s.get(_)??o.get(g);y&&u.set(f,{assetLogo:y,chainLogo:n})}return u},[r,s,o,e,n]),d=x.useMemo(()=>(u,h)=>{const f=v.denomToMetadata(u);if(h==="staking"){const p=i?.get(f);return p?v.fromBaseUnit(p.amount,{decimals:Be}):"0"}if(h==="lockstaking"){const p=c?.get(f);return p?v.fromBaseUnit(p.amount,{decimals:Be}):"0"}return"0"},[i,c]),m=x.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:Oo,positions:r}],[r]);return m.length===0?null:t.jsx(jc,{protocols:m,denomLogoMap:l,isInitia:!0,getClaimableInitByType:d,initPrice:a})},Nb=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o})=>{const a=ea(),r=x.useMemo(()=>{const i=new Map;for(const c of a.rows){const{denom:l,symbol:d}=c,m=d.toUpperCase(),u=`${e}:${l}`,h=s.get(u)??o.get(m);h&&i.set(l,{assetLogo:h,chainLogo:n})}return i},[a.rows,s,o,e,n]);return a.rows.length===0?null:t.jsx(Lw,{data:a,denomLogoMap:r})},kb=()=>{const e=Bs();return e.rows.length===0?null:t.jsx(rb,{data:e})},Ib=({chainGroup:e})=>{const{chainId:n,chainName:s,chainLogo:o}=e,[a,r]=U.useAtom(bb),i=de(),c=Ln(),{denomLogos:l,symbolLogos:d}=x.useMemo(()=>ta(c,i),[c,i]),m=re(),{data:u}=yt(m),h=x.useMemo(()=>u?.find(p=>p.id===Ie)?.price??0,[u]);return t.jsx("div",{className:Te.container,children:t.jsxs(Z.Collapsible.Root,{open:a,onOpenChange:r,children:[t.jsx(Z.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Te.trigger,children:[t.jsxs("div",{className:Te.chainInfo,children:[o&&t.jsx(J,{src:o,width:32,height:32,className:Te.logo,logo:!0}),t.jsxs("div",{className:Te.chainNameContainer,children:[t.jsx("span",{className:Te.chainName,children:s}),t.jsx("a",{href:Oo,target:"_blank",rel:"noopener noreferrer",className:Te.externalLink,onClick:f=>f.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:Te.externalIcon})})]})]}),t.jsxs("div",{className:Te.valueColumn,children:[t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:16,width:60,length:1}),children:t.jsx(vb,{})}),t.jsx(S.IconChevronDown,{size:16,className:q(Te.expandIcon,{[Te.expanded]:a})})]})]})}),t.jsx(Z.Collapsible.Content,{className:Te.collapsibleContent,children:t.jsxs("div",{className:Te.content,children:[t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:36,length:2}),children:t.jsx(Cb,{chainId:n,chainLogo:o,denomLogos:l,symbolLogos:d,initPrice:h})}),t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:36,length:2}),children:t.jsx(Nb,{chainId:n,chainLogo:o,denomLogos:l,symbolLogos:d})}),t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:36,length:1}),children:t.jsx(kb,{})})]})})]})})},Ab="_totalValue_1v2ca_1",Sb={totalValue:Ab},Tb=({filteredChainGroups:e})=>{const{totalValue:n}=Jo(),{totalValue:s}=ea(),{totalValue:o}=Bs(),a=n+s+o,r=x.useMemo(()=>{const i=e.some(l=>l.isInitia);return e.reduce((l,d)=>d.isInitia?l:l+d.totalValue,0)+(i?a:0)},[e,a]);return t.jsx("span",{className:Sb.totalValue,children:te(r)})},$b="_container_1eubu_1",Eb="_header_1eubu_7",Mb="_title_1eubu_13",Lb="_list_1eubu_19",qb="_skeletonWrapper_1eubu_24",vn={container:$b,header:Eb,title:Mb,list:Lb,skeletonWrapper:qb},Pb=x.memo(({searchQuery:e,selectedChain:n,chainInfoMap:s})=>{const{positions:o,isLoading:a}=Un(),r=re(),{data:i,isLoading:c}=yc(),l=x.useMemo(()=>{const m=[];for(const h of o){if(!Array.isArray(h.positions))continue;const f=s.get(h.chainName.toLowerCase()),p=h.chainName.toLowerCase(),g=p==="civitia";if(n&&f?.chainId!==n)continue;const _=h.positions.some(C=>C.positions.some(I=>I.type!=="fungible-position")),y=g&&!c&&i&&((i.gold_balance??0)>0||(i.silver_balance??0)>0);if(!_&&!y||e&&!p.includes(e.toLowerCase()))continue;const j=h.positions.filter(C=>e&&!C.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(C.positions)&&C.positions.length>0),b=r.chainId===f?.chainId,w=j.reduce((C,I)=>C+I.positions.reduce((E,M)=>E+ln(M),0),0);m.push({chainId:f?.chainId??"",chainName:f?.prettyName??h.chainName,chainLogo:f?.logoUrl??"",protocols:j,isInitia:b,totalValue:w})}const u=["civitia","yominet"];return T.sortWith([T.descend(h=>h.isInitia??!1),T.ascend(h=>u.includes(h.chainName.toLowerCase())),T.descend(h=>h.totalValue??0),T.ascend(h=>h.chainName.toLowerCase())],m)},[o,s,e,n,r.chainId,i,c]),d=l.length>0;return t.jsxs("div",{className:vn.container,children:[t.jsxs("div",{className:vn.header,children:[t.jsx("span",{className:vn.title,children:"Positions"}),d&&t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:16,width:60,length:1}),children:t.jsx(Tb,{filteredChainGroups:l})})]}),d?t.jsx("div",{className:vn.list,children:l.map(m=>m.isInitia?t.jsx(me,{suspenseFallback:t.jsx("div",{className:vn.skeletonWrapper,children:t.jsx(Ze,{height:56,length:1})}),children:t.jsx(Ib,{chainGroup:m})},m.chainName):t.jsx(cw,{chainGroup:m},m.chainName))}):o.length===0&&a?t.jsx(Ze,{height:56,length:3}):t.jsx(he,{children:"No positions"})]})}),Db="_content_1w1ad_1",Bb={content:Db},Rb=({selectedChain:e,setSelectedChain:n})=>{const{defaultChainId:s}=ee(),o=re(),a=su(),{totalValue:r}=Bs(),{chainIds:i,chainIdToValueMap:c,totalBalance:l}=x.useMemo(()=>{const d=new Map;let m=0;for(const h of a)d.set(h.chainId,h.totalBalance),m+=h.totalBalance;return r>0&&(d.set(o.chainId,(d.get(o.chainId)??0)+r),m+=r),{chainIds:T.sortWith([T.descend(h=>h===s),T.descend(h=>h===o.chainId),T.descend(h=>d.get(h)??0)],a.map(h=>h.chainId)),chainIdToValueMap:d,totalBalance:m}},[a,s,o,r]);return t.jsx(Hs,{value:e,onChange:n,chainIds:i,renderExtra:d=>te(d?c.get(d)??0:l)})},Fb=()=>{const[e,n]=U.useAtom(mc),[s,o]=U.useAtom(hc),a=de(),r=Ln(),{denomLogos:i,symbolLogos:c}=x.useMemo(()=>ta(r,a),[r,a]),l=Po(),d=x.useMemo(()=>xi(a,l),[a,l]),m=nu();return t.jsxs(Je.Root,{children:[t.jsxs(Je.Controls,{children:[t.jsx(Je.SearchInput,{value:e,onChange:u=>n(u.target.value),onClear:()=>n(""),placeholder:"Search portfolio"}),t.jsx(me,{suspenseFallback:t.jsx(Kt,{height:44,width:132}),children:t.jsx(Rb,{selectedChain:s,setSelectedChain:o})})]}),t.jsxs("div",{className:Bb.content,children:[t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:48,length:5}),children:t.jsx(nj,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:c,chainInfoMap:m,chainPrices:d})}),t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:56,length:3}),children:t.jsx(Pb,{searchQuery:e,selectedChain:s,chainInfoMap:m})})]})]})},Ub="_totalValue_5pf7e_1",Ob="_totalLabel_5pf7e_7",Vb="_totalAmount_5pf7e_13",Kb="_loading_5pf7e_18",Wb="_skeletonWrapper_5pf7e_23",zb="_nav_5pf7e_28",Hb="_item_5pf7e_34",Gb="_tabs_5pf7e_59",Qb="_tab_5pf7e_59",$e={totalValue:Ub,totalLabel:Ob,totalAmount:Vb,loading:Kb,skeletonWrapper:Wb,nav:zb,item:Hb,tabs:Gb,tab:Qb},Yb=()=>{const{totalValue:e,isLoading:n}=Go();return t.jsx("div",{className:q($e.totalAmount,{[$e.loading]:n}),children:te(e)})},Zb=()=>{const e=ou(),n=au(),s=_i(),o=e+s+n;return t.jsx("div",{className:$e.totalAmount,children:te(o)})},Jb=()=>{Ui(),eu();const e=na(),n=Ce(),s=Ts(),o=x.useRef(null);return t.jsx(pc.Provider,{value:o,children:t.jsxs(nt,{ref:o,children:[t.jsxs("div",{className:$e.totalValue,children:[t.jsx("div",{className:$e.totalLabel,children:"Total value"}),t.jsx(me,{suspenseFallback:t.jsx("div",{className:$e.skeletonWrapper,children:t.jsx(Kt,{height:48,width:120})}),children:e?t.jsx(Yb,{}):t.jsx(Zb,{})})]}),t.jsxs("div",{className:$e.nav,children:[t.jsxs(cn,{to:"/send",className:$e.item,children:[t.jsx(S.IconSend,{size:20}),t.jsx("span",{children:"Send"})]}),t.jsxs(cn,{to:"/bridge",className:$e.item,children:[t.jsx(S.IconBridge,{size:20}),t.jsx("span",{children:"Bridge/Swap"})]}),t.jsxs(cn,{to:"/receive",className:$e.item,children:[t.jsx(S.IconQrCode,{size:20}),t.jsx("span",{children:"Receive"})]})]}),t.jsxs(Ct.Tabs.Root,{value:s,onValueChange:n,children:[t.jsxs(Ct.Tabs.List,{className:$e.tabs,children:[t.jsx(Ct.Tabs.Tab,{className:$e.tab,value:"/",children:e?"Assets":"Portfolio"}),t.jsx(Ct.Tabs.Tab,{className:$e.tab,value:"/nfts",children:"NFTs"}),t.jsx(Ct.Tabs.Tab,{className:$e.tab,value:"/activity",children:"Activity"})]}),t.jsx(Ct.Tabs.Panel,{value:"/",children:e?t.jsx(X0,{}):t.jsx(Fb,{})}),t.jsx(Ct.Tabs.Panel,{value:"/nfts",children:t.jsx(u0,{})}),t.jsx(Ct.Tabs.Panel,{value:"/activity",children:t.jsx(H2,{})})]})]})})},Xb="_root_th990_1",ev="_collectionName_th990_9",tv="_nftName_th990_13",nv="_chainInfo_th990_17",sv="_attributes_th990_21",ov="_title_th990_24",av="_count_th990_29",rv="_item_th990_33",iv="_type_th990_39",cv="_value_th990_45",Bt={root:Xb,collectionName:ev,nftName:tv,chainInfo:nv,attributes:sv,title:ov,count:av,item:rv,type:iv,value:cv},lv=()=>{const e=Ce(),n=et(),{attributes:s}=n;return t.jsxs(ht,{title:"NFT details",children:[t.jsx(fa,{normalizedNft:n,chainIconSize:14,classNames:Bt}),t.jsx(xe,{children:t.jsx(le.White,{onClick:()=>e("/nft/send",n),sm:!0,children:"Send"})}),s&&t.jsxs("div",{className:Bt.attributes,children:[t.jsxs("header",{className:Bt.title,children:["Traits ",t.jsxs("span",{className:Bt.count,children:["(",s.length,")"]})]}),t.jsx("div",{children:s.map(({trait_type:o,value:a})=>t.jsxs("div",{className:Bt.item,children:[t.jsx("div",{className:Bt.type,children:o}),t.jsx("div",{className:Bt.value,children:a})]},o))})]})]})};function dv({balances:e,gasPrices:n,gas:s}){return n.map(({denom:o,amount:a})=>{const r=B(a).times(s).toFixed(0,B.ROUND_CEIL),i=e.find(c=>c.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>B(a).gte(o))}function uv({denom:e,balances:n,gasPrices:s,lastFeeDenom:o,gas:a}){const r=n.find(d=>d.denom===e)?.amount??"0",i=dv({balances:n,gasPrices:s,gas:a}),c=i.find(d=>d.denom===o);if(i.length===0)return r;if(e===o&&c){const d=B(r).minus(c.amount);return B.max(d,0).toString()}const l=i.find(d=>d.denom!==e)||i[0];if(!c&&e===l.denom){const d=B(r).minus(l.amount);return B.max(d,0).toString()}return B(r).toString()}const mv=({chain:e,onSelect:n})=>{const s=Hc(e);return t.jsx(Hn,{assets:s,onSelect:n})},hv=({afterSelect:e})=>{const{watch:n,setValue:s}=_e.useFormContext(),{chainId:o,denom:a}=n(),{chainId:r}=n(),[i,c]=x.useState(r),l=Xe(i),d=de(),m=u=>{if(o===i&&a===u){e();return}s("chainId",i),s("denom",u),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(Vt.Stack,{children:t.jsx(Vt,{chains:d,value:i,onSelect:c})}),t.jsx(me,{suspenseFallback:t.jsx(Hn.Placeholder,{}),children:t.jsx(mv,{chain:l,onSelect:m})},i)]})},fv="_fields_brpej_1",pv="_divider_brpej_11",nr={fields:fv,divider:pv},gv=ye.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),_v=()=>{const{address:e,initiaAddress:n,estimateGas:s,requestTxSync:o}=Ue(),{register:a,watch:r,setValue:i,handleSubmit:c,formState:l}=_e.useFormContext(),{errors:d}=l,{chainId:m,denom:u,recipient:h,quantity:f,memo:p}=r(),g=Xe(m),_=qn(g),y=zo(g),j=Ho(g),b=gr(u,g),{data:w}=yt(g),{decimals:C}=b,I=_.find(F=>F.denom===u)?.amount??"0",E=w?.find(({id:F})=>F===u)?.price,{data:M=0,isLoading:A}=$.useQuery({queryKey:gv.gas({chainId:m,denom:u,recipient:h,initiaAddress:n}).queryKey,queryFn:()=>{const F=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:va.MsgSend.fromPartial({fromAddress:n,toAddress:v.InitiaAddress(h).bech32,amount:[{denom:u,amount:"1"}]})}];return s({messages:F,chainId:m})},enabled:v.InitiaAddress.validate(h),staleTime:K.INFINITY}),L=Math.ceil(M*zt),N=uv({denom:u,balances:_,gasPrices:y,lastFeeDenom:j,gas:L}),k=B(I).isZero(),R=y.some(({denom:F})=>F===u)&&A,O=k||R,{mutate:V,isPending:H}=$.useMutation({mutationFn:({chainId:F,denom:W,quantity:qe,recipient:we,memo:st})=>{const Oe=v.toBaseUnit(qe,{decimals:C}),Zt=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:va.MsgSend.fromPartial({fromAddress:n,toAddress:v.InitiaAddress(we).bech32,amount:[{denom:W,amount:Oe}]})}];return o({messages:Zt,memo:st,chainId:F,gas:M,gasAdjustment:zt,gasPrices:y,spendCoins:[{denom:W,amount:Oe}],internal:"/"})}}),Q=x.useMemo(()=>{if(!f)return"Enter amount";if(d.quantity)return d.quantity.message;if(!h)return"Enter recipient address";if(d.recipient)return d.recipient.message;if(d.memo)return d.memo.message},[f,h,d.quantity,d.recipient,d.memo]);return t.jsx(ht,{title:"Send",children:t.jsxs("form",{onSubmit:c(F=>V(F)),children:[t.jsxs("div",{className:nr.fields,children:[t.jsx(Co,{selectButton:t.jsx(dn,{title:"Select chain and asset",content:F=>t.jsx(hv,{afterSelect:F}),children:t.jsx(Wi,{asset:b,chain:g})}),quantityInput:t.jsx(En,{balance:I,decimals:C}),balanceButton:t.jsx(Oi,{onClick:()=>i("quantity",v.fromBaseUnit(N,{decimals:C}),{shouldValidate:!0}),disabled:O,children:v.formatAmount(I??"0",{decimals:C})}),value:f?E?te(B(f).times(E)):"$-":"$0"}),t.jsx("div",{className:nr.divider}),t.jsx(ra,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...a("memo",{validate:F=>!F||new Blob([F]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),t.jsx(fe.Stack,{children:!p&&t.jsx(fe,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(xe,{children:t.jsx(le.White,{type:"submit",loading:(A?"Estimating gas...":!1)||H,disabled:!!Q,children:Q??"Confirm"})})]})})},xv=()=>{const e=et(),n=Gt(),s=xt(n),{chain:o=n}=e,a=T.head(s);if(!e.denom&&!a)throw new Error("Asset list not found. This occurs during local development when asset list is not configured. Use asset-specific send buttons instead of the default send button, or register chain in Initia Registry with at least one asset defined.");const r=e.denom??a?.denom,i=_e.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return t.jsx(_e.FormProvider,{...i,children:t.jsx(_v,{})})};async function $o(e,n){const s=e.replace("ibc/",""),{class_trace:o}=await z.create({prefixUrl:n}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function yv(e,n){const s=new ct.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await z.create({prefixUrl:n}).post("minievm/evm/v1/call",{json:{sender:v.InitiaAddress("0x1").bech32,contract_addr:v.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function jv(e,n,s){if(n.startsWith("evm/"))return e;const{token_infos:o}=await z.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${n}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function wv({collection_addr:e},{restUrl:n}){const s=await yv(e,n);if(!s.startsWith("ibc/"))return{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await $o(s,n);return o?{class_id:s,class_trace:o}:{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function bv(e,n){const{data:s}=await z.create({prefixUrl:n}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(s)}async function vv({object_addr:e,collection_addr:n},{restUrl:s}){const o=await bv(n,s);return o.startsWith("ibc/")?v.InitiaAddress.equals(v.createObjectAddress("0x1",o),n)?{class_id:o,class_trace:await $o(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await $o(o,s)}:{class_id:`move/${n.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function Cv(e,n){const s=se.toBase64(Ft.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await z.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function Nv(e,n){const{collection:s}=await z.create({prefixUrl:n}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function kv(e,n){const s=se.toBase64(Ft.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function sr(e){const n=/^(.*channel-\d+)\/(.*)$/,s=e.match(n);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,o,a]=s;return[o,a]}async function Iv({collection_addr:e},n,s){const o=v.InitiaAddress(e).bech32,a=await Cv(o,n.restUrl),r=n.metadata?.ibc_channels?.find(({chain_id:g,version:_})=>g===s.chain_id&&_.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,c=i.split(".")[1],l=se.toBase64(Ft.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await z.create({prefixUrl:n.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),m=d??o,u=await kv(c,n.restUrl),h=await Nv(o,n.indexerUrl);if(m===o)return{class_id:m,class_trace:void 0,outgoing_proxy:u};if(d&&h!==i.replace("wasm.","")){const[g,_]=sr(d);return{class_id:o,class_trace:{path:g,base_class_id:_},outgoing_proxy:u}}const[f,p]=sr(a);return{class_id:o,class_trace:{path:f,base_class_id:p},outgoing_proxy:u}}const Av={minimove:vv,minievm:wv,miniwasm:Iv};async function Sv({nft:e,srcChain:n,intermediaryChain:s}){const o=n.metadata?.is_l1?"minimove":n.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const a=await Av[o](e,n,s);return Object.assign(a,o==="minievm"&&{token_ids:await jv([e.token_id],a.class_id,n.restUrl)})}const Tv="_root_1tyvn_1",$v="_collectionName_1tyvn_10",Ev="_nftName_1tyvn_15",Mv="_chainInfo_1tyvn_19",Lv="_fields_1tyvn_24",qv="_chain_1tyvn_19",xo={root:Tv,collectionName:$v,nftName:Ev,chainInfo:Mv,fields:Lv,chain:qv},Pv=ye.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),Dv=()=>{const e=de(),n=et(),{chain:s,collection_addr:o}=n,{routerApiUrl:a}=ee(),r=Bn(),i=re(),{address:c,initiaAddress:l,requestTxSync:d}=Ue(),{watch:m,setValue:u,handleSubmit:h,formState:f}=_e.useFormContext(),{errors:p}=f,g=m(),{recipient:_,dstChainId:y}=g,j=Xe(y),b=$.useQuery({queryKey:Pv.simulation({collection_addr:o,nft:n,sender:l,recipient:_,srcChain:s,dstChain:j,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const N=Object.assign({from_address:l,from_chain_id:s.chainId,to_address:v.InitiaAddress(_).bech32,to_chain_id:j.chainId,collection_address:o,token_ids:[n.token_id],object_addresses:[n.object_addr]},s.chainId!==j.chainId&&await Sv({nft:n,srcChain:s,intermediaryChain:i})),{msgs:k}=await z.create({prefixUrl:a}).post("nft",{json:N}).json();return k.map(P=>r.fromAmino(P))},enabled:v.InitiaAddress.validate(_)}),{data:w,isLoading:C,error:I}=b,E=$.useQueryClient(),{mutate:M,isPending:A}=$.useMutation({mutationFn:async()=>{if(!w)throw new Error("Route not found");await d({messages:w,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{E.invalidateQueries({queryKey:pa.nfts._def})}}),L=x.useMemo(()=>{if(!_)return"Enter recipient address";if(p.recipient)return p.recipient.message;if(I)return"Route not found"},[_,p.recipient,I]);return t.jsxs("form",{onSubmit:h(()=>M()),children:[t.jsx(fa,{normalizedNft:n,thumbnailSize:80,classNames:xo}),t.jsxs("div",{className:xo.fields,children:[t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(dn,{title:"Destination appchain",content:N=>t.jsx(Ki,{onSelect:({chainId:k})=>{u("dstChainId",k),N()},list:e,getImage:k=>k.logoUrl,getName:k=>k.name,getKey:k=>k.chainId}),className:q("input",xo.chain),children:[t.jsx(J,{src:j.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:j.name})]})]}),t.jsx(ra,{myAddress:c,ref:Kn()})]}),t.jsx(xe,{children:t.jsx(le.White,{loading:(C?"Finding route...":!1)||A,disabled:!!L,children:L??"Confirm"})})]})},Bv=()=>{const{chain:e}=et(),n=_e.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(ht,{title:"Send NFT",children:t.jsx(_e.FormProvider,{...n,children:t.jsx(Dv,{})})})},Eo=()=>{const e=Ce(),n=Ts(),s=At(),{closeDrawer:o}=jt(),{closeModal:a}=qs();x.useEffect(()=>{a(),n.startsWith("/bridge/")&&n!=="/bridge/history"&&e("/bridge"),(n==="/collection"||n.startsWith("/nft"))&&e("/nfts")},[s]);const r=un();if(x.useEffect(()=>{r("Page View")},[n,r]),n==="/connect")return s?null:t.jsx(Ya,{onSuccess:o});if(n==="/blank")return null;if(!s)return t.jsx(Ya,{});switch(n){case"/":case"/nfts":case"/activity":return t.jsx(Jb,{});case"/send":return t.jsx(xv,{},s);case"/receive":return t.jsx(b1,{});case"/nft":return t.jsx(lv,{});case"/nft/send":return t.jsx(Bv,{},s);case"/bridge":return t.jsx(wg,{},s);case"/bridge/preview":return t.jsx(E_,{});case"/bridge/history":return t.jsx(f_,{});case"/op/withdrawals":return t.jsx(ax,{});case"/tx":return t.jsx(Li,{});case"/autosign/enable":return t.jsx(cf,{});case"/settings":return t.jsx(Y1,{});case"/settings/autosign":return t.jsx(B1,{});case"/deposit":return t.jsx(c1,{});case"/deposit/completed":return t.jsx(To,{type:"deposit"});case"/withdraw":return t.jsx(l1,{});case"/withdraw/completed":return t.jsx(To,{type:"withdraw"})}},Rv="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",Fv=()=>t.jsxs(t.Fragment,{children:[t.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),t.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),t.jsx("link",{rel:"stylesheet",href:Rv}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),Uv=()=>(pl(),Fl(),de(),tu(),_i(),Ln(),Vn(),Qt(),null),Ov=({children:e,...n})=>(x.useEffect(()=>{Md()},[]),Le.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(Fv,{}),t.jsx(mr.Provider,{value:{...ur,...n},children:t.jsx(vr,{children:t.jsx(Th,{children:t.jsx(Z.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(Sh,{children:t.jsxs(_h,{children:[e,t.jsx(ru,{}),t.jsx(me,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(Uv,{})}),t.jsx(Qu,{children:t.jsx(Eo,{})}),t.jsx(Wu,{children:t.jsx(Eo,{})})]})})})})})})]}):null),Vv=({bridge:e})=>t.jsx(vr,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Ai.Provider,{value:!!e,children:t.jsx(me,{children:t.jsx(Eo,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=zt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=dr;exports.InterwovenKit=Vv;exports.InterwovenKitProvider=Ov;exports.MAINNET=ur;exports.MoveError=Zr;exports.PRIVY_APP_ID=qo;exports.TESTNET=Pc;exports.initiaPrivyWallet=Bc;exports.initiaPrivyWalletConnector=Dc;exports.initiaPrivyWalletOptions=kn;exports.injectStyles=wu;exports.useAddress=At;exports.useHexAddress=hn;exports.useInitiaAddress=X;exports.useInterwovenKit=Ue;exports.usePortfolio=Go;exports.useUsernameQuery=li;
|
|
8
|
+
Sign this message to create a dedicated signing wallet for auto-sign transactions. This wallet will only be used to sign transactions on your behalf when auto-sign is enabled.`}async function Cl(e,n){const s=Kt.hexToBytes(e);if(s.length!==65)throw new Error(`Invalid signature length: expected 65 bytes (r: 32, s: 32, v: 1), got ${s.length}`);const o=s.slice(0,64),a=Kt.hexToBytes(Kt.keccak256(Kt.bytesToHex(o))),r=nt.Bip39.encode(a),i=await nt.Bip39.mnemonicToSeed(r),c=nt.stringToPath("m/44'/60'/0'/0/0"),{privkey:l}=nt.Slip10.derivePath(nt.Slip10Curve.Secp256k1,i,c),d=await nt.Secp256k1.makeKeypair(l),m=nt.Secp256k1.compressPubkey(d.pubkey),h=d.pubkey.slice(1),f=Kt.bytesToHex(h),g=Kt.keccak256(f),p=Kt.hexToBytes(g).slice(-20),_=ae.toBech32(n,p);return{privateKey:l,publicKey:m,address:_}}function gs(e,n){return`${e}:${n}`}const ts=H.atom(null),Hn=H.atom({}),Gn=H.atom({}),Gs=H.atom({}),Oa=H.atom(0),Nl="autosign:";function kl(e,n){const s=e.get(Oa)+1;return e.set(Oa,s),`${n}:${s}`}function $s(e,n){return e.get(Gs)[n]}function Il(e,n,s){e.set(Gs,o=>({...o,[n]:s}))}function Qr(e,n){e.set(Gs,s=>{const o={...s};return delete o[n],o})}function Al(e,n,s){const o=$s(e,n);!o||o.token!==s||Qr(e,n)}function Sl(e,n,s){const o=$s(e,n);return!!o&&o.token===s}function ps(e,n){return e.get(Gn)[n]}function Tl(e,n,s){e.set(Gn,o=>({...o,[n]:s}))}function $l(e,n){e.set(Gn,s=>{const o={...s};return delete o[n],o})}function El(e,n,s){e.set(Hn,o=>({...o,[n]:s}))}function Ml(e,n){e.set(Hn,s=>{const o={...s};return delete o[n],o})}function Yr(e,n){return`${Nl}${e}:${n}`}function Ll(e,n,s){try{return e.getItem(Yr(n,s))}catch{return null}}function ql(e,n,s,o){try{e.setItem(Yr(n,s),o)}catch{}}function Zr(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function oa(e,n){const s=Zr();if(s)return Ll(s,e,n)}function Pl(e,n,s){const o=Zr();o&&ql(o,e,n,s)}function Dl(e){return{publicKey:e.publicKey,address:e.address}}function Es(e){e&&e.fill(0)}function Jr(e){e.set(Gs,{});const n=e.get(Gn);for(const s of Object.values(n))Es(s);e.set(Gn,{}),e.set(Hn,{})}function Rl(e,n){return e!==""&&e!==n}function Bl(){const e=te(),n=H.useStore(),s=x.useRef(e);x.useEffect(()=>{const o=s.current;Rl(o,e)&&Jr(n),s.current=e},[n,e])}class Fl{constructor(n,s){this.wallet=n,this.privateKey=s}async getAccounts(){return[{address:this.wallet.address,algo:"ethsecp256k1",pubkey:this.wallet.publicKey}]}async signAmino(n,s){if(this.wallet.address!==n)throw new Error("Signer address does not match the derived wallet address");const o=Vn.escapeCharacters(Vn.sortedJsonStringify(s)),a=ft.ethers.hashMessage(o),r=ae.fromHex(a.replace("0x","")),i=await nt.Secp256k1.createSignature(r,this.privateKey),c=new Uint8Array([...i.r(32),...i.s(32)]),l=Gr(this.wallet.publicKey,c);return{signed:s,signature:l}}}function Qs(){const e=H.useStore(),{signMessageAsync:n}=De.useSignMessage(),s=Ke(),o=te();return{deriveWallet:async d=>{if(!o)throw new Error("User address not available");const m=s(d),u=gs(o,m.bech32_prefix),h=e.get(Hn)[u];if(h&&ps(e,u))return h;const f=$s(e,u);if(f)return f.promise;const g=kl(e,u),p=(async()=>{try{const _=window.location.origin,y=vl(_),j=await n({message:y}),C=await Cl(j,m.bech32_prefix),w=Dl(C);if(Sl(e,u,g))return Tl(e,u,C.privateKey),El(e,u,w),w;throw Es(C.privateKey),new Error("Wallet derivation was cancelled")}finally{Al(e,u,g)}})();return Il(e,u,{promise:p,token:g}),p},getWallet:d=>{if(!o)return;const m=s(d),u=gs(o,m.bech32_prefix);if(ps(e,u))return e.get(Hn)[u]},getWalletPrivateKey:d=>{if(!o)return;const m=s(d),u=gs(o,m.bech32_prefix);return ps(e,u)},clearWallet:d=>{if(!o)return;const m=s(d),u=gs(o,m.bech32_prefix),h=ps(e,u);$s(e,u)&&Qr(e,u),Es(h),$l(e,u),Ml(e,u)},clearAllWallets:()=>{Jr(e)}}}function Xr({granteeAddress:e,messages:n,encoder:s}){return[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:Zo.MsgExec.fromPartial({grantee:e,msgs:n.map(o=>({typeUrl:o.typeUrl,value:s.encode(o)}))})}]}async function Ul({chainId:e,granterAddress:n,messages:s,fee:o,memo:a,derivedWallet:r,privateKey:i,encoder:c,signWithEthSecp256k1:l}){const d=Xr({granteeAddress:r.address,messages:s,encoder:c}),m={...o,granter:n},u=new Uint8Array(i),h=new Fl(r,u);try{return await l(e,r.address,d,m,a,{customSigner:h})}finally{Es(u)}}const ut="interwovenkit",Oe="uinit",st="INIT",Xe=6,Ol="uoinit",Vl="omniINIT",ei="https://app.initia.xyz",aa=`${ei}/liquidity/my`,Kl=`${ei}/vip/my`,Wl=1e3,ti=60*Wl,ni=60*ti,Va=24*ni,ie={PUBLIC_KEY:`${ut}:public-key`,BRIDGE_SRC_CHAIN_ID:`${ut}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${ut}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${ut}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${ut}:bridge:dst-denom`,BRIDGE_QUANTITY:`${ut}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${ut}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${ut}:bridge:route-type`,BRIDGE_HISTORY:`${ut}:bridge:history`,OP_REMINDER:`${ut}:op:reminder`},si=H.atom(!1),oi=H.atom(!1);function kt(){const e=na(),[n,s]=H.useAtom(si),o=H.useSetAtom(oi),a=kn();return{isDrawerOpen:n,openDrawer:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function In(){const e=na(),[n,s]=H.useAtom(oi),o=H.useSetAtom(si),a=kn();return{isModalOpen:n,openModal:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function ai(){const e=Ie(),{closeDrawer:n}=kt(),{closeModal:s}=In(),{disconnect:o}=De.useDisconnect(),{clearAllWallets:a}=Qs();return()=>{e("/blank"),n(),s(),o(),a(),localStorage.removeItem(ie.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(ie.BRIDGE_SRC_DENOM),localStorage.removeItem(ie.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(ie.BRIDGE_DST_DENOM),localStorage.removeItem(ie.BRIDGE_QUANTITY),localStorage.removeItem(ie.BRIDGE_SLIPPAGE_PERCENT)}}function zl(){const e=Bt(),n=cn(),{openModal:s}=In();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,srcOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??n.chainId,d=a.map(m=>({denom:m,chainId:l}));s("/deposit",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function Hl(){const e=Bt(),n=cn(),{openModal:s}=In();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,dstOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??n.chainId,d=a.map(m=>({denom:m,chainId:l}));s("/withdraw",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function Gl(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:n}=Do.PubKey.decode(e.value);return Kn.encodeSecp256k1Pubkey(n)}return Us.decodeOptionalPubkey(e)}function Ql({typeUrl:e,value:n}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Yc.BaseAccount.decode(n),i=Gl(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Ce.accountFromAny({typeUrl:e,value:n})}const ri="/cosmos.feegrant.v1beta1.MsgGrantAllowance",ii="/cosmos.feegrant.v1beta1.AllowedMsgAllowance",ci="cosmos-sdk/AllowedMsgAllowance";function Yl(){const e=sn.aminoConverters[ri];if(!e)throw new Error("Missing base converter for MsgGrantAllowance");return e}const Ms=Yl();function li(e){if(e.typeUrl===ii){const n=Zt.AllowedMsgAllowance.decode(e.value);if(!n.allowance)throw new Error("AllowedMsgAllowance is missing nested allowance");return{type:ci,value:{allowance:li(n.allowance),allowed_messages:n.allowedMessages}}}return Ms.toAmino({granter:"",grantee:"",allowance:e}).allowance}function di(e){if(e.type===ci){const n=e.value;if(!n.allowance)throw new Error("AllowedMsgAllowance amino value is missing nested allowance");const s=di(n.allowance);return{typeUrl:ii,value:Zt.AllowedMsgAllowance.encode(Zt.AllowedMsgAllowance.fromPartial({allowance:s,allowedMessages:n.allowed_messages??n.allowedMessages??[]})).finish()}}return Ms.fromAmino({granter:"",grantee:"",allowance:e}).allowance}const Zl={...sn.aminoConverters,[ri]:{...Ms,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:li(e.allowance)}:Ms.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:di(e.allowance)})}},ns=()=>{const e=se();return new Us.Registry([...sn.protoRegistry,...e.protoTypes??[]])},ss=()=>{const e=se();return new Ce.AminoTypes({...Zl,...e.aminoConverters})};class Jl{constructor(n,s,o){this.address=n,this.signMessage=s,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const n=`${ie.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(n);if(s)return this.cachedPublicKey=ae.fromHex(s),ae.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(n,ae.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(n,ae.toHex(a)),a}async getPublicKeyFromRestApi(){try{const s=(await G.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return s?ae.fromBase64(s):null}catch{return null}}async getPublicKey(){const n="Sign this message to identify your Initia account.",s=await this.signMessage(n),o=ft.ethers.hashMessage(n),a=ft.ethers.SigningKey.recoverPublicKey(o,s);return nt.Secp256k1.compressPubkey(ae.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(n,s){if(this.address!==n)throw new Error("Signer address does not match the provided address");const o=Vn.escapeCharacters(Vn.sortedJsonStringify(s)),a=await this.signMessage(o),r=ae.fromHex(a.replace("0x","")).subarray(0,-1),c=nt.Secp256k1Signature.fromFixedLength(r).toFixedLength(),l=Gr(await this.getCachedPublicKey(),c);return{signed:s,signature:l}}}function ui(){const e=ns(),n=ss(),s=os(),o=Ys();return async function(a,r,i,c,l,d){const m=d?.customSigner??s;if(!m)throw new Error("Signer not initialized");const u=await o(a),{accountNumber:h,sequence:f}=await mi({getSequence:v=>u.getSequence(v),signerAddress:r,incrementSequence:d?.incrementSequence??0,allowMissingAccount:!!d?.customSigner}),[g]=await m.getAccounts(),p=Hr(sa(g.pubkey)),_=Sr.SignMode.SIGN_MODE_EIP_191,y=i.map(v=>n.toAmino(v)),j=Vn.makeSignDoc(y,c,a,l,h,f),{signature:C,signed:w}=await m.signAmino(r,j),A={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:w.msgs.map(v=>n.fromAmino(v)),memo:l}},L=e.encode(A),E=qa.Int53.fromString(w.fee.gas).toNumber(),k=qa.Int53.fromString(w.sequence).toNumber(),M=Us.makeAuthInfoBytes([{pubkey:p,sequence:k}],w.fee.amount,E,w.fee.granter,w.fee.payer,_);return Ue.TxRaw.fromPartial({bodyBytes:L,authInfoBytes:M,signatures:[ae.fromBase64(C.signature)]})}}function Xl(e,n){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(n):!1}async function mi({getSequence:e,signerAddress:n,incrementSequence:s,allowMissingAccount:o}){try{const{accountNumber:a,sequence:r}=await e(n);return{accountNumber:a,sequence:r+s}}catch(a){if(o&&Xl(a,n))return{accountNumber:0,sequence:s};throw a}}function os(){const e=te(),{signMessageAsync:n}=De.useSignMessage(),s=oe();return x.useMemo(()=>new Jl(e,o=>n({message:o}),s.restUrl),[e,n,s.restUrl])}const fo=new Map,ks=new Map;function ed(e,n){const s=`${e}:${n}`;ks.delete(s)}function ra(){const e=Ke();return async n=>{if(fo.has(n))return fo.get(n);const{rpcUrl:s}=e(n),o=await Pa.Comet38Client.create(new Pa.HttpClient(s));return fo.set(n,o),o}}function Ys(){const e=ns(),n=ss(),s=os(),o=te(),a=ra();return async r=>{const i=`${o}:${r}`;if(ks.has(i))return ks.get(i);if(!s)throw new Error("Signer not initialized");const c=await a(r),l=await Ce.SigningStargateClient.createWithSigner(c,s,{registry:e,aminoTypes:n,accountParser:Ql,broadcastPollIntervalMs:500});return ks.set(i,l),l}}function hi(){const{connector:e}=De.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new ft.BrowserProvider(await e.getProvider())}}function fi(e){return e.filter(n=>n.authorization["@type"].includes("GenericAuthorization")).filter(n=>!!n.authorization.msg)}function gi(e){return e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance"?e.allowance?.expiration:e.expiration}function td(e){if(e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance")return e.allowedMessages??e.allowed_messages??[]}function pi(){const e=te(),n=Ke();return{fetchFeegrant:async(r,i)=>{if(!e)return null;const c=n(r),l=G.create({prefixUrl:c.restUrl});try{const{allowance:d}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${i}`).json();return d}catch(d){if(d instanceof G.HTTPError&&[404,500].includes(d.response.status))return null;throw d}},fetchGrants:async(r,i)=>{if(!e)return[];const c=n(r),l=G.create({prefixUrl:c.restUrl}),{grants:d}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:i}}).json();return d},fetchAllGrants:async r=>{const i=n(r),c=e;if(!c)return[];const l=`cosmos/authz/v1beta1/grants/granter/${c}`,d=await Ks(l,{prefixUrl:i.restUrl},"grants");return fi(d)}}}const Ls=ve.createQueryKeys("interwovenkit:autosign",{expirations:(e,n,s)=>[e,n,s],grants:(e,n)=>[e,n]}),nd=4,_i=4;function sd(e){return Object.entries(e).sort(([n],[s])=>n.localeCompare(s)).map(([n,s])=>`${n}:${[...s].sort().join(",")}`).join("|")}function ia(){const e=se(),n=cn(),{enableAutoSign:s,defaultChainId:o}=e;if(!s)return{[o]:[]};if(typeof s!="boolean")return s;switch(n.metadata?.minitia?.type){case"minievm":return{[o]:["/minievm.evm.v1.MsgCall"]};case"miniwasm":return{[o]:["/cosmwasm.wasm.v1.MsgExecuteContract"]};default:return{[o]:["/initia.move.v1.MsgExecute"]}}}function od(){const{data:e}=Zs(),n=ia();return(s,o)=>{const a=o.every(i=>{const c=n[s];return c?c.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function Zs(){const e=te(),n=ia(),s=sd(n),{fetchFeegrant:o,fetchAllGrants:a}=pi();return T.useQuery({queryKey:Ls.expirations(e,s,n).queryKey,queryFn:()=>ad({initiaAddress:e,messageTypes:n,fetchAllGrants:a,fetchFeegrant:o}),staleTime:z.MINUTE,retry:1})}async function ad(e){const{initiaAddress:n,messageTypes:s,fetchAllGrants:o,fetchFeegrant:a}=e;if(!n)return{expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}};const r={},i={},c={},l={},d=[];for(const[u,h]of Object.entries(s))r[u]=null,i[u]=void 0,c[u]=!1,h.length>0&&d.push([u,h]);if(d.length===0)return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i};const m=await xi(d,nd,async([u,h])=>{const f=oa(n,u);try{const g=await o(u),p=f===void 0?g:f===null?[]:g.filter(A=>A.grantee===f),_=cd(p,h);if(_.length===0)return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0};const y=await id({chainId:u,candidates:_,fetchFeegrant:a,concurrency:_i});if(!y)return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0};const j=y.grantee.grants.filter(A=>h.includes(A.authorization.msg)).map(A=>A.expiration),C=gi(y.feegrant.allowance),w=[...j,C],I=ca(w);return{chainId:u,expectedAddress:f,expiration:I?new Date(I):void 0,grantee:y.grantee.grantee}}catch{return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0}}});for(const u of m)l[u.chainId]=u.expectedAddress,r[u.chainId]=u.expiration,i[u.chainId]=u.grantee;for(const[u]of d)c[u]=ld({expiration:r[u],grantee:i[u],expectedAddress:l[u]});return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i}}async function xi(e,n,s){const o=new Array(e.length),a=Math.max(1,n);let r=0;const i=Array.from({length:Math.min(a,e.length)},async()=>{for(;;){const c=r;if(r+=1,c>=e.length)return;o[c]=await s(e[c],c)}});return await Promise.all(i),o}function rd(e){const n=td(e.allowance);if(!(!n||n.includes("/cosmos.authz.v1beta1.MsgExec")))return!1;const o=gi(e.allowance);if(!o)return!0;const a=new Date(o);return!Number.isNaN(a.getTime())&&Ve.isFuture(a)}async function id(e){const{chainId:n,candidates:s,fetchFeegrant:o,concurrency:a=_i}=e,r=await xi(s,a,async i=>{const c=await o(n,i.grantee);return c&&rd(c)?{grantee:i,feegrant:c}:null});for(const i of r)if(i)return i;return null}function cd(e,n){if(n.length===0)return[];const s=new Map;for(const a of e){const r=s.get(a.grantee)||[];r.push({authorization:a.authorization,expiration:a.expiration}),s.set(a.grantee,r)}const o=[];for(const[a,r]of s){const i=r.filter(d=>!d.expiration||Ve.isFuture(new Date(d.expiration))),c=i.map(d=>d.authorization.msg);n.every(d=>c.includes(d))&&o.push({grantee:a,grants:i})}return o}function ld(e){const{expiration:n,grantee:s,expectedAddress:o}=e,a=o===void 0?!!s:!!s&&o===s;switch(n){case null:return!1;case void 0:return a;default:return a&&Ve.isFuture(n)}}function dd(){const{data:e,refetch:n}=Zs();x.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&Ve.isFuture(c));if(o.length===0)return;const a=ca(o);if(!a)return;const r=a.getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{n()},r+100);return()=>clearTimeout(i)},[e,n])}function ca(e){const n=e.filter(s=>s!==void 0);if(n.length!==0)return[...n].sort((s,o)=>new Date(s).getTime()-new Date(o).getTime())[0]}const yi=x.createContext(null),Js=()=>x.useContext(yi);class bi extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(n,s,o,a,r,i,c){super(n),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=c}}const ud=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,go=new Map;function md(e){const n=e.match(ud);if(!n)return null;const[,s,o,a]=n;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:a.replace(/^0+/,"")||"0"}}async function hd(e,n,s){const o=`${e}:${n}`;if(go.has(o))return go.get(o);try{const a=n==="0x1"?"0x1.json":`${e}/${n}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await G.get(r).json();return go.set(o,i),i}catch{return null}}function fd(e,n,s,o,a,r,i){return new bi(e,n,s,o,a,r,i)}async function _n(e,n,s){if(!n.metadata?.is_l1&&n.metadata?.minitia?.type!=="minimove")return await Ct(e);const o=md(e.message);if(!o)return await Ct(e);const a=await hd(n.chain_name,o.moduleAddress,s),r=`0x${parseInt(o.errorCode,10).toString(16)}`,i=`Failed with code ${r} in module ${o.moduleName} at ${o.moduleAddress}`,c=a?.[o.moduleName]?.[o.errorCode],l=c||i,d=!!c;return fd(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const gd=10;function wi(){const e=te();return(n,s)=>T.queryOptions({queryKey:Ws.txs(n.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":gd},{txs:a}=await G.create({prefixUrl:n.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:z.SECOND})}function pd(e,n){const s=wi();return T.useSuspenseQuery(s(e,n))}function _d(e,n){const s=e.flatMap((o,a)=>(n[a]??[]).map(i=>({...i,chain:o})));return $.sortWith([$.descend(o=>new Date(o.timestamp).getTime())])(s)}const xd=()=>{const e=ue(),n=wi(),s=T.useQueries({queries:e.map(i=>n(i,{enabled:!0}))}),o=s.map($.prop("data")),a=_d(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};async function ji(e){if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:s}=await G.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return s.toSorted($.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const r=o==="uinit"?1:Mr;return{amount:V(a).times(r).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:s})=>{if($.isNil(s))throw new Error(`${n} has no price`);return{amount:String(s),denom:n}})}function la(e){const{data:n}=T.useSuspenseQuery({queryKey:Vs.gasPrices(e).queryKey,queryFn:()=>ji(e),staleTime:z.SECOND});return n}function da(e){const n=te(),{data:s}=pd(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const o=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return o;try{return s.find(({tx:r})=>r.auth_info.signer_infos.some(i=>b.InitiaAddress.equals(n,ft.computeAddress(`0x${ae.toHex(nt.Secp256k1.uncompressPubkey(ae.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const vi="approve",Xs=H.atom(),Ci=H.atom(null),yd=on,bd=1.5;function wd({gasPrices:e,preferredFeeDenom:n,fallbackFeeDenom:s,allowedFeeDenoms:o}){const a=o?.length?e.filter(({denom:i})=>o.includes(i)):e;if(a.length===0)throw new Error("No allowed gas price tokens available for auto-sign");const r=i=>i?a.find(c=>c.denom===i):void 0;return r(n)??r(s)??a[0]}function jd({simulatedGas:e,gasPrices:n,preferredFeeDenom:s,fallbackFeeDenom:o,policy:a}){if(!Number.isFinite(e)||e<=0)throw new Error("Auto-sign gas simulation failed");const{gasMultiplier:r,maxGasMultiplierFromSim:i,allowedFeeDenoms:c}=a;if(r<=0||i<=0||r>i)throw new Error("Invalid auto-sign gas multiplier policy");const l=Math.ceil(e*r),d=wd({gasPrices:n,preferredFeeDenom:s,fallbackFeeDenom:o,allowedFeeDenoms:c});return Ce.calculateFee(l,Ce.GasPrice.fromString(`${d.amount}${d.denom}`))}function vd({derivedAddress:e,messages:n,encoder:s}){return{messages:Xr({granteeAddress:e,messages:n,encoder:s})}}function Cd(e){if(!(e instanceof Error))return!1;const n=e.message.toLowerCase(),s=e.code,o=e.cause?.code,a=n.includes("user rejected")||n.includes("rejected the request")||n.includes("user denied")||n.includes("denied by user")||n.includes("user cancelled")||n.includes("user canceled")||n.includes("cancelled by user")||n.includes("canceled by user");return s===4001||s==="ACTION_REJECTED"||o===4001||o==="ACTION_REJECTED"||a}async function Nd({queryClient:e,messages:n,memo:s,pubkey:o,sequence:a}){const r=Ce.createProtobufRpcClient(e),i=new Da.ServiceClientImpl(r),c=Ue.Tx.fromPartial({authInfo:Ue.AuthInfo.fromPartial({fee:Ue.Fee.fromPartial({}),signerInfos:[{publicKey:o,sequence:BigInt(a),modeInfo:{single:{mode:Sr.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:Ue.TxBody.fromPartial({messages:Array.from(n),memo:s}),signatures:[new Uint8Array]});return await i.Simulate(Da.SimulateRequest.fromPartial({txBytes:Ue.Tx.encode(c).finish()}))}function kd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e}async function Id({address:e,chainId:n,messages:s,memo:o,fee:a,preferredFeeDenom:r,client:i,allowAutoSign:c=!0,allowWalletDerivation:l=!1},d){const m=async()=>d.signWithEthSecp256k1(n,e,s,a,o),u=(_,y)=>{d.onAutoSignFallback?.({chainId:n,reason:_,errorMessage:kd(y)})};if(!c)return m();if(!d.validateAutoSign(n,s))return u("validation_failed"),m();let f=d.getWallet(n),g=!1;if(!f&&l)try{f=await d.deriveWallet(n)}catch(_){if(Cd(_))throw _;u("derive_wallet_failed",_),g=!0,f=void 0}if(!f)return g||u("missing_derived_wallet"),m();let p;try{const _=i??await d.getSigningClient(n);p=await d.computeAutoSignFee({chainId:n,messages:s,memo:o,derivedWallet:f,preferredFeeDenom:r,fallbackFeeDenom:a.amount[0]?.denom,client:_})}catch(_){return u("fee_computation_failed",_),m()}try{return await d.signWithDerivedWallet(n,e,s,p,o,f)}catch(_){return u("derived_wallet_sign_failed",_),m()}}function Ni(){const e=te(),{autoSignFeePolicy:n}=se(),s=Ke(),o=ra(),a=Ys(),r=ns(),i=od(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:d}=Qs(),m=ui(),u=kn(),h=p=>{const _=n?.[p];return{gasMultiplier:_?.gasMultiplier??yd,maxGasMultiplierFromSim:_?.maxGasMultiplierFromSim??bd,allowedFeeDenoms:_?.allowedFeeDenoms}},f=async({chainId:p,messages:_,memo:y,derivedWallet:j,preferredFeeDenom:C,fallbackFeeDenom:w,client:I})=>{const A=s(p),L=await ji(A),k=vd({derivedAddress:j.address,messages:_,encoder:r}).messages.map(Q=>r.encodeAsAny(Q)),M=Hr(sa(j.publicKey)),{sequence:v}=await mi({getSequence:Q=>I.getSequence(Q),signerAddress:j.address,incrementSequence:0,allowMissingAccount:!0}),N=await o(p),B=Ce.QueryClient.withExtensions(N,Ce.setupTxExtension),{gasInfo:R}=await Nd({queryClient:B,messages:k,memo:y,pubkey:M,sequence:v}),P=R?Number(R.gasUsed.toString()):0,F=h(p);return jd({simulatedGas:P,gasPrices:L,preferredFeeDenom:C,fallbackFeeDenom:w,policy:F})},g=async(p,_,y,j,C,w)=>{let I=w??c(p);I||(I=await l(p));const A=d(p);if(!A)throw new Error("Derived wallet key not initialized");return await Ul({chainId:p,granterAddress:_,messages:y,fee:j,memo:C,derivedWallet:I,privateKey:A,encoder:r,signWithEthSecp256k1:m})};return p=>Id({...p,address:e},{validateAutoSign:i,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:f,signWithDerivedWallet:g,signWithEthSecp256k1:m,onAutoSignFallback:({chainId:_,reason:y,errorMessage:j})=>{u("AutoSign Fallback",{chainId:_,reason:y,errorMessage:j})}})}function ki(){const e=H.useAtomValue(Xs);if(!e)throw new Error("Tx request not found");return e}function eo(){const e=Ie(),n=te(),{defaultChainId:s,registryUrl:o}=se(),a=Ke(),{openDrawer:r,closeDrawer:i}=kt(),{openModal:c,closeModal:l}=Js(),d=H.useSetAtom(Xs),m=H.useSetAtom(Ci),u=ra(),h=Ys(),f=os(),g=ns(),p=Ni(),_=async({messages:k,memo:M,chainId:v=s})=>{try{return await(await h(v)).simulate(n,k,M)}catch(N){throw await _n(N,a(v),o)}},y=async({messages:k,memo:M,chainId:v=s})=>{const N=await u(v),B=Ce.QueryClient.withExtensions(N,Ce.setupTxExtension),R=k.map(K=>g.encodeAsAny(K)),[P]=await f.getAccounts(),F=Kn.encodeSecp256k1Pubkey(P.pubkey),Q=await h(v),{sequence:U}=await Q.getSequence(n);return B.tx.simulate(R,M,F,U)},j=async({txRequest:k,broadcaster:M})=>{const N={...{memo:"",chainId:s,gas:k.gas||await _(k),gasAdjustment:on,gasPrices:null,spendCoins:[],internal:!1},...k};return new Promise((B,R)=>{d({txRequest:N,resolve:async F=>{try{const Q=await h(N.chainId),U=await M(Q,Ue.TxRaw.encode(F).finish());B(U),typeof N.internal=="string"&&e(N.internal)}catch(Q){R(await _n(Q,a(N.chainId),o))}finally{P()}},reject:F=>{R(F),P()}}),N.internal?c({path:"/tx"}):r("/tx");const P=()=>{if(!N.internal){e("/blank"),i();return}l()}})},C=async k=>{const M=k.chainId??s;try{const v=await j({txRequest:k,broadcaster:async(N,B)=>await N.broadcastTxSync(B)});return k.internal&&typeof k.internal!="number"&&(m({txHash:v,chainId:M,status:"loading"}),E({txHash:v,chainId:k.chainId}).then(N=>{m({status:N.code===0?"success":"error",chainId:M,txHash:v})}).catch(()=>{m({status:"error",chainId:M,txHash:v})})),v}catch(v){throw k.internal&&typeof k.internal!="number"&&m({status:"error",chainId:M,error:v}),v}},w=(k,M=30*1e3,v=.5*1e3)=>j({txRequest:k,broadcaster:async(N,B)=>{const R=await N.broadcastTx(B,M,v);if(R.code!==0)throw new Error(R.rawLog);return R}}),I=async({chainId:k,messages:M,memo:v="",fee:N,preferredFeeDenom:B})=>{const R=await h(k),P=await p({chainId:k,messages:M,memo:v,fee:N,preferredFeeDenom:B,client:R,allowWalletDerivation:!0});return{client:R,signedTx:P}},A=async k=>{const M=k.chainId??s;try{const{client:v,signedTx:N}=await I({...k,chainId:M});return await v.broadcastTxSync(Ue.TxRaw.encode(N).finish())}catch(v){throw await _n(v,a(M),o)}},L=async(k,M=30*1e3,v=.5*1e3)=>{const N=k.chainId??s;try{const{client:B,signedTx:R}=await I({...k,chainId:N}),P=await B.broadcastTx(Ue.TxRaw.encode(R).finish(),M,v);if(P.code!==0)throw new Error(P.rawLog);return P}catch(B){throw await _n(B,a(N),o)}},E=async({chainId:k=s,...M})=>{try{const v=await h(k);return await Ii({...M,client:v})}catch(v){throw await _n(v,a(k),o)}};return{estimateGas:_,simulateTx:y,requestTxSync:C,requestTxBlock:w,submitTxSync:A,submitTxBlock:L,waitForTxConfirmation:E}}async function Ii({txHash:e,client:n,timeoutMs:s=30*1e3,intervalMs:o=.5*1e3}){const a=Date.now();for(;;){const r=await n.getTx(e);if(r){if(r.code!==0)throw new Error(r.rawLog);return r}if(Date.now()-a>=s)throw new Error(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const Ad="/cosmos.authz.v1beta1.MsgExec";function Sd(e){if(e.explicitGrantee)return[e.explicitGrantee];const n=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(s=>!!s);return[...new Set(n)]}function Td(e){const n=[e.currentGrantee,e.expectedGrantee].filter(s=>!!s);return[...new Set(n)]}function $d(e){const{isEnabledOnTargetChain:n,hasEnabledSibling:s,didBroadcast:o,hasExplicitGrantee:a}=e;return s?!1:n===!1?!0:n===void 0&&o&&!a}function Ed(e){return[...new Set(e.map(n=>n.authorization.msg))].filter(n=>!!n)}async function Ai(e){const n=[Ls.expirations._def,Ls.grants._def];for(const s of n)await e.invalidateQueries({queryKey:s})}function Si(){const e=te(),{fetchFeegrant:n,fetchGrants:s}=pi();return async o=>{const{chainId:a,grantee:r}=o;if(!e)throw new Error("Granter wallet not initialized");const i=await n(a,r),c=await s(a,r),l=i?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:Tr.MsgRevokeAllowance.fromPartial({granter:e,grantee:r})}]:[],m=Ed(c).map(u=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:Zo.MsgRevoke.fromPartial({granter:e,grantee:r,msgTypeUrl:u})}));return[...l,...m]}}function Md(){const e=te(),n=ia(),{requestTxBlock:s}=eo(),o=T.useQueryClient(),[a,r]=H.useAtom(ts),{closeDrawer:i}=kt(),c=Si(),{deriveWallet:l}=Qs();return T.useMutation({mutationFn:async d=>{if(!a)throw new Error("No pending request");const{chainId:m}=a;if(!e)throw new Error("Wallet not connected");const u=n[m];if(!u||u.length===0)throw new Error(`No message types configured for chain ${m}`);const h=await l(m);ed(e,m);const f=oa(e,m),g=Td({currentGrantee:h.address,expectedGrantee:f}),_=(await Promise.all(g.map(A=>c({chainId:m,grantee:A})))).flat(),y=d===0?void 0:Ve.addMilliseconds(new Date,d),j={typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:Zt.BasicAllowance.encode(Zt.BasicAllowance.fromPartial({expiration:y})).finish()},C={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:Tr.MsgGrantAllowance.fromPartial({granter:e,grantee:h.address,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.AllowedMsgAllowance",value:Zt.AllowedMsgAllowance.encode(Zt.AllowedMsgAllowance.fromPartial({allowance:j,allowedMessages:[Ad]})).finish()}})},w=u.map(A=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:Zo.MsgGrant.fromPartial({granter:e,grantee:h.address,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:Ra.GenericAuthorization.encode(Ra.GenericAuthorization.fromPartial({msg:A})).finish()},expiration:y}})})),I=[..._,C,...w];return await s({messages:I,chainId:m,internal:!0}),{chainId:m,derivedWallet:h}},onSuccess:async({chainId:d,derivedWallet:m})=>{e&&Pl(e,d,m.address),await Ai(o),a?.resolve()},onError:d=>{a?.reject(d)},onSettled:()=>{r(null),i()}})}function Ti(e){const n=se(),s=ue(),o=Ke(),{getWallet:a,clearWallet:r}=Qs(),{requestTxBlock:i}=eo(),c=T.useQueryClient(),l=Si(),{data:d,refetch:m}=Zs();return T.useMutation({mutationFn:async(u=n.defaultChainId)=>{const h=a(u),f=d?.granteeByChain[u];let g;e?.grantee||(g=(await m()).data?.granteeByChain[u]);const p=Sd({explicitGrantee:e?.grantee,cachedDerivedAddress:h?.address,statusGrantee:f,refetchedStatusGrantee:g});if(p.length===0)throw new Error("No grantee address available");const y=(await Promise.all(p.map(j=>l({chainId:u,grantee:j})))).flat();return y.length===0?{chainId:u,didBroadcast:!1}:(await i({messages:y,chainId:u,internal:e?.internal}),{chainId:u,didBroadcast:!0})},onSuccess:async({chainId:u,didBroadcast:h})=>{await Ai(c);const f=o(u),g=s.filter(w=>w.bech32_prefix===f.bech32_prefix).map(w=>w.chain_id).filter(w=>w!==u);let p;try{p=(await m()).data}catch{p=void 0}const _=p??d;let y=!1;g.length>0&&_&&(y=g.some(w=>_?.isEnabledByChain[w]));const j=h?p?.isEnabledByChain[u]:(p??d)?.isEnabledByChain[u];$d({isEnabledOnTargetChain:j,hasEnabledSibling:y,didBroadcast:h,hasExplicitGrantee:!!e?.grantee})&&r(u)}})}function Ld(){const{defaultChainId:e}=se(),{openDrawer:n}=kt(),s=H.useSetAtom(ts),o=Ti(),{data:a={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:r}=Zs();return{...a,isLoading:r,enable:async(l=e)=>new Promise((d,m)=>{s({chainId:l,resolve:d,reject:m}),n("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}function $i(e){return e.assets.reduce((n,{value:s})=>n+(s??0),0)}function qd(e){return e.assets.reduce((n,{quantity:s})=>n.plus(s),V(0)).toString()}function Pd(e,n){return{symbol:n?.symbol??e,logoUrl:n?.logoUrl??ta}}function Ka(e){return $.pick(["chainId","name","logoUrl"],e)}function Dd(e){return $.sortWith([$.descend(({symbol:n})=>n===st),$.descend($i),$.descend(({assets:n})=>n.length),$.ascend(({symbol:n})=>n)])(e)}function Rd(e){return $.sortWith([$.descend(({value:n})=>n??0),$.descend(({quantity:n})=>Number(n)),$.ascend(({chain:n})=>n.name)])(e)}function Bd(e,n){return $.sortWith([$.descend(({chain:s})=>s.chainId===n),$.ascend(({chain:s})=>s.name),$.ascend(({denom:s})=>s)])(e)}function Fd(e,n){return $.sortWith([$.descend(({chainId:s})=>s===n),$.descend($.prop("value"))])(e)}function Ud(e,n,s,o,a){const r=e.find(u=>u.metadata?.is_l1)?.chainId,i={};for(const u of e){const h=u.chainId,f=n[h]??[],g=s[h],p=o[h],_=[];for(const{amount:y,denom:j}of f){if(!V(y).gt(0))continue;const C=g?.find(E=>E.denom===j),w=p?.find(E=>E.id===j)?.price,I=C?.decimals??0,A=b.fromBaseUnit(y,{decimals:I}),L=w?V(A).times(w).toNumber():void 0;_.push({...Pd(j,C),amount:y,denom:j,decimals:I,quantity:A,price:w,value:L,address:C?.address,unlisted:!C,chain:Ka(u)})}i[h]=_}const c=new Map;for(const[u,h]of Object.entries(i)){if(h.length===0)continue;const f=e.find(p=>p.chainId===u);if(!f)continue;const g=h.reduce((p,{value:_})=>p+(_??0),0);c.set(u,{...Ka(f),value:g})}const l=new Map;for(const u of Object.values(i))for(const h of u)if(!h.unlisted){const{symbol:f}=h,g=l.get(f)??[];l.set(f,[...g,h])}const d=[];for(const[u,h]of l){const f=$.head(h);if(!f)continue;const g=Rd(h),p=g.reduce((y,{value:j})=>y+(j??0),0),_=g.reduce((y,{quantity:j})=>y.plus(j),V(0)).toNumber();d.push({symbol:u,logoUrl:f.logoUrl,assets:g,totalValue:p,totalAmount:_})}const m=[];for(const u of Object.values(i))for(const h of u)h.unlisted&&m.push(h);return{chainsByValue:Fd(Array.from(c.values()),a),assetGroups:Dd(d),unlistedAssets:Bd(m,r),totalValue:d.reduce((u,h)=>u+h.totalValue,0)}}function ua(){const{defaultChainId:e}=se(),n=ue(),s=pl(),o=Xn(),a=ea(),r=n.map(h=>h.chainId),i=$.zipObj(r,s.map($.prop("data"))),c=$.zipObj(r,o.map($.prop("data"))),l=$.zipObj(r,a.map($.prop("data"))),d=Ud(n,i,c,l,e),m=[s,o,a].flat().some(({isLoading:h})=>h);return{...d,isLoading:m,refetch:()=>{s.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),a.forEach(({refetch:h})=>h())}}}function te(){const e=An();return e?b.InitiaAddress(e).bech32:""}function An(){const{address:e}=De.useAccount();return e?b.InitiaAddress(e).hex:""}function Bt(){const e=cn(),n=te(),s=An();return e.metadata?.minitia?.type==="minievm"?s:n}function Ei(){const e=Bt(),n=Ur();return T.useQuery({queryKey:Ws.username(n.restUrl,e).queryKey,queryFn:()=>n.getUsername(e),enabled:!!e,staleTime:z.MINUTE})}function We(){const e=Bt(),n=te(),s=An(),{data:o}=Ei(),a=os(),r=ai(),i=Ld(),{isDrawerOpen:c,openDrawer:l}=kt(),{isModalOpen:d}=In(),m=()=>{l("/")},u=()=>{l("/connect")},h=j=>{l("/bridge",j)},f=zl(),g=Hl(),p=eo();return{address:e,initiaAddress:n,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:c||d,openConnect:u,openWallet:m,openBridge:h,openDeposit:f,openWithdraw:g,disconnect:r,autoSign:i,...p}}const Od="_status_tn9m1_1",Vd="_error_tn9m1_9",Wa={status:Od,error:Vd},ge=({error:e,children:n})=>t.jsx("p",{className:q(Wa.status,{[Wa.error]:e}),children:n}),fe=({errorBoundaryProps:e={fallbackRender:({error:o})=>t.jsx(ge,{error:!0,children:o.message})},suspenseFallback:n=t.jsx(ge,{children:"Loading..."}),children:s})=>t.jsx($r.ErrorBoundary,{...e,children:t.jsx(x.Suspense,{fallback:n,children:s})}),an=1n<<64n,Kd=1n<<63n,Mi=(1n<<128n)-1n;function Rt(e){const n=BigInt(e);return n>=Kd?n-an:n}const Wd=(1n<<256n)-1n,qt=443636n,zd=4295048017n,Hd=18446744073709551616n,Gd=79226673515401279992447579062n,Qd=255738958999603826347141n;function Yd(e,n,s){const o=Number(Rt(e)),a=Number(Rt(n)),r=Math.floor(-Number(qt)/s)*s,i=Math.floor(Number(qt)/s)*s;return o===r&&a===i}function Li(e){return e>>64n}function Zd(e){const n=e>>64n;return e%an!==0n?n+1n:n}function vn(e){if(e<0n||e>Mi)throw new Error("INPUT_OUT_OF_RANGE");return e}function Jd(e,n){const s=e*n>>64n;if(s>Mi)throw new Error("OVERFLOW");return s}function ma(e,n){return e>n?[n,e]:[e,n]}function Xd(e,n,s,o){if(e===n)return 0n;const[a,r]=ma(e,n);if(a===0n||r===0n)return 0n;const i=s*an,c=r-a,l=i*c;if(l===0n)return 0n;const d=a*r;return o?(l-1n)/d+1n:l/d}function eu(e,n,s,o){if(e===n)return 0n;const[a,r]=ma(e,n),c=(r-a)*s;return o?Zd(vn(c)):Li(vn(c))}function za(e,n,s){return Xd(e,n,s<0n?-s:s,s>=0n)}function Ha(e,n,s){return eu(e,n,s<0n?-s:s,s>=0n)}const po=1n<<64n,Ga=1n<<65n,tu=64n;function nu(e){if(e<=0n)throw new Error("LOG_2_ZERO_UNBOUNDED");let n=e,s=0n,o=0n,a=1n<<tu-1n,r=0n,i=1;for(;n>=Ga;)n>>=1n,s+=po;for(;n<po;)i=0,n<<=1n,o+=po;for(;r<62n;){const l=n>>1n;n=l*l>>62n,n>=Ga&&(n>>=1n,s+=a),a>>=1n,r+=1n}const c=i>0?vn(s):vn(o-s);return[i,c]}function Pt(e){const n=e<0n?-e:e;if(n>qt)throw new Error("MAX_TICK");let s=(n&0x1n)!==0n?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;(n&0x2n)!==0n&&(s=s*0xfff97272373d413259a46990580e213an>>128n),(n&0x4n)!==0n&&(s=s*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(n&0x8n)!==0n&&(s=s*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(n&0x10n)!==0n&&(s=s*0xffcb9843d60f6159c9db58835c926644n>>128n),(n&0x20n)!==0n&&(s=s*0xff973b41fa98c081472e6896dfb254c0n>>128n),(n&0x40n)!==0n&&(s=s*0xff2ea16466c96a3843ec78b326b52861n>>128n),(n&0x80n)!==0n&&(s=s*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(n&0x100n)!==0n&&(s=s*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(n&0x200n)!==0n&&(s=s*0xf987a7253ac413176f2b074cf7815e54n>>128n),(n&0x400n)!==0n&&(s=s*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(n&0x800n)!==0n&&(s=s*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(n&0x1000n)!==0n&&(s=s*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(n&0x2000n)!==0n&&(s=s*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(n&0x4000n)!==0n&&(s=s*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(n&0x8000n)!==0n&&(s=s*0x31be135f97d08fd981231505542fcfa6n>>128n),(n&0x10000n)!==0n&&(s=s*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(n&0x20000n)!==0n&&(s=s*0x5d6af8dedb81196699c329225ee604n>>128n),(n&0x40000n)!==0n&&(s=s*0x2216e584f5fa1ea926041bedfe98n>>128n),e>=0n&&(s=Wd/s);const o=s/an;return s%an!==0n?o+1n:o}function su(e){if(e<zd||e>=Gd)throw new Error("INVALID_SQRT_PRICE");const[,n]=nu(vn(e)),s=Jd(n,vn(Qd)),o=Li(s);let a,r,i;if(o===0n?(a=-1n,r=0n,i=1n):e<Hd?(a=-o-1n,r=-o,i=-o+1n):(a=o-1n,r=o,i=o+1n),a<-qt&&(a=-qt),i>qt&&(i=qt),Pt(i)<=e){if(i>=qt)throw new Error("GTE_MAX_TICK");if(Pt(i+1n)<=e)throw new Error("NO_SAFE_TICK_FOUND");return i}if(Pt(r)<=e)return r;if(Pt(a)<=e)return a;throw new Error("NO_SAFE_TICK_FOUND")}function ou(e,n,s,o){const[a,r]=ma(n,s);return e<a?[za(a,r,o),0n]:e<r?[za(e,r,o),Ha(a,e,o)]:[0n,Ha(a,r,o)]}function au({tickLower:e,tickUpper:n,liquidity:s,sqrtPrice:o}){const a=Pt(Rt(e)),r=Pt(Rt(n));return ou(BigInt(o),BigInt(a),BigInt(r),BigInt(s))}const _o=an*an,ru=1e-300,iu=BigInt(Number.MAX_SAFE_INTEGER);function Qa(e){const n=e*e,s=n/_o,o=n%_o;return s>iu?Number(s):Number(s)+Number(o)/Number(_o)}function Ya(e){if(!Number.isFinite(e)||e<0)throw new Error("calculateTokens: price must be finite and non-negative");return 1/Math.max(e,ru)}function cu({tickLower:e,tickUpper:n,isReversed:s=!1}){const o=Pt(Rt(e)),a=Pt(Rt(n)),r=Qa(o),i=Qa(a);return s?{min:Ya(i),max:Ya(r)}:{min:r,max:i}}const ln=ve.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,n)=>[e,n],lpPrices:(e,n)=>[e,n],poolByMetadata:(e,n)=>[e,n],clammPositions:(e,n)=>[e,n],clammPoolInfo:(e,n,s)=>[e,n,s],clammFees:(e,n,s)=>[e,n,s],clammIncentive:(e,n,s,o)=>[e,n,s,o]}),ha={lens:"lens",pool:"pool",farming:"farming"},fa={"interwoven-1":{clammModuleAddress:"0xd78a3b72c7ef0cfba7286bfb8c618aa4d6011dce05a832871cc9ab323c25f55e",incentiveModuleAddress:"0xcb2999c70a9b8db7cb473255bb01f956f0726087f08b04ece50844a6d8167351"},"initiation-2":{clammModuleAddress:"0x6b41bf295bc31cd9bef75a9a5a67e5a8d6749b34a7ab3105808251fa2697823d",incentiveModuleAddress:"0xf8ef0cb7c73607b7658524565015ce2aadc45ccf7164e5351959a4d7a1c37753"}};function lu(e){return e.startsWith("0x")?`0x${e.replace(/^0x/,"").padStart(64,"0")}`:b.InitiaAddress(e).hex}function qs(e){return ae.toBase64(b.InitiaAddress(lu(e),32).bytes)}function qi(e,n){return`${e}:${n}`}function du(e){return`clamm:${e}`}function uu(e){return!Array.isArray(e)||e.length===0?[]:Array.isArray(e[0])?e.flat():e}function mu(e){return e.map(n=>({tokenAddress:n.token_address,lpMetadata:n.lp_metadata,tickLower:n.tick_lower,tickUpper:n.tick_upper,liquidity:n.liquidity,incentives:n.incentives.map(s=>({incentiveAddress:s.incentive_address,rewardMetadata:s.reward_metadata}))}))}function hu(e){const{dexUrl:n}=se();return T.useSuspenseQuery({queryKey:ln.clammPositions(n,e).queryKey,queryFn:async()=>{if(!e)return[];const s=[];let o;do{const a={"pagination.limit":"100"};o&&(a["pagination.key"]=o);const r=await G.get(`${n}/indexer/clamm/v1/positions/${e}`,{searchParams:a}).json().catch(()=>({positions:[],pagination:{next_key:null,total:"0"}}));s.push(...uu(r.positions)),o=r.pagination.next_key||void 0}while(o);return mu(s)},staleTime:z.MINUTE})}function fu(e){const n=oe(),{viewFunction:s}=b.createMoveClient(n.restUrl),a=T.useSuspenseQueries({queries:e.map(r=>({queryKey:ln.clammPoolInfo(n.restUrl,n.chainId,r).queryKey,queryFn:async()=>{const i=fa[n.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:ha.lens,functionName:"get_pool_info",typeArgs:[],args:[qs(r)]});return!c?.sqrt_price||!c?.tick_spacing?null:{sqrtPrice:c.sqrt_price,tickSpacing:c.tick_spacing}}catch{return null}},staleTime:z.MINUTE}))}).map(r=>r.data);return x.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(i,a[c]??null)}),r},[e,a])}function gu(e){const n=oe(),{viewFunction:s}=b.createMoveClient(n.restUrl),a=T.useSuspenseQueries({queries:e.map(r=>({queryKey:ln.clammFees(n.restUrl,n.chainId,r).queryKey,queryFn:async()=>{const i=fa[n.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:ha.pool,functionName:"fees_available",typeArgs:[],args:[qs(r)]});return Array.isArray(c)?c:null}catch{return null}},staleTime:z.MINUTE}))}).map(r=>r.data);return x.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{const l=a[c];l&&r.set(i,l)}),r},[e,a])}function pu(e){const n=oe(),{viewFunction:s}=b.createMoveClient(n.restUrl),a=T.useSuspenseQueries({queries:e.map(r=>({queryKey:ln.clammIncentive(n.restUrl,n.chainId,r.tokenAddress,r.incentiveAddress).queryKey,queryFn:async()=>{const i=fa[n.chainId];if(!i)return"0";try{const c=await s({moduleAddress:i.incentiveModuleAddress,moduleName:ha.farming,functionName:"pending_reward_info",typeArgs:[],args:[qs(r.tokenAddress),qs(r.incentiveAddress)]});return typeof c=="string"?c:Array.isArray(c)&&typeof c[0]=="string"?c[0]:"0"}catch{return"0"}},staleTime:z.MINUTE}))}).map(r=>r.data);return x.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(qi(i.tokenAddress,i.incentiveAddress),a[c]||"0")}),r},[e,a])}function Pi(e){const{dexUrl:n}=se(),o=T.useSuspenseQueries({queries:e.map(a=>({queryKey:ln.poolByMetadata(n,a).queryKey,queryFn:async()=>{try{return(await G.get(`${n}/indexer/dex/v2/pools/${encodeURIComponent(a)}`).json()).pool}catch{return null}},staleTime:z.MINUTE}))}).map(a=>a.data);return x.useMemo(()=>{const a=new Map;return e.forEach((r,i)=>{a.set(r,o[i]??null)}),a},[e,o])}function Di(e,n){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>n.get(s.denom)?.logoUrl||"")}function _u(e){return Pi(e)}function xu(e){const n=oe(),s=Dt(n),o=x.useMemo(()=>{const i=new Map;for(const c of s)i.set(c.denom,c);return i},[s]),a=x.useMemo(()=>e.map(i=>b.denomToMetadata(i)),[e]),r=Pi(a);return x.useMemo(()=>{const i=new Map;return e.forEach((c,l)=>{const d=a[l];if(!d){i.set(c,null);return}const m=r.get(d);if(!m){i.set(c,null);return}if(c===Ol){i.set(c,{...m,symbol:Vl});return}const u=m.coins.map(h=>o.get(h.denom)?.symbol||h.denom).join("-");i.set(c,{...m,symbol:u})}),i},[e,a,r,o])}const yu="lock_staking";function Ri(e,n){const s=`${n}::lock_staking::StakingAccount`,o=b.createObjectAddress(e,s);return b.InitiaAddress(o).bech32}const as=ve.createQueryKeys("interwovenkit:initia-staking",{delegations:(e,n)=>[e,n],undelegations:(e,n,s)=>[e,n,s],lockStaking:(e,n,s)=>[e,n,s],stakingRewards:(e,n)=>[e,n],lockStakingRewards:(e,n,s)=>[e,n,s]});function ga(){const{restUrl:e}=oe(),n=te();return T.useSuspenseQuery({queryKey:as.delegations(e,n||"").queryKey,queryFn:async()=>n?(await G.get(`${e}/initia/mstaking/v1/delegations/${n}`).json()).delegation_responses:[],select:s=>{const o=new Map;for(const a of s){const r=a.delegation.validator_address;for(const i of a.balance){const c=b.denomToMetadata(i.denom),l={denom:i.denom,metadata:c,amount:i.amount,validator:r},d=o.get(c)??[];d.push(l),o.set(c,d)}}return o},staleTime:z.MINUTE})}function pa(){const{restUrl:e}=oe(),{lockStakeModuleAddress:n}=se(),s=te(),o=s?Ri(s,n):"";return T.useSuspenseQuery({queryKey:as.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await G.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await G.get(`${e}/initia/mstaking/v1/delegators/${o}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...a.unbonding_responses,...r.unbonding_responses]},select:a=>{const r=new Map;for(const i of a){const c=i.validator_address;for(const l of i.entries)for(const d of l.balance){const m=b.denomToMetadata(d.denom),u={denom:d.denom,metadata:m,amount:d.amount,validator:c,completionTime:l.completion_time},h=r.get(m)??[];h.push(u),r.set(m,h)}}return r},staleTime:z.MINUTE})}function _a(){const{restUrl:e}=oe(),{lockStakeModuleAddress:n}=se(),s=te();return T.useSuspenseQuery({queryKey:as.lockStaking(e,s||"",n).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=b.createMoveClient(e);return await o({moduleAddress:n,moduleName:yu,functionName:"get_locked_delegations",typeArgs:[],args:[ae.toBase64(b.InitiaAddress(s,32).bytes)]})??[]},select:o=>{const a=new Map;for(const r of o){const i={metadata:r.metadata,amount:r.amount,validator:r.validator,releaseTime:r.release_time},c=a.get(r.metadata)??[];c.push(i),a.set(r.metadata,c)}return a},staleTime:z.MINUTE})}function Bi(e){const n=new Map;if(!e.total||!Array.isArray(e.total))return n;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=b.denomToMetadata(s.denom);let a=new V(0);for(const i of s.dec_coins)i?.amount&&(a=a.plus(i.amount));const r=n.get(o);if(r){const i=new V(r.amount);a=a.plus(i)}n.set(o,{denom:s.denom,amount:a.toString()})}return n}function Fi(){const{restUrl:e}=oe(),n=te();return T.useSuspenseQuery({queryKey:as.stakingRewards(e,n||"").queryKey,queryFn:async()=>n?await G.get(`${e}/initia/distribution/v1/delegators/${n}/rewards`).json():{rewards:[],total:[]},select:Bi,staleTime:z.MINUTE})}function Ui(){const{restUrl:e}=oe(),{lockStakeModuleAddress:n}=se(),s=te(),o=s?Ri(s,n):"";return T.useSuspenseQuery({queryKey:as.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await G.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:Bi,staleTime:z.MINUTE})}function xa(){const e=oe(),n=Dt(e),{data:s,isLoading:o}=Nt(e),{data:a}=ga(),{data:r}=pa(),{data:i}=_a(),c=x.useMemo(()=>{const f=new Set;for(const g of a.keys())f.add(g);for(const g of i.keys())f.add(g);for(const g of r.keys())f.add(g);return Array.from(f)},[a,i,r]),l=Ts(c),d=x.useMemo(()=>{const f=new Map;if(s)for(const g of s)f.set(g.id,g.price);return f},[s]),m=x.useMemo(()=>{const f=new Map;for(const g of n)f.set(g.denom,g);return f},[n]),u=x.useMemo(()=>{const f=[],g=p=>{const _=m.get(p);return _?{symbol:_.symbol,decimals:_.decimals}:null};for(const[p,_]of a){const y=l.get(p)??_[0]?.denom;if(!y)continue;const j=g(y);if(!j)continue;const C=d.get(y)??0;for(const w of _){const{symbol:I,decimals:A}=j,L=Number(b.fromBaseUnit(w.amount,{decimals:A})),E={type:"asset",denom:y,symbol:I,amount:w.amount,formattedAmount:L,decimals:A,value:L*C};f.push({type:"staking",validator:w.validator,balance:E})}}for(const[p,_]of i){const y=l.get(p);if(!y)continue;const j=g(y);if(!j)continue;const C=d.get(y)??0;for(const w of _){const{symbol:I,decimals:A}=j,L=Number(b.fromBaseUnit(w.amount,{decimals:A})),E={type:"asset",denom:y,symbol:I,amount:w.amount,formattedAmount:L,decimals:A,value:L*C},k=Number(w.releaseTime);f.push({type:"lockstaking",validator:w.validator,releaseTime:Number.isNaN(k)?0:k,balance:E})}}for(const[p,_]of r){const y=l.get(p)??_[0]?.denom;if(!y)continue;const j=g(y);if(!j)continue;const C=d.get(y)??0;for(const w of _){const{symbol:I,decimals:A}=j,L=Number(b.fromBaseUnit(w.amount,{decimals:A})),E={type:"asset",denom:y,symbol:I,amount:w.amount,formattedAmount:L,decimals:A,value:L*C},k=new Date(w.completionTime).getTime(),M=Number.isNaN(k)?0:Math.floor(k/1e3);f.push({type:"unstaking",validator:w.validator,completionTime:M,balance:E})}}return f.filter(p=>p.type!=="fungible-position"&&p.balance.denom===Oe)},[a,i,r,l,m,d]),h=x.useMemo(()=>u.reduce((f,g)=>g.type==="fungible-position"||g.balance.type==="unknown"?f:f+(g.balance.value??0),0),[u]);return{positions:u,totalValue:h,isLoading:o}}function bu(e){const n=new Map;for(const s of e){const o=b.denomToMetadata(s.denom),a={...s,metadata:o},r=n.get(o)??[];r.push(a),n.set(o,r)}return n}function wu(e,n){return e.map(s=>n.get(s)?.symbol||s).join("/")}function ju(e){const{dexUrl:n}=se();return T.useSuspenseQuery({queryKey:ln.checkLpTokens(n,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await G.post(`${n}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:z.MINUTE})}function vu(){const e=oe(),n=es(e),s=x.useMemo(()=>n.map(a=>a.denom),[n]),{data:o}=ju(s);return x.useMemo(()=>{const a=n.filter(r=>o.get(r.denom)===!0);return bu(a)},[n,o])}function Cu(e){const{dexUrl:n}=se();return T.useSuspenseQuery({queryKey:ln.lpPrices(n,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await G.get(`${n}/indexer/price/v1/lp_prices/${encodeURIComponent(e.join(","))}`).json(),{prices:o}=s;return Array.isArray(o)?new Map(o.map(({denom:a,price:r})=>[a,r])):new Map(Object.entries(o))},staleTime:z.MINUTE})}function Nu(e,n,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of n){const c=i[0]?.denom;c&&c!==Oe&&a.add(r)}for(const r of s.keys())a.add(r);for(const[r,i]of o){const c=i[0]?.denom;c&&c!==Oe&&a.add(r)}return Array.from(a)}function ku(e){const n=[];for(const[,s]of e)s&&s!==Oe&&n.push(s);return n}function Iu(e,n,s){const o=n.get(e)??null,a=o?.symbol||e,r=Di(o,s),i=r.length>0&&r.some(l=>l),c=i?void 0:s.get(e)?.logoUrl;return{denom:e,symbol:a,totalAmount:0,totalValue:0,decimals:s.get(e)?.decimals??6,poolType:o?.pool_type,logoUrl:c,coinLogos:i?r:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0}}}function xo(e,n,s,o,a){for(const[r,i]of e){const c=n.get(r)??i[0]?.denom;if(!c||c===Oe)continue;const l=o.get(c);if(l)for(const d of i){const m=l.decimals,u=Number(b.fromBaseUnit(String(d.amount),{decimals:m})),h=s.get(c)??0,f=u*h;l.breakdown[a]+=u,l.totalAmount+=u,l.totalValue+=f}}}function Au(e,n,s,o,a){for(const[r,i]of e){const c=n.get(r);if(!c||c===Oe)continue;const l=o.get(c);if(l)for(const d of i){const m=l.decimals,u=Number(b.fromBaseUnit(String(d.amount),{decimals:m})),h=s.get(c)??0,f=u*h;l.breakdown[a]+=u,l.totalAmount+=u,l.totalValue+=f}}}function Su(e,n,s,o){for(const[a,r]of e){const i=b.denomToMetadata(a),c=n?.get(i),l=c?b.fromBaseUnit(c.amount,{decimals:Xe}):"0",d=s?.get(i),m=d?b.fromBaseUnit(d.amount,{decimals:Xe}):"0",u=Number(l)+Number(m);u<=0||(r.claimableInit={staking:l,lockStaking:m,total:String(u),totalValue:u*o})}}function Tu(e){return`#${e.replace(/^0x/,"").slice(-6)}`}function to(){const e=oe(),n=Dt(e),s=te(),o=vu(),{data:a}=ga(),{data:r}=_a(),{data:i}=pa(),{data:c}=Fi(),{data:l}=Ui(),{data:d}=Nt(e),{data:m}=hu(s),u=x.useMemo(()=>{const R=new Map;for(const P of m){const F=R.get(P.lpMetadata)??[];F.push(P),R.set(P.lpMetadata,F)}return R},[m]),h=x.useMemo(()=>Array.from(u.keys()),[u]),f=_u(h),g=fu(h),p=x.useMemo(()=>m.map(R=>R.tokenAddress),[m]),_=gu(p),y=x.useMemo(()=>{const R=[];for(const P of m)for(const F of P.incentives)R.push({tokenAddress:P.tokenAddress,incentiveAddress:F.incentiveAddress});return R},[m]),j=pu(y),C=x.useMemo(()=>{const R=new Set;for(const P of m)for(const F of P.incentives)R.add(F.rewardMetadata);return Array.from(R)},[m]),w=Ts(C,{failSoft:!0}),I=x.useMemo(()=>Nu(o,a,r,i),[o,a,r,i]),A=Ts(I),L=x.useMemo(()=>ku(A),[A]),{data:E}=Cu(L),k=xu(L),M=x.useMemo(()=>{const R=new Map;for(const P of n)R.set(P.denom,P);return R},[n]),v=x.useMemo(()=>{const R=new Map;for(const P of d??[])R.set(P.id,P.price);return R},[d]),{rows:N,totalValue:B}=x.useMemo(()=>{const R=d?.find(U=>U.id===Oe)?.price??0,P=new Map;for(const U of L)P.set(U,Iu(U,k,M));xo(o,A,E,P,"deposit"),xo(a,A,E,P,"staking"),Au(r,A,E,P,"lockStaking"),xo(i,A,E,P,"unstaking"),Su(P,c,l,R);for(const U of h){const K=u.get(U)??[];if(K.length===0)continue;const W=f.get(U),ye=g.get(U),pe=du(U),$e=W?.coins.map(re=>re.denom)??[],Ae=W?Di(W,M).filter(Boolean):[],St=$e.map(re=>M.get(re)?.symbol||re),Ot=W?.symbol||St.join("-")||pe,mn=wu($e,M),Tt=K.map(re=>{let He,Tn,$n,En=!1,Mn=0,Vt=0;try{const Ge=cu({tickLower:re.tickLower,tickUpper:re.tickUpper});He=Ge.min,Tn=Ge.max}catch{He=void 0,Tn=void 0}if(ye){try{const Ge=su(BigInt(ye.sqrtPrice)),tt=Rt(re.tickLower),Y=Rt(re.tickUpper),me=Number(ye.tickSpacing);En=Number.isFinite(me)&&me>0?Yd(re.tickLower,re.tickUpper,me):!1,$n=En||Ge>=tt&&Ge<Y}catch{$n=void 0,En=!1}if(W&&$e.length>0)try{au({sqrtPrice:ye.sqrtPrice,tickLower:re.tickLower,tickUpper:re.tickUpper,liquidity:re.liquidity}).forEach((tt,Y)=>{const me=W.coins[Y];if(!me)return;const bt=M.get(me.denom)?.decimals??6,hn=v.get(me.denom)??0,Ln=Number(b.fromBaseUnit(String(tt),{decimals:bt}));Mn+=Ln*hn})}catch{Mn=0}}return W&&((_.get(re.tokenAddress)??[]).forEach((tt,Y)=>{const me=W.coins[Y];if(!me)return;const bt=M.get(me.denom)?.decimals??6,hn=v.get(me.denom)??0,Ln=Number(b.fromBaseUnit(tt,{decimals:bt}));Vt+=Ln*hn}),re.incentives.forEach(tt=>{const Y=j.get(qi(re.tokenAddress,tt.incentiveAddress))??"0",me=w.get(tt.rewardMetadata);if(!me)return;const bt=M.get(me)?.decimals??6,hn=v.get(me)??0,Ln=Number(b.fromBaseUnit(Y,{decimals:bt}));Vt+=Ln*hn})),{tokenAddress:re.tokenAddress,positionId:Tu(re.tokenAddress),inRange:$n,isFullRange:En,minPrice:He,maxPrice:Tn,pricePairLabel:mn,rewardValue:Vt,value:Mn}}),ze=Tt.reduce((re,He)=>re+He.value,0),Ee=Tt.reduce((re,He)=>re+He.rewardValue,0),dt=Ae.length>0;P.set(pe,{denom:pe,symbol:Ot,totalAmount:0,totalValue:ze,decimals:6,poolType:"CLAMM",logoUrl:void 0,coinLogos:dt?Ae:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0},isClamm:!0,clamm:{lpMetadata:U,totalRewardValue:Ee,positions:Tt}})}const F=Array.from(P.values()).filter(U=>U.totalAmount>0||U.isClamm).sort((U,K)=>K.totalValue-U.totalValue),Q=F.reduce((U,K)=>U+K.totalValue,0);return{rows:F,totalValue:Q}},[d,L,k,M,o,a,r,i,A,E,c,l,h,u,f,g,_,j,w,v]);return{totalValue:B,rows:N}}const $u=ve.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,n)=>[e,n]});function Eu(e){return e.filter(n=>n.data.length>0).map(n=>{const s=n.data[0].bridge_id,o=n.data[0].version,a=n.data.reduce((r,i)=>r+i.claimed_reward,0);return{claimableReward:n.total_claimable_reward,claimedReward:a,initialReward:n.total_vesting_reward,lockedReward:n.total_locked_reward,requiredScore:n.required_score,rollup:{bridgeId:s,version:o}}}).filter(n=>n.initialReward>0).toSorted((n,s)=>s.initialReward-n.initialReward)}function Oi(){const{vipUrl:e}=se(),n=te();return T.useQuery({queryKey:$u.allVestingPositions(e,n).queryKey,queryFn:async()=>(await G.get(`${e}/vesting/positions/${n}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:z.MINUTE,enabled:!!n})}function Mu(){const e=ue();return x.useCallback(n=>e.find(({metadata:s})=>s?.op_bridge_id===String(n)),[e])}function no(){const{data:e}=Oi(),n=oe(),{data:s}=Nt(n),o=Mu(),a=x.useMemo(()=>s?.find(l=>l.id===Oe)?.price??0,[s]),r=x.useMemo(()=>e?Eu(e).map(l=>{const d=o(l.rollup.bridgeId),m=Number(b.fromBaseUnit(String(l.lockedReward),{decimals:Xe})),u=Number(b.fromBaseUnit(String(l.claimableReward),{decimals:Xe})),h=V(b.fromBaseUnit(String(l.lockedReward),{decimals:Xe})).times(a).toNumber(),f=V(b.fromBaseUnit(String(l.claimableReward),{decimals:Xe})).times(a).toNumber();return{bridgeId:l.rollup.bridgeId,version:l.rollup.version,name:d?.name??"",logoUrl:d?.logoUrl,lockedReward:m,lockedRewardValue:h,claimableReward:u,claimableRewardValue:f}}):[],[e,a,o]),i=x.useMemo(()=>r.reduce((c,l)=>c+l.lockedRewardValue+l.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function Vi(){const{totalValue:e}=to(),{data:n}=ga(),{data:s}=_a(),{data:o}=pa(),{data:a}=Oi(),r=x.useMemo(()=>Array.from(s.keys()),[s]),i=Ts(r),c=oe(),{data:l}=Nt(c),d=x.useMemo(()=>l?.find(u=>u.id===Oe)?.price??0,[l]);return x.useMemo(()=>{let m=0,u=0;const h=d??0;for(const[,g]of n)for(const{denom:p,amount:_}of g)p===Oe&&(m+=Number(b.fromBaseUnit(_,{decimals:Xe}))*h);for(const[g,p]of s)if(i.get(g)===Oe)for(const{amount:_}of p)u+=Number(b.fromBaseUnit(_,{decimals:Xe}))*h;for(const[,g]of o)for(const{denom:p,amount:_}of g)p===Oe&&(m+=Number(b.fromBaseUnit(_,{decimals:Xe}))*h);let f=0;if(a)for(const g of a){const p=g.total_locked_reward??0,_=g.total_claimable_reward??0;f+=Number(b.fromBaseUnit(String(p+_),{decimals:Xe}))*h}return m+u+e+f},[n,s,i,o,a,d,e])}function Lu(){const e=["initia-wallet-widget:last-connected-wallet","initia-wallet-widget:fee-denoms","initia-wallet-widget:chain-ids","initia-wallet-widget:opened-layers-assets","initia-wallet-widget:opened-layers-nft"],n={"initia-wallet-widget:ethereum-public-keys":{prefix:ie.PUBLIC_KEY,getSuffix:s=>b.InitiaAddress(s).bech32}};for(const s of e)localStorage.removeItem(s);for(const[s,{prefix:o,getSuffix:a}]of Object.entries(n)){const r=localStorage.getItem(s);if(r)try{const i=JSON.parse(r);for(const[c,l]of Object.entries(i)){const d=`${o}:${a(c)}`;localStorage.setItem(d,l)}localStorage.removeItem(s)}catch{}}}const Ro=ve.createQueryKeys("interwovenkit:minity",{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,n)=>[e,n],balances:(e,n,s)=>[e,n,s],initiaPositions:(e,n)=>[e,"initia",n],echelonPositions:(e,n)=>[e,"echelon",n],inertiaPositions:(e,n)=>[e,"inertia",n],ravePositions:(e,n,s)=>[e,"rave",n,s],civitiaPositions:(e,n)=>[e,"civitia",n],yominetPositions:(e,n)=>[e,"yominet",n],chainPositions:(e,n,s)=>[e,n,s]});function ya(e,n){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=n[a],c=r.data;if(!(!i||!c)){for(const l of c)if(l.logoUrl&&!l.logoUrl.includes("undefined")){const d=`${i.chainId}:${l.denom}`;s.has(d)||s.set(d,l.logoUrl);const m=l.symbol.toUpperCase();o.has(m)||o.set(m,l.logoUrl)}}}return{denomLogos:s,symbolLogos:o}}function Cn(e){if(e.type==="fungible-position")return e.value??0;if(e.balance.type==="unknown")return 0;const n=e.balance.value??0;return e.type==="lending"&&e.direction==="borrow"?-n:n}function qu(e){return e.type==="fungible-position"?null:e.type==="staking"||e.type==="unstaking"||e.type==="lockstaking"?"staking":e.type==="lending"?e.direction==="supply"?"lending":"borrowing":null}function Pu(e,n=!1){switch(e){case"staking":return n?"INIT staking":"Staking";case"borrowing":return"Borrowing";case"lending":return"Lending";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function Du(e){const n=new Map;for(const d of e){const m=qu(d);if(!m)continue;const u=n.get(m)??[];u.push(d),n.set(m,u)}const s=new Map,o=new Map;for(const[d,m]of n){const u=m.reduce((f,g)=>f+Cn(g),0),h=m.reduce((f,g)=>f+Math.abs(Cn(g)),0);s.set(d,u),o.set(d,h)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,c=[...n.keys()].sort((d,m)=>{const u=d==="lending"||d==="borrowing"?i:o.get(d)??0,h=m==="lending"||m==="borrowing"?i:o.get(m)??0;return(d==="lending"||d==="borrowing")&&(m==="lending"||m==="borrowing")?d==="lending"?-1:1:h-u}),l=new Map;for(const d of c)l.set(d,{positions:n.get(d),totalValue:s.get(d)??0});return l}function Ru(e){return e.type==="fungible-position"?e.title:e.balance.denom}function Bu(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function Fu(e){return e.type==="fungible-position"?null:e.balance}function Uu(e){switch(e){case"staking":return"Staking";case"unstaking":return"Unstaking";case"lockstaking":return"Lock staking";case"lending":return"Lending";case"fungible-position":return"Position";default:return""}}function Ou(e){const n=new Map;for(const s of e){const o=n.get(s.type)??[];o.push(s),n.set(s.type,o)}return n}function Vu(e,n){return e.symbol===st&&n.symbol===st?0:e.symbol===st?-1:n.symbol===st?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function Ku(e){const n=new Map;for(const o of e){const a=Ru(o),r=n.get(a)??[];r.push(o),n.set(a,r)}return Array.from(n.entries()).map(([o,a])=>{const r=Fu(a[0]);let i=0;for(const c of a)c.type!=="fungible-position"&&c.balance.type!=="unknown"&&(i+=c.balance.formattedAmount);return{denom:o,symbol:Bu(a[0]),positions:a,totalValue:a.reduce((c,l)=>c+Cn(l),0),totalAmount:i,balance:r}}).toSorted(Vu)}function Ki(e,n){const s=new Map;return e.forEach((o,a)=>{const r=n[a]?.data;if(r&&r.length>0){const i=new Map(r.map(c=>[c.id,c.price]));s.set(o.chainId,i)}}),s}function Wu(e,n){return e.map(s=>({...s,balances:s.balances.map(o=>{if(o.type==="unknown"||o.value!=null&&o.value>0)return o;const a=n.get(s.chainId);if(a){const r=a.get(o.denom)??0;if(r>0)return{...o,value:o.formattedAmount*r}}return o})}))}function zu(e,n){return e.symbol===st&&n.symbol===st?0:e.symbol===st?-1:n.symbol===st?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function Hu(e,n,s){return e.map(o=>{const a=o.assets.map(i=>{const c=i.symbol.toUpperCase(),l=`${i.chain.chainId}:${i.denom}`,d=n.get(l)??s.get(c)??"";return d!==i.logoUrl?{...i,logoUrl:d}:i});let r="";for(const i of a)if(i.logoUrl){r=i.logoUrl;break}return r||(r=s.get(o.symbol.toUpperCase())??""),r!==o.logoUrl||a!==o.assets?{...o,logoUrl:r,assets:a}:o})}function Gu(e,n,s){const o=n?e.filter(i=>{const{symbol:c,assets:l}=i,d=n.toLowerCase();return c.toLowerCase().includes(d)||l.some(({denom:m})=>m.toLowerCase().includes(d))}):e,a=s?o.map(i=>{const c=i.assets.filter(({chain:l})=>l.chainId===s);return{...i,assets:c,totalValue:c.reduce((l,d)=>l+(d.value??0),0),totalAmount:c.reduce((l,d)=>l+Number(d.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,c)=>i+c.assets.reduce((l,d)=>l+(d.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Qu(e,n,s){const o=n?e.filter(({denom:a,address:r})=>{const i=n.toLowerCase();return a.toLowerCase().includes(i)||r?.toLowerCase().includes(i)}):e;return s?o.filter(({chain:a})=>a.chainId===s):o}function Yu(e,n,s,o){const{filteredAssets:a,totalAssetsValue:r}=Gu(e,s,o),i=Qu(n,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function Zu(e,n,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const c of e){const{chainName:l,chainId:d,balances:m}=c;if(!Array.isArray(m))continue;const u=n.get(l.toLowerCase()),h=u?.chainId??d??l,f=u?.prettyName??l,g=u?.logoUrl??"",p=s.get(h);for(const _ of m){if(_.type==="unknown"){if(!_.amount||_.amount==="0")continue;r.push({symbol:_.denom,logoUrl:"",denom:_.denom,amount:_.amount,decimals:0,quantity:_.amount,value:void 0,unlisted:!0,chain:{chainId:h,name:f,logoUrl:g}});continue}if(_.type==="lp"||(_.value??0)<=0&&(_.formattedAmount??0)<=0)continue;let y=_.value;if((y==null||y<=0)&&p){const w=p.get(_.denom)??0;w>0&&(y=_.formattedAmount*w)}const j={symbol:_.symbol,logoUrl:"",denom:_.denom,amount:_.amount,decimals:_.decimals,quantity:String(_.formattedAmount),value:y,chain:{chainId:h,name:f,logoUrl:g}},C=a.get(_.symbol);C?C.push(j):a.set(_.symbol,[j])}}r.sort((c,l)=>{const d=c.chain.chainId===o,m=l.chain.chainId===o;if(d&&!m)return-1;if(!d&&m)return 1;const u=c.chain.name.localeCompare(l.chain.name);if(u!==0)return u;try{const h=BigInt(c.amount),f=BigInt(l.amount);if(h>f)return-1;if(h<f)return 1}catch{const h=c.amount.localeCompare(l.amount);if(h!==0)return-h}return c.denom.localeCompare(l.denom)});const i=[];for(const[c,l]of a){l.sort((u,h)=>(h.value??0)-(u.value??0));let d=0,m=0;for(const u of l)d+=u.value??0,m+=Number(u.quantity);i.push({symbol:c,logoUrl:"",assets:l,totalValue:d,totalAmount:m})}return i.sort(zu),{listedGroups:i,unlistedAssets:r}}function ba(){return oe().network_type==="testnet"}function Ft(){return we.useFormContext()}function Ju(){const e=it(),n=ba(),s={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},o={...s,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},a={...s,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},r=$.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(ie.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(ie.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(ie.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(ie.BRIDGE_DST_DENOM),quantity:localStorage.getItem(ie.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(ie.BRIDGE_SLIPPAGE_PERCENT)});return{...n?o:a,...r,...e}}const Xu={balances:[],positions:[],isLoading:!0,isComplete:!1},Wi=H.atom(0),em=1e3;let Za=0;function tm(){const e=H.useSetAtom(Wi);x.useEffect(()=>{const n=Date.now();n-Za>=em&&(Za=n,e(s=>s+1))},[e])}function nm(){const e=T.useQueryClient(),n=te(),{minityUrl:s}=se(),o=ba(),a=H.useAtomValue(Wi),r=x.useEffectEvent((l,d)=>{const m=Array.isArray(l.balances)?l.balances:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,balances:m})}),i=x.useEffectEvent((l,d)=>{const m=Array.isArray(l.positions)?l.positions:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,positions:m})}),c=x.useEffectEvent((l,d)=>{const m=Ro.ssePortfolio(n??"",s).queryKey,u=e.getQueryData(m)??Xu,h=l.size>0||d.size>0;e.setQueryData(m,{...u,balances:Array.from(l.values()),positions:Array.from(d.values()),isLoading:h?!1:u.isLoading,isComplete:!1})});x.useEffect(()=>{if(!n||o)return;const l=Ro.ssePortfolio(n,s).queryKey,d=e.getQueryData(l),m=new Map,u=new Map;for(const _ of d?.balances??[])m.set(_.chainName,_);for(const _ of d?.positions??[])u.set(_.chainName,_);const f=`${s}/v1/chain/all/${encodeURIComponent(n)}`;let g=null,p=!1;return e.setQueryData(l,{balances:d?.balances??[],positions:d?.positions??[],isLoading:!0,isComplete:!1}),g=new EventSource(f),g.onmessage=_=>{if(!p)try{const y=JSON.parse(_.data);y.type==="balances"?r(y,m):y.type==="positions"&&i(y,u),c(m,u)}catch{}},g.onerror=()=>{g?.close()},()=>{p=!0,g?.close()}},[n,o,a])}const Ja={balances:[],positions:[],isLoading:!0,isComplete:!1};function rs(){const e=te(),{minityUrl:n}=se(),s=Ro.ssePortfolio(e??"",n).queryKey,{data:o}=T.useQuery({queryKey:s,queryFn:()=>Ja,enabled:!!e,staleTime:z.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??Ja}function sm(){const e=ue();return x.useMemo(()=>{const n=new Map;for(const s of e){const o=s.chain_name.toLowerCase();n.set(o,{chainId:s.chainId,chainName:s.chain_name,prettyName:s.name||s.chain_name,logoUrl:s.logoUrl||""})}return n},[e])}function om(){const{balances:e,positions:n}=rs(),s=ue(),o=x.useMemo(()=>{const r=new Map;for(const i of s)r.set(i.chain_name.toLowerCase(),i);return r},[s]);return x.useMemo(()=>{const r=f=>f.type==="unknown"?0:f.value??0,i=f=>f.positions.reduce((g,p)=>{if(p.type==="fungible-position")return g+(p.value??0);if(p.balance.type==="unknown")return g;const _=p.balance.value??0;return p.type==="lending"&&p.direction==="borrow"?g-_:g+_},0),c=new Map,l=Array.isArray(e)?e:[],d=Array.isArray(n)?n:[];for(const{chainName:f,balances:g}of l){if(!Array.isArray(g))continue;const p=g.reduce((_,y)=>_+r(y),0);c.set(f,(c.get(f)||0)+p)}for(const{chainName:f,positions:g}of d){if(!Array.isArray(g))continue;const p=g.reduce((_,y)=>_+i(y),0);c.set(f,(c.get(f)||0)+p)}const m=Array.from(c.values()).reduce((f,g)=>f+g,0),u=Array.from(c.entries()).filter(([,f])=>f>0).map(([f,g])=>{const p=o.get(f.toLowerCase());return{chainId:p?.chainId||"",chainName:p?.name||f,logoUrl:p?.logoUrl||"",totalBalance:g,percentage:m>0?g/m:0}}).filter(f=>f.chainId!==""),h=f=>f.chainName.toLowerCase()==="initia";return $.sortWith([$.descend(h),$.descend($.prop("totalBalance"))],u)},[e,n,o])}function am(){const{balances:e}=rs(),n=ue(),s=ea(),o=x.useMemo(()=>Ki(n,s),[n,s]);return x.useMemo(()=>{const a=l=>l.type==="unknown"?0:l.value??0;let r=0;const i=Array.isArray(e)?e:[],c=Wu(i,o);for(const{balances:l}of c)if(Array.isArray(l))for(const d of l)d.type!=="lp"&&(r+=a(d));return r},[e,o])}function rm(){const{positions:e}=rs();return x.useMemo(()=>{const n=r=>r.positions.reduce((i,c)=>{if(c.type==="fungible-position")return i+(c.value??0);if(c.balance.type==="unknown")return i;const l=c.balance.value??0;return c.type==="lending"&&c.direction==="borrow"?i-l:i+l},0),s=["initia","civitia","yominet"];let o=0;const a=Array.isArray(e)?e:[];for(const{chainName:r,positions:i}of a){const c=r.toLowerCase();s.includes(c)||Array.isArray(i)&&(o+=i.reduce((l,d)=>l+n(d),0))}return o},[e])}const Re=ve.createQueryKeys("interwovenkit:skip",{chains:null,allAssets:()=>["allAssets"],assets:e=>[e],asset:(e,n)=>[e,n],allBalances:(e,n)=>[e,n],balances:(e,n)=>[e,n],route:(e,n)=>[{...e,quantity:V(e.quantity||0).toString()},n],routeErrorInfo:e=>[e],txTrack:(e,n)=>[e,n],txStatus:(e,n)=>[e,n]});function ct(){const{routerApiUrl:e}=se();return x.useMemo(()=>G.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.4.3"}}),[e])}function zi(){const e=ue();return n=>e.some(s=>s.chain_id===n)}function is(){const e=zi();return n=>e(n.chain_id)?"initia":n.chain_type}function Qn(e){return is()(e)}function cs(){const e=ct(),{data:n}=T.useSuspenseQuery({queryKey:Re.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>$.sortWith([$.descend(({chain_name:o})=>o==="initia"),$.ascend(({pretty_name:o})=>o)],s),staleTime:z.MINUTE});return n}function It(){const e=cs(),n=Pr();return s=>{const o=e.find(r=>r.chain_id===s);if(o)return o;const a=n.find(r=>r.chain_id===s);if(!a)throw new Error(`Chain not found: ${s}`);return{chain_id:a.chain_id,chain_name:a.name,pretty_name:a.pretty_name,logo_uri:a.logo,chain_type:"cosmos",rpc:"",rest:""}}}function et(e){return It()(e)}function dn(){const e=ct(),n=cs(),s=T.useQueryClient(),{data:o}=T.useSuspenseQuery({queryKey:Re.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),select:({chain_to_assets_map:a})=>{const r=[];for(const i in a){if(!n.find(l=>l.chain_id===i))continue;const{assets:c}=a[i]??{assets:[]};s.setQueryData(Re.assets(i).queryKey,{chain_to_assets_map:a}),r.push(...c);for(const l of c)s.setQueryData(Re.asset(i,l.denom).queryKey,l)}return r},staleTime:z.MINUTE});return o}function Ps(e){const n=ct(),s=T.useQueryClient(),{data:o}=T.useSuspenseQuery({queryKey:Re.assets(e).queryKey,queryFn:()=>n.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:a})=>{const{assets:r}=a[e]??{assets:[]};for(const i of r)s.setQueryData(Re.asset(e,i.denom).queryKey,i);return r.toSorted($.descend(i=>i.symbol==="INIT"))},staleTime:z.MINUTE});return o}function Hi(e){const n=Ps(e);return s=>{const o=n.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function pt(e,n){return Hi(n)(e)}const im=()=>(yl(),bl(),null),cm="_loader_1vxch_1",lm={loader:cm},_t=({size:e=24,color:n="currentColor",border:s=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${n} ${n} transparent ${n}`,borderWidth:`${s}px`};return t.jsx("div",{className:lm.loader,style:o})},dm="_button_1q027_1",um="_outline_1q027_28",mm="_sm_1q027_46",hm="_full_1q027_53",fm="_small_1q027_57",gm="_unpadded_1q027_88",Xt={button:dm,outline:um,sm:mm,full:hm,small:fm,unpadded:gm},Gi=e=>{const{sm:n,fullWidth:s,loading:o,className:a,children:r,disabled:i,...c}=e;return t.jsx("button",{...c,className:q(Xt.button,{[Xt.sm]:n,[Xt.full]:s},a),disabled:!!o||i,children:o?t.jsxs(t.Fragment,{children:[t.jsx(_t,{color:"currentColor",size:16}),typeof o=="string"&&t.jsx("span",{className:Xt.loading,children:o})]}):r})},pm=({className:e,...n})=>t.jsx(Gi,{...n,className:q(Xt.outline,e)}),_m=({className:e,unpadded:n,...s})=>t.jsx("button",{...s,className:q(Xt.small,{[Xt.unpadded]:n},e)}),de={White:Gi,Outline:pm,Small:_m},xm="_footer_1vp4h_1",ym="_actions_1vp4h_10",Xa={footer:xm,actions:ym},je=({extra:e,className:n,children:s})=>t.jsxs("footer",{className:q(Xa.footer,n),children:[e,t.jsx("div",{className:Xa.actions,children:s})]}),bm="_scrollable_13su7_1",wm={scrollable:bm},lt=({className:e,children:n,ref:s})=>t.jsx("div",{ref:s,className:q(wm.scrollable,e),children:n});function so(){return Be.useMediaQuery("(max-width: 576px)")}const Bo="interwoven-kit";function Qi(){const e=document.querySelector(Bo)||document.body.appendChild(document.createElement(Bo));return e.shadowRoot||e.attachShadow({mode:"open"})}function Yi(){const{theme:e,container:n}=se();return x.useEffect(()=>{document.querySelector(Bo)?.setAttribute("data-theme",e)},[e]),n??Qi()}function jm(e){const n=Qi(),s=document.createElement("style");s.textContent=e,n.appendChild(s)}const oo=x.createContext(null);function rn(){const{container:e}=x.useContext(oo);return e}function Zi(e){const n=rn();return n?getComputedStyle(n).getPropertyValue(e):""}function vm(){return Be.useScrollLock(),null}function Cm(e){return/^[A-F0-9]{64}$/i.test(e)}function Nm(e,n){const{txHash:s,accountAddress:o,pathSuffix:a}=n;if(s)return Cm(s)?$.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!b.InitiaAddress.validate(o))return;const i=$.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function km(e){try{const n=new URL(e,window.location.href);if(!["http:","https:"].includes(n.protocol))throw new Error("Invalid protocol");return n.toString()}catch{return"#"}}const Im="_link_j1lkz_1",er={link:Im},ao=({chainId:e,txHash:n,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:c,onClick:l,...d}=a,m=rt(e),u=Nm(m,{txHash:n,accountAddress:s,pathSuffix:o}),h=n?b.truncate(n):s?b.truncate(s):"",f=c??h;return u?t.jsxs("a",{...d,href:Zc(km(u)),className:q(er.link,i),onClick:l,target:"_blank",children:[f,r&&t.jsx(S.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:q(er.link,i),children:f})},Ji=x.createContext(null),ro=()=>x.useContext(Ji),Am=()=>{const[e,n]=H.useAtom(Ci),{showNotification:s,updateNotification:o,hideNotification:a}=ro();return x.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:c,error:l}=e,d=l?l.message:c?t.jsx(ao,{txHash:c,chainId:i,onClick:a,showIcon:!0,children:"View on Initia Scan"}):null;switch(r){case"loading":s({type:"loading",title:"Transaction is pending..."});break;case"error":o({type:"error",title:"Transaction failed",description:d}),n(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),n(null);break}},[e,n,s,o,a]),null},Ds=({value:e,children:n})=>{const[s,o]=x.useState(!1);return n({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},Sm="_placeholder_10r3x_1",Tm="_logo_10r3x_5",tr={placeholder:Sm,logo:Tm},ne=({src:e,alt:n,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[c,l]=x.useState(void 0),{width:d,height:m}=i,u=s??t.jsx("div",{className:q(tr.placeholder,o?.placeholder),style:{width:d,height:m,...a}});return!e||c===e?u:t.jsx("img",{...i,className:q(i.className,{[tr.logo]:r}),style:{width:d,height:m,...a},src:e,alt:n,loading:"lazy",onError:()=>l(e)})};function Xi(){const{connector:e}=De.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const $m="_header_1q8ju_1",Em="_account_1q8ju_17",Mm="_name_1q8ju_28",Lm="_address_1q8ju_32",qm="_icon_1q8ju_36",Pm="_copied_1q8ju_43",Dm="_button_1q8ju_58",Rm="_settings_1q8ju_69",Bm="_disconnect_1q8ju_73",Fm="_label_1q8ju_83",Um="_expanded_1q8ju_91",Qe={header:$m,account:Em,name:Mm,address:Lm,icon:qm,copied:Pm,button:Dm,settings:Rm,disconnect:Bm,label:Fm,expanded:Um},Om=()=>{const e=ai(),{address:n,username:s}=We(),o=Xi(),a=s??n,[r,i]=x.useState(!1),c=x.useRef(null),l=gt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{r?e():i(!0)},m=()=>{r&&(c.current=setTimeout(()=>{i(!1)},500))},u=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return x.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),n?t.jsxs("header",{className:Qe.header,children:[t.jsx(Ds,{value:n,children:({copy:h,copied:f})=>t.jsxs("button",{className:q(Qe.account,{[Qe.copied]:f}),onClick:h,children:[t.jsx(ne,{src:o,width:18,height:18}),t.jsx("div",{className:Qe.address,children:b.truncate(n)}),t.jsx("div",{className:Qe.name,children:b.truncate(a)}),t.jsx(S.IconCopy,{className:Qe.icon,size:12}),f?"Copied!":""]})}),t.jsx(jn,{to:"/settings",className:q(Qe.button,Qe.settings),"aria-label":"Open settings",children:t.jsx(S.IconSettingFilled,{size:16})}),t.jsxs(gt.animated.button,{className:q(Qe.button,Qe.disconnect,{[Qe.expanded]:r}),style:l,onClick:d,onMouseLeave:m,onMouseEnter:u,children:[t.jsx(S.IconSignOut,{size:16}),t.jsx("span",{className:Qe.label,children:"Disconnect"})]})]}):null},Vm="_overlay_jij9g_1",Km="_content_jij9g_28",Wm="_inner_jij9g_60",yo={overlay:Vm,content:Km,inner:Wm},zm=({children:e})=>{const{isDrawerOpen:n,closeDrawer:s}=kt(),{setContainer:o}=x.useContext(oo),a=so(),r=Yi(),i=H.useAtomValue(Xs),c=H.useAtomValue(ts),l=T.useIsMutating({mutationKey:[vi]}),d=()=>{const g=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),i?.reject(new Error(g)),c?.reject(new Error("User rejected"))},m=Hs(),u=Ie(),h=T.useQueryClient(),f={fallbackRender:({error:g,resetErrorBoundary:p})=>{const _=()=>{m==="/bridge"&&(localStorage.removeItem(ie.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(ie.BRIDGE_SRC_DENOM),localStorage.removeItem(ie.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(ie.BRIDGE_DST_DENOM)),u("/"),h.clear(),p()};return t.jsxs(lt,{children:[t.jsx(ge,{error:!0,children:g.message}),t.jsx(je,{children:t.jsx(de.White,{onClick:_,children:"Retry"})})]})}};return t.jsx(Te.Dialog.Root,{open:n,onOpenChange:g=>!g&&d(),modal:!1,children:t.jsxs(Te.Dialog.Portal,{container:r,children:[a&&t.jsx(Te.Dialog.Backdrop,{className:yo.overlay,onClick:d,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[t.jsx("path",{d:"M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z"}),t.jsx("path",{d:"M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z"})]})}),t.jsx(Te.Dialog.Popup,{className:yo.content,children:t.jsxs("div",{className:q(yo.inner,"body"),ref:o,children:[a&&t.jsx(vm,{}),t.jsx(Am,{}),t.jsx(Om,{}),t.jsx(fe,{errorBoundaryProps:f,children:e})]})})]})})},Hm="_backdrop_1bqx9_1",Gm="_modal_1bqx9_12",Qm="_closeButton_1bqx9_44",bo={backdrop:Hm,modal:Gm,closeButton:Qm},Ym=({children:e})=>{const{isModalOpen:n,closeModal:s}=In(),{setContainer:o}=x.useContext(oo),a=Yi();return t.jsx(Te.Dialog.Root,{open:n,onOpenChange:r=>!r&&s(),children:t.jsxs(Te.Dialog.Portal,{container:a,children:[t.jsx(Te.Dialog.Backdrop,{className:bo.backdrop,onClick:s}),t.jsxs(Te.Dialog.Popup,{className:q(bo.modal),ref:o,children:[t.jsx("button",{className:bo.closeButton,onClick:s,"aria-label":"Close",children:t.jsx(S.IconClose,{size:20})}),e]})]})})},ec=x.createContext(!1),Zm="_overlay_1iyfl_1",Jm="_fullscreen_1iyfl_15",Xm="_content_1iyfl_19",eh="_header_1iyfl_56",th="_title_1iyfl_65",nh="_close_1iyfl_70",Wt={overlay:Zm,fullscreen:Jm,content:Xm,header:eh,title:th,close:nh},tc=({title:e,children:n,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=rn(),c=x.useContext(ec);return i?t.jsxs(Te.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&t.jsx(Te.Dialog.Trigger,{className:o,children:s}),t.jsxs(Te.Dialog.Portal,{container:i,children:[t.jsx(Te.Dialog.Backdrop,{className:q(Wt.overlay,{[Wt.fullscreen]:c}),onClick:()=>r(!1),forceRender:!0}),t.jsxs(Te.Dialog.Popup,{className:q(Wt.content,{[Wt.fullscreen]:c}),children:[e&&t.jsxs("header",{className:Wt.header,children:[t.jsx(Te.Dialog.Title,{className:Wt.title,children:e}),t.jsx(Te.Dialog.Close,{className:Wt.close,children:t.jsx(S.IconClose,{size:20})})]}),n]})]})]}):null},Yn=({children:e})=>{const n=x.useRef(null),[s,o]=x.useState(0),[a,r]=x.useState(!1),i=gt.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return x.useEffect(()=>{const c=n.current;if(!c)return;const l=()=>{const{height:m}=c.getBoundingClientRect();o(m),r(!0)};l();const d=new ResizeObserver(l);return d.observe(c),()=>d.disconnect()},[e]),e?t.jsx(gt.animated.div,{style:{overflow:"hidden",...i},children:t.jsx("div",{ref:n,children:e})}):null},sh="_help_qcmtq_1",oh="_icon_qcmtq_10",ah="_info_qcmtq_19",rh="_warning_qcmtq_23",ih="_error_qcmtq_27",ch="_success_qcmtq_33",wo={help:sh,icon:oh,info:ah,warning:rh,error:ih,success:ch},xn=({level:e,className:n,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return t.jsx(_t,{size:12});case"info":return t.jsx(S.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(S.IconWarningFilled,{size:12});default:return t.jsx(S.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:q(wo.help,e&&wo[e],n),style:{marginTop:s},children:[t.jsx("div",{className:wo.icon,children:a()}),o]})},lh="_stack_a6m7u_1",dh="_help_a6m7u_6",uh="_info_a6m7u_14",mh="_warning_a6m7u_19",hh="_error_a6m7u_24",fh="_success_a6m7u_29",Fo={stack:lh,help:dh,info:uh,warning:mh,error:hh,success:fh},gh=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(Yn,{children:t.jsx("div",{className:Fo.stack,children:e})}),_e=({mt:e=0,...n})=>t.jsx(xn,{...n,className:q(Fo.help,Fo[n.level]),mt:e});_e.Stack=gh;const ph="_root_16p5j_1",_h="_item_16p5j_10",xh="_chevron_16p5j_14",yh="_trigger_16p5j_19",bh="_content_16p5j_39",qn={root:ph,item:_h,chevron:xh,trigger:yh,content:bh};function wh(e){const{list:n,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return t.jsxs(J.Accordion.Root,{className:qn.root,type:"multiple",...i,children:[n.map((c,l)=>t.jsxs(J.Accordion.Item,{className:qn.item,value:s?.(c)??String(l),children:[t.jsx(J.Accordion.Header,{children:t.jsxs(J.Accordion.Trigger,{className:qn.trigger,children:[o(c),t.jsx(S.IconChevronDown,{className:qn.chevron,size:16})]})}),t.jsx(J.Accordion.Content,{className:qn.content,children:a(c)})]},s?.(c)??l)),r]})}const jh="_trigger_u613p_1",vh="_icon_u613p_18",Ch="_content_u613p_27",Nh="_item_u613p_36",kh="_itemText_u613p_52",Ih="_itemIndicator_u613p_57",Ah="_active_u613p_60",Et={trigger:jh,icon:vh,content:Ch,item:Nh,itemText:kh,itemIndicator:Ih,active:Ah};function wa({options:e,value:n,onChange:s,classNames:o}){const a=rn(),r=e.find(c=>c.value===n);if(!r)throw new Error("Selected option not found");const i=c=>{const l=e.find(d=>String(d.value)===c);if(!l)throw new Error(`Option not found: ${c}`);s(l.value)};return t.jsxs(wt.Select.Root,{value:String(n),onValueChange:i,modal:!1,children:[t.jsxs(wt.Select.Trigger,{className:q(Et.trigger,o?.trigger),children:[t.jsx(wt.Select.Value,{children:r.triggerLabel||r.label}),t.jsx(wt.Select.Icon,{className:Et.icon,children:t.jsx(S.IconChevronDown,{size:12})})]}),t.jsx(wt.Select.Portal,{container:a,children:t.jsx(wt.Select.Positioner,{className:Et.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(wt.Select.Popup,{className:Et.popup,children:e.map(c=>t.jsxs(wt.Select.Item,{className:q(Et.item,o?.item),value:String(c.value),children:[t.jsx(wt.Select.ItemText,{className:q(Et.itemText,o?.itemText),children:c.label}),t.jsx(S.IconCheck,{size:12,className:q(Et.itemIndicator,{[Et.active]:c.value===n})})]},String(c.value)))})})})]})}const Sh="_root_1t37n_1",Th="_trigger_1t37n_7",$h="_item_1t37n_11",Eh="_itemText_1t37n_17",nr={root:Sh,trigger:Th,item:$h,itemText:Eh},Mh=({options:e,value:n,onChange:s})=>{const{txRequest:o}=ki(),a=rt(o.chainId),r=xt(a),i=(g,p)=>{if(b.formatAmount(g,{decimals:p})==="0.000000")return 8},c=({amount:[{amount:g,denom:p}]})=>{if(V(g).isZero())return"0";const{symbol:_,decimals:y}=r(p),j=i(g,y);return`${b.formatAmount(g,{decimals:y,dp:j})} ${_}`},l=e.map(g=>{const[{denom:p}]=g.amount,{symbol:_}=r(p);return{value:p,label:c(g),triggerLabel:_}});if(e.length===1)return t.jsx("span",{className:"monospace",children:c(e[0])});const d=e.find(g=>g.amount[0].denom===n);if(!d)throw new Error("Fee option not found");const[{amount:m,denom:u}]=d.amount,{decimals:h}=r(u),f=i(m,h);return t.jsxs("div",{className:nr.root,children:[t.jsx("span",{className:"monospace",children:b.formatAmount(m,{decimals:h,dp:f})}),t.jsx(wa,{options:l,value:n,onChange:s,classNames:nr})]})},Lh="_root_16nr2_1",qh="_trigger_16nr2_5",Ph="_chevron_16nr2_13",Dh="_panel_16nr2_27",Rh="_details_16nr2_39",Bh="_row_16nr2_48",gn={root:Lh,trigger:qh,chevron:Ph,panel:Dh,details:Rh,row:Bh},Fh=({spend:e,fee:n,total:s,balance:o,symbol:a,decimals:r})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:n},e&&{label:"Required (spend + fee)",value:s},{label:"Balance",value:o}].filter(Boolean),c=r===6?void 0:8;return t.jsxs(ho.Collapsible.Root,{className:gn.root,children:[t.jsxs(ho.Collapsible.Trigger,{className:gn.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(S.IconChevronDown,{className:gn.chevron,size:16})]}),t.jsx(ho.Collapsible.Panel,{className:gn.panel,children:t.jsx("div",{className:gn.details,children:i.map(({label:l,value:d})=>t.jsxs("div",{className:gn.row,children:[t.jsx("span",{children:l}),t.jsxs("span",{children:[b.formatAmount(d,{decimals:r,dp:c})," ",a]})]},l))})})]})};function Rs(e){switch(typeof e){case"string":return e;case"number":case"bigint":return e.toString();case"boolean":return e?"true":"false";case"object":return e===null?"null":e instanceof Uint8Array?ae.toBase64(e):Array.isArray(e)?`[${e.map(Rs).join(",")}]`:JSON.stringify(e,(n,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const Uh="_container_1xzyq_1",Oh="_toggle_1xzyq_5",Vh="_list_1xzyq_11",Kh="_arg_1xzyq_16",Wh="_type_1xzyq_21",Pn={container:Uh,toggle:Oh,list:Vh,arg:Kh,type:Wh},zh=ve.createQueryKeys("interwovenkit:move",{abi:(e,n,s,o)=>[e,n,s,o]}),Hh=({type:e,arg:n})=>Rs(b.resolveBcsType(e).parse(n)),Gh=({msg:e,chainId:n,fallback:s})=>{const[o,a]=Be.useToggle(!1),{restUrl:r}=rt(n),{moduleAddress:i,moduleName:c,functionName:l,args:d}=e,{data:m}=T.useQuery({queryKey:zh.abi(r,i,c,l).queryKey,queryFn:async()=>{const h=await G.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),g=JSON.parse(h.module.abi).exposed_functions.find(({name:p})=>p===l);if(!g)throw new Error(`Function ${l} not found in module ${c}`);return g.params.filter(p=>!p.startsWith("&"))},staleTime:z.INFINITY});if(!m)return s;const u=(h,f)=>{const g=m[f];return t.jsxs("div",{className:Pn.arg,children:[t.jsx("div",{className:Pn.type,children:g}),t.jsx($r.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(Hh,{type:g,arg:h})})]},f)};return t.jsxs("div",{className:Pn.container,children:[t.jsx(de.Small,{className:Pn.toggle,onClick:a,disabled:!m,children:o?"Encode":"Decode"}),o?t.jsx("div",{className:Pn.list,children:d.map(u)}):s]})},Qh="_list_oip9m_1",Yh="_key_oip9m_9",Zh="_value_oip9m_14",jo={list:Qh,key:Yh,value:Zh},Jh=({message:e,chainId:n})=>{const{typeUrl:s,value:o}=e;return t.jsx("div",{className:jo.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{children:[t.jsx("div",{className:jo.key,children:a}),t.jsx("div",{className:jo.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?t.jsx(Gh,{msg:o,chainId:n,fallback:Rs(r)}):Rs(r)})]},a))})},Xh="_item_1n572_1",ef="_title_1n572_10",tf="_content_1n572_14",vo={item:Xh,title:ef,content:tf},Co=({title:e,content:n})=>t.jsxs("div",{className:vo.item,children:[t.jsx("div",{className:vo.title,children:e}),t.jsx("div",{className:vo.content,children:n})]});function ee(e){const n=e?V(e).abs():void 0;if(n&&n.gt(0)&&n.lt(.01))return"< $0.01";const s=e&&V(e).lt(0),o=b.formatNumber(n?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function nc(e,n){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")){if(o.type==="coin_spent"){const r=o.attributes.find(c=>c.key==="spender")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===n&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=s[l]||BigInt(0);s[l]=d-BigInt(c)}}}if(o.type==="coin_received"){const r=o.attributes.find(c=>c.key==="receiver")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===n&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=s[l]||BigInt(0);s[l]=d+BigInt(c)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),denom:o}))}function sc(e,n){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")&&o.type==="move"){const r=o.attributes.find(l=>l.key==="type_tag")?.value,i=o.attributes.find(l=>l.key==="data")?.value;if(!r||!i)continue;let c;try{c=JSON.parse(i)}catch{continue}if(r==="0x1::fungible_asset::WithdrawEvent"){const l=c.store_addr,d=c.amount,m=c.metadata_addr;if(l&&d&&m&&b.createUserDerivedObjectAddress(n,m)===l){const h=s[m]||BigInt(0);s[m]=h-BigInt(d)}}if(r==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,d=c.amount,m=c.metadata_addr;if(l&&d&&m&&b.createUserDerivedObjectAddress(n,m)===l){const h=s[m]||BigInt(0);s[m]=h+BigInt(d)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const oc=({metadata:e,chain:n,children:s})=>{const{restUrl:o}=n,{data:a}=T.useSuspenseQuery({queryKey:zn.denom(o,e).queryKey,queryFn:()=>G.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:z.INFINITY});return s(a)},nf="_root_1p8a4_1",sf="_title_1p8a4_8",of="_changes_1p8a4_14",af="_change_1p8a4_14",rf="_amount_1p8a4_35",cf="_text_1p8a4_42",lf="_value_1p8a4_49",en={root:nf,title:sf,changes:of,change:af,amount:rf,text:cf,value:lf},ac=({amount:e,asset:n,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=n,c=b.formatAmount(e,{decimals:r}),l=s&&V(b.fromBaseUnit(e,{decimals:r})).times(s).abs();return t.jsxs("div",{className:en.change,children:[t.jsxs("div",{className:en.amount,children:[t.jsx(ne,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:en.text,children:[c," ",a||o]})]}),l&&t.jsx("div",{className:en.value,children:ee(l)})]})},df=({changes:e,chain:n})=>{const s=xt(n),{data:o}=Nt(n);return e.map(({amount:a,denom:r},i)=>{const c=s(r),l=o?.find(({id:d})=>d===r)?.price;return t.jsx(ac,{amount:a,asset:c,price:l},i)})},uf=({changes:e,chain:n})=>{const s=xt(n),{data:o}=Nt(n);return e.map(({amount:a,metadata:r},i)=>t.jsx(oc,{metadata:r,chain:n,children:c=>{const l=o?.find(({id:d})=>d===c)?.price;return t.jsx(ac,{amount:a,asset:s(c),price:l})}},i))};function mf(e,n){return typeof n=="bigint"?n.toString():n}const hf=ve.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,mf)]}),ff=({messages:e,memo:n,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=We(),r=rt(s),{simulateTx:i}=eo(),{data:c}=T.useSuspenseQuery({queryKey:hf.simulate({messages:e,memo:n,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:n,chainId:s}),staleTime:z.SECOND}),l=h=>t.jsxs("div",{className:en.root,children:[t.jsx("h2",{className:en.title,children:"Estimated changes"}),t.jsx("div",{className:en.changes,children:h})]});if(!c)return null;const d=c.result?.events??[];if(d.length===0)return null;if(r.metadata?.is_l1||r.metadata?.minitia?.type==="minimove"){const h=sc(d,a),[f]=sr(h);return f.length===0?null:l(t.jsx(uf,{changes:f,chain:r}))}const m=nc(d,o),[u]=sr(m);return u.length===0?null:l(t.jsx(df,{changes:u,chain:r}))};function sr(e){return $.partition(n=>new V(n.amount).isNegative(),e)}const gf="_title_1d032_1",pf="_meta_1d032_7",_f="_footer_1d032_14",xf="_rejectButton_1d032_19",_s={title:gf,meta:pf,footer:_f,rejectButton:xf},rc=()=>{const{txRequest:e,resolve:n,reject:s}=ki(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:c,spendCoins:l}=e,d=rt(r),m=es(d),u=la(d),h=da(d),f=xt(d),g=Ni(),p=(e.gasPrices??u).map(({amount:k,denom:M})=>Ce.calculateFee(Math.ceil(i*c),Ce.GasPrice.fromString(k+M))),_=p.map(k=>k.amount[0]),y=k=>{const M=m.find(Q=>Q.denom===k)?.amount??"0",v=_.find(Q=>Q.denom===k)?.amount??"0",N=l.filter(Q=>Q.denom===k).reduce((Q,U)=>V(Q).plus(U.amount),V("0")),B=V(v).plus(N),R=V(M).gte(B),{symbol:P,decimals:F}=f(k);return{symbol:P,decimals:F,spend:N.gt(0)?N.toFixed():null,fee:v,total:B.toFixed(),balance:M,isSufficient:R}},j=()=>{if(h&&y(h).isSufficient)return h;for(const{denom:k}of _)if(y(k).isSufficient)return k;return _[0]?.denom},[C,w]=x.useState(j),{mutate:I,isPending:A}=T.useMutation({mutationKey:[vi],mutationFn:async()=>{const k=p.find(v=>v.amount[0].denom===C);if(!k)throw new Error("Fee not found");const M=await g({chainId:r,messages:o,memo:a||"",fee:k,preferredFeeDenom:C,allowAutoSign:!e.internal,allowWalletDerivation:!0});await n(M)},onError:async k=>{s(k)}}),L=y(C),E=!L.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(lt,{children:[t.jsx("h1",{className:_s.title,children:"Confirm tx"}),t.jsxs("div",{className:_s.meta,children:[t.jsx(Co,{title:"Chain",content:r}),t.jsx(Co,{title:"Tx fee",content:t.jsx(Mh,{options:p,value:C,onChange:w})}),a&&t.jsx(Co,{title:"Memo",content:a}),E&&t.jsx(_e,{level:"error",children:t.jsx(Fh,{...L})})]}),t.jsx(ff,{messages:o,memo:a,chainId:r}),t.jsx(wh,{list:o,renderHeader:({typeUrl:k})=>Os.sentenceCase(k.split(".").pop().replace(/^Msg/,"")),renderContent:k=>t.jsx(Jh,{message:k,chainId:r})})]}),t.jsxs(je,{className:_s.footer,children:[t.jsx(de.Outline,{onClick:()=>s(new Error("User rejected")),disabled:A,className:_s.rejectButton,"aria-label":"Reject",children:t.jsx(S.IconClose,{size:16})}),t.jsx(de.White,{onClick:()=>I(),disabled:E,loading:A,children:"Approve"})]})]})},yf=({children:e})=>{const[{title:n,content:s,path:o},a]=x.useState({}),[r,i]=x.useState(!1),c=H.useAtomValue(Xs),l=x.useCallback(u=>{a(u),i(!0)},[]),d=x.useCallback(()=>{a({}),i(!1)},[]),m=x.useCallback(u=>{u||(c?.reject(new Error("User rejected")),a({})),i(u)},[c]);return t.jsxs(yi.Provider,{value:{openModal:l,closeModal:d},children:[e,t.jsx(tc,{title:n,open:r,onOpenChange:m,children:t.jsx(fe,{children:o==="/tx"?t.jsx(rc,{}):s})})]})},bf="_container_1w1hx_1",wf="_toast_1w1hx_11",jf="_info_1w1hx_24",vf="_success_1w1hx_28",Cf="_error_1w1hx_32",Nf="_icon_1w1hx_37",kf="_content_1w1hx_45",If="_title_1w1hx_48",Af="_description_1w1hx_53",Sf="_close_1w1hx_75",Mt={container:bf,toast:wf,info:jf,success:vf,error:Cf,icon:Nf,content:kf,title:If,description:Af,close:Sf},Tf=({notification:e,onClose:n,...s})=>{const o=gt.useTransition(e,{keys:r=>r?.id||"empty",from:{transform:"translateY(-52px)",opacity:0},enter:{transform:"translateY(0px)",opacity:1},leave:{transform:"translateY(-52px)",opacity:0},config:{tension:500,friction:30,clamp:!0}}),a=r=>{switch(r){case"loading":return t.jsx(_t,{size:16});case"info":case"success":return t.jsx(S.IconCheckCircleFilled,{size:16});case"error":return t.jsx(S.IconCloseCircleFilled,{size:16});default:return null}};return o((r,i)=>{if(!i)return null;const{type:c,title:l,description:d}=i,m=a(c);return t.jsx(gt.animated.div,{style:r,className:Mt.container,children:t.jsxs("div",{className:q(Mt.toast,c&&Mt[c]),...s,children:[m&&t.jsx("div",{className:Mt.icon,children:m}),t.jsxs("div",{className:Mt.content,children:[t.jsx("p",{className:Mt.title,children:l}),d&&t.jsx("div",{className:Mt.description,children:d})]}),t.jsx("button",{className:Mt.close,onClick:n,children:t.jsx(S.IconClose,{size:14})})]})})})},No=5e3,$f=({children:e})=>{const n=rn(),[s,o]=x.useState(null),a=x.useRef(null),r=x.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},c=x.useCallback(()=>{i(),o(null)},[]),l=x.useCallback(h=>{i(),o({...h,id:Ba.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),No))},[c]),d=x.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:Ba.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),No))},[c]),m=()=>{i(),r.current=!0},u=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>c(),No))};return x.useEffect(()=>()=>i(),[]),t.jsxs(Ji.Provider,{value:{showNotification:l,updateNotification:d,hideNotification:c},children:[e,n&&Jc.createPortal(t.jsx(Tf,{notification:s,onClose:c,onMouseEnter:m,onMouseLeave:u}),n)]})},Ef=({children:e})=>{const[n,s]=x.useState(null);return t.jsx(oo.Provider,{value:{container:n,setContainer:s},children:e})},ic=[{value:10*ti,label:"for 10 minutes"},{value:ni,label:"for 1 hour"},{value:Va,label:"for 1 day"},{value:7*Va,label:"for 7 days"},{value:0,label:"until revoked"}],Mf=ic[0].value;function Lf(e){const n=e.split(".");return n.length!==4?!1:n.every(s=>{if(!/^\d+$/.test(s))return!1;const o=Number(s);return o>=0&&o<=255})}function cc(e){return Lf(e)||e.includes(":")}function Uo(e){const n=Xc.parse(e);return"error"in n?null:n.domain}function qf(e,n){return e===n||e===`www.${n}`}function Pf(e){if(e.protocol!=="https:")return!1;const n=e.hostname.toLowerCase();return!n||!n.includes(".")||n==="localhost"||cc(n)?!1:Uo(n)!==null}function Df(e,n){try{const s=new URL(e);if(!Pf(s))return!1;const o=s.hostname.toLowerCase(),a=n.toLowerCase();if(!o||!a||cc(a)||a==="localhost")return!1;const r=Uo(o);if(!r)return!1;const i=Uo(a);return!i||i!==r?!1:qf(o,r)?a===r||a.endsWith(`.${r}`):a===o||a.endsWith(`.${o}`)}catch{return!1}}const Rf="_container_1422v_1",Bf="_title_1422v_7",Ff="_description_1422v_14",Uf="_sectionTitle_1422v_20",Of="_websiteInfo_1422v_27",Vf="_favicon_1422v_37",Kf="_websiteTitle_1422v_42",Wf="_websiteHost_1422v_48",zf="_warningContent_1422v_54",Hf="_ignoreButton_1422v_61",Gf="_infoList_1422v_65",Qf="_infoItem_1422v_75",Yf="_label_1422v_84",Zf="_infoValue_1422v_94",Jf="_durationTrigger_1422v_100",Xf="_durationItem_1422v_101",eg="_featureList_1422v_105",tg="_featureItem_1422v_113",ng="_checkIcon_1422v_123",sg="_learnMoreLink_1422v_127",og="_feedbackContainer_1422v_140",ag="_footer_1422v_146",ce={container:Rf,title:Bf,description:Ff,sectionTitle:Uf,websiteInfo:Of,favicon:Vf,websiteTitle:Kf,websiteHost:Wf,warningContent:zf,ignoreButton:Hf,infoList:Gf,infoItem:Qf,label:Yf,infoValue:Zf,durationTrigger:Jf,durationItem:Xf,featureList:eg,featureItem:tg,checkIcon:ng,learnMoreLink:sg,feedbackContainer:og,footer:ag};function rg(e){return e instanceof G.HTTPError&&e.response.status===404}const ig=ve.createQueryKeys("interwovenkit:account",{info:(e,n)=>({queryKey:[e,n],queryFn:async()=>{const s=G.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${n}`;try{return await s.get(o).json(),!0}catch(a){if(rg(a))return!1;throw a}}})}),cg=()=>{const[e,n]=x.useState(Mf),[s,o]=H.useAtom(ts),[a,r]=x.useState(!1),i=Ke(),c=ue(),{address:l,username:d}=We(),{mutate:m,isPending:u}=Md(),{closeDrawer:h}=kt();if(!s)throw new Error("Pending request not found");const{logoUrl:f,name:g,restUrl:p}=i(s.chainId),{data:_,isLoading:y,isError:j}=T.useQuery(ig.info(p,l)),C={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},w=c.find(N=>N.chainId===s.chainId),I=w?.website?Df(w.website,window.location.hostname):!1,A=()=>{m(e)},L=()=>{s?.reject(new Error("User cancelled")),o(null),h()},E=!I&&!a,k=!y&&!j&&_===!1,M=!y&&j,v=E||y||j||_===!1;return t.jsxs(t.Fragment,{children:[t.jsxs(lt,{className:ce.container,children:[t.jsxs("header",{children:[t.jsx("h1",{className:ce.title,children:"Enable auto-signing"}),t.jsx("p",{className:ce.description,children:"An application is requesting to enable auto-signing"})]}),t.jsxs("section",{children:[t.jsx("h2",{className:ce.sectionTitle,children:"Requested by"}),t.jsxs("div",{className:ce.websiteInfo,children:[t.jsx("img",{src:C.favicon,alt:"",className:ce.favicon}),t.jsxs("div",{children:[t.jsx("div",{className:ce.websiteTitle,children:C.title}),t.jsx("div",{className:ce.websiteHost,children:C.hostname})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:ce.sectionTitle,children:"Applies to"}),t.jsxs("div",{className:ce.infoList,children:[t.jsxs("div",{className:ce.infoItem,children:[t.jsx("div",{className:ce.label,children:"Address"}),t.jsxs("div",{className:ce.infoValue,children:[t.jsx(S.IconWallet,{size:14}),t.jsx("span",{className:"monospace",children:b.truncate(d??l)})]})]}),t.jsxs("div",{className:ce.infoItem,children:[t.jsx("div",{className:ce.label,children:"Chain"}),t.jsxs("div",{className:ce.infoValue,children:[t.jsx(ne,{src:f,width:14,height:14,logo:!0}),t.jsx("span",{children:g})]})]}),t.jsxs("div",{className:ce.infoItem,children:[t.jsx("div",{className:ce.label,children:"Duration"}),t.jsx(wa,{options:ic,value:e,onChange:n,classNames:{trigger:ce.durationTrigger,item:ce.durationItem}})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:ce.sectionTitle,children:"About auto-signing"}),t.jsx("ul",{className:ce.featureList,children:["Send transactions without confirmation pop-ups","Secured by your wallet signature","Revoke permissions any time in settings"].map(N=>t.jsxs("li",{className:ce.featureItem,children:[t.jsx(S.IconCheckCircle,{size:12,className:ce.checkIcon}),t.jsx("span",{children:N})]},N))}),t.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",rel:"noopener noreferrer",className:ce.learnMoreLink,children:["Learn more ",t.jsx(S.IconExternalLink,{size:12})]})]})]}),t.jsxs(je,{className:ce.footer,extra:t.jsxs("div",{className:ce.feedbackContainer,children:[k&&t.jsx(_e,{level:"error",children:"Insufficient balance for fee"}),M&&t.jsx(_e,{level:"warning",children:"Unable to verify account status. Try again."}),!I&&!a&&t.jsx(_e,{level:"warning",children:t.jsxs("div",{className:ce.warningContent,children:[t.jsx("span",{children:"You are on an unverified website"}),t.jsx("button",{onClick:()=>r(!0),className:ce.ignoreButton,children:"Ignore"})]})})]}),children:[t.jsx(de.Outline,{onClick:L,children:"Cancel"}),t.jsx(de.White,{onClick:A,disabled:v,loading:u,children:"Enable"})]})]})},lg=()=>H.useAtomValue(ts)?t.jsx(cg,{}):null,dg="_container_mqvhs_1",ug="_badge_mqvhs_5",or={container:dg,badge:ug},lc=e=>{const{offset:n=-4,disabled:s,children:o,className:a}=e;return t.jsxs("div",{className:q(or.container,a),children:[o,!s&&t.jsx("div",{className:or.badge,style:{right:n,top:n}})]})},mg="_header_s7mee_1",hg="_back_s7mee_12",fg="_title_s7mee_24",ko={header:mg,back:hg,title:fg},yt=({title:e,backButton:n,extra:s,children:o})=>{const a=Wr();return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:ko.header,children:[t.jsx(jn,{to:n??(a.length>1?-1:"/"),className:ko.back,shouldReset:!!n,children:t.jsx(S.IconBack,{size:16})}),t.jsx("h1",{className:ko.title,children:e}),s]}),t.jsx(lt,{children:o})]})};function dc(){const{initiaAddress:e,hexAddress:n}=We(),s=It(),o=is();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return n;default:return""}}}function uc(){const e=It(),n=is();return(s,o)=>{const a=e(o);switch(n(a)){case"initia":return b.InitiaAddress.validate(s);case"evm":return ft.isAddress(s);case"cosmos":try{return ae.fromBech32(s).prefix===a.bech32_prefix}catch{return!1}default:return!1}}}function gg(){const e=It(),n=is();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),c=n(i),l=e(a),d=n(l);if(c==="evm"&&d==="initia")return b.InitiaAddress(s).bech32;if(c==="initia"&&d==="evm")return b.InitiaAddress(s).hex;if(c===d)return s;if(r){if(d==="initia")return b.InitiaAddress(r).bech32;if(d==="evm")return b.InitiaAddress(r).hex}return""}}const pg="_root_ekn9t_1",_g="_header_ekn9t_6",xg="_title_ekn9t_12",yg="_warning_ekn9t_18",bg="_content_ekn9t_22",wg="_footer_ekn9t_26",jg="_secondary_ekn9t_36",zt={root:pg,header:_g,title:xg,warning:yg,content:bg,footer:wg,secondary:jg},mc=e=>{const{type:n,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return t.jsxs(lt,{className:zt.root,children:[t.jsxs("header",{className:q(zt.header,n&&zt[n]),children:[s,t.jsx("h1",{className:zt.title,children:o})]}),t.jsx("div",{className:zt.content,children:a}),t.jsxs("footer",{className:zt.footer,children:[t.jsx(de.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),t.jsxs("button",{className:zt.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(S.IconChevronRight,{size:14})]})]})]})},vg="_list_k4n3k_1",Cg="_row_k4n3k_9",Ng="_dt_k4n3k_20",kg="_asset_k4n3k_26",xs={list:vg,row:Cg,dt:Ng,asset:kg},Ig=({list:e,onNavigate:n,onDismiss:s})=>{const o=oe(),a=Ke(),r=xt(o);return t.jsx(mc,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:n},secondaryButton:{label:"Do not show again",onClick:s},children:t.jsx("div",{className:xs.list,children:e.toSorted((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:d})=>{const m=a(c),{decimals:u,symbol:h}=r(d),f=b.formatAmount(l,{decimals:u});return t.jsxs("div",{className:xs.row,children:[t.jsxs("div",{className:xs.dt,children:[t.jsx(ne,{src:m.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:m.name})]}),t.jsxs("span",{className:xs.asset,children:[f," ",h]})]},i)})})})};function Io(e,n){return e.chainId===n.chainId&&e.txHash===n.txHash}const ys=({chainId:e,txHash:n})=>`${ie.OP_REMINDER}:${e}:${n}`,Ag=el.atomWithStorage(ie.OP_REMINDER,[]);function Sn(){const e=te(),[n=[],s]=H.useAtom(Ag),o=x.useMemo(()=>n.map(l=>{const d=localStorage.getItem(ys(l));return d?JSON.parse(d):null}).filter(l=>{if(!l)return!1;const{recipient:d,claimableAt:m}=l;return d!==e?!1:Ve.isPast(m)}),[e,n]),a=x.useCallback((l,d)=>{n.some(m=>Io(m,l))||(s((m=[])=>[...m,l]),localStorage.setItem(ys(l),JSON.stringify(d)))},[n,s]),r=x.useCallback(l=>{s((d=[])=>d.filter(m=>!Io(m,l))),localStorage.removeItem(ys(l))},[s]),i=x.useCallback(l=>{const d=l.filter(m=>!n.some(u=>Io(u,m)));d.length!==0&&s((m=[])=>[...m,...d])},[n,s]),c=x.useCallback((l,d)=>{localStorage.setItem(ys(l),JSON.stringify(d)),s((m=[])=>[...m])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:c}}function hc(){const e=Ie(),{openModal:n,closeModal:s}=Js(),{reminders:o,setReminder:a}=Sn();x.useEffect(()=>{const r=o.filter(l=>!l.dismissed);if(r.length===0)return;const i=()=>{const l=r.every(d=>d.chainId===r[0].chainId)?r[0].chainId:void 0;e("/op/withdrawals",{chainId:l}),c()},c=()=>{s();for(const l of r)a(l,{...l,dismissed:!0})};n({content:x.createElement(Ig,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,n,a])}const Sg="_wrapper_5ssm8_1",Tg="_balance_5ssm8_11",$g="_button_5ssm8_15",Ao={wrapper:Sg,balance:Tg,button:$g},fc=({onClick:e,children:n,disabled:s})=>t.jsxs("div",{className:Ao.wrapper,children:[t.jsx(S.IconWallet,{size:16}),t.jsx("span",{className:Ao.balance,children:n}),t.jsx("button",{type:"button",tabIndex:-1,className:Ao.button,onClick:()=>e(),disabled:s,children:"MAX"})]}),Eg="_fieldset_up6fh_1",Mg="_upper_up6fh_9",Lg="_select_up6fh_14",qg="_account_up6fh_20",Pg="_lower_up6fh_25",Dg="_wrapper_up6fh_26",Rg="_balance_up6fh_33",Bg="_value_up6fh_37",Fg="_error_up6fh_50",jt={fieldset:Eg,upper:Mg,select:Lg,account:qg,lower:Pg,wrapper:Dg,balance:Rg,value:Bg,error:Fg},Oo=e=>{const{selectButton:n,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:c}=e;return t.jsxs("div",{className:jt.fieldset,children:[t.jsxs("div",{className:jt.upper,children:[t.jsx("div",{className:jt.select,children:n}),t.jsx("div",{className:jt.account,children:s})]}),!c&&t.jsxs("div",{className:jt.lower,children:[o,t.jsxs("div",{className:jt.wrapper,children:[t.jsx("div",{className:jt.balance,children:a}),r&&t.jsx("div",{className:jt.value,children:r})]}),i&&t.jsxs("footer",{className:jt.error,children:[t.jsx(S.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function ls(){const e=x.useRef(null),n=so();return x.useEffect(()=>{n||e.current?.focus()},[n]),e}const Ug="_input_h8073_1",Og={input:Ug};function gc(e){const{name:n,control:s,dp:o=6,className:a,rules:r,...i}=e,c=ls();return t.jsx(we.Controller,{name:n,control:s,rules:r,render:({field:l})=>t.jsx(tl.NumericFormat,{value:l.value,getInputRef:Er.mergeRefs([l.ref,c]),className:q(Og.input,a),onValueChange:d=>{l.onChange(d.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const Vg="_input_19r9r_1",Kg="_placeholder_19r9r_18",Vo={input:Vg,placeholder:Kg},Wg=({children:e})=>t.jsx("p",{className:q(Vo.input,{[Vo.placeholder]:V(e).isZero()}),children:e}),Zn=({balance:e,decimals:n,className:s})=>{const{control:o}=we.useFormContext(),a={required:"Enter amount",validate:r=>V(r).isZero()?"Enter amount":V(b.toBaseUnit(r,{decimals:n})).gt(e??0)?"Insufficient balance":!0};return t.jsx(gc,{name:"quantity",control:o,className:q(Vo.input,s),rules:a})};Zn.ReadOnly=Wg;const Nn=({title:e,content:n,children:s,className:o})=>{const[a,r]=x.useState(!1),i=()=>r(!1);return t.jsx(tc,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:n(i)})},zg="_tooltip_19kvs_1",Hg="_arrow_19kvs_44",ar={tooltip:zg,arrow:Hg},ds=({label:e,children:n,small:s,...o})=>t.jsxs(J.Tooltip.Root,{...o,children:[t.jsx(J.Tooltip.Trigger,{asChild:!0,children:n}),t.jsx(J.Tooltip.Portal,{container:rn(),children:t.jsxs(J.Tooltip.Content,{className:q(ar.tooltip,{small:s}),collisionBoundary:rn(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(J.Tooltip.Arrow,{className:ar.arrow})]})})]});function ja(e,n){const s=ct();return T.useQuery({queryKey:Re.balances(n,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[n]:{address:e,denoms:[]}}}}).json(),select:({chains:o})=>e?o?o[n].denoms??{}:{}:{},enabled:!!e,staleTime:z.SECOND})}function Gg(e,n,s){const{data:o={}}=ja(e,n);return $.path([s],o)}const Qg=[["d",1440*60],["h",3600],["m",60],["s",1]];function Jn(e){if(!e)return;const{formattedParts:n}=Qg.reduce(({remainingSeconds:s,formattedParts:o},[a,r])=>{const i=Math.floor(s/r);return{remainingSeconds:s-i*r,formattedParts:i>0?[...o,`${i}${a}`]:o}},{remainingSeconds:e,formattedParts:[]});return n.join(" ")}function va(e){return e?.map(n=>{const{amount:s,origin_asset:o}=n;return`${b.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function Ko(e,n){const{watch:s}=Ft(),o=s(),a=ct(),r=kn(),i={...o,quantity:e},c=!o.srcChainId||!o.srcDenom||!o.dstChainId||!o.dstDenom,l=V(i.quantity||0),d=l.isFinite()&&l.gt(0),m=T.useQueryClient();return T.useQuery({queryKey:Re.route(i,n?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:u,srcDenom:h,quantity:f,dstChainId:g,dstDenom:p}=i,{decimals:_}=m.getQueryData(Re.asset(u,h).queryKey)??{decimals:0},y={amount_in:b.toBaseUnit(f,{decimals:_}),source_asset_chain_id:u,source_asset_denom:h,dest_asset_chain_id:g,dest_asset_denom:p,is_op_withdraw:n?.isOpWithdraw},j=await a.post("v2/fungible/route",{json:y}).json(),C={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return r("Bridge Simulation Success",C),j},enabled:d&&!n?.disabled&&!c,staleTime:z.MINUTE})}function Yg(e){return T.useQuery({queryKey:Re.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof G.HTTPError))return null;const{response:n}=e;return(n.headers.get("content-type")??"").includes("application/json")?(await n.json()).info??null:null},enabled:!!e})}function Zg(){const{watch:e}=Ft(),{srcChainId:n,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=et(n),i=Qn(r),c=pt(s,n),l=pt(a,o),d=oe(),m=ue();return i==="initia"&&o===d.chainId&&c.symbol===l.symbol&&m.find(u=>u.chainId===n)?.metadata?.op_denoms?.includes(l.denom)}const Jg="_label_t93ix_1",Xg="_wrapper_t93ix_7",ep="_input_t93ix_10",tp="_clear_t93ix_18",bs={label:Jg,wrapper:Xg,input:ep,clear:tp},Ca=({mode:e="onChange",myAddress:n,...s})=>{const{validate:o=b.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,c=ls(),{control:l,getValues:d,setValue:m,formState:u}=we.useFormContext(),h=d("recipient"),[f,g]=x.useState(h),p=Ur(),{data:_,isLoading:y,error:j}=T.useQuery({queryKey:Ws.address(p.restUrl,f).queryKey,queryFn:()=>p.getAddress(f),staleTime:z.MINUTE,enabled:p.validateUsername(f)}),C=_??(o(f)?f:""),w=n&&b.InitiaAddress.equals(C,n),I=async()=>{try{const E=await navigator.clipboard.readText();g(E.trim())}catch{}};x.useEffect(()=>{e==="onChange"&&(!f&&!u.dirtyFields.recipient||m("recipient",_??f,{shouldValidate:!0,shouldDirty:!0}))},[u.dirtyFields.recipient,f,e,m,_]);const A=()=>{y||j||(m("recipient",C,{shouldValidate:!0,shouldDirty:!0}),r?.())},L=()=>{if(y)return t.jsx(xn,{level:"loading",children:"Resolving username..."});if(j)return t.jsx(xn,{level:"error",children:j.message});if(_)return t.jsx(xn,{level:"success",className:"monospace",children:_});if(e==="onSubmit"&&f&&!C)return t.jsx(xn,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:bs.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(de.Small,{type:"button",tabIndex:-1,onClick:I,children:"Paste"})]}),t.jsxs("div",{className:bs.wrapper,children:[t.jsx(we.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:E=>o(E)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:q(bs.input,"monospace"),value:f,onChange:E=>g(E.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?Er.mergeRefs([i,c]):i})}),!!f&&t.jsx("button",{type:"button",className:bs.clear,onClick:()=>g(""),"aria-label":"Clear recipient",children:t.jsx(S.IconCloseCircleFilled,{size:16})})]}),L(),w&&t.jsx(xn,{children:"This is my address"}),e==="onSubmit"&&t.jsx(je,{extra:(!n||!!C&&!w)&&t.jsx(_e,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:t.jsx(de.White,{type:"button",onClick:A,disabled:y||!!j||!C,children:"Apply"})})]})},np="_scrollable_vgj3r_1",sp="_list_vgj3r_5",op="_item_vgj3r_9",ap="_name_vgj3r_22",ws={scrollable:np,list:sp,item:op,name:ap};function pc({onSelect:e,list:n,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:c}=s;return t.jsx(lt,{className:ws.scrollable,children:t.jsx("div",{className:ws.list,children:n.map(l=>t.jsxs("button",{className:ws.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),children:[t.jsx(ne,{src:o(l),width:28,height:28}),t.jsx("span",{className:ws.name,children:a(l)}),i?.(l)&&t.jsx(_t,{size:16})]},r(l)))})})}function io(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:s=>e.find(o=>o.name===s)}}const rp="_account_h04x1_8",ip="_clear_h04x1_28",cp="_white_h04x1_39",Dn={account:rp,clear:ip,white:cp},rr=({type:e})=>{const{watch:n,setValue:s}=Ft(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=n(),c=n(e==="src"?"sender":"recipient"),l=Qn(et(a)),{list:d,find:m}=io(),u=m(r),h=dc(),f=uc(),g=h(a),p=b.InitiaAddress.equals(c,g),_=()=>t.jsx(Nn,{title:"Connect wallet",content:C=>t.jsx(pc,{onSelect:async w=>{const I=w.getProvider();if(!I)return window.open(w.fallbackUrl,"_blank");const A=I.getOfflineSigner(o),[{address:L}]=await A.getAccounts();s("sender",L),s("cosmosWalletName",w.name),C()},list:d,getImage:w=>w.image,getName:w=>w.name,getKey:w=>w.name}),className:q(Dn.account,{[Dn.white]:!c}),children:c?t.jsxs(t.Fragment,{children:[u&&t.jsx(ne,{src:u.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:b.truncate(c)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(S.IconChevronRight,{size:14})]})}),y=C=>t.jsx(Nn,{title:"Recipient",content:w=>t.jsx(lt,{children:t.jsx(Ca,{mode:"onSubmit",myAddress:g,chainType:l,validate:I=>f(I,a),onApply:w})}),className:Dn.account,children:C}),j=()=>{switch(l){case"initia":case"evm":return p?y(t.jsx(S.IconWallet,{size:14})):t.jsxs("div",{className:Dn.account,children:[t.jsx("span",{className:"monospace",children:b.truncate(c)}),t.jsx("button",{type:"button",className:Dn.clear,onClick:()=>s("recipient",g,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(S.IconCloseCircleFilled,{size:14})})]});case"cosmos":return y(t.jsxs(t.Fragment,{children:[c?t.jsx("span",{className:"monospace",children:b.truncate(c)}):t.jsx("span",{children:"Recipient"}),t.jsx(S.IconEdit,{size:14})]}))}};switch(e){case"src":return _();case"dst":return j()}},lp="_images_cj4xz_1",So={images:lp},co=({assetLogoUrl:e,assetLogoSize:n=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>t.jsxs("div",{className:q(So.images,r),style:{position:"relative"},children:[t.jsx(ne,{src:e,width:n,height:n,className:So.asset,logo:!0}),t.jsx(ne,{src:s,width:o,height:o,className:So.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),dp="_root_6187w_1",up="_content_6187w_10",mp="_details_6187w_20",hp="_symbol_6187w_26",fp="_chain_6187w_34",gp="_chevron_6187w_43",Ht={root:dp,content:up,details:mp,symbol:hp,chain:fp,chevron:gp},_c=({asset:e,chain:n,readOnly:s})=>{const o=t.jsxs("div",{className:Ht.content,children:[t.jsx(co,{assetLogoUrl:e.logoUrl,chainLogoUrl:n.logoUrl}),t.jsxs("div",{className:Ht.details,children:[t.jsx("div",{className:Ht.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:Ht.chain,children:["on ",n.name]})]})]});return s?t.jsx("div",{className:Ht.root,children:o}):t.jsxs("div",{className:Ht.root,children:[o,t.jsx(S.IconChevronDown,{size:16,className:Ht.chevron})]})};function pp(e,n,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return $.any($.includes(n.toLowerCase()),a)})}const _p="_root_1sh27_1",xp="_label_1sh27_8",yp="_input_1sh27_21",bp="_hasValue_1sh27_31",wp="_clear_1sh27_35",Rn={root:_p,label:xp,input:yp,hasValue:bp,clear:wp},us=e=>{const{rootClassName:n,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return t.jsxs("div",{className:q(Rn.root,n,{[Rn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[t.jsx("label",{htmlFor:"search",className:Rn.label,children:t.jsx(S.IconSearch,{size:o})}),t.jsx("input",{className:Rn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&t.jsx("button",{type:"button",className:Rn.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:a,children:t.jsx(S.IconCloseCircleFilled,{size:o})})]})},jp="_container_5tajg_1",vp="_search_5tajg_7",Cp="_list_5tajg_11",Np="_item_5tajg_15",kp="_logo_5tajg_37",Ip="_info_5tajg_41",Ap="_symbol_5tajg_47",Sp="_name_5tajg_56",Tp="_balance_5tajg_62",$p="_value_5tajg_69",Je={container:jp,search:vp,list:Cp,item:Np,logo:kp,info:Ip,symbol:Ap,name:Sp,balance:Tp,value:$p},ms=e=>{const{assets:n,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=x.useState(""),i=pp(["symbol"],a,n);return t.jsxs("div",{className:Je.container,children:[t.jsx(us,{value:a,onChange:c=>r(c.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:Je.search,padding:20,ref:ls()}),i.length===0?t.jsx(ge,{children:"No assets"}):t.jsx("div",{className:Je.list,children:i.map(c=>t.jsx("button",{type:"button",className:Je.item,onClick:()=>s(c.denom),children:o(c,l=>{const{denom:d,logoUrl:m,symbol:u,name:h,balance:f,decimals:g,value:p=0}=l;return t.jsxs(t.Fragment,{children:[t.jsx(ne,{src:m,width:32,height:32,className:Je.logo,logo:!0}),t.jsxs("div",{className:Je.info,children:[t.jsx("div",{className:Je.symbol,children:u||d}),t.jsx("div",{className:Je.name,children:h})]}),t.jsxs("div",{className:Je.balance,children:[f&&t.jsx("div",{children:b.formatAmount(f,{decimals:g})}),p>0&&t.jsx("div",{className:Je.value,children:ee(p)})]})]})})},c.denom))})]})},Ep=()=>t.jsxs("div",{className:Je.container,children:[t.jsx(us,{rootClassName:Je.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(ge,{children:"Loading..."})]});ms.Placeholder=Ep;const Mp="_stack_16oqn_1",Lp="_title_16oqn_9",qp="_grid_16oqn_16",Pp="_item_16oqn_22",Dp="_button_16oqn_26",Rp="_active_16oqn_44",yn={stack:Mp,title:Lp,grid:qp,item:Pp,button:Dp,active:Rp},tn=({label:e,chains:n,value:s,onSelect:o,getShowIndicator:a})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:yn.title,children:e}),t.jsx("div",{className:yn.grid,children:n.map(({chainId:r,name:i,logoUrl:c})=>t.jsx(lc,{offset:-2,disabled:!a?.(r),className:yn.item,children:t.jsx(ds,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:q(yn.button,{[yn.active]:r===s}),onClick:()=>o(r),children:t.jsx(ne,{src:c,width:28,height:28,logo:!0})})})},r))})]}),Bp=({children:e})=>t.jsx("div",{className:yn.stack,children:e});tn.Stack=Bp;const Fp=({address:e,chain:n,onSelect:s})=>{const o=Ps(n.chain_id),{data:a={}}=ja(e,n.chain_id);return t.jsx(ms,{assets:$.sortWith([$.descend(r=>r.symbol==="INIT"),$.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>V(i).comparedTo(r)??0,$.ascend(r=>r.symbol.toLowerCase())],o.filter(r=>!r.hidden).map(r=>{const{denom:i,symbol:c=b.truncate(i),logo_uri:l}=r,d=a[i]??{};return{...r,symbol:c,decimals:r.decimals??0,logoUrl:l??"",name:r.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:s})},Up=({type:e,afterSelect:n})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=Bt(),i=cs(),{watch:c,setValue:l}=Ft(),d=c(a),m=c(s),u=c(o),[h,f]=x.useState(m),g=et(h),p=gg(),_=zi(),[y,j]=$.partition(w=>_(w.chain_id),i.filter(w=>!w.hidden)),C=w=>{if(m===h&&u===w){n();return}l(s,h),l(o,w),n()};return t.jsxs(t.Fragment,{children:[t.jsxs(tn.Stack,{children:[t.jsx(tn,{label:"Interwoven Economy",chains:y.map(({chain_id:w,chain_name:I,pretty_name:A,logo_uri:L})=>({chainId:w,name:A||I,logoUrl:L??""})),value:h,onSelect:f}),t.jsx(tn,{label:"Chains",chains:j.map(({chain_id:w,chain_name:I,pretty_name:A,logo_uri:L})=>({chainId:w,name:A||I,logoUrl:L??""})),value:h,onSelect:f})]}),t.jsx(fe,{suspenseFallback:t.jsx(ms.Placeholder,{}),children:t.jsx(Fp,{address:p({initialAddress:d,initialChainId:m,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:g,onSelect:C})},h)]})},ir=({type:e})=>{const n=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=Ft(),r=a(n),i=a(s),c=et(r),l=pt(i,r);return t.jsx(Nn,{title:o,content:d=>t.jsx(Up,{type:e,afterSelect:d}),children:t.jsx(_c,{asset:{denom:l.denom,decimals:l.decimals??0,symbol:l.symbol,logoUrl:l.logo_uri??""},chain:{chainId:c.chain_id,name:c.pretty_name||c.chain_name,logoUrl:c.logo_uri??""}})})},Op="_skeleton_1l4jn_1",Vp={skeleton:Op},nn=({width:e="100%",height:n})=>t.jsx("div",{className:Vp.skeleton,style:{width:e,height:n}}),Kp="_stack_oq1ir_1",Wp="_button_oq1ir_6",zp="_isLoading_oq1ir_19",Hp="_disabled_oq1ir_19",Gp="_checked_oq1ir_23",Qp="_header_oq1ir_37",Yp="_title_oq1ir_43",Zp="_duration_oq1ir_52",Jp="_warning_oq1ir_62",Xp="_amount_oq1ir_66",e_="_value_oq1ir_67",Ze={stack:Kp,button:Wp,isLoading:zp,disabled:Hp,checked:Gp,header:Qp,title:Yp,duration:Zp,warning:Jp,amount:Xp,value:e_},t_=({children:e})=>t.jsx("div",{className:Ze.stack,children:e}),Is=({label:e,query:n,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=n,{watch:c}=Ft(),{dstChainId:l,dstDenom:d}=c(),m=pt(d,l),u=!i&&a.checked,h=!i&&!r;return t.jsxs("button",{type:"button",className:q(Ze.button,{[Ze.isLoading]:i,[Ze.disabled]:h,[Ze.checked]:u}),onClick:()=>{i||h||o(s)},children:[t.jsxs("div",{className:Ze.header,children:[t.jsxs("div",{className:Ze.title,children:[t.jsx("span",{children:e}),u&&t.jsx(S.IconCheck,{size:14})]}),i?t.jsx(nn,{width:80,height:16}):r?t.jsxs("div",{className:q(Ze.duration,{[Ze.warning]:s==="op"}),children:[t.jsx(S.IconClockFilled,{size:12}),t.jsx("span",{children:Jn(r.estimated_route_duration_seconds)})]}):t.jsx("div",{className:Ze.duration,children:"Not available"})]}),(i||r)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Ze.amount,children:i?t.jsx(nn,{width:260,height:40}):r?b.formatAmount(r.amount_out,{decimals:m.decimals}):null}),t.jsx("div",{className:Ze.value,children:i?t.jsx(nn,{width:120,height:16}):r?r.usd_amount_out?ee(r.usd_amount_out):"$-":null})]})]})};Is.Stack=t_;const n_="_description_nuyvt_1",s_="_presets_nuyvt_8",o_="_preset_nuyvt_8",a_="_active_nuyvt_29",r_="_custom_nuyvt_40",i_="_wrapper_nuyvt_47",c_="_percent_nuyvt_58",mt={description:n_,presets:s_,preset:o_,active:a_,custom:r_,wrapper:i_,percent:c_},cr=["0.1","0.5","1.0"],l_=({afterConfirm:e})=>{const n=Ft(),s=n.getValues("slippagePercent"),[o,a]=x.useState(null),{control:r,watch:i,getValues:c,setValue:l}=we.useForm({defaultValues:{value:s}}),d=i("value");x.useEffect(()=>{const p=cr.findIndex(_=>_===s);a(p>=0?p:null)},[s]);const m=(p,_)=>{l("value",p),a(_)},u=()=>{a(null)},h=x.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),f=h?.type==="error",g=({value:p})=>{n.setValue("slippagePercent",p),e()};return t.jsxs(lt,{children:[t.jsx("p",{className:mt.description,children:"Slippage is how much price movement you can tolerate between the time you send out a transaction and the time it's executed."}),t.jsxs("div",{className:mt.presets,children:[cr.map((p,_)=>t.jsxs("button",{type:"button",className:q(mt.preset,{[mt.active]:o===_}),onClick:()=>m(p,_),children:[p,"%"]},p)),o!==null?t.jsx("button",{type:"button",className:q(mt.preset,mt.custom),onClick:()=>a(null),children:"Custom"}):t.jsxs("div",{className:mt.wrapper,children:[t.jsx(gc,{name:"value",control:r,dp:2,onFocus:u,placeholder:"",className:q(mt.preset,mt.active)}),t.jsx("span",{className:mt.percent,children:"%"})]})]}),h&&t.jsx(_e,{level:h.type,children:h.text}),t.jsx(je,{children:t.jsx(de.White,{type:"button",onClick:()=>g(c()),disabled:f,children:"Confirm"})})]})},d_="_form_1owk5_1",u_="_arrow_1owk5_5",m_="_divider_1owk5_14",h_="_flip_1owk5_23",f_="_meta_1owk5_41",g_="_row_1owk5_54",p_="_title_1owk5_60",__="_description_1owk5_64",x_="_icon_1owk5_71",y_="_edit_1owk5_76",b_="_warning_1owk5_99",Fe={form:d_,arrow:u_,divider:m_,flip:h_,meta:f_,row:g_,title:p_,description:__,icon:x_,edit:y_,warning:b_},w_=()=>{const e=Ie(),n=so(),[s,o]=Be.useLocalStorage(ie.BRIDGE_ROUTE_TYPE,"default"),{watch:a,setValue:r,handleSubmit:i,formState:c}=Ft(),l=a(),{srcChainId:d,srcDenom:m,dstChainId:u,dstDenom:h,quantity:f,sender:g,slippagePercent:p}=l,_=Ke(),y=et(d),j=Qn(y),C=et(u),w=Qn(C),I=pt(m,d),A=pt(h,u),{data:L}=ja(g,d),E=Gg(g,d,m),k=!E?.amount||V(E.amount).isZero(),[M]=Be.useDebounceValue(f,300),v=j!=="initia"&&w!=="initia",N=Zg(),B=Ko(M,{disabled:v}),R=Ko(M,{isOpWithdraw:!0,disabled:!N}),P=N&&s==="op",F=P?R:B,Q=P?B:R,U=P?!v:N,K=F.error&&U?Q:F,{data:W,isLoading:ye,isFetching:pe,error:$e}=K,{data:Ae}=Yg($e),St=M&&(ye||pe),Ot=()=>{r("srcChainId",u),r("srcDenom",h),r("dstChainId",d),r("dstDenom",m),r("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:mn,closeModal:Tt}=Js(),ze=i(Y=>{if(W?.warning){const{type:me="",message:bt}=W.warning??{};mn({content:t.jsx(mc,{type:"warning",icon:t.jsx(S.IconWarningFilled,{size:40}),title:Os.sentenceCase(me),primaryButton:{label:"Cancel",onClick:Tt},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:W,values:Y}),Tt()}},children:t.jsx("p",{className:Fe.warning,children:bt})})});return}e("/bridge/preview",{route:W,values:Y})}),Ee=x.useMemo(()=>W?.estimated_fees?.filter(({fee_behavior:Y})=>Y==="FEE_BEHAVIOR_DEDUCTED")??[],[W]),dt=x.useMemo(()=>W?.estimated_fees?.filter(({fee_behavior:Y})=>Y==="FEE_BEHAVIOR_ADDITIONAL")??[],[W]),re=x.useMemo(()=>{for(const Y of dt){const me=L?.[Y.origin_asset.denom]?.amount??"0",bt=W?.source_asset_denom===Y.origin_asset.denom?W.amount_in:"0";if(V(me).lt(V(bt).plus(Y.amount??"0")))return`Insufficient ${Y.origin_asset.symbol} for fees`}},[L,W,dt]),He=x.useMemo(()=>{if(!l.sender)return"Connect wallet";if(!l.quantity||!M)return"Enter amount";if(!l.recipient)return"Enter recipient address";if(c.errors.quantity)return c.errors.quantity.message;if(!W)return"Route not found";if(re)return re},[M,re,c,W,l]),Tn=W?b.formatAmount(W.amount_out,{decimals:A.decimals}):"0",$n=V(f).gt(0)&&V(f).isEqualTo(b.fromBaseUnit(E?.amount,{decimals:E?.decimals??0})),Mn=(()=>{switch(j){case"initia":return _(d).fees.fee_tokens.some(({denom:Y})=>Y===m);case"cosmos":return y.fee_assets.some(({denom:Y})=>Y===m);case"evm":return!ft.isAddress(m);default:return!1}})(),Vt=x.useCallback((Y,me)=>Y.length?t.jsxs("div",{className:Fe.description,children:[va(Y),!n&&t.jsx(ds,{label:me,children:t.jsx("span",{className:Fe.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]}):null,[n]),Ge=V(f).gt(0)&&N&&B.data&&R.data&&R.data.estimated_route_duration_seconds>B.data.estimated_route_duration_seconds,tt=x.useMemo(()=>W?[{condition:!!W.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Vt(Ee,"Fee deducted from the amount you receive"),Vt(dt,"Fee charged in addition to the amount you enter")]})},{condition:!Ge&&!!Jn(W.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:Fe.description,children:Jn(W.estimated_route_duration_seconds)})},{condition:W.does_swap,title:"Slippage",content:t.jsxs("span",{className:Fe.description,children:[t.jsxs("span",{children:[p,"%"]}),t.jsx(Nn,{title:"Slippage tolerance",content:Y=>t.jsx(l_,{afterConfirm:Y}),className:Fe.edit,children:t.jsx(S.IconSettingFilled,{size:12})})]})}].filter(Y=>Y.condition):[],[dt,Ee,Vt,W,Ge,p]);return t.jsxs("form",{className:Fe.form,onSubmit:ze,children:[t.jsx(Oo,{selectButton:t.jsx(ir,{type:"src"}),accountButton:j==="cosmos"&&t.jsx(rr,{type:"src"}),quantityInput:t.jsx(Zn,{balance:E?.amount,decimals:I?.decimals}),balanceButton:t.jsx(fc,{onClick:()=>r("quantity",b.fromBaseUnit(E?.amount,{decimals:I?.decimals??0}),{shouldValidate:!0}),disabled:k,children:b.formatAmount(E?.amount??"0",{decimals:I.decimals})}),value:W?ee(W.usd_amount_in):"$-"}),t.jsxs("div",{className:Fe.arrow,children:[t.jsx("div",{className:Fe.divider}),t.jsx("button",{type:"button",className:Fe.flip,onClick:()=>Ot(),children:t.jsx(S.IconChevronDown,{size:16})})]}),t.jsx(Oo,{selectButton:t.jsx(ir,{type:"dst"}),accountButton:t.jsx(rr,{type:"dst"}),quantityInput:t.jsx(Zn.ReadOnly,{children:Tn}),value:W?ee(W.usd_amount_out):"$-",hideNumbers:Ge}),t.jsx(Yn,{children:Ge?t.jsxs(Is.Stack,{children:[t.jsx(Is,{label:"Fast",query:B,value:"default",onSelect:o,checked:s==="default"}),t.jsx(Is,{label:"Lossless",query:R,value:"op",onSelect:o,checked:s==="op"})]}):null}),t.jsx(je,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(_e.Stack,{children:[W?.extra_infos?.map(Y=>t.jsx(_e,{level:"info",children:Y},Y)),Ae&&t.jsx(_e,{level:"info",children:Ae}),$n&&Mn&&t.jsx(_e,{level:"warning",children:"Make sure to leave enough for transaction fee"}),W?.warning&&t.jsx(_e,{level:"warning",children:W.warning.message}),W?.extra_warnings?.map(Y=>t.jsx(_e,{level:"warning",children:Y},Y))]}),t.jsx(Yn,{children:tt.length>0&&t.jsx("div",{className:Fe.meta,children:tt.map((Y,me)=>t.jsxs("div",{className:Fe.row,children:[t.jsx("span",{className:Fe.title,children:Y.title}),Y.content]},me))})})]}),children:t.jsx(de.White,{loading:St&&"Simulating...",disabled:!!He,children:He??"Preview route"})})]})},j_=()=>{hc();const e=Wr(),n=Ie(),s=Bt(),o=Ju(),a=we.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:c,dstChainId:l,srcDenom:d,dstDenom:m,quantity:u,slippagePercent:h,recipient:f}=r();r((N,{name:B})=>{(B==="srcChainId"||B==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const g=dc(),p=g(c),_=g(l),j=uc()(f,l);x.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",p)},[c,p,i]),x.useEffect(()=>{j||i("recipient",_)},[_,j,i]);const{showNotification:C}=ro(),w=et(c),I=et(l),A=Ps(c),L=Ps(l),E=A.some(N=>N.denom===d),k=L.some(N=>N.denom===m);x.useEffect(()=>{A.length>0&&!E&&(i("srcDenom",A[0].denom),C({type:"info",title:`Switched to ${A[0].symbol}`,description:`The selected asset is not available on ${w.pretty_name}.`,autoHide:!0}))},[A,E,i,C,w.pretty_name]),x.useEffect(()=>{L.length>0&&!k&&(i("dstDenom",L[0].denom),C({type:"info",title:`Switched to ${L[0].symbol}`,description:`The selected asset is not available on ${I.pretty_name}.`,autoHide:!0}))},[L,k,i,C,I.pretty_name]),x.useEffect(()=>{!E||!k||(localStorage.setItem(ie.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(ie.BRIDGE_SRC_DENOM,d),localStorage.setItem(ie.BRIDGE_DST_CHAIN_ID,l),localStorage.setItem(ie.BRIDGE_DST_DENOM,m),localStorage.setItem(ie.BRIDGE_QUANTITY,u),localStorage.setItem(ie.BRIDGE_SLIPPAGE_PERCENT,h))},[c,d,l,m,u,h,E,k]);const M=e[0].path==="/bridge",{reminders:v}=Sn();return t.jsx(yt,{title:"Bridge/Swap",backButton:M?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(de.Small,{onClick:()=>n("/bridge/history"),unpadded:!0,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[t.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),t.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),t.jsx(lc,{offset:0,disabled:v.length===0,children:t.jsx(de.Small,{onClick:()=>n("/op/withdrawals"),disabled:!s,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:E&&k&&t.jsx(we.FormProvider,{...a,children:t.jsx(fe,{children:t.jsx(w_,{})})})})},v_="_button_1crvp_1",C_="_checkbox_1crvp_11",N_="_checked_1crvp_25",js={button:v_,checkbox:C_,checked:N_},k_=({checked:e,onClick:n,label:s,className:o})=>t.jsxs("button",{type:"button",className:q(js.button,o),onClick:n,children:[t.jsx("div",{className:q(js.checkbox,{[js.checked]:e}),children:e&&t.jsx(S.IconCheck,{size:12})}),t.jsx("span",{className:js.label,children:s})]}),I_="_button_aoxv2_1",A_={button:I_},xc=({onClick:e,disabled:n})=>{const{ref:s,inView:o}=nl.useInView();return x.useEffect(()=>{o&&e()},[o,e]),t.jsxs("button",{className:A_.button,onClick:e,disabled:n,ref:s,children:[t.jsx("span",{children:"Load more"}),t.jsx(S.IconChevronDown,{size:12})]})};function yc(e,n){return e.reduce((s,o)=>{const a=n(o);if(!a)return s;const r=a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=s[r]||[];return{...s,[r]:[...i,o]}},{})}const As=({chainId:e,txHash:n})=>`${ie.BRIDGE_HISTORY}:${e}:${n}`,Bs=100,lr=10;function bc(){const[e,n]=Be.useLocalStorage(ie.BRIDGE_HISTORY,[]),s=x.useCallback((a,r)=>{localStorage.setItem(As(a),JSON.stringify(r));for(const i of e.slice(Bs-1))localStorage.removeItem(As(i));n((i=[])=>[a,...i.slice(0,Bs-1)])},[e,n]),o=x.useCallback(a=>{const r=localStorage.getItem(As(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function wc(e){return Be.useLocalStorage(As(e),null)}const un=ve.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,n)=>[e,n],latestOutput:e=>[e],output:(e,n)=>[e,n],outputResponse:(e,n)=>[e,n],withdrawalClaimed:(e,n)=>[e,n]});function lo(){const{restUrl:e}=oe();return x.useMemo(()=>G.create({prefixUrl:e}),[e])}function S_(e){const n=lo(),{data:s}=T.useSuspenseQuery({queryKey:un.bridge(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:z.INFINITY});return s}const dr=20;function T_(e){const n=te();return T.useSuspenseInfiniteQuery({queryKey:un.withdrawals(e,n).queryKey,queryFn:async({pageParam:s})=>{if(!n)return[];const o={limit:dr,offset:s,order:"desc"},{withdrawals:a}=await G.create({prefixUrl:e}).get(`withdrawals/${n}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=$.last(s)?.sequence;return s.length<dr||!o||o<=1?null:o-1},initialPageParam:0,staleTime:z.SECOND})}function $_(e){const n=lo(),{data:s}=T.useSuspenseQuery({queryKey:un.latestOutput(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:o})=>{const[a]=o;return a||null},staleTime:z.SECOND});return s}function E_({bridge_id:e,output_index:n}){const s=lo(),{data:o}=T.useSuspenseQuery({queryKey:un.output(e,n).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${n}`).json()}catch{return null}},staleTime:z.SECOND});return o}function M_({bridge_id:e,sequence:n}){const o=ue().find(({metadata:l})=>l?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const r=Ke()(o);if(!r)throw new Error(`Chain not found: ${o}`);const i=r.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${o}`);const{data:c}=T.useSuspenseQuery({queryKey:un.outputResponse(i,n).queryKey,queryFn:()=>G.create({prefixUrl:i}).get(`withdrawal/${n}`).json(),staleTime:z.SECOND});return c}function jc(e,n){const{bridge_id:s}=e,o=lo(),{data:a}=T.useSuspenseQuery({queryKey:un.withdrawalClaimed(s,n).queryKey,queryFn:()=>o.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:n}}).json(),select:({claimed:r})=>r,staleTime:({state:{data:r}})=>r?.claimed?1/0:z.SECOND});return a}function Bn(e){return sl.sha3_256.create().update(e).digest()}function To(e,n){const s=new ArrayBuffer(n);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function vc(e){const{bridge_id:n,sequence:s,amount:o,from:a,to:r}=e,i=To(n.toString(),8),c=To(s.toString(),8),l=To(o.amount,8),d=Jt.concatBytes(i,c,Bn(Jt.utf8ToBytes(a)),Bn(Jt.utf8ToBytes(r)),Bn(Jt.utf8ToBytes(o.denom)),l);return Bn(Bn(d))}async function L_(e,n,s){try{return await G.get(`${e}/opinit/ophost/v1/bridges/${n}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function q_(e,n){const s=G.create({prefixUrl:n}),o=`cosmos/auth/v1beta1/account_info/${e}`;for(let a=1;a<=24;a++)try{return await s.get(o).json()}catch{await new Promise(r=>setTimeout(r,5e3))}throw new Error(`Timeout: ${e} not found`)}async function Wo(e,n){const{chain_type:s,chain_id:o,chain_name:a,evm_fee_asset:r,rpc:i}=n;if(s!=="evm")throw new Error(`Chain is not an EVM chain: ${a}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}catch(c){if($.path(["error","code"],c)!==4902)throw c;if(!r)throw new Error(`Fee asset is not defined for chain: ${a}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(o).toString(16)}`,chainName:a,nativeCurrency:r,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}}function At(){return it()}function P_(e,n){const{customFee:s,onCompleted:o}=n??{},a=Ie(),{showNotification:r,updateNotification:i,hideNotification:c}=ro(),{addHistoryItem:l}=bc(),d=kn(),{route:m,values:u}=At(),{srcChainId:h,sender:f,recipient:g,cosmosWalletName:p}=u,_=hi(),{requestTxSync:y,submitTxSync:j,waitForTxConfirmation:C}=We(),{find:w}=io(),I=ns(),A=ss(),L=et(h),E=Qn(L),k=Hi(h),M=T.useQueryClient(),{registryUrl:v}=se(),N=Ke(),B=oe(),{addReminder:R}=Sn(),P=ct();return T.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const F=e.cosmos_tx.msgs.map(({msg_type_url:ze,msg:Ee})=>{if(!(ze&&Ee))throw new Error("Invalid transaction data");return A.fromAmino({type:sn.aminoConverters[ze].aminoType,value:JSON.parse(Ee)})});if(E==="initia"){const{srcDenom:ze,quantity:Ee}=u,{decimals:dt}=k(ze),re=s?await j({messages:F,chainId:h,fee:s}):await y({messages:F,chainId:h,internal:1,spendCoins:[{denom:ze,amount:b.toBaseUnit(Ee,{decimals:dt})}]}),He=C({txHash:re,chainId:h});return{txHash:re,wait:He}}const Q=w(p)?.getProvider();if(!Q)throw new Error("Wallet not connected");const U=Q.getOfflineSignerOnlyAmino(h),K=await Ce.SigningStargateClient.connectWithSigner(L.rpc,U,{registry:I,aminoTypes:A}),W=await K.getAllBalances(f),ye=L.fee_assets.find(ze=>W.some(Ee=>Ee.denom===ze.denom&&V(Ee.amount).gt(0)));if(!ye){const Ee=["Insufficient balance for fees.",`Available fee assets: ${L.fee_assets.map(dt=>k(dt.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Ee)}const{denom:pe,gas_price:$e}=ye;if(!$e)throw new Error(`Gas price not found for ${pe}`);const Ae=await K.simulate(f,F,""),St=Ce.GasPrice.fromString($e.average+pe),Ot=Ce.calculateFee(Math.ceil(Ae*on),St),mn=await K.signAndBroadcastSync(f,F,Ot),Tt=Ii({txHash:mn,client:K});return{txHash:mn,wait:Tt}}if("evm_tx"in e){const{chain_id:F,to:Q,value:U,data:K}=e.evm_tx,W=await _(),ye=await W.getSigner();await Wo(W,L);const pe=await ye.sendTransaction({chainId:F,to:Q,value:U,data:`0x${K}`});return{txHash:pe.hash,wait:pe.wait()}}throw new Error("Unlisted chain type")}catch(F){throw await Ct(F)}},onSuccess:async({txHash:F,wait:Q})=>{localStorage.removeItem(ie.BRIDGE_QUANTITY),o?o({txhash:F,chainId:h,timestamp:Date.now(),success:!0,route:m,values:u}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await Q;const U=Na(m)==="OP Bridge withdrawal",K=U?{success:!0,error:null}:await U_(P,F,h);if(!o&&!K.success&&K.error){const Ae=K.error instanceof Error?K.error.message:String(K.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${Ae}. The transaction may still be processing.`,autoHide:!0})}const W=K.success,pe=B_({txHash:F,srcChainId:h,route:m,values:u,recipient:g},W);l(pe.tx,pe.details),o||i(R_(c));const $e=$o(u,F);if(d("Bridge Transaction Success",$e),U){const Ae=N(h).metadata?.op_bridge_id;if(Ae&&!await L_(B.restUrl,Number(Ae),m.dest_asset_denom)){const Ot=F_(pe.tx,m,g);R(pe.tx,Ot)}}}catch(U){const K=U instanceof Error?U.message:String(U);o?o({success:!1,error:K,route:m,values:u}):i({type:"error",title:"Transaction not confirmed",description:K});const W={...$o(u,F),error:K};d("Bridge Confirmation Failed",W)}finally{M.invalidateQueries({queryKey:Re.balances(h,f).queryKey})}},onError:async F=>{const Q=E==="initia"?await _n(F,N(h),v):F;o?o({success:!1,error:Q.message,route:m,values:u}):r({type:"error",title:"Transaction failed",description:Q.message});const U=$o(u);d("Bridge Transaction Failed",{...U,error:Q.message})}})}function D_(){const e=ct(),n=te(),s=ui(),{route:o,values:a}=At(),r=It();return T.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:c}=await e.post("op-hook",{json:{source_address:n,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:b.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await q_(n,r(o.dest_asset_chain_id).rest);const l=c.map(({msg_type_url:u,msg:h})=>sn.aminoTypes.fromAmino({type:sn.aminoConverters[u].aminoType,value:JSON.parse(h)})),d=await s(i,n,l,{amount:[],gas:"1"},"",{incrementSequence:i===a.srcChainId?2:0}),m=Ue.Tx.fromPartial({body:Ue.TxBody.decode(d.bodyBytes),authInfo:Ue.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:n,hook:ae.toBase64(Ue.Tx.encode(m).finish())}}catch(i){throw await Ct(i)}}})}function R_(e){return{type:"info",title:"Transaction submitted",description:x.createElement(x.Fragment,null,"Check ",x.createElement(jn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function $o(e,n){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:n}}function B_(e,n){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},c=Na(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:c?"success":void 0,tracked:n},isOpWithdraw:c}}function F_(e,n,s){return{...e,recipient:b.InitiaAddress(s).bech32,claimableAt:Date.now()+n.estimated_route_duration_seconds*1e3,amount:n.amount_out,denom:n.dest_asset_denom}}async function U_(e,n,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await Ct(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Cc(e){const{chainId:n,txHash:s,tracked:o}=e,a=ct();return T.useQuery({queryKey:Re.txTrack(n,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:n}}).json()}catch(r){throw await Ct(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:z.INFINITY,enabled:!o})}function Nc(e){const{timestamp:n,chainId:s,txHash:o,tracked:a,state:r}=e,i=ct();return T.useQuery({queryKey:Re.txStatus(s,o).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:o,chain_id:s}}).json(),enabled:!!o&&a&&!r,refetchInterval:({state:{data:c}})=>{if(!c)return!1;const{status:l}=c;if(l==="STATE_COMPLETED")return!1;const d=n+e.route.estimated_route_duration_seconds*1e3,m=Date.now(),u=Math.floor((d-m)/1e3);return u<=0?1e3:u<=300?5e3:60*1e3},staleTime:z.INFINITY})}var Ss=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(Ss||{});function Na(e){const{operations:n,dest_asset_denom:s}=e;return $.has("op_init_transfer",$.head(n))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const O_="_success_t4dfk_1",V_="_error_t4dfk_5",ur={success:O_,error:V_},K_=({tx:e})=>{const[n,s]=wc(e);if(!n)throw new Error("Bridge history details not found");const{data:o}=Nc(n),a=n.state??W_(o);switch(x.useEffect(()=>{a!=="loading"&&s(r=>{if(!r)throw new Error("Bridge history details not found");return{...r,tracked:!0,state:a}})},[s,a]),a){case"error":return t.jsx("div",{className:ur.error,children:t.jsx(S.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:ur.success,children:t.jsx(S.IconCheckCircleFilled,{size:14})});default:return t.jsx(_t,{size:14})}};function W_(e){if(!e)return"loading";switch(e.state){case"STATE_ABANDONED":case"STATE_COMPLETED_ERROR":case"STATE_PENDING_ERROR":return"error";case"STATE_COMPLETED_SUCCESS":return"success";default:return"loading"}}const z_="_link_104m3_1",H_="_header_104m3_23",G_="_title_104m3_31",Q_="_date_104m3_37",Y_="_explorer_104m3_41",Z_="_fees_104m3_57",J_="_label_104m3_65",X_="_content_104m3_69",ex="_route_104m3_75",tx="_row_104m3_80",nx="_asset_104m3_86",sx="_amount_104m3_94",ox="_chain_104m3_99",ax="_account_104m3_108",rx="_arrow_104m3_115",Ne={link:z_,header:H_,title:G_,date:Q_,explorer:Y_,fees:Z_,label:J_,content:X_,route:ex,row:tx,asset:nx,amount:sx,chain:ox,account:ax,arrow:rx},ix=({tx:e})=>{const[n,s]=wc(e);if(!n)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:c,tracked:l}=n,{data:d}=Cc(n),{address:m="",connector:u}=De.useAccount(),{find:h}=io();x.useEffect(()=>{d&&s(P=>{if(!P)throw new Error("Bridge history details not found");return{...P,tracked:!0}})},[s,d]);const{amount_in:f,amount_out:g,source_asset_chain_id:p,source_asset_denom:_,dest_asset_chain_id:y,dest_asset_denom:j,estimated_fees:C=[]}=r,w=et(p),I=et(y),A=pt(_,p),L=pt(j,y),E=(P,F)=>F?t.jsx(ne,{src:F,width:12,height:12}):b.InitiaAddress.equals(P,m)?t.jsx(ne,{src:u?.icon,width:12,height:12}):t.jsx(S.IconWallet,{size:12}),k=(P,{symbol:F,decimals:Q,logo_uri:U},{chain_name:K,pretty_name:W,...ye},pe,$e)=>t.jsxs("div",{className:Ne.row,children:[t.jsx(co,{assetLogoUrl:U,chainLogoUrl:ye.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:Ne.asset,children:[t.jsx("span",{className:Ne.amount,children:b.formatAmount(P,{decimals:Q})}),t.jsx("span",{children:F})]}),t.jsxs("div",{className:Ne.chain,children:[t.jsxs("span",{children:["on ",W||K]}),t.jsxs("div",{className:Ne.account,children:[$e,t.jsx("span",{className:"monospace",children:b.truncate(pe)})]})]})]})]}),M=Na(r),v=x.useMemo(()=>{switch(M){case Ss.SKIP:return"Skip Explorer";case Ss.OP_WITHDRAW:return"Initia Scan"}},[M]),N=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Ne.header,children:[t.jsxs("div",{className:Ne.title,children:[l?t.jsx(K_,{tx:e}):t.jsx(_t,{size:14}),t.jsx("div",{className:Ne.date,children:Ve.format(new Date(c),"h:mm a")})]}),t.jsxs("div",{className:Ne.explorer,children:[t.jsx("span",{children:v}),t.jsx(S.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:Ne.route,children:[k(f,A,w,i.sender,E(i.sender,h(i.cosmosWalletName)?.image)),t.jsx("div",{className:Ne.arrow,children:t.jsx(S.IconArrowDown,{size:12})}),k(g,L,I,i.recipient,E(i.recipient))]}),C.length>0&&t.jsxs("div",{className:Ne.fees,children:[t.jsx("span",{className:Ne.label,children:"Fees"}),t.jsx("span",{className:Ne.content,children:va(C)})]})]});if(M===Ss.OP_WITHDRAW)return t.jsx(ao,{chainId:o,txHash:a,className:Ne.link,children:N});const B=new URLSearchParams({tx_hash:a,chain_id:o}),R=new URL(`?${B.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:R.toString(),className:Ne.link,target:"_blank",children:N})},cx="_history_13u9z_1",lx="_header_13u9z_5",dx="_checkbox_13u9z_9",ux="_groups_13u9z_13",mx="_dateGroup_13u9z_21",hx="_dateHeader_13u9z_26",fx="_list_13u9z_32",Gt={history:cx,header:lx,checkbox:dx,groups:ux,dateGroup:mx,dateHeader:hx,list:fx},gx=()=>{const{initiaAddress:e,hexAddress:n}=We(),{history:s,getHistoryDetails:o}=bc(),a=s.filter(f=>o(f)),r=a.filter(f=>{const g=o(f);if(!g)return!1;const{values:p}=g,{sender:_,recipient:y}=p;return[_,y].some(j=>[e,n].includes(j))}),[i,c]=x.useState(1),[l,d]=Be.useToggle(!r.length),m=l?a:r,u=m.slice(0,i*lr),h=x.useMemo(()=>yc(u,f=>{const g=o(f);if(g)return new Date(g.timestamp)}),[u,o]);return t.jsx(yt,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:Gt.history,children:[a.length>0&&a.length!==r.length&&t.jsx("header",{className:Gt.header,children:t.jsx(k_,{checked:l,onClick:d,label:"Show all transactions stored in this browser",className:Gt.checkbox})}),m.length===0?t.jsx(ge,{children:"No bridge/swap activity"}):t.jsx("div",{className:Gt.groups,children:Object.entries(h).map(([f,g])=>t.jsxs("div",{className:Gt.dateGroup,children:[t.jsx("div",{className:Gt.dateHeader,children:f}),t.jsx("div",{className:Gt.list,children:g.map(p=>t.jsx(fe,{children:t.jsx(ix,{tx:p})},p.txHash))})]},f))}),m.length>i*lr?t.jsx(xc,{onClick:()=>c(f=>f+1)}):s.length>=Bs&&t.jsxs(ge,{children:["Only the latest ",Bs," items are stored. Older entries will be removed automatically."]})]})})},ka=({tx:e,fee:n,onCompleted:s,confirmMessage:o,error:a})=>{const{mutate:r,isPending:i}=P_(e,{customFee:n,onCompleted:s});return t.jsx(je,{children:t.jsx(de.White,{onClick:()=>r(),loading:i&&"Signing transaction...",disabled:!!a,children:a||o||"Confirm"})})},px="_content_1hzj2_1",_x="_info_1hzj2_6",xx="_arrow_1hzj2_11",yx="_divider_1hzj2_19",bx="_type_1hzj2_27",wx="_asset_1hzj2_47",jx="_amount_1hzj2_55",vx="_lower_1hzj2_60",Cx="_chain_1hzj2_66",Nx="_address_1hzj2_72",Ye={content:px,info:_x,arrow:xx,divider:yx,type:bx,asset:wx,amount:jx,lower:vx,chain:Cx,address:Nx},kc=e=>{const{source:n,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:c}=e,{symbol:l=b.truncate(a),decimals:d=0,logo_uri:m=ta}=e,{chain_name:u,pretty_name:h,...f}=et(r);return t.jsxs("div",{children:[!n&&t.jsxs("div",{className:Ye.arrow,children:[t.jsx("div",{className:Ye.divider}),s?t.jsx(ds,{label:s,children:t.jsx("button",{className:Ye.type,children:t.jsx(S.IconArrowDown,{size:12})})}):t.jsx("span",{className:Ye.type,children:t.jsx(S.IconArrowDown,{size:12})}),t.jsx("div",{className:Ye.divider})]}),t.jsxs("div",{className:Ye.content,children:[t.jsx(co,{assetLogoUrl:m,chainLogoUrl:f.logo_uri??void 0}),t.jsxs("div",{className:Ye.info,children:[t.jsxs("div",{className:Ye.asset,children:[t.jsx("span",{className:Ye.amount,children:b.formatAmount(o,{decimals:d})}),t.jsx("span",{children:l})]}),t.jsxs("div",{className:Ye.lower,children:[t.jsxs("div",{className:Ye.chain,children:["on ",h||u]}),i&&t.jsx(Ds,{value:i,children:({copy:g,copied:p})=>t.jsxs("button",{className:Ye.address,onClick:g,children:[c,p?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:b.truncate(i)})]})})]})]})]})]})},bn=e=>{const n=pt(e.denom,e.chainId);return t.jsx(kc,{...e,...n})};bn.Placeholder=kc;const kx="_root_1hbar_1",Ix="_flexEnd_1hbar_6",Ax="_toggle_1hbar_11",Sx="_route_1hbar_36",Tx="_content_1hbar_43",Fn={root:kx,flexEnd:Ix,toggle:Ax,route:Sx,content:Tx};function $x(e){const n=({name:s})=>s==="initia-dex"?"Initia DEX":Os.capitalCase($.head(s?.split("-")??[])??"");if("transfer"in e)return{label:"Bridge via IBC",...e,...e.transfer};if("bank_send"in e)return{label:"Send",...e,...e.bank_send};if("swap"in e){const s=e.swap?.swap_venues?.map(n).join(", ");return{label:s?`Swap on ${s}`:"Swap",...e,...e.swap}}if("axelar_transfer"in e)return{label:"Bridge via Axelar",...e,...e.axelar_transfer};if("cctp_transfer"in e)return{label:"Bridge via CCTP",...e,...e.cctp_transfer};if("hyperlane_transfer"in e)return{label:"Bridge via Hyperlane",...e,...e.hyperlane_transfer};if("evm_swap"in e){const s=e.evm_swap?.swap_venues?.map(n).join(", ");return{label:s?`Swap on ${s}`:"Swap",...e,...e.evm_swap}}if("op_init_transfer"in e)return{label:"Bridge via OP Bridge",...e,...e.op_init_transfer};if("go_fast_transfer"in e)return{label:"Bridge via Go Fast",...e,...e.go_fast_transfer};if("eureka_transfer"in e)return{label:"Bridge via Eureka",...e,...e.eureka_transfer};if("stargate_transfer"in e)return{label:"Bridge via Stargate",...e,...e.stargate_transfer};if("layer_zero_transfer"in e)return{label:"Bridge via LayerZero",...e,...e.layer_zero_transfer};throw new Error("Unknown operation type")}const Ex=({addressList:e})=>{const{values:n,route:s}=At(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,c=$.zipObj(s.required_chain_addresses,e),{find:l}=io(),{connector:d,address:m=""}=De.useAccount(),[u,h]=Be.useToggle(!1),f=i.length>1,g=t.jsx(ne,{src:n.cosmosWalletName?l(n.cosmosWalletName)?.image:d?.icon,width:12,height:12}),p={amount:r,denom:o,chainId:a,address:n.sender,walletIcon:g},_=I=>b.InitiaAddress.equals(I,m)?g:t.jsx(S.IconWallet,{size:11}),y=I=>{const{label:A,amount_out:L,denom:E,denom_out:k=E,chain_id:M,from_chain_id:v,to_chain_id:N=M??v}=I,B=c[N];return{label:f&&!u?void 0:A,amount:L,denom:k,chainId:N,address:B,walletIcon:_(B)}},j=i.map($x).map(y),C=j.slice(0,-1),w=j[j.length-1];return t.jsxs(J.Collapsible.Root,{className:Fn.root,open:u,onOpenChange:h,children:[f&&t.jsx("div",{className:Fn.flexEnd,children:t.jsx(J.Collapsible.Trigger,{className:Fn.toggle,children:u?t.jsxs(t.Fragment,{children:[t.jsx(S.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(S.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:Fn.route,children:[t.jsx(bn,{...p,source:!0}),t.jsx(J.Collapsible.Content,{className:Fn.content,children:C.map((I,A)=>t.jsx(fe,{suspenseFallback:t.jsx(bn.Placeholder,{...I}),errorBoundaryProps:{fallback:t.jsx(bn.Placeholder,{...I})},children:t.jsx(bn,{...I})},A))}),t.jsx(bn,{...w})]})]})},Ic=({error:e})=>{const n=Ie();return t.jsx(je,{extra:t.jsx(_e,{level:"error",children:e.message}),children:t.jsx(de.White,{onClick:()=>n("/bridge"),children:"Home"})})},Ac=({children:e})=>{const n=At(),{route:s,values:o}=n,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:d,hexAddress:m}=We(),u=os(),h=It(),f=is(),g=h(r),p=f(g),_=a.slice(0,-1).some(L=>{const E=h(L);return f(E)==="cosmos"})&&p!=="cosmos",[y,j]=x.useState(void 0),[C,w]=x.useState(!1),[I,A]=x.useState(null);if(x.useEffect(()=>{(async()=>{try{if(!_)return;if(!u)throw new Error("Wallet not connected");w(!0),A(null);const[{pubkey:E}]=await u.getAccounts();j(E)}catch(E){A(await Ct(E))}finally{w(!1)}})()},[_,u]),I)return t.jsx(Ic,{error:I});if(C)return t.jsx(je,{children:t.jsx(de.White,{loading:C&&"Generating intermediary addresses..."})});if(!_||y){const L=a.map((E,k)=>{if(k===a.length-1){const R=h(i);return f(R)==="initia"?b.InitiaAddress(l).bech32:l}const M=h(E),v=f(M),N=h(r),B=f(N);switch(v){case"initia":return d;case"evm":return m;case"cosmos":{if(B==="cosmos")return ae.toBech32(M.bech32_prefix,ae.fromBech32(c).data);if(!y)throw new Error("Pubkey not found");return Kn.pubkeyToAddress(Kn.encodeSecp256k1Pubkey(y),M.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(L)}return null},Ia=({tx:e,children:n})=>{const s=hi(),o=It(),{data:a,isLoading:r}=T.useQuery({queryKey:["erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:m,signer_address:u}=e.evm_tx,h=await s();await Wo(h,o(m));const f=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async p=>{const{token_contract:_,spender:y}=p,C=await new ft.ethers.Contract(_,f,h).allowance(u,y);return{approval:p,currentAllowance:BigInt(C.toString())}}))).filter(({approval:p,currentAllowance:_})=>_<BigInt(p.amount)).map(({approval:p})=>p)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:c,isPending:l,error:d}=T.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!a||a.length===0)throw new Error("No approvals needed");const{chain_id:m}=e.evm_tx,u=await s(),h=await u.getSigner();await Wo(u,o(m));for(const f of a){const{token_contract:g,spender:p,amount:_}=f,y=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new ft.ethers.Contract(g,y,h).approve(p,_)).wait()}return!0}catch(m){throw await Ct(m)}}});return r?t.jsx(je,{children:t.jsx(de.White,{loading:"Checking approvals..."})}):a&&a.length>0&&!c?t.jsx(je,{extra:t.jsx(_e,{level:"error",children:d?.message}),children:t.jsx(de.White,{onClick:()=>i(),loading:l&&"Approving tokens...",children:"Approve tokens"})}):n},Sc=({addressList:e,signedOpHook:n,children:s})=>{const o=ct(),{route:a,values:r}=At(),[i,c]=x.useState(void 0),[l,d]=x.useState(!1),[m,u]=x.useState(null);return x.useEffect(()=>{(async()=>{try{if(a.required_op_hook&&!n)throw new Error("Op hook is required");d(!0),u(null);const f={address_list:e,amount_in:a.amount_in,amount_out:a.amount_out,source_asset_chain_id:a.source_asset_chain_id,source_asset_denom:a.source_asset_denom,dest_asset_chain_id:a.dest_asset_chain_id,dest_asset_denom:a.dest_asset_denom,slippage_tolerance_percent:r.slippagePercent,operations:a.operations,signed_op_hook:n},{txs:g}=await o.post("v2/fungible/msgs",{json:f}).json();if(!g||g.length===0)throw new Error("No transaction data found");const[p]=g;c(p)}catch(f){u(f)}finally{d(!1)}})()},[a,r,JSON.stringify(e),n,o]),m?t.jsx(Ic,{error:m}):l||!i?t.jsx(je,{children:t.jsx(de.White,{loading:"Fetching messages..."})}):s(i)},Tc=({children:e})=>{const{route:n}=At(),s=D_();return n.required_op_hook&&!s.data?t.jsx(je,{extra:t.jsx(_e,{level:"error",children:s.error?.message}),children:t.jsx(de.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)},Mx=()=>t.jsx(yt,{title:"Route preview",children:t.jsx(Ac,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(Ex,{addressList:e}),t.jsx(Tc,{children:n=>t.jsx(Sc,{addressList:e,signedOpHook:n,children:s=>t.jsx(Ia,{tx:s,children:t.jsx(ka,{tx:s})})})})]})})}),$c=x.createContext(null);function uo(){return x.useContext($c)}const Lx="_button_17r1o_1",qx="_claimed_17r1o_24",mr={button:Lx,claimed:qx},Px=()=>{const{withdrawalTx:e}=uo(),{bridge_id:n,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:c,to:l,version:d}=e,m=oe(),u=te(),{requestTxSync:h,waitForTxConfirmation:f}=We(),g=M_(e),p=ae.toBase64(vc(e)),_=jc(e,p),y=T.useQueryClient(),{mutate:j,isPending:C}=T.useMutation({mutationFn:async()=>{if(!g)throw new Error("Output not found");const{last_block_hash:w}=g;return h({chainId:m.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:u,bridgeId:BigInt(n),outputIndex:BigInt(a),withdrawalProofs:r.map(ae.fromBase64),from:c,to:l,sequence:BigInt(s),amount:o,version:ae.fromBase64(d),storageRoot:ae.fromBase64(i),lastBlockHash:ae.fromBase64(w)}}],internal:!0})},onSuccess:async w=>{await f({chainId:m.chain_id,txHash:w}),y.invalidateQueries({queryKey:un.withdrawalClaimed(n,p).queryKey})}});return _?t.jsxs("div",{className:mr.claimed,children:[t.jsx(S.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:mr.button,onClick:()=>j(),disabled:C,children:"Claim"})},Dx=({children:e})=>{const{withdrawalTx:n}=uo(),s=S_(n.bridge_id),o=E_(n),a=x.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Ve.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},Ec=1e3,Rx=60,Bx=60,Fx=24,zo=Ec*Rx,Ho=zo*Bx,hr=Ho*Fx,Ux=({date:e})=>{const n=x.useCallback(()=>{const d=new Date().getTime(),u=e.getTime()-d;if(u<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(u/hr),f=Math.floor(u%hr/Ho),g=Math.floor(u%Ho/zo),p=Math.floor(u%zo/Ec);return{days:h,hours:f,minutes:g,seconds:p}},[e]),[s,o]=x.useState(n());x.useEffect(()=>{const d=window.setInterval(()=>{o(n())},1e3);return()=>window.clearInterval(d)},[n,e]);const a=d=>d.toString().padStart(2,"0"),{days:r,hours:i,minutes:c,seconds:l}=s;return t.jsx(ds,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(c),"m ",a(l),"s"]})})},Ox="_container_1lz3w_1",Vx="_title_1lz3w_5",fr={container:Ox,title:Vx},Kx=({date:e})=>t.jsxs("div",{className:fr.container,children:[t.jsx("div",{className:fr.title,children:"Claimable in"}),t.jsx(Ux,{date:e})]}),Wx="_container_1oldz_1",zx="_icon_1oldz_7",gr={container:Wx,icon:zx},Hx="Withdrawal will begin within an hour",pr=()=>{const e=so();return t.jsxs("div",{className:gr.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(ds,{label:Hx,children:t.jsx("span",{className:gr.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]})},Gx=({children:e})=>{const{withdrawalTx:n}=uo(),s=$_(n.bridge_id),o=n.output_index>Number(s?.output_index);return e(o)},Qx=({date:e,children:n})=>{const{chainId:s,withdrawalTx:o}=uo(),a=ae.toBase64(vc(o)),r=jc(o,a),{setReminder:i,removeReminder:c}=Sn();return x.useEffect(()=>{const l={chainId:s,txHash:o.tx_hash};r?c(l):i(l,{...l,recipient:o.to,claimableAt:e.getTime(),amount:o.amount.amount,denom:o.amount.denom,dismissed:Ve.isPast(e.getTime())?!0:void 0})},[s,r,e,c,i,o]),n},Yx=()=>t.jsx(Gx,{children:e=>e?t.jsx(pr,{}):t.jsx(Dx,{children:n=>n?t.jsx(Qx,{date:n,children:Ve.isFuture(n)?t.jsx(Kx,{date:n}):t.jsx(Px,{})}):t.jsx(pr,{})})}),Zx="_asset_6h8u2_1",Jx="_info_6h8u2_7",Xx="_symbol_6h8u2_11",Eo={asset:Zx,info:Jx,symbol:Xx},ey=({amount:e,denom:n})=>{const s=oe(),o=Br(n,s),{symbol:a,logoUrl:r,decimals:i}=o;return t.jsxs("div",{className:Eo.asset,children:[t.jsx(ne,{src:r,width:32,height:32,logo:!0}),t.jsxs("div",{className:Eo.info,children:[t.jsx("span",{className:"monospace",children:b.formatAmount(e,{decimals:i})}),t.jsx("span",{className:Eo.symbol,children:a})]})]})},ty="_item_km5w2_1",ny={item:ty},sy=({chain:e})=>{const n=e.metadata?.executor_uri;if(!n)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:o,hasNextPage:a,isFetching:r}=T_(n),i=x.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:c}=Sn();return x.useEffect(()=>{const l=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));c(l)},[e.chainId,i,c]),i.length?t.jsxs(t.Fragment,{children:[i.map(l=>{const{amount:d}=l;return t.jsxs("div",{className:ny.item,children:[t.jsx(ey,{...d}),t.jsx(fe,{suspenseFallback:null,children:t.jsx($c.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:t.jsx(Yx,{})})})]},l.sequence)}),a&&t.jsx(xc,{onClick:()=>o(),disabled:r})]}):t.jsx(ge,{children:"No withdrawals"})},oy="_content_dj1qm_1",ay="_title_dj1qm_5",_r={content:oy,title:ay},ry=()=>{const{chainId:e}=it(),n=ue(),s=cn(),[o,a]=x.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=Ke(),{reminders:i}=Sn(),c=o?r(o):void 0;return t.jsxs(yt,{title:"OP Bridge withdrawals",children:[t.jsx(tn,{chains:n.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:l=>i.some(d=>d.chainId===l)}),t.jsx("div",{className:_r.content,children:c?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:_r.title,children:c.name}),t.jsx(fe,{children:t.jsx(sy,{chain:c})},o)]}):t.jsx(_e,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},Fs=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),iy="5722e7dffb709492cf5312446ceeff73",cy=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${iy}`,Mc=["walletconnect-wallets"],ly=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",Lc=async e=>{const n=await G.get(cy,{signal:e}).json(),s=n!==null&&typeof n=="object"&&"listings"in n?n.listings:n;return Object.values(s??{}).filter(ly)},dy=()=>T.useQuery({queryKey:Mc,queryFn:({signal:e})=>Lc(e),staleTime:z.INFINITY,gcTime:z.INFINITY,retry:2}),uy="_page_13y8q_1",my="_pageTop_13y8q_19",hy="_backButtonFixed_13y8q_63",fy="_listItem_13y8q_64",gy="_socialButton_13y8q_65",py="_arrowIcon_13y8q_66",_y="_searchInputUnderline_13y8q_67",xy="_header_13y8q_72",yy="_title_13y8q_81",by="_headerSpacer_13y8q_116",wy="_icon_13y8q_120",jy="_installedText_13y8q_124",vy="_divider_13y8q_131",Cy="_dividerText_13y8q_152",Ny="_loading_13y8q_193",ky="_socialIcons_13y8q_198",Iy="_socialText_13y8q_204",Ay="_searchWrapper_13y8q_214",Sy="_scrollable_13y8q_248",Ty="_list_13y8q_64",$y="_listIconWrapper_13y8q_332",Ey="_moreIconSmall_13y8q_342",My="_externalLinkIcon_13y8q_364",Ly="_listName_13y8q_368",qy="_listNameMuted_13y8q_381",Py="_recentBadge_13y8q_394",Dy="_learnMoreLink_13y8q_408",O={page:uy,pageTop:my,backButtonFixed:hy,listItem:fy,socialButton:gy,arrowIcon:py,searchInputUnderline:_y,header:xy,title:yy,headerSpacer:by,icon:wy,installedText:jy,divider:vy,dividerText:Cy,loading:Ny,socialIcons:ky,socialText:Iy,searchWrapper:Ay,scrollable:Sy,list:Ty,listIconWrapper:$y,moreIconSmall:Ey,externalLinkIcon:My,listName:Ly,listNameMuted:qy,recentBadge:Py,learnMoreLink:Dy},Ry=e=>{try{const n=new URL(e.trim());return n.protocol==="https:"&&!n.username&&!n.password}catch{return!1}},By=({walletConnectors:e,isPending:n,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,c]=x.useState(""),{data:l=[],isError:d,isLoading:m,isFetching:u}=dy(),h=m||u&&l.length===0,f=x.useMemo(()=>{if(!i)return e;const p=i.toLowerCase();return e.filter(_=>_.name.toLowerCase().includes(p))},[e,i]),g=x.useMemo(()=>{const p=new Set(e.map(y=>Fs(y.name))),_=i.toLowerCase();return l.filter(y=>!p.has(Fs(y.name))).filter(y=>!i||y.name.toLowerCase().includes(_)).sort((y,j)=>y.name.localeCompare(j.name))},[l,e,i]);return t.jsxs("div",{className:O.pageTop,children:[t.jsx("button",{type:"button",className:O.backButtonFixed,onClick:r,"aria-label":"Back",children:t.jsx(S.IconBack,{size:16,"aria-hidden":"true"})}),t.jsxs("header",{className:O.header,children:[t.jsx("div",{className:O.headerSpacer}),t.jsx("h1",{className:O.title,children:"All Wallets"}),t.jsx("div",{className:O.headerSpacer})]}),t.jsx("div",{className:O.searchWrapper,children:t.jsx(us,{rootClassName:O.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:p=>c(p.target.value),onClear:()=>c("")})}),t.jsx(lt,{className:O.scrollable,children:t.jsxs("div",{className:O.list,children:[f.map(p=>{const{name:_,icon:y,id:j}=p,C=o===j,w=s===j,I="ready"in p?!!p.ready:!0;return t.jsxs("button",{type:"button",className:q(O.listItem,{[O.loading]:w}),onClick:()=>a(p),disabled:n||!I,"aria-busy":w,children:[t.jsx("div",{className:O.listIconWrapper,children:t.jsx(ne,{src:y,width:26,height:26,alt:"",className:O.icon})}),t.jsx("span",{className:O.listName,children:_}),w?t.jsx(_t,{size:16}):C?t.jsx("span",{className:O.recentBadge,children:"Recent"}):I?t.jsx("span",{className:O.installedText,children:"Installed"}):null]},`connector:${j}`)}),h&&t.jsxs("div",{className:q(O.listItem,O.loading),role:"status","aria-live":"polite",children:[t.jsx("div",{className:O.listIconWrapper,children:t.jsx(_t,{size:16})}),t.jsx("span",{className:O.listNameMuted,children:"Loading more wallets..."})]}),g.map(p=>{const _=p.image_url?.sm||p.image_url?.md||p.image_url?.lg,y=_&&Ry(_)?_:void 0;return t.jsxs("button",{type:"button",className:O.listItem,disabled:!0,"aria-label":`${p.name} (not installed)`,children:[t.jsx("div",{className:O.listIconWrapper,children:y&&t.jsx(ne,{src:y,width:26,height:26,alt:"",className:O.icon})}),t.jsx("span",{className:O.listNameMuted,children:p.name})]},`wc:${p.id}`)}),d&&t.jsx(_e,{level:"error",children:"Couldn't load additional wallets."})]})})]})},Fy=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[t.jsx("circle",{cx:"4",cy:"8",r:"1.5"}),t.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),t.jsx("circle",{cx:"12",cy:"8",r:"1.5"})]}),Uy=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),t.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),t.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),t.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),Oy=()=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),Vy=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),Ky=[{id:"io.rabby",name:"Rabby",icon:"https://assets.initia.xyz/images/wallets/Rabby.webp",url:"https://rabby.io"},{id:"app.phantom",name:"Phantom",icon:"https://assets.initia.xyz/images/wallets/Phantom.webp",url:"https://phantom.com"},{id:"app.keplr",name:"Keplr",icon:"https://assets.initia.xyz/images/wallets/Keplr.webp",url:"https://keplr.app"},{id:"io.leapwallet",name:"Leap",icon:"https://assets.initia.xyz/images/wallets/Leap.webp",url:"https://leapwallet.io"},{id:"io.metamask",name:"MetaMask",icon:"https://assets.initia.xyz/images/wallets/MetaMask.webp",url:"https://metamask.io"}],Wy=({walletConnectors:e,privyConnector:n,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:c})=>{const l=e.filter(g=>!("ready"in g)||!!g.ready),d=l.slice(0,5),m=new Set(l.map(g=>g.id)),u=new Set(l.map(g=>Fs(g.name))),h=Math.max(0,5-d.length),f=Ky.filter(g=>!m.has(g.id)&&!u.has(Fs(g.name))).slice(0,h);return t.jsxs("div",{className:O.page,children:[t.jsxs("header",{className:O.header,children:[t.jsx("div",{className:O.headerSpacer}),t.jsx("h1",{className:O.title,children:"Sign In"}),t.jsx("div",{className:O.headerSpacer})]}),n&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:q(O.socialButton,{[O.loading]:o===n.id}),onClick:()=>r(n),disabled:s,"aria-busy":o===n.id,children:[t.jsx("span",{className:O.socialText,children:"Email / Socials"}),o===n.id?t.jsx(_t,{size:16}):t.jsxs("div",{className:O.socialIcons,children:[t.jsx(Uy,{}),t.jsx(Vy,{}),t.jsx(Oy,{})]})]}),t.jsx("div",{className:O.divider,children:t.jsx("span",{className:O.dividerText,children:"or"})})]}),t.jsx(lt,{className:O.scrollable,children:t.jsxs("div",{className:O.list,children:[d.map(g=>{const{name:p,icon:_,id:y}=g,j=o===y,C=a===y;return t.jsxs("button",{type:"button",className:q(O.listItem,{[O.loading]:j}),onClick:()=>r(g),disabled:s,"aria-busy":j,children:[t.jsx("div",{className:O.listIconWrapper,children:t.jsx(ne,{src:_,width:26,height:26,alt:"",className:O.icon})}),t.jsx("span",{className:O.listName,children:p}),j?t.jsx(_t,{size:16}):C?t.jsx("span",{className:O.recentBadge,children:"Recent"}):t.jsx("span",{className:O.installedText,children:"Installed"})]},y)}),f.map(g=>t.jsxs("a",{className:O.listItem,href:g.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${g.name} (opens in new tab)`,children:[t.jsx("div",{className:O.listIconWrapper,children:t.jsx(ne,{src:g.icon,width:26,height:26,alt:"",className:O.icon})}),t.jsx("span",{className:O.listNameMuted,children:g.name}),t.jsx(S.IconExternalLink,{size:10,className:O.externalLinkIcon,"aria-hidden":"true"})]},g.id)),t.jsxs("button",{type:"button",className:O.listItem,onClick:i,onMouseEnter:c,onFocus:c,disabled:s,children:[t.jsx("div",{className:O.listIconWrapper,children:t.jsx("div",{className:O.moreIconSmall,children:t.jsx(Fy,{})})}),t.jsx("span",{className:O.listNameMuted,children:"More wallets"}),t.jsx("span",{className:O.arrowIcon,"aria-hidden":"true",children:"→"})]})]})}),t.jsxs("a",{className:O.learnMoreLink,href:"https://docs.initia.xyz/home/tools/wallet",target:"_blank",rel:"noopener noreferrer","aria-label":"Learn more (opens in new tab)",children:["Learn more",t.jsx(S.IconExternalLink,{size:14,"aria-hidden":"true"})]})]})},xr=({onSuccess:e})=>{const{connectors:n,connectAsync:s}=De.useConnect(),o=Be.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=x.useState(null),[i,c]=x.useState("signin"),l=T.useQueryClient(),d=()=>l.prefetchQuery({queryKey:Mc,queryFn:({signal:p})=>Lc(p),staleTime:z.INFINITY,gcTime:z.INFINITY}),{mutate:m,isPending:u}=T.useMutation({mutationFn:async p=>{try{await s({connector:p})}catch(_){throw await Ct(_)}},onMutate:p=>{r(p.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),h=x.useMemo(()=>[...n].sort((p,_)=>p.id===o?-1:_.id===o?1:p.name.localeCompare(_.name)),[n,o]),f=x.useMemo(()=>h.find(p=>p.id===Wn.id),[h]),g=x.useMemo(()=>h.filter(p=>p.id!==Wn.id),[h]);return i==="all"?t.jsx(By,{walletConnectors:g,isPending:u,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onBack:()=>c("signin")}):t.jsx(Wy,{walletConnectors:g,privyConnector:f,isPending:u,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onShowAll:()=>c("all"),onPrefetchWallets:d})},zy={deposit:{mode:"deposit",label:"Deposit",local:{denomKey:"dstDenom",chainIdKey:"dstChainId"},external:{denomKey:"srcDenom",chainIdKey:"srcChainId"}},withdraw:{mode:"withdraw",label:"Withdraw",local:{denomKey:"srcDenom",chainIdKey:"srcChainId"},external:{denomKey:"dstDenom",chainIdKey:"dstChainId"}}};function hs(e){return zy[e]}function Aa(){const e=ct(),n=An(),s=te(),o=cs(),a=Object.fromEntries(o.filter(({chain_type:r,bech32_prefix:i})=>r==="evm"||r==="cosmos"&&i==="init").map(r=>[r.chain_id,{address:r.chain_type==="evm"?n:s,denoms:[]}]));return T.useQuery({queryKey:Re.allBalances(Object.keys(a),[n,s]).queryKey,queryFn:()=>e.post("v2/info/balances",{json:{chains:a}}).json(),select:({chains:r})=>r?Object.fromEntries(Object.entries(r).map(([i,{denoms:c}])=>[i,c||{}])):{},enabled:!!s,staleTime:z.SECOND})}function Sa(){const{localOptions:e=[]}=it();return dn().filter(({denom:s,chain_id:o})=>e.some(a=>a.denom===s&&a.chainId===o))}function Ta(e){const{local:n}=hs(e),s=dn(),{watch:o}=Ut(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function Hy(e){const{external:n}=hs(e),s=dn(),{watch:o}=Ut(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function Gy(e){const n=dn(),s=It(),{data:o,isLoading:a}=Aa(),{remoteOptions:r=[]}=it(),i=Ta(e);return i?{data:n.filter(({symbol:l,denom:d,chain_id:m})=>r.length?r.some(u=>u.denom===d&&u.chainId===m):l===i.symbol).map(l=>{if(l.hidden||l.chain_id===i.chain_id)return null;const d=s(l.chain_id);if(!d||d.chain_type==="cosmos"&&d.bech32_prefix!=="init")return null;const m=o?.[d.chain_id]?.[l.denom];return e==="deposit"&&(!m||!Number(m.amount))?null:{asset:l,chain:d,balance:m}}).filter(l=>l!==null),isLoading:a}:{data:[],isLoading:a}}function Ut(){return we.useFormContext()}const Qy="data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23242629'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%23585F67'/%3e%3cpath%20d='M47.7916%2037.0445C47.7916%2035.2783%2049.2313%2033.8464%2051.0071%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.0071C49.2313%2082.8837%2047.7916%2081.4519%2047.7916%2079.6854V37.0445Z'%20fill='%23585F67'/%3e%3cpath%20d='M91.7372%2056.2323C91.7372%2052.6999%2094.6166%2049.8362%2098.1681%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1681C94.6166%2066.8927%2091.7372%2064.0289%2091.7372%2060.4965V56.2323Z'%20fill='%23242629'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.24%2061.5626C97.4642%2061.5626%2096.0245%2060.1308%2096.0245%2058.3646C96.0245%2056.5984%2097.4642%2055.1665%2099.24%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%23585F67'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%232F3337'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23757C82'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23757C82'/%3e%3c/svg%3e",Yy="data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M47.7915%2037.0445C47.7915%2035.2783%2049.2312%2033.8464%2051.007%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.007C49.2312%2082.8837%2047.7915%2081.4519%2047.7915%2079.6854V37.0445Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M91.7373%2056.2323C91.7373%2052.6999%2094.6167%2049.8362%2098.1682%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1682C94.6167%2066.8927%2091.7373%2064.0289%2091.7373%2060.4965V56.2323Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.2399%2061.5626C97.4641%2061.5626%2096.0244%2060.1308%2096.0244%2058.3646C96.0244%2056.5984%2097.4641%2055.1665%2099.2399%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%23E9EBED'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23797D81'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23797D81'/%3e%3c/svg%3e",Zy="_container_uxgnj_1",Jy="_title_uxgnj_5",Xy="_close_uxgnj_12",e1="_emptyIcon_uxgnj_24",t1="_empty_uxgnj_24",n1="_list_uxgnj_51",s1="_asset_uxgnj_66",o1="_placeholder_uxgnj_82",a1="_activeAsset_uxgnj_95",r1="_iconContainer_uxgnj_99",i1="_assetIcon_uxgnj_109",c1="_chainIcon_uxgnj_119",l1="_assetPlaceholder_uxgnj_133",d1="_assetName_uxgnj_154",u1="_assetChain_uxgnj_169",m1="_balance_uxgnj_177",h1="_value_uxgnj_186",he={container:Zy,title:Jy,close:Xy,emptyIcon:e1,empty:t1,list:n1,asset:s1,placeholder:o1,activeAsset:a1,iconContainer:r1,assetIcon:i1,chainIcon:c1,assetPlaceholder:l1,assetName:d1,assetChain:u1,balance:m1,value:h1},f1=({mode:e})=>{const{external:n}=hs(e),{data:s,isLoading:o}=Gy(e),{setValue:a,watch:r}=Ut(),i=Ta(e),c=Sa(),{theme:l}=se(),d=r(),m=d[n.denomKey],u=d[n.chainIdKey];function h(){const f=m&&u;return!f&&c.length<=1&&e==="deposit"?null:t.jsx("button",{className:he.close,onClick:()=>{e==="withdraw"||f?a("page","fields"):a("page","select-local")},children:t.jsx(S.IconBack,{size:20})})}return i?!o&&!s.length?t.jsxs("div",{className:he.container,children:[h(),t.jsx("h4",{className:he.title,children:"No available assets"}),t.jsx("img",{src:l==="dark"?Qy:Yy,alt:"No assets",className:he.emptyIcon}),t.jsx("p",{className:he.empty,children:e==="withdraw"?`No supported destinations to withdraw ${i.symbol}.`:`No supported assets to deposit ${i.symbol}.`})]}):t.jsxs("div",{className:he.container,children:[h(),t.jsxs("h4",{className:he.title,children:[e==="withdraw"?"Select destination":`Deposit ${i.symbol}`," "]}),t.jsxs("div",{className:he.list,children:[o&&Array.from({length:5}).map((f,g)=>t.jsxs("div",{className:q(he.asset,he.placeholder),children:[t.jsxs("div",{className:he.iconContainer,children:[t.jsx("div",{className:he.assetIcon}),t.jsx("div",{className:he.chainIcon})]}),t.jsx("div",{className:he.assetPlaceholder})]},g)),!o&&s.sort(({balance:f},{balance:g})=>Number(g?.value_usd??0)-Number(f?.value_usd??0)).map(({asset:f,chain:g,balance:p})=>{const _=m===f.denom&&u===g.chain_id;return t.jsxs("button",{className:q(he.asset,_&&he.activeAsset),onClick:()=>{a(n.denomKey,f.denom),a(n.chainIdKey,g.chain_id),e==="deposit"&&a("quantity",""),a("page","fields")},children:[t.jsxs("div",{className:he.iconContainer,children:[t.jsx("img",{src:f.logo_uri,alt:f.symbol,className:he.assetIcon}),t.jsx("img",{src:g.logo_uri||"",alt:g.chain_name,className:he.chainIcon})]}),t.jsxs("p",{className:he.assetName,children:[f.symbol," ",_&&t.jsx("span",{children:t.jsx(S.IconCheck,{size:16})})]}),t.jsxs("p",{className:he.assetChain,children:["on ",g.pretty_name]}),p&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:he.balance,children:b.formatAmount(p.amount,{decimals:p.decimals||6})}),t.jsx("p",{className:he.value,children:ee(p.value_usd||0)})]})]},`${f.chain_id}-${f.denom}`)})]})]}):t.jsx("div",{children:"No assets found"})},g1="_title_9ovji_1",p1="_list_9ovji_7",_1="_asset_9ovji_15",Mo={title:g1,list:p1,asset:_1},x1=({mode:e})=>{const{local:n,external:s}=hs(e),{setValue:o}=Ut(),a=Sa(),r=(c,l)=>{o(n.denomKey,c),o(n.chainIdKey,l),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),o("page",e==="withdraw"?"fields":"select-external")},i=x.useEffectEvent(()=>{const{denom:c,chain_id:l}=a[0];r(c,l)});return x.useEffect(()=>{a.length===1&&i()},[a]),a.length?t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:Mo.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),t.jsx("div",{className:Mo.list,children:a.map(({denom:c,chain_id:l,symbol:d,logo_uri:m})=>t.jsxs("button",{className:Mo.asset,onClick:()=>r(c,l),children:[t.jsx("img",{src:m,alt:d}),d]},`${c}-${l}`))})]}):t.jsx("div",{children:"No assets found"})},y1="data:image/svg+xml,%3csvg%20width='58'%20height='58'%20viewBox='0%200%2058%2058'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M29%202.71875C43.5%202.71875%2055.2812%2014.5%2055.2812%2029C55.2812%2043.5%2043.5%2055.2812%2029%2055.2812C14.5%2055.2812%202.71875%2043.5%202.71875%2029C2.71875%2014.5%2014.5%202.71875%2029%202.71875ZM29%206.34375C16.4937%206.34375%206.34375%2016.4937%206.34375%2029C6.34375%2041.5062%2016.4937%2051.6562%2029%2051.6562C41.5062%2051.6562%2051.6562%2041.5062%2051.6562%2029C51.6562%2016.4937%2041.5062%206.34375%2029%206.34375Z'%20fill='%23F85454'/%3e%3cpath%20d='M36.1616%2018.7623C37.0109%2017.9129%2038.3885%2017.9129%2039.2378%2018.7623C40.087%2019.6117%2040.0871%2020.9893%2039.2378%2021.8386L32.0763%2029.0001L39.2378%2036.1616L39.3865%2036.3279C40.083%2037.1822%2040.034%2038.4417%2039.2378%2039.2378C38.4417%2040.034%2037.1822%2040.083%2036.3279%2039.3865L36.1616%2039.2378L29.0001%2032.0763L21.8386%2039.2378C20.9893%2040.0871%2019.6117%2040.087%2018.7623%2039.2378C17.9129%2038.3885%2017.9129%2037.0109%2018.7623%2036.1616L25.9238%2029.0001L18.7623%2021.8386C17.9129%2020.9892%2017.9129%2019.6116%2018.7623%2018.7623C19.6116%2017.9129%2020.9892%2017.9129%2021.8386%2018.7623L29.0001%2025.9238L36.1616%2018.7623Z'%20fill='%23F85454'/%3e%3c/svg%3e",b1="data:image/svg+xml,%3csvg%20width='72'%20height='72'%20viewBox='0%200%2072%2072'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M36%209.71875C50.5%209.71875%2062.2812%2021.5%2062.2812%2036C62.2812%2050.5%2050.5%2062.2812%2036%2062.2812C21.5%2062.2812%209.71875%2050.5%209.71875%2036C9.71875%2021.5%2021.5%209.71875%2036%209.71875ZM36%2013.3438C23.4937%2013.3438%2013.3438%2023.4937%2013.3438%2036C13.3438%2048.5062%2023.4937%2058.6562%2036%2058.6562C48.5062%2058.6562%2058.6562%2048.5062%2058.6562%2036C58.6562%2023.4937%2048.5062%2013.3438%2036%2013.3438Z'%20fill='%23D1242F'/%3e%3cpath%20d='M43.1616%2025.7623C44.0109%2024.9129%2045.3885%2024.9129%2046.2378%2025.7623C47.087%2026.6117%2047.0871%2027.9893%2046.2378%2028.8386L39.0763%2036.0001L46.2378%2043.1616L46.3865%2043.3279C47.083%2044.1822%2047.034%2045.4417%2046.2378%2046.2378C45.4417%2047.034%2044.1822%2047.083%2043.3279%2046.3865L43.1616%2046.2378L36.0001%2039.0763L28.8386%2046.2378C27.9893%2047.0871%2026.6117%2047.087%2025.7623%2046.2378C24.9129%2045.3885%2024.9129%2044.0109%2025.7623%2043.1616L32.9238%2036.0001L25.7623%2028.8386C24.9129%2027.9892%2024.9129%2026.6116%2025.7623%2025.7623C26.6116%2024.9129%2027.9892%2024.9129%2028.8386%2025.7623L36.0001%2032.9238L43.1616%2025.7623Z'%20fill='%23D1242F'/%3e%3c/svg%3e",w1="_container_9k4hs_1",j1="_title_9k4hs_8",v1="_subtitle_9k4hs_14",C1="_linkContainer_9k4hs_30",N1="_link_9k4hs_30",k1="_separator_9k4hs_51",I1="_errorIcon_9k4hs_62",A1="_error_9k4hs_62",ke={container:w1,title:j1,subtitle:v1,linkContainer:C1,link:N1,separator:k1,errorIcon:I1,error:A1};function S1(e){if(!e)return"pending";const n=e.state;return n==="STATE_COMPLETED_SUCCESS"?"success":n==="STATE_ABANDONED"||n==="STATE_COMPLETED_ERROR"||n==="STATE_PENDING_ERROR"?"failed":"pending"}function Go({type:e}){const{closeModal:n}=In(),{theme:s}=se(),{watch:o}=Ut(),{result:a}=o(),{openDrawer:r}=kt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,c=i?"":a.txhash,l=i?"":a.chainId,d=i?0:a.timestamp??0,{route:m,values:u}=a,{srcDenom:h,srcChainId:f,quantity:g}=u,p=pt(h,f),_=e==="deposit"?"Deposit":"Withdraw",{data:y}=Cc({chainId:l,txHash:c,tracked:!1}),{data:j}=Nc({chainId:l,txHash:c,tracked:!!y,timestamp:d,route:m}),C=S1(j),w=s==="dark"?y1:b1,I=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,A=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return t.jsxs("div",{className:ke.container,children:[t.jsxs("h3",{className:ke.title,children:[_," failed"]}),t.jsx("img",{src:w,alt:"Failed",className:ke.errorIcon}),t.jsx("p",{className:ke.error,children:a?.error}),t.jsx(de.White,{fullWidth:!0,onClick:n,children:"Close"})]});const L=Jn(m.estimated_route_duration_seconds),E=new URLSearchParams({tx_hash:c,chain_id:l}),k=new URL(`?${E.toString()}`,"https://explorer.skip.build"),M=()=>t.jsxs("div",{className:ke.linkContainer,children:[t.jsx("a",{href:k.toString(),target:"_blank",rel:"noopener noreferrer",className:ke.link,children:"View transaction"}),t.jsx("div",{className:ke.separator}),t.jsx("button",{className:ke.link,onClick:()=>{n(),r("/bridge/history")},children:"Go to history"})]});return t.jsxs("div",{className:ke.container,children:[C==="pending"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ke.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",g," ",p.symbol]}),t.jsx("video",{src:I,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),t.jsxs("p",{className:ke.subtitle,children:["Estimated time: ",t.jsx("span",{children:L})]}),M(),t.jsx("p",{className:ke.subtitle,children:"Your transaction will continue even if you close this"})]}),C==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ke.title,children:[_," complete"]}),t.jsx("video",{src:A,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:v=>{const N=v.currentTarget;N.duration-N.currentTime<.1&&N.pause()}}),M(),t.jsx(de.White,{fullWidth:!0,onClick:n,children:"Close"})]}),C==="failed"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ke.title,children:[_," failed"]}),t.jsx("img",{src:w,alt:"Failed",className:ke.errorIcon}),t.jsx("p",{className:ke.error,children:"Your transaction could not be completed"}),t.jsx(de.White,{fullWidth:!0,onClick:n,children:"Close"})]})]})}const T1=ve.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),$1=({tx:e,children:n})=>{const{values:s}=At(),{srcChainId:o}=s,a=te(),r=ss(),i=Ys(),{data:c,isLoading:l}=T.useQuery({queryKey:T1.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const m=e.cosmos_tx.msgs.map(({msg_type_url:f,msg:g})=>{if(!(f&&g))throw new Error("Invalid transaction data");return r.fromAmino({type:sn.aminoConverters[f].aminoType,value:JSON.parse(g)})});return{estimatedGas:await(await i(o)).simulate(a,m,""),messages:m}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if(l)return t.jsx(je,{children:t.jsx(de.White,{loading:"Estimating gas..."})});const d=c?.estimatedGas??null;return t.jsx(t.Fragment,{children:n(d)})},E1="_container_eg177_1",M1="_back_eg177_6",L1="_title_eg177_18",q1="_divider_eg177_26",P1="_label_eg177_30",D1="_asset_eg177_37",R1="_assetIcon_eg177_55",B1="_chainIcon_eg177_67",F1="_assetName_eg177_80",U1="_chevron_eg177_92",O1="_input_eg177_96",V1="_balanceContainer_eg177_108",K1="_value_eg177_116",W1="_maxButton_eg177_126",z1="_detail_eg177_142",H1="_detailsContainer_eg177_153",G1="_detailsButton_eg177_163",Q1="_detailValue_eg177_180",Y1="_detailToken_eg177_190",Z1="_minimumReceived_eg177_198",Z={container:E1,back:M1,title:L1,divider:q1,label:P1,asset:D1,assetIcon:R1,chainIcon:B1,assetName:F1,chevron:U1,input:O1,balanceContainer:V1,value:K1,maxButton:W1,detail:z1,detailsContainer:H1,detailsButton:G1,detailValue:Q1,detailToken:Y1,minimumReceived:Z1},qc=({renderFee:e})=>{const{route:n}=it(),{values:s}=At(),{dstDenom:o,dstChainId:a}=s,i=dn().find(({denom:f,chain_id:g})=>f===o&&g===a),c=te(),l=Xi(),[d,m]=Be.useToggle(!1),u=n&&n.estimated_route_duration_seconds>60;if(!n||!i)return null;const h=n.does_swap?BigInt(n.amount_out||n.estimated_amount_out)*BigInt(1e4-Number(s.slippagePercent)*100)/BigInt(1e4):BigInt(n.amount_out||n.estimated_amount_out);return t.jsx(Yn,{children:t.jsxs("div",{className:Z.detailsContainer,children:[t.jsxs("button",{className:Z.detailsButton,onClick:m,children:["Transaction details"," ",t.jsx(S.IconChevronDown,{size:12,style:{transform:d?"rotate(180deg)":"rotate(0deg)"}})]}),d&&t.jsxs(t.Fragment,{children:[n.does_swap&&t.jsxs("div",{className:Z.detail,children:[t.jsx("p",{className:Z.detailLabel,children:"Slippage"}),t.jsxs("p",{className:Z.detailValue,children:[s.slippagePercent,"%"]})]}),!!n.estimated_fees?.length&&t.jsxs("div",{className:Z.detail,children:[t.jsx("p",{className:Z.detailLabel,children:"Bridge fee"}),t.jsx("div",{className:Z.detailValue,children:va(n.estimated_fees)})]}),e&&t.jsxs("div",{className:Z.detail,children:[t.jsx("p",{className:Z.detailLabel,children:"Tx fee"}),t.jsx("div",{className:Z.detailValue,children:e()})]}),c&&t.jsxs("div",{className:Z.detail,children:[t.jsx("p",{className:Z.detailLabel,children:"Receiving address"}),t.jsxs("p",{className:Z.detailValue,children:[t.jsx("img",{src:l,alt:"Wallet",height:12,width:12})," ",b.truncate(c)]})]})]}),t.jsxs("div",{className:Z.detail,children:[t.jsx("p",{className:Z.detailLabel,children:"Estimated time"}),t.jsx("p",{className:q(Z.detailValue),style:u?{color:"var(--warning)"}:void 0,children:Jn(n.estimated_route_duration_seconds)})]}),t.jsxs("div",{className:q(Z.detail,Z.minimumReceived),children:[t.jsx("p",{className:Z.detailLabel,children:"Minimum received"}),t.jsxs("p",{className:Z.detailValue,children:[t.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Z.detailToken})," ",b.formatAmount(h,{decimals:i.decimals})," ",i.symbol]})]})]})})},J1="_trigger_1c7d7_1",X1="_item_1c7d7_5",e0="_itemText_1c7d7_13",t0={trigger:J1,item:X1,itemText:e0},n0=({tx:e,gas:n,confirmMessage:s,onCompleted:o})=>{const{values:a}=At(),{srcChainId:r,srcDenom:i,quantity:c}=a,d=dn().find(({denom:v,chain_id:N})=>v===i&&N===r),m=rt(r),u=es(m),h=la(m),f=da(m),g=xt(m),p=h.map(({amount:v,denom:N})=>Ce.calculateFee(Math.ceil(n*on),Ce.GasPrice.fromString(v+N))),_=p.map(v=>v.amount[0]),y=v=>{const N=u.find(K=>K.denom===v)?.amount??"0",B=_.find(K=>K.denom===v)?.amount??"0",R=d&&i===v?V(c||"0").times(V(10).pow(d.decimals)).toFixed(0):"0",P=V(B).plus(R),F=V(N).gte(P),{symbol:Q,decimals:U}=g(v);return{symbol:Q,decimals:U,spend:V(R).gt(0)?R:null,fee:B,total:P.toFixed(),balance:N,isSufficient:F}},j=()=>{if(!_.length)return null;if(f&&y(f).isSufficient)return f;for(const{denom:v}of _)if(y(v).isSufficient)return v;return _[0]?.denom},[C,w]=x.useState(j),I=p.find(v=>v.amount[0].denom===C)??void 0,A=C?y(C):null,L=A&&!A.isSufficient?"Insufficient balance":void 0,E=(v,N)=>{if(b.formatAmount(v,{decimals:N})==="0.000000")return 8},k=v=>{const[{amount:N,denom:B}]=v.amount;if(V(N).isZero())return"0";const{symbol:R,decimals:P}=g(B),F=E(N,P);return`${b.formatAmount(N,{decimals:P,dp:F})} ${R}`},M=()=>{if(p.length===0)return null;if(p.length===1)return t.jsx("span",{className:"monospace",children:k(p[0])});if(!I||!C)return null;const v=p.map(F=>{const[{denom:Q}]=F.amount,{symbol:U}=g(Q);return{value:Q,label:k(F),triggerLabel:U}}),[{amount:N,denom:B}]=I.amount,{decimals:R}=g(B),P=E(N,R);return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{className:"monospace",children:b.formatAmount(N,{decimals:R,dp:P})}),t.jsx(wa,{options:v,value:C,onChange:w,classNames:t0})]})};return t.jsxs(t.Fragment,{children:[t.jsx(qc,{renderFee:p.length>0?M:void 0}),t.jsx(Ia,{tx:e,children:t.jsx(ka,{tx:e,fee:I,onCompleted:o,confirmMessage:s,error:L})})]})},s0=({tx:e,confirmMessage:n,onCompleted:s})=>t.jsxs(t.Fragment,{children:[t.jsx(qc,{}),t.jsx(Ia,{tx:e,children:t.jsx(ka,{tx:e,fee:void 0,onCompleted:s,confirmMessage:n})})]}),o0=({tx:e,gas:n,mode:s})=>{const{setValue:o}=Ut(),a=i=>{o("page","completed"),o("result",i)},r=s==="withdraw"?"Withdraw":"Deposit";return!n||!("cosmos_tx"in e)?t.jsx(s0,{tx:e,onCompleted:a,confirmMessage:r}):t.jsx(n0,{tx:e,gas:n,onCompleted:a,confirmMessage:r})},a0=({mode:e})=>{const n=hs(e),s=Ie(),o=it(),a=Sa(),r=It(),{data:i}=Aa(),c=An(),{watch:l,setValue:d,getValues:m}=Ut(),u=l(),{srcChainId:h,srcDenom:f,quantity:g=""}=u,p=Ta(e),_=Hy(e),y=u[n.external.chainIdKey],j=y?r(y):null,C=i?.[h]?.[f]?.amount,w=i?.[h]?.[f]?.price||0,I=V(w||0).times(g||0),[A]=Be.useDebounceValue(g,300),L=e==="withdraw"?p:_,E=x.useMemo(()=>{if(e==="deposit"&&!_)return"Select asset";const U=V(g||0);if(!U.isFinite()||U.lte(0))return"Enter amount";const K=b.fromBaseUnit(C??"0",{decimals:L?.decimals||6});if(U.gt(K))return"Insufficient balance";if(e==="withdraw"&&!_)return"Select destination"},[e,g,C,L,_]),{data:k,error:M}=Ko(A,{disabled:!!E}),v=!M&&!E?k:void 0,N=x.useEffectEvent(()=>{s(0,{...o,route:v,values:{sender:c,recipient:o.recipientAddress?b.InitiaAddress(o.recipientAddress).hex:c,slippagePercent:"1",...m()}})});if(x.useEffect(()=>{N()},[v,c]),!p||e==="deposit"&&!_)return null;const B=L?.decimals||6,R=e==="withdraw"?"Select chain":"Select asset",P=()=>{d("quantity",""),d(n.external.denomKey,""),d(n.external.chainIdKey,""),e==="withdraw"&&(d(n.local.denomKey,""),d(n.local.chainIdKey,"")),d("page",e==="withdraw"?"select-local":"select-external")},F=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:Z.label,children:e==="withdraw"?"Destination":"From"}),t.jsxs("button",{className:Z.asset,onClick:()=>{d("page","select-external")},children:[t.jsx("div",{className:Z.assetIcon,children:_?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:_.logo_uri,alt:_.symbol}),t.jsx("img",{src:j?.logo_uri||"",alt:j?.pretty_name,className:Z.chainIcon})]}):e==="withdraw"&&t.jsx("div",{className:Z.chainIcon})}),t.jsx("p",{className:Z.assetName,children:_?t.jsxs(t.Fragment,{children:[_.symbol,t.jsx("br",{}),t.jsxs("span",{children:["on ",j?.pretty_name]})]}):R}),t.jsx(S.IconChevronDown,{className:Z.chevron,size:16})]})]}),Q=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:Z.label,children:"Amount"}),t.jsx(Zn,{balance:C,decimals:B,className:Z.input}),Number(C)>0&&t.jsxs("div",{className:Z.balanceContainer,children:[t.jsx("p",{className:Z.value,children:I.gt(0)?ee(I.toString()):"$-"}),t.jsxs("button",{className:Z.maxButton,onClick:()=>{const U=b.fromBaseUnit(C??"0",{decimals:B});V(g||0).eq(U)||d("quantity",U)},children:[t.jsx(S.IconWallet,{size:16})," ",b.formatAmount(C,{decimals:B})," ",t.jsx("span",{children:"MAX"})]})]})]});return t.jsxs("div",{className:Z.container,children:[a.length>1&&t.jsx("button",{type:"button","aria-label":"Back",className:Z.back,onClick:P,children:t.jsx(S.IconBack,{size:20})}),t.jsxs("h3",{className:Z.title,children:[n.label," ",p.symbol]}),e==="withdraw"?t.jsxs(t.Fragment,{children:[Q,t.jsx("div",{className:Z.divider}),F]}):t.jsxs(t.Fragment,{children:[F,t.jsx("div",{className:Z.divider}),Q]}),!o.route||E?t.jsx(je,{children:t.jsx(de.White,{type:"submit",loading:!M&&!E&&"Fetching route...",disabled:!0,fullWidth:!0,children:M?"No route found":E})}):t.jsx(Ac,{children:U=>t.jsx(Tc,{children:K=>t.jsx(Sc,{addressList:U,signedOpHook:K,children:W=>t.jsx($1,{tx:W,children:ye=>t.jsx(o0,{tx:W,gas:ye,mode:e})})})})})]})},r0="_container_7nl9j_1",i0="_page_7nl9j_5",yr={container:r0,page:i0},Pc=({mode:e})=>{const n=we.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Aa(),t.jsx(we.FormProvider,{...n,children:t.jsx(c0,{mode:e})})},c0=({mode:e})=>{const{watch:n}=Ut(),s=n("page"),o=gt.useTransition(s,{keys:s,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:"absolute",inset:0},config:{tension:500,friction:30,clamp:!0,duration:150}}),a=r=>{switch(r){case"select-local":return t.jsx(x1,{mode:e});case"select-external":return t.jsx(f1,{mode:e});case"fields":return t.jsx(a0,{mode:e});case"completed":return t.jsx(Go,{type:e})}};return t.jsx(Yn,{children:t.jsx("div",{className:yr.container,children:o((r,i)=>t.jsx(gt.animated.div,{style:r,className:yr.page,children:a(i)}))})})},l0=()=>t.jsx(Pc,{mode:"deposit"}),d0=()=>t.jsx(Pc,{mode:"withdraw"}),u0="_root_1lo0i_1",m0="_address_1lo0i_9",h0="_copy_1lo0i_19",f0="_labelWrapper_1lo0i_33",g0="_labelCopy_1lo0i_43",p0="_labelCopied_1lo0i_47",_0="_copied_1lo0i_55",x0="_derived_1lo0i_65",y0="_derivedLabel_1lo0i_79",b0="_derivedAddress_1lo0i_83",w0="_hexAddress_1lo0i_89",j0="_derivedCopy_1lo0i_94",Me={root:u0,address:m0,copy:h0,labelWrapper:f0,labelCopy:g0,labelCopied:p0,copied:_0,derived:x0,derivedLabel:y0,derivedAddress:b0,hexAddress:w0,derivedCopy:j0},v0=()=>{const e=x.useRef(null),n=x.useRef(null),{initiaAddress:s,hexAddress:o}=We(),a=Zi("--gray-0");return x.useEffect(()=>{e.current&&(n.current?n.current.update({data:s}):(n.current=new ol({type:"canvas",width:400,height:400,margin:0,data:s,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:a},cornersSquareOptions:{type:"extra-rounded",color:a},cornersDotOptions:{type:"dot",color:a},backgroundOptions:{color:"transparent"}}),n.current.append(e.current)))},[s,a]),t.jsx(yt,{title:"Receive",children:t.jsxs("div",{className:Me.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:Me.address,children:s}),t.jsx(Ds,{value:s,children:({copy:r,copied:i})=>t.jsxs("button",{className:q(Me.copy,{[Me.copied]:i}),onClick:r,children:[t.jsx(S.IconCopy,{size:12}),t.jsxs("div",{className:Me.labelWrapper,children:[t.jsx("span",{className:Me.labelCopy,children:"Copy address"}),t.jsx("span",{className:Me.labelCopied,children:"Copied!"})]})]})}),t.jsx(Ds,{value:o,children:({copy:r,copied:i})=>t.jsxs("button",{className:q(Me.derived,{[Me.copied]:i}),onClick:r,children:[t.jsx("span",{className:Me.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:Me.derivedAddress,children:[t.jsx("span",{className:Me.hexAddress,children:b.truncate(o)}),t.jsx(S.IconCopy,{size:12,className:Me.derivedCopy}),i&&t.jsx("span",{className:Me.copiedText,children:"Copied!"})]})]})})]})})};function C0(e,n){return n==null?e:e.filter(s=>s.grantee===n)}function N0(){const e=te(),n=ue();return T.useQueries({queries:n.map(s=>({queryKey:Ls.grants(s.chainId,e).queryKey,queryFn:async()=>{const o=await Ks(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:s.restUrl},"grants"),a=fi(o),r=e?oa(e,s.chainId):null,i=C0(a,r);return{chainId:s.chainId,grants:i}},enabled:!!e,staleTime:z.SECOND,retry:!1}))})}const k0="_countdown_vfms8_1",I0={countdown:k0},A0=({expiration:e})=>{const n=()=>{const a=new Date,r=Ve.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),c=Math.floor(r%(1440*60)/3600),l=Math.floor(r%3600/60),d=r%60,m=[];return i>0&&m.push(`${i}d`),(c>0||i>0)&&m.push(`${c}h`),(l>0||c>0||i>0)&&m.push(`${l}m`),m.push(`${d}s`),m.join(" ")},[s,o]=x.useState(n());return Be.useInterval(()=>{o(n())},1e3),Ve.isPast(e)?"Expired":t.jsxs(t.Fragment,{children:["Expires in ",t.jsx("span",{className:I0.countdown,children:s})]})},S0="_container_1l528_1",T0="_info_1l528_11",$0="_header_1l528_17",E0="_chainName_1l528_23",M0="_expiration_1l528_29",L0="_revokeButton_1l528_35",pn={container:S0,info:T0,header:$0,chainName:E0,expiration:M0,revokeButton:L0},q0=({chainId:e,grantee:n,expiration:s})=>{const o=rt(e),{mutate:a,isPending:r}=Ti({grantee:n,internal:!0});return t.jsxs("div",{className:pn.container,children:[t.jsxs("div",{className:pn.info,children:[t.jsxs("div",{className:pn.header,children:[t.jsx(ne,{src:o.logoUrl,width:16,height:16,logo:!0}),t.jsx("div",{className:pn.chainName,children:o.name})]}),t.jsx("div",{className:pn.expiration,children:s?t.jsx(A0,{expiration:s}):"Until revoked"})]}),t.jsx("button",{className:pn.revokeButton,onClick:()=>a(e),disabled:r,children:r?"Revoking...":"Revoke"})]})},P0=({chainId:e,grants:n})=>{const s=new Map;for(const a of n){const r=s.get(a.grantee),i=a.expiration?new Date(a.expiration):void 0;if(!r){s.set(a.grantee,{grantee:a.grantee,expiration:i});continue}r.expiration=ca([r.expiration,i])}return[...s.values()].map(a=>x.createElement(q0,{...a,chainId:e,key:a.grantee}))},D0="_content_q36qs_1",R0={content:D0},B0=()=>{const e=N0(),n=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?t.jsx(ge,{children:"No permissions found"}):t.jsx("div",{className:R0.content,children:s.map(({chainId:o,grants:a})=>t.jsx(P0,{chainId:o,grants:a},o))})};return t.jsx(yt,{title:"Manage auto-signing",backButton:"/settings",children:n()})},F0="_version_1sf5y_1",U0={version:F0},O0=()=>t.jsxs("aside",{className:U0.version,children:["v","2.4.3"]}),V0="_link_se23z_1",K0="_title_se23z_17",W0="_subtitle_se23z_23",z0="_icon_se23z_30",vs={link:V0,title:K0,subtitle:W0,icon:z0},Dc=({title:e,subtitle:n,rightSection:s,onClick:o})=>t.jsxs("button",{className:vs.link,onClick:o,children:[t.jsxs("div",{children:[t.jsx("p",{className:vs.title,children:e}),n&&t.jsx("p",{className:vs.subtitle,children:n})]}),t.jsx("div",{className:vs.icon,children:s??t.jsx(S.IconChevronRight,{size:16})})]}),H0="https://export.initia.xyz/",G0=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return t.jsx(Dc,{title:"Export private key",rightSection:t.jsx(S.IconExternalLink,{size:16}),onClick:()=>window.open(H0,"_blank",e)})},Q0="_container_1vxr7_1",Y0="_separator_1vxr7_7",br={container:Q0,separator:Y0},Z0=()=>{const e=Ie(),{connector:n}=De.useAccount();return t.jsx(yt,{title:"Settings",backButton:"/",children:t.jsxs("div",{className:br.container,children:[t.jsx(Dc,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),n?.id===Xo&&t.jsx(G0,{}),t.jsx(vt.Separator,{className:br.separator}),t.jsx(O0,{})]})})},J0="_trigger_1yjkd_1",X0="_icon_1yjkd_23",e2="_full_1yjkd_27",t2="_triggerContent_1yjkd_32",n2="_triggerText_1yjkd_40",s2="_popoverBackdrop_1yjkd_51",o2="_popoverPositioner_1yjkd_70",a2="_popoverPopup_1yjkd_74",r2="_search_1yjkd_99",i2="_viewport_1yjkd_105",c2="_item_1yjkd_111",l2="_highlighted_1yjkd_127",d2="_active_1yjkd_131",u2="_itemContent_1yjkd_136",m2="_extra_1yjkd_142",h2="_connectedTag_1yjkd_149",be={trigger:J0,icon:X0,full:e2,triggerContent:t2,triggerText:n2,popoverBackdrop:s2,popoverPositioner:o2,popoverPopup:a2,search:r2,viewport:i2,item:c2,highlighted:l2,active:d2,itemContent:u2,extra:m2,connectedTag:h2},mo=({value:e,onChange:n,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=se(),[i,c]=x.useState(""),[l,d]=x.useState(!1),[m,u]=x.useState(0),[h,f]=x.useState(),g=x.useRef([]),p=x.useRef(null),_=ue(),y=s.map(v=>_.find(N=>N.chainId===v)).filter(Boolean),j=v=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:v,height:v,viewBox:"0 0 14 14",children:[t.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),t.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),C=x.useMemo(()=>({chainId:"",name:"All",logoUrl:j}),[]),w=x.useMemo(()=>{const v=[C,...y];if(!i)return v;const N=i.toLowerCase();return v.filter(B=>B.name.toLowerCase().includes(N)||B.chainId.toLowerCase().includes(N))},[y,i,C]),I=y.find(v=>v.chainId===e)||C,A=parseInt(Zi("--drawer-offset")),L=6,E=()=>{if(c(""),u(-1),p.current){const N=p.current.getBoundingClientRect().bottom+L,B=window.innerHeight-N-2*A;f(B)}d(!0)};x.useEffect(()=>{m>=0&&m<g.current.length&&g.current[m]?.scrollIntoView({block:"nearest",behavior:"auto"})},[m]);const k=x.useCallback(v=>{switch(v.key){case"ArrowDown":v.preventDefault(),u(N=>(N+1)%w.length);break;case"ArrowUp":v.preventDefault(),u(N=>(N-1+w.length)%w.length);break;case"Enter":v.preventDefault(),w[m]&&(n(w[m].chainId),d(!1));break;case"Escape":v.preventDefault(),d(!1);break}},[w,m,n,d]),M=v=>{n(v),d(!1)};return t.jsxs(fn.Popover.Root,{open:l,onOpenChange:E,modal:"trap-focus",children:[t.jsx(fn.Popover.Trigger,{render:t.jsxs("button",{className:q(be.trigger,{[be.full]:a}),"aria-expanded":l,role:"listbox",ref:p,children:[t.jsxs("div",{className:be.triggerContent,children:[typeof I.logoUrl=="string"?t.jsx(ne,{src:I.logoUrl,width:14,height:14,logo:!0}):I.logoUrl(14),t.jsx("span",{className:be.triggerText,children:I.name})]}),t.jsx(S.IconChevronDown,{size:16,className:be.icon})]})}),t.jsxs(fn.Popover.Portal,{container:rn(),children:[t.jsx(fn.Popover.Backdrop,{className:be.popoverBackdrop,onClick:()=>d(!1)}),t.jsx(fn.Popover.Positioner,{className:be.popoverPositioner,align:"end",side:"bottom",sideOffset:L,collisionAvoidance:{side:"none"},children:t.jsxs(fn.Popover.Popup,{className:q(be.popoverPopup,{[be.full]:a}),style:{maxHeight:h},children:[t.jsx(us,{value:i,onChange:v=>{c(v.target.value),u(0)},onClear:()=>c(""),onKeyDown:k,placeholder:"Search appchains",rootClassName:be.search,ref:ls()}),t.jsx("div",{className:be.viewport,role:"listbox",children:w.length===0?t.jsx(ge,{children:"No appchains found"}):w.map(({chainId:v,name:N,logoUrl:B},R)=>t.jsxs("div",{className:q(be.item,{[be.highlighted]:R===m,[be.active]:e===v}),onClick:()=>M(v),onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),M(v))},onMouseEnter:()=>u(R),role:"option","aria-selected":e===v,tabIndex:-1,ref:P=>{P&&(g.current[R]=P)},children:[t.jsxs("div",{className:be.itemContent,children:[typeof B=="string"?t.jsx(ne,{src:B,width:16,height:16,logo:!0}):B(16),t.jsx("span",{className:be.name,children:N}),v===r&&t.jsx("span",{className:be.connectedTag,children:"Connected"})]}),o&&t.jsx("span",{className:be.extra,children:o(v)})]},v))})]})})]})]})},f2="_container_1nap1_1",g2="_controls_1nap1_7",p2="_search_1nap1_13",$a={container:f2,controls:g2,search:p2},_2=({children:e})=>t.jsx("div",{className:$a.container,children:e}),x2=({children:e})=>t.jsx("div",{className:$a.controls,children:e}),y2=e=>t.jsx(us,{...e,rootClassName:$a.search}),at={Root:_2,Controls:x2,SearchInput:y2},Rc=H.atom(""),Bc=H.atom(""),b2=H.atom(""),w2=H.atom(""),j2=H.atom(""),v2="_change_1x9v4_1",C2="_positive_1x9v4_10",N2="_negative_1x9v4_14",Lo={change:v2,positive:C2,negative:N2},Fc=({amount:e,asset:n})=>{const{denom:s,symbol:o,decimals:a}=n,r=new V(e).isPositive(),i=new V(e).abs().toString();return t.jsxs("div",{className:q(Lo.change,r?Lo.positive:Lo.negative),children:[r?"+":"-",b.formatAmount(i,{decimals:a})," ",o||s]})},k2=({changes:e,chain:n})=>{const s=xt(n);return e.map(({amount:o,denom:a},r)=>t.jsx(Fc,{amount:o,asset:s(a)},r))},I2=({changes:e,chain:n})=>{const s=xt(n);return e.map(({amount:o,metadata:a},r)=>t.jsx(oc,{metadata:a,chain:n,children:i=>t.jsx(Fc,{amount:o,asset:s(i)})},r))},A2=({events:e,chain:n})=>{const{initiaAddress:s,hexAddress:o}=We();return n.metadata?.is_l1||n.metadata?.minitia?.type==="minimove"?t.jsx(I2,{changes:sc(e,o),chain:n}):t.jsx(k2,{changes:nc(e,s),chain:n})},S2="_message_1g2hc_1",T2="_more_1g2hc_8",wr={message:S2,more:T2},$2=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((n,s)=>t.jsx("p",{className:wr.message,children:Os.sentenceCase(n["@type"].split("Msg")[1])},s)),e.length>3&&t.jsx("footer",{className:wr.more,children:`+${e.length-3} more`})]}),E2="_link_fuhbt_1",M2="_inner_fuhbt_16",L2="_header_fuhbt_21",q2="_time_fuhbt_30",P2="_error_fuhbt_36",D2="_timestamp_fuhbt_40",R2="_chainInfo_fuhbt_45",B2="_content_fuhbt_53",F2="_messages_fuhbt_61",U2="_changes_fuhbt_67",ht={link:E2,inner:M2,header:L2,time:q2,error:P2,timestamp:D2,chainInfo:R2,content:B2,messages:F2,changes:U2},O2=({txItem:e,chain:n})=>t.jsx(ao,{txHash:e.txhash,chainId:n.chainId,className:ht.link,children:t.jsxs("div",{className:ht.inner,children:[t.jsxs("div",{className:ht.header,children:[t.jsxs("div",{className:ht.time,children:[e.code!==0&&t.jsx(S.IconWarningFilled,{size:14,className:ht.error}),t.jsx("span",{className:ht.timestamp,children:Ve.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:ht.chainInfo,children:[t.jsx(ne,{src:n.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:n.name})]})]}),t.jsxs("div",{className:ht.content,children:[t.jsx("div",{className:ht.messages,children:t.jsx($2,{messages:e.tx.body.messages})}),t.jsx("div",{className:ht.changes,children:t.jsx(fe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(A2,{...e,chain:n})})})]})]})}),V2="_list_1mv55_1",K2="_dateGroup_1mv55_7",W2="_dateHeader_1mv55_12",z2="_more_1mv55_18",Cs={list:V2,dateGroup:K2,dateHeader:W2,more:z2},H2=({list:e,chainId:n})=>{const s=te(),o=x.useMemo(()=>yc(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?t.jsx(ge,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Cs.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{className:Cs.dateGroup,children:[t.jsx("div",{className:Cs.dateHeader,children:a}),r.map(i=>t.jsx(fe,{errorBoundaryProps:{fallback:null},children:t.jsx(O2,{txItem:i,chain:i.chain})},i.txhash))]},a))}),t.jsx(ao,{chainId:n,accountAddress:s,pathSuffix:"/txs",className:Cs.more,showIcon:!0,children:"View more on Initia Scan"})]})},G2=()=>{const{activities:e,isLoading:n}=xd(),[s,o]=H.useAtom(j2),a=oe(),r=x.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=x.useMemo(()=>s?e.filter(c=>c.chain.chainId===s):e,[e,s]);return n&&e.length===0?t.jsx(ge,{children:"Loading activities..."}):!e.length&&!n?t.jsx(ge,{children:"No activity yet"}):t.jsxs(at.Root,{children:[t.jsx(at.Controls,{children:t.jsx(mo,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),t.jsx(H2,{list:i,chainId:s||a.chainId})]})},Q2="_thumbnail_1xyqw_1",Y2="_placeholder_1xyqw_18",Z2="_clickable_1xyqw_24",Un={thumbnail:Q2,placeholder:Y2,clickable:Z2},J2=({nftInfo:e,size:n,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:c}=se(),l=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,c).toString();return s?t.jsx("button",{className:q(Un.thumbnail,Un.clickable),onClick:s,style:{width:n,height:n},children:t.jsx(ne,{src:l,classNames:{placeholder:Un.placeholder}})}):t.jsx("div",{className:Un.thumbnail,style:{width:n,height:n},children:t.jsx(ne,{src:l,classNames:{placeholder:Un.placeholder}})})},X2="_collectionName_qs5tw_1",eb="_nftName_qs5tw_6",tb="_chainInfo_qs5tw_10",qo={collectionName:X2,nftName:eb,chainInfo:tb},Ea=({normalizedNft:e,onThumbnailClick:n,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:c}=e;return t.jsxs("div",{className:a?.root,children:[t.jsx(J2,{nftInfo:e,onClick:n,size:s}),t.jsxs("div",{children:[t.jsx("div",{className:q(qo.collectionName,a?.collectionName),children:r}),t.jsx("div",{className:q(qo.nftName,a?.nftName),children:i}),t.jsxs("div",{className:q(qo.chainInfo,a?.chainInfo),children:[t.jsx(ne,{src:c.logoUrl,width:o,height:o,logo:!0}),t.jsx("span",{children:c.name})]})]})]})},Ma=ve.createQueryKeys("interwovenkit:nft",{nfts:(e,n)=>[e,n],metadata:e=>[e]});function nb(e,n){const{nft:s}=e,o=n.name??s.token_id;return{...e,...s,...n,name:o}}function sb(e,n){return e.flatMap((s,o)=>(n[o]??[]).map(r=>({...r,chain:s})))}const ob=()=>{const e=te(),n=ue(),s=T.useQueries({queries:n.map(l=>({queryKey:Ma.nfts(l.indexerUrl,e).queryKey,queryFn:()=>Ks(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:z.SECOND}))}),o=s.map($.prop("data")),a=sb(n,o),r=a.reduce((l,{chain:d})=>({...l,[d.chainId]:(l[d.chainId]||0)+1}),{}),i=Object.values(r).reduce((l,d)=>l+d,0),c=s.some(l=>l.isLoading);return{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}};function ab(e){const n=jr(e);return T.useQuery({queryKey:Ma.metadata(n).queryKey,queryFn:async()=>{try{if(!n)return{};const s=await G.get(n).json();return{...s,image:jr(s.image)}}catch{return{}}},staleTime:z.INFINITY})}function jr(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const rb=({nftInfo:e,children:n})=>{const{data:s={}}=ab(e.nft.uri),o=nb(e,s);return n(o)},ib="_grid_1wwdn_1",cb="_root_1wwdn_7",lb="_collectionName_1wwdn_15",db="_nftName_1wwdn_23",ub="_chainInfo_1wwdn_32",vr={grid:ib,root:cb,collectionName:lb,nftName:db,chainInfo:ub},mb=()=>{const[e,n]=H.useAtom(b2),[s,o]=H.useAtom(w2),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=ob(),l=Ie(),d=x.useMemo(()=>a.filter(({collection_addr:u,collection_name:h,nft:f,object_addr:g,chain:p})=>{if(s&&p.chainId!==s)return!1;if(e){const _=e.trim().toLowerCase();return u.toLowerCase().includes(_)||h.toLowerCase().includes(_)||f.token_id.toLowerCase().includes(_)||g.toLowerCase().includes(_)}return!0}),[a,s,e]),m=x.useMemo(()=>Array.from(new Set(a.map(({chain:u})=>u.chainId))),[a]);return c&&a.length===0?t.jsx(ge,{children:"Loading NFTs..."}):!a.length&&!e&&!c?t.jsx(ge,{children:"No NFTs"}):t.jsxs(at.Root,{children:[t.jsxs(at.Controls,{children:[t.jsx(at.SearchInput,{value:e,onChange:u=>n(u.target.value),onClear:()=>n(""),placeholder:"Search NFTs"}),t.jsx(mo,{value:s,onChange:o,chainIds:m,renderExtra:u=>u?r[u]||0:i})]}),d.length===0?t.jsx(ge,{children:"No NFTs found"}):t.jsx("div",{className:vr.grid,children:d.map(u=>{const{collection_addr:h,nft:f}=u;return t.jsx(rb,{nftInfo:u,children:g=>t.jsx(Ea,{normalizedNft:g,onThumbnailClick:()=>l("/nft",g),classNames:vr})},h+f.token_id)})})]})},Uc=x.createContext(null);function Oc(){return x.useContext(Uc)}const hb="_popup_nbecp_1",fb="_item_nbecp_19",Ns={popup:hb,item:fb},Vc=({asset:e,children:n})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:c,chain:l}=e,{chainId:d}=l,[m,u]=x.useState(!1),h=Ie(),f=Oc(),{showNotification:g}=ro(),{defaultChainId:p}=se(),{evm_chain_id:_}=cn(),y=De.useChainId(),{switchChainAsync:j}=De.useSwitchChain(),{watchAssetAsync:C}=De.useWatchAsset(),w=()=>{u(!1),h("/send",{denom:s,chain:l})},I=()=>{u(!1),h("/bridge",{srcChainId:d,srcDenom:s,quantity:""})},A=T.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const L=r;return await j({chainId:Number(_)}),C({type:"ERC20",options:{address:c,symbol:a,decimals:o,image:L}})},onSuccess:()=>{g({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:L=>{g({type:"error",title:"Asset addition failed",description:L.message})}});return t.jsxs(vt.Menu.Root,{open:m,onOpenChange:u,modal:!1,children:[t.jsx(vt.Menu.Trigger,{render:n}),t.jsx(vt.Menu.Portal,{container:f,children:t.jsx(vt.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(vt.Menu.Popup,{className:Ns.popup,children:[t.jsxs(vt.Menu.Item,{className:Ns.item,onClick:w,children:[t.jsx(S.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(vt.Menu.Item,{className:Ns.item,onClick:I,disabled:i,children:[t.jsx(S.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===p&&_===y&&!!c&&t.jsxs(vt.Menu.Item,{className:Ns.item,onClick:()=>A.mutate(),disabled:A.isPending||A.data,children:[A.data?t.jsx(S.IconCheck,{size:16}):t.jsx(S.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},gb="_item_38qhm_1",pb="_info_38qhm_23",_b="_images_38qhm_29",xb="_name_38qhm_33",yb="_value_38qhm_39",bb="_amount_38qhm_47",wb="_usd_38qhm_53",Qt={item:gb,info:pb,images:_b,name:xb,value:yb,amount:bb,usd:wb},jb=({asset:e})=>{const{amount:n,value:s,logoUrl:o,chain:a}=e,r=b.formatAmount(n,{decimals:e.decimals});return t.jsx(Vc,{asset:e,children:t.jsxs("button",{className:Qt.item,children:[t.jsxs("div",{className:Qt.info,children:[t.jsx(co,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:Qt.images}),t.jsx("span",{className:Qt.name,children:a.name})]}),t.jsxs("div",{className:Qt.value,children:[t.jsx("span",{className:Qt.amount,children:r}),Number(s)>0&&t.jsx("span",{className:Qt.usd,children:ee(s)})]})]})})},vb="_container_ytg3p_1",Cb="_assetItem_ytg3p_6",Nb="_expandIcon_ytg3p_22",kb="_assetInfo_ytg3p_27",Ib="_logo_ytg3p_33",Ab="_details_ytg3p_37",Sb="_symbol_ytg3p_42",Tb="_chainName_ytg3p_53",$b="_chainInfos_ytg3p_59",Eb="_chainLogos_ytg3p_65",Mb="_chainLogo_ytg3p_65",Lb="_moreChains_ytg3p_76",qb="_expanded_ytg3p_93",Pb="_valueColumn_ytg3p_98",Db="_amount_ytg3p_108",Rb="_value_ytg3p_98",Bb="_collapsibleContent_ytg3p_121",Fb="_chainsList_ytg3p_151",xe={container:vb,assetItem:Cb,expandIcon:Nb,assetInfo:kb,logo:Ib,details:Ab,symbol:Sb,chainName:Tb,chainInfos:$b,chainLogos:Eb,chainLogo:Mb,moreChains:Lb,expanded:qb,valueColumn:Pb,amount:Db,value:Rb,collapsibleContent:Bb,chainsList:Fb},Ub=H.atom([]),La=({assetGroup:e})=>{const{symbol:n,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=H.useAtom(Ub),c=x.useMemo(()=>qd(e),[e]),l=x.useMemo(()=>$i(e),[e]),d=r.includes(n),m=()=>{i(h=>d?h.filter(f=>f!==n):[...new Set([...h,n])])},u=()=>t.jsxs("button",{className:xe.assetItem,children:[t.jsxs("div",{className:xe.assetInfo,children:[s&&t.jsx(ne,{src:s,width:32,height:32,className:xe.logo,logo:!0}),t.jsxs("div",{className:xe.details,children:[t.jsx("div",{className:xe.symbol,children:n}),a?t.jsx("div",{className:xe.chainName,children:o[0].chain.name}):t.jsxs("div",{className:xe.chainInfos,children:[t.jsx("div",{className:xe.chainLogos,children:o.slice(0,5).map(({chain:h})=>t.jsx(ne,{src:h.logoUrl,width:16,height:16,className:xe.chainLogo,logo:!0},h.chainId))}),o.length>5&&t.jsxs("span",{className:xe.moreChains,children:["+",o.length-5]}),t.jsx(S.IconChevronDown,{size:16,className:q(xe.expandIcon,{[xe.expanded]:d})})]})]})]}),t.jsxs("div",{className:xe.valueColumn,children:[t.jsx("div",{className:xe.amount,children:b.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&t.jsx("div",{className:xe.value,children:ee(l)})]})]});if(a){const[h]=o;return t.jsx("div",{className:xe.container,children:t.jsx(Vc,{asset:h,children:u()})})}return t.jsx("div",{className:xe.container,children:t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:m,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:u()}),t.jsx(J.Collapsible.Content,{className:xe.collapsibleContent,children:t.jsx("div",{className:xe.chainsList,children:o.map(h=>t.jsx(jb,{asset:h},h.chain.chainId))})})]})})},Ob="_collapsible_1g7rh_1",Vb="_trigger_1g7rh_5",Kb="_divider_1g7rh_20",Wb="_label_1g7rh_28",zb="_chevron_1g7rh_33",Hb="_content_1g7rh_41",Gb="_list_1g7rh_45",Lt={collapsible:Ob,trigger:Vb,divider:Kb,label:Wb,chevron:zb,content:Hb,list:Gb},Kc=({unlistedAssets:e})=>{const[n,s]=x.useState(!1),o=Oc(),a=x.useRef(null),[r,i]=x.useState(0);x.useEffect(()=>{if(a.current){const u=a.current.scrollHeight;i(u)}},[e]);const c=x.useRef(null),l=u=>{s(u),u&&c.current&&o?.current&&window.setTimeout(()=>{if(!c.current||!a.current||!o?.current)return;const h=o.current,f=h.getBoundingClientRect(),g=c.current.getBoundingClientRect(),p=a.current.scrollHeight;if(g.bottom+p>f.bottom){const y=g.top-f.top+h.scrollTop-16;h.scrollTo({top:y,behavior:"smooth"})}},50)},d=gt.useSpring({height:n?r:0,opacity:n?1:0,config:{tension:500,friction:30,clamp:!0}}),m=x.useMemo(()=>e.map(u=>({...u,assets:[u],totalValue:u.value??0,totalAmount:Number(u.quantity)})),[e]);return e.length===0?null:t.jsxs(J.Collapsible.Root,{open:n,onOpenChange:l,className:Lt.collapsible,children:[t.jsxs(J.Collapsible.Trigger,{ref:c,className:Lt.trigger,children:[t.jsx("div",{className:Lt.divider}),t.jsxs("span",{className:Lt.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(S.IconChevronDown,{className:Lt.chevron,size:12,"data-state":n?"open":"closed"}),t.jsx("div",{className:Lt.divider})]}),t.jsx(J.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(gt.animated.div,{className:Lt.content,style:d,children:t.jsx("div",{className:Lt.list,ref:a,children:m.map(u=>t.jsx(La,{assetGroup:u},u.assets[0].denom))})})})]})},Qb="_container_15xfg_1",Yb="_header_15xfg_7",Zb="_title_15xfg_13",Jb="_totalValue_15xfg_19",Xb="_list_15xfg_26",wn={container:Qb,header:Yb,title:Zb,totalValue:Jb,list:Xb},ew=()=>{const[e,n]=H.useAtom(Rc),[s,o]=H.useAtom(Bc),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:c,isLoading:l}=ua(),d=i.map(({chainId:h})=>h),m=x.useMemo(()=>{const h=e?a.filter(g=>{const{symbol:p,assets:_}=g;return p.toLowerCase().includes(e.toLowerCase())||_.some(({denom:y,address:j})=>y.toLowerCase().includes(e.toLowerCase())||j?.toLowerCase().includes(e.toLowerCase()))}):a;return s?h.map(g=>({...g,assets:g.assets.filter(({chain:p})=>p.chainId===s)})).filter(g=>g.assets.length>0):h},[a,e,s]),u=x.useMemo(()=>{const h=e?r.filter(({denom:g,address:p})=>g.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):r;return s?h.filter(({chain:g})=>g.chainId===s):h},[r,e,s]);return l&&a.length===0?t.jsx(ge,{children:"Loading assets..."}):!m.length&&!u.length&&!e&&!s&&!l?t.jsx(ge,{children:"No assets"}):t.jsxs(at.Root,{children:[t.jsxs(at.Controls,{children:[t.jsx(at.SearchInput,{value:e,onChange:h=>n(h.target.value),onClear:()=>n(""),placeholder:"Search assets"}),t.jsx(mo,{value:s,onChange:o,chainIds:d,renderExtra:h=>{if(!h)return ee(c);const f=i.find(g=>g.chainId===h);return f?ee(f.value):null}})]}),t.jsx("div",{children:m.length===0&&u.length===0?t.jsx(ge,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:wn.list,children:m.map(h=>t.jsx(La,{assetGroup:h},h.symbol))}),t.jsx(Kc,{unlistedAssets:u})]})})]})},tw="_container_11k2x_1",nw={container:tw},ot=({height:e,length:n=1,width:s="100%"})=>{const o=Array.from({length:n},(a,r)=>r);return n===1?t.jsx(nn,{height:e,width:s}):t.jsx("div",{className:nw.container,children:o.map(a=>t.jsx(nn,{height:e,width:s},a))})},sw=x.memo(({searchQuery:e,selectedChain:n,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:c}=rs(),l=oe(),{listedGroups:d,unlistedAssets:m}=x.useMemo(()=>Zu(i,a,r,l.chainId),[i,a,r,l.chainId]),u=x.useMemo(()=>Hu(d,s,o),[d,s,o]),{filteredAssets:h,totalAssetsValue:f,filteredUnlistedAssets:g}=x.useMemo(()=>Yu(u,m,e,n),[u,m,e,n]);return t.jsxs("div",{className:wn.container,children:[t.jsxs("div",{className:wn.header,children:[t.jsx("span",{className:wn.title,children:"Assets"}),h.length>0&&t.jsx("span",{className:wn.totalValue,children:ee(f)})]}),h.length>0?t.jsxs("div",{children:[t.jsx("div",{className:wn.list,children:h.map(p=>t.jsx(La,{assetGroup:p},p.symbol))}),t.jsx(Kc,{unlistedAssets:g})]}):u.length===0&&c?t.jsx(ot,{height:56,length:3}):t.jsx(ge,{children:"No liquid assets"})]})}),ow=ve.createQueryKeys("interwovenkit:civitia",{player:(e,n)=>[e,n]});function Wc(){const{civitiaUrl:e}=se(),n=te();return T.useQuery({enabled:!!n,queryKey:ow.player(e,n??"").queryKey,queryFn:async()=>{if(!n)throw new Error("address is not available");return G.get(`${e}/players/${n}`).json()},staleTime:z.MINUTE,throwOnError:!1})}const aw="_section_xdyfz_2",rw="_row_xdyfz_15",iw="_rowLeft_xdyfz_23",cw="_rowIcon_xdyfz_29",lw="_goldIcon_xdyfz_38",dw="_silverIcon_xdyfz_46",uw="_rowTitle_xdyfz_54",mw="_rowValue_xdyfz_60",hw="_rowSubtitle_xdyfz_67",Se={section:aw,row:rw,rowLeft:iw,rowIcon:cw,goldIcon:lw,silverIcon:dw,rowTitle:uw,rowValue:mw,rowSubtitle:hw},fw=()=>{const{data:e,isLoading:n}=Wc();if(n)return t.jsx(ot,{height:36,length:2});const s=e?.gold_balance??0,o=e?.silver_balance??0;return t.jsxs("div",{className:Se.section,children:[t.jsxs("div",{className:Se.row,children:[t.jsxs("div",{className:Se.rowLeft,children:[t.jsx("div",{className:q(Se.rowIcon,Se.goldIcon)}),t.jsx("span",{className:Se.rowTitle,children:"Gold"})]}),t.jsx("span",{className:q(Se.rowValue,s===0&&Se.rowSubtitle),children:s===0?"—":b.formatNumber(s,{dp:6})})]}),t.jsxs("div",{className:Se.row,children:[t.jsxs("div",{className:Se.rowLeft,children:[t.jsx("div",{className:q(Se.rowIcon,Se.silverIcon)}),t.jsx("span",{className:Se.rowTitle,children:"Silver"})]}),t.jsx("span",{className:q(Se.rowValue,o===0&&Se.rowSubtitle),children:o===0?"—":b.formatNumber(o,{dp:6})})]})]})},gw="_container_1n61l_1",pw="_section_1n61l_7",_w="_sectionHeader_1n61l_19",xw="_sectionTitle_1n61l_25",yw="_sectionLabel_1n61l_31",bw="_externalLink_1n61l_37",ww="_sectionValue_1n61l_49",jw="_tokenList_1n61l_56",vw="_stakingTokenList_1n61l_62",Cw="_tokenRow_1n61l_72",Nw="_tokenMain_1n61l_78",kw="_tokenTrigger_1n61l_84",Iw="_tokenChevron_1n61l_100",Aw="_expanded_1n61l_111",Sw="_triggerValue_1n61l_115",Tw="_tokenInfo_1n61l_122",$w="_tokenInfoLabel_1n61l_128",Ew="_tokenLogo_1n61l_134",Mw="_tokenSymbol_1n61l_138",Lw="_tokenValues_1n61l_144",qw="_tokenAmount_1n61l_150",Pw="_tokenValue_1n61l_144",Dw="_typeBreakdown_1n61l_164",Rw="_typeRow_1n61l_172",Bw="_typeLabel_1n61l_180",Fw="_typeValues_1n61l_186",Uw="_typeAmount_1n61l_192",Ow="_typeValue_1n61l_186",Vw="_collapsibleContent_1n61l_206",X={container:gw,section:pw,sectionHeader:_w,sectionTitle:xw,sectionLabel:yw,externalLink:bw,sectionValue:ww,tokenList:jw,stakingTokenList:vw,tokenRow:Cw,tokenMain:Nw,tokenTrigger:kw,tokenChevron:Iw,expanded:Aw,triggerValue:Sw,tokenInfo:Tw,tokenInfoLabel:$w,tokenLogo:Ew,tokenSymbol:Mw,tokenValues:Lw,tokenAmount:qw,tokenValue:Pw,typeBreakdown:Dw,typeRow:Rw,typeLabel:Bw,typeValues:Fw,typeAmount:Uw,typeValue:Ow,collapsibleContent:Vw},zc=({protocols:e,denomLogoMap:n,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=x.useMemo(()=>{const c=e.flatMap(l=>l.positions);return Du(c)},[e]);return i.size===0?null:t.jsx("div",{className:X.container,children:Array.from(i.entries()).map(([c,l])=>t.jsx(Kw,{sectionKey:c,sectionGroup:l,denomLogoMap:n,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},c))})},Kw=({sectionKey:e,sectionGroup:n,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:c,totalValue:l}=n,d=Pu(e,o),m=x.useMemo(()=>Ku(c),[c]),u=e==="staking";return t.jsxs("div",{className:X.section,children:[t.jsxs("div",{className:X.sectionHeader,children:[t.jsxs("div",{className:X.sectionTitle,children:[t.jsx("span",{className:X.sectionLabel,children:d}),u&&a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:X.externalLink,onClick:h=>h.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:X.sectionValue,children:ee(l)})]}),t.jsx("div",{className:q(X.tokenList,{[X.stakingTokenList]:u}),children:m.map(h=>t.jsx(Ww,{group:h,showTypeBreakdown:u,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},h.denom))})]})},Ww=({group:e,showTypeBreakdown:n,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:c,totalValue:l,positions:d}=e,m=s.get(r),[u,h]=x.useState(!1),f=x.useMemo(()=>{if(!n)return null;const g=Ou(d);return g.size>0?g:null},[d,n]);return f?t.jsxs(J.Collapsible.Root,{open:u,onOpenChange:h,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:X.tokenTrigger,children:[t.jsxs("div",{className:X.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:q(X.tokenChevron,{[X.expanded]:u})}),t.jsxs("div",{className:X.tokenInfoLabel,children:[m?.assetLogo&&t.jsx(ne,{src:m.assetLogo,width:20,height:20,className:X.tokenLogo}),t.jsx("span",{className:X.tokenSymbol,children:i})]})]}),t.jsx("span",{className:X.triggerValue,children:ee(l)})]})}),t.jsx(J.Collapsible.Content,{className:X.collapsibleContent,children:t.jsx(zw,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):t.jsx("div",{className:X.tokenRow,children:t.jsxs("div",{className:X.tokenMain,children:[t.jsxs("div",{className:X.tokenInfo,children:[m?.assetLogo&&t.jsx(ne,{src:m.assetLogo,width:20,height:20,className:X.tokenLogo}),t.jsx("span",{className:X.tokenSymbol,children:i})]}),t.jsxs("div",{className:X.tokenValues,children:[t.jsx("span",{className:X.tokenAmount,children:b.formatNumber(c,{dp:6})}),t.jsx("span",{className:X.tokenValue,children:ee(l)})]})]})})},zw=({typeGroups:e,symbol:n,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=x.useMemo(()=>Array.from(e.entries()).map(([l,d])=>{const m=d.reduce((h,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?h:h+f.balance.formattedAmount,0),u=d.reduce((h,f)=>h+Cn(f),0);return{type:l,typeAmount:m,typeValue:u}}),[e]),i=x.useMemo(()=>{if(!o)return 0;let l=0;for(const{type:d}of r){const m=o(s,d);l+=Number(m)}return l},[s,o,r]),c=i>0;return t.jsxs("div",{className:X.typeBreakdown,children:[r.map(({type:l,typeAmount:d,typeValue:m})=>t.jsxs("div",{className:X.typeRow,children:[t.jsx("span",{className:X.typeLabel,children:Uu(l)}),t.jsxs("div",{className:X.typeValues,children:[t.jsxs("span",{className:X.typeAmount,children:[b.formatNumber(d,{dp:6})," ",n]}),t.jsx("span",{className:X.typeValue,children:ee(m)})]})]},l)),c&&t.jsxs("div",{className:X.typeRow,children:[t.jsx("span",{className:X.typeLabel,children:"Claimable"}),t.jsxs("div",{className:X.typeValues,children:[t.jsxs("span",{className:X.typeAmount,children:[b.formatNumber(i,{dp:6})," ",st]}),t.jsx("span",{className:X.typeValue,children:ee(i*(a??0))})]})]})]})},Hw="_container_ymkoc_1",Gw="_trigger_ymkoc_6",Qw="_expandIcon_ymkoc_22",Yw="_chainInfo_ymkoc_27",Zw="_logo_ymkoc_33",Jw="_chainNameContainer_ymkoc_37",Xw="_chainName_ymkoc_37",ej="_externalLink_ymkoc_49",tj="_externalIcon_ymkoc_53",nj="_valueColumn_ymkoc_63",sj="_value_ymkoc_63",oj="_expanded_ymkoc_80",aj="_collapsibleContent_ymkoc_85",rj="_content_ymkoc_97",Le={container:Hw,trigger:Gw,expandIcon:Qw,chainInfo:Yw,logo:Zw,chainNameContainer:Jw,chainName:Xw,externalLink:ej,externalIcon:tj,valueColumn:nj,value:sj,expanded:oj,collapsibleContent:aj,content:rj},ij=H.atom([]),cj=({chainGroup:e})=>{const{chainId:n,chainLogo:s,protocols:o}=e,a=ue(),r=Xn(),{denomLogos:i,symbolLogos:c}=x.useMemo(()=>ya(r,a),[r,a]),l=x.useMemo(()=>{const d=new Map;for(const m of o)for(const u of m.positions){if(u.type==="fungible-position"||u.balance.type==="unknown")continue;const{denom:h,symbol:f}=u.balance,g=f.toUpperCase(),p=`${n}:${h}`,_=i.get(p)??c.get(g);_&&d.set(h,{assetLogo:_,chainLogo:s??""})}return d},[o,i,c,n,s]);return t.jsx(zc,{protocols:o,denomLogoMap:l})},lj=({chainGroup:e})=>{const{chainName:n,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=H.useAtom(ij),c=x.useMemo(()=>o.reduce((g,p)=>g+p.positions.reduce((_,y)=>_+Cn(y),0),0),[o]),l=["civitia","yominet"],d=r.includes(n),m=n?.toLowerCase(),u=m==="civitia",h=l.includes(m),f=()=>{i(g=>d?g.filter(p=>p!==n):[...new Set([...g,n])])};return t.jsx("div",{className:Le.container,children:t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:f,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Le.trigger,children:[t.jsxs("div",{className:Le.chainInfo,children:[s&&t.jsx(ne,{src:s,width:32,height:32,className:Le.logo,logo:!0}),t.jsxs("div",{className:Le.chainNameContainer,children:[t.jsx("span",{className:Le.chainName,children:n}),a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:Le.externalLink,onClick:g=>g.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:Le.externalIcon})})]})]}),t.jsxs("div",{className:Le.valueColumn,children:[!h&&t.jsx("span",{className:Le.value,children:ee(c)}),t.jsx(S.IconChevronDown,{size:16,className:q(Le.expandIcon,{[Le.expanded]:d})})]})]})}),t.jsx(J.Collapsible.Content,{className:Le.collapsibleContent,children:t.jsxs("div",{className:Le.content,children:[t.jsx(cj,{chainGroup:e}),u&&t.jsx(fw,{})]})})]})})},dj="_container_g7q2b_1",uj="_section_g7q2b_6",mj="_sectionHeader_g7q2b_14",hj="_sectionTitle_g7q2b_20",fj="_sectionLabel_g7q2b_26",gj="_externalLink_g7q2b_32",pj="_sectionValue_g7q2b_44",_j="_tokenList_g7q2b_51",xj="_tokenTrigger_g7q2b_63",yj="_tokenChevron_g7q2b_79",bj="_expanded_g7q2b_90",wj="_tokenInfo_g7q2b_94",jj="_tokenInfoLabel_g7q2b_100",vj="_tokenLogo_g7q2b_106",Cj="_pairedLogos_g7q2b_110",Nj="_coinLogo_g7q2b_115",kj="_tokenSymbol_g7q2b_133",Ij="_triggerValue_g7q2b_139",Aj="_clammBreakdownContent_g7q2b_146",Sj="_clammPositionRow_g7q2b_154",Tj="_statusDot_g7q2b_163",$j="_inRange_g7q2b_170",Ej="_outRange_g7q2b_174",Mj="_unknown_g7q2b_178",Lj="_clammStatusValue_g7q2b_182",qj="_breakdownContent_g7q2b_192",Pj="_breakdownRow_g7q2b_200",Dj="_breakdownLabel_g7q2b_208",Rj="_breakdownValues_g7q2b_214",Bj="_breakdownAmount_g7q2b_220",Fj="_breakdownValue_g7q2b_214",Uj="_collapsibleContent_g7q2b_241",D={container:dj,section:uj,sectionHeader:mj,sectionTitle:hj,sectionLabel:fj,externalLink:gj,sectionValue:pj,tokenList:_j,tokenTrigger:xj,tokenChevron:yj,expanded:bj,tokenInfo:wj,tokenInfoLabel:jj,tokenLogo:vj,pairedLogos:Cj,coinLogo:Nj,tokenSymbol:kj,triggerValue:Ij,clammBreakdownContent:Aj,clammPositionRow:Sj,statusDot:Tj,inRange:$j,outRange:Ej,unknown:Mj,clammStatusValue:Lj,breakdownContent:qj,breakdownRow:Pj,breakdownLabel:Dj,breakdownValues:Rj,breakdownAmount:Bj,breakdownValue:Fj,collapsibleContent:Uj},Oj=({data:e,denomLogoMap:n})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:t.jsx("div",{className:D.container,children:t.jsxs("div",{className:D.section,children:[t.jsxs("div",{className:D.sectionHeader,children:[t.jsxs("div",{className:D.sectionTitle,children:[t.jsx("span",{className:D.sectionLabel,children:"Liquidity"}),t.jsx("a",{href:aa,target:"_blank",rel:"noopener noreferrer",className:D.externalLink,onClick:a=>a.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:D.sectionValue,children:ee(s)})]}),t.jsx("div",{className:D.tokenList,children:o.map(a=>t.jsx(Qj,{row:a,denomLogoMap:n},a.denom))})]})})},Vj={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"};function Kj(e){return e===void 0?D.unknown:e?D.inRange:D.outRange}function Wj(e){return e===void 0?"Status unavailable":e?"In range":"Out of range"}function Cr(e,n){return e===void 0?"-":`${b.formatNumber(e,{dp:6})} ${n}`}function Hc({isOpen:e,symbol:n,coinLogos:s,singleLogoUrl:o,rightContent:a}){const r=s&&s.length>0&&s.some(i=>i);return t.jsxs("button",{className:D.tokenTrigger,children:[t.jsxs("div",{className:D.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:q(D.tokenChevron,{[D.expanded]:e})}),t.jsxs("div",{className:D.tokenInfoLabel,children:[r?t.jsx("div",{className:D.pairedLogos,children:s.map((i,c)=>t.jsx(ne,{src:i,width:20,height:20,className:D.coinLogo,logo:!0},c))}):o&&t.jsx(ne,{src:o,width:20,height:20,className:D.tokenLogo}),t.jsx("span",{className:D.tokenSymbol,children:n})]})]}),a]})}const zj=({position:e})=>{const n=Kj(e.inRange),s=Wj(e.inRange);return t.jsxs("div",{className:D.clammPositionRow,children:[t.jsxs("div",{className:D.breakdownRow,children:[t.jsx("span",{className:D.breakdownLabel,children:"Position ID"}),t.jsx("div",{className:D.breakdownValues,children:t.jsx("span",{className:D.breakdownAmount,children:e.positionId})})]}),t.jsxs("div",{className:D.breakdownRow,children:[t.jsx("span",{className:D.breakdownLabel,children:"Deposit"}),t.jsx("div",{className:D.breakdownValues,children:t.jsx("span",{className:D.breakdownValue,children:ee(e.value)})})]}),t.jsxs("div",{className:D.breakdownRow,children:[t.jsx("span",{className:D.breakdownLabel,children:"Status"}),t.jsxs("div",{className:D.clammStatusValue,children:[t.jsx("span",{className:q(D.statusDot,n)}),t.jsx("span",{children:s})]})]}),e.isFullRange?t.jsxs("div",{className:D.breakdownRow,children:[t.jsx("span",{className:D.breakdownLabel,children:"Range Bounds"}),t.jsx("div",{className:D.breakdownValues,children:t.jsx("span",{className:D.breakdownAmount,children:"Full range"})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:D.breakdownRow,children:[t.jsx("span",{className:D.breakdownLabel,children:"Min"}),t.jsx("div",{className:D.breakdownValues,children:t.jsx("span",{className:D.breakdownAmount,children:Cr(e.minPrice,e.pricePairLabel)})})]}),t.jsxs("div",{className:D.breakdownRow,children:[t.jsx("span",{className:D.breakdownLabel,children:"Max"}),t.jsx("div",{className:D.breakdownValues,children:t.jsx("span",{className:D.breakdownAmount,children:Cr(e.maxPrice,e.pricePairLabel)})})]})]}),t.jsxs("div",{className:D.breakdownRow,children:[t.jsx("span",{className:D.breakdownLabel,children:"Reward"}),t.jsx("div",{className:D.breakdownValues,children:t.jsx("span",{className:D.breakdownValue,children:ee(e.rewardValue)})})]})]})},Hj=({row:e,denomLogoMap:n})=>{const[s,o]=x.useState(!1),{denom:a,symbol:r,totalValue:i,coinLogos:c,logoUrl:l,clamm:d}=e,m=n.get(a);if(!d)return null;const u=l||m?.assetLogo;return t.jsxs(J.Collapsible.Root,{open:s,onOpenChange:o,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:Hc({isOpen:s,symbol:r,coinLogos:c,singleLogoUrl:u,rightContent:t.jsx("span",{className:D.triggerValue,children:ee(i)})})}),t.jsx(J.Collapsible.Content,{className:D.collapsibleContent,children:t.jsxs("div",{className:D.clammBreakdownContent,children:[t.jsxs("div",{className:D.breakdownRow,children:[t.jsx("span",{className:D.breakdownLabel,children:"Reward"}),t.jsx("div",{className:D.breakdownValues,children:t.jsx("span",{className:D.breakdownValue,children:ee(d.totalRewardValue)})})]}),d.positions.map(h=>t.jsx(zj,{position:h},h.tokenAddress))]})})]})},Gj=({row:e,denomLogoMap:n})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:c,claimableInit:l}=e,[d,m]=x.useState(!1),u=n.get(s),h=i||u?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,g=x.useMemo(()=>Object.entries(r).filter(([,_])=>_>0),[r]),p=l&&Number(l.total)>0;return t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:m,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:Hc({isOpen:d,symbol:o,coinLogos:c,singleLogoUrl:h,rightContent:t.jsx("span",{className:D.triggerValue,children:ee(a)})})}),t.jsx(J.Collapsible.Content,{className:D.collapsibleContent,children:t.jsxs("div",{className:D.breakdownContent,children:[g.map(([_,y])=>{const j=y*f;return t.jsxs("div",{className:D.breakdownRow,children:[t.jsx("span",{className:D.breakdownLabel,children:Vj[_]}),t.jsxs("div",{className:D.breakdownValues,children:[t.jsxs("span",{className:D.breakdownAmount,children:[b.formatNumber(y,{dp:6})," LP"]}),t.jsx("span",{className:D.breakdownValue,children:ee(j)})]})]},_)}),p&&t.jsxs("div",{className:D.breakdownRow,children:[t.jsx("span",{className:D.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:D.breakdownValues,children:[t.jsxs("span",{className:D.breakdownAmount,children:[b.formatNumber(Number(l.total),{dp:6})," ",st]}),t.jsx("span",{className:D.breakdownValue,children:ee(l.totalValue)})]})]})]})})]})},Qj=({row:e,denomLogoMap:n})=>e.clamm?t.jsx(Hj,{row:e,denomLogoMap:n}):t.jsx(Gj,{row:e,denomLogoMap:n}),Yj="_container_1nijk_1",Zj="_section_1nijk_6",Jj="_sectionHeader_1nijk_14",Xj="_sectionTitle_1nijk_20",ev="_sectionLabel_1nijk_26",tv="_externalLink_1nijk_32",nv="_sectionValue_1nijk_44",sv="_tokenList_1nijk_51",ov="_tokenTrigger_1nijk_63",av="_tokenChevron_1nijk_79",rv="_expanded_1nijk_90",iv="_tokenInfo_1nijk_94",cv="_tokenInfoLabel_1nijk_100",lv="_tokenLogo_1nijk_106",dv="_tokenName_1nijk_110",uv="_triggerValue_1nijk_116",mv="_breakdownContent_1nijk_123",hv="_breakdownRow_1nijk_131",fv="_breakdownLabel_1nijk_139",gv="_breakdownValues_1nijk_145",pv="_breakdownAmount_1nijk_151",_v="_breakdownValue_1nijk_145",xv="_collapsibleContent_1nijk_165",le={container:Yj,section:Zj,sectionHeader:Jj,sectionTitle:Xj,sectionLabel:ev,externalLink:tv,sectionValue:nv,tokenList:sv,tokenTrigger:ov,tokenChevron:av,expanded:rv,tokenInfo:iv,tokenInfoLabel:cv,tokenLogo:lv,tokenName:dv,triggerValue:uv,breakdownContent:mv,breakdownRow:hv,breakdownLabel:fv,breakdownValues:gv,breakdownAmount:pv,breakdownValue:_v,collapsibleContent:xv},yv=({data:e})=>{const{totalValue:n,rows:s}=e;return s.length===0?null:t.jsx("div",{className:le.container,children:t.jsxs("div",{className:le.section,children:[t.jsxs("div",{className:le.sectionHeader,children:[t.jsxs("div",{className:le.sectionTitle,children:[t.jsx("span",{className:le.sectionLabel,children:"VIP"}),t.jsx("a",{href:Kl,target:"_blank",rel:"noopener noreferrer",className:le.externalLink,onClick:o=>o.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:le.sectionValue,children:ee(n)})]}),t.jsx("div",{className:le.tokenList,children:s.map(o=>t.jsx(bv,{row:o},`${o.bridgeId}-${o.version}`))})]})})},bv=({row:e})=>{const{name:n,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[c,l]=x.useState(!1),d=a+i;return t.jsxs(J.Collapsible.Root,{open:c,onOpenChange:l,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:le.tokenTrigger,children:[t.jsxs("div",{className:le.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:q(le.tokenChevron,{[le.expanded]:c})}),t.jsxs("div",{className:le.tokenInfoLabel,children:[s&&t.jsx(ne,{src:s,width:20,height:20,className:le.tokenLogo,logo:!0}),t.jsx("span",{className:le.tokenName,children:n})]})]}),t.jsx("span",{className:le.triggerValue,children:ee(d)})]})}),t.jsx(J.Collapsible.Content,{className:le.collapsibleContent,children:t.jsxs("div",{className:le.breakdownContent,children:[o>0&&t.jsxs("div",{className:le.breakdownRow,children:[t.jsx("span",{className:le.breakdownLabel,children:"Locked"}),t.jsxs("div",{className:le.breakdownValues,children:[t.jsxs("span",{className:le.breakdownAmount,children:[b.formatNumber(o,{dp:2})," INIT"]}),t.jsx("span",{className:le.breakdownValue,children:ee(a)})]})]}),r>0&&t.jsxs("div",{className:le.breakdownRow,children:[t.jsx("span",{className:le.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:le.breakdownValues,children:[t.jsxs("span",{className:le.breakdownAmount,children:[b.formatNumber(r,{dp:2})," INIT"]}),t.jsx("span",{className:le.breakdownValue,children:ee(i)})]})]})]})})]})},wv="_container_ymkoc_1",jv="_trigger_ymkoc_6",vv="_expandIcon_ymkoc_22",Cv="_chainInfo_ymkoc_27",Nv="_logo_ymkoc_33",kv="_chainNameContainer_ymkoc_37",Iv="_chainName_ymkoc_37",Av="_externalLink_ymkoc_49",Sv="_externalIcon_ymkoc_53",Tv="_valueColumn_ymkoc_63",$v="_value_ymkoc_63",Ev="_expanded_ymkoc_80",Mv="_collapsibleContent_ymkoc_85",Lv="_content_ymkoc_97",qe={container:wv,trigger:jv,expandIcon:vv,chainInfo:Cv,logo:Nv,chainNameContainer:kv,chainName:Iv,externalLink:Av,externalIcon:Sv,valueColumn:Tv,value:$v,expanded:Ev,collapsibleContent:Mv,content:Lv},qv=H.atom(!1),Pv=()=>{const{totalValue:e}=xa(),{totalValue:n}=to(),{totalValue:s}=no(),o=e+n+s;return t.jsx("span",{className:qe.value,children:ee(o)})},Dv=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=xa(),{data:i}=Fi(),{data:c}=Ui(),l=x.useMemo(()=>{const u=new Map;for(const h of r){if(h.type==="fungible-position"||h.balance.type==="unknown")continue;const{denom:f,symbol:g}=h.balance,p=g.toUpperCase(),_=`${e}:${f}`,y=s.get(_)??o.get(p);y&&u.set(f,{assetLogo:y,chainLogo:n})}return u},[r,s,o,e,n]),d=x.useMemo(()=>(u,h)=>{const f=b.denomToMetadata(u);if(h==="staking"){const g=i?.get(f);return g?b.fromBaseUnit(g.amount,{decimals:Xe}):"0"}if(h==="lockstaking"){const g=c?.get(f);return g?b.fromBaseUnit(g.amount,{decimals:Xe}):"0"}return"0"},[i,c]),m=x.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:aa,positions:r}],[r]);return m.length===0?null:t.jsx(zc,{protocols:m,denomLogoMap:l,isInitia:!0,getClaimableInitByType:d,initPrice:a})},Rv=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o})=>{const a=to(),r=x.useMemo(()=>{const i=new Map;for(const c of a.rows){const{denom:l,symbol:d}=c,m=d.toUpperCase(),u=`${e}:${l}`,h=s.get(u)??o.get(m);h&&i.set(l,{assetLogo:h,chainLogo:n})}return i},[a.rows,s,o,e,n]);return a.rows.length===0?null:t.jsx(Oj,{data:a,denomLogoMap:r})},Bv=()=>{const e=no();return e.rows.length===0?null:t.jsx(yv,{data:e})},Fv=({chainGroup:e})=>{const{chainId:n,chainName:s,chainLogo:o}=e,[a,r]=H.useAtom(qv),i=ue(),c=Xn(),{denomLogos:l,symbolLogos:d}=x.useMemo(()=>ya(c,i),[c,i]),m=oe(),{data:u}=Nt(m),h=x.useMemo(()=>u?.find(g=>g.id===Oe)?.price??0,[u]);return t.jsx("div",{className:qe.container,children:t.jsxs(J.Collapsible.Root,{open:a,onOpenChange:r,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:qe.trigger,children:[t.jsxs("div",{className:qe.chainInfo,children:[o&&t.jsx(ne,{src:o,width:32,height:32,className:qe.logo,logo:!0}),t.jsxs("div",{className:qe.chainNameContainer,children:[t.jsx("span",{className:qe.chainName,children:s}),t.jsx("a",{href:aa,target:"_blank",rel:"noopener noreferrer",className:qe.externalLink,onClick:f=>f.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:qe.externalIcon})})]})]}),t.jsxs("div",{className:qe.valueColumn,children:[t.jsx(fe,{suspenseFallback:t.jsx(ot,{height:16,width:60,length:1}),children:t.jsx(Pv,{})}),t.jsx(S.IconChevronDown,{size:16,className:q(qe.expandIcon,{[qe.expanded]:a})})]})]})}),t.jsx(J.Collapsible.Content,{className:qe.collapsibleContent,children:t.jsxs("div",{className:qe.content,children:[t.jsx(fe,{suspenseFallback:t.jsx(ot,{height:36,length:2}),children:t.jsx(Dv,{chainId:n,chainLogo:o,denomLogos:l,symbolLogos:d,initPrice:h})}),t.jsx(fe,{suspenseFallback:t.jsx(ot,{height:36,length:2}),children:t.jsx(Rv,{chainId:n,chainLogo:o,denomLogos:l,symbolLogos:d})}),t.jsx(fe,{suspenseFallback:t.jsx(ot,{height:36,length:1}),children:t.jsx(Bv,{})})]})})]})})},Uv="_totalValue_1v2ca_1",Ov={totalValue:Uv},Vv=({filteredChainGroups:e})=>{const{totalValue:n}=xa(),{totalValue:s}=to(),{totalValue:o}=no(),a=n+s+o,r=x.useMemo(()=>{const i=e.some(l=>l.isInitia);return e.reduce((l,d)=>d.isInitia?l:l+d.totalValue,0)+(i?a:0)},[e,a]);return t.jsx("span",{className:Ov.totalValue,children:ee(r)})},Kv="_container_1eubu_1",Wv="_header_1eubu_7",zv="_title_1eubu_13",Hv="_list_1eubu_19",Gv="_skeletonWrapper_1eubu_24",On={container:Kv,header:Wv,title:zv,list:Hv,skeletonWrapper:Gv},Qv=x.memo(({searchQuery:e,selectedChain:n,chainInfoMap:s})=>{const{positions:o,isLoading:a}=rs(),r=oe(),{data:i,isLoading:c}=Wc(),l=x.useMemo(()=>{const m=[];for(const h of o){if(!Array.isArray(h.positions))continue;const f=s.get(h.chainName.toLowerCase()),g=h.chainName.toLowerCase(),p=g==="civitia";if(n&&f?.chainId!==n)continue;const _=h.positions.some(I=>I.positions.some(A=>A.type!=="fungible-position")),y=p&&!c&&i&&((i.gold_balance??0)>0||(i.silver_balance??0)>0);if(!_&&!y||e&&!g.includes(e.toLowerCase()))continue;const j=h.positions.filter(I=>e&&!I.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(I.positions)&&I.positions.length>0),C=r.chainId===f?.chainId,w=j.reduce((I,A)=>I+A.positions.reduce((L,E)=>L+Cn(E),0),0);m.push({chainId:f?.chainId??"",chainName:f?.prettyName??h.chainName,chainLogo:f?.logoUrl??"",protocols:j,isInitia:C,totalValue:w})}const u=["civitia","yominet"];return $.sortWith([$.descend(h=>h.isInitia??!1),$.ascend(h=>u.includes(h.chainName.toLowerCase())),$.descend(h=>h.totalValue??0),$.ascend(h=>h.chainName.toLowerCase())],m)},[o,s,e,n,r.chainId,i,c]),d=l.length>0;return t.jsxs("div",{className:On.container,children:[t.jsxs("div",{className:On.header,children:[t.jsx("span",{className:On.title,children:"Positions"}),d&&t.jsx(fe,{suspenseFallback:t.jsx(ot,{height:16,width:60,length:1}),children:t.jsx(Vv,{filteredChainGroups:l})})]}),d?t.jsx("div",{className:On.list,children:l.map(m=>m.isInitia?t.jsx(fe,{suspenseFallback:t.jsx("div",{className:On.skeletonWrapper,children:t.jsx(ot,{height:56,length:1})}),children:t.jsx(Fv,{chainGroup:m})},m.chainName):t.jsx(lj,{chainGroup:m},m.chainName))}):o.length===0&&a?t.jsx(ot,{height:56,length:3}):t.jsx(ge,{children:"No positions"})]})}),Yv="_content_1w1ad_1",Zv={content:Yv},Jv=({selectedChain:e,setSelectedChain:n})=>{const{defaultChainId:s}=se(),o=oe(),a=om(),{totalValue:r}=no(),{chainIds:i,chainIdToValueMap:c,totalBalance:l}=x.useMemo(()=>{const d=new Map;let m=0;for(const h of a)d.set(h.chainId,h.totalBalance),m+=h.totalBalance;return r>0&&(d.set(o.chainId,(d.get(o.chainId)??0)+r),m+=r),{chainIds:$.sortWith([$.descend(h=>h===s),$.descend(h=>h===o.chainId),$.descend(h=>d.get(h)??0)],a.map(h=>h.chainId)),chainIdToValueMap:d,totalBalance:m}},[a,s,o,r]);return t.jsx(mo,{value:e,onChange:n,chainIds:i,renderExtra:d=>ee(d?c.get(d)??0:l)})},Xv=()=>{const[e,n]=H.useAtom(Rc),[s,o]=H.useAtom(Bc),a=ue(),r=Xn(),{denomLogos:i,symbolLogos:c}=x.useMemo(()=>ya(r,a),[r,a]),l=ea(),d=x.useMemo(()=>Ki(a,l),[a,l]),m=sm();return t.jsxs(at.Root,{children:[t.jsxs(at.Controls,{children:[t.jsx(at.SearchInput,{value:e,onChange:u=>n(u.target.value),onClear:()=>n(""),placeholder:"Search portfolio"}),t.jsx(fe,{suspenseFallback:t.jsx(nn,{height:44,width:132}),children:t.jsx(Jv,{selectedChain:s,setSelectedChain:o})})]}),t.jsxs("div",{className:Zv.content,children:[t.jsx(fe,{suspenseFallback:t.jsx(ot,{height:48,length:5}),children:t.jsx(sw,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:c,chainInfoMap:m,chainPrices:d})}),t.jsx(fe,{suspenseFallback:t.jsx(ot,{height:56,length:3}),children:t.jsx(Qv,{searchQuery:e,selectedChain:s,chainInfoMap:m})})]})]})},eC="_totalValue_5pf7e_1",tC="_totalLabel_5pf7e_7",nC="_totalAmount_5pf7e_13",sC="_loading_5pf7e_18",oC="_skeletonWrapper_5pf7e_23",aC="_nav_5pf7e_28",rC="_item_5pf7e_34",iC="_tabs_5pf7e_59",cC="_tab_5pf7e_59",Pe={totalValue:eC,totalLabel:tC,totalAmount:nC,loading:sC,skeletonWrapper:oC,nav:aC,item:rC,tabs:iC,tab:cC},lC=()=>{const{totalValue:e,isLoading:n}=ua();return t.jsx("div",{className:q(Pe.totalAmount,{[Pe.loading]:n}),children:ee(e)})},dC=()=>{const e=am(),n=rm(),s=Vi(),o=e+s+n;return t.jsx("div",{className:Pe.totalAmount,children:ee(o)})},uC=()=>{hc(),tm();const e=ba(),n=Ie(),s=Hs(),o=x.useRef(null);return t.jsx(Uc.Provider,{value:o,children:t.jsxs(lt,{ref:o,children:[t.jsxs("div",{className:Pe.totalValue,children:[t.jsx("div",{className:Pe.totalLabel,children:"Total value"}),t.jsx(fe,{suspenseFallback:t.jsx("div",{className:Pe.skeletonWrapper,children:t.jsx(nn,{height:48,width:120})}),children:e?t.jsx(lC,{}):t.jsx(dC,{})})]}),t.jsxs("div",{className:Pe.nav,children:[t.jsxs(jn,{to:"/send",className:Pe.item,children:[t.jsx(S.IconSend,{size:20}),t.jsx("span",{children:"Send"})]}),t.jsxs(jn,{to:"/bridge",className:Pe.item,children:[t.jsx(S.IconBridge,{size:20}),t.jsx("span",{children:"Bridge/Swap"})]}),t.jsxs(jn,{to:"/receive",className:Pe.item,children:[t.jsx(S.IconQrCode,{size:20}),t.jsx("span",{children:"Receive"})]})]}),t.jsxs($t.Tabs.Root,{value:s,onValueChange:n,children:[t.jsxs($t.Tabs.List,{className:Pe.tabs,children:[t.jsx($t.Tabs.Tab,{className:Pe.tab,value:"/",children:e?"Assets":"Portfolio"}),t.jsx($t.Tabs.Tab,{className:Pe.tab,value:"/nfts",children:"NFTs"}),t.jsx($t.Tabs.Tab,{className:Pe.tab,value:"/activity",children:"Activity"})]}),t.jsx($t.Tabs.Panel,{value:"/",children:e?t.jsx(ew,{}):t.jsx(Xv,{})}),t.jsx($t.Tabs.Panel,{value:"/nfts",children:t.jsx(mb,{})}),t.jsx($t.Tabs.Panel,{value:"/activity",children:t.jsx(G2,{})})]})]})})},mC="_root_th990_1",hC="_collectionName_th990_9",fC="_nftName_th990_13",gC="_chainInfo_th990_17",pC="_attributes_th990_21",_C="_title_th990_24",xC="_count_th990_29",yC="_item_th990_33",bC="_type_th990_39",wC="_value_th990_45",Yt={root:mC,collectionName:hC,nftName:fC,chainInfo:gC,attributes:pC,title:_C,count:xC,item:yC,type:bC,value:wC},jC=()=>{const e=Ie(),n=it(),{attributes:s}=n;return t.jsxs(yt,{title:"NFT details",children:[t.jsx(Ea,{normalizedNft:n,chainIconSize:14,classNames:Yt}),t.jsx(je,{children:t.jsx(de.White,{onClick:()=>e("/nft/send",n),sm:!0,children:"Send"})}),s&&t.jsxs("div",{className:Yt.attributes,children:[t.jsxs("header",{className:Yt.title,children:["Traits ",t.jsxs("span",{className:Yt.count,children:["(",s.length,")"]})]}),t.jsx("div",{children:s.map(({trait_type:o,value:a})=>t.jsxs("div",{className:Yt.item,children:[t.jsx("div",{className:Yt.type,children:o}),t.jsx("div",{className:Yt.value,children:a})]},o))})]})]})};function vC({balances:e,gasPrices:n,gas:s}){return n.map(({denom:o,amount:a})=>{const r=V(a).times(s).toFixed(0,V.ROUND_CEIL),i=e.find(c=>c.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>V(a).gte(o))}function CC({denom:e,balances:n,gasPrices:s,lastFeeDenom:o,gas:a}){const r=n.find(d=>d.denom===e)?.amount??"0",i=vC({balances:n,gasPrices:s,gas:a}),c=i.find(d=>d.denom===o);if(i.length===0)return r;if(e===o&&c){const d=V(r).minus(c.amount);return V.max(d,0).toString()}const l=i.find(d=>d.denom!==e)||i[0];if(!c&&e===l.denom){const d=V(r).minus(l.amount);return V.max(d,0).toString()}return V(r).toString()}const NC=({chain:e,onSelect:n})=>{const s=_l(e);return t.jsx(ms,{assets:s,onSelect:n})},kC=({afterSelect:e})=>{const{watch:n,setValue:s}=we.useFormContext(),{chainId:o,denom:a}=n(),{chainId:r}=n(),[i,c]=x.useState(r),l=rt(i),d=ue(),m=u=>{if(o===i&&a===u){e();return}s("chainId",i),s("denom",u),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(tn.Stack,{children:t.jsx(tn,{chains:d,value:i,onSelect:c})}),t.jsx(fe,{suspenseFallback:t.jsx(ms.Placeholder,{}),children:t.jsx(NC,{chain:l,onSelect:m})},i)]})},IC="_fields_brpej_1",AC="_divider_brpej_11",Nr={fields:IC,divider:AC},SC=ve.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),TC=()=>{const{address:e,initiaAddress:n,estimateGas:s,requestTxSync:o}=We(),{register:a,watch:r,setValue:i,handleSubmit:c,formState:l}=we.useFormContext(),{errors:d}=l,{chainId:m,denom:u,recipient:h,quantity:f,memo:g}=r(),p=rt(m),_=es(p),y=la(p),j=da(p),C=Br(u,p),{data:w}=Nt(p),{decimals:I}=C,A=_.find(K=>K.denom===u)?.amount??"0",L=w?.find(({id:K})=>K===u)?.price,{data:E=0,isLoading:k}=T.useQuery({queryKey:SC.gas({chainId:m,denom:u,recipient:h,initiaAddress:n}).queryKey,queryFn:()=>{const K=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Fa.MsgSend.fromPartial({fromAddress:n,toAddress:b.InitiaAddress(h).bech32,amount:[{denom:u,amount:"1"}]})}];return s({messages:K,chainId:m})},enabled:b.InitiaAddress.validate(h),staleTime:z.INFINITY}),M=Math.ceil(E*on),v=CC({denom:u,balances:_,gasPrices:y,lastFeeDenom:j,gas:M}),N=V(A).isZero(),R=y.some(({denom:K})=>K===u)&&k,P=N||R,{mutate:F,isPending:Q}=T.useMutation({mutationFn:({chainId:K,denom:W,quantity:ye,recipient:pe,memo:$e})=>{const Ae=b.toBaseUnit(ye,{decimals:I}),St=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Fa.MsgSend.fromPartial({fromAddress:n,toAddress:b.InitiaAddress(pe).bech32,amount:[{denom:W,amount:Ae}]})}];return o({messages:St,memo:$e,chainId:K,gas:E,gasAdjustment:on,gasPrices:y,spendCoins:[{denom:W,amount:Ae}],internal:"/"})}}),U=x.useMemo(()=>{if(!f)return"Enter amount";if(d.quantity)return d.quantity.message;if(!h)return"Enter recipient address";if(d.recipient)return d.recipient.message;if(d.memo)return d.memo.message},[f,h,d.quantity,d.recipient,d.memo]);return t.jsx(yt,{title:"Send",children:t.jsxs("form",{onSubmit:c(K=>F(K)),children:[t.jsxs("div",{className:Nr.fields,children:[t.jsx(Oo,{selectButton:t.jsx(Nn,{title:"Select chain and asset",content:K=>t.jsx(kC,{afterSelect:K}),children:t.jsx(_c,{asset:C,chain:p})}),quantityInput:t.jsx(Zn,{balance:A,decimals:I}),balanceButton:t.jsx(fc,{onClick:()=>i("quantity",b.fromBaseUnit(v,{decimals:I}),{shouldValidate:!0}),disabled:P,children:b.formatAmount(A??"0",{decimals:I})}),value:f?L?ee(V(f).times(L)):"$-":"$0"}),t.jsx("div",{className:Nr.divider}),t.jsx(Ca,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...a("memo",{validate:K=>!K||new Blob([K]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),t.jsx(_e.Stack,{children:!g&&t.jsx(_e,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(je,{children:t.jsx(de.White,{type:"submit",loading:(k?"Estimating gas...":!1)||Q,disabled:!!U,children:U??"Confirm"})})]})})},$C=()=>{const e=it(),n=cn(),s=Dt(n),{chain:o=n}=e,a=$.head(s);if(!e.denom&&!a)throw new Error("Asset list not found. This occurs during local development when asset list is not configured. Use asset-specific send buttons instead of the default send button, or register chain in Initia Registry with at least one asset defined.");const r=e.denom??a?.denom,i=we.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return t.jsx(we.FormProvider,{...i,children:t.jsx(TC,{})})};async function Qo(e,n){const s=e.replace("ibc/",""),{class_trace:o}=await G.create({prefixUrl:n}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function EC(e,n){const s=new ft.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await G.create({prefixUrl:n}).post("minievm/evm/v1/call",{json:{sender:b.InitiaAddress("0x1").bech32,contract_addr:b.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function MC(e,n,s){if(n.startsWith("evm/"))return e;const{token_infos:o}=await G.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${n}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function LC({collection_addr:e},{restUrl:n}){const s=await EC(e,n);if(!s.startsWith("ibc/"))return{class_id:`evm/${b.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await Qo(s,n);return o?{class_id:s,class_trace:o}:{class_id:`evm/${b.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function qC(e,n){const{data:s}=await G.create({prefixUrl:n}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(s)}async function PC({object_addr:e,collection_addr:n},{restUrl:s}){const o=await qC(n,s);return o.startsWith("ibc/")?b.InitiaAddress.equals(b.createObjectAddress("0x1",o),n)?{class_id:o,class_trace:await Qo(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await Qo(o,s)}:{class_id:`move/${n.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function DC(e,n){const s=ae.toBase64(Jt.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await G.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function RC(e,n){const{collection:s}=await G.create({prefixUrl:n}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function BC(e,n){const s=ae.toBase64(Jt.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await G.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function kr(e){const n=/^(.*channel-\d+)\/(.*)$/,s=e.match(n);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,o,a]=s;return[o,a]}async function FC({collection_addr:e},n,s){const o=b.InitiaAddress(e).bech32,a=await DC(o,n.restUrl),r=n.metadata?.ibc_channels?.find(({chain_id:p,version:_})=>p===s.chain_id&&_.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,c=i.split(".")[1],l=ae.toBase64(Jt.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await G.create({prefixUrl:n.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),m=d??o,u=await BC(c,n.restUrl),h=await RC(o,n.indexerUrl);if(m===o)return{class_id:m,class_trace:void 0,outgoing_proxy:u};if(d&&h!==i.replace("wasm.","")){const[p,_]=kr(d);return{class_id:o,class_trace:{path:p,base_class_id:_},outgoing_proxy:u}}const[f,g]=kr(a);return{class_id:o,class_trace:{path:f,base_class_id:g},outgoing_proxy:u}}const UC={minimove:PC,minievm:LC,miniwasm:FC};async function OC({nft:e,srcChain:n,intermediaryChain:s}){const o=n.metadata?.is_l1?"minimove":n.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const a=await UC[o](e,n,s);return Object.assign(a,o==="minievm"&&{token_ids:await MC([e.token_id],a.class_id,n.restUrl)})}const VC="_root_1tyvn_1",KC="_collectionName_1tyvn_10",WC="_nftName_1tyvn_15",zC="_chainInfo_1tyvn_19",HC="_fields_1tyvn_24",GC="_chain_1tyvn_19",Po={root:VC,collectionName:KC,nftName:WC,chainInfo:zC,fields:HC,chain:GC},QC=ve.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),YC=()=>{const e=ue(),n=it(),{chain:s,collection_addr:o}=n,{routerApiUrl:a}=se(),r=ss(),i=oe(),{address:c,initiaAddress:l,requestTxSync:d}=We(),{watch:m,setValue:u,handleSubmit:h,formState:f}=we.useFormContext(),{errors:g}=f,p=m(),{recipient:_,dstChainId:y}=p,j=rt(y),C=T.useQuery({queryKey:QC.simulation({collection_addr:o,nft:n,sender:l,recipient:_,srcChain:s,dstChain:j,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const v=Object.assign({from_address:l,from_chain_id:s.chainId,to_address:b.InitiaAddress(_).bech32,to_chain_id:j.chainId,collection_address:o,token_ids:[n.token_id],object_addresses:[n.object_addr]},s.chainId!==j.chainId&&await OC({nft:n,srcChain:s,intermediaryChain:i})),{msgs:N}=await G.create({prefixUrl:a}).post("nft",{json:v}).json();return N.map(B=>r.fromAmino(B))},enabled:b.InitiaAddress.validate(_)}),{data:w,isLoading:I,error:A}=C,L=T.useQueryClient(),{mutate:E,isPending:k}=T.useMutation({mutationFn:async()=>{if(!w)throw new Error("Route not found");await d({messages:w,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{L.invalidateQueries({queryKey:Ma.nfts._def})}}),M=x.useMemo(()=>{if(!_)return"Enter recipient address";if(g.recipient)return g.recipient.message;if(A)return"Route not found"},[_,g.recipient,A]);return t.jsxs("form",{onSubmit:h(()=>E()),children:[t.jsx(Ea,{normalizedNft:n,thumbnailSize:80,classNames:Po}),t.jsxs("div",{className:Po.fields,children:[t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(Nn,{title:"Destination appchain",content:v=>t.jsx(pc,{onSelect:({chainId:N})=>{u("dstChainId",N),v()},list:e,getImage:N=>N.logoUrl,getName:N=>N.name,getKey:N=>N.chainId}),className:q("input",Po.chain),children:[t.jsx(ne,{src:j.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:j.name})]})]}),t.jsx(Ca,{myAddress:c,ref:ls()})]}),t.jsx(je,{children:t.jsx(de.White,{loading:(I?"Finding route...":!1)||k,disabled:!!M,children:M??"Confirm"})})]})},ZC=()=>{const{chain:e}=it(),n=we.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(yt,{title:"Send NFT",children:t.jsx(we.FormProvider,{...n,children:t.jsx(YC,{})})})},Yo=()=>{const e=Ie(),n=Hs(),s=Bt(),{closeDrawer:o}=kt(),{closeModal:a}=Js();x.useEffect(()=>{a(),n.startsWith("/bridge/")&&n!=="/bridge/history"&&e("/bridge"),(n==="/collection"||n.startsWith("/nft"))&&e("/nfts")},[s]);const r=kn();if(x.useEffect(()=>{r("Page View")},[n,r]),n==="/connect")return s?null:t.jsx(xr,{onSuccess:o});if(n==="/blank")return null;if(!s)return t.jsx(xr,{});switch(n){case"/":case"/nfts":case"/activity":return t.jsx(uC,{});case"/send":return t.jsx($C,{},s);case"/receive":return t.jsx(v0,{});case"/nft":return t.jsx(jC,{});case"/nft/send":return t.jsx(ZC,{},s);case"/bridge":return t.jsx(j_,{},s);case"/bridge/preview":return t.jsx(Mx,{});case"/bridge/history":return t.jsx(gx,{});case"/op/withdrawals":return t.jsx(ry,{});case"/tx":return t.jsx(rc,{});case"/autosign/enable":return t.jsx(lg,{});case"/settings":return t.jsx(Z0,{});case"/settings/autosign":return t.jsx(B0,{});case"/deposit":return t.jsx(l0,{});case"/deposit/completed":return t.jsx(Go,{type:"deposit"});case"/withdraw":return t.jsx(d0,{});case"/withdraw/completed":return t.jsx(Go,{type:"withdraw"})}},JC="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",XC=()=>t.jsxs(t.Fragment,{children:[t.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),t.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),t.jsx("link",{rel:"stylesheet",href:JC}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),eN=()=>(Bl(),dd(),ue(),nm(),Vi(),Xn(),cs(),dn(),null),tN=({children:e,...n})=>(x.useEffect(()=>{Lu()},[]),Be.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(XC,{}),t.jsx(qr.Provider,{value:{...Lr,...n},children:t.jsx(zr,{children:t.jsx(Ef,{children:t.jsx(J.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx($f,{children:t.jsxs(yf,{children:[e,t.jsx(im,{}),t.jsx(fe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(eN,{})}),t.jsx(Ym,{children:t.jsx(Yo,{})}),t.jsx(zm,{children:t.jsx(Yo,{})})]})})})})})})]}):null),nN=({bridge:e})=>t.jsx(zr,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(ec.Provider,{value:!!e,children:t.jsx(fe,{children:t.jsx(Yo,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=on;exports.DEFAULT_GAS_PRICE_MULTIPLIER=Mr;exports.InterwovenKit=nN;exports.InterwovenKitProvider=tN;exports.MAINNET=Lr;exports.MoveError=bi;exports.PRIVY_APP_ID=Xo;exports.TESTNET=rl;exports.initiaPrivyWallet=cl;exports.initiaPrivyWalletConnector=il;exports.initiaPrivyWalletOptions=Wn;exports.injectStyles=jm;exports.useAddress=Bt;exports.useHexAddress=An;exports.useInitiaAddress=te;exports.useInterwovenKit=We;exports.usePortfolio=ua;exports.useUsernameQuery=Ei;
|