@initia/interwovenkit-react 2.2.5 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +438 -432
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wa=require("@privy-io/cross-app-connect/rainbow-kit"),ve=require("wagmi"),T=require("@tanstack/react-query"),j=require("@initia/utils"),B=require("bignumber.js"),A=require("ramda"),ye=require("@lukemorales/query-key-factory"),z=require("ky"),_=require("react"),ie=require("@cosmjs/encoding"),Gi=require("@mysten/bcs"),W=require("jotai"),Ha=require("@amplitude/analytics-browser"),t=require("react/jsx-runtime"),ao=require("@cosmjs/amino/build/signdoc"),ro=require("@cosmjs/crypto"),ra=require("@cosmjs/math"),ms=require("@cosmjs/proto-signing"),Ke=require("@cosmjs/stargate"),ia=require("@cosmjs/tendermint-rpc"),Yi=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),It=require("cosmjs-types/cosmos/tx/v1beta1/tx"),pt=require("ethers"),sn=require("@initia/amino-converter"),jn=require("@cosmjs/amino"),Zi=require("cosmjs-types/cosmos/auth/v1beta1/auth"),io=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Ji=require("cosmjs-types/google/protobuf/any"),Ge=require("date-fns"),bo=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),ca=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),la=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),Qa=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),J=require("radix-ui"),Le=require("usehooks-ts"),Ga=require("react-error-boundary"),L=require("clsx"),_e=require("react-hook-form"),ke=require("@base-ui/react/dialog"),Xi=require("xss"),S=require("@initia/icons-react"),rt=require("@react-spring/web"),hs=require("change-case"),ut=require("@base-ui/react/select"),Ps=require("@base-ui/react/collapsible"),da=require("nanoid"),ec=require("react-dom"),tc=require("jotai/utils"),Ya=require("react-merge-refs"),nc=require("react-number-format"),sc=require("react-intersection-observer"),oc=require("@noble/hashes/sha3"),Dt=require("@noble/hashes/utils"),ac=require("qr-code-styling"),ht=require("@base-ui/react"),wt=require("@base-ui/react/tabs"),Qt=require("@base-ui/react/popover"),ua=require("cosmjs-types/cosmos/bank/v1beta1/tx");function rc(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 wo=rc(Ha),on=1.4,Za=1.05,Ja={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"},ic={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},vo="cmbq1ozyc006al70lx4uciz0q",bn={id:vo,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},cc=Wa.toPrivyWalletConnector(bn),lc=Wa.toPrivyWallet(bn),Xa=_.createContext(null);function Y(){const e=_.useContext(Xa);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const K={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function dc(e){if(e instanceof z.HTTPError){const{response:n}=e,s=n.headers.get("content-type")??"";if(A.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(A.path(["code"],e)===4001||A.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const n=A.path(["error","message"],e),s=A.path(["cause","message"],e),o=A.path(["shortMessage"],e);return n||s||o||e.message}return String(e)}async function ft(e){return new Error(await dc(e))}const ps=ye.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function Qn(e){const n=A.path([0,"address"],e);if(!n)throw new Error("URL not found");return n}function uc(e){const{chain_id:n,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,l=o||s,c=a?.png??"",{rpc:d,rest:u,["json-rpc"]:h,indexer:m}=r,f=Qn(d),p=Qn(u),g=Qn(m),x=i?.minitia?.type==="minievm"?Qn(h):void 0;return{...e,chainId:n,name:l,logoUrl:c,rpcUrl:f,restUrl:p,indexerUrl:g,jsonRpcUrl:x}}function de(){const{defaultChainId:e,registryUrl:n,customChain:s}=Y(),{data:o}=T.useSuspenseQuery({queryKey:ps.list(n).queryKey,queryFn:()=>z.create({prefixUrl:n}).get("chains.json").json(),select:a=>(s?[s,...a.filter(i=>i.chain_id!==s.chain_id)]:a).map(uc).toSorted(A.descend(i=>i.chainId===e)),staleTime:K.MINUTE});return o}function er(){const{registryUrl:e}=Y(),{data:n}=T.useSuspenseQuery({queryKey:ps.profiles(e).queryKey,queryFn:()=>z.create({prefixUrl:e}).get("profiles.json").json(),staleTime:K.MINUTE});return n}function Ye(){const e=ae(),n=de(),s=er();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 Ze(e){return Ye()(e)}function Vt(){const{defaultChainId:e}=Y();return Ze(e)}function ae(){const n=de().find(s=>s.metadata?.is_l1);if(!n)throw new Error("Layer 1 not found");return n}function tr(){return({chainId:e})=>T.queryOptions({queryKey:ps.prices(e).queryKey,queryFn:()=>z.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:K.SECOND})}function _t(e){const n=tr();return T.useQuery(n(e))}function Co(){const e=de(),n=tr();return T.useQueries({queries:e.map(s=>n(s))})}const mc=`<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>`,hc=encodeURIComponent(mc),No=`data:image/svg+xml;utf8,${hc}`,wn=ye.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 pc(e){const{base:n,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:l,traces:c}=e,d=o.find(h=>h.denom===a)?.exponent??o.find(h=>h.denom===n)?.exponent??A.head(o)?.exponent??0,u=r?.png??"";return{denom:n,symbol:s,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function nr(){const e=T.useQueryClient();return n=>{const s=n?.metadata?.assetlist;return T.queryOptions({queryKey:wn.list(s).queryKey,queryFn:async()=>s?z.get(s).json():{assets:[]},select:({assets:o})=>{if(!n)return[];const a=o.map(pc);for(const r of a)e.setQueryData(wn.item(n.chainId,r.denom).queryKey,r);return a},staleTime:K.MINUTE})}}function gt(e){const n=nr(),{data:s}=T.useSuspenseQuery(n(e));return s}function Sn(){const e=de(),n=nr();return T.useQueries({queries:e.map(s=>n(s))})}function lt(e){const n=gt(e),s=ae(),o=gt(s),a=or(e);return r=>{const i=n.find(c=>c.denom===r);if(i)return i;const l=o.find(c=>c.denom===a(r));return l?{...l,denom:r}:{denom:r,symbol:"",decimals:0,logoUrl:No}}}function sr(e,n){const s=lt(n),a=T.useQueryClient().getQueryData(wn.item(n.chainId,e).queryKey);return a||s(e)}function or(e){const n=ae(),s=gt(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(l=>l.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?j.getIbcDenom(a,o):""}}function Io(e){const n=ae(),s=z.create({prefixUrl:n.restUrl}),o=T.useSuspenseQueries({queries:e.map(a=>({queryFn:()=>s.get("initia/move/v1/denom",{searchParams:{metadata:a}}).json(),queryKey:wn.denom(n.restUrl,a).queryKey,select:r=>[a,r.denom],staleTime:K.INFINITY}))});return new Map(o.map(({data:a})=>a))}function fc(e){return e.pagination?.next_key??null}async function ar(e,n,s){const o=z.create(n),a=async(r,i)=>{const l=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[s]??[],d=fc(l),u=[...r,...c];return d?a(u,d):u};return a([],null)}const ma="usernames";function gc({restUrl:e,moduleAddress:n}){const{viewFunction:s}=j.createMoveClient(e);async function o(i){if(!j.InitiaAddress.validate(i))return null;const l=await s({moduleAddress:n,moduleName:ma,functionName:"get_name_from_address",typeArgs:[],args:[ie.toBase64(j.InitiaAddress(i,32).bytes)]});return l?l+".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 l=await s({moduleAddress:n,moduleName:ma,functionName:"get_address_from_name",typeArgs:[],args:[Gi.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return l?j.InitiaAddress(l).bech32:null}return{restUrl:e,getUsername:o,getAddress:r,validateUsername:a}}const fs=ye.createQueryKeys("interwovenkit:account",{username:(e,n)=>[e,n],address:(e,n)=>[e,n],balances:(e,n)=>[e,n],txs:(e,n)=>[e,n]});function rr(){const{restUrl:e}=ae(),{usernamesModuleAddress:n}=Y();return gc({restUrl:e,moduleAddress:n})}function ir(){const e=te();return n=>T.queryOptions({queryKey:fs.balances(n.restUrl,e||"").queryKey,queryFn:()=>e?ar(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:n.restUrl},"balances"):[],staleTime:K.SECOND})}function An(e){const n=ir(),{data:s}=T.useSuspenseQuery(n(e));return s}function _c(){const e=de(),n=ir();return T.useQueries({queries:e.map(s=>n(s))})}function xc(e){const n=An(e),s=gt(e),o=lt(e),a=or(e),{data:r}=_t(e),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>s.some(d=>d.denom===c);return A.sortWith([A.descend(({denom:c})=>a(c)==="uinit"),A.descend(({denom:c})=>i(c)),A.descend(({value:c})=>c),A.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>B(d).comparedTo(c)??0,A.descend(({symbol:c})=>c.toLowerCase())],n.filter(({amount:c})=>!B(c).isZero()).map(({amount:c,denom:d})=>{const u=o(d),h=r?.find(({id:f})=>f===u?.denom)?.price??0,m=B(c).times(h).div(B(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:h,value:m}}))}const cr=_.createContext(null);function gs(){return _.useContext(cr)}function lr(){const{location:e}=gs();return e}function _s(){const{path:e}=lr();return e}function Je(){const{state:e={}}=lr();return e}function dr(){const{history:e}=gs();return e}function Ce(){const{navigate:e}=gs();return e}function ko(){const{reset:e}=gs();return e}const nn=({to:e,state:n,shouldReset:s,children:o,onClick:a,...r})=>{const i=Ce(),l=ko(),c=d=>{d.preventDefault(),a?.(d),s?l(e,n):i(e,n)};return t.jsx("button",{type:"button",...r,onClick:c,children:o})},ur=({children:e,initialEntry:n})=>{const[s,o]=_.useState([n??{path:"/"}]),a=s[s.length-1],r=_.useCallback((l,c)=>{o(d=>{if(typeof l=="string")return[...d,{path:l,state:c}];const u=d.length+l;if(u<1)return d;const h=A.take(u,d);return c!==void 0?A.adjust(u-1,m=>({...m,state:c}),h):h})},[]),i=_.useCallback((l,c)=>{o([{path:l,state:c}])},[]);return t.jsx(cr.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},yc="c33b940c24c17e95f7d9d525d508ac61";function jc(){const{disableAnalytics:e}=Y();_.useEffect(()=>{e||wo.init(yc,{autocapture:!1})},[e])}function bc(){const{connector:e}=ve.useAccount(),{defaultChainId:n,disableAnalytics:s}=Y();_.useEffect(()=>{const o=new Ha.Identify;e?.name&&o.set("connector",e.name),n&&o.set("defaultChainId",n),wo.identify(o)},[n,e?.name,s])}function Tn(){const e=_s();return _.useCallback((s,o)=>{wo.track(s,{path:e,...o})},[e])}const st="interwovenkit",Se="uinit",We="INIT",Pe=6,wc="uoinit",vc="omniINIT",mr="https://app.initia.xyz",So=`${mr}/liquidity/my`,Cc=`${mr}/vip/my`,Nc=1e3,hr=60*Nc,pr=60*hr,ha=24*pr,oe={PUBLIC_KEY:`${st}:public-key`,BRIDGE_SRC_CHAIN_ID:`${st}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${st}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${st}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${st}:bridge:dst-denom`,BRIDGE_QUANTITY:`${st}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${st}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${st}:bridge:route-type`,BRIDGE_HISTORY:`${st}:bridge:history`,OP_REMINDER:`${st}:op:reminder`},fr=W.atom(!1),gr=W.atom(!1);function xt(){const e=ko(),[n,s]=W.useAtom(fr),o=W.useSetAtom(gr),a=Tn();return{isDrawerOpen:n,openDrawer:(l,c)=>{l&&e(l,c),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function cn(){const e=ko(),[n,s]=W.useAtom(gr),o=W.useSetAtom(fr),a=Tn();return{isModalOpen:n,openModal:(l,c)=>{l&&e(l,c),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function Ao(){const e=Ce(),{closeDrawer:n}=xt(),{closeModal:s}=cn(),{disconnect:o}=ve.useDisconnect();return()=>{e("/blank"),n(),s(),o(),localStorage.removeItem(oe.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_SRC_DENOM),localStorage.removeItem(oe.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_DST_DENOM),localStorage.removeItem(oe.BRIDGE_QUANTITY),localStorage.removeItem(oe.BRIDGE_SLIPPAGE_PERCENT)}}function Ic(){const e=kt(),n=Vt(),{openModal:s}=cn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,srcOptions:i,recipientAddress:l}=o;if(a.length===0)throw new Error("denoms cannot be empty");const c=r??n.chainId,d=a.map(u=>({denom:u,chainId:c}));s("/deposit",{localOptions:d,remoteOptions:i,recipientAddress:l})}}function kc(){const e=kt(),n=Vt(),{openModal:s}=cn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,dstOptions:i,recipientAddress:l}=o;if(a.length===0)throw new Error("denoms cannot be empty");const c=r??n.chainId,d=a.map(u=>({denom:u,chainId:c}));s("/withdraw",{localOptions:d,remoteOptions:i,recipientAddress:l})}}function To(){const{privyContext:e}=Y(),{address:n}=ve.useAccount();return e?n?!!e.privy.user?.linkedAccounts.map(o=>"address"in o&&o.address).filter(o=>!!o)?.some(o=>j.InitiaAddress.equals(o,n)):!1:!0}function Sc(){const{privyContext:e}=Y(),n=To(),{address:s}=ve.useAccount(),{signMessageAsync:o}=ve.useSignMessage(),a=Ao(),r=!!e?.privy.ready,i=_.useRef(e);_.useEffect(()=>{i.current=e},[e]);const l=async c=>{try{if(!i.current)throw new Error("Privy context not found");i.current.privy.authenticated&&await i.current.privy.logout();const d=await i.current.siwe.generateSiweMessage({chainId:"eip155:1",address:c});if(!d)throw new Error("Failed to generate SIWE message");const u=await o({message:d});await i.current.siwe.loginWithSiwe({signature:u,message:d})}catch{a()}};_.useEffect(()=>{n||r&&s&&l(s)},[n,r,s])}function Ac(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:n}=io.PubKey.decode(e.value);return jn.encodeSecp256k1Pubkey(n)}return ms.decodeOptionalPubkey(e)}function Tc({typeUrl:e,value:n}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Zi.BaseAccount.decode(n),i=Ac(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Ke.accountFromAny({typeUrl:e,value:n})}function $c(e){return e.type==="initia/PubKeyEthSecp256k1"}const Ec={...jn.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function qc(e){if($c(e)){const n=io.PubKey.fromPartial({key:ie.fromBase64(e.value)});return Ji.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(io.PubKey.encode(n).finish())})}return ms.encodePubkey(e)}function _r(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:Ec.ethsecp256k1,value:ie.toBase64(e)}}function Lc(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:_r(e),signature:ie.toBase64(n)}}const $n=()=>{const e=Y();return new ms.Registry([...sn.protoRegistry,...e.protoTypes??[]])},En=()=>{const e=Y();return new Ke.AminoTypes({...sn.aminoConverters,...e.aminoConverters})};class xr{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=`${oe.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(n);if(s)return this.cachedPublicKey=ie.fromHex(s),ie.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(n,ie.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(n,ie.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?ie.fromBase64(s):null}catch{return null}}async getPublicKey(){const n="Sign this message to identify your Initia account.",s=await this.signMessage(n),o=pt.ethers.hashMessage(n),a=pt.ethers.SigningKey.recoverPublicKey(o,s);return ro.Secp256k1.compressPubkey(ie.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=ao.escapeCharacters(ao.sortedJsonStringify(s)),a=await this.signMessage(o),r=ie.fromHex(a.replace("0x","")).subarray(0,-1),l=ro.Secp256k1Signature.fromFixedLength(r).toFixedLength(),c=Lc(await this.getCachedPublicKey(),l);return{signed:s,signature:c}}}function xs(){const e=$n(),n=En(),s=qn(),o=$o();return async function(a,r,i,l,c,d){const u=d?.customSigner??s;if(!u)throw new Error("Signer not initialized");const h=await o(a),{accountNumber:m,...f}=await h.getSequence(r),p=f.sequence+(d?.incrementSequence??0),[g]=await u.getAccounts(),x=qc(_r(g.pubkey)),y=Yi.SignMode.SIGN_MODE_EIP_191,b=i.map(w=>n.toAmino(w)),C=ao.makeSignDoc(b,l,a,c,m,p),{signature:v,signed:N}=await u.signAmino(r,C),$={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:N.msgs.map(w=>n.fromAmino(w)),memo:c}},q=e.encode($),V=ra.Int53.fromString(N.fee.gas).toNumber(),M=ra.Int53.fromString(N.sequence).toNumber(),I=ms.makeAuthInfoBytes([{pubkey:x,sequence:M}],N.fee.amount,V,N.fee.granter,N.fee.payer,y);return It.TxRaw.fromPartial({bodyBytes:q,authInfoBytes:I,signatures:[ie.fromBase64(v.signature)]})}}function qn(){const e=te(),{signMessageAsync:n}=ve.useSignMessage(),s=ae();return _.useMemo(()=>new xr(e,o=>n({message:o}),s.restUrl),[e,n,s.restUrl])}const Ds=new Map,Bs=new Map;function yr(){const e=Ye();return async n=>{if(Ds.has(n))return Ds.get(n);const{rpcUrl:s}=e(n),o=await ia.Comet38Client.create(new ia.HttpClient(s));return Ds.set(n,o),o}}function $o(){const e=$n(),n=En(),s=qn(),o=te(),a=yr();return async r=>{const i=`${o}:${r}`;if(Bs.has(i))return Bs.get(i);if(!s)throw new Error("Signer not initialized");const l=await a(r),c=await Ke.SigningStargateClient.createWithSigner(l,s,{registry:e,aminoTypes:n,accountParser:Tc,broadcastPollIntervalMs:500});return Bs.set(i,c),c}}function jr(){const{connector:e}=ve.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new pt.BrowserProvider(await e.getProvider())}}function br(){const e=te(),n=Ye();return{fetchFeegrant:async(a,r)=>{if(!e)return null;const i=n(a),l=z.create({prefixUrl:i.restUrl});try{const{allowance:c}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${r}`).json();return c}catch{return null}},fetchGrants:async(a,r)=>{if(!e)return[];const i=n(a),l=z.create({prefixUrl:i.restUrl}),{grants:c}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:r}}).json();return c}}}function wr(){const{privyContext:e}=Y(),n=To();if(!(!e||!n))return e.wallets.find(s=>s.connectorType==="embedded")}function ys(){const e=wr();return e?.address?j.InitiaAddress(e.address).bech32:void 0}function vr(){const e=wr(),n=ys(),s=$n(),o=Ye(),a=xs();return async(r,i,l,c,d)=>{if(!e||!n)throw new Error("Embedded wallet not initialized");const u=[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:bo.MsgExec.fromPartial({grantee:n,msgs:l.map(f=>({typeUrl:f.typeUrl,value:s.encode(f)}))})}],h={...c,granter:i},m=new xr(n,e.sign,o(r).restUrl);return await a(r,n,u,h,d,{customSigner:m})}}const vn=ye.createQueryKeys("interwovenkit:autosign",{expirations:(e,n)=>[e,n],grants:(e,n)=>[e,n]});function js(){const e=Y(),n=Vt(),{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 Cr(){const{data:e}=Eo(),n=js();return async(s,o)=>{const a=o.every(i=>{const l=n[s];return l?l.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function Eo(){const e=te(),n=ys(),s=js(),{fetchFeegrant:o,fetchGrants:a}=br();return T.useQuery({queryKey:vn.expirations(e,n).queryKey,queryFn:async()=>{if(!e||!n)return{expiredAtByChain:{},isEnabledByChain:{}};const r={};for(const[l,c]of Object.entries(s))try{const d=await a(l,n);if(!c.every(x=>d.some(y=>y.authorization?.msg===x))){r[l]=null;continue}const h=await o(l,n);if(!h){r[l]=null;continue}const m=d.filter(x=>c.includes(x.authorization.msg)).map(x=>x.expiration),f=h.allowance.expiration,p=[...m,f],g=qo(p);r[l]=g?new Date(g):void 0}catch{r[l]=null}const i={};for(const[l,c]of Object.entries(r))switch(c){case null:i[l]=!1;break;case void 0:i[l]=!0;break;default:i[l]=Ge.isFuture(c);break}return{expiredAtByChain:r,isEnabledByChain:i}},staleTime:K.INFINITY,retry:!1})}function Mc(){const{data:e,refetch:n}=Eo();_.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(l=>l instanceof Date&&Ge.isFuture(l));if(o.length===0)return;const r=qo(o).getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{n()},r+100);return()=>clearTimeout(i)},[e,n])}function qo(e){return e.filter(n=>n!==void 0).toSorted((n,s)=>new Date(n).getTime()-new Date(s).getTime())[0]}const Nr=_.createContext(null),bs=()=>_.useContext(Nr);class Ir extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(n,s,o,a,r,i,l){super(n),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=l}}const Pc=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Rs=new Map;function Dc(e){const n=e.match(Pc);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 Bc(e,n,s){const o=`${e}:${n}`;if(Rs.has(o))return Rs.get(o);try{const a=n==="0x1"?"0x1.json":`${e}/${n}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await z.get(r).json();return Rs.set(o,i),i}catch{return null}}function Rc(e,n,s,o,a,r,i){return new Ir(e,n,s,o,a,r,i)}async function Zt(e,n,s){if(!n.metadata?.is_l1&&n.metadata?.minitia?.type!=="minimove")return await ft(e);const o=Dc(e.message);if(!o)return await ft(e);const a=await Bc(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}`,l=a?.[o.moduleName]?.[o.errorCode],c=l||i,d=!!l;return Rc(c,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const kr="approve",ws=W.atom(),Sr=W.atom(null);function Ar(){const e=W.useAtomValue(ws);if(!e)throw new Error("Tx request not found");return e}function vs(){const e=Ce(),n=te(),{defaultChainId:s,registryUrl:o}=Y(),a=Ye(),{openDrawer:r,closeDrawer:i}=xt(),{openModal:l,closeModal:c}=bs(),d=W.useSetAtom(ws),u=W.useSetAtom(Sr),h=yr(),m=$o(),f=qn(),p=$n(),g=Cr(),x=vr(),y=xs(),b=async({messages:M,memo:I,chainId:w=s})=>{try{return await(await m(w)).simulate(n,M,I)}catch(E){throw await Zt(E,a(w),o)}},C=async({messages:M,memo:I,chainId:w=s})=>{const E=await h(w),U=Ke.QueryClient.withExtensions(E,Ke.setupTxExtension),F=M.map(P=>p.encodeAsAny(P)),[O]=await f.getAccounts(),Z=jn.encodeSecp256k1Pubkey(O.pubkey),H=await m(w),{sequence:R}=await H.getSequence(n);return U.tx.simulate(F,I,Z,R)},v=async({txRequest:M,broadcaster:I})=>{const E={...{memo:"",chainId:s,gas:M.gas||await b(M),gasAdjustment:on,gasPrices:null,spendCoins:[],internal:!1},...M};return new Promise((U,F)=>{d({txRequest:E,resolve:async Z=>{try{const H=await m(E.chainId),R=await I(H,It.TxRaw.encode(Z).finish());U(R),typeof E.internal=="string"&&e(E.internal)}catch(H){F(await Zt(H,a(E.chainId),o))}finally{O()}},reject:Z=>{F(Z),O()}}),E.internal?l({path:"/tx"}):r("/tx");const O=()=>{if(!E.internal){e("/blank"),i();return}c()}})},N=async M=>{const I=M.chainId??s;try{const w=await v({txRequest:M,broadcaster:async(E,U)=>await E.broadcastTxSync(U)});return M.internal&&typeof M.internal!="number"&&(u({txHash:w,chainId:I,status:"loading"}),V({txHash:w,chainId:M.chainId}).then(E=>{u({status:E.code===0?"success":"error",chainId:I,txHash:w})}).catch(()=>{u({status:"error",chainId:I,txHash:w})})),w}catch(w){throw M.internal&&typeof M.internal!="number"&&u({status:"error",chainId:I,error:w}),w}},k=(M,I=30*1e3,w=.5*1e3)=>v({txRequest:M,broadcaster:async(E,U)=>{const F=await E.broadcastTx(U,I,w);if(F.code!==0)throw new Error(F.rawLog);return F}}),$=async M=>{const I=M.chainId??s;try{const{messages:w,memo:E="",fee:U}=M,F=await m(I),Z=await g(I,w)?await x(I,n,w,U,E):await y(I,n,w,U,E);return await F.broadcastTxSync(It.TxRaw.encode(Z).finish())}catch(w){throw await Zt(w,a(I),o)}},q=async(M,I=30*1e3,w=.5*1e3)=>{const E=M.chainId??s;try{const{messages:U,memo:F="",fee:O}=M,Z=await m(E),R=await g(E,U)?await x(E,n,U,O,F):await y(E,n,U,O,F),P=await Z.broadcastTx(It.TxRaw.encode(R).finish(),I,w);if(P.code!==0)throw new Error(P.rawLog);return P}catch(U){throw await Zt(U,a(E),o)}},V=async({chainId:M=s,...I})=>{try{const w=await m(M);return await Tr({...I,client:w})}catch(w){throw await Zt(w,a(M),o)}};return{estimateGas:b,simulateTx:C,requestTxSync:N,requestTxBlock:k,submitTxSync:$,submitTxBlock:q,waitForTxConfirmation:V}}async function Tr({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 Ln=W.atom(null);function $r(){const e=te(),n=js(),{fetchFeegrant:s,fetchGrants:o}=br();return async a=>{const{chainId:r,grantee:i}=a;if(!e)throw new Error("Granter wallet not initialized");const l=await s(r,i),c=await o(r,i),d=l?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:Qa.MsgRevokeAllowance.fromPartial({granter:e,grantee:i})}]:[],u=n[r].filter(h=>c.some(m=>m?.authorization?.msg===h)).map(h=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:bo.MsgRevoke.fromPartial({granter:e,grantee:i,msgTypeUrl:h})}));return[...d,...u]}}function Fc(){const{privyContext:e}=Y(),n=te(),s=ys(),o=js(),{requestTxBlock:a}=vs(),r=T.useQueryClient(),[i,l]=W.useAtom(Ln),{closeDrawer:c}=xt(),d=$r(),u=async()=>{if(s)return s;if(!e)throw new Error("Privy context not available");const h=await e.createWallet({createAdditional:!1});return j.InitiaAddress(h.address).bech32};return T.useMutation({mutationFn:async h=>{if(!i)throw new Error("No pending request");const{chainId:m}=i,f=await u();if(!n||!f)throw new Error("Wallets not initialized");const p=await d({chainId:m,grantee:f}),g=h===0?void 0:Ge.addMilliseconds(new Date,h),x={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:Qa.MsgGrantAllowance.fromPartial({granter:n,grantee:f,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:la.BasicAllowance.encode(la.BasicAllowance.fromPartial({expiration:g})).finish()}})},y=o[m].map(C=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:bo.MsgGrant.fromPartial({granter:n,grantee:f,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:ca.GenericAuthorization.encode(ca.GenericAuthorization.fromPartial({msg:C})).finish()},expiration:g}})})),b=[...p,x,...y];await a({messages:b,chainId:m,internal:!0})},onSuccess:async()=>{await r.invalidateQueries({queryKey:vn.expirations._def}),i?.resolve()},onError:h=>{i?.reject(h)},onSettled:()=>{l(null),c()}})}function Er(e){const n=Y(),s=ys(),o=e?.grantee||s,{requestTxBlock:a}=vs(),r=T.useQueryClient(),i=$r();return T.useMutation({mutationFn:async(l=n.defaultChainId)=>{if(!o)throw new Error("Wallets not initialized");const c=await i({chainId:l,grantee:o});await a({messages:c,chainId:l,internal:e?.internal})},onSuccess:async()=>{const l=[vn.expirations._def,vn.grants._def];for(const c of l)await r.invalidateQueries({queryKey:c})}})}function Uc(){const{defaultChainId:e}=Y(),{openDrawer:n}=xt(),s=W.useSetAtom(Ln),o=Er(),{data:a={expiredAtByChain:{},isEnabledByChain:{}},isLoading:r}=Eo();return{...a,isLoading:r,enable:async(c=e)=>new Promise((d,u)=>{s({chainId:c,resolve:d,reject:u}),n("/autosign/enable")}),disable:async(c=e)=>{await o.mutateAsync(c)}}}function qr(e){return e.assets.reduce((n,{value:s})=>n+(s??0),0)}function Oc(e){return e.assets.reduce((n,{quantity:s})=>n.plus(s),B(0)).toString()}function Vc(e,n){return{symbol:n?.symbol??e,logoUrl:n?.logoUrl??No}}function pa(e){return A.pick(["chainId","name","logoUrl"],e)}function Kc(e){return A.sortWith([A.descend(({symbol:n})=>n===We),A.descend(qr),A.descend(({assets:n})=>n.length),A.ascend(({symbol:n})=>n)])(e)}function zc(e){return A.sortWith([A.descend(({value:n})=>n??0),A.descend(({quantity:n})=>Number(n)),A.ascend(({chain:n})=>n.name)])(e)}function Wc(e,n){return A.sortWith([A.descend(({chain:s})=>s.chainId===n),A.ascend(({chain:s})=>s.name),A.ascend(({denom:s})=>s)])(e)}function Hc(e,n){return A.sortWith([A.descend(({chainId:s})=>s===n),A.descend(A.prop("value"))])(e)}function Qc(e,n,s,o,a){const r=e.find(h=>h.metadata?.is_l1)?.chainId,i={};for(const h of e){const m=h.chainId,f=n[m]??[],p=s[m],g=o[m],x=[];for(const{amount:y,denom:b}of f){if(!B(y).gt(0))continue;const C=p?.find(q=>q.denom===b),v=g?.find(q=>q.id===b)?.price,N=C?.decimals??0,k=j.fromBaseUnit(y,{decimals:N}),$=v?B(k).times(v).toNumber():void 0;x.push({...Vc(b,C),amount:y,denom:b,decimals:N,quantity:k,price:v,value:$,address:C?.address,unlisted:!C,chain:pa(h)})}i[m]=x}const l=new Map;for(const[h,m]of Object.entries(i)){if(m.length===0)continue;const f=e.find(g=>g.chainId===h);if(!f)continue;const p=m.reduce((g,{value:x})=>g+(x??0),0);l.set(h,{...pa(f),value:p})}const c=new Map;for(const h of Object.values(i))for(const m of h)if(!m.unlisted){const{symbol:f}=m,p=c.get(f)??[];c.set(f,[...p,m])}const d=[];for(const[h,m]of c){const f=A.head(m);if(!f)continue;const p=zc(m),g=p.reduce((y,{value:b})=>y+(b??0),0),x=p.reduce((y,{quantity:b})=>y.plus(b),B(0)).toNumber();d.push({symbol:h,logoUrl:f.logoUrl,assets:p,totalValue:g,totalAmount:x})}const u=[];for(const h of Object.values(i))for(const m of h)m.unlisted&&u.push(m);return{chainsByValue:Hc(Array.from(l.values()),a),assetGroups:Kc(d),unlistedAssets:Wc(u,r),totalValue:d.reduce((h,m)=>h+m.totalValue,0)}}function Lo(){const{defaultChainId:e}=Y(),n=de(),s=_c(),o=Sn(),a=Co(),r=n.map(m=>m.chainId),i=A.zipObj(r,s.map(A.prop("data"))),l=A.zipObj(r,o.map(A.prop("data"))),c=A.zipObj(r,a.map(A.prop("data"))),d=Qc(n,i,l,c,e),u=[s,o,a].flat().some(({isLoading:m})=>m);return{...d,isLoading:u,refetch:()=>{s.forEach(({refetch:m})=>m()),o.forEach(({refetch:m})=>m()),a.forEach(({refetch:m})=>m())}}}function te(){const e=ln();return e?j.InitiaAddress(e).bech32:""}function ln(){const{address:e}=ve.useAccount(),n=To();return!e||!n?"":j.InitiaAddress(e).hex}function kt(){const e=Vt(),n=te(),s=ln();return e.metadata?.minitia?.type==="minievm"?s:n}function Lr(){const e=kt(),n=rr();return T.useQuery({queryKey:fs.username(n.restUrl,e).queryKey,queryFn:()=>n.getUsername(e),enabled:!!e,staleTime:K.MINUTE})}function De(){const e=kt(),n=te(),s=ln(),{data:o}=Lr(),a=qn(),r=Ao(),i=Uc(),{isDrawerOpen:l,openDrawer:c}=xt(),{isModalOpen:d}=cn(),u=()=>{c("/")},h=()=>{c("/connect")},m=b=>{c("/bridge",b)},f=Ic(),p=kc(),g=vs();return{address:e,initiaAddress:n,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:l||d,openConnect:h,openWallet:u,openBridge:m,openDeposit:f,openWithdraw:p,disconnect:r,autoSign:i,...g}}const Gc="_status_tn9m1_1",Yc="_error_tn9m1_9",fa={status:Gc,error:Yc},he=({error:e,children:n})=>t.jsx("p",{className:L(fa.status,{[fa.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(Ga.ErrorBoundary,{...e,children:t.jsx(_.Suspense,{fallback:n,children:s})}),Zc="lock_staking";function Mr(e,n){const s=`${n}::lock_staking::StakingAccount`,o=j.createObjectAddress(e,s);return j.InitiaAddress(o).bech32}const Mn=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 Mo(){const{restUrl:e}=ae(),n=te();return T.useSuspenseQuery({queryKey:Mn.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 l=j.denomToMetadata(i.denom),c={denom:i.denom,metadata:l,amount:i.amount,validator:r},d=o.get(l)??[];d.push(c),o.set(l,d)}}return o},staleTime:K.MINUTE})}function Po(){const{restUrl:e}=ae(),{lockStakeModuleAddress:n}=Y(),s=te(),o=s?Mr(s,n):"";return T.useSuspenseQuery({queryKey:Mn.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 l=i.validator_address;for(const c of i.entries)for(const d of c.balance){const u=j.denomToMetadata(d.denom),h={denom:d.denom,metadata:u,amount:d.amount,validator:l,completionTime:c.completion_time},m=r.get(u)??[];m.push(h),r.set(u,m)}}return r},staleTime:K.MINUTE})}function Do(){const{restUrl:e}=ae(),{lockStakeModuleAddress:n}=Y(),s=te();return T.useSuspenseQuery({queryKey:Mn.lockStaking(e,s||"",n).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=j.createMoveClient(e);return await o({moduleAddress:n,moduleName:Zc,functionName:"get_locked_delegations",typeArgs:[],args:[ie.toBase64(j.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},l=a.get(r.metadata)??[];l.push(i),a.set(r.metadata,l)}return a},staleTime:K.MINUTE})}function Pr(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=j.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 Dr(){const{restUrl:e}=ae(),n=te();return T.useSuspenseQuery({queryKey:Mn.stakingRewards(e,n||"").queryKey,queryFn:async()=>n?await z.get(`${e}/initia/distribution/v1/delegators/${n}/rewards`).json():{rewards:[],total:[]},select:Pr,staleTime:K.MINUTE})}function Br(){const{restUrl:e}=ae(),{lockStakeModuleAddress:n}=Y(),s=te(),o=s?Mr(s,n):"";return T.useSuspenseQuery({queryKey:Mn.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await z.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:Pr,staleTime:K.MINUTE})}function Bo(){const e=ae(),n=gt(e),{data:s,isLoading:o}=_t(e),{data:a}=Mo(),{data:r}=Po(),{data:i}=Do(),l=_.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]),c=Io(l),d=_.useMemo(()=>{const f=new Map;if(s)for(const p of s)f.set(p.id,p.price);return f},[s]),u=_.useMemo(()=>{const f=new Map;for(const p of n)f.set(p.denom,p);return f},[n]),h=_.useMemo(()=>{const f=[],p=g=>{const x=u.get(g);return x?{symbol:x.symbol,decimals:x.decimals}:null};for(const[g,x]of a){const y=c.get(g)??x[0]?.denom;if(!y)continue;const b=p(y);if(!b)continue;const C=d.get(y)??0;for(const v of x){const{symbol:N,decimals:k}=b,$=Number(j.fromBaseUnit(v.amount,{decimals:k})),q={type:"asset",denom:y,symbol:N,amount:v.amount,formattedAmount:$,decimals:k,value:$*C};f.push({type:"staking",validator:v.validator,balance:q})}}for(const[g,x]of i){const y=c.get(g);if(!y)continue;const b=p(y);if(!b)continue;const C=d.get(y)??0;for(const v of x){const{symbol:N,decimals:k}=b,$=Number(j.fromBaseUnit(v.amount,{decimals:k})),q={type:"asset",denom:y,symbol:N,amount:v.amount,formattedAmount:$,decimals:k,value:$*C},V=Number(v.releaseTime);f.push({type:"lockstaking",validator:v.validator,releaseTime:Number.isNaN(V)?0:V,balance:q})}}for(const[g,x]of r){const y=c.get(g)??x[0]?.denom;if(!y)continue;const b=p(y);if(!b)continue;const C=d.get(y)??0;for(const v of x){const{symbol:N,decimals:k}=b,$=Number(j.fromBaseUnit(v.amount,{decimals:k})),q={type:"asset",denom:y,symbol:N,amount:v.amount,formattedAmount:$,decimals:k,value:$*C},V=new Date(v.completionTime).getTime(),M=Number.isNaN(V)?0:Math.floor(V/1e3);f.push({type:"unstaking",validator:v.validator,completionTime:M,balance:q})}}return f.filter(g=>g.type!=="fungible-position"&&g.balance.denom===Se)},[a,i,r,c,u,d]),m=_.useMemo(()=>h.reduce((f,p)=>p.type==="fungible-position"||p.balance.type==="unknown"?f:f+(p.balance.value??0),0),[h]);return{positions:h,totalValue:m,isLoading:o}}const Ro=ye.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,n)=>[e,n],lpPrices:(e,n)=>[e,n],pool:(e,n)=>[e,n]});function Jc(e){const n=new Map;for(const s of e){const o=j.denomToMetadata(s.denom),a={...s,metadata:o},r=n.get(o)??[];r.push(a),n.set(o,r)}return n}function Xc(e){const{dexUrl:n}=Y();return T.useSuspenseQuery({queryKey:Ro.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 Rr(){const e=ae(),n=An(e),s=_.useMemo(()=>n.map(a=>a.denom),[n]),{data:o}=Xc(s);return _.useMemo(()=>{const a=n.filter(r=>o.get(r.denom)===!0);return Jc(a)},[n,o])}function Fr(e){const{dexUrl:n}=Y();return T.useSuspenseQuery({queryKey:Ro.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 el(e){const{dexUrl:n}=Y(),s=ae(),o=gt(s),a=_.useMemo(()=>{const l=new Map;for(const c of o)l.set(c.denom,c);return l},[o]),i=T.useSuspenseQueries({queries:e.map(l=>({queryKey:Ro.pool(n,l).queryKey,queryFn:async()=>{try{const c=j.denomToMetadata(l);return(await z.get(`${n}/indexer/dex/v2/pools/${encodeURIComponent(c)}`).json()).pool}catch{return null}},staleTime:K.MINUTE}))}).map(l=>l.data);return _.useMemo(()=>{const l=new Map;return e.forEach((c,d)=>{const u=i[d];if(!u){l.set(c,null);return}if(c===wc){l.set(c,{...u,symbol:vc});return}const h=u.coins.map(m=>a.get(m.denom)?.symbol||m.denom).join("-");l.set(c,{...u,symbol:h})}),l},[e,i,a])}function tl(e,n,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of n){const l=i[0]?.denom;l&&l!==Se&&a.add(r)}for(const r of s.keys())a.add(r);for(const[r,i]of o){const l=i[0]?.denom;l&&l!==Se&&a.add(r)}return Array.from(a)}function nl(e){const n=[];for(const[,s]of e)s&&s!==Se&&n.push(s);return n}function sl(e,n){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>n.get(s.denom)?.logoUrl||"")}function ol(e,n,s){const o=n.get(e)??null,a=o?.symbol||e,r=sl(o,s),i=r.length>0&&r.some(c=>c),l=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:l,coinLogos:i?r:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0}}}function Fs(e,n,s,o,a){for(const[r,i]of e){const l=n.get(r)??i[0]?.denom;if(!l||l===Se)continue;const c=o.get(l);if(c)for(const d of i){const u=String(d.amount),h=c.decimals,m=Number(j.fromBaseUnit(u,{decimals:h})),f=s.get(l)??0,p=m*f;c.breakdown[a]+=m,c.totalAmount+=m,c.totalValue+=p}}}function al(e,n,s,o,a){for(const[r,i]of e){const l=n.get(r);if(!l||l===Se)continue;const c=o.get(l);if(c)for(const d of i){const u=String(d.amount),h=c.decimals,m=Number(j.fromBaseUnit(u,{decimals:h})),f=s.get(l)??0,p=m*f;c.breakdown[a]+=m,c.totalAmount+=m,c.totalValue+=p}}}function rl(e,n,s,o){for(const[a,r]of e){const i=j.denomToMetadata(a),l=n?.get(i),c=l?j.fromBaseUnit(l.amount,{decimals:Pe}):"0",d=s?.get(i),u=d?j.fromBaseUnit(d.amount,{decimals:Pe}):"0",h=Number(c)+Number(u);h>0&&(r.claimableInit={staking:c,lockStaking:u,total:String(h),totalValue:h*o})}}function Fo(){const e=ae(),n=gt(e),s=Rr(),{data:o}=Mo(),{data:a}=Do(),{data:r}=Po(),{data:i}=Dr(),{data:l}=Br(),{data:c}=_t(e),d=_.useMemo(()=>{const y=new Map;for(const b of n)y.set(b.denom,b);return y},[n]),u=_.useMemo(()=>tl(s,o,a,r),[s,o,a,r]),h=Io(u),m=_.useMemo(()=>nl(h),[h]),{data:f}=Fr(m),p=el(m),{rows:g,totalValue:x}=_.useMemo(()=>{const y=c?.find(N=>N.id===Se)?.price??0,b=new Map;for(const N of m)b.set(N,ol(N,p,d));Fs(s,h,f,b,"deposit"),Fs(o,h,f,b,"staking"),al(a,h,f,b,"lockStaking"),Fs(r,h,f,b,"unstaking"),rl(b,i,l,y);const C=Array.from(b.values()).filter(N=>N.totalAmount>0).sort((N,k)=>k.totalValue-N.totalValue),v=C.reduce((N,k)=>N+k.totalValue,0);return{rows:C,totalValue:v}},[m,p,d,s,o,a,r,h,f,i,l,c]);return{totalValue:x,rows:g}}const il=ye.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,n)=>[e,n]});function cl(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 Ur(){const{vipUrl:e}=Y(),n=te();return T.useQuery({queryKey:il.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 ll(){const e=de();return _.useCallback(n=>e.find(({metadata:s})=>s?.op_bridge_id===String(n)),[e])}function Cs(){const{data:e}=Ur(),n=ae(),{data:s}=_t(n),o=ll(),a=_.useMemo(()=>s?.find(c=>c.id===Se)?.price??0,[s]),r=_.useMemo(()=>e?cl(e).map(c=>{const d=o(c.rollup.bridgeId),u=Number(j.fromBaseUnit(String(c.lockedReward),{decimals:Pe})),h=Number(j.fromBaseUnit(String(c.claimableReward),{decimals:Pe})),m=B(j.fromBaseUnit(String(c.lockedReward),{decimals:Pe})).times(a).toNumber(),f=B(j.fromBaseUnit(String(c.claimableReward),{decimals:Pe})).times(a).toNumber();return{bridgeId:c.rollup.bridgeId,version:c.rollup.version,name:d?.name??"",logoUrl:d?.logoUrl,lockedReward:u,lockedRewardValue:m,claimableReward:h,claimableRewardValue:f}}):[],[e,a,o]),i=_.useMemo(()=>r.reduce((l,c)=>l+c.lockedRewardValue+c.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function Or(){const e=Rr(),{data:n}=Mo(),{data:s}=Do(),{data:o}=Po(),{data:a}=Ur(),r=ae(),{data:i}=_t(r),l=_.useMemo(()=>i?.find(g=>g.id===Se)?.price??0,[i]),c=_.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=Io(c),u=_.useMemo(()=>Array.from(d.values()).filter(p=>p!==Se),[d]),{data:h}=Fr(u),m=gt(r),f=_.useMemo(()=>{const p=new Map;for(const g of m)p.set(g.denom,{decimals:g.decimals});return p},[m]);return _.useMemo(()=>{let p=0,g=0;const x=l??0,y=(C,v)=>{const N=d.get(C)??C;if(N===Se)return 0;const k=f.get(N)?.decimals??Pe;return Number(j.fromBaseUnit(v,{decimals:k}))*(h.get(N)??0)};for(const[,C]of n)for(const{denom:v,metadata:N,amount:k}of C)v===Se?p+=Number(j.fromBaseUnit(k,{decimals:Pe}))*x:g+=y(N,k);for(const[C,v]of s){const k=(d.get(C)??C)===Se;for(const{amount:$}of v)k?p+=Number(j.fromBaseUnit($,{decimals:Pe}))*x:g+=y(C,$)}for(const[,C]of o)for(const{denom:v,metadata:N,amount:k}of C)v===Se?p+=Number(j.fromBaseUnit(k,{decimals:Pe}))*x:g+=y(N,k);for(const[C,v]of e)for(const{amount:N}of v)g+=y(C,String(N));let b=0;if(a)for(const C of a){const v=C.total_locked_reward??0,N=C.total_claimable_reward??0;b+=Number(j.fromBaseUnit(String(v+N),{decimals:Pe}))*x}return p+g+b},[n,s,o,e,a,l,d,h,f])}function dl(){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:oe.PUBLIC_KEY,getSuffix:s=>j.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[l,c]of Object.entries(i)){const d=`${o}:${a(l)}`;localStorage.setItem(d,c)}localStorage.removeItem(s)}catch{}}}const co=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 Uo(e,n){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=n[a],l=r.data;if(!(!i||!l)){for(const c of l)if(c.logoUrl&&!c.logoUrl.includes("undefined")){const d=`${i.chainId}:${c.denom}`;s.has(d)||s.set(d,c.logoUrl);const u=c.symbol.toUpperCase();o.has(u)||o.set(u,c.logoUrl)}}}return{denomLogos:s,symbolLogos:o}}function an(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 ul(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 ml(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 hl(e){const n=new Map;for(const d of e){const u=ul(d);if(!u)continue;const h=n.get(u)??[];h.push(d),n.set(u,h)}const s=new Map,o=new Map;for(const[d,u]of n){const h=u.reduce((f,p)=>f+an(p),0),m=u.reduce((f,p)=>f+Math.abs(an(p)),0);s.set(d,h),o.set(d,m)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,l=[...n.keys()].sort((d,u)=>{const h=d==="lending"||d==="borrowing"?i:o.get(d)??0,m=u==="lending"||u==="borrowing"?i:o.get(u)??0;return(d==="lending"||d==="borrowing")&&(u==="lending"||u==="borrowing")?d==="lending"?-1:1:m-h}),c=new Map;for(const d of l)c.set(d,{positions:n.get(d),totalValue:s.get(d)??0});return c}function pl(e){return e.type==="fungible-position"?e.title:e.balance.denom}function fl(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function gl(e){return e.type==="fungible-position"?null:e.balance}function _l(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 xl(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 yl(e,n){return e.symbol===We&&n.symbol===We?0:e.symbol===We?-1:n.symbol===We?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function jl(e){const n=new Map;for(const o of e){const a=pl(o),r=n.get(a)??[];r.push(o),n.set(a,r)}return Array.from(n.entries()).map(([o,a])=>{const r=gl(a[0]);let i=0;for(const l of a)l.type!=="fungible-position"&&l.balance.type!=="unknown"&&(i+=l.balance.formattedAmount);return{denom:o,symbol:fl(a[0]),positions:a,totalValue:a.reduce((l,c)=>l+an(c),0),totalAmount:i,balance:r}}).toSorted(yl)}function Vr(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(l=>[l.id,l.price]));s.set(o.chainId,i)}}),s}function bl(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 wl(e,n){return e.symbol===We&&n.symbol===We?0:e.symbol===We?-1:n.symbol===We?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function vl(e,n,s){return e.map(o=>{const a=o.assets.map(i=>{const l=i.symbol.toUpperCase(),c=`${i.chain.chainId}:${i.denom}`,d=n.get(c)??s.get(l)??"";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 Cl(e,n,s){const o=n?e.filter(i=>{const{symbol:l,assets:c}=i,d=n.toLowerCase();return l.toLowerCase().includes(d)||c.some(({denom:u})=>u.toLowerCase().includes(d))}):e,a=s?o.map(i=>{const l=i.assets.filter(({chain:c})=>c.chainId===s);return{...i,assets:l,totalValue:l.reduce((c,d)=>c+(d.value??0),0),totalAmount:l.reduce((c,d)=>c+Number(d.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,l)=>i+l.assets.reduce((c,d)=>c+(d.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Nl(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 Il(e,n,s,o){const{filteredAssets:a,totalAssetsValue:r}=Cl(e,s,o),i=Nl(n,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function kl(e,n,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const l of e){const{chainName:c,chainId:d,balances:u}=l;if(!Array.isArray(u))continue;const h=n.get(c.toLowerCase()),m=h?.chainId??d??c,f=h?.prettyName??c,p=h?.logoUrl??"",g=s.get(m);for(const x of u){if(x.type==="unknown"){if(!x.amount||x.amount==="0")continue;r.push({symbol:x.denom,logoUrl:"",denom:x.denom,amount:x.amount,decimals:0,quantity:x.amount,value:void 0,unlisted:!0,chain:{chainId:m,name:f,logoUrl:p}});continue}if(x.type==="lp"||(x.value??0)<=0&&(x.formattedAmount??0)<=0)continue;let y=x.value;if((y==null||y<=0)&&g){const v=g.get(x.denom)??0;v>0&&(y=x.formattedAmount*v)}const b={symbol:x.symbol,logoUrl:"",denom:x.denom,amount:x.amount,decimals:x.decimals,quantity:String(x.formattedAmount),value:y,chain:{chainId:m,name:f,logoUrl:p}},C=a.get(x.symbol);C?C.push(b):a.set(x.symbol,[b])}}r.sort((l,c)=>{const d=l.chain.chainId===o,u=c.chain.chainId===o;if(d&&!u)return-1;if(!d&&u)return 1;const h=l.chain.name.localeCompare(c.chain.name);if(h!==0)return h;try{const m=BigInt(l.amount),f=BigInt(c.amount);if(m>f)return-1;if(m<f)return 1}catch{const m=l.amount.localeCompare(c.amount);if(m!==0)return-m}return l.denom.localeCompare(c.denom)});const i=[];for(const[l,c]of a){c.sort((h,m)=>(m.value??0)-(h.value??0));let d=0,u=0;for(const h of c)d+=h.value??0,u+=Number(h.quantity);i.push({symbol:l,logoUrl:"",assets:c,totalValue:d,totalAmount:u})}return i.sort(wl),{listedGroups:i,unlistedAssets:r}}function Oo(){return ae().network_type==="testnet"}function St(){return _e.useFormContext()}function Sl(){const e=Je(),n=Oo(),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=A.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(oe.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(oe.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(oe.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(oe.BRIDGE_DST_DENOM),quantity:localStorage.getItem(oe.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(oe.BRIDGE_SLIPPAGE_PERCENT)});return{...n?o:a,...r,...e}}const Al={balances:[],positions:[],isLoading:!0,isComplete:!1},Kr=W.atom(0),Tl=1e3;let ga=0;function $l(){const e=W.useSetAtom(Kr);_.useEffect(()=>{const n=Date.now();n-ga>=Tl&&(ga=n,e(s=>s+1))},[e])}function El(){const e=T.useQueryClient(),n=te(),{minityUrl:s}=Y(),o=Oo(),a=W.useAtomValue(Kr),r=_.useEffectEvent((c,d)=>{const u=Array.isArray(c.balances)?c.balances:[];d.set(c.chain,{chainName:c.chain,chainId:c.chainId,balances:u})}),i=_.useEffectEvent((c,d)=>{const u=Array.isArray(c.positions)?c.positions:[];d.set(c.chain,{chainName:c.chain,chainId:c.chainId,positions:u})}),l=_.useEffectEvent((c,d)=>{const u=co.ssePortfolio(n??"",s).queryKey,h=e.getQueryData(u)??Al,m=c.size>0||d.size>0;e.setQueryData(u,{...h,balances:Array.from(c.values()),positions:Array.from(d.values()),isLoading:m?!1:h.isLoading,isComplete:!1})});_.useEffect(()=>{if(!n||o)return;const c=co.ssePortfolio(n,s).queryKey,d=e.getQueryData(c),u=new Map,h=new Map;for(const x of d?.balances??[])u.set(x.chainName,x);for(const x of d?.positions??[])h.set(x.chainName,x);const f=`${s}/v1/chain/all/${encodeURIComponent(n)}`;let p=null,g=!1;return e.setQueryData(c,{balances:d?.balances??[],positions:d?.positions??[],isLoading:!0,isComplete:!1}),p=new EventSource(f),p.onmessage=x=>{if(!g)try{const y=JSON.parse(x.data);y.type==="balances"?r(y,u):y.type==="positions"&&i(y,h),l(u,h)}catch{}},p.onerror=()=>{p?.close()},()=>{g=!0,p?.close()}},[n,o,a])}const _a={balances:[],positions:[],isLoading:!0,isComplete:!1};function Pn(){const e=te(),{minityUrl:n}=Y(),s=co.ssePortfolio(e??"",n).queryKey,{data:o}=T.useQuery({queryKey:s,queryFn:()=>_a,enabled:!!e,staleTime:K.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??_a}function ql(){const e=de();return _.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 Ll(){const{balances:e,positions:n}=Pn(),s=de(),o=_.useMemo(()=>{const r=new Map;for(const i of s)r.set(i.chain_name.toLowerCase(),i);return r},[s]);return _.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 x=g.balance.value??0;return g.type==="lending"&&g.direction==="borrow"?p-x:p+x},0),l=new Map,c=Array.isArray(e)?e:[],d=Array.isArray(n)?n:[];for(const{chainName:f,balances:p}of c){if(!Array.isArray(p))continue;const g=p.reduce((x,y)=>x+r(y),0);l.set(f,(l.get(f)||0)+g)}for(const{chainName:f,positions:p}of d){if(!Array.isArray(p))continue;const g=p.reduce((x,y)=>x+i(y),0);l.set(f,(l.get(f)||0)+g)}const u=Array.from(l.values()).reduce((f,p)=>f+p,0),h=Array.from(l.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:u>0?p/u:0}}).filter(f=>f.chainId!==""),m=f=>f.chainName.toLowerCase()==="initia";return A.sortWith([A.descend(m),A.descend(A.prop("totalBalance"))],h)},[e,n,o])}function Ml(){const{balances:e}=Pn(),n=de(),s=Co(),o=_.useMemo(()=>Vr(n,s),[n,s]);return _.useMemo(()=>{const a=c=>c.type==="unknown"?0:c.value??0;let r=0;const i=Array.isArray(e)?e:[],l=bl(i,o);for(const{balances:c}of l)if(Array.isArray(c))for(const d of c)d.type!=="lp"&&(r+=a(d));return r},[e,o])}function Pl(){const{positions:e}=Pn();return _.useMemo(()=>{const n=r=>r.positions.reduce((i,l)=>{if(l.type==="fungible-position")return i+(l.value??0);if(l.balance.type==="unknown")return i;const c=l.balance.value??0;return l.type==="lending"&&l.direction==="borrow"?i-c:i+c},0),s=["initia","civitia","yominet"];let o=0;const a=Array.isArray(e)?e:[];for(const{chainName:r,positions:i}of a){const l=r.toLowerCase();s.includes(l)||Array.isArray(i)&&(o+=i.reduce((c,d)=>c+n(d),0))}return o},[e])}const qe=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 Xe(){const{routerApiUrl:e}=Y();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function zr(){const e=de();return n=>e.some(s=>s.chain_id===n)}function Dn(){const e=zr();return n=>e(n.chain_id)?"initia":n.chain_type}function Cn(e){return Dn()(e)}function Bn(){const e=Xe(),{data:n}=T.useSuspenseQuery({queryKey:qe.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>A.sortWith([A.descend(({chain_name:o})=>o==="initia"),A.ascend(({pretty_name:o})=>o)],s),staleTime:K.MINUTE});return n}function yt(){const e=Bn(),n=er();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 ze(e){return yt()(e)}function Kt(){const e=Xe(),n=Bn(),s=T.useQueryClient(),{data:o}=T.useSuspenseQuery({queryKey:qe.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(c=>c.chain_id===i))continue;const{assets:l}=a[i]??{assets:[]};s.setQueryData(qe.assets(i).queryKey,{chain_to_assets_map:a}),r.push(...l);for(const c of l)s.setQueryData(qe.asset(i,c.denom).queryKey,c)}return r},staleTime:K.MINUTE});return o}function is(e){const n=Xe(),s=T.useQueryClient(),{data:o}=T.useSuspenseQuery({queryKey:qe.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(qe.asset(e,i.denom).queryKey,i);return r.toSorted(A.descend(i=>i.symbol==="INIT"))},staleTime:K.MINUTE});return o}function Wr(e){const n=is(e);return s=>{const o=n.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function it(e,n){return Wr(n)(e)}const Dl=()=>(jc(),bc(),null),Bl="_loader_1vxch_1",Rl={loader:Bl},ct=({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:Rl.loader,style:o})},Fl="_button_1q027_1",Ul="_outline_1q027_28",Ol="_sm_1q027_46",Vl="_full_1q027_53",Kl="_small_1q027_57",zl="_unpadded_1q027_88",Bt={button:Fl,outline:Ul,sm:Ol,full:Vl,small:Kl,unpadded:zl},Hr=e=>{const{sm:n,fullWidth:s,loading:o,className:a,children:r,disabled:i,...l}=e;return t.jsx("button",{...l,className:L(Bt.button,{[Bt.sm]:n,[Bt.full]:s},a),disabled:!!o||i,children:o?t.jsxs(t.Fragment,{children:[t.jsx(ct,{color:"currentColor",size:16}),typeof o=="string"&&t.jsx("span",{className:Bt.loading,children:o})]}):r})},Wl=({className:e,...n})=>t.jsx(Hr,{...n,className:L(Bt.outline,e)}),Hl=({className:e,unpadded:n,...s})=>t.jsx("button",{...s,className:L(Bt.small,{[Bt.unpadded]:n},e)}),le={White:Hr,Outline:Wl,Small:Hl},Ql="_footer_1vp4h_1",Gl="_actions_1vp4h_10",xa={footer:Ql,actions:Gl},xe=({extra:e,className:n,children:s})=>t.jsxs("footer",{className:L(xa.footer,n),children:[e,t.jsx("div",{className:xa.actions,children:s})]}),Yl="_scrollable_13su7_1",Zl={scrollable:Yl},et=({className:e,children:n,ref:s})=>t.jsx("div",{ref:s,className:L(Zl.scrollable,e),children:n});function Ns(){return Le.useMediaQuery("(max-width: 576px)")}const lo="interwoven-kit";function Qr(){const e=document.querySelector(lo)||document.body.appendChild(document.createElement(lo));return e.shadowRoot||e.attachShadow({mode:"open"})}function Gr(){const{theme:e,container:n}=Y();return _.useEffect(()=>{document.querySelector(lo)?.setAttribute("data-theme",e)},[e]),n??Qr()}function Jl(e){const n=Qr(),s=document.createElement("style");s.textContent=e,n.appendChild(s)}const Is=_.createContext(null);function Ot(){const{container:e}=_.useContext(Is);return e}function Yr(e){const n=Ot();return n?getComputedStyle(n).getPropertyValue(e):""}function Xl(){return Le.useScrollLock(),null}function ed(e){return/^[A-F0-9]{64}$/i.test(e)}function td(e,n){const{txHash:s,accountAddress:o,pathSuffix:a}=n;if(s)return ed(s)?A.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!j.InitiaAddress.validate(o))return;const i=A.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function nd(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 sd="_link_j1lkz_1",ya={link:sd},ks=({chainId:e,txHash:n,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:l,onClick:c,...d}=a,u=Ze(e),h=td(u,{txHash:n,accountAddress:s,pathSuffix:o}),m=n?j.truncate(n):s?j.truncate(s):"",f=l??m;return h?t.jsxs("a",{...d,href:Xi(nd(h)),className:L(ya.link,i),onClick:c,target:"_blank",children:[f,r&&t.jsx(S.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:L(ya.link,i),children:f})},Zr=_.createContext(null),Ss=()=>_.useContext(Zr),od=()=>{const[e,n]=W.useAtom(Sr),{showNotification:s,updateNotification:o,hideNotification:a}=Ss();return _.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(ks,{txHash:l,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},cs=({value:e,children:n})=>{const[s,o]=_.useState(!1);return n({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},ad="_placeholder_10r3x_1",rd="_logo_10r3x_5",ja={placeholder:ad,logo:rd},X=({src:e,alt:n,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[l,c]=_.useState(void 0),{width:d,height:u}=i,h=s??t.jsx("div",{className:L(ja.placeholder,o?.placeholder),style:{width:d,height:u,...a}});return!e||l===e?h:t.jsx("img",{...i,className:L(i.className,{[ja.logo]:r}),style:{width:d,height:u,...a},src:e,alt:n,loading:"lazy",onError:()=>c(e)})};function Jr(){const{connector:e}=ve.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const id="_header_1q8ju_1",cd="_account_1q8ju_17",ld="_name_1q8ju_28",dd="_address_1q8ju_32",ud="_icon_1q8ju_36",md="_copied_1q8ju_43",hd="_button_1q8ju_58",pd="_settings_1q8ju_69",fd="_disconnect_1q8ju_73",gd="_label_1q8ju_83",_d="_expanded_1q8ju_91",Fe={header:id,account:cd,name:ld,address:dd,icon:ud,copied:md,button:hd,settings:pd,disconnect:fd,label:gd,expanded:_d},xd=()=>{const e=Ao(),{address:n,username:s}=De(),o=Jr(),a=s??n,[r,i]=_.useState(!1),l=_.useRef(null),c=rt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{r?e():i(!0)},u=()=>{r&&(l.current=setTimeout(()=>{i(!1)},500))},h=()=>{l.current&&(clearTimeout(l.current),l.current=null)};return _.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]),n?t.jsxs("header",{className:Fe.header,children:[t.jsx(cs,{value:n,children:({copy:m,copied:f})=>t.jsxs("button",{className:L(Fe.account,{[Fe.copied]:f}),onClick:m,children:[t.jsx(X,{src:o,width:18,height:18}),t.jsx("div",{className:Fe.address,children:j.truncate(n)}),t.jsx("div",{className:Fe.name,children:j.truncate(a)}),t.jsx(S.IconCopy,{className:Fe.icon,size:12}),f?"Copied!":""]})}),t.jsx(nn,{to:"/settings",className:L(Fe.button,Fe.settings),"aria-label":"Open settings",children:t.jsx(S.IconSettingFilled,{size:16})}),t.jsxs(rt.animated.button,{className:L(Fe.button,Fe.disconnect,{[Fe.expanded]:r}),style:c,onClick:d,onMouseLeave:u,onMouseEnter:h,children:[t.jsx(S.IconSignOut,{size:16}),t.jsx("span",{className:Fe.label,children:"Disconnect"})]})]}):null},yd="_overlay_jij9g_1",jd="_content_jij9g_28",bd="_inner_jij9g_60",Us={overlay:yd,content:jd,inner:bd},wd=({children:e})=>{const{isDrawerOpen:n,closeDrawer:s}=xt(),{setContainer:o}=_.useContext(Is),a=Ns(),r=Gr(),i=W.useAtomValue(ws),l=W.useAtomValue(Ln),c=T.useIsMutating({mutationKey:[kr]}),d=()=>{const p=c?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),i?.reject(new Error(p)),l?.reject(new Error("User rejected"))},u=_s(),h=Ce(),m=T.useQueryClient(),f={fallbackRender:({error:p,resetErrorBoundary:g})=>{const x=()=>{u==="/bridge"&&(localStorage.removeItem(oe.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_SRC_DENOM),localStorage.removeItem(oe.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_DST_DENOM)),h("/"),m.clear(),g()};return t.jsxs(et,{children:[t.jsx(he,{error:!0,children:p.message}),t.jsx(xe,{children:t.jsx(le.White,{onClick:x,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:Us.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:Us.content,children:t.jsxs("div",{className:L(Us.inner,"body"),ref:o,children:[a&&t.jsx(Xl,{}),t.jsx(od,{}),t.jsx(xd,{}),t.jsx(me,{errorBoundaryProps:f,children:e})]})})]})})},vd="_backdrop_1bqx9_1",Cd="_modal_1bqx9_12",Nd="_closeButton_1bqx9_44",Os={backdrop:vd,modal:Cd,closeButton:Nd},Id=({children:e})=>{const{isModalOpen:n,closeModal:s}=cn(),{setContainer:o}=_.useContext(Is),a=Gr();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:Os.backdrop,onClick:s}),t.jsxs(ke.Dialog.Popup,{className:L(Os.modal),ref:o,children:[t.jsx("button",{className:Os.closeButton,onClick:s,"aria-label":"Close",children:t.jsx(S.IconClose,{size:20})}),e]})]})})},Xr=_.createContext(!1),kd="_overlay_1iyfl_1",Sd="_fullscreen_1iyfl_15",Ad="_content_1iyfl_19",Td="_header_1iyfl_56",$d="_title_1iyfl_65",Ed="_close_1iyfl_70",$t={overlay:kd,fullscreen:Sd,content:Ad,header:Td,title:$d,close:Ed},ei=({title:e,children:n,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=Ot(),l=_.useContext(Xr);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:L($t.overlay,{[$t.fullscreen]:l}),onClick:()=>r(!1),forceRender:!0}),t.jsxs(ke.Dialog.Popup,{className:L($t.content,{[$t.fullscreen]:l}),children:[e&&t.jsxs("header",{className:$t.header,children:[t.jsx(ke.Dialog.Title,{className:$t.title,children:e}),t.jsx(ke.Dialog.Close,{className:$t.close,children:t.jsx(S.IconClose,{size:20})})]}),n]})]})]}):null},Nn=({children:e})=>{const n=_.useRef(null),[s,o]=_.useState(0),[a,r]=_.useState(!1),i=rt.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return _.useEffect(()=>{const l=n.current;if(!l)return;const c=()=>{const{height:u}=l.getBoundingClientRect();o(u),r(!0)};c();const d=new ResizeObserver(c);return d.observe(l),()=>d.disconnect()},[e]),e?t.jsx(rt.animated.div,{style:{overflow:"hidden",...i},children:t.jsx("div",{ref:n,children:e})}):null},qd="_help_qcmtq_1",Ld="_icon_qcmtq_10",Md="_info_qcmtq_19",Pd="_warning_qcmtq_23",Dd="_error_qcmtq_27",Bd="_success_qcmtq_33",Vs={help:qd,icon:Ld,info:Md,warning:Pd,error:Dd,success:Bd},Jt=({level:e,className:n,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return t.jsx(ct,{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:L(Vs.help,e&&Vs[e],n),style:{marginTop:s},children:[t.jsx("div",{className:Vs.icon,children:a()}),o]})},Rd="_stack_a6m7u_1",Fd="_help_a6m7u_6",Ud="_info_a6m7u_14",Od="_warning_a6m7u_19",Vd="_error_a6m7u_24",Kd="_success_a6m7u_29",uo={stack:Rd,help:Fd,info:Ud,warning:Od,error:Vd,success:Kd},zd=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(Nn,{children:t.jsx("div",{className:uo.stack,children:e})}),fe=({mt:e=0,...n})=>t.jsx(Jt,{...n,className:L(uo.help,uo[n.level]),mt:e});fe.Stack=zd;const Wd="_root_16p5j_1",Hd="_item_16p5j_10",Qd="_chevron_16p5j_14",Gd="_trigger_16p5j_19",Yd="_content_16p5j_39",mn={root:Wd,item:Hd,chevron:Qd,trigger:Gd,content:Yd};function Zd(e){const{list:n,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return t.jsxs(J.Accordion.Root,{className:mn.root,type:"multiple",...i,children:[n.map((l,c)=>t.jsxs(J.Accordion.Item,{className:mn.item,value:s?.(l)??String(c),children:[t.jsx(J.Accordion.Header,{children:t.jsxs(J.Accordion.Trigger,{className:mn.trigger,children:[o(l),t.jsx(S.IconChevronDown,{className:mn.chevron,size:16})]})}),t.jsx(J.Accordion.Content,{className:mn.content,children:a(l)})]},s?.(l)??c)),r]})}const Jd=10;function ti(){const e=te();return(n,s)=>T.queryOptions({queryKey:fs.txs(n.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Jd},{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 Xd(e,n){const s=ti();return T.useSuspenseQuery(s(e,n))}function eu(e,n){const s=e.flatMap((o,a)=>(n[a]??[]).map(i=>({...i,chain:o})));return A.sortWith([A.descend(o=>new Date(o.timestamp).getTime())])(s)}const tu=()=>{const e=de(),n=ti(),s=T.useQueries({queries:e.map(i=>n(i,{enabled:!0}))}),o=s.map(A.prop("data")),a=eu(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};function Vo(e){const{data:n}=T.useSuspenseQuery({queryKey:ps.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:s}=e,{gas_prices:o}=await z.create({prefixUrl:s}).get("initia/tx/v1/gas_prices").json();return o.toSorted(A.descend(({denom:a})=>a==="uinit")).map(({denom:a,amount:r})=>{const i=a==="uinit"?1:Za;return{amount:B(r).times(i).toFixed(18),denom:a}})}return e.fees.fee_tokens.map(({denom:s,fixed_min_gas_price:o})=>{if(A.isNil(o))throw new Error(`${s} has no price`);return{amount:String(o),denom:s}})},staleTime:K.SECOND});return n}function Ko(e){const n=te(),{data:s}=Xd(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=>j.InitiaAddress.equals(n,pt.computeAddress(`0x${ie.toHex(ro.Secp256k1.uncompressPubkey(ie.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const nu="_trigger_u613p_1",su="_icon_u613p_18",ou="_content_u613p_27",au="_item_u613p_36",ru="_itemText_u613p_52",iu="_itemIndicator_u613p_57",cu="_active_u613p_60",vt={trigger:nu,icon:su,content:ou,item:au,itemText:ru,itemIndicator:iu,active:cu};function zo({options:e,value:n,onChange:s,classNames:o}){const a=Ot(),r=e.find(l=>l.value===n);if(!r)throw new Error("Selected option not found");const i=l=>{const c=e.find(d=>String(d.value)===l);if(!c)throw new Error(`Option not found: ${l}`);s(c.value)};return t.jsxs(ut.Select.Root,{value:String(n),onValueChange:i,modal:!1,children:[t.jsxs(ut.Select.Trigger,{className:L(vt.trigger,o?.trigger),children:[t.jsx(ut.Select.Value,{children:r.triggerLabel||r.label}),t.jsx(ut.Select.Icon,{className:vt.icon,children:t.jsx(S.IconChevronDown,{size:12})})]}),t.jsx(ut.Select.Portal,{container:a,children:t.jsx(ut.Select.Positioner,{className:vt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(ut.Select.Popup,{className:vt.popup,children:e.map(l=>t.jsxs(ut.Select.Item,{className:L(vt.item,o?.item),value:String(l.value),children:[t.jsx(ut.Select.ItemText,{className:L(vt.itemText,o?.itemText),children:l.label}),t.jsx(S.IconCheck,{size:12,className:L(vt.itemIndicator,{[vt.active]:l.value===n})})]},String(l.value)))})})})]})}const lu="_root_1t37n_1",du="_trigger_1t37n_7",uu="_item_1t37n_11",mu="_itemText_1t37n_17",ba={root:lu,trigger:du,item:uu,itemText:mu},hu=({options:e,value:n,onChange:s})=>{const{txRequest:o}=Ar(),a=Ze(o.chainId),r=lt(a),i=(p,g)=>{if(j.formatAmount(p,{decimals:g})==="0.000000")return 8},l=({amount:[{amount:p,denom:g}]})=>{if(B(p).isZero())return"0";const{symbol:x,decimals:y}=r(g),b=i(p,y);return`${j.formatAmount(p,{decimals:y,dp:b})} ${x}`},c=e.map(p=>{const[{denom:g}]=p.amount,{symbol:x}=r(g);return{value:g,label:l(p),triggerLabel:x}});if(e.length===1)return t.jsx("span",{className:"monospace",children:l(e[0])});const d=e.find(p=>p.amount[0].denom===n);if(!d)throw new Error("Fee option not found");const[{amount:u,denom:h}]=d.amount,{decimals:m}=r(h),f=i(u,m);return t.jsxs("div",{className:ba.root,children:[t.jsx("span",{className:"monospace",children:j.formatAmount(u,{decimals:m,dp:f})}),t.jsx(zo,{options:c,value:n,onChange:s,classNames:ba})]})},pu="_root_16nr2_1",fu="_trigger_16nr2_5",gu="_chevron_16nr2_13",_u="_panel_16nr2_27",xu="_details_16nr2_39",yu="_row_16nr2_48",Gt={root:pu,trigger:fu,chevron:gu,panel:_u,details:xu,row:yu},ju=({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),l=r===6?void 0:8;return t.jsxs(Ps.Collapsible.Root,{className:Gt.root,children:[t.jsxs(Ps.Collapsible.Trigger,{className:Gt.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(S.IconChevronDown,{className:Gt.chevron,size:16})]}),t.jsx(Ps.Collapsible.Panel,{className:Gt.panel,children:t.jsx("div",{className:Gt.details,children:i.map(({label:c,value:d})=>t.jsxs("div",{className:Gt.row,children:[t.jsx("span",{children:c}),t.jsxs("span",{children:[j.formatAmount(d,{decimals:r,dp:l})," ",a]})]},c))})})]})};function ls(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?ie.toBase64(e):Array.isArray(e)?`[${e.map(ls).join(",")}]`:JSON.stringify(e,(n,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const bu="_container_1xzyq_1",wu="_toggle_1xzyq_5",vu="_list_1xzyq_11",Cu="_arg_1xzyq_16",Nu="_type_1xzyq_21",hn={container:bu,toggle:wu,list:vu,arg:Cu,type:Nu},Iu=ye.createQueryKeys("interwovenkit:move",{abi:(e,n,s,o)=>[e,n,s,o]}),ku=({type:e,arg:n})=>ls(j.resolveBcsType(e).parse(n)),Su=({msg:e,chainId:n,fallback:s})=>{const[o,a]=Le.useToggle(!1),{restUrl:r}=Ze(n),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=T.useQuery({queryKey:Iu.abi(r,i,l,c).queryKey,queryFn:async()=>{const m=await z.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${l}`).json(),p=JSON.parse(m.module.abi).exposed_functions.find(({name:g})=>g===c);if(!p)throw new Error(`Function ${c} not found in module ${l}`);return p.params.filter(g=>!g.startsWith("&"))},staleTime:K.INFINITY});if(!u)return s;const h=(m,f)=>{const p=u[f];return t.jsxs("div",{className:hn.arg,children:[t.jsx("div",{className:hn.type,children:p}),t.jsx(Ga.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(ku,{type:p,arg:m})})]},f)};return t.jsxs("div",{className:hn.container,children:[t.jsx(le.Small,{className:hn.toggle,onClick:a,disabled:!u,children:o?"Encode":"Decode"}),o?t.jsx("div",{className:hn.list,children:d.map(h)}):s]})},Au="_list_oip9m_1",Tu="_key_oip9m_9",$u="_value_oip9m_14",Ks={list:Au,key:Tu,value:$u},Eu=({message:e,chainId:n})=>{const{typeUrl:s,value:o}=e;return t.jsx("div",{className:Ks.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{children:[t.jsx("div",{className:Ks.key,children:a}),t.jsx("div",{className:Ks.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?t.jsx(Su,{msg:o,chainId:n,fallback:ls(r)}):ls(r)})]},a))})},qu="_item_1n572_1",Lu="_title_1n572_10",Mu="_content_1n572_14",zs={item:qu,title:Lu,content:Mu},Ws=({title:e,content:n})=>t.jsxs("div",{className:zs.item,children:[t.jsx("div",{className:zs.title,children:e}),t.jsx("div",{className:zs.content,children:n})]});function ee(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=j.formatNumber(n?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function ni(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(l=>l.key==="spender")?.value,i=o.attributes.find(l=>l.key==="amount")?.value;if(r===n&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=s[c]||BigInt(0);s[c]=d-BigInt(l)}}}if(o.type==="coin_received"){const r=o.attributes.find(l=>l.key==="receiver")?.value,i=o.attributes.find(l=>l.key==="amount")?.value;if(r===n&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=s[c]||BigInt(0);s[c]=d+BigInt(l)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),denom:o}))}function si(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(c=>c.key==="type_tag")?.value,i=o.attributes.find(c=>c.key==="data")?.value;if(!r||!i)continue;let l;try{l=JSON.parse(i)}catch{continue}if(r==="0x1::fungible_asset::WithdrawEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&j.createUserDerivedObjectAddress(n,u)===c){const m=s[u]||BigInt(0);s[u]=m-BigInt(d)}}if(r==="0x1::fungible_asset::DepositEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&j.createUserDerivedObjectAddress(n,u)===c){const m=s[u]||BigInt(0);s[u]=m+BigInt(d)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const oi=({metadata:e,chain:n,children:s})=>{const{restUrl:o}=n,{data:a}=T.useSuspenseQuery({queryKey:wn.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)},Pu="_root_1p8a4_1",Du="_title_1p8a4_8",Bu="_changes_1p8a4_14",Ru="_change_1p8a4_14",Fu="_amount_1p8a4_35",Uu="_text_1p8a4_42",Ou="_value_1p8a4_49",Rt={root:Pu,title:Du,changes:Bu,change:Ru,amount:Fu,text:Uu,value:Ou},ai=({amount:e,asset:n,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=n,l=j.formatAmount(e,{decimals:r}),c=s&&B(j.fromBaseUnit(e,{decimals:r})).times(s).abs();return t.jsxs("div",{className:Rt.change,children:[t.jsxs("div",{className:Rt.amount,children:[t.jsx(X,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:Rt.text,children:[l," ",a||o]})]}),c&&t.jsx("div",{className:Rt.value,children:ee(c)})]})},Vu=({changes:e,chain:n})=>{const s=lt(n),{data:o}=_t(n);return e.map(({amount:a,denom:r},i)=>{const l=s(r),c=o?.find(({id:d})=>d===r)?.price;return t.jsx(ai,{amount:a,asset:l,price:c},i)})},Ku=({changes:e,chain:n})=>{const s=lt(n),{data:o}=_t(n);return e.map(({amount:a,metadata:r},i)=>t.jsx(oi,{metadata:r,chain:n,children:l=>{const c=o?.find(({id:d})=>d===l)?.price;return t.jsx(ai,{amount:a,asset:s(l),price:c})}},i))};function zu(e,n){return typeof n=="bigint"?n.toString():n}const Wu=ye.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,zu)]}),Hu=({messages:e,memo:n,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=De(),r=Ze(s),{simulateTx:i}=vs(),{data:l}=T.useSuspenseQuery({queryKey:Wu.simulate({messages:e,memo:n,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:n,chainId:s}),staleTime:K.SECOND}),c=m=>t.jsxs("div",{className:Rt.root,children:[t.jsx("h2",{className:Rt.title,children:"Estimated changes"}),t.jsx("div",{className:Rt.changes,children:m})]});if(!l)return null;const d=l.result?.events??[];if(d.length===0)return null;if(r.metadata?.is_l1||r.metadata?.minitia?.type==="minimove"){const m=si(d,a),[f]=wa(m);return f.length===0?null:c(t.jsx(Ku,{changes:f,chain:r}))}const u=ni(d,o),[h]=wa(u);return h.length===0?null:c(t.jsx(Vu,{changes:h,chain:r}))};function wa(e){return A.partition(n=>new B(n.amount).isNegative(),e)}const Qu="_title_1d032_1",Gu="_meta_1d032_7",Yu="_footer_1d032_14",Zu="_rejectButton_1d032_19",Gn={title:Qu,meta:Gu,footer:Yu,rejectButton:Zu},ri=()=>{const{txRequest:e,resolve:n,reject:s}=Ar(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:l,spendCoins:c}=e,d=te(),u=xs(),h=Ze(r),m=An(h),f=Vo(h),p=Ko(h),g=lt(h),x=Cr(),y=vr(),b=(e.gasPrices??f).map(({amount:w,denom:E})=>Ke.calculateFee(Math.ceil(i*l),Ke.GasPrice.fromString(w+E))),C=b.map(w=>w.amount[0]),v=w=>{const E=m.find(P=>P.denom===w)?.amount??"0",U=C.find(P=>P.denom===w)?.amount??"0",F=c.filter(P=>P.denom===w).reduce((P,Ne)=>B(P).plus(Ne.amount),B("0")),O=B(U).plus(F),Z=B(E).gte(O),{symbol:H,decimals:R}=g(w);return{symbol:H,decimals:R,spend:F.gt(0)?F.toFixed():null,fee:U,total:O.toFixed(),balance:E,isSufficient:Z}},N=()=>{if(p&&v(p).isSufficient)return p;for(const{denom:w}of C)if(v(w).isSufficient)return w;return C[0]?.denom},[k,$]=_.useState(N),{mutate:q,isPending:V}=T.useMutation({mutationKey:[kr],mutationFn:async()=>{const w=b.find(F=>F.amount[0].denom===k);if(!w)throw new Error("Fee not found");const U=!e.internal&&await x(r,o)?await y(r,d,o,w,a||""):await u(r,d,o,w,a);await n(U)},onError:async w=>{s(w)}}),M=v(k),I=!M.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(et,{children:[t.jsx("h1",{className:Gn.title,children:"Confirm tx"}),t.jsxs("div",{className:Gn.meta,children:[t.jsx(Ws,{title:"Chain",content:r}),t.jsx(Ws,{title:"Tx fee",content:t.jsx(hu,{options:b,value:k,onChange:$})}),a&&t.jsx(Ws,{title:"Memo",content:a}),I&&t.jsx(fe,{level:"error",children:t.jsx(ju,{...M})})]}),t.jsx(Hu,{messages:o,memo:a,chainId:r}),t.jsx(Zd,{list:o,renderHeader:({typeUrl:w})=>hs.sentenceCase(w.split(".").pop().replace(/^Msg/,"")),renderContent:w=>t.jsx(Eu,{message:w,chainId:r})})]}),t.jsxs(xe,{className:Gn.footer,children:[t.jsx(le.Outline,{onClick:()=>s(new Error("User rejected")),disabled:V,className:Gn.rejectButton,children:t.jsx(S.IconClose,{size:16})}),t.jsx(le.White,{onClick:()=>q(),disabled:I,loading:V,children:"Approve"})]})]})},Ju=({children:e})=>{const[{title:n,content:s,path:o},a]=_.useState({}),[r,i]=_.useState(!1),l=W.useAtomValue(ws),c=_.useCallback(h=>{a(h),i(!0)},[]),d=_.useCallback(()=>{a({}),i(!1)},[]),u=_.useCallback(h=>{h||(l?.reject(new Error("User rejected")),a({})),i(h)},[l]);return t.jsxs(Nr.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(ei,{title:n,open:r,onOpenChange:u,children:t.jsx(me,{children:o==="/tx"?t.jsx(ri,{}):s})})]})},Xu="_container_1w1hx_1",em="_toast_1w1hx_11",tm="_info_1w1hx_24",nm="_success_1w1hx_28",sm="_error_1w1hx_32",om="_icon_1w1hx_37",am="_content_1w1hx_45",rm="_title_1w1hx_48",im="_description_1w1hx_53",cm="_close_1w1hx_75",Ct={container:Xu,toast:em,info:tm,success:nm,error:sm,icon:om,content:am,title:rm,description:im,close:cm},lm=({notification:e,onClose:n,...s})=>{const o=rt.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(ct,{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:l,title:c,description:d}=i,u=a(l);return t.jsx(rt.animated.div,{style:r,className:Ct.container,children:t.jsxs("div",{className:L(Ct.toast,l&&Ct[l]),...s,children:[u&&t.jsx("div",{className:Ct.icon,children:u}),t.jsxs("div",{className:Ct.content,children:[t.jsx("p",{className:Ct.title,children:c}),d&&t.jsx("div",{className:Ct.description,children:d})]}),t.jsx("button",{className:Ct.close,onClick:n,children:t.jsx(S.IconClose,{size:14})})]})})})},Hs=5e3,dm=({children:e})=>{const n=Ot(),[s,o]=_.useState(null),a=_.useRef(null),r=_.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},l=_.useCallback(()=>{i(),o(null)},[]),c=_.useCallback(m=>{i(),o({...m,id:da.nanoid()}),m.autoHide&&!r.current&&(a.current=setTimeout(()=>l(),Hs))},[l]),d=_.useCallback(m=>{i(),o(f=>f?{...f,...m}:{...m,id:da.nanoid()}),m.autoHide&&!r.current&&(a.current=setTimeout(()=>l(),Hs))},[l]),u=()=>{i(),r.current=!0},h=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>l(),Hs))};return _.useEffect(()=>()=>i(),[]),t.jsxs(Zr.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,n&&ec.createPortal(t.jsx(lm,{notification:s,onClose:l,onMouseEnter:u,onMouseLeave:h}),n)]})},um=({children:e})=>{const[n,s]=_.useState(null);return t.jsx(Is.Provider,{value:{container:n,setContainer:s},children:e})},ii=[{value:10*hr,label:"for 10 minutes"},{value:pr,label:"for 1 hour"},{value:ha,label:"for 1 day"},{value:7*ha,label:"for 7 days"},{value:0,label:"until revoked"}],mm=ii[0].value,hm="_container_1422v_1",pm="_title_1422v_7",fm="_description_1422v_14",gm="_sectionTitle_1422v_20",_m="_websiteInfo_1422v_27",xm="_favicon_1422v_37",ym="_websiteTitle_1422v_42",jm="_websiteHost_1422v_48",bm="_warningContent_1422v_54",wm="_ignoreButton_1422v_61",vm="_infoList_1422v_65",Cm="_infoItem_1422v_75",Nm="_label_1422v_84",Im="_infoValue_1422v_94",km="_durationTrigger_1422v_100",Sm="_durationItem_1422v_101",Am="_featureList_1422v_105",Tm="_featureItem_1422v_113",$m="_checkIcon_1422v_123",Em="_learnMoreLink_1422v_127",qm="_feedbackContainer_1422v_140",Lm="_footer_1422v_146",re={container:hm,title:pm,description:fm,sectionTitle:gm,websiteInfo:_m,favicon:xm,websiteTitle:ym,websiteHost:jm,warningContent:bm,ignoreButton:wm,infoList:vm,infoItem:Cm,label:Nm,infoValue:Im,durationTrigger:km,durationItem:Sm,featureList:Am,featureItem:Tm,checkIcon:$m,learnMoreLink:Em,feedbackContainer:qm,footer:Lm},Mm=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}`;return s.get(o).json()}})}),Pm=()=>{const[e,n]=_.useState(mm),[s,o]=W.useAtom(Ln),[a,r]=_.useState(!1),i=Ye(),l=de(),{address:c,username:d}=De(),{mutate:u,isPending:h}=Fc(),{closeDrawer:m}=xt();if(!s)throw new Error("Pending request not found");const{logoUrl:f,name:p,restUrl:g}=i(s.chainId),{data:x,isLoading:y}=T.useQuery(Mm.info(g,c)),b={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},C=l.some($=>{if(!$.website)return!1;const q=va(new URL($.website).hostname),V=va(window.location.hostname);return q===V}),v=()=>{u(e)},N=()=>{s?.reject(new Error("User cancelled")),o(null),m()},k=!C&&!a;return t.jsxs(t.Fragment,{children:[t.jsxs(et,{className:re.container,children:[t.jsxs("header",{children:[t.jsx("h1",{className:re.title,children:"Enable auto-signing"}),t.jsx("p",{className:re.description,children:"An application is requesting to enable auto-signing"})]}),t.jsxs("section",{children:[t.jsx("h2",{className:re.sectionTitle,children:"Requested by"}),t.jsxs("div",{className:re.websiteInfo,children:[t.jsx("img",{src:b.favicon,alt:"",className:re.favicon}),t.jsxs("div",{children:[t.jsx("div",{className:re.websiteTitle,children:b.title}),t.jsx("div",{className:re.websiteHost,children:b.hostname})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:re.sectionTitle,children:"Applies to"}),t.jsxs("div",{className:re.infoList,children:[t.jsxs("div",{className:re.infoItem,children:[t.jsx("div",{className:re.label,children:"Address"}),t.jsxs("div",{className:re.infoValue,children:[t.jsx(S.IconWallet,{size:14}),t.jsx("span",{className:"monospace",children:j.truncate(d??c)})]})]}),t.jsxs("div",{className:re.infoItem,children:[t.jsx("div",{className:re.label,children:"Chain"}),t.jsxs("div",{className:re.infoValue,children:[t.jsx(X,{src:f,width:14,height:14,logo:!0}),t.jsx("span",{children:p})]})]}),t.jsxs("div",{className:re.infoItem,children:[t.jsx("div",{className:re.label,children:"Duration"}),t.jsx(zo,{options:ii,value:e,onChange:n,classNames:{trigger:re.durationTrigger,item:re.durationItem}})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:re.sectionTitle,children:"About auto-signing"}),t.jsx("ul",{className:re.featureList,children:["Send transactions without confirmation pop-ups","Protected by Privy embedded wallet","Revoke permissions any time in settings"].map($=>t.jsxs("li",{className:re.featureItem,children:[t.jsx(S.IconCheckCircle,{size:12,className:re.checkIcon}),t.jsx("span",{children:$})]},$))}),t.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",className:re.learnMoreLink,children:["Learn more ",t.jsx(S.IconExternalLink,{size:12})]})]})]}),t.jsxs(xe,{className:re.footer,extra:t.jsxs("div",{className:re.feedbackContainer,children:[!y&&!x&&t.jsx(fe,{level:"error",children:"Insufficient balance for fee"}),!C&&!a&&t.jsx(fe,{level:"warning",children:t.jsxs("div",{className:re.warningContent,children:[t.jsx("span",{children:"You are on an unverified website"}),t.jsx("button",{onClick:()=>r(!0),className:re.ignoreButton,children:"Ignore"})]})})]}),children:[t.jsx(le.Outline,{onClick:N,children:"Cancel"}),t.jsx(le.White,{onClick:v,disabled:k||!x||y,loading:h,children:"Enable"})]})]})},Dm=()=>W.useAtomValue(Ln)?t.jsx(Pm,{}):null;function va(e){const n=e.split(".");return n.length<2?e:n.slice(-2).join(".")}const Bm="_container_mqvhs_1",Rm="_badge_mqvhs_5",Ca={container:Bm,badge:Rm},ci=e=>{const{offset:n=-4,disabled:s,children:o,className:a}=e;return t.jsxs("div",{className:L(Ca.container,a),children:[o,!s&&t.jsx("div",{className:Ca.badge,style:{right:n,top:n}})]})},Fm="_header_s7mee_1",Um="_back_s7mee_12",Om="_title_s7mee_24",Qs={header:Fm,back:Um,title:Om},dt=({title:e,backButton:n,extra:s,children:o})=>{const a=dr();return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Qs.header,children:[t.jsx(nn,{to:n??(a.length>1?-1:"/"),className:Qs.back,shouldReset:!!n,children:t.jsx(S.IconBack,{size:16})}),t.jsx("h1",{className:Qs.title,children:e}),s]}),t.jsx(et,{children:o})]})};function li(){const{initiaAddress:e,hexAddress:n}=De(),s=yt(),o=Dn();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return n;default:return""}}}function di(){const e=yt(),n=Dn();return(s,o)=>{const a=e(o);switch(n(a)){case"initia":return j.InitiaAddress.validate(s);case"evm":return pt.isAddress(s);case"cosmos":try{return ie.fromBech32(s).prefix===a.bech32_prefix}catch{return!1}default:return!1}}}function Vm(){const e=yt(),n=Dn();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),l=n(i),c=e(a),d=n(c);if(l==="evm"&&d==="initia")return j.InitiaAddress(s).bech32;if(l==="initia"&&d==="evm")return j.InitiaAddress(s).hex;if(l===d)return s;if(r){if(d==="initia")return j.InitiaAddress(r).bech32;if(d==="evm")return j.InitiaAddress(r).hex}return""}}const Km="_root_ekn9t_1",zm="_header_ekn9t_6",Wm="_title_ekn9t_12",Hm="_warning_ekn9t_18",Qm="_content_ekn9t_22",Gm="_footer_ekn9t_26",Ym="_secondary_ekn9t_36",Et={root:Km,header:zm,title:Wm,warning:Hm,content:Qm,footer:Gm,secondary:Ym},ui=e=>{const{type:n,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return t.jsxs(et,{className:Et.root,children:[t.jsxs("header",{className:L(Et.header,n&&Et[n]),children:[s,t.jsx("h1",{className:Et.title,children:o})]}),t.jsx("div",{className:Et.content,children:a}),t.jsxs("footer",{className:Et.footer,children:[t.jsx(le.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),t.jsxs("button",{className:Et.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(S.IconChevronRight,{size:14})]})]})]})},Zm="_list_k4n3k_1",Jm="_row_k4n3k_9",Xm="_dt_k4n3k_20",eh="_asset_k4n3k_26",Yn={list:Zm,row:Jm,dt:Xm,asset:eh},th=({list:e,onNavigate:n,onDismiss:s})=>{const o=ae(),a=Ye(),r=lt(o);return t.jsx(ui,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:n},secondaryButton:{label:"Do not show again",onClick:s},children:t.jsx("div",{className:Yn.list,children:e.toSorted((i,l)=>i.chainId.localeCompare(l.chainId)).map(({txHash:i,chainId:l,amount:c,denom:d})=>{const u=a(l),{decimals:h,symbol:m}=r(d),f=j.formatAmount(c,{decimals:h});return t.jsxs("div",{className:Yn.row,children:[t.jsxs("div",{className:Yn.dt,children:[t.jsx(X,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:Yn.asset,children:[f," ",m]})]},i)})})})};function Gs(e,n){return e.chainId===n.chainId&&e.txHash===n.txHash}const Zn=({chainId:e,txHash:n})=>`${oe.OP_REMINDER}:${e}:${n}`,nh=tc.atomWithStorage(oe.OP_REMINDER,[]);function dn(){const e=te(),[n=[],s]=W.useAtom(nh),o=_.useMemo(()=>n.map(c=>{const d=localStorage.getItem(Zn(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:Ge.isPast(u)}),[e,n]),a=_.useCallback((c,d)=>{n.some(u=>Gs(u,c))||(s((u=[])=>[...u,c]),localStorage.setItem(Zn(c),JSON.stringify(d)))},[n,s]),r=_.useCallback(c=>{s((d=[])=>d.filter(u=>!Gs(u,c))),localStorage.removeItem(Zn(c))},[s]),i=_.useCallback(c=>{const d=c.filter(u=>!n.some(h=>Gs(h,u)));d.length!==0&&s((u=[])=>[...u,...d])},[n,s]),l=_.useCallback((c,d)=>{localStorage.setItem(Zn(c),JSON.stringify(d)),s((u=[])=>[...u])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:l}}function mi(){const e=Ce(),{openModal:n,closeModal:s}=bs(),{reminders:o,setReminder:a}=dn();_.useEffect(()=>{const r=o.filter(c=>!c.dismissed);if(r.length===0)return;const i=()=>{const c=r.every(d=>d.chainId===r[0].chainId)?r[0].chainId:void 0;e("/op/withdrawals",{chainId:c}),l()},l=()=>{s();for(const c of r)a(c,{...c,dismissed:!0})};n({content:_.createElement(th,{list:r,onNavigate:i,onDismiss:l})})},[o,s,e,n,a])}const sh="_wrapper_5ssm8_1",oh="_balance_5ssm8_11",ah="_button_5ssm8_15",Ys={wrapper:sh,balance:oh,button:ah},hi=({onClick:e,children:n,disabled:s})=>t.jsxs("div",{className:Ys.wrapper,children:[t.jsx(S.IconWallet,{size:16}),t.jsx("span",{className:Ys.balance,children:n}),t.jsx("button",{type:"button",tabIndex:-1,className:Ys.button,onClick:()=>e(),disabled:s,children:"MAX"})]}),rh="_fieldset_up6fh_1",ih="_upper_up6fh_9",ch="_select_up6fh_14",lh="_account_up6fh_20",dh="_lower_up6fh_25",uh="_wrapper_up6fh_26",mh="_balance_up6fh_33",hh="_value_up6fh_37",ph="_error_up6fh_50",mt={fieldset:rh,upper:ih,select:ch,account:lh,lower:dh,wrapper:uh,balance:mh,value:hh,error:ph},mo=e=>{const{selectButton:n,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:l}=e;return t.jsxs("div",{className:mt.fieldset,children:[t.jsxs("div",{className:mt.upper,children:[t.jsx("div",{className:mt.select,children:n}),t.jsx("div",{className:mt.account,children:s})]}),!l&&t.jsxs("div",{className:mt.lower,children:[o,t.jsxs("div",{className:mt.wrapper,children:[t.jsx("div",{className:mt.balance,children:a}),r&&t.jsx("div",{className:mt.value,children:r})]}),i&&t.jsxs("footer",{className:mt.error,children:[t.jsx(S.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function Rn(){const e=_.useRef(null),n=Ns();return _.useEffect(()=>{n||e.current?.focus()},[n]),e}const fh="_input_h8073_1",gh={input:fh};function pi(e){const{name:n,control:s,dp:o=6,className:a,rules:r,...i}=e,l=Rn();return t.jsx(_e.Controller,{name:n,control:s,rules:r,render:({field:c})=>t.jsx(nc.NumericFormat,{value:c.value,getInputRef:Ya.mergeRefs([c.ref,l]),className:L(gh.input,a),onValueChange:d=>{c.onChange(d.value)},onBlur:c.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const _h="_input_19r9r_1",xh="_placeholder_19r9r_18",ho={input:_h,placeholder:xh},yh=({children:e})=>t.jsx("p",{className:L(ho.input,{[ho.placeholder]:B(e).isZero()}),children:e}),In=({balance:e,decimals:n,className:s})=>{const{control:o}=_e.useFormContext(),a={required:"Enter amount",validate:r=>B(r).isZero()?"Enter amount":B(j.toBaseUnit(r,{decimals:n})).gt(e??0)?"Insufficient balance":!0};return t.jsx(pi,{name:"quantity",control:o,className:L(ho.input,s),rules:a})};In.ReadOnly=yh;const rn=({title:e,content:n,children:s,className:o})=>{const[a,r]=_.useState(!1),i=()=>r(!1);return t.jsx(ei,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:n(i)})},jh="_tooltip_19kvs_1",bh="_arrow_19kvs_44",Na={tooltip:jh,arrow:bh},Fn=({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:Ot(),children:t.jsxs(J.Tooltip.Content,{className:L(Na.tooltip,{small:s}),collisionBoundary:Ot(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(J.Tooltip.Arrow,{className:Na.arrow})]})})]});function Wo(e,n){const s=Xe();return T.useQuery({queryKey:qe.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 wh(e,n,s){const{data:o={}}=Wo(e,n);return A.path([s],o)}const vh=[["d",1440*60],["h",3600],["m",60],["s",1]];function kn(e){if(!e)return;const{formattedParts:n}=vh.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 Ho(e){return e?.map(n=>{const{amount:s,origin_asset:o}=n;return`${j.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function po(e,n){const{watch:s}=St(),o=s(),a=Xe(),r=Tn(),i={...o,quantity:e},l=!o.srcChainId||!o.srcDenom||!o.dstChainId||!o.dstDenom,c=B(i.quantity||0),d=c.isFinite()&&c.gt(0),u=T.useQueryClient();return T.useQuery({queryKey:qe.route(i,n?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:h,srcDenom:m,quantity:f,dstChainId:p,dstDenom:g}=i,{decimals:x}=u.getQueryData(qe.asset(h,m).queryKey)??{decimals:0},y={amount_in:j.toBaseUnit(f,{decimals:x}),source_asset_chain_id:h,source_asset_denom:m,dest_asset_chain_id:p,dest_asset_denom:g,is_op_withdraw:n?.isOpWithdraw},b=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),b},enabled:d&&!n?.disabled&&!l,staleTime:K.MINUTE})}function Ch(e){return T.useQuery({queryKey:qe.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 Nh(){const{watch:e}=St(),{srcChainId:n,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=ze(n),i=Cn(r),l=it(s,n),c=it(a,o),d=ae(),u=de();return i==="initia"&&o===d.chainId&&l.symbol===c.symbol&&u.find(h=>h.chainId===n)?.metadata?.op_denoms?.includes(c.denom)}const Ih="_label_t93ix_1",kh="_wrapper_t93ix_7",Sh="_input_t93ix_10",Ah="_clear_t93ix_18",Jn={label:Ih,wrapper:kh,input:Sh,clear:Ah},Qo=({mode:e="onChange",myAddress:n,...s})=>{const{validate:o=j.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,l=Rn(),{control:c,getValues:d,setValue:u,formState:h}=_e.useFormContext(),m=d("recipient"),[f,p]=_.useState(m),g=rr(),{data:x,isLoading:y,error:b}=T.useQuery({queryKey:fs.address(g.restUrl,f).queryKey,queryFn:()=>g.getAddress(f),staleTime:K.MINUTE,enabled:g.validateUsername(f)}),C=x??(o(f)?f:""),v=n&&j.InitiaAddress.equals(C,n),N=async()=>{try{const q=await navigator.clipboard.readText();p(q.trim())}catch{}};_.useEffect(()=>{e==="onChange"&&(!f&&!h.dirtyFields.recipient||u("recipient",x??f,{shouldValidate:!0,shouldDirty:!0}))},[h.dirtyFields.recipient,f,e,u,x]);const k=()=>{y||b||(u("recipient",C,{shouldValidate:!0,shouldDirty:!0}),r?.())},$=()=>{if(y)return t.jsx(Jt,{level:"loading",children:"Resolving username..."});if(b)return t.jsx(Jt,{level:"error",children:b.message});if(x)return t.jsx(Jt,{level:"success",className:"monospace",children:x});if(e==="onSubmit"&&f&&!C)return t.jsx(Jt,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:Jn.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(le.Small,{type:"button",tabIndex:-1,onClick:N,children:"Paste"})]}),t.jsxs("div",{className:Jn.wrapper,children:[t.jsx(_e.Controller,{name:"recipient",control:c,rules:{required:"Recipient address is required",validate:q=>o(q)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:L(Jn.input,"monospace"),value:f,onChange:q=>p(q.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?Ya.mergeRefs([i,l]):i})}),!!f&&t.jsx("button",{type:"button",className:Jn.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:t.jsx(S.IconCloseCircleFilled,{size:16})})]}),$(),v&&t.jsx(Jt,{children:"This is my address"}),e==="onSubmit"&&t.jsx(xe,{extra:(!n||!!C&&!v)&&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:k,disabled:y||!!b||!C,children:"Apply"})})]})},Th="_scrollable_vgj3r_1",$h="_list_vgj3r_5",Eh="_item_vgj3r_9",qh="_name_vgj3r_22",Xn={scrollable:Th,list:$h,item:Eh,name:qh};function fi({onSelect:e,list:n,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:l}=s;return t.jsx(et,{className:Xn.scrollable,children:t.jsx("div",{className:Xn.list,children:n.map(c=>t.jsxs("button",{className:Xn.item,onClick:()=>e(c),disabled:i?.(c)||l?.(c),children:[t.jsx(X,{src:o(c),width:28,height:28}),t.jsx("span",{className:Xn.name,children:a(c)}),i?.(c)&&t.jsx(ct,{size:16})]},r(c)))})})}function As(){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 Lh="_account_h04x1_8",Mh="_clear_h04x1_28",Ph="_white_h04x1_39",pn={account:Lh,clear:Mh,white:Ph},Ia=({type:e})=>{const{watch:n,setValue:s}=St(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=n(),l=n(e==="src"?"sender":"recipient"),c=Cn(ze(a)),{list:d,find:u}=As(),h=u(r),m=li(),f=di(),p=m(a),g=j.InitiaAddress.equals(l,p),x=()=>t.jsx(rn,{title:"Connect wallet",content:C=>t.jsx(fi,{onSelect:async v=>{const N=v.getProvider();if(!N)return window.open(v.fallbackUrl,"_blank");const k=N.getOfflineSigner(o),[{address:$}]=await k.getAccounts();s("sender",$),s("cosmosWalletName",v.name),C()},list:d,getImage:v=>v.image,getName:v=>v.name,getKey:v=>v.name}),className:L(pn.account,{[pn.white]:!l}),children:l?t.jsxs(t.Fragment,{children:[h&&t.jsx(X,{src:h.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:j.truncate(l)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(S.IconChevronRight,{size:14})]})}),y=C=>t.jsx(rn,{title:"Recipient",content:v=>t.jsx(et,{children:t.jsx(Qo,{mode:"onSubmit",myAddress:p,chainType:c,validate:N=>f(N,a),onApply:v})}),className:pn.account,children:C}),b=()=>{switch(c){case"initia":case"evm":return g?y(t.jsx(S.IconWallet,{size:14})):t.jsxs("div",{className:pn.account,children:[t.jsx("span",{className:"monospace",children:j.truncate(l)}),t.jsx("button",{type:"button",className:pn.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:[l?t.jsx("span",{className:"monospace",children:j.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx(S.IconEdit,{size:14})]}))}};switch(e){case"src":return x();case"dst":return b()}},Dh="_images_cj4xz_1",Zs={images:Dh},Ts=({assetLogoUrl:e,assetLogoSize:n=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>t.jsxs("div",{className:L(Zs.images,r),style:{position:"relative"},children:[t.jsx(X,{src:e,width:n,height:n,className:Zs.asset,logo:!0}),t.jsx(X,{src:s,width:o,height:o,className:Zs.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),Bh="_root_6187w_1",Rh="_content_6187w_10",Fh="_details_6187w_20",Uh="_symbol_6187w_26",Oh="_chain_6187w_34",Vh="_chevron_6187w_43",qt={root:Bh,content:Rh,details:Fh,symbol:Uh,chain:Oh,chevron:Vh},gi=({asset:e,chain:n,readOnly:s})=>{const o=t.jsxs("div",{className:qt.content,children:[t.jsx(Ts,{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 Kh(e,n,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return A.any(A.includes(n.toLowerCase()),a)})}const zh="_root_1sh27_1",Wh="_label_1sh27_8",Hh="_input_1sh27_21",Qh="_hasValue_1sh27_31",Gh="_clear_1sh27_35",fn={root:zh,label:Wh,input:Hh,hasValue:Qh,clear:Gh},Un=e=>{const{rootClassName:n,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return t.jsxs("div",{className:L(fn.root,n,{[fn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[t.jsx("label",{htmlFor:"search",className:fn.label,children:t.jsx(S.IconSearch,{size:o})}),t.jsx("input",{className:fn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&t.jsx("button",{type:"button",className:fn.clear,"aria-label":"Clear search",onMouseDown:l=>l.preventDefault(),onClick:a,children:t.jsx(S.IconCloseCircleFilled,{size:o})})]})},Yh="_container_5tajg_1",Zh="_search_5tajg_7",Jh="_list_5tajg_11",Xh="_item_5tajg_15",ep="_logo_5tajg_37",tp="_info_5tajg_41",np="_symbol_5tajg_47",sp="_name_5tajg_56",op="_balance_5tajg_62",ap="_value_5tajg_69",Ve={container:Yh,search:Zh,list:Jh,item:Xh,logo:ep,info:tp,symbol:np,name:sp,balance:op,value:ap},On=e=>{const{assets:n,onSelect:s,renderAsset:o=(l,c)=>c(l)}=e,[a,r]=_.useState(""),i=Kh(["symbol"],a,n);return t.jsxs("div",{className:Ve.container,children:[t.jsx(Un,{value:a,onChange:l=>r(l.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:Ve.search,padding:20,ref:Rn()}),i.length===0?t.jsx(he,{children:"No assets"}):t.jsx("div",{className:Ve.list,children:i.map(l=>t.jsx("button",{type:"button",className:Ve.item,onClick:()=>s(l.denom),children:o(l,c=>{const{denom:d,logoUrl:u,symbol:h,name:m,balance:f,decimals:p,value:g=0}=c;return t.jsxs(t.Fragment,{children:[t.jsx(X,{src:u,width:32,height:32,className:Ve.logo,logo:!0}),t.jsxs("div",{className:Ve.info,children:[t.jsx("div",{className:Ve.symbol,children:h||d}),t.jsx("div",{className:Ve.name,children:m})]}),t.jsxs("div",{className:Ve.balance,children:[f&&t.jsx("div",{children:j.formatAmount(f,{decimals:p})}),g>0&&t.jsx("div",{className:Ve.value,children:ee(g)})]})]})})},l.denom))})]})},rp=()=>t.jsxs("div",{className:Ve.container,children:[t.jsx(Un,{rootClassName:Ve.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(he,{children:"Loading..."})]});On.Placeholder=rp;const ip="_stack_16oqn_1",cp="_title_16oqn_9",lp="_grid_16oqn_16",dp="_item_16oqn_22",up="_button_16oqn_26",mp="_active_16oqn_44",Xt={stack:ip,title:cp,grid:lp,item:dp,button:up,active:mp},Ft=({label:e,chains:n,value:s,onSelect:o,getShowIndicator:a})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:Xt.title,children:e}),t.jsx("div",{className:Xt.grid,children:n.map(({chainId:r,name:i,logoUrl:l})=>t.jsx(ci,{offset:-2,disabled:!a?.(r),className:Xt.item,children:t.jsx(Fn,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:L(Xt.button,{[Xt.active]:r===s}),onClick:()=>o(r),children:t.jsx(X,{src:l,width:28,height:28,logo:!0})})})},r))})]}),hp=({children:e})=>t.jsx("div",{className:Xt.stack,children:e});Ft.Stack=hp;const pp=({address:e,chain:n,onSelect:s})=>{const o=is(n.chain_id),{data:a={}}=Wo(e,n.chain_id);return t.jsx(On,{assets:A.sortWith([A.descend(r=>r.symbol==="INIT"),A.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>B(i).comparedTo(r)??0,A.ascend(r=>r.symbol.toLowerCase())],o.filter(r=>!r.hidden).map(r=>{const{denom:i,symbol:l=j.truncate(i),logo_uri:c}=r,d=a[i]??{};return{...r,symbol:l,decimals:r.decimals??0,logoUrl:c??"",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=kt(),i=Bn(),{watch:l,setValue:c}=St(),d=l(a),u=l(s),h=l(o),[m,f]=_.useState(u),p=ze(m),g=Vm(),x=zr(),[y,b]=A.partition(v=>x(v.chain_id),i.filter(v=>!v.hidden)),C=v=>{if(u===m&&h===v){n();return}c(s,m),c(o,v),n()};return t.jsxs(t.Fragment,{children:[t.jsxs(Ft.Stack,{children:[t.jsx(Ft,{label:"Interwoven Economy",chains:y.map(({chain_id:v,chain_name:N,pretty_name:k,logo_uri:$})=>({chainId:v,name:k||N,logoUrl:$??""})),value:m,onSelect:f}),t.jsx(Ft,{label:"Chains",chains:b.map(({chain_id:v,chain_name:N,pretty_name:k,logo_uri:$})=>({chainId:v,name:k||N,logoUrl:$??""})),value:m,onSelect:f})]}),t.jsx(me,{suspenseFallback:t.jsx(On.Placeholder,{}),children:t.jsx(pp,{address:g({initialAddress:d,initialChainId:u,chainId:m,fallbackAddress:e==="src"?r:void 0}),chain:p,onSelect:C})},m)]})},ka=({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),l=ze(r),c=it(i,r);return t.jsx(rn,{title:o,content:d=>t.jsx(fp,{type:e,afterSelect:d}),children:t.jsx(gi,{asset:{denom:c.denom,decimals:c.decimals??0,symbol:c.symbol,logoUrl:c.logo_uri??""},chain:{chainId:l.chain_id,name:l.pretty_name||l.chain_name,logoUrl:l.logo_uri??""}})})},gp="_skeleton_1l4jn_1",_p={skeleton:gp},Ut=({width:e="100%",height:n})=>t.jsx("div",{className:_p.skeleton,style:{width:e,height:n}}),xp="_stack_oq1ir_1",yp="_button_oq1ir_6",jp="_isLoading_oq1ir_19",bp="_disabled_oq1ir_19",wp="_checked_oq1ir_23",vp="_header_oq1ir_37",Cp="_title_oq1ir_43",Np="_duration_oq1ir_52",Ip="_warning_oq1ir_62",kp="_amount_oq1ir_66",Sp="_value_oq1ir_67",Oe={stack:xp,button:yp,isLoading:jp,disabled:bp,checked:wp,header:vp,title:Cp,duration:Np,warning:Ip,amount:kp,value:Sp},Ap=({children:e})=>t.jsx("div",{className:Oe.stack,children:e}),os=({label:e,query:n,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=n,{watch:l}=St(),{dstChainId:c,dstDenom:d}=l(),u=it(d,c),h=!i&&a.checked,m=!i&&!r;return t.jsxs("button",{type:"button",className:L(Oe.button,{[Oe.isLoading]:i,[Oe.disabled]:m,[Oe.checked]:h}),onClick:()=>{i||m||o(s)},children:[t.jsxs("div",{className:Oe.header,children:[t.jsxs("div",{className:Oe.title,children:[t.jsx("span",{children:e}),h&&t.jsx(S.IconCheck,{size:14})]}),i?t.jsx(Ut,{width:80,height:16}):r?t.jsxs("div",{className:L(Oe.duration,{[Oe.warning]:s==="op"}),children:[t.jsx(S.IconClockFilled,{size:12}),t.jsx("span",{children:kn(r.estimated_route_duration_seconds)})]}):t.jsx("div",{className:Oe.duration,children:"Not available"})]}),(i||r)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Oe.amount,children:i?t.jsx(Ut,{width:260,height:40}):r?j.formatAmount(r.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:Oe.value,children:i?t.jsx(Ut,{width:120,height:16}):r?r.usd_amount_out?ee(r.usd_amount_out):"$-":null})]})]})};os.Stack=Ap;const Tp="_description_nuyvt_1",$p="_presets_nuyvt_8",Ep="_preset_nuyvt_8",qp="_active_nuyvt_29",Lp="_custom_nuyvt_40",Mp="_wrapper_nuyvt_47",Pp="_percent_nuyvt_58",ot={description:Tp,presets:$p,preset:Ep,active:qp,custom:Lp,wrapper:Mp,percent:Pp},Sa=["0.1","0.5","1.0"],Dp=({afterConfirm:e})=>{const n=St(),s=n.getValues("slippagePercent"),[o,a]=_.useState(null),{control:r,watch:i,getValues:l,setValue:c}=_e.useForm({defaultValues:{value:s}}),d=i("value");_.useEffect(()=>{const g=Sa.findIndex(x=>x===s);a(g>=0?g:null)},[s]);const u=(g,x)=>{c("value",g),a(x)},h=()=>{a(null)},m=_.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=m?.type==="error",p=({value:g})=>{n.setValue("slippagePercent",g),e()};return t.jsxs(et,{children:[t.jsx("p",{className:ot.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:ot.presets,children:[Sa.map((g,x)=>t.jsxs("button",{type:"button",className:L(ot.preset,{[ot.active]:o===x}),onClick:()=>u(g,x),children:[g,"%"]},g)),o!==null?t.jsx("button",{type:"button",className:L(ot.preset,ot.custom),onClick:()=>a(null),children:"Custom"}):t.jsxs("div",{className:ot.wrapper,children:[t.jsx(pi,{name:"value",control:r,dp:2,onFocus:h,placeholder:"",className:L(ot.preset,ot.active)}),t.jsx("span",{className:ot.percent,children:"%"})]})]}),m&&t.jsx(fe,{level:m.type,children:m.text}),t.jsx(xe,{children:t.jsx(le.White,{type:"button",onClick:()=>p(l()),disabled:f,children:"Confirm"})})]})},Bp="_form_1owk5_1",Rp="_arrow_1owk5_5",Fp="_divider_1owk5_14",Up="_flip_1owk5_23",Op="_meta_1owk5_41",Vp="_row_1owk5_54",Kp="_title_1owk5_60",zp="_description_1owk5_64",Wp="_icon_1owk5_71",Hp="_edit_1owk5_76",Qp="_warning_1owk5_99",Me={form:Bp,arrow:Rp,divider:Fp,flip:Up,meta:Op,row:Vp,title:Kp,description:zp,icon:Wp,edit:Hp,warning:Qp},Gp=()=>{const e=Ce(),n=Ns(),[s,o]=Le.useLocalStorage(oe.BRIDGE_ROUTE_TYPE,"default"),{watch:a,setValue:r,handleSubmit:i,formState:l}=St(),c=a(),{srcChainId:d,srcDenom:u,dstChainId:h,dstDenom:m,quantity:f,sender:p,slippagePercent:g}=c,x=Ye(),y=ze(d),b=Cn(y),C=ze(h),v=Cn(C),N=it(u,d),k=it(m,h),{data:$}=Wo(p,d),q=wh(p,d,u),V=!q?.amount||B(q.amount).isZero(),[M]=Le.useDebounceValue(f,300),I=b!=="initia"&&v!=="initia",w=Nh(),E=po(M,{disabled:I}),U=po(M,{isOpWithdraw:!0,disabled:!w}),F=w&&s==="op",O=F?U:E,Z=F?E:U,H=F?!I:w,R=O.error&&H?Z:O,{data:P,isLoading:Ne,isFetching:je,error:tt}=R,{data:Be}=Ch(tt),Wt=M&&(Ne||je),un=()=>{r("srcChainId",h),r("srcDenom",m),r("dstChainId",d),r("dstDenom",u),r("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:Kn,closeModal:zn}=bs(),nt=i(ne=>{if(P?.warning){const{type:Tt="",message:Ms}=P.warning??{};Kn({content:t.jsx(ui,{type:"warning",icon:t.jsx(S.IconWarningFilled,{size:40}),title:hs.sentenceCase(Tt),primaryButton:{label:"Cancel",onClick:zn},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:P,values:ne}),zn()}},children:t.jsx("p",{className:Me.warning,children:Ms})})});return}e("/bridge/preview",{route:P,values:ne})}),Re=_.useMemo(()=>P?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_DEDUCTED")??[],[P]),bt=_.useMemo(()=>P?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_ADDITIONAL")??[],[P]),Ht=_.useMemo(()=>{for(const ne of bt){const Tt=$?.[ne.origin_asset.denom]?.amount??"0",Ms=P?.source_asset_denom===ne.origin_asset.denom?P.amount_in:"0";if(B(Tt).lt(B(Ms).plus(ne.amount??"0")))return`Insufficient ${ne.origin_asset.symbol} for fees`}},[$,P,bt]),Wn=_.useMemo(()=>{if(!c.sender)return"Connect wallet";if(!c.quantity||!M)return"Enter amount";if(!c.recipient)return"Enter recipient address";if(l.errors.quantity)return l.errors.quantity.message;if(!P)return"Route not found";if(Ht)return Ht},[M,Ht,l,P,c]),Wi=P?j.formatAmount(P.amount_out,{decimals:k.decimals}):"0",Hi=B(f).gt(0)&&B(f).isEqualTo(j.fromBaseUnit(q?.amount,{decimals:q?.decimals??0})),Qi=(()=>{switch(b){case"initia":return x(d).fees.fee_tokens.some(({denom:ne})=>ne===u);case"cosmos":return y.fee_assets.some(({denom:ne})=>ne===u);case"evm":return!pt.isAddress(u);default:return!1}})(),Ls=_.useCallback((ne,Tt)=>ne.length?t.jsxs("div",{className:Me.description,children:[Ho(ne),!n&&t.jsx(Fn,{label:Tt,children:t.jsx("span",{className:Me.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]}):null,[n]),Hn=B(f).gt(0)&&w&&E.data&&U.data&&U.data.estimated_route_duration_seconds>E.data.estimated_route_duration_seconds,aa=_.useMemo(()=>P?[{condition:!!P.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Ls(Re,"Fee deducted from the amount you receive"),Ls(bt,"Fee charged in addition to the amount you enter")]})},{condition:!Hn&&!!kn(P.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:Me.description,children:kn(P.estimated_route_duration_seconds)})},{condition:P.does_swap,title:"Slippage",content:t.jsxs("span",{className:Me.description,children:[t.jsxs("span",{children:[g,"%"]}),t.jsx(rn,{title:"Slippage tolerance",content:ne=>t.jsx(Dp,{afterConfirm:ne}),className:Me.edit,children:t.jsx(S.IconSettingFilled,{size:12})})]})}].filter(ne=>ne.condition):[],[bt,Re,Ls,P,Hn,g]);return t.jsxs("form",{className:Me.form,onSubmit:nt,children:[t.jsx(mo,{selectButton:t.jsx(ka,{type:"src"}),accountButton:b==="cosmos"&&t.jsx(Ia,{type:"src"}),quantityInput:t.jsx(In,{balance:q?.amount,decimals:N?.decimals}),balanceButton:t.jsx(hi,{onClick:()=>r("quantity",j.fromBaseUnit(q?.amount,{decimals:N?.decimals??0}),{shouldValidate:!0}),disabled:V,children:j.formatAmount(q?.amount??"0",{decimals:N.decimals})}),value:P?ee(P.usd_amount_in):"$-"}),t.jsxs("div",{className:Me.arrow,children:[t.jsx("div",{className:Me.divider}),t.jsx("button",{type:"button",className:Me.flip,onClick:()=>un(),children:t.jsx(S.IconChevronDown,{size:16})})]}),t.jsx(mo,{selectButton:t.jsx(ka,{type:"dst"}),accountButton:t.jsx(Ia,{type:"dst"}),quantityInput:t.jsx(In.ReadOnly,{children:Wi}),value:P?ee(P.usd_amount_out):"$-",hideNumbers:Hn}),t.jsx(Nn,{children:Hn?t.jsxs(os.Stack,{children:[t.jsx(os,{label:"Fast",query:E,value:"default",onSelect:o,checked:s==="default"}),t.jsx(os,{label:"Lossless",query:U,value:"op",onSelect:o,checked:s==="op"})]}):null}),t.jsx(xe,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(fe.Stack,{children:[P?.extra_infos?.map(ne=>t.jsx(fe,{level:"info",children:ne},ne)),Be&&t.jsx(fe,{level:"info",children:Be}),Hi&&Qi&&t.jsx(fe,{level:"warning",children:"Make sure to leave enough for transaction fee"}),P?.warning&&t.jsx(fe,{level:"warning",children:P.warning.message}),P?.extra_warnings?.map(ne=>t.jsx(fe,{level:"warning",children:ne},ne))]}),t.jsx(Nn,{children:aa.length>0&&t.jsx("div",{className:Me.meta,children:aa.map((ne,Tt)=>t.jsxs("div",{className:Me.row,children:[t.jsx("span",{className:Me.title,children:ne.title}),ne.content]},Tt))})})]}),children:t.jsx(le.White,{loading:Wt&&"Simulating...",disabled:!!Wn,children:Wn??"Preview route"})})]})},Yp=()=>{mi();const e=dr(),n=Ce(),s=kt(),o=Sl(),a=_e.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:l,dstChainId:c,srcDenom:d,dstDenom:u,quantity:h,slippagePercent:m,recipient:f}=r();r((w,{name:E})=>{(E==="srcChainId"||E==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=li(),g=p(l),x=p(c),b=di()(f,c);_.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",g)},[l,g,i]),_.useEffect(()=>{b||i("recipient",x)},[x,b,i]);const{showNotification:C}=Ss(),v=ze(l),N=ze(c),k=is(l),$=is(c),q=k.some(w=>w.denom===d),V=$.some(w=>w.denom===u);_.useEffect(()=>{k.length>0&&!q&&(i("srcDenom",k[0].denom),C({type:"info",title:`Switched to ${k[0].symbol}`,description:`The selected asset is not available on ${v.pretty_name}.`,autoHide:!0}))},[k,q,i,C,v.pretty_name]),_.useEffect(()=>{$.length>0&&!V&&(i("dstDenom",$[0].denom),C({type:"info",title:`Switched to ${$[0].symbol}`,description:`The selected asset is not available on ${N.pretty_name}.`,autoHide:!0}))},[$,V,i,C,N.pretty_name]),_.useEffect(()=>{!q||!V||(localStorage.setItem(oe.BRIDGE_SRC_CHAIN_ID,l),localStorage.setItem(oe.BRIDGE_SRC_DENOM,d),localStorage.setItem(oe.BRIDGE_DST_CHAIN_ID,c),localStorage.setItem(oe.BRIDGE_DST_DENOM,u),localStorage.setItem(oe.BRIDGE_QUANTITY,h),localStorage.setItem(oe.BRIDGE_SLIPPAGE_PERCENT,m))},[l,d,c,u,h,m,q,V]);const M=e[0].path==="/bridge",{reminders:I}=dn();return t.jsx(dt,{title:"Bridge/Swap",backButton:M?"/":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(ci,{offset:0,disabled:I.length===0,children:t.jsx(le.Small,{onClick:()=>n("/op/withdrawals"),disabled:!s,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:q&&V&&t.jsx(_e.FormProvider,{...a,children:t.jsx(me,{children:t.jsx(Gp,{})})})})},Zp="_button_1crvp_1",Jp="_checkbox_1crvp_11",Xp="_checked_1crvp_25",es={button:Zp,checkbox:Jp,checked:Xp},ef=({checked:e,onClick:n,label:s,className:o})=>t.jsxs("button",{type:"button",className:L(es.button,o),onClick:n,children:[t.jsx("div",{className:L(es.checkbox,{[es.checked]:e}),children:e&&t.jsx(S.IconCheck,{size:12})}),t.jsx("span",{className:es.label,children:s})]}),tf="_button_aoxv2_1",nf={button:tf},_i=({onClick:e,disabled:n})=>{const{ref:s,inView:o}=sc.useInView();return _.useEffect(()=>{o&&e()},[o,e]),t.jsxs("button",{className:nf.button,onClick:e,disabled:n,ref:s,children:[t.jsx("span",{children:"Load more"}),t.jsx(S.IconChevronDown,{size:12})]})};function xi(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})=>`${oe.BRIDGE_HISTORY}:${e}:${n}`,ds=100,Aa=10;function yi(){const[e,n]=Le.useLocalStorage(oe.BRIDGE_HISTORY,[]),s=_.useCallback((a,r)=>{localStorage.setItem(as(a),JSON.stringify(r));for(const i of e.slice(ds-1))localStorage.removeItem(as(i));n((i=[])=>[a,...i.slice(0,ds-1)])},[e,n]),o=_.useCallback(a=>{const r=localStorage.getItem(as(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function ji(e){return Le.useLocalStorage(as(e),null)}const zt=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 $s(){const{restUrl:e}=ae();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function sf(e){const n=$s(),{data:s}=T.useSuspenseQuery({queryKey:zt.bridge(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:K.INFINITY});return s}const Ta=20;function of(e){const n=te();return T.useSuspenseInfiniteQuery({queryKey:zt.withdrawals(e,n).queryKey,queryFn:async({pageParam:s})=>{if(!n)return[];const o={limit:Ta,offset:s,order:"desc"},{withdrawals:a}=await z.create({prefixUrl:e}).get(`withdrawals/${n}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=A.last(s)?.sequence;return s.length<Ta||!o||o<=1?null:o-1},initialPageParam:0,staleTime:K.SECOND})}function af(e){const n=$s(),{data:s}=T.useSuspenseQuery({queryKey:zt.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 rf({bridge_id:e,output_index:n}){const s=$s(),{data:o}=T.useSuspenseQuery({queryKey:zt.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 cf({bridge_id:e,sequence:n}){const o=de().find(({metadata:c})=>c?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const r=Ye()(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:l}=T.useSuspenseQuery({queryKey:zt.outputResponse(i,n).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${n}`).json(),staleTime:K.SECOND});return l}function bi(e,n){const{bridge_id:s}=e,o=$s(),{data:a}=T.useSuspenseQuery({queryKey:zt.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 gn(e){return oc.sha3_256.create().update(e).digest()}function Js(e,n){const s=new ArrayBuffer(n);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function wi(e){const{bridge_id:n,sequence:s,amount:o,from:a,to:r}=e,i=Js(n.toString(),8),l=Js(s.toString(),8),c=Js(o.amount,8),d=Dt.concatBytes(i,l,gn(Dt.utf8ToBytes(a)),gn(Dt.utf8ToBytes(r)),gn(Dt.utf8ToBytes(o.denom)),c);return gn(gn(d))}async function lf(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 df(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 fo(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(l){if(A.path(["error","code"],l)!==4902)throw l;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 jt(){return Je()}function uf(e,n){const{customFee:s,onCompleted:o}=n??{},a=Ce(),{showNotification:r,updateNotification:i,hideNotification:l}=Ss(),{addHistoryItem:c}=yi(),d=Tn(),{route:u,values:h}=jt(),{srcChainId:m,sender:f,recipient:p,cosmosWalletName:g}=h,x=jr(),{requestTxSync:y,submitTxSync:b,waitForTxConfirmation:C}=De(),{find:v}=As(),N=$n(),k=En(),$=ze(m),q=Cn($),V=Wr(m),M=T.useQueryClient(),{registryUrl:I}=Y(),w=Ye(),E=ae(),{addReminder:U}=dn(),F=Xe();return T.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const O=e.cosmos_tx.msgs.map(({msg_type_url:nt,msg:Re})=>{if(!(nt&&Re))throw new Error("Invalid transaction data");return k.fromAmino({type:sn.aminoConverters[nt].aminoType,value:JSON.parse(Re)})});if(q==="initia"){const{srcDenom:nt,quantity:Re}=h,{decimals:bt}=V(nt),Ht=s?await b({messages:O,chainId:m,fee:s}):await y({messages:O,chainId:m,internal:1,spendCoins:[{denom:nt,amount:j.toBaseUnit(Re,{decimals:bt})}]}),Wn=C({txHash:Ht,chainId:m});return{txHash:Ht,wait:Wn}}const Z=v(g)?.getProvider();if(!Z)throw new Error("Wallet not connected");const H=Z.getOfflineSignerOnlyAmino(m),R=await Ke.SigningStargateClient.connectWithSigner($.rpc,H,{registry:N,aminoTypes:k}),P=await R.getAllBalances(f),Ne=$.fee_assets.find(nt=>P.some(Re=>Re.denom===nt.denom&&B(Re.amount).gt(0)));if(!Ne){const Re=["Insufficient balance for fees.",`Available fee assets: ${$.fee_assets.map(bt=>V(bt.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Re)}const{denom:je,gas_price:tt}=Ne;if(!tt)throw new Error(`Gas price not found for ${je}`);const Be=await R.simulate(f,O,""),Wt=Ke.GasPrice.fromString(tt.average+je),un=Ke.calculateFee(Math.ceil(Be*on),Wt),Kn=await R.signAndBroadcastSync(f,O,un),zn=Tr({txHash:Kn,client:R});return{txHash:Kn,wait:zn}}if("evm_tx"in e){const{chain_id:O,to:Z,value:H,data:R}=e.evm_tx,P=await x(),Ne=await P.getSigner();await fo(P,$);const je=await Ne.sendTransaction({chainId:O,to:Z,value:H,data:`0x${R}`});return{txHash:je.hash,wait:je.wait()}}throw new Error("Unlisted chain type")}catch(O){throw await ft(O)}},onSuccess:async({txHash:O,wait:Z})=>{localStorage.removeItem(oe.BRIDGE_QUANTITY),o?o({txhash:O,chainId:m,timestamp:Date.now(),success:!0,route:u,values:h}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await Z;const H=Go(u)==="OP Bridge withdrawal",R=H?{success:!0,error:null}:await gf(F,O,m);if(!o&&!R.success&&R.error){const Be=R.error instanceof Error?R.error.message:String(R.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${Be}. The transaction may still be processing.`,autoHide:!0})}const P=R.success,je=pf({txHash:O,srcChainId:m,route:u,values:h,recipient:p},P);c(je.tx,je.details),o||i(hf(l));const tt=Xs(h,O);if(d("Bridge Transaction Success",tt),H){const Be=w(m).metadata?.op_bridge_id;if(Be&&!await lf(E.restUrl,Number(Be),u.dest_asset_denom)){const un=ff(je.tx,u,p);U(je.tx,un)}}}catch(H){const R=H instanceof Error?H.message:String(H);o?o({success:!1,error:R,route:u,values:h}):i({type:"error",title:"Transaction not confirmed",description:R});const P={...Xs(h,O),error:R};d("Bridge Confirmation Failed",P)}finally{M.invalidateQueries({queryKey:qe.balances(m,f).queryKey})}},onError:async O=>{const Z=q==="initia"?await Zt(O,w(m),I):O;o?o({success:!1,error:Z.message,route:u,values:h}):r({type:"error",title:"Transaction failed",description:Z.message});const H=Xs(h);d("Bridge Transaction Failed",{...H,error:Z.message})}})}function mf(){const e=Xe(),n=te(),s=xs(),{route:o,values:a}=jt(),r=yt();return T.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:l}=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:j.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await df(n,r(o.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:h,msg:m})=>sn.aminoTypes.fromAmino({type:sn.aminoConverters[h].aminoType,value:JSON.parse(m)})),d=await s(i,n,c,{amount:[],gas:"1"},"",{incrementSequence:i===a.srcChainId?2:0}),u=It.Tx.fromPartial({body:It.TxBody.decode(d.bodyBytes),authInfo:It.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:n,hook:ie.toBase64(It.Tx.encode(u).finish())}}catch(i){throw await ft(i)}}})}function hf(e){return{type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(nn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function Xs(e,n){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:n}}function pf(e,n){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},l=Go(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:l?"success":void 0,tracked:n},isOpWithdraw:l}}function ff(e,n,s){return{...e,recipient:j.InitiaAddress(s).bech32,claimableAt:Date.now()+n.estimated_route_duration_seconds*1e3,amount:n.amount_out,denom:n.dest_asset_denom}}async function gf(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 ft(i)};await new Promise(l=>setTimeout(l,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function vi(e){const{chainId:n,txHash:s,tracked:o}=e,a=Xe();return T.useQuery({queryKey:qe.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 ft(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:K.INFINITY,enabled:!o})}function Ci(e){const{timestamp:n,chainId:s,txHash:o,tracked:a,state:r}=e,i=Xe();return T.useQuery({queryKey:qe.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:l}})=>{if(!l)return!1;const{status:c}=l;if(c==="STATE_COMPLETED")return!1;const d=n+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),h=Math.floor((d-u)/1e3);return h<=0?1e3:h<=300?5e3:60*1e3},staleTime:K.INFINITY})}var rs=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(rs||{});function Go(e){const{operations:n,dest_asset_denom:s}=e;return A.has("op_init_transfer",A.head(n))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const _f="_success_t4dfk_1",xf="_error_t4dfk_5",$a={success:_f,error:xf},yf=({tx:e})=>{const[n,s]=ji(e);if(!n)throw new Error("Bridge history details not found");const{data:o}=Ci(n),a=n.state??jf(o);switch(_.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:$a.error,children:t.jsx(S.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:$a.success,children:t.jsx(S.IconCheckCircleFilled,{size:14})});default:return t.jsx(ct,{size:14})}};function jf(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 bf="_link_104m3_1",wf="_header_104m3_23",vf="_title_104m3_31",Cf="_date_104m3_37",Nf="_explorer_104m3_41",If="_fees_104m3_57",kf="_label_104m3_65",Sf="_content_104m3_69",Af="_route_104m3_75",Tf="_row_104m3_80",$f="_asset_104m3_86",Ef="_amount_104m3_94",qf="_chain_104m3_99",Lf="_account_104m3_108",Mf="_arrow_104m3_115",be={link:bf,header:wf,title:vf,date:Cf,explorer:Nf,fees:If,label:kf,content:Sf,route:Af,row:Tf,asset:$f,amount:Ef,chain:qf,account:Lf,arrow:Mf},Pf=({tx:e})=>{const[n,s]=ji(e);if(!n)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:l,tracked:c}=n,{data:d}=vi(n),{address:u="",connector:h}=ve.useAccount(),{find:m}=As();_.useEffect(()=>{d&&s(F=>{if(!F)throw new Error("Bridge history details not found");return{...F,tracked:!0}})},[s,d]);const{amount_in:f,amount_out:p,source_asset_chain_id:g,source_asset_denom:x,dest_asset_chain_id:y,dest_asset_denom:b,estimated_fees:C=[]}=r,v=ze(g),N=ze(y),k=it(x,g),$=it(b,y),q=(F,O)=>O?t.jsx(X,{src:O,width:12,height:12}):j.InitiaAddress.equals(F,u)?t.jsx(X,{src:h?.icon,width:12,height:12}):t.jsx(S.IconWallet,{size:12}),V=(F,{symbol:O,decimals:Z,logo_uri:H},{chain_name:R,pretty_name:P,...Ne},je,tt)=>t.jsxs("div",{className:be.row,children:[t.jsx(Ts,{assetLogoUrl:H,chainLogoUrl:Ne.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:be.asset,children:[t.jsx("span",{className:be.amount,children:j.formatAmount(F,{decimals:Z})}),t.jsx("span",{children:O})]}),t.jsxs("div",{className:be.chain,children:[t.jsxs("span",{children:["on ",P||R]}),t.jsxs("div",{className:be.account,children:[tt,t.jsx("span",{className:"monospace",children:j.truncate(je)})]})]})]})]}),M=Go(r),I=_.useMemo(()=>{switch(M){case rs.SKIP:return"Skip Explorer";case rs.OP_WITHDRAW:return"Initia Scan"}},[M]),w=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:be.header,children:[t.jsxs("div",{className:be.title,children:[c?t.jsx(yf,{tx:e}):t.jsx(ct,{size:14}),t.jsx("div",{className:be.date,children:Ge.format(new Date(l),"h:mm a")})]}),t.jsxs("div",{className:be.explorer,children:[t.jsx("span",{children:I}),t.jsx(S.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:be.route,children:[V(f,k,v,i.sender,q(i.sender,m(i.cosmosWalletName)?.image)),t.jsx("div",{className:be.arrow,children:t.jsx(S.IconArrowDown,{size:12})}),V(p,$,N,i.recipient,q(i.recipient))]}),C.length>0&&t.jsxs("div",{className:be.fees,children:[t.jsx("span",{className:be.label,children:"Fees"}),t.jsx("span",{className:be.content,children:Ho(C)})]})]});if(M===rs.OP_WITHDRAW)return t.jsx(ks,{chainId:o,txHash:a,className:be.link,children:w});const E=new URLSearchParams({tx_hash:a,chain_id:o}),U=new URL(`?${E.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:U.toString(),className:be.link,target:"_blank",children:w})},Df="_history_13u9z_1",Bf="_header_13u9z_5",Rf="_checkbox_13u9z_9",Ff="_groups_13u9z_13",Uf="_dateGroup_13u9z_21",Of="_dateHeader_13u9z_26",Vf="_list_13u9z_32",Lt={history:Df,header:Bf,checkbox:Rf,groups:Ff,dateGroup:Uf,dateHeader:Of,list:Vf},Kf=()=>{const{initiaAddress:e,hexAddress:n}=De(),{history:s,getHistoryDetails:o}=yi(),a=s.filter(f=>o(f)),r=a.filter(f=>{const p=o(f);if(!p)return!1;const{values:g}=p,{sender:x,recipient:y}=g;return[x,y].some(b=>[e,n].includes(b))}),[i,l]=_.useState(1),[c,d]=Le.useToggle(!r.length),u=c?a:r,h=u.slice(0,i*Aa),m=_.useMemo(()=>xi(h,f=>{const p=o(f);if(p)return new Date(p.timestamp)}),[h,o]);return t.jsx(dt,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:Lt.history,children:[a.length>0&&a.length!==r.length&&t.jsx("header",{className:Lt.header,children:t.jsx(ef,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:Lt.checkbox})}),u.length===0?t.jsx(he,{children:"No bridge/swap activity"}):t.jsx("div",{className:Lt.groups,children:Object.entries(m).map(([f,p])=>t.jsxs("div",{className:Lt.dateGroup,children:[t.jsx("div",{className:Lt.dateHeader,children:f}),t.jsx("div",{className:Lt.list,children:p.map(g=>t.jsx(me,{children:t.jsx(Pf,{tx:g})},g.txHash))})]},f))}),u.length>i*Aa?t.jsx(_i,{onClick:()=>l(f=>f+1)}):s.length>=ds&&t.jsxs(he,{children:["Only the latest ",ds," items are stored. Older entries will be removed automatically."]})]})})},Yo=({tx:e,fee:n,onCompleted:s,confirmMessage:o,error:a})=>{const{mutate:r,isPending:i}=uf(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"})})},zf="_content_1hzj2_1",Wf="_info_1hzj2_6",Hf="_arrow_1hzj2_11",Qf="_divider_1hzj2_19",Gf="_type_1hzj2_27",Yf="_asset_1hzj2_47",Zf="_amount_1hzj2_55",Jf="_lower_1hzj2_60",Xf="_chain_1hzj2_66",eg="_address_1hzj2_72",Ue={content:zf,info:Wf,arrow:Hf,divider:Qf,type:Gf,asset:Yf,amount:Zf,lower:Jf,chain:Xf,address:eg},Ni=e=>{const{source:n,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:l}=e,{symbol:c=j.truncate(a),decimals:d=0,logo_uri:u=No}=e,{chain_name:h,pretty_name:m,...f}=ze(r);return t.jsxs("div",{children:[!n&&t.jsxs("div",{className:Ue.arrow,children:[t.jsx("div",{className:Ue.divider}),s?t.jsx(Fn,{label:s,children:t.jsx("button",{className:Ue.type,children:t.jsx(S.IconArrowDown,{size:12})})}):t.jsx("span",{className:Ue.type,children:t.jsx(S.IconArrowDown,{size:12})}),t.jsx("div",{className:Ue.divider})]}),t.jsxs("div",{className:Ue.content,children:[t.jsx(Ts,{assetLogoUrl:u,chainLogoUrl:f.logo_uri??void 0}),t.jsxs("div",{className:Ue.info,children:[t.jsxs("div",{className:Ue.asset,children:[t.jsx("span",{className:Ue.amount,children:j.formatAmount(o,{decimals:d})}),t.jsx("span",{children:c})]}),t.jsxs("div",{className:Ue.lower,children:[t.jsxs("div",{className:Ue.chain,children:["on ",m||h]}),i&&t.jsx(cs,{value:i,children:({copy:p,copied:g})=>t.jsxs("button",{className:Ue.address,onClick:p,children:[l,g?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:j.truncate(i)})]})})]})]})]})]})},en=e=>{const n=it(e.denom,e.chainId);return t.jsx(Ni,{...e,...n})};en.Placeholder=Ni;const tg="_root_1hbar_1",ng="_flexEnd_1hbar_6",sg="_toggle_1hbar_11",og="_route_1hbar_36",ag="_content_1hbar_43",_n={root:tg,flexEnd:ng,toggle:sg,route:og,content:ag};function rg(e){const n=({name:s})=>s==="initia-dex"?"Initia DEX":hs.capitalCase(A.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 ig=({addressList:e})=>{const{values:n,route:s}=jt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,l=A.zipObj(s.required_chain_addresses,e),{find:c}=As(),{connector:d,address:u=""}=ve.useAccount(),[h,m]=Le.useToggle(!1),f=i.length>1,p=t.jsx(X,{src:n.cosmosWalletName?c(n.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:r,denom:o,chainId:a,address:n.sender,walletIcon:p},x=N=>j.InitiaAddress.equals(N,u)?p:t.jsx(S.IconWallet,{size:11}),y=N=>{const{label:k,amount_out:$,denom:q,denom_out:V=q,chain_id:M,from_chain_id:I,to_chain_id:w=M??I}=N,E=l[w];return{label:f&&!h?void 0:k,amount:$,denom:V,chainId:w,address:E,walletIcon:x(E)}},b=i.map(rg).map(y),C=b.slice(0,-1),v=b[b.length-1];return t.jsxs(J.Collapsible.Root,{className:_n.root,open:h,onOpenChange:m,children:[f&&t.jsx("div",{className:_n.flexEnd,children:t.jsx(J.Collapsible.Trigger,{className:_n.toggle,children:h?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:_n.route,children:[t.jsx(en,{...g,source:!0}),t.jsx(J.Collapsible.Content,{className:_n.content,children:C.map((N,k)=>t.jsx(me,{suspenseFallback:t.jsx(en.Placeholder,{...N}),errorBoundaryProps:{fallback:t.jsx(en.Placeholder,{...N})},children:t.jsx(en,{...N})},k))}),t.jsx(en,{...v})]})]})},Ii=({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"})})},ki=({children:e})=>{const n=jt(),{route:s,values:o}=n,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:l,recipient:c}=o,{initiaAddress:d,hexAddress:u}=De(),h=qn(),m=yt(),f=Dn(),p=m(r),g=f(p),x=a.slice(0,-1).some($=>{const q=m($);return f(q)==="cosmos"})&&g!=="cosmos",[y,b]=_.useState(void 0),[C,v]=_.useState(!1),[N,k]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!x)return;if(!h)throw new Error("Wallet not connected");v(!0),k(null);const[{pubkey:q}]=await h.getAccounts();b(q)}catch(q){k(await ft(q))}finally{v(!1)}})()},[x,h]),N)return t.jsx(Ii,{error:N});if(C)return t.jsx(xe,{children:t.jsx(le.White,{loading:C&&"Generating intermediary addresses..."})});if(!x||y){const $=a.map((q,V)=>{if(V===a.length-1){const U=m(i);return f(U)==="initia"?j.InitiaAddress(c).bech32:c}const M=m(q),I=f(M),w=m(r),E=f(w);switch(I){case"initia":return d;case"evm":return u;case"cosmos":{if(E==="cosmos")return ie.toBech32(M.bech32_prefix,ie.fromBech32(l).data);if(!y)throw new Error("Pubkey not found");return jn.pubkeyToAddress(jn.encodeSecp256k1Pubkey(y),M.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e($)}return null},Zo=({tx:e,children:n})=>{const s=jr(),o=yt(),{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:u,signer_address:h}=e.evm_tx,m=await s();await fo(m,o(u));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:x,spender:y}=g,C=await new pt.ethers.Contract(x,f,m).allowance(h,y);return{approval:g,currentAllowance:BigInt(C.toString())}}))).filter(({approval:g,currentAllowance:x})=>x<BigInt(g.amount)).map(({approval:g})=>g)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:l,isPending:c,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:u}=e.evm_tx,h=await s(),m=await h.getSigner();await fo(h,o(u));for(const f of a){const{token_contract:p,spender:g,amount:x}=f,y=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new pt.ethers.Contract(p,y,m).approve(g,x)).wait()}return!0}catch(u){throw await ft(u)}}});return r?t.jsx(xe,{children:t.jsx(le.White,{loading:"Checking approvals..."})}):a&&a.length>0&&!l?t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:d?.message}),children:t.jsx(le.White,{onClick:()=>i(),loading:c&&"Approving tokens...",children:"Approve tokens"})}):n},Si=({addressList:e,signedOpHook:n,children:s})=>{const o=Xe(),{route:a,values:r}=jt(),[i,l]=_.useState(void 0),[c,d]=_.useState(!1),[u,h]=_.useState(null);return _.useEffect(()=>{(async()=>{try{if(a.required_op_hook&&!n)throw new Error("Op hook is required");d(!0),h(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;l(g)}catch(f){h(f)}finally{d(!1)}})()},[a,r,JSON.stringify(e),n,o]),u?t.jsx(Ii,{error:u}):c||!i?t.jsx(xe,{children:t.jsx(le.White,{loading:"Fetching messages..."})}):s(i)},Ai=({children:e})=>{const{route:n}=jt(),s=mf();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)},cg=()=>t.jsx(dt,{title:"Route preview",children:t.jsx(ki,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(ig,{addressList:e}),t.jsx(Ai,{children:n=>t.jsx(Si,{addressList:e,signedOpHook:n,children:s=>t.jsx(Zo,{tx:s,children:t.jsx(Yo,{tx:s})})})})]})})}),Ti=_.createContext(null);function Es(){return _.useContext(Ti)}const lg="_button_17r1o_1",dg="_claimed_17r1o_24",Ea={button:lg,claimed:dg},ug=()=>{const{withdrawalTx:e}=Es(),{bridge_id:n,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:l,to:c,version:d}=e,u=ae(),h=te(),{requestTxSync:m,waitForTxConfirmation:f}=De(),p=cf(e),g=ie.toBase64(wi(e)),x=bi(e,g),y=T.useQueryClient(),{mutate:b,isPending:C}=T.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:v}=p;return m({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:h,bridgeId:BigInt(n),outputIndex:BigInt(a),withdrawalProofs:r.map(ie.fromBase64),from:l,to:c,sequence:BigInt(s),amount:o,version:ie.fromBase64(d),storageRoot:ie.fromBase64(i),lastBlockHash:ie.fromBase64(v)}}],internal:!0})},onSuccess:async v=>{await f({chainId:u.chain_id,txHash:v}),y.invalidateQueries({queryKey:zt.withdrawalClaimed(n,g).queryKey})}});return x?t.jsxs("div",{className:Ea.claimed,children:[t.jsx(S.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:Ea.button,onClick:()=>b(),disabled:C,children:"Claim"})},mg=({children:e})=>{const{withdrawalTx:n}=Es(),s=sf(n.bridge_id),o=rf(n),a=_.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Ge.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},$i=1e3,hg=60,pg=60,fg=24,go=$i*hg,_o=go*pg,qa=_o*fg,gg=({date:e})=>{const n=_.useCallback(()=>{const d=new Date().getTime(),h=e.getTime()-d;if(h<=0)return{days:0,hours:0,minutes:0,seconds:0};const m=Math.floor(h/qa),f=Math.floor(h%qa/_o),p=Math.floor(h%_o/go),g=Math.floor(h%go/$i);return{days:m,hours:f,minutes:p,seconds:g}},[e]),[s,o]=_.useState(n());_.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:l,seconds:c}=s;return t.jsx(Fn,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(l),"m ",a(c),"s"]})})},_g="_container_1lz3w_1",xg="_title_1lz3w_5",La={container:_g,title:xg},yg=({date:e})=>t.jsxs("div",{className:La.container,children:[t.jsx("div",{className:La.title,children:"Claimable in"}),t.jsx(gg,{date:e})]}),jg="_container_1oldz_1",bg="_icon_1oldz_7",Ma={container:jg,icon:bg},wg="Withdrawal will begin within an hour",Pa=()=>{const e=Ns();return t.jsxs("div",{className:Ma.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Fn,{label:wg,children:t.jsx("span",{className:Ma.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]})},vg=({children:e})=>{const{withdrawalTx:n}=Es(),s=af(n.bridge_id),o=n.output_index>Number(s?.output_index);return e(o)},Cg=({date:e,children:n})=>{const{chainId:s,withdrawalTx:o}=Es(),a=ie.toBase64(wi(o)),r=bi(o,a),{setReminder:i,removeReminder:l}=dn();return _.useEffect(()=>{const c={chainId:s,txHash:o.tx_hash};r?l(c):i(c,{...c,recipient:o.to,claimableAt:e.getTime(),amount:o.amount.amount,denom:o.amount.denom,dismissed:Ge.isPast(e.getTime())?!0:void 0})},[s,r,e,l,i,o]),n},Ng=()=>t.jsx(vg,{children:e=>e?t.jsx(Pa,{}):t.jsx(mg,{children:n=>n?t.jsx(Cg,{date:n,children:Ge.isFuture(n)?t.jsx(yg,{date:n}):t.jsx(ug,{})}):t.jsx(Pa,{})})}),Ig="_asset_6h8u2_1",kg="_info_6h8u2_7",Sg="_symbol_6h8u2_11",eo={asset:Ig,info:kg,symbol:Sg},Ag=({amount:e,denom:n})=>{const s=ae(),o=sr(n,s),{symbol:a,logoUrl:r,decimals:i}=o;return t.jsxs("div",{className:eo.asset,children:[t.jsx(X,{src:r,width:32,height:32,logo:!0}),t.jsxs("div",{className:eo.info,children:[t.jsx("span",{className:"monospace",children:j.formatAmount(e,{decimals:i})}),t.jsx("span",{className:eo.symbol,children:a})]})]})},Tg="_item_km5w2_1",$g={item:Tg},Eg=({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}=of(n),i=_.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:l}=dn();return _.useEffect(()=>{const c=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));l(c)},[e.chainId,i,l]),i.length?t.jsxs(t.Fragment,{children:[i.map(c=>{const{amount:d}=c;return t.jsxs("div",{className:$g.item,children:[t.jsx(Ag,{...d}),t.jsx(me,{suspenseFallback:null,children:t.jsx(Ti.Provider,{value:{chainId:e.chainId,withdrawalTx:c},children:t.jsx(Ng,{})})})]},c.sequence)}),a&&t.jsx(_i,{onClick:()=>o(),disabled:r})]}):t.jsx(he,{children:"No withdrawals"})},qg="_content_dj1qm_1",Lg="_title_dj1qm_5",Da={content:qg,title:Lg},Mg=()=>{const{chainId:e}=Je(),n=de(),s=Vt(),[o,a]=_.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=Ye(),{reminders:i}=dn(),l=o?r(o):void 0;return t.jsxs(dt,{title:"OP Bridge withdrawals",children:[t.jsx(Ft,{chains:n.filter(({metadata:c})=>!c?.is_l1&&c?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:c=>i.some(d=>d.chainId===c)}),t.jsx("div",{className:Da.content,children:l?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:Da.title,children:l.name}),t.jsx(me,{children:t.jsx(Eg,{chain:l})},o)]}):t.jsx(fe,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},us=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),Pg="5722e7dffb709492cf5312446ceeff73",Dg=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${Pg}`,Ei=["walletconnect-wallets"],Bg=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",qi=async e=>{const n=await z.get(Dg,{signal:e}).json(),s=n!==null&&typeof n=="object"&&"listings"in n?n.listings:n;return Object.values(s??{}).filter(Bg)},Rg=()=>T.useQuery({queryKey:Ei,queryFn:({signal:e})=>qi(e),staleTime:K.INFINITY,gcTime:K.INFINITY,retry:2}),Fg="_page_13y8q_1",Ug="_pageTop_13y8q_19",Og="_backButtonFixed_13y8q_63",Vg="_listItem_13y8q_64",Kg="_socialButton_13y8q_65",zg="_arrowIcon_13y8q_66",Wg="_searchInputUnderline_13y8q_67",Hg="_header_13y8q_72",Qg="_title_13y8q_81",Gg="_headerSpacer_13y8q_116",Yg="_icon_13y8q_120",Zg="_installedText_13y8q_124",Jg="_divider_13y8q_131",Xg="_dividerText_13y8q_152",e_="_loading_13y8q_193",t_="_socialIcons_13y8q_198",n_="_socialText_13y8q_204",s_="_searchWrapper_13y8q_214",o_="_scrollable_13y8q_248",a_="_list_13y8q_64",r_="_listIconWrapper_13y8q_332",i_="_moreIconSmall_13y8q_342",c_="_externalLinkIcon_13y8q_364",l_="_listName_13y8q_368",d_="_listNameMuted_13y8q_381",u_="_recentBadge_13y8q_394",m_="_learnMoreLink_13y8q_408",D={page:Fg,pageTop:Ug,backButtonFixed:Og,listItem:Vg,socialButton:Kg,arrowIcon:zg,searchInputUnderline:Wg,header:Hg,title:Qg,headerSpacer:Gg,icon:Yg,installedText:Zg,divider:Jg,dividerText:Xg,loading:e_,socialIcons:t_,socialText:n_,searchWrapper:s_,scrollable:o_,list:a_,listIconWrapper:r_,moreIconSmall:i_,externalLinkIcon:c_,listName:l_,listNameMuted:d_,recentBadge:u_,learnMoreLink:m_},h_=e=>{try{const n=new URL(e.trim());return n.protocol==="https:"&&!n.username&&!n.password}catch{return!1}},p_=({walletConnectors:e,isPending:n,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,l]=_.useState(""),{data:c=[],isError:d,isLoading:u,isFetching:h}=Rg(),m=u||h&&c.length===0,f=_.useMemo(()=>{if(!i)return e;const g=i.toLowerCase();return e.filter(x=>x.name.toLowerCase().includes(g))},[e,i]),p=_.useMemo(()=>{const g=new Set(e.map(y=>us(y.name))),x=i.toLowerCase();return c.filter(y=>!g.has(us(y.name))).filter(y=>!i||y.name.toLowerCase().includes(x)).sort((y,b)=>y.name.localeCompare(b.name))},[c,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(Un,{rootClassName:D.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:g=>l(g.target.value),onClear:()=>l("")})}),t.jsx(et,{className:D.scrollable,children:t.jsxs("div",{className:D.list,children:[f.map(g=>{const{name:x,icon:y,id:b}=g,C=o===b,v=s===b,N="ready"in g?!!g.ready:!0;return t.jsxs("button",{type:"button",className:L(D.listItem,{[D.loading]:v}),onClick:()=>a(g),disabled:n||!N,"aria-busy":v,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(X,{src:y,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listName,children:x}),v?t.jsx(ct,{size:16}):C?t.jsx("span",{className:D.recentBadge,children:"Recent"}):N?t.jsx("span",{className:D.installedText,children:"Installed"}):null]},`connector:${b}`)}),m&&t.jsxs("div",{className:L(D.listItem,D.loading),role:"status","aria-live":"polite",children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(ct,{size:16})}),t.jsx("span",{className:D.listNameMuted,children:"Loading more wallets..."})]}),p.map(g=>{const x=g.image_url?.sm||g.image_url?.md||g.image_url?.lg,y=x&&h_(x)?x: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(X,{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."})]})})]})},f_=()=>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"})]}),g_=()=>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"})]}),__=()=>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"})}),x_=()=>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"})]}),y_=[{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"}],j_=({walletConnectors:e,privyConnector:n,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:l})=>{const c=e.filter(p=>!("ready"in p)||!!p.ready),d=c.slice(0,5),u=new Set(c.map(p=>p.id)),h=new Set(c.map(p=>us(p.name))),m=Math.max(0,5-d.length),f=y_.filter(p=>!u.has(p.id)&&!h.has(us(p.name))).slice(0,m);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:L(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(ct,{size:16}):t.jsxs("div",{className:D.socialIcons,children:[t.jsx(g_,{}),t.jsx(x_,{}),t.jsx(__,{})]})]}),t.jsx("div",{className:D.divider,children:t.jsx("span",{className:D.dividerText,children:"or"})})]}),t.jsx(et,{className:D.scrollable,children:t.jsxs("div",{className:D.list,children:[d.map(p=>{const{name:g,icon:x,id:y}=p,b=o===y,C=a===y;return t.jsxs("button",{type:"button",className:L(D.listItem,{[D.loading]:b}),onClick:()=>r(p),disabled:s,"aria-busy":b,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(X,{src:x,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listName,children:g}),b?t.jsx(ct,{size:16}):C?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(X,{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:l,onFocus:l,disabled:s,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx("div",{className:D.moreIconSmall,children:t.jsx(f_,{})})}),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"})]})]})},Ba=({onSuccess:e})=>{const{connectors:n,connectAsync:s}=ve.useConnect(),o=Le.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=_.useState(null),[i,l]=_.useState("signin"),c=T.useQueryClient(),d=()=>c.prefetchQuery({queryKey:Ei,queryFn:({signal:g})=>qi(g),staleTime:K.INFINITY,gcTime:K.INFINITY}),{mutate:u,isPending:h}=T.useMutation({mutationFn:async g=>{try{await s({connector:g})}catch(x){throw await ft(x)}},onMutate:g=>{r(g.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),m=_.useMemo(()=>[...n].sort((g,x)=>g.id===o?-1:x.id===o?1:g.name.localeCompare(x.name)),[n,o]),f=_.useMemo(()=>m.find(g=>g.id===bn.id),[m]),p=_.useMemo(()=>m.filter(g=>g.id!==bn.id),[m]);return i==="all"?t.jsx(p_,{walletConnectors:p,isPending:h,pendingConnectorId:a,recentConnectorId:o,onConnect:u,onBack:()=>l("signin")}):t.jsx(j_,{walletConnectors:p,privyConnector:f,isPending:h,pendingConnectorId:a,recentConnectorId:o,onConnect:u,onShowAll:()=>l("all"),onPrefetchWallets:d})},b_={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 Vn(e){return b_[e]}function Jo(){const e=Xe(),n=ln(),s=te(),o=Bn(),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:qe.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:l}])=>[i,l||{}])):{},enabled:!!s,staleTime:K.SECOND})}function Xo(){const{localOptions:e=[]}=Je();return Kt().filter(({denom:s,chain_id:o})=>e.some(a=>a.denom===s&&a.chainId===o))}function ea(e){const{local:n}=Vn(e),s=Kt(),{watch:o}=At(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:l,chain_id:c})=>i===l&&c===r)||null}function w_(e){const{external:n}=Vn(e),s=Kt(),{watch:o}=At(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:l,chain_id:c})=>i===l&&c===r)||null}function v_(e){const n=Kt(),s=yt(),{data:o,isLoading:a}=Jo(),{remoteOptions:r=[]}=Je(),i=ea(e);return i?{data:n.filter(({symbol:c,denom:d,chain_id:u})=>r.length?r.some(h=>h.denom===d&&h.chainId===u):c===i.symbol).map(c=>{if(c.hidden||c.chain_id===i.chain_id)return null;const d=s(c.chain_id);if(!d||d.chain_type==="cosmos"&&d.bech32_prefix!=="init")return null;const u=o?.[d.chain_id]?.[c.denom];return e==="deposit"&&(!u||!Number(u.amount))?null:{asset:c,chain:d,balance:u}}).filter(c=>c!==null),isLoading:a}:{data:[],isLoading:a}}function At(){return _e.useFormContext()}const C_="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",N_="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",I_="_container_uxgnj_1",k_="_title_uxgnj_5",S_="_close_uxgnj_12",A_="_emptyIcon_uxgnj_24",T_="_empty_uxgnj_24",$_="_list_uxgnj_51",E_="_asset_uxgnj_66",q_="_placeholder_uxgnj_82",L_="_activeAsset_uxgnj_95",M_="_iconContainer_uxgnj_99",P_="_assetIcon_uxgnj_109",D_="_chainIcon_uxgnj_119",B_="_assetPlaceholder_uxgnj_133",R_="_assetName_uxgnj_154",F_="_assetChain_uxgnj_169",U_="_balance_uxgnj_177",O_="_value_uxgnj_186",ue={container:I_,title:k_,close:S_,emptyIcon:A_,empty:T_,list:$_,asset:E_,placeholder:q_,activeAsset:L_,iconContainer:M_,assetIcon:P_,chainIcon:D_,assetPlaceholder:B_,assetName:R_,assetChain:F_,balance:U_,value:O_},V_=({mode:e})=>{const{external:n}=Vn(e),{data:s,isLoading:o}=v_(e),{setValue:a,watch:r}=At(),i=ea(e),l=Xo(),{theme:c}=Y(),d=r(),u=d[n.denomKey],h=d[n.chainIdKey];function m(){const f=u&&h;return!f&&l.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:[m(),t.jsx("h4",{className:ue.title,children:"No available assets"}),t.jsx("img",{src:c==="dark"?C_:N_,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:[m(),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:L(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 x=u===f.denom&&h===p.chain_id;return t.jsxs("button",{className:L(ue.asset,x&&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," ",x&&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:j.formatAmount(g.amount,{decimals:g.decimals||6})}),t.jsx("p",{className:ue.value,children:ee(g.value_usd||0)})]})]},`${f.chain_id}-${f.denom}`)})]})]}):t.jsx("div",{children:"No assets found"})},K_="_title_9ovji_1",z_="_list_9ovji_7",W_="_asset_9ovji_15",to={title:K_,list:z_,asset:W_},H_=({mode:e})=>{const{local:n,external:s}=Vn(e),{setValue:o}=At(),a=Xo(),r=(l,c)=>{o(n.denomKey,l),o(n.chainIdKey,c),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),o("page",e==="withdraw"?"fields":"select-external")},i=_.useEffectEvent(()=>{const{denom:l,chain_id:c}=a[0];r(l,c)});return _.useEffect(()=>{a.length===1&&i()},[a]),a.length?t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:to.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),t.jsx("div",{className:to.list,children:a.map(({denom:l,chain_id:c,symbol:d,logo_uri:u})=>t.jsxs("button",{className:to.asset,onClick:()=>r(l,c),children:[t.jsx("img",{src:u,alt:d}),d]},`${l}-${c}`))})]}):t.jsx("div",{children:"No assets found"})},Q_="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",G_="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",Y_="_container_9k4hs_1",Z_="_title_9k4hs_8",J_="_subtitle_9k4hs_14",X_="_linkContainer_9k4hs_30",ex="_link_9k4hs_30",tx="_separator_9k4hs_51",nx="_errorIcon_9k4hs_62",sx="_error_9k4hs_62",we={container:Y_,title:Z_,subtitle:J_,linkContainer:X_,link:ex,separator:tx,errorIcon:nx,error:sx};function ox(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 xo({type:e}){const{closeModal:n}=cn(),{theme:s}=Y(),{watch:o}=At(),{result:a}=o(),{openDrawer:r}=xt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,l=i?"":a.txhash,c=i?"":a.chainId,d=i?0:a.timestamp??0,{route:u,values:h}=a,{srcDenom:m,srcChainId:f,quantity:p}=h,g=it(m,f),x=e==="deposit"?"Deposit":"Withdraw",{data:y}=vi({chainId:c,txHash:l,tracked:!1}),{data:b}=Ci({chainId:c,txHash:l,tracked:!!y,timestamp:d,route:u}),C=ox(b),v=s==="dark"?Q_:G_,N=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,k=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return t.jsxs("div",{className:we.container,children:[t.jsxs("h3",{className:we.title,children:[x," failed"]}),t.jsx("img",{src:v,alt:"Failed",className:we.errorIcon}),t.jsx("p",{className:we.error,children:a?.error}),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]});const $=kn(u.estimated_route_duration_seconds),q=new URLSearchParams({tx_hash:l,chain_id:c}),V=new URL(`?${q.toString()}`,"https://explorer.skip.build"),M=()=>t.jsxs("div",{className:we.linkContainer,children:[t.jsx("a",{href:V.toString(),target:"_blank",rel:"noopener noreferrer",className:we.link,children:"View transaction"}),t.jsx("div",{className:we.separator}),t.jsx("button",{className:we.link,onClick:()=>{n(),r("/bridge/history")},children:"Go to history"})]});return t.jsxs("div",{className:we.container,children:[C==="pending"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:we.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",p," ",g.symbol]}),t.jsx("video",{src:N,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),t.jsxs("p",{className:we.subtitle,children:["Estimated time: ",t.jsx("span",{children:$})]}),M(),t.jsx("p",{className:we.subtitle,children:"Your transaction will continue even if you close this"})]}),C==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:we.title,children:[x," complete"]}),t.jsx("video",{src:k,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:I=>{const w=I.currentTarget;w.duration-w.currentTime<.1&&w.pause()}}),M(),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]}),C==="failed"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:we.title,children:[x," failed"]}),t.jsx("img",{src:v,alt:"Failed",className:we.errorIcon}),t.jsx("p",{className:we.error,children:"Your transaction could not be completed"}),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]})]})}const ax=ye.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),rx=({tx:e,children:n})=>{const{values:s}=jt(),{srcChainId:o}=s,a=te(),r=En(),i=$o(),{data:l,isLoading:c}=T.useQuery({queryKey:ax.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const u=e.cosmos_tx.msgs.map(({msg_type_url:f,msg:p})=>{if(!(f&&p))throw new Error("Invalid transaction data");return r.fromAmino({type:sn.aminoConverters[f].aminoType,value:JSON.parse(p)})});return{estimatedGas:await(await i(o)).simulate(a,u,""),messages:u}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if(c)return t.jsx(xe,{children:t.jsx(le.White,{loading:"Estimating gas..."})});const d=l?.estimatedGas??null;return t.jsx(t.Fragment,{children:n(d)})},ix="_container_eg177_1",cx="_back_eg177_6",lx="_title_eg177_18",dx="_divider_eg177_26",ux="_label_eg177_30",mx="_asset_eg177_37",hx="_assetIcon_eg177_55",px="_chainIcon_eg177_67",fx="_assetName_eg177_80",gx="_chevron_eg177_92",_x="_input_eg177_96",xx="_balanceContainer_eg177_108",yx="_value_eg177_116",jx="_maxButton_eg177_126",bx="_detail_eg177_142",wx="_detailsContainer_eg177_153",vx="_detailsButton_eg177_163",Cx="_detailValue_eg177_180",Nx="_detailToken_eg177_190",Ix="_minimumReceived_eg177_198",Q={container:ix,back:cx,title:lx,divider:dx,label:ux,asset:mx,assetIcon:hx,chainIcon:px,assetName:fx,chevron:gx,input:_x,balanceContainer:xx,value:yx,maxButton:jx,detail:bx,detailsContainer:wx,detailsButton:vx,detailValue:Cx,detailToken:Nx,minimumReceived:Ix},Li=({renderFee:e})=>{const{route:n}=Je(),{values:s}=jt(),{dstDenom:o,dstChainId:a}=s,i=Kt().find(({denom:f,chain_id:p})=>f===o&&p===a),l=te(),c=Jr(),[d,u]=Le.useToggle(!1),h=n&&n.estimated_route_duration_seconds>60;if(!n||!i)return null;const m=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(Nn,{children:t.jsxs("div",{className:Q.detailsContainer,children:[t.jsxs("button",{className:Q.detailsButton,onClick:u,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:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Slippage"}),t.jsxs("p",{className:Q.detailValue,children:[s.slippagePercent,"%"]})]}),!!n.estimated_fees?.length&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Bridge fee"}),t.jsx("div",{className:Q.detailValue,children:Ho(n.estimated_fees)})]}),e&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Tx fee"}),t.jsx("div",{className:Q.detailValue,children:e()})]}),l&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Receiving address"}),t.jsxs("p",{className:Q.detailValue,children:[t.jsx("img",{src:c,alt:"Wallet",height:12,width:12})," ",j.truncate(l)]})]})]}),t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Estimated time"}),t.jsx("p",{className:L(Q.detailValue),style:h?{color:"var(--warning)"}:void 0,children:kn(n.estimated_route_duration_seconds)})]}),t.jsxs("div",{className:L(Q.detail,Q.minimumReceived),children:[t.jsx("p",{className:Q.detailLabel,children:"Minimum received"}),t.jsxs("p",{className:Q.detailValue,children:[t.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Q.detailToken})," ",j.formatAmount(m,{decimals:i.decimals})," ",i.symbol]})]})]})})},kx="_trigger_1c7d7_1",Sx="_item_1c7d7_5",Ax="_itemText_1c7d7_13",Tx={trigger:kx,item:Sx,itemText:Ax},$x=({tx:e,gas:n,confirmMessage:s,onCompleted:o})=>{const{values:a}=jt(),{srcChainId:r,srcDenom:i,quantity:l}=a,d=Kt().find(({denom:I,chain_id:w})=>I===i&&w===r),u=Ze(r),h=An(u),m=Vo(u),f=Ko(u),p=lt(u),g=m.map(({amount:I,denom:w})=>Ke.calculateFee(Math.ceil(n*on),Ke.GasPrice.fromString(I+w))),x=g.map(I=>I.amount[0]),y=I=>{const w=h.find(R=>R.denom===I)?.amount??"0",E=x.find(R=>R.denom===I)?.amount??"0",U=d&&i===I?B(l||"0").times(B(10).pow(d.decimals)).toFixed(0):"0",F=B(E).plus(U),O=B(w).gte(F),{symbol:Z,decimals:H}=p(I);return{symbol:Z,decimals:H,spend:B(U).gt(0)?U:null,fee:E,total:F.toFixed(),balance:w,isSufficient:O}},b=()=>{if(!x.length)return null;if(f&&y(f).isSufficient)return f;for(const{denom:I}of x)if(y(I).isSufficient)return I;return x[0]?.denom},[C,v]=_.useState(b),N=g.find(I=>I.amount[0].denom===C)??void 0,k=C?y(C):null,$=k&&!k.isSufficient?"Insufficient balance":void 0,q=(I,w)=>{if(j.formatAmount(I,{decimals:w})==="0.000000")return 8},V=I=>{const[{amount:w,denom:E}]=I.amount;if(B(w).isZero())return"0";const{symbol:U,decimals:F}=p(E),O=q(w,F);return`${j.formatAmount(w,{decimals:F,dp:O})} ${U}`},M=()=>{if(g.length===0)return null;if(g.length===1)return t.jsx("span",{className:"monospace",children:V(g[0])});if(!N||!C)return null;const I=g.map(O=>{const[{denom:Z}]=O.amount,{symbol:H}=p(Z);return{value:Z,label:V(O),triggerLabel:H}}),[{amount:w,denom:E}]=N.amount,{decimals:U}=p(E),F=q(w,U);return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{className:"monospace",children:j.formatAmount(w,{decimals:U,dp:F})}),t.jsx(zo,{options:I,value:C,onChange:v,classNames:Tx})]})};return t.jsxs(t.Fragment,{children:[t.jsx(Li,{renderFee:g.length>0?M:void 0}),t.jsx(Zo,{tx:e,children:t.jsx(Yo,{tx:e,fee:N,onCompleted:o,confirmMessage:s,error:$})})]})},Ex=({tx:e,confirmMessage:n,onCompleted:s})=>t.jsxs(t.Fragment,{children:[t.jsx(Li,{}),t.jsx(Zo,{tx:e,children:t.jsx(Yo,{tx:e,fee:void 0,onCompleted:s,confirmMessage:n})})]}),qx=({tx:e,gas:n,mode:s})=>{const{setValue:o}=At(),a=i=>{o("page","completed"),o("result",i)},r=s==="withdraw"?"Withdraw":"Deposit";return!n||!("cosmos_tx"in e)?t.jsx(Ex,{tx:e,onCompleted:a,confirmMessage:r}):t.jsx($x,{tx:e,gas:n,onCompleted:a,confirmMessage:r})},Lx=({mode:e})=>{const n=Vn(e),s=Ce(),o=Je(),a=Xo(),r=yt(),{data:i}=Jo(),l=ln(),{watch:c,setValue:d,getValues:u}=At(),h=c(),{srcChainId:m,srcDenom:f,quantity:p=""}=h,g=ea(e),x=w_(e),y=h[n.external.chainIdKey],b=y?r(y):null,C=i?.[m]?.[f]?.amount,v=i?.[m]?.[f]?.price||0,N=B(v||0).times(p||0),[k]=Le.useDebounceValue(p,300),$=e==="withdraw"?g:x,q=_.useMemo(()=>{if(e==="deposit"&&!x)return"Select asset";const H=B(p||0);if(!H.isFinite()||H.lte(0))return"Enter amount";const R=j.fromBaseUnit(C??"0",{decimals:$?.decimals||6});if(H.gt(R))return"Insufficient balance";if(e==="withdraw"&&!x)return"Select destination"},[e,p,C,$,x]),{data:V,error:M}=po(k,{disabled:!!q}),I=!M&&!q?V:void 0,w=_.useEffectEvent(()=>{s(0,{...o,route:I,values:{sender:l,recipient:o.recipientAddress?j.InitiaAddress(o.recipientAddress).hex:l,slippagePercent:"1",...u()}})});if(_.useEffect(()=>{w()},[I,l]),!g||e==="deposit"&&!x)return null;const E=$?.decimals||6,U=e==="withdraw"?"Select chain":"Select asset",F=()=>{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")},O=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:Q.label,children:e==="withdraw"?"Destination":"From"}),t.jsxs("button",{className:Q.asset,onClick:()=>{d("page","select-external")},children:[t.jsx("div",{className:Q.assetIcon,children:x?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:x.logo_uri,alt:x.symbol}),t.jsx("img",{src:b?.logo_uri||"",alt:b?.pretty_name,className:Q.chainIcon})]}):e==="withdraw"&&t.jsx("div",{className:Q.chainIcon})}),t.jsx("p",{className:Q.assetName,children:x?t.jsxs(t.Fragment,{children:[x.symbol,t.jsx("br",{}),t.jsxs("span",{children:["on ",b?.pretty_name]})]}):U}),t.jsx(S.IconChevronDown,{className:Q.chevron,size:16})]})]}),Z=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:Q.label,children:"Amount"}),t.jsx(In,{balance:C,decimals:E,className:Q.input}),Number(C)>0&&t.jsxs("div",{className:Q.balanceContainer,children:[t.jsx("p",{className:Q.value,children:N.gt(0)?ee(N.toString()):"$-"}),t.jsxs("button",{className:Q.maxButton,onClick:()=>{const H=j.fromBaseUnit(C??"0",{decimals:E});B(p||0).eq(H)||d("quantity",H)},children:[t.jsx(S.IconWallet,{size:16})," ",j.formatAmount(C,{decimals:E})," ",t.jsx("span",{children:"MAX"})]})]})]});return t.jsxs("div",{className:Q.container,children:[a.length>1&&t.jsx("button",{type:"button","aria-label":"Back",className:Q.back,onClick:F,children:t.jsx(S.IconBack,{size:20})}),t.jsxs("h3",{className:Q.title,children:[n.label," ",g.symbol]}),e==="withdraw"?t.jsxs(t.Fragment,{children:[Z,t.jsx("div",{className:Q.divider}),O]}):t.jsxs(t.Fragment,{children:[O,t.jsx("div",{className:Q.divider}),Z]}),!o.route||q?t.jsx(xe,{children:t.jsx(le.White,{type:"submit",loading:!M&&!q&&"Fetching route...",disabled:!0,fullWidth:!0,children:M?"No route found":q})}):t.jsx(ki,{children:H=>t.jsx(Ai,{children:R=>t.jsx(Si,{addressList:H,signedOpHook:R,children:P=>t.jsx(rx,{tx:P,children:Ne=>t.jsx(qx,{tx:P,gas:Ne,mode:e})})})})})]})},Mx="_container_7nl9j_1",Px="_page_7nl9j_5",Ra={container:Mx,page:Px},Mi=({mode:e})=>{const n=_e.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Jo(),t.jsx(_e.FormProvider,{...n,children:t.jsx(Dx,{mode:e})})},Dx=({mode:e})=>{const{watch:n}=At(),s=n("page"),o=rt.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(H_,{mode:e});case"select-external":return t.jsx(V_,{mode:e});case"fields":return t.jsx(Lx,{mode:e});case"completed":return t.jsx(xo,{type:e})}};return t.jsx(Nn,{children:t.jsx("div",{className:Ra.container,children:o((r,i)=>t.jsx(rt.animated.div,{style:r,className:Ra.page,children:a(i)}))})})},Bx=()=>t.jsx(Mi,{mode:"deposit"}),Rx=()=>t.jsx(Mi,{mode:"withdraw"}),Fx="_root_1lo0i_1",Ux="_address_1lo0i_9",Ox="_copy_1lo0i_19",Vx="_labelWrapper_1lo0i_33",Kx="_labelCopy_1lo0i_43",zx="_labelCopied_1lo0i_47",Wx="_copied_1lo0i_55",Hx="_derived_1lo0i_65",Qx="_derivedLabel_1lo0i_79",Gx="_derivedAddress_1lo0i_83",Yx="_hexAddress_1lo0i_89",Zx="_derivedCopy_1lo0i_94",Ae={root:Fx,address:Ux,copy:Ox,labelWrapper:Vx,labelCopy:Kx,labelCopied:zx,copied:Wx,derived:Hx,derivedLabel:Qx,derivedAddress:Gx,hexAddress:Yx,derivedCopy:Zx},Jx=()=>{const e=_.useRef(null),n=_.useRef(null),{initiaAddress:s,hexAddress:o}=De(),a=Yr("--gray-0");return _.useEffect(()=>{e.current&&(n.current?n.current.update({data:s}):(n.current=new ac({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(dt,{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(cs,{value:s,children:({copy:r,copied:i})=>t.jsxs("button",{className:L(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(cs,{value:o,children:({copy:r,copied:i})=>t.jsxs("button",{className:L(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:j.truncate(o)}),t.jsx(S.IconCopy,{size:12,className:Ae.derivedCopy}),i&&t.jsx("span",{className:Ae.copiedText,children:"Copied!"})]})]})})]})})};function Xx(){const e=te(),n=de();return T.useQueries({queries:n.map(s=>({queryKey:vn.grants(s.chainId,e).queryKey,queryFn:async()=>{const{grants:o}=await z.create({prefixUrl:s.restUrl}).get(`cosmos/authz/v1beta1/grants/granter/${e}`).json();return{chainId:s.chainId,grants:o}},enabled:!!e,staleTime:K.SECOND,retry:!1}))})}const e1="_countdown_vfms8_1",t1={countdown:e1},n1=({expiration:e})=>{const n=()=>{const a=new Date,r=Ge.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),l=Math.floor(r%(1440*60)/3600),c=Math.floor(r%3600/60),d=r%60,u=[];return i>0&&u.push(`${i}d`),(l>0||i>0)&&u.push(`${l}h`),(c>0||l>0||i>0)&&u.push(`${c}m`),u.push(`${d}s`),u.join(" ")},[s,o]=_.useState(n());return Le.useInterval(()=>{o(n())},1e3),Ge.isPast(e)?"Expired":t.jsxs(t.Fragment,{children:["Expires in ",t.jsx("span",{className:t1.countdown,children:s})]})},s1="_container_1l528_1",o1="_info_1l528_11",a1="_header_1l528_17",r1="_chainName_1l528_23",i1="_expiration_1l528_29",c1="_revokeButton_1l528_35",Yt={container:s1,info:o1,header:a1,chainName:r1,expiration:i1,revokeButton:c1},l1=({chainId:e,grantee:n,messageTypes:s,expiration:o})=>{const a=Ze(e),{mutate:r,isPending:i}=Er({grantee:n,internal:!0});return t.jsxs("div",{className:Yt.container,children:[t.jsxs("div",{className:Yt.info,children:[t.jsxs("div",{className:Yt.header,children:[t.jsx(X,{src:a.logoUrl,width:16,height:16,logo:!0}),t.jsx("div",{className:Yt.chainName,children:a.name})]}),t.jsx("div",{className:Yt.expiration,children:o?t.jsx(n1,{expiration:o}):"Until revoked"})]}),t.jsx("button",{className:Yt.revokeButton,onClick:()=>r(e),disabled:i,children:i?"Revoking...":"Revoke"})]})},d1=({chainId:e,grants:n})=>Object.values(n.reduce((o,a)=>{const r=o[a.grantee];return r?{...o,[a.grantee]:{...r,messageTypes:[...r.messageTypes,a.authorization.msg],expiration:qo([r.expiration,a.expiration?new Date(a.expiration):void 0])}}:{...o,[a.grantee]:{grantee:a.grantee,messageTypes:[a.authorization.msg],expiration:a.expiration?new Date(a.expiration):void 0}}},{})).map(o=>_.createElement(l1,{...o,chainId:e,key:o.grantee})),u1="_content_q36qs_1",m1={content:u1},h1=()=>{const e=Xx(),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:m1.content,children:s.map(({chainId:o,grants:a})=>t.jsx(d1,{chainId:o,grants:a},o))})};return t.jsx(dt,{title:"Manage auto-signing",backButton:"/settings",children:n()})},p1="2.2.5",f1="_version_1sf5y_1",g1={version:f1},_1=()=>t.jsxs("aside",{className:g1.version,children:["v",p1]}),x1="_link_se23z_1",y1="_title_se23z_17",j1="_subtitle_se23z_23",b1="_icon_se23z_30",ts={link:x1,title:y1,subtitle:j1,icon:b1},Pi=({title:e,subtitle:n,rightSection:s,onClick:o})=>t.jsxs("button",{className:ts.link,onClick:o,children:[t.jsxs("div",{children:[t.jsx("p",{className:ts.title,children:e}),n&&t.jsx("p",{className:ts.subtitle,children:n})]}),t.jsx("div",{className:ts.icon,children:s??t.jsx(S.IconChevronRight,{size:16})})]}),w1="https://export.initia.xyz/",v1=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return t.jsx(Pi,{title:"Export private key",rightSection:t.jsx(S.IconExternalLink,{size:16}),onClick:()=>window.open(w1,"_blank",e)})},C1="_container_1vxr7_1",N1="_separator_1vxr7_7",Fa={container:C1,separator:N1},I1=()=>{const e=Ce(),{connector:n}=ve.useAccount();return t.jsx(dt,{title:"Settings",backButton:"/",children:t.jsxs("div",{className:Fa.container,children:[t.jsx(Pi,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),n?.id===vo&&t.jsx(v1,{}),t.jsx(ht.Separator,{className:Fa.separator}),t.jsx(_1,{})]})})},k1="_trigger_1yjkd_1",S1="_icon_1yjkd_23",A1="_full_1yjkd_27",T1="_triggerContent_1yjkd_32",$1="_triggerText_1yjkd_40",E1="_popoverBackdrop_1yjkd_51",q1="_popoverPositioner_1yjkd_70",L1="_popoverPopup_1yjkd_74",M1="_search_1yjkd_99",P1="_viewport_1yjkd_105",D1="_item_1yjkd_111",B1="_highlighted_1yjkd_127",R1="_active_1yjkd_131",F1="_itemContent_1yjkd_136",U1="_extra_1yjkd_142",O1="_connectedTag_1yjkd_149",ge={trigger:k1,icon:S1,full:A1,triggerContent:T1,triggerText:$1,popoverBackdrop:E1,popoverPositioner:q1,popoverPopup:L1,search:M1,viewport:P1,item:D1,highlighted:B1,active:R1,itemContent:F1,extra:U1,connectedTag:O1},qs=({value:e,onChange:n,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=Y(),[i,l]=_.useState(""),[c,d]=_.useState(!1),[u,h]=_.useState(0),[m,f]=_.useState(),p=_.useRef([]),g=_.useRef(null),x=de(),y=s.map(I=>x.find(w=>w.chainId===I)).filter(Boolean),b=I=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:I,height:I,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=_.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),v=_.useMemo(()=>{const I=[C,...y];if(!i)return I;const w=i.toLowerCase();return I.filter(E=>E.name.toLowerCase().includes(w)||E.chainId.toLowerCase().includes(w))},[y,i,C]),N=y.find(I=>I.chainId===e)||C,k=parseInt(Yr("--drawer-offset")),$=6,q=()=>{if(l(""),h(-1),g.current){const w=g.current.getBoundingClientRect().bottom+$,E=window.innerHeight-w-2*k;f(E)}d(!0)};_.useEffect(()=>{u>=0&&u<p.current.length&&p.current[u]?.scrollIntoView({block:"nearest",behavior:"auto"})},[u]);const V=_.useCallback(I=>{switch(I.key){case"ArrowDown":I.preventDefault(),h(w=>(w+1)%v.length);break;case"ArrowUp":I.preventDefault(),h(w=>(w-1+v.length)%v.length);break;case"Enter":I.preventDefault(),v[u]&&(n(v[u].chainId),d(!1));break;case"Escape":I.preventDefault(),d(!1);break}},[v,u,n,d]),M=I=>{n(I),d(!1)};return t.jsxs(Qt.Popover.Root,{open:c,onOpenChange:q,modal:"trap-focus",children:[t.jsx(Qt.Popover.Trigger,{render:t.jsxs("button",{className:L(ge.trigger,{[ge.full]:a}),"aria-expanded":c,role:"listbox",ref:g,children:[t.jsxs("div",{className:ge.triggerContent,children:[typeof N.logoUrl=="string"?t.jsx(X,{src:N.logoUrl,width:14,height:14,logo:!0}):N.logoUrl(14),t.jsx("span",{className:ge.triggerText,children:N.name})]}),t.jsx(S.IconChevronDown,{size:16,className:ge.icon})]})}),t.jsxs(Qt.Popover.Portal,{container:Ot(),children:[t.jsx(Qt.Popover.Backdrop,{className:ge.popoverBackdrop,onClick:()=>d(!1)}),t.jsx(Qt.Popover.Positioner,{className:ge.popoverPositioner,align:"end",side:"bottom",sideOffset:$,collisionAvoidance:{side:"none"},children:t.jsxs(Qt.Popover.Popup,{className:L(ge.popoverPopup,{[ge.full]:a}),style:{maxHeight:m},children:[t.jsx(Un,{value:i,onChange:I=>{l(I.target.value),h(0)},onClear:()=>l(""),onKeyDown:V,placeholder:"Search appchains",rootClassName:ge.search,ref:Rn()}),t.jsx("div",{className:ge.viewport,role:"listbox",children:v.length===0?t.jsx(he,{children:"No appchains found"}):v.map(({chainId:I,name:w,logoUrl:E},U)=>t.jsxs("div",{className:L(ge.item,{[ge.highlighted]:U===u,[ge.active]:e===I}),onClick:()=>M(I),onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),M(I))},onMouseEnter:()=>h(U),role:"option","aria-selected":e===I,tabIndex:-1,ref:F=>{F&&(p.current[U]=F)},children:[t.jsxs("div",{className:ge.itemContent,children:[typeof E=="string"?t.jsx(X,{src:E,width:16,height:16,logo:!0}):E(16),t.jsx("span",{className:ge.name,children:w}),I===r&&t.jsx("span",{className:ge.connectedTag,children:"Connected"})]}),o&&t.jsx("span",{className:ge.extra,children:o(I)})]},I))})]})})]})]})},V1="_container_1nap1_1",K1="_controls_1nap1_7",z1="_search_1nap1_13",ta={container:V1,controls:K1,search:z1},W1=({children:e})=>t.jsx("div",{className:ta.container,children:e}),H1=({children:e})=>t.jsx("div",{className:ta.controls,children:e}),Q1=e=>t.jsx(Un,{...e,rootClassName:ta.search}),Qe={Root:W1,Controls:H1,SearchInput:Q1},Di=W.atom(""),Bi=W.atom(""),G1=W.atom(""),Y1=W.atom(""),Z1=W.atom(""),J1="_change_1x9v4_1",X1="_positive_1x9v4_10",ey="_negative_1x9v4_14",no={change:J1,positive:X1,negative:ey},Ri=({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:L(no.change,r?no.positive:no.negative),children:[r?"+":"-",j.formatAmount(i,{decimals:a})," ",o||s]})},ty=({changes:e,chain:n})=>{const s=lt(n);return e.map(({amount:o,denom:a},r)=>t.jsx(Ri,{amount:o,asset:s(a)},r))},ny=({changes:e,chain:n})=>{const s=lt(n);return e.map(({amount:o,metadata:a},r)=>t.jsx(oi,{metadata:a,chain:n,children:i=>t.jsx(Ri,{amount:o,asset:s(i)})},r))},sy=({events:e,chain:n})=>{const{initiaAddress:s,hexAddress:o}=De();return n.metadata?.is_l1||n.metadata?.minitia?.type==="minimove"?t.jsx(ny,{changes:si(e,o),chain:n}):t.jsx(ty,{changes:ni(e,s),chain:n})},oy="_message_1g2hc_1",ay="_more_1g2hc_8",Ua={message:oy,more:ay},ry=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((n,s)=>t.jsx("p",{className:Ua.message,children:hs.sentenceCase(n["@type"].split("Msg")[1])},s)),e.length>3&&t.jsx("footer",{className:Ua.more,children:`+${e.length-3} more`})]}),iy="_link_fuhbt_1",cy="_inner_fuhbt_16",ly="_header_fuhbt_21",dy="_time_fuhbt_30",uy="_error_fuhbt_36",my="_timestamp_fuhbt_40",hy="_chainInfo_fuhbt_45",py="_content_fuhbt_53",fy="_messages_fuhbt_61",gy="_changes_fuhbt_67",at={link:iy,inner:cy,header:ly,time:dy,error:uy,timestamp:my,chainInfo:hy,content:py,messages:fy,changes:gy},_y=({txItem:e,chain:n})=>t.jsx(ks,{txHash:e.txhash,chainId:n.chainId,className:at.link,children:t.jsxs("div",{className:at.inner,children:[t.jsxs("div",{className:at.header,children:[t.jsxs("div",{className:at.time,children:[e.code!==0&&t.jsx(S.IconWarningFilled,{size:14,className:at.error}),t.jsx("span",{className:at.timestamp,children:Ge.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:at.chainInfo,children:[t.jsx(X,{src:n.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:n.name})]})]}),t.jsxs("div",{className:at.content,children:[t.jsx("div",{className:at.messages,children:t.jsx(ry,{messages:e.tx.body.messages})}),t.jsx("div",{className:at.changes,children:t.jsx(me,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(sy,{...e,chain:n})})})]})]})}),xy="_list_1mv55_1",yy="_dateGroup_1mv55_7",jy="_dateHeader_1mv55_12",by="_more_1mv55_18",ns={list:xy,dateGroup:yy,dateHeader:jy,more:by},wy=({list:e,chainId:n})=>{const s=te(),o=_.useMemo(()=>xi(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:ns.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{className:ns.dateGroup,children:[t.jsx("div",{className:ns.dateHeader,children:a}),r.map(i=>t.jsx(me,{errorBoundaryProps:{fallback:null},children:t.jsx(_y,{txItem:i,chain:i.chain})},i.txhash))]},a))}),t.jsx(ks,{chainId:n,accountAddress:s,pathSuffix:"/txs",className:ns.more,showIcon:!0,children:"View more on Initia Scan"})]})},vy=()=>{const{activities:e,isLoading:n}=tu(),[s,o]=W.useAtom(Z1),a=ae(),r=_.useMemo(()=>Array.from(new Set(e.map(l=>l.chain.chainId))),[e]),i=_.useMemo(()=>s?e.filter(l=>l.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(Qe.Root,{children:[t.jsx(Qe.Controls,{children:t.jsx(qs,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),t.jsx(wy,{list:i,chainId:s||a.chainId})]})},Cy="_thumbnail_1xyqw_1",Ny="_placeholder_1xyqw_18",Iy="_clickable_1xyqw_24",xn={thumbnail:Cy,placeholder:Ny,clickable:Iy},ky=({nftInfo:e,size:n,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:l}=Y(),c=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,l).toString();return s?t.jsx("button",{className:L(xn.thumbnail,xn.clickable),onClick:s,style:{width:n,height:n},children:t.jsx(X,{src:c,classNames:{placeholder:xn.placeholder}})}):t.jsx("div",{className:xn.thumbnail,style:{width:n,height:n},children:t.jsx(X,{src:c,classNames:{placeholder:xn.placeholder}})})},Sy="_collectionName_qs5tw_1",Ay="_nftName_qs5tw_6",Ty="_chainInfo_qs5tw_10",so={collectionName:Sy,nftName:Ay,chainInfo:Ty},na=({normalizedNft:e,onThumbnailClick:n,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:l}=e;return t.jsxs("div",{className:a?.root,children:[t.jsx(ky,{nftInfo:e,onClick:n,size:s}),t.jsxs("div",{children:[t.jsx("div",{className:L(so.collectionName,a?.collectionName),children:r}),t.jsx("div",{className:L(so.nftName,a?.nftName),children:i}),t.jsxs("div",{className:L(so.chainInfo,a?.chainInfo),children:[t.jsx(X,{src:l.logoUrl,width:o,height:o,logo:!0}),t.jsx("span",{children:l.name})]})]})]})},sa=ye.createQueryKeys("interwovenkit:nft",{nfts:(e,n)=>[e,n],metadata:e=>[e]});function $y(e,n){const{nft:s}=e,o=n.name??s.token_id;return{...e,...s,...n,name:o}}function Ey(e,n){return e.flatMap((s,o)=>(n[o]??[]).map(r=>({...r,chain:s})))}const qy=()=>{const e=te(),n=de(),s=T.useQueries({queries:n.map(c=>({queryKey:sa.nfts(c.indexerUrl,e).queryKey,queryFn:()=>ar(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:c.indexerUrl},"tokens"),staleTime:K.SECOND}))}),o=s.map(A.prop("data")),a=Ey(n,o),r=a.reduce((c,{chain:d})=>({...c,[d.chainId]:(c[d.chainId]||0)+1}),{}),i=Object.values(r).reduce((c,d)=>c+d,0),l=s.some(c=>c.isLoading);return{nftInfos:a,chainCounts:r,totalCount:i,isLoading:l}};function Ly(e){const n=Oa(e);return T.useQuery({queryKey:sa.metadata(n).queryKey,queryFn:async()=>{try{if(!n)return{};const s=await z.get(n).json();return{...s,image:Oa(s.image)}}catch{return{}}},staleTime:K.INFINITY})}function Oa(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const My=({nftInfo:e,children:n})=>{const{data:s={}}=Ly(e.nft.uri),o=$y(e,s);return n(o)},Py="_grid_1wwdn_1",Dy="_root_1wwdn_7",By="_collectionName_1wwdn_15",Ry="_nftName_1wwdn_23",Fy="_chainInfo_1wwdn_32",Va={grid:Py,root:Dy,collectionName:By,nftName:Ry,chainInfo:Fy},Uy=()=>{const[e,n]=W.useAtom(G1),[s,o]=W.useAtom(Y1),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:l}=qy(),c=Ce(),d=_.useMemo(()=>a.filter(({collection_addr:h,collection_name:m,nft:f,object_addr:p,chain:g})=>{if(s&&g.chainId!==s)return!1;if(e){const x=e.trim().toLowerCase();return h.toLowerCase().includes(x)||m.toLowerCase().includes(x)||f.token_id.toLowerCase().includes(x)||p.toLowerCase().includes(x)}return!0}),[a,s,e]),u=_.useMemo(()=>Array.from(new Set(a.map(({chain:h})=>h.chainId))),[a]);return l&&a.length===0?t.jsx(he,{children:"Loading NFTs..."}):!a.length&&!e&&!l?t.jsx(he,{children:"No NFTs"}):t.jsxs(Qe.Root,{children:[t.jsxs(Qe.Controls,{children:[t.jsx(Qe.SearchInput,{value:e,onChange:h=>n(h.target.value),onClear:()=>n(""),placeholder:"Search NFTs"}),t.jsx(qs,{value:s,onChange:o,chainIds:u,renderExtra:h=>h?r[h]||0:i})]}),d.length===0?t.jsx(he,{children:"No NFTs found"}):t.jsx("div",{className:Va.grid,children:d.map(h=>{const{collection_addr:m,nft:f}=h;return t.jsx(My,{nftInfo:h,children:p=>t.jsx(na,{normalizedNft:p,onThumbnailClick:()=>c("/nft",p),classNames:Va})},m+f.token_id)})})]})},Fi=_.createContext(null);function Ui(){return _.useContext(Fi)}const Oy="_popup_nbecp_1",Vy="_item_nbecp_19",ss={popup:Oy,item:Vy},Oi=({asset:e,children:n})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:l,chain:c}=e,{chainId:d}=c,[u,h]=_.useState(!1),m=Ce(),f=Ui(),{showNotification:p}=Ss(),{defaultChainId:g}=Y(),{evm_chain_id:x}=Vt(),y=ve.useChainId(),{switchChainAsync:b}=ve.useSwitchChain(),{watchAssetAsync:C}=ve.useWatchAsset(),v=()=>{h(!1),m("/send",{denom:s,chain:c})},N=()=>{h(!1),m("/bridge",{srcChainId:d,srcDenom:s,quantity:""})},k=T.useMutation({mutationFn:async()=>{if(!l)throw new Error("Address is required");const $=r;return await b({chainId:Number(x)}),C({type:"ERC20",options:{address:l,symbol:a,decimals:o,image:$}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:$=>{p({type:"error",title:"Asset addition failed",description:$.message})}});return t.jsxs(ht.Menu.Root,{open:u,onOpenChange:h,modal:!1,children:[t.jsx(ht.Menu.Trigger,{render:n}),t.jsx(ht.Menu.Portal,{container:f,children:t.jsx(ht.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(ht.Menu.Popup,{className:ss.popup,children:[t.jsxs(ht.Menu.Item,{className:ss.item,onClick:v,children:[t.jsx(S.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(ht.Menu.Item,{className:ss.item,onClick:N,disabled:i,children:[t.jsx(S.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===g&&x===y&&!!l&&t.jsxs(ht.Menu.Item,{className:ss.item,onClick:()=>k.mutate(),disabled:k.isPending||k.data,children:[k.data?t.jsx(S.IconCheck,{size:16}):t.jsx(S.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},Ky="_item_38qhm_1",zy="_info_38qhm_23",Wy="_images_38qhm_29",Hy="_name_38qhm_33",Qy="_value_38qhm_39",Gy="_amount_38qhm_47",Yy="_usd_38qhm_53",Mt={item:Ky,info:zy,images:Wy,name:Hy,value:Qy,amount:Gy,usd:Yy},Zy=({asset:e})=>{const{amount:n,value:s,logoUrl:o,chain:a}=e,r=j.formatAmount(n,{decimals:e.decimals});return t.jsx(Oi,{asset:e,children:t.jsxs("button",{className:Mt.item,children:[t.jsxs("div",{className:Mt.info,children:[t.jsx(Ts,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:Mt.images}),t.jsx("span",{className:Mt.name,children:a.name})]}),t.jsxs("div",{className:Mt.value,children:[t.jsx("span",{className:Mt.amount,children:r}),Number(s)>0&&t.jsx("span",{className:Mt.usd,children:ee(s)})]})]})})},Jy="_container_ytg3p_1",Xy="_assetItem_ytg3p_6",e2="_expandIcon_ytg3p_22",t2="_assetInfo_ytg3p_27",n2="_logo_ytg3p_33",s2="_details_ytg3p_37",o2="_symbol_ytg3p_42",a2="_chainName_ytg3p_53",r2="_chainInfos_ytg3p_59",i2="_chainLogos_ytg3p_65",c2="_chainLogo_ytg3p_65",l2="_moreChains_ytg3p_76",d2="_expanded_ytg3p_93",u2="_valueColumn_ytg3p_98",m2="_amount_ytg3p_108",h2="_value_ytg3p_98",p2="_collapsibleContent_ytg3p_121",f2="_chainsList_ytg3p_151",pe={container:Jy,assetItem:Xy,expandIcon:e2,assetInfo:t2,logo:n2,details:s2,symbol:o2,chainName:a2,chainInfos:r2,chainLogos:i2,chainLogo:c2,moreChains:l2,expanded:d2,valueColumn:u2,amount:m2,value:h2,collapsibleContent:p2,chainsList:f2},g2=W.atom([]),oa=({assetGroup:e})=>{const{symbol:n,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=W.useAtom(g2),l=_.useMemo(()=>Oc(e),[e]),c=_.useMemo(()=>qr(e),[e]),d=r.includes(n),u=()=>{i(m=>d?m.filter(f=>f!==n):[...new Set([...m,n])])},h=()=>t.jsxs("button",{className:pe.assetItem,children:[t.jsxs("div",{className:pe.assetInfo,children:[s&&t.jsx(X,{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:m})=>t.jsx(X,{src:m.logoUrl,width:16,height:16,className:pe.chainLogo,logo:!0},m.chainId))}),o.length>5&&t.jsxs("span",{className:pe.moreChains,children:["+",o.length-5]}),t.jsx(S.IconChevronDown,{size:16,className:L(pe.expandIcon,{[pe.expanded]:d})})]})]})]}),t.jsxs("div",{className:pe.valueColumn,children:[t.jsx("div",{className:pe.amount,children:j.formatNumber(l,{dp:o[0].unlisted?0:6})}),c>0&&t.jsx("div",{className:pe.value,children:ee(c)})]})]});if(a){const[m]=o;return t.jsx("div",{className:pe.container,children:t.jsx(Oi,{asset:m,children:h()})})}return t.jsx("div",{className:pe.container,children:t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:h()}),t.jsx(J.Collapsible.Content,{className:pe.collapsibleContent,children:t.jsx("div",{className:pe.chainsList,children:o.map(m=>t.jsx(Zy,{asset:m},m.chain.chainId))})})]})})},_2="_collapsible_1g7rh_1",x2="_trigger_1g7rh_5",y2="_divider_1g7rh_20",j2="_label_1g7rh_28",b2="_chevron_1g7rh_33",w2="_content_1g7rh_41",v2="_list_1g7rh_45",Nt={collapsible:_2,trigger:x2,divider:y2,label:j2,chevron:b2,content:w2,list:v2},Vi=({unlistedAssets:e})=>{const[n,s]=_.useState(!1),o=Ui(),a=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{if(a.current){const h=a.current.scrollHeight;i(h)}},[e]);const l=_.useRef(null),c=h=>{s(h),h&&l.current&&o?.current&&window.setTimeout(()=>{if(!l.current||!a.current||!o?.current)return;const m=o.current,f=m.getBoundingClientRect(),p=l.current.getBoundingClientRect(),g=a.current.scrollHeight;if(p.bottom+g>f.bottom){const y=p.top-f.top+m.scrollTop-16;m.scrollTo({top:y,behavior:"smooth"})}},50)},d=rt.useSpring({height:n?r:0,opacity:n?1:0,config:{tension:500,friction:30,clamp:!0}}),u=_.useMemo(()=>e.map(h=>({...h,assets:[h],totalValue:h.value??0,totalAmount:Number(h.quantity)})),[e]);return e.length===0?null:t.jsxs(J.Collapsible.Root,{open:n,onOpenChange:c,className:Nt.collapsible,children:[t.jsxs(J.Collapsible.Trigger,{ref:l,className:Nt.trigger,children:[t.jsx("div",{className:Nt.divider}),t.jsxs("span",{className:Nt.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(S.IconChevronDown,{className:Nt.chevron,size:12,"data-state":n?"open":"closed"}),t.jsx("div",{className:Nt.divider})]}),t.jsx(J.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(rt.animated.div,{className:Nt.content,style:d,children:t.jsx("div",{className:Nt.list,ref:a,children:u.map(h=>t.jsx(oa,{assetGroup:h},h.assets[0].denom))})})})]})},C2="_container_15xfg_1",N2="_header_15xfg_7",I2="_title_15xfg_13",k2="_totalValue_15xfg_19",S2="_list_15xfg_26",tn={container:C2,header:N2,title:I2,totalValue:k2,list:S2},A2=()=>{const[e,n]=W.useAtom(Di),[s,o]=W.useAtom(Bi),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:l,isLoading:c}=Lo(),d=i.map(({chainId:m})=>m),u=_.useMemo(()=>{const m=e?a.filter(p=>{const{symbol:g,assets:x}=p;return g.toLowerCase().includes(e.toLowerCase())||x.some(({denom:y,address:b})=>y.toLowerCase().includes(e.toLowerCase())||b?.toLowerCase().includes(e.toLowerCase()))}):a;return s?m.map(p=>({...p,assets:p.assets.filter(({chain:g})=>g.chainId===s)})).filter(p=>p.assets.length>0):m},[a,e,s]),h=_.useMemo(()=>{const m=e?r.filter(({denom:p,address:g})=>p.toLowerCase().includes(e.toLowerCase())||g?.toLowerCase().includes(e.toLowerCase())):r;return s?m.filter(({chain:p})=>p.chainId===s):m},[r,e,s]);return c&&a.length===0?t.jsx(he,{children:"Loading assets..."}):!u.length&&!h.length&&!e&&!s&&!c?t.jsx(he,{children:"No assets"}):t.jsxs(Qe.Root,{children:[t.jsxs(Qe.Controls,{children:[t.jsx(Qe.SearchInput,{value:e,onChange:m=>n(m.target.value),onClear:()=>n(""),placeholder:"Search assets"}),t.jsx(qs,{value:s,onChange:o,chainIds:d,renderExtra:m=>{if(!m)return ee(l);const f=i.find(p=>p.chainId===m);return f?ee(f.value):null}})]}),t.jsx("div",{children:u.length===0&&h.length===0?t.jsx(he,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:tn.list,children:u.map(m=>t.jsx(oa,{assetGroup:m},m.symbol))}),t.jsx(Vi,{unlistedAssets:h})]})})]})},T2="_container_11k2x_1",$2={container:T2},He=({height:e,length:n=1,width:s="100%"})=>{const o=Array.from({length:n},(a,r)=>r);return n===1?t.jsx(Ut,{height:e,width:s}):t.jsx("div",{className:$2.container,children:o.map(a=>t.jsx(Ut,{height:e,width:s},a))})},E2=_.memo(({searchQuery:e,selectedChain:n,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:l}=Pn(),c=ae(),{listedGroups:d,unlistedAssets:u}=_.useMemo(()=>kl(i,a,r,c.chainId),[i,a,r,c.chainId]),h=_.useMemo(()=>vl(d,s,o),[d,s,o]),{filteredAssets:m,totalAssetsValue:f,filteredUnlistedAssets:p}=_.useMemo(()=>Il(h,u,e,n),[h,u,e,n]);return t.jsxs("div",{className:tn.container,children:[t.jsxs("div",{className:tn.header,children:[t.jsx("span",{className:tn.title,children:"Assets"}),m.length>0&&t.jsx("span",{className:tn.totalValue,children:ee(f)})]}),m.length>0?t.jsxs("div",{children:[t.jsx("div",{className:tn.list,children:m.map(g=>t.jsx(oa,{assetGroup:g},g.symbol))}),t.jsx(Vi,{unlistedAssets:p})]}):h.length===0&&l?t.jsx(He,{height:56,length:3}):t.jsx(he,{children:"No liquid assets"})]})}),q2=ye.createQueryKeys("interwovenkit:civitia",{player:(e,n)=>[e,n]});function Ki(){const{civitiaUrl:e}=Y(),n=te();return T.useQuery({enabled:!!n,queryKey:q2.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 L2="_section_xdyfz_2",M2="_row_xdyfz_15",P2="_rowLeft_xdyfz_23",D2="_rowIcon_xdyfz_29",B2="_goldIcon_xdyfz_38",R2="_silverIcon_xdyfz_46",F2="_rowTitle_xdyfz_54",U2="_rowValue_xdyfz_60",O2="_rowSubtitle_xdyfz_67",Ie={section:L2,row:M2,rowLeft:P2,rowIcon:D2,goldIcon:B2,silverIcon:R2,rowTitle:F2,rowValue:U2,rowSubtitle:O2},V2=()=>{const{data:e,isLoading:n}=Ki();if(n)return t.jsx(He,{height:36,length:2});const s=e?.gold_balance??0,o=e?.silver_balance??0;return t.jsxs("div",{className:Ie.section,children:[t.jsxs("div",{className:Ie.row,children:[t.jsxs("div",{className:Ie.rowLeft,children:[t.jsx("div",{className:L(Ie.rowIcon,Ie.goldIcon)}),t.jsx("span",{className:Ie.rowTitle,children:"Gold"})]}),t.jsx("span",{className:L(Ie.rowValue,s===0&&Ie.rowSubtitle),children:s===0?"—":j.formatNumber(s,{dp:6})})]}),t.jsxs("div",{className:Ie.row,children:[t.jsxs("div",{className:Ie.rowLeft,children:[t.jsx("div",{className:L(Ie.rowIcon,Ie.silverIcon)}),t.jsx("span",{className:Ie.rowTitle,children:"Silver"})]}),t.jsx("span",{className:L(Ie.rowValue,o===0&&Ie.rowSubtitle),children:o===0?"—":j.formatNumber(o,{dp:6})})]})]})},K2="_container_1n61l_1",z2="_section_1n61l_7",W2="_sectionHeader_1n61l_19",H2="_sectionTitle_1n61l_25",Q2="_sectionLabel_1n61l_31",G2="_externalLink_1n61l_37",Y2="_sectionValue_1n61l_49",Z2="_tokenList_1n61l_56",J2="_stakingTokenList_1n61l_62",X2="_tokenRow_1n61l_72",e0="_tokenMain_1n61l_78",t0="_tokenTrigger_1n61l_84",n0="_tokenChevron_1n61l_100",s0="_expanded_1n61l_111",o0="_triggerValue_1n61l_115",a0="_tokenInfo_1n61l_122",r0="_tokenInfoLabel_1n61l_128",i0="_tokenLogo_1n61l_134",c0="_tokenSymbol_1n61l_138",l0="_tokenValues_1n61l_144",d0="_tokenAmount_1n61l_150",u0="_tokenValue_1n61l_144",m0="_typeBreakdown_1n61l_164",h0="_typeRow_1n61l_172",p0="_typeLabel_1n61l_180",f0="_typeValues_1n61l_186",g0="_typeAmount_1n61l_192",_0="_typeValue_1n61l_186",x0="_collapsibleContent_1n61l_206",G={container:K2,section:z2,sectionHeader:W2,sectionTitle:H2,sectionLabel:Q2,externalLink:G2,sectionValue:Y2,tokenList:Z2,stakingTokenList:J2,tokenRow:X2,tokenMain:e0,tokenTrigger:t0,tokenChevron:n0,expanded:s0,triggerValue:o0,tokenInfo:a0,tokenInfoLabel:r0,tokenLogo:i0,tokenSymbol:c0,tokenValues:l0,tokenAmount:d0,tokenValue:u0,typeBreakdown:m0,typeRow:h0,typeLabel:p0,typeValues:f0,typeAmount:g0,typeValue:_0,collapsibleContent:x0},zi=({protocols:e,denomLogoMap:n,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=_.useMemo(()=>{const l=e.flatMap(c=>c.positions);return hl(l)},[e]);return i.size===0?null:t.jsx("div",{className:G.container,children:Array.from(i.entries()).map(([l,c])=>t.jsx(y0,{sectionKey:l,sectionGroup:c,denomLogoMap:n,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},l))})},y0=({sectionKey:e,sectionGroup:n,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:l,totalValue:c}=n,d=ml(e,o),u=_.useMemo(()=>jl(l),[l]),h=e==="staking";return t.jsxs("div",{className:G.section,children:[t.jsxs("div",{className:G.sectionHeader,children:[t.jsxs("div",{className:G.sectionTitle,children:[t.jsx("span",{className:G.sectionLabel,children:d}),h&&a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:G.externalLink,onClick:m=>m.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:G.sectionValue,children:ee(c)})]}),t.jsx("div",{className:L(G.tokenList,{[G.stakingTokenList]:h}),children:u.map(m=>t.jsx(j0,{group:m,showTypeBreakdown:h,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},m.denom))})]})},j0=({group:e,showTypeBreakdown:n,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:l,totalValue:c,positions:d}=e,u=s.get(r),[h,m]=_.useState(!1),f=_.useMemo(()=>{if(!n)return null;const p=xl(d);return p.size>0?p:null},[d,n]);return f?t.jsxs(J.Collapsible.Root,{open:h,onOpenChange:m,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:G.tokenTrigger,children:[t.jsxs("div",{className:G.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:L(G.tokenChevron,{[G.expanded]:h})}),t.jsxs("div",{className:G.tokenInfoLabel,children:[u?.assetLogo&&t.jsx(X,{src:u.assetLogo,width:20,height:20,className:G.tokenLogo}),t.jsx("span",{className:G.tokenSymbol,children:i})]})]}),t.jsx("span",{className:G.triggerValue,children:ee(c)})]})}),t.jsx(J.Collapsible.Content,{className:G.collapsibleContent,children:t.jsx(b0,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):t.jsx("div",{className:G.tokenRow,children:t.jsxs("div",{className:G.tokenMain,children:[t.jsxs("div",{className:G.tokenInfo,children:[u?.assetLogo&&t.jsx(X,{src:u.assetLogo,width:20,height:20,className:G.tokenLogo}),t.jsx("span",{className:G.tokenSymbol,children:i})]}),t.jsxs("div",{className:G.tokenValues,children:[t.jsx("span",{className:G.tokenAmount,children:j.formatNumber(l,{dp:6})}),t.jsx("span",{className:G.tokenValue,children:ee(c)})]})]})})},b0=({typeGroups:e,symbol:n,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=_.useMemo(()=>Array.from(e.entries()).map(([c,d])=>{const u=d.reduce((m,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?m:m+f.balance.formattedAmount,0),h=d.reduce((m,f)=>m+an(f),0);return{type:c,typeAmount:u,typeValue:h}}),[e]),i=_.useMemo(()=>{if(!o)return 0;let c=0;for(const{type:d}of r){const u=o(s,d);c+=Number(u)}return c},[s,o,r]),l=i>0;return t.jsxs("div",{className:G.typeBreakdown,children:[r.map(({type:c,typeAmount:d,typeValue:u})=>t.jsxs("div",{className:G.typeRow,children:[t.jsx("span",{className:G.typeLabel,children:_l(c)}),t.jsxs("div",{className:G.typeValues,children:[t.jsxs("span",{className:G.typeAmount,children:[j.formatNumber(d,{dp:6})," ",n]}),t.jsx("span",{className:G.typeValue,children:ee(u)})]})]},c)),l&&t.jsxs("div",{className:G.typeRow,children:[t.jsx("span",{className:G.typeLabel,children:"Claimable"}),t.jsxs("div",{className:G.typeValues,children:[t.jsxs("span",{className:G.typeAmount,children:[j.formatNumber(i,{dp:6})," ",We]}),t.jsx("span",{className:G.typeValue,children:ee(i*(a??0))})]})]})]})},w0="_container_ymkoc_1",v0="_trigger_ymkoc_6",C0="_expandIcon_ymkoc_22",N0="_chainInfo_ymkoc_27",I0="_logo_ymkoc_33",k0="_chainNameContainer_ymkoc_37",S0="_chainName_ymkoc_37",A0="_externalLink_ymkoc_49",T0="_externalIcon_ymkoc_53",$0="_valueColumn_ymkoc_63",E0="_value_ymkoc_63",q0="_expanded_ymkoc_80",L0="_collapsibleContent_ymkoc_85",M0="_content_ymkoc_97",Te={container:w0,trigger:v0,expandIcon:C0,chainInfo:N0,logo:I0,chainNameContainer:k0,chainName:S0,externalLink:A0,externalIcon:T0,valueColumn:$0,value:E0,expanded:q0,collapsibleContent:L0,content:M0},P0=W.atom([]),D0=({chainGroup:e})=>{const{chainId:n,chainLogo:s,protocols:o}=e,a=de(),r=Sn(),{denomLogos:i,symbolLogos:l}=_.useMemo(()=>Uo(r,a),[r,a]),c=_.useMemo(()=>{const d=new Map;for(const u of o)for(const h of u.positions){if(h.type==="fungible-position"||h.balance.type==="unknown")continue;const{denom:m,symbol:f}=h.balance,p=f.toUpperCase(),g=`${n}:${m}`,x=i.get(g)??l.get(p);x&&d.set(m,{assetLogo:x,chainLogo:s??""})}return d},[o,i,l,n,s]);return t.jsx(zi,{protocols:o,denomLogoMap:c})},B0=({chainGroup:e})=>{const{chainName:n,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=W.useAtom(P0),l=_.useMemo(()=>o.reduce((p,g)=>p+g.positions.reduce((x,y)=>x+an(y),0),0),[o]),c=["civitia","yominet"],d=r.includes(n),u=n?.toLowerCase(),h=u==="civitia",m=c.includes(u),f=()=>{i(p=>d?p.filter(g=>g!==n):[...new Set([...p,n])])};return t.jsx("div",{className:Te.container,children:t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:f,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Te.trigger,children:[t.jsxs("div",{className:Te.chainInfo,children:[s&&t.jsx(X,{src:s,width:32,height:32,className:Te.logo,logo:!0}),t.jsxs("div",{className:Te.chainNameContainer,children:[t.jsx("span",{className:Te.chainName,children:n}),a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:Te.externalLink,onClick:p=>p.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:Te.externalIcon})})]})]}),t.jsxs("div",{className:Te.valueColumn,children:[!m&&t.jsx("span",{className:Te.value,children:ee(l)}),t.jsx(S.IconChevronDown,{size:16,className:L(Te.expandIcon,{[Te.expanded]:d})})]})]})}),t.jsx(J.Collapsible.Content,{className:Te.collapsibleContent,children:t.jsxs("div",{className:Te.content,children:[t.jsx(D0,{chainGroup:e}),h&&t.jsx(V2,{})]})})]})})},R0="_container_1gqx9_1",F0="_section_1gqx9_6",U0="_sectionHeader_1gqx9_14",O0="_sectionTitle_1gqx9_20",V0="_sectionLabel_1gqx9_26",K0="_externalLink_1gqx9_32",z0="_sectionValue_1gqx9_44",W0="_tokenList_1gqx9_51",H0="_tokenTrigger_1gqx9_63",Q0="_tokenChevron_1gqx9_79",G0="_expanded_1gqx9_90",Y0="_tokenInfo_1gqx9_94",Z0="_tokenInfoLabel_1gqx9_100",J0="_tokenLogo_1gqx9_106",X0="_pairedLogos_1gqx9_110",ej="_coinLogo_1gqx9_115",tj="_tokenSymbol_1gqx9_133",nj="_triggerValue_1gqx9_139",sj="_breakdownContent_1gqx9_146",oj="_breakdownRow_1gqx9_154",aj="_breakdownLabel_1gqx9_162",rj="_breakdownValues_1gqx9_168",ij="_breakdownAmount_1gqx9_174",cj="_breakdownValue_1gqx9_168",lj="_collapsibleContent_1gqx9_195",se={container:R0,section:F0,sectionHeader:U0,sectionTitle:O0,sectionLabel:V0,externalLink:K0,sectionValue:z0,tokenList:W0,tokenTrigger:H0,tokenChevron:Q0,expanded:G0,tokenInfo:Y0,tokenInfoLabel:Z0,tokenLogo:J0,pairedLogos:X0,coinLogo:ej,tokenSymbol:tj,triggerValue:nj,breakdownContent:sj,breakdownRow:oj,breakdownLabel:aj,breakdownValues:rj,breakdownAmount:ij,breakdownValue:cj,collapsibleContent:lj},dj=({data:e,denomLogoMap:n})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:t.jsx("div",{className:se.container,children:t.jsxs("div",{className:se.section,children:[t.jsxs("div",{className:se.sectionHeader,children:[t.jsxs("div",{className:se.sectionTitle,children:[t.jsx("span",{className:se.sectionLabel,children:"Liquidity"}),t.jsx("a",{href:So,target:"_blank",rel:"noopener noreferrer",className:se.externalLink,onClick:a=>a.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:se.sectionValue,children:ee(s)})]}),t.jsx("div",{className:se.tokenList,children:o.map(a=>t.jsx(mj,{row:a,denomLogoMap:n},a.denom))})]})})},uj={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"},mj=({row:e,denomLogoMap:n})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:l,claimableInit:c}=e,[d,u]=_.useState(!1),h=n.get(s),m=i||h?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,p=_.useMemo(()=>Object.entries(r).filter(([,y])=>y>0),[r]),g=l&&l.length>0&&l.some(y=>y),x=c&&Number(c.total)>0;return t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:se.tokenTrigger,children:[t.jsxs("div",{className:se.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:L(se.tokenChevron,{[se.expanded]:d})}),t.jsxs("div",{className:se.tokenInfoLabel,children:[g?t.jsx("div",{className:se.pairedLogos,children:l.map((y,b)=>t.jsx(X,{src:y,width:20,height:20,className:se.coinLogo,logo:!0},b))}):m&&t.jsx(X,{src:m,width:20,height:20,className:se.tokenLogo}),t.jsx("span",{className:se.tokenSymbol,children:o})]})]}),t.jsx("span",{className:se.triggerValue,children:ee(a)})]})}),t.jsx(J.Collapsible.Content,{className:se.collapsibleContent,children:t.jsxs("div",{className:se.breakdownContent,children:[p.map(([y,b])=>{const C=b*f;return t.jsxs("div",{className:se.breakdownRow,children:[t.jsx("span",{className:se.breakdownLabel,children:uj[y]}),t.jsxs("div",{className:se.breakdownValues,children:[t.jsxs("span",{className:se.breakdownAmount,children:[j.formatNumber(b,{dp:6})," LP"]}),t.jsx("span",{className:se.breakdownValue,children:ee(C)})]})]},y)}),x&&t.jsxs("div",{className:se.breakdownRow,children:[t.jsx("span",{className:se.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:se.breakdownValues,children:[t.jsxs("span",{className:se.breakdownAmount,children:[j.formatNumber(Number(c.total),{dp:6})," ",We]}),t.jsx("span",{className:se.breakdownValue,children:ee(c.totalValue)})]})]})]})})]})},hj="_container_1nijk_1",pj="_section_1nijk_6",fj="_sectionHeader_1nijk_14",gj="_sectionTitle_1nijk_20",_j="_sectionLabel_1nijk_26",xj="_externalLink_1nijk_32",yj="_sectionValue_1nijk_44",jj="_tokenList_1nijk_51",bj="_tokenTrigger_1nijk_63",wj="_tokenChevron_1nijk_79",vj="_expanded_1nijk_90",Cj="_tokenInfo_1nijk_94",Nj="_tokenInfoLabel_1nijk_100",Ij="_tokenLogo_1nijk_106",kj="_tokenName_1nijk_110",Sj="_triggerValue_1nijk_116",Aj="_breakdownContent_1nijk_123",Tj="_breakdownRow_1nijk_131",$j="_breakdownLabel_1nijk_139",Ej="_breakdownValues_1nijk_145",qj="_breakdownAmount_1nijk_151",Lj="_breakdownValue_1nijk_145",Mj="_collapsibleContent_1nijk_165",ce={container:hj,section:pj,sectionHeader:fj,sectionTitle:gj,sectionLabel:_j,externalLink:xj,sectionValue:yj,tokenList:jj,tokenTrigger:bj,tokenChevron:wj,expanded:vj,tokenInfo:Cj,tokenInfoLabel:Nj,tokenLogo:Ij,tokenName:kj,triggerValue:Sj,breakdownContent:Aj,breakdownRow:Tj,breakdownLabel:$j,breakdownValues:Ej,breakdownAmount:qj,breakdownValue:Lj,collapsibleContent:Mj},Pj=({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:Cc,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:ee(n)})]}),t.jsx("div",{className:ce.tokenList,children:s.map(o=>t.jsx(Dj,{row:o},`${o.bridgeId}-${o.version}`))})]})})},Dj=({row:e})=>{const{name:n,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[l,c]=_.useState(!1),d=a+i;return t.jsxs(J.Collapsible.Root,{open:l,onOpenChange:c,children:[t.jsx(J.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:L(ce.tokenChevron,{[ce.expanded]:l})}),t.jsxs("div",{className:ce.tokenInfoLabel,children:[s&&t.jsx(X,{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:ee(d)})]})}),t.jsx(J.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:[j.formatNumber(o,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:ee(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:[j.formatNumber(r,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:ee(i)})]})]})]})})]})},Bj="_container_ymkoc_1",Rj="_trigger_ymkoc_6",Fj="_expandIcon_ymkoc_22",Uj="_chainInfo_ymkoc_27",Oj="_logo_ymkoc_33",Vj="_chainNameContainer_ymkoc_37",Kj="_chainName_ymkoc_37",zj="_externalLink_ymkoc_49",Wj="_externalIcon_ymkoc_53",Hj="_valueColumn_ymkoc_63",Qj="_value_ymkoc_63",Gj="_expanded_ymkoc_80",Yj="_collapsibleContent_ymkoc_85",Zj="_content_ymkoc_97",$e={container:Bj,trigger:Rj,expandIcon:Fj,chainInfo:Uj,logo:Oj,chainNameContainer:Vj,chainName:Kj,externalLink:zj,externalIcon:Wj,valueColumn:Hj,value:Qj,expanded:Gj,collapsibleContent:Yj,content:Zj},Jj=W.atom(!1),Xj=()=>{const{totalValue:e}=Bo(),{totalValue:n}=Fo(),{totalValue:s}=Cs(),o=e+n+s;return t.jsx("span",{className:$e.value,children:ee(o)})},eb=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Bo(),{data:i}=Dr(),{data:l}=Br(),c=_.useMemo(()=>{const h=new Map;for(const m of r){if(m.type==="fungible-position"||m.balance.type==="unknown")continue;const{denom:f,symbol:p}=m.balance,g=p.toUpperCase(),x=`${e}:${f}`,y=s.get(x)??o.get(g);y&&h.set(f,{assetLogo:y,chainLogo:n})}return h},[r,s,o,e,n]),d=_.useMemo(()=>(h,m)=>{const f=j.denomToMetadata(h);if(m==="staking"){const p=i?.get(f);return p?j.fromBaseUnit(p.amount,{decimals:Pe}):"0"}if(m==="lockstaking"){const p=l?.get(f);return p?j.fromBaseUnit(p.amount,{decimals:Pe}):"0"}return"0"},[i,l]),u=_.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:So,positions:r}],[r]);return u.length===0?null:t.jsx(zi,{protocols:u,denomLogoMap:c,isInitia:!0,getClaimableInitByType:d,initPrice:a})},tb=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o})=>{const a=Fo(),r=_.useMemo(()=>{const i=new Map;for(const l of a.rows){const{denom:c,symbol:d}=l,u=d.toUpperCase(),h=`${e}:${c}`,m=s.get(h)??o.get(u);m&&i.set(c,{assetLogo:m,chainLogo:n})}return i},[a.rows,s,o,e,n]);return a.rows.length===0?null:t.jsx(dj,{data:a,denomLogoMap:r})},nb=()=>{const e=Cs();return e.rows.length===0?null:t.jsx(Pj,{data:e})},sb=({chainGroup:e})=>{const{chainId:n,chainName:s,chainLogo:o}=e,[a,r]=W.useAtom(Jj),i=de(),l=Sn(),{denomLogos:c,symbolLogos:d}=_.useMemo(()=>Uo(l,i),[l,i]),u=ae(),{data:h}=_t(u),m=_.useMemo(()=>h?.find(p=>p.id===Se)?.price??0,[h]);return t.jsx("div",{className:$e.container,children:t.jsxs(J.Collapsible.Root,{open:a,onOpenChange:r,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:$e.trigger,children:[t.jsxs("div",{className:$e.chainInfo,children:[o&&t.jsx(X,{src:o,width:32,height:32,className:$e.logo,logo:!0}),t.jsxs("div",{className:$e.chainNameContainer,children:[t.jsx("span",{className:$e.chainName,children:s}),t.jsx("a",{href:So,target:"_blank",rel:"noopener noreferrer",className:$e.externalLink,onClick:f=>f.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:$e.externalIcon})})]})]}),t.jsxs("div",{className:$e.valueColumn,children:[t.jsx(me,{suspenseFallback:t.jsx(He,{height:16,width:60,length:1}),children:t.jsx(Xj,{})}),t.jsx(S.IconChevronDown,{size:16,className:L($e.expandIcon,{[$e.expanded]:a})})]})]})}),t.jsx(J.Collapsible.Content,{className:$e.collapsibleContent,children:t.jsxs("div",{className:$e.content,children:[t.jsx(me,{suspenseFallback:t.jsx(He,{height:36,length:2}),children:t.jsx(eb,{chainId:n,chainLogo:o,denomLogos:c,symbolLogos:d,initPrice:m})}),t.jsx(me,{suspenseFallback:t.jsx(He,{height:36,length:2}),children:t.jsx(tb,{chainId:n,chainLogo:o,denomLogos:c,symbolLogos:d})}),t.jsx(me,{suspenseFallback:t.jsx(He,{height:36,length:1}),children:t.jsx(nb,{})})]})})]})})},ob="_totalValue_1v2ca_1",ab={totalValue:ob},rb=({filteredChainGroups:e})=>{const{totalValue:n}=Bo(),{totalValue:s}=Fo(),{totalValue:o}=Cs(),a=n+s+o,r=_.useMemo(()=>{const i=e.some(c=>c.isInitia);return e.reduce((c,d)=>d.isInitia?c:c+d.totalValue,0)+(i?a:0)},[e,a]);return t.jsx("span",{className:ab.totalValue,children:ee(r)})},ib="_container_1eubu_1",cb="_header_1eubu_7",lb="_title_1eubu_13",db="_list_1eubu_19",ub="_skeletonWrapper_1eubu_24",yn={container:ib,header:cb,title:lb,list:db,skeletonWrapper:ub},mb=_.memo(({searchQuery:e,selectedChain:n,chainInfoMap:s})=>{const{positions:o,isLoading:a}=Pn(),r=ae(),{data:i,isLoading:l}=Ki(),c=_.useMemo(()=>{const u=[];for(const m of o){if(!Array.isArray(m.positions))continue;const f=s.get(m.chainName.toLowerCase()),p=m.chainName.toLowerCase(),g=p==="civitia";if(n&&f?.chainId!==n)continue;const x=m.positions.some(N=>N.positions.some(k=>k.type!=="fungible-position")),y=g&&!l&&i&&((i.gold_balance??0)>0||(i.silver_balance??0)>0);if(!x&&!y||e&&!p.includes(e.toLowerCase()))continue;const b=m.positions.filter(N=>e&&!N.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(N.positions)&&N.positions.length>0),C=r.chainId===f?.chainId,v=b.reduce((N,k)=>N+k.positions.reduce(($,q)=>$+an(q),0),0);u.push({chainId:f?.chainId??"",chainName:f?.prettyName??m.chainName,chainLogo:f?.logoUrl??"",protocols:b,isInitia:C,totalValue:v})}const h=["civitia","yominet"];return A.sortWith([A.descend(m=>m.isInitia??!1),A.ascend(m=>h.includes(m.chainName.toLowerCase())),A.descend(m=>m.totalValue??0),A.ascend(m=>m.chainName.toLowerCase())],u)},[o,s,e,n,r.chainId,i,l]),d=c.length>0;return t.jsxs("div",{className:yn.container,children:[t.jsxs("div",{className:yn.header,children:[t.jsx("span",{className:yn.title,children:"Positions"}),d&&t.jsx(me,{suspenseFallback:t.jsx(He,{height:16,width:60,length:1}),children:t.jsx(rb,{filteredChainGroups:c})})]}),d?t.jsx("div",{className:yn.list,children:c.map(u=>u.isInitia?t.jsx(me,{suspenseFallback:t.jsx("div",{className:yn.skeletonWrapper,children:t.jsx(He,{height:56,length:1})}),children:t.jsx(sb,{chainGroup:u})},u.chainName):t.jsx(B0,{chainGroup:u},u.chainName))}):o.length===0&&a?t.jsx(He,{height:56,length:3}):t.jsx(he,{children:"No positions"})]})}),hb="_content_1w1ad_1",pb={content:hb},fb=({selectedChain:e,setSelectedChain:n})=>{const{defaultChainId:s}=Y(),o=ae(),a=Ll(),{totalValue:r}=Cs(),{chainIds:i,chainIdToValueMap:l,totalBalance:c}=_.useMemo(()=>{const d=new Map;let u=0;for(const m of a)d.set(m.chainId,m.totalBalance),u+=m.totalBalance;return r>0&&(d.set(o.chainId,(d.get(o.chainId)??0)+r),u+=r),{chainIds:A.sortWith([A.descend(m=>m===s),A.descend(m=>m===o.chainId),A.descend(m=>d.get(m)??0)],a.map(m=>m.chainId)),chainIdToValueMap:d,totalBalance:u}},[a,s,o,r]);return t.jsx(qs,{value:e,onChange:n,chainIds:i,renderExtra:d=>ee(d?l.get(d)??0:c)})},gb=()=>{const[e,n]=W.useAtom(Di),[s,o]=W.useAtom(Bi),a=de(),r=Sn(),{denomLogos:i,symbolLogos:l}=_.useMemo(()=>Uo(r,a),[r,a]),c=Co(),d=_.useMemo(()=>Vr(a,c),[a,c]),u=ql();return t.jsxs(Qe.Root,{children:[t.jsxs(Qe.Controls,{children:[t.jsx(Qe.SearchInput,{value:e,onChange:h=>n(h.target.value),onClear:()=>n(""),placeholder:"Search portfolio"}),t.jsx(me,{suspenseFallback:t.jsx(Ut,{height:44,width:132}),children:t.jsx(fb,{selectedChain:s,setSelectedChain:o})})]}),t.jsxs("div",{className:pb.content,children:[t.jsx(me,{suspenseFallback:t.jsx(He,{height:48,length:5}),children:t.jsx(E2,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:l,chainInfoMap:u,chainPrices:d})}),t.jsx(me,{suspenseFallback:t.jsx(He,{height:56,length:3}),children:t.jsx(mb,{searchQuery:e,selectedChain:s,chainInfoMap:u})})]})]})},_b="_totalValue_5pf7e_1",xb="_totalLabel_5pf7e_7",yb="_totalAmount_5pf7e_13",jb="_loading_5pf7e_18",bb="_skeletonWrapper_5pf7e_23",wb="_nav_5pf7e_28",vb="_item_5pf7e_34",Cb="_tabs_5pf7e_59",Nb="_tab_5pf7e_59",Ee={totalValue:_b,totalLabel:xb,totalAmount:yb,loading:jb,skeletonWrapper:bb,nav:wb,item:vb,tabs:Cb,tab:Nb},Ib=()=>{const{totalValue:e,isLoading:n}=Lo();return t.jsx("div",{className:L(Ee.totalAmount,{[Ee.loading]:n}),children:ee(e)})},kb=()=>{const e=Ml(),n=Pl(),s=Or(),o=e+s+n;return t.jsx("div",{className:Ee.totalAmount,children:ee(o)})},Sb=()=>{mi(),$l();const e=Oo(),n=Ce(),s=_s(),o=_.useRef(null);return t.jsx(Fi.Provider,{value:o,children:t.jsxs(et,{ref:o,children:[t.jsxs("div",{className:Ee.totalValue,children:[t.jsx("div",{className:Ee.totalLabel,children:"Total value"}),t.jsx(me,{suspenseFallback:t.jsx("div",{className:Ee.skeletonWrapper,children:t.jsx(Ut,{height:48,width:120})}),children:e?t.jsx(Ib,{}):t.jsx(kb,{})})]}),t.jsxs("div",{className:Ee.nav,children:[t.jsxs(nn,{to:"/send",className:Ee.item,children:[t.jsx(S.IconSend,{size:20}),t.jsx("span",{children:"Send"})]}),t.jsxs(nn,{to:"/bridge",className:Ee.item,children:[t.jsx(S.IconBridge,{size:20}),t.jsx("span",{children:"Bridge/Swap"})]}),t.jsxs(nn,{to:"/receive",className:Ee.item,children:[t.jsx(S.IconQrCode,{size:20}),t.jsx("span",{children:"Receive"})]})]}),t.jsxs(wt.Tabs.Root,{value:s,onValueChange:n,children:[t.jsxs(wt.Tabs.List,{className:Ee.tabs,children:[t.jsx(wt.Tabs.Tab,{className:Ee.tab,value:"/",children:e?"Assets":"Portfolio"}),t.jsx(wt.Tabs.Tab,{className:Ee.tab,value:"/nfts",children:"NFTs"}),t.jsx(wt.Tabs.Tab,{className:Ee.tab,value:"/activity",children:"Activity"})]}),t.jsx(wt.Tabs.Panel,{value:"/",children:e?t.jsx(A2,{}):t.jsx(gb,{})}),t.jsx(wt.Tabs.Panel,{value:"/nfts",children:t.jsx(Uy,{})}),t.jsx(wt.Tabs.Panel,{value:"/activity",children:t.jsx(vy,{})})]})]})})},Ab="_root_th990_1",Tb="_collectionName_th990_9",$b="_nftName_th990_13",Eb="_chainInfo_th990_17",qb="_attributes_th990_21",Lb="_title_th990_24",Mb="_count_th990_29",Pb="_item_th990_33",Db="_type_th990_39",Bb="_value_th990_45",Pt={root:Ab,collectionName:Tb,nftName:$b,chainInfo:Eb,attributes:qb,title:Lb,count:Mb,item:Pb,type:Db,value:Bb},Rb=()=>{const e=Ce(),n=Je(),{attributes:s}=n;return t.jsxs(dt,{title:"NFT details",children:[t.jsx(na,{normalizedNft:n,chainIconSize:14,classNames:Pt}),t.jsx(xe,{children:t.jsx(le.White,{onClick:()=>e("/nft/send",n),sm:!0,children:"Send"})}),s&&t.jsxs("div",{className:Pt.attributes,children:[t.jsxs("header",{className:Pt.title,children:["Traits ",t.jsxs("span",{className:Pt.count,children:["(",s.length,")"]})]}),t.jsx("div",{children:s.map(({trait_type:o,value:a})=>t.jsxs("div",{className:Pt.item,children:[t.jsx("div",{className:Pt.type,children:o}),t.jsx("div",{className:Pt.value,children:a})]},o))})]})]})};function Fb({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(l=>l.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>B(a).gte(o))}function Ub({denom:e,balances:n,gasPrices:s,lastFeeDenom:o,gas:a}){const r=n.find(d=>d.denom===e)?.amount??"0",i=Fb({balances:n,gasPrices:s,gas:a}),l=i.find(d=>d.denom===o);if(i.length===0)return r;if(e===o&&l){const d=B(r).minus(l.amount);return B.max(d,0).toString()}const c=i.find(d=>d.denom!==e)||i[0];if(!l&&e===c.denom){const d=B(r).minus(c.amount);return B.max(d,0).toString()}return B(r).toString()}const Ob=({chain:e,onSelect:n})=>{const s=xc(e);return t.jsx(On,{assets:s,onSelect:n})},Vb=({afterSelect:e})=>{const{watch:n,setValue:s}=_e.useFormContext(),{chainId:o,denom:a}=n(),{chainId:r}=n(),[i,l]=_.useState(r),c=Ze(i),d=de(),u=h=>{if(o===i&&a===h){e();return}s("chainId",i),s("denom",h),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(Ft.Stack,{children:t.jsx(Ft,{chains:d,value:i,onSelect:l})}),t.jsx(me,{suspenseFallback:t.jsx(On.Placeholder,{}),children:t.jsx(Ob,{chain:c,onSelect:u})},i)]})},Kb="_fields_brpej_1",zb="_divider_brpej_11",Ka={fields:Kb,divider:zb},Wb=ye.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Hb=()=>{const{address:e,initiaAddress:n,estimateGas:s,requestTxSync:o}=De(),{register:a,watch:r,setValue:i,handleSubmit:l,formState:c}=_e.useFormContext(),{errors:d}=c,{chainId:u,denom:h,recipient:m,quantity:f,memo:p}=r(),g=Ze(u),x=An(g),y=Vo(g),b=Ko(g),C=sr(h,g),{data:v}=_t(g),{decimals:N}=C,k=x.find(R=>R.denom===h)?.amount??"0",$=v?.find(({id:R})=>R===h)?.price,{data:q=0,isLoading:V}=T.useQuery({queryKey:Wb.gas({chainId:u,denom:h,recipient:m,initiaAddress:n}).queryKey,queryFn:()=>{const R=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ua.MsgSend.fromPartial({fromAddress:n,toAddress:j.InitiaAddress(m).bech32,amount:[{denom:h,amount:"1"}]})}];return s({messages:R,chainId:u})},enabled:j.InitiaAddress.validate(m),staleTime:K.INFINITY}),M=Math.ceil(q*on),I=Ub({denom:h,balances:x,gasPrices:y,lastFeeDenom:b,gas:M}),w=B(k).isZero(),U=y.some(({denom:R})=>R===h)&&V,F=w||U,{mutate:O,isPending:Z}=T.useMutation({mutationFn:({chainId:R,denom:P,quantity:Ne,recipient:je,memo:tt})=>{const Be=j.toBaseUnit(Ne,{decimals:N}),Wt=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ua.MsgSend.fromPartial({fromAddress:n,toAddress:j.InitiaAddress(je).bech32,amount:[{denom:P,amount:Be}]})}];return o({messages:Wt,memo:tt,chainId:R,gas:q,gasAdjustment:on,gasPrices:y,spendCoins:[{denom:P,amount:Be}],internal:"/"})}}),H=_.useMemo(()=>{if(!f)return"Enter amount";if(d.quantity)return d.quantity.message;if(!m)return"Enter recipient address";if(d.recipient)return d.recipient.message;if(d.memo)return d.memo.message},[f,m,d.quantity,d.recipient,d.memo]);return t.jsx(dt,{title:"Send",children:t.jsxs("form",{onSubmit:l(R=>O(R)),children:[t.jsxs("div",{className:Ka.fields,children:[t.jsx(mo,{selectButton:t.jsx(rn,{title:"Select chain and asset",content:R=>t.jsx(Vb,{afterSelect:R}),children:t.jsx(gi,{asset:C,chain:g})}),quantityInput:t.jsx(In,{balance:k,decimals:N}),balanceButton:t.jsx(hi,{onClick:()=>i("quantity",j.fromBaseUnit(I,{decimals:N}),{shouldValidate:!0}),disabled:F,children:j.formatAmount(k??"0",{decimals:N})}),value:f?$?ee(B(f).times($)):"$-":"$0"}),t.jsx("div",{className:Ka.divider}),t.jsx(Qo,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...a("memo",{validate:R=>!R||new Blob([R]).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:(V?"Estimating gas...":!1)||Z,disabled:!!H,children:H??"Confirm"})})]})})},Qb=()=>{const e=Je(),n=Vt(),s=gt(n),{chain:o=n}=e,a=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=_e.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return t.jsx(_e.FormProvider,{...i,children:t.jsx(Hb,{})})};async function yo(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 Gb(e,n){const s=new pt.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:j.InitiaAddress("0x1").bech32,contract_addr:j.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function Yb(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 Zb({collection_addr:e},{restUrl:n}){const s=await Gb(e,n);if(!s.startsWith("ibc/"))return{class_id:`evm/${j.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await yo(s,n);return o?{class_id:s,class_trace:o}:{class_id:`evm/${j.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function Jb(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 Xb({object_addr:e,collection_addr:n},{restUrl:s}){const o=await Jb(n,s);return o.startsWith("ibc/")?j.InitiaAddress.equals(j.createObjectAddress("0x1",o),n)?{class_id:o,class_trace:await yo(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await yo(o,s)}:{class_id:`move/${n.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function ew(e,n){const s=ie.toBase64(Dt.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 tw(e,n){const{collection:s}=await z.create({prefixUrl:n}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function nw(e,n){const s=ie.toBase64(Dt.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function za(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 sw({collection_addr:e},n,s){const o=j.InitiaAddress(e).bech32,a=await ew(o,n.restUrl),r=n.metadata?.ibc_channels?.find(({chain_id:g,version:x})=>g===s.chain_id&&x.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,l=i.split(".")[1],c=ie.toBase64(Dt.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await z.create({prefixUrl:n.restUrl}).get(`cosmwasm/wasm/v1/contract/${l}/smart/${c}`).json(),u=d??o,h=await nw(l,n.restUrl),m=await tw(o,n.indexerUrl);if(u===o)return{class_id:u,class_trace:void 0,outgoing_proxy:h};if(d&&m!==i.replace("wasm.","")){const[g,x]=za(d);return{class_id:o,class_trace:{path:g,base_class_id:x},outgoing_proxy:h}}const[f,p]=za(a);return{class_id:o,class_trace:{path:f,base_class_id:p},outgoing_proxy:h}}const ow={minimove:Xb,minievm:Zb,miniwasm:sw};async function aw({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 ow[o](e,n,s);return Object.assign(a,o==="minievm"&&{token_ids:await Yb([e.token_id],a.class_id,n.restUrl)})}const rw="_root_1tyvn_1",iw="_collectionName_1tyvn_10",cw="_nftName_1tyvn_15",lw="_chainInfo_1tyvn_19",dw="_fields_1tyvn_24",uw="_chain_1tyvn_19",oo={root:rw,collectionName:iw,nftName:cw,chainInfo:lw,fields:dw,chain:uw},mw=ye.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),hw=()=>{const e=de(),n=Je(),{chain:s,collection_addr:o}=n,{routerApiUrl:a}=Y(),r=En(),i=ae(),{address:l,initiaAddress:c,requestTxSync:d}=De(),{watch:u,setValue:h,handleSubmit:m,formState:f}=_e.useFormContext(),{errors:p}=f,g=u(),{recipient:x,dstChainId:y}=g,b=Ze(y),C=T.useQuery({queryKey:mw.simulation({collection_addr:o,nft:n,sender:c,recipient:x,srcChain:s,dstChain:b,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const I=Object.assign({from_address:c,from_chain_id:s.chainId,to_address:j.InitiaAddress(x).bech32,to_chain_id:b.chainId,collection_address:o,token_ids:[n.token_id],object_addresses:[n.object_addr]},s.chainId!==b.chainId&&await aw({nft:n,srcChain:s,intermediaryChain:i})),{msgs:w}=await z.create({prefixUrl:a}).post("nft",{json:I}).json();return w.map(E=>r.fromAmino(E))},enabled:j.InitiaAddress.validate(x)}),{data:v,isLoading:N,error:k}=C,$=T.useQueryClient(),{mutate:q,isPending:V}=T.useMutation({mutationFn:async()=>{if(!v)throw new Error("Route not found");await d({messages:v,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{$.invalidateQueries({queryKey:sa.nfts._def})}}),M=_.useMemo(()=>{if(!x)return"Enter recipient address";if(p.recipient)return p.recipient.message;if(k)return"Route not found"},[x,p.recipient,k]);return t.jsxs("form",{onSubmit:m(()=>q()),children:[t.jsx(na,{normalizedNft:n,thumbnailSize:80,classNames:oo}),t.jsxs("div",{className:oo.fields,children:[t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(rn,{title:"Destination appchain",content:I=>t.jsx(fi,{onSelect:({chainId:w})=>{h("dstChainId",w),I()},list:e,getImage:w=>w.logoUrl,getName:w=>w.name,getKey:w=>w.chainId}),className:L("input",oo.chain),children:[t.jsx(X,{src:b.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:b.name})]})]}),t.jsx(Qo,{myAddress:l,ref:Rn()})]}),t.jsx(xe,{children:t.jsx(le.White,{loading:(N?"Finding route...":!1)||V,disabled:!!M,children:M??"Confirm"})})]})},pw=()=>{const{chain:e}=Je(),n=_e.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(dt,{title:"Send NFT",children:t.jsx(_e.FormProvider,{...n,children:t.jsx(hw,{})})})},jo=()=>{const e=Ce(),n=_s(),s=kt(),{closeDrawer:o}=xt(),{closeModal:a}=bs();_.useEffect(()=>{a(),n.startsWith("/bridge/")&&n!=="/bridge/history"&&e("/bridge"),(n==="/collection"||n.startsWith("/nft"))&&e("/nfts")},[s]);const r=Tn();if(_.useEffect(()=>{r("Page View")},[n,r]),n==="/connect")return s?null:t.jsx(Ba,{onSuccess:o});if(n==="/blank")return null;if(!s)return t.jsx(Ba,{});switch(n){case"/":case"/nfts":case"/activity":return t.jsx(Sb,{});case"/send":return t.jsx(Qb,{},s);case"/receive":return t.jsx(Jx,{});case"/nft":return t.jsx(Rb,{});case"/nft/send":return t.jsx(pw,{},s);case"/bridge":return t.jsx(Yp,{},s);case"/bridge/preview":return t.jsx(cg,{});case"/bridge/history":return t.jsx(Kf,{});case"/op/withdrawals":return t.jsx(Mg,{});case"/tx":return t.jsx(ri,{});case"/autosign/enable":return t.jsx(Dm,{});case"/settings":return t.jsx(I1,{});case"/settings/autosign":return t.jsx(h1,{});case"/deposit":return t.jsx(Bx,{});case"/deposit/completed":return t.jsx(xo,{type:"deposit"});case"/withdraw":return t.jsx(Rx,{});case"/withdraw/completed":return t.jsx(xo,{type:"withdraw"})}},fw="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",gw=()=>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:fw}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),_w=()=>(Sc(),Mc(),de(),El(),Or(),Sn(),Bn(),Kt(),null),xw=({children:e,...n})=>(_.useEffect(()=>{dl()},[]),Le.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(gw,{}),t.jsx(Xa.Provider,{value:{...Ja,...n},children:t.jsx(ur,{children:t.jsx(um,{children:t.jsx(J.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(dm,{children:t.jsxs(Ju,{children:[e,t.jsx(Dl,{}),t.jsx(me,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(_w,{})}),t.jsx(Id,{children:t.jsx(jo,{})}),t.jsx(wd,{children:t.jsx(jo,{})})]})})})})})})]}):null),yw=({bridge:e})=>t.jsx(ur,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Xr.Provider,{value:!!e,children:t.jsx(me,{children:t.jsx(jo,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=on;exports.DEFAULT_GAS_PRICE_MULTIPLIER=Za;exports.InterwovenKit=yw;exports.InterwovenKitProvider=xw;exports.MAINNET=Ja;exports.MoveError=Ir;exports.PRIVY_APP_ID=vo;exports.TESTNET=ic;exports.initiaPrivyWallet=lc;exports.initiaPrivyWalletConnector=cc;exports.initiaPrivyWalletOptions=bn;exports.injectStyles=Jl;exports.useAddress=kt;exports.useHexAddress=ln;exports.useInitiaAddress=te;exports.useInterwovenKit=De;exports.usePortfolio=Lo;exports.useUsernameQuery=Lr;
|
|
4
|
+
</svg>`,hc=encodeURIComponent(mc),No=`data:image/svg+xml;utf8,${hc}`,wn=ye.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 pc(e){const{base:n,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:l,traces:c}=e,d=o.find(h=>h.denom===a)?.exponent??o.find(h=>h.denom===n)?.exponent??A.head(o)?.exponent??0,u=r?.png??"";return{denom:n,symbol:s,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function nr(){const e=T.useQueryClient();return n=>{const s=n?.metadata?.assetlist;return T.queryOptions({queryKey:wn.list(s).queryKey,queryFn:async()=>s?z.get(s).json():{assets:[]},select:({assets:o})=>{if(!n)return[];const a=o.map(pc);for(const r of a)e.setQueryData(wn.item(n.chainId,r.denom).queryKey,r);return a},staleTime:K.MINUTE})}}function gt(e){const n=nr(),{data:s}=T.useSuspenseQuery(n(e));return s}function Sn(){const e=de(),n=nr();return T.useQueries({queries:e.map(s=>n(s))})}function lt(e){const n=gt(e),s=ae(),o=gt(s),a=or(e);return r=>{const i=n.find(c=>c.denom===r);if(i)return i;const l=o.find(c=>c.denom===a(r));return l?{...l,denom:r}:{denom:r,symbol:"",decimals:0,logoUrl:No}}}function sr(e,n){const s=lt(n),a=T.useQueryClient().getQueryData(wn.item(n.chainId,e).queryKey);return a||s(e)}function or(e){const n=ae(),s=gt(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(l=>l.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?j.getIbcDenom(a,o):""}}function Io(e){const n=ae(),s=z.create({prefixUrl:n.restUrl}),o=T.useSuspenseQueries({queries:e.map(a=>({queryFn:()=>s.get("initia/move/v1/denom",{searchParams:{metadata:a}}).json(),queryKey:wn.denom(n.restUrl,a).queryKey,select:r=>[a,r.denom],staleTime:K.INFINITY}))});return new Map(o.map(({data:a})=>a))}function fc(e){return e.pagination?.next_key??null}async function ar(e,n,s){const o=z.create(n),a=async(r,i)=>{const l=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[s]??[],d=fc(l),u=[...r,...c];return d?a(u,d):u};return a([],null)}const ma="usernames";function gc({restUrl:e,moduleAddress:n}){const{viewFunction:s}=j.createMoveClient(e);async function o(i){if(!j.InitiaAddress.validate(i))return null;const l=await s({moduleAddress:n,moduleName:ma,functionName:"get_name_from_address",typeArgs:[],args:[ie.toBase64(j.InitiaAddress(i,32).bytes)]});return l?l+".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 l=await s({moduleAddress:n,moduleName:ma,functionName:"get_address_from_name",typeArgs:[],args:[Gi.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return l?j.InitiaAddress(l).bech32:null}return{restUrl:e,getUsername:o,getAddress:r,validateUsername:a}}const fs=ye.createQueryKeys("interwovenkit:account",{username:(e,n)=>[e,n],address:(e,n)=>[e,n],balances:(e,n)=>[e,n],txs:(e,n)=>[e,n]});function rr(){const{restUrl:e}=ae(),{usernamesModuleAddress:n}=Y();return gc({restUrl:e,moduleAddress:n})}function ir(){const e=te();return n=>T.queryOptions({queryKey:fs.balances(n.restUrl,e||"").queryKey,queryFn:()=>e?ar(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:n.restUrl},"balances"):[],staleTime:K.SECOND})}function An(e){const n=ir(),{data:s}=T.useSuspenseQuery(n(e));return s}function _c(){const e=de(),n=ir();return T.useQueries({queries:e.map(s=>n(s))})}function xc(e){const n=An(e),s=gt(e),o=lt(e),a=or(e),{data:r}=_t(e),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>s.some(d=>d.denom===c);return A.sortWith([A.descend(({denom:c})=>a(c)==="uinit"),A.descend(({denom:c})=>i(c)),A.descend(({value:c})=>c),A.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>B(d).comparedTo(c)??0,A.descend(({symbol:c})=>c.toLowerCase())],n.filter(({amount:c})=>!B(c).isZero()).map(({amount:c,denom:d})=>{const u=o(d),h=r?.find(({id:f})=>f===u?.denom)?.price??0,m=B(c).times(h).div(B(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:h,value:m}}))}const cr=_.createContext(null);function gs(){return _.useContext(cr)}function lr(){const{location:e}=gs();return e}function _s(){const{path:e}=lr();return e}function Je(){const{state:e={}}=lr();return e}function dr(){const{history:e}=gs();return e}function Ce(){const{navigate:e}=gs();return e}function ko(){const{reset:e}=gs();return e}const nn=({to:e,state:n,shouldReset:s,children:o,onClick:a,...r})=>{const i=Ce(),l=ko(),c=d=>{d.preventDefault(),a?.(d),s?l(e,n):i(e,n)};return t.jsx("button",{type:"button",...r,onClick:c,children:o})},ur=({children:e,initialEntry:n})=>{const[s,o]=_.useState([n??{path:"/"}]),a=s[s.length-1],r=_.useCallback((l,c)=>{o(d=>{if(typeof l=="string")return[...d,{path:l,state:c}];const u=d.length+l;if(u<1)return d;const h=A.take(u,d);return c!==void 0?A.adjust(u-1,m=>({...m,state:c}),h):h})},[]),i=_.useCallback((l,c)=>{o([{path:l,state:c}])},[]);return t.jsx(cr.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},yc="c33b940c24c17e95f7d9d525d508ac61";function jc(){const{disableAnalytics:e}=Y();_.useEffect(()=>{e||wo.init(yc,{autocapture:!1})},[e])}function bc(){const{connector:e}=ve.useAccount(),{defaultChainId:n,disableAnalytics:s}=Y();_.useEffect(()=>{const o=new Ha.Identify;e?.name&&o.set("connector",e.name),n&&o.set("defaultChainId",n),wo.identify(o)},[n,e?.name,s])}function Tn(){const e=_s();return _.useCallback((s,o)=>{wo.track(s,{path:e,...o})},[e])}const st="interwovenkit",Se="uinit",We="INIT",Pe=6,wc="uoinit",vc="omniINIT",mr="https://app.initia.xyz",So=`${mr}/liquidity/my`,Cc=`${mr}/vip/my`,Nc=1e3,hr=60*Nc,pr=60*hr,ha=24*pr,oe={PUBLIC_KEY:`${st}:public-key`,BRIDGE_SRC_CHAIN_ID:`${st}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${st}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${st}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${st}:bridge:dst-denom`,BRIDGE_QUANTITY:`${st}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${st}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${st}:bridge:route-type`,BRIDGE_HISTORY:`${st}:bridge:history`,OP_REMINDER:`${st}:op:reminder`},fr=W.atom(!1),gr=W.atom(!1);function xt(){const e=ko(),[n,s]=W.useAtom(fr),o=W.useSetAtom(gr),a=Tn();return{isDrawerOpen:n,openDrawer:(l,c)=>{l&&e(l,c),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function cn(){const e=ko(),[n,s]=W.useAtom(gr),o=W.useSetAtom(fr),a=Tn();return{isModalOpen:n,openModal:(l,c)=>{l&&e(l,c),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function Ao(){const e=Ce(),{closeDrawer:n}=xt(),{closeModal:s}=cn(),{disconnect:o}=ve.useDisconnect();return()=>{e("/blank"),n(),s(),o(),localStorage.removeItem(oe.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_SRC_DENOM),localStorage.removeItem(oe.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_DST_DENOM),localStorage.removeItem(oe.BRIDGE_QUANTITY),localStorage.removeItem(oe.BRIDGE_SLIPPAGE_PERCENT)}}function Ic(){const e=kt(),n=Vt(),{openModal:s}=cn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,srcOptions:i,recipientAddress:l}=o;if(a.length===0)throw new Error("denoms cannot be empty");const c=r??n.chainId,d=a.map(u=>({denom:u,chainId:c}));s("/deposit",{localOptions:d,remoteOptions:i,recipientAddress:l})}}function kc(){const e=kt(),n=Vt(),{openModal:s}=cn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,dstOptions:i,recipientAddress:l}=o;if(a.length===0)throw new Error("denoms cannot be empty");const c=r??n.chainId,d=a.map(u=>({denom:u,chainId:c}));s("/withdraw",{localOptions:d,remoteOptions:i,recipientAddress:l})}}function To(){const{privyContext:e}=Y(),{address:n}=ve.useAccount();return e?n?!!e.privy.user?.linkedAccounts.map(o=>"address"in o&&o.address).filter(o=>!!o)?.some(o=>j.InitiaAddress.equals(o,n)):!1:!0}function Sc(){const{privyContext:e}=Y(),n=To(),{address:s}=ve.useAccount(),{signMessageAsync:o}=ve.useSignMessage(),a=Ao(),r=!!e?.privy.ready,i=_.useRef(e);_.useEffect(()=>{i.current=e},[e]);const l=async c=>{try{if(!i.current)throw new Error("Privy context not found");i.current.privy.authenticated&&await i.current.privy.logout();const d=await i.current.siwe.generateSiweMessage({chainId:"eip155:1",address:c});if(!d)throw new Error("Failed to generate SIWE message");const u=await o({message:d});await i.current.siwe.loginWithSiwe({signature:u,message:d})}catch{a()}};_.useEffect(()=>{n||r&&s&&l(s)},[n,r,s])}function Ac(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:n}=io.PubKey.decode(e.value);return jn.encodeSecp256k1Pubkey(n)}return ms.decodeOptionalPubkey(e)}function Tc({typeUrl:e,value:n}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Zi.BaseAccount.decode(n),i=Ac(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Ke.accountFromAny({typeUrl:e,value:n})}function $c(e){return e.type==="initia/PubKeyEthSecp256k1"}const Ec={...jn.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function qc(e){if($c(e)){const n=io.PubKey.fromPartial({key:ie.fromBase64(e.value)});return Ji.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(io.PubKey.encode(n).finish())})}return ms.encodePubkey(e)}function _r(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:Ec.ethsecp256k1,value:ie.toBase64(e)}}function Lc(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:_r(e),signature:ie.toBase64(n)}}const $n=()=>{const e=Y();return new ms.Registry([...sn.protoRegistry,...e.protoTypes??[]])},En=()=>{const e=Y();return new Ke.AminoTypes({...sn.aminoConverters,...e.aminoConverters})};class xr{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=`${oe.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(n);if(s)return this.cachedPublicKey=ie.fromHex(s),ie.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(n,ie.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(n,ie.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?ie.fromBase64(s):null}catch{return null}}async getPublicKey(){const n="Sign this message to identify your Initia account.",s=await this.signMessage(n),o=pt.ethers.hashMessage(n),a=pt.ethers.SigningKey.recoverPublicKey(o,s);return ro.Secp256k1.compressPubkey(ie.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=ao.escapeCharacters(ao.sortedJsonStringify(s)),a=await this.signMessage(o),r=ie.fromHex(a.replace("0x","")).subarray(0,-1),l=ro.Secp256k1Signature.fromFixedLength(r).toFixedLength(),c=Lc(await this.getCachedPublicKey(),l);return{signed:s,signature:c}}}function xs(){const e=$n(),n=En(),s=qn(),o=$o();return async function(a,r,i,l,c,d){const u=d?.customSigner??s;if(!u)throw new Error("Signer not initialized");const h=await o(a),{accountNumber:m,...f}=await h.getSequence(r),p=f.sequence+(d?.incrementSequence??0),[g]=await u.getAccounts(),x=qc(_r(g.pubkey)),y=Yi.SignMode.SIGN_MODE_EIP_191,b=i.map(w=>n.toAmino(w)),C=ao.makeSignDoc(b,l,a,c,m,p),{signature:v,signed:N}=await u.signAmino(r,C),$={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:N.msgs.map(w=>n.fromAmino(w)),memo:c}},q=e.encode($),V=ra.Int53.fromString(N.fee.gas).toNumber(),M=ra.Int53.fromString(N.sequence).toNumber(),I=ms.makeAuthInfoBytes([{pubkey:x,sequence:M}],N.fee.amount,V,N.fee.granter,N.fee.payer,y);return It.TxRaw.fromPartial({bodyBytes:q,authInfoBytes:I,signatures:[ie.fromBase64(v.signature)]})}}function qn(){const e=te(),{signMessageAsync:n}=ve.useSignMessage(),s=ae();return _.useMemo(()=>new xr(e,o=>n({message:o}),s.restUrl),[e,n,s.restUrl])}const Ds=new Map,Bs=new Map;function yr(){const e=Ye();return async n=>{if(Ds.has(n))return Ds.get(n);const{rpcUrl:s}=e(n),o=await ia.Comet38Client.create(new ia.HttpClient(s));return Ds.set(n,o),o}}function $o(){const e=$n(),n=En(),s=qn(),o=te(),a=yr();return async r=>{const i=`${o}:${r}`;if(Bs.has(i))return Bs.get(i);if(!s)throw new Error("Signer not initialized");const l=await a(r),c=await Ke.SigningStargateClient.createWithSigner(l,s,{registry:e,aminoTypes:n,accountParser:Tc,broadcastPollIntervalMs:500});return Bs.set(i,c),c}}function jr(){const{connector:e}=ve.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new pt.BrowserProvider(await e.getProvider())}}function br(){const e=te(),n=Ye();return{fetchFeegrant:async(a,r)=>{if(!e)return null;const i=n(a),l=z.create({prefixUrl:i.restUrl});try{const{allowance:c}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${r}`).json();return c}catch{return null}},fetchGrants:async(a,r)=>{if(!e)return[];const i=n(a),l=z.create({prefixUrl:i.restUrl}),{grants:c}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:r}}).json();return c}}}function wr(){const{privyContext:e}=Y(),n=To();if(!(!e||!n))return e.wallets.find(s=>s.connectorType==="embedded")}function ys(){const e=wr();return e?.address?j.InitiaAddress(e.address).bech32:void 0}function vr(){const e=wr(),n=ys(),s=$n(),o=Ye(),a=xs();return async(r,i,l,c,d)=>{if(!e||!n)throw new Error("Embedded wallet not initialized");const u=[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:bo.MsgExec.fromPartial({grantee:n,msgs:l.map(f=>({typeUrl:f.typeUrl,value:s.encode(f)}))})}],h={...c,granter:i},m=new xr(n,e.sign,o(r).restUrl);return await a(r,n,u,h,d,{customSigner:m})}}const vn=ye.createQueryKeys("interwovenkit:autosign",{expirations:(e,n)=>[e,n],grants:(e,n)=>[e,n]});function js(){const e=Y(),n=Vt(),{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 Cr(){const{data:e}=Eo(),n=js();return async(s,o)=>{const a=o.every(i=>{const l=n[s];return l?l.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function Eo(){const e=te(),n=ys(),s=js(),{fetchFeegrant:o,fetchGrants:a}=br();return T.useQuery({queryKey:vn.expirations(e,n).queryKey,queryFn:async()=>{if(!e||!n)return{expiredAtByChain:{},isEnabledByChain:{}};const r={};for(const[l,c]of Object.entries(s))try{const d=await a(l,n);if(!c.every(x=>d.some(y=>y.authorization?.msg===x))){r[l]=null;continue}const h=await o(l,n);if(!h){r[l]=null;continue}const m=d.filter(x=>c.includes(x.authorization.msg)).map(x=>x.expiration),f=h.allowance.expiration,p=[...m,f],g=qo(p);r[l]=g?new Date(g):void 0}catch{r[l]=null}const i={};for(const[l,c]of Object.entries(r))switch(c){case null:i[l]=!1;break;case void 0:i[l]=!0;break;default:i[l]=Ge.isFuture(c);break}return{expiredAtByChain:r,isEnabledByChain:i}},staleTime:K.INFINITY,retry:!1})}function Mc(){const{data:e,refetch:n}=Eo();_.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(l=>l instanceof Date&&Ge.isFuture(l));if(o.length===0)return;const r=qo(o).getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{n()},r+100);return()=>clearTimeout(i)},[e,n])}function qo(e){return e.filter(n=>n!==void 0).toSorted((n,s)=>new Date(n).getTime()-new Date(s).getTime())[0]}const Nr=_.createContext(null),bs=()=>_.useContext(Nr);class Ir extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(n,s,o,a,r,i,l){super(n),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=l}}const Pc=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Rs=new Map;function Dc(e){const n=e.match(Pc);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 Bc(e,n,s){const o=`${e}:${n}`;if(Rs.has(o))return Rs.get(o);try{const a=n==="0x1"?"0x1.json":`${e}/${n}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await z.get(r).json();return Rs.set(o,i),i}catch{return null}}function Rc(e,n,s,o,a,r,i){return new Ir(e,n,s,o,a,r,i)}async function Zt(e,n,s){if(!n.metadata?.is_l1&&n.metadata?.minitia?.type!=="minimove")return await ft(e);const o=Dc(e.message);if(!o)return await ft(e);const a=await Bc(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}`,l=a?.[o.moduleName]?.[o.errorCode],c=l||i,d=!!l;return Rc(c,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const kr="approve",ws=W.atom(),Sr=W.atom(null);function Ar(){const e=W.useAtomValue(ws);if(!e)throw new Error("Tx request not found");return e}function vs(){const e=Ce(),n=te(),{defaultChainId:s,registryUrl:o}=Y(),a=Ye(),{openDrawer:r,closeDrawer:i}=xt(),{openModal:l,closeModal:c}=bs(),d=W.useSetAtom(ws),u=W.useSetAtom(Sr),h=yr(),m=$o(),f=qn(),p=$n(),g=Cr(),x=vr(),y=xs(),b=async({messages:M,memo:I,chainId:w=s})=>{try{return await(await m(w)).simulate(n,M,I)}catch(E){throw await Zt(E,a(w),o)}},C=async({messages:M,memo:I,chainId:w=s})=>{const E=await h(w),U=Ke.QueryClient.withExtensions(E,Ke.setupTxExtension),F=M.map(P=>p.encodeAsAny(P)),[O]=await f.getAccounts(),Z=jn.encodeSecp256k1Pubkey(O.pubkey),H=await m(w),{sequence:R}=await H.getSequence(n);return U.tx.simulate(F,I,Z,R)},v=async({txRequest:M,broadcaster:I})=>{const E={...{memo:"",chainId:s,gas:M.gas||await b(M),gasAdjustment:on,gasPrices:null,spendCoins:[],internal:!1},...M};return new Promise((U,F)=>{d({txRequest:E,resolve:async Z=>{try{const H=await m(E.chainId),R=await I(H,It.TxRaw.encode(Z).finish());U(R),typeof E.internal=="string"&&e(E.internal)}catch(H){F(await Zt(H,a(E.chainId),o))}finally{O()}},reject:Z=>{F(Z),O()}}),E.internal?l({path:"/tx"}):r("/tx");const O=()=>{if(!E.internal){e("/blank"),i();return}c()}})},N=async M=>{const I=M.chainId??s;try{const w=await v({txRequest:M,broadcaster:async(E,U)=>await E.broadcastTxSync(U)});return M.internal&&typeof M.internal!="number"&&(u({txHash:w,chainId:I,status:"loading"}),V({txHash:w,chainId:M.chainId}).then(E=>{u({status:E.code===0?"success":"error",chainId:I,txHash:w})}).catch(()=>{u({status:"error",chainId:I,txHash:w})})),w}catch(w){throw M.internal&&typeof M.internal!="number"&&u({status:"error",chainId:I,error:w}),w}},k=(M,I=30*1e3,w=.5*1e3)=>v({txRequest:M,broadcaster:async(E,U)=>{const F=await E.broadcastTx(U,I,w);if(F.code!==0)throw new Error(F.rawLog);return F}}),$=async M=>{const I=M.chainId??s;try{const{messages:w,memo:E="",fee:U}=M,F=await m(I),Z=await g(I,w)?await x(I,n,w,U,E):await y(I,n,w,U,E);return await F.broadcastTxSync(It.TxRaw.encode(Z).finish())}catch(w){throw await Zt(w,a(I),o)}},q=async(M,I=30*1e3,w=.5*1e3)=>{const E=M.chainId??s;try{const{messages:U,memo:F="",fee:O}=M,Z=await m(E),R=await g(E,U)?await x(E,n,U,O,F):await y(E,n,U,O,F),P=await Z.broadcastTx(It.TxRaw.encode(R).finish(),I,w);if(P.code!==0)throw new Error(P.rawLog);return P}catch(U){throw await Zt(U,a(E),o)}},V=async({chainId:M=s,...I})=>{try{const w=await m(M);return await Tr({...I,client:w})}catch(w){throw await Zt(w,a(M),o)}};return{estimateGas:b,simulateTx:C,requestTxSync:N,requestTxBlock:k,submitTxSync:$,submitTxBlock:q,waitForTxConfirmation:V}}async function Tr({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 Ln=W.atom(null);function $r(){const e=te(),n=js(),{fetchFeegrant:s,fetchGrants:o}=br();return async a=>{const{chainId:r,grantee:i}=a;if(!e)throw new Error("Granter wallet not initialized");const l=await s(r,i),c=await o(r,i),d=l?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:Qa.MsgRevokeAllowance.fromPartial({granter:e,grantee:i})}]:[],u=n[r].filter(h=>c.some(m=>m?.authorization?.msg===h)).map(h=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:bo.MsgRevoke.fromPartial({granter:e,grantee:i,msgTypeUrl:h})}));return[...d,...u]}}function Fc(){const{privyContext:e}=Y(),n=te(),s=ys(),o=js(),{requestTxBlock:a}=vs(),r=T.useQueryClient(),[i,l]=W.useAtom(Ln),{closeDrawer:c}=xt(),d=$r(),u=async()=>{if(s)return s;if(!e)throw new Error("Privy context not available");const h=await e.createWallet({createAdditional:!1});return j.InitiaAddress(h.address).bech32};return T.useMutation({mutationFn:async h=>{if(!i)throw new Error("No pending request");const{chainId:m}=i,f=await u();if(!n||!f)throw new Error("Wallets not initialized");const p=await d({chainId:m,grantee:f}),g=h===0?void 0:Ge.addMilliseconds(new Date,h),x={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:Qa.MsgGrantAllowance.fromPartial({granter:n,grantee:f,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:la.BasicAllowance.encode(la.BasicAllowance.fromPartial({expiration:g})).finish()}})},y=o[m].map(C=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:bo.MsgGrant.fromPartial({granter:n,grantee:f,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:ca.GenericAuthorization.encode(ca.GenericAuthorization.fromPartial({msg:C})).finish()},expiration:g}})})),b=[...p,x,...y];await a({messages:b,chainId:m,internal:!0})},onSuccess:async()=>{await r.invalidateQueries({queryKey:vn.expirations._def}),i?.resolve()},onError:h=>{i?.reject(h)},onSettled:()=>{l(null),c()}})}function Er(e){const n=Y(),s=ys(),o=e?.grantee||s,{requestTxBlock:a}=vs(),r=T.useQueryClient(),i=$r();return T.useMutation({mutationFn:async(l=n.defaultChainId)=>{if(!o)throw new Error("Wallets not initialized");const c=await i({chainId:l,grantee:o});await a({messages:c,chainId:l,internal:e?.internal})},onSuccess:async()=>{const l=[vn.expirations._def,vn.grants._def];for(const c of l)await r.invalidateQueries({queryKey:c})}})}function Uc(){const{defaultChainId:e}=Y(),{openDrawer:n}=xt(),s=W.useSetAtom(Ln),o=Er(),{data:a={expiredAtByChain:{},isEnabledByChain:{}},isLoading:r}=Eo();return{...a,isLoading:r,enable:async(c=e)=>new Promise((d,u)=>{s({chainId:c,resolve:d,reject:u}),n("/autosign/enable")}),disable:async(c=e)=>{await o.mutateAsync(c)}}}function qr(e){return e.assets.reduce((n,{value:s})=>n+(s??0),0)}function Oc(e){return e.assets.reduce((n,{quantity:s})=>n.plus(s),B(0)).toString()}function Vc(e,n){return{symbol:n?.symbol??e,logoUrl:n?.logoUrl??No}}function pa(e){return A.pick(["chainId","name","logoUrl"],e)}function Kc(e){return A.sortWith([A.descend(({symbol:n})=>n===We),A.descend(qr),A.descend(({assets:n})=>n.length),A.ascend(({symbol:n})=>n)])(e)}function zc(e){return A.sortWith([A.descend(({value:n})=>n??0),A.descend(({quantity:n})=>Number(n)),A.ascend(({chain:n})=>n.name)])(e)}function Wc(e,n){return A.sortWith([A.descend(({chain:s})=>s.chainId===n),A.ascend(({chain:s})=>s.name),A.ascend(({denom:s})=>s)])(e)}function Hc(e,n){return A.sortWith([A.descend(({chainId:s})=>s===n),A.descend(A.prop("value"))])(e)}function Qc(e,n,s,o,a){const r=e.find(h=>h.metadata?.is_l1)?.chainId,i={};for(const h of e){const m=h.chainId,f=n[m]??[],p=s[m],g=o[m],x=[];for(const{amount:y,denom:b}of f){if(!B(y).gt(0))continue;const C=p?.find(q=>q.denom===b),v=g?.find(q=>q.id===b)?.price,N=C?.decimals??0,k=j.fromBaseUnit(y,{decimals:N}),$=v?B(k).times(v).toNumber():void 0;x.push({...Vc(b,C),amount:y,denom:b,decimals:N,quantity:k,price:v,value:$,address:C?.address,unlisted:!C,chain:pa(h)})}i[m]=x}const l=new Map;for(const[h,m]of Object.entries(i)){if(m.length===0)continue;const f=e.find(g=>g.chainId===h);if(!f)continue;const p=m.reduce((g,{value:x})=>g+(x??0),0);l.set(h,{...pa(f),value:p})}const c=new Map;for(const h of Object.values(i))for(const m of h)if(!m.unlisted){const{symbol:f}=m,p=c.get(f)??[];c.set(f,[...p,m])}const d=[];for(const[h,m]of c){const f=A.head(m);if(!f)continue;const p=zc(m),g=p.reduce((y,{value:b})=>y+(b??0),0),x=p.reduce((y,{quantity:b})=>y.plus(b),B(0)).toNumber();d.push({symbol:h,logoUrl:f.logoUrl,assets:p,totalValue:g,totalAmount:x})}const u=[];for(const h of Object.values(i))for(const m of h)m.unlisted&&u.push(m);return{chainsByValue:Hc(Array.from(l.values()),a),assetGroups:Kc(d),unlistedAssets:Wc(u,r),totalValue:d.reduce((h,m)=>h+m.totalValue,0)}}function Lo(){const{defaultChainId:e}=Y(),n=de(),s=_c(),o=Sn(),a=Co(),r=n.map(m=>m.chainId),i=A.zipObj(r,s.map(A.prop("data"))),l=A.zipObj(r,o.map(A.prop("data"))),c=A.zipObj(r,a.map(A.prop("data"))),d=Qc(n,i,l,c,e),u=[s,o,a].flat().some(({isLoading:m})=>m);return{...d,isLoading:u,refetch:()=>{s.forEach(({refetch:m})=>m()),o.forEach(({refetch:m})=>m()),a.forEach(({refetch:m})=>m())}}}function te(){const e=ln();return e?j.InitiaAddress(e).bech32:""}function ln(){const{address:e}=ve.useAccount(),n=To();return!e||!n?"":j.InitiaAddress(e).hex}function kt(){const e=Vt(),n=te(),s=ln();return e.metadata?.minitia?.type==="minievm"?s:n}function Lr(){const e=kt(),n=rr();return T.useQuery({queryKey:fs.username(n.restUrl,e).queryKey,queryFn:()=>n.getUsername(e),enabled:!!e,staleTime:K.MINUTE})}function De(){const e=kt(),n=te(),s=ln(),{data:o}=Lr(),a=qn(),r=Ao(),i=Uc(),{isDrawerOpen:l,openDrawer:c}=xt(),{isModalOpen:d}=cn(),u=()=>{c("/")},h=()=>{c("/connect")},m=b=>{c("/bridge",b)},f=Ic(),p=kc(),g=vs();return{address:e,initiaAddress:n,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:l||d,openConnect:h,openWallet:u,openBridge:m,openDeposit:f,openWithdraw:p,disconnect:r,autoSign:i,...g}}const Gc="_status_tn9m1_1",Yc="_error_tn9m1_9",fa={status:Gc,error:Yc},he=({error:e,children:n})=>t.jsx("p",{className:L(fa.status,{[fa.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(Ga.ErrorBoundary,{...e,children:t.jsx(_.Suspense,{fallback:n,children:s})}),Zc="lock_staking";function Mr(e,n){const s=`${n}::lock_staking::StakingAccount`,o=j.createObjectAddress(e,s);return j.InitiaAddress(o).bech32}const Mn=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 Mo(){const{restUrl:e}=ae(),n=te();return T.useSuspenseQuery({queryKey:Mn.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 l=j.denomToMetadata(i.denom),c={denom:i.denom,metadata:l,amount:i.amount,validator:r},d=o.get(l)??[];d.push(c),o.set(l,d)}}return o},staleTime:K.MINUTE})}function Po(){const{restUrl:e}=ae(),{lockStakeModuleAddress:n}=Y(),s=te(),o=s?Mr(s,n):"";return T.useSuspenseQuery({queryKey:Mn.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 l=i.validator_address;for(const c of i.entries)for(const d of c.balance){const u=j.denomToMetadata(d.denom),h={denom:d.denom,metadata:u,amount:d.amount,validator:l,completionTime:c.completion_time},m=r.get(u)??[];m.push(h),r.set(u,m)}}return r},staleTime:K.MINUTE})}function Do(){const{restUrl:e}=ae(),{lockStakeModuleAddress:n}=Y(),s=te();return T.useSuspenseQuery({queryKey:Mn.lockStaking(e,s||"",n).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=j.createMoveClient(e);return await o({moduleAddress:n,moduleName:Zc,functionName:"get_locked_delegations",typeArgs:[],args:[ie.toBase64(j.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},l=a.get(r.metadata)??[];l.push(i),a.set(r.metadata,l)}return a},staleTime:K.MINUTE})}function Pr(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=j.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 Dr(){const{restUrl:e}=ae(),n=te();return T.useSuspenseQuery({queryKey:Mn.stakingRewards(e,n||"").queryKey,queryFn:async()=>n?await z.get(`${e}/initia/distribution/v1/delegators/${n}/rewards`).json():{rewards:[],total:[]},select:Pr,staleTime:K.MINUTE})}function Br(){const{restUrl:e}=ae(),{lockStakeModuleAddress:n}=Y(),s=te(),o=s?Mr(s,n):"";return T.useSuspenseQuery({queryKey:Mn.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await z.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:Pr,staleTime:K.MINUTE})}function Bo(){const e=ae(),n=gt(e),{data:s,isLoading:o}=_t(e),{data:a}=Mo(),{data:r}=Po(),{data:i}=Do(),l=_.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]),c=Io(l),d=_.useMemo(()=>{const f=new Map;if(s)for(const p of s)f.set(p.id,p.price);return f},[s]),u=_.useMemo(()=>{const f=new Map;for(const p of n)f.set(p.denom,p);return f},[n]),h=_.useMemo(()=>{const f=[],p=g=>{const x=u.get(g);return x?{symbol:x.symbol,decimals:x.decimals}:null};for(const[g,x]of a){const y=c.get(g)??x[0]?.denom;if(!y)continue;const b=p(y);if(!b)continue;const C=d.get(y)??0;for(const v of x){const{symbol:N,decimals:k}=b,$=Number(j.fromBaseUnit(v.amount,{decimals:k})),q={type:"asset",denom:y,symbol:N,amount:v.amount,formattedAmount:$,decimals:k,value:$*C};f.push({type:"staking",validator:v.validator,balance:q})}}for(const[g,x]of i){const y=c.get(g);if(!y)continue;const b=p(y);if(!b)continue;const C=d.get(y)??0;for(const v of x){const{symbol:N,decimals:k}=b,$=Number(j.fromBaseUnit(v.amount,{decimals:k})),q={type:"asset",denom:y,symbol:N,amount:v.amount,formattedAmount:$,decimals:k,value:$*C},V=Number(v.releaseTime);f.push({type:"lockstaking",validator:v.validator,releaseTime:Number.isNaN(V)?0:V,balance:q})}}for(const[g,x]of r){const y=c.get(g)??x[0]?.denom;if(!y)continue;const b=p(y);if(!b)continue;const C=d.get(y)??0;for(const v of x){const{symbol:N,decimals:k}=b,$=Number(j.fromBaseUnit(v.amount,{decimals:k})),q={type:"asset",denom:y,symbol:N,amount:v.amount,formattedAmount:$,decimals:k,value:$*C},V=new Date(v.completionTime).getTime(),M=Number.isNaN(V)?0:Math.floor(V/1e3);f.push({type:"unstaking",validator:v.validator,completionTime:M,balance:q})}}return f.filter(g=>g.type!=="fungible-position"&&g.balance.denom===Se)},[a,i,r,c,u,d]),m=_.useMemo(()=>h.reduce((f,p)=>p.type==="fungible-position"||p.balance.type==="unknown"?f:f+(p.balance.value??0),0),[h]);return{positions:h,totalValue:m,isLoading:o}}const Ro=ye.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,n)=>[e,n],lpPrices:(e,n)=>[e,n],pool:(e,n)=>[e,n]});function Jc(e){const n=new Map;for(const s of e){const o=j.denomToMetadata(s.denom),a={...s,metadata:o},r=n.get(o)??[];r.push(a),n.set(o,r)}return n}function Xc(e){const{dexUrl:n}=Y();return T.useSuspenseQuery({queryKey:Ro.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 Rr(){const e=ae(),n=An(e),s=_.useMemo(()=>n.map(a=>a.denom),[n]),{data:o}=Xc(s);return _.useMemo(()=>{const a=n.filter(r=>o.get(r.denom)===!0);return Jc(a)},[n,o])}function Fr(e){const{dexUrl:n}=Y();return T.useSuspenseQuery({queryKey:Ro.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 el(e){const{dexUrl:n}=Y(),s=ae(),o=gt(s),a=_.useMemo(()=>{const l=new Map;for(const c of o)l.set(c.denom,c);return l},[o]),i=T.useSuspenseQueries({queries:e.map(l=>({queryKey:Ro.pool(n,l).queryKey,queryFn:async()=>{try{const c=j.denomToMetadata(l);return(await z.get(`${n}/indexer/dex/v2/pools/${encodeURIComponent(c)}`).json()).pool}catch{return null}},staleTime:K.MINUTE}))}).map(l=>l.data);return _.useMemo(()=>{const l=new Map;return e.forEach((c,d)=>{const u=i[d];if(!u){l.set(c,null);return}if(c===wc){l.set(c,{...u,symbol:vc});return}const h=u.coins.map(m=>a.get(m.denom)?.symbol||m.denom).join("-");l.set(c,{...u,symbol:h})}),l},[e,i,a])}function tl(e,n,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of n){const l=i[0]?.denom;l&&l!==Se&&a.add(r)}for(const r of s.keys())a.add(r);for(const[r,i]of o){const l=i[0]?.denom;l&&l!==Se&&a.add(r)}return Array.from(a)}function nl(e){const n=[];for(const[,s]of e)s&&s!==Se&&n.push(s);return n}function sl(e,n){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>n.get(s.denom)?.logoUrl||"")}function ol(e,n,s){const o=n.get(e)??null,a=o?.symbol||e,r=sl(o,s),i=r.length>0&&r.some(c=>c),l=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:l,coinLogos:i?r:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0}}}function Fs(e,n,s,o,a){for(const[r,i]of e){const l=n.get(r)??i[0]?.denom;if(!l||l===Se)continue;const c=o.get(l);if(c)for(const d of i){const u=String(d.amount),h=c.decimals,m=Number(j.fromBaseUnit(u,{decimals:h})),f=s.get(l)??0,p=m*f;c.breakdown[a]+=m,c.totalAmount+=m,c.totalValue+=p}}}function al(e,n,s,o,a){for(const[r,i]of e){const l=n.get(r);if(!l||l===Se)continue;const c=o.get(l);if(c)for(const d of i){const u=String(d.amount),h=c.decimals,m=Number(j.fromBaseUnit(u,{decimals:h})),f=s.get(l)??0,p=m*f;c.breakdown[a]+=m,c.totalAmount+=m,c.totalValue+=p}}}function rl(e,n,s,o){for(const[a,r]of e){const i=j.denomToMetadata(a),l=n?.get(i),c=l?j.fromBaseUnit(l.amount,{decimals:Pe}):"0",d=s?.get(i),u=d?j.fromBaseUnit(d.amount,{decimals:Pe}):"0",h=Number(c)+Number(u);h>0&&(r.claimableInit={staking:c,lockStaking:u,total:String(h),totalValue:h*o})}}function Fo(){const e=ae(),n=gt(e),s=Rr(),{data:o}=Mo(),{data:a}=Do(),{data:r}=Po(),{data:i}=Dr(),{data:l}=Br(),{data:c}=_t(e),d=_.useMemo(()=>{const y=new Map;for(const b of n)y.set(b.denom,b);return y},[n]),u=_.useMemo(()=>tl(s,o,a,r),[s,o,a,r]),h=Io(u),m=_.useMemo(()=>nl(h),[h]),{data:f}=Fr(m),p=el(m),{rows:g,totalValue:x}=_.useMemo(()=>{const y=c?.find(N=>N.id===Se)?.price??0,b=new Map;for(const N of m)b.set(N,ol(N,p,d));Fs(s,h,f,b,"deposit"),Fs(o,h,f,b,"staking"),al(a,h,f,b,"lockStaking"),Fs(r,h,f,b,"unstaking"),rl(b,i,l,y);const C=Array.from(b.values()).filter(N=>N.totalAmount>0).sort((N,k)=>k.totalValue-N.totalValue),v=C.reduce((N,k)=>N+k.totalValue,0);return{rows:C,totalValue:v}},[m,p,d,s,o,a,r,h,f,i,l,c]);return{totalValue:x,rows:g}}const il=ye.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,n)=>[e,n]});function cl(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 Ur(){const{vipUrl:e}=Y(),n=te();return T.useQuery({queryKey:il.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 ll(){const e=de();return _.useCallback(n=>e.find(({metadata:s})=>s?.op_bridge_id===String(n)),[e])}function Cs(){const{data:e}=Ur(),n=ae(),{data:s}=_t(n),o=ll(),a=_.useMemo(()=>s?.find(c=>c.id===Se)?.price??0,[s]),r=_.useMemo(()=>e?cl(e).map(c=>{const d=o(c.rollup.bridgeId),u=Number(j.fromBaseUnit(String(c.lockedReward),{decimals:Pe})),h=Number(j.fromBaseUnit(String(c.claimableReward),{decimals:Pe})),m=B(j.fromBaseUnit(String(c.lockedReward),{decimals:Pe})).times(a).toNumber(),f=B(j.fromBaseUnit(String(c.claimableReward),{decimals:Pe})).times(a).toNumber();return{bridgeId:c.rollup.bridgeId,version:c.rollup.version,name:d?.name??"",logoUrl:d?.logoUrl,lockedReward:u,lockedRewardValue:m,claimableReward:h,claimableRewardValue:f}}):[],[e,a,o]),i=_.useMemo(()=>r.reduce((l,c)=>l+c.lockedRewardValue+c.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function Or(){const e=Rr(),{data:n}=Mo(),{data:s}=Do(),{data:o}=Po(),{data:a}=Ur(),r=ae(),{data:i}=_t(r),l=_.useMemo(()=>i?.find(g=>g.id===Se)?.price??0,[i]),c=_.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=Io(c),u=_.useMemo(()=>Array.from(d.values()).filter(p=>p!==Se),[d]),{data:h}=Fr(u),m=gt(r),f=_.useMemo(()=>{const p=new Map;for(const g of m)p.set(g.denom,{decimals:g.decimals});return p},[m]);return _.useMemo(()=>{let p=0,g=0;const x=l??0,y=(C,v)=>{const N=d.get(C)??C;if(N===Se)return 0;const k=f.get(N)?.decimals??Pe;return Number(j.fromBaseUnit(v,{decimals:k}))*(h.get(N)??0)};for(const[,C]of n)for(const{denom:v,metadata:N,amount:k}of C)v===Se?p+=Number(j.fromBaseUnit(k,{decimals:Pe}))*x:g+=y(N,k);for(const[C,v]of s){const k=(d.get(C)??C)===Se;for(const{amount:$}of v)k?p+=Number(j.fromBaseUnit($,{decimals:Pe}))*x:g+=y(C,$)}for(const[,C]of o)for(const{denom:v,metadata:N,amount:k}of C)v===Se?p+=Number(j.fromBaseUnit(k,{decimals:Pe}))*x:g+=y(N,k);for(const[C,v]of e)for(const{amount:N}of v)g+=y(C,String(N));let b=0;if(a)for(const C of a){const v=C.total_locked_reward??0,N=C.total_claimable_reward??0;b+=Number(j.fromBaseUnit(String(v+N),{decimals:Pe}))*x}return p+g+b},[n,s,o,e,a,l,d,h,f])}function dl(){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:oe.PUBLIC_KEY,getSuffix:s=>j.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[l,c]of Object.entries(i)){const d=`${o}:${a(l)}`;localStorage.setItem(d,c)}localStorage.removeItem(s)}catch{}}}const co=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 Uo(e,n){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=n[a],l=r.data;if(!(!i||!l)){for(const c of l)if(c.logoUrl&&!c.logoUrl.includes("undefined")){const d=`${i.chainId}:${c.denom}`;s.has(d)||s.set(d,c.logoUrl);const u=c.symbol.toUpperCase();o.has(u)||o.set(u,c.logoUrl)}}}return{denomLogos:s,symbolLogos:o}}function an(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 ul(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 ml(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 hl(e){const n=new Map;for(const d of e){const u=ul(d);if(!u)continue;const h=n.get(u)??[];h.push(d),n.set(u,h)}const s=new Map,o=new Map;for(const[d,u]of n){const h=u.reduce((f,p)=>f+an(p),0),m=u.reduce((f,p)=>f+Math.abs(an(p)),0);s.set(d,h),o.set(d,m)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,l=[...n.keys()].sort((d,u)=>{const h=d==="lending"||d==="borrowing"?i:o.get(d)??0,m=u==="lending"||u==="borrowing"?i:o.get(u)??0;return(d==="lending"||d==="borrowing")&&(u==="lending"||u==="borrowing")?d==="lending"?-1:1:m-h}),c=new Map;for(const d of l)c.set(d,{positions:n.get(d),totalValue:s.get(d)??0});return c}function pl(e){return e.type==="fungible-position"?e.title:e.balance.denom}function fl(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function gl(e){return e.type==="fungible-position"?null:e.balance}function _l(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 xl(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 yl(e,n){return e.symbol===We&&n.symbol===We?0:e.symbol===We?-1:n.symbol===We?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function jl(e){const n=new Map;for(const o of e){const a=pl(o),r=n.get(a)??[];r.push(o),n.set(a,r)}return Array.from(n.entries()).map(([o,a])=>{const r=gl(a[0]);let i=0;for(const l of a)l.type!=="fungible-position"&&l.balance.type!=="unknown"&&(i+=l.balance.formattedAmount);return{denom:o,symbol:fl(a[0]),positions:a,totalValue:a.reduce((l,c)=>l+an(c),0),totalAmount:i,balance:r}}).toSorted(yl)}function Vr(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(l=>[l.id,l.price]));s.set(o.chainId,i)}}),s}function bl(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 wl(e,n){return e.symbol===We&&n.symbol===We?0:e.symbol===We?-1:n.symbol===We?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function vl(e,n,s){return e.map(o=>{const a=o.assets.map(i=>{const l=i.symbol.toUpperCase(),c=`${i.chain.chainId}:${i.denom}`,d=n.get(c)??s.get(l)??"";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 Cl(e,n,s){const o=n?e.filter(i=>{const{symbol:l,assets:c}=i,d=n.toLowerCase();return l.toLowerCase().includes(d)||c.some(({denom:u})=>u.toLowerCase().includes(d))}):e,a=s?o.map(i=>{const l=i.assets.filter(({chain:c})=>c.chainId===s);return{...i,assets:l,totalValue:l.reduce((c,d)=>c+(d.value??0),0),totalAmount:l.reduce((c,d)=>c+Number(d.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,l)=>i+l.assets.reduce((c,d)=>c+(d.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Nl(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 Il(e,n,s,o){const{filteredAssets:a,totalAssetsValue:r}=Cl(e,s,o),i=Nl(n,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function kl(e,n,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const l of e){const{chainName:c,chainId:d,balances:u}=l;if(!Array.isArray(u))continue;const h=n.get(c.toLowerCase()),m=h?.chainId??d??c,f=h?.prettyName??c,p=h?.logoUrl??"",g=s.get(m);for(const x of u){if(x.type==="unknown"){if(!x.amount||x.amount==="0")continue;r.push({symbol:x.denom,logoUrl:"",denom:x.denom,amount:x.amount,decimals:0,quantity:x.amount,value:void 0,unlisted:!0,chain:{chainId:m,name:f,logoUrl:p}});continue}if(x.type==="lp"||(x.value??0)<=0&&(x.formattedAmount??0)<=0)continue;let y=x.value;if((y==null||y<=0)&&g){const v=g.get(x.denom)??0;v>0&&(y=x.formattedAmount*v)}const b={symbol:x.symbol,logoUrl:"",denom:x.denom,amount:x.amount,decimals:x.decimals,quantity:String(x.formattedAmount),value:y,chain:{chainId:m,name:f,logoUrl:p}},C=a.get(x.symbol);C?C.push(b):a.set(x.symbol,[b])}}r.sort((l,c)=>{const d=l.chain.chainId===o,u=c.chain.chainId===o;if(d&&!u)return-1;if(!d&&u)return 1;const h=l.chain.name.localeCompare(c.chain.name);if(h!==0)return h;try{const m=BigInt(l.amount),f=BigInt(c.amount);if(m>f)return-1;if(m<f)return 1}catch{const m=l.amount.localeCompare(c.amount);if(m!==0)return-m}return l.denom.localeCompare(c.denom)});const i=[];for(const[l,c]of a){c.sort((h,m)=>(m.value??0)-(h.value??0));let d=0,u=0;for(const h of c)d+=h.value??0,u+=Number(h.quantity);i.push({symbol:l,logoUrl:"",assets:c,totalValue:d,totalAmount:u})}return i.sort(wl),{listedGroups:i,unlistedAssets:r}}function Oo(){return ae().network_type==="testnet"}function St(){return _e.useFormContext()}function Sl(){const e=Je(),n=Oo(),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=A.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(oe.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(oe.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(oe.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(oe.BRIDGE_DST_DENOM),quantity:localStorage.getItem(oe.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(oe.BRIDGE_SLIPPAGE_PERCENT)});return{...n?o:a,...r,...e}}const Al={balances:[],positions:[],isLoading:!0,isComplete:!1},Kr=W.atom(0),Tl=1e3;let ga=0;function $l(){const e=W.useSetAtom(Kr);_.useEffect(()=>{const n=Date.now();n-ga>=Tl&&(ga=n,e(s=>s+1))},[e])}function El(){const e=T.useQueryClient(),n=te(),{minityUrl:s}=Y(),o=Oo(),a=W.useAtomValue(Kr),r=_.useEffectEvent((c,d)=>{const u=Array.isArray(c.balances)?c.balances:[];d.set(c.chain,{chainName:c.chain,chainId:c.chainId,balances:u})}),i=_.useEffectEvent((c,d)=>{const u=Array.isArray(c.positions)?c.positions:[];d.set(c.chain,{chainName:c.chain,chainId:c.chainId,positions:u})}),l=_.useEffectEvent((c,d)=>{const u=co.ssePortfolio(n??"",s).queryKey,h=e.getQueryData(u)??Al,m=c.size>0||d.size>0;e.setQueryData(u,{...h,balances:Array.from(c.values()),positions:Array.from(d.values()),isLoading:m?!1:h.isLoading,isComplete:!1})});_.useEffect(()=>{if(!n||o)return;const c=co.ssePortfolio(n,s).queryKey,d=e.getQueryData(c),u=new Map,h=new Map;for(const x of d?.balances??[])u.set(x.chainName,x);for(const x of d?.positions??[])h.set(x.chainName,x);const f=`${s}/v1/chain/all/${encodeURIComponent(n)}`;let p=null,g=!1;return e.setQueryData(c,{balances:d?.balances??[],positions:d?.positions??[],isLoading:!0,isComplete:!1}),p=new EventSource(f),p.onmessage=x=>{if(!g)try{const y=JSON.parse(x.data);y.type==="balances"?r(y,u):y.type==="positions"&&i(y,h),l(u,h)}catch{}},p.onerror=()=>{p?.close()},()=>{g=!0,p?.close()}},[n,o,a])}const _a={balances:[],positions:[],isLoading:!0,isComplete:!1};function Pn(){const e=te(),{minityUrl:n}=Y(),s=co.ssePortfolio(e??"",n).queryKey,{data:o}=T.useQuery({queryKey:s,queryFn:()=>_a,enabled:!!e,staleTime:K.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??_a}function ql(){const e=de();return _.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 Ll(){const{balances:e,positions:n}=Pn(),s=de(),o=_.useMemo(()=>{const r=new Map;for(const i of s)r.set(i.chain_name.toLowerCase(),i);return r},[s]);return _.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 x=g.balance.value??0;return g.type==="lending"&&g.direction==="borrow"?p-x:p+x},0),l=new Map,c=Array.isArray(e)?e:[],d=Array.isArray(n)?n:[];for(const{chainName:f,balances:p}of c){if(!Array.isArray(p))continue;const g=p.reduce((x,y)=>x+r(y),0);l.set(f,(l.get(f)||0)+g)}for(const{chainName:f,positions:p}of d){if(!Array.isArray(p))continue;const g=p.reduce((x,y)=>x+i(y),0);l.set(f,(l.get(f)||0)+g)}const u=Array.from(l.values()).reduce((f,p)=>f+p,0),h=Array.from(l.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:u>0?p/u:0}}).filter(f=>f.chainId!==""),m=f=>f.chainName.toLowerCase()==="initia";return A.sortWith([A.descend(m),A.descend(A.prop("totalBalance"))],h)},[e,n,o])}function Ml(){const{balances:e}=Pn(),n=de(),s=Co(),o=_.useMemo(()=>Vr(n,s),[n,s]);return _.useMemo(()=>{const a=c=>c.type==="unknown"?0:c.value??0;let r=0;const i=Array.isArray(e)?e:[],l=bl(i,o);for(const{balances:c}of l)if(Array.isArray(c))for(const d of c)d.type!=="lp"&&(r+=a(d));return r},[e,o])}function Pl(){const{positions:e}=Pn();return _.useMemo(()=>{const n=r=>r.positions.reduce((i,l)=>{if(l.type==="fungible-position")return i+(l.value??0);if(l.balance.type==="unknown")return i;const c=l.balance.value??0;return l.type==="lending"&&l.direction==="borrow"?i-c:i+c},0),s=["initia","civitia","yominet"];let o=0;const a=Array.isArray(e)?e:[];for(const{chainName:r,positions:i}of a){const l=r.toLowerCase();s.includes(l)||Array.isArray(i)&&(o+=i.reduce((c,d)=>c+n(d),0))}return o},[e])}const qe=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 Xe(){const{routerApiUrl:e}=Y();return _.useMemo(()=>z.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.3.0"}}),[e])}function zr(){const e=de();return n=>e.some(s=>s.chain_id===n)}function Dn(){const e=zr();return n=>e(n.chain_id)?"initia":n.chain_type}function Cn(e){return Dn()(e)}function Bn(){const e=Xe(),{data:n}=T.useSuspenseQuery({queryKey:qe.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>A.sortWith([A.descend(({chain_name:o})=>o==="initia"),A.ascend(({pretty_name:o})=>o)],s),staleTime:K.MINUTE});return n}function yt(){const e=Bn(),n=er();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 ze(e){return yt()(e)}function Kt(){const e=Xe(),n=Bn(),s=T.useQueryClient(),{data:o}=T.useSuspenseQuery({queryKey:qe.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(c=>c.chain_id===i))continue;const{assets:l}=a[i]??{assets:[]};s.setQueryData(qe.assets(i).queryKey,{chain_to_assets_map:a}),r.push(...l);for(const c of l)s.setQueryData(qe.asset(i,c.denom).queryKey,c)}return r},staleTime:K.MINUTE});return o}function is(e){const n=Xe(),s=T.useQueryClient(),{data:o}=T.useSuspenseQuery({queryKey:qe.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(qe.asset(e,i.denom).queryKey,i);return r.toSorted(A.descend(i=>i.symbol==="INIT"))},staleTime:K.MINUTE});return o}function Wr(e){const n=is(e);return s=>{const o=n.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function it(e,n){return Wr(n)(e)}const Dl=()=>(jc(),bc(),null),Bl="_loader_1vxch_1",Rl={loader:Bl},ct=({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:Rl.loader,style:o})},Fl="_button_1q027_1",Ul="_outline_1q027_28",Ol="_sm_1q027_46",Vl="_full_1q027_53",Kl="_small_1q027_57",zl="_unpadded_1q027_88",Bt={button:Fl,outline:Ul,sm:Ol,full:Vl,small:Kl,unpadded:zl},Hr=e=>{const{sm:n,fullWidth:s,loading:o,className:a,children:r,disabled:i,...l}=e;return t.jsx("button",{...l,className:L(Bt.button,{[Bt.sm]:n,[Bt.full]:s},a),disabled:!!o||i,children:o?t.jsxs(t.Fragment,{children:[t.jsx(ct,{color:"currentColor",size:16}),typeof o=="string"&&t.jsx("span",{className:Bt.loading,children:o})]}):r})},Wl=({className:e,...n})=>t.jsx(Hr,{...n,className:L(Bt.outline,e)}),Hl=({className:e,unpadded:n,...s})=>t.jsx("button",{...s,className:L(Bt.small,{[Bt.unpadded]:n},e)}),le={White:Hr,Outline:Wl,Small:Hl},Ql="_footer_1vp4h_1",Gl="_actions_1vp4h_10",xa={footer:Ql,actions:Gl},xe=({extra:e,className:n,children:s})=>t.jsxs("footer",{className:L(xa.footer,n),children:[e,t.jsx("div",{className:xa.actions,children:s})]}),Yl="_scrollable_13su7_1",Zl={scrollable:Yl},et=({className:e,children:n,ref:s})=>t.jsx("div",{ref:s,className:L(Zl.scrollable,e),children:n});function Ns(){return Le.useMediaQuery("(max-width: 576px)")}const lo="interwoven-kit";function Qr(){const e=document.querySelector(lo)||document.body.appendChild(document.createElement(lo));return e.shadowRoot||e.attachShadow({mode:"open"})}function Gr(){const{theme:e,container:n}=Y();return _.useEffect(()=>{document.querySelector(lo)?.setAttribute("data-theme",e)},[e]),n??Qr()}function Jl(e){const n=Qr(),s=document.createElement("style");s.textContent=e,n.appendChild(s)}const Is=_.createContext(null);function Ot(){const{container:e}=_.useContext(Is);return e}function Yr(e){const n=Ot();return n?getComputedStyle(n).getPropertyValue(e):""}function Xl(){return Le.useScrollLock(),null}function ed(e){return/^[A-F0-9]{64}$/i.test(e)}function td(e,n){const{txHash:s,accountAddress:o,pathSuffix:a}=n;if(s)return ed(s)?A.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!j.InitiaAddress.validate(o))return;const i=A.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function nd(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 sd="_link_j1lkz_1",ya={link:sd},ks=({chainId:e,txHash:n,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:l,onClick:c,...d}=a,u=Ze(e),h=td(u,{txHash:n,accountAddress:s,pathSuffix:o}),m=n?j.truncate(n):s?j.truncate(s):"",f=l??m;return h?t.jsxs("a",{...d,href:Xi(nd(h)),className:L(ya.link,i),onClick:c,target:"_blank",children:[f,r&&t.jsx(S.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:L(ya.link,i),children:f})},Zr=_.createContext(null),Ss=()=>_.useContext(Zr),od=()=>{const[e,n]=W.useAtom(Sr),{showNotification:s,updateNotification:o,hideNotification:a}=Ss();return _.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(ks,{txHash:l,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},cs=({value:e,children:n})=>{const[s,o]=_.useState(!1);return n({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},ad="_placeholder_10r3x_1",rd="_logo_10r3x_5",ja={placeholder:ad,logo:rd},X=({src:e,alt:n,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[l,c]=_.useState(void 0),{width:d,height:u}=i,h=s??t.jsx("div",{className:L(ja.placeholder,o?.placeholder),style:{width:d,height:u,...a}});return!e||l===e?h:t.jsx("img",{...i,className:L(i.className,{[ja.logo]:r}),style:{width:d,height:u,...a},src:e,alt:n,loading:"lazy",onError:()=>c(e)})};function Jr(){const{connector:e}=ve.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const id="_header_1q8ju_1",cd="_account_1q8ju_17",ld="_name_1q8ju_28",dd="_address_1q8ju_32",ud="_icon_1q8ju_36",md="_copied_1q8ju_43",hd="_button_1q8ju_58",pd="_settings_1q8ju_69",fd="_disconnect_1q8ju_73",gd="_label_1q8ju_83",_d="_expanded_1q8ju_91",Fe={header:id,account:cd,name:ld,address:dd,icon:ud,copied:md,button:hd,settings:pd,disconnect:fd,label:gd,expanded:_d},xd=()=>{const e=Ao(),{address:n,username:s}=De(),o=Jr(),a=s??n,[r,i]=_.useState(!1),l=_.useRef(null),c=rt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{r?e():i(!0)},u=()=>{r&&(l.current=setTimeout(()=>{i(!1)},500))},h=()=>{l.current&&(clearTimeout(l.current),l.current=null)};return _.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]),n?t.jsxs("header",{className:Fe.header,children:[t.jsx(cs,{value:n,children:({copy:m,copied:f})=>t.jsxs("button",{className:L(Fe.account,{[Fe.copied]:f}),onClick:m,children:[t.jsx(X,{src:o,width:18,height:18}),t.jsx("div",{className:Fe.address,children:j.truncate(n)}),t.jsx("div",{className:Fe.name,children:j.truncate(a)}),t.jsx(S.IconCopy,{className:Fe.icon,size:12}),f?"Copied!":""]})}),t.jsx(nn,{to:"/settings",className:L(Fe.button,Fe.settings),"aria-label":"Open settings",children:t.jsx(S.IconSettingFilled,{size:16})}),t.jsxs(rt.animated.button,{className:L(Fe.button,Fe.disconnect,{[Fe.expanded]:r}),style:c,onClick:d,onMouseLeave:u,onMouseEnter:h,children:[t.jsx(S.IconSignOut,{size:16}),t.jsx("span",{className:Fe.label,children:"Disconnect"})]})]}):null},yd="_overlay_jij9g_1",jd="_content_jij9g_28",bd="_inner_jij9g_60",Us={overlay:yd,content:jd,inner:bd},wd=({children:e})=>{const{isDrawerOpen:n,closeDrawer:s}=xt(),{setContainer:o}=_.useContext(Is),a=Ns(),r=Gr(),i=W.useAtomValue(ws),l=W.useAtomValue(Ln),c=T.useIsMutating({mutationKey:[kr]}),d=()=>{const p=c?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),i?.reject(new Error(p)),l?.reject(new Error("User rejected"))},u=_s(),h=Ce(),m=T.useQueryClient(),f={fallbackRender:({error:p,resetErrorBoundary:g})=>{const x=()=>{u==="/bridge"&&(localStorage.removeItem(oe.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_SRC_DENOM),localStorage.removeItem(oe.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_DST_DENOM)),h("/"),m.clear(),g()};return t.jsxs(et,{children:[t.jsx(he,{error:!0,children:p.message}),t.jsx(xe,{children:t.jsx(le.White,{onClick:x,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:Us.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:Us.content,children:t.jsxs("div",{className:L(Us.inner,"body"),ref:o,children:[a&&t.jsx(Xl,{}),t.jsx(od,{}),t.jsx(xd,{}),t.jsx(me,{errorBoundaryProps:f,children:e})]})})]})})},vd="_backdrop_1bqx9_1",Cd="_modal_1bqx9_12",Nd="_closeButton_1bqx9_44",Os={backdrop:vd,modal:Cd,closeButton:Nd},Id=({children:e})=>{const{isModalOpen:n,closeModal:s}=cn(),{setContainer:o}=_.useContext(Is),a=Gr();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:Os.backdrop,onClick:s}),t.jsxs(ke.Dialog.Popup,{className:L(Os.modal),ref:o,children:[t.jsx("button",{className:Os.closeButton,onClick:s,"aria-label":"Close",children:t.jsx(S.IconClose,{size:20})}),e]})]})})},Xr=_.createContext(!1),kd="_overlay_1iyfl_1",Sd="_fullscreen_1iyfl_15",Ad="_content_1iyfl_19",Td="_header_1iyfl_56",$d="_title_1iyfl_65",Ed="_close_1iyfl_70",$t={overlay:kd,fullscreen:Sd,content:Ad,header:Td,title:$d,close:Ed},ei=({title:e,children:n,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=Ot(),l=_.useContext(Xr);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:L($t.overlay,{[$t.fullscreen]:l}),onClick:()=>r(!1),forceRender:!0}),t.jsxs(ke.Dialog.Popup,{className:L($t.content,{[$t.fullscreen]:l}),children:[e&&t.jsxs("header",{className:$t.header,children:[t.jsx(ke.Dialog.Title,{className:$t.title,children:e}),t.jsx(ke.Dialog.Close,{className:$t.close,children:t.jsx(S.IconClose,{size:20})})]}),n]})]})]}):null},Nn=({children:e})=>{const n=_.useRef(null),[s,o]=_.useState(0),[a,r]=_.useState(!1),i=rt.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return _.useEffect(()=>{const l=n.current;if(!l)return;const c=()=>{const{height:u}=l.getBoundingClientRect();o(u),r(!0)};c();const d=new ResizeObserver(c);return d.observe(l),()=>d.disconnect()},[e]),e?t.jsx(rt.animated.div,{style:{overflow:"hidden",...i},children:t.jsx("div",{ref:n,children:e})}):null},qd="_help_qcmtq_1",Ld="_icon_qcmtq_10",Md="_info_qcmtq_19",Pd="_warning_qcmtq_23",Dd="_error_qcmtq_27",Bd="_success_qcmtq_33",Vs={help:qd,icon:Ld,info:Md,warning:Pd,error:Dd,success:Bd},Jt=({level:e,className:n,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return t.jsx(ct,{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:L(Vs.help,e&&Vs[e],n),style:{marginTop:s},children:[t.jsx("div",{className:Vs.icon,children:a()}),o]})},Rd="_stack_a6m7u_1",Fd="_help_a6m7u_6",Ud="_info_a6m7u_14",Od="_warning_a6m7u_19",Vd="_error_a6m7u_24",Kd="_success_a6m7u_29",uo={stack:Rd,help:Fd,info:Ud,warning:Od,error:Vd,success:Kd},zd=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(Nn,{children:t.jsx("div",{className:uo.stack,children:e})}),fe=({mt:e=0,...n})=>t.jsx(Jt,{...n,className:L(uo.help,uo[n.level]),mt:e});fe.Stack=zd;const Wd="_root_16p5j_1",Hd="_item_16p5j_10",Qd="_chevron_16p5j_14",Gd="_trigger_16p5j_19",Yd="_content_16p5j_39",mn={root:Wd,item:Hd,chevron:Qd,trigger:Gd,content:Yd};function Zd(e){const{list:n,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return t.jsxs(J.Accordion.Root,{className:mn.root,type:"multiple",...i,children:[n.map((l,c)=>t.jsxs(J.Accordion.Item,{className:mn.item,value:s?.(l)??String(c),children:[t.jsx(J.Accordion.Header,{children:t.jsxs(J.Accordion.Trigger,{className:mn.trigger,children:[o(l),t.jsx(S.IconChevronDown,{className:mn.chevron,size:16})]})}),t.jsx(J.Accordion.Content,{className:mn.content,children:a(l)})]},s?.(l)??c)),r]})}const Jd=10;function ti(){const e=te();return(n,s)=>T.queryOptions({queryKey:fs.txs(n.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Jd},{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 Xd(e,n){const s=ti();return T.useSuspenseQuery(s(e,n))}function eu(e,n){const s=e.flatMap((o,a)=>(n[a]??[]).map(i=>({...i,chain:o})));return A.sortWith([A.descend(o=>new Date(o.timestamp).getTime())])(s)}const tu=()=>{const e=de(),n=ti(),s=T.useQueries({queries:e.map(i=>n(i,{enabled:!0}))}),o=s.map(A.prop("data")),a=eu(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};function Vo(e){const{data:n}=T.useSuspenseQuery({queryKey:ps.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:s}=e,{gas_prices:o}=await z.create({prefixUrl:s}).get("initia/tx/v1/gas_prices").json();return o.toSorted(A.descend(({denom:a})=>a==="uinit")).map(({denom:a,amount:r})=>{const i=a==="uinit"?1:Za;return{amount:B(r).times(i).toFixed(18),denom:a}})}return e.fees.fee_tokens.map(({denom:s,fixed_min_gas_price:o})=>{if(A.isNil(o))throw new Error(`${s} has no price`);return{amount:String(o),denom:s}})},staleTime:K.SECOND});return n}function Ko(e){const n=te(),{data:s}=Xd(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=>j.InitiaAddress.equals(n,pt.computeAddress(`0x${ie.toHex(ro.Secp256k1.uncompressPubkey(ie.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const nu="_trigger_u613p_1",su="_icon_u613p_18",ou="_content_u613p_27",au="_item_u613p_36",ru="_itemText_u613p_52",iu="_itemIndicator_u613p_57",cu="_active_u613p_60",vt={trigger:nu,icon:su,content:ou,item:au,itemText:ru,itemIndicator:iu,active:cu};function zo({options:e,value:n,onChange:s,classNames:o}){const a=Ot(),r=e.find(l=>l.value===n);if(!r)throw new Error("Selected option not found");const i=l=>{const c=e.find(d=>String(d.value)===l);if(!c)throw new Error(`Option not found: ${l}`);s(c.value)};return t.jsxs(ut.Select.Root,{value:String(n),onValueChange:i,modal:!1,children:[t.jsxs(ut.Select.Trigger,{className:L(vt.trigger,o?.trigger),children:[t.jsx(ut.Select.Value,{children:r.triggerLabel||r.label}),t.jsx(ut.Select.Icon,{className:vt.icon,children:t.jsx(S.IconChevronDown,{size:12})})]}),t.jsx(ut.Select.Portal,{container:a,children:t.jsx(ut.Select.Positioner,{className:vt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(ut.Select.Popup,{className:vt.popup,children:e.map(l=>t.jsxs(ut.Select.Item,{className:L(vt.item,o?.item),value:String(l.value),children:[t.jsx(ut.Select.ItemText,{className:L(vt.itemText,o?.itemText),children:l.label}),t.jsx(S.IconCheck,{size:12,className:L(vt.itemIndicator,{[vt.active]:l.value===n})})]},String(l.value)))})})})]})}const lu="_root_1t37n_1",du="_trigger_1t37n_7",uu="_item_1t37n_11",mu="_itemText_1t37n_17",ba={root:lu,trigger:du,item:uu,itemText:mu},hu=({options:e,value:n,onChange:s})=>{const{txRequest:o}=Ar(),a=Ze(o.chainId),r=lt(a),i=(p,g)=>{if(j.formatAmount(p,{decimals:g})==="0.000000")return 8},l=({amount:[{amount:p,denom:g}]})=>{if(B(p).isZero())return"0";const{symbol:x,decimals:y}=r(g),b=i(p,y);return`${j.formatAmount(p,{decimals:y,dp:b})} ${x}`},c=e.map(p=>{const[{denom:g}]=p.amount,{symbol:x}=r(g);return{value:g,label:l(p),triggerLabel:x}});if(e.length===1)return t.jsx("span",{className:"monospace",children:l(e[0])});const d=e.find(p=>p.amount[0].denom===n);if(!d)throw new Error("Fee option not found");const[{amount:u,denom:h}]=d.amount,{decimals:m}=r(h),f=i(u,m);return t.jsxs("div",{className:ba.root,children:[t.jsx("span",{className:"monospace",children:j.formatAmount(u,{decimals:m,dp:f})}),t.jsx(zo,{options:c,value:n,onChange:s,classNames:ba})]})},pu="_root_16nr2_1",fu="_trigger_16nr2_5",gu="_chevron_16nr2_13",_u="_panel_16nr2_27",xu="_details_16nr2_39",yu="_row_16nr2_48",Gt={root:pu,trigger:fu,chevron:gu,panel:_u,details:xu,row:yu},ju=({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),l=r===6?void 0:8;return t.jsxs(Ps.Collapsible.Root,{className:Gt.root,children:[t.jsxs(Ps.Collapsible.Trigger,{className:Gt.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(S.IconChevronDown,{className:Gt.chevron,size:16})]}),t.jsx(Ps.Collapsible.Panel,{className:Gt.panel,children:t.jsx("div",{className:Gt.details,children:i.map(({label:c,value:d})=>t.jsxs("div",{className:Gt.row,children:[t.jsx("span",{children:c}),t.jsxs("span",{children:[j.formatAmount(d,{decimals:r,dp:l})," ",a]})]},c))})})]})};function ls(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?ie.toBase64(e):Array.isArray(e)?`[${e.map(ls).join(",")}]`:JSON.stringify(e,(n,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const bu="_container_1xzyq_1",wu="_toggle_1xzyq_5",vu="_list_1xzyq_11",Cu="_arg_1xzyq_16",Nu="_type_1xzyq_21",hn={container:bu,toggle:wu,list:vu,arg:Cu,type:Nu},Iu=ye.createQueryKeys("interwovenkit:move",{abi:(e,n,s,o)=>[e,n,s,o]}),ku=({type:e,arg:n})=>ls(j.resolveBcsType(e).parse(n)),Su=({msg:e,chainId:n,fallback:s})=>{const[o,a]=Le.useToggle(!1),{restUrl:r}=Ze(n),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=T.useQuery({queryKey:Iu.abi(r,i,l,c).queryKey,queryFn:async()=>{const m=await z.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${l}`).json(),p=JSON.parse(m.module.abi).exposed_functions.find(({name:g})=>g===c);if(!p)throw new Error(`Function ${c} not found in module ${l}`);return p.params.filter(g=>!g.startsWith("&"))},staleTime:K.INFINITY});if(!u)return s;const h=(m,f)=>{const p=u[f];return t.jsxs("div",{className:hn.arg,children:[t.jsx("div",{className:hn.type,children:p}),t.jsx(Ga.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(ku,{type:p,arg:m})})]},f)};return t.jsxs("div",{className:hn.container,children:[t.jsx(le.Small,{className:hn.toggle,onClick:a,disabled:!u,children:o?"Encode":"Decode"}),o?t.jsx("div",{className:hn.list,children:d.map(h)}):s]})},Au="_list_oip9m_1",Tu="_key_oip9m_9",$u="_value_oip9m_14",Ks={list:Au,key:Tu,value:$u},Eu=({message:e,chainId:n})=>{const{typeUrl:s,value:o}=e;return t.jsx("div",{className:Ks.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{children:[t.jsx("div",{className:Ks.key,children:a}),t.jsx("div",{className:Ks.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?t.jsx(Su,{msg:o,chainId:n,fallback:ls(r)}):ls(r)})]},a))})},qu="_item_1n572_1",Lu="_title_1n572_10",Mu="_content_1n572_14",zs={item:qu,title:Lu,content:Mu},Ws=({title:e,content:n})=>t.jsxs("div",{className:zs.item,children:[t.jsx("div",{className:zs.title,children:e}),t.jsx("div",{className:zs.content,children:n})]});function ee(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=j.formatNumber(n?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function ni(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(l=>l.key==="spender")?.value,i=o.attributes.find(l=>l.key==="amount")?.value;if(r===n&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=s[c]||BigInt(0);s[c]=d-BigInt(l)}}}if(o.type==="coin_received"){const r=o.attributes.find(l=>l.key==="receiver")?.value,i=o.attributes.find(l=>l.key==="amount")?.value;if(r===n&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=s[c]||BigInt(0);s[c]=d+BigInt(l)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),denom:o}))}function si(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(c=>c.key==="type_tag")?.value,i=o.attributes.find(c=>c.key==="data")?.value;if(!r||!i)continue;let l;try{l=JSON.parse(i)}catch{continue}if(r==="0x1::fungible_asset::WithdrawEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&j.createUserDerivedObjectAddress(n,u)===c){const m=s[u]||BigInt(0);s[u]=m-BigInt(d)}}if(r==="0x1::fungible_asset::DepositEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&j.createUserDerivedObjectAddress(n,u)===c){const m=s[u]||BigInt(0);s[u]=m+BigInt(d)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const oi=({metadata:e,chain:n,children:s})=>{const{restUrl:o}=n,{data:a}=T.useSuspenseQuery({queryKey:wn.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)},Pu="_root_1p8a4_1",Du="_title_1p8a4_8",Bu="_changes_1p8a4_14",Ru="_change_1p8a4_14",Fu="_amount_1p8a4_35",Uu="_text_1p8a4_42",Ou="_value_1p8a4_49",Rt={root:Pu,title:Du,changes:Bu,change:Ru,amount:Fu,text:Uu,value:Ou},ai=({amount:e,asset:n,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=n,l=j.formatAmount(e,{decimals:r}),c=s&&B(j.fromBaseUnit(e,{decimals:r})).times(s).abs();return t.jsxs("div",{className:Rt.change,children:[t.jsxs("div",{className:Rt.amount,children:[t.jsx(X,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:Rt.text,children:[l," ",a||o]})]}),c&&t.jsx("div",{className:Rt.value,children:ee(c)})]})},Vu=({changes:e,chain:n})=>{const s=lt(n),{data:o}=_t(n);return e.map(({amount:a,denom:r},i)=>{const l=s(r),c=o?.find(({id:d})=>d===r)?.price;return t.jsx(ai,{amount:a,asset:l,price:c},i)})},Ku=({changes:e,chain:n})=>{const s=lt(n),{data:o}=_t(n);return e.map(({amount:a,metadata:r},i)=>t.jsx(oi,{metadata:r,chain:n,children:l=>{const c=o?.find(({id:d})=>d===l)?.price;return t.jsx(ai,{amount:a,asset:s(l),price:c})}},i))};function zu(e,n){return typeof n=="bigint"?n.toString():n}const Wu=ye.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,zu)]}),Hu=({messages:e,memo:n,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=De(),r=Ze(s),{simulateTx:i}=vs(),{data:l}=T.useSuspenseQuery({queryKey:Wu.simulate({messages:e,memo:n,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:n,chainId:s}),staleTime:K.SECOND}),c=m=>t.jsxs("div",{className:Rt.root,children:[t.jsx("h2",{className:Rt.title,children:"Estimated changes"}),t.jsx("div",{className:Rt.changes,children:m})]});if(!l)return null;const d=l.result?.events??[];if(d.length===0)return null;if(r.metadata?.is_l1||r.metadata?.minitia?.type==="minimove"){const m=si(d,a),[f]=wa(m);return f.length===0?null:c(t.jsx(Ku,{changes:f,chain:r}))}const u=ni(d,o),[h]=wa(u);return h.length===0?null:c(t.jsx(Vu,{changes:h,chain:r}))};function wa(e){return A.partition(n=>new B(n.amount).isNegative(),e)}const Qu="_title_1d032_1",Gu="_meta_1d032_7",Yu="_footer_1d032_14",Zu="_rejectButton_1d032_19",Gn={title:Qu,meta:Gu,footer:Yu,rejectButton:Zu},ri=()=>{const{txRequest:e,resolve:n,reject:s}=Ar(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:l,spendCoins:c}=e,d=te(),u=xs(),h=Ze(r),m=An(h),f=Vo(h),p=Ko(h),g=lt(h),x=Cr(),y=vr(),b=(e.gasPrices??f).map(({amount:w,denom:E})=>Ke.calculateFee(Math.ceil(i*l),Ke.GasPrice.fromString(w+E))),C=b.map(w=>w.amount[0]),v=w=>{const E=m.find(P=>P.denom===w)?.amount??"0",U=C.find(P=>P.denom===w)?.amount??"0",F=c.filter(P=>P.denom===w).reduce((P,Ne)=>B(P).plus(Ne.amount),B("0")),O=B(U).plus(F),Z=B(E).gte(O),{symbol:H,decimals:R}=g(w);return{symbol:H,decimals:R,spend:F.gt(0)?F.toFixed():null,fee:U,total:O.toFixed(),balance:E,isSufficient:Z}},N=()=>{if(p&&v(p).isSufficient)return p;for(const{denom:w}of C)if(v(w).isSufficient)return w;return C[0]?.denom},[k,$]=_.useState(N),{mutate:q,isPending:V}=T.useMutation({mutationKey:[kr],mutationFn:async()=>{const w=b.find(F=>F.amount[0].denom===k);if(!w)throw new Error("Fee not found");const U=!e.internal&&await x(r,o)?await y(r,d,o,w,a||""):await u(r,d,o,w,a);await n(U)},onError:async w=>{s(w)}}),M=v(k),I=!M.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(et,{children:[t.jsx("h1",{className:Gn.title,children:"Confirm tx"}),t.jsxs("div",{className:Gn.meta,children:[t.jsx(Ws,{title:"Chain",content:r}),t.jsx(Ws,{title:"Tx fee",content:t.jsx(hu,{options:b,value:k,onChange:$})}),a&&t.jsx(Ws,{title:"Memo",content:a}),I&&t.jsx(fe,{level:"error",children:t.jsx(ju,{...M})})]}),t.jsx(Hu,{messages:o,memo:a,chainId:r}),t.jsx(Zd,{list:o,renderHeader:({typeUrl:w})=>hs.sentenceCase(w.split(".").pop().replace(/^Msg/,"")),renderContent:w=>t.jsx(Eu,{message:w,chainId:r})})]}),t.jsxs(xe,{className:Gn.footer,children:[t.jsx(le.Outline,{onClick:()=>s(new Error("User rejected")),disabled:V,className:Gn.rejectButton,children:t.jsx(S.IconClose,{size:16})}),t.jsx(le.White,{onClick:()=>q(),disabled:I,loading:V,children:"Approve"})]})]})},Ju=({children:e})=>{const[{title:n,content:s,path:o},a]=_.useState({}),[r,i]=_.useState(!1),l=W.useAtomValue(ws),c=_.useCallback(h=>{a(h),i(!0)},[]),d=_.useCallback(()=>{a({}),i(!1)},[]),u=_.useCallback(h=>{h||(l?.reject(new Error("User rejected")),a({})),i(h)},[l]);return t.jsxs(Nr.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(ei,{title:n,open:r,onOpenChange:u,children:t.jsx(me,{children:o==="/tx"?t.jsx(ri,{}):s})})]})},Xu="_container_1w1hx_1",em="_toast_1w1hx_11",tm="_info_1w1hx_24",nm="_success_1w1hx_28",sm="_error_1w1hx_32",om="_icon_1w1hx_37",am="_content_1w1hx_45",rm="_title_1w1hx_48",im="_description_1w1hx_53",cm="_close_1w1hx_75",Ct={container:Xu,toast:em,info:tm,success:nm,error:sm,icon:om,content:am,title:rm,description:im,close:cm},lm=({notification:e,onClose:n,...s})=>{const o=rt.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(ct,{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:l,title:c,description:d}=i,u=a(l);return t.jsx(rt.animated.div,{style:r,className:Ct.container,children:t.jsxs("div",{className:L(Ct.toast,l&&Ct[l]),...s,children:[u&&t.jsx("div",{className:Ct.icon,children:u}),t.jsxs("div",{className:Ct.content,children:[t.jsx("p",{className:Ct.title,children:c}),d&&t.jsx("div",{className:Ct.description,children:d})]}),t.jsx("button",{className:Ct.close,onClick:n,children:t.jsx(S.IconClose,{size:14})})]})})})},Hs=5e3,dm=({children:e})=>{const n=Ot(),[s,o]=_.useState(null),a=_.useRef(null),r=_.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},l=_.useCallback(()=>{i(),o(null)},[]),c=_.useCallback(m=>{i(),o({...m,id:da.nanoid()}),m.autoHide&&!r.current&&(a.current=setTimeout(()=>l(),Hs))},[l]),d=_.useCallback(m=>{i(),o(f=>f?{...f,...m}:{...m,id:da.nanoid()}),m.autoHide&&!r.current&&(a.current=setTimeout(()=>l(),Hs))},[l]),u=()=>{i(),r.current=!0},h=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>l(),Hs))};return _.useEffect(()=>()=>i(),[]),t.jsxs(Zr.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,n&&ec.createPortal(t.jsx(lm,{notification:s,onClose:l,onMouseEnter:u,onMouseLeave:h}),n)]})},um=({children:e})=>{const[n,s]=_.useState(null);return t.jsx(Is.Provider,{value:{container:n,setContainer:s},children:e})},ii=[{value:10*hr,label:"for 10 minutes"},{value:pr,label:"for 1 hour"},{value:ha,label:"for 1 day"},{value:7*ha,label:"for 7 days"},{value:0,label:"until revoked"}],mm=ii[0].value,hm="_container_1422v_1",pm="_title_1422v_7",fm="_description_1422v_14",gm="_sectionTitle_1422v_20",_m="_websiteInfo_1422v_27",xm="_favicon_1422v_37",ym="_websiteTitle_1422v_42",jm="_websiteHost_1422v_48",bm="_warningContent_1422v_54",wm="_ignoreButton_1422v_61",vm="_infoList_1422v_65",Cm="_infoItem_1422v_75",Nm="_label_1422v_84",Im="_infoValue_1422v_94",km="_durationTrigger_1422v_100",Sm="_durationItem_1422v_101",Am="_featureList_1422v_105",Tm="_featureItem_1422v_113",$m="_checkIcon_1422v_123",Em="_learnMoreLink_1422v_127",qm="_feedbackContainer_1422v_140",Lm="_footer_1422v_146",re={container:hm,title:pm,description:fm,sectionTitle:gm,websiteInfo:_m,favicon:xm,websiteTitle:ym,websiteHost:jm,warningContent:bm,ignoreButton:wm,infoList:vm,infoItem:Cm,label:Nm,infoValue:Im,durationTrigger:km,durationItem:Sm,featureList:Am,featureItem:Tm,checkIcon:$m,learnMoreLink:Em,feedbackContainer:qm,footer:Lm},Mm=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}`;return s.get(o).json()}})}),Pm=()=>{const[e,n]=_.useState(mm),[s,o]=W.useAtom(Ln),[a,r]=_.useState(!1),i=Ye(),l=de(),{address:c,username:d}=De(),{mutate:u,isPending:h}=Fc(),{closeDrawer:m}=xt();if(!s)throw new Error("Pending request not found");const{logoUrl:f,name:p,restUrl:g}=i(s.chainId),{data:x,isLoading:y}=T.useQuery(Mm.info(g,c)),b={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},C=l.some($=>{if(!$.website)return!1;const q=va(new URL($.website).hostname),V=va(window.location.hostname);return q===V}),v=()=>{u(e)},N=()=>{s?.reject(new Error("User cancelled")),o(null),m()},k=!C&&!a;return t.jsxs(t.Fragment,{children:[t.jsxs(et,{className:re.container,children:[t.jsxs("header",{children:[t.jsx("h1",{className:re.title,children:"Enable auto-signing"}),t.jsx("p",{className:re.description,children:"An application is requesting to enable auto-signing"})]}),t.jsxs("section",{children:[t.jsx("h2",{className:re.sectionTitle,children:"Requested by"}),t.jsxs("div",{className:re.websiteInfo,children:[t.jsx("img",{src:b.favicon,alt:"",className:re.favicon}),t.jsxs("div",{children:[t.jsx("div",{className:re.websiteTitle,children:b.title}),t.jsx("div",{className:re.websiteHost,children:b.hostname})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:re.sectionTitle,children:"Applies to"}),t.jsxs("div",{className:re.infoList,children:[t.jsxs("div",{className:re.infoItem,children:[t.jsx("div",{className:re.label,children:"Address"}),t.jsxs("div",{className:re.infoValue,children:[t.jsx(S.IconWallet,{size:14}),t.jsx("span",{className:"monospace",children:j.truncate(d??c)})]})]}),t.jsxs("div",{className:re.infoItem,children:[t.jsx("div",{className:re.label,children:"Chain"}),t.jsxs("div",{className:re.infoValue,children:[t.jsx(X,{src:f,width:14,height:14,logo:!0}),t.jsx("span",{children:p})]})]}),t.jsxs("div",{className:re.infoItem,children:[t.jsx("div",{className:re.label,children:"Duration"}),t.jsx(zo,{options:ii,value:e,onChange:n,classNames:{trigger:re.durationTrigger,item:re.durationItem}})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:re.sectionTitle,children:"About auto-signing"}),t.jsx("ul",{className:re.featureList,children:["Send transactions without confirmation pop-ups","Protected by Privy embedded wallet","Revoke permissions any time in settings"].map($=>t.jsxs("li",{className:re.featureItem,children:[t.jsx(S.IconCheckCircle,{size:12,className:re.checkIcon}),t.jsx("span",{children:$})]},$))}),t.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",className:re.learnMoreLink,children:["Learn more ",t.jsx(S.IconExternalLink,{size:12})]})]})]}),t.jsxs(xe,{className:re.footer,extra:t.jsxs("div",{className:re.feedbackContainer,children:[!y&&!x&&t.jsx(fe,{level:"error",children:"Insufficient balance for fee"}),!C&&!a&&t.jsx(fe,{level:"warning",children:t.jsxs("div",{className:re.warningContent,children:[t.jsx("span",{children:"You are on an unverified website"}),t.jsx("button",{onClick:()=>r(!0),className:re.ignoreButton,children:"Ignore"})]})})]}),children:[t.jsx(le.Outline,{onClick:N,children:"Cancel"}),t.jsx(le.White,{onClick:v,disabled:k||!x||y,loading:h,children:"Enable"})]})]})},Dm=()=>W.useAtomValue(Ln)?t.jsx(Pm,{}):null;function va(e){const n=e.split(".");return n.length<2?e:n.slice(-2).join(".")}const Bm="_container_mqvhs_1",Rm="_badge_mqvhs_5",Ca={container:Bm,badge:Rm},ci=e=>{const{offset:n=-4,disabled:s,children:o,className:a}=e;return t.jsxs("div",{className:L(Ca.container,a),children:[o,!s&&t.jsx("div",{className:Ca.badge,style:{right:n,top:n}})]})},Fm="_header_s7mee_1",Um="_back_s7mee_12",Om="_title_s7mee_24",Qs={header:Fm,back:Um,title:Om},dt=({title:e,backButton:n,extra:s,children:o})=>{const a=dr();return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Qs.header,children:[t.jsx(nn,{to:n??(a.length>1?-1:"/"),className:Qs.back,shouldReset:!!n,children:t.jsx(S.IconBack,{size:16})}),t.jsx("h1",{className:Qs.title,children:e}),s]}),t.jsx(et,{children:o})]})};function li(){const{initiaAddress:e,hexAddress:n}=De(),s=yt(),o=Dn();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return n;default:return""}}}function di(){const e=yt(),n=Dn();return(s,o)=>{const a=e(o);switch(n(a)){case"initia":return j.InitiaAddress.validate(s);case"evm":return pt.isAddress(s);case"cosmos":try{return ie.fromBech32(s).prefix===a.bech32_prefix}catch{return!1}default:return!1}}}function Vm(){const e=yt(),n=Dn();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),l=n(i),c=e(a),d=n(c);if(l==="evm"&&d==="initia")return j.InitiaAddress(s).bech32;if(l==="initia"&&d==="evm")return j.InitiaAddress(s).hex;if(l===d)return s;if(r){if(d==="initia")return j.InitiaAddress(r).bech32;if(d==="evm")return j.InitiaAddress(r).hex}return""}}const Km="_root_ekn9t_1",zm="_header_ekn9t_6",Wm="_title_ekn9t_12",Hm="_warning_ekn9t_18",Qm="_content_ekn9t_22",Gm="_footer_ekn9t_26",Ym="_secondary_ekn9t_36",Et={root:Km,header:zm,title:Wm,warning:Hm,content:Qm,footer:Gm,secondary:Ym},ui=e=>{const{type:n,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return t.jsxs(et,{className:Et.root,children:[t.jsxs("header",{className:L(Et.header,n&&Et[n]),children:[s,t.jsx("h1",{className:Et.title,children:o})]}),t.jsx("div",{className:Et.content,children:a}),t.jsxs("footer",{className:Et.footer,children:[t.jsx(le.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),t.jsxs("button",{className:Et.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(S.IconChevronRight,{size:14})]})]})]})},Zm="_list_k4n3k_1",Jm="_row_k4n3k_9",Xm="_dt_k4n3k_20",eh="_asset_k4n3k_26",Yn={list:Zm,row:Jm,dt:Xm,asset:eh},th=({list:e,onNavigate:n,onDismiss:s})=>{const o=ae(),a=Ye(),r=lt(o);return t.jsx(ui,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:n},secondaryButton:{label:"Do not show again",onClick:s},children:t.jsx("div",{className:Yn.list,children:e.toSorted((i,l)=>i.chainId.localeCompare(l.chainId)).map(({txHash:i,chainId:l,amount:c,denom:d})=>{const u=a(l),{decimals:h,symbol:m}=r(d),f=j.formatAmount(c,{decimals:h});return t.jsxs("div",{className:Yn.row,children:[t.jsxs("div",{className:Yn.dt,children:[t.jsx(X,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:Yn.asset,children:[f," ",m]})]},i)})})})};function Gs(e,n){return e.chainId===n.chainId&&e.txHash===n.txHash}const Zn=({chainId:e,txHash:n})=>`${oe.OP_REMINDER}:${e}:${n}`,nh=tc.atomWithStorage(oe.OP_REMINDER,[]);function dn(){const e=te(),[n=[],s]=W.useAtom(nh),o=_.useMemo(()=>n.map(c=>{const d=localStorage.getItem(Zn(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:Ge.isPast(u)}),[e,n]),a=_.useCallback((c,d)=>{n.some(u=>Gs(u,c))||(s((u=[])=>[...u,c]),localStorage.setItem(Zn(c),JSON.stringify(d)))},[n,s]),r=_.useCallback(c=>{s((d=[])=>d.filter(u=>!Gs(u,c))),localStorage.removeItem(Zn(c))},[s]),i=_.useCallback(c=>{const d=c.filter(u=>!n.some(h=>Gs(h,u)));d.length!==0&&s((u=[])=>[...u,...d])},[n,s]),l=_.useCallback((c,d)=>{localStorage.setItem(Zn(c),JSON.stringify(d)),s((u=[])=>[...u])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:l}}function mi(){const e=Ce(),{openModal:n,closeModal:s}=bs(),{reminders:o,setReminder:a}=dn();_.useEffect(()=>{const r=o.filter(c=>!c.dismissed);if(r.length===0)return;const i=()=>{const c=r.every(d=>d.chainId===r[0].chainId)?r[0].chainId:void 0;e("/op/withdrawals",{chainId:c}),l()},l=()=>{s();for(const c of r)a(c,{...c,dismissed:!0})};n({content:_.createElement(th,{list:r,onNavigate:i,onDismiss:l})})},[o,s,e,n,a])}const sh="_wrapper_5ssm8_1",oh="_balance_5ssm8_11",ah="_button_5ssm8_15",Ys={wrapper:sh,balance:oh,button:ah},hi=({onClick:e,children:n,disabled:s})=>t.jsxs("div",{className:Ys.wrapper,children:[t.jsx(S.IconWallet,{size:16}),t.jsx("span",{className:Ys.balance,children:n}),t.jsx("button",{type:"button",tabIndex:-1,className:Ys.button,onClick:()=>e(),disabled:s,children:"MAX"})]}),rh="_fieldset_up6fh_1",ih="_upper_up6fh_9",ch="_select_up6fh_14",lh="_account_up6fh_20",dh="_lower_up6fh_25",uh="_wrapper_up6fh_26",mh="_balance_up6fh_33",hh="_value_up6fh_37",ph="_error_up6fh_50",mt={fieldset:rh,upper:ih,select:ch,account:lh,lower:dh,wrapper:uh,balance:mh,value:hh,error:ph},mo=e=>{const{selectButton:n,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:l}=e;return t.jsxs("div",{className:mt.fieldset,children:[t.jsxs("div",{className:mt.upper,children:[t.jsx("div",{className:mt.select,children:n}),t.jsx("div",{className:mt.account,children:s})]}),!l&&t.jsxs("div",{className:mt.lower,children:[o,t.jsxs("div",{className:mt.wrapper,children:[t.jsx("div",{className:mt.balance,children:a}),r&&t.jsx("div",{className:mt.value,children:r})]}),i&&t.jsxs("footer",{className:mt.error,children:[t.jsx(S.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function Rn(){const e=_.useRef(null),n=Ns();return _.useEffect(()=>{n||e.current?.focus()},[n]),e}const fh="_input_h8073_1",gh={input:fh};function pi(e){const{name:n,control:s,dp:o=6,className:a,rules:r,...i}=e,l=Rn();return t.jsx(_e.Controller,{name:n,control:s,rules:r,render:({field:c})=>t.jsx(nc.NumericFormat,{value:c.value,getInputRef:Ya.mergeRefs([c.ref,l]),className:L(gh.input,a),onValueChange:d=>{c.onChange(d.value)},onBlur:c.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const _h="_input_19r9r_1",xh="_placeholder_19r9r_18",ho={input:_h,placeholder:xh},yh=({children:e})=>t.jsx("p",{className:L(ho.input,{[ho.placeholder]:B(e).isZero()}),children:e}),In=({balance:e,decimals:n,className:s})=>{const{control:o}=_e.useFormContext(),a={required:"Enter amount",validate:r=>B(r).isZero()?"Enter amount":B(j.toBaseUnit(r,{decimals:n})).gt(e??0)?"Insufficient balance":!0};return t.jsx(pi,{name:"quantity",control:o,className:L(ho.input,s),rules:a})};In.ReadOnly=yh;const rn=({title:e,content:n,children:s,className:o})=>{const[a,r]=_.useState(!1),i=()=>r(!1);return t.jsx(ei,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:n(i)})},jh="_tooltip_19kvs_1",bh="_arrow_19kvs_44",Na={tooltip:jh,arrow:bh},Fn=({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:Ot(),children:t.jsxs(J.Tooltip.Content,{className:L(Na.tooltip,{small:s}),collisionBoundary:Ot(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(J.Tooltip.Arrow,{className:Na.arrow})]})})]});function Wo(e,n){const s=Xe();return T.useQuery({queryKey:qe.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 wh(e,n,s){const{data:o={}}=Wo(e,n);return A.path([s],o)}const vh=[["d",1440*60],["h",3600],["m",60],["s",1]];function kn(e){if(!e)return;const{formattedParts:n}=vh.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 Ho(e){return e?.map(n=>{const{amount:s,origin_asset:o}=n;return`${j.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function po(e,n){const{watch:s}=St(),o=s(),a=Xe(),r=Tn(),i={...o,quantity:e},l=!o.srcChainId||!o.srcDenom||!o.dstChainId||!o.dstDenom,c=B(i.quantity||0),d=c.isFinite()&&c.gt(0),u=T.useQueryClient();return T.useQuery({queryKey:qe.route(i,n?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:h,srcDenom:m,quantity:f,dstChainId:p,dstDenom:g}=i,{decimals:x}=u.getQueryData(qe.asset(h,m).queryKey)??{decimals:0},y={amount_in:j.toBaseUnit(f,{decimals:x}),source_asset_chain_id:h,source_asset_denom:m,dest_asset_chain_id:p,dest_asset_denom:g,is_op_withdraw:n?.isOpWithdraw},b=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),b},enabled:d&&!n?.disabled&&!l,staleTime:K.MINUTE})}function Ch(e){return T.useQuery({queryKey:qe.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 Nh(){const{watch:e}=St(),{srcChainId:n,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=ze(n),i=Cn(r),l=it(s,n),c=it(a,o),d=ae(),u=de();return i==="initia"&&o===d.chainId&&l.symbol===c.symbol&&u.find(h=>h.chainId===n)?.metadata?.op_denoms?.includes(c.denom)}const Ih="_label_t93ix_1",kh="_wrapper_t93ix_7",Sh="_input_t93ix_10",Ah="_clear_t93ix_18",Jn={label:Ih,wrapper:kh,input:Sh,clear:Ah},Qo=({mode:e="onChange",myAddress:n,...s})=>{const{validate:o=j.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,l=Rn(),{control:c,getValues:d,setValue:u,formState:h}=_e.useFormContext(),m=d("recipient"),[f,p]=_.useState(m),g=rr(),{data:x,isLoading:y,error:b}=T.useQuery({queryKey:fs.address(g.restUrl,f).queryKey,queryFn:()=>g.getAddress(f),staleTime:K.MINUTE,enabled:g.validateUsername(f)}),C=x??(o(f)?f:""),v=n&&j.InitiaAddress.equals(C,n),N=async()=>{try{const q=await navigator.clipboard.readText();p(q.trim())}catch{}};_.useEffect(()=>{e==="onChange"&&(!f&&!h.dirtyFields.recipient||u("recipient",x??f,{shouldValidate:!0,shouldDirty:!0}))},[h.dirtyFields.recipient,f,e,u,x]);const k=()=>{y||b||(u("recipient",C,{shouldValidate:!0,shouldDirty:!0}),r?.())},$=()=>{if(y)return t.jsx(Jt,{level:"loading",children:"Resolving username..."});if(b)return t.jsx(Jt,{level:"error",children:b.message});if(x)return t.jsx(Jt,{level:"success",className:"monospace",children:x});if(e==="onSubmit"&&f&&!C)return t.jsx(Jt,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:Jn.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(le.Small,{type:"button",tabIndex:-1,onClick:N,children:"Paste"})]}),t.jsxs("div",{className:Jn.wrapper,children:[t.jsx(_e.Controller,{name:"recipient",control:c,rules:{required:"Recipient address is required",validate:q=>o(q)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:L(Jn.input,"monospace"),value:f,onChange:q=>p(q.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?Ya.mergeRefs([i,l]):i})}),!!f&&t.jsx("button",{type:"button",className:Jn.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:t.jsx(S.IconCloseCircleFilled,{size:16})})]}),$(),v&&t.jsx(Jt,{children:"This is my address"}),e==="onSubmit"&&t.jsx(xe,{extra:(!n||!!C&&!v)&&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:k,disabled:y||!!b||!C,children:"Apply"})})]})},Th="_scrollable_vgj3r_1",$h="_list_vgj3r_5",Eh="_item_vgj3r_9",qh="_name_vgj3r_22",Xn={scrollable:Th,list:$h,item:Eh,name:qh};function fi({onSelect:e,list:n,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:l}=s;return t.jsx(et,{className:Xn.scrollable,children:t.jsx("div",{className:Xn.list,children:n.map(c=>t.jsxs("button",{className:Xn.item,onClick:()=>e(c),disabled:i?.(c)||l?.(c),children:[t.jsx(X,{src:o(c),width:28,height:28}),t.jsx("span",{className:Xn.name,children:a(c)}),i?.(c)&&t.jsx(ct,{size:16})]},r(c)))})})}function As(){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 Lh="_account_h04x1_8",Mh="_clear_h04x1_28",Ph="_white_h04x1_39",pn={account:Lh,clear:Mh,white:Ph},Ia=({type:e})=>{const{watch:n,setValue:s}=St(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=n(),l=n(e==="src"?"sender":"recipient"),c=Cn(ze(a)),{list:d,find:u}=As(),h=u(r),m=li(),f=di(),p=m(a),g=j.InitiaAddress.equals(l,p),x=()=>t.jsx(rn,{title:"Connect wallet",content:C=>t.jsx(fi,{onSelect:async v=>{const N=v.getProvider();if(!N)return window.open(v.fallbackUrl,"_blank");const k=N.getOfflineSigner(o),[{address:$}]=await k.getAccounts();s("sender",$),s("cosmosWalletName",v.name),C()},list:d,getImage:v=>v.image,getName:v=>v.name,getKey:v=>v.name}),className:L(pn.account,{[pn.white]:!l}),children:l?t.jsxs(t.Fragment,{children:[h&&t.jsx(X,{src:h.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:j.truncate(l)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(S.IconChevronRight,{size:14})]})}),y=C=>t.jsx(rn,{title:"Recipient",content:v=>t.jsx(et,{children:t.jsx(Qo,{mode:"onSubmit",myAddress:p,chainType:c,validate:N=>f(N,a),onApply:v})}),className:pn.account,children:C}),b=()=>{switch(c){case"initia":case"evm":return g?y(t.jsx(S.IconWallet,{size:14})):t.jsxs("div",{className:pn.account,children:[t.jsx("span",{className:"monospace",children:j.truncate(l)}),t.jsx("button",{type:"button",className:pn.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:[l?t.jsx("span",{className:"monospace",children:j.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx(S.IconEdit,{size:14})]}))}};switch(e){case"src":return x();case"dst":return b()}},Dh="_images_cj4xz_1",Zs={images:Dh},Ts=({assetLogoUrl:e,assetLogoSize:n=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>t.jsxs("div",{className:L(Zs.images,r),style:{position:"relative"},children:[t.jsx(X,{src:e,width:n,height:n,className:Zs.asset,logo:!0}),t.jsx(X,{src:s,width:o,height:o,className:Zs.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),Bh="_root_6187w_1",Rh="_content_6187w_10",Fh="_details_6187w_20",Uh="_symbol_6187w_26",Oh="_chain_6187w_34",Vh="_chevron_6187w_43",qt={root:Bh,content:Rh,details:Fh,symbol:Uh,chain:Oh,chevron:Vh},gi=({asset:e,chain:n,readOnly:s})=>{const o=t.jsxs("div",{className:qt.content,children:[t.jsx(Ts,{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 Kh(e,n,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return A.any(A.includes(n.toLowerCase()),a)})}const zh="_root_1sh27_1",Wh="_label_1sh27_8",Hh="_input_1sh27_21",Qh="_hasValue_1sh27_31",Gh="_clear_1sh27_35",fn={root:zh,label:Wh,input:Hh,hasValue:Qh,clear:Gh},Un=e=>{const{rootClassName:n,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return t.jsxs("div",{className:L(fn.root,n,{[fn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[t.jsx("label",{htmlFor:"search",className:fn.label,children:t.jsx(S.IconSearch,{size:o})}),t.jsx("input",{className:fn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&t.jsx("button",{type:"button",className:fn.clear,"aria-label":"Clear search",onMouseDown:l=>l.preventDefault(),onClick:a,children:t.jsx(S.IconCloseCircleFilled,{size:o})})]})},Yh="_container_5tajg_1",Zh="_search_5tajg_7",Jh="_list_5tajg_11",Xh="_item_5tajg_15",ep="_logo_5tajg_37",tp="_info_5tajg_41",np="_symbol_5tajg_47",sp="_name_5tajg_56",op="_balance_5tajg_62",ap="_value_5tajg_69",Ve={container:Yh,search:Zh,list:Jh,item:Xh,logo:ep,info:tp,symbol:np,name:sp,balance:op,value:ap},On=e=>{const{assets:n,onSelect:s,renderAsset:o=(l,c)=>c(l)}=e,[a,r]=_.useState(""),i=Kh(["symbol"],a,n);return t.jsxs("div",{className:Ve.container,children:[t.jsx(Un,{value:a,onChange:l=>r(l.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:Ve.search,padding:20,ref:Rn()}),i.length===0?t.jsx(he,{children:"No assets"}):t.jsx("div",{className:Ve.list,children:i.map(l=>t.jsx("button",{type:"button",className:Ve.item,onClick:()=>s(l.denom),children:o(l,c=>{const{denom:d,logoUrl:u,symbol:h,name:m,balance:f,decimals:p,value:g=0}=c;return t.jsxs(t.Fragment,{children:[t.jsx(X,{src:u,width:32,height:32,className:Ve.logo,logo:!0}),t.jsxs("div",{className:Ve.info,children:[t.jsx("div",{className:Ve.symbol,children:h||d}),t.jsx("div",{className:Ve.name,children:m})]}),t.jsxs("div",{className:Ve.balance,children:[f&&t.jsx("div",{children:j.formatAmount(f,{decimals:p})}),g>0&&t.jsx("div",{className:Ve.value,children:ee(g)})]})]})})},l.denom))})]})},rp=()=>t.jsxs("div",{className:Ve.container,children:[t.jsx(Un,{rootClassName:Ve.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(he,{children:"Loading..."})]});On.Placeholder=rp;const ip="_stack_16oqn_1",cp="_title_16oqn_9",lp="_grid_16oqn_16",dp="_item_16oqn_22",up="_button_16oqn_26",mp="_active_16oqn_44",Xt={stack:ip,title:cp,grid:lp,item:dp,button:up,active:mp},Ft=({label:e,chains:n,value:s,onSelect:o,getShowIndicator:a})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:Xt.title,children:e}),t.jsx("div",{className:Xt.grid,children:n.map(({chainId:r,name:i,logoUrl:l})=>t.jsx(ci,{offset:-2,disabled:!a?.(r),className:Xt.item,children:t.jsx(Fn,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:L(Xt.button,{[Xt.active]:r===s}),onClick:()=>o(r),children:t.jsx(X,{src:l,width:28,height:28,logo:!0})})})},r))})]}),hp=({children:e})=>t.jsx("div",{className:Xt.stack,children:e});Ft.Stack=hp;const pp=({address:e,chain:n,onSelect:s})=>{const o=is(n.chain_id),{data:a={}}=Wo(e,n.chain_id);return t.jsx(On,{assets:A.sortWith([A.descend(r=>r.symbol==="INIT"),A.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>B(i).comparedTo(r)??0,A.ascend(r=>r.symbol.toLowerCase())],o.filter(r=>!r.hidden).map(r=>{const{denom:i,symbol:l=j.truncate(i),logo_uri:c}=r,d=a[i]??{};return{...r,symbol:l,decimals:r.decimals??0,logoUrl:c??"",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=kt(),i=Bn(),{watch:l,setValue:c}=St(),d=l(a),u=l(s),h=l(o),[m,f]=_.useState(u),p=ze(m),g=Vm(),x=zr(),[y,b]=A.partition(v=>x(v.chain_id),i.filter(v=>!v.hidden)),C=v=>{if(u===m&&h===v){n();return}c(s,m),c(o,v),n()};return t.jsxs(t.Fragment,{children:[t.jsxs(Ft.Stack,{children:[t.jsx(Ft,{label:"Interwoven Economy",chains:y.map(({chain_id:v,chain_name:N,pretty_name:k,logo_uri:$})=>({chainId:v,name:k||N,logoUrl:$??""})),value:m,onSelect:f}),t.jsx(Ft,{label:"Chains",chains:b.map(({chain_id:v,chain_name:N,pretty_name:k,logo_uri:$})=>({chainId:v,name:k||N,logoUrl:$??""})),value:m,onSelect:f})]}),t.jsx(me,{suspenseFallback:t.jsx(On.Placeholder,{}),children:t.jsx(pp,{address:g({initialAddress:d,initialChainId:u,chainId:m,fallbackAddress:e==="src"?r:void 0}),chain:p,onSelect:C})},m)]})},ka=({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),l=ze(r),c=it(i,r);return t.jsx(rn,{title:o,content:d=>t.jsx(fp,{type:e,afterSelect:d}),children:t.jsx(gi,{asset:{denom:c.denom,decimals:c.decimals??0,symbol:c.symbol,logoUrl:c.logo_uri??""},chain:{chainId:l.chain_id,name:l.pretty_name||l.chain_name,logoUrl:l.logo_uri??""}})})},gp="_skeleton_1l4jn_1",_p={skeleton:gp},Ut=({width:e="100%",height:n})=>t.jsx("div",{className:_p.skeleton,style:{width:e,height:n}}),xp="_stack_oq1ir_1",yp="_button_oq1ir_6",jp="_isLoading_oq1ir_19",bp="_disabled_oq1ir_19",wp="_checked_oq1ir_23",vp="_header_oq1ir_37",Cp="_title_oq1ir_43",Np="_duration_oq1ir_52",Ip="_warning_oq1ir_62",kp="_amount_oq1ir_66",Sp="_value_oq1ir_67",Oe={stack:xp,button:yp,isLoading:jp,disabled:bp,checked:wp,header:vp,title:Cp,duration:Np,warning:Ip,amount:kp,value:Sp},Ap=({children:e})=>t.jsx("div",{className:Oe.stack,children:e}),os=({label:e,query:n,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=n,{watch:l}=St(),{dstChainId:c,dstDenom:d}=l(),u=it(d,c),h=!i&&a.checked,m=!i&&!r;return t.jsxs("button",{type:"button",className:L(Oe.button,{[Oe.isLoading]:i,[Oe.disabled]:m,[Oe.checked]:h}),onClick:()=>{i||m||o(s)},children:[t.jsxs("div",{className:Oe.header,children:[t.jsxs("div",{className:Oe.title,children:[t.jsx("span",{children:e}),h&&t.jsx(S.IconCheck,{size:14})]}),i?t.jsx(Ut,{width:80,height:16}):r?t.jsxs("div",{className:L(Oe.duration,{[Oe.warning]:s==="op"}),children:[t.jsx(S.IconClockFilled,{size:12}),t.jsx("span",{children:kn(r.estimated_route_duration_seconds)})]}):t.jsx("div",{className:Oe.duration,children:"Not available"})]}),(i||r)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Oe.amount,children:i?t.jsx(Ut,{width:260,height:40}):r?j.formatAmount(r.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:Oe.value,children:i?t.jsx(Ut,{width:120,height:16}):r?r.usd_amount_out?ee(r.usd_amount_out):"$-":null})]})]})};os.Stack=Ap;const Tp="_description_nuyvt_1",$p="_presets_nuyvt_8",Ep="_preset_nuyvt_8",qp="_active_nuyvt_29",Lp="_custom_nuyvt_40",Mp="_wrapper_nuyvt_47",Pp="_percent_nuyvt_58",ot={description:Tp,presets:$p,preset:Ep,active:qp,custom:Lp,wrapper:Mp,percent:Pp},Sa=["0.1","0.5","1.0"],Dp=({afterConfirm:e})=>{const n=St(),s=n.getValues("slippagePercent"),[o,a]=_.useState(null),{control:r,watch:i,getValues:l,setValue:c}=_e.useForm({defaultValues:{value:s}}),d=i("value");_.useEffect(()=>{const g=Sa.findIndex(x=>x===s);a(g>=0?g:null)},[s]);const u=(g,x)=>{c("value",g),a(x)},h=()=>{a(null)},m=_.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=m?.type==="error",p=({value:g})=>{n.setValue("slippagePercent",g),e()};return t.jsxs(et,{children:[t.jsx("p",{className:ot.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:ot.presets,children:[Sa.map((g,x)=>t.jsxs("button",{type:"button",className:L(ot.preset,{[ot.active]:o===x}),onClick:()=>u(g,x),children:[g,"%"]},g)),o!==null?t.jsx("button",{type:"button",className:L(ot.preset,ot.custom),onClick:()=>a(null),children:"Custom"}):t.jsxs("div",{className:ot.wrapper,children:[t.jsx(pi,{name:"value",control:r,dp:2,onFocus:h,placeholder:"",className:L(ot.preset,ot.active)}),t.jsx("span",{className:ot.percent,children:"%"})]})]}),m&&t.jsx(fe,{level:m.type,children:m.text}),t.jsx(xe,{children:t.jsx(le.White,{type:"button",onClick:()=>p(l()),disabled:f,children:"Confirm"})})]})},Bp="_form_1owk5_1",Rp="_arrow_1owk5_5",Fp="_divider_1owk5_14",Up="_flip_1owk5_23",Op="_meta_1owk5_41",Vp="_row_1owk5_54",Kp="_title_1owk5_60",zp="_description_1owk5_64",Wp="_icon_1owk5_71",Hp="_edit_1owk5_76",Qp="_warning_1owk5_99",Me={form:Bp,arrow:Rp,divider:Fp,flip:Up,meta:Op,row:Vp,title:Kp,description:zp,icon:Wp,edit:Hp,warning:Qp},Gp=()=>{const e=Ce(),n=Ns(),[s,o]=Le.useLocalStorage(oe.BRIDGE_ROUTE_TYPE,"default"),{watch:a,setValue:r,handleSubmit:i,formState:l}=St(),c=a(),{srcChainId:d,srcDenom:u,dstChainId:h,dstDenom:m,quantity:f,sender:p,slippagePercent:g}=c,x=Ye(),y=ze(d),b=Cn(y),C=ze(h),v=Cn(C),N=it(u,d),k=it(m,h),{data:$}=Wo(p,d),q=wh(p,d,u),V=!q?.amount||B(q.amount).isZero(),[M]=Le.useDebounceValue(f,300),I=b!=="initia"&&v!=="initia",w=Nh(),E=po(M,{disabled:I}),U=po(M,{isOpWithdraw:!0,disabled:!w}),F=w&&s==="op",O=F?U:E,Z=F?E:U,H=F?!I:w,R=O.error&&H?Z:O,{data:P,isLoading:Ne,isFetching:je,error:tt}=R,{data:Be}=Ch(tt),Wt=M&&(Ne||je),un=()=>{r("srcChainId",h),r("srcDenom",m),r("dstChainId",d),r("dstDenom",u),r("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:Kn,closeModal:zn}=bs(),nt=i(ne=>{if(P?.warning){const{type:Tt="",message:Ms}=P.warning??{};Kn({content:t.jsx(ui,{type:"warning",icon:t.jsx(S.IconWarningFilled,{size:40}),title:hs.sentenceCase(Tt),primaryButton:{label:"Cancel",onClick:zn},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:P,values:ne}),zn()}},children:t.jsx("p",{className:Me.warning,children:Ms})})});return}e("/bridge/preview",{route:P,values:ne})}),Re=_.useMemo(()=>P?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_DEDUCTED")??[],[P]),bt=_.useMemo(()=>P?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_ADDITIONAL")??[],[P]),Ht=_.useMemo(()=>{for(const ne of bt){const Tt=$?.[ne.origin_asset.denom]?.amount??"0",Ms=P?.source_asset_denom===ne.origin_asset.denom?P.amount_in:"0";if(B(Tt).lt(B(Ms).plus(ne.amount??"0")))return`Insufficient ${ne.origin_asset.symbol} for fees`}},[$,P,bt]),Wn=_.useMemo(()=>{if(!c.sender)return"Connect wallet";if(!c.quantity||!M)return"Enter amount";if(!c.recipient)return"Enter recipient address";if(l.errors.quantity)return l.errors.quantity.message;if(!P)return"Route not found";if(Ht)return Ht},[M,Ht,l,P,c]),Wi=P?j.formatAmount(P.amount_out,{decimals:k.decimals}):"0",Hi=B(f).gt(0)&&B(f).isEqualTo(j.fromBaseUnit(q?.amount,{decimals:q?.decimals??0})),Qi=(()=>{switch(b){case"initia":return x(d).fees.fee_tokens.some(({denom:ne})=>ne===u);case"cosmos":return y.fee_assets.some(({denom:ne})=>ne===u);case"evm":return!pt.isAddress(u);default:return!1}})(),Ls=_.useCallback((ne,Tt)=>ne.length?t.jsxs("div",{className:Me.description,children:[Ho(ne),!n&&t.jsx(Fn,{label:Tt,children:t.jsx("span",{className:Me.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]}):null,[n]),Hn=B(f).gt(0)&&w&&E.data&&U.data&&U.data.estimated_route_duration_seconds>E.data.estimated_route_duration_seconds,aa=_.useMemo(()=>P?[{condition:!!P.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Ls(Re,"Fee deducted from the amount you receive"),Ls(bt,"Fee charged in addition to the amount you enter")]})},{condition:!Hn&&!!kn(P.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:Me.description,children:kn(P.estimated_route_duration_seconds)})},{condition:P.does_swap,title:"Slippage",content:t.jsxs("span",{className:Me.description,children:[t.jsxs("span",{children:[g,"%"]}),t.jsx(rn,{title:"Slippage tolerance",content:ne=>t.jsx(Dp,{afterConfirm:ne}),className:Me.edit,children:t.jsx(S.IconSettingFilled,{size:12})})]})}].filter(ne=>ne.condition):[],[bt,Re,Ls,P,Hn,g]);return t.jsxs("form",{className:Me.form,onSubmit:nt,children:[t.jsx(mo,{selectButton:t.jsx(ka,{type:"src"}),accountButton:b==="cosmos"&&t.jsx(Ia,{type:"src"}),quantityInput:t.jsx(In,{balance:q?.amount,decimals:N?.decimals}),balanceButton:t.jsx(hi,{onClick:()=>r("quantity",j.fromBaseUnit(q?.amount,{decimals:N?.decimals??0}),{shouldValidate:!0}),disabled:V,children:j.formatAmount(q?.amount??"0",{decimals:N.decimals})}),value:P?ee(P.usd_amount_in):"$-"}),t.jsxs("div",{className:Me.arrow,children:[t.jsx("div",{className:Me.divider}),t.jsx("button",{type:"button",className:Me.flip,onClick:()=>un(),children:t.jsx(S.IconChevronDown,{size:16})})]}),t.jsx(mo,{selectButton:t.jsx(ka,{type:"dst"}),accountButton:t.jsx(Ia,{type:"dst"}),quantityInput:t.jsx(In.ReadOnly,{children:Wi}),value:P?ee(P.usd_amount_out):"$-",hideNumbers:Hn}),t.jsx(Nn,{children:Hn?t.jsxs(os.Stack,{children:[t.jsx(os,{label:"Fast",query:E,value:"default",onSelect:o,checked:s==="default"}),t.jsx(os,{label:"Lossless",query:U,value:"op",onSelect:o,checked:s==="op"})]}):null}),t.jsx(xe,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(fe.Stack,{children:[P?.extra_infos?.map(ne=>t.jsx(fe,{level:"info",children:ne},ne)),Be&&t.jsx(fe,{level:"info",children:Be}),Hi&&Qi&&t.jsx(fe,{level:"warning",children:"Make sure to leave enough for transaction fee"}),P?.warning&&t.jsx(fe,{level:"warning",children:P.warning.message}),P?.extra_warnings?.map(ne=>t.jsx(fe,{level:"warning",children:ne},ne))]}),t.jsx(Nn,{children:aa.length>0&&t.jsx("div",{className:Me.meta,children:aa.map((ne,Tt)=>t.jsxs("div",{className:Me.row,children:[t.jsx("span",{className:Me.title,children:ne.title}),ne.content]},Tt))})})]}),children:t.jsx(le.White,{loading:Wt&&"Simulating...",disabled:!!Wn,children:Wn??"Preview route"})})]})},Yp=()=>{mi();const e=dr(),n=Ce(),s=kt(),o=Sl(),a=_e.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:l,dstChainId:c,srcDenom:d,dstDenom:u,quantity:h,slippagePercent:m,recipient:f}=r();r((w,{name:E})=>{(E==="srcChainId"||E==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=li(),g=p(l),x=p(c),b=di()(f,c);_.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",g)},[l,g,i]),_.useEffect(()=>{b||i("recipient",x)},[x,b,i]);const{showNotification:C}=Ss(),v=ze(l),N=ze(c),k=is(l),$=is(c),q=k.some(w=>w.denom===d),V=$.some(w=>w.denom===u);_.useEffect(()=>{k.length>0&&!q&&(i("srcDenom",k[0].denom),C({type:"info",title:`Switched to ${k[0].symbol}`,description:`The selected asset is not available on ${v.pretty_name}.`,autoHide:!0}))},[k,q,i,C,v.pretty_name]),_.useEffect(()=>{$.length>0&&!V&&(i("dstDenom",$[0].denom),C({type:"info",title:`Switched to ${$[0].symbol}`,description:`The selected asset is not available on ${N.pretty_name}.`,autoHide:!0}))},[$,V,i,C,N.pretty_name]),_.useEffect(()=>{!q||!V||(localStorage.setItem(oe.BRIDGE_SRC_CHAIN_ID,l),localStorage.setItem(oe.BRIDGE_SRC_DENOM,d),localStorage.setItem(oe.BRIDGE_DST_CHAIN_ID,c),localStorage.setItem(oe.BRIDGE_DST_DENOM,u),localStorage.setItem(oe.BRIDGE_QUANTITY,h),localStorage.setItem(oe.BRIDGE_SLIPPAGE_PERCENT,m))},[l,d,c,u,h,m,q,V]);const M=e[0].path==="/bridge",{reminders:I}=dn();return t.jsx(dt,{title:"Bridge/Swap",backButton:M?"/":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(ci,{offset:0,disabled:I.length===0,children:t.jsx(le.Small,{onClick:()=>n("/op/withdrawals"),disabled:!s,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:q&&V&&t.jsx(_e.FormProvider,{...a,children:t.jsx(me,{children:t.jsx(Gp,{})})})})},Zp="_button_1crvp_1",Jp="_checkbox_1crvp_11",Xp="_checked_1crvp_25",es={button:Zp,checkbox:Jp,checked:Xp},ef=({checked:e,onClick:n,label:s,className:o})=>t.jsxs("button",{type:"button",className:L(es.button,o),onClick:n,children:[t.jsx("div",{className:L(es.checkbox,{[es.checked]:e}),children:e&&t.jsx(S.IconCheck,{size:12})}),t.jsx("span",{className:es.label,children:s})]}),tf="_button_aoxv2_1",nf={button:tf},_i=({onClick:e,disabled:n})=>{const{ref:s,inView:o}=sc.useInView();return _.useEffect(()=>{o&&e()},[o,e]),t.jsxs("button",{className:nf.button,onClick:e,disabled:n,ref:s,children:[t.jsx("span",{children:"Load more"}),t.jsx(S.IconChevronDown,{size:12})]})};function xi(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})=>`${oe.BRIDGE_HISTORY}:${e}:${n}`,ds=100,Aa=10;function yi(){const[e,n]=Le.useLocalStorage(oe.BRIDGE_HISTORY,[]),s=_.useCallback((a,r)=>{localStorage.setItem(as(a),JSON.stringify(r));for(const i of e.slice(ds-1))localStorage.removeItem(as(i));n((i=[])=>[a,...i.slice(0,ds-1)])},[e,n]),o=_.useCallback(a=>{const r=localStorage.getItem(as(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function ji(e){return Le.useLocalStorage(as(e),null)}const zt=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 $s(){const{restUrl:e}=ae();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function sf(e){const n=$s(),{data:s}=T.useSuspenseQuery({queryKey:zt.bridge(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:K.INFINITY});return s}const Ta=20;function of(e){const n=te();return T.useSuspenseInfiniteQuery({queryKey:zt.withdrawals(e,n).queryKey,queryFn:async({pageParam:s})=>{if(!n)return[];const o={limit:Ta,offset:s,order:"desc"},{withdrawals:a}=await z.create({prefixUrl:e}).get(`withdrawals/${n}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=A.last(s)?.sequence;return s.length<Ta||!o||o<=1?null:o-1},initialPageParam:0,staleTime:K.SECOND})}function af(e){const n=$s(),{data:s}=T.useSuspenseQuery({queryKey:zt.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 rf({bridge_id:e,output_index:n}){const s=$s(),{data:o}=T.useSuspenseQuery({queryKey:zt.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 cf({bridge_id:e,sequence:n}){const o=de().find(({metadata:c})=>c?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const r=Ye()(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:l}=T.useSuspenseQuery({queryKey:zt.outputResponse(i,n).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${n}`).json(),staleTime:K.SECOND});return l}function bi(e,n){const{bridge_id:s}=e,o=$s(),{data:a}=T.useSuspenseQuery({queryKey:zt.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 gn(e){return oc.sha3_256.create().update(e).digest()}function Js(e,n){const s=new ArrayBuffer(n);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function wi(e){const{bridge_id:n,sequence:s,amount:o,from:a,to:r}=e,i=Js(n.toString(),8),l=Js(s.toString(),8),c=Js(o.amount,8),d=Dt.concatBytes(i,l,gn(Dt.utf8ToBytes(a)),gn(Dt.utf8ToBytes(r)),gn(Dt.utf8ToBytes(o.denom)),c);return gn(gn(d))}async function lf(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 df(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 fo(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(l){if(A.path(["error","code"],l)!==4902)throw l;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 jt(){return Je()}function uf(e,n){const{customFee:s,onCompleted:o}=n??{},a=Ce(),{showNotification:r,updateNotification:i,hideNotification:l}=Ss(),{addHistoryItem:c}=yi(),d=Tn(),{route:u,values:h}=jt(),{srcChainId:m,sender:f,recipient:p,cosmosWalletName:g}=h,x=jr(),{requestTxSync:y,submitTxSync:b,waitForTxConfirmation:C}=De(),{find:v}=As(),N=$n(),k=En(),$=ze(m),q=Cn($),V=Wr(m),M=T.useQueryClient(),{registryUrl:I}=Y(),w=Ye(),E=ae(),{addReminder:U}=dn(),F=Xe();return T.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const O=e.cosmos_tx.msgs.map(({msg_type_url:nt,msg:Re})=>{if(!(nt&&Re))throw new Error("Invalid transaction data");return k.fromAmino({type:sn.aminoConverters[nt].aminoType,value:JSON.parse(Re)})});if(q==="initia"){const{srcDenom:nt,quantity:Re}=h,{decimals:bt}=V(nt),Ht=s?await b({messages:O,chainId:m,fee:s}):await y({messages:O,chainId:m,internal:1,spendCoins:[{denom:nt,amount:j.toBaseUnit(Re,{decimals:bt})}]}),Wn=C({txHash:Ht,chainId:m});return{txHash:Ht,wait:Wn}}const Z=v(g)?.getProvider();if(!Z)throw new Error("Wallet not connected");const H=Z.getOfflineSignerOnlyAmino(m),R=await Ke.SigningStargateClient.connectWithSigner($.rpc,H,{registry:N,aminoTypes:k}),P=await R.getAllBalances(f),Ne=$.fee_assets.find(nt=>P.some(Re=>Re.denom===nt.denom&&B(Re.amount).gt(0)));if(!Ne){const Re=["Insufficient balance for fees.",`Available fee assets: ${$.fee_assets.map(bt=>V(bt.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Re)}const{denom:je,gas_price:tt}=Ne;if(!tt)throw new Error(`Gas price not found for ${je}`);const Be=await R.simulate(f,O,""),Wt=Ke.GasPrice.fromString(tt.average+je),un=Ke.calculateFee(Math.ceil(Be*on),Wt),Kn=await R.signAndBroadcastSync(f,O,un),zn=Tr({txHash:Kn,client:R});return{txHash:Kn,wait:zn}}if("evm_tx"in e){const{chain_id:O,to:Z,value:H,data:R}=e.evm_tx,P=await x(),Ne=await P.getSigner();await fo(P,$);const je=await Ne.sendTransaction({chainId:O,to:Z,value:H,data:`0x${R}`});return{txHash:je.hash,wait:je.wait()}}throw new Error("Unlisted chain type")}catch(O){throw await ft(O)}},onSuccess:async({txHash:O,wait:Z})=>{localStorage.removeItem(oe.BRIDGE_QUANTITY),o?o({txhash:O,chainId:m,timestamp:Date.now(),success:!0,route:u,values:h}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await Z;const H=Go(u)==="OP Bridge withdrawal",R=H?{success:!0,error:null}:await gf(F,O,m);if(!o&&!R.success&&R.error){const Be=R.error instanceof Error?R.error.message:String(R.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${Be}. The transaction may still be processing.`,autoHide:!0})}const P=R.success,je=pf({txHash:O,srcChainId:m,route:u,values:h,recipient:p},P);c(je.tx,je.details),o||i(hf(l));const tt=Xs(h,O);if(d("Bridge Transaction Success",tt),H){const Be=w(m).metadata?.op_bridge_id;if(Be&&!await lf(E.restUrl,Number(Be),u.dest_asset_denom)){const un=ff(je.tx,u,p);U(je.tx,un)}}}catch(H){const R=H instanceof Error?H.message:String(H);o?o({success:!1,error:R,route:u,values:h}):i({type:"error",title:"Transaction not confirmed",description:R});const P={...Xs(h,O),error:R};d("Bridge Confirmation Failed",P)}finally{M.invalidateQueries({queryKey:qe.balances(m,f).queryKey})}},onError:async O=>{const Z=q==="initia"?await Zt(O,w(m),I):O;o?o({success:!1,error:Z.message,route:u,values:h}):r({type:"error",title:"Transaction failed",description:Z.message});const H=Xs(h);d("Bridge Transaction Failed",{...H,error:Z.message})}})}function mf(){const e=Xe(),n=te(),s=xs(),{route:o,values:a}=jt(),r=yt();return T.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:l}=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:j.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await df(n,r(o.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:h,msg:m})=>sn.aminoTypes.fromAmino({type:sn.aminoConverters[h].aminoType,value:JSON.parse(m)})),d=await s(i,n,c,{amount:[],gas:"1"},"",{incrementSequence:i===a.srcChainId?2:0}),u=It.Tx.fromPartial({body:It.TxBody.decode(d.bodyBytes),authInfo:It.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:n,hook:ie.toBase64(It.Tx.encode(u).finish())}}catch(i){throw await ft(i)}}})}function hf(e){return{type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(nn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function Xs(e,n){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:n}}function pf(e,n){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},l=Go(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:l?"success":void 0,tracked:n},isOpWithdraw:l}}function ff(e,n,s){return{...e,recipient:j.InitiaAddress(s).bech32,claimableAt:Date.now()+n.estimated_route_duration_seconds*1e3,amount:n.amount_out,denom:n.dest_asset_denom}}async function gf(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 ft(i)};await new Promise(l=>setTimeout(l,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function vi(e){const{chainId:n,txHash:s,tracked:o}=e,a=Xe();return T.useQuery({queryKey:qe.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 ft(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:K.INFINITY,enabled:!o})}function Ci(e){const{timestamp:n,chainId:s,txHash:o,tracked:a,state:r}=e,i=Xe();return T.useQuery({queryKey:qe.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:l}})=>{if(!l)return!1;const{status:c}=l;if(c==="STATE_COMPLETED")return!1;const d=n+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),h=Math.floor((d-u)/1e3);return h<=0?1e3:h<=300?5e3:60*1e3},staleTime:K.INFINITY})}var rs=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(rs||{});function Go(e){const{operations:n,dest_asset_denom:s}=e;return A.has("op_init_transfer",A.head(n))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const _f="_success_t4dfk_1",xf="_error_t4dfk_5",$a={success:_f,error:xf},yf=({tx:e})=>{const[n,s]=ji(e);if(!n)throw new Error("Bridge history details not found");const{data:o}=Ci(n),a=n.state??jf(o);switch(_.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:$a.error,children:t.jsx(S.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:$a.success,children:t.jsx(S.IconCheckCircleFilled,{size:14})});default:return t.jsx(ct,{size:14})}};function jf(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 bf="_link_104m3_1",wf="_header_104m3_23",vf="_title_104m3_31",Cf="_date_104m3_37",Nf="_explorer_104m3_41",If="_fees_104m3_57",kf="_label_104m3_65",Sf="_content_104m3_69",Af="_route_104m3_75",Tf="_row_104m3_80",$f="_asset_104m3_86",Ef="_amount_104m3_94",qf="_chain_104m3_99",Lf="_account_104m3_108",Mf="_arrow_104m3_115",be={link:bf,header:wf,title:vf,date:Cf,explorer:Nf,fees:If,label:kf,content:Sf,route:Af,row:Tf,asset:$f,amount:Ef,chain:qf,account:Lf,arrow:Mf},Pf=({tx:e})=>{const[n,s]=ji(e);if(!n)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:l,tracked:c}=n,{data:d}=vi(n),{address:u="",connector:h}=ve.useAccount(),{find:m}=As();_.useEffect(()=>{d&&s(F=>{if(!F)throw new Error("Bridge history details not found");return{...F,tracked:!0}})},[s,d]);const{amount_in:f,amount_out:p,source_asset_chain_id:g,source_asset_denom:x,dest_asset_chain_id:y,dest_asset_denom:b,estimated_fees:C=[]}=r,v=ze(g),N=ze(y),k=it(x,g),$=it(b,y),q=(F,O)=>O?t.jsx(X,{src:O,width:12,height:12}):j.InitiaAddress.equals(F,u)?t.jsx(X,{src:h?.icon,width:12,height:12}):t.jsx(S.IconWallet,{size:12}),V=(F,{symbol:O,decimals:Z,logo_uri:H},{chain_name:R,pretty_name:P,...Ne},je,tt)=>t.jsxs("div",{className:be.row,children:[t.jsx(Ts,{assetLogoUrl:H,chainLogoUrl:Ne.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:be.asset,children:[t.jsx("span",{className:be.amount,children:j.formatAmount(F,{decimals:Z})}),t.jsx("span",{children:O})]}),t.jsxs("div",{className:be.chain,children:[t.jsxs("span",{children:["on ",P||R]}),t.jsxs("div",{className:be.account,children:[tt,t.jsx("span",{className:"monospace",children:j.truncate(je)})]})]})]})]}),M=Go(r),I=_.useMemo(()=>{switch(M){case rs.SKIP:return"Skip Explorer";case rs.OP_WITHDRAW:return"Initia Scan"}},[M]),w=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:be.header,children:[t.jsxs("div",{className:be.title,children:[c?t.jsx(yf,{tx:e}):t.jsx(ct,{size:14}),t.jsx("div",{className:be.date,children:Ge.format(new Date(l),"h:mm a")})]}),t.jsxs("div",{className:be.explorer,children:[t.jsx("span",{children:I}),t.jsx(S.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:be.route,children:[V(f,k,v,i.sender,q(i.sender,m(i.cosmosWalletName)?.image)),t.jsx("div",{className:be.arrow,children:t.jsx(S.IconArrowDown,{size:12})}),V(p,$,N,i.recipient,q(i.recipient))]}),C.length>0&&t.jsxs("div",{className:be.fees,children:[t.jsx("span",{className:be.label,children:"Fees"}),t.jsx("span",{className:be.content,children:Ho(C)})]})]});if(M===rs.OP_WITHDRAW)return t.jsx(ks,{chainId:o,txHash:a,className:be.link,children:w});const E=new URLSearchParams({tx_hash:a,chain_id:o}),U=new URL(`?${E.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:U.toString(),className:be.link,target:"_blank",children:w})},Df="_history_13u9z_1",Bf="_header_13u9z_5",Rf="_checkbox_13u9z_9",Ff="_groups_13u9z_13",Uf="_dateGroup_13u9z_21",Of="_dateHeader_13u9z_26",Vf="_list_13u9z_32",Lt={history:Df,header:Bf,checkbox:Rf,groups:Ff,dateGroup:Uf,dateHeader:Of,list:Vf},Kf=()=>{const{initiaAddress:e,hexAddress:n}=De(),{history:s,getHistoryDetails:o}=yi(),a=s.filter(f=>o(f)),r=a.filter(f=>{const p=o(f);if(!p)return!1;const{values:g}=p,{sender:x,recipient:y}=g;return[x,y].some(b=>[e,n].includes(b))}),[i,l]=_.useState(1),[c,d]=Le.useToggle(!r.length),u=c?a:r,h=u.slice(0,i*Aa),m=_.useMemo(()=>xi(h,f=>{const p=o(f);if(p)return new Date(p.timestamp)}),[h,o]);return t.jsx(dt,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:Lt.history,children:[a.length>0&&a.length!==r.length&&t.jsx("header",{className:Lt.header,children:t.jsx(ef,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:Lt.checkbox})}),u.length===0?t.jsx(he,{children:"No bridge/swap activity"}):t.jsx("div",{className:Lt.groups,children:Object.entries(m).map(([f,p])=>t.jsxs("div",{className:Lt.dateGroup,children:[t.jsx("div",{className:Lt.dateHeader,children:f}),t.jsx("div",{className:Lt.list,children:p.map(g=>t.jsx(me,{children:t.jsx(Pf,{tx:g})},g.txHash))})]},f))}),u.length>i*Aa?t.jsx(_i,{onClick:()=>l(f=>f+1)}):s.length>=ds&&t.jsxs(he,{children:["Only the latest ",ds," items are stored. Older entries will be removed automatically."]})]})})},Yo=({tx:e,fee:n,onCompleted:s,confirmMessage:o,error:a})=>{const{mutate:r,isPending:i}=uf(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"})})},zf="_content_1hzj2_1",Wf="_info_1hzj2_6",Hf="_arrow_1hzj2_11",Qf="_divider_1hzj2_19",Gf="_type_1hzj2_27",Yf="_asset_1hzj2_47",Zf="_amount_1hzj2_55",Jf="_lower_1hzj2_60",Xf="_chain_1hzj2_66",eg="_address_1hzj2_72",Ue={content:zf,info:Wf,arrow:Hf,divider:Qf,type:Gf,asset:Yf,amount:Zf,lower:Jf,chain:Xf,address:eg},Ni=e=>{const{source:n,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:l}=e,{symbol:c=j.truncate(a),decimals:d=0,logo_uri:u=No}=e,{chain_name:h,pretty_name:m,...f}=ze(r);return t.jsxs("div",{children:[!n&&t.jsxs("div",{className:Ue.arrow,children:[t.jsx("div",{className:Ue.divider}),s?t.jsx(Fn,{label:s,children:t.jsx("button",{className:Ue.type,children:t.jsx(S.IconArrowDown,{size:12})})}):t.jsx("span",{className:Ue.type,children:t.jsx(S.IconArrowDown,{size:12})}),t.jsx("div",{className:Ue.divider})]}),t.jsxs("div",{className:Ue.content,children:[t.jsx(Ts,{assetLogoUrl:u,chainLogoUrl:f.logo_uri??void 0}),t.jsxs("div",{className:Ue.info,children:[t.jsxs("div",{className:Ue.asset,children:[t.jsx("span",{className:Ue.amount,children:j.formatAmount(o,{decimals:d})}),t.jsx("span",{children:c})]}),t.jsxs("div",{className:Ue.lower,children:[t.jsxs("div",{className:Ue.chain,children:["on ",m||h]}),i&&t.jsx(cs,{value:i,children:({copy:p,copied:g})=>t.jsxs("button",{className:Ue.address,onClick:p,children:[l,g?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:j.truncate(i)})]})})]})]})]})]})},en=e=>{const n=it(e.denom,e.chainId);return t.jsx(Ni,{...e,...n})};en.Placeholder=Ni;const tg="_root_1hbar_1",ng="_flexEnd_1hbar_6",sg="_toggle_1hbar_11",og="_route_1hbar_36",ag="_content_1hbar_43",_n={root:tg,flexEnd:ng,toggle:sg,route:og,content:ag};function rg(e){const n=({name:s})=>s==="initia-dex"?"Initia DEX":hs.capitalCase(A.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 ig=({addressList:e})=>{const{values:n,route:s}=jt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,l=A.zipObj(s.required_chain_addresses,e),{find:c}=As(),{connector:d,address:u=""}=ve.useAccount(),[h,m]=Le.useToggle(!1),f=i.length>1,p=t.jsx(X,{src:n.cosmosWalletName?c(n.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:r,denom:o,chainId:a,address:n.sender,walletIcon:p},x=N=>j.InitiaAddress.equals(N,u)?p:t.jsx(S.IconWallet,{size:11}),y=N=>{const{label:k,amount_out:$,denom:q,denom_out:V=q,chain_id:M,from_chain_id:I,to_chain_id:w=M??I}=N,E=l[w];return{label:f&&!h?void 0:k,amount:$,denom:V,chainId:w,address:E,walletIcon:x(E)}},b=i.map(rg).map(y),C=b.slice(0,-1),v=b[b.length-1];return t.jsxs(J.Collapsible.Root,{className:_n.root,open:h,onOpenChange:m,children:[f&&t.jsx("div",{className:_n.flexEnd,children:t.jsx(J.Collapsible.Trigger,{className:_n.toggle,children:h?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:_n.route,children:[t.jsx(en,{...g,source:!0}),t.jsx(J.Collapsible.Content,{className:_n.content,children:C.map((N,k)=>t.jsx(me,{suspenseFallback:t.jsx(en.Placeholder,{...N}),errorBoundaryProps:{fallback:t.jsx(en.Placeholder,{...N})},children:t.jsx(en,{...N})},k))}),t.jsx(en,{...v})]})]})},Ii=({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"})})},ki=({children:e})=>{const n=jt(),{route:s,values:o}=n,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:l,recipient:c}=o,{initiaAddress:d,hexAddress:u}=De(),h=qn(),m=yt(),f=Dn(),p=m(r),g=f(p),x=a.slice(0,-1).some($=>{const q=m($);return f(q)==="cosmos"})&&g!=="cosmos",[y,b]=_.useState(void 0),[C,v]=_.useState(!1),[N,k]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!x)return;if(!h)throw new Error("Wallet not connected");v(!0),k(null);const[{pubkey:q}]=await h.getAccounts();b(q)}catch(q){k(await ft(q))}finally{v(!1)}})()},[x,h]),N)return t.jsx(Ii,{error:N});if(C)return t.jsx(xe,{children:t.jsx(le.White,{loading:C&&"Generating intermediary addresses..."})});if(!x||y){const $=a.map((q,V)=>{if(V===a.length-1){const U=m(i);return f(U)==="initia"?j.InitiaAddress(c).bech32:c}const M=m(q),I=f(M),w=m(r),E=f(w);switch(I){case"initia":return d;case"evm":return u;case"cosmos":{if(E==="cosmos")return ie.toBech32(M.bech32_prefix,ie.fromBech32(l).data);if(!y)throw new Error("Pubkey not found");return jn.pubkeyToAddress(jn.encodeSecp256k1Pubkey(y),M.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e($)}return null},Zo=({tx:e,children:n})=>{const s=jr(),o=yt(),{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:u,signer_address:h}=e.evm_tx,m=await s();await fo(m,o(u));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:x,spender:y}=g,C=await new pt.ethers.Contract(x,f,m).allowance(h,y);return{approval:g,currentAllowance:BigInt(C.toString())}}))).filter(({approval:g,currentAllowance:x})=>x<BigInt(g.amount)).map(({approval:g})=>g)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:l,isPending:c,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:u}=e.evm_tx,h=await s(),m=await h.getSigner();await fo(h,o(u));for(const f of a){const{token_contract:p,spender:g,amount:x}=f,y=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new pt.ethers.Contract(p,y,m).approve(g,x)).wait()}return!0}catch(u){throw await ft(u)}}});return r?t.jsx(xe,{children:t.jsx(le.White,{loading:"Checking approvals..."})}):a&&a.length>0&&!l?t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:d?.message}),children:t.jsx(le.White,{onClick:()=>i(),loading:c&&"Approving tokens...",children:"Approve tokens"})}):n},Si=({addressList:e,signedOpHook:n,children:s})=>{const o=Xe(),{route:a,values:r}=jt(),[i,l]=_.useState(void 0),[c,d]=_.useState(!1),[u,h]=_.useState(null);return _.useEffect(()=>{(async()=>{try{if(a.required_op_hook&&!n)throw new Error("Op hook is required");d(!0),h(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;l(g)}catch(f){h(f)}finally{d(!1)}})()},[a,r,JSON.stringify(e),n,o]),u?t.jsx(Ii,{error:u}):c||!i?t.jsx(xe,{children:t.jsx(le.White,{loading:"Fetching messages..."})}):s(i)},Ai=({children:e})=>{const{route:n}=jt(),s=mf();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)},cg=()=>t.jsx(dt,{title:"Route preview",children:t.jsx(ki,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(ig,{addressList:e}),t.jsx(Ai,{children:n=>t.jsx(Si,{addressList:e,signedOpHook:n,children:s=>t.jsx(Zo,{tx:s,children:t.jsx(Yo,{tx:s})})})})]})})}),Ti=_.createContext(null);function Es(){return _.useContext(Ti)}const lg="_button_17r1o_1",dg="_claimed_17r1o_24",Ea={button:lg,claimed:dg},ug=()=>{const{withdrawalTx:e}=Es(),{bridge_id:n,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:l,to:c,version:d}=e,u=ae(),h=te(),{requestTxSync:m,waitForTxConfirmation:f}=De(),p=cf(e),g=ie.toBase64(wi(e)),x=bi(e,g),y=T.useQueryClient(),{mutate:b,isPending:C}=T.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:v}=p;return m({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:h,bridgeId:BigInt(n),outputIndex:BigInt(a),withdrawalProofs:r.map(ie.fromBase64),from:l,to:c,sequence:BigInt(s),amount:o,version:ie.fromBase64(d),storageRoot:ie.fromBase64(i),lastBlockHash:ie.fromBase64(v)}}],internal:!0})},onSuccess:async v=>{await f({chainId:u.chain_id,txHash:v}),y.invalidateQueries({queryKey:zt.withdrawalClaimed(n,g).queryKey})}});return x?t.jsxs("div",{className:Ea.claimed,children:[t.jsx(S.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:Ea.button,onClick:()=>b(),disabled:C,children:"Claim"})},mg=({children:e})=>{const{withdrawalTx:n}=Es(),s=sf(n.bridge_id),o=rf(n),a=_.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Ge.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},$i=1e3,hg=60,pg=60,fg=24,go=$i*hg,_o=go*pg,qa=_o*fg,gg=({date:e})=>{const n=_.useCallback(()=>{const d=new Date().getTime(),h=e.getTime()-d;if(h<=0)return{days:0,hours:0,minutes:0,seconds:0};const m=Math.floor(h/qa),f=Math.floor(h%qa/_o),p=Math.floor(h%_o/go),g=Math.floor(h%go/$i);return{days:m,hours:f,minutes:p,seconds:g}},[e]),[s,o]=_.useState(n());_.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:l,seconds:c}=s;return t.jsx(Fn,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(l),"m ",a(c),"s"]})})},_g="_container_1lz3w_1",xg="_title_1lz3w_5",La={container:_g,title:xg},yg=({date:e})=>t.jsxs("div",{className:La.container,children:[t.jsx("div",{className:La.title,children:"Claimable in"}),t.jsx(gg,{date:e})]}),jg="_container_1oldz_1",bg="_icon_1oldz_7",Ma={container:jg,icon:bg},wg="Withdrawal will begin within an hour",Pa=()=>{const e=Ns();return t.jsxs("div",{className:Ma.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Fn,{label:wg,children:t.jsx("span",{className:Ma.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]})},vg=({children:e})=>{const{withdrawalTx:n}=Es(),s=af(n.bridge_id),o=n.output_index>Number(s?.output_index);return e(o)},Cg=({date:e,children:n})=>{const{chainId:s,withdrawalTx:o}=Es(),a=ie.toBase64(wi(o)),r=bi(o,a),{setReminder:i,removeReminder:l}=dn();return _.useEffect(()=>{const c={chainId:s,txHash:o.tx_hash};r?l(c):i(c,{...c,recipient:o.to,claimableAt:e.getTime(),amount:o.amount.amount,denom:o.amount.denom,dismissed:Ge.isPast(e.getTime())?!0:void 0})},[s,r,e,l,i,o]),n},Ng=()=>t.jsx(vg,{children:e=>e?t.jsx(Pa,{}):t.jsx(mg,{children:n=>n?t.jsx(Cg,{date:n,children:Ge.isFuture(n)?t.jsx(yg,{date:n}):t.jsx(ug,{})}):t.jsx(Pa,{})})}),Ig="_asset_6h8u2_1",kg="_info_6h8u2_7",Sg="_symbol_6h8u2_11",eo={asset:Ig,info:kg,symbol:Sg},Ag=({amount:e,denom:n})=>{const s=ae(),o=sr(n,s),{symbol:a,logoUrl:r,decimals:i}=o;return t.jsxs("div",{className:eo.asset,children:[t.jsx(X,{src:r,width:32,height:32,logo:!0}),t.jsxs("div",{className:eo.info,children:[t.jsx("span",{className:"monospace",children:j.formatAmount(e,{decimals:i})}),t.jsx("span",{className:eo.symbol,children:a})]})]})},Tg="_item_km5w2_1",$g={item:Tg},Eg=({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}=of(n),i=_.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:l}=dn();return _.useEffect(()=>{const c=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));l(c)},[e.chainId,i,l]),i.length?t.jsxs(t.Fragment,{children:[i.map(c=>{const{amount:d}=c;return t.jsxs("div",{className:$g.item,children:[t.jsx(Ag,{...d}),t.jsx(me,{suspenseFallback:null,children:t.jsx(Ti.Provider,{value:{chainId:e.chainId,withdrawalTx:c},children:t.jsx(Ng,{})})})]},c.sequence)}),a&&t.jsx(_i,{onClick:()=>o(),disabled:r})]}):t.jsx(he,{children:"No withdrawals"})},qg="_content_dj1qm_1",Lg="_title_dj1qm_5",Da={content:qg,title:Lg},Mg=()=>{const{chainId:e}=Je(),n=de(),s=Vt(),[o,a]=_.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=Ye(),{reminders:i}=dn(),l=o?r(o):void 0;return t.jsxs(dt,{title:"OP Bridge withdrawals",children:[t.jsx(Ft,{chains:n.filter(({metadata:c})=>!c?.is_l1&&c?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:c=>i.some(d=>d.chainId===c)}),t.jsx("div",{className:Da.content,children:l?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:Da.title,children:l.name}),t.jsx(me,{children:t.jsx(Eg,{chain:l})},o)]}):t.jsx(fe,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},us=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),Pg="5722e7dffb709492cf5312446ceeff73",Dg=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${Pg}`,Ei=["walletconnect-wallets"],Bg=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",qi=async e=>{const n=await z.get(Dg,{signal:e}).json(),s=n!==null&&typeof n=="object"&&"listings"in n?n.listings:n;return Object.values(s??{}).filter(Bg)},Rg=()=>T.useQuery({queryKey:Ei,queryFn:({signal:e})=>qi(e),staleTime:K.INFINITY,gcTime:K.INFINITY,retry:2}),Fg="_page_13y8q_1",Ug="_pageTop_13y8q_19",Og="_backButtonFixed_13y8q_63",Vg="_listItem_13y8q_64",Kg="_socialButton_13y8q_65",zg="_arrowIcon_13y8q_66",Wg="_searchInputUnderline_13y8q_67",Hg="_header_13y8q_72",Qg="_title_13y8q_81",Gg="_headerSpacer_13y8q_116",Yg="_icon_13y8q_120",Zg="_installedText_13y8q_124",Jg="_divider_13y8q_131",Xg="_dividerText_13y8q_152",e_="_loading_13y8q_193",t_="_socialIcons_13y8q_198",n_="_socialText_13y8q_204",s_="_searchWrapper_13y8q_214",o_="_scrollable_13y8q_248",a_="_list_13y8q_64",r_="_listIconWrapper_13y8q_332",i_="_moreIconSmall_13y8q_342",c_="_externalLinkIcon_13y8q_364",l_="_listName_13y8q_368",d_="_listNameMuted_13y8q_381",u_="_recentBadge_13y8q_394",m_="_learnMoreLink_13y8q_408",D={page:Fg,pageTop:Ug,backButtonFixed:Og,listItem:Vg,socialButton:Kg,arrowIcon:zg,searchInputUnderline:Wg,header:Hg,title:Qg,headerSpacer:Gg,icon:Yg,installedText:Zg,divider:Jg,dividerText:Xg,loading:e_,socialIcons:t_,socialText:n_,searchWrapper:s_,scrollable:o_,list:a_,listIconWrapper:r_,moreIconSmall:i_,externalLinkIcon:c_,listName:l_,listNameMuted:d_,recentBadge:u_,learnMoreLink:m_},h_=e=>{try{const n=new URL(e.trim());return n.protocol==="https:"&&!n.username&&!n.password}catch{return!1}},p_=({walletConnectors:e,isPending:n,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,l]=_.useState(""),{data:c=[],isError:d,isLoading:u,isFetching:h}=Rg(),m=u||h&&c.length===0,f=_.useMemo(()=>{if(!i)return e;const g=i.toLowerCase();return e.filter(x=>x.name.toLowerCase().includes(g))},[e,i]),p=_.useMemo(()=>{const g=new Set(e.map(y=>us(y.name))),x=i.toLowerCase();return c.filter(y=>!g.has(us(y.name))).filter(y=>!i||y.name.toLowerCase().includes(x)).sort((y,b)=>y.name.localeCompare(b.name))},[c,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(Un,{rootClassName:D.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:g=>l(g.target.value),onClear:()=>l("")})}),t.jsx(et,{className:D.scrollable,children:t.jsxs("div",{className:D.list,children:[f.map(g=>{const{name:x,icon:y,id:b}=g,C=o===b,v=s===b,N="ready"in g?!!g.ready:!0;return t.jsxs("button",{type:"button",className:L(D.listItem,{[D.loading]:v}),onClick:()=>a(g),disabled:n||!N,"aria-busy":v,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(X,{src:y,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listName,children:x}),v?t.jsx(ct,{size:16}):C?t.jsx("span",{className:D.recentBadge,children:"Recent"}):N?t.jsx("span",{className:D.installedText,children:"Installed"}):null]},`connector:${b}`)}),m&&t.jsxs("div",{className:L(D.listItem,D.loading),role:"status","aria-live":"polite",children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(ct,{size:16})}),t.jsx("span",{className:D.listNameMuted,children:"Loading more wallets..."})]}),p.map(g=>{const x=g.image_url?.sm||g.image_url?.md||g.image_url?.lg,y=x&&h_(x)?x: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(X,{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."})]})})]})},f_=()=>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"})]}),g_=()=>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"})]}),__=()=>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"})}),x_=()=>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"})]}),y_=[{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"}],j_=({walletConnectors:e,privyConnector:n,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:l})=>{const c=e.filter(p=>!("ready"in p)||!!p.ready),d=c.slice(0,5),u=new Set(c.map(p=>p.id)),h=new Set(c.map(p=>us(p.name))),m=Math.max(0,5-d.length),f=y_.filter(p=>!u.has(p.id)&&!h.has(us(p.name))).slice(0,m);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:L(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(ct,{size:16}):t.jsxs("div",{className:D.socialIcons,children:[t.jsx(g_,{}),t.jsx(x_,{}),t.jsx(__,{})]})]}),t.jsx("div",{className:D.divider,children:t.jsx("span",{className:D.dividerText,children:"or"})})]}),t.jsx(et,{className:D.scrollable,children:t.jsxs("div",{className:D.list,children:[d.map(p=>{const{name:g,icon:x,id:y}=p,b=o===y,C=a===y;return t.jsxs("button",{type:"button",className:L(D.listItem,{[D.loading]:b}),onClick:()=>r(p),disabled:s,"aria-busy":b,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(X,{src:x,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listName,children:g}),b?t.jsx(ct,{size:16}):C?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(X,{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:l,onFocus:l,disabled:s,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx("div",{className:D.moreIconSmall,children:t.jsx(f_,{})})}),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"})]})]})},Ba=({onSuccess:e})=>{const{connectors:n,connectAsync:s}=ve.useConnect(),o=Le.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=_.useState(null),[i,l]=_.useState("signin"),c=T.useQueryClient(),d=()=>c.prefetchQuery({queryKey:Ei,queryFn:({signal:g})=>qi(g),staleTime:K.INFINITY,gcTime:K.INFINITY}),{mutate:u,isPending:h}=T.useMutation({mutationFn:async g=>{try{await s({connector:g})}catch(x){throw await ft(x)}},onMutate:g=>{r(g.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),m=_.useMemo(()=>[...n].sort((g,x)=>g.id===o?-1:x.id===o?1:g.name.localeCompare(x.name)),[n,o]),f=_.useMemo(()=>m.find(g=>g.id===bn.id),[m]),p=_.useMemo(()=>m.filter(g=>g.id!==bn.id),[m]);return i==="all"?t.jsx(p_,{walletConnectors:p,isPending:h,pendingConnectorId:a,recentConnectorId:o,onConnect:u,onBack:()=>l("signin")}):t.jsx(j_,{walletConnectors:p,privyConnector:f,isPending:h,pendingConnectorId:a,recentConnectorId:o,onConnect:u,onShowAll:()=>l("all"),onPrefetchWallets:d})},b_={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 Vn(e){return b_[e]}function Jo(){const e=Xe(),n=ln(),s=te(),o=Bn(),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:qe.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:l}])=>[i,l||{}])):{},enabled:!!s,staleTime:K.SECOND})}function Xo(){const{localOptions:e=[]}=Je();return Kt().filter(({denom:s,chain_id:o})=>e.some(a=>a.denom===s&&a.chainId===o))}function ea(e){const{local:n}=Vn(e),s=Kt(),{watch:o}=At(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:l,chain_id:c})=>i===l&&c===r)||null}function w_(e){const{external:n}=Vn(e),s=Kt(),{watch:o}=At(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:l,chain_id:c})=>i===l&&c===r)||null}function v_(e){const n=Kt(),s=yt(),{data:o,isLoading:a}=Jo(),{remoteOptions:r=[]}=Je(),i=ea(e);return i?{data:n.filter(({symbol:c,denom:d,chain_id:u})=>r.length?r.some(h=>h.denom===d&&h.chainId===u):c===i.symbol).map(c=>{if(c.hidden||c.chain_id===i.chain_id)return null;const d=s(c.chain_id);if(!d||d.chain_type==="cosmos"&&d.bech32_prefix!=="init")return null;const u=o?.[d.chain_id]?.[c.denom];return e==="deposit"&&(!u||!Number(u.amount))?null:{asset:c,chain:d,balance:u}}).filter(c=>c!==null),isLoading:a}:{data:[],isLoading:a}}function At(){return _e.useFormContext()}const C_="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",N_="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",I_="_container_uxgnj_1",k_="_title_uxgnj_5",S_="_close_uxgnj_12",A_="_emptyIcon_uxgnj_24",T_="_empty_uxgnj_24",$_="_list_uxgnj_51",E_="_asset_uxgnj_66",q_="_placeholder_uxgnj_82",L_="_activeAsset_uxgnj_95",M_="_iconContainer_uxgnj_99",P_="_assetIcon_uxgnj_109",D_="_chainIcon_uxgnj_119",B_="_assetPlaceholder_uxgnj_133",R_="_assetName_uxgnj_154",F_="_assetChain_uxgnj_169",U_="_balance_uxgnj_177",O_="_value_uxgnj_186",ue={container:I_,title:k_,close:S_,emptyIcon:A_,empty:T_,list:$_,asset:E_,placeholder:q_,activeAsset:L_,iconContainer:M_,assetIcon:P_,chainIcon:D_,assetPlaceholder:B_,assetName:R_,assetChain:F_,balance:U_,value:O_},V_=({mode:e})=>{const{external:n}=Vn(e),{data:s,isLoading:o}=v_(e),{setValue:a,watch:r}=At(),i=ea(e),l=Xo(),{theme:c}=Y(),d=r(),u=d[n.denomKey],h=d[n.chainIdKey];function m(){const f=u&&h;return!f&&l.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:[m(),t.jsx("h4",{className:ue.title,children:"No available assets"}),t.jsx("img",{src:c==="dark"?C_:N_,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:[m(),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:L(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 x=u===f.denom&&h===p.chain_id;return t.jsxs("button",{className:L(ue.asset,x&&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," ",x&&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:j.formatAmount(g.amount,{decimals:g.decimals||6})}),t.jsx("p",{className:ue.value,children:ee(g.value_usd||0)})]})]},`${f.chain_id}-${f.denom}`)})]})]}):t.jsx("div",{children:"No assets found"})},K_="_title_9ovji_1",z_="_list_9ovji_7",W_="_asset_9ovji_15",to={title:K_,list:z_,asset:W_},H_=({mode:e})=>{const{local:n,external:s}=Vn(e),{setValue:o}=At(),a=Xo(),r=(l,c)=>{o(n.denomKey,l),o(n.chainIdKey,c),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),o("page",e==="withdraw"?"fields":"select-external")},i=_.useEffectEvent(()=>{const{denom:l,chain_id:c}=a[0];r(l,c)});return _.useEffect(()=>{a.length===1&&i()},[a]),a.length?t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:to.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),t.jsx("div",{className:to.list,children:a.map(({denom:l,chain_id:c,symbol:d,logo_uri:u})=>t.jsxs("button",{className:to.asset,onClick:()=>r(l,c),children:[t.jsx("img",{src:u,alt:d}),d]},`${l}-${c}`))})]}):t.jsx("div",{children:"No assets found"})},Q_="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",G_="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",Y_="_container_9k4hs_1",Z_="_title_9k4hs_8",J_="_subtitle_9k4hs_14",X_="_linkContainer_9k4hs_30",ex="_link_9k4hs_30",tx="_separator_9k4hs_51",nx="_errorIcon_9k4hs_62",sx="_error_9k4hs_62",we={container:Y_,title:Z_,subtitle:J_,linkContainer:X_,link:ex,separator:tx,errorIcon:nx,error:sx};function ox(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 xo({type:e}){const{closeModal:n}=cn(),{theme:s}=Y(),{watch:o}=At(),{result:a}=o(),{openDrawer:r}=xt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,l=i?"":a.txhash,c=i?"":a.chainId,d=i?0:a.timestamp??0,{route:u,values:h}=a,{srcDenom:m,srcChainId:f,quantity:p}=h,g=it(m,f),x=e==="deposit"?"Deposit":"Withdraw",{data:y}=vi({chainId:c,txHash:l,tracked:!1}),{data:b}=Ci({chainId:c,txHash:l,tracked:!!y,timestamp:d,route:u}),C=ox(b),v=s==="dark"?Q_:G_,N=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,k=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return t.jsxs("div",{className:we.container,children:[t.jsxs("h3",{className:we.title,children:[x," failed"]}),t.jsx("img",{src:v,alt:"Failed",className:we.errorIcon}),t.jsx("p",{className:we.error,children:a?.error}),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]});const $=kn(u.estimated_route_duration_seconds),q=new URLSearchParams({tx_hash:l,chain_id:c}),V=new URL(`?${q.toString()}`,"https://explorer.skip.build"),M=()=>t.jsxs("div",{className:we.linkContainer,children:[t.jsx("a",{href:V.toString(),target:"_blank",rel:"noopener noreferrer",className:we.link,children:"View transaction"}),t.jsx("div",{className:we.separator}),t.jsx("button",{className:we.link,onClick:()=>{n(),r("/bridge/history")},children:"Go to history"})]});return t.jsxs("div",{className:we.container,children:[C==="pending"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:we.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",p," ",g.symbol]}),t.jsx("video",{src:N,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),t.jsxs("p",{className:we.subtitle,children:["Estimated time: ",t.jsx("span",{children:$})]}),M(),t.jsx("p",{className:we.subtitle,children:"Your transaction will continue even if you close this"})]}),C==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:we.title,children:[x," complete"]}),t.jsx("video",{src:k,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:I=>{const w=I.currentTarget;w.duration-w.currentTime<.1&&w.pause()}}),M(),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]}),C==="failed"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:we.title,children:[x," failed"]}),t.jsx("img",{src:v,alt:"Failed",className:we.errorIcon}),t.jsx("p",{className:we.error,children:"Your transaction could not be completed"}),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]})]})}const ax=ye.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),rx=({tx:e,children:n})=>{const{values:s}=jt(),{srcChainId:o}=s,a=te(),r=En(),i=$o(),{data:l,isLoading:c}=T.useQuery({queryKey:ax.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const u=e.cosmos_tx.msgs.map(({msg_type_url:f,msg:p})=>{if(!(f&&p))throw new Error("Invalid transaction data");return r.fromAmino({type:sn.aminoConverters[f].aminoType,value:JSON.parse(p)})});return{estimatedGas:await(await i(o)).simulate(a,u,""),messages:u}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if(c)return t.jsx(xe,{children:t.jsx(le.White,{loading:"Estimating gas..."})});const d=l?.estimatedGas??null;return t.jsx(t.Fragment,{children:n(d)})},ix="_container_eg177_1",cx="_back_eg177_6",lx="_title_eg177_18",dx="_divider_eg177_26",ux="_label_eg177_30",mx="_asset_eg177_37",hx="_assetIcon_eg177_55",px="_chainIcon_eg177_67",fx="_assetName_eg177_80",gx="_chevron_eg177_92",_x="_input_eg177_96",xx="_balanceContainer_eg177_108",yx="_value_eg177_116",jx="_maxButton_eg177_126",bx="_detail_eg177_142",wx="_detailsContainer_eg177_153",vx="_detailsButton_eg177_163",Cx="_detailValue_eg177_180",Nx="_detailToken_eg177_190",Ix="_minimumReceived_eg177_198",Q={container:ix,back:cx,title:lx,divider:dx,label:ux,asset:mx,assetIcon:hx,chainIcon:px,assetName:fx,chevron:gx,input:_x,balanceContainer:xx,value:yx,maxButton:jx,detail:bx,detailsContainer:wx,detailsButton:vx,detailValue:Cx,detailToken:Nx,minimumReceived:Ix},Li=({renderFee:e})=>{const{route:n}=Je(),{values:s}=jt(),{dstDenom:o,dstChainId:a}=s,i=Kt().find(({denom:f,chain_id:p})=>f===o&&p===a),l=te(),c=Jr(),[d,u]=Le.useToggle(!1),h=n&&n.estimated_route_duration_seconds>60;if(!n||!i)return null;const m=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(Nn,{children:t.jsxs("div",{className:Q.detailsContainer,children:[t.jsxs("button",{className:Q.detailsButton,onClick:u,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:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Slippage"}),t.jsxs("p",{className:Q.detailValue,children:[s.slippagePercent,"%"]})]}),!!n.estimated_fees?.length&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Bridge fee"}),t.jsx("div",{className:Q.detailValue,children:Ho(n.estimated_fees)})]}),e&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Tx fee"}),t.jsx("div",{className:Q.detailValue,children:e()})]}),l&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Receiving address"}),t.jsxs("p",{className:Q.detailValue,children:[t.jsx("img",{src:c,alt:"Wallet",height:12,width:12})," ",j.truncate(l)]})]})]}),t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Estimated time"}),t.jsx("p",{className:L(Q.detailValue),style:h?{color:"var(--warning)"}:void 0,children:kn(n.estimated_route_duration_seconds)})]}),t.jsxs("div",{className:L(Q.detail,Q.minimumReceived),children:[t.jsx("p",{className:Q.detailLabel,children:"Minimum received"}),t.jsxs("p",{className:Q.detailValue,children:[t.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Q.detailToken})," ",j.formatAmount(m,{decimals:i.decimals})," ",i.symbol]})]})]})})},kx="_trigger_1c7d7_1",Sx="_item_1c7d7_5",Ax="_itemText_1c7d7_13",Tx={trigger:kx,item:Sx,itemText:Ax},$x=({tx:e,gas:n,confirmMessage:s,onCompleted:o})=>{const{values:a}=jt(),{srcChainId:r,srcDenom:i,quantity:l}=a,d=Kt().find(({denom:I,chain_id:w})=>I===i&&w===r),u=Ze(r),h=An(u),m=Vo(u),f=Ko(u),p=lt(u),g=m.map(({amount:I,denom:w})=>Ke.calculateFee(Math.ceil(n*on),Ke.GasPrice.fromString(I+w))),x=g.map(I=>I.amount[0]),y=I=>{const w=h.find(R=>R.denom===I)?.amount??"0",E=x.find(R=>R.denom===I)?.amount??"0",U=d&&i===I?B(l||"0").times(B(10).pow(d.decimals)).toFixed(0):"0",F=B(E).plus(U),O=B(w).gte(F),{symbol:Z,decimals:H}=p(I);return{symbol:Z,decimals:H,spend:B(U).gt(0)?U:null,fee:E,total:F.toFixed(),balance:w,isSufficient:O}},b=()=>{if(!x.length)return null;if(f&&y(f).isSufficient)return f;for(const{denom:I}of x)if(y(I).isSufficient)return I;return x[0]?.denom},[C,v]=_.useState(b),N=g.find(I=>I.amount[0].denom===C)??void 0,k=C?y(C):null,$=k&&!k.isSufficient?"Insufficient balance":void 0,q=(I,w)=>{if(j.formatAmount(I,{decimals:w})==="0.000000")return 8},V=I=>{const[{amount:w,denom:E}]=I.amount;if(B(w).isZero())return"0";const{symbol:U,decimals:F}=p(E),O=q(w,F);return`${j.formatAmount(w,{decimals:F,dp:O})} ${U}`},M=()=>{if(g.length===0)return null;if(g.length===1)return t.jsx("span",{className:"monospace",children:V(g[0])});if(!N||!C)return null;const I=g.map(O=>{const[{denom:Z}]=O.amount,{symbol:H}=p(Z);return{value:Z,label:V(O),triggerLabel:H}}),[{amount:w,denom:E}]=N.amount,{decimals:U}=p(E),F=q(w,U);return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{className:"monospace",children:j.formatAmount(w,{decimals:U,dp:F})}),t.jsx(zo,{options:I,value:C,onChange:v,classNames:Tx})]})};return t.jsxs(t.Fragment,{children:[t.jsx(Li,{renderFee:g.length>0?M:void 0}),t.jsx(Zo,{tx:e,children:t.jsx(Yo,{tx:e,fee:N,onCompleted:o,confirmMessage:s,error:$})})]})},Ex=({tx:e,confirmMessage:n,onCompleted:s})=>t.jsxs(t.Fragment,{children:[t.jsx(Li,{}),t.jsx(Zo,{tx:e,children:t.jsx(Yo,{tx:e,fee:void 0,onCompleted:s,confirmMessage:n})})]}),qx=({tx:e,gas:n,mode:s})=>{const{setValue:o}=At(),a=i=>{o("page","completed"),o("result",i)},r=s==="withdraw"?"Withdraw":"Deposit";return!n||!("cosmos_tx"in e)?t.jsx(Ex,{tx:e,onCompleted:a,confirmMessage:r}):t.jsx($x,{tx:e,gas:n,onCompleted:a,confirmMessage:r})},Lx=({mode:e})=>{const n=Vn(e),s=Ce(),o=Je(),a=Xo(),r=yt(),{data:i}=Jo(),l=ln(),{watch:c,setValue:d,getValues:u}=At(),h=c(),{srcChainId:m,srcDenom:f,quantity:p=""}=h,g=ea(e),x=w_(e),y=h[n.external.chainIdKey],b=y?r(y):null,C=i?.[m]?.[f]?.amount,v=i?.[m]?.[f]?.price||0,N=B(v||0).times(p||0),[k]=Le.useDebounceValue(p,300),$=e==="withdraw"?g:x,q=_.useMemo(()=>{if(e==="deposit"&&!x)return"Select asset";const H=B(p||0);if(!H.isFinite()||H.lte(0))return"Enter amount";const R=j.fromBaseUnit(C??"0",{decimals:$?.decimals||6});if(H.gt(R))return"Insufficient balance";if(e==="withdraw"&&!x)return"Select destination"},[e,p,C,$,x]),{data:V,error:M}=po(k,{disabled:!!q}),I=!M&&!q?V:void 0,w=_.useEffectEvent(()=>{s(0,{...o,route:I,values:{sender:l,recipient:o.recipientAddress?j.InitiaAddress(o.recipientAddress).hex:l,slippagePercent:"1",...u()}})});if(_.useEffect(()=>{w()},[I,l]),!g||e==="deposit"&&!x)return null;const E=$?.decimals||6,U=e==="withdraw"?"Select chain":"Select asset",F=()=>{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")},O=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:Q.label,children:e==="withdraw"?"Destination":"From"}),t.jsxs("button",{className:Q.asset,onClick:()=>{d("page","select-external")},children:[t.jsx("div",{className:Q.assetIcon,children:x?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:x.logo_uri,alt:x.symbol}),t.jsx("img",{src:b?.logo_uri||"",alt:b?.pretty_name,className:Q.chainIcon})]}):e==="withdraw"&&t.jsx("div",{className:Q.chainIcon})}),t.jsx("p",{className:Q.assetName,children:x?t.jsxs(t.Fragment,{children:[x.symbol,t.jsx("br",{}),t.jsxs("span",{children:["on ",b?.pretty_name]})]}):U}),t.jsx(S.IconChevronDown,{className:Q.chevron,size:16})]})]}),Z=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:Q.label,children:"Amount"}),t.jsx(In,{balance:C,decimals:E,className:Q.input}),Number(C)>0&&t.jsxs("div",{className:Q.balanceContainer,children:[t.jsx("p",{className:Q.value,children:N.gt(0)?ee(N.toString()):"$-"}),t.jsxs("button",{className:Q.maxButton,onClick:()=>{const H=j.fromBaseUnit(C??"0",{decimals:E});B(p||0).eq(H)||d("quantity",H)},children:[t.jsx(S.IconWallet,{size:16})," ",j.formatAmount(C,{decimals:E})," ",t.jsx("span",{children:"MAX"})]})]})]});return t.jsxs("div",{className:Q.container,children:[a.length>1&&t.jsx("button",{type:"button","aria-label":"Back",className:Q.back,onClick:F,children:t.jsx(S.IconBack,{size:20})}),t.jsxs("h3",{className:Q.title,children:[n.label," ",g.symbol]}),e==="withdraw"?t.jsxs(t.Fragment,{children:[Z,t.jsx("div",{className:Q.divider}),O]}):t.jsxs(t.Fragment,{children:[O,t.jsx("div",{className:Q.divider}),Z]}),!o.route||q?t.jsx(xe,{children:t.jsx(le.White,{type:"submit",loading:!M&&!q&&"Fetching route...",disabled:!0,fullWidth:!0,children:M?"No route found":q})}):t.jsx(ki,{children:H=>t.jsx(Ai,{children:R=>t.jsx(Si,{addressList:H,signedOpHook:R,children:P=>t.jsx(rx,{tx:P,children:Ne=>t.jsx(qx,{tx:P,gas:Ne,mode:e})})})})})]})},Mx="_container_7nl9j_1",Px="_page_7nl9j_5",Ra={container:Mx,page:Px},Mi=({mode:e})=>{const n=_e.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Jo(),t.jsx(_e.FormProvider,{...n,children:t.jsx(Dx,{mode:e})})},Dx=({mode:e})=>{const{watch:n}=At(),s=n("page"),o=rt.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(H_,{mode:e});case"select-external":return t.jsx(V_,{mode:e});case"fields":return t.jsx(Lx,{mode:e});case"completed":return t.jsx(xo,{type:e})}};return t.jsx(Nn,{children:t.jsx("div",{className:Ra.container,children:o((r,i)=>t.jsx(rt.animated.div,{style:r,className:Ra.page,children:a(i)}))})})},Bx=()=>t.jsx(Mi,{mode:"deposit"}),Rx=()=>t.jsx(Mi,{mode:"withdraw"}),Fx="_root_1lo0i_1",Ux="_address_1lo0i_9",Ox="_copy_1lo0i_19",Vx="_labelWrapper_1lo0i_33",Kx="_labelCopy_1lo0i_43",zx="_labelCopied_1lo0i_47",Wx="_copied_1lo0i_55",Hx="_derived_1lo0i_65",Qx="_derivedLabel_1lo0i_79",Gx="_derivedAddress_1lo0i_83",Yx="_hexAddress_1lo0i_89",Zx="_derivedCopy_1lo0i_94",Ae={root:Fx,address:Ux,copy:Ox,labelWrapper:Vx,labelCopy:Kx,labelCopied:zx,copied:Wx,derived:Hx,derivedLabel:Qx,derivedAddress:Gx,hexAddress:Yx,derivedCopy:Zx},Jx=()=>{const e=_.useRef(null),n=_.useRef(null),{initiaAddress:s,hexAddress:o}=De(),a=Yr("--gray-0");return _.useEffect(()=>{e.current&&(n.current?n.current.update({data:s}):(n.current=new ac({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(dt,{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(cs,{value:s,children:({copy:r,copied:i})=>t.jsxs("button",{className:L(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(cs,{value:o,children:({copy:r,copied:i})=>t.jsxs("button",{className:L(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:j.truncate(o)}),t.jsx(S.IconCopy,{size:12,className:Ae.derivedCopy}),i&&t.jsx("span",{className:Ae.copiedText,children:"Copied!"})]})]})})]})})};function Xx(){const e=te(),n=de();return T.useQueries({queries:n.map(s=>({queryKey:vn.grants(s.chainId,e).queryKey,queryFn:async()=>{const{grants:o}=await z.create({prefixUrl:s.restUrl}).get(`cosmos/authz/v1beta1/grants/granter/${e}`).json();return{chainId:s.chainId,grants:o}},enabled:!!e,staleTime:K.SECOND,retry:!1}))})}const e1="_countdown_vfms8_1",t1={countdown:e1},n1=({expiration:e})=>{const n=()=>{const a=new Date,r=Ge.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),l=Math.floor(r%(1440*60)/3600),c=Math.floor(r%3600/60),d=r%60,u=[];return i>0&&u.push(`${i}d`),(l>0||i>0)&&u.push(`${l}h`),(c>0||l>0||i>0)&&u.push(`${c}m`),u.push(`${d}s`),u.join(" ")},[s,o]=_.useState(n());return Le.useInterval(()=>{o(n())},1e3),Ge.isPast(e)?"Expired":t.jsxs(t.Fragment,{children:["Expires in ",t.jsx("span",{className:t1.countdown,children:s})]})},s1="_container_1l528_1",o1="_info_1l528_11",a1="_header_1l528_17",r1="_chainName_1l528_23",i1="_expiration_1l528_29",c1="_revokeButton_1l528_35",Yt={container:s1,info:o1,header:a1,chainName:r1,expiration:i1,revokeButton:c1},l1=({chainId:e,grantee:n,messageTypes:s,expiration:o})=>{const a=Ze(e),{mutate:r,isPending:i}=Er({grantee:n,internal:!0});return t.jsxs("div",{className:Yt.container,children:[t.jsxs("div",{className:Yt.info,children:[t.jsxs("div",{className:Yt.header,children:[t.jsx(X,{src:a.logoUrl,width:16,height:16,logo:!0}),t.jsx("div",{className:Yt.chainName,children:a.name})]}),t.jsx("div",{className:Yt.expiration,children:o?t.jsx(n1,{expiration:o}):"Until revoked"})]}),t.jsx("button",{className:Yt.revokeButton,onClick:()=>r(e),disabled:i,children:i?"Revoking...":"Revoke"})]})},d1=({chainId:e,grants:n})=>Object.values(n.reduce((o,a)=>{const r=o[a.grantee];return r?{...o,[a.grantee]:{...r,messageTypes:[...r.messageTypes,a.authorization.msg],expiration:qo([r.expiration,a.expiration?new Date(a.expiration):void 0])}}:{...o,[a.grantee]:{grantee:a.grantee,messageTypes:[a.authorization.msg],expiration:a.expiration?new Date(a.expiration):void 0}}},{})).map(o=>_.createElement(l1,{...o,chainId:e,key:o.grantee})),u1="_content_q36qs_1",m1={content:u1},h1=()=>{const e=Xx(),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:m1.content,children:s.map(({chainId:o,grants:a})=>t.jsx(d1,{chainId:o,grants:a},o))})};return t.jsx(dt,{title:"Manage auto-signing",backButton:"/settings",children:n()})},p1="_version_1sf5y_1",f1={version:p1},g1=()=>t.jsxs("aside",{className:f1.version,children:["v","2.3.0"]}),_1="_link_se23z_1",x1="_title_se23z_17",y1="_subtitle_se23z_23",j1="_icon_se23z_30",ts={link:_1,title:x1,subtitle:y1,icon:j1},Pi=({title:e,subtitle:n,rightSection:s,onClick:o})=>t.jsxs("button",{className:ts.link,onClick:o,children:[t.jsxs("div",{children:[t.jsx("p",{className:ts.title,children:e}),n&&t.jsx("p",{className:ts.subtitle,children:n})]}),t.jsx("div",{className:ts.icon,children:s??t.jsx(S.IconChevronRight,{size:16})})]}),b1="https://export.initia.xyz/",w1=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return t.jsx(Pi,{title:"Export private key",rightSection:t.jsx(S.IconExternalLink,{size:16}),onClick:()=>window.open(b1,"_blank",e)})},v1="_container_1vxr7_1",C1="_separator_1vxr7_7",Fa={container:v1,separator:C1},N1=()=>{const e=Ce(),{connector:n}=ve.useAccount();return t.jsx(dt,{title:"Settings",backButton:"/",children:t.jsxs("div",{className:Fa.container,children:[t.jsx(Pi,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),n?.id===vo&&t.jsx(w1,{}),t.jsx(ht.Separator,{className:Fa.separator}),t.jsx(g1,{})]})})},I1="_trigger_1yjkd_1",k1="_icon_1yjkd_23",S1="_full_1yjkd_27",A1="_triggerContent_1yjkd_32",T1="_triggerText_1yjkd_40",$1="_popoverBackdrop_1yjkd_51",E1="_popoverPositioner_1yjkd_70",q1="_popoverPopup_1yjkd_74",L1="_search_1yjkd_99",M1="_viewport_1yjkd_105",P1="_item_1yjkd_111",D1="_highlighted_1yjkd_127",B1="_active_1yjkd_131",R1="_itemContent_1yjkd_136",F1="_extra_1yjkd_142",U1="_connectedTag_1yjkd_149",ge={trigger:I1,icon:k1,full:S1,triggerContent:A1,triggerText:T1,popoverBackdrop:$1,popoverPositioner:E1,popoverPopup:q1,search:L1,viewport:M1,item:P1,highlighted:D1,active:B1,itemContent:R1,extra:F1,connectedTag:U1},qs=({value:e,onChange:n,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=Y(),[i,l]=_.useState(""),[c,d]=_.useState(!1),[u,h]=_.useState(0),[m,f]=_.useState(),p=_.useRef([]),g=_.useRef(null),x=de(),y=s.map(I=>x.find(w=>w.chainId===I)).filter(Boolean),b=I=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:I,height:I,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=_.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),v=_.useMemo(()=>{const I=[C,...y];if(!i)return I;const w=i.toLowerCase();return I.filter(E=>E.name.toLowerCase().includes(w)||E.chainId.toLowerCase().includes(w))},[y,i,C]),N=y.find(I=>I.chainId===e)||C,k=parseInt(Yr("--drawer-offset")),$=6,q=()=>{if(l(""),h(-1),g.current){const w=g.current.getBoundingClientRect().bottom+$,E=window.innerHeight-w-2*k;f(E)}d(!0)};_.useEffect(()=>{u>=0&&u<p.current.length&&p.current[u]?.scrollIntoView({block:"nearest",behavior:"auto"})},[u]);const V=_.useCallback(I=>{switch(I.key){case"ArrowDown":I.preventDefault(),h(w=>(w+1)%v.length);break;case"ArrowUp":I.preventDefault(),h(w=>(w-1+v.length)%v.length);break;case"Enter":I.preventDefault(),v[u]&&(n(v[u].chainId),d(!1));break;case"Escape":I.preventDefault(),d(!1);break}},[v,u,n,d]),M=I=>{n(I),d(!1)};return t.jsxs(Qt.Popover.Root,{open:c,onOpenChange:q,modal:"trap-focus",children:[t.jsx(Qt.Popover.Trigger,{render:t.jsxs("button",{className:L(ge.trigger,{[ge.full]:a}),"aria-expanded":c,role:"listbox",ref:g,children:[t.jsxs("div",{className:ge.triggerContent,children:[typeof N.logoUrl=="string"?t.jsx(X,{src:N.logoUrl,width:14,height:14,logo:!0}):N.logoUrl(14),t.jsx("span",{className:ge.triggerText,children:N.name})]}),t.jsx(S.IconChevronDown,{size:16,className:ge.icon})]})}),t.jsxs(Qt.Popover.Portal,{container:Ot(),children:[t.jsx(Qt.Popover.Backdrop,{className:ge.popoverBackdrop,onClick:()=>d(!1)}),t.jsx(Qt.Popover.Positioner,{className:ge.popoverPositioner,align:"end",side:"bottom",sideOffset:$,collisionAvoidance:{side:"none"},children:t.jsxs(Qt.Popover.Popup,{className:L(ge.popoverPopup,{[ge.full]:a}),style:{maxHeight:m},children:[t.jsx(Un,{value:i,onChange:I=>{l(I.target.value),h(0)},onClear:()=>l(""),onKeyDown:V,placeholder:"Search appchains",rootClassName:ge.search,ref:Rn()}),t.jsx("div",{className:ge.viewport,role:"listbox",children:v.length===0?t.jsx(he,{children:"No appchains found"}):v.map(({chainId:I,name:w,logoUrl:E},U)=>t.jsxs("div",{className:L(ge.item,{[ge.highlighted]:U===u,[ge.active]:e===I}),onClick:()=>M(I),onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),M(I))},onMouseEnter:()=>h(U),role:"option","aria-selected":e===I,tabIndex:-1,ref:F=>{F&&(p.current[U]=F)},children:[t.jsxs("div",{className:ge.itemContent,children:[typeof E=="string"?t.jsx(X,{src:E,width:16,height:16,logo:!0}):E(16),t.jsx("span",{className:ge.name,children:w}),I===r&&t.jsx("span",{className:ge.connectedTag,children:"Connected"})]}),o&&t.jsx("span",{className:ge.extra,children:o(I)})]},I))})]})})]})]})},O1="_container_1nap1_1",V1="_controls_1nap1_7",K1="_search_1nap1_13",ta={container:O1,controls:V1,search:K1},z1=({children:e})=>t.jsx("div",{className:ta.container,children:e}),W1=({children:e})=>t.jsx("div",{className:ta.controls,children:e}),H1=e=>t.jsx(Un,{...e,rootClassName:ta.search}),Qe={Root:z1,Controls:W1,SearchInput:H1},Di=W.atom(""),Bi=W.atom(""),Q1=W.atom(""),G1=W.atom(""),Y1=W.atom(""),Z1="_change_1x9v4_1",J1="_positive_1x9v4_10",X1="_negative_1x9v4_14",no={change:Z1,positive:J1,negative:X1},Ri=({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:L(no.change,r?no.positive:no.negative),children:[r?"+":"-",j.formatAmount(i,{decimals:a})," ",o||s]})},ey=({changes:e,chain:n})=>{const s=lt(n);return e.map(({amount:o,denom:a},r)=>t.jsx(Ri,{amount:o,asset:s(a)},r))},ty=({changes:e,chain:n})=>{const s=lt(n);return e.map(({amount:o,metadata:a},r)=>t.jsx(oi,{metadata:a,chain:n,children:i=>t.jsx(Ri,{amount:o,asset:s(i)})},r))},ny=({events:e,chain:n})=>{const{initiaAddress:s,hexAddress:o}=De();return n.metadata?.is_l1||n.metadata?.minitia?.type==="minimove"?t.jsx(ty,{changes:si(e,o),chain:n}):t.jsx(ey,{changes:ni(e,s),chain:n})},sy="_message_1g2hc_1",oy="_more_1g2hc_8",Ua={message:sy,more:oy},ay=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((n,s)=>t.jsx("p",{className:Ua.message,children:hs.sentenceCase(n["@type"].split("Msg")[1])},s)),e.length>3&&t.jsx("footer",{className:Ua.more,children:`+${e.length-3} more`})]}),ry="_link_fuhbt_1",iy="_inner_fuhbt_16",cy="_header_fuhbt_21",ly="_time_fuhbt_30",dy="_error_fuhbt_36",uy="_timestamp_fuhbt_40",my="_chainInfo_fuhbt_45",hy="_content_fuhbt_53",py="_messages_fuhbt_61",fy="_changes_fuhbt_67",at={link:ry,inner:iy,header:cy,time:ly,error:dy,timestamp:uy,chainInfo:my,content:hy,messages:py,changes:fy},gy=({txItem:e,chain:n})=>t.jsx(ks,{txHash:e.txhash,chainId:n.chainId,className:at.link,children:t.jsxs("div",{className:at.inner,children:[t.jsxs("div",{className:at.header,children:[t.jsxs("div",{className:at.time,children:[e.code!==0&&t.jsx(S.IconWarningFilled,{size:14,className:at.error}),t.jsx("span",{className:at.timestamp,children:Ge.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:at.chainInfo,children:[t.jsx(X,{src:n.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:n.name})]})]}),t.jsxs("div",{className:at.content,children:[t.jsx("div",{className:at.messages,children:t.jsx(ay,{messages:e.tx.body.messages})}),t.jsx("div",{className:at.changes,children:t.jsx(me,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(ny,{...e,chain:n})})})]})]})}),_y="_list_1mv55_1",xy="_dateGroup_1mv55_7",yy="_dateHeader_1mv55_12",jy="_more_1mv55_18",ns={list:_y,dateGroup:xy,dateHeader:yy,more:jy},by=({list:e,chainId:n})=>{const s=te(),o=_.useMemo(()=>xi(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:ns.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{className:ns.dateGroup,children:[t.jsx("div",{className:ns.dateHeader,children:a}),r.map(i=>t.jsx(me,{errorBoundaryProps:{fallback:null},children:t.jsx(gy,{txItem:i,chain:i.chain})},i.txhash))]},a))}),t.jsx(ks,{chainId:n,accountAddress:s,pathSuffix:"/txs",className:ns.more,showIcon:!0,children:"View more on Initia Scan"})]})},wy=()=>{const{activities:e,isLoading:n}=tu(),[s,o]=W.useAtom(Y1),a=ae(),r=_.useMemo(()=>Array.from(new Set(e.map(l=>l.chain.chainId))),[e]),i=_.useMemo(()=>s?e.filter(l=>l.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(Qe.Root,{children:[t.jsx(Qe.Controls,{children:t.jsx(qs,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),t.jsx(by,{list:i,chainId:s||a.chainId})]})},vy="_thumbnail_1xyqw_1",Cy="_placeholder_1xyqw_18",Ny="_clickable_1xyqw_24",xn={thumbnail:vy,placeholder:Cy,clickable:Ny},Iy=({nftInfo:e,size:n,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:l}=Y(),c=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,l).toString();return s?t.jsx("button",{className:L(xn.thumbnail,xn.clickable),onClick:s,style:{width:n,height:n},children:t.jsx(X,{src:c,classNames:{placeholder:xn.placeholder}})}):t.jsx("div",{className:xn.thumbnail,style:{width:n,height:n},children:t.jsx(X,{src:c,classNames:{placeholder:xn.placeholder}})})},ky="_collectionName_qs5tw_1",Sy="_nftName_qs5tw_6",Ay="_chainInfo_qs5tw_10",so={collectionName:ky,nftName:Sy,chainInfo:Ay},na=({normalizedNft:e,onThumbnailClick:n,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:l}=e;return t.jsxs("div",{className:a?.root,children:[t.jsx(Iy,{nftInfo:e,onClick:n,size:s}),t.jsxs("div",{children:[t.jsx("div",{className:L(so.collectionName,a?.collectionName),children:r}),t.jsx("div",{className:L(so.nftName,a?.nftName),children:i}),t.jsxs("div",{className:L(so.chainInfo,a?.chainInfo),children:[t.jsx(X,{src:l.logoUrl,width:o,height:o,logo:!0}),t.jsx("span",{children:l.name})]})]})]})},sa=ye.createQueryKeys("interwovenkit:nft",{nfts:(e,n)=>[e,n],metadata:e=>[e]});function Ty(e,n){const{nft:s}=e,o=n.name??s.token_id;return{...e,...s,...n,name:o}}function $y(e,n){return e.flatMap((s,o)=>(n[o]??[]).map(r=>({...r,chain:s})))}const Ey=()=>{const e=te(),n=de(),s=T.useQueries({queries:n.map(c=>({queryKey:sa.nfts(c.indexerUrl,e).queryKey,queryFn:()=>ar(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:c.indexerUrl},"tokens"),staleTime:K.SECOND}))}),o=s.map(A.prop("data")),a=$y(n,o),r=a.reduce((c,{chain:d})=>({...c,[d.chainId]:(c[d.chainId]||0)+1}),{}),i=Object.values(r).reduce((c,d)=>c+d,0),l=s.some(c=>c.isLoading);return{nftInfos:a,chainCounts:r,totalCount:i,isLoading:l}};function qy(e){const n=Oa(e);return T.useQuery({queryKey:sa.metadata(n).queryKey,queryFn:async()=>{try{if(!n)return{};const s=await z.get(n).json();return{...s,image:Oa(s.image)}}catch{return{}}},staleTime:K.INFINITY})}function Oa(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const Ly=({nftInfo:e,children:n})=>{const{data:s={}}=qy(e.nft.uri),o=Ty(e,s);return n(o)},My="_grid_1wwdn_1",Py="_root_1wwdn_7",Dy="_collectionName_1wwdn_15",By="_nftName_1wwdn_23",Ry="_chainInfo_1wwdn_32",Va={grid:My,root:Py,collectionName:Dy,nftName:By,chainInfo:Ry},Fy=()=>{const[e,n]=W.useAtom(Q1),[s,o]=W.useAtom(G1),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:l}=Ey(),c=Ce(),d=_.useMemo(()=>a.filter(({collection_addr:h,collection_name:m,nft:f,object_addr:p,chain:g})=>{if(s&&g.chainId!==s)return!1;if(e){const x=e.trim().toLowerCase();return h.toLowerCase().includes(x)||m.toLowerCase().includes(x)||f.token_id.toLowerCase().includes(x)||p.toLowerCase().includes(x)}return!0}),[a,s,e]),u=_.useMemo(()=>Array.from(new Set(a.map(({chain:h})=>h.chainId))),[a]);return l&&a.length===0?t.jsx(he,{children:"Loading NFTs..."}):!a.length&&!e&&!l?t.jsx(he,{children:"No NFTs"}):t.jsxs(Qe.Root,{children:[t.jsxs(Qe.Controls,{children:[t.jsx(Qe.SearchInput,{value:e,onChange:h=>n(h.target.value),onClear:()=>n(""),placeholder:"Search NFTs"}),t.jsx(qs,{value:s,onChange:o,chainIds:u,renderExtra:h=>h?r[h]||0:i})]}),d.length===0?t.jsx(he,{children:"No NFTs found"}):t.jsx("div",{className:Va.grid,children:d.map(h=>{const{collection_addr:m,nft:f}=h;return t.jsx(Ly,{nftInfo:h,children:p=>t.jsx(na,{normalizedNft:p,onThumbnailClick:()=>c("/nft",p),classNames:Va})},m+f.token_id)})})]})},Fi=_.createContext(null);function Ui(){return _.useContext(Fi)}const Uy="_popup_nbecp_1",Oy="_item_nbecp_19",ss={popup:Uy,item:Oy},Oi=({asset:e,children:n})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:l,chain:c}=e,{chainId:d}=c,[u,h]=_.useState(!1),m=Ce(),f=Ui(),{showNotification:p}=Ss(),{defaultChainId:g}=Y(),{evm_chain_id:x}=Vt(),y=ve.useChainId(),{switchChainAsync:b}=ve.useSwitchChain(),{watchAssetAsync:C}=ve.useWatchAsset(),v=()=>{h(!1),m("/send",{denom:s,chain:c})},N=()=>{h(!1),m("/bridge",{srcChainId:d,srcDenom:s,quantity:""})},k=T.useMutation({mutationFn:async()=>{if(!l)throw new Error("Address is required");const $=r;return await b({chainId:Number(x)}),C({type:"ERC20",options:{address:l,symbol:a,decimals:o,image:$}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:$=>{p({type:"error",title:"Asset addition failed",description:$.message})}});return t.jsxs(ht.Menu.Root,{open:u,onOpenChange:h,modal:!1,children:[t.jsx(ht.Menu.Trigger,{render:n}),t.jsx(ht.Menu.Portal,{container:f,children:t.jsx(ht.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(ht.Menu.Popup,{className:ss.popup,children:[t.jsxs(ht.Menu.Item,{className:ss.item,onClick:v,children:[t.jsx(S.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(ht.Menu.Item,{className:ss.item,onClick:N,disabled:i,children:[t.jsx(S.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===g&&x===y&&!!l&&t.jsxs(ht.Menu.Item,{className:ss.item,onClick:()=>k.mutate(),disabled:k.isPending||k.data,children:[k.data?t.jsx(S.IconCheck,{size:16}):t.jsx(S.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},Vy="_item_38qhm_1",Ky="_info_38qhm_23",zy="_images_38qhm_29",Wy="_name_38qhm_33",Hy="_value_38qhm_39",Qy="_amount_38qhm_47",Gy="_usd_38qhm_53",Mt={item:Vy,info:Ky,images:zy,name:Wy,value:Hy,amount:Qy,usd:Gy},Yy=({asset:e})=>{const{amount:n,value:s,logoUrl:o,chain:a}=e,r=j.formatAmount(n,{decimals:e.decimals});return t.jsx(Oi,{asset:e,children:t.jsxs("button",{className:Mt.item,children:[t.jsxs("div",{className:Mt.info,children:[t.jsx(Ts,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:Mt.images}),t.jsx("span",{className:Mt.name,children:a.name})]}),t.jsxs("div",{className:Mt.value,children:[t.jsx("span",{className:Mt.amount,children:r}),Number(s)>0&&t.jsx("span",{className:Mt.usd,children:ee(s)})]})]})})},Zy="_container_ytg3p_1",Jy="_assetItem_ytg3p_6",Xy="_expandIcon_ytg3p_22",e2="_assetInfo_ytg3p_27",t2="_logo_ytg3p_33",n2="_details_ytg3p_37",s2="_symbol_ytg3p_42",o2="_chainName_ytg3p_53",a2="_chainInfos_ytg3p_59",r2="_chainLogos_ytg3p_65",i2="_chainLogo_ytg3p_65",c2="_moreChains_ytg3p_76",l2="_expanded_ytg3p_93",d2="_valueColumn_ytg3p_98",u2="_amount_ytg3p_108",m2="_value_ytg3p_98",h2="_collapsibleContent_ytg3p_121",p2="_chainsList_ytg3p_151",pe={container:Zy,assetItem:Jy,expandIcon:Xy,assetInfo:e2,logo:t2,details:n2,symbol:s2,chainName:o2,chainInfos:a2,chainLogos:r2,chainLogo:i2,moreChains:c2,expanded:l2,valueColumn:d2,amount:u2,value:m2,collapsibleContent:h2,chainsList:p2},f2=W.atom([]),oa=({assetGroup:e})=>{const{symbol:n,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=W.useAtom(f2),l=_.useMemo(()=>Oc(e),[e]),c=_.useMemo(()=>qr(e),[e]),d=r.includes(n),u=()=>{i(m=>d?m.filter(f=>f!==n):[...new Set([...m,n])])},h=()=>t.jsxs("button",{className:pe.assetItem,children:[t.jsxs("div",{className:pe.assetInfo,children:[s&&t.jsx(X,{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:m})=>t.jsx(X,{src:m.logoUrl,width:16,height:16,className:pe.chainLogo,logo:!0},m.chainId))}),o.length>5&&t.jsxs("span",{className:pe.moreChains,children:["+",o.length-5]}),t.jsx(S.IconChevronDown,{size:16,className:L(pe.expandIcon,{[pe.expanded]:d})})]})]})]}),t.jsxs("div",{className:pe.valueColumn,children:[t.jsx("div",{className:pe.amount,children:j.formatNumber(l,{dp:o[0].unlisted?0:6})}),c>0&&t.jsx("div",{className:pe.value,children:ee(c)})]})]});if(a){const[m]=o;return t.jsx("div",{className:pe.container,children:t.jsx(Oi,{asset:m,children:h()})})}return t.jsx("div",{className:pe.container,children:t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:h()}),t.jsx(J.Collapsible.Content,{className:pe.collapsibleContent,children:t.jsx("div",{className:pe.chainsList,children:o.map(m=>t.jsx(Yy,{asset:m},m.chain.chainId))})})]})})},g2="_collapsible_1g7rh_1",_2="_trigger_1g7rh_5",x2="_divider_1g7rh_20",y2="_label_1g7rh_28",j2="_chevron_1g7rh_33",b2="_content_1g7rh_41",w2="_list_1g7rh_45",Nt={collapsible:g2,trigger:_2,divider:x2,label:y2,chevron:j2,content:b2,list:w2},Vi=({unlistedAssets:e})=>{const[n,s]=_.useState(!1),o=Ui(),a=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{if(a.current){const h=a.current.scrollHeight;i(h)}},[e]);const l=_.useRef(null),c=h=>{s(h),h&&l.current&&o?.current&&window.setTimeout(()=>{if(!l.current||!a.current||!o?.current)return;const m=o.current,f=m.getBoundingClientRect(),p=l.current.getBoundingClientRect(),g=a.current.scrollHeight;if(p.bottom+g>f.bottom){const y=p.top-f.top+m.scrollTop-16;m.scrollTo({top:y,behavior:"smooth"})}},50)},d=rt.useSpring({height:n?r:0,opacity:n?1:0,config:{tension:500,friction:30,clamp:!0}}),u=_.useMemo(()=>e.map(h=>({...h,assets:[h],totalValue:h.value??0,totalAmount:Number(h.quantity)})),[e]);return e.length===0?null:t.jsxs(J.Collapsible.Root,{open:n,onOpenChange:c,className:Nt.collapsible,children:[t.jsxs(J.Collapsible.Trigger,{ref:l,className:Nt.trigger,children:[t.jsx("div",{className:Nt.divider}),t.jsxs("span",{className:Nt.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(S.IconChevronDown,{className:Nt.chevron,size:12,"data-state":n?"open":"closed"}),t.jsx("div",{className:Nt.divider})]}),t.jsx(J.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(rt.animated.div,{className:Nt.content,style:d,children:t.jsx("div",{className:Nt.list,ref:a,children:u.map(h=>t.jsx(oa,{assetGroup:h},h.assets[0].denom))})})})]})},v2="_container_15xfg_1",C2="_header_15xfg_7",N2="_title_15xfg_13",I2="_totalValue_15xfg_19",k2="_list_15xfg_26",tn={container:v2,header:C2,title:N2,totalValue:I2,list:k2},S2=()=>{const[e,n]=W.useAtom(Di),[s,o]=W.useAtom(Bi),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:l,isLoading:c}=Lo(),d=i.map(({chainId:m})=>m),u=_.useMemo(()=>{const m=e?a.filter(p=>{const{symbol:g,assets:x}=p;return g.toLowerCase().includes(e.toLowerCase())||x.some(({denom:y,address:b})=>y.toLowerCase().includes(e.toLowerCase())||b?.toLowerCase().includes(e.toLowerCase()))}):a;return s?m.map(p=>({...p,assets:p.assets.filter(({chain:g})=>g.chainId===s)})).filter(p=>p.assets.length>0):m},[a,e,s]),h=_.useMemo(()=>{const m=e?r.filter(({denom:p,address:g})=>p.toLowerCase().includes(e.toLowerCase())||g?.toLowerCase().includes(e.toLowerCase())):r;return s?m.filter(({chain:p})=>p.chainId===s):m},[r,e,s]);return c&&a.length===0?t.jsx(he,{children:"Loading assets..."}):!u.length&&!h.length&&!e&&!s&&!c?t.jsx(he,{children:"No assets"}):t.jsxs(Qe.Root,{children:[t.jsxs(Qe.Controls,{children:[t.jsx(Qe.SearchInput,{value:e,onChange:m=>n(m.target.value),onClear:()=>n(""),placeholder:"Search assets"}),t.jsx(qs,{value:s,onChange:o,chainIds:d,renderExtra:m=>{if(!m)return ee(l);const f=i.find(p=>p.chainId===m);return f?ee(f.value):null}})]}),t.jsx("div",{children:u.length===0&&h.length===0?t.jsx(he,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:tn.list,children:u.map(m=>t.jsx(oa,{assetGroup:m},m.symbol))}),t.jsx(Vi,{unlistedAssets:h})]})})]})},A2="_container_11k2x_1",T2={container:A2},He=({height:e,length:n=1,width:s="100%"})=>{const o=Array.from({length:n},(a,r)=>r);return n===1?t.jsx(Ut,{height:e,width:s}):t.jsx("div",{className:T2.container,children:o.map(a=>t.jsx(Ut,{height:e,width:s},a))})},$2=_.memo(({searchQuery:e,selectedChain:n,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:l}=Pn(),c=ae(),{listedGroups:d,unlistedAssets:u}=_.useMemo(()=>kl(i,a,r,c.chainId),[i,a,r,c.chainId]),h=_.useMemo(()=>vl(d,s,o),[d,s,o]),{filteredAssets:m,totalAssetsValue:f,filteredUnlistedAssets:p}=_.useMemo(()=>Il(h,u,e,n),[h,u,e,n]);return t.jsxs("div",{className:tn.container,children:[t.jsxs("div",{className:tn.header,children:[t.jsx("span",{className:tn.title,children:"Assets"}),m.length>0&&t.jsx("span",{className:tn.totalValue,children:ee(f)})]}),m.length>0?t.jsxs("div",{children:[t.jsx("div",{className:tn.list,children:m.map(g=>t.jsx(oa,{assetGroup:g},g.symbol))}),t.jsx(Vi,{unlistedAssets:p})]}):h.length===0&&l?t.jsx(He,{height:56,length:3}):t.jsx(he,{children:"No liquid assets"})]})}),E2=ye.createQueryKeys("interwovenkit:civitia",{player:(e,n)=>[e,n]});function Ki(){const{civitiaUrl:e}=Y(),n=te();return T.useQuery({enabled:!!n,queryKey:E2.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 q2="_section_xdyfz_2",L2="_row_xdyfz_15",M2="_rowLeft_xdyfz_23",P2="_rowIcon_xdyfz_29",D2="_goldIcon_xdyfz_38",B2="_silverIcon_xdyfz_46",R2="_rowTitle_xdyfz_54",F2="_rowValue_xdyfz_60",U2="_rowSubtitle_xdyfz_67",Ie={section:q2,row:L2,rowLeft:M2,rowIcon:P2,goldIcon:D2,silverIcon:B2,rowTitle:R2,rowValue:F2,rowSubtitle:U2},O2=()=>{const{data:e,isLoading:n}=Ki();if(n)return t.jsx(He,{height:36,length:2});const s=e?.gold_balance??0,o=e?.silver_balance??0;return t.jsxs("div",{className:Ie.section,children:[t.jsxs("div",{className:Ie.row,children:[t.jsxs("div",{className:Ie.rowLeft,children:[t.jsx("div",{className:L(Ie.rowIcon,Ie.goldIcon)}),t.jsx("span",{className:Ie.rowTitle,children:"Gold"})]}),t.jsx("span",{className:L(Ie.rowValue,s===0&&Ie.rowSubtitle),children:s===0?"—":j.formatNumber(s,{dp:6})})]}),t.jsxs("div",{className:Ie.row,children:[t.jsxs("div",{className:Ie.rowLeft,children:[t.jsx("div",{className:L(Ie.rowIcon,Ie.silverIcon)}),t.jsx("span",{className:Ie.rowTitle,children:"Silver"})]}),t.jsx("span",{className:L(Ie.rowValue,o===0&&Ie.rowSubtitle),children:o===0?"—":j.formatNumber(o,{dp:6})})]})]})},V2="_container_1n61l_1",K2="_section_1n61l_7",z2="_sectionHeader_1n61l_19",W2="_sectionTitle_1n61l_25",H2="_sectionLabel_1n61l_31",Q2="_externalLink_1n61l_37",G2="_sectionValue_1n61l_49",Y2="_tokenList_1n61l_56",Z2="_stakingTokenList_1n61l_62",J2="_tokenRow_1n61l_72",X2="_tokenMain_1n61l_78",e0="_tokenTrigger_1n61l_84",t0="_tokenChevron_1n61l_100",n0="_expanded_1n61l_111",s0="_triggerValue_1n61l_115",o0="_tokenInfo_1n61l_122",a0="_tokenInfoLabel_1n61l_128",r0="_tokenLogo_1n61l_134",i0="_tokenSymbol_1n61l_138",c0="_tokenValues_1n61l_144",l0="_tokenAmount_1n61l_150",d0="_tokenValue_1n61l_144",u0="_typeBreakdown_1n61l_164",m0="_typeRow_1n61l_172",h0="_typeLabel_1n61l_180",p0="_typeValues_1n61l_186",f0="_typeAmount_1n61l_192",g0="_typeValue_1n61l_186",_0="_collapsibleContent_1n61l_206",G={container:V2,section:K2,sectionHeader:z2,sectionTitle:W2,sectionLabel:H2,externalLink:Q2,sectionValue:G2,tokenList:Y2,stakingTokenList:Z2,tokenRow:J2,tokenMain:X2,tokenTrigger:e0,tokenChevron:t0,expanded:n0,triggerValue:s0,tokenInfo:o0,tokenInfoLabel:a0,tokenLogo:r0,tokenSymbol:i0,tokenValues:c0,tokenAmount:l0,tokenValue:d0,typeBreakdown:u0,typeRow:m0,typeLabel:h0,typeValues:p0,typeAmount:f0,typeValue:g0,collapsibleContent:_0},zi=({protocols:e,denomLogoMap:n,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=_.useMemo(()=>{const l=e.flatMap(c=>c.positions);return hl(l)},[e]);return i.size===0?null:t.jsx("div",{className:G.container,children:Array.from(i.entries()).map(([l,c])=>t.jsx(x0,{sectionKey:l,sectionGroup:c,denomLogoMap:n,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},l))})},x0=({sectionKey:e,sectionGroup:n,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:l,totalValue:c}=n,d=ml(e,o),u=_.useMemo(()=>jl(l),[l]),h=e==="staking";return t.jsxs("div",{className:G.section,children:[t.jsxs("div",{className:G.sectionHeader,children:[t.jsxs("div",{className:G.sectionTitle,children:[t.jsx("span",{className:G.sectionLabel,children:d}),h&&a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:G.externalLink,onClick:m=>m.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:G.sectionValue,children:ee(c)})]}),t.jsx("div",{className:L(G.tokenList,{[G.stakingTokenList]:h}),children:u.map(m=>t.jsx(y0,{group:m,showTypeBreakdown:h,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},m.denom))})]})},y0=({group:e,showTypeBreakdown:n,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:l,totalValue:c,positions:d}=e,u=s.get(r),[h,m]=_.useState(!1),f=_.useMemo(()=>{if(!n)return null;const p=xl(d);return p.size>0?p:null},[d,n]);return f?t.jsxs(J.Collapsible.Root,{open:h,onOpenChange:m,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:G.tokenTrigger,children:[t.jsxs("div",{className:G.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:L(G.tokenChevron,{[G.expanded]:h})}),t.jsxs("div",{className:G.tokenInfoLabel,children:[u?.assetLogo&&t.jsx(X,{src:u.assetLogo,width:20,height:20,className:G.tokenLogo}),t.jsx("span",{className:G.tokenSymbol,children:i})]})]}),t.jsx("span",{className:G.triggerValue,children:ee(c)})]})}),t.jsx(J.Collapsible.Content,{className:G.collapsibleContent,children:t.jsx(j0,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):t.jsx("div",{className:G.tokenRow,children:t.jsxs("div",{className:G.tokenMain,children:[t.jsxs("div",{className:G.tokenInfo,children:[u?.assetLogo&&t.jsx(X,{src:u.assetLogo,width:20,height:20,className:G.tokenLogo}),t.jsx("span",{className:G.tokenSymbol,children:i})]}),t.jsxs("div",{className:G.tokenValues,children:[t.jsx("span",{className:G.tokenAmount,children:j.formatNumber(l,{dp:6})}),t.jsx("span",{className:G.tokenValue,children:ee(c)})]})]})})},j0=({typeGroups:e,symbol:n,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=_.useMemo(()=>Array.from(e.entries()).map(([c,d])=>{const u=d.reduce((m,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?m:m+f.balance.formattedAmount,0),h=d.reduce((m,f)=>m+an(f),0);return{type:c,typeAmount:u,typeValue:h}}),[e]),i=_.useMemo(()=>{if(!o)return 0;let c=0;for(const{type:d}of r){const u=o(s,d);c+=Number(u)}return c},[s,o,r]),l=i>0;return t.jsxs("div",{className:G.typeBreakdown,children:[r.map(({type:c,typeAmount:d,typeValue:u})=>t.jsxs("div",{className:G.typeRow,children:[t.jsx("span",{className:G.typeLabel,children:_l(c)}),t.jsxs("div",{className:G.typeValues,children:[t.jsxs("span",{className:G.typeAmount,children:[j.formatNumber(d,{dp:6})," ",n]}),t.jsx("span",{className:G.typeValue,children:ee(u)})]})]},c)),l&&t.jsxs("div",{className:G.typeRow,children:[t.jsx("span",{className:G.typeLabel,children:"Claimable"}),t.jsxs("div",{className:G.typeValues,children:[t.jsxs("span",{className:G.typeAmount,children:[j.formatNumber(i,{dp:6})," ",We]}),t.jsx("span",{className:G.typeValue,children:ee(i*(a??0))})]})]})]})},b0="_container_ymkoc_1",w0="_trigger_ymkoc_6",v0="_expandIcon_ymkoc_22",C0="_chainInfo_ymkoc_27",N0="_logo_ymkoc_33",I0="_chainNameContainer_ymkoc_37",k0="_chainName_ymkoc_37",S0="_externalLink_ymkoc_49",A0="_externalIcon_ymkoc_53",T0="_valueColumn_ymkoc_63",$0="_value_ymkoc_63",E0="_expanded_ymkoc_80",q0="_collapsibleContent_ymkoc_85",L0="_content_ymkoc_97",Te={container:b0,trigger:w0,expandIcon:v0,chainInfo:C0,logo:N0,chainNameContainer:I0,chainName:k0,externalLink:S0,externalIcon:A0,valueColumn:T0,value:$0,expanded:E0,collapsibleContent:q0,content:L0},M0=W.atom([]),P0=({chainGroup:e})=>{const{chainId:n,chainLogo:s,protocols:o}=e,a=de(),r=Sn(),{denomLogos:i,symbolLogos:l}=_.useMemo(()=>Uo(r,a),[r,a]),c=_.useMemo(()=>{const d=new Map;for(const u of o)for(const h of u.positions){if(h.type==="fungible-position"||h.balance.type==="unknown")continue;const{denom:m,symbol:f}=h.balance,p=f.toUpperCase(),g=`${n}:${m}`,x=i.get(g)??l.get(p);x&&d.set(m,{assetLogo:x,chainLogo:s??""})}return d},[o,i,l,n,s]);return t.jsx(zi,{protocols:o,denomLogoMap:c})},D0=({chainGroup:e})=>{const{chainName:n,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=W.useAtom(M0),l=_.useMemo(()=>o.reduce((p,g)=>p+g.positions.reduce((x,y)=>x+an(y),0),0),[o]),c=["civitia","yominet"],d=r.includes(n),u=n?.toLowerCase(),h=u==="civitia",m=c.includes(u),f=()=>{i(p=>d?p.filter(g=>g!==n):[...new Set([...p,n])])};return t.jsx("div",{className:Te.container,children:t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:f,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Te.trigger,children:[t.jsxs("div",{className:Te.chainInfo,children:[s&&t.jsx(X,{src:s,width:32,height:32,className:Te.logo,logo:!0}),t.jsxs("div",{className:Te.chainNameContainer,children:[t.jsx("span",{className:Te.chainName,children:n}),a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:Te.externalLink,onClick:p=>p.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:Te.externalIcon})})]})]}),t.jsxs("div",{className:Te.valueColumn,children:[!m&&t.jsx("span",{className:Te.value,children:ee(l)}),t.jsx(S.IconChevronDown,{size:16,className:L(Te.expandIcon,{[Te.expanded]:d})})]})]})}),t.jsx(J.Collapsible.Content,{className:Te.collapsibleContent,children:t.jsxs("div",{className:Te.content,children:[t.jsx(P0,{chainGroup:e}),h&&t.jsx(O2,{})]})})]})})},B0="_container_1gqx9_1",R0="_section_1gqx9_6",F0="_sectionHeader_1gqx9_14",U0="_sectionTitle_1gqx9_20",O0="_sectionLabel_1gqx9_26",V0="_externalLink_1gqx9_32",K0="_sectionValue_1gqx9_44",z0="_tokenList_1gqx9_51",W0="_tokenTrigger_1gqx9_63",H0="_tokenChevron_1gqx9_79",Q0="_expanded_1gqx9_90",G0="_tokenInfo_1gqx9_94",Y0="_tokenInfoLabel_1gqx9_100",Z0="_tokenLogo_1gqx9_106",J0="_pairedLogos_1gqx9_110",X0="_coinLogo_1gqx9_115",ej="_tokenSymbol_1gqx9_133",tj="_triggerValue_1gqx9_139",nj="_breakdownContent_1gqx9_146",sj="_breakdownRow_1gqx9_154",oj="_breakdownLabel_1gqx9_162",aj="_breakdownValues_1gqx9_168",rj="_breakdownAmount_1gqx9_174",ij="_breakdownValue_1gqx9_168",cj="_collapsibleContent_1gqx9_195",se={container:B0,section:R0,sectionHeader:F0,sectionTitle:U0,sectionLabel:O0,externalLink:V0,sectionValue:K0,tokenList:z0,tokenTrigger:W0,tokenChevron:H0,expanded:Q0,tokenInfo:G0,tokenInfoLabel:Y0,tokenLogo:Z0,pairedLogos:J0,coinLogo:X0,tokenSymbol:ej,triggerValue:tj,breakdownContent:nj,breakdownRow:sj,breakdownLabel:oj,breakdownValues:aj,breakdownAmount:rj,breakdownValue:ij,collapsibleContent:cj},lj=({data:e,denomLogoMap:n})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:t.jsx("div",{className:se.container,children:t.jsxs("div",{className:se.section,children:[t.jsxs("div",{className:se.sectionHeader,children:[t.jsxs("div",{className:se.sectionTitle,children:[t.jsx("span",{className:se.sectionLabel,children:"Liquidity"}),t.jsx("a",{href:So,target:"_blank",rel:"noopener noreferrer",className:se.externalLink,onClick:a=>a.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:se.sectionValue,children:ee(s)})]}),t.jsx("div",{className:se.tokenList,children:o.map(a=>t.jsx(uj,{row:a,denomLogoMap:n},a.denom))})]})})},dj={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"},uj=({row:e,denomLogoMap:n})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:l,claimableInit:c}=e,[d,u]=_.useState(!1),h=n.get(s),m=i||h?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,p=_.useMemo(()=>Object.entries(r).filter(([,y])=>y>0),[r]),g=l&&l.length>0&&l.some(y=>y),x=c&&Number(c.total)>0;return t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:se.tokenTrigger,children:[t.jsxs("div",{className:se.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:L(se.tokenChevron,{[se.expanded]:d})}),t.jsxs("div",{className:se.tokenInfoLabel,children:[g?t.jsx("div",{className:se.pairedLogos,children:l.map((y,b)=>t.jsx(X,{src:y,width:20,height:20,className:se.coinLogo,logo:!0},b))}):m&&t.jsx(X,{src:m,width:20,height:20,className:se.tokenLogo}),t.jsx("span",{className:se.tokenSymbol,children:o})]})]}),t.jsx("span",{className:se.triggerValue,children:ee(a)})]})}),t.jsx(J.Collapsible.Content,{className:se.collapsibleContent,children:t.jsxs("div",{className:se.breakdownContent,children:[p.map(([y,b])=>{const C=b*f;return t.jsxs("div",{className:se.breakdownRow,children:[t.jsx("span",{className:se.breakdownLabel,children:dj[y]}),t.jsxs("div",{className:se.breakdownValues,children:[t.jsxs("span",{className:se.breakdownAmount,children:[j.formatNumber(b,{dp:6})," LP"]}),t.jsx("span",{className:se.breakdownValue,children:ee(C)})]})]},y)}),x&&t.jsxs("div",{className:se.breakdownRow,children:[t.jsx("span",{className:se.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:se.breakdownValues,children:[t.jsxs("span",{className:se.breakdownAmount,children:[j.formatNumber(Number(c.total),{dp:6})," ",We]}),t.jsx("span",{className:se.breakdownValue,children:ee(c.totalValue)})]})]})]})})]})},mj="_container_1nijk_1",hj="_section_1nijk_6",pj="_sectionHeader_1nijk_14",fj="_sectionTitle_1nijk_20",gj="_sectionLabel_1nijk_26",_j="_externalLink_1nijk_32",xj="_sectionValue_1nijk_44",yj="_tokenList_1nijk_51",jj="_tokenTrigger_1nijk_63",bj="_tokenChevron_1nijk_79",wj="_expanded_1nijk_90",vj="_tokenInfo_1nijk_94",Cj="_tokenInfoLabel_1nijk_100",Nj="_tokenLogo_1nijk_106",Ij="_tokenName_1nijk_110",kj="_triggerValue_1nijk_116",Sj="_breakdownContent_1nijk_123",Aj="_breakdownRow_1nijk_131",Tj="_breakdownLabel_1nijk_139",$j="_breakdownValues_1nijk_145",Ej="_breakdownAmount_1nijk_151",qj="_breakdownValue_1nijk_145",Lj="_collapsibleContent_1nijk_165",ce={container:mj,section:hj,sectionHeader:pj,sectionTitle:fj,sectionLabel:gj,externalLink:_j,sectionValue:xj,tokenList:yj,tokenTrigger:jj,tokenChevron:bj,expanded:wj,tokenInfo:vj,tokenInfoLabel:Cj,tokenLogo:Nj,tokenName:Ij,triggerValue:kj,breakdownContent:Sj,breakdownRow:Aj,breakdownLabel:Tj,breakdownValues:$j,breakdownAmount:Ej,breakdownValue:qj,collapsibleContent:Lj},Mj=({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:Cc,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:ee(n)})]}),t.jsx("div",{className:ce.tokenList,children:s.map(o=>t.jsx(Pj,{row:o},`${o.bridgeId}-${o.version}`))})]})})},Pj=({row:e})=>{const{name:n,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[l,c]=_.useState(!1),d=a+i;return t.jsxs(J.Collapsible.Root,{open:l,onOpenChange:c,children:[t.jsx(J.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:L(ce.tokenChevron,{[ce.expanded]:l})}),t.jsxs("div",{className:ce.tokenInfoLabel,children:[s&&t.jsx(X,{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:ee(d)})]})}),t.jsx(J.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:[j.formatNumber(o,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:ee(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:[j.formatNumber(r,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:ee(i)})]})]})]})})]})},Dj="_container_ymkoc_1",Bj="_trigger_ymkoc_6",Rj="_expandIcon_ymkoc_22",Fj="_chainInfo_ymkoc_27",Uj="_logo_ymkoc_33",Oj="_chainNameContainer_ymkoc_37",Vj="_chainName_ymkoc_37",Kj="_externalLink_ymkoc_49",zj="_externalIcon_ymkoc_53",Wj="_valueColumn_ymkoc_63",Hj="_value_ymkoc_63",Qj="_expanded_ymkoc_80",Gj="_collapsibleContent_ymkoc_85",Yj="_content_ymkoc_97",$e={container:Dj,trigger:Bj,expandIcon:Rj,chainInfo:Fj,logo:Uj,chainNameContainer:Oj,chainName:Vj,externalLink:Kj,externalIcon:zj,valueColumn:Wj,value:Hj,expanded:Qj,collapsibleContent:Gj,content:Yj},Zj=W.atom(!1),Jj=()=>{const{totalValue:e}=Bo(),{totalValue:n}=Fo(),{totalValue:s}=Cs(),o=e+n+s;return t.jsx("span",{className:$e.value,children:ee(o)})},Xj=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Bo(),{data:i}=Dr(),{data:l}=Br(),c=_.useMemo(()=>{const h=new Map;for(const m of r){if(m.type==="fungible-position"||m.balance.type==="unknown")continue;const{denom:f,symbol:p}=m.balance,g=p.toUpperCase(),x=`${e}:${f}`,y=s.get(x)??o.get(g);y&&h.set(f,{assetLogo:y,chainLogo:n})}return h},[r,s,o,e,n]),d=_.useMemo(()=>(h,m)=>{const f=j.denomToMetadata(h);if(m==="staking"){const p=i?.get(f);return p?j.fromBaseUnit(p.amount,{decimals:Pe}):"0"}if(m==="lockstaking"){const p=l?.get(f);return p?j.fromBaseUnit(p.amount,{decimals:Pe}):"0"}return"0"},[i,l]),u=_.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:So,positions:r}],[r]);return u.length===0?null:t.jsx(zi,{protocols:u,denomLogoMap:c,isInitia:!0,getClaimableInitByType:d,initPrice:a})},eb=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o})=>{const a=Fo(),r=_.useMemo(()=>{const i=new Map;for(const l of a.rows){const{denom:c,symbol:d}=l,u=d.toUpperCase(),h=`${e}:${c}`,m=s.get(h)??o.get(u);m&&i.set(c,{assetLogo:m,chainLogo:n})}return i},[a.rows,s,o,e,n]);return a.rows.length===0?null:t.jsx(lj,{data:a,denomLogoMap:r})},tb=()=>{const e=Cs();return e.rows.length===0?null:t.jsx(Mj,{data:e})},nb=({chainGroup:e})=>{const{chainId:n,chainName:s,chainLogo:o}=e,[a,r]=W.useAtom(Zj),i=de(),l=Sn(),{denomLogos:c,symbolLogos:d}=_.useMemo(()=>Uo(l,i),[l,i]),u=ae(),{data:h}=_t(u),m=_.useMemo(()=>h?.find(p=>p.id===Se)?.price??0,[h]);return t.jsx("div",{className:$e.container,children:t.jsxs(J.Collapsible.Root,{open:a,onOpenChange:r,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:$e.trigger,children:[t.jsxs("div",{className:$e.chainInfo,children:[o&&t.jsx(X,{src:o,width:32,height:32,className:$e.logo,logo:!0}),t.jsxs("div",{className:$e.chainNameContainer,children:[t.jsx("span",{className:$e.chainName,children:s}),t.jsx("a",{href:So,target:"_blank",rel:"noopener noreferrer",className:$e.externalLink,onClick:f=>f.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:$e.externalIcon})})]})]}),t.jsxs("div",{className:$e.valueColumn,children:[t.jsx(me,{suspenseFallback:t.jsx(He,{height:16,width:60,length:1}),children:t.jsx(Jj,{})}),t.jsx(S.IconChevronDown,{size:16,className:L($e.expandIcon,{[$e.expanded]:a})})]})]})}),t.jsx(J.Collapsible.Content,{className:$e.collapsibleContent,children:t.jsxs("div",{className:$e.content,children:[t.jsx(me,{suspenseFallback:t.jsx(He,{height:36,length:2}),children:t.jsx(Xj,{chainId:n,chainLogo:o,denomLogos:c,symbolLogos:d,initPrice:m})}),t.jsx(me,{suspenseFallback:t.jsx(He,{height:36,length:2}),children:t.jsx(eb,{chainId:n,chainLogo:o,denomLogos:c,symbolLogos:d})}),t.jsx(me,{suspenseFallback:t.jsx(He,{height:36,length:1}),children:t.jsx(tb,{})})]})})]})})},sb="_totalValue_1v2ca_1",ob={totalValue:sb},ab=({filteredChainGroups:e})=>{const{totalValue:n}=Bo(),{totalValue:s}=Fo(),{totalValue:o}=Cs(),a=n+s+o,r=_.useMemo(()=>{const i=e.some(c=>c.isInitia);return e.reduce((c,d)=>d.isInitia?c:c+d.totalValue,0)+(i?a:0)},[e,a]);return t.jsx("span",{className:ob.totalValue,children:ee(r)})},rb="_container_1eubu_1",ib="_header_1eubu_7",cb="_title_1eubu_13",lb="_list_1eubu_19",db="_skeletonWrapper_1eubu_24",yn={container:rb,header:ib,title:cb,list:lb,skeletonWrapper:db},ub=_.memo(({searchQuery:e,selectedChain:n,chainInfoMap:s})=>{const{positions:o,isLoading:a}=Pn(),r=ae(),{data:i,isLoading:l}=Ki(),c=_.useMemo(()=>{const u=[];for(const m of o){if(!Array.isArray(m.positions))continue;const f=s.get(m.chainName.toLowerCase()),p=m.chainName.toLowerCase(),g=p==="civitia";if(n&&f?.chainId!==n)continue;const x=m.positions.some(N=>N.positions.some(k=>k.type!=="fungible-position")),y=g&&!l&&i&&((i.gold_balance??0)>0||(i.silver_balance??0)>0);if(!x&&!y||e&&!p.includes(e.toLowerCase()))continue;const b=m.positions.filter(N=>e&&!N.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(N.positions)&&N.positions.length>0),C=r.chainId===f?.chainId,v=b.reduce((N,k)=>N+k.positions.reduce(($,q)=>$+an(q),0),0);u.push({chainId:f?.chainId??"",chainName:f?.prettyName??m.chainName,chainLogo:f?.logoUrl??"",protocols:b,isInitia:C,totalValue:v})}const h=["civitia","yominet"];return A.sortWith([A.descend(m=>m.isInitia??!1),A.ascend(m=>h.includes(m.chainName.toLowerCase())),A.descend(m=>m.totalValue??0),A.ascend(m=>m.chainName.toLowerCase())],u)},[o,s,e,n,r.chainId,i,l]),d=c.length>0;return t.jsxs("div",{className:yn.container,children:[t.jsxs("div",{className:yn.header,children:[t.jsx("span",{className:yn.title,children:"Positions"}),d&&t.jsx(me,{suspenseFallback:t.jsx(He,{height:16,width:60,length:1}),children:t.jsx(ab,{filteredChainGroups:c})})]}),d?t.jsx("div",{className:yn.list,children:c.map(u=>u.isInitia?t.jsx(me,{suspenseFallback:t.jsx("div",{className:yn.skeletonWrapper,children:t.jsx(He,{height:56,length:1})}),children:t.jsx(nb,{chainGroup:u})},u.chainName):t.jsx(D0,{chainGroup:u},u.chainName))}):o.length===0&&a?t.jsx(He,{height:56,length:3}):t.jsx(he,{children:"No positions"})]})}),mb="_content_1w1ad_1",hb={content:mb},pb=({selectedChain:e,setSelectedChain:n})=>{const{defaultChainId:s}=Y(),o=ae(),a=Ll(),{totalValue:r}=Cs(),{chainIds:i,chainIdToValueMap:l,totalBalance:c}=_.useMemo(()=>{const d=new Map;let u=0;for(const m of a)d.set(m.chainId,m.totalBalance),u+=m.totalBalance;return r>0&&(d.set(o.chainId,(d.get(o.chainId)??0)+r),u+=r),{chainIds:A.sortWith([A.descend(m=>m===s),A.descend(m=>m===o.chainId),A.descend(m=>d.get(m)??0)],a.map(m=>m.chainId)),chainIdToValueMap:d,totalBalance:u}},[a,s,o,r]);return t.jsx(qs,{value:e,onChange:n,chainIds:i,renderExtra:d=>ee(d?l.get(d)??0:c)})},fb=()=>{const[e,n]=W.useAtom(Di),[s,o]=W.useAtom(Bi),a=de(),r=Sn(),{denomLogos:i,symbolLogos:l}=_.useMemo(()=>Uo(r,a),[r,a]),c=Co(),d=_.useMemo(()=>Vr(a,c),[a,c]),u=ql();return t.jsxs(Qe.Root,{children:[t.jsxs(Qe.Controls,{children:[t.jsx(Qe.SearchInput,{value:e,onChange:h=>n(h.target.value),onClear:()=>n(""),placeholder:"Search portfolio"}),t.jsx(me,{suspenseFallback:t.jsx(Ut,{height:44,width:132}),children:t.jsx(pb,{selectedChain:s,setSelectedChain:o})})]}),t.jsxs("div",{className:hb.content,children:[t.jsx(me,{suspenseFallback:t.jsx(He,{height:48,length:5}),children:t.jsx($2,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:l,chainInfoMap:u,chainPrices:d})}),t.jsx(me,{suspenseFallback:t.jsx(He,{height:56,length:3}),children:t.jsx(ub,{searchQuery:e,selectedChain:s,chainInfoMap:u})})]})]})},gb="_totalValue_5pf7e_1",_b="_totalLabel_5pf7e_7",xb="_totalAmount_5pf7e_13",yb="_loading_5pf7e_18",jb="_skeletonWrapper_5pf7e_23",bb="_nav_5pf7e_28",wb="_item_5pf7e_34",vb="_tabs_5pf7e_59",Cb="_tab_5pf7e_59",Ee={totalValue:gb,totalLabel:_b,totalAmount:xb,loading:yb,skeletonWrapper:jb,nav:bb,item:wb,tabs:vb,tab:Cb},Nb=()=>{const{totalValue:e,isLoading:n}=Lo();return t.jsx("div",{className:L(Ee.totalAmount,{[Ee.loading]:n}),children:ee(e)})},Ib=()=>{const e=Ml(),n=Pl(),s=Or(),o=e+s+n;return t.jsx("div",{className:Ee.totalAmount,children:ee(o)})},kb=()=>{mi(),$l();const e=Oo(),n=Ce(),s=_s(),o=_.useRef(null);return t.jsx(Fi.Provider,{value:o,children:t.jsxs(et,{ref:o,children:[t.jsxs("div",{className:Ee.totalValue,children:[t.jsx("div",{className:Ee.totalLabel,children:"Total value"}),t.jsx(me,{suspenseFallback:t.jsx("div",{className:Ee.skeletonWrapper,children:t.jsx(Ut,{height:48,width:120})}),children:e?t.jsx(Nb,{}):t.jsx(Ib,{})})]}),t.jsxs("div",{className:Ee.nav,children:[t.jsxs(nn,{to:"/send",className:Ee.item,children:[t.jsx(S.IconSend,{size:20}),t.jsx("span",{children:"Send"})]}),t.jsxs(nn,{to:"/bridge",className:Ee.item,children:[t.jsx(S.IconBridge,{size:20}),t.jsx("span",{children:"Bridge/Swap"})]}),t.jsxs(nn,{to:"/receive",className:Ee.item,children:[t.jsx(S.IconQrCode,{size:20}),t.jsx("span",{children:"Receive"})]})]}),t.jsxs(wt.Tabs.Root,{value:s,onValueChange:n,children:[t.jsxs(wt.Tabs.List,{className:Ee.tabs,children:[t.jsx(wt.Tabs.Tab,{className:Ee.tab,value:"/",children:e?"Assets":"Portfolio"}),t.jsx(wt.Tabs.Tab,{className:Ee.tab,value:"/nfts",children:"NFTs"}),t.jsx(wt.Tabs.Tab,{className:Ee.tab,value:"/activity",children:"Activity"})]}),t.jsx(wt.Tabs.Panel,{value:"/",children:e?t.jsx(S2,{}):t.jsx(fb,{})}),t.jsx(wt.Tabs.Panel,{value:"/nfts",children:t.jsx(Fy,{})}),t.jsx(wt.Tabs.Panel,{value:"/activity",children:t.jsx(wy,{})})]})]})})},Sb="_root_th990_1",Ab="_collectionName_th990_9",Tb="_nftName_th990_13",$b="_chainInfo_th990_17",Eb="_attributes_th990_21",qb="_title_th990_24",Lb="_count_th990_29",Mb="_item_th990_33",Pb="_type_th990_39",Db="_value_th990_45",Pt={root:Sb,collectionName:Ab,nftName:Tb,chainInfo:$b,attributes:Eb,title:qb,count:Lb,item:Mb,type:Pb,value:Db},Bb=()=>{const e=Ce(),n=Je(),{attributes:s}=n;return t.jsxs(dt,{title:"NFT details",children:[t.jsx(na,{normalizedNft:n,chainIconSize:14,classNames:Pt}),t.jsx(xe,{children:t.jsx(le.White,{onClick:()=>e("/nft/send",n),sm:!0,children:"Send"})}),s&&t.jsxs("div",{className:Pt.attributes,children:[t.jsxs("header",{className:Pt.title,children:["Traits ",t.jsxs("span",{className:Pt.count,children:["(",s.length,")"]})]}),t.jsx("div",{children:s.map(({trait_type:o,value:a})=>t.jsxs("div",{className:Pt.item,children:[t.jsx("div",{className:Pt.type,children:o}),t.jsx("div",{className:Pt.value,children:a})]},o))})]})]})};function Rb({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(l=>l.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>B(a).gte(o))}function Fb({denom:e,balances:n,gasPrices:s,lastFeeDenom:o,gas:a}){const r=n.find(d=>d.denom===e)?.amount??"0",i=Rb({balances:n,gasPrices:s,gas:a}),l=i.find(d=>d.denom===o);if(i.length===0)return r;if(e===o&&l){const d=B(r).minus(l.amount);return B.max(d,0).toString()}const c=i.find(d=>d.denom!==e)||i[0];if(!l&&e===c.denom){const d=B(r).minus(c.amount);return B.max(d,0).toString()}return B(r).toString()}const Ub=({chain:e,onSelect:n})=>{const s=xc(e);return t.jsx(On,{assets:s,onSelect:n})},Ob=({afterSelect:e})=>{const{watch:n,setValue:s}=_e.useFormContext(),{chainId:o,denom:a}=n(),{chainId:r}=n(),[i,l]=_.useState(r),c=Ze(i),d=de(),u=h=>{if(o===i&&a===h){e();return}s("chainId",i),s("denom",h),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(Ft.Stack,{children:t.jsx(Ft,{chains:d,value:i,onSelect:l})}),t.jsx(me,{suspenseFallback:t.jsx(On.Placeholder,{}),children:t.jsx(Ub,{chain:c,onSelect:u})},i)]})},Vb="_fields_brpej_1",Kb="_divider_brpej_11",Ka={fields:Vb,divider:Kb},zb=ye.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Wb=()=>{const{address:e,initiaAddress:n,estimateGas:s,requestTxSync:o}=De(),{register:a,watch:r,setValue:i,handleSubmit:l,formState:c}=_e.useFormContext(),{errors:d}=c,{chainId:u,denom:h,recipient:m,quantity:f,memo:p}=r(),g=Ze(u),x=An(g),y=Vo(g),b=Ko(g),C=sr(h,g),{data:v}=_t(g),{decimals:N}=C,k=x.find(R=>R.denom===h)?.amount??"0",$=v?.find(({id:R})=>R===h)?.price,{data:q=0,isLoading:V}=T.useQuery({queryKey:zb.gas({chainId:u,denom:h,recipient:m,initiaAddress:n}).queryKey,queryFn:()=>{const R=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ua.MsgSend.fromPartial({fromAddress:n,toAddress:j.InitiaAddress(m).bech32,amount:[{denom:h,amount:"1"}]})}];return s({messages:R,chainId:u})},enabled:j.InitiaAddress.validate(m),staleTime:K.INFINITY}),M=Math.ceil(q*on),I=Fb({denom:h,balances:x,gasPrices:y,lastFeeDenom:b,gas:M}),w=B(k).isZero(),U=y.some(({denom:R})=>R===h)&&V,F=w||U,{mutate:O,isPending:Z}=T.useMutation({mutationFn:({chainId:R,denom:P,quantity:Ne,recipient:je,memo:tt})=>{const Be=j.toBaseUnit(Ne,{decimals:N}),Wt=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ua.MsgSend.fromPartial({fromAddress:n,toAddress:j.InitiaAddress(je).bech32,amount:[{denom:P,amount:Be}]})}];return o({messages:Wt,memo:tt,chainId:R,gas:q,gasAdjustment:on,gasPrices:y,spendCoins:[{denom:P,amount:Be}],internal:"/"})}}),H=_.useMemo(()=>{if(!f)return"Enter amount";if(d.quantity)return d.quantity.message;if(!m)return"Enter recipient address";if(d.recipient)return d.recipient.message;if(d.memo)return d.memo.message},[f,m,d.quantity,d.recipient,d.memo]);return t.jsx(dt,{title:"Send",children:t.jsxs("form",{onSubmit:l(R=>O(R)),children:[t.jsxs("div",{className:Ka.fields,children:[t.jsx(mo,{selectButton:t.jsx(rn,{title:"Select chain and asset",content:R=>t.jsx(Ob,{afterSelect:R}),children:t.jsx(gi,{asset:C,chain:g})}),quantityInput:t.jsx(In,{balance:k,decimals:N}),balanceButton:t.jsx(hi,{onClick:()=>i("quantity",j.fromBaseUnit(I,{decimals:N}),{shouldValidate:!0}),disabled:F,children:j.formatAmount(k??"0",{decimals:N})}),value:f?$?ee(B(f).times($)):"$-":"$0"}),t.jsx("div",{className:Ka.divider}),t.jsx(Qo,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...a("memo",{validate:R=>!R||new Blob([R]).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:(V?"Estimating gas...":!1)||Z,disabled:!!H,children:H??"Confirm"})})]})})},Hb=()=>{const e=Je(),n=Vt(),s=gt(n),{chain:o=n}=e,a=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=_e.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return t.jsx(_e.FormProvider,{...i,children:t.jsx(Wb,{})})};async function yo(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 Qb(e,n){const s=new pt.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:j.InitiaAddress("0x1").bech32,contract_addr:j.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function Gb(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 Yb({collection_addr:e},{restUrl:n}){const s=await Qb(e,n);if(!s.startsWith("ibc/"))return{class_id:`evm/${j.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await yo(s,n);return o?{class_id:s,class_trace:o}:{class_id:`evm/${j.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function Zb(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 Jb({object_addr:e,collection_addr:n},{restUrl:s}){const o=await Zb(n,s);return o.startsWith("ibc/")?j.InitiaAddress.equals(j.createObjectAddress("0x1",o),n)?{class_id:o,class_trace:await yo(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await yo(o,s)}:{class_id:`move/${n.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function Xb(e,n){const s=ie.toBase64(Dt.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 ew(e,n){const{collection:s}=await z.create({prefixUrl:n}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function tw(e,n){const s=ie.toBase64(Dt.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function za(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 nw({collection_addr:e},n,s){const o=j.InitiaAddress(e).bech32,a=await Xb(o,n.restUrl),r=n.metadata?.ibc_channels?.find(({chain_id:g,version:x})=>g===s.chain_id&&x.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,l=i.split(".")[1],c=ie.toBase64(Dt.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await z.create({prefixUrl:n.restUrl}).get(`cosmwasm/wasm/v1/contract/${l}/smart/${c}`).json(),u=d??o,h=await tw(l,n.restUrl),m=await ew(o,n.indexerUrl);if(u===o)return{class_id:u,class_trace:void 0,outgoing_proxy:h};if(d&&m!==i.replace("wasm.","")){const[g,x]=za(d);return{class_id:o,class_trace:{path:g,base_class_id:x},outgoing_proxy:h}}const[f,p]=za(a);return{class_id:o,class_trace:{path:f,base_class_id:p},outgoing_proxy:h}}const sw={minimove:Jb,minievm:Yb,miniwasm:nw};async function ow({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 sw[o](e,n,s);return Object.assign(a,o==="minievm"&&{token_ids:await Gb([e.token_id],a.class_id,n.restUrl)})}const aw="_root_1tyvn_1",rw="_collectionName_1tyvn_10",iw="_nftName_1tyvn_15",cw="_chainInfo_1tyvn_19",lw="_fields_1tyvn_24",dw="_chain_1tyvn_19",oo={root:aw,collectionName:rw,nftName:iw,chainInfo:cw,fields:lw,chain:dw},uw=ye.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),mw=()=>{const e=de(),n=Je(),{chain:s,collection_addr:o}=n,{routerApiUrl:a}=Y(),r=En(),i=ae(),{address:l,initiaAddress:c,requestTxSync:d}=De(),{watch:u,setValue:h,handleSubmit:m,formState:f}=_e.useFormContext(),{errors:p}=f,g=u(),{recipient:x,dstChainId:y}=g,b=Ze(y),C=T.useQuery({queryKey:uw.simulation({collection_addr:o,nft:n,sender:c,recipient:x,srcChain:s,dstChain:b,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const I=Object.assign({from_address:c,from_chain_id:s.chainId,to_address:j.InitiaAddress(x).bech32,to_chain_id:b.chainId,collection_address:o,token_ids:[n.token_id],object_addresses:[n.object_addr]},s.chainId!==b.chainId&&await ow({nft:n,srcChain:s,intermediaryChain:i})),{msgs:w}=await z.create({prefixUrl:a}).post("nft",{json:I}).json();return w.map(E=>r.fromAmino(E))},enabled:j.InitiaAddress.validate(x)}),{data:v,isLoading:N,error:k}=C,$=T.useQueryClient(),{mutate:q,isPending:V}=T.useMutation({mutationFn:async()=>{if(!v)throw new Error("Route not found");await d({messages:v,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{$.invalidateQueries({queryKey:sa.nfts._def})}}),M=_.useMemo(()=>{if(!x)return"Enter recipient address";if(p.recipient)return p.recipient.message;if(k)return"Route not found"},[x,p.recipient,k]);return t.jsxs("form",{onSubmit:m(()=>q()),children:[t.jsx(na,{normalizedNft:n,thumbnailSize:80,classNames:oo}),t.jsxs("div",{className:oo.fields,children:[t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(rn,{title:"Destination appchain",content:I=>t.jsx(fi,{onSelect:({chainId:w})=>{h("dstChainId",w),I()},list:e,getImage:w=>w.logoUrl,getName:w=>w.name,getKey:w=>w.chainId}),className:L("input",oo.chain),children:[t.jsx(X,{src:b.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:b.name})]})]}),t.jsx(Qo,{myAddress:l,ref:Rn()})]}),t.jsx(xe,{children:t.jsx(le.White,{loading:(N?"Finding route...":!1)||V,disabled:!!M,children:M??"Confirm"})})]})},hw=()=>{const{chain:e}=Je(),n=_e.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(dt,{title:"Send NFT",children:t.jsx(_e.FormProvider,{...n,children:t.jsx(mw,{})})})},jo=()=>{const e=Ce(),n=_s(),s=kt(),{closeDrawer:o}=xt(),{closeModal:a}=bs();_.useEffect(()=>{a(),n.startsWith("/bridge/")&&n!=="/bridge/history"&&e("/bridge"),(n==="/collection"||n.startsWith("/nft"))&&e("/nfts")},[s]);const r=Tn();if(_.useEffect(()=>{r("Page View")},[n,r]),n==="/connect")return s?null:t.jsx(Ba,{onSuccess:o});if(n==="/blank")return null;if(!s)return t.jsx(Ba,{});switch(n){case"/":case"/nfts":case"/activity":return t.jsx(kb,{});case"/send":return t.jsx(Hb,{},s);case"/receive":return t.jsx(Jx,{});case"/nft":return t.jsx(Bb,{});case"/nft/send":return t.jsx(hw,{},s);case"/bridge":return t.jsx(Yp,{},s);case"/bridge/preview":return t.jsx(cg,{});case"/bridge/history":return t.jsx(Kf,{});case"/op/withdrawals":return t.jsx(Mg,{});case"/tx":return t.jsx(ri,{});case"/autosign/enable":return t.jsx(Dm,{});case"/settings":return t.jsx(N1,{});case"/settings/autosign":return t.jsx(h1,{});case"/deposit":return t.jsx(Bx,{});case"/deposit/completed":return t.jsx(xo,{type:"deposit"});case"/withdraw":return t.jsx(Rx,{});case"/withdraw/completed":return t.jsx(xo,{type:"withdraw"})}},pw="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",fw=()=>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:pw}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),gw=()=>(Sc(),Mc(),de(),El(),Or(),Sn(),Bn(),Kt(),null),_w=({children:e,...n})=>(_.useEffect(()=>{dl()},[]),Le.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(fw,{}),t.jsx(Xa.Provider,{value:{...Ja,...n},children:t.jsx(ur,{children:t.jsx(um,{children:t.jsx(J.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(dm,{children:t.jsxs(Ju,{children:[e,t.jsx(Dl,{}),t.jsx(me,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(gw,{})}),t.jsx(Id,{children:t.jsx(jo,{})}),t.jsx(wd,{children:t.jsx(jo,{})})]})})})})})})]}):null),xw=({bridge:e})=>t.jsx(ur,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Xr.Provider,{value:!!e,children:t.jsx(me,{children:t.jsx(jo,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=on;exports.DEFAULT_GAS_PRICE_MULTIPLIER=Za;exports.InterwovenKit=xw;exports.InterwovenKitProvider=_w;exports.MAINNET=Ja;exports.MoveError=Ir;exports.PRIVY_APP_ID=vo;exports.TESTNET=ic;exports.initiaPrivyWallet=lc;exports.initiaPrivyWalletConnector=cc;exports.initiaPrivyWalletOptions=bn;exports.injectStyles=Jl;exports.useAddress=kt;exports.useHexAddress=ln;exports.useInitiaAddress=te;exports.useInterwovenKit=De;exports.usePortfolio=Lo;exports.useUsernameQuery=Lr;
|