@initia/interwovenkit-react 2.6.0 → 2.8.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 CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ai=require("@privy-io/cross-app-connect/rainbow-kit"),Qe=require("wagmi"),E=require("@tanstack/react-query"),k=require("@initia/utils"),q=require("bignumber.js"),L=require("ramda"),qe=require("@lukemorales/query-key-factory"),z=require("ky"),_=require("react"),de=require("@cosmjs/encoding"),Pl=require("@mysten/bcs"),H=require("jotai"),ri=require("@amplitude/analytics-browser"),n=require("react/jsx-runtime"),Zn=require("@cosmjs/amino/build/signdoc"),ht=require("@cosmjs/crypto"),kt=require("ethers"),ma=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),En=require("@cosmjs/amino"),Gs=require("@cosmjs/proto-signing"),Yo=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Dl=require("cosmjs-types/google/protobuf/any"),ft=require("viem"),tr=require("@cosmjs/math"),Le=require("@cosmjs/stargate"),nr=require("@cosmjs/tendermint-rpc"),ii=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Ze=require("cosmjs-types/cosmos/tx/v1beta1/tx"),ha=require("@initia/amino-converter"),Bl=require("cosmjs-types/cosmos/auth/v1beta1/auth"),cn=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),sr=require("cosmjs-types/cosmos/tx/v1beta1/service"),Xe=require("date-fns"),or=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),ci=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),te=require("radix-ui"),Ge=require("usehooks-ts"),li=require("react-error-boundary"),B=require("clsx"),$e=require("react-hook-form"),Be=require("@base-ui/react/dialog"),Fl=require("xss"),M=require("@initia/icons-react"),Nt=require("@react-spring/web"),Ys=require("change-case"),Lt=require("@base-ui/react/select"),Io=require("@base-ui/react/collapsible"),ar=require("nanoid"),Ul=require("react-dom"),Ol=require("psl"),Vl=require("jotai/utils"),ui=require("react-merge-refs"),Kl=require("react-number-format"),Wl=require("react-intersection-observer"),zl=require("@noble/hashes/sha3"),ln=require("@noble/hashes/utils"),Hl=require("qr-code-styling"),Rt=require("@base-ui/react"),Ut=require("@base-ui/react/tabs"),jn=require("@base-ui/react/popover"),rr=require("cosmjs-types/cosmos/bank/v1beta1/tx"),ir=require("viem/accounts"),Ql=require("viem/chains"),Gl=require("wagmi/connectors");function Yl(e){const t=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(t,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const fa=Yl(ri),Ht=1.4,di=1.05,mi={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",theme:"dark"},Zl={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",theme:"dark",disableAnalytics:!0},pa="cmbq1ozyc006al70lx4uciz0q",Jn={id:pa,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Jl=ai.toPrivyWalletConnector(Jn),Xl=ai.toPrivyWallet(Jn),hi=_.createContext(null);function se(){const e=_.useContext(hi);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const V={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function eu(e){if(e instanceof z.HTTPError){const{response:t}=e,s=t.headers.get("content-type")??"";if(L.includes("application/json",s))try{const o=await t.json();if(o.message)return o.message}catch{return e.message}try{return await t.text()}catch{return e.message}}if(e instanceof Error){if(L.path(["code"],e)===4001||L.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const t=L.path(["error","message"],e),s=L.path(["cause","message"],e),o=L.path(["shortMessage"],e);return t||s||o||e.message}return String(e)}async function ct(e){return new Error(await eu(e))}const Zs=qe.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function js(e){const t=L.path([0,"address"],e);if(!t)throw new Error("URL not found");return t}function tu(e){const{chain_id:t,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,c=o||s,l=a?.png??"",{rpc:u,rest:m,["json-rpc"]:d,indexer:h}=r,f=js(u),g=js(m),p=js(h),y=i?.minitia?.type==="minievm"?js(d):void 0;return{...e,chainId:t,name:c,logoUrl:l,rpcUrl:f,restUrl:g,indexerUrl:p,jsonRpcUrl:y}}function nu({chainId:e,chains:t,enabled:s,error:o,isLoading:a}){if(!s)return{chain:void 0,error:null,isLoading:!1};const r=t?.find(i=>i.chain_id===e);return r?{chain:r,error:null,isLoading:!1}:o&&!t?{chain:void 0,error:o instanceof Error?o:new Error(`Failed to load chains: ${String(o)}`),isLoading:!1}:a||!t?{chain:void 0,error:null,isLoading:!0}:o?{chain:void 0,error:o instanceof Error?o:new Error(`Failed to load chains: ${String(o)}`),isLoading:!1}:{chain:void 0,error:new Error(`Chain not found: ${e}`),isLoading:!1}}function fi({customChain:e,defaultChainId:t,registryUrl:s}){return E.queryOptions({queryKey:Zs.list(s).queryKey,queryFn:()=>z.create({prefixUrl:s}).get("chains.json").json(),select:o=>(e?[e,...o.filter(r=>r.chain_id!==e.chain_id)]:o).map(tu).sort(L.descend(r=>r.chainId===t)),staleTime:V.MINUTE})}function _e(){const{defaultChainId:e,registryUrl:t,customChain:s}=se(),{data:o}=E.useSuspenseQuery(fi({customChain:s,defaultChainId:e,registryUrl:t}));return o}function su(e){const{defaultChainId:t,registryUrl:s,customChain:o}=se();return E.useQuery({...fi({customChain:o,defaultChainId:t,registryUrl:s}),enabled:e})}function pi(){const{registryUrl:e}=se(),{data:t}=E.useSuspenseQuery({queryKey:Zs.profiles(e).queryKey,queryFn:()=>z.create({prefixUrl:e}).get("profiles.json").json(),staleTime:V.MINUTE});return t}function lt(){const e=ce(),t=_e(),s=pi();return o=>{const a=t.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 _t(e){return lt()(e)}function ou(e,t){const s=su(t);return nu({chainId:e,chains:s.data,enabled:t,error:s.error,isLoading:s.isLoading})}function xn(){const{defaultChainId:e}=se();return _t(e)}function ce(){const t=_e().find(s=>s.metadata?.is_l1);if(!t)throw new Error("Layer 1 not found");return t}function gi(){return({chainId:e})=>E.queryOptions({queryKey:Zs.prices(e).queryKey,queryFn:()=>z.create({prefixUrl:"https://indexer.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:V.SECOND})}function Pt(e){const t=gi();return E.useQuery(t(e))}function ga(){const e=_e(),t=gi();return E.useQueries({queries:e.map(s=>t(s))})}const au=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ii=require("@privy-io/cross-app-connect/rainbow-kit"),Qe=require("wagmi"),E=require("@tanstack/react-query"),k=require("@initia/utils"),q=require("bignumber.js"),L=require("ramda"),qe=require("@lukemorales/query-key-factory"),z=require("ky"),_=require("react"),de=require("@cosmjs/encoding"),Dl=require("@mysten/bcs"),H=require("jotai"),ci=require("@amplitude/analytics-browser"),n=require("react/jsx-runtime"),Zn=require("@cosmjs/amino/build/signdoc"),ht=require("@cosmjs/crypto"),kt=require("ethers"),ha=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),En=require("@cosmjs/amino"),Gs=require("@cosmjs/proto-signing"),Yo=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Bl=require("cosmjs-types/google/protobuf/any"),ft=require("viem"),sr=require("@cosmjs/math"),Le=require("@cosmjs/stargate"),or=require("@cosmjs/tendermint-rpc"),li=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Ze=require("cosmjs-types/cosmos/tx/v1beta1/tx"),fa=require("@initia/amino-converter"),Fl=require("cosmjs-types/cosmos/auth/v1beta1/auth"),cn=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),ar=require("cosmjs-types/cosmos/tx/v1beta1/service"),Xe=require("date-fns"),rr=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),ui=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),te=require("radix-ui"),Ge=require("usehooks-ts"),di=require("react-error-boundary"),B=require("clsx"),$e=require("react-hook-form"),Be=require("@base-ui/react/dialog"),Ul=require("xss"),M=require("@initia/icons-react"),Nt=require("@react-spring/web"),Ys=require("change-case"),Lt=require("@base-ui/react/select"),Io=require("@base-ui/react/collapsible"),ir=require("nanoid"),Ol=require("react-dom"),Vl=require("psl"),Kl=require("jotai/utils"),mi=require("react-merge-refs"),Wl=require("react-number-format"),zl=require("react-intersection-observer"),Hl=require("@noble/hashes/sha3"),ln=require("@noble/hashes/utils"),Ql=require("qr-code-styling"),Rt=require("@base-ui/react"),Ut=require("@base-ui/react/tabs"),jn=require("@base-ui/react/popover"),cr=require("cosmjs-types/cosmos/bank/v1beta1/tx"),lr=require("viem/accounts"),Gl=require("viem/chains"),Yl=require("wagmi/connectors");function Zl(e){const t=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(t,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const pa=Zl(ci),Ht=1.4,hi=1.05,fi={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",theme:"dark"},Jl={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",theme:"dark",disableAnalytics:!0},ga="cmbq1ozyc006al70lx4uciz0q",Jn={id:ga,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Xl=ii.toPrivyWalletConnector(Jn),eu=ii.toPrivyWallet(Jn),pi=_.createContext(null);function se(){const e=_.useContext(pi);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const V={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function tu(e){if(e instanceof z.HTTPError){const{response:t}=e,s=t.headers.get("content-type")??"";if(L.includes("application/json",s))try{const o=await t.json();if(o.message)return o.message}catch{return e.message}try{return await t.text()}catch{return e.message}}if(e instanceof Error){if(L.path(["code"],e)===4001||L.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const t=L.path(["error","message"],e),s=L.path(["cause","message"],e),o=L.path(["shortMessage"],e);return t||s||o||e.message}return String(e)}async function ct(e){return new Error(await tu(e))}const Zs=qe.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function js(e){const t=L.path([0,"address"],e);if(!t)throw new Error("URL not found");return t}function nu(e){const{chain_id:t,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,c=o||s,l=a?.png??"",{rpc:u,rest:m,["json-rpc"]:d,indexer:h}=r,f=js(u),g=js(m),p=js(h),y=i?.minitia?.type==="minievm"?js(d):void 0;return{...e,chainId:t,name:c,logoUrl:l,rpcUrl:f,restUrl:g,indexerUrl:p,jsonRpcUrl:y}}function su({chainId:e,chains:t,enabled:s,error:o,isLoading:a}){if(!s)return{chain:void 0,error:null,isLoading:!1};const r=t?.find(i=>i.chain_id===e);return r?{chain:r,error:null,isLoading:!1}:o&&!t?{chain:void 0,error:o instanceof Error?o:new Error(`Failed to load chains: ${String(o)}`),isLoading:!1}:a||!t?{chain:void 0,error:null,isLoading:!0}:o?{chain:void 0,error:o instanceof Error?o:new Error(`Failed to load chains: ${String(o)}`),isLoading:!1}:{chain:void 0,error:new Error(`Chain not found: ${e}`),isLoading:!1}}function gi({customChain:e,defaultChainId:t,registryUrl:s}){return E.queryOptions({queryKey:Zs.list(s).queryKey,queryFn:()=>z.create({prefixUrl:s}).get("chains.json").json(),select:o=>(e?[e,...o.filter(r=>r.chain_id!==e.chain_id)]:o).map(nu).sort(L.descend(r=>r.chainId===t)),staleTime:V.MINUTE})}function _e(){const{defaultChainId:e,registryUrl:t,customChain:s}=se(),{data:o}=E.useSuspenseQuery(gi({customChain:s,defaultChainId:e,registryUrl:t}));return o}function ou(e){const{defaultChainId:t,registryUrl:s,customChain:o}=se();return E.useQuery({...gi({customChain:o,defaultChainId:t,registryUrl:s}),enabled:e})}function _i(){const{registryUrl:e}=se(),{data:t}=E.useSuspenseQuery({queryKey:Zs.profiles(e).queryKey,queryFn:()=>z.create({prefixUrl:e}).get("profiles.json").json(),staleTime:V.MINUTE});return t}function lt(){const e=ce(),t=_e(),s=_i();return o=>{const a=t.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 _t(e){return lt()(e)}function au(e,t){const s=ou(t);return su({chainId:e,chains:s.data,enabled:t,error:s.error,isLoading:s.isLoading})}function xn(){const{defaultChainId:e}=se();return _t(e)}function ce(){const t=_e().find(s=>s.metadata?.is_l1);if(!t)throw new Error("Layer 1 not found");return t}function yi(){return({chainId:e})=>E.queryOptions({queryKey:Zs.prices(e).queryKey,queryFn:()=>z.create({prefixUrl:"https://indexer.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:V.SECOND})}function Pt(e){const t=yi();return E.useQuery(t(e))}function _a(){const e=_e(),t=yi();return E.useQueries({queries:e.map(s=>t(s))})}const ru=`<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>`,ru=encodeURIComponent(au),_a=`data:image/svg+xml;utf8,${ru}`,$n=qe.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,t)=>[e,t],resource:(e,t)=>[e.chainId,t.denom],denom:(e,t)=>[e,t],metadata:(e,t)=>[e,t]});function iu(e){const{base:t,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:c,traces:l}=e,u=o.find(d=>d.denom===a)?.exponent??o.find(d=>d.denom===t)?.exponent??L.head(o)?.exponent??0,m=r?.png??"";return{denom:t,symbol:s,decimals:u,logoUrl:m,name:i,address:c,traces:l}}function _i(){const e=E.useQueryClient();return t=>{const s=t?.metadata?.assetlist;return E.queryOptions({queryKey:$n.list(s).queryKey,queryFn:async()=>s?z.get(s).json():{assets:[]},select:({assets:o})=>{if(!t)return[];const a=o.map(iu);for(const r of a)e.setQueryData($n.item(t.chainId,r.denom).queryKey,r);return a},staleTime:V.MINUTE})}}function Qt(e){const t=_i(),{data:s}=E.useSuspenseQuery(t(e));return s}function os(){const e=_e(),t=_i();return E.useQueries({queries:e.map(s=>t(s))})}function St(e){const t=Qt(e),s=ce(),o=Qt(s),a=xi(e);return r=>{const i=t.find(l=>l.denom===r);if(i)return i;const c=o.find(l=>l.denom===a(r));return c?{...c,denom:r}:{denom:r,symbol:"",decimals:0,logoUrl:_a}}}function yi(e,t){const s=St(t),a=E.useQueryClient().getQueryData($n.item(t.chainId,e).queryKey);return a||s(e)}function xi(e){const t=ce(),s=Qt(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const r=s.find(i=>i.denom===o)??s.find(i=>i.traces?.some(c=>c.counterparty.base_denom===o));if(r?.traces){for(const i of r.traces)if(i.counterparty.chain_name===t.chain_name)return i.counterparty.base_denom}}const a=t.metadata?.ibc_channels?.find(({chain_id:r,version:i})=>r===e.chain_id&&i==="ics20-1")?.channel_id;return a?k.getIbcDenom(a,o):""}}function Bs(e,t){const s=ce(),o=z.create({prefixUrl:s.restUrl}),a=t?.failSoft??!1,r=E.useSuspenseQueries({queries:e.map(i=>({queryFn:async()=>{try{return await o.get("initia/move/v1/denom",{searchParams:{metadata:i}}).json()}catch(c){if(a)return{denom:""};throw c}},queryKey:[...$n.denom(s.restUrl,i).queryKey,a],select:c=>[i,c.denom],staleTime:V.INFINITY}))});return new Map(r.map(({data:i})=>i))}function cu(e){return e.pagination?.next_key??null}async function Js(e,t,s){const o=z.create(t),a=async(r,i)=>{const c=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),l=c[s]??[],u=cu(c),m=[...r,...l];return u?a(m,u):m};return a([],null)}const cr="usernames";function lu({restUrl:e,moduleAddress:t}){const{viewFunction:s}=k.createMoveClient(e);async function o(i){if(!k.InitiaAddress.validate(i))return null;const c=await s({moduleAddress:t,moduleName:cr,functionName:"get_name_from_address",typeArgs:[],args:[de.toBase64(k.InitiaAddress(i,32).bytes)]});return c?c+".init":null}function a(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function r(i){if(!a(i))return null;const c=await s({moduleAddress:t,moduleName:cr,functionName:"get_address_from_name",typeArgs:[],args:[Pl.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return c?k.InitiaAddress(c).bech32:null}return{restUrl:e,getUsername:o,getAddress:r,validateUsername:a}}const Xs=qe.createQueryKeys("interwovenkit:account",{username:(e,t)=>[e,t],address:(e,t)=>[e,t],balances:(e,t)=>[e,t],txs:(e,t)=>[e,t]});function bi(){const{restUrl:e}=ce(),{usernamesModuleAddress:t}=se();return lu({restUrl:e,moduleAddress:t})}function wi(){const e=ie();return t=>E.queryOptions({queryKey:Xs.balances(t.restUrl,e||"").queryKey,queryFn:()=>e?Js(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:t.restUrl},"balances"):[],staleTime:V.SECOND})}function as(e){const t=wi(),{data:s}=E.useSuspenseQuery(t(e));return s}function uu(){const e=_e(),t=wi();return E.useQueries({queries:e.map(s=>t(s))})}function du(e){const t=as(e),s=Qt(e),o=St(e),a=xi(e),{data:r}=Pt(e),i=l=>e.fees.fee_tokens.some(u=>u.denom===l),c=l=>s.some(u=>u.denom===l);return L.sortWith([L.descend(({denom:l})=>a(l)==="uinit"),L.descend(({denom:l})=>i(l)),L.descend(({value:l})=>l),L.descend(({denom:l})=>c(l)),({balance:l},{balance:u})=>q(u).comparedTo(l)??0,L.descend(({symbol:l})=>l.toLowerCase())],t.filter(({amount:l})=>!q(l).isZero()).map(({amount:l,denom:u})=>{const m=o(u),d=r?.find(({id:f})=>f===m?.denom)?.price??0,h=q(l).times(d).div(q(10).pow(m.decimals)).toNumber();return{...m,balance:l,price:d,value:h}}))}const vi=_.createContext(null);function eo(){return _.useContext(vi)}function ji(){const{location:e}=eo();return e}function to(){const{path:e}=ji();return e}function et(){const{state:e={}}=ji();return e}function Ci(){const{history:e}=eo();return e}function Me(){const{navigate:e}=eo();return e}function ya(){const{reset:e}=eo();return e}const mn=({to:e,state:t,shouldReset:s,children:o,onClick:a,...r})=>{const i=Me(),c=ya(),l=u=>{u.preventDefault(),a?.(u),s?c(e,t):i(e,t)};return n.jsx("button",{type:"button",...r,onClick:l,children:o})},ki=({children:e,initialEntry:t})=>{const[s,o]=_.useState([t??{path:"/"}]),a=s[s.length-1],r=_.useCallback((c,l)=>{o(u=>{if(typeof c=="string")return[...u,{path:c,state:l}];const m=u.length+c;if(m<1)return u;const d=L.take(m,u);return l!==void 0?L.adjust(m-1,h=>({...h,state:l}),d):d})},[]),i=_.useCallback((c,l)=>{o([{path:c,state:l}])},[]);return n.jsx(vi.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},mu="c33b940c24c17e95f7d9d525d508ac61";function hu(){const{disableAnalytics:e}=se();_.useEffect(()=>{e||fa.init(mu,{autocapture:!1})},[e])}function fu(){const{connector:e}=Qe.useAccount(),{defaultChainId:t,disableAnalytics:s}=se();_.useEffect(()=>{const o=new ri.Identify;e?.name&&o.set("connector",e.name),t&&o.set("defaultChainId",t),fa.identify(o)},[t,e?.name,s])}function Pn(){const e=to();return _.useCallback((s,o)=>{fa.track(s,{path:e,...o})},[e])}function pu(e){return e.type==="initia/PubKeyEthSecp256k1"}const gu={...En.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function Ni(e){if(pu(e)){const t=Yo.PubKey.fromPartial({key:de.fromBase64(e.value)});return Dl.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(Yo.PubKey.encode(t).finish())})}return Gs.encodePubkey(e)}function xa(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:gu.ethsecp256k1,value:de.toBase64(e)}}function Ii(e,t){if(t.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:xa(e),signature:de.toBase64(t)}}function _u(e){return`Enable Auto-Sign for InterwovenKit
4
+ </svg>`,iu=encodeURIComponent(ru),ya=`data:image/svg+xml;utf8,${iu}`,$n=qe.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,t)=>[e,t],resource:(e,t)=>[e.chainId,t.denom],denom:(e,t)=>[e,t],metadata:(e,t)=>[e,t]});function cu(e){const{base:t,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:c,traces:l}=e,u=o.find(d=>d.denom===a)?.exponent??o.find(d=>d.denom===t)?.exponent??L.head(o)?.exponent??0,m=r?.png??"";return{denom:t,symbol:s,decimals:u,logoUrl:m,name:i,address:c,traces:l}}function xi(){const e=E.useQueryClient();return t=>{const s=t?.metadata?.assetlist;return E.queryOptions({queryKey:$n.list(s).queryKey,queryFn:async()=>s?z.get(s).json():{assets:[]},select:({assets:o})=>{if(!t)return[];const a=o.map(cu);for(const r of a)e.setQueryData($n.item(t.chainId,r.denom).queryKey,r);return a},staleTime:V.MINUTE})}}function Qt(e){const t=xi(),{data:s}=E.useSuspenseQuery(t(e));return s}function os(){const e=_e(),t=xi();return E.useQueries({queries:e.map(s=>t(s))})}function St(e){const t=Qt(e),s=ce(),o=Qt(s),a=wi(e);return r=>{const i=t.find(l=>l.denom===r);if(i)return i;const c=o.find(l=>l.denom===a(r));return c?{...c,denom:r}:{denom:r,symbol:"",decimals:0,logoUrl:ya}}}function bi(e,t){const s=St(t),a=E.useQueryClient().getQueryData($n.item(t.chainId,e).queryKey);return a||s(e)}function wi(e){const t=ce(),s=Qt(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const r=s.find(i=>i.denom===o)??s.find(i=>i.traces?.some(c=>c.counterparty.base_denom===o));if(r?.traces){for(const i of r.traces)if(i.counterparty.chain_name===t.chain_name)return i.counterparty.base_denom}}const a=t.metadata?.ibc_channels?.find(({chain_id:r,version:i})=>r===e.chain_id&&i==="ics20-1")?.channel_id;return a?k.getIbcDenom(a,o):""}}function Bs(e,t){const s=ce(),o=z.create({prefixUrl:s.restUrl}),a=t?.failSoft??!1,r=E.useSuspenseQueries({queries:e.map(i=>({queryFn:async()=>{try{return await o.get("initia/move/v1/denom",{searchParams:{metadata:i}}).json()}catch(c){if(a)return{denom:""};throw c}},queryKey:[...$n.denom(s.restUrl,i).queryKey,a],select:c=>[i,c.denom],staleTime:V.INFINITY}))});return new Map(r.map(({data:i})=>i))}function lu(e){return e.pagination?.next_key??null}async function Js(e,t,s){const o=z.create(t),a=async(r,i)=>{const c=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),l=c[s]??[],u=lu(c),m=[...r,...l];return u?a(m,u):m};return a([],null)}const ur="usernames";function uu({restUrl:e,moduleAddress:t}){const{viewFunction:s}=k.createMoveClient(e);async function o(i){if(!k.InitiaAddress.validate(i))return null;const c=await s({moduleAddress:t,moduleName:ur,functionName:"get_name_from_address",typeArgs:[],args:[de.toBase64(k.InitiaAddress(i,32).bytes)]});return c?c+".init":null}function a(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function r(i){if(!a(i))return null;const c=await s({moduleAddress:t,moduleName:ur,functionName:"get_address_from_name",typeArgs:[],args:[Dl.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return c?k.InitiaAddress(c).bech32:null}return{restUrl:e,getUsername:o,getAddress:r,validateUsername:a}}const Xs=qe.createQueryKeys("interwovenkit:account",{username:(e,t)=>[e,t],address:(e,t)=>[e,t],balances:(e,t)=>[e,t],txs:(e,t)=>[e,t]});function vi(){const{restUrl:e}=ce(),{usernamesModuleAddress:t}=se();return uu({restUrl:e,moduleAddress:t})}function ji(){const e=ie();return t=>E.queryOptions({queryKey:Xs.balances(t.restUrl,e||"").queryKey,queryFn:()=>e?Js(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:t.restUrl},"balances"):[],staleTime:V.SECOND})}function as(e){const t=ji(),{data:s}=E.useSuspenseQuery(t(e));return s}function du(){const e=_e(),t=ji();return E.useQueries({queries:e.map(s=>t(s))})}function mu(e){const t=as(e),s=Qt(e),o=St(e),a=wi(e),{data:r}=Pt(e),i=l=>e.fees.fee_tokens.some(u=>u.denom===l),c=l=>s.some(u=>u.denom===l);return L.sortWith([L.descend(({denom:l})=>a(l)==="uinit"),L.descend(({denom:l})=>i(l)),L.descend(({value:l})=>l),L.descend(({denom:l})=>c(l)),({balance:l},{balance:u})=>q(u).comparedTo(l)??0,L.descend(({symbol:l})=>l.toLowerCase())],t.filter(({amount:l})=>!q(l).isZero()).map(({amount:l,denom:u})=>{const m=o(u),d=r?.find(({id:f})=>f===m?.denom)?.price??0,h=q(l).times(d).div(q(10).pow(m.decimals)).toNumber();return{...m,balance:l,price:d,value:h}}))}const Ci=_.createContext(null);function eo(){return _.useContext(Ci)}function ki(){const{location:e}=eo();return e}function to(){const{path:e}=ki();return e}function et(){const{state:e={}}=ki();return e}function Ni(){const{history:e}=eo();return e}function Me(){const{navigate:e}=eo();return e}function xa(){const{reset:e}=eo();return e}const mn=({to:e,state:t,shouldReset:s,children:o,onClick:a,...r})=>{const i=Me(),c=xa(),l=u=>{u.preventDefault(),a?.(u),s?c(e,t):i(e,t)};return n.jsx("button",{type:"button",...r,onClick:l,children:o})},Ii=({children:e,initialEntry:t})=>{const[s,o]=_.useState([t??{path:"/"}]),a=s[s.length-1],r=_.useCallback((c,l)=>{o(u=>{if(typeof c=="string")return[...u,{path:c,state:l}];const m=u.length+c;if(m<1)return u;const d=L.take(m,u);return l!==void 0?L.adjust(m-1,h=>({...h,state:l}),d):d})},[]),i=_.useCallback((c,l)=>{o([{path:c,state:l}])},[]);return n.jsx(Ci.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},hu="c33b940c24c17e95f7d9d525d508ac61";function fu(){const{disableAnalytics:e}=se();_.useEffect(()=>{e||pa.init(hu,{autocapture:!1})},[e])}function pu(){const{connector:e}=Qe.useAccount(),{defaultChainId:t,disableAnalytics:s}=se();_.useEffect(()=>{const o=new ci.Identify;e?.name&&o.set("connector",e.name),t&&o.set("defaultChainId",t),pa.identify(o)},[t,e?.name,s])}function Pn(){const e=to();return _.useCallback((s,o)=>{pa.track(s,{path:e,...o})},[e])}function gu(e){return e.type==="initia/PubKeyEthSecp256k1"}const _u={...En.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function Ai(e){if(gu(e)){const t=Yo.PubKey.fromPartial({key:de.fromBase64(e.value)});return Bl.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(Yo.PubKey.encode(t).finish())})}return Gs.encodePubkey(e)}function ba(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:_u.ethsecp256k1,value:de.toBase64(e)}}function Si(e,t){if(t.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:ba(e),signature:de.toBase64(t)}}function yu(e){return`Enable Auto-Sign for InterwovenKit
5
5
 
6
6
  Origin: ${e}
7
7
 
8
- Sign this message to create a dedicated signing wallet for auto-sign transactions. This wallet will only be used to sign transactions on your behalf when auto-sign is enabled.`}async function yu(e,t){const s=ft.hexToBytes(e);if(s.length!==65)throw new Error(`Invalid signature length: expected 65 bytes (r: 32, s: 32, v: 1), got ${s.length}`);const o=s.slice(0,64),a=ft.hexToBytes(ft.keccak256(ft.bytesToHex(o))),r=ht.Bip39.encode(a),i=await ht.Bip39.mnemonicToSeed(r),c=ht.stringToPath("m/44'/60'/0'/0/0"),{privkey:l}=ht.Slip10.derivePath(ht.Slip10Curve.Secp256k1,i,c),u=await ht.Secp256k1.makeKeypair(l),m=ht.Secp256k1.compressPubkey(u.pubkey),h=u.pubkey.slice(1),f=ft.bytesToHex(h),g=ft.keccak256(f),p=ft.hexToBytes(g).slice(-20),y=de.toBech32(t,p);return{privateKey:l,publicKey:m,address:y}}function Cs(e,t){return`${e}:${t}`}const rs=H.atom(null),Xn=H.atom({}),es=H.atom({}),no=H.atom({}),lr=H.atom(0),xu="autosign:";function bu(e,t){const s=e.get(lr)+1;return e.set(lr,s),`${t}:${s}`}function Fs(e,t){return e.get(no)[t]}function wu(e,t,s){e.set(no,o=>({...o,[t]:s}))}function Ai(e,t){e.set(no,s=>{const o={...s};return delete o[t],o})}function vu(e,t,s){const o=Fs(e,t);!o||o.token!==s||Ai(e,t)}function ju(e,t,s){const o=Fs(e,t);return!!o&&o.token===s}function ks(e,t){return e.get(es)[t]}function Cu(e,t,s){e.set(es,o=>({...o,[t]:s}))}function ku(e,t){e.set(es,s=>{const o={...s};return delete o[t],o})}function Nu(e,t,s){e.set(Xn,o=>({...o,[t]:s}))}function Iu(e,t){e.set(Xn,s=>{const o={...s};return delete o[t],o})}function Si(e,t){return`${xu}${e}:${t}`}function Au(e,t,s){try{return e.getItem(Si(t,s))}catch{return null}}function Su(e,t,s,o){try{e.setItem(Si(t,s),o)}catch{}}function Ti(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function ba(e,t){const s=Ti();if(s)return Au(s,e,t)}function Tu(e,t,s){const o=Ti();o&&Su(o,e,t,s)}function Eu(e){return{publicKey:e.publicKey,address:e.address}}function Us(e){e&&e.fill(0)}function Ei(e){e.set(no,{});const t=e.get(es);for(const s of Object.values(t))Us(s);e.set(es,{}),e.set(Xn,{})}function $u(e,t){return e!==""&&e!==t}function Mu(){const e=ie(),t=H.useStore(),s=_.useRef(e);_.useEffect(()=>{const o=s.current;$u(o,e)&&Ei(t),s.current=e},[t,e])}class Lu{constructor(t,s){this.wallet=t,this.privateKey=s}async getAccounts(){return[{address:this.wallet.address,algo:"ethsecp256k1",pubkey:this.wallet.publicKey}]}async signAmino(t,s){if(this.wallet.address!==t)throw new Error("Signer address does not match the derived wallet address");const o=Zn.escapeCharacters(Zn.sortedJsonStringify(s)),a=kt.ethers.hashMessage(o),r=de.fromHex(a.replace("0x","")),i=await ht.Secp256k1.createSignature(r,this.privateKey),c=new Uint8Array([...i.r(32),...i.s(32)]),l=Ii(this.wallet.publicKey,c);return{signed:s,signature:l}}}function so(){const e=H.useStore(),{signMessageAsync:t}=Qe.useSignMessage(),s=lt(),o=ie();return{deriveWallet:async u=>{if(!o)throw new Error("User address not available");const m=s(u),d=Cs(o,m.bech32_prefix),h=e.get(Xn)[d];if(h&&ks(e,d))return h;const f=Fs(e,d);if(f)return f.promise;const g=bu(e,d),p=(async()=>{try{const y=window.location.origin,x=_u(y),b=await t({message:x}),j=await yu(b,m.bech32_prefix),v=Eu(j);if(ju(e,d,g))return Cu(e,d,j.privateKey),Nu(e,d,v),v;throw Us(j.privateKey),new Error("Wallet derivation was cancelled")}finally{vu(e,d,g)}})();return wu(e,d,{promise:p,token:g}),p},getWallet:u=>{if(!o)return;const m=s(u),d=Cs(o,m.bech32_prefix);if(ks(e,d))return e.get(Xn)[d]},getWalletPrivateKey:u=>{if(!o)return;const m=s(u),d=Cs(o,m.bech32_prefix);return ks(e,d)},clearWallet:u=>{if(!o)return;const m=s(u),d=Cs(o,m.bech32_prefix),h=ks(e,d);Fs(e,d)&&Ai(e,d),Us(h),ku(e,d),Iu(e,d)},clearAllWallets:()=>{Ei(e)}}}function $i({granteeAddress:e,messages:t,encoder:s}){return[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:ma.MsgExec.fromPartial({grantee:e,msgs:t.map(o=>({typeUrl:o.typeUrl,value:s.encode(o)}))})}]}async function qu({chainId:e,granterAddress:t,messages:s,fee:o,memo:a,derivedWallet:r,privateKey:i,encoder:c,signWithEthSecp256k1:l}){const u=$i({granteeAddress:r.address,messages:s,encoder:c}),m={...o,granter:t},d=new Uint8Array(i),h=new Lu(r,d);try{return await l(e,r.address,u,m,a,{customSigner:h})}finally{Us(d)}}const wt="interwovenkit",Je="uinit",pt="INIT",it=6,Ru="uoinit",Pu="omniINIT",Mi="https://app.initia.xyz",wa=`${Mi}/liquidity/my`,Du=`${Mi}/vip/my`,Bu=1e3,Li=60*Bu,qi=60*Li,ur=24*qi,he={PUBLIC_KEY:`${wt}:public-key`,BRIDGE_SRC_CHAIN_ID:`${wt}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${wt}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${wt}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${wt}:bridge:dst-denom`,BRIDGE_QUANTITY:`${wt}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${wt}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${wt}:bridge:route-type`,BRIDGE_HISTORY:`${wt}:bridge:history`,OP_REMINDER:`${wt}:op:reminder`},Ri=H.atom(!1),Pi=H.atom(!1);function Dt(){const e=ya(),[t,s]=H.useAtom(Ri),o=H.useSetAtom(Pi),a=Pn();return{isDrawerOpen:t,openDrawer:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function Dn(){const e=ya(),[t,s]=H.useAtom(Pi),o=H.useSetAtom(Ri),a=Pn();return{isModalOpen:t,openModal:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function Di(){const e=Me(),{closeDrawer:t}=Dt(),{closeModal:s}=Dn(),{disconnect:o}=Qe.useDisconnect(),{clearAllWallets:a}=so();return()=>{e("/blank"),t(),s(),o(),a(),localStorage.removeItem(he.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(he.BRIDGE_SRC_DENOM),localStorage.removeItem(he.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(he.BRIDGE_DST_DENOM),localStorage.removeItem(he.BRIDGE_QUANTITY),localStorage.removeItem(he.BRIDGE_SLIPPAGE_PERCENT)}}function Fu(){const e=Yt(),t=xn(),{openModal:s}=Dn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,srcOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??t.chainId,u=a.map(m=>({denom:m,chainId:l}));s("/deposit",{localOptions:u,remoteOptions:i,recipientAddress:c})}}function Uu(){const e=Yt(),t=xn(),{openModal:s}=Dn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,dstOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??t.chainId,u=a.map(m=>({denom:m,chainId:l}));s("/withdraw",{localOptions:u,remoteOptions:i,recipientAddress:c})}}function Ou(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:t}=Yo.PubKey.decode(e.value);return En.encodeSecp256k1Pubkey(t)}return Gs.decodeOptionalPubkey(e)}function Vu({typeUrl:e,value:t}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Bl.BaseAccount.decode(t),i=Ou(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Le.accountFromAny({typeUrl:e,value:t})}const Bi="/cosmos.feegrant.v1beta1.MsgGrantAllowance",Fi="/cosmos.feegrant.v1beta1.AllowedMsgAllowance",Ui="cosmos-sdk/AllowedMsgAllowance";function Ku(){const e=ha.aminoConverters[Bi];if(!e)throw new Error("Missing base converter for MsgGrantAllowance");return e}const Os=Ku();function Oi(e){if(e.typeUrl===Fi){const t=cn.AllowedMsgAllowance.decode(e.value);if(!t.allowance)throw new Error("AllowedMsgAllowance is missing nested allowance");return{type:Ui,value:{allowance:Oi(t.allowance),allowed_messages:t.allowedMessages}}}return Os.toAmino({granter:"",grantee:"",allowance:e}).allowance}function Vi(e){if(e.type===Ui){const t=e.value;if(!t.allowance)throw new Error("AllowedMsgAllowance amino value is missing nested allowance");const s=Vi(t.allowance);return{typeUrl:Fi,value:cn.AllowedMsgAllowance.encode(cn.AllowedMsgAllowance.fromPartial({allowance:s,allowedMessages:t.allowed_messages??t.allowedMessages??[]})).finish()}}return Os.fromAmino({granter:"",grantee:"",allowance:e}).allowance}const Wu={...ha.aminoConverters,[Bi]:{...Os,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:Oi(e.allowance)}:Os.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:Vi(e.allowance)})}},is=()=>{const e=se();return new Gs.Registry([...ha.protoRegistry,...e.protoTypes??[]])},cs=()=>{const e=se();return{...Wu,...e.aminoConverters}},bn=()=>{const e=cs();return new Le.AminoTypes(e)};class zu{constructor(t,s,o){this.address=t,this.signMessage=s,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const t=`${he.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(t);if(s)return this.cachedPublicKey=de.fromHex(s),de.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(t,de.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(t,de.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?de.fromBase64(s):null}catch{return null}}async getPublicKey(){const t="Sign this message to identify your Initia account.",s=await this.signMessage(t),o=kt.ethers.hashMessage(t),a=kt.ethers.SigningKey.recoverPublicKey(o,s);return ht.Secp256k1.compressPubkey(de.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(t,s){if(this.address!==t)throw new Error("Signer address does not match the provided address");const o=Zn.escapeCharacters(Zn.sortedJsonStringify(s)),a=await this.signMessage(o),r=de.fromHex(a.replace("0x","")).subarray(0,-1),c=ht.Secp256k1Signature.fromFixedLength(r).toFixedLength(),l=Ii(await this.getCachedPublicKey(),c);return{signed:s,signature:l}}}function Ki(){const e=is(),t=bn(),s=ls(),o=us();return async function(a,r,i,c,l,u){const m=u?.customSigner??s;if(!m)throw new Error("Signer not initialized");const d=await o(a),{accountNumber:h,sequence:f}=await Wi({getSequence:N=>d.getSequence(N),signerAddress:r,incrementSequence:u?.incrementSequence??0,allowMissingAccount:!!u?.customSigner}),[g]=await m.getAccounts(),p=Ni(xa(g.pubkey)),y=ii.SignMode.SIGN_MODE_EIP_191,x=i.map(N=>t.toAmino(N)),b=Zn.makeSignDoc(x,c,a,l,h,f),{signature:j,signed:v}=await m.signAmino(r,b),C={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:v.msgs.map(N=>t.fromAmino(N)),memo:l}},I=e.encode(C),T=tr.Int53.fromString(v.fee.gas).toNumber(),A=tr.Int53.fromString(v.sequence).toNumber(),$=Gs.makeAuthInfoBytes([{pubkey:p,sequence:A}],v.fee.amount,T,v.fee.granter,v.fee.payer,y);return Ze.TxRaw.fromPartial({bodyBytes:I,authInfoBytes:$,signatures:[de.fromBase64(j.signature)]})}}function Hu(e,t){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(t):!1}async function Wi({getSequence:e,signerAddress:t,incrementSequence:s,allowMissingAccount:o}){try{const{accountNumber:a,sequence:r}=await e(t);return{accountNumber:a,sequence:r+s}}catch(a){if(o&&Hu(a,t))return{accountNumber:0,sequence:s};throw a}}function ls(){const e=ie(),{signMessageAsync:t}=Qe.useSignMessage(),s=ce();return _.useMemo(()=>new zu(e,o=>t({message:o}),s.restUrl),[e,t,s.restUrl])}const Ao=new Map,Rs=new Map;function Qu(e,t){const s=`${e}:${t}`;Rs.delete(s)}function va(){const e=lt();return async t=>{if(Ao.has(t))return Ao.get(t);const{rpcUrl:s}=e(t),o=await nr.Comet38Client.create(new nr.HttpClient(s));return Ao.set(t,o),o}}function us(){const e=is(),t=bn(),s=ls(),o=ie(),a=va();return async r=>{const i=`${o}:${r}`;if(Rs.has(i))return Rs.get(i);if(!s)throw new Error("Signer not initialized");const c=await a(r),l=await Le.SigningStargateClient.createWithSigner(c,s,{registry:e,aminoTypes:t,accountParser:Vu,broadcastPollIntervalMs:500});return Rs.set(i,l),l}}function zi(){const{connector:e}=Qe.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new kt.BrowserProvider(await e.getProvider())}}class hn extends Error{constructor(t){super(t),this.name="TimeoutError"}}function Hi(e,t,s){let o;const a=new Promise((r,i)=>{o=setTimeout(()=>i(new hn(s)),t)});return Promise.race([e,a]).finally(()=>{clearTimeout(o)})}function Qi(e){return e.filter(t=>t.authorization["@type"].includes("GenericAuthorization")).filter(t=>!!t.authorization.msg)}function Gi(e){return e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance"?e.allowance?.expiration:e.expiration}function Gu(e){if(e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance")return e.allowedMessages??e.allowed_messages??[]}function Yi(){const e=ie(),t=lt();return{fetchFeegrant:async(r,i)=>{if(!e)return null;const c=t(r),l=z.create({prefixUrl:c.restUrl});try{const{allowance:u}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${i}`).json();return u}catch(u){if(u instanceof z.HTTPError&&[404,500].includes(u.response.status))return null;throw u}},fetchGrants:async(r,i)=>{if(!e)return[];const c=t(r),l=z.create({prefixUrl:c.restUrl}),{grants:u}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:i}}).json();return u},fetchAllGrants:async r=>{const i=t(r),c=e;if(!c)return[];const l=`cosmos/authz/v1beta1/grants/granter/${c}`,u=await Js(l,{prefixUrl:i.restUrl},"grants");return Qi(u)}}}const Vs=qe.createQueryKeys("interwovenkit:autosign",{expirations:(e,t,s)=>[e,t,s],grants:(e,t)=>[e,t]}),Yu=4,Zi=4;function Zu(e){return Object.entries(e).sort(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${t}:${[...s].sort().join(",")}`).join("|")}function ja(){const e=se(),t=xn(),{enableAutoSign:s,defaultChainId:o}=e;if(!s)return{[o]:[]};if(typeof s!="boolean")return s;switch(t.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 Ju(){const{data:e}=oo(),t=ja();return(s,o)=>{const a=o.every(i=>{const c=t[s];return c?c.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function oo(){const e=ie(),t=ja(),s=Zu(t),{fetchFeegrant:o,fetchAllGrants:a}=Yi();return E.useQuery({queryKey:Vs.expirations(e,s,t).queryKey,queryFn:()=>Xu({initiaAddress:e,messageTypes:t,fetchAllGrants:a,fetchFeegrant:o}),staleTime:V.MINUTE,retry:1})}async function Xu(e){const{initiaAddress:t,messageTypes:s,fetchAllGrants:o,fetchFeegrant:a}=e;if(!t)return{expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}};const r={},i={},c={},l={},u=[];for(const[d,h]of Object.entries(s))r[d]=null,i[d]=void 0,c[d]=!1,h.length>0&&u.push([d,h]);if(u.length===0)return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i};const m=await Ji(u,Yu,async([d,h])=>{const f=ba(t,d);try{const g=await o(d),p=f===void 0?g:f===null?[]:g.filter(C=>C.grantee===f),y=nd(p,h);if(y.length===0)return{chainId:d,expectedAddress:f,expiration:null,grantee:void 0};const x=await td({chainId:d,candidates:y,fetchFeegrant:a,concurrency:Zi});if(!x)return{chainId:d,expectedAddress:f,expiration:null,grantee:void 0};const b=x.grantee.grants.filter(C=>h.includes(C.authorization.msg)).map(C=>C.expiration),j=Gi(x.feegrant.allowance),v=[...b,j],w=Ca(v);return{chainId:d,expectedAddress:f,expiration:w?new Date(w):void 0,grantee:x.grantee.grantee}}catch{return{chainId:d,expectedAddress:f,expiration:null,grantee:void 0}}});for(const d of m)l[d.chainId]=d.expectedAddress,r[d.chainId]=d.expiration,i[d.chainId]=d.grantee;for(const[d]of u)c[d]=sd({expiration:r[d],grantee:i[d],expectedAddress:l[d]});return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i}}async function Ji(e,t,s){const o=new Array(e.length),a=Math.max(1,t);let r=0;const i=Array.from({length:Math.min(a,e.length)},async()=>{for(;;){const c=r;if(r+=1,c>=e.length)return;o[c]=await s(e[c],c)}});return await Promise.all(i),o}function ed(e){const t=Gu(e.allowance);if(!(!t||t.includes("/cosmos.authz.v1beta1.MsgExec")))return!1;const o=Gi(e.allowance);if(!o)return!0;const a=new Date(o);return!Number.isNaN(a.getTime())&&Xe.isFuture(a)}async function td(e){const{chainId:t,candidates:s,fetchFeegrant:o,concurrency:a=Zi}=e,r=await Ji(s,a,async i=>{const c=await o(t,i.grantee);return c&&ed(c)?{grantee:i,feegrant:c}:null});for(const i of r)if(i)return i;return null}function nd(e,t){if(t.length===0)return[];const s=new Map;for(const a of e){const r=s.get(a.grantee)||[];r.push({authorization:a.authorization,expiration:a.expiration}),s.set(a.grantee,r)}const o=[];for(const[a,r]of s){const i=r.filter(u=>!u.expiration||Xe.isFuture(new Date(u.expiration))),c=i.map(u=>u.authorization.msg);t.every(u=>c.includes(u))&&o.push({grantee:a,grants:i})}return o}function sd(e){const{expiration:t,grantee:s,expectedAddress:o}=e,a=o===void 0?!!s:!!s&&o===s;switch(t){case null:return!1;case void 0:return a;default:return a&&Xe.isFuture(t)}}function od(){const{data:e,refetch:t}=oo();_.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&Xe.isFuture(c));if(o.length===0)return;const a=Ca(o);if(!a)return;const r=a.getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{t()},r+100);return()=>clearTimeout(i)},[e,t])}function Ca(e){const t=e.filter(s=>s!==void 0);if(t.length!==0)return[...t].sort((s,o)=>new Date(s).getTime()-new Date(o).getTime())[0]}const Xi=_.createContext(null),ao=()=>_.useContext(Xi);class ec extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(t,s,o,a,r,i,c){super(t),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=c}}const ad=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,So=new Map;function rd(e){const t=e.match(ad);if(!t)return null;const[,s,o,a]=t;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:a.replace(/^0+/,"")||"0"}}async function id(e,t,s){const o=`${e}:${t}`;if(So.has(o))return So.get(o);try{const a=t==="0x1"?"0x1.json":`${e}/${t}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await z.get(r).json();return So.set(o,i),i}catch{return null}}function cd(e,t,s,o,a,r,i){return new ec(e,t,s,o,a,r,i)}async function Nn(e,t,s){if(!t.metadata?.is_l1&&t.metadata?.minitia?.type!=="minimove")return await ct(e);const o=rd(e.message);if(!o)return await ct(e);const a=await id(t.chain_name,o.moduleAddress,s),r=`0x${parseInt(o.errorCode,10).toString(16)}`,i=`Failed with code ${r} in module ${o.moduleName} at ${o.moduleAddress}`,c=a?.[o.moduleName]?.[o.errorCode],l=c||i,u=!!c;return cd(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,u)}const ld=10;function tc(){const e=ie();return(t,s)=>E.queryOptions({queryKey:Xs.txs(t.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":ld},{txs:a}=await z.create({prefixUrl:t.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:V.SECOND})}function ud(e,t){const s=tc();return E.useSuspenseQuery(s(e,t))}function dd(e,t){const s=e.flatMap((o,a)=>(t[a]??[]).map(i=>({...i,chain:o})));return L.sortWith([L.descend(o=>new Date(o.timestamp).getTime())])(s)}const md=()=>{const e=_e(),t=tc(),s=E.useQueries({queries:e.map(i=>t(i,{enabled:!0}))}),o=s.map(L.prop("data")),a=dd(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};async function ka(e){if(e.metadata?.is_l1){const{restUrl:t}=e,{gas_prices:s}=await z.create({prefixUrl:t}).get("initia/tx/v1/gas_prices").json();return s.slice().sort(L.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const r=o==="uinit"?1:di;return{amount:q(a).times(r).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:t,fixed_min_gas_price:s})=>{if(L.isNil(s))throw new Error(`${t} has no price`);return{amount:String(s),denom:t}})}function Na(e){const{data:t}=E.useSuspenseQuery({queryKey:Zs.gasPrices(e).queryKey,queryFn:()=>ka(e),staleTime:V.SECOND});return t}function Ia(e){const t=ie(),{data:s}=ud(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=>k.InitiaAddress.equals(t,kt.computeAddress(`0x${de.toHex(ht.Secp256k1.uncompressPubkey(de.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const nc="approve",ro=H.atom(),sc=H.atom(null),hd=Ht,fd=1.5;function pd({gasPrices:e,preferredFeeDenom:t,fallbackFeeDenom:s,allowedFeeDenoms:o}){const a=o?.length?e.filter(({denom:i})=>o.includes(i)):e;if(a.length===0)throw new Error("No allowed gas price tokens available for auto-sign");const r=i=>i?a.find(c=>c.denom===i):void 0;return r(t)??r(s)??a[0]}function gd({simulatedGas:e,gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,policy:a}){if(!Number.isFinite(e)||e<=0)throw new Error("Auto-sign gas simulation failed");const{gasMultiplier:r,maxGasMultiplierFromSim:i,allowedFeeDenoms:c}=a;if(r<=0||i<=0||r>i)throw new Error("Invalid auto-sign gas multiplier policy");const l=Math.ceil(e*r),u=pd({gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,allowedFeeDenoms:c});return Le.calculateFee(l,Le.GasPrice.fromString(`${u.amount}${u.denom}`))}function _d({derivedAddress:e,messages:t,encoder:s}){return{messages:$i({granteeAddress:e,messages:t,encoder:s})}}function yd(e){if(!(e instanceof Error))return!1;const t=e.message.toLowerCase(),s=e.code,o=e.cause?.code,a=t.includes("user rejected")||t.includes("rejected the request")||t.includes("user denied")||t.includes("denied by user")||t.includes("user cancelled")||t.includes("user canceled")||t.includes("cancelled by user")||t.includes("canceled by user");return s===4001||s==="ACTION_REJECTED"||o===4001||o==="ACTION_REJECTED"||a}async function xd({queryClient:e,messages:t,memo:s,pubkey:o,sequence:a}){const r=Le.createProtobufRpcClient(e),i=new sr.ServiceClientImpl(r),c=Ze.Tx.fromPartial({authInfo:Ze.AuthInfo.fromPartial({fee:Ze.Fee.fromPartial({}),signerInfos:[{publicKey:o,sequence:BigInt(a),modeInfo:{single:{mode:ii.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:Ze.TxBody.fromPartial({messages:Array.from(t),memo:s}),signatures:[new Uint8Array]});return await i.Simulate(sr.SimulateRequest.fromPartial({txBytes:Ze.Tx.encode(c).finish()}))}function bd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e}async function wd({address:e,chainId:t,messages:s,memo:o,fee:a,preferredFeeDenom:r,client:i,allowAutoSign:c=!0,allowWalletDerivation:l=!1},u){const m=async()=>u.signWithEthSecp256k1(t,e,s,a,o),d=(y,x)=>{u.onAutoSignFallback?.({chainId:t,reason:y,errorMessage:bd(x)})};if(!c)return m();if(!u.validateAutoSign(t,s))return d("validation_failed"),m();let f=u.getWallet(t),g=!1;if(!f&&l)try{f=await u.deriveWallet(t)}catch(y){if(yd(y))throw y;d("derive_wallet_failed",y),g=!0,f=void 0}if(!f)return g||d("missing_derived_wallet"),m();let p;try{const y=i??await u.getSigningClient(t);p=await u.computeAutoSignFee({chainId:t,messages:s,memo:o,derivedWallet:f,preferredFeeDenom:r,fallbackFeeDenom:a.amount[0]?.denom,client:y})}catch(y){return d("fee_computation_failed",y),m()}try{return await u.signWithDerivedWallet(t,e,s,p,o,f)}catch(y){return d("derived_wallet_sign_failed",y),m()}}function oc(){const e=ie(),{autoSignFeePolicy:t}=se(),s=lt(),o=va(),a=us(),r=is(),i=Ju(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:u}=so(),m=Ki(),d=Pn(),h=p=>{const y=t?.[p];return{gasMultiplier:y?.gasMultiplier??hd,maxGasMultiplierFromSim:y?.maxGasMultiplierFromSim??fd,allowedFeeDenoms:y?.allowedFeeDenoms}},f=async({chainId:p,messages:y,memo:x,derivedWallet:b,preferredFeeDenom:j,fallbackFeeDenom:v,client:w})=>{const C=s(p),I=await ka(C),A=_d({derivedAddress:b.address,messages:y,encoder:r}).messages.map(K=>r.encodeAsAny(K)),$=Ni(xa(b.publicKey)),{sequence:N}=await Wi({getSequence:K=>w.getSequence(K),signerAddress:b.address,incrementSequence:0,allowMissingAccount:!0}),S=await o(p),P=Le.QueryClient.withExtensions(S,Le.setupTxExtension),{gasInfo:F}=await xd({queryClient:P,messages:A,memo:x,pubkey:$,sequence:N}),D=F?Number(F.gasUsed.toString()):0,Z=h(p);return gd({simulatedGas:D,gasPrices:I,preferredFeeDenom:j,fallbackFeeDenom:v,policy:Z})},g=async(p,y,x,b,j,v)=>{let w=v??c(p);w||(w=await l(p));const C=u(p);if(!C)throw new Error("Derived wallet key not initialized");return await qu({chainId:p,granterAddress:y,messages:x,fee:b,memo:j,derivedWallet:w,privateKey:C,encoder:r,signWithEthSecp256k1:m})};return p=>wd({...p,address:e},{validateAutoSign:i,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:f,signWithDerivedWallet:g,signWithEthSecp256k1:m,onAutoSignFallback:({chainId:y,reason:x,errorMessage:b})=>{d("AutoSign Fallback",{chainId:y,reason:x,errorMessage:b})}})}function ac(){const e=H.useAtomValue(ro);if(!e)throw new Error("Tx request not found");return e}function io(){const e=Me(),t=ie(),{defaultChainId:s,registryUrl:o}=se(),a=lt(),{openDrawer:r,closeDrawer:i}=Dt(),{openModal:c,closeModal:l}=ao(),u=H.useSetAtom(ro),m=H.useSetAtom(sc),d=va(),h=us(),f=ls(),g=is(),p=oc(),y=async({messages:A,memo:$,chainId:N=s})=>{try{return await(await h(N)).simulate(t,A,$)}catch(S){throw await Nn(S,a(N),o)}},x=async({messages:A,memo:$,chainId:N=s})=>{const S=await d(N),P=Le.QueryClient.withExtensions(S,Le.setupTxExtension),F=A.map(O=>g.encodeAsAny(O)),[D]=await f.getAccounts(),Z=En.encodeSecp256k1Pubkey(D.pubkey),K=await h(N),{sequence:W}=await K.getSequence(t);return P.tx.simulate(F,$,Z,W)},b=async({txRequest:A,broadcaster:$})=>{const S={...{memo:"",chainId:s,gas:A.gas||await y(A),gasAdjustment:Ht,gasPrices:null,spendCoins:[],internal:!1},...A};return new Promise((P,F)=>{u({txRequest:S,resolve:async Z=>{try{const K=await h(S.chainId),W=await $(K,Ze.TxRaw.encode(Z).finish());P(W),typeof S.internal=="string"&&e(S.internal)}catch(K){F(await Nn(K,a(S.chainId),o))}finally{D()}},reject:Z=>{F(Z),D()}}),S.internal?c({path:"/tx"}):r("/tx");const D=()=>{if(!S.internal){e("/blank"),i();return}l()}})},j=async A=>{const $=A.chainId??s;try{const N=await b({txRequest:A,broadcaster:async(S,P)=>await S.broadcastTxSync(P)});return A.internal&&typeof A.internal!="number"&&(m({txHash:N,chainId:$,status:"loading"}),T({txHash:N,chainId:A.chainId}).then(S=>{m({status:S.code===0?"success":"error",chainId:$,txHash:N})}).catch(()=>{m({status:"error",chainId:$,txHash:N})})),N}catch(N){throw A.internal&&typeof A.internal!="number"&&m({status:"error",chainId:$,error:N}),N}},v=(A,$=30*1e3,N=.5*1e3)=>b({txRequest:A,broadcaster:async(S,P)=>{const F=await S.broadcastTx(P,$,N);if(F.code!==0)throw new Error(F.rawLog);return F}}),w=async({chainId:A,messages:$,memo:N="",fee:S,preferredFeeDenom:P})=>{const F=await h(A),D=await p({chainId:A,messages:$,memo:N,fee:S,preferredFeeDenom:P,client:F,allowWalletDerivation:!0});return{client:F,signedTx:D}},C=async A=>{const $=A.chainId??s;try{const{client:N,signedTx:S}=await w({...A,chainId:$});return await N.broadcastTxSync(Ze.TxRaw.encode(S).finish())}catch(N){throw await Nn(N,a($),o)}},I=async(A,$=30*1e3,N=.5*1e3)=>{const S=A.chainId??s;try{const{client:P,signedTx:F}=await w({...A,chainId:S}),D=await P.broadcastTx(Ze.TxRaw.encode(F).finish(),$,N);if(D.code!==0)throw new Error(D.rawLog);return D}catch(P){throw await Nn(P,a(S),o)}},T=async({chainId:A=s,...$})=>{try{const N=await h(A);return await rc({...$,client:N})}catch(N){throw N instanceof hn?N:await Nn(N,a(A),o)}};return{estimateGas:y,simulateTx:x,requestTxSync:j,requestTxBlock:v,submitTxSync:C,submitTxBlock:I,waitForTxConfirmation:T}}async function rc({txHash:e,client:t,timeoutMs:s=30*1e3,intervalMs:o=.5*1e3}){const a=Date.now();for(;;){const r=await t.getTx(e);if(r){if(r.code!==0)throw new Error(r.rawLog);return r}if(Date.now()-a>=s)throw new hn(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const vd="/cosmos.authz.v1beta1.MsgExec";function jd(e){if(e.explicitGrantee)return[e.explicitGrantee];const t=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(s=>!!s);return[...new Set(t)]}function Cd(e){const t=[e.currentGrantee,e.expectedGrantee].filter(s=>!!s);return[...new Set(t)]}function kd(e){const{isEnabledOnTargetChain:t,hasEnabledSibling:s,didBroadcast:o,hasExplicitGrantee:a}=e;return s?!1:t===!1?!0:t===void 0&&o&&!a}function Nd(e){return[...new Set(e.map(t=>t.authorization.msg))].filter(t=>!!t)}async function ic(e){const t=[Vs.expirations._def,Vs.grants._def];for(const s of t)await e.invalidateQueries({queryKey:s})}function cc(){const e=ie(),{fetchFeegrant:t,fetchGrants:s}=Yi();return async o=>{const{chainId:a,grantee:r}=o;if(!e)throw new Error("Granter wallet not initialized");const i=await t(a,r),c=await s(a,r),l=i?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:ci.MsgRevokeAllowance.fromPartial({granter:e,grantee:r})}]:[],m=Nd(c).map(d=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:ma.MsgRevoke.fromPartial({granter:e,grantee:r,msgTypeUrl:d})}));return[...l,...m]}}function Id(){const e=ie(),t=ja(),{requestTxBlock:s}=io(),o=E.useQueryClient(),[a,r]=H.useAtom(rs),{closeDrawer:i}=Dt(),c=cc(),{deriveWallet:l}=so();return E.useMutation({mutationFn:async u=>{if(!a)throw new Error("No pending request");const{chainId:m}=a;if(!e)throw new Error("Wallet not connected");const d=t[m];if(!d||d.length===0)throw new Error(`No message types configured for chain ${m}`);const h=await l(m);Qu(e,m);const f=ba(e,m),g=Cd({currentGrantee:h.address,expectedGrantee:f}),y=(await Promise.all(g.map(C=>c({chainId:m,grantee:C})))).flat(),x=u===0?void 0:Xe.addMilliseconds(new Date,u),b={typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:cn.BasicAllowance.encode(cn.BasicAllowance.fromPartial({expiration:x})).finish()},j={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:ci.MsgGrantAllowance.fromPartial({granter:e,grantee:h.address,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.AllowedMsgAllowance",value:cn.AllowedMsgAllowance.encode(cn.AllowedMsgAllowance.fromPartial({allowance:b,allowedMessages:[vd]})).finish()}})},v=d.map(C=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:ma.MsgGrant.fromPartial({granter:e,grantee:h.address,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:or.GenericAuthorization.encode(or.GenericAuthorization.fromPartial({msg:C})).finish()},expiration:x}})})),w=[...y,j,...v];return await s({messages:w,chainId:m,internal:!0}),{chainId:m,derivedWallet:h}},onSuccess:async({chainId:u,derivedWallet:m})=>{e&&Tu(e,u,m.address),await ic(o),a?.resolve()},onError:u=>{a?.reject(u)},onSettled:()=>{r(null),i()}})}function lc(e){const t=se(),s=_e(),o=lt(),{getWallet:a,clearWallet:r}=so(),{requestTxBlock:i}=io(),c=E.useQueryClient(),l=cc(),{data:u,refetch:m}=oo();return E.useMutation({mutationFn:async(d=t.defaultChainId)=>{const h=a(d),f=u?.granteeByChain[d];let g;e?.grantee||(g=(await m()).data?.granteeByChain[d]);const p=jd({explicitGrantee:e?.grantee,cachedDerivedAddress:h?.address,statusGrantee:f,refetchedStatusGrantee:g});if(p.length===0)throw new Error("No grantee address available");const x=(await Promise.all(p.map(b=>l({chainId:d,grantee:b})))).flat();return x.length===0?{chainId:d,didBroadcast:!1}:(await i({messages:x,chainId:d,internal:e?.internal}),{chainId:d,didBroadcast:!0})},onSuccess:async({chainId:d,didBroadcast:h})=>{await ic(c);const f=o(d),g=s.filter(v=>v.bech32_prefix===f.bech32_prefix).map(v=>v.chain_id).filter(v=>v!==d);let p;try{p=(await m()).data}catch{p=void 0}const y=p??u;let x=!1;g.length>0&&y&&(x=g.some(v=>y?.isEnabledByChain[v]));const b=h?p?.isEnabledByChain[d]:(p??u)?.isEnabledByChain[d];kd({isEnabledOnTargetChain:b,hasEnabledSibling:x,didBroadcast:h,hasExplicitGrantee:!!e?.grantee})&&r(d)}})}function Ad(){const{defaultChainId:e}=se(),{openDrawer:t}=Dt(),s=H.useSetAtom(rs),o=lc(),{data:a={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:r}=oo();return{...a,isLoading:r,enable:async(l=e)=>new Promise((u,m)=>{s({chainId:l,resolve:u,reject:m}),t("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}function uc(e){return e.assets.reduce((t,{value:s})=>t+(s??0),0)}function Sd(e){return e.assets.reduce((t,{quantity:s})=>t.plus(s),q(0)).toString()}function Td(e,t){return{symbol:t?.symbol??e,logoUrl:t?.logoUrl??_a}}function dr(e){return L.pick(["chainId","name","logoUrl"],e)}function Ed(e){return L.sortWith([L.descend(({symbol:t})=>t===pt),L.descend(uc),L.descend(({assets:t})=>t.length),L.ascend(({symbol:t})=>t)])(e)}function $d(e){return L.sortWith([L.descend(({value:t})=>t??0),L.descend(({quantity:t})=>Number(t)),L.ascend(({chain:t})=>t.name)])(e)}function Md(e,t){return L.sortWith([L.descend(({chain:s})=>s.chainId===t),L.ascend(({chain:s})=>s.name),L.ascend(({denom:s})=>s)])(e)}function Ld(e,t){return L.sortWith([L.descend(({chainId:s})=>s===t),L.descend(L.prop("value"))])(e)}function qd(e,t,s,o,a){const r=e.find(d=>d.metadata?.is_l1)?.chainId,i={};for(const d of e){const h=d.chainId,f=t[h]??[],g=s[h],p=o[h],y=[];for(const{amount:x,denom:b}of f){if(!q(x).gt(0))continue;const j=g?.find(T=>T.denom===b),v=p?.find(T=>T.id===b)?.price,w=j?.decimals??0,C=k.fromBaseUnit(x,{decimals:w}),I=v?q(C).times(v).toNumber():void 0;y.push({...Td(b,j),amount:x,denom:b,decimals:w,quantity:C,price:v,value:I,address:j?.address,unlisted:!j,chain:dr(d)})}i[h]=y}const c=new Map;for(const[d,h]of Object.entries(i)){if(h.length===0)continue;const f=e.find(p=>p.chainId===d);if(!f)continue;const g=h.reduce((p,{value:y})=>p+(y??0),0);c.set(d,{...dr(f),value:g})}const l=new Map;for(const d of Object.values(i))for(const h of d)if(!h.unlisted){const{symbol:f}=h,g=l.get(f)??[];l.set(f,[...g,h])}const u=[];for(const[d,h]of l){const f=L.head(h);if(!f)continue;const g=$d(h),p=g.reduce((x,{value:b})=>x+(b??0),0),y=g.reduce((x,{quantity:b})=>x.plus(b),q(0)).toNumber();u.push({symbol:d,logoUrl:f.logoUrl,assets:g,totalValue:p,totalAmount:y})}const m=[];for(const d of Object.values(i))for(const h of d)h.unlisted&&m.push(h);return{chainsByValue:Ld(Array.from(c.values()),a),assetGroups:Ed(u),unlistedAssets:Md(m,r),totalValue:u.reduce((d,h)=>d+h.totalValue,0)}}function Aa(){const{defaultChainId:e}=se(),t=_e(),s=uu(),o=os(),a=ga(),r=t.map(h=>h.chainId),i=L.zipObj(r,s.map(L.prop("data"))),c=L.zipObj(r,o.map(L.prop("data"))),l=L.zipObj(r,a.map(L.prop("data"))),u=qd(t,i,c,l,e),m=[s,o,a].flat().some(({isLoading:h})=>h);return{...u,isLoading:m,refetch:()=>{s.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),a.forEach(({refetch:h})=>h())}}}function ie(){const e=Bn();return e?k.InitiaAddress(e).bech32:""}function Bn(){const{address:e}=Qe.useAccount();return e?k.InitiaAddress(e).hex:""}function Yt(){const e=xn(),t=ie(),s=Bn();return e.metadata?.minitia?.type==="minievm"?s:t}function dc(e){const t=Yt(),s=e??t,o=bi();return E.useQuery({queryKey:Xs.username(o.restUrl,s).queryKey,queryFn:()=>o.getUsername(s),enabled:!!s,staleTime:V.MINUTE})}function tt(){const e=Yt(),t=ie(),s=Bn(),{data:o}=dc(),a=ls(),r=Di(),i=Ad(),{isDrawerOpen:c,openDrawer:l}=Dt(),{isModalOpen:u}=Dn(),m=()=>{l("/")},d=()=>{l("/connect")},h=b=>{l("/bridge",b)},f=Fu(),g=Uu(),p=io();return{address:e,initiaAddress:t,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:c||u,openConnect:d,openWallet:m,openBridge:h,openDeposit:f,openWithdraw:g,disconnect:r,autoSign:i,...p}}const Rd="_status_tn9m1_1",Pd="_error_tn9m1_9",mr={status:Rd,error:Pd},je=({error:e,children:t})=>n.jsx("p",{className:B(mr.status,{[mr.error]:e}),role:e?"alert":"status",children:t}),xe=({errorBoundaryProps:e={fallbackRender:({error:o})=>n.jsx(je,{error:!0,children:o.message})},suspenseFallback:t=n.jsx(je,{children:"Loading..."}),children:s})=>n.jsx(li.ErrorBoundary,{...e,children:n.jsx(_.Suspense,{fallback:t,children:s})}),gn=1n<<64n,Dd=1n<<63n,mc=(1n<<128n)-1n;function Gt(e){const t=BigInt(e);return t>=Dd?t-gn:t}const Bd=(1n<<256n)-1n,Wt=443636n,Fd=4295048017n,Ud=18446744073709551616n,Od=79226673515401279992447579062n,Vd=255738958999603826347141n;function Kd(e,t,s){const o=Number(Gt(e)),a=Number(Gt(t)),r=Math.floor(-Number(Wt)/s)*s,i=Math.floor(Number(Wt)/s)*s;return o===r&&a===i}function hc(e){return e>>64n}function Wd(e){const t=e>>64n;return e%gn!==0n?t+1n:t}function Mn(e){if(e<0n||e>mc)throw new Error("INPUT_OUT_OF_RANGE");return e}function zd(e,t){const s=e*t>>64n;if(s>mc)throw new Error("OVERFLOW");return s}function Sa(e,t){return e>t?[t,e]:[e,t]}function Hd(e,t,s,o){if(e===t)return 0n;const[a,r]=Sa(e,t);if(a===0n||r===0n)return 0n;const i=s*gn,c=r-a,l=i*c;if(l===0n)return 0n;const u=a*r;return o?(l-1n)/u+1n:l/u}function Qd(e,t,s,o){if(e===t)return 0n;const[a,r]=Sa(e,t),c=(r-a)*s;return o?Wd(Mn(c)):hc(Mn(c))}function hr(e,t,s){return Hd(e,t,s<0n?-s:s,s>=0n)}function fr(e,t,s){return Qd(e,t,s<0n?-s:s,s>=0n)}const To=1n<<64n,pr=1n<<65n,Gd=64n;function Yd(e){if(e<=0n)throw new Error("LOG_2_ZERO_UNBOUNDED");let t=e,s=0n,o=0n,a=1n<<Gd-1n,r=0n,i=1;for(;t>=pr;)t>>=1n,s+=To;for(;t<To;)i=0,t<<=1n,o+=To;for(;r<62n;){const l=t>>1n;t=l*l>>62n,t>=pr&&(t>>=1n,s+=a),a>>=1n,r+=1n}const c=i>0?Mn(s):Mn(o-s);return[i,c]}function zt(e){const t=e<0n?-e:e;if(t>Wt)throw new Error("MAX_TICK");let s=(t&0x1n)!==0n?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;(t&0x2n)!==0n&&(s=s*0xfff97272373d413259a46990580e213an>>128n),(t&0x4n)!==0n&&(s=s*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(t&0x8n)!==0n&&(s=s*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(t&0x10n)!==0n&&(s=s*0xffcb9843d60f6159c9db58835c926644n>>128n),(t&0x20n)!==0n&&(s=s*0xff973b41fa98c081472e6896dfb254c0n>>128n),(t&0x40n)!==0n&&(s=s*0xff2ea16466c96a3843ec78b326b52861n>>128n),(t&0x80n)!==0n&&(s=s*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(t&0x100n)!==0n&&(s=s*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(t&0x200n)!==0n&&(s=s*0xf987a7253ac413176f2b074cf7815e54n>>128n),(t&0x400n)!==0n&&(s=s*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(t&0x800n)!==0n&&(s=s*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(t&0x1000n)!==0n&&(s=s*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(t&0x2000n)!==0n&&(s=s*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(t&0x4000n)!==0n&&(s=s*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(t&0x8000n)!==0n&&(s=s*0x31be135f97d08fd981231505542fcfa6n>>128n),(t&0x10000n)!==0n&&(s=s*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(t&0x20000n)!==0n&&(s=s*0x5d6af8dedb81196699c329225ee604n>>128n),(t&0x40000n)!==0n&&(s=s*0x2216e584f5fa1ea926041bedfe98n>>128n),e>=0n&&(s=Bd/s);const o=s/gn;return s%gn!==0n?o+1n:o}function Zd(e){if(e<Fd||e>=Od)throw new Error("INVALID_SQRT_PRICE");const[,t]=Yd(Mn(e)),s=zd(t,Mn(Vd)),o=hc(s);let a,r,i;if(o===0n?(a=-1n,r=0n,i=1n):e<Ud?(a=-o-1n,r=-o,i=-o+1n):(a=o-1n,r=o,i=o+1n),a<-Wt&&(a=-Wt),i>Wt&&(i=Wt),zt(i)<=e){if(i>=Wt)throw new Error("GTE_MAX_TICK");if(zt(i+1n)<=e)throw new Error("NO_SAFE_TICK_FOUND");return i}if(zt(r)<=e)return r;if(zt(a)<=e)return a;throw new Error("NO_SAFE_TICK_FOUND")}function Jd(e,t,s,o){const[a,r]=Sa(t,s);return e<a?[hr(a,r,o),0n]:e<r?[hr(e,r,o),fr(a,e,o)]:[0n,fr(a,r,o)]}function Xd({tickLower:e,tickUpper:t,liquidity:s,sqrtPrice:o}){const a=zt(Gt(e)),r=zt(Gt(t));return Jd(BigInt(o),BigInt(a),BigInt(r),BigInt(s))}const Eo=gn*gn,em=1e-300,tm=BigInt(Number.MAX_SAFE_INTEGER);function gr(e){const t=e*e,s=t/Eo,o=t%Eo;return s>tm?Number(s):Number(s)+Number(o)/Number(Eo)}function _r(e){if(!Number.isFinite(e)||e<0)throw new Error("calculateTokens: price must be finite and non-negative");return 1/Math.max(e,em)}function nm({tickLower:e,tickUpper:t,isReversed:s=!1}){const o=zt(Gt(e)),a=zt(Gt(t)),r=gr(o),i=gr(a);return s?{min:_r(i),max:_r(r)}:{min:r,max:i}}const wn=qe.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,t)=>[e,t],lpPrices:(e,t)=>[e,t],poolByMetadata:(e,t)=>[e,t],clammPositions:(e,t)=>[e,t],clammPoolInfo:(e,t,s)=>[e,t,s],clammFees:(e,t,s)=>[e,t,s],clammIncentive:(e,t,s,o)=>[e,t,s,o]}),Ta={lens:"lens",pool:"pool",farming:"farming"},Ea={"interwoven-1":{clammModuleAddress:"0xd78a3b72c7ef0cfba7286bfb8c618aa4d6011dce05a832871cc9ab323c25f55e",incentiveModuleAddress:"0xcb2999c70a9b8db7cb473255bb01f956f0726087f08b04ece50844a6d8167351"},"initiation-2":{clammModuleAddress:"0x6b41bf295bc31cd9bef75a9a5a67e5a8d6749b34a7ab3105808251fa2697823d",incentiveModuleAddress:"0xf8ef0cb7c73607b7658524565015ce2aadc45ccf7164e5351959a4d7a1c37753"}};function sm(e){return e.startsWith("0x")?`0x${e.replace(/^0x/,"").padStart(64,"0")}`:k.InitiaAddress(e).hex}function Ks(e){return de.toBase64(k.InitiaAddress(sm(e),32).bytes)}function fc(e,t){return`${e}:${t}`}function om(e){return`clamm:${e}`}function am(e){return!Array.isArray(e)||e.length===0?[]:Array.isArray(e[0])?e.flat():e}function rm(e){return e.map(t=>({tokenAddress:t.token_address,lpMetadata:t.lp_metadata,tickLower:t.tick_lower,tickUpper:t.tick_upper,liquidity:t.liquidity,incentives:t.incentives.map(s=>({incentiveAddress:s.incentive_address,rewardMetadata:s.reward_metadata}))}))}function im(e){const{dexUrl:t}=se();return E.useSuspenseQuery({queryKey:wn.clammPositions(t,e).queryKey,queryFn:async()=>{if(!e)return[];const s=[];let o;do{const a={"pagination.limit":"100"};o&&(a["pagination.key"]=o);const r=await z.get(`${t}/indexer/clamm/v1/positions/${e}`,{searchParams:a}).json().catch(()=>({positions:[],pagination:{next_key:null,total:"0"}}));s.push(...am(r.positions)),o=r.pagination.next_key||void 0}while(o);return rm(s)},staleTime:V.MINUTE})}function cm(e){const t=ce(),{viewFunction:s}=k.createMoveClient(t.restUrl),a=E.useSuspenseQueries({queries:e.map(r=>({queryKey:wn.clammPoolInfo(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=Ea[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:Ta.lens,functionName:"get_pool_info",typeArgs:[],args:[Ks(r)]});return!c?.sqrt_price||!c?.tick_spacing?null:{sqrtPrice:c.sqrt_price,tickSpacing:c.tick_spacing}}catch{return null}},staleTime:V.MINUTE}))}).map(r=>r.data);return _.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(i,a[c]??null)}),r},[e,a])}function lm(e){const t=ce(),{viewFunction:s}=k.createMoveClient(t.restUrl),a=E.useSuspenseQueries({queries:e.map(r=>({queryKey:wn.clammFees(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=Ea[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:Ta.pool,functionName:"fees_available",typeArgs:[],args:[Ks(r)]});return Array.isArray(c)?c:null}catch{return null}},staleTime:V.MINUTE}))}).map(r=>r.data);return _.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{const l=a[c];l&&r.set(i,l)}),r},[e,a])}function um(e){const t=ce(),{viewFunction:s}=k.createMoveClient(t.restUrl),a=E.useSuspenseQueries({queries:e.map(r=>({queryKey:wn.clammIncentive(t.restUrl,t.chainId,r.tokenAddress,r.incentiveAddress).queryKey,queryFn:async()=>{const i=Ea[t.chainId];if(!i)return"0";try{const c=await s({moduleAddress:i.incentiveModuleAddress,moduleName:Ta.farming,functionName:"pending_reward_info",typeArgs:[],args:[Ks(r.tokenAddress),Ks(r.incentiveAddress)]});return typeof c=="string"?c:Array.isArray(c)&&typeof c[0]=="string"?c[0]:"0"}catch{return"0"}},staleTime:V.MINUTE}))}).map(r=>r.data);return _.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(fc(i.tokenAddress,i.incentiveAddress),a[c]||"0")}),r},[e,a])}function pc(e){const{dexUrl:t}=se(),o=E.useSuspenseQueries({queries:e.map(a=>({queryKey:wn.poolByMetadata(t,a).queryKey,queryFn:async()=>{try{return(await z.get(`${t}/indexer/dex/v2/pools/${encodeURIComponent(a)}`).json()).pool}catch{return null}},staleTime:V.MINUTE}))}).map(a=>a.data);return _.useMemo(()=>{const a=new Map;return e.forEach((r,i)=>{a.set(r,o[i]??null)}),a},[e,o])}function gc(e,t){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>t.get(s.denom)?.logoUrl||"")}function dm(e){return pc(e)}function mm(e){const t=ce(),s=Qt(t),o=_.useMemo(()=>{const i=new Map;for(const c of s)i.set(c.denom,c);return i},[s]),a=_.useMemo(()=>e.map(i=>k.denomToMetadata(i)),[e]),r=pc(a);return _.useMemo(()=>{const i=new Map;return e.forEach((c,l)=>{const u=a[l];if(!u){i.set(c,null);return}const m=r.get(u);if(!m){i.set(c,null);return}if(c===Ru){i.set(c,{...m,symbol:Pu});return}const d=m.coins.map(h=>o.get(h.denom)?.symbol||h.denom).join("-");i.set(c,{...m,symbol:d})}),i},[e,a,r,o])}const hm="lock_staking";function _c(e,t){const s=`${t}::lock_staking::StakingAccount`,o=k.createObjectAddress(e,s);return k.InitiaAddress(o).bech32}const ds=qe.createQueryKeys("interwovenkit:initia-staking",{delegations:(e,t)=>[e,t],undelegations:(e,t,s)=>[e,t,s],lockStaking:(e,t,s)=>[e,t,s],stakingRewards:(e,t)=>[e,t],lockStakingRewards:(e,t,s)=>[e,t,s]});function $a(){const{restUrl:e}=ce(),t=ie();return E.useSuspenseQuery({queryKey:ds.delegations(e,t||"").queryKey,queryFn:async()=>t?(await z.get(`${e}/initia/mstaking/v1/delegations/${t}`).json()).delegation_responses:[],select:s=>{const o=new Map;for(const a of s){const r=a.delegation.validator_address;for(const i of a.balance){const c=k.denomToMetadata(i.denom),l={denom:i.denom,metadata:c,amount:i.amount,validator:r},u=o.get(c)??[];u.push(l),o.set(c,u)}}return o},staleTime:V.MINUTE})}function Ma(){const{restUrl:e}=ce(),{lockStakeModuleAddress:t}=se(),s=ie(),o=s?_c(s,t):"";return E.useSuspenseQuery({queryKey:ds.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await z.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await z.get(`${e}/initia/mstaking/v1/delegators/${o}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...a.unbonding_responses,...r.unbonding_responses]},select:a=>{const r=new Map;for(const i of a){const c=i.validator_address;for(const l of i.entries)for(const u of l.balance){const m=k.denomToMetadata(u.denom),d={denom:u.denom,metadata:m,amount:u.amount,validator:c,completionTime:l.completion_time},h=r.get(m)??[];h.push(d),r.set(m,h)}}return r},staleTime:V.MINUTE})}function La(){const{restUrl:e}=ce(),{lockStakeModuleAddress:t}=se(),s=ie();return E.useSuspenseQuery({queryKey:ds.lockStaking(e,s||"",t).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=k.createMoveClient(e);return await o({moduleAddress:t,moduleName:hm,functionName:"get_locked_delegations",typeArgs:[],args:[de.toBase64(k.InitiaAddress(s,32).bytes)]})??[]},select:o=>{const a=new Map;for(const r of o){const i={metadata:r.metadata,amount:r.amount,validator:r.validator,releaseTime:r.release_time},c=a.get(r.metadata)??[];c.push(i),a.set(r.metadata,c)}return a},staleTime:V.MINUTE})}function yc(e){const t=new Map;if(!e.total||!Array.isArray(e.total))return t;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=k.denomToMetadata(s.denom);let a=new q(0);for(const i of s.dec_coins)i?.amount&&(a=a.plus(i.amount));const r=t.get(o);if(r){const i=new q(r.amount);a=a.plus(i)}t.set(o,{denom:s.denom,amount:a.toString()})}return t}function xc(){const{restUrl:e}=ce(),t=ie();return E.useSuspenseQuery({queryKey:ds.stakingRewards(e,t||"").queryKey,queryFn:async()=>t?await z.get(`${e}/initia/distribution/v1/delegators/${t}/rewards`).json():{rewards:[],total:[]},select:yc,staleTime:V.MINUTE})}function bc(){const{restUrl:e}=ce(),{lockStakeModuleAddress:t}=se(),s=ie(),o=s?_c(s,t):"";return E.useSuspenseQuery({queryKey:ds.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await z.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:yc,staleTime:V.MINUTE})}function qa(){const e=ce(),t=Qt(e),{data:s,isLoading:o}=Pt(e),{data:a}=$a(),{data:r}=Ma(),{data:i}=La(),c=_.useMemo(()=>{const f=new Set;for(const g of a.keys())f.add(g);for(const g of i.keys())f.add(g);for(const g of r.keys())f.add(g);return Array.from(f)},[a,i,r]),l=Bs(c),u=_.useMemo(()=>{const f=new Map;if(s)for(const g of s)f.set(g.id,g.price);return f},[s]),m=_.useMemo(()=>{const f=new Map;for(const g of t)f.set(g.denom,g);return f},[t]),d=_.useMemo(()=>{const f=[],g=p=>{const y=m.get(p);return y?{symbol:y.symbol,decimals:y.decimals}:null};for(const[p,y]of a){const x=l.get(p)??y[0]?.denom;if(!x)continue;const b=g(x);if(!b)continue;const j=u.get(x)??0;for(const v of y){const{symbol:w,decimals:C}=b,I=Number(k.fromBaseUnit(v.amount,{decimals:C})),T={type:"asset",denom:x,symbol:w,amount:v.amount,formattedAmount:I,decimals:C,value:I*j};f.push({type:"staking",validator:v.validator,balance:T})}}for(const[p,y]of i){const x=l.get(p);if(!x)continue;const b=g(x);if(!b)continue;const j=u.get(x)??0;for(const v of y){const{symbol:w,decimals:C}=b,I=Number(k.fromBaseUnit(v.amount,{decimals:C})),T={type:"asset",denom:x,symbol:w,amount:v.amount,formattedAmount:I,decimals:C,value:I*j},A=Number(v.releaseTime);f.push({type:"lockstaking",validator:v.validator,releaseTime:Number.isNaN(A)?0:A,balance:T})}}for(const[p,y]of r){const x=l.get(p)??y[0]?.denom;if(!x)continue;const b=g(x);if(!b)continue;const j=u.get(x)??0;for(const v of y){const{symbol:w,decimals:C}=b,I=Number(k.fromBaseUnit(v.amount,{decimals:C})),T={type:"asset",denom:x,symbol:w,amount:v.amount,formattedAmount:I,decimals:C,value:I*j},A=new Date(v.completionTime).getTime(),$=Number.isNaN(A)?0:Math.floor(A/1e3);f.push({type:"unstaking",validator:v.validator,completionTime:$,balance:T})}}return f.filter(p=>p.type!=="fungible-position"&&p.balance.denom===Je)},[a,i,r,l,m,u]),h=_.useMemo(()=>d.reduce((f,g)=>g.type==="fungible-position"||g.balance.type==="unknown"?f:f+(g.balance.value??0),0),[d]);return{positions:d,totalValue:h,isLoading:o}}function fm(e){const t=new Map;for(const s of e){const o=k.denomToMetadata(s.denom),a={...s,metadata:o},r=t.get(o)??[];r.push(a),t.set(o,r)}return t}function pm(e,t){return e.map(s=>t.get(s)?.symbol||s).join("/")}function gm(e){const{dexUrl:t}=se();return E.useSuspenseQuery({queryKey:wn.checkLpTokens(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.post(`${t}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:V.MINUTE})}function _m(){const e=ce(),t=as(e),s=_.useMemo(()=>t.map(a=>a.denom),[t]),{data:o}=gm(s);return _.useMemo(()=>{const a=t.filter(r=>o.get(r.denom)===!0);return fm(a)},[t,o])}function ym(e){const{dexUrl:t}=se();return E.useSuspenseQuery({queryKey:wn.lpPrices(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.get(`${t}/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:V.MINUTE})}function xm(e,t,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of t){const c=i[0]?.denom;c&&c!==Je&&a.add(r)}for(const r of s.keys())a.add(r);for(const[r,i]of o){const c=i[0]?.denom;c&&c!==Je&&a.add(r)}return Array.from(a)}function bm(e){const t=[];for(const[,s]of e)s&&s!==Je&&t.push(s);return t}function wm(e,t,s){const o=t.get(e)??null,a=o?.symbol||e,r=gc(o,s),i=r.length>0&&r.some(l=>l),c=i?void 0:s.get(e)?.logoUrl;return{denom:e,symbol:a,totalAmount:0,totalValue:0,decimals:s.get(e)?.decimals??6,poolType:o?.pool_type,logoUrl:c,coinLogos:i?r:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0}}}function $o(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r)??i[0]?.denom;if(!c||c===Je)continue;const l=o.get(c);if(l)for(const u of i){const m=l.decimals,d=Number(k.fromBaseUnit(String(u.amount),{decimals:m})),h=s.get(c)??0,f=d*h;l.breakdown[a]+=d,l.totalAmount+=d,l.totalValue+=f}}}function vm(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r);if(!c||c===Je)continue;const l=o.get(c);if(l)for(const u of i){const m=l.decimals,d=Number(k.fromBaseUnit(String(u.amount),{decimals:m})),h=s.get(c)??0,f=d*h;l.breakdown[a]+=d,l.totalAmount+=d,l.totalValue+=f}}}function jm(e,t,s,o){for(const[a,r]of e){const i=k.denomToMetadata(a),c=t?.get(i),l=c?k.fromBaseUnit(c.amount,{decimals:it}):"0",u=s?.get(i),m=u?k.fromBaseUnit(u.amount,{decimals:it}):"0",d=Number(l)+Number(m);d<=0||(r.claimableInit={staking:l,lockStaking:m,total:String(d),totalValue:d*o})}}function Cm(e){return`#${e.replace(/^0x/,"").slice(-6)}`}function co(){const e=ce(),t=Qt(e),s=ie(),o=_m(),{data:a}=$a(),{data:r}=La(),{data:i}=Ma(),{data:c}=xc(),{data:l}=bc(),{data:u}=Pt(e),{data:m}=im(s),d=_.useMemo(()=>{const F=new Map;for(const D of m){const Z=F.get(D.lpMetadata)??[];Z.push(D),F.set(D.lpMetadata,Z)}return F},[m]),h=_.useMemo(()=>Array.from(d.keys()),[d]),f=dm(h),g=cm(h),p=_.useMemo(()=>m.map(F=>F.tokenAddress),[m]),y=lm(p),x=_.useMemo(()=>{const F=[];for(const D of m)for(const Z of D.incentives)F.push({tokenAddress:D.tokenAddress,incentiveAddress:Z.incentiveAddress});return F},[m]),b=um(x),j=_.useMemo(()=>{const F=new Set;for(const D of m)for(const Z of D.incentives)F.add(Z.rewardMetadata);return Array.from(F)},[m]),v=Bs(j,{failSoft:!0}),w=_.useMemo(()=>xm(o,a,r,i),[o,a,r,i]),C=Bs(w),I=_.useMemo(()=>bm(C),[C]),{data:T}=ym(I),A=mm(I),$=_.useMemo(()=>{const F=new Map;for(const D of t)F.set(D.denom,D);return F},[t]),N=_.useMemo(()=>{const F=new Map;for(const D of u??[])F.set(D.id,D.price);return F},[u]),{rows:S,totalValue:P}=_.useMemo(()=>{const F=u?.find(W=>W.id===Je)?.price??0,D=new Map;for(const W of I)D.set(W,wm(W,A,$));$o(o,C,T,D,"deposit"),$o(a,C,T,D,"staking"),vm(r,C,T,D,"lockStaking"),$o(i,C,T,D,"unstaking"),jm(D,c,l,F);for(const W of h){const O=d.get(W)??[];if(O.length===0)continue;const J=f.get(W),Q=g.get(W),ee=om(W),ue=J?.coins.map(le=>le.denom)??[],ye=J?gc(J,$).filter(Boolean):[],me=ue.map(le=>$.get(le)?.symbol||le),Ce=J?.symbol||me.join("-")||ee,Se=pm(ue,$),ke=O.map(le=>{let G,$t,Xt,Mt=!1,bt=0,en=0;try{const dt=nm({tickLower:le.tickLower,tickUpper:le.tickUpper});G=dt.min,$t=dt.max}catch{G=void 0,$t=void 0}if(Q){try{const dt=Zd(BigInt(Q.sqrtPrice)),Ue=Gt(le.tickLower),nt=Gt(le.tickUpper),X=Number(Q.tickSpacing);Mt=Number.isFinite(X)&&X>0?Kd(le.tickLower,le.tickUpper,X):!1,Xt=Mt||dt>=Ue&&dt<nt}catch{Xt=void 0,Mt=!1}if(J&&ue.length>0)try{Xd({sqrtPrice:Q.sqrtPrice,tickLower:le.tickLower,tickUpper:le.tickUpper,liquidity:le.liquidity}).forEach((Ue,nt)=>{const X=J.coins[nt];if(!X)return;const ve=$.get(X.denom)?.decimals??6,Oe=N.get(X.denom)??0,mt=Number(k.fromBaseUnit(String(Ue),{decimals:ve}));bt+=mt*Oe})}catch{bt=0}}return J&&((y.get(le.tokenAddress)??[]).forEach((Ue,nt)=>{const X=J.coins[nt];if(!X)return;const ve=$.get(X.denom)?.decimals??6,Oe=N.get(X.denom)??0,mt=Number(k.fromBaseUnit(Ue,{decimals:ve}));en+=mt*Oe}),le.incentives.forEach(Ue=>{const nt=b.get(fc(le.tokenAddress,Ue.incentiveAddress))??"0",X=v.get(Ue.rewardMetadata);if(!X)return;const ve=$.get(X)?.decimals??6,Oe=N.get(X)??0,mt=Number(k.fromBaseUnit(nt,{decimals:ve}));en+=mt*Oe})),{tokenAddress:le.tokenAddress,positionId:Cm(le.tokenAddress),inRange:Xt,isFullRange:Mt,minPrice:G,maxPrice:$t,pricePairLabel:Se,rewardValue:en,value:bt}}),Et=ke.reduce((le,G)=>le+G.value,0),ut=ke.reduce((le,G)=>le+G.rewardValue,0),Re=ye.length>0;D.set(ee,{denom:ee,symbol:Ce,totalAmount:0,totalValue:Et,decimals:6,poolType:"CLAMM",logoUrl:void 0,coinLogos:Re?ye:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0},isClamm:!0,clamm:{lpMetadata:W,totalRewardValue:ut,positions:ke}})}const Z=Array.from(D.values()).filter(W=>W.totalAmount>0||W.isClamm).sort((W,O)=>O.totalValue-W.totalValue),K=Z.reduce((W,O)=>W+O.totalValue,0);return{rows:Z,totalValue:K}},[u,I,A,$,o,a,r,i,C,T,c,l,h,d,f,g,y,b,v,N]);return{totalValue:P,rows:S}}const km=qe.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,t)=>[e,t]});function Nm(e){return e.filter(t=>t.data.length>0).map(t=>{const s=t.data[0].bridge_id,o=t.data[0].version,a=t.data.reduce((r,i)=>r+i.claimed_reward,0);return{claimableReward:t.total_claimable_reward,claimedReward:a,initialReward:t.total_vesting_reward,lockedReward:t.total_locked_reward,requiredScore:t.required_score,rollup:{bridgeId:s,version:o}}}).filter(t=>t.initialReward>0).sort((t,s)=>s.initialReward-t.initialReward)}function wc(){const{vipUrl:e}=se(),t=ie();return E.useQuery({queryKey:km.allVestingPositions(e,t).queryKey,queryFn:async()=>(await z.get(`${e}/vesting/positions/${t}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:V.MINUTE,enabled:!!t})}function Im(){const e=_e();return _.useCallback(t=>e.find(({metadata:s})=>s?.op_bridge_id===String(t)),[e])}function lo(){const{data:e}=wc(),t=ce(),{data:s}=Pt(t),o=Im(),a=_.useMemo(()=>s?.find(l=>l.id===Je)?.price??0,[s]),r=_.useMemo(()=>e?Nm(e).map(l=>{const u=o(l.rollup.bridgeId),m=Number(k.fromBaseUnit(String(l.lockedReward),{decimals:it})),d=Number(k.fromBaseUnit(String(l.claimableReward),{decimals:it})),h=q(k.fromBaseUnit(String(l.lockedReward),{decimals:it})).times(a).toNumber(),f=q(k.fromBaseUnit(String(l.claimableReward),{decimals:it})).times(a).toNumber();return{bridgeId:l.rollup.bridgeId,version:l.rollup.version,name:u?.name??"",logoUrl:u?.logoUrl,lockedReward:m,lockedRewardValue:h,claimableReward:d,claimableRewardValue:f}}).filter(l=>l.lockedReward+l.claimableReward>0):[],[e,a,o]),i=_.useMemo(()=>r.reduce((c,l)=>c+l.lockedRewardValue+l.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function vc(){const{totalValue:e}=co(),{data:t}=$a(),{data:s}=La(),{data:o}=Ma(),{data:a}=wc(),r=_.useMemo(()=>Array.from(s.keys()),[s]),i=Bs(r),c=ce(),{data:l}=Pt(c),u=_.useMemo(()=>l?.find(d=>d.id===Je)?.price??0,[l]);return _.useMemo(()=>{let m=0,d=0;const h=u??0;for(const[,g]of t)for(const{denom:p,amount:y}of g)p===Je&&(m+=Number(k.fromBaseUnit(y,{decimals:it}))*h);for(const[g,p]of s)if(i.get(g)===Je)for(const{amount:y}of p)d+=Number(k.fromBaseUnit(y,{decimals:it}))*h;for(const[,g]of o)for(const{denom:p,amount:y}of g)p===Je&&(m+=Number(k.fromBaseUnit(y,{decimals:it}))*h);let f=0;if(a)for(const g of a){const p=g.total_locked_reward??0,y=g.total_claimable_reward??0;f+=Number(k.fromBaseUnit(String(p+y),{decimals:it}))*h}return m+d+e+f},[t,s,i,o,a,u,e])}function Am(){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"],t={"initia-wallet-widget:ethereum-public-keys":{prefix:he.PUBLIC_KEY,getSuffix:s=>k.InitiaAddress(s).bech32}};for(const s of e)localStorage.removeItem(s);for(const[s,{prefix:o,getSuffix:a}]of Object.entries(t)){const r=localStorage.getItem(s);if(r)try{const i=JSON.parse(r);for(const[c,l]of Object.entries(i)){const u=`${o}:${a(c)}`;localStorage.setItem(u,l)}localStorage.removeItem(s)}catch{}}}const Zo=qe.createQueryKeys("interwovenkit:minity",{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,t)=>[e,t],balances:(e,t,s)=>[e,t,s],initiaPositions:(e,t)=>[e,"initia",t],echelonPositions:(e,t)=>[e,"echelon",t],inertiaPositions:(e,t)=>[e,"inertia",t],ravePositions:(e,t,s)=>[e,"rave",t,s],yominetPositions:(e,t)=>[e,"yominet",t],chainPositions:(e,t,s)=>[e,t,s]});function Ra(e,t){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=t[a],c=r.data;if(!(!i||!c)){for(const l of c)if(l.logoUrl&&!l.logoUrl.includes("undefined")){const u=`${i.chainId}:${l.denom}`;s.has(u)||s.set(u,l.logoUrl);const m=l.symbol.toUpperCase();o.has(m)||o.set(m,l.logoUrl)}}}return{denomLogos:s,symbolLogos:o}}function Ln(e){if(e.type==="fungible-position")return e.value??0;if(e.balance.type==="unknown")return 0;const t=e.balance.value??0;return e.type==="lending"&&e.direction==="borrow"?-t:t}function Sm(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 Tm(e,t=!1){switch(e){case"staking":return t?"INIT staking":"Staking";case"borrowing":return"Borrowing";case"lending":return"Lending";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function Em(e){const t=new Map;for(const u of e){const m=Sm(u);if(!m)continue;const d=t.get(m)??[];d.push(u),t.set(m,d)}const s=new Map,o=new Map;for(const[u,m]of t){const d=m.reduce((f,g)=>f+Ln(g),0),h=m.reduce((f,g)=>f+Math.abs(Ln(g)),0);s.set(u,d),o.set(u,h)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,c=[...t.keys()].sort((u,m)=>{const d=u==="lending"||u==="borrowing"?i:o.get(u)??0,h=m==="lending"||m==="borrowing"?i:o.get(m)??0;return(u==="lending"||u==="borrowing")&&(m==="lending"||m==="borrowing")?u==="lending"?-1:1:h-d}),l=new Map;for(const u of c)l.set(u,{positions:t.get(u),totalValue:s.get(u)??0});return l}function $m(e){return e.type==="fungible-position"?e.title:e.balance.denom}function Mm(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function Lm(e){return e.type==="fungible-position"?null:e.balance}function qm(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 Rm(e){const t=new Map;for(const s of e){const o=t.get(s.type)??[];o.push(s),t.set(s.type,o)}return t}function Pm(e,t){return e.symbol===pt&&t.symbol===pt?0:e.symbol===pt?-1:t.symbol===pt?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function Dm(e){const t=new Map;for(const o of e){const a=$m(o),r=t.get(a)??[];r.push(o),t.set(a,r)}return Array.from(t.entries()).map(([o,a])=>{const r=Lm(a[0]);let i=0;for(const c of a)c.type!=="fungible-position"&&c.balance.type!=="unknown"&&(i+=c.balance.formattedAmount);return{denom:o,symbol:Mm(a[0]),positions:a,totalValue:a.reduce((c,l)=>c+Ln(l),0),totalAmount:i,balance:r}}).sort(Pm)}function jc(e,t){const s=new Map;return e.forEach((o,a)=>{const r=t[a]?.data;if(r&&r.length>0){const i=new Map(r.map(c=>[c.id,c.price]));s.set(o.chainId,i)}}),s}function Bm(e,t){return e.map(s=>({...s,balances:s.balances.map(o=>{if(o.type==="unknown"||o.value!=null&&o.value>0)return o;const a=t.get(s.chainId);if(a){const r=a.get(o.denom)??0;if(r>0)return{...o,value:o.formattedAmount*r}}return o})}))}function Fm(e,t){return e.symbol===pt&&t.symbol===pt?0:e.symbol===pt?-1:t.symbol===pt?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function Um(e,t,s){return e.map(o=>{const a=o.assets.map(i=>{const c=i.symbol.toUpperCase(),l=`${i.chain.chainId}:${i.denom}`,u=t.get(l)??s.get(c)??"";return u!==i.logoUrl?{...i,logoUrl:u}: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 Om(e,t,s){const o=t?e.filter(i=>{const{symbol:c,assets:l}=i,u=t.toLowerCase();return c.toLowerCase().includes(u)||l.some(({denom:m})=>m.toLowerCase().includes(u))}):e,a=s?o.map(i=>{const c=i.assets.filter(({chain:l})=>l.chainId===s);return{...i,assets:c,totalValue:c.reduce((l,u)=>l+(u.value??0),0),totalAmount:c.reduce((l,u)=>l+Number(u.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,c)=>i+c.assets.reduce((l,u)=>l+(u.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Vm(e,t,s){const o=t?e.filter(({denom:a,address:r})=>{const i=t.toLowerCase();return a.toLowerCase().includes(i)||r?.toLowerCase().includes(i)}):e;return s?o.filter(({chain:a})=>a.chainId===s):o}function Km(e,t,s,o){const{filteredAssets:a,totalAssetsValue:r}=Om(e,s,o),i=Vm(t,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function Wm(e,t,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const c of e){const{chainName:l,chainId:u,balances:m}=c;if(!Array.isArray(m))continue;const d=t.get(l.toLowerCase()),h=d?.chainId??u??l,f=d?.prettyName??l,g=d?.logoUrl??"",p=s.get(h);for(const y of m){if(y.type==="unknown"){if(!y.amount||y.amount==="0")continue;r.push({symbol:y.denom,logoUrl:"",denom:y.denom,amount:y.amount,decimals:0,quantity:y.amount,value:void 0,unlisted:!0,chain:{chainId:h,name:f,logoUrl:g}});continue}if(y.type==="lp"||(y.value??0)<=0&&(y.formattedAmount??0)<=0)continue;let x=y.value;if((x==null||x<=0)&&p){const v=p.get(y.denom)??0;v>0&&(x=y.formattedAmount*v)}const b={symbol:y.symbol,logoUrl:"",denom:y.denom,amount:y.amount,decimals:y.decimals,quantity:String(y.formattedAmount),value:x,chain:{chainId:h,name:f,logoUrl:g}},j=a.get(y.symbol);j?j.push(b):a.set(y.symbol,[b])}}r.sort((c,l)=>{const u=c.chain.chainId===o,m=l.chain.chainId===o;if(u&&!m)return-1;if(!u&&m)return 1;const d=c.chain.name.localeCompare(l.chain.name);if(d!==0)return d;try{const h=BigInt(c.amount),f=BigInt(l.amount);if(h>f)return-1;if(h<f)return 1}catch{const h=c.amount.localeCompare(l.amount);if(h!==0)return-h}return c.denom.localeCompare(l.denom)});const i=[];for(const[c,l]of a){l.sort((d,h)=>(h.value??0)-(d.value??0));let u=0,m=0;for(const d of l)u+=d.value??0,m+=Number(d.quantity);i.push({symbol:c,logoUrl:"",assets:l,totalValue:u,totalAmount:m})}return i.sort(Fm),{listedGroups:i,unlistedAssets:r}}function Pa(){return ce().network_type==="testnet"}function Zt(){return $e.useFormContext()}function zm(){const e=et(),t=Pa(),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=L.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(he.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(he.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(he.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(he.BRIDGE_DST_DENOM),quantity:localStorage.getItem(he.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(he.BRIDGE_SLIPPAGE_PERCENT)});return{...t?o:a,...r,...e}}const Hm={balances:[],positions:[],isLoading:!0,isComplete:!1},Cc=H.atom(0),Qm=1e3;let yr=0;function Gm(){const e=H.useSetAtom(Cc);_.useEffect(()=>{const t=Date.now();t-yr>=Qm&&(yr=t,e(s=>s+1))},[e])}function Ym(){const e=E.useQueryClient(),t=ie(),{minityUrl:s}=se(),o=Pa(),a=H.useAtomValue(Cc),r=_.useEffectEvent((l,u)=>{const m=Array.isArray(l.balances)?l.balances:[];u.set(l.chain,{chainName:l.chain,chainId:l.chainId,balances:m})}),i=_.useEffectEvent((l,u)=>{const m=Array.isArray(l.positions)?l.positions:[];u.set(l.chain,{chainName:l.chain,chainId:l.chainId,positions:m})}),c=_.useEffectEvent((l,u)=>{const m=Zo.ssePortfolio(t??"",s).queryKey,d=e.getQueryData(m)??Hm,h=l.size>0||u.size>0;e.setQueryData(m,{...d,balances:Array.from(l.values()),positions:Array.from(u.values()),isLoading:h?!1:d.isLoading,isComplete:!1})});_.useEffect(()=>{if(!t||o)return;const l=Zo.ssePortfolio(t,s).queryKey,u=e.getQueryData(l),m=new Map,d=new Map;for(const y of u?.balances??[])m.set(y.chainName,y);for(const y of u?.positions??[])d.set(y.chainName,y);const f=`${s}/v1/chain/all/${encodeURIComponent(t)}`;let g=null,p=!1;return e.setQueryData(l,{balances:u?.balances??[],positions:u?.positions??[],isLoading:!0,isComplete:!1}),g=new EventSource(f),g.onmessage=y=>{if(!p)try{const x=JSON.parse(y.data);x.type==="balances"?r(x,m):x.type==="positions"&&i(x,d),c(m,d)}catch{}},g.onerror=()=>{g?.close()},()=>{p=!0,g?.close()}},[t,o,a])}const xr={balances:[],positions:[],isLoading:!0,isComplete:!1};function ms(){const e=ie(),{minityUrl:t}=se(),s=Zo.ssePortfolio(e??"",t).queryKey,{data:o}=E.useQuery({queryKey:s,queryFn:()=>xr,enabled:!!e,staleTime:V.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??xr}function Zm(){const e=_e();return _.useMemo(()=>{const t=new Map;for(const s of e){const o=s.chain_name.toLowerCase();t.set(o,{chainId:s.chainId,chainName:s.chain_name,prettyName:s.name||s.chain_name,logoUrl:s.logoUrl||""})}return t},[e])}function Jm(){const{balances:e,positions:t}=ms(),s=_e(),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((g,p)=>{if(p.type==="fungible-position")return g+(p.value??0);if(p.balance.type==="unknown")return g;const y=p.balance.value??0;return p.type==="lending"&&p.direction==="borrow"?g-y:g+y},0),c=new Map,l=Array.isArray(e)?e:[],u=Array.isArray(t)?t:[];for(const{chainName:f,balances:g}of l){if(!Array.isArray(g))continue;const p=g.reduce((y,x)=>y+r(x),0);c.set(f,(c.get(f)||0)+p)}for(const{chainName:f,positions:g}of u){if(!Array.isArray(g))continue;const p=g.reduce((y,x)=>y+i(x),0);c.set(f,(c.get(f)||0)+p)}const m=Array.from(c.values()).reduce((f,g)=>f+g,0),d=Array.from(c.entries()).filter(([,f])=>f>0).map(([f,g])=>{const p=o.get(f.toLowerCase());return{chainId:p?.chainId||"",chainName:p?.name||f,logoUrl:p?.logoUrl||"",totalBalance:g,percentage:m>0?g/m:0}}).filter(f=>f.chainId!==""),h=f=>f.chainName.toLowerCase()==="initia";return L.sortWith([L.descend(h),L.descend(L.prop("totalBalance"))],d)},[e,t,o])}function Xm(){const{balances:e}=ms(),t=_e(),s=ga(),o=_.useMemo(()=>jc(t,s),[t,s]);return _.useMemo(()=>{const a=l=>l.type==="unknown"?0:l.value??0;let r=0;const i=Array.isArray(e)?e:[],c=Bm(i,o);for(const{balances:l}of c)if(Array.isArray(l))for(const u of l)u.type!=="lp"&&(r+=a(u));return r},[e,o])}function eh(){const{positions:e}=ms();return _.useMemo(()=>{const t=r=>r.positions.reduce((i,c)=>{if(c.type==="fungible-position")return i+(c.value??0);if(c.balance.type==="unknown")return i;const l=c.balance.value??0;return c.type==="lending"&&c.direction==="borrow"?i-l:i+l},0),s=["initia","civitia","yominet"];let o=0;const a=Array.isArray(e)?e:[];for(const{chainName:r,positions:i}of a){const c=r.toLowerCase();s.includes(c)||Array.isArray(i)&&(o+=i.reduce((l,u)=>l+t(u),0))}return o},[e])}const Ie=qe.createQueryKeys("interwovenkit:skip",{chains:null,allAssets:()=>["allAssets"],assets:e=>[e],asset:(e,t)=>[e,t],allBalances:(e,t)=>[e,t],balances:(e,t)=>[e,t],route:(e,t)=>[{...e,quantity:q(e.quantity||0).toString()},t],routeErrorInfo:e=>[e],txTrack:(e,t)=>[e,t],txStatus:(e,t)=>[e,t]});function Fe(){const{routerApiUrl:e}=se();return _.useMemo(()=>z.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.6.0"}}),[e])}function th(){const e=Fe();E.usePrefetchQuery({queryKey:Ie.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),staleTime:V.MINUTE}),E.usePrefetchQuery({queryKey:Ie.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:V.MINUTE})}const nh=()=>(hu(),fu(),null),sh="_loader_1vxch_1",oh={loader:sh},It=({size:e=24,color:t="currentColor",border:s=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${t} ${t} transparent ${t}`,borderWidth:`${s}px`};return n.jsx("div",{className:oh.loader,style:o,role:"status","aria-label":"Loading"})},ah="_button_1q027_1",rh="_outline_1q027_28",ih="_sm_1q027_46",ch="_full_1q027_53",lh="_small_1q027_57",uh="_unpadded_1q027_88",un={button:ah,outline:rh,sm:ih,full:ch,small:lh,unpadded:uh},kc=e=>{const{sm:t,fullWidth:s,loading:o,className:a,children:r,disabled:i,...c}=e;return n.jsx("button",{...c,className:B(un.button,{[un.sm]:t,[un.full]:s},a),disabled:!!o||i,"aria-busy":!!o,children:o?n.jsxs(n.Fragment,{children:[n.jsx(It,{color:"currentColor",size:16}),typeof o=="string"&&n.jsx("span",{className:un.loading,children:o})]}):r})},dh=({className:e,...t})=>n.jsx(kc,{...t,className:B(un.outline,e)}),mh=({className:e,unpadded:t,...s})=>n.jsx("button",{...s,className:B(un.small,{[un.unpadded]:t},e)}),fe={White:kc,Outline:dh,Small:mh},hh="_footer_1vp4h_1",fh="_actions_1vp4h_10",br={footer:hh,actions:fh},Ae=({extra:e,className:t,children:s})=>n.jsxs("footer",{className:B(br.footer,t),children:[e,n.jsx("div",{className:br.actions,children:s})]}),ph="_scrollable_13su7_1",gh={scrollable:ph},yt=({className:e,children:t,ref:s})=>n.jsx("div",{ref:s,className:B(gh.scrollable,e),children:t}),_h="interwovenkit:";function yh(e){const[t]=e;return typeof t=="string"&&t.startsWith(_h)}function xh(e){e.removeQueries({predicate:t=>yh(t.queryKey)})}function uo(){return Ge.useMediaQuery("(max-width: 576px)")}const Jo="interwoven-kit";function Nc(){const e=document.querySelector(Jo)||document.body.appendChild(document.createElement(Jo));return e.shadowRoot||e.attachShadow({mode:"open"})}function Ic(){const{theme:e,container:t}=se();return _.useEffect(()=>{document.querySelector(Jo)?.setAttribute("data-theme",e)},[e]),t??Nc()}function bh(e){const t=Nc(),s=document.createElement("style");s.textContent=e,t.appendChild(s)}const mo=_.createContext(null);function _n(){const{container:e}=_.useContext(mo);return e}function Ac(e){const t=_n();return t?getComputedStyle(t).getPropertyValue(e):""}function wh(){return Ge.useScrollLock(),null}function vh(e){return/^[A-F0-9]{64}$/i.test(e)}function jh(e,t){const{txHash:s,accountAddress:o,pathSuffix:a}=t;if(s)return vh(s)?L.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!k.InitiaAddress.validate(o))return;const i=L.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function Ch(e){try{const t=new URL(e,window.location.href);if(!["http:","https:"].includes(t.protocol))throw new Error("Invalid protocol");return t.toString()}catch{return"#"}}const kh="_link_j1lkz_1",wr={link:kh},ho=({chainId:e,txHash:t,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:c,onClick:l,...u}=a,m=_t(e),d=jh(m,{txHash:t,accountAddress:s,pathSuffix:o}),h=t?k.truncate(t):s?k.truncate(s):"",f=c??h;return d?n.jsxs("a",{...u,href:Fl(Ch(d)),className:B(wr.link,i),onClick:l,target:"_blank",rel:"noopener noreferrer",children:[f,r&&n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})]}):n.jsx("span",{...u,className:B(wr.link,i),children:f})},Sc=_.createContext(null),hs=()=>_.useContext(Sc),Nh=()=>{const[e,t]=H.useAtom(sc),{showNotification:s,updateNotification:o,hideNotification:a}=hs();return _.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:c,error:l}=e,u=l?l.message:c?n.jsx(ho,{txHash:c,chainId:i,onClick:a,showIcon:!0,children:"View on Initia Scan"}):null;switch(r){case"loading":s({type:"loading",title:"Transaction is pending..."});break;case"error":o({type:"error",title:"Transaction failed",description:u}),t(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:u,autoHide:!0}),t(null);break}},[e,t,s,o,a]),null},Ws=({value:e,children:t})=>{const[s,o]=_.useState(!1);return t({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},Ih="_placeholder_10r3x_1",Ah="_logo_10r3x_5",vr={placeholder:Ih,logo:Ah},re=({src:e,alt:t,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[c,l]=_.useState(void 0),{width:u,height:m}=i,d=s??n.jsx("div",{className:B(vr.placeholder,o?.placeholder),style:{width:u,height:m,...a},"aria-hidden":"true"});return!e||c===e?d:n.jsx("img",{...i,className:B(i.className,{[vr.logo]:r}),style:{width:u,height:m,...a},src:e,alt:t,loading:"lazy",onError:()=>l(e)})};function Tc(){const{connector:e}=Qe.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const Sh="_header_1q8ju_1",Th="_account_1q8ju_17",Eh="_name_1q8ju_28",$h="_address_1q8ju_32",Mh="_icon_1q8ju_36",Lh="_copied_1q8ju_43",qh="_button_1q8ju_58",Rh="_settings_1q8ju_69",Ph="_disconnect_1q8ju_73",Dh="_label_1q8ju_83",Bh="_expanded_1q8ju_91",st={header:Sh,account:Th,name:Eh,address:$h,icon:Mh,copied:Lh,button:qh,settings:Rh,disconnect:Ph,label:Dh,expanded:Bh},Fh=()=>{const e=Di(),{address:t,username:s}=tt(),o=Tc(),a=s??t,[r,i]=_.useState(!1),c=_.useRef(null),l=Nt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),u=()=>{r?e():i(!0)},m=()=>{r&&(c.current=setTimeout(()=>{i(!1)},500))},d=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return _.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),t?n.jsxs("header",{className:st.header,children:[n.jsx(Ws,{value:t,children:({copy:h,copied:f})=>n.jsxs("button",{className:B(st.account,{[st.copied]:f}),onClick:h,"aria-label":f?"Copied":"Copy address",children:[n.jsx(re,{src:o,width:18,height:18}),n.jsx("div",{className:st.address,children:k.truncate(t)}),n.jsx("div",{className:st.name,children:k.truncate(a)}),n.jsx(M.IconCopy,{className:st.icon,size:12,"aria-hidden":"true"}),f?"Copied!":""]})}),n.jsx(mn,{to:"/settings",className:B(st.button,st.settings),"aria-label":"Open settings",children:n.jsx(M.IconSettingFilled,{size:16,"aria-hidden":"true"})}),n.jsxs(Nt.animated.button,{className:B(st.button,st.disconnect,{[st.expanded]:r}),style:l,onClick:u,onMouseLeave:m,onMouseEnter:d,"aria-label":"Disconnect wallet",children:[n.jsx(M.IconSignOut,{size:16,"aria-hidden":"true"}),n.jsx("span",{className:st.label,children:"Disconnect"})]})]}):null},Uh="_overlay_jij9g_1",Oh="_content_jij9g_28",Vh="_inner_jij9g_60",Mo={overlay:Uh,content:Oh,inner:Vh},Kh=({children:e})=>{const{isDrawerOpen:t,closeDrawer:s}=Dt(),{setContainer:o}=_.useContext(mo),a=_.useCallback(p=>{p&&o(p)},[o]),r=uo(),i=Ic(),c=H.useAtomValue(ro),l=H.useAtomValue(rs),u=E.useIsMutating({mutationKey:[nc]}),m=()=>{const p=u?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),c?.reject(new Error(p)),l?.reject(new Error("User rejected"))},d=to(),h=Me(),f=E.useQueryClient(),g={fallbackRender:({error:p,resetErrorBoundary:y})=>{const x=()=>{d==="/bridge"&&(localStorage.removeItem(he.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(he.BRIDGE_SRC_DENOM),localStorage.removeItem(he.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(he.BRIDGE_DST_DENOM)),h("/"),xh(f),y()};return n.jsxs(yt,{children:[n.jsx(je,{error:!0,children:p.message}),n.jsx(Ae,{children:n.jsx(fe.White,{onClick:x,children:"Retry"})})]})}};return n.jsx(Be.Dialog.Root,{open:t,onOpenChange:p=>!p&&m(),modal:!1,children:n.jsxs(Be.Dialog.Portal,{container:i,children:[r&&n.jsx(Be.Dialog.Backdrop,{className:Mo.overlay,onClick:m,children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:[n.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"}),n.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"})]})}),n.jsx(Be.Dialog.Popup,{className:Mo.content,children:n.jsxs("div",{className:B(Mo.inner,"body"),ref:a,children:[r&&n.jsx(wh,{}),n.jsx(Nh,{}),n.jsx(Fh,{}),n.jsx(xe,{errorBoundaryProps:g,children:e})]})})]})})},Wh="_backdrop_1bqx9_1",zh="_modal_1bqx9_12",Hh="_closeButton_1bqx9_44",Lo={backdrop:Wh,modal:zh,closeButton:Hh},Qh=({children:e})=>{const{isModalOpen:t,closeModal:s}=Dn(),{setContainer:o}=_.useContext(mo),a=_.useCallback(i=>{i&&o(i)},[o]),r=Ic();return n.jsx(Be.Dialog.Root,{open:t,onOpenChange:i=>!i&&s(),children:n.jsxs(Be.Dialog.Portal,{container:r,children:[n.jsx(Be.Dialog.Backdrop,{className:Lo.backdrop,onClick:s}),n.jsxs(Be.Dialog.Popup,{className:Lo.modal,ref:a,children:[n.jsx("button",{className:Lo.closeButton,onClick:s,"aria-label":"Close",children:n.jsx(M.IconClose,{size:20})}),n.jsx(xe,{children:e})]})]})})},Ec=_.createContext(!1),Gh="_overlay_1iyfl_1",Yh="_fullscreen_1iyfl_15",Zh="_content_1iyfl_19",Jh="_header_1iyfl_56",Xh="_title_1iyfl_65",ef="_close_1iyfl_70",tn={overlay:Gh,fullscreen:Yh,content:Zh,header:Jh,title:Xh,close:ef},$c=({title:e,children:t,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=_n(),c=_.useContext(Ec);return i?n.jsxs(Be.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&n.jsx(Be.Dialog.Trigger,{className:o,children:s}),n.jsxs(Be.Dialog.Portal,{container:i,children:[n.jsx(Be.Dialog.Backdrop,{className:B(tn.overlay,{[tn.fullscreen]:c}),onClick:()=>r(!1),forceRender:!0}),n.jsxs(Be.Dialog.Popup,{className:B(tn.content,{[tn.fullscreen]:c}),children:[e&&n.jsxs("header",{className:tn.header,children:[n.jsx(Be.Dialog.Title,{className:tn.title,children:e}),n.jsx(Be.Dialog.Close,{className:tn.close,"aria-label":"Close",children:n.jsx(M.IconClose,{size:20,"aria-hidden":"true"})})]}),t]})]})]}):null},ts=({children:e})=>{const t=_.useRef(null),[s,o]=_.useState(0),[a,r]=_.useState(!1),i=Nt.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return _.useEffect(()=>{const c=t.current;if(!c)return;const l=()=>{const{height:m}=c.getBoundingClientRect();o(m),r(!0)};l();const u=new ResizeObserver(l);return u.observe(c),()=>u.disconnect()},[e]),e?n.jsx(Nt.animated.div,{style:{overflow:"hidden",...i},children:n.jsx("div",{ref:t,children:e})}):null},tf="_help_qcmtq_1",nf="_icon_qcmtq_10",sf="_info_qcmtq_19",of="_warning_qcmtq_23",af="_error_qcmtq_27",rf="_success_qcmtq_33",qo={help:tf,icon:nf,info:sf,warning:of,error:af,success:rf},In=({level:e,className:t,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return n.jsx(It,{size:12});case"info":return n.jsx(M.IconInfoFilled,{size:12});case"warning":case"error":return n.jsx(M.IconWarningFilled,{size:12});default:return n.jsx(M.IconCheckCircleFilled,{size:12})}};return n.jsxs("div",{className:B(qo.help,e&&qo[e],t),style:{marginTop:s},role:e==="error"?"alert":"status",children:[n.jsx("div",{className:qo.icon,"aria-hidden":"true",children:a()}),o]})},cf="_stack_a6m7u_1",lf="_help_a6m7u_6",uf="_info_a6m7u_14",df="_warning_a6m7u_19",mf="_error_a6m7u_24",hf="_success_a6m7u_29",Xo={stack:cf,help:lf,info:uf,warning:df,error:mf,success:hf},ff=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:n.jsx(ts,{children:n.jsx("div",{className:Xo.stack,children:e})}),we=({mt:e=0,...t})=>n.jsx(In,{...t,className:B(Xo.help,Xo[t.level]),mt:e});we.Stack=ff;const pf="_root_16p5j_1",gf="_item_16p5j_10",_f="_chevron_16p5j_14",yf="_trigger_16p5j_19",xf="_content_16p5j_39",On={root:pf,item:gf,chevron:_f,trigger:yf,content:xf};function bf(e){const{list:t,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return n.jsxs(te.Accordion.Root,{className:On.root,type:"multiple",...i,children:[t.map((c,l)=>n.jsxs(te.Accordion.Item,{className:On.item,value:s?.(c)??String(l),children:[n.jsx(te.Accordion.Header,{children:n.jsxs(te.Accordion.Trigger,{className:On.trigger,children:[o(c),n.jsx(M.IconChevronDown,{className:On.chevron,size:16,"aria-hidden":"true"})]})}),n.jsx(te.Accordion.Content,{className:On.content,children:a(c)})]},s?.(c)??l)),r]})}const wf="_trigger_u613p_1",vf="_icon_u613p_18",jf="_content_u613p_27",Cf="_item_u613p_36",kf="_itemText_u613p_52",Nf="_itemIndicator_u613p_57",If="_active_u613p_60",Ot={trigger:wf,icon:vf,content:jf,item:Cf,itemText:kf,itemIndicator:Nf,active:If};function Da({options:e,value:t,onChange:s,classNames:o}){const a=_n(),r=e.find(c=>c.value===t);if(!r)throw new Error("Selected option not found");const i=c=>{const l=e.find(u=>String(u.value)===c);if(!l)throw new Error(`Option not found: ${c}`);s(l.value)};return n.jsxs(Lt.Select.Root,{value:String(t),onValueChange:i,modal:!1,children:[n.jsxs(Lt.Select.Trigger,{className:B(Ot.trigger,o?.trigger),children:[n.jsx(Lt.Select.Value,{children:r.triggerLabel||r.label}),n.jsx(Lt.Select.Icon,{className:Ot.icon,children:n.jsx(M.IconChevronDown,{size:12,"aria-hidden":"true"})})]}),n.jsx(Lt.Select.Portal,{container:a,children:n.jsx(Lt.Select.Positioner,{className:Ot.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:n.jsx(Lt.Select.Popup,{className:Ot.popup,children:e.map(c=>n.jsxs(Lt.Select.Item,{className:B(Ot.item,o?.item),value:String(c.value),children:[n.jsx(Lt.Select.ItemText,{className:B(Ot.itemText,o?.itemText),children:c.label}),n.jsx(M.IconCheck,{size:12,className:B(Ot.itemIndicator,{[Ot.active]:c.value===t}),"aria-hidden":"true"})]},String(c.value)))})})})]})}const Af="_root_1t37n_1",Sf="_trigger_1t37n_7",Tf="_item_1t37n_11",Ef="_itemText_1t37n_17",jr={root:Af,trigger:Sf,item:Tf,itemText:Ef},$f=({options:e,value:t,onChange:s})=>{const{txRequest:o}=ac(),a=_t(o.chainId),r=St(a),i=(g,p)=>{if(k.formatAmount(g,{decimals:p})==="0.000000")return 8},c=({amount:[{amount:g,denom:p}]})=>{if(q(g).isZero())return"0";const{symbol:y,decimals:x}=r(p),b=i(g,x);return`${k.formatAmount(g,{decimals:x,dp:b})} ${y}`},l=e.map(g=>{const[{denom:p}]=g.amount,{symbol:y}=r(p);return{value:p,label:c(g),triggerLabel:y}});if(e.length===1)return n.jsx("span",{className:"monospace",children:c(e[0])});const u=e.find(g=>g.amount[0].denom===t);if(!u)throw new Error("Fee option not found");const[{amount:m,denom:d}]=u.amount,{decimals:h}=r(d),f=i(m,h);return n.jsxs("div",{className:jr.root,children:[n.jsx("span",{className:"monospace",children:k.formatAmount(m,{decimals:h,dp:f})}),n.jsx(Da,{options:l,value:t,onChange:s,classNames:jr})]})},Mf="_root_16nr2_1",Lf="_trigger_16nr2_5",qf="_chevron_16nr2_13",Rf="_panel_16nr2_27",Pf="_details_16nr2_39",Df="_row_16nr2_48",Cn={root:Mf,trigger:Lf,chevron:qf,panel:Rf,details:Pf,row:Df},Bf=({spend:e,fee:t,total:s,balance:o,symbol:a,decimals:r})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:t},e&&{label:"Required (spend + fee)",value:s},{label:"Balance",value:o}].filter(Boolean),c=r===6?void 0:8;return n.jsxs(Io.Collapsible.Root,{className:Cn.root,children:[n.jsxs(Io.Collapsible.Trigger,{className:Cn.trigger,children:[n.jsx("span",{children:"Insufficient balance for fee"}),n.jsx(M.IconChevronDown,{className:Cn.chevron,size:16})]}),n.jsx(Io.Collapsible.Panel,{className:Cn.panel,children:n.jsx("div",{className:Cn.details,children:i.map(({label:l,value:u})=>n.jsxs("div",{className:Cn.row,children:[n.jsx("span",{children:l}),n.jsxs("span",{children:[k.formatAmount(u,{decimals:r,dp:c})," ",a]})]},l))})})]})};function zs(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?de.toBase64(e):Array.isArray(e)?`[${e.map(zs).join(",")}]`:JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const Ff="_container_1xzyq_1",Uf="_toggle_1xzyq_5",Of="_list_1xzyq_11",Vf="_arg_1xzyq_16",Kf="_type_1xzyq_21",Vn={container:Ff,toggle:Uf,list:Of,arg:Vf,type:Kf},Wf=qe.createQueryKeys("interwovenkit:move",{abi:(e,t,s,o)=>[e,t,s,o]}),zf=({type:e,arg:t})=>zs(k.resolveBcsType(e).parse(t)),Hf=({msg:e,chainId:t,fallback:s})=>{const[o,a]=Ge.useToggle(!1),{restUrl:r}=_t(t),{moduleAddress:i,moduleName:c,functionName:l,args:u}=e,{data:m}=E.useQuery({queryKey:Wf.abi(r,i,c,l).queryKey,queryFn:async()=>{const h=await z.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),g=JSON.parse(h.module.abi).exposed_functions.find(({name:p})=>p===l);if(!g)throw new Error(`Function ${l} not found in module ${c}`);return g.params.filter(p=>!p.startsWith("&"))},staleTime:V.INFINITY});if(!m)return s;const d=(h,f)=>{const g=m[f];return n.jsxs("div",{className:Vn.arg,children:[n.jsx("div",{className:Vn.type,children:g}),n.jsx(li.ErrorBoundary,{fallback:n.jsx("div",{className:"error",children:"Error decoding argument"}),children:n.jsx(zf,{type:g,arg:h})})]},f)};return n.jsxs("div",{className:Vn.container,children:[n.jsx(fe.Small,{className:Vn.toggle,onClick:a,disabled:!m,children:o?"Encode":"Decode"}),o?n.jsx("div",{className:Vn.list,children:u.map(d)}):s]})},Qf="_list_oip9m_1",Gf="_key_oip9m_9",Yf="_value_oip9m_14",Ro={list:Qf,key:Gf,value:Yf},Zf=({message:e,chainId:t})=>{const{typeUrl:s,value:o}=e;return n.jsx("div",{className:Ro.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{children:[n.jsx("div",{className:Ro.key,children:a}),n.jsx("div",{className:Ro.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?n.jsx(Hf,{msg:o,chainId:t,fallback:zs(r)}):zs(r)})]},a))})},Jf="_item_1n572_1",Xf="_title_1n572_10",ep="_content_1n572_14",Po={item:Jf,title:Xf,content:ep},Do=({title:e,content:t})=>n.jsxs("div",{className:Po.item,children:[n.jsx("div",{className:Po.title,children:e}),n.jsx("div",{className:Po.content,children:t})]});function ae(e){const t=e?q(e).abs():void 0;if(t&&t.gt(0)&&t.lt(.01))return"< $0.01";const s=e&&q(e).lt(0),o=k.formatNumber(t?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function Ba(e,t){return t==null?"$-":ae(e??0)}function Mc(e,t){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")){if(o.type==="coin_spent"){const r=o.attributes.find(c=>c.key==="spender")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===t&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const u=s[l]||BigInt(0);s[l]=u-BigInt(c)}}}if(o.type==="coin_received"){const r=o.attributes.find(c=>c.key==="receiver")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===t&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const u=s[l]||BigInt(0);s[l]=u+BigInt(c)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),denom:o}))}function Lc(e,t){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")&&o.type==="move"){const r=o.attributes.find(l=>l.key==="type_tag")?.value,i=o.attributes.find(l=>l.key==="data")?.value;if(!r||!i)continue;let c;try{c=JSON.parse(i)}catch{continue}if(r==="0x1::fungible_asset::WithdrawEvent"){const l=c.store_addr,u=c.amount,m=c.metadata_addr;if(l&&u&&m&&k.createUserDerivedObjectAddress(t,m)===l){const h=s[m]||BigInt(0);s[m]=h-BigInt(u)}}if(r==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,u=c.amount,m=c.metadata_addr;if(l&&u&&m&&k.createUserDerivedObjectAddress(t,m)===l){const h=s[m]||BigInt(0);s[m]=h+BigInt(u)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const qc=({metadata:e,chain:t,children:s})=>{const{restUrl:o}=t,{data:a}=E.useSuspenseQuery({queryKey:$n.denom(o,e).queryKey,queryFn:()=>z.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:V.INFINITY});return s(a)},tp="_root_1p8a4_1",np="_title_1p8a4_8",sp="_changes_1p8a4_14",op="_change_1p8a4_14",ap="_amount_1p8a4_35",rp="_text_1p8a4_42",ip="_value_1p8a4_49",dn={root:tp,title:np,changes:sp,change:op,amount:ap,text:rp,value:ip},Rc=({amount:e,asset:t,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=t,c=k.formatAmount(e,{decimals:r}),l=s&&q(k.fromBaseUnit(e,{decimals:r})).times(s).abs();return n.jsxs("div",{className:dn.change,children:[n.jsxs("div",{className:dn.amount,children:[n.jsx(re,{src:i,width:14,height:14,logo:!0}),n.jsxs("span",{className:dn.text,children:[c," ",a||o]})]}),l&&n.jsx("div",{className:dn.value,children:ae(l)})]})},cp=({changes:e,chain:t})=>{const s=St(t),{data:o}=Pt(t);return e.map(({amount:a,denom:r},i)=>{const c=s(r),l=o?.find(({id:u})=>u===r)?.price;return n.jsx(Rc,{amount:a,asset:c,price:l},i)})},lp=({changes:e,chain:t})=>{const s=St(t),{data:o}=Pt(t);return e.map(({amount:a,metadata:r},i)=>n.jsx(qc,{metadata:r,chain:t,children:c=>{const l=o?.find(({id:u})=>u===c)?.price;return n.jsx(Rc,{amount:a,asset:s(c),price:l})}},i))};function up(e,t){return typeof t=="bigint"?t.toString():t}const dp=qe.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,up)]}),mp=({messages:e,memo:t,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=tt(),r=_t(s),{simulateTx:i}=io(),{data:c}=E.useSuspenseQuery({queryKey:dp.simulate({messages:e,memo:t,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:t,chainId:s}),staleTime:V.SECOND}),l=h=>n.jsxs("div",{className:dn.root,children:[n.jsx("h2",{className:dn.title,children:"Estimated changes"}),n.jsx("div",{className:dn.changes,children:h})]});if(!c)return null;const u=c.result?.events??[];if(u.length===0)return null;if(r.metadata?.is_l1||r.metadata?.minitia?.type==="minimove"){const h=Lc(u,a),[f]=Cr(h);return f.length===0?null:l(n.jsx(lp,{changes:f,chain:r}))}const m=Mc(u,o),[d]=Cr(m);return d.length===0?null:l(n.jsx(cp,{changes:d,chain:r}))};function Cr(e){return L.partition(t=>new q(t.amount).isNegative(),e)}const hp="_title_1d032_1",fp="_meta_1d032_7",pp="_footer_1d032_14",gp="_rejectButton_1d032_19",Ns={title:hp,meta:fp,footer:pp,rejectButton:gp},Pc=()=>{const{txRequest:e,resolve:t,reject:s}=ac(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:c,spendCoins:l}=e,u=_t(r),m=as(u),d=Na(u),h=Ia(u),f=St(u),g=oc(),p=(e.gasPrices??d).map(({amount:A,denom:$})=>Le.calculateFee(Math.ceil(i*c),Le.GasPrice.fromString(A+$))),y=p.map(A=>A.amount[0]),x=A=>{const $=m.find(K=>K.denom===A)?.amount??"0",N=y.find(K=>K.denom===A)?.amount??"0",S=l.filter(K=>K.denom===A).reduce((K,W)=>q(K).plus(W.amount),q("0")),P=q(N).plus(S),F=q($).gte(P),{symbol:D,decimals:Z}=f(A);return{symbol:D,decimals:Z,spend:S.gt(0)?S.toFixed():null,fee:N,total:P.toFixed(),balance:$,isSufficient:F}},b=()=>{if(h&&x(h).isSufficient)return h;for(const{denom:A}of y)if(x(A).isSufficient)return A;return y[0]?.denom},[j,v]=_.useState(b),{mutate:w,isPending:C}=E.useMutation({mutationKey:[nc],mutationFn:async()=>{const A=p.find(N=>N.amount[0].denom===j);if(!A)throw new Error("Fee not found");const $=await g({chainId:r,messages:o,memo:a||"",fee:A,preferredFeeDenom:j,allowAutoSign:!e.internal,allowWalletDerivation:!0});await t($)},onError:async A=>{s(A)}}),I=x(j),T=!I.isSufficient;return n.jsxs(n.Fragment,{children:[n.jsxs(yt,{children:[n.jsx("h1",{className:Ns.title,children:"Confirm tx"}),n.jsxs("section",{className:Ns.meta,"aria-label":"Transaction metadata",children:[n.jsx(Do,{title:"Chain",content:r}),n.jsx(Do,{title:"Tx fee",content:n.jsx($f,{options:p,value:j,onChange:v})}),a&&n.jsx(Do,{title:"Memo",content:a}),T&&n.jsx(we,{level:"error",children:n.jsx(Bf,{...I})})]}),n.jsx(mp,{messages:o,memo:a,chainId:r}),n.jsx(bf,{list:o,renderHeader:({typeUrl:A})=>Ys.sentenceCase(A.split(".").pop().replace(/^Msg/,"")),renderContent:A=>n.jsx(Zf,{message:A,chainId:r})})]}),n.jsxs(Ae,{className:Ns.footer,children:[n.jsx(fe.Outline,{onClick:()=>s(new Error("User rejected")),disabled:C,className:Ns.rejectButton,"aria-label":"Reject",children:n.jsx(M.IconClose,{size:16})}),n.jsx(fe.White,{onClick:()=>w(),disabled:T,loading:C,children:"Approve"})]})]})},_p=({children:e})=>{const[{title:t,content:s,path:o},a]=_.useState({}),[r,i]=_.useState(!1),c=H.useAtomValue(ro),l=_.useCallback(d=>{a(d),i(!0)},[]),u=_.useCallback(()=>{a({}),i(!1)},[]),m=_.useCallback(d=>{d||(c?.reject(new Error("User rejected")),a({})),i(d)},[c]);return n.jsxs(Xi.Provider,{value:{openModal:l,closeModal:u},children:[e,n.jsx($c,{title:t,open:r,onOpenChange:m,children:n.jsx(xe,{children:o==="/tx"?n.jsx(Pc,{}):s})})]})},yp="_container_1w1hx_1",xp="_toast_1w1hx_11",bp="_info_1w1hx_24",wp="_success_1w1hx_28",vp="_error_1w1hx_32",jp="_icon_1w1hx_37",Cp="_content_1w1hx_45",kp="_title_1w1hx_48",Np="_description_1w1hx_53",Ip="_close_1w1hx_75",Vt={container:yp,toast:xp,info:bp,success:wp,error:vp,icon:jp,content:Cp,title:kp,description:Np,close:Ip},Ap=({notification:e,onClose:t,...s})=>{const o=Nt.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 n.jsx(It,{size:16});case"info":case"success":return n.jsx(M.IconCheckCircleFilled,{size:16});case"error":return n.jsx(M.IconCloseCircleFilled,{size:16});default:return null}};return o((r,i)=>{if(!i)return null;const{type:c,title:l,description:u}=i,m=a(c);return n.jsx(Nt.animated.div,{style:r,className:Vt.container,children:n.jsxs("div",{className:B(Vt.toast,c&&Vt[c]),role:"alert",...s,children:[m&&n.jsx("div",{className:Vt.icon,"aria-hidden":"true",children:m}),n.jsxs("div",{className:Vt.content,children:[n.jsx("p",{className:Vt.title,children:l}),u&&n.jsx("div",{className:Vt.description,children:u})]}),n.jsx("button",{className:Vt.close,onClick:t,"aria-label":"Dismiss notification",children:n.jsx(M.IconClose,{size:14,"aria-hidden":"true"})})]})})})},Bo=5e3,Sp=({children:e})=>{const t=_n(),[s,o]=_.useState(null),a=_.useRef(null),r=_.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},c=_.useCallback(()=>{i(),o(null)},[]),l=_.useCallback(h=>{i(),o({...h,id:ar.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Bo))},[c]),u=_.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:ar.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Bo))},[c]),m=()=>{i(),r.current=!0},d=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>c(),Bo))};return _.useEffect(()=>()=>i(),[]),n.jsxs(Sc.Provider,{value:{showNotification:l,updateNotification:u,hideNotification:c},children:[e,t&&Ul.createPortal(n.jsx(Ap,{notification:s,onClose:c,onMouseEnter:m,onMouseLeave:d}),t)]})},Tp=({children:e})=>{const[t,s]=_.useState(null);return n.jsx(mo.Provider,{value:{container:t,setContainer:s},children:e})},Dc=[{value:10*Li,label:"for 10 minutes"},{value:qi,label:"for 1 hour"},{value:ur,label:"for 1 day"},{value:7*ur,label:"for 7 days"},{value:0,label:"until revoked"}],Ep=Dc[0].value;function $p(e){const t=e.split(".");return t.length!==4?!1:t.every(s=>{if(!/^\d+$/.test(s))return!1;const o=Number(s);return o>=0&&o<=255})}function Bc(e){return $p(e)||e.includes(":")}function ea(e){const t=Ol.parse(e);return"error"in t?null:t.domain}function Mp(e,t){return e===t||e===`www.${t}`}function Lp(e){if(e.protocol!=="https:")return!1;const t=e.hostname.toLowerCase();return!t||!t.includes(".")||t==="localhost"||Bc(t)?!1:ea(t)!==null}function qp(e,t){try{const s=new URL(e);if(!Lp(s))return!1;const o=s.hostname.toLowerCase(),a=t.toLowerCase();if(!o||!a||Bc(a)||a==="localhost")return!1;const r=ea(o);if(!r)return!1;const i=ea(a);return!i||i!==r?!1:Mp(o,r)?a===r||a.endsWith(`.${r}`):a===o||a.endsWith(`.${o}`)}catch{return!1}}const Rp="_container_1422v_1",Pp="_title_1422v_7",Dp="_description_1422v_14",Bp="_sectionTitle_1422v_20",Fp="_websiteInfo_1422v_27",Up="_favicon_1422v_37",Op="_websiteTitle_1422v_42",Vp="_websiteHost_1422v_48",Kp="_warningContent_1422v_54",Wp="_ignoreButton_1422v_61",zp="_infoList_1422v_65",Hp="_infoItem_1422v_75",Qp="_label_1422v_84",Gp="_infoValue_1422v_94",Yp="_durationTrigger_1422v_100",Zp="_durationItem_1422v_101",Jp="_featureList_1422v_105",Xp="_featureItem_1422v_113",eg="_checkIcon_1422v_123",tg="_learnMoreLink_1422v_127",ng="_feedbackContainer_1422v_140",sg="_footer_1422v_146",pe={container:Rp,title:Pp,description:Dp,sectionTitle:Bp,websiteInfo:Fp,favicon:Up,websiteTitle:Op,websiteHost:Vp,warningContent:Kp,ignoreButton:Wp,infoList:zp,infoItem:Hp,label:Qp,infoValue:Gp,durationTrigger:Yp,durationItem:Zp,featureList:Jp,featureItem:Xp,checkIcon:eg,learnMoreLink:tg,feedbackContainer:ng,footer:sg};function og(e){return e instanceof z.HTTPError&&e.response.status===404}const ag=qe.createQueryKeys("interwovenkit:account",{info:(e,t)=>({queryKey:[e,t],queryFn:async()=>{const s=z.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${t}`;try{return await s.get(o).json(),!0}catch(a){if(og(a))return!1;throw a}}})}),rg=()=>{const[e,t]=_.useState(Ep),[s,o]=H.useAtom(rs),[a,r]=_.useState(!1),i=lt(),c=_e(),{address:l,initiaAddress:u,username:m}=tt(),{mutate:d,isPending:h}=Id(),{closeDrawer:f}=Dt();if(!s)throw new Error("Pending request not found");const{logoUrl:g,name:p,restUrl:y}=i(s.chainId),{data:x,isLoading:b,isError:j}=E.useQuery(ag.info(y,u)),v={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},w=c.find(P=>P.chainId===s.chainId),C=w?.website?qp(w.website,window.location.hostname):!1,I=()=>{d(e)},T=()=>{s?.reject(new Error("User cancelled")),o(null),f()},A=!C&&!a,$=!b&&!j&&x===!1,N=!b&&j,S=A||b||j||x===!1;return n.jsxs(n.Fragment,{children:[n.jsxs(yt,{className:pe.container,children:[n.jsxs("header",{children:[n.jsx("h1",{className:pe.title,children:"Enable auto-signing"}),n.jsx("p",{className:pe.description,children:"An application is requesting to enable auto-signing"})]}),n.jsxs("section",{children:[n.jsx("h2",{className:pe.sectionTitle,children:"Requested by"}),n.jsxs("div",{className:pe.websiteInfo,children:[n.jsx("img",{src:v.favicon,alt:"",className:pe.favicon}),n.jsxs("div",{children:[n.jsx("div",{className:pe.websiteTitle,children:v.title}),n.jsx("div",{className:pe.websiteHost,children:v.hostname})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:pe.sectionTitle,children:"Applies to"}),n.jsxs("div",{className:pe.infoList,children:[n.jsxs("div",{className:pe.infoItem,children:[n.jsx("div",{className:pe.label,children:"Address"}),n.jsxs("div",{className:pe.infoValue,children:[n.jsx(M.IconWallet,{size:14}),n.jsx("span",{className:"monospace",children:k.truncate(m??l)})]})]}),n.jsxs("div",{className:pe.infoItem,children:[n.jsx("div",{className:pe.label,children:"Chain"}),n.jsxs("div",{className:pe.infoValue,children:[n.jsx(re,{src:g,width:14,height:14,logo:!0}),n.jsx("span",{children:p})]})]}),n.jsxs("div",{className:pe.infoItem,children:[n.jsx("div",{className:pe.label,children:"Duration"}),n.jsx(Da,{options:Dc,value:e,onChange:t,classNames:{trigger:pe.durationTrigger,item:pe.durationItem}})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:pe.sectionTitle,children:"About auto-signing"}),n.jsx("ul",{className:pe.featureList,children:["Send transactions without confirmation pop-ups","Secured by your wallet signature","Revoke permissions any time in settings"].map(P=>n.jsxs("li",{className:pe.featureItem,children:[n.jsx(M.IconCheckCircle,{size:12,className:pe.checkIcon}),n.jsx("span",{children:P})]},P))}),n.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",rel:"noopener noreferrer",className:pe.learnMoreLink,children:["Learn more ",n.jsx(M.IconExternalLink,{size:12})]})]})]}),n.jsxs(Ae,{className:pe.footer,extra:n.jsxs("div",{className:pe.feedbackContainer,children:[$&&n.jsx(we,{level:"error",children:"Insufficient balance for fee"}),N&&n.jsx(we,{level:"warning",children:"Unable to verify account status. Try again."}),!C&&!a&&n.jsx(we,{level:"warning",children:n.jsxs("div",{className:pe.warningContent,children:[n.jsx("span",{children:"You are on an unverified website"}),n.jsx("button",{onClick:()=>r(!0),className:pe.ignoreButton,children:"Ignore"})]})})]}),children:[n.jsx(fe.Outline,{onClick:T,children:"Cancel"}),n.jsx(fe.White,{onClick:I,disabled:S,loading:h,children:"Enable"})]})]})},ig=()=>H.useAtomValue(rs)?n.jsx(rg,{}):null,cg="_container_mqvhs_1",lg="_badge_mqvhs_5",kr={container:cg,badge:lg},Fc=e=>{const{offset:t=-4,disabled:s,children:o,className:a}=e;return n.jsxs("div",{className:B(kr.container,a),children:[o,!s&&n.jsx("div",{className:kr.badge,style:{right:t,top:t},"aria-hidden":"true"})]})},ug="_header_s7mee_1",dg="_back_s7mee_12",mg="_title_s7mee_24",Fo={header:ug,back:dg,title:mg},Tt=({title:e,backButton:t,extra:s,children:o})=>{const a=Ci();return n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Fo.header,children:[n.jsx(mn,{to:t??(a.length>1?-1:"/"),className:Fo.back,shouldReset:!!t,"aria-label":"Go back",children:n.jsx(M.IconBack,{size:16,"aria-hidden":"true"})}),n.jsx("h1",{className:Fo.title,children:e}),s]}),n.jsx(yt,{children:o})]})};function Fa(){const e=_e();return t=>e.some(s=>s.chain_id===t)}function hg(e,t){return t(e.chain_id)&&e.chain_name.toLowerCase()!=="initia"}function fs(){const e=Fa();return t=>e(t.chain_id)?"initia":t.chain_type}function yn(e){return fs()(e)}function fo(){const e=Fe(),{data:t}=E.useSuspenseQuery({queryKey:Ie.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>L.sortWith([L.descend(({chain_name:o})=>o==="initia"),L.ascend(({pretty_name:o})=>o)],s),staleTime:V.MINUTE});return t}function Bt(){const e=fo(),t=pi();return s=>{const o=e.find(r=>r.chain_id===s);if(o)return o;const a=t.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 Ye(e){return Bt()(e)}function fg(e,t){try{return de.fromBech32(e).prefix===t}catch{return!1}}function Uc(){const{initiaAddress:e,hexAddress:t}=tt(),s=Bt(),o=fs();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return t;default:return""}}}function Ua(){const e=Bt(),t=fs();return(s,o)=>{const a=e(o);switch(t(a)){case"initia":return k.InitiaAddress.validate(s);case"evm":return kt.isAddress(s);case"cosmos":return a.bech32_prefix?fg(s,a.bech32_prefix):!1;default:return!1}}}function pg(){const e=Bt(),t=fs();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),c=t(i),l=e(a),u=t(l);if(c==="evm"&&u==="initia")return k.InitiaAddress(s).bech32;if(c==="initia"&&u==="evm")return k.InitiaAddress(s).hex;if(c===u)return s;if(r){if(u==="initia")return k.InitiaAddress(r).bech32;if(u==="evm")return k.InitiaAddress(r).hex}return""}}function gg(){const e=Fe();return E.useSuspenseQuery({queryKey:Ie.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:V.MINUTE})}function ps(){const{data:{chain_to_assets_map:e}}=gg(),t=fo(),s=E.useQueryClient();return _.useMemo(()=>{const o=[];for(const a in e){if(!t.some(i=>i.chain_id===a))continue;const{assets:r}=e[a]??{assets:[]};s.setQueryData(Ie.assets(a).queryKey,{chain_to_assets_map:{[a]:e[a]}});for(const i of r)s.setQueryData(Ie.asset(a,i.denom).queryKey,i);o.push(...r)}return o},[e,t,s])}function Hs(e){const t=Fe(),s=E.useQueryClient(),{data:o}=E.useSuspenseQuery({queryKey:Ie.assets(e).queryKey,queryFn:()=>t.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(Ie.asset(e,i.denom).queryKey,i);return r.slice().sort(L.descend(i=>i.symbol==="INIT"))},staleTime:V.MINUTE});return o}function Oc(e){const t=Hs(e);return s=>{const o=t.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function At(e,t){return Oc(t)(e)}const _g="_root_ekn9t_1",yg="_header_ekn9t_6",xg="_title_ekn9t_12",bg="_warning_ekn9t_18",wg="_content_ekn9t_22",vg="_footer_ekn9t_26",jg="_secondary_ekn9t_36",nn={root:_g,header:yg,title:xg,warning:bg,content:wg,footer:vg,secondary:jg},Vc=e=>{const{type:t,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return n.jsxs(yt,{className:nn.root,children:[n.jsxs("header",{className:B(nn.header,t&&nn[t]),children:[s,n.jsx("h1",{className:nn.title,children:o})]}),n.jsx("div",{className:nn.content,children:a}),n.jsxs("footer",{className:nn.footer,children:[n.jsx(fe.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),n.jsxs("button",{className:nn.secondary,onClick:i.onClick,children:[n.jsx("span",{children:i.label}),n.jsx(M.IconChevronRight,{size:14,"aria-hidden":"true"})]})]})]})},Cg="_list_k4n3k_1",kg="_row_k4n3k_9",Ng="_dt_k4n3k_20",Ig="_asset_k4n3k_26",Is={list:Cg,row:kg,dt:Ng,asset:Ig},Ag=({list:e,onNavigate:t,onDismiss:s})=>{const o=ce(),a=lt(),r=St(o);return n.jsx(Vc,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:t},secondaryButton:{label:"Do not show again",onClick:s},children:n.jsx("div",{className:Is.list,children:e.slice().sort((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:u})=>{const m=a(c),{decimals:d,symbol:h}=r(u),f=k.formatAmount(l,{decimals:d});return n.jsxs("div",{className:Is.row,children:[n.jsxs("div",{className:Is.dt,children:[n.jsx(re,{src:m.logoUrl,width:16,height:16,logo:!0}),n.jsx("span",{children:m.name})]}),n.jsxs("span",{className:Is.asset,children:[f," ",h]})]},i)})})})};function Uo(e,t){return e.chainId===t.chainId&&e.txHash===t.txHash}const As=({chainId:e,txHash:t})=>`${he.OP_REMINDER}:${e}:${t}`,Sg=Vl.atomWithStorage(he.OP_REMINDER,[]);function Fn(){const e=ie(),[t=[],s]=H.useAtom(Sg),o=_.useMemo(()=>t.map(l=>{const u=localStorage.getItem(As(l));return u?JSON.parse(u):null}).filter(l=>{if(!l)return!1;const{recipient:u,claimableAt:m}=l;return u!==e?!1:Xe.isPast(m)}),[e,t]),a=_.useCallback((l,u)=>{t.some(m=>Uo(m,l))||(s((m=[])=>[...m,l]),localStorage.setItem(As(l),JSON.stringify(u)))},[t,s]),r=_.useCallback(l=>{s((u=[])=>u.filter(m=>!Uo(m,l))),localStorage.removeItem(As(l))},[s]),i=_.useCallback(l=>{const u=l.filter(m=>!t.some(d=>Uo(d,m)));u.length!==0&&s((m=[])=>[...m,...u])},[t,s]),c=_.useCallback((l,u)=>{localStorage.setItem(As(l),JSON.stringify(u)),s((m=[])=>[...m])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:c}}function Kc(){const e=Me(),{openModal:t,closeModal:s}=ao(),{reminders:o,setReminder:a}=Fn();_.useEffect(()=>{const r=o.filter(l=>!l.dismissed);if(r.length===0)return;const i=()=>{const l=r.every(u=>u.chainId===r[0].chainId)?r[0].chainId:void 0;e("/op/withdrawals",{chainId:l}),c()},c=()=>{s();for(const l of r)a(l,{...l,dismissed:!0})};t({content:_.createElement(Ag,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,t,a])}const Tg="_wrapper_5ssm8_1",Eg="_balance_5ssm8_11",$g="_button_5ssm8_15",Oo={wrapper:Tg,balance:Eg,button:$g},Wc=({onClick:e,children:t,disabled:s})=>n.jsxs("div",{className:Oo.wrapper,children:[n.jsx(M.IconWallet,{size:16,"aria-hidden":"true"}),n.jsx("span",{className:Oo.balance,children:t}),n.jsx("button",{type:"button",tabIndex:-1,className:Oo.button,onClick:()=>e(),disabled:s,"aria-label":"Use maximum balance",children:"MAX"})]}),Mg="_fieldset_up6fh_1",Lg="_upper_up6fh_9",qg="_select_up6fh_14",Rg="_account_up6fh_20",Pg="_lower_up6fh_25",Dg="_wrapper_up6fh_26",Bg="_balance_up6fh_33",Fg="_value_up6fh_37",Ug="_error_up6fh_50",qt={fieldset:Mg,upper:Lg,select:qg,account:Rg,lower:Pg,wrapper:Dg,balance:Bg,value:Fg,error:Ug},ta=e=>{const{selectButton:t,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:c}=e;return n.jsxs("div",{className:qt.fieldset,children:[n.jsxs("div",{className:qt.upper,children:[n.jsx("div",{className:qt.select,children:t}),n.jsx("div",{className:qt.account,children:s})]}),!c&&n.jsxs("div",{className:qt.lower,children:[o,n.jsxs("div",{className:qt.wrapper,children:[n.jsx("div",{className:qt.balance,children:a}),r&&n.jsx("div",{className:qt.value,children:r})]}),i&&n.jsxs("footer",{className:qt.error,children:[n.jsx(M.IconWarningFilled,{size:12,"aria-hidden":"true"}),n.jsx("p",{role:"alert",children:i})]})]})]})},zc=({quantity:e,balance:t,decimals:s})=>!e||t===void 0||s===void 0||q(e).isZero()?!1:q(k.toBaseUnit(e,{decimals:s})).gt(t);function gs(){const e=_.useRef(null),t=uo();return _.useEffect(()=>{t||e.current?.focus()},[t]),e}const Og="_input_h8073_1",Vg={input:Og};function Hc(e){const{name:t,control:s,dp:o=6,className:a,rules:r,...i}=e,c=gs();return n.jsx($e.Controller,{name:t,control:s,rules:r,render:({field:l})=>n.jsx(Kl.NumericFormat,{value:l.value,getInputRef:ui.mergeRefs([l.ref,c]),className:B(Vg.input,a),onValueChange:u=>{l.onChange(u.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const Kg="_input_19r9r_1",Wg="_placeholder_19r9r_18",na={input:Kg,placeholder:Wg},zg=({children:e})=>n.jsx("p",{className:B(na.input,{[na.placeholder]:q(e).isZero()}),children:e}),ns=({balance:e,decimals:t,className:s})=>{const{control:o}=$e.useFormContext(),a={required:"Enter amount",validate:r=>q(r).isZero()?"Enter amount":zc({quantity:r,balance:e,decimals:t})?"Insufficient balance":!0};return n.jsx(Hc,{name:"quantity",control:o,className:B(na.input,s),rules:a})};ns.ReadOnly=zg;const qn=({title:e,content:t,children:s,className:o})=>{const[a,r]=_.useState(!1),i=()=>r(!1);return n.jsx($c,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:t(i)})},Hg="_tooltip_19kvs_1",Qg="_arrow_19kvs_44",Nr={tooltip:Hg,arrow:Qg},_s=({label:e,children:t,small:s,...o})=>n.jsxs(te.Tooltip.Root,{...o,children:[n.jsx(te.Tooltip.Trigger,{asChild:!0,children:t}),n.jsx(te.Tooltip.Portal,{container:_n(),children:n.jsxs(te.Tooltip.Content,{className:B(Nr.tooltip,{small:s}),collisionBoundary:_n(),collisionPadding:8,sideOffset:4,children:[e,n.jsx(te.Tooltip.Arrow,{className:Nr.arrow})]})})]});function po(e,t){const s=Fe(),o=Ua(),a=!!t&&!!e&&o(e,t);return E.useQuery({queryKey:Ie.balances(t,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[t]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>a?r?r[t]?.denoms??{}:{}:{},enabled:a,staleTime:V.SECOND})}function Gg(e,t,s){const{data:o={}}=po(e,t);return L.path([s],o)}function Yg({sourceDenom:e,sourceBalance:t,amountIn:s,feeTokenDenoms:o,balancesByDenom:a,additionalFees:r=[]}){if(!o.includes(e)||t===void 0||s===void 0||a===void 0)return!1;const c=r.reduce((m,d)=>{if(d.amount===void 0)return m;const h=d.origin_asset.denom,f=m.get(h)??q(0);return m.set(h,f.plus(d.amount)),m},new Map);if(o.some(m=>{if(m===e)return!1;const d=q(a[m]?.amount??"0"),h=c.get(m);return h?d.gte(h):d.gt(0)}))return!1;const u=c.get(e)??q(0);return u.isZero()?!1:q(t).lt(q(s).plus(u))}const Zg=[["d",1440*60],["h",3600],["m",60],["s",1]];function ss(e){if(!e)return;const{formattedParts:t}=Zg.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 t.join(" ")}function Qc(e,t){return q(e).times(q(100).minus(t)).div(100).integerValue(q.ROUND_FLOOR).toFixed(0)}function Oa(e){return e?.map(t=>{const{amount:s,origin_asset:o}=t;return`${k.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function Gc(e,t,s,o){const{srcChainId:a,srcDenom:r,quantity:i,dstChainId:c,dstDenom:l}=s,u=t.getQueryData(Ie.asset(a,r).queryKey);if(!u||u.decimals==null)throw new Error("Failed to refresh route: source asset metadata is unavailable.");const m=u.decimals;return e.post("v2/fungible/route",{signal:o?.signal,json:{amount_in:k.toBaseUnit(i,{decimals:m}),source_asset_chain_id:a,source_asset_denom:r,dest_asset_chain_id:c,dest_asset_denom:l,is_op_withdraw:o?.isOpWithdraw}}).json()}function sa(e,t){const{watch:s}=Zt(),o=s(),a=Fe(),r={srcChainId:o.srcChainId,srcDenom:o.srcDenom,dstChainId:o.dstChainId,dstDenom:o.dstDenom,quantity:e},i=!r.srcChainId||!r.srcDenom||!r.dstChainId||!r.dstDenom,c=q(r.quantity||0),l=c.isFinite()&&c.gt(0),u=t?.refreshMs??1e4,m=l&&!t?.disabled&&!i,d=E.useQueryClient();return E.useQuery({queryKey:Ie.route(r,t?.isOpWithdraw).queryKey,queryFn:async({signal:h})=>Gc(a,d,r,{isOpWithdraw:t?.isOpWithdraw,signal:h}),enabled:m,staleTime:u,refetchInterval:m?u:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,refetchOnMount:"always"})}function Jg(e){return E.useQuery({queryKey:Ie.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof z.HTTPError))return null;const{response:t}=e;return(t.headers.get("content-type")??"").includes("application/json")?(await t.json()).info??null:null},enabled:!!e})}function Xg(){const{watch:e}=Zt(),{srcChainId:t,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=Ye(t),i=yn(r),c=At(s,t),l=At(a,o),u=ce(),m=_e();return i==="initia"&&o===u.chainId&&c.symbol===l.symbol&&m.find(d=>d.chainId===t)?.metadata?.op_denoms?.includes(l.denom)}const e_="_label_t93ix_1",t_="_wrapper_t93ix_7",n_="_input_t93ix_10",s_="_clear_t93ix_18",Ss={label:e_,wrapper:t_,input:n_,clear:s_},Va=({mode:e="onChange",myAddress:t,...s})=>{const{validate:o=k.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,c=gs(),{control:l,getValues:u,setValue:m,formState:d}=$e.useFormContext(),h=u("recipient"),[f,g]=_.useState(h),p=bi(),{data:y,isLoading:x,error:b}=E.useQuery({queryKey:Xs.address(p.restUrl,f).queryKey,queryFn:()=>p.getAddress(f),staleTime:V.MINUTE,enabled:p.validateUsername(f)}),j=y??(o(f)?f:""),v=t&&k.InitiaAddress.equals(j,t),w=async()=>{try{const T=await navigator.clipboard.readText();g(T.trim())}catch{}};_.useEffect(()=>{e==="onChange"&&(!f&&!d.dirtyFields.recipient||m("recipient",y??f,{shouldValidate:!0,shouldDirty:!0}))},[d.dirtyFields.recipient,f,e,m,y]);const C=()=>{x||b||(m("recipient",j,{shouldValidate:!0,shouldDirty:!0}),r?.())},I=()=>{if(x)return n.jsx(In,{level:"loading",children:"Resolving username..."});if(b)return n.jsx(In,{level:"error",children:b.message});if(y)return n.jsx(In,{level:"success",className:"monospace",children:y});if(e==="onSubmit"&&f&&!j)return n.jsx(In,{level:"error",children:"Invalid address"})};return n.jsxs("div",{children:[n.jsxs("label",{htmlFor:"recipient",className:Ss.label,children:[n.jsx("span",{children:"Recipient"}),n.jsx(fe.Small,{type:"button",tabIndex:-1,onClick:w,children:"Paste"})]}),n.jsxs("div",{className:Ss.wrapper,children:[n.jsx($e.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:T=>o(T)||"Invalid address"},render:()=>n.jsx("input",{id:"recipient",className:B(Ss.input,"monospace"),value:f,onChange:T=>g(T.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?ui.mergeRefs([i,c]):i})}),!!f&&n.jsx("button",{type:"button",className:Ss.clear,onClick:()=>g(""),"aria-label":"Clear recipient",children:n.jsx(M.IconCloseCircleFilled,{size:16})})]}),I(),v&&n.jsx(In,{children:"This is my address"}),e==="onSubmit"&&n.jsx(Ae,{extra:(!t||!!j&&!v)&&n.jsx(we,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:n.jsx(fe.White,{type:"button",onClick:C,disabled:x||!!b||!j,children:"Apply"})})]})},o_="_scrollable_vgj3r_1",a_="_list_vgj3r_5",r_="_item_vgj3r_9",i_="_name_vgj3r_22",Ts={scrollable:o_,list:a_,item:r_,name:i_};function Yc({onSelect:e,list:t,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:c}=s;return n.jsx(yt,{className:Ts.scrollable,children:n.jsx("div",{className:Ts.list,children:t.map(l=>n.jsxs("button",{className:Ts.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),"aria-busy":!!i?.(l),children:[n.jsx(re,{src:o(l),width:28,height:28}),n.jsx("span",{className:Ts.name,children:a(l)}),i?.(l)&&n.jsx(It,{size:16})]},r(l)))})})}function go(){const{cosmosWallets:e=[]}=se(),t=_.useMemo(()=>{const a=[{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"}].filter(r=>!e.some(i=>i.name===r.name));return[...e,...a]},[e]);return{list:t,find:o=>t.find(a=>a.name===o)}}const c_="_account_h04x1_8",l_="_clear_h04x1_28",u_="_white_h04x1_39",Kn={account:c_,clear:l_,white:u_},Ir=({type:e})=>{const{watch:t,setValue:s}=Zt(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=t(),c=t(e==="src"?"sender":"recipient"),l=yn(Ye(a)),{showNotification:u}=hs(),{list:m,find:d}=go(),h=d(r),f=Uc(),g=Ua(),p=f(a),y=k.InitiaAddress.equals(c,p),x=()=>n.jsx(qn,{title:"Connect wallet",content:v=>n.jsx(Yc,{onSelect:async w=>{const C=w.getProvider();if(!C){w.fallbackUrl?window.open(w.fallbackUrl,"_blank"):u({type:"error",title:`${w.name} not available`,description:"Please install the wallet extension and try again."});return}try{const T=await C.getOfflineSigner(o).getAccounts();if(T.length===0)throw new Error("No accounts found");s("sender",T[0].address),s("cosmosWalletName",w.name),v()}catch(I){const T=I instanceof Error?I.message:"Unknown error";u({type:"error",title:`Failed to connect ${w.name}`,description:T})}},list:m,getImage:w=>w.image,getName:w=>w.name,getKey:w=>w.name}),className:B(Kn.account,{[Kn.white]:!c}),children:c?n.jsxs(n.Fragment,{children:[h&&n.jsx(re,{src:h.image,width:18,height:18}),n.jsx("span",{className:"monospace",children:k.truncate(c)})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"Connect wallet"}),n.jsx(M.IconChevronRight,{size:14,"aria-hidden":"true"})]})}),b=v=>n.jsx(qn,{title:"Recipient",content:w=>n.jsx(yt,{children:n.jsx(Va,{mode:"onSubmit",myAddress:p,chainType:l,validate:C=>g(C,a),onApply:w})}),className:Kn.account,children:v}),j=()=>{switch(l){case"initia":case"evm":return y?b(n.jsx(M.IconWallet,{size:14})):n.jsxs("div",{className:Kn.account,children:[n.jsx("span",{className:"monospace",children:k.truncate(c)}),n.jsx("button",{type:"button",className:Kn.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:n.jsx(M.IconCloseCircleFilled,{size:14})})]});case"cosmos":return b(n.jsxs(n.Fragment,{children:[c?n.jsx("span",{className:"monospace",children:k.truncate(c)}):n.jsx("span",{children:"Recipient"}),n.jsx(M.IconEdit,{size:14,"aria-hidden":"true"})]}))}};switch(e){case"src":return x();case"dst":return j()}},d_="_images_cj4xz_1",Vo={images:d_},_o=({assetLogoUrl:e,assetLogoSize:t=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>n.jsxs("div",{className:B(Vo.images,r),style:{position:"relative"},"aria-hidden":"true",children:[n.jsx(re,{src:e,width:t,height:t,className:Vo.asset,logo:!0}),n.jsx(re,{src:s,width:o,height:o,className:Vo.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),m_="_root_6187w_1",h_="_content_6187w_10",f_="_details_6187w_20",p_="_symbol_6187w_26",g_="_chain_6187w_34",__="_chevron_6187w_43",sn={root:m_,content:h_,details:f_,symbol:p_,chain:g_,chevron:__},Zc=({asset:e,chain:t,readOnly:s})=>{const o=n.jsxs("div",{className:sn.content,children:[n.jsx(_o,{assetLogoUrl:e.logoUrl,chainLogoUrl:t.logoUrl}),n.jsxs("div",{className:sn.details,children:[n.jsx("div",{className:sn.symbol,children:e.symbol||e.denom}),n.jsxs("div",{className:sn.chain,children:["on ",t.name]})]})]});return s?n.jsx("div",{className:sn.root,children:o}):n.jsxs("div",{className:sn.root,children:[o,n.jsx(M.IconChevronDown,{size:16,className:sn.chevron,"aria-hidden":"true"})]})};function y_(e,t,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return L.any(L.includes(t.toLowerCase()),a)})}const x_="_root_1sh27_1",b_="_label_1sh27_8",w_="_input_1sh27_21",v_="_hasValue_1sh27_31",j_="_clear_1sh27_35",Wn={root:x_,label:b_,input:w_,hasValue:v_,clear:j_},ys=e=>{const{rootClassName:t,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return n.jsxs("div",{className:B(Wn.root,t,{[Wn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[n.jsx("label",{htmlFor:"search",className:Wn.label,children:n.jsx(M.IconSearch,{size:o})}),n.jsx("input",{className:Wn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&n.jsx("button",{type:"button",className:Wn.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:a,children:n.jsx(M.IconCloseCircleFilled,{size:o})})]})},C_="_container_5tajg_1",k_="_search_5tajg_7",N_="_list_5tajg_11",I_="_item_5tajg_15",A_="_logo_5tajg_37",S_="_info_5tajg_41",T_="_symbol_5tajg_47",E_="_name_5tajg_56",$_="_balance_5tajg_62",M_="_value_5tajg_69",rt={container:C_,search:k_,list:N_,item:I_,logo:A_,info:S_,symbol:T_,name:E_,balance:$_,value:M_},xs=e=>{const{assets:t,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=_.useState(""),i=y_(["symbol"],a,t);return n.jsxs("div",{className:rt.container,children:[n.jsx(ys,{value:a,onChange:c=>r(c.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:rt.search,padding:20,ref:gs()}),i.length===0?n.jsx(je,{children:"No assets"}):n.jsx("div",{className:rt.list,children:i.map(c=>n.jsx("button",{type:"button",className:rt.item,onClick:()=>s(c.denom),children:o(c,l=>{const{denom:u,logoUrl:m,symbol:d,name:h,balance:f,decimals:g,value:p=0}=l;return n.jsxs(n.Fragment,{children:[n.jsx(re,{src:m,width:32,height:32,className:rt.logo,logo:!0}),n.jsxs("div",{className:rt.info,children:[n.jsx("div",{className:rt.symbol,children:d||u}),n.jsx("div",{className:rt.name,children:h})]}),n.jsxs("div",{className:rt.balance,children:[f&&n.jsx("div",{children:k.formatAmount(f,{decimals:g})}),p>0&&n.jsx("div",{className:rt.value,children:ae(p)})]})]})})},c.denom))})]})},L_=()=>n.jsxs("div",{className:rt.container,children:[n.jsx(ys,{rootClassName:rt.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),n.jsx(je,{children:"Loading..."})]});xs.Placeholder=L_;const q_="_stack_16oqn_1",R_="_title_16oqn_9",P_="_grid_16oqn_16",D_="_item_16oqn_22",B_="_button_16oqn_26",F_="_active_16oqn_44",An={stack:q_,title:R_,grid:P_,item:D_,button:B_,active:F_},fn=({label:e,chains:t,value:s,onSelect:o,getShowIndicator:a})=>n.jsxs("div",{children:[e&&n.jsx("h2",{className:An.title,children:e}),n.jsx("div",{className:An.grid,children:t.map(({chainId:r,name:i,logoUrl:c})=>n.jsx(Fc,{offset:-2,disabled:!a?.(r),className:An.item,children:n.jsx(_s,{label:i,disableHoverableContent:!0,children:n.jsx("button",{type:"button","aria-label":i,className:B(An.button,{[An.active]:r===s}),onClick:()=>o(r),children:n.jsx(re,{src:c,width:28,height:28,logo:!0})})})},r))})]}),U_=({children:e})=>n.jsx("div",{className:An.stack,children:e});fn.Stack=U_;const O_=({address:e,chain:t,onSelect:s})=>{const o=Hs(t.chain_id),{data:a={}}=po(e,t.chain_id);return n.jsx(xs,{assets:L.sortWith([L.descend(r=>r.symbol==="INIT"),L.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>q(i).comparedTo(r)??0,L.ascend(r=>r.symbol.toLowerCase())],o.filter(r=>!r.hidden).map(r=>{const{denom:i,symbol:c=k.truncate(i),logo_uri:l}=r,u=a[i]??{};return{...r,symbol:c,decimals:r.decimals??0,logoUrl:l??"",name:r.name??"",balance:u.amount,value:Number(u.value_usd??0)}})),onSelect:s})},V_=({type:e,afterSelect:t})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=Yt(),i=fo(),{watch:c,setValue:l}=Zt(),u=c(a),m=c(s),d=c(o),[h,f]=_.useState(m),g=Ye(h),p=pg(),y=Fa(),[x,b]=L.partition(v=>y(v.chain_id),i.filter(v=>!v.hidden)),j=v=>{if(m===h&&d===v){t();return}l(s,h),l(o,v),t()};return n.jsxs(n.Fragment,{children:[n.jsxs(fn.Stack,{children:[n.jsx(fn,{label:"Interwoven Economy",chains:x.map(({chain_id:v,chain_name:w,pretty_name:C,logo_uri:I})=>({chainId:v,name:C||w,logoUrl:I??""})),value:h,onSelect:f}),n.jsx(fn,{label:"Chains",chains:b.map(({chain_id:v,chain_name:w,pretty_name:C,logo_uri:I})=>({chainId:v,name:C||w,logoUrl:I??""})),value:h,onSelect:f})]}),n.jsx(xe,{suspenseFallback:n.jsx(xs.Placeholder,{}),children:n.jsx(O_,{address:p({initialAddress:u,initialChainId:m,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:g,onSelect:j})},h)]})},Ar=({type:e})=>{const t=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=Zt(),r=a(t),i=a(s),c=Ye(r),l=At(i,r);return n.jsx(qn,{title:o,content:u=>n.jsx(V_,{type:e,afterSelect:u}),children:n.jsx(Zc,{asset:{denom:l.denom,decimals:l.decimals??0,symbol:l.symbol,logoUrl:l.logo_uri??""},chain:{chainId:c.chain_id,name:c.pretty_name||c.chain_name,logoUrl:c.logo_uri??""}})})},K_="_skeleton_1l4jn_1",W_={skeleton:K_},pn=({width:e="100%",height:t})=>n.jsx("div",{className:W_.skeleton,style:{width:e,height:t},"aria-hidden":"true"}),z_="_stack_oq1ir_1",H_="_button_oq1ir_6",Q_="_isLoading_oq1ir_19",G_="_disabled_oq1ir_19",Y_="_checked_oq1ir_23",Z_="_header_oq1ir_37",J_="_title_oq1ir_43",X_="_duration_oq1ir_52",ey="_warning_oq1ir_62",ty="_amount_oq1ir_66",ny="_value_oq1ir_67",at={stack:z_,button:H_,isLoading:Q_,disabled:G_,checked:Y_,header:Z_,title:J_,duration:X_,warning:ey,amount:ty,value:ny},sy=({children:e})=>n.jsx("div",{className:at.stack,role:"radiogroup","aria-label":"Route options",children:e}),Ps=({label:e,query:t,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=t,{watch:c}=Zt(),{dstChainId:l,dstDenom:u}=c(),m=At(u,l),d=!i&&a.checked,h=!i&&!r;return n.jsxs("button",{type:"button",className:B(at.button,{[at.isLoading]:i,[at.disabled]:h,[at.checked]:d}),onClick:()=>{i||h||o(s)},role:"radio","aria-checked":d,"aria-disabled":h,children:[n.jsxs("div",{className:at.header,children:[n.jsxs("div",{className:at.title,children:[n.jsx("span",{children:e}),d&&n.jsx(M.IconCheck,{size:14,"aria-hidden":"true"})]}),i?n.jsx(pn,{width:80,height:16}):r?n.jsxs("div",{className:B(at.duration,{[at.warning]:s==="op"}),children:[n.jsx(M.IconClockFilled,{size:12,"aria-hidden":"true"}),n.jsx("span",{children:ss(r.estimated_route_duration_seconds)})]}):n.jsx("div",{className:at.duration,children:"Not available"})]}),(i||r)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:at.amount,children:i?n.jsx(pn,{width:260,height:40}):r?k.formatAmount(r.amount_out,{decimals:m.decimals}):null}),n.jsx("div",{className:at.value,children:i?n.jsx(pn,{width:120,height:16}):r?r.usd_amount_out?ae(r.usd_amount_out):"$-":null})]})]})};Ps.Stack=sy;const oy="_description_nuyvt_1",ay="_presets_nuyvt_8",ry="_preset_nuyvt_8",iy="_active_nuyvt_29",cy="_custom_nuyvt_40",ly="_wrapper_nuyvt_47",uy="_percent_nuyvt_58",vt={description:oy,presets:ay,preset:ry,active:iy,custom:cy,wrapper:ly,percent:uy},Sr=["0.1","0.5","1.0"],dy=({afterConfirm:e})=>{const t=Zt(),s=t.getValues("slippagePercent"),[o,a]=_.useState(null),{control:r,watch:i,getValues:c,setValue:l}=$e.useForm({defaultValues:{value:s}}),u=i("value");_.useEffect(()=>{const p=Sr.findIndex(y=>y===s);a(p>=0?p:null)},[s]);const m=(p,y)=>{l("value",p),a(y)},d=()=>{a(null)},h=_.useMemo(()=>Number(u)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(u)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(u)<.1?{type:"warning",text:"Your transaction may fail"}:null,[u]),f=h?.type==="error",g=({value:p})=>{t.setValue("slippagePercent",p),e()};return n.jsxs(yt,{children:[n.jsx("p",{className:vt.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."}),n.jsxs("div",{className:vt.presets,role:"radiogroup","aria-label":"Slippage presets",children:[Sr.map((p,y)=>n.jsxs("button",{type:"button",className:B(vt.preset,{[vt.active]:o===y}),onClick:()=>m(p,y),role:"radio","aria-checked":o===y,children:[p,"%"]},p)),o!==null?n.jsx("button",{type:"button",className:B(vt.preset,vt.custom),onClick:()=>a(null),role:"radio","aria-checked":o===null,children:"Custom"}):n.jsxs("div",{className:vt.wrapper,children:[n.jsx(Hc,{name:"value",control:r,dp:2,onFocus:d,placeholder:"",className:B(vt.preset,vt.active)}),n.jsx("span",{className:vt.percent,children:"%"})]})]}),h&&n.jsx(we,{level:h.type,children:h.text}),n.jsx(Ae,{children:n.jsx(fe.White,{type:"button",onClick:()=>g(c()),disabled:f,children:"Confirm"})})]})},my="_form_1owk5_1",hy="_arrow_1owk5_5",fy="_divider_1owk5_14",py="_flip_1owk5_23",gy="_meta_1owk5_41",_y="_row_1owk5_54",yy="_title_1owk5_60",xy="_description_1owk5_64",by="_icon_1owk5_71",wy="_edit_1owk5_76",vy="_link_1owk5_94",jy="_warning_1owk5_99",Ve={form:my,arrow:hy,divider:fy,flip:py,meta:gy,row:_y,title:yy,description:xy,icon:by,edit:wy,link:vy,warning:jy};function Cy({isLayer1Swap:e,isL2Swap:t}){return e?5e3:t?2e3:1e4}function ky({srcChainType:e,chainFeeAssets:t,srcDenom:s}){switch(e){case"initia":case"cosmos":return t.map(({denom:o})=>o);case"evm":return kt.isAddress(s)?[]:[s];default:return[]}}const Ny=q(1),Iy=()=>{const e=Me(),t=uo(),s=Pn(),[o,a]=_.useState(void 0),[r,i]=_.useState(!1),[c,l]=Ge.useLocalStorage(he.BRIDGE_ROUTE_TYPE,"default"),{watch:u,setValue:m,handleSubmit:d,formState:h}=Zt(),f=u(),{srcChainId:g,srcDenom:p,dstChainId:y,dstDenom:x,quantity:b,sender:j,slippagePercent:v}=f,w=ce(),C=Ye(g),I=yn(C),T=Ye(y),A=yn(T),$=At(p,g),N=At(x,y),{data:S,isError:P}=po(j,g),F=Gg(j,g,p),D=S!==void 0,Z=F?.amount??(S?"0":void 0),K=!Z||q(Z).isZero(),[W]=Ge.useDebounceValue(b,300),O=zc({quantity:W,balance:Z,decimals:$?.decimals}),J=g===y,Q=J&&g===w.chainId,ue=Cy({isLayer1Swap:Q,isL2Swap:J&&I==="initia"&&!Q}),ye=I!=="initia"&&A!=="initia",me=Xg(),Ce=sa(W,{disabled:ye,refreshMs:ue}),Se=sa(W,{isOpWithdraw:!0,disabled:!me,refreshMs:ue}),ke=me&&c==="op",Et=ke?Se:Ce,ut=ke?Ce:Se,Re=ke?!ye:me,le=Et.error&&Re?ut:Et,{data:G,isLoading:$t,error:Xt}=le,{data:Mt}=Jg(Xt),bt=W&&$t&&!r,en=()=>{m("srcChainId",y),m("srcDenom",x),m("dstChainId",g),m("dstDenom",p),m("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:dt,closeModal:Ue}=ao(),nt=d(async oe=>{a(void 0),i(!0);try{const Ne=await le.refetch();if(Ne.error||!Ne.data||!Ne.dataUpdatedAt){a(Ne.error instanceof Error?Ne.error.message:"Failed to refresh route. Please try again.");return}const Ft=Ne.data,Un=Ne.dataUpdatedAt;if(s("Bridge Simulation Success",{quantity:oe.quantity,srcChainId:oe.srcChainId,srcDenom:oe.srcDenom,dstChainId:oe.dstChainId,dstDenom:oe.dstDenom}),Ft.warning){const{type:ql="",message:Rl}=Ft.warning??{};dt({content:n.jsx(Vc,{type:"warning",icon:n.jsx(M.IconWarningFilled,{size:40}),title:Ys.sentenceCase(ql),primaryButton:{label:"Cancel",onClick:Ue},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:Ft,values:oe,quoteVerifiedAt:Un}),Ue()}},children:n.jsx("p",{className:Ve.warning,children:Rl})})});return}e("/bridge/preview",{route:Ft,values:oe,quoteVerifiedAt:Un})}finally{i(!1)}}),X=_.useMemo(()=>G?.estimated_fees?.filter(({fee_behavior:oe})=>oe==="FEE_BEHAVIOR_DEDUCTED")??[],[G]),ve=_.useMemo(()=>G?.estimated_fees?.filter(({fee_behavior:oe})=>oe==="FEE_BEHAVIOR_ADDITIONAL")??[],[G]),Oe=_.useMemo(()=>{if(D)for(const oe of ve){const Ne=S?.[oe.origin_asset.denom]?.amount??"0",Ft=G?.source_asset_denom===oe.origin_asset.denom?G.amount_in:"0";if(q(Ne).lt(q(Ft).plus(oe.amount??"0")))return`Insufficient ${oe.origin_asset.symbol} for fees`}},[ve,S,D,G]),mt=!!G&&ve.length>0&&!D,jo=G?k.formatAmount(G.amount_out,{decimals:N.decimals}):"0",ws=_.useMemo(()=>C.fee_assets??[],[C.fee_assets]),Co=_.useCallback((oe,Ne)=>{const Ft=q(S?.[oe]?.amount??"0"),Un=oe===(Ne?.sourceDenom??p)?q(Ne?.amountIn??G?.amount_in??"0"):q(0);return Ft.minus(Un)},[S,G?.amount_in,p]),ko=_.useMemo(()=>ky({srcChainType:I,chainFeeAssets:ws,srcDenom:p}),[ws,I,p]),El=Yg({sourceDenom:p,sourceBalance:Z,amountIn:G?.amount_in,feeTokenDenoms:ko,balancesByDenom:S,additionalFees:ve}),$l=ko.some(oe=>Co(oe).gt(Ny)),Ja=D&&!!G&&ko.length>0&&!$l||El?"Insufficient balance for fees":void 0,Ml=!!o,Xa=_.useMemo(()=>{if(!f.sender)return"Connect wallet";if(!f.quantity||!W)return"Enter amount";if(!f.recipient)return"Enter recipient address";if(h.errors.quantity)return h.errors.quantity.message;if(P)return"Failed to load balance";if(O)return"Insufficient balance";if(!G)return"Route not found";if(mt)return"Loading balances...";if(Oe)return Oe},[W,Oe,h,mt,P,O,G,f]),Ll=_.useMemo(()=>r?"Refreshing route...":bt?"Simulating...":!1,[bt,r]),No=_.useCallback((oe,Ne)=>oe.length?n.jsxs("div",{className:Ve.description,children:[Oa(oe),!t&&n.jsx(_s,{label:Ne,children:n.jsx("span",{className:Ve.icon,children:n.jsx(M.IconInfoFilled,{size:12,"aria-hidden":"true"})})})]}):null,[t]),vs=q(b).gt(0)&&me&&Ce.data&&Se.data&&Se.data.estimated_route_duration_seconds>Ce.data.estimated_route_duration_seconds,er=_.useMemo(()=>{if(!G)return[];const oe=Qc(G.amount_out,v);return[{condition:!!G.estimated_fees?.length,title:"Fees",content:n.jsxs("div",{children:[No(X,"Fee deducted from the amount you receive"),No(ve,"Fee charged in addition to the amount you enter")]})},{condition:!vs&&!!ss(G.estimated_route_duration_seconds),title:"Estimated time",content:n.jsx("span",{className:Ve.description,children:ss(G.estimated_route_duration_seconds)})},{condition:G.does_swap,title:"Slippage",content:n.jsxs("span",{className:Ve.description,children:[n.jsxs("span",{children:[v,"%"]}),n.jsx(qn,{title:"Slippage tolerance",content:Ne=>n.jsx(dy,{afterConfirm:Ne}),className:Ve.edit,children:n.jsx(M.IconSettingFilled,{size:12,"aria-hidden":"true"})})]})},{condition:G.does_swap,title:"Minimum received",content:n.jsxs("span",{className:Ve.description,children:[n.jsx("img",{src:N.logo_uri,alt:N.symbol,width:12,height:12}),k.formatAmount(oe,{decimals:N.decimals})," ",N.symbol]})}].filter(Ne=>Ne.condition)},[ve,X,N,No,G,vs,v]);return n.jsxs("form",{className:Ve.form,onSubmit:nt,"aria-label":"Bridge and swap form",children:[n.jsx(ta,{selectButton:n.jsx(Ar,{type:"src"}),accountButton:I==="cosmos"&&n.jsx(Ir,{type:"src"}),quantityInput:n.jsx(ns,{balance:Z,decimals:$?.decimals}),balanceButton:n.jsx(Wc,{onClick:()=>m("quantity",k.fromBaseUnit(F?.amount,{decimals:$?.decimals??0}),{shouldValidate:!0}),disabled:K,children:k.formatAmount(Z??"0",{decimals:$.decimals})}),value:G?.usd_amount_in?ae(G.usd_amount_in):"$-"}),n.jsxs("div",{className:Ve.arrow,children:[n.jsx("div",{className:Ve.divider}),n.jsx("button",{type:"button",className:Ve.flip,onClick:()=>en(),"aria-label":"Swap source and destination",children:n.jsx(M.IconChevronDown,{size:16,"aria-hidden":"true"})})]}),n.jsx(ta,{selectButton:n.jsx(Ar,{type:"dst"}),accountButton:n.jsx(Ir,{type:"dst"}),quantityInput:n.jsx(ns.ReadOnly,{children:jo}),value:G?.usd_amount_out?ae(G.usd_amount_out):"$-",hideNumbers:vs}),n.jsx(ts,{children:vs?n.jsxs(Ps.Stack,{children:[n.jsx(Ps,{label:"Fast",query:Ce,value:"default",onSelect:l,checked:c==="default"}),n.jsx(Ps,{label:"Lossless",query:Se,value:"op",onSelect:l,checked:c==="op"})]}):null}),n.jsx(Ae,{extra:n.jsxs(n.Fragment,{children:[n.jsxs(we.Stack,{children:[P&&n.jsx(we,{level:"error",children:"Failed to load balance"}),Ml&&n.jsx(we,{level:"error",children:o}),G?.extra_infos?.map(oe=>n.jsx(we,{level:"info",children:oe},oe)),Mt&&n.jsx(we,{level:"info",children:Mt}),Ja&&n.jsx(we,{level:"warning",children:Ja}),G?.warning&&n.jsx(we,{level:"warning",children:G.warning.message}),G?.extra_warnings?.map(oe=>n.jsx(we,{level:"warning",children:oe},oe))]}),n.jsx(ts,{children:er.length>0&&n.jsx("section",{className:Ve.meta,"aria-label":"Route details",children:er.map((oe,Ne)=>n.jsxs("div",{className:Ve.row,children:[n.jsx("span",{className:Ve.title,children:oe.title}),oe.content]},Ne))})})]}),children:n.jsx(fe.White,{loading:Ll,disabled:!!Xa||r,children:Xa??"Preview route"})})]})},Ay=()=>{Kc();const e=Ci(),t=Me(),s=Yt(),o=zm(),a=$e.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:c,dstChainId:l,srcDenom:u,dstDenom:m,quantity:d,slippagePercent:h,recipient:f}=r();r((S,{name:P})=>{(P==="srcChainId"||P==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const g=Uc(),p=g(c),y=g(l),b=Ua()(f,l);_.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",p)},[c,p,i]),_.useEffect(()=>{b||i("recipient",y)},[y,b,i]);const{showNotification:j}=hs(),v=Ye(c),w=Ye(l),C=Hs(c),I=Hs(l),T=C.some(S=>S.denom===u),A=I.some(S=>S.denom===m);_.useEffect(()=>{C.length>0&&!T&&(i("srcDenom",C[0].denom),j({type:"info",title:`Switched to ${C[0].symbol}`,description:`The selected asset is not available on ${v.pretty_name}.`,autoHide:!0}))},[C,T,i,j,v.pretty_name]),_.useEffect(()=>{I.length>0&&!A&&(i("dstDenom",I[0].denom),j({type:"info",title:`Switched to ${I[0].symbol}`,description:`The selected asset is not available on ${w.pretty_name}.`,autoHide:!0}))},[I,A,i,j,w.pretty_name]),_.useEffect(()=>{!T||!A||(localStorage.setItem(he.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(he.BRIDGE_SRC_DENOM,u),localStorage.setItem(he.BRIDGE_DST_CHAIN_ID,l),localStorage.setItem(he.BRIDGE_DST_DENOM,m),localStorage.setItem(he.BRIDGE_QUANTITY,d),localStorage.setItem(he.BRIDGE_SLIPPAGE_PERCENT,h))},[c,u,l,m,d,h,T,A]);const $=e[0].path==="/bridge",{reminders:N}=Fn();return n.jsx(Tt,{title:"Bridge/Swap",backButton:$?"/":void 0,extra:n.jsxs(n.Fragment,{children:[n.jsx(fe.Small,{onClick:()=>t("/bridge/history"),unpadded:!0,"aria-label":"Bridge/Swap history",children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:[n.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"}),n.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),n.jsx(Fc,{offset:0,disabled:N.length===0,children:n.jsx(fe.Small,{onClick:()=>t("/op/withdrawals"),disabled:!s,children:n.jsx("span",{children:"Withdrawal status"})})})]}),children:T&&A&&n.jsx($e.FormProvider,{...a,children:n.jsx(xe,{children:n.jsx(Iy,{})})})})},Sy="_button_1crvp_1",Ty="_checkbox_1crvp_11",Ey="_checked_1crvp_25",Es={button:Sy,checkbox:Ty,checked:Ey},$y=({checked:e,onClick:t,label:s,className:o})=>n.jsxs("button",{type:"button",className:B(Es.button,o),onClick:t,role:"checkbox","aria-checked":e,children:[n.jsx("div",{className:B(Es.checkbox,{[Es.checked]:e}),children:e&&n.jsx(M.IconCheck,{size:12,"aria-hidden":"true"})}),n.jsx("span",{className:Es.label,children:s})]}),My="_button_aoxv2_1",Ly={button:My},Jc=({onClick:e,disabled:t})=>{const{ref:s,inView:o}=Wl.useInView();return _.useEffect(()=>{o&&e()},[o,e]),n.jsxs("button",{className:Ly.button,onClick:e,disabled:t,ref:s,children:[n.jsx("span",{children:"Load more"}),n.jsx(M.IconChevronDown,{size:12,"aria-hidden":"true"})]})};function Xc(e,t){return e.reduce((s,o)=>{const a=t(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 Ds=({chainId:e,txHash:t})=>`${he.BRIDGE_HISTORY}:${e}:${t}`,Qs=100,Tr=10;function el(){const[e,t]=Ge.useLocalStorage(he.BRIDGE_HISTORY,[]),s=_.useCallback((a,r)=>{localStorage.setItem(Ds(a),JSON.stringify(r));for(const i of e.slice(Qs-1))localStorage.removeItem(Ds(i));t((i=[])=>[a,...i.slice(0,Qs-1)])},[e,t]),o=_.useCallback(a=>{const r=localStorage.getItem(Ds(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function tl(e){return Ge.useLocalStorage(Ds(e),null)}const vn=qe.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,t)=>[e,t],latestOutput:e=>[e],output:(e,t)=>[e,t],outputResponse:(e,t)=>[e,t],withdrawalClaimed:(e,t)=>[e,t]});function yo(){const{restUrl:e}=ce();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function qy(e){const t=yo(),{data:s}=E.useSuspenseQuery({queryKey:vn.bridge(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:V.INFINITY});return s}const Er=20;function Ry(e){const t=ie();return E.useSuspenseInfiniteQuery({queryKey:vn.withdrawals(e,t).queryKey,queryFn:async({pageParam:s})=>{if(!t)return[];const o={limit:Er,offset:s,order:"desc"},{withdrawals:a}=await z.create({prefixUrl:e}).get(`withdrawals/${t}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=L.last(s)?.sequence;return s.length<Er||!o||o<=1?null:o-1},initialPageParam:0,staleTime:V.SECOND})}function Py(e){const t=yo(),{data:s}=E.useSuspenseQuery({queryKey:vn.latestOutput(e).queryKey,queryFn:()=>t.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:V.SECOND});return s}function Dy({bridge_id:e,output_index:t}){const s=yo(),{data:o}=E.useSuspenseQuery({queryKey:vn.output(e,t).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${t}`).json()}catch{return null}},staleTime:V.SECOND});return o}function By({bridge_id:e,sequence:t}){const o=_e().find(({metadata:l})=>l?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const r=lt()(o);if(!r)throw new Error(`Chain not found: ${o}`);const i=r.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${o}`);const{data:c}=E.useSuspenseQuery({queryKey:vn.outputResponse(i,t).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${t}`).json(),staleTime:V.SECOND});return c}function nl(e,t){const{bridge_id:s}=e,o=yo(),{data:a}=E.useSuspenseQuery({queryKey:vn.withdrawalClaimed(s,t).queryKey,queryFn:()=>o.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:t}}).json(),select:({claimed:r})=>r,staleTime:({state:{data:r}})=>r?.claimed?1/0:V.SECOND});return a}function zn(e){return zl.sha3_256.create().update(e).digest()}function Ko(e,t){const s=new ArrayBuffer(t);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function sl(e){const{bridge_id:t,sequence:s,amount:o,from:a,to:r}=e,i=Ko(t.toString(),8),c=Ko(s.toString(),8),l=Ko(o.amount,8),u=ln.concatBytes(i,c,zn(ln.utf8ToBytes(a)),zn(ln.utf8ToBytes(r)),zn(ln.utf8ToBytes(o.denom)),l);return zn(zn(u))}async function Fy(e,t,s){try{return await z.get(`${e}/opinit/ophost/v1/bridges/${t}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function Uy(e,t){const s=z.create({prefixUrl:t}),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`)}function Oy({addressList:e,route:t,slippagePercent:s,signedOpHook:o}){return{address_list:e,amount_in:t.amount_in,amount_out:t.amount_out,source_asset_chain_id:t.source_asset_chain_id,source_asset_denom:t.source_asset_denom,dest_asset_chain_id:t.dest_asset_chain_id,dest_asset_denom:t.dest_asset_denom,slippage_tolerance_percent:s,operations:t.operations,signed_op_hook:o}}async function Vy(e,t){const s=Oy(t),{txs:o}=await e.post("v2/fungible/msgs",{json:s}).json();if(!o||o.length===0)throw new Error("No transaction data found");return o}function xo(e,t){if(!e?.length)throw new Error("Invalid transaction data");return e.map(({msg_type_url:s,msg:o})=>{if(!(s&&o))throw new Error("Invalid transaction data");const a=t.converters[s];if(!a)throw new Error(`Unsupported message type: ${s}`);return t.fromAmino({type:a.aminoType,value:JSON.parse(o)})})}function Ky({gas:e,gasPrices:t,gasAdjustment:s=Ht}){return t.reduce((o,{amount:a,denom:r})=>(o[r]=q(e).times(s).times(a).integerValue(q.ROUND_CEIL).toFixed(0),o),{})}function Wy({balances:e,requiredFeeByDenom:t,sourceDenom:s,amountIn:o}){const a=Object.keys(t);return a.length===0?!0:a.some(r=>{const i=q(e[r]?.amount??"0"),c=q(r===s?o:0),l=q(t[r]??"0");return i.minus(c).gte(l)})}async function oa(e,t){const{chain_type:s,chain_id:o,chain_name:a,evm_fee_asset:r,rpc:i}=t;if(s!=="evm")throw new Error(`Chain is not an EVM chain: ${a}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}catch(c){if(L.path(["error","code"],c)!==4902)throw c;if(!r)throw new Error(`Fee asset is not defined for chain: ${a}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(o).toString(16)}`,chainName:a,nativeCurrency:r,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}}function xt(){return et()}function zy(e,t){const{customFee:s,onCompleted:o}=t??{},a=Me(),{showNotification:r,updateNotification:i,hideNotification:c}=hs(),{addHistoryItem:l}=el(),u=Pn(),{route:m,values:d}=xt(),{srcChainId:h,sender:f,recipient:g,cosmosWalletName:p}=d,y=zi(),{requestTxSync:x,submitTxSync:b,waitForTxConfirmation:j}=tt(),{find:v}=go(),w=is(),C=cs(),I=bn(),T=Ye(h),A=yn(T),$=Oc(h),N=E.useQueryClient(),{registryUrl:S}=se(),P=lt(),F=ce(),{addReminder:D}=Fn(),Z=Fe();return E.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const K=xo(e.cosmos_tx.msgs,{converters:C,fromAmino:I.fromAmino.bind(I)});if(A==="initia"){const{srcDenom:ut,quantity:Re}=d,{decimals:le}=$(ut),G=s?await b({messages:K,chainId:h,fee:s}):await x({messages:K,chainId:h,internal:1,spendCoins:[{denom:ut,amount:k.toBaseUnit(Re,{decimals:le})}]}),$t=j({txHash:G,chainId:h});return{txHash:G,wait:$t}}const W=v(p)?.getProvider();if(!W)throw new Error("Wallet not connected");const O=W.getOfflineSignerOnlyAmino(h),J=await Le.SigningStargateClient.connectWithSigner(T.rpc,O,{registry:w,aminoTypes:I}),Q=await J.getAllBalances(f),ee=T.fee_assets.find(ut=>Q.some(Re=>Re.denom===ut.denom&&q(Re.amount).gt(0)));if(!ee){const Re=["Insufficient balance for fees.",`Available fee assets: ${T.fee_assets.map(le=>$(le.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Re)}const{denom:ue,gas_price:ye}=ee;if(!ye)throw new Error(`Gas price not found for ${ue}`);const me=await J.simulate(f,K,""),Ce=Le.GasPrice.fromString(ye.average+ue),Se=Le.calculateFee(Math.ceil(me*Ht),Ce),ke=await J.signAndBroadcastSync(f,K,Se),Et=rc({txHash:ke,client:J});return{txHash:ke,wait:Et}}if("evm_tx"in e){const{chain_id:K,to:W,value:O,data:J}=e.evm_tx,Q=await y(),ee=await Q.getSigner();await oa(Q,T);const ue=await ee.sendTransaction({chainId:K,to:W,value:O,data:`0x${J}`}),ye=Hi(ue.wait(),3e4,"Transaction was not confirmed in time. It may still be processing.");return{txHash:ue.hash,wait:ye}}throw new Error("Unlisted chain type")}catch(K){throw K instanceof hn?K:await ct(K)}},onSuccess:async({txHash:K,wait:W})=>{localStorage.removeItem(he.BRIDGE_QUANTITY),N.removeQueries({queryKey:Ie.route._def}),N.removeQueries({queryKey:Ie.routeErrorInfo._def}),o?o({txhash:K,chainId:h,timestamp:Date.now(),success:!0,route:m,values:d}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await W;const O=bo(m)==="OP Bridge withdrawal",J=O?{success:!0,error:null}:await Zy(Z,K,h);if(!o&&!J.success&&J.error){const me=J.error instanceof Error?J.error.message:String(J.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${me}. The transaction may still be processing.`,autoHide:!0})}const Q=J.success,ue=$r({txHash:K,srcChainId:h,route:m,values:d,recipient:g},Q);l(ue.tx,ue.details),o||i(Qy(c));const ye=Wo(d,K);if(u("Bridge Transaction Success",ye),O){const me=P(h).metadata?.op_bridge_id;if(me&&!await Fy(F.restUrl,Number(me),m.dest_asset_denom)){const Se=Yy(ue.tx,m,g);D(ue.tx,Se)}}}catch(O){const J=O instanceof Error?O.message:String(O);if(O instanceof hn){const ee=$r({txHash:K,srcChainId:h,route:m,values:d},!1);l(ee.tx,ee.details),o||i(Gy(c))}else o?o({success:!1,error:J,route:m,values:d}):i({type:"error",title:"Transaction not confirmed",description:J});u("Bridge Confirmation Failed",{...Wo(d,K),error:J,type:O instanceof hn?"timeout":"error"})}finally{N.invalidateQueries({queryKey:Ie.balances(h,f).queryKey})}},onError:async K=>{const W=A==="initia"?await Nn(K,P(h),S):K;o?o({success:!1,error:W.message,route:m,values:d}):r({type:"error",title:"Transaction failed",description:W.message});const O=Wo(d);u("Bridge Transaction Failed",{...O,error:W.message})}})}function Hy(){const e=Fe(),t=ie(),s=Ki(),{route:o,values:a}=xt(),r=Bt(),i=cs(),c=bn();return E.useMutation({mutationFn:async()=>{try{const{chain_id:l,hook:u}=await e.post("op-hook",{json:{source_address:t,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:k.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await Uy(t,r(o.dest_asset_chain_id).rest);const m=xo(u,{converters:i,fromAmino:c.fromAmino.bind(c)}),d=await s(l,t,m,{amount:[],gas:"1"},"",{incrementSequence:l===a.srcChainId?2:0}),h=Ze.Tx.fromPartial({body:Ze.TxBody.decode(d.bodyBytes),authInfo:Ze.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:t,hook:de.toBase64(Ze.Tx.encode(h).finish())}}catch(l){throw await ct(l)}}})}function Qy(e){return{type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(mn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function Gy(e){return{type:"info",title:"Transaction pending",description:_.createElement(_.Fragment,null,"Confirmation is taking longer than expected. Check ",_.createElement(mn,{to:"/bridge/history",onClick:e},"the activity page")," for updates"),autoHide:!0}}function Wo(e,t){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:t}}function $r(e,t){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},c=bo(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:c?"success":void 0,tracked:t},isOpWithdraw:c}}function Yy(e,t,s){return{...e,recipient:k.InitiaAddress(s).bech32,claimableAt:Date.now()+t.estimated_route_duration_seconds*1e3,amount:t.amount_out,denom:t.dest_asset_denom}}async function Zy(e,t,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:t,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await ct(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function ol(e){const{chainId:t,txHash:s,tracked:o}=e,a=Fe();return E.useQuery({queryKey:Ie.txTrack(t,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:t}}).json()}catch(r){throw await ct(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:V.INFINITY,enabled:!o})}function al(e){const{timestamp:t,chainId:s,txHash:o,tracked:a,state:r}=e,i=Fe();return E.useQuery({queryKey:Ie.txStatus(s,o).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:o,chain_id:s}}).json(),enabled:!!o&&a&&!r,refetchInterval:({state:{data:c}})=>{if(!c)return!1;const{status:l}=c;if(l==="STATE_COMPLETED")return!1;const u=t+e.route.estimated_route_duration_seconds*1e3,m=Date.now(),d=Math.floor((u-m)/1e3);return d<=0?1e3:d<=300?5e3:60*1e3},staleTime:V.INFINITY})}var Yn=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(Yn||{});function bo(e){const{operations:t,dest_asset_denom:s}=e;return L.has("op_init_transfer",L.head(t))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const Jy="_success_t4dfk_1",Xy="_error_t4dfk_5",Mr={success:Jy,error:Xy},ex=({tx:e})=>{const[t,s]=tl(e);if(!t)throw new Error("Bridge history details not found");const{data:o}=al(t),a=t.state??tx(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 n.jsx("div",{className:Mr.error,children:n.jsx(M.IconCloseCircleFilled,{size:14})});case"success":return n.jsx("div",{className:Mr.success,children:n.jsx(M.IconCheckCircleFilled,{size:14})});default:return n.jsx(It,{size:14})}};function tx(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 nx="_link_104m3_1",sx="_header_104m3_23",ox="_title_104m3_31",ax="_date_104m3_37",rx="_explorer_104m3_41",ix="_fees_104m3_57",cx="_label_104m3_65",lx="_content_104m3_69",ux="_route_104m3_75",dx="_row_104m3_80",mx="_asset_104m3_86",hx="_amount_104m3_94",fx="_chain_104m3_99",px="_account_104m3_108",gx="_arrow_104m3_115",Pe={link:nx,header:sx,title:ox,date:ax,explorer:rx,fees:ix,label:cx,content:lx,route:ux,row:dx,asset:mx,amount:hx,chain:fx,account:px,arrow:gx},_x=({tx:e})=>{const[t,s]=tl(e);if(!t)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:c,tracked:l}=t,{data:u}=ol(t),{address:m="",connector:d}=Qe.useAccount(),{find:h}=go();_.useEffect(()=>{u&&s(D=>{if(!D)throw new Error("Bridge history details not found");return{...D,tracked:!0}})},[s,u]);const{amount_in:f,amount_out:g,source_asset_chain_id:p,source_asset_denom:y,dest_asset_chain_id:x,dest_asset_denom:b,estimated_fees:j=[]}=r,v=Ye(p),w=Ye(x),C=At(y,p),I=At(b,x),T=(D,Z)=>Z?n.jsx(re,{src:Z,width:12,height:12}):k.InitiaAddress.equals(D,m)?n.jsx(re,{src:d?.icon,width:12,height:12}):n.jsx(M.IconWallet,{size:12}),A=(D,{symbol:Z,decimals:K,logo_uri:W},{chain_name:O,pretty_name:J,...Q},ee,ue)=>n.jsxs("div",{className:Pe.row,children:[n.jsx(_o,{assetLogoUrl:W,chainLogoUrl:Q.logo_uri??void 0}),n.jsxs("div",{children:[n.jsxs("div",{className:Pe.asset,children:[n.jsx("span",{className:Pe.amount,children:k.formatAmount(D,{decimals:K})}),n.jsx("span",{children:Z})]}),n.jsxs("div",{className:Pe.chain,children:[n.jsxs("span",{children:["on ",J||O]}),n.jsxs("div",{className:Pe.account,children:[ue,n.jsx("span",{className:"monospace",children:k.truncate(ee)})]})]})]})]}),$=bo(r),N=_.useMemo(()=>{switch($){case Yn.SKIP:return"Skip Explorer";case Yn.OP_WITHDRAW:return"Initia Scan"}},[$]),S=n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Pe.header,children:[n.jsxs("div",{className:Pe.title,children:[l?n.jsx(ex,{tx:e}):n.jsx(It,{size:14}),n.jsx("div",{className:Pe.date,children:Xe.format(new Date(c),"h:mm a")})]}),n.jsxs("div",{className:Pe.explorer,children:[n.jsx("span",{children:N}),n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})]})]}),n.jsxs("div",{className:Pe.route,children:[A(f,C,v,i.sender,T(i.sender,h(i.cosmosWalletName)?.image)),n.jsx("div",{className:Pe.arrow,children:n.jsx(M.IconArrowDown,{size:12,"aria-hidden":"true"})}),A(g,I,w,i.recipient,T(i.recipient))]}),j.length>0&&n.jsxs("div",{className:Pe.fees,children:[n.jsx("span",{className:Pe.label,children:"Fees"}),n.jsx("span",{className:Pe.content,children:Oa(j)})]})]});if($===Yn.OP_WITHDRAW)return n.jsx(ho,{chainId:o,txHash:a,className:Pe.link,children:S});const P=new URLSearchParams({tx_hash:a,chain_id:o}),F=new URL(`?${P.toString()}`,"https://explorer.skip.build");return n.jsx("a",{href:F.toString(),className:Pe.link,target:"_blank",rel:"noopener noreferrer",children:S})},yx="_history_13u9z_1",xx="_header_13u9z_5",bx="_checkbox_13u9z_9",wx="_groups_13u9z_13",vx="_dateGroup_13u9z_21",jx="_dateHeader_13u9z_26",Cx="_list_13u9z_32",on={history:yx,header:xx,checkbox:bx,groups:wx,dateGroup:vx,dateHeader:jx,list:Cx},kx=()=>{const{initiaAddress:e,hexAddress:t}=tt(),{history:s,getHistoryDetails:o}=el(),a=s.filter(f=>o(f)),r=a.filter(f=>{const g=o(f);if(!g)return!1;const{values:p}=g,{sender:y,recipient:x}=p;return[y,x].some(b=>[e,t].includes(b))}),[i,c]=_.useState(1),[l,u]=Ge.useToggle(!r.length),m=l?a:r,d=m.slice(0,i*Tr),h=_.useMemo(()=>Xc(d,f=>{const g=o(f);if(g)return new Date(g.timestamp)}),[d,o]);return n.jsx(Tt,{title:"Bridge/Swap activity",children:n.jsxs("div",{className:on.history,children:[a.length>0&&a.length!==r.length&&n.jsx("header",{className:on.header,children:n.jsx($y,{checked:l,onClick:u,label:"Show all transactions stored in this browser",className:on.checkbox})}),m.length===0?n.jsx(je,{children:"No bridge/swap activity"}):n.jsx("div",{className:on.groups,children:Object.entries(h).map(([f,g])=>n.jsxs("div",{className:on.dateGroup,children:[n.jsx("div",{className:on.dateHeader,children:f}),n.jsx("div",{className:on.list,children:g.map(p=>n.jsx(xe,{children:n.jsx(_x,{tx:p})},p.txHash))})]},f))}),m.length>i*Tr?n.jsx(Jc,{onClick:()=>c(f=>f+1)}):s.length>=Qs&&n.jsxs(je,{children:["Only the latest ",Qs," items are stored. Older entries will be removed automatically."]})]})})};function rl({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}){return{...e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}}function Nx({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return rl({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!0})}function Ix({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return rl({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!1})}const Ax=1e4;function aa(e){return e===void 0?"undefined":e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(aa).join(",")}]`:`{${Object.entries(e).sort(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${JSON.stringify(t)}:${aa(s)}`).join(",")}}`}function Lr(e){return aa({amount_in:e.amount_in,amount_out:e.amount_out,usd_amount_in:e.usd_amount_in,usd_amount_out:e.usd_amount_out,operations:e.operations,estimated_fees:e.estimated_fees,estimated_route_duration_seconds:e.estimated_route_duration_seconds,warning:e.warning,extra_infos:e.extra_infos,extra_warnings:e.extra_warnings,required_op_hook:e.required_op_hook})}function Sx(e,t,s){const o=Me(),a=et(),r=E.useQueryClient(),i=Fe(),[c,l]=_.useState(!1),[u,m]=_.useState(void 0),[d,h]=_.useState(s??0),f=_.useRef(null);return _.useEffect(()=>{h(s??0)},[s]),_.useEffect(()=>()=>{f.current?.abort()},[]),{refreshRouteIfNeeded:async()=>{const p=Math.max(s??0,d);if(Date.now()-p<=Ax)return!1;l(!0),m(void 0);const y=new AbortController;f.current=y;try{const x=await Gc(i,r,t,{isOpWithdraw:bo(e)===Yn.OP_WITHDRAW,signal:y.signal});if(y.signal.aborted)return!0;const b=Lr(x)!==Lr(e),j=Date.now();return b?(o(0,Nx({currentState:a,route:x,values:t,quoteVerifiedAt:j})),!0):(h(j),!1)}catch(x){return x instanceof DOMException&&x.name==="AbortError"||y.signal.aborted||m((await ct(x)).message),!0}finally{f.current===y&&(f.current=null),y.signal.aborted||l(!1)}},isRefreshing:c,refreshError:u,clearRefreshError:()=>m(void 0)}}function Tx(e,t){return t?"Confirm updated route":e||"Confirm"}function Ex({error:e,warning:t,messageRefreshError:s,refreshError:o,requiresReconfirm:a}){if(e)return{level:"error",text:e};if(s)return{level:"error",text:s};if(o)return{level:"error",text:o};if(t)return{level:"warning",text:t};if(a)return{level:"info",text:"Route updated. Please review and confirm again."}}function $x({isCheckingApprovals:e,isCheckingFeeBalance:t,isFetchingMessages:s,isEstimatingGas:o,isRouteTransitioning:a}){return a?"Refreshing route...":s?"Fetching messages...":t?"Checking fee balance...":e?"Checking approvals...":o?"Estimating gas...":!1}function Mx({isRefreshing:e,isPending:t,backgroundLoadingText:s}){return e?"Refreshing route...":t?"Signing transaction...":s}const Ka=({tx:e,fee:t,onCompleted:s,confirmMessage:o,error:a,warning:r,isCheckingApprovals:i,isCheckingFeeBalance:c,messageRefreshError:l,isRouteTransitioning:u,isFetchingMessages:m,isEstimatingGas:d})=>{const h=Me(),f=et(),{route:g,values:p,quoteVerifiedAt:y,requiresReconfirm:x}=xt(),{mutate:b,isPending:j}=zy(e,{customFee:t,onCompleted:s}),{refreshRouteIfNeeded:v,isRefreshing:w,refreshError:C,clearRefreshError:I}=Sx(g,p,y),T=$x({isCheckingApprovals:i,isCheckingFeeBalance:c,isFetchingMessages:m,isEstimatingGas:d,isRouteTransitioning:u}),A=async()=>{if(!(j||w||T||l)){if(x){h(0,Ix({currentState:f,route:g,values:p,quoteVerifiedAt:y??Date.now()}));return}await v()||(I(),b())}},$=Ex({error:a,warning:r,messageRefreshError:l,refreshError:C,requiresReconfirm:x}),N=Mx({isRefreshing:w,isPending:j,backgroundLoadingText:T}),S=j||w||!!T||!!l;return n.jsx(Ae,{extra:$&&n.jsx(we,{level:$.level,children:$.text}),children:n.jsx(fe.White,{onClick:A,loading:N,disabled:!!a||!!r||S,children:Tx(o,!!x)})})};function Lx({approvalError:e,approveTokens:t,exactFeeCheckError:s,isApproving:o,isCheckingApprovals:a,isCheckingFeeBalance:r,isFetchingMessages:i,messageRefreshError:c,requiresApproval:l}){return i||c?{kind:"preview",isFetchingMessages:i,messageRefreshError:c}:r?{kind:"preview",isCheckingFeeBalance:!0}:s?{kind:"preview",error:s}:a?{kind:"preview",isCheckingApprovals:!0}:l&&t?{kind:"approval",approvalError:e,approveTokens:t,isApproving:!!o}:{kind:"preview"}}const qx="_content_1hzj2_1",Rx="_info_1hzj2_6",Px="_arrow_1hzj2_11",Dx="_divider_1hzj2_19",Bx="_type_1hzj2_27",Fx="_asset_1hzj2_47",Ux="_amount_1hzj2_55",Ox="_lower_1hzj2_60",Vx="_chain_1hzj2_66",Kx="_address_1hzj2_72",ot={content:qx,info:Rx,arrow:Px,divider:Dx,type:Bx,asset:Fx,amount:Ux,lower:Ox,chain:Vx,address:Kx},il=e=>{const{source:t,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:c}=e,{symbol:l=k.truncate(a),decimals:u=0,logo_uri:m=_a}=e,{chain_name:d,pretty_name:h,...f}=Ye(r);return n.jsxs("div",{children:[!t&&n.jsxs("div",{className:ot.arrow,children:[n.jsx("div",{className:ot.divider}),s?n.jsx(_s,{label:s,children:n.jsx("button",{className:ot.type,children:n.jsx(M.IconArrowDown,{size:12})})}):n.jsx("span",{className:ot.type,children:n.jsx(M.IconArrowDown,{size:12})}),n.jsx("div",{className:ot.divider})]}),n.jsxs("div",{className:ot.content,children:[n.jsx(_o,{assetLogoUrl:m,chainLogoUrl:f.logo_uri??void 0}),n.jsxs("div",{className:ot.info,children:[n.jsxs("div",{className:ot.asset,children:[n.jsx("span",{className:ot.amount,children:k.formatAmount(o,{decimals:u})}),n.jsx("span",{children:l})]}),n.jsxs("div",{className:ot.lower,children:[n.jsxs("div",{className:ot.chain,children:["on ",h||d]}),i&&n.jsx(Ws,{value:i,children:({copy:g,copied:p})=>n.jsxs("button",{className:ot.address,onClick:g,children:[c,p?n.jsx("span",{children:"Copied!"}):n.jsx("span",{className:"monospace",children:k.truncate(i)})]})})]})]})]})]})},Sn=e=>{const t=At(e.denom,e.chainId);return n.jsx(il,{...e,...t})};Sn.Placeholder=il;const Wx="_root_1hbar_1",zx="_flexEnd_1hbar_6",Hx="_toggle_1hbar_11",Qx="_route_1hbar_36",Gx="_content_1hbar_43",Hn={root:Wx,flexEnd:zx,toggle:Hx,route:Qx,content:Gx};function Yx(e){const t=({name:s})=>s==="initia-dex"?"Initia DEX":Ys.capitalCase(L.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(t).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(t).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 Zx=({addressList:e})=>{const{values:t,route:s}=xt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,c=L.zipObj(s.required_chain_addresses,e),{find:l}=go(),{connector:u,address:m=""}=Qe.useAccount(),[d,h]=Ge.useToggle(!1),f=i.length>1,g=n.jsx(re,{src:t.cosmosWalletName?l(t.cosmosWalletName)?.image:u?.icon,width:12,height:12}),p={amount:r,denom:o,chainId:a,address:t.sender,walletIcon:g},y=w=>k.InitiaAddress.equals(w,m)?g:n.jsx(M.IconWallet,{size:11}),x=w=>{const{label:C,amount_out:I,denom:T,denom_out:A=T,chain_id:$,from_chain_id:N,to_chain_id:S=$??N}=w,P=c[S];return{label:f&&!d?void 0:C,amount:I,denom:A,chainId:S,address:P,walletIcon:y(P)}},b=i.map(Yx).map(x),j=b.slice(0,-1),v=b[b.length-1];return n.jsxs(te.Collapsible.Root,{className:Hn.root,open:d,onOpenChange:h,children:[f&&n.jsx("div",{className:Hn.flexEnd,children:n.jsx(te.Collapsible.Trigger,{className:Hn.toggle,children:d?n.jsxs(n.Fragment,{children:[n.jsx(M.IconMinus,{size:12}),n.jsx("span",{children:"Hide details"})]}):n.jsxs(n.Fragment,{children:[n.jsx(M.IconList,{size:12}),n.jsx("span",{children:"Show details"})]})})}),n.jsxs("div",{className:Hn.route,children:[n.jsx(Sn,{...p,source:!0}),n.jsx(te.Collapsible.Content,{className:Hn.content,children:j.map((w,C)=>n.jsx(xe,{suspenseFallback:n.jsx(Sn.Placeholder,{...w}),errorBoundaryProps:{fallback:n.jsx(Sn.Placeholder,{...w})},children:n.jsx(Sn,{...w})},C))}),n.jsx(Sn,{...v})]})]})},cl=({error:e})=>{const t=Me();return n.jsx(Ae,{extra:n.jsx(we,{level:"error",children:e.message}),children:n.jsx(fe.White,{onClick:()=>t("/bridge"),children:"Home"})})},ll=({children:e})=>{const t=xt(),{route:s,values:o}=t,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:u,hexAddress:m}=tt(),d=ls(),h=Bt(),f=fs(),g=h(r),p=f(g),y=a.slice(0,-1).some(I=>{const T=h(I);return f(T)==="cosmos"})&&p!=="cosmos",[x,b]=_.useState(void 0),[j,v]=_.useState(!1),[w,C]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!y)return;if(!d)throw new Error("Wallet not connected");v(!0),C(null);const[{pubkey:T}]=await d.getAccounts();b(T)}catch(T){C(await ct(T))}finally{v(!1)}})()},[y,d]),w)return n.jsx(cl,{error:w});if(j)return n.jsx(Ae,{children:n.jsx(fe.White,{loading:j&&"Generating intermediary addresses..."})});if(!y||x){const I=a.map((T,A)=>{if(A===a.length-1){const F=h(i);return f(F)==="initia"?k.InitiaAddress(l).bech32:l}const $=h(T),N=f($),S=h(r),P=f(S);switch(N){case"initia":return u;case"evm":return m;case"cosmos":{if(P==="cosmos")return de.toBech32($.bech32_prefix,de.fromBech32(c).data);if(!x)throw new Error("Pubkey not found");return En.pubkeyToAddress(En.encodeSecp256k1Pubkey(x),$.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(I)}return null};function Jx(e){return"evm_tx"in e?JSON.stringify({approvals:e.evm_tx.required_erc20_approvals??[],chainId:e.evm_tx.chain_id,signerAddress:e.evm_tx.signer_address}):"non-evm"}function Xx({currentKey:e,isPending:t,nextKey:s}){return!t&&e!==s}function e1(e,t){return typeof e=="function"?e(t):t.isCheckingApprovals?n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Checking approvals..."})}):t.requiresApproval&&t.approveTokens?n.jsx(Ae,{extra:n.jsx(we,{level:"error",children:t.approvalError}),children:n.jsx(fe.White,{onClick:t.approveTokens,loading:t.isApproving&&"Approving tokens...",children:"Approve tokens"})}):e}const ul=({tx:e,children:t})=>{const s=zi(),o=Bt(),a=E.useQueryClient(),r=Jx(e),i=_.useRef(r),{data:c,isLoading:l}=E.useQuery({queryKey:["interwovenkit:erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:g,signer_address:p}=e.evm_tx,y=await s();await oa(y,o(g));const x=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async j=>{const{token_contract:v,spender:w}=j,I=await new kt.ethers.Contract(v,x,y).allowance(p,w);return{approval:j,currentAllowance:BigInt(I.toString())}}))).filter(({approval:j,currentAllowance:v})=>v<BigInt(j.amount)).map(({approval:j})=>j)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:u,data:m,isPending:d,error:h,reset:f}=E.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!c||c.length===0)throw new Error("No approvals needed");const{chain_id:g}=e.evm_tx,p=await s(),y=await p.getSigner();await oa(p,o(g));for(const x of c){const{token_contract:b,spender:j,amount:v}=x,w=["function approve(address spender, uint256 amount) external returns (bool)"],I=await new kt.ethers.Contract(b,w,y).approve(j,v);await Hi(I.wait(),3e4,"Approval was not confirmed in time. It may still be processing.")}return!0}catch(g){throw g instanceof hn?(a.invalidateQueries({queryKey:["interwovenkit:erc20-approvals-needed",e]}),g):await ct(g)}}});return _.useEffect(()=>{const g=i.current;Xx({currentKey:g,isPending:d,nextKey:r})&&(i.current=r,f())},[r,d,f]),e1(t,{approvalError:h?.message,approveTokens:c&&c.length>0&&!m?()=>u():void 0,isApproving:d,isCheckingApprovals:l,requiresApproval:!!c&&c.length>0&&!m})};function t1({route:e,tx:t,isSrcInitia:s,isDstInitia:o,sender:a,recipient:r}){return!!e&&"cosmos_tx"in t&&!!t.cosmos_tx.msgs?.length&&!e.required_op_hook&&s&&o&&!!a&&!!r}function n1({hasBalances:e,hasChain:t,requiresExactFeeCheck:s}){return s&&e&&t}function s1({balances:e,feeDenoms:t}){return e?t.toSorted().map(s=>`${s}:${e[s]?.amount??"0"}`).join("|"):""}function o1({tx:e,children:t}){const{route:s,values:o}=xt(),{sender:a,recipient:r,srcChainId:i,srcDenom:c,dstChainId:l}=o,u=Ye(i),m=Ye(l),d=yn(u),h=yn(m),{data:f,isLoading:g,error:p}=po(a,i),y=cs(),x=bn(),b=us(),j=t1({route:s,tx:e,isSrcInitia:d==="initia",isDstInitia:h==="initia",sender:a,recipient:r}),{chain:v,error:w,isLoading:C}=ou(i,j),I=v?Array.from(new Set([c,...v.fees.fee_tokens.map(({denom:P})=>P)])):[],T=s1({balances:f,feeDenoms:I}),A=n1({hasBalances:f!==void 0,hasChain:!!v,requiresExactFeeCheck:j}),{data:$,error:N,isLoading:S}=E.useQuery({queryKey:["interwovenkit:bridge-preview-fee-check",e,a,i,c,s.amount_in,T],queryFn:async()=>{try{if(!(j&&v&&"cosmos_tx"in e&&e.cosmos_tx.msgs?.length&&f))throw new Error("Invalid transaction data");const P=xo(e.cosmos_tx.msgs,{converters:y,fromAmino:x.fromAmino.bind(x)}),D=await(await b(i)).simulate(a,P,""),Z=await ka(v),K=Ky({gas:D,gasPrices:Z});return Wy({balances:f,requiredFeeByDenom:K,sourceDenom:c,amountIn:s.amount_in})}catch(P){throw await ct(P)}},enabled:A,retry:!1});return t(j?w?{exactFeeCheckError:w.message,isCheckingFeeBalance:!1}:p?{exactFeeCheckError:p instanceof Error?p.message:"Failed to load balances",isCheckingFeeBalance:!1}:C||g||f===void 0||S?{isCheckingFeeBalance:!0}:N?{exactFeeCheckError:N.message,isCheckingFeeBalance:!1}:$?{isCheckingFeeBalance:!1}:{exactFeeCheckError:"Insufficient balance for fees",isCheckingFeeBalance:!1}:{isCheckingFeeBalance:!1})}function a1({addressList:e,operations:t,signedOpHook:s}){return JSON.stringify({addressList:e,operations:t,signedOpHook:s??null})}function r1({previousQuoteVerifiedAt:e,quoteVerifiedAt:t,hasValue:s,hasMessageRefreshError:o}){return s&&o&&e!==void 0&&t!==void 0&&t!==e}function i1({error:e,loading:t,value:s}){const o=s!==void 0;return{isFetchingMessages:t,messageRefreshError:!t&&o&&e?e.message:void 0,shouldRenderError:!!e&&!o,shouldRenderLoading:!o}}const dl=({addressList:e,signedOpHook:t,children:s})=>{const o=Fe(),{route:a,values:r,quoteVerifiedAt:i}=xt(),[c,l]=_.useState(void 0),[u,m]=_.useState(!1),[d,h]=_.useState(null),[f,g]=_.useState(0),p=_.useRef(i),y=a1({addressList:e,operations:a.operations,signedOpHook:t});_.useEffect(()=>{const b=p.current;r1({previousQuoteVerifiedAt:b,quoteVerifiedAt:i,hasValue:c!==void 0,hasMessageRefreshError:d!==null})&&g(j=>j+1),p.current=i},[i,c,d]),_.useEffect(()=>{let b=!1;return(async()=>{try{if(m(!0),h(null),a.required_op_hook&&!t)throw new Error("Op hook is required");const v=await Vy(o,{addressList:e,route:{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,operations:a.operations},slippagePercent:String(r.slippagePercent),signedOpHook:t});if(b)return;const[w]=v;l(w)}catch(v){if(b)return;h(await ct(v))}finally{b||m(!1)}})(),()=>{b=!0}},[y,f,a.amount_in,a.amount_out,a.source_asset_chain_id,a.source_asset_denom,a.dest_asset_chain_id,a.dest_asset_denom,a.required_op_hook,r.slippagePercent,o]);const x=i1({error:d,loading:u,value:c});return x.shouldRenderError&&d?n.jsx(cl,{error:d}):x.shouldRenderLoading?n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Fetching messages..."})}):s(c,{isFetchingMessages:x.isFetchingMessages,messageRefreshError:x.messageRefreshError})},ml=({children:e})=>{const{route:t}=xt(),s=Hy();return t.required_op_hook&&!s.data?n.jsx(Ae,{extra:n.jsx(we,{level:"error",children:s.error?.message}),children:n.jsx(fe.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)};function c1({approvalError:e,approveTokens:t,isApproving:s}){return n.jsx(Ae,{extra:e&&n.jsx(we,{level:"error",children:e}),children:n.jsx(fe.White,{onClick:t,loading:s&&"Approving tokens...",children:"Approve tokens"})})}const l1=()=>n.jsx(Tt,{title:"Route preview",children:n.jsx(ll,{children:e=>n.jsxs(n.Fragment,{children:[n.jsx(Zx,{addressList:e}),n.jsx(ml,{children:t=>n.jsx(dl,{addressList:e,signedOpHook:t,children:(s,{isFetchingMessages:o,messageRefreshError:a})=>n.jsx(o1,{tx:s,children:({exactFeeCheckError:r,isCheckingFeeBalance:i})=>n.jsx(ul,{tx:s,children:({approvalError:c,approveTokens:l,isApproving:u,isCheckingApprovals:m,requiresApproval:d})=>{const h=Lx({approvalError:c,approveTokens:l,exactFeeCheckError:r,isApproving:u,isCheckingApprovals:m,isCheckingFeeBalance:i,isFetchingMessages:o,messageRefreshError:a,requiresApproval:d});return h.kind==="approval"?c1({approvalError:h.approvalError,approveTokens:h.approveTokens,isApproving:h.isApproving}):n.jsx(Ka,{tx:s,error:h.error,isCheckingApprovals:h.isCheckingApprovals,isCheckingFeeBalance:h.isCheckingFeeBalance,isFetchingMessages:h.isFetchingMessages,messageRefreshError:h.messageRefreshError})}})})})})]})})}),hl=_.createContext(null);function wo(){return _.useContext(hl)}const u1="_button_17r1o_1",d1="_claimed_17r1o_24",qr={button:u1,claimed:d1},m1=()=>{const{withdrawalTx:e}=wo(),{bridge_id:t,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:c,to:l,version:u}=e,m=ce(),d=ie(),{requestTxSync:h,waitForTxConfirmation:f}=tt(),g=By(e),p=de.toBase64(sl(e)),y=nl(e,p),x=E.useQueryClient(),{mutate:b,isPending:j}=E.useMutation({mutationFn:async()=>{if(!g)throw new Error("Output not found");const{last_block_hash:v}=g;return h({chainId:m.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:d,bridgeId:BigInt(t),outputIndex:BigInt(a),withdrawalProofs:r.map(de.fromBase64),from:c,to:l,sequence:BigInt(s),amount:o,version:de.fromBase64(u),storageRoot:de.fromBase64(i),lastBlockHash:de.fromBase64(v)}}],internal:!0})},onSuccess:async v=>{await f({chainId:m.chain_id,txHash:v}),x.invalidateQueries({queryKey:vn.withdrawalClaimed(t,p).queryKey})}});return y?n.jsxs("div",{className:qr.claimed,children:[n.jsx(M.IconCheckCircleFilled,{size:14}),n.jsx("span",{children:"Claimed"})]}):n.jsx("button",{className:qr.button,onClick:()=>b(),disabled:j,children:"Claim"})},h1=({children:e})=>{const{withdrawalTx:t}=wo(),s=qy(t.bridge_id),o=Dy(t),a=_.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Xe.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},fl=1e3,f1=60,p1=60,g1=24,ra=fl*f1,ia=ra*p1,Rr=ia*g1,_1=({date:e})=>{const t=_.useCallback(()=>{const u=new Date().getTime(),d=e.getTime()-u;if(d<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(d/Rr),f=Math.floor(d%Rr/ia),g=Math.floor(d%ia/ra),p=Math.floor(d%ra/fl);return{days:h,hours:f,minutes:g,seconds:p}},[e]),[s,o]=_.useState(t());_.useEffect(()=>{const u=window.setInterval(()=>{o(t())},1e3);return()=>window.clearInterval(u)},[t,e]);const a=u=>u.toString().padStart(2,"0"),{days:r,hours:i,minutes:c,seconds:l}=s;return n.jsx(_s,{label:e.toLocaleString(),children:n.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(c),"m ",a(l),"s"]})})},y1="_container_1lz3w_1",x1="_title_1lz3w_5",Pr={container:y1,title:x1},b1=({date:e})=>n.jsxs("div",{className:Pr.container,children:[n.jsx("div",{className:Pr.title,children:"Claimable in"}),n.jsx(_1,{date:e})]}),w1="_container_1oldz_1",v1="_icon_1oldz_7",Dr={container:w1,icon:v1},j1="Withdrawal will begin within an hour",Br=()=>{const e=uo();return n.jsxs("div",{className:Dr.container,children:[n.jsx("span",{children:"In progress"}),!e&&n.jsx(_s,{label:j1,children:n.jsx("span",{className:Dr.icon,children:n.jsx(M.IconInfoFilled,{size:12})})})]})},C1=({children:e})=>{const{withdrawalTx:t}=wo(),s=Py(t.bridge_id),o=t.output_index>Number(s?.output_index);return e(o)},k1=({date:e,children:t})=>{const{chainId:s,withdrawalTx:o}=wo(),a=de.toBase64(sl(o)),r=nl(o,a),{setReminder:i,removeReminder:c}=Fn();return _.useEffect(()=>{const l={chainId:s,txHash:o.tx_hash};r?c(l):i(l,{...l,recipient:o.to,claimableAt:e.getTime(),amount:o.amount.amount,denom:o.amount.denom,dismissed:Xe.isPast(e.getTime())?!0:void 0})},[s,r,e,c,i,o]),t},N1=()=>n.jsx(C1,{children:e=>e?n.jsx(Br,{}):n.jsx(h1,{children:t=>t?n.jsx(k1,{date:t,children:Xe.isFuture(t)?n.jsx(b1,{date:t}):n.jsx(m1,{})}):n.jsx(Br,{})})}),I1="_asset_6h8u2_1",A1="_info_6h8u2_7",S1="_symbol_6h8u2_11",zo={asset:I1,info:A1,symbol:S1},T1=({amount:e,denom:t})=>{const s=ce(),o=yi(t,s),{symbol:a,logoUrl:r,decimals:i}=o;return n.jsxs("div",{className:zo.asset,children:[n.jsx(re,{src:r,width:32,height:32,logo:!0}),n.jsxs("div",{className:zo.info,children:[n.jsx("span",{className:"monospace",children:k.formatAmount(e,{decimals:i})}),n.jsx("span",{className:zo.symbol,children:a})]})]})},E1="_item_km5w2_1",$1={item:E1},M1=({chain:e})=>{const t=e.metadata?.executor_uri;if(!t)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:o,hasNextPage:a,isFetching:r}=Ry(t),i=_.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:c}=Fn();return _.useEffect(()=>{const l=i.map(u=>({chainId:e.chainId,txHash:u.tx_hash}));c(l)},[e.chainId,i,c]),i.length?n.jsxs(n.Fragment,{children:[i.map(l=>{const{amount:u}=l;return n.jsxs("div",{className:$1.item,children:[n.jsx(T1,{...u}),n.jsx(xe,{suspenseFallback:null,children:n.jsx(hl.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:n.jsx(N1,{})})})]},l.sequence)}),a&&n.jsx(Jc,{onClick:()=>o(),disabled:r})]}):n.jsx(je,{children:"No withdrawals"})},L1="_content_dj1qm_1",q1="_title_dj1qm_5",Fr={content:L1,title:q1},R1=()=>{const{chainId:e}=et(),t=_e(),s=xn(),[o,a]=_.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=lt(),{reminders:i}=Fn(),c=o?r(o):void 0;return n.jsxs(Tt,{title:"OP Bridge withdrawals",children:[n.jsx(fn,{chains:t.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:l=>i.some(u=>u.chainId===l)}),n.jsx("div",{className:Fr.content,children:c?n.jsxs(n.Fragment,{children:[n.jsx("h2",{className:Fr.title,children:c.name}),n.jsx(xe,{children:n.jsx(M1,{chain:c})},o)]}):n.jsx(we,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},Rn=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),P1="5722e7dffb709492cf5312446ceeff73",D1=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${P1}`,pl=["interwovenkit:walletconnect-wallets"],B1=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",gl=async e=>{const t=await z.get(D1,{signal:e}).json(),s=t!==null&&typeof t=="object"&&"listings"in t?t.listings:t;return Object.values(s??{}).filter(B1)},F1=()=>E.useQuery({queryKey:pl,queryFn:({signal:e})=>gl(e),staleTime:V.INFINITY,gcTime:V.INFINITY,retry:2}),U1="_page_13y8q_1",O1="_pageTop_13y8q_19",V1="_backButtonFixed_13y8q_63",K1="_listItem_13y8q_64",W1="_socialButton_13y8q_65",z1="_arrowIcon_13y8q_66",H1="_searchInputUnderline_13y8q_67",Q1="_header_13y8q_72",G1="_title_13y8q_81",Y1="_headerSpacer_13y8q_116",Z1="_icon_13y8q_120",J1="_installedText_13y8q_124",X1="_divider_13y8q_131",e0="_dividerText_13y8q_152",t0="_loading_13y8q_193",n0="_socialIcons_13y8q_198",s0="_socialText_13y8q_204",o0="_searchWrapper_13y8q_214",a0="_scrollable_13y8q_248",r0="_list_13y8q_64",i0="_listIconWrapper_13y8q_332",c0="_moreIconSmall_13y8q_342",l0="_externalLinkIcon_13y8q_364",u0="_listName_13y8q_368",d0="_listNameMuted_13y8q_381",m0="_recentBadge_13y8q_394",h0="_learnMoreLink_13y8q_408",U={page:U1,pageTop:O1,backButtonFixed:V1,listItem:K1,socialButton:W1,arrowIcon:z1,searchInputUnderline:H1,header:Q1,title:G1,headerSpacer:Y1,icon:Z1,installedText:J1,divider:X1,dividerText:e0,loading:t0,socialIcons:n0,socialText:s0,searchWrapper:o0,scrollable:a0,list:r0,listIconWrapper:i0,moreIconSmall:c0,externalLinkIcon:l0,listName:u0,listNameMuted:d0,recentBadge:m0,learnMoreLink:h0},f0=e=>{try{const t=new URL(e.trim());return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}},p0=({walletConnectors:e,isPending:t,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,c]=_.useState(""),{data:l=[],isError:u,isLoading:m,isFetching:d}=F1(),h=m||d&&l.length===0,f=_.useMemo(()=>{if(!i)return e;const p=i.toLowerCase();return e.filter(y=>y.name.toLowerCase().includes(p))},[e,i]),g=_.useMemo(()=>{const p=new Set(e.map(x=>Rn(x.name))),y=i.toLowerCase();return l.filter(x=>!p.has(Rn(x.name))).filter(x=>!i||x.name.toLowerCase().includes(y)).sort((x,b)=>x.name.localeCompare(b.name))},[l,e,i]);return n.jsxs("div",{className:U.pageTop,children:[n.jsx("button",{type:"button",className:U.backButtonFixed,onClick:r,"aria-label":"Back",children:n.jsx(M.IconBack,{size:16,"aria-hidden":"true"})}),n.jsxs("header",{className:U.header,children:[n.jsx("div",{className:U.headerSpacer}),n.jsx("h1",{className:U.title,children:"All Wallets"}),n.jsx("div",{className:U.headerSpacer})]}),n.jsx("div",{className:U.searchWrapper,children:n.jsx(ys,{rootClassName:U.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:p=>c(p.target.value),onClear:()=>c("")})}),n.jsx(yt,{className:U.scrollable,children:n.jsxs("div",{className:U.list,children:[f.map(p=>{const{name:y,icon:x,id:b}=p,j=o===b,v=s===b,w="ready"in p?!!p.ready:!0;return n.jsxs("button",{type:"button",className:B(U.listItem,{[U.loading]:v}),onClick:()=>a(p),disabled:t||!w,"aria-busy":v,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(re,{src:x,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listName,children:y}),v?n.jsx(It,{size:16}):j?n.jsx("span",{className:U.recentBadge,children:"Recent"}):w?n.jsx("span",{className:U.installedText,children:"Installed"}):null]},`connector:${b}`)}),h&&n.jsxs("div",{className:B(U.listItem,U.loading),role:"status","aria-live":"polite",children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(It,{size:16})}),n.jsx("span",{className:U.listNameMuted,children:"Loading more wallets..."})]}),g.map(p=>{const y=p.image_url?.sm||p.image_url?.md||p.image_url?.lg,x=y&&f0(y)?y:void 0;return n.jsxs("button",{type:"button",className:U.listItem,disabled:!0,"aria-label":`${p.name} (not installed)`,children:[n.jsx("div",{className:U.listIconWrapper,children:x&&n.jsx(re,{src:x,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listNameMuted,children:p.name})]},`wc:${p.id}`)}),u&&n.jsx(we,{level:"error",children:"Couldn't load additional wallets."})]})})]})},g0=(e,t,s,o)=>{if(e.length<=s)return[...e];const a=o?e.findIndex(d=>d.id===o):-1,r=a>=0?e[a]:void 0,i=a>=0?e.filter((d,h)=>h!==a):e,c=new Set(t.map(d=>d.id)),l=new Set(t.map(d=>Rn(d.name))),u=[],m=[];for(const d of i)c.has(d.id)||l.has(Rn(d.name))?u.push(d):m.push(d);return r?[r,...u,...m].slice(0,s):u.concat(m).slice(0,s)},_0=()=>n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"4",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"12",cy:"8",r:"1.5"})]}),y0=()=>n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",children:[n.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"}),n.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"}),n.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"}),n.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"})]}),x0=()=>n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.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"})}),b0=()=>n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),Ur=[{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"}],Or=5,w0=({walletConnectors:e,privyConnector:t,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:c})=>{const l=e.filter(g=>!("ready"in g)||!!g.ready),u=g0(l,Ur,Or,a),m=new Set(l.map(g=>g.id)),d=new Set(l.map(g=>Rn(g.name))),h=Math.max(0,Or-u.length),f=Ur.filter(g=>!m.has(g.id)&&!d.has(Rn(g.name))).slice(0,h);return n.jsxs("div",{className:U.page,children:[n.jsxs("header",{className:U.header,children:[n.jsx("div",{className:U.headerSpacer}),n.jsx("h1",{className:U.title,children:"Sign In"}),n.jsx("div",{className:U.headerSpacer})]}),t&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",className:B(U.socialButton,{[U.loading]:o===t.id}),onClick:()=>r(t),disabled:s,"aria-busy":o===t.id,children:[n.jsx("span",{className:U.socialText,children:"Email / Socials"}),o===t.id?n.jsx(It,{size:16}):n.jsxs("div",{className:U.socialIcons,children:[n.jsx(y0,{}),n.jsx(b0,{}),n.jsx(x0,{})]})]}),n.jsx("div",{className:U.divider,children:n.jsx("span",{className:U.dividerText,children:"or"})})]}),n.jsx(yt,{className:U.scrollable,children:n.jsxs("div",{className:U.list,children:[u.map(g=>{const{icon:p,id:y,name:x,uid:b}=g,j=o===y,v=a===y;return n.jsxs("button",{type:"button",className:B(U.listItem,{[U.loading]:j}),onClick:()=>r(g),disabled:s,"aria-busy":j,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(re,{src:p,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listName,children:x}),j?n.jsx(It,{size:16}):v?n.jsx("span",{className:U.recentBadge,children:"Recent"}):n.jsx("span",{className:U.installedText,children:"Installed"})]},b)}),f.map(g=>n.jsxs("a",{className:U.listItem,href:g.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${g.name} (opens in new tab)`,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(re,{src:g.icon,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listNameMuted,children:g.name}),n.jsx(M.IconExternalLink,{size:10,className:U.externalLinkIcon,"aria-hidden":"true"})]},g.id)),n.jsxs("button",{type:"button",className:U.listItem,onClick:i,onMouseEnter:c,onFocus:c,disabled:s,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx("div",{className:U.moreIconSmall,children:n.jsx(_0,{})})}),n.jsx("span",{className:U.listNameMuted,children:"More wallets"}),n.jsx("span",{className:U.arrowIcon,"aria-hidden":"true",children:"→"})]})]})}),n.jsxs("a",{className:U.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",n.jsx(M.IconExternalLink,{size:14,"aria-hidden":"true"})]})]})},Vr=({onSuccess:e})=>{const{connectors:t,connectAsync:s}=Qe.useConnect(),o=Ge.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=_.useState(null),[i,c]=_.useState("signin"),l=E.useQueryClient(),u=()=>l.prefetchQuery({queryKey:pl,queryFn:({signal:p})=>gl(p),staleTime:V.INFINITY,gcTime:V.INFINITY}),{mutate:m,isPending:d}=E.useMutation({mutationFn:async p=>{try{await s({connector:p})}catch(y){throw await ct(y)}},onMutate:p=>{r(p.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),h=_.useMemo(()=>[...t].sort((p,y)=>p.id===o?-1:y.id===o?1:p.name.localeCompare(y.name)),[t,o]),f=_.useMemo(()=>h.find(p=>p.id===Jn.id),[h]),g=_.useMemo(()=>h.filter(p=>p.id!==Jn.id),[h]);return i==="all"?n.jsx(p0,{walletConnectors:g,isPending:d,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onBack:()=>c("signin")}):n.jsx(w0,{walletConnectors:g,privyConnector:f,isPending:d,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onShowAll:()=>c("all"),onPrefetchWallets:u})},v0="iUSD",Kr="1",j0="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",C0="0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a",k0={[v0]:{externalSourceSymbols:["USDC","AUSD"],extraExternalOptions:[{chainId:Kr,denom:j0},{chainId:Kr,denom:C0}],extraInitiaSourceSymbols:["USDC"],externalChainListSource:"extra-options"}};function Wr(e,t,s){return e.chainId!==t?!1:e.denom.startsWith("0x")&&s.startsWith("0x")?e.denom.toLowerCase()===s.toLowerCase():e.denom===s}function N0(e){return k0[e]}function zr(e){return e.pretty_name||e.chain_name}function Hr(e){return e.chain_type!=="cosmos"||e.bech32_prefix==="init"}const I0={data:[],isLoading:!1,supportedExternalChains:[],appchainSourceSymbols:[],externalSourceSymbols:[],localSymbol:""};function A0({chainIds:e,chains:t}){return Object.fromEntries(e.map(s=>[s,t?.[s]?.denoms??{}]))}const S0={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 bs(e){return S0[e]}function T0(){const e=Fe(),{data:t,error:s}=E.useQuery({queryKey:Ie.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:o})=>o.filter(({chain_type:a,bech32_prefix:r})=>a==="evm"||a==="cosmos"&&r==="init"),staleTime:V.MINUTE});return{chains:t??[],error:s}}function Wa(){const e=Fe(),t=Bn(),s=ie(),{chains:o,error:a}=T0(),r=_.useMemo(()=>o.map(({chain_id:u})=>u),[o]),{data:i,error:c,isLoading:l}=E.useQuery({queryKey:Ie.allBalances(r,[t,s]).queryKey,queryFn:()=>{const u=Object.fromEntries(o.map(m=>[m.chain_id,{address:m.chain_type==="evm"?t:s,denoms:[]}]));return e.post("v2/info/balances",{json:{chains:u}}).json()},select:({chains:u})=>A0({chainIds:r,chains:u}),enabled:!!s&&r.length>0,staleTime:V.SECOND});return{data:i,error:c,isLoading:l,chainsError:a}}function za(){const{localOptions:e=[]}=et(),t=E.useQueryClient(),s=Fe(),{data:o,isLoading:a}=E.useQuery({queryKey:Ie.allAssets().queryKey,queryFn:()=>s.get("v2/fungible/assets").json(),staleTime:V.MINUTE});return{data:_.useMemo(()=>{if(o){const i=Object.values(o.chain_to_assets_map).flatMap(l=>l?.assets??[]),c=new Map(i.map(l=>[`${l.chain_id}:${l.denom}`,l]));return e.map(({denom:l,chainId:u})=>{const m=c.get(`${u}:${l}`);return{denom:l,chain_id:u,symbol:m?.symbol??"",logo_uri:m?.logo_uri??""}})}return e.map(({denom:i,chainId:c})=>{const l=t.getQueryData($n.item(c,i).queryKey);return{denom:i,chain_id:c,symbol:l?.symbol??"",logo_uri:l?.logoUrl??""}})},[e,o,t]),isLoading:a}}function Ha(e){const{local:t}=bs(e),s=ps(),{watch:o}=Jt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function E0(e){const{external:t}=bs(e),s=ps(),{watch:o}=Jt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function _l(e){const t=ps(),s=fo(),o=Bt(),a=Fa(),{data:r,isLoading:i}=Wa(),{remoteOptions:c=[]}=et(),l=Ha(e);if(!l)return{...I0,isLoading:i};const u=N0(l.symbol),m=u?.externalSourceSymbols??[l.symbol],d=c.length>0,h=u?.extraExternalOptions??[],f=u?.extraInitiaSourceSymbols??[],g=u?.externalChainListSource??"supported-assets",p=new Map(s.map(w=>[w.chain_id,w])),y=t.filter(({symbol:w,denom:C,chain_id:I})=>{if(d)return c.some(P=>Wr(P,I,C));const T=h.some(P=>Wr(P,I,C)),A=p.get(I),$=!!A&&a(A.chain_id)&&f.includes(w),N=T||$;return w===l.symbol||N}).map(w=>{if(w.hidden||w.chain_id===l.chain_id)return null;const C=o(w.chain_id);if(!C||!Hr(C))return null;const I=r?.[C.chain_id]?.[w.denom];return{asset:w,chain:C,balance:I}}).filter(w=>w!==null),x=y.filter(({balance:w})=>e!=="deposit"||!!w&&Number(w.amount)>0),b=new Map;if(g==="extra-options")for(const{chainId:w}of h){const C=p.get(w);C&&Hr(C)&&(a(C.chain_id)||b.set(C.chain_id,C))}else for(const{chain:w}of x)a(w.chain_id)||b.set(w.chain_id,w);const j=Array.from(b.values()).sort((w,C)=>zr(w).localeCompare(zr(C))),v=[...new Set(y.filter(({chain:w})=>hg(w,a)).map(({asset:w})=>w.symbol))];return{data:x,isLoading:i,supportedExternalChains:j,appchainSourceSymbols:v,externalSourceSymbols:m,localSymbol:l.symbol}}function Jt(){return $e.useFormContext()}const $0="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",M0="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";function ca(e){return e.length===0?"":e.length===1?e[0]:e.length===2?`${e[0]} or ${e[1]}`:`${e.slice(0,-1).join(", ")}, or ${e[e.length-1]}`}function L0(e,t,s){const o=[...new Set(e)],a=[],r=[...s,t];for(const c of r)o.includes(c)&&!a.includes(c)&&a.push(c);const i=o.filter(c=>!a.includes(c)).sort((c,l)=>c.localeCompare(l));return[...a,...i]}function q0(e,t,s){if(!e.length)return"";const o=L0(e,t,s);return o.length===1&&o[0]===t?"from any app":`using ${ca(o)} from any app`}function R0({localSymbol:e,externalSourceSymbols:t,externalChainNames:s,appchainSourceSymbols:o}){const a=`No ${e} available to deposit.`,r=s.length>0,i=ca(s),c=[...new Set(t)],l=ca(c),u=q0(o,e,c),m=!!u,d=c.length!==1||c[0]!==e;if(r&&m){const h=d?`using ${l} from ${i}`:`from ${i}`;return{title:a,description:`You can deposit ${e} ${h}, or ${u}.`}}return r?d?{title:a,description:`You can deposit ${e} using ${l} from ${i}.`}:{title:a,description:`You can deposit ${e} from ${i}.`}:m?{title:a,description:`You can deposit ${e} ${u}.`}:{title:a,description:"No deposit sources are currently available."}}const P0="_container_pjkfr_1",D0="_title_pjkfr_5",B0="_close_pjkfr_12",F0="_emptyIcon_pjkfr_24",U0="_empty_pjkfr_24",O0="_emptyDescription_pjkfr_39",V0="_list_pjkfr_60",K0="_asset_pjkfr_75",W0="_placeholder_pjkfr_91",z0="_activeAsset_pjkfr_104",H0="_iconContainer_pjkfr_108",Q0="_assetIcon_pjkfr_118",G0="_chainIcon_pjkfr_128",Y0="_assetPlaceholder_pjkfr_142",Z0="_assetName_pjkfr_163",J0="_assetChain_pjkfr_178",X0="_balance_pjkfr_186",e2="_value_pjkfr_195",be={container:P0,title:D0,close:B0,emptyIcon:F0,empty:U0,emptyDescription:O0,list:V0,asset:K0,placeholder:W0,activeAsset:z0,iconContainer:H0,assetIcon:Q0,chainIcon:G0,assetPlaceholder:Y0,assetName:Z0,assetChain:J0,balance:X0,value:e2},t2=({mode:e})=>{const{external:t}=bs(e),{data:s,isLoading:o,supportedExternalChains:a,appchainSourceSymbols:r,externalSourceSymbols:i,localSymbol:c}=_l(e),{setValue:l,watch:u}=Jt(),m=Ha(e),{data:d}=za(),{theme:h}=se(),f=u(),g=f[t.denomKey],p=f[t.chainIdKey],x=!o&&s.length===1?`${s[0].chain.chain_id}:${s[0].asset.denom}`:"";function b(w,C){l(t.denomKey,w),l(t.chainIdKey,C),e==="deposit"&&l("quantity",""),l("page","fields")}const j=_.useEffectEvent(()=>{if(!x)return;const[{asset:w,chain:C}]=s;if(g===w.denom&&p===C.chain_id){l("page","fields");return}b(w.denom,C.chain_id)});_.useEffect(()=>{j()},[x]);function v(){const w=g&&p;return!w&&d.length<=1&&e==="deposit"?null:n.jsx("button",{className:be.close,onClick:()=>{e==="withdraw"||w?l("page","fields"):l("page","select-local")},children:n.jsx(M.IconBack,{size:20})})}if(!m)return n.jsx("div",{children:"No assets found"});if(!o&&!s.length){const w=a.map(T=>T.pretty_name||T.chain_name).filter(T=>!!T),C=R0({localSymbol:c,externalSourceSymbols:i,externalChainNames:w,appchainSourceSymbols:r}),I=e==="withdraw"?`No supported destinations to withdraw ${m.symbol}.`:C.title;return n.jsxs("div",{className:be.container,children:[v(),n.jsx("h4",{className:be.title,children:"No available assets"}),n.jsx("img",{src:h==="dark"?$0:M0,alt:"No assets",className:be.emptyIcon}),n.jsx("p",{className:be.empty,children:I}),e==="deposit"&&n.jsx("p",{className:be.emptyDescription,children:C.description})]})}return n.jsxs("div",{className:be.container,children:[v(),n.jsxs("h4",{className:be.title,children:[e==="withdraw"?"Select destination":`Deposit ${m.symbol}`," "]}),n.jsxs("div",{className:be.list,children:[o&&Array.from({length:5}).map((w,C)=>n.jsxs("div",{className:B(be.asset,be.placeholder),children:[n.jsxs("div",{className:be.iconContainer,children:[n.jsx("div",{className:be.assetIcon}),n.jsx("div",{className:be.chainIcon})]}),n.jsx("div",{className:be.assetPlaceholder})]},C)),!o&&s.sort(({balance:w},{balance:C})=>Number(C?.value_usd??0)-Number(w?.value_usd??0)).map(({asset:w,chain:C,balance:I})=>{const T=g===w.denom&&p===C.chain_id,A=Ba(I?.value_usd,I?.price);return n.jsxs("button",{className:B(be.asset,T&&be.activeAsset),onClick:()=>b(w.denom,C.chain_id),children:[n.jsxs("div",{className:be.iconContainer,children:[n.jsx("img",{src:w.logo_uri,alt:w.symbol,className:be.assetIcon}),n.jsx("img",{src:C.logo_uri||"",alt:C.chain_name,className:be.chainIcon})]}),n.jsxs("p",{className:be.assetName,children:[w.symbol," ",T&&n.jsx("span",{children:n.jsx(M.IconCheck,{size:16})})]}),n.jsxs("p",{className:be.assetChain,children:["on ",C.pretty_name]}),I&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:be.balance,children:k.formatAmount(I.amount,{decimals:I.decimals||6})}),n.jsx("p",{className:be.value,children:A})]})]},`${w.chain_id}-${w.denom}`)})]})]})},n2="_title_iequo_1",s2="_list_iequo_7",o2="_asset_iequo_15",a2="_imgPlaceholder_iequo_40",$s={title:n2,list:s2,asset:o2,imgPlaceholder:a2},r2=({mode:e})=>{const{local:t,external:s}=bs(e),{setValue:o}=Jt(),{data:a,isLoading:r}=za(),[i,c]=_.useTransition(),l=(m,d)=>{o(t.denomKey,m),o(t.chainIdKey,d),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),c(()=>{o("page",e==="withdraw"?"fields":"select-external")})},u=_.useEffectEvent(()=>{const{denom:m,chain_id:d}=a[0];l(m,d)});return _.useEffect(()=>{!r&&a.length===1&&u()},[a,r]),a.length?n.jsxs(n.Fragment,{children:[n.jsx("h3",{className:$s.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),n.jsx("div",{className:$s.list,"aria-busy":i,children:a.map(({denom:m,chain_id:d,symbol:h,logo_uri:f})=>n.jsxs("button",{className:$s.asset,onClick:()=>l(m,d),disabled:i,children:[f?n.jsx("img",{src:f,alt:h}):n.jsx("div",{className:$s.imgPlaceholder,"aria-hidden":"true"}),h]},`${m}-${d}`))})]}):n.jsx("div",{children:"No assets found"})},i2="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",c2="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",l2="_container_9k4hs_1",u2="_title_9k4hs_8",d2="_subtitle_9k4hs_14",m2="_linkContainer_9k4hs_30",h2="_link_9k4hs_30",f2="_separator_9k4hs_51",p2="_errorIcon_9k4hs_62",g2="_error_9k4hs_62",De={container:l2,title:u2,subtitle:d2,linkContainer:m2,link:h2,separator:f2,errorIcon:p2,error:g2};function _2(e){if(!e)return"pending";const t=e.state;return t==="STATE_COMPLETED_SUCCESS"?"success":t==="STATE_ABANDONED"||t==="STATE_COMPLETED_ERROR"||t==="STATE_PENDING_ERROR"?"failed":"pending"}function la({type:e}){const{closeModal:t}=Dn(),{theme:s}=se(),{watch:o}=Jt(),{result:a}=o(),{openDrawer:r}=Dt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,c=i?"":a.txhash,l=i?"":a.chainId,u=i?0:a.timestamp??0,{route:m,values:d}=a,{srcDenom:h,srcChainId:f,quantity:g}=d,p=At(h,f),y=e==="deposit"?"Deposit":"Withdraw",{data:x}=ol({chainId:l,txHash:c,tracked:!1}),{data:b}=al({chainId:l,txHash:c,tracked:!!x,timestamp:u,route:m}),j=_2(b),v=s==="dark"?i2:c2,w=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,C=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return n.jsxs("div",{className:De.container,children:[n.jsxs("h3",{className:De.title,children:[y," failed"]}),n.jsx("img",{src:v,alt:"Failed",className:De.errorIcon}),n.jsx("p",{className:De.error,children:a?.error}),n.jsx(fe.White,{fullWidth:!0,onClick:t,children:"Close"})]});const I=ss(m.estimated_route_duration_seconds),T=new URLSearchParams({tx_hash:c,chain_id:l}),A=new URL(`?${T.toString()}`,"https://explorer.skip.build"),$=()=>n.jsxs("div",{className:De.linkContainer,children:[n.jsx("a",{href:A.toString(),target:"_blank",rel:"noopener noreferrer",className:De.link,children:"View transaction"}),n.jsx("div",{className:De.separator}),n.jsx("button",{className:De.link,onClick:()=>{t(),r("/bridge/history")},children:"Go to history"})]});return n.jsxs("div",{className:De.container,children:[j==="pending"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:De.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",g," ",p.symbol]}),n.jsx("video",{src:w,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),n.jsxs("p",{className:De.subtitle,children:["Estimated time: ",n.jsx("span",{children:I})]}),$(),n.jsx("p",{className:De.subtitle,children:"Your transaction will continue even if you close this"})]}),j==="success"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:De.title,children:[y," complete"]}),n.jsx("video",{src:C,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:N=>{const S=N.currentTarget;S.duration-S.currentTime<.1&&S.pause()}}),$(),n.jsx(fe.White,{fullWidth:!0,onClick:t,children:"Close"})]}),j==="failed"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:De.title,children:[y," failed"]}),n.jsx("img",{src:v,alt:"Failed",className:De.errorIcon}),n.jsx("p",{className:De.error,children:"Your transaction could not be completed"}),n.jsx(fe.White,{fullWidth:!0,onClick:t,children:"Close"})]})]})}const y2=qe.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),x2=({tx:e,children:t})=>{const{values:s}=xt(),{srcChainId:o}=s,a=ie(),r=cs(),i=bn(),c=us(),{data:l,isLoading:u,isFetching:m}=E.useQuery({queryKey:y2.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const f=xo(e.cosmos_tx.msgs,{converters:r,fromAmino:i.fromAmino.bind(i)});return{estimatedGas:await(await c(o)).simulate(a,f,""),messages:f}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if("cosmos_tx"in e&&!l&&u)return n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Estimating gas...",disabled:!0,fullWidth:!0})});const d=l?.estimatedGas??null,h="cosmos_tx"in e&&(u||m);return n.jsx(n.Fragment,{children:t(d,{isEstimatingGas:h})})};function b2(e,t){return e?k.InitiaAddress(e).hex:t}function w2({currentState:e,route:t,quoteVerifiedAt:s,hexAddress:o,values:a}){return{...e,route:t,quoteVerifiedAt:s,values:{sender:o,recipient:b2(e.recipientAddress,o),slippagePercent:"0.1",...a}}}function v2({hasBalancesSnapshot:e,hasBalanceQueryError:t,isBalancesLoading:s}){if(!e){if(s)return"loading";if(t)return"error"}}function j2({hasBalancesSnapshot:e,balance:t}){if(e)return t??"0"}function Qr(e){if(!e)return null;const t=q(e);return!t.isFinite()||t.lt(0)?null:t}function C2({balance:e,requiredAmount:t}){if(t==="0")return!0;const s=Qr(e??"0"),o=Qr(t);return!s||!o?!1:s.gte(o)}function k2({sourceDenom:e,feeDetailsByDenom:t}){const s=t.get(e);if(!s||s.isSufficient)return;for(const[a,r]of t)if(a!==e&&r.isSufficient)return;if(q(s.balance).gte(s.fee))return"Make sure to leave enough for transaction fee"}function N2({feeDenom:e,sourceDenom:t,feeWarning:s,hasSourceBalance:o,isFeeBalanceSufficient:a}){if(!o)return{error:"Insufficient balance"};const r=e===t?s:void 0;return r?{warning:r}:a?{}:{error:"Insufficient balance"}}const I2="_container_11kmm_1",A2="_back_11kmm_6",S2="_title_11kmm_18",T2="_divider_11kmm_26",E2="_label_11kmm_30",$2="_asset_11kmm_37",M2="_assetIcon_11kmm_55",L2="_chainIcon_11kmm_67",q2="_assetName_11kmm_80",R2="_chevron_11kmm_92",P2="_input_11kmm_96",D2="_balanceContainer_11kmm_108",B2="_value_11kmm_116",F2="_maxButton_11kmm_126",U2="_detail_11kmm_142",O2="_detailsContainer_11kmm_153",V2="_detailsButton_11kmm_163",K2="_expandableDetails_11kmm_184",W2="_detailValue_11kmm_192",z2="_detailToken_11kmm_202",H2="_receiveSummary_11kmm_210",Y={container:I2,back:A2,title:S2,divider:T2,label:E2,asset:$2,assetIcon:M2,chainIcon:L2,assetName:q2,chevron:R2,input:P2,balanceContainer:D2,value:B2,maxButton:F2,detail:U2,detailsContainer:O2,detailsButton:V2,expandableDetails:K2,detailValue:W2,detailToken:z2,receiveSummary:H2},yl=({renderFee:e})=>{const{route:t}=et(),{values:s}=xt(),{dstDenom:o,dstChainId:a}=s,i=ps().find(({denom:g,chain_id:p})=>g===o&&p===a),c=ie(),l=Tc(),[u,m]=Ge.useToggle(!1),d=_.useId(),h=t&&t.estimated_route_duration_seconds>60;if(!t||!i)return null;const f=Qc(t.amount_out,s.slippagePercent);return n.jsxs("div",{className:Y.detailsContainer,children:[n.jsxs("div",{children:[n.jsxs("button",{type:"button",className:Y.detailsButton,onClick:m,"aria-expanded":u,"aria-controls":d,children:["Transaction details"," ",n.jsx(M.IconChevronDown,{size:12,style:{transform:u?"rotate(180deg)":"rotate(0deg)"},"aria-hidden":"true"})]}),n.jsx(ts,{children:n.jsx("div",{id:d,children:u&&n.jsxs("div",{className:Y.expandableDetails,children:[t.does_swap&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Slippage"}),n.jsxs("p",{className:Y.detailValue,children:[s.slippagePercent,"%"]})]}),!!t.estimated_fees?.length&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Bridge fee"}),n.jsx("div",{className:Y.detailValue,children:Oa(t.estimated_fees)})]}),e&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Tx fee"}),n.jsx("div",{className:Y.detailValue,children:e()})]}),c&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Receiving address"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:l,alt:"Wallet",height:12,width:12})," ",k.truncate(c)]})]}),t.does_swap&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Minimum received"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Y.detailToken})," ",k.formatAmount(f,{decimals:i.decimals})," ",i.symbol]})]})]})})})]}),n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Estimated time"}),n.jsx("p",{className:Y.detailValue,style:h?{color:"var(--warning)"}:void 0,children:ss(t.estimated_route_duration_seconds)})]}),n.jsxs("div",{className:B(Y.detail,Y.receiveSummary),children:[n.jsx("p",{className:Y.detailLabel,children:"Estimated received"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Y.detailToken})," ",k.formatAmount(t.amount_out,{decimals:i.decimals})," ",i.symbol]})]})]})},Q2="_trigger_1c7d7_1",G2="_item_1c7d7_5",Y2="_itemText_1c7d7_13",Z2={trigger:Q2,item:G2,itemText:Y2};function J2(e){return!e.isFetchingMessages&&!e.messageRefreshError}function xl(e,t,s){return J2(s)?n.jsx(ul,{tx:e,children:t}):t}function X2({feeDetailsByDenom:e,feeOptions:t,lastUsedFeeDenom:s,preferredFeeDenom:o}){if(o&&e.get(o)?.isSufficient)return o;if(s&&e.get(s)?.isSufficient)return s;for(const a of t){const[{denom:r}]=a.amount;if(e.get(r)?.isSufficient)return r}return t[0]?.amount[0].denom}const eb=({tx:e,gas:t,confirmMessage:s,onCompleted:o,messageRefreshError:a,isRouteTransitioning:r,isFetchingMessages:i,isEstimatingGas:c})=>{const{values:l}=xt(),{srcChainId:u,srcDenom:m,quantity:d}=l,f=ps().find(({denom:Q,chain_id:ee})=>Q===m&&ee===u),g=_t(u),p=as(g),y=Na(g),x=Ia(g),b=St(g),j=t==null?[]:y.map(({amount:Q,denom:ee})=>Le.calculateFee(Math.ceil(t*Ht),Le.GasPrice.fromString(Q+ee))),v=new Map(j.map(Q=>{const[{denom:ee}]=Q.amount;return[ee,Q]})),w=new Map(p.map(({denom:Q,amount:ee})=>[Q,ee])),C=f?q(d||"0").times(q(10).pow(f.decimals)).toFixed(0):"0",I=new Map(j.map(Q=>{const[{amount:ee,denom:ue}]=Q.amount,ye=w.get(ue)??"0",me=f&&m===ue?C:"0",Ce=q(ee).plus(me),{symbol:Se,decimals:ke}=b(ue);return[ue,{symbol:Se,decimals:ke,spend:q(me).gt(0)?me:null,fee:ee,total:Ce.toFixed(),balance:ye,isSufficient:q(ye).gte(Ce)}]})),[T,A]=_.useState(null),$={isRouteTransitioning:r,isFetchingMessages:i,isEstimatingGas:c,messageRefreshError:a},N=X2({feeDetailsByDenom:I,feeOptions:j,lastUsedFeeDenom:x,preferredFeeDenom:T}),S=N?v.get(N):void 0,P=N?I.get(N):null,F=k2({sourceDenom:m,feeDetailsByDenom:I}),D=C2({balance:w.get(m)??"0",requiredAmount:C}),Z=N2({feeDenom:N,sourceDenom:m,feeWarning:F,hasSourceBalance:D,isFeeBalanceSufficient:P?.isSufficient??!0}),K=n.jsx(Ka,{tx:e,fee:S,onCompleted:o,confirmMessage:s,error:Z.error,warning:Z.warning,...$}),W=(Q,ee)=>{if(k.formatAmount(Q,{decimals:ee})==="0.000000")return 8},O=Q=>{const[{amount:ee,denom:ue}]=Q.amount;if(q(ee).isZero())return"0";const{symbol:ye,decimals:me}=b(ue),Ce=W(ee,me);return`${k.formatAmount(ee,{decimals:me,dp:Ce})} ${ye}`},J=()=>{if(j.length===0)return null;if(j.length===1)return n.jsx("span",{className:"monospace",children:O(j[0])});if(!S||!N)return null;const Q=j.map(Ce=>{const[{denom:Se}]=Ce.amount,{symbol:ke}=b(Se);return{value:Se,label:O(Ce),triggerLabel:ke}}),[{amount:ee,denom:ue}]=S.amount,{decimals:ye}=b(ue),me=W(ee,ye);return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{className:"monospace",children:k.formatAmount(ee,{decimals:ye,dp:me})}),n.jsx(Da,{options:Q,value:N,onChange:A,classNames:Z2})]})};return n.jsxs(n.Fragment,{children:[n.jsx(yl,{renderFee:j.length>0?J:void 0}),xl(e,K,$)]})},tb=({tx:e,gas:t,mode:s,messageRefreshError:o,isRouteTransitioning:a,isFetchingMessages:r,isEstimatingGas:i})=>{const{setValue:c}=Jt(),l={isRouteTransitioning:a,isFetchingMessages:r,isEstimatingGas:i,messageRefreshError:o},u=h=>{c("page","completed"),c("result",h)},m=s==="withdraw"?"Withdraw":"Deposit",d=n.jsx(Ka,{tx:e,fee:void 0,onCompleted:u,confirmMessage:m,...l});return"cosmos_tx"in e?n.jsx(eb,{tx:e,gas:t,onCompleted:u,confirmMessage:m,...l}):n.jsxs(n.Fragment,{children:[n.jsx(yl,{}),xl(e,d,l)]})};function Gr(e){const t=e.values;return{recipient:t?.recipient,sender:t?.sender}}function nb({currentState:e,nextState:t}){if(e.route!==t.route||e.quoteVerifiedAt!==t.quoteVerifiedAt)return!0;const s=Gr(e),o=Gr(t);return s.sender!==o.sender||s.recipient!==o.recipient}function sb({disabledMessage:e,routeForState:t,routeError:s,isNoRouteError:o,isServerError:a}){return e?"disabled":t?"ready":s?o?"no-route":a?"server-error":"refresh-failed":"loading"}function ob({hasRouteState:e,routeStatus:t}){return e&&(t==="ready"||t==="loading")}function ab({routeStatus:e,disabledMessage:t,isRouteSynced:s}){if(e==="disabled")return t;if(e==="loading"||e==="ready"&&!s)return"Fetching route...";if(e==="no-route")return"No route found";if(e==="server-error")return"Server error";if(e==="refresh-failed")return"Failed to refresh route"}const rb=typeof window>"u"?_.useEffect:_.useLayoutEffect,ib=({mode:e})=>{const t=bs(e),s=Me(),o=et(),{data:a}=za(),r=Bt(),{data:i,error:c,chainsError:l,isLoading:u}=Wa(),m=Bn(),{watch:d,setValue:h,getValues:f}=Jt(),g=d(),{srcChainId:p,srcDenom:y,quantity:x=""}=g,{recipientAddress:b,route:j}=o,v=g[t.external.denomKey],w=g[t.external.chainIdKey],C=Ha(e),I=E0(e),{data:T,isLoading:A}=_l(e),$=!A&&T.length===1,N=e==="withdraw"&&!A&&T.length>0&&new Set(T.map(({chain:X})=>X.chain_id)).size===1,S=_.useMemo(()=>A||!T.length?null:$?T[0]:N?T.reduce((X,ve)=>{const Oe=Number(X.balance?.value_usd??0);return Number(ve.balance?.value_usd??0)>Oe?ve:X},T[0]):null,[T,$,N,A]),P=S?`${S.chain.chain_id}:${S.asset.denom}`:"",F=w?r(w):null,D=i?.[p]?.[y]?.amount,Z=i?.[p]?.[y]?.price,K=q(Z??0).times(x||0),[W]=Ge.useDebounceValue(x,300),O=e==="withdraw"?C:I,J=v2({hasBalancesSnapshot:i!==void 0,hasBalanceQueryError:!!(c||l),isBalancesLoading:u}),Q=j2({hasBalancesSnapshot:i!==void 0,balance:D}),ee=_.useMemo(()=>{if(e==="deposit"&&!I)return"Select asset";const X=q(x||0);if(!X.isFinite()||X.lte(0))return"Enter amount";if(e==="withdraw"&&!I)return"Select destination";if(J==="loading")return"Loading balances...";if(J==="error")return"Failed to load balances";if(Q!==void 0){const ve=k.fromBaseUnit(Q,{decimals:O?.decimals||6});if(X.gt(ve))return"Insufficient balance"}},[O,Q,J,I,e,x]),ue=_.useMemo(()=>{if(e==="deposit"&&!I)return!0;const X=q(x||0);if(!X.isFinite()||X.lte(0)||e==="withdraw"&&!I||J==="error")return!0;if(Q!==void 0){const ve=k.fromBaseUnit(Q,{decimals:O?.decimals||6});if(X.gt(ve))return!0}return!1},[O,Q,J,I,e,x]),{data:ye,error:me,dataUpdatedAt:Ce}=sa(W,{disabled:ue}),Se=me instanceof z.HTTPError&&me.response.status===400,ke=!ee&&!Se?ye:void 0,Et=ke&&Ce>0?Ce:void 0,ut=me instanceof z.HTTPError&&me.response.status===500,Re=sb({disabledMessage:ee,routeForState:ke,routeError:me,isNoRouteError:Se,isServerError:ut}),le=Re==="ready"&&o.route===ke,G=Re==="loading"||Re==="ready"&&!le,$t=ob({hasRouteState:!!o.route,routeStatus:Re}),Xt=ab({routeStatus:Re,disabledMessage:ee,isRouteSynced:le});rb(()=>{const X=w2({currentState:o,route:ke,quoteVerifiedAt:Et,hexAddress:m,values:f()});nb({currentState:o,nextState:X})&&s(0,X)},[j,f,m,s,Et,b,ke]);const Mt=_.useEffectEvent(()=>{if(!S||v&&w)return;const{asset:X,chain:ve}=S;h(t.external.denomKey,X.denom),h(t.external.chainIdKey,ve.chain_id),e==="deposit"&&h("quantity","")});if(_.useEffect(()=>{Mt()},[P]),!C||e==="deposit"&&!I)return null;const bt=O?.decimals||6,en=e==="withdraw"?"Select chain":"Select asset",dt=()=>{h("quantity",""),h(t.external.denomKey,""),h(t.external.chainIdKey,""),(e==="withdraw"||$)&&(h(t.local.denomKey,""),h(t.local.chainIdKey,"")),h("page",e==="withdraw"||$?"select-local":"select-external")},Ue=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:Y.label,children:e==="withdraw"?"Destination":"From"}),n.jsxs("button",{className:Y.asset,disabled:$,onClick:()=>h("page","select-external"),children:[n.jsx("div",{className:Y.assetIcon,children:I?n.jsxs(n.Fragment,{children:[n.jsx("img",{src:I.logo_uri,alt:I.symbol}),n.jsx("img",{src:F?.logo_uri||"",alt:F?.pretty_name,className:Y.chainIcon})]}):e==="withdraw"&&n.jsx("div",{className:Y.chainIcon})}),n.jsx("p",{className:Y.assetName,children:I?n.jsxs(n.Fragment,{children:[I.symbol,n.jsx("br",{}),n.jsxs("span",{children:["on ",F?.pretty_name]})]}):en}),!$&&n.jsx(M.IconChevronDown,{className:Y.chevron,size:16})]})]}),nt=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:Y.label,children:"Amount"}),n.jsx(ns,{balance:Q,decimals:bt,className:Y.input}),Q!==void 0&&n.jsxs("div",{className:Y.balanceContainer,children:[n.jsx("p",{className:Y.value,children:x?Ba(K.toString(),Z):"$-"}),n.jsxs("button",{className:Y.maxButton,onClick:()=>{const X=k.fromBaseUnit(Q,{decimals:bt});q(x||0).eq(X)||h("quantity",X)},children:[n.jsx(M.IconWallet,{size:16})," ",k.formatAmount(Q,{decimals:bt})," ",n.jsx("span",{children:"MAX"})]})]})]});return n.jsxs("section",{className:Y.container,"aria-label":"Transfer form",children:[a.length>1&&n.jsx("button",{type:"button","aria-label":"Back",className:Y.back,onClick:dt,children:n.jsx(M.IconBack,{size:20})}),n.jsxs("h3",{className:Y.title,children:[t.label," ",C.symbol]}),e==="withdraw"?n.jsxs(n.Fragment,{children:[nt,n.jsx("div",{className:Y.divider}),Ue]}):n.jsxs(n.Fragment,{children:[Ue,n.jsx("div",{className:Y.divider}),nt]}),(l||c)&&n.jsx(je,{error:!0,children:"Failed to load balances"}),$t?n.jsx(ll,{children:X=>n.jsx(ml,{children:ve=>n.jsx(dl,{addressList:X,signedOpHook:ve,children:(Oe,{isFetchingMessages:mt,messageRefreshError:jo})=>n.jsx(x2,{tx:Oe,children:(ws,{isEstimatingGas:Co})=>n.jsx(xe,{suspenseFallback:n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Estimating gas...",disabled:!0,fullWidth:!0})}),children:n.jsx(tb,{tx:Oe,gas:ws,mode:e,isRouteTransitioning:G,isFetchingMessages:mt,isEstimatingGas:Co,messageRefreshError:jo})})})})})}):n.jsx(Ae,{children:n.jsx(fe.White,{type:"submit",loading:G&&"Fetching route...",disabled:!0,fullWidth:!0,children:Xt})})]})},cb="_container_7nl9j_1",lb="_page_7nl9j_5",Yr={container:cb,page:lb},bl=({mode:e})=>{const t=$e.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Wa(),n.jsx($e.FormProvider,{...t,children:n.jsx(ub,{mode:e})})},ub=({mode:e})=>{const{watch:t}=Jt(),s=t("page"),o=Nt.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 n.jsx(r2,{mode:e});case"select-external":return n.jsx(t2,{mode:e});case"fields":return n.jsx(ib,{mode:e});case"completed":return n.jsx(la,{type:e})}};return n.jsx(ts,{children:n.jsx("div",{className:Yr.container,children:o((r,i)=>n.jsx(Nt.animated.div,{style:r,className:Yr.page,children:a(i)}))})})},db=()=>n.jsx(bl,{mode:"deposit"}),mb=()=>n.jsx(bl,{mode:"withdraw"}),hb="_root_1lo0i_1",fb="_address_1lo0i_9",pb="_copy_1lo0i_19",gb="_labelWrapper_1lo0i_33",_b="_labelCopy_1lo0i_43",yb="_labelCopied_1lo0i_47",xb="_copied_1lo0i_55",bb="_derived_1lo0i_65",wb="_derivedLabel_1lo0i_79",vb="_derivedAddress_1lo0i_83",jb="_hexAddress_1lo0i_89",Cb="_derivedCopy_1lo0i_94",Ke={root:hb,address:fb,copy:pb,labelWrapper:gb,labelCopy:_b,labelCopied:yb,copied:xb,derived:bb,derivedLabel:wb,derivedAddress:vb,hexAddress:jb,derivedCopy:Cb},kb=()=>{const e=_.useRef(null),t=_.useRef(null),{initiaAddress:s,hexAddress:o}=tt(),a=Ac("--gray-0");return _.useEffect(()=>{e.current&&(t.current?t.current.update({data:s}):(t.current=new Hl({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"}}),t.current.append(e.current)))},[s,a]),n.jsx(Tt,{title:"Receive",children:n.jsxs("div",{className:Ke.root,children:[n.jsx("div",{ref:e,style:{width:200,height:200}}),n.jsx("span",{className:Ke.address,children:s}),n.jsx(Ws,{value:s,children:({copy:r,copied:i})=>n.jsxs("button",{className:B(Ke.copy,{[Ke.copied]:i}),onClick:r,"aria-label":i?"Copied":"Copy address",children:[n.jsx(M.IconCopy,{size:12,"aria-hidden":"true"}),n.jsxs("div",{className:Ke.labelWrapper,children:[n.jsx("span",{className:Ke.labelCopy,children:"Copy address"}),n.jsx("span",{className:Ke.labelCopied,children:"Copied!"})]})]})}),n.jsx(Ws,{value:o,children:({copy:r,copied:i})=>n.jsxs("button",{className:B(Ke.derived,{[Ke.copied]:i}),onClick:r,"aria-label":i?"Copied":"Copy derived address",children:[n.jsx("span",{className:Ke.derivedLabel,children:"Derived from"}),n.jsxs("span",{className:Ke.derivedAddress,children:[n.jsx("span",{className:Ke.hexAddress,children:k.truncate(o)}),n.jsx(M.IconCopy,{size:12,className:Ke.derivedCopy,"aria-hidden":"true"}),i&&n.jsx("span",{className:Ke.copiedText,children:"Copied!"})]})]})})]})})};function Nb(e,t){return t==null?e:e.filter(s=>s.grantee===t)}function Ib(){const e=ie(),t=_e();return E.useQueries({queries:t.map(s=>({queryKey:Vs.grants(s.chainId,e).queryKey,queryFn:async()=>{const o=await Js(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:s.restUrl},"grants"),a=Qi(o),r=e?ba(e,s.chainId):null,i=Nb(a,r);return{chainId:s.chainId,grants:i}},enabled:!!e,staleTime:V.SECOND,retry:!1}))})}const Ab="_countdown_vfms8_1",Sb={countdown:Ab},Tb=({expiration:e})=>{const t=()=>{const a=new Date,r=Xe.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),c=Math.floor(r%(1440*60)/3600),l=Math.floor(r%3600/60),u=r%60,m=[];return i>0&&m.push(`${i}d`),(c>0||i>0)&&m.push(`${c}h`),(l>0||c>0||i>0)&&m.push(`${l}m`),m.push(`${u}s`),m.join(" ")},[s,o]=_.useState(t());return Ge.useInterval(()=>{o(t())},1e3),Xe.isPast(e)?"Expired":n.jsxs(n.Fragment,{children:["Expires in ",n.jsx("span",{className:Sb.countdown,children:s})]})},Eb="_container_1l528_1",$b="_info_1l528_11",Mb="_header_1l528_17",Lb="_chainName_1l528_23",qb="_expiration_1l528_29",Rb="_revokeButton_1l528_35",kn={container:Eb,info:$b,header:Mb,chainName:Lb,expiration:qb,revokeButton:Rb},Pb=({chainId:e,grantee:t,expiration:s})=>{const o=_t(e),{mutate:a,isPending:r}=lc({grantee:t,internal:!0});return n.jsxs("div",{className:kn.container,children:[n.jsxs("div",{className:kn.info,children:[n.jsxs("div",{className:kn.header,children:[n.jsx(re,{src:o.logoUrl,width:16,height:16,logo:!0}),n.jsx("div",{className:kn.chainName,children:o.name})]}),n.jsx("div",{className:kn.expiration,children:s?n.jsx(Tb,{expiration:s}):"Until revoked"})]}),n.jsx("button",{className:kn.revokeButton,onClick:()=>a(e),disabled:r,"aria-busy":r,children:r?"Revoking...":"Revoke"})]})},Db=({chainId:e,grants:t})=>{const s=new Map;for(const a of t){const r=s.get(a.grantee),i=a.expiration?new Date(a.expiration):void 0;if(!r){s.set(a.grantee,{grantee:a.grantee,expiration:i});continue}r.expiration=Ca([r.expiration,i])}return[...s.values()].map(a=>_.createElement(Pb,{...a,chainId:e,key:a.grantee}))},Bb="_content_q36qs_1",Fb={content:Bb},Ub=()=>{const e=Ib(),t=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?n.jsx(je,{children:"No permissions found"}):n.jsx("div",{className:Fb.content,children:s.map(({chainId:o,grants:a})=>n.jsx(Db,{chainId:o,grants:a},o))})};return n.jsx(Tt,{title:"Manage auto-signing",backButton:"/settings",children:t()})},Ob="_version_1sf5y_1",Vb={version:Ob},Kb=()=>n.jsxs("aside",{className:Vb.version,children:["v","2.6.0"]}),Wb="_link_se23z_1",zb="_title_se23z_17",Hb="_subtitle_se23z_23",Qb="_icon_se23z_30",Ms={link:Wb,title:zb,subtitle:Hb,icon:Qb},wl=({title:e,subtitle:t,rightSection:s,onClick:o})=>n.jsxs("button",{className:Ms.link,onClick:o,children:[n.jsxs("div",{children:[n.jsx("p",{className:Ms.title,children:e}),t&&n.jsx("p",{className:Ms.subtitle,children:t})]}),n.jsx("div",{className:Ms.icon,children:s??n.jsx(M.IconChevronRight,{size:16,"aria-hidden":"true"})})]}),Gb="https://export.initia.xyz/",Yb=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return n.jsx(wl,{title:"Export private key",rightSection:n.jsx(M.IconExternalLink,{size:16}),onClick:()=>window.open(Gb,"_blank",e)})},Zb="_container_1vxr7_1",Jb="_separator_1vxr7_7",Zr={container:Zb,separator:Jb},Xb=()=>{const e=Me(),{connector:t}=Qe.useAccount();return n.jsx(Tt,{title:"Settings",backButton:"/",children:n.jsxs("div",{className:Zr.container,children:[n.jsx(wl,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),t?.id===pa&&n.jsx(Yb,{}),n.jsx(Rt.Separator,{className:Zr.separator}),n.jsx(Kb,{})]})})},ew="_trigger_1yjkd_1",tw="_icon_1yjkd_23",nw="_full_1yjkd_27",sw="_triggerContent_1yjkd_32",ow="_triggerText_1yjkd_40",aw="_popoverBackdrop_1yjkd_51",rw="_popoverPositioner_1yjkd_70",iw="_popoverPopup_1yjkd_74",cw="_search_1yjkd_99",lw="_viewport_1yjkd_105",uw="_item_1yjkd_111",dw="_highlighted_1yjkd_127",mw="_active_1yjkd_131",hw="_itemContent_1yjkd_136",fw="_extra_1yjkd_142",pw="_connectedTag_1yjkd_149",Ee={trigger:ew,icon:tw,full:nw,triggerContent:sw,triggerText:ow,popoverBackdrop:aw,popoverPositioner:rw,popoverPopup:iw,search:cw,viewport:lw,item:uw,highlighted:dw,active:mw,itemContent:hw,extra:fw,connectedTag:pw},vo=({value:e,onChange:t,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=se(),[i,c]=_.useState(""),[l,u]=_.useState(!1),[m,d]=_.useState(0),[h,f]=_.useState(),g=_.useRef([]),p=_.useRef(null),y=_e(),x=s.map(N=>y.find(S=>S.chainId===N)).filter(Boolean),b=N=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:N,height:N,viewBox:"0 0 14 14",children:[n.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"}),n.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"})]}),j=_.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),v=_.useMemo(()=>{const N=[j,...x];if(!i)return N;const S=i.toLowerCase();return N.filter(P=>P.name.toLowerCase().includes(S)||P.chainId.toLowerCase().includes(S))},[x,i,j]),w=x.find(N=>N.chainId===e)||j,C=parseInt(Ac("--drawer-offset")),I=6,T=()=>{if(c(""),d(-1),p.current){const S=p.current.getBoundingClientRect().bottom+I,P=window.innerHeight-S-2*C;f(P)}u(!0)};_.useEffect(()=>{m>=0&&m<g.current.length&&g.current[m]?.scrollIntoView({block:"nearest",behavior:"auto"})},[m]);const A=_.useCallback(N=>{switch(N.key){case"ArrowDown":N.preventDefault(),d(S=>(S+1)%v.length);break;case"ArrowUp":N.preventDefault(),d(S=>(S-1+v.length)%v.length);break;case"Enter":N.preventDefault(),v[m]&&(t(v[m].chainId),u(!1));break;case"Escape":N.preventDefault(),u(!1);break}},[v,m,t,u]),$=N=>{t(N),u(!1)};return n.jsxs(jn.Popover.Root,{open:l,onOpenChange:T,modal:"trap-focus",children:[n.jsx(jn.Popover.Trigger,{render:n.jsxs("button",{className:B(Ee.trigger,{[Ee.full]:a}),"aria-expanded":l,role:"listbox",ref:p,children:[n.jsxs("div",{className:Ee.triggerContent,children:[typeof w.logoUrl=="string"?n.jsx(re,{src:w.logoUrl,width:14,height:14,logo:!0}):w.logoUrl(14),n.jsx("span",{className:Ee.triggerText,children:w.name})]}),n.jsx(M.IconChevronDown,{size:16,className:Ee.icon})]})}),n.jsxs(jn.Popover.Portal,{container:_n(),children:[n.jsx(jn.Popover.Backdrop,{className:Ee.popoverBackdrop,onClick:()=>u(!1)}),n.jsx(jn.Popover.Positioner,{className:Ee.popoverPositioner,align:"end",side:"bottom",sideOffset:I,collisionAvoidance:{side:"none"},children:n.jsxs(jn.Popover.Popup,{className:B(Ee.popoverPopup,{[Ee.full]:a}),style:{maxHeight:h},children:[n.jsx(ys,{value:i,onChange:N=>{c(N.target.value),d(0)},onClear:()=>c(""),onKeyDown:A,placeholder:"Search apps",rootClassName:Ee.search,ref:gs()}),n.jsx("div",{className:Ee.viewport,role:"listbox",children:v.length===0?n.jsx(je,{children:"No apps found"}):v.map(({chainId:N,name:S,logoUrl:P},F)=>n.jsxs("div",{className:B(Ee.item,{[Ee.highlighted]:F===m,[Ee.active]:e===N}),onClick:()=>$(N),onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),$(N))},onMouseEnter:()=>d(F),role:"option","aria-selected":e===N,tabIndex:-1,ref:D=>{D&&(g.current[F]=D)},children:[n.jsxs("div",{className:Ee.itemContent,children:[typeof P=="string"?n.jsx(re,{src:P,width:16,height:16,logo:!0}):P(16),n.jsx("span",{className:Ee.name,children:S}),N===r&&n.jsx("span",{className:Ee.connectedTag,children:"Connected"})]}),o&&n.jsx("span",{className:Ee.extra,children:o(N)})]},N))})]})})]})]})},gw="_container_1nap1_1",_w="_controls_1nap1_7",yw="_search_1nap1_13",Qa={container:gw,controls:_w,search:yw},xw=({children:e})=>n.jsx("div",{className:Qa.container,children:e}),bw=({children:e})=>n.jsx("div",{className:Qa.controls,children:e}),ww=e=>n.jsx(ys,{...e,rootClassName:Qa.search}),gt={Root:xw,Controls:bw,SearchInput:ww},vl=H.atom(""),jl=H.atom(""),vw=H.atom(""),jw=H.atom(""),Cw=H.atom(""),kw="_change_1nm9m_1",Nw="_positive_1nm9m_8",Iw="_negative_1nm9m_12",Ho={change:kw,positive:Nw,negative:Iw},Cl=({amount:e,asset:t})=>{const{denom:s,symbol:o,decimals:a}=t,r=new q(e).isPositive(),i=new q(e).abs().toString();return n.jsxs("div",{className:B(Ho.change,r?Ho.positive:Ho.negative),children:[r?"+":"-",k.formatAmount(i,{decimals:a})," ",o||s]})},Aw=({changes:e,chain:t})=>{const s=St(t);return e.map(({amount:o,denom:a},r)=>n.jsx(Cl,{amount:o,asset:s(a)},r))},Sw=({changes:e,chain:t})=>{const s=St(t);return e.map(({amount:o,metadata:a},r)=>n.jsx(qc,{metadata:a,chain:t,children:i=>n.jsx(Cl,{amount:o,asset:s(i)})},r))},Tw=({events:e,chain:t})=>{const{initiaAddress:s,hexAddress:o}=tt();return t.metadata?.is_l1||t.metadata?.minitia?.type==="minimove"?n.jsx(Sw,{changes:Lc(e,o),chain:t}):n.jsx(Aw,{changes:Mc(e,s),chain:t})},Ew="_message_1qc8m_1",$w="_more_1qc8m_9",Jr={message:Ew,more:$w},Mw=({messages:e})=>n.jsxs(n.Fragment,{children:[e.slice(0,3).map((t,s)=>n.jsx("p",{className:Jr.message,children:Ys.sentenceCase(t["@type"].split("Msg")[1])},s)),e.length>3&&n.jsx("footer",{className:Jr.more,children:`+${e.length-3} more`})]}),Lw="_link_1vbb0_1",qw="_inner_1vbb0_16",Rw="_header_1vbb0_21",Pw="_time_1vbb0_30",Dw="_error_1vbb0_36",Bw="_timestamp_1vbb0_40",Fw="_chainInfo_1vbb0_45",Uw="_content_1vbb0_53",Ow="_messages_1vbb0_61",Vw="_changes_1vbb0_67",jt={link:Lw,inner:qw,header:Rw,time:Pw,error:Dw,timestamp:Bw,chainInfo:Fw,content:Uw,messages:Ow,changes:Vw},Kw=({txItem:e,chain:t})=>n.jsx(ho,{txHash:e.txhash,chainId:t.chainId,className:jt.link,children:n.jsxs("div",{className:jt.inner,children:[n.jsxs("div",{className:jt.header,children:[n.jsxs("div",{className:jt.time,children:[e.code!==0&&n.jsx(M.IconWarningFilled,{size:14,className:jt.error}),n.jsx("span",{className:jt.timestamp,children:Xe.format(new Date(e.timestamp),"h:mm a")})]}),n.jsxs("div",{className:jt.chainInfo,children:[n.jsx(re,{src:t.logoUrl,width:12,height:12,logo:!0}),n.jsx("span",{children:t.name})]})]}),n.jsxs("div",{className:jt.content,children:[n.jsx("div",{className:jt.messages,children:n.jsx(Mw,{messages:e.tx.body.messages})}),n.jsx("div",{className:jt.changes,children:n.jsx(xe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(Tw,{...e,chain:t})})})]})]})}),Ww="_list_1mv55_1",zw="_dateGroup_1mv55_7",Hw="_dateHeader_1mv55_12",Qw="_more_1mv55_18",Ls={list:Ww,dateGroup:zw,dateHeader:Hw,more:Qw},Gw=({list:e,chainId:t})=>{const s=ie(),o=_.useMemo(()=>Xc(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?n.jsx(je,{children:"No activity found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Ls.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{className:Ls.dateGroup,children:[n.jsx("div",{className:Ls.dateHeader,children:a}),r.map(i=>n.jsx(xe,{errorBoundaryProps:{fallback:null},children:n.jsx(Kw,{txItem:i,chain:i.chain})},i.txhash))]},a))}),n.jsx(ho,{chainId:t,accountAddress:s,pathSuffix:"/txs",className:Ls.more,showIcon:!0,children:"View more on Initia Scan"})]})},Yw=()=>{const{activities:e,isLoading:t}=md(),[s,o]=H.useAtom(Cw),a=ce(),r=_.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=_.useMemo(()=>s?e.filter(c=>c.chain.chainId===s):e,[e,s]);return t&&e.length===0?n.jsx(je,{children:"Loading activities..."}):!e.length&&!t?n.jsx(je,{children:"No activity yet"}):n.jsxs(gt.Root,{children:[n.jsx(gt.Controls,{children:n.jsx(vo,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),n.jsx(Gw,{list:i,chainId:s||a.chainId})]})},Zw="_thumbnail_1xyqw_1",Jw="_placeholder_1xyqw_18",Xw="_clickable_1xyqw_24",Qn={thumbnail:Zw,placeholder:Jw,clickable:Xw},ev=({nftInfo:e,size:t,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:c}=se(),l=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,c).toString();return s?n.jsx("button",{className:B(Qn.thumbnail,Qn.clickable),onClick:s,style:{width:t,height:t},children:n.jsx(re,{src:l,classNames:{placeholder:Qn.placeholder}})}):n.jsx("div",{className:Qn.thumbnail,style:{width:t,height:t},children:n.jsx(re,{src:l,classNames:{placeholder:Qn.placeholder}})})},tv="_collectionName_qs5tw_1",nv="_nftName_qs5tw_6",sv="_chainInfo_qs5tw_10",Qo={collectionName:tv,nftName:nv,chainInfo:sv},Ga=({normalizedNft:e,onThumbnailClick:t,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:c}=e;return n.jsxs("div",{className:a?.root,children:[n.jsx(ev,{nftInfo:e,onClick:t,size:s}),n.jsxs("div",{children:[n.jsx("div",{className:B(Qo.collectionName,a?.collectionName),children:r}),n.jsx("div",{className:B(Qo.nftName,a?.nftName),children:i}),n.jsxs("div",{className:B(Qo.chainInfo,a?.chainInfo),children:[n.jsx(re,{src:c.logoUrl,width:o,height:o,logo:!0}),n.jsx("span",{children:c.name})]})]})]})},Ya=qe.createQueryKeys("interwovenkit:nft",{nfts:(e,t)=>[e,t],metadata:e=>[e]});function ov(e,t){const{nft:s}=e,o=t.name??s.token_id;return{...e,...s,...t,name:o}}function av(e,t){return e.flatMap((s,o)=>(t[o]??[]).map(r=>({...r,chain:s})))}const rv=()=>{const e=ie(),t=_e(),s=E.useQueries({queries:t.map(l=>({queryKey:Ya.nfts(l.indexerUrl,e).queryKey,queryFn:()=>Js(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:V.SECOND}))}),o=s.map(L.prop("data")),a=av(t,o),r=a.reduce((l,{chain:u})=>({...l,[u.chainId]:(l[u.chainId]||0)+1}),{}),i=Object.values(r).reduce((l,u)=>l+u,0),c=s.some(l=>l.isLoading);return{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}};function iv(e){const t=Xr(e);return E.useQuery({queryKey:Ya.metadata(t).queryKey,queryFn:async()=>{try{if(!t)return{};const s=await z.get(t).json();return{...s,image:Xr(s.image)}}catch{return{}}},staleTime:V.INFINITY})}function Xr(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const cv=({nftInfo:e,children:t})=>{const{data:s={}}=iv(e.nft.uri),o=ov(e,s);return t(o)},lv="_grid_1wwdn_1",uv="_root_1wwdn_7",dv="_collectionName_1wwdn_15",mv="_nftName_1wwdn_23",hv="_chainInfo_1wwdn_32",ei={grid:lv,root:uv,collectionName:dv,nftName:mv,chainInfo:hv},fv=()=>{const[e,t]=H.useAtom(vw),[s,o]=H.useAtom(jw),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=rv(),l=Me(),u=_.useMemo(()=>a.filter(({collection_addr:d,collection_name:h,nft:f,object_addr:g,chain:p})=>{if(s&&p.chainId!==s)return!1;if(e){const y=e.trim().toLowerCase();return d.toLowerCase().includes(y)||h.toLowerCase().includes(y)||f.token_id.toLowerCase().includes(y)||g.toLowerCase().includes(y)}return!0}),[a,s,e]),m=_.useMemo(()=>Array.from(new Set(a.map(({chain:d})=>d.chainId))),[a]);return c&&a.length===0?n.jsx(je,{children:"Loading NFTs..."}):!a.length&&!e&&!c?n.jsx(je,{children:"No NFTs"}):n.jsxs(gt.Root,{children:[n.jsxs(gt.Controls,{children:[n.jsx(gt.SearchInput,{value:e,onChange:d=>t(d.target.value),onClear:()=>t(""),placeholder:"Search NFTs"}),n.jsx(vo,{value:s,onChange:o,chainIds:m,renderExtra:d=>d?r[d]||0:i})]}),u.length===0?n.jsx(je,{children:"No NFTs found"}):n.jsx("div",{className:ei.grid,children:u.map(d=>{const{collection_addr:h,nft:f}=d;return n.jsx(cv,{nftInfo:d,children:g=>n.jsx(Ga,{normalizedNft:g,onThumbnailClick:()=>l("/nft",g),classNames:ei})},h+f.token_id)})})]})},kl=_.createContext(null);function Nl(){return _.useContext(kl)}const pv="_popup_nbecp_1",gv="_item_nbecp_19",qs={popup:pv,item:gv},Il=({asset:e,children:t})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:c,chain:l}=e,{chainId:u}=l,[m,d]=_.useState(!1),h=Me(),f=Nl(),{showNotification:g}=hs(),{defaultChainId:p}=se(),{evm_chain_id:y}=xn(),x=Qe.useChainId(),{switchChainAsync:b}=Qe.useSwitchChain(),{watchAssetAsync:j}=Qe.useWatchAsset(),v=()=>{d(!1),h("/send",{denom:s,chain:l})},w=()=>{d(!1),h("/bridge",{srcChainId:u,srcDenom:s,quantity:""})},C=E.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const I=r;return await b({chainId:Number(y)}),j({type:"ERC20",options:{address:c,symbol:a,decimals:o,image:I}})},onSuccess:()=>{g({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:I=>{g({type:"error",title:"Asset addition failed",description:I.message})}});return n.jsxs(Rt.Menu.Root,{open:m,onOpenChange:d,modal:!1,children:[n.jsx(Rt.Menu.Trigger,{render:t}),n.jsx(Rt.Menu.Portal,{container:f,children:n.jsx(Rt.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:n.jsxs(Rt.Menu.Popup,{className:qs.popup,children:[n.jsxs(Rt.Menu.Item,{className:qs.item,onClick:v,children:[n.jsx(M.IconArrowRight,{size:16}),n.jsx("span",{children:"Send"})]}),n.jsxs(Rt.Menu.Item,{className:qs.item,onClick:w,disabled:i,children:[n.jsx(M.IconSwap,{size:16}),n.jsx("span",{children:"Bridge/Swap"})]}),u===p&&y===x&&!!c&&n.jsxs(Rt.Menu.Item,{className:qs.item,onClick:()=>C.mutate(),disabled:C.isPending||C.data,children:[C.data?n.jsx(M.IconCheck,{size:16}):n.jsx(M.IconPlus,{size:16}),n.jsx("span",{children:"Add to Wallet"})]})]})})})]})},_v="_item_38qhm_1",yv="_info_38qhm_23",xv="_images_38qhm_29",bv="_name_38qhm_33",wv="_value_38qhm_39",vv="_amount_38qhm_47",jv="_usd_38qhm_53",an={item:_v,info:yv,images:xv,name:bv,value:wv,amount:vv,usd:jv},Cv=({asset:e})=>{const{amount:t,value:s,logoUrl:o,chain:a}=e,r=k.formatAmount(t,{decimals:e.decimals});return n.jsx(Il,{asset:e,children:n.jsxs("button",{className:an.item,children:[n.jsxs("div",{className:an.info,children:[n.jsx(_o,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:an.images}),n.jsx("span",{className:an.name,children:a.name})]}),n.jsxs("div",{className:an.value,children:[n.jsx("span",{className:an.amount,children:r}),Number(s)>0&&n.jsx("span",{className:an.usd,children:ae(s)})]})]})})},kv="_container_ytg3p_1",Nv="_assetItem_ytg3p_6",Iv="_expandIcon_ytg3p_22",Av="_assetInfo_ytg3p_27",Sv="_logo_ytg3p_33",Tv="_details_ytg3p_37",Ev="_symbol_ytg3p_42",$v="_chainName_ytg3p_53",Mv="_chainInfos_ytg3p_59",Lv="_chainLogos_ytg3p_65",qv="_chainLogo_ytg3p_65",Rv="_moreChains_ytg3p_76",Pv="_expanded_ytg3p_93",Dv="_valueColumn_ytg3p_98",Bv="_amount_ytg3p_108",Fv="_value_ytg3p_98",Uv="_collapsibleContent_ytg3p_121",Ov="_chainsList_ytg3p_151",Te={container:kv,assetItem:Nv,expandIcon:Iv,assetInfo:Av,logo:Sv,details:Tv,symbol:Ev,chainName:$v,chainInfos:Mv,chainLogos:Lv,chainLogo:qv,moreChains:Rv,expanded:Pv,valueColumn:Dv,amount:Bv,value:Fv,collapsibleContent:Uv,chainsList:Ov},Vv=H.atom([]),Za=({assetGroup:e})=>{const{symbol:t,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=H.useAtom(Vv),c=_.useMemo(()=>Sd(e),[e]),l=_.useMemo(()=>uc(e),[e]),u=r.includes(t),m=()=>{i(h=>u?h.filter(f=>f!==t):[...new Set([...h,t])])},d=()=>n.jsxs("button",{className:Te.assetItem,children:[n.jsxs("div",{className:Te.assetInfo,children:[s&&n.jsx(re,{src:s,width:32,height:32,className:Te.logo,logo:!0}),n.jsxs("div",{className:Te.details,children:[n.jsx("div",{className:Te.symbol,children:t}),a?n.jsx("div",{className:Te.chainName,children:o[0].chain.name}):n.jsxs("div",{className:Te.chainInfos,children:[n.jsx("div",{className:Te.chainLogos,children:o.slice(0,5).map(({chain:h})=>n.jsx(re,{src:h.logoUrl,width:16,height:16,className:Te.chainLogo,logo:!0},h.chainId))}),o.length>5&&n.jsxs("span",{className:Te.moreChains,children:["+",o.length-5]}),n.jsx(M.IconChevronDown,{size:16,className:B(Te.expandIcon,{[Te.expanded]:u})})]})]})]}),n.jsxs("div",{className:Te.valueColumn,children:[n.jsx("div",{className:Te.amount,children:k.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&n.jsx("div",{className:Te.value,children:ae(l)})]})]});if(a){const[h]=o;return n.jsx("div",{className:Te.container,children:n.jsx(Il,{asset:h,children:d()})})}return n.jsx("div",{className:Te.container,children:n.jsxs(te.Collapsible.Root,{open:u,onOpenChange:m,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:d()}),n.jsx(te.Collapsible.Content,{className:Te.collapsibleContent,children:n.jsx("div",{className:Te.chainsList,children:o.map(h=>n.jsx(Cv,{asset:h},h.chain.chainId))})})]})})},Kv="_collapsible_1g7rh_1",Wv="_trigger_1g7rh_5",zv="_divider_1g7rh_20",Hv="_label_1g7rh_28",Qv="_chevron_1g7rh_33",Gv="_content_1g7rh_41",Yv="_list_1g7rh_45",Kt={collapsible:Kv,trigger:Wv,divider:zv,label:Hv,chevron:Qv,content:Gv,list:Yv},Al=({unlistedAssets:e})=>{const[t,s]=_.useState(!1),o=Nl(),a=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{if(a.current){const d=a.current.scrollHeight;i(d)}},[e]);const c=_.useRef(null),l=d=>{s(d),d&&c.current&&o?.current&&window.setTimeout(()=>{if(!c.current||!a.current||!o?.current)return;const h=o.current,f=h.getBoundingClientRect(),g=c.current.getBoundingClientRect(),p=a.current.scrollHeight;if(g.bottom+p>f.bottom){const x=g.top-f.top+h.scrollTop-16;h.scrollTo({top:x,behavior:"smooth"})}},50)},u=Nt.useSpring({height:t?r:0,opacity:t?1:0,config:{tension:500,friction:30,clamp:!0}}),m=_.useMemo(()=>e.map(d=>({...d,assets:[d],totalValue:d.value??0,totalAmount:Number(d.quantity)})),[e]);return e.length===0?null:n.jsxs(te.Collapsible.Root,{open:t,onOpenChange:l,className:Kt.collapsible,children:[n.jsxs(te.Collapsible.Trigger,{ref:c,className:Kt.trigger,children:[n.jsx("div",{className:Kt.divider}),n.jsxs("span",{className:Kt.label,children:["Unlisted assets (",e.length,")"]}),n.jsx(M.IconChevronDown,{className:Kt.chevron,size:12,"data-state":t?"open":"closed"}),n.jsx("div",{className:Kt.divider})]}),n.jsx(te.Collapsible.Content,{forceMount:!0,asChild:!0,children:n.jsx(Nt.animated.div,{className:Kt.content,style:u,children:n.jsx("div",{className:Kt.list,ref:a,children:m.map(d=>n.jsx(Za,{assetGroup:d},d.assets[0].denom))})})})]})},Zv="_container_15xfg_1",Jv="_header_15xfg_7",Xv="_title_15xfg_13",ej="_totalValue_15xfg_19",tj="_list_15xfg_26",Tn={container:Zv,header:Jv,title:Xv,totalValue:ej,list:tj},nj=()=>{const[e,t]=H.useAtom(vl),[s,o]=H.useAtom(jl),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:c,isLoading:l}=Aa(),u=i.map(({chainId:h})=>h),m=_.useMemo(()=>{const h=e?a.filter(g=>{const{symbol:p,assets:y}=g;return p.toLowerCase().includes(e.toLowerCase())||y.some(({denom:x,address:b})=>x.toLowerCase().includes(e.toLowerCase())||b?.toLowerCase().includes(e.toLowerCase()))}):a;return s?h.map(g=>({...g,assets:g.assets.filter(({chain:p})=>p.chainId===s)})).filter(g=>g.assets.length>0):h},[a,e,s]),d=_.useMemo(()=>{const h=e?r.filter(({denom:g,address:p})=>g.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):r;return s?h.filter(({chain:g})=>g.chainId===s):h},[r,e,s]);return l&&a.length===0?n.jsx(je,{children:"Loading assets..."}):!m.length&&!d.length&&!e&&!s&&!l?n.jsx(je,{children:"No assets"}):n.jsxs(gt.Root,{children:[n.jsxs(gt.Controls,{children:[n.jsx(gt.SearchInput,{value:e,onChange:h=>t(h.target.value),onClear:()=>t(""),placeholder:"Search assets"}),n.jsx(vo,{value:s,onChange:o,chainIds:u,renderExtra:h=>{if(!h)return ae(c);const f=i.find(g=>g.chainId===h);return f?ae(f.value):null}})]}),n.jsx("div",{children:m.length===0&&d.length===0?n.jsx(je,{children:"No assets found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Tn.list,children:m.map(h=>n.jsx(Za,{assetGroup:h},h.symbol))}),n.jsx(Al,{unlistedAssets:d})]})})]})},sj="_container_11k2x_1",oj={container:sj},Ct=({height:e,length:t=1,width:s="100%"})=>{const o=Array.from({length:t},(a,r)=>r);return t===1?n.jsx(pn,{height:e,width:s}):n.jsx("div",{className:oj.container,"aria-hidden":"true",children:o.map(a=>n.jsx(pn,{height:e,width:s},a))})},aj=_.memo(({searchQuery:e,selectedChain:t,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:c}=ms(),l=ce(),{listedGroups:u,unlistedAssets:m}=_.useMemo(()=>Wm(i,a,r,l.chainId),[i,a,r,l.chainId]),d=_.useMemo(()=>Um(u,s,o),[u,s,o]),{filteredAssets:h,totalAssetsValue:f,filteredUnlistedAssets:g}=_.useMemo(()=>Km(d,m,e,t),[d,m,e,t]);return n.jsxs("div",{className:Tn.container,children:[n.jsxs("div",{className:Tn.header,children:[n.jsx("span",{className:Tn.title,children:"Assets"}),h.length>0&&n.jsx("span",{className:Tn.totalValue,children:ae(f)})]}),h.length>0?n.jsxs("div",{children:[n.jsx("div",{className:Tn.list,children:h.map(p=>n.jsx(Za,{assetGroup:p},p.symbol))}),n.jsx(Al,{unlistedAssets:g})]}):d.length===0&&c?n.jsx(Ct,{height:56,length:3}):n.jsx(je,{children:"No liquid assets"})]})}),rj="_container_1n61l_1",ij="_section_1n61l_7",cj="_sectionHeader_1n61l_19",lj="_sectionTitle_1n61l_25",uj="_sectionLabel_1n61l_31",dj="_externalLink_1n61l_37",mj="_sectionValue_1n61l_49",hj="_tokenList_1n61l_56",fj="_stakingTokenList_1n61l_62",pj="_tokenRow_1n61l_72",gj="_tokenMain_1n61l_78",_j="_tokenTrigger_1n61l_84",yj="_tokenChevron_1n61l_100",xj="_expanded_1n61l_111",bj="_triggerValue_1n61l_115",wj="_tokenInfo_1n61l_122",vj="_tokenInfoLabel_1n61l_128",jj="_tokenLogo_1n61l_134",Cj="_tokenSymbol_1n61l_138",kj="_tokenValues_1n61l_144",Nj="_tokenAmount_1n61l_150",Ij="_tokenValue_1n61l_144",Aj="_typeBreakdown_1n61l_164",Sj="_typeRow_1n61l_172",Tj="_typeLabel_1n61l_180",Ej="_typeValues_1n61l_186",$j="_typeAmount_1n61l_192",Mj="_typeValue_1n61l_186",Lj="_collapsibleContent_1n61l_206",ne={container:rj,section:ij,sectionHeader:cj,sectionTitle:lj,sectionLabel:uj,externalLink:dj,sectionValue:mj,tokenList:hj,stakingTokenList:fj,tokenRow:pj,tokenMain:gj,tokenTrigger:_j,tokenChevron:yj,expanded:xj,triggerValue:bj,tokenInfo:wj,tokenInfoLabel:vj,tokenLogo:jj,tokenSymbol:Cj,tokenValues:kj,tokenAmount:Nj,tokenValue:Ij,typeBreakdown:Aj,typeRow:Sj,typeLabel:Tj,typeValues:Ej,typeAmount:$j,typeValue:Mj,collapsibleContent:Lj},Sl=({protocols:e,denomLogoMap:t,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=_.useMemo(()=>{const c=e.flatMap(l=>l.positions);return Em(c)},[e]);return i.size===0?null:n.jsx("div",{className:ne.container,children:Array.from(i.entries()).map(([c,l])=>n.jsx(qj,{sectionKey:c,sectionGroup:l,denomLogoMap:t,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},c))})},qj=({sectionKey:e,sectionGroup:t,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:c,totalValue:l}=t,u=Tm(e,o),m=_.useMemo(()=>Dm(c),[c]),d=e==="staking";return n.jsxs("section",{className:ne.section,"aria-label":u,children:[n.jsxs("div",{className:ne.sectionHeader,children:[n.jsxs("div",{className:ne.sectionTitle,children:[n.jsx("span",{className:ne.sectionLabel,children:u}),d&&a&&n.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:ne.externalLink,onClick:h=>h.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:ne.sectionValue,children:ae(l)})]}),n.jsx("div",{className:B(ne.tokenList,{[ne.stakingTokenList]:d}),children:m.map(h=>n.jsx(Rj,{group:h,showTypeBreakdown:d,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},h.denom))})]})},Rj=({group:e,showTypeBreakdown:t,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:c,totalValue:l,positions:u}=e,m=s.get(r),[d,h]=_.useState(!1),f=_.useMemo(()=>{if(!t)return null;const g=Rm(u);return g.size>0?g:null},[u,t]);return f?n.jsxs(te.Collapsible.Root,{open:d,onOpenChange:h,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:ne.tokenTrigger,children:[n.jsxs("div",{className:ne.tokenInfo,children:[n.jsx(M.IconChevronDown,{size:14,className:B(ne.tokenChevron,{[ne.expanded]:d}),"aria-hidden":"true"}),n.jsxs("div",{className:ne.tokenInfoLabel,children:[m?.assetLogo&&n.jsx(re,{src:m.assetLogo,width:20,height:20,className:ne.tokenLogo}),n.jsx("span",{className:ne.tokenSymbol,children:i})]})]}),n.jsx("span",{className:ne.triggerValue,children:ae(l)})]})}),n.jsx(te.Collapsible.Content,{className:ne.collapsibleContent,children:n.jsx(Pj,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):n.jsx("div",{className:ne.tokenRow,children:n.jsxs("div",{className:ne.tokenMain,children:[n.jsxs("div",{className:ne.tokenInfo,children:[m?.assetLogo&&n.jsx(re,{src:m.assetLogo,width:20,height:20,className:ne.tokenLogo}),n.jsx("span",{className:ne.tokenSymbol,children:i})]}),n.jsxs("div",{className:ne.tokenValues,children:[n.jsx("span",{className:ne.tokenAmount,children:k.formatNumber(c,{dp:6})}),n.jsx("span",{className:ne.tokenValue,children:ae(l)})]})]})})},Pj=({typeGroups:e,symbol:t,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=_.useMemo(()=>Array.from(e.entries()).map(([l,u])=>{const m=u.reduce((h,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?h:h+f.balance.formattedAmount,0),d=u.reduce((h,f)=>h+Ln(f),0);return{type:l,typeAmount:m,typeValue:d}}),[e]),i=_.useMemo(()=>{if(!o)return 0;let l=0;for(const{type:u}of r){const m=o(s,u);l+=Number(m)}return l},[s,o,r]),c=i>0;return n.jsxs("div",{className:ne.typeBreakdown,children:[r.map(({type:l,typeAmount:u,typeValue:m})=>n.jsxs("div",{className:ne.typeRow,children:[n.jsx("span",{className:ne.typeLabel,children:qm(l)}),n.jsxs("div",{className:ne.typeValues,children:[n.jsxs("span",{className:ne.typeAmount,children:[k.formatNumber(u,{dp:6})," ",t]}),n.jsx("span",{className:ne.typeValue,children:ae(m)})]})]},l)),c&&n.jsxs("div",{className:ne.typeRow,children:[n.jsx("span",{className:ne.typeLabel,children:"Claimable rewards"}),n.jsxs("div",{className:ne.typeValues,children:[n.jsxs("span",{className:ne.typeAmount,children:[k.formatNumber(i,{dp:6})," ",pt]}),n.jsx("span",{className:ne.typeValue,children:ae(i*(a??0))})]})]})]})},Dj="_container_ymkoc_1",Bj="_trigger_ymkoc_6",Fj="_expandIcon_ymkoc_22",Uj="_chainInfo_ymkoc_27",Oj="_logo_ymkoc_33",Vj="_chainNameContainer_ymkoc_37",Kj="_chainName_ymkoc_37",Wj="_externalLink_ymkoc_49",zj="_externalIcon_ymkoc_53",Hj="_valueColumn_ymkoc_63",Qj="_value_ymkoc_63",Gj="_expanded_ymkoc_80",Yj="_collapsibleContent_ymkoc_85",Zj="_content_ymkoc_97",We={container:Dj,trigger:Bj,expandIcon:Fj,chainInfo:Uj,logo:Oj,chainNameContainer:Vj,chainName:Kj,externalLink:Wj,externalIcon:zj,valueColumn:Hj,value:Qj,expanded:Gj,collapsibleContent:Yj,content:Zj},Jj=H.atom([]),Xj=({chainGroup:e})=>{const{chainId:t,chainLogo:s,protocols:o}=e,a=_e(),r=os(),{denomLogos:i,symbolLogos:c}=_.useMemo(()=>Ra(r,a),[r,a]),l=_.useMemo(()=>{const u=new Map;for(const m of o)for(const d of m.positions){if(d.type==="fungible-position"||d.balance.type==="unknown")continue;const{denom:h,symbol:f}=d.balance,g=f.toUpperCase(),p=`${t}:${h}`,y=i.get(p)??c.get(g);y&&u.set(h,{assetLogo:y,chainLogo:s??""})}return u},[o,i,c,t,s]);return n.jsx(Sl,{protocols:o,denomLogoMap:l})},eC=({chainGroup:e})=>{const{chainName:t,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=H.useAtom(Jj),c=_.useMemo(()=>o.reduce((f,g)=>f+g.positions.reduce((p,y)=>p+Ln(y),0),0),[o]),l=["civitia","yominet"],u=r.includes(t),m=t?.toLowerCase(),d=l.includes(m),h=()=>{i(f=>u?f.filter(g=>g!==t):[...new Set([...f,t])])};return n.jsx("div",{className:We.container,children:n.jsxs(te.Collapsible.Root,{open:u,onOpenChange:h,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:We.trigger,children:[n.jsxs("div",{className:We.chainInfo,children:[s&&n.jsx(re,{src:s,width:32,height:32,className:We.logo,logo:!0}),n.jsxs("div",{className:We.chainNameContainer,children:[n.jsx("span",{className:We.chainName,children:t}),a&&n.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:We.externalLink,onClick:f=>f.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,className:We.externalIcon})})]})]}),n.jsxs("div",{className:We.valueColumn,children:[!d&&n.jsx("span",{className:We.value,children:ae(c)}),n.jsx(M.IconChevronDown,{size:16,className:B(We.expandIcon,{[We.expanded]:u})})]})]})}),n.jsx(te.Collapsible.Content,{className:We.collapsibleContent,children:n.jsx("div",{className:We.content,children:n.jsx(Xj,{chainGroup:e})})})]})})},tC="_container_g7q2b_1",nC="_section_g7q2b_6",sC="_sectionHeader_g7q2b_14",oC="_sectionTitle_g7q2b_20",aC="_sectionLabel_g7q2b_26",rC="_externalLink_g7q2b_32",iC="_sectionValue_g7q2b_44",cC="_tokenList_g7q2b_51",lC="_tokenTrigger_g7q2b_63",uC="_tokenChevron_g7q2b_79",dC="_expanded_g7q2b_90",mC="_tokenInfo_g7q2b_94",hC="_tokenInfoLabel_g7q2b_100",fC="_tokenLogo_g7q2b_106",pC="_pairedLogos_g7q2b_110",gC="_coinLogo_g7q2b_115",_C="_tokenSymbol_g7q2b_133",yC="_triggerValue_g7q2b_139",xC="_clammBreakdownContent_g7q2b_146",bC="_clammPositionRow_g7q2b_154",wC="_statusDot_g7q2b_163",vC="_inRange_g7q2b_170",jC="_outRange_g7q2b_174",CC="_unknown_g7q2b_178",kC="_clammStatusValue_g7q2b_182",NC="_breakdownContent_g7q2b_192",IC="_breakdownRow_g7q2b_200",AC="_breakdownLabel_g7q2b_208",SC="_breakdownValues_g7q2b_214",TC="_breakdownAmount_g7q2b_220",EC="_breakdownValue_g7q2b_214",$C="_collapsibleContent_g7q2b_241",R={container:tC,section:nC,sectionHeader:sC,sectionTitle:oC,sectionLabel:aC,externalLink:rC,sectionValue:iC,tokenList:cC,tokenTrigger:lC,tokenChevron:uC,expanded:dC,tokenInfo:mC,tokenInfoLabel:hC,tokenLogo:fC,pairedLogos:pC,coinLogo:gC,tokenSymbol:_C,triggerValue:yC,clammBreakdownContent:xC,clammPositionRow:bC,statusDot:wC,inRange:vC,outRange:jC,unknown:CC,clammStatusValue:kC,breakdownContent:NC,breakdownRow:IC,breakdownLabel:AC,breakdownValues:SC,breakdownAmount:TC,breakdownValue:EC,collapsibleContent:$C},MC=({data:e,denomLogoMap:t})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:n.jsx("div",{className:R.container,children:n.jsxs("section",{className:R.section,"aria-label":"Liquidity positions",children:[n.jsxs("div",{className:R.sectionHeader,children:[n.jsxs("div",{className:R.sectionTitle,children:[n.jsx("span",{className:R.sectionLabel,children:"Liquidity"}),n.jsx("a",{href:wa,target:"_blank",rel:"noopener noreferrer",className:R.externalLink,onClick:a=>a.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:R.sectionValue,children:ae(s)})]}),n.jsx("div",{className:R.tokenList,children:o.map(a=>n.jsx(FC,{row:a,denomLogoMap:t},a.denom))})]})})},LC={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"};function qC(e){return e===void 0?R.unknown:e?R.inRange:R.outRange}function RC(e){return e===void 0?"Status unavailable":e?"In range":"Out of range"}function ti(e,t){return e===void 0?"-":`${k.formatNumber(e,{dp:6})} ${t}`}function Tl({isOpen:e,symbol:t,coinLogos:s,singleLogoUrl:o,rightContent:a}){const r=s&&s.length>0&&s.some(i=>i);return n.jsxs("button",{className:R.tokenTrigger,children:[n.jsxs("div",{className:R.tokenInfo,children:[n.jsx(M.IconChevronDown,{size:14,className:B(R.tokenChevron,{[R.expanded]:e}),"aria-hidden":"true"}),n.jsxs("div",{className:R.tokenInfoLabel,children:[r?n.jsx("div",{className:R.pairedLogos,children:s.map((i,c)=>n.jsx(re,{src:i,width:20,height:20,className:R.coinLogo,logo:!0},c))}):o&&n.jsx(re,{src:o,width:20,height:20,className:R.tokenLogo}),n.jsx("span",{className:R.tokenSymbol,children:t})]})]}),a]})}const PC=({position:e})=>{const t=qC(e.inRange),s=RC(e.inRange);return n.jsxs("div",{className:R.clammPositionRow,children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Position ID"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:e.positionId})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Deposit"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:ae(e.value)})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Status"}),n.jsxs("div",{className:R.clammStatusValue,children:[n.jsx("span",{className:B(R.statusDot,t)}),n.jsx("span",{children:s})]})]}),e.isFullRange?n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Range Bounds"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:"Full range"})})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Min"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:ti(e.minPrice,e.pricePairLabel)})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Max"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:ti(e.maxPrice,e.pricePairLabel)})})]})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:ae(e.rewardValue)})})]})]})},DC=({row:e,denomLogoMap:t})=>{const[s,o]=_.useState(!1),{denom:a,symbol:r,totalValue:i,coinLogos:c,logoUrl:l,clamm:u}=e,m=t.get(a);if(!u)return null;const d=l||m?.assetLogo;return n.jsxs(te.Collapsible.Root,{open:s,onOpenChange:o,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:Tl({isOpen:s,symbol:r,coinLogos:c,singleLogoUrl:d,rightContent:n.jsx("span",{className:R.triggerValue,children:ae(i)})})}),n.jsx(te.Collapsible.Content,{className:R.collapsibleContent,children:n.jsxs("div",{className:R.clammBreakdownContent,children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:ae(u.totalRewardValue)})})]}),u.positions.map(h=>n.jsx(PC,{position:h},h.tokenAddress))]})})]})},BC=({row:e,denomLogoMap:t})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:c,claimableInit:l}=e,[u,m]=_.useState(!1),d=t.get(s),h=i||d?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,g=_.useMemo(()=>Object.entries(r).filter(([,y])=>y>0),[r]),p=l&&Number(l.total)>0;return n.jsxs(te.Collapsible.Root,{open:u,onOpenChange:m,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:Tl({isOpen:u,symbol:o,coinLogos:c,singleLogoUrl:h,rightContent:n.jsx("span",{className:R.triggerValue,children:ae(a)})})}),n.jsx(te.Collapsible.Content,{className:R.collapsibleContent,children:n.jsxs("div",{className:R.breakdownContent,children:[g.map(([y,x])=>{const b=x*f;return n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:LC[y]}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[k.formatNumber(x,{dp:6})," LP"]}),n.jsx("span",{className:R.breakdownValue,children:ae(b)})]})]},y)}),p&&n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[k.formatNumber(Number(l.total),{dp:6})," ",pt]}),n.jsx("span",{className:R.breakdownValue,children:ae(l.totalValue)})]})]})]})})]})},FC=({row:e,denomLogoMap:t})=>e.clamm?n.jsx(DC,{row:e,denomLogoMap:t}):n.jsx(BC,{row:e,denomLogoMap:t}),UC="_container_1nijk_1",OC="_section_1nijk_6",VC="_sectionHeader_1nijk_14",KC="_sectionTitle_1nijk_20",WC="_sectionLabel_1nijk_26",zC="_externalLink_1nijk_32",HC="_sectionValue_1nijk_44",QC="_tokenList_1nijk_51",GC="_tokenTrigger_1nijk_63",YC="_tokenChevron_1nijk_79",ZC="_expanded_1nijk_90",JC="_tokenInfo_1nijk_94",XC="_tokenInfoLabel_1nijk_100",ek="_tokenLogo_1nijk_106",tk="_tokenName_1nijk_110",nk="_triggerValue_1nijk_116",sk="_breakdownContent_1nijk_123",ok="_breakdownRow_1nijk_131",ak="_breakdownLabel_1nijk_139",rk="_breakdownValues_1nijk_145",ik="_breakdownAmount_1nijk_151",ck="_breakdownValue_1nijk_145",lk="_collapsibleContent_1nijk_165",ge={container:UC,section:OC,sectionHeader:VC,sectionTitle:KC,sectionLabel:WC,externalLink:zC,sectionValue:HC,tokenList:QC,tokenTrigger:GC,tokenChevron:YC,expanded:ZC,tokenInfo:JC,tokenInfoLabel:XC,tokenLogo:ek,tokenName:tk,triggerValue:nk,breakdownContent:sk,breakdownRow:ok,breakdownLabel:ak,breakdownValues:rk,breakdownAmount:ik,breakdownValue:ck,collapsibleContent:lk},uk=({data:e})=>{const{totalValue:t,rows:s}=e;return s.length===0?null:n.jsx("div",{className:ge.container,children:n.jsxs("section",{className:ge.section,"aria-label":"VIP rewards",children:[n.jsxs("div",{className:ge.sectionHeader,children:[n.jsxs("div",{className:ge.sectionTitle,children:[n.jsx("span",{className:ge.sectionLabel,children:"VIP"}),n.jsx("a",{href:Du,target:"_blank",rel:"noopener noreferrer",className:ge.externalLink,onClick:o=>o.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:ge.sectionValue,children:ae(t)})]}),n.jsx("div",{className:ge.tokenList,children:s.map(o=>n.jsx(dk,{row:o},`${o.bridgeId}-${o.version}`))})]})})},dk=({row:e})=>{const{name:t,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[c,l]=_.useState(!1),u=a+i;return n.jsxs(te.Collapsible.Root,{open:c,onOpenChange:l,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:ge.tokenTrigger,children:[n.jsxs("div",{className:ge.tokenInfo,children:[n.jsx(M.IconChevronDown,{size:14,className:B(ge.tokenChevron,{[ge.expanded]:c}),"aria-hidden":"true"}),n.jsxs("div",{className:ge.tokenInfoLabel,children:[s&&n.jsx(re,{src:s,width:20,height:20,className:ge.tokenLogo,logo:!0}),n.jsx("span",{className:ge.tokenName,children:t})]})]}),n.jsx("span",{className:ge.triggerValue,children:ae(u)})]})}),n.jsx(te.Collapsible.Content,{className:ge.collapsibleContent,children:n.jsxs("div",{className:ge.breakdownContent,children:[o>0&&n.jsxs("div",{className:ge.breakdownRow,children:[n.jsx("span",{className:ge.breakdownLabel,children:"Locked"}),n.jsxs("div",{className:ge.breakdownValues,children:[n.jsxs("span",{className:ge.breakdownAmount,children:[k.formatNumber(o,{dp:2})," INIT"]}),n.jsx("span",{className:ge.breakdownValue,children:ae(a)})]})]}),r>0&&n.jsxs("div",{className:ge.breakdownRow,children:[n.jsx("span",{className:ge.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:ge.breakdownValues,children:[n.jsxs("span",{className:ge.breakdownAmount,children:[k.formatNumber(r,{dp:2})," INIT"]}),n.jsx("span",{className:ge.breakdownValue,children:ae(i)})]})]})]})})]})},mk="_container_ymkoc_1",hk="_trigger_ymkoc_6",fk="_expandIcon_ymkoc_22",pk="_chainInfo_ymkoc_27",gk="_logo_ymkoc_33",_k="_chainNameContainer_ymkoc_37",yk="_chainName_ymkoc_37",xk="_externalLink_ymkoc_49",bk="_externalIcon_ymkoc_53",wk="_valueColumn_ymkoc_63",vk="_value_ymkoc_63",jk="_expanded_ymkoc_80",Ck="_collapsibleContent_ymkoc_85",kk="_content_ymkoc_97",ze={container:mk,trigger:hk,expandIcon:fk,chainInfo:pk,logo:gk,chainNameContainer:_k,chainName:yk,externalLink:xk,externalIcon:bk,valueColumn:wk,value:vk,expanded:jk,collapsibleContent:Ck,content:kk},Nk=H.atom(!1),Ik=()=>{const{totalValue:e}=qa(),{totalValue:t}=co(),{totalValue:s}=lo(),o=e+t+s;return n.jsx("span",{className:ze.value,children:ae(o)})},Ak=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=qa(),{data:i}=xc(),{data:c}=bc(),l=_.useMemo(()=>{const d=new Map;for(const h of r){if(h.type==="fungible-position"||h.balance.type==="unknown")continue;const{denom:f,symbol:g}=h.balance,p=g.toUpperCase(),y=`${e}:${f}`,x=s.get(y)??o.get(p);x&&d.set(f,{assetLogo:x,chainLogo:t})}return d},[r,s,o,e,t]),u=_.useMemo(()=>(d,h)=>{const f=k.denomToMetadata(d);if(h==="staking"){const g=i?.get(f);return g?k.fromBaseUnit(g.amount,{decimals:it}):"0"}if(h==="lockstaking"){const g=c?.get(f);return g?k.fromBaseUnit(g.amount,{decimals:it}):"0"}return"0"},[i,c]),m=_.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:wa,positions:r}],[r]);return m.length===0?null:n.jsx(Sl,{protocols:m,denomLogoMap:l,isInitia:!0,getClaimableInitByType:u,initPrice:a})},Sk=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o})=>{const a=co(),r=_.useMemo(()=>{const i=new Map;for(const c of a.rows){const{denom:l,symbol:u}=c,m=u.toUpperCase(),d=`${e}:${l}`,h=s.get(d)??o.get(m);h&&i.set(l,{assetLogo:h,chainLogo:t})}return i},[a.rows,s,o,e,t]);return a.rows.length===0?null:n.jsx(MC,{data:a,denomLogoMap:r})},Tk=()=>{const e=lo();return e.rows.length===0?null:n.jsx(uk,{data:e})},Ek=({chainGroup:e})=>{const{chainId:t,chainName:s,chainLogo:o}=e,[a,r]=H.useAtom(Nk),i=_e(),c=os(),{denomLogos:l,symbolLogos:u}=_.useMemo(()=>Ra(c,i),[c,i]),m=ce(),{data:d}=Pt(m),h=_.useMemo(()=>d?.find(g=>g.id===Je)?.price??0,[d]);return n.jsx("div",{className:ze.container,children:n.jsxs(te.Collapsible.Root,{open:a,onOpenChange:r,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:ze.trigger,children:[n.jsxs("div",{className:ze.chainInfo,children:[o&&n.jsx(re,{src:o,width:32,height:32,className:ze.logo,logo:!0}),n.jsxs("div",{className:ze.chainNameContainer,children:[n.jsx("span",{className:ze.chainName,children:s}),n.jsx("a",{href:wa,target:"_blank",rel:"noopener noreferrer",className:ze.externalLink,onClick:f=>f.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,className:ze.externalIcon})})]})]}),n.jsxs("div",{className:ze.valueColumn,children:[n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:16,width:60,length:1}),children:n.jsx(Ik,{})}),n.jsx(M.IconChevronDown,{size:16,className:B(ze.expandIcon,{[ze.expanded]:a})})]})]})}),n.jsx(te.Collapsible.Content,{className:ze.collapsibleContent,children:n.jsxs("div",{className:ze.content,children:[n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:36,length:2}),children:n.jsx(Ak,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:u,initPrice:h})}),n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:36,length:2}),children:n.jsx(Sk,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:u})}),n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:36,length:1}),children:n.jsx(Tk,{})})]})})]})})},$k="_totalValue_1v2ca_1",Mk={totalValue:$k},Lk=({filteredChainGroups:e})=>{const{totalValue:t}=qa(),{totalValue:s}=co(),{totalValue:o}=lo(),a=t+s+o,r=_.useMemo(()=>{const i=e.some(l=>l.isInitia);return e.reduce((l,u)=>u.isInitia?l:l+u.totalValue,0)+(i?a:0)},[e,a]);return n.jsx("span",{className:Mk.totalValue,children:ae(r)})},qk="_container_1eubu_1",Rk="_header_1eubu_7",Pk="_title_1eubu_13",Dk="_list_1eubu_19",Bk="_skeletonWrapper_1eubu_24",Gn={container:qk,header:Rk,title:Pk,list:Dk,skeletonWrapper:Bk},Fk=_.memo(({searchQuery:e,selectedChain:t,chainInfoMap:s})=>{const{positions:o,isLoading:a}=ms(),r=ce(),i=_.useMemo(()=>{const l=[];for(const m of o){if(!Array.isArray(m.positions))continue;const d=s.get(m.chainName.toLowerCase()),h=m.chainName.toLowerCase();if(t&&d?.chainId!==t||!m.positions.some(x=>x.positions.some(b=>b.type!=="fungible-position"))||e&&!h.includes(e.toLowerCase()))continue;const g=m.positions.filter(x=>e&&!x.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(x.positions)&&x.positions.length>0),p=r.chainId===d?.chainId,y=g.reduce((x,b)=>x+b.positions.reduce((j,v)=>j+Ln(v),0),0);l.push({chainId:d?.chainId??"",chainName:d?.prettyName??m.chainName,chainLogo:d?.logoUrl??"",protocols:g,isInitia:p,totalValue:y})}const u=["civitia","yominet"];return L.sortWith([L.descend(m=>m.isInitia??!1),L.ascend(m=>u.includes(m.chainName.toLowerCase())),L.descend(m=>m.totalValue??0),L.ascend(m=>m.chainName.toLowerCase())],l)},[o,s,e,t,r.chainId]),c=i.length>0;return n.jsxs("div",{className:Gn.container,children:[n.jsxs("div",{className:Gn.header,children:[n.jsx("span",{className:Gn.title,children:"Positions"}),c&&n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:16,width:60,length:1}),children:n.jsx(Lk,{filteredChainGroups:i})})]}),c?n.jsx("div",{className:Gn.list,children:i.map(l=>l.isInitia?n.jsx(xe,{suspenseFallback:n.jsx("div",{className:Gn.skeletonWrapper,children:n.jsx(Ct,{height:56,length:1})}),children:n.jsx(Ek,{chainGroup:l})},l.chainName):n.jsx(eC,{chainGroup:l},l.chainName))}):o.length===0&&a?n.jsx(Ct,{height:56,length:3}):n.jsx(je,{children:"No positions"})]})}),Uk="_content_1w1ad_1",Ok={content:Uk},Vk=({selectedChain:e,setSelectedChain:t})=>{const{defaultChainId:s}=se(),o=ce(),a=Jm(),{totalValue:r}=lo(),{chainIds:i,chainIdToValueMap:c,totalBalance:l}=_.useMemo(()=>{const u=new Map;let m=0;for(const h of a)u.set(h.chainId,h.totalBalance),m+=h.totalBalance;return r>0&&(u.set(o.chainId,(u.get(o.chainId)??0)+r),m+=r),{chainIds:L.sortWith([L.descend(h=>h===s),L.descend(h=>h===o.chainId),L.descend(h=>u.get(h)??0)],a.map(h=>h.chainId)),chainIdToValueMap:u,totalBalance:m}},[a,s,o,r]);return n.jsx(vo,{value:e,onChange:t,chainIds:i,renderExtra:u=>ae(u?c.get(u)??0:l)})},Kk=()=>{const[e,t]=H.useAtom(vl),[s,o]=H.useAtom(jl),a=_e(),r=os(),{denomLogos:i,symbolLogos:c}=_.useMemo(()=>Ra(r,a),[r,a]),l=ga(),u=_.useMemo(()=>jc(a,l),[a,l]),m=Zm();return n.jsxs(gt.Root,{children:[n.jsxs(gt.Controls,{children:[n.jsx(gt.SearchInput,{value:e,onChange:d=>t(d.target.value),onClear:()=>t(""),placeholder:"Search portfolio"}),n.jsx(xe,{suspenseFallback:n.jsx(pn,{height:44,width:132}),children:n.jsx(Vk,{selectedChain:s,setSelectedChain:o})})]}),n.jsxs("section",{className:Ok.content,"aria-label":"Assets and positions",children:[n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:48,length:5}),children:n.jsx(aj,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:c,chainInfoMap:m,chainPrices:u})}),n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:56,length:3}),children:n.jsx(Fk,{searchQuery:e,selectedChain:s,chainInfoMap:m})})]})]})},Wk="_totalValue_5pf7e_1",zk="_totalLabel_5pf7e_7",Hk="_totalAmount_5pf7e_13",Qk="_loading_5pf7e_18",Gk="_skeletonWrapper_5pf7e_23",Yk="_nav_5pf7e_28",Zk="_item_5pf7e_34",Jk="_tabs_5pf7e_59",Xk="_tab_5pf7e_59",He={totalValue:Wk,totalLabel:zk,totalAmount:Hk,loading:Qk,skeletonWrapper:Gk,nav:Yk,item:Zk,tabs:Jk,tab:Xk},eN=()=>{const{totalValue:e,isLoading:t}=Aa();return n.jsx("div",{className:B(He.totalAmount,{[He.loading]:t}),children:ae(e)})},tN=()=>{const e=Xm(),t=eh(),s=vc(),o=e+s+t;return n.jsx("div",{className:He.totalAmount,children:ae(o)})},nN=()=>{Kc(),Gm();const e=Pa(),t=Me(),s=to(),o=_.useRef(null);return n.jsx(kl.Provider,{value:o,children:n.jsxs(yt,{ref:o,children:[n.jsxs("div",{className:He.totalValue,children:[n.jsx("div",{className:He.totalLabel,children:"Total value"}),n.jsx(xe,{suspenseFallback:n.jsx("div",{className:He.skeletonWrapper,children:n.jsx(pn,{height:48,width:120})}),children:e?n.jsx(eN,{}):n.jsx(tN,{})})]}),n.jsxs("nav",{className:He.nav,"aria-label":"Quick actions",children:[n.jsxs(mn,{to:"/send",className:He.item,children:[n.jsx(M.IconSend,{size:20}),n.jsx("span",{children:"Send"})]}),n.jsxs(mn,{to:"/bridge",className:He.item,children:[n.jsx(M.IconBridge,{size:20}),n.jsx("span",{children:"Bridge/Swap"})]}),n.jsxs(mn,{to:"/receive",className:He.item,children:[n.jsx(M.IconQrCode,{size:20}),n.jsx("span",{children:"Receive"})]})]}),n.jsxs(Ut.Tabs.Root,{value:s,onValueChange:t,children:[n.jsxs(Ut.Tabs.List,{className:He.tabs,children:[n.jsx(Ut.Tabs.Tab,{className:He.tab,value:"/",children:e?"Assets":"Portfolio"}),n.jsx(Ut.Tabs.Tab,{className:He.tab,value:"/nfts",children:"NFTs"}),n.jsx(Ut.Tabs.Tab,{className:He.tab,value:"/activity",children:"Activity"})]}),n.jsx(Ut.Tabs.Panel,{value:"/",children:e?n.jsx(nj,{}):n.jsx(Kk,{})}),n.jsx(Ut.Tabs.Panel,{value:"/nfts",children:n.jsx(fv,{})}),n.jsx(Ut.Tabs.Panel,{value:"/activity",children:n.jsx(Yw,{})})]})]})})},sN="_root_th990_1",oN="_collectionName_th990_9",aN="_nftName_th990_13",rN="_chainInfo_th990_17",iN="_attributes_th990_21",cN="_title_th990_24",lN="_count_th990_29",uN="_item_th990_33",dN="_type_th990_39",mN="_value_th990_45",rn={root:sN,collectionName:oN,nftName:aN,chainInfo:rN,attributes:iN,title:cN,count:lN,item:uN,type:dN,value:mN},hN=()=>{const e=Me(),t=et(),{attributes:s}=t;return n.jsxs(Tt,{title:"NFT details",children:[n.jsx(Ga,{normalizedNft:t,chainIconSize:14,classNames:rn}),n.jsx(Ae,{children:n.jsx(fe.White,{onClick:()=>e("/nft/send",t),sm:!0,children:"Send"})}),s&&n.jsxs("div",{className:rn.attributes,children:[n.jsxs("header",{className:rn.title,children:["Traits ",n.jsxs("span",{className:rn.count,children:["(",s.length,")"]})]}),n.jsx("div",{children:s.map(({trait_type:o,value:a})=>n.jsxs("div",{className:rn.item,children:[n.jsx("div",{className:rn.type,children:o}),n.jsx("div",{className:rn.value,children:a})]},o))})]})]})};function fN({balances:e,gasPrices:t,gas:s}){return t.map(({denom:o,amount:a})=>{const r=q(a).times(s).toFixed(0,q.ROUND_CEIL),i=e.find(c=>c.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>q(a).gte(o))}function pN({denom:e,balances:t,gasPrices:s,lastFeeDenom:o,gas:a}){const r=t.find(u=>u.denom===e)?.amount??"0",i=fN({balances:t,gasPrices:s,gas:a}),c=i.find(u=>u.denom===o);if(i.length===0)return r;if(e===o&&c){const u=q(r).minus(c.amount);return q.max(u,0).toString()}const l=i.find(u=>u.denom!==e)||i[0];if(!c&&e===l.denom){const u=q(r).minus(l.amount);return q.max(u,0).toString()}return q(r).toString()}const gN=({chain:e,onSelect:t})=>{const s=du(e);return n.jsx(xs,{assets:s,onSelect:t})},_N=({afterSelect:e})=>{const{watch:t,setValue:s}=$e.useFormContext(),{chainId:o,denom:a}=t(),{chainId:r}=t(),[i,c]=_.useState(r),l=_t(i),u=_e(),m=d=>{if(o===i&&a===d){e();return}s("chainId",i),s("denom",d),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return n.jsxs(n.Fragment,{children:[n.jsx(fn.Stack,{children:n.jsx(fn,{chains:u,value:i,onSelect:c})}),n.jsx(xe,{suspenseFallback:n.jsx(xs.Placeholder,{}),children:n.jsx(gN,{chain:l,onSelect:m})},i)]})},yN="_fields_brpej_1",xN="_divider_brpej_11",ni={fields:yN,divider:xN},bN=qe.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),wN=()=>{const{address:e,initiaAddress:t,estimateGas:s,requestTxSync:o}=tt(),{register:a,watch:r,setValue:i,handleSubmit:c,formState:l}=$e.useFormContext(),{errors:u}=l,{chainId:m,denom:d,recipient:h,quantity:f,memo:g}=r(),p=_t(m),y=as(p),x=Na(p),b=Ia(p),j=yi(d,p),{data:v}=Pt(p),{decimals:w}=j,C=y.find(O=>O.denom===d)?.amount??"0",I=v?.find(({id:O})=>O===d)?.price,{data:T=0,isLoading:A}=E.useQuery({queryKey:bN.gas({chainId:m,denom:d,recipient:h,initiaAddress:t}).queryKey,queryFn:()=>{const O=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:rr.MsgSend.fromPartial({fromAddress:t,toAddress:k.InitiaAddress(h).bech32,amount:[{denom:d,amount:"1"}]})}];return s({messages:O,chainId:m})},enabled:k.InitiaAddress.validate(h),staleTime:V.INFINITY}),$=Math.ceil(T*Ht),N=pN({denom:d,balances:y,gasPrices:x,lastFeeDenom:b,gas:$}),S=q(C).isZero(),F=x.some(({denom:O})=>O===d)&&A,D=S||F,{mutate:Z,isPending:K}=E.useMutation({mutationFn:({chainId:O,denom:J,quantity:Q,recipient:ee,memo:ue})=>{const ye=k.toBaseUnit(Q,{decimals:w}),me=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:rr.MsgSend.fromPartial({fromAddress:t,toAddress:k.InitiaAddress(ee).bech32,amount:[{denom:J,amount:ye}]})}];return o({messages:me,memo:ue,chainId:O,gas:T,gasAdjustment:Ht,gasPrices:x,spendCoins:[{denom:J,amount:ye}],internal:"/"})}}),W=_.useMemo(()=>{if(!f)return"Enter amount";if(u.quantity)return u.quantity.message;if(!h)return"Enter recipient address";if(u.recipient)return u.recipient.message;if(u.memo)return u.memo.message},[f,h,u.quantity,u.recipient,u.memo]);return n.jsx(Tt,{title:"Send",children:n.jsxs("form",{onSubmit:c(O=>Z(O)),"aria-label":"Send token form",children:[n.jsxs("div",{className:ni.fields,children:[n.jsx(ta,{selectButton:n.jsx(qn,{title:"Select chain and asset",content:O=>n.jsx(_N,{afterSelect:O}),children:n.jsx(Zc,{asset:j,chain:p})}),quantityInput:n.jsx(ns,{balance:C,decimals:w}),balanceButton:n.jsx(Wc,{onClick:()=>i("quantity",k.fromBaseUnit(N,{decimals:w}),{shouldValidate:!0}),disabled:D,children:k.formatAmount(C??"0",{decimals:w})}),value:f?Ba(q(f).times(I??0),I):"$0"}),n.jsx("div",{className:ni.divider}),n.jsx(Va,{myAddress:e}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),n.jsx("input",{...a("memo",{validate:O=>!O||new Blob([O]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),n.jsx(we.Stack,{children:!g&&n.jsx(we,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),n.jsx(Ae,{children:n.jsx(fe.White,{type:"submit",loading:(A?"Estimating gas...":!1)||K,disabled:!!W,children:W??"Confirm"})})]})})},vN=()=>{const e=et(),t=xn(),s=Qt(t),{chain:o=t}=e,a=L.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 n.jsx($e.FormProvider,{...i,children:n.jsx(wN,{})})};async function ua(e,t){const s=e.replace("ibc/",""),{class_trace:o}=await z.create({prefixUrl:t}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function jN(e,t){const s=new kt.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await z.create({prefixUrl:t}).post("minievm/evm/v1/call",{json:{sender:k.InitiaAddress("0x1").bech32,contract_addr:k.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function CN(e,t,s){if(t.startsWith("evm/"))return e;const{token_infos:o}=await z.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${t}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function kN({collection_addr:e},{restUrl:t}){const s=await jN(e,t);if(!s.startsWith("ibc/"))return{class_id:`evm/${k.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await ua(s,t);return o?{class_id:s,class_trace:o}:{class_id:`evm/${k.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function NN(e,t){const{data:s}=await z.create({prefixUrl:t}).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 IN({object_addr:e,collection_addr:t},{restUrl:s}){const o=await NN(t,s);return o.startsWith("ibc/")?k.InitiaAddress.equals(k.createObjectAddress("0x1",o),t)?{class_id:o,class_trace:await ua(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await ua(o,s)}:{class_id:`move/${t.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function AN(e,t){const s=de.toBase64(ln.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await z.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function SN(e,t){const{collection:s}=await z.create({prefixUrl:t}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function TN(e,t){const s=de.toBase64(ln.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function si(e){const t=/^(.*channel-\d+)\/(.*)$/,s=e.match(t);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,o,a]=s;return[o,a]}async function EN({collection_addr:e},t,s){const o=k.InitiaAddress(e).bech32,a=await AN(o,t.restUrl),r=t.metadata?.ibc_channels?.find(({chain_id:p,version:y})=>p===s.chain_id&&y.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,c=i.split(".")[1],l=de.toBase64(ln.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:u}=await z.create({prefixUrl:t.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),m=u??o,d=await TN(c,t.restUrl),h=await SN(o,t.indexerUrl);if(m===o)return{class_id:m,class_trace:void 0,outgoing_proxy:d};if(u&&h!==i.replace("wasm.","")){const[p,y]=si(u);return{class_id:o,class_trace:{path:p,base_class_id:y},outgoing_proxy:d}}const[f,g]=si(a);return{class_id:o,class_trace:{path:f,base_class_id:g},outgoing_proxy:d}}const $N={minimove:IN,minievm:kN,miniwasm:EN};async function MN({nft:e,srcChain:t,intermediaryChain:s}){const o=t.metadata?.is_l1?"minimove":t.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const a=await $N[o](e,t,s);return Object.assign(a,o==="minievm"&&{token_ids:await CN([e.token_id],a.class_id,t.restUrl)})}const LN="_root_1tyvn_1",qN="_collectionName_1tyvn_10",RN="_nftName_1tyvn_15",PN="_chainInfo_1tyvn_19",DN="_fields_1tyvn_24",BN="_chain_1tyvn_19",Go={root:LN,collectionName:qN,nftName:RN,chainInfo:PN,fields:DN,chain:BN},FN=qe.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),UN=()=>{const e=_e(),t=et(),{chain:s,collection_addr:o}=t,{routerApiUrl:a}=se(),r=bn(),i=ce(),{address:c,initiaAddress:l,requestTxSync:u}=tt(),{watch:m,setValue:d,handleSubmit:h,formState:f}=$e.useFormContext(),{errors:g}=f,p=m(),{recipient:y,dstChainId:x}=p,b=_t(x),j=E.useQuery({queryKey:FN.simulation({collection_addr:o,nft:t,sender:l,recipient:y,srcChain:s,dstChain:b,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const N=Object.assign({from_address:l,from_chain_id:s.chainId,to_address:k.InitiaAddress(y).bech32,to_chain_id:b.chainId,collection_address:o,token_ids:[t.token_id],object_addresses:[t.object_addr]},s.chainId!==b.chainId&&await MN({nft:t,srcChain:s,intermediaryChain:i})),{msgs:S}=await z.create({prefixUrl:a}).post("nft",{json:N}).json();return S.map(P=>r.fromAmino(P))},enabled:k.InitiaAddress.validate(y)}),{data:v,isLoading:w,error:C}=j,I=E.useQueryClient(),{mutate:T,isPending:A}=E.useMutation({mutationFn:async()=>{if(!v)throw new Error("Route not found");await u({messages:v,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{I.invalidateQueries({queryKey:Ya.nfts._def})}}),$=_.useMemo(()=>{if(!y)return"Enter recipient address";if(g.recipient)return g.recipient.message;if(C)return"Route not found"},[y,g.recipient,C]);return n.jsxs("form",{onSubmit:h(()=>T()),children:[n.jsx(Ga,{normalizedNft:t,thumbnailSize:80,classNames:Go}),n.jsxs("div",{className:Go.fields,children:[n.jsxs("div",{children:[n.jsx("div",{className:"label",children:"Destination app"}),n.jsxs(qn,{title:"Destination app",content:N=>n.jsx(Yc,{onSelect:({chainId:S})=>{d("dstChainId",S),N()},list:e,getImage:S=>S.logoUrl,getName:S=>S.name,getKey:S=>S.chainId}),className:B("input",Go.chain),children:[n.jsx(re,{src:b.logoUrl,width:20,height:20,logo:!0}),n.jsx("span",{children:b.name})]})]}),n.jsx(Va,{myAddress:c,ref:gs()})]}),n.jsx(Ae,{children:n.jsx(fe.White,{loading:(w?"Finding route...":!1)||A,disabled:!!$,children:$??"Confirm"})})]})},ON=()=>{const{chain:e}=et(),t=$e.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return n.jsx(Tt,{title:"Send NFT",children:n.jsx($e.FormProvider,{...t,children:n.jsx(UN,{})})})},da=()=>{const e=Me(),t=to(),s=Yt(),{closeDrawer:o}=Dt(),{closeModal:a}=ao();_.useEffect(()=>{a(),t.startsWith("/bridge/")&&t!=="/bridge/history"&&e("/bridge"),(t==="/collection"||t.startsWith("/nft"))&&e("/nfts")},[s]);const r=Pn();if(_.useEffect(()=>{r("Page View")},[t,r]),t==="/connect")return s?null:n.jsx(Vr,{onSuccess:o});if(t==="/blank")return null;if(!s)return n.jsx(Vr,{});switch(t){case"/":case"/nfts":case"/activity":return n.jsx(nN,{});case"/send":return n.jsx(vN,{},s);case"/receive":return n.jsx(kb,{});case"/nft":return n.jsx(hN,{});case"/nft/send":return n.jsx(ON,{},s);case"/bridge":return n.jsx(Ay,{},s);case"/bridge/preview":return n.jsx(l1,{});case"/bridge/history":return n.jsx(kx,{});case"/op/withdrawals":return n.jsx(R1,{});case"/tx":return n.jsx(Pc,{});case"/autosign/enable":return n.jsx(ig,{});case"/settings":return n.jsx(Xb,{});case"/settings/autosign":return n.jsx(Ub,{});case"/deposit":return n.jsx(db,{});case"/deposit/completed":return n.jsx(la,{type:"deposit"});case"/withdraw":return n.jsx(mb,{});case"/withdraw/completed":return n.jsx(la,{type:"withdraw"})}},VN="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",KN=()=>n.jsxs(n.Fragment,{children:[n.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),n.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),n.jsx("link",{rel:"stylesheet",href:VN}),n.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),WN=()=>(th(),Mu(),od(),_e(),Ym(),vc(),os(),null),zN=({children:e,...t})=>(_.useEffect(()=>{Am()},[]),Ge.useIsClient()?n.jsxs(n.Fragment,{children:[n.jsx(KN,{}),n.jsx(hi.Provider,{value:{...mi,...t},children:n.jsx(ki,{children:n.jsx(Tp,{children:n.jsx(te.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:n.jsx(Sp,{children:n.jsxs(_p,{children:[e,n.jsx(nh,{}),n.jsx(xe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(WN,{})}),n.jsx(Qh,{children:n.jsx(da,{})}),n.jsx(Kh,{children:n.jsx(da,{})})]})})})})})})]}):null),HN=({bridge:e})=>n.jsx(ki,{initialEntry:{path:e?"/bridge":"/",state:e},children:n.jsx("div",{className:"body",children:n.jsx(Ec.Provider,{value:!!e,children:n.jsx(xe,{children:n.jsx(da,{})})})})}),QN={1:"https://ethereum-rpc.publicnode.com",42161:"https://arbitrum-one-rpc.publicnode.com",8453:"https://base-rpc.publicnode.com"};function GN(e){const{id:t="testWallet",name:s="Test Wallet",rpcUrls:o,debug:a=!1,sendTransactionOverrides:r}=e;if("mnemonic"in e&&e.mnemonic==="")throw new Error("mnemonic must not be empty");if(!("mnemonic"in e&&e.mnemonic)&&!("privateKey"in e&&e.privateKey))throw new Error("Either mnemonic or privateKey is required");let i;try{i=e.mnemonic?ir.mnemonicToAccount(e.mnemonic):ir.privateKeyToAccount(e.privateKey)}catch(p){throw new Error(`[${t}] Failed to create account from ${e.mnemonic?"mnemonic":"privateKey"}`,{cause:p})}let c=1;const l={};function u(p,...y){l[p]?.forEach(x=>{x(...y)})}const m={...QN,...o},d={1:Ql.mainnet};function h(p){if(m[p])return m[p];const y=d[p];if(y)return y.rpcUrls.default.http[0];throw new Error(`[${t}] No RPC configured for chain ${p}`)}async function f(p,y){const x=h(c),b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:p,params:y??[]})});if(!b.ok)throw new Error(`[${t}] RPC "${p}" failed: HTTP ${b.status} ${b.statusText} (${x})`);let j;try{j=await b.json()}catch(v){throw new Error(`[${t}] RPC "${p}" returned non-JSON response (${x})`,{cause:v})}if(j.error)throw new ft.EIP1193ProviderRpcError(j.error.code,j.error.message);return j.result}const g={request:async({method:p,params:y})=>{switch(a&&console.log(`[${t}] ${p}`,y),p){case"eth_requestAccounts":case"eth_accounts":return[i.address];case"eth_chainId":return`0x${c.toString(16)}`;case"wallet_switchEthereumChain":{const[{chainId:x}]=y,b=Number(x);if(!d[b]&&!m[b])throw new ft.EIP1193ProviderRpcError(4902,"Unrecognized chain ID");return!d[b]&&m[b]&&(d[b]={id:b,name:`Chain ${b}`,nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[m[b]]}}}),c=b,u("chainChanged",x),null}case"wallet_addEthereumChain":{const[x]=y,b=x.rpcUrls?.[0];if(!b)throw new Error(`[${t}] wallet_addEthereumChain requires at least one RPC URL`);const j=Number(x.chainId);return d[j]?a&&console.log(`[${t}] Chain ${j} already registered, skipping`):d[j]={id:j,name:x.chainName??`Chain ${j}`,nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[b]}}},null}case"personal_sign":{const[x]=y;return i.signMessage({message:{raw:x}})}case"eth_signTypedData":case"eth_signTypedData_v4":{const[,x]=y;return i.signMessage({message:{raw:x}})}case"wallet_getPermissions":case"wallet_requestPermissions":return[{parentCapability:"eth_accounts"}];case"eth_sendTransaction":{const[x]=y,b=d[c];if(!b)throw new Error(`[${t}] No chain registered for chain ${c}. Call wallet_switchEthereumChain first.`);return ft.createWalletClient({account:i,chain:b,transport:ft.http(h(c))}).sendTransaction({to:x.to,value:x.value?BigInt(x.value):void 0,data:x.data,chainId:c,...r})}default:return f(p,y)}},on:(p,y)=>{(l[p]??=new Set).add(y)},removeListener:(p,y)=>{l[p]?.delete(y)},removeAllListeners:()=>{for(const p of Object.keys(l))delete l[p]}};return Gl.injected({target:()=>({id:t,name:s,provider:g})})}const oi={"noble-1":"noble",celestia:"celestia","neutron-1":"neutron","osmosis-1":"osmo"};function YN(e){const{mnemonic:t,name:s="Test Cosmos Wallet",image:o,chains:a,debug:r=!1}=e;if(!t)throw new Error("mnemonic is required");const i=new Map;function c(d){return a?.[d]?a[d].prefix:oi[d]?oi[d]:d.replace(/-\d+$/,"")}function l(d){const h=c(d),f=i.get(h);if(f)return f;r&&console.log(`[${s}] Creating wallet for chain ${d} (prefix: ${h})`);const g=En.Secp256k1HdWallet.fromMnemonic(t,{prefix:h});return g.catch(p=>{i.delete(h),console.error(`[${s}] Failed to create wallet for prefix "${h}":`,p)}),i.set(h,g),g}function u(d){return{async getAccounts(){return(await l(d)).getAccounts()},async signAmino(h,f){return(await l(d)).signAmino(h,f)}}}const m={getOfflineSigner(d){return u(d)},getOfflineSignerOnlyAmino(d){return u(d)}};return{name:s,image:o,getProvider:()=>m}}exports.DEFAULT_GAS_ADJUSTMENT=Ht;exports.DEFAULT_GAS_PRICE_MULTIPLIER=di;exports.InterwovenKit=HN;exports.InterwovenKitProvider=zN;exports.MAINNET=mi;exports.MoveError=ec;exports.PRIVY_APP_ID=pa;exports.TESTNET=Zl;exports.createTestCosmosWallet=YN;exports.createTestWalletConnector=GN;exports.initiaPrivyWallet=Xl;exports.initiaPrivyWalletConnector=Jl;exports.initiaPrivyWalletOptions=Jn;exports.injectStyles=bh;exports.useAddress=Yt;exports.useHexAddress=Bn;exports.useInitiaAddress=ie;exports.useInterwovenKit=tt;exports.usePortfolio=Aa;exports.useUsernameQuery=dc;
8
+ Sign this message to create a dedicated signing wallet for auto-sign transactions. This wallet will only be used to sign transactions on your behalf when auto-sign is enabled.`}async function xu(e,t){const s=ft.hexToBytes(e);if(s.length!==65)throw new Error(`Invalid signature length: expected 65 bytes (r: 32, s: 32, v: 1), got ${s.length}`);const o=s.slice(0,64),a=ft.hexToBytes(ft.keccak256(ft.bytesToHex(o))),r=ht.Bip39.encode(a),i=await ht.Bip39.mnemonicToSeed(r),c=ht.stringToPath("m/44'/60'/0'/0/0"),{privkey:l}=ht.Slip10.derivePath(ht.Slip10Curve.Secp256k1,i,c),u=await ht.Secp256k1.makeKeypair(l),m=ht.Secp256k1.compressPubkey(u.pubkey),h=u.pubkey.slice(1),f=ft.bytesToHex(h),g=ft.keccak256(f),p=ft.hexToBytes(g).slice(-20),y=de.toBech32(t,p);return{privateKey:l,publicKey:m,address:y}}function Cs(e,t){return`${e}:${t}`}const rs=H.atom(null),Xn=H.atom({}),es=H.atom({}),no=H.atom({}),dr=H.atom(0),bu="autosign:";function wu(e,t){const s=e.get(dr)+1;return e.set(dr,s),`${t}:${s}`}function Fs(e,t){return e.get(no)[t]}function vu(e,t,s){e.set(no,o=>({...o,[t]:s}))}function Ti(e,t){e.set(no,s=>{const o={...s};return delete o[t],o})}function ju(e,t,s){const o=Fs(e,t);!o||o.token!==s||Ti(e,t)}function Cu(e,t,s){const o=Fs(e,t);return!!o&&o.token===s}function ks(e,t){return e.get(es)[t]}function ku(e,t,s){e.set(es,o=>({...o,[t]:s}))}function Nu(e,t){e.set(es,s=>{const o={...s};return delete o[t],o})}function Iu(e,t,s){e.set(Xn,o=>({...o,[t]:s}))}function Au(e,t){e.set(Xn,s=>{const o={...s};return delete o[t],o})}function Ei(e,t){return`${bu}${e}:${t}`}function Su(e,t,s){try{return e.getItem(Ei(t,s))}catch{return null}}function Tu(e,t,s,o){try{e.setItem(Ei(t,s),o)}catch{}}function $i(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function wa(e,t){const s=$i();if(s)return Su(s,e,t)}function Eu(e,t,s){const o=$i();o&&Tu(o,e,t,s)}function $u(e){return{publicKey:e.publicKey,address:e.address}}function Us(e){e&&e.fill(0)}function Mi(e){e.set(no,{});const t=e.get(es);for(const s of Object.values(t))Us(s);e.set(es,{}),e.set(Xn,{})}function Mu(e,t){return e!==""&&e!==t}function Lu(){const e=ie(),t=H.useStore(),s=_.useRef(e);_.useEffect(()=>{const o=s.current;Mu(o,e)&&Mi(t),s.current=e},[t,e])}class qu{constructor(t,s){this.wallet=t,this.privateKey=s}async getAccounts(){return[{address:this.wallet.address,algo:"ethsecp256k1",pubkey:this.wallet.publicKey}]}async signAmino(t,s){if(this.wallet.address!==t)throw new Error("Signer address does not match the derived wallet address");const o=Zn.escapeCharacters(Zn.sortedJsonStringify(s)),a=kt.ethers.hashMessage(o),r=de.fromHex(a.replace("0x","")),i=await ht.Secp256k1.createSignature(r,this.privateKey),c=new Uint8Array([...i.r(32),...i.s(32)]),l=Si(this.wallet.publicKey,c);return{signed:s,signature:l}}}function so(){const e=H.useStore(),{signMessageAsync:t}=Qe.useSignMessage(),s=lt(),o=ie();return{deriveWallet:async u=>{if(!o)throw new Error("User address not available");const m=s(u),d=Cs(o,m.bech32_prefix),h=e.get(Xn)[d];if(h&&ks(e,d))return h;const f=Fs(e,d);if(f)return f.promise;const g=wu(e,d),p=(async()=>{try{const y=window.location.origin,x=yu(y),b=await t({message:x}),j=await xu(b,m.bech32_prefix),v=$u(j);if(Cu(e,d,g))return ku(e,d,j.privateKey),Iu(e,d,v),v;throw Us(j.privateKey),new Error("Wallet derivation was cancelled")}finally{ju(e,d,g)}})();return vu(e,d,{promise:p,token:g}),p},getWallet:u=>{if(!o)return;const m=s(u),d=Cs(o,m.bech32_prefix);if(ks(e,d))return e.get(Xn)[d]},getWalletPrivateKey:u=>{if(!o)return;const m=s(u),d=Cs(o,m.bech32_prefix);return ks(e,d)},clearWallet:u=>{if(!o)return;const m=s(u),d=Cs(o,m.bech32_prefix),h=ks(e,d);Fs(e,d)&&Ti(e,d),Us(h),Nu(e,d),Au(e,d)},clearAllWallets:()=>{Mi(e)}}}function Li({granteeAddress:e,messages:t,encoder:s}){return[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:ha.MsgExec.fromPartial({grantee:e,msgs:t.map(o=>({typeUrl:o.typeUrl,value:s.encode(o)}))})}]}async function Ru({chainId:e,granterAddress:t,messages:s,fee:o,memo:a,derivedWallet:r,privateKey:i,encoder:c,signWithEthSecp256k1:l}){const u=Li({granteeAddress:r.address,messages:s,encoder:c}),m={...o,granter:t},d=new Uint8Array(i),h=new qu(r,d);try{return await l(e,r.address,u,m,a,{customSigner:h})}finally{Us(d)}}const wt="interwovenkit",Je="uinit",pt="INIT",it=6,Pu="uoinit",Du="omniINIT",qi="https://app.initia.xyz",va=`${qi}/liquidity/my`,Bu=`${qi}/vip/my`,Fu=1e3,Ri=60*Fu,Pi=60*Ri,mr=24*Pi,he={PUBLIC_KEY:`${wt}:public-key`,BRIDGE_SRC_CHAIN_ID:`${wt}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${wt}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${wt}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${wt}:bridge:dst-denom`,BRIDGE_QUANTITY:`${wt}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${wt}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${wt}:bridge:route-type`,BRIDGE_HISTORY:`${wt}:bridge:history`,OP_REMINDER:`${wt}:op:reminder`},Di=H.atom(!1),Bi=H.atom(!1);function Dt(){const e=xa(),[t,s]=H.useAtom(Di),o=H.useSetAtom(Bi),a=Pn();return{isDrawerOpen:t,openDrawer:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function Dn(){const e=xa(),[t,s]=H.useAtom(Bi),o=H.useSetAtom(Di),a=Pn();return{isModalOpen:t,openModal:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function Fi(){const e=Me(),{closeDrawer:t}=Dt(),{closeModal:s}=Dn(),{disconnect:o}=Qe.useDisconnect(),{clearAllWallets:a}=so();return()=>{e("/blank"),t(),s(),o(),a(),localStorage.removeItem(he.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(he.BRIDGE_SRC_DENOM),localStorage.removeItem(he.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(he.BRIDGE_DST_DENOM),localStorage.removeItem(he.BRIDGE_QUANTITY),localStorage.removeItem(he.BRIDGE_SLIPPAGE_PERCENT)}}function Uu(){const e=Yt(),t=xn(),{openModal:s}=Dn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,srcOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??t.chainId,u=a.map(m=>({denom:m,chainId:l}));s("/deposit",{localOptions:u,remoteOptions:i,recipientAddress:c})}}function Ou(){const e=Yt(),t=xn(),{openModal:s}=Dn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,dstOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??t.chainId,u=a.map(m=>({denom:m,chainId:l}));s("/withdraw",{localOptions:u,remoteOptions:i,recipientAddress:c})}}function Vu(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:t}=Yo.PubKey.decode(e.value);return En.encodeSecp256k1Pubkey(t)}return Gs.decodeOptionalPubkey(e)}function Ku({typeUrl:e,value:t}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Fl.BaseAccount.decode(t),i=Vu(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Le.accountFromAny({typeUrl:e,value:t})}const Ui="/cosmos.feegrant.v1beta1.MsgGrantAllowance",Oi="/cosmos.feegrant.v1beta1.AllowedMsgAllowance",Vi="cosmos-sdk/AllowedMsgAllowance";function Wu(){const e=fa.aminoConverters[Ui];if(!e)throw new Error("Missing base converter for MsgGrantAllowance");return e}const Os=Wu();function Ki(e){if(e.typeUrl===Oi){const t=cn.AllowedMsgAllowance.decode(e.value);if(!t.allowance)throw new Error("AllowedMsgAllowance is missing nested allowance");return{type:Vi,value:{allowance:Ki(t.allowance),allowed_messages:t.allowedMessages}}}return Os.toAmino({granter:"",grantee:"",allowance:e}).allowance}function Wi(e){if(e.type===Vi){const t=e.value;if(!t.allowance)throw new Error("AllowedMsgAllowance amino value is missing nested allowance");const s=Wi(t.allowance);return{typeUrl:Oi,value:cn.AllowedMsgAllowance.encode(cn.AllowedMsgAllowance.fromPartial({allowance:s,allowedMessages:t.allowed_messages??t.allowedMessages??[]})).finish()}}return Os.fromAmino({granter:"",grantee:"",allowance:e}).allowance}const zu={...fa.aminoConverters,[Ui]:{...Os,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:Ki(e.allowance)}:Os.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:Wi(e.allowance)})}},is=()=>{const e=se();return new Gs.Registry([...fa.protoRegistry,...e.protoTypes??[]])},cs=()=>{const e=se();return{...zu,...e.aminoConverters}},bn=()=>{const e=cs();return new Le.AminoTypes(e)};class Hu{constructor(t,s,o){this.address=t,this.signMessage=s,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const t=`${he.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(t);if(s)return this.cachedPublicKey=de.fromHex(s),de.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(t,de.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(t,de.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?de.fromBase64(s):null}catch{return null}}async getPublicKey(){const t="Sign this message to identify your Initia account.",s=await this.signMessage(t),o=kt.ethers.hashMessage(t),a=kt.ethers.SigningKey.recoverPublicKey(o,s);return ht.Secp256k1.compressPubkey(de.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(t,s){if(this.address!==t)throw new Error("Signer address does not match the provided address");const o=Zn.escapeCharacters(Zn.sortedJsonStringify(s)),a=await this.signMessage(o),r=de.fromHex(a.replace("0x","")).subarray(0,-1),c=ht.Secp256k1Signature.fromFixedLength(r).toFixedLength(),l=Si(await this.getCachedPublicKey(),c);return{signed:s,signature:l}}}function zi(){const e=is(),t=bn(),s=ls(),o=us();return async function(a,r,i,c,l,u){const m=u?.customSigner??s;if(!m)throw new Error("Signer not initialized");const d=await o(a),{accountNumber:h,sequence:f}=await Hi({getSequence:N=>d.getSequence(N),signerAddress:r,incrementSequence:u?.incrementSequence??0,allowMissingAccount:!!u?.customSigner}),[g]=await m.getAccounts(),p=Ai(ba(g.pubkey)),y=li.SignMode.SIGN_MODE_EIP_191,x=i.map(N=>t.toAmino(N)),b=Zn.makeSignDoc(x,c,a,l,h,f),{signature:j,signed:v}=await m.signAmino(r,b),C={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:v.msgs.map(N=>t.fromAmino(N)),memo:l}},I=e.encode(C),T=sr.Int53.fromString(v.fee.gas).toNumber(),A=sr.Int53.fromString(v.sequence).toNumber(),$=Gs.makeAuthInfoBytes([{pubkey:p,sequence:A}],v.fee.amount,T,v.fee.granter,v.fee.payer,y);return Ze.TxRaw.fromPartial({bodyBytes:I,authInfoBytes:$,signatures:[de.fromBase64(j.signature)]})}}function Qu(e,t){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(t):!1}async function Hi({getSequence:e,signerAddress:t,incrementSequence:s,allowMissingAccount:o}){try{const{accountNumber:a,sequence:r}=await e(t);return{accountNumber:a,sequence:r+s}}catch(a){if(o&&Qu(a,t))return{accountNumber:0,sequence:s};throw a}}function ls(){const e=ie(),{signMessageAsync:t}=Qe.useSignMessage(),s=ce();return _.useMemo(()=>new Hu(e,o=>t({message:o}),s.restUrl),[e,t,s.restUrl])}const Ao=new Map,Rs=new Map;function Gu(e,t){const s=`${e}:${t}`;Rs.delete(s)}function ja(){const e=lt();return async t=>{if(Ao.has(t))return Ao.get(t);const{rpcUrl:s}=e(t),o=await or.Comet38Client.create(new or.HttpClient(s));return Ao.set(t,o),o}}function us(){const e=is(),t=bn(),s=ls(),o=ie(),a=ja();return async r=>{const i=`${o}:${r}`;if(Rs.has(i))return Rs.get(i);if(!s)throw new Error("Signer not initialized");const c=await a(r),l=await Le.SigningStargateClient.createWithSigner(c,s,{registry:e,aminoTypes:t,accountParser:Ku,broadcastPollIntervalMs:500});return Rs.set(i,l),l}}function Qi(){const{connector:e}=Qe.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new kt.BrowserProvider(await e.getProvider())}}class hn extends Error{constructor(t){super(t),this.name="TimeoutError"}}function Gi(e,t,s){let o;const a=new Promise((r,i)=>{o=setTimeout(()=>i(new hn(s)),t)});return Promise.race([e,a]).finally(()=>{clearTimeout(o)})}function Yi(e){return e.filter(t=>t.authorization["@type"].includes("GenericAuthorization")).filter(t=>!!t.authorization.msg)}function Zi(e){return e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance"?e.allowance?.expiration:e.expiration}function Yu(e){if(e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance")return e.allowedMessages??e.allowed_messages??[]}function Ji(){const e=ie(),t=lt();return{fetchFeegrant:async(r,i)=>{if(!e)return null;const c=t(r),l=z.create({prefixUrl:c.restUrl});try{const{allowance:u}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${i}`).json();return u}catch(u){if(u instanceof z.HTTPError&&[404,500].includes(u.response.status))return null;throw u}},fetchGrants:async(r,i)=>{if(!e)return[];const c=t(r),l=z.create({prefixUrl:c.restUrl}),{grants:u}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:i}}).json();return u},fetchAllGrants:async r=>{const i=t(r),c=e;if(!c)return[];const l=`cosmos/authz/v1beta1/grants/granter/${c}`,u=await Js(l,{prefixUrl:i.restUrl},"grants");return Yi(u)}}}const Vs=qe.createQueryKeys("interwovenkit:autosign",{expirations:(e,t,s)=>[e,t,s],grants:(e,t)=>[e,t]}),Zu=4,Xi=4;function Ju(e){return Object.entries(e).sort(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${t}:${[...s].sort().join(",")}`).join("|")}function Ca(){const e=se(),t=xn(),{enableAutoSign:s,defaultChainId:o}=e;if(!s)return{[o]:[]};if(typeof s!="boolean")return s;switch(t.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 Xu(){const{data:e}=oo(),t=Ca();return(s,o)=>{const a=o.every(i=>{const c=t[s];return c?c.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function oo(){const e=ie(),t=Ca(),s=Ju(t),{fetchFeegrant:o,fetchAllGrants:a}=Ji();return E.useQuery({queryKey:Vs.expirations(e,s,t).queryKey,queryFn:()=>ed({initiaAddress:e,messageTypes:t,fetchAllGrants:a,fetchFeegrant:o}),staleTime:V.MINUTE,retry:1})}async function ed(e){const{initiaAddress:t,messageTypes:s,fetchAllGrants:o,fetchFeegrant:a}=e;if(!t)return{expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}};const r={},i={},c={},l={},u=[];for(const[d,h]of Object.entries(s))r[d]=null,i[d]=void 0,c[d]=!1,h.length>0&&u.push([d,h]);if(u.length===0)return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i};const m=await ec(u,Zu,async([d,h])=>{const f=wa(t,d);try{const g=await o(d),p=f===void 0?g:f===null?[]:g.filter(C=>C.grantee===f),y=sd(p,h);if(y.length===0)return{chainId:d,expectedAddress:f,expiration:null,grantee:void 0};const x=await nd({chainId:d,candidates:y,fetchFeegrant:a,concurrency:Xi});if(!x)return{chainId:d,expectedAddress:f,expiration:null,grantee:void 0};const b=x.grantee.grants.filter(C=>h.includes(C.authorization.msg)).map(C=>C.expiration),j=Zi(x.feegrant.allowance),v=[...b,j],w=ka(v);return{chainId:d,expectedAddress:f,expiration:w?new Date(w):void 0,grantee:x.grantee.grantee}}catch{return{chainId:d,expectedAddress:f,expiration:null,grantee:void 0}}});for(const d of m)l[d.chainId]=d.expectedAddress,r[d.chainId]=d.expiration,i[d.chainId]=d.grantee;for(const[d]of u)c[d]=od({expiration:r[d],grantee:i[d],expectedAddress:l[d]});return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i}}async function ec(e,t,s){const o=new Array(e.length),a=Math.max(1,t);let r=0;const i=Array.from({length:Math.min(a,e.length)},async()=>{for(;;){const c=r;if(r+=1,c>=e.length)return;o[c]=await s(e[c],c)}});return await Promise.all(i),o}function td(e){const t=Yu(e.allowance);if(!(!t||t.includes("/cosmos.authz.v1beta1.MsgExec")))return!1;const o=Zi(e.allowance);if(!o)return!0;const a=new Date(o);return!Number.isNaN(a.getTime())&&Xe.isFuture(a)}async function nd(e){const{chainId:t,candidates:s,fetchFeegrant:o,concurrency:a=Xi}=e,r=await ec(s,a,async i=>{const c=await o(t,i.grantee);return c&&td(c)?{grantee:i,feegrant:c}:null});for(const i of r)if(i)return i;return null}function sd(e,t){if(t.length===0)return[];const s=new Map;for(const a of e){const r=s.get(a.grantee)||[];r.push({authorization:a.authorization,expiration:a.expiration}),s.set(a.grantee,r)}const o=[];for(const[a,r]of s){const i=r.filter(u=>!u.expiration||Xe.isFuture(new Date(u.expiration))),c=i.map(u=>u.authorization.msg);t.every(u=>c.includes(u))&&o.push({grantee:a,grants:i})}return o}function od(e){const{expiration:t,grantee:s,expectedAddress:o}=e,a=o===void 0?!!s:!!s&&o===s;switch(t){case null:return!1;case void 0:return a;default:return a&&Xe.isFuture(t)}}function ad(){const{data:e,refetch:t}=oo();_.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&Xe.isFuture(c));if(o.length===0)return;const a=ka(o);if(!a)return;const r=a.getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{t()},r+100);return()=>clearTimeout(i)},[e,t])}function ka(e){const t=e.filter(s=>s!==void 0);if(t.length!==0)return[...t].sort((s,o)=>new Date(s).getTime()-new Date(o).getTime())[0]}const tc=_.createContext(null),ao=()=>_.useContext(tc);class nc extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(t,s,o,a,r,i,c){super(t),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=c}}const rd=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,So=new Map;function id(e){const t=e.match(rd);if(!t)return null;const[,s,o,a]=t;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:a.replace(/^0+/,"")||"0"}}async function cd(e,t,s){const o=`${e}:${t}`;if(So.has(o))return So.get(o);try{const a=t==="0x1"?"0x1.json":`${e}/${t}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await z.get(r).json();return So.set(o,i),i}catch{return null}}function ld(e,t,s,o,a,r,i){return new nc(e,t,s,o,a,r,i)}async function Nn(e,t,s){if(!t.metadata?.is_l1&&t.metadata?.minitia?.type!=="minimove")return await ct(e);const o=id(e.message);if(!o)return await ct(e);const a=await cd(t.chain_name,o.moduleAddress,s),r=`0x${parseInt(o.errorCode,10).toString(16)}`,i=`Failed with code ${r} in module ${o.moduleName} at ${o.moduleAddress}`,c=a?.[o.moduleName]?.[o.errorCode],l=c||i,u=!!c;return ld(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,u)}const ud=10;function sc(){const e=ie();return(t,s)=>E.queryOptions({queryKey:Xs.txs(t.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":ud},{txs:a}=await z.create({prefixUrl:t.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:V.SECOND})}function dd(e,t){const s=sc();return E.useSuspenseQuery(s(e,t))}function md(e,t){const s=e.flatMap((o,a)=>(t[a]??[]).map(i=>({...i,chain:o})));return L.sortWith([L.descend(o=>new Date(o.timestamp).getTime())])(s)}const hd=()=>{const e=_e(),t=sc(),s=E.useQueries({queries:e.map(i=>t(i,{enabled:!0}))}),o=s.map(L.prop("data")),a=md(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};async function Na(e){if(e.metadata?.is_l1){const{restUrl:t}=e,{gas_prices:s}=await z.create({prefixUrl:t}).get("initia/tx/v1/gas_prices").json();return s.slice().sort(L.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const r=o==="uinit"?1:hi;return{amount:q(a).times(r).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:t,fixed_min_gas_price:s})=>{if(L.isNil(s))throw new Error(`${t} has no price`);return{amount:String(s),denom:t}})}function Ia(e){const{data:t}=E.useSuspenseQuery({queryKey:Zs.gasPrices(e).queryKey,queryFn:()=>Na(e),staleTime:V.SECOND});return t}function Aa(e){const t=ie(),{data:s}=dd(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=>k.InitiaAddress.equals(t,kt.computeAddress(`0x${de.toHex(ht.Secp256k1.uncompressPubkey(de.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const oc="approve",ro=H.atom(),ac=H.atom(null),fd=Ht,pd=1.5;function gd({gasPrices:e,preferredFeeDenom:t,fallbackFeeDenom:s,allowedFeeDenoms:o}){const a=o?.length?e.filter(({denom:i})=>o.includes(i)):e;if(a.length===0)throw new Error("No allowed gas price tokens available for auto-sign");const r=i=>i?a.find(c=>c.denom===i):void 0;return r(t)??r(s)??a[0]}function _d({simulatedGas:e,gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,policy:a}){if(!Number.isFinite(e)||e<=0)throw new Error("Auto-sign gas simulation failed");const{gasMultiplier:r,maxGasMultiplierFromSim:i,allowedFeeDenoms:c}=a;if(r<=0||i<=0||r>i)throw new Error("Invalid auto-sign gas multiplier policy");const l=Math.ceil(e*r),u=gd({gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,allowedFeeDenoms:c});return Le.calculateFee(l,Le.GasPrice.fromString(`${u.amount}${u.denom}`))}function yd({derivedAddress:e,messages:t,encoder:s}){return{messages:Li({granteeAddress:e,messages:t,encoder:s})}}function xd(e){if(!(e instanceof Error))return!1;const t=e.message.toLowerCase(),s=e.code,o=e.cause?.code,a=t.includes("user rejected")||t.includes("rejected the request")||t.includes("user denied")||t.includes("denied by user")||t.includes("user cancelled")||t.includes("user canceled")||t.includes("cancelled by user")||t.includes("canceled by user");return s===4001||s==="ACTION_REJECTED"||o===4001||o==="ACTION_REJECTED"||a}async function bd({queryClient:e,messages:t,memo:s,pubkey:o,sequence:a}){const r=Le.createProtobufRpcClient(e),i=new ar.ServiceClientImpl(r),c=Ze.Tx.fromPartial({authInfo:Ze.AuthInfo.fromPartial({fee:Ze.Fee.fromPartial({}),signerInfos:[{publicKey:o,sequence:BigInt(a),modeInfo:{single:{mode:li.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:Ze.TxBody.fromPartial({messages:Array.from(t),memo:s}),signatures:[new Uint8Array]});return await i.Simulate(ar.SimulateRequest.fromPartial({txBytes:Ze.Tx.encode(c).finish()}))}function wd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e}async function vd({address:e,chainId:t,messages:s,memo:o,fee:a,preferredFeeDenom:r,client:i,allowAutoSign:c=!0,allowWalletDerivation:l=!1},u){const m=async()=>u.signWithEthSecp256k1(t,e,s,a,o),d=(y,x)=>{u.onAutoSignFallback?.({chainId:t,reason:y,errorMessage:wd(x)})};if(!c)return m();if(!u.validateAutoSign(t,s))return d("validation_failed"),m();let f=u.getWallet(t),g=!1;if(!f&&l)try{f=await u.deriveWallet(t)}catch(y){if(xd(y))throw y;d("derive_wallet_failed",y),g=!0,f=void 0}if(!f)return g||d("missing_derived_wallet"),m();let p;try{const y=i??await u.getSigningClient(t);p=await u.computeAutoSignFee({chainId:t,messages:s,memo:o,derivedWallet:f,preferredFeeDenom:r,fallbackFeeDenom:a.amount[0]?.denom,client:y})}catch(y){return d("fee_computation_failed",y),m()}try{return await u.signWithDerivedWallet(t,e,s,p,o,f)}catch(y){return d("derived_wallet_sign_failed",y),m()}}function rc(){const e=ie(),{autoSignFeePolicy:t}=se(),s=lt(),o=ja(),a=us(),r=is(),i=Xu(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:u}=so(),m=zi(),d=Pn(),h=p=>{const y=t?.[p];return{gasMultiplier:y?.gasMultiplier??fd,maxGasMultiplierFromSim:y?.maxGasMultiplierFromSim??pd,allowedFeeDenoms:y?.allowedFeeDenoms}},f=async({chainId:p,messages:y,memo:x,derivedWallet:b,preferredFeeDenom:j,fallbackFeeDenom:v,client:w})=>{const C=s(p),I=await Na(C),A=yd({derivedAddress:b.address,messages:y,encoder:r}).messages.map(K=>r.encodeAsAny(K)),$=Ai(ba(b.publicKey)),{sequence:N}=await Hi({getSequence:K=>w.getSequence(K),signerAddress:b.address,incrementSequence:0,allowMissingAccount:!0}),S=await o(p),P=Le.QueryClient.withExtensions(S,Le.setupTxExtension),{gasInfo:F}=await bd({queryClient:P,messages:A,memo:x,pubkey:$,sequence:N}),D=F?Number(F.gasUsed.toString()):0,Z=h(p);return _d({simulatedGas:D,gasPrices:I,preferredFeeDenom:j,fallbackFeeDenom:v,policy:Z})},g=async(p,y,x,b,j,v)=>{let w=v??c(p);w||(w=await l(p));const C=u(p);if(!C)throw new Error("Derived wallet key not initialized");return await Ru({chainId:p,granterAddress:y,messages:x,fee:b,memo:j,derivedWallet:w,privateKey:C,encoder:r,signWithEthSecp256k1:m})};return p=>vd({...p,address:e},{validateAutoSign:i,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:f,signWithDerivedWallet:g,signWithEthSecp256k1:m,onAutoSignFallback:({chainId:y,reason:x,errorMessage:b})=>{d("AutoSign Fallback",{chainId:y,reason:x,errorMessage:b})}})}function ic(){const e=H.useAtomValue(ro);if(!e)throw new Error("Tx request not found");return e}function io(){const e=Me(),t=ie(),{defaultChainId:s,registryUrl:o}=se(),a=lt(),{openDrawer:r,closeDrawer:i}=Dt(),{openModal:c,closeModal:l}=ao(),u=H.useSetAtom(ro),m=H.useSetAtom(ac),d=ja(),h=us(),f=ls(),g=is(),p=rc(),y=async({messages:A,memo:$,chainId:N=s})=>{try{return await(await h(N)).simulate(t,A,$)}catch(S){throw await Nn(S,a(N),o)}},x=async({messages:A,memo:$,chainId:N=s})=>{const S=await d(N),P=Le.QueryClient.withExtensions(S,Le.setupTxExtension),F=A.map(O=>g.encodeAsAny(O)),[D]=await f.getAccounts(),Z=En.encodeSecp256k1Pubkey(D.pubkey),K=await h(N),{sequence:W}=await K.getSequence(t);return P.tx.simulate(F,$,Z,W)},b=async({txRequest:A,broadcaster:$})=>{const S={...{memo:"",chainId:s,gas:A.gas||await y(A),gasAdjustment:Ht,gasPrices:null,spendCoins:[],internal:!1},...A};return new Promise((P,F)=>{u({txRequest:S,resolve:async Z=>{try{const K=await h(S.chainId),W=await $(K,Ze.TxRaw.encode(Z).finish());P(W),typeof S.internal=="string"&&e(S.internal)}catch(K){F(await Nn(K,a(S.chainId),o))}finally{D()}},reject:Z=>{F(Z),D()}}),S.internal?c({path:"/tx"}):r("/tx");const D=()=>{if(!S.internal){e("/blank"),i();return}l()}})},j=async A=>{const $=A.chainId??s;try{const N=await b({txRequest:A,broadcaster:async(S,P)=>await S.broadcastTxSync(P)});return A.internal&&typeof A.internal!="number"&&(m({txHash:N,chainId:$,status:"loading"}),T({txHash:N,chainId:A.chainId}).then(S=>{m({status:S.code===0?"success":"error",chainId:$,txHash:N})}).catch(()=>{m({status:"error",chainId:$,txHash:N})})),N}catch(N){throw A.internal&&typeof A.internal!="number"&&m({status:"error",chainId:$,error:N}),N}},v=(A,$=30*1e3,N=.5*1e3)=>b({txRequest:A,broadcaster:async(S,P)=>{const F=await S.broadcastTx(P,$,N);if(F.code!==0)throw new Error(F.rawLog);return F}}),w=async({chainId:A,messages:$,memo:N="",fee:S,preferredFeeDenom:P})=>{const F=await h(A),D=await p({chainId:A,messages:$,memo:N,fee:S,preferredFeeDenom:P,client:F,allowWalletDerivation:!0});return{client:F,signedTx:D}},C=async A=>{const $=A.chainId??s;try{const{client:N,signedTx:S}=await w({...A,chainId:$});return await N.broadcastTxSync(Ze.TxRaw.encode(S).finish())}catch(N){throw await Nn(N,a($),o)}},I=async(A,$=30*1e3,N=.5*1e3)=>{const S=A.chainId??s;try{const{client:P,signedTx:F}=await w({...A,chainId:S}),D=await P.broadcastTx(Ze.TxRaw.encode(F).finish(),$,N);if(D.code!==0)throw new Error(D.rawLog);return D}catch(P){throw await Nn(P,a(S),o)}},T=async({chainId:A=s,...$})=>{try{const N=await h(A);return await cc({...$,client:N})}catch(N){throw N instanceof hn?N:await Nn(N,a(A),o)}};return{estimateGas:y,simulateTx:x,requestTxSync:j,requestTxBlock:v,submitTxSync:C,submitTxBlock:I,waitForTxConfirmation:T}}async function cc({txHash:e,client:t,timeoutMs:s=30*1e3,intervalMs:o=.5*1e3}){const a=Date.now();for(;;){const r=await t.getTx(e);if(r){if(r.code!==0)throw new Error(r.rawLog);return r}if(Date.now()-a>=s)throw new hn(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const jd="/cosmos.authz.v1beta1.MsgExec";function Cd(e){if(e.explicitGrantee)return[e.explicitGrantee];const t=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(s=>!!s);return[...new Set(t)]}function kd(e){const t=[e.currentGrantee,e.expectedGrantee].filter(s=>!!s);return[...new Set(t)]}function Nd(e){const{isEnabledOnTargetChain:t,hasEnabledSibling:s,didBroadcast:o,hasExplicitGrantee:a}=e;return s?!1:t===!1?!0:t===void 0&&o&&!a}function Id(e){return[...new Set(e.map(t=>t.authorization.msg))].filter(t=>!!t)}async function lc(e){const t=[Vs.expirations._def,Vs.grants._def];for(const s of t)await e.invalidateQueries({queryKey:s})}function uc(){const e=ie(),{fetchFeegrant:t,fetchGrants:s}=Ji();return async o=>{const{chainId:a,grantee:r}=o;if(!e)throw new Error("Granter wallet not initialized");const i=await t(a,r),c=await s(a,r),l=i?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:ui.MsgRevokeAllowance.fromPartial({granter:e,grantee:r})}]:[],m=Id(c).map(d=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:ha.MsgRevoke.fromPartial({granter:e,grantee:r,msgTypeUrl:d})}));return[...l,...m]}}function Ad(){const e=ie(),t=Ca(),{requestTxBlock:s}=io(),o=E.useQueryClient(),[a,r]=H.useAtom(rs),{closeDrawer:i}=Dt(),c=uc(),{deriveWallet:l}=so();return E.useMutation({mutationFn:async u=>{if(!a)throw new Error("No pending request");const{chainId:m}=a;if(!e)throw new Error("Wallet not connected");const d=t[m];if(!d||d.length===0)throw new Error(`No message types configured for chain ${m}`);const h=await l(m);Gu(e,m);const f=wa(e,m),g=kd({currentGrantee:h.address,expectedGrantee:f}),y=(await Promise.all(g.map(C=>c({chainId:m,grantee:C})))).flat(),x=u===0?void 0:Xe.addMilliseconds(new Date,u),b={typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:cn.BasicAllowance.encode(cn.BasicAllowance.fromPartial({expiration:x})).finish()},j={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:ui.MsgGrantAllowance.fromPartial({granter:e,grantee:h.address,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.AllowedMsgAllowance",value:cn.AllowedMsgAllowance.encode(cn.AllowedMsgAllowance.fromPartial({allowance:b,allowedMessages:[jd]})).finish()}})},v=d.map(C=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:ha.MsgGrant.fromPartial({granter:e,grantee:h.address,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:rr.GenericAuthorization.encode(rr.GenericAuthorization.fromPartial({msg:C})).finish()},expiration:x}})})),w=[...y,j,...v];return await s({messages:w,chainId:m,internal:!0}),{chainId:m,derivedWallet:h}},onSuccess:async({chainId:u,derivedWallet:m})=>{e&&Eu(e,u,m.address),await lc(o),a?.resolve()},onError:u=>{a?.reject(u)},onSettled:()=>{r(null),i()}})}function dc(e){const t=se(),s=_e(),o=lt(),{getWallet:a,clearWallet:r}=so(),{requestTxBlock:i}=io(),c=E.useQueryClient(),l=uc(),{data:u,refetch:m}=oo();return E.useMutation({mutationFn:async(d=t.defaultChainId)=>{const h=a(d),f=u?.granteeByChain[d];let g;e?.grantee||(g=(await m()).data?.granteeByChain[d]);const p=Cd({explicitGrantee:e?.grantee,cachedDerivedAddress:h?.address,statusGrantee:f,refetchedStatusGrantee:g});if(p.length===0)throw new Error("No grantee address available");const x=(await Promise.all(p.map(b=>l({chainId:d,grantee:b})))).flat();return x.length===0?{chainId:d,didBroadcast:!1}:(await i({messages:x,chainId:d,internal:e?.internal}),{chainId:d,didBroadcast:!0})},onSuccess:async({chainId:d,didBroadcast:h})=>{await lc(c);const f=o(d),g=s.filter(v=>v.bech32_prefix===f.bech32_prefix).map(v=>v.chain_id).filter(v=>v!==d);let p;try{p=(await m()).data}catch{p=void 0}const y=p??u;let x=!1;g.length>0&&y&&(x=g.some(v=>y?.isEnabledByChain[v]));const b=h?p?.isEnabledByChain[d]:(p??u)?.isEnabledByChain[d];Nd({isEnabledOnTargetChain:b,hasEnabledSibling:x,didBroadcast:h,hasExplicitGrantee:!!e?.grantee})&&r(d)}})}const Sa=[{value:10*Ri,label:"for 10 minutes"},{value:Pi,label:"for 1 hour"},{value:mr,label:"for 1 day"},{value:7*mr,label:"for 7 days"},{value:0,label:"until revoked"}],Zo=Sa[0].value;function Sd(e){return e===void 0?Zo:Sa.some(t=>t.value===e)?e:Zo}function Td(){const{defaultChainId:e}=se(),{openDrawer:t}=Dt(),s=H.useSetAtom(rs),o=dc(),{data:a={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:r}=oo();return{...a,isLoading:r,enable:async(l=e,u)=>new Promise((m,d)=>{s({chainId:l,defaultDuration:Sd(u?.defaultDuration),resolve:m,reject:d}),t("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}function mc(e){return e.assets.reduce((t,{value:s})=>t+(s??0),0)}function Ed(e){return e.assets.reduce((t,{quantity:s})=>t.plus(s),q(0)).toString()}function $d(e,t){return{symbol:t?.symbol??e,logoUrl:t?.logoUrl??ya}}function hr(e){return L.pick(["chainId","name","logoUrl"],e)}function Md(e){return L.sortWith([L.descend(({symbol:t})=>t===pt),L.descend(mc),L.descend(({assets:t})=>t.length),L.ascend(({symbol:t})=>t)])(e)}function Ld(e){return L.sortWith([L.descend(({value:t})=>t??0),L.descend(({quantity:t})=>Number(t)),L.ascend(({chain:t})=>t.name)])(e)}function qd(e,t){return L.sortWith([L.descend(({chain:s})=>s.chainId===t),L.ascend(({chain:s})=>s.name),L.ascend(({denom:s})=>s)])(e)}function Rd(e,t){return L.sortWith([L.descend(({chainId:s})=>s===t),L.descend(L.prop("value"))])(e)}function Pd(e,t,s,o,a){const r=e.find(d=>d.metadata?.is_l1)?.chainId,i={};for(const d of e){const h=d.chainId,f=t[h]??[],g=s[h],p=o[h],y=[];for(const{amount:x,denom:b}of f){if(!q(x).gt(0))continue;const j=g?.find(T=>T.denom===b),v=p?.find(T=>T.id===b)?.price,w=j?.decimals??0,C=k.fromBaseUnit(x,{decimals:w}),I=v?q(C).times(v).toNumber():void 0;y.push({...$d(b,j),amount:x,denom:b,decimals:w,quantity:C,price:v,value:I,address:j?.address,unlisted:!j,chain:hr(d)})}i[h]=y}const c=new Map;for(const[d,h]of Object.entries(i)){if(h.length===0)continue;const f=e.find(p=>p.chainId===d);if(!f)continue;const g=h.reduce((p,{value:y})=>p+(y??0),0);c.set(d,{...hr(f),value:g})}const l=new Map;for(const d of Object.values(i))for(const h of d)if(!h.unlisted){const{symbol:f}=h,g=l.get(f)??[];l.set(f,[...g,h])}const u=[];for(const[d,h]of l){const f=L.head(h);if(!f)continue;const g=Ld(h),p=g.reduce((x,{value:b})=>x+(b??0),0),y=g.reduce((x,{quantity:b})=>x.plus(b),q(0)).toNumber();u.push({symbol:d,logoUrl:f.logoUrl,assets:g,totalValue:p,totalAmount:y})}const m=[];for(const d of Object.values(i))for(const h of d)h.unlisted&&m.push(h);return{chainsByValue:Rd(Array.from(c.values()),a),assetGroups:Md(u),unlistedAssets:qd(m,r),totalValue:u.reduce((d,h)=>d+h.totalValue,0)}}function Ta(){const{defaultChainId:e}=se(),t=_e(),s=du(),o=os(),a=_a(),r=t.map(h=>h.chainId),i=L.zipObj(r,s.map(L.prop("data"))),c=L.zipObj(r,o.map(L.prop("data"))),l=L.zipObj(r,a.map(L.prop("data"))),u=Pd(t,i,c,l,e),m=[s,o,a].flat().some(({isLoading:h})=>h);return{...u,isLoading:m,refetch:()=>{s.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),a.forEach(({refetch:h})=>h())}}}function ie(){const e=Bn();return e?k.InitiaAddress(e).bech32:""}function Bn(){const{address:e}=Qe.useAccount();return e?k.InitiaAddress(e).hex:""}function Yt(){const e=xn(),t=ie(),s=Bn();return e.metadata?.minitia?.type==="minievm"?s:t}function hc(e){const t=Yt(),s=e??t,o=vi();return E.useQuery({queryKey:Xs.username(o.restUrl,s).queryKey,queryFn:()=>o.getUsername(s),enabled:!!s,staleTime:V.MINUTE})}function tt(){const e=Yt(),t=ie(),s=Bn(),{data:o}=hc(),a=ls(),r=Fi(),i=Td(),{isDrawerOpen:c,openDrawer:l}=Dt(),{isModalOpen:u}=Dn(),m=()=>{l("/")},d=()=>{l("/connect")},h=b=>{l("/bridge",b)},f=Uu(),g=Ou(),p=io();return{address:e,initiaAddress:t,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:c||u,openConnect:d,openWallet:m,openBridge:h,openDeposit:f,openWithdraw:g,disconnect:r,autoSign:i,...p}}const Dd="_status_tn9m1_1",Bd="_error_tn9m1_9",fr={status:Dd,error:Bd},je=({error:e,children:t})=>n.jsx("p",{className:B(fr.status,{[fr.error]:e}),role:e?"alert":"status",children:t}),xe=({errorBoundaryProps:e={fallbackRender:({error:o})=>n.jsx(je,{error:!0,children:o.message})},suspenseFallback:t=n.jsx(je,{children:"Loading..."}),children:s})=>n.jsx(di.ErrorBoundary,{...e,children:n.jsx(_.Suspense,{fallback:t,children:s})}),gn=1n<<64n,Fd=1n<<63n,fc=(1n<<128n)-1n;function Gt(e){const t=BigInt(e);return t>=Fd?t-gn:t}const Ud=(1n<<256n)-1n,Wt=443636n,Od=4295048017n,Vd=18446744073709551616n,Kd=79226673515401279992447579062n,Wd=255738958999603826347141n;function zd(e,t,s){const o=Number(Gt(e)),a=Number(Gt(t)),r=Math.floor(-Number(Wt)/s)*s,i=Math.floor(Number(Wt)/s)*s;return o===r&&a===i}function pc(e){return e>>64n}function Hd(e){const t=e>>64n;return e%gn!==0n?t+1n:t}function Mn(e){if(e<0n||e>fc)throw new Error("INPUT_OUT_OF_RANGE");return e}function Qd(e,t){const s=e*t>>64n;if(s>fc)throw new Error("OVERFLOW");return s}function Ea(e,t){return e>t?[t,e]:[e,t]}function Gd(e,t,s,o){if(e===t)return 0n;const[a,r]=Ea(e,t);if(a===0n||r===0n)return 0n;const i=s*gn,c=r-a,l=i*c;if(l===0n)return 0n;const u=a*r;return o?(l-1n)/u+1n:l/u}function Yd(e,t,s,o){if(e===t)return 0n;const[a,r]=Ea(e,t),c=(r-a)*s;return o?Hd(Mn(c)):pc(Mn(c))}function pr(e,t,s){return Gd(e,t,s<0n?-s:s,s>=0n)}function gr(e,t,s){return Yd(e,t,s<0n?-s:s,s>=0n)}const To=1n<<64n,_r=1n<<65n,Zd=64n;function Jd(e){if(e<=0n)throw new Error("LOG_2_ZERO_UNBOUNDED");let t=e,s=0n,o=0n,a=1n<<Zd-1n,r=0n,i=1;for(;t>=_r;)t>>=1n,s+=To;for(;t<To;)i=0,t<<=1n,o+=To;for(;r<62n;){const l=t>>1n;t=l*l>>62n,t>=_r&&(t>>=1n,s+=a),a>>=1n,r+=1n}const c=i>0?Mn(s):Mn(o-s);return[i,c]}function zt(e){const t=e<0n?-e:e;if(t>Wt)throw new Error("MAX_TICK");let s=(t&0x1n)!==0n?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;(t&0x2n)!==0n&&(s=s*0xfff97272373d413259a46990580e213an>>128n),(t&0x4n)!==0n&&(s=s*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(t&0x8n)!==0n&&(s=s*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(t&0x10n)!==0n&&(s=s*0xffcb9843d60f6159c9db58835c926644n>>128n),(t&0x20n)!==0n&&(s=s*0xff973b41fa98c081472e6896dfb254c0n>>128n),(t&0x40n)!==0n&&(s=s*0xff2ea16466c96a3843ec78b326b52861n>>128n),(t&0x80n)!==0n&&(s=s*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(t&0x100n)!==0n&&(s=s*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(t&0x200n)!==0n&&(s=s*0xf987a7253ac413176f2b074cf7815e54n>>128n),(t&0x400n)!==0n&&(s=s*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(t&0x800n)!==0n&&(s=s*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(t&0x1000n)!==0n&&(s=s*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(t&0x2000n)!==0n&&(s=s*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(t&0x4000n)!==0n&&(s=s*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(t&0x8000n)!==0n&&(s=s*0x31be135f97d08fd981231505542fcfa6n>>128n),(t&0x10000n)!==0n&&(s=s*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(t&0x20000n)!==0n&&(s=s*0x5d6af8dedb81196699c329225ee604n>>128n),(t&0x40000n)!==0n&&(s=s*0x2216e584f5fa1ea926041bedfe98n>>128n),e>=0n&&(s=Ud/s);const o=s/gn;return s%gn!==0n?o+1n:o}function Xd(e){if(e<Od||e>=Kd)throw new Error("INVALID_SQRT_PRICE");const[,t]=Jd(Mn(e)),s=Qd(t,Mn(Wd)),o=pc(s);let a,r,i;if(o===0n?(a=-1n,r=0n,i=1n):e<Vd?(a=-o-1n,r=-o,i=-o+1n):(a=o-1n,r=o,i=o+1n),a<-Wt&&(a=-Wt),i>Wt&&(i=Wt),zt(i)<=e){if(i>=Wt)throw new Error("GTE_MAX_TICK");if(zt(i+1n)<=e)throw new Error("NO_SAFE_TICK_FOUND");return i}if(zt(r)<=e)return r;if(zt(a)<=e)return a;throw new Error("NO_SAFE_TICK_FOUND")}function em(e,t,s,o){const[a,r]=Ea(t,s);return e<a?[pr(a,r,o),0n]:e<r?[pr(e,r,o),gr(a,e,o)]:[0n,gr(a,r,o)]}function tm({tickLower:e,tickUpper:t,liquidity:s,sqrtPrice:o}){const a=zt(Gt(e)),r=zt(Gt(t));return em(BigInt(o),BigInt(a),BigInt(r),BigInt(s))}const Eo=gn*gn,nm=1e-300,sm=BigInt(Number.MAX_SAFE_INTEGER);function yr(e){const t=e*e,s=t/Eo,o=t%Eo;return s>sm?Number(s):Number(s)+Number(o)/Number(Eo)}function xr(e){if(!Number.isFinite(e)||e<0)throw new Error("calculateTokens: price must be finite and non-negative");return 1/Math.max(e,nm)}function om({tickLower:e,tickUpper:t,isReversed:s=!1}){const o=zt(Gt(e)),a=zt(Gt(t)),r=yr(o),i=yr(a);return s?{min:xr(i),max:xr(r)}:{min:r,max:i}}const wn=qe.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,t)=>[e,t],lpPrices:(e,t)=>[e,t],poolByMetadata:(e,t)=>[e,t],clammPositions:(e,t)=>[e,t],clammPoolInfo:(e,t,s)=>[e,t,s],clammFees:(e,t,s)=>[e,t,s],clammIncentive:(e,t,s,o)=>[e,t,s,o]}),$a={lens:"lens",pool:"pool",farming:"farming"},Ma={"interwoven-1":{clammModuleAddress:"0xd78a3b72c7ef0cfba7286bfb8c618aa4d6011dce05a832871cc9ab323c25f55e",incentiveModuleAddress:"0xcb2999c70a9b8db7cb473255bb01f956f0726087f08b04ece50844a6d8167351"},"initiation-2":{clammModuleAddress:"0x6b41bf295bc31cd9bef75a9a5a67e5a8d6749b34a7ab3105808251fa2697823d",incentiveModuleAddress:"0xf8ef0cb7c73607b7658524565015ce2aadc45ccf7164e5351959a4d7a1c37753"}};function am(e){return e.startsWith("0x")?`0x${e.replace(/^0x/,"").padStart(64,"0")}`:k.InitiaAddress(e).hex}function Ks(e){return de.toBase64(k.InitiaAddress(am(e),32).bytes)}function gc(e,t){return`${e}:${t}`}function rm(e){return`clamm:${e}`}function im(e){return!Array.isArray(e)||e.length===0?[]:Array.isArray(e[0])?e.flat():e}function cm(e){return e.map(t=>({tokenAddress:t.token_address,lpMetadata:t.lp_metadata,tickLower:t.tick_lower,tickUpper:t.tick_upper,liquidity:t.liquidity,incentives:t.incentives.map(s=>({incentiveAddress:s.incentive_address,rewardMetadata:s.reward_metadata}))}))}function lm(e){const{dexUrl:t}=se();return E.useSuspenseQuery({queryKey:wn.clammPositions(t,e).queryKey,queryFn:async()=>{if(!e)return[];const s=[];let o;do{const a={"pagination.limit":"100"};o&&(a["pagination.key"]=o);const r=await z.get(`${t}/indexer/clamm/v1/positions/${e}`,{searchParams:a}).json().catch(()=>({positions:[],pagination:{next_key:null,total:"0"}}));s.push(...im(r.positions)),o=r.pagination.next_key||void 0}while(o);return cm(s)},staleTime:V.MINUTE})}function um(e){const t=ce(),{viewFunction:s}=k.createMoveClient(t.restUrl),a=E.useSuspenseQueries({queries:e.map(r=>({queryKey:wn.clammPoolInfo(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=Ma[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:$a.lens,functionName:"get_pool_info",typeArgs:[],args:[Ks(r)]});return!c?.sqrt_price||!c?.tick_spacing?null:{sqrtPrice:c.sqrt_price,tickSpacing:c.tick_spacing}}catch{return null}},staleTime:V.MINUTE}))}).map(r=>r.data);return _.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(i,a[c]??null)}),r},[e,a])}function dm(e){const t=ce(),{viewFunction:s}=k.createMoveClient(t.restUrl),a=E.useSuspenseQueries({queries:e.map(r=>({queryKey:wn.clammFees(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=Ma[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:$a.pool,functionName:"fees_available",typeArgs:[],args:[Ks(r)]});return Array.isArray(c)?c:null}catch{return null}},staleTime:V.MINUTE}))}).map(r=>r.data);return _.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{const l=a[c];l&&r.set(i,l)}),r},[e,a])}function mm(e){const t=ce(),{viewFunction:s}=k.createMoveClient(t.restUrl),a=E.useSuspenseQueries({queries:e.map(r=>({queryKey:wn.clammIncentive(t.restUrl,t.chainId,r.tokenAddress,r.incentiveAddress).queryKey,queryFn:async()=>{const i=Ma[t.chainId];if(!i)return"0";try{const c=await s({moduleAddress:i.incentiveModuleAddress,moduleName:$a.farming,functionName:"pending_reward_info",typeArgs:[],args:[Ks(r.tokenAddress),Ks(r.incentiveAddress)]});return typeof c=="string"?c:Array.isArray(c)&&typeof c[0]=="string"?c[0]:"0"}catch{return"0"}},staleTime:V.MINUTE}))}).map(r=>r.data);return _.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(gc(i.tokenAddress,i.incentiveAddress),a[c]||"0")}),r},[e,a])}function _c(e){const{dexUrl:t}=se(),o=E.useSuspenseQueries({queries:e.map(a=>({queryKey:wn.poolByMetadata(t,a).queryKey,queryFn:async()=>{try{return(await z.get(`${t}/indexer/dex/v2/pools/${encodeURIComponent(a)}`).json()).pool}catch{return null}},staleTime:V.MINUTE}))}).map(a=>a.data);return _.useMemo(()=>{const a=new Map;return e.forEach((r,i)=>{a.set(r,o[i]??null)}),a},[e,o])}function yc(e,t){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>t.get(s.denom)?.logoUrl||"")}function hm(e){return _c(e)}function fm(e){const t=ce(),s=Qt(t),o=_.useMemo(()=>{const i=new Map;for(const c of s)i.set(c.denom,c);return i},[s]),a=_.useMemo(()=>e.map(i=>k.denomToMetadata(i)),[e]),r=_c(a);return _.useMemo(()=>{const i=new Map;return e.forEach((c,l)=>{const u=a[l];if(!u){i.set(c,null);return}const m=r.get(u);if(!m){i.set(c,null);return}if(c===Pu){i.set(c,{...m,symbol:Du});return}const d=m.coins.map(h=>o.get(h.denom)?.symbol||h.denom).join("-");i.set(c,{...m,symbol:d})}),i},[e,a,r,o])}const pm="lock_staking";function xc(e,t){const s=`${t}::lock_staking::StakingAccount`,o=k.createObjectAddress(e,s);return k.InitiaAddress(o).bech32}const ds=qe.createQueryKeys("interwovenkit:initia-staking",{delegations:(e,t)=>[e,t],undelegations:(e,t,s)=>[e,t,s],lockStaking:(e,t,s)=>[e,t,s],stakingRewards:(e,t)=>[e,t],lockStakingRewards:(e,t,s)=>[e,t,s]});function La(){const{restUrl:e}=ce(),t=ie();return E.useSuspenseQuery({queryKey:ds.delegations(e,t||"").queryKey,queryFn:async()=>t?(await z.get(`${e}/initia/mstaking/v1/delegations/${t}`).json()).delegation_responses:[],select:s=>{const o=new Map;for(const a of s){const r=a.delegation.validator_address;for(const i of a.balance){const c=k.denomToMetadata(i.denom),l={denom:i.denom,metadata:c,amount:i.amount,validator:r},u=o.get(c)??[];u.push(l),o.set(c,u)}}return o},staleTime:V.MINUTE})}function qa(){const{restUrl:e}=ce(),{lockStakeModuleAddress:t}=se(),s=ie(),o=s?xc(s,t):"";return E.useSuspenseQuery({queryKey:ds.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await z.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await z.get(`${e}/initia/mstaking/v1/delegators/${o}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...a.unbonding_responses,...r.unbonding_responses]},select:a=>{const r=new Map;for(const i of a){const c=i.validator_address;for(const l of i.entries)for(const u of l.balance){const m=k.denomToMetadata(u.denom),d={denom:u.denom,metadata:m,amount:u.amount,validator:c,completionTime:l.completion_time},h=r.get(m)??[];h.push(d),r.set(m,h)}}return r},staleTime:V.MINUTE})}function Ra(){const{restUrl:e}=ce(),{lockStakeModuleAddress:t}=se(),s=ie();return E.useSuspenseQuery({queryKey:ds.lockStaking(e,s||"",t).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=k.createMoveClient(e);return await o({moduleAddress:t,moduleName:pm,functionName:"get_locked_delegations",typeArgs:[],args:[de.toBase64(k.InitiaAddress(s,32).bytes)]})??[]},select:o=>{const a=new Map;for(const r of o){const i={metadata:r.metadata,amount:r.amount,validator:r.validator,releaseTime:r.release_time},c=a.get(r.metadata)??[];c.push(i),a.set(r.metadata,c)}return a},staleTime:V.MINUTE})}function bc(e){const t=new Map;if(!e.total||!Array.isArray(e.total))return t;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=k.denomToMetadata(s.denom);let a=new q(0);for(const i of s.dec_coins)i?.amount&&(a=a.plus(i.amount));const r=t.get(o);if(r){const i=new q(r.amount);a=a.plus(i)}t.set(o,{denom:s.denom,amount:a.toString()})}return t}function wc(){const{restUrl:e}=ce(),t=ie();return E.useSuspenseQuery({queryKey:ds.stakingRewards(e,t||"").queryKey,queryFn:async()=>t?await z.get(`${e}/initia/distribution/v1/delegators/${t}/rewards`).json():{rewards:[],total:[]},select:bc,staleTime:V.MINUTE})}function vc(){const{restUrl:e}=ce(),{lockStakeModuleAddress:t}=se(),s=ie(),o=s?xc(s,t):"";return E.useSuspenseQuery({queryKey:ds.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await z.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:bc,staleTime:V.MINUTE})}function Pa(){const e=ce(),t=Qt(e),{data:s,isLoading:o}=Pt(e),{data:a}=La(),{data:r}=qa(),{data:i}=Ra(),c=_.useMemo(()=>{const f=new Set;for(const g of a.keys())f.add(g);for(const g of i.keys())f.add(g);for(const g of r.keys())f.add(g);return Array.from(f)},[a,i,r]),l=Bs(c),u=_.useMemo(()=>{const f=new Map;if(s)for(const g of s)f.set(g.id,g.price);return f},[s]),m=_.useMemo(()=>{const f=new Map;for(const g of t)f.set(g.denom,g);return f},[t]),d=_.useMemo(()=>{const f=[],g=p=>{const y=m.get(p);return y?{symbol:y.symbol,decimals:y.decimals}:null};for(const[p,y]of a){const x=l.get(p)??y[0]?.denom;if(!x)continue;const b=g(x);if(!b)continue;const j=u.get(x)??0;for(const v of y){const{symbol:w,decimals:C}=b,I=Number(k.fromBaseUnit(v.amount,{decimals:C})),T={type:"asset",denom:x,symbol:w,amount:v.amount,formattedAmount:I,decimals:C,value:I*j};f.push({type:"staking",validator:v.validator,balance:T})}}for(const[p,y]of i){const x=l.get(p);if(!x)continue;const b=g(x);if(!b)continue;const j=u.get(x)??0;for(const v of y){const{symbol:w,decimals:C}=b,I=Number(k.fromBaseUnit(v.amount,{decimals:C})),T={type:"asset",denom:x,symbol:w,amount:v.amount,formattedAmount:I,decimals:C,value:I*j},A=Number(v.releaseTime);f.push({type:"lockstaking",validator:v.validator,releaseTime:Number.isNaN(A)?0:A,balance:T})}}for(const[p,y]of r){const x=l.get(p)??y[0]?.denom;if(!x)continue;const b=g(x);if(!b)continue;const j=u.get(x)??0;for(const v of y){const{symbol:w,decimals:C}=b,I=Number(k.fromBaseUnit(v.amount,{decimals:C})),T={type:"asset",denom:x,symbol:w,amount:v.amount,formattedAmount:I,decimals:C,value:I*j},A=new Date(v.completionTime).getTime(),$=Number.isNaN(A)?0:Math.floor(A/1e3);f.push({type:"unstaking",validator:v.validator,completionTime:$,balance:T})}}return f.filter(p=>p.type!=="fungible-position"&&p.balance.denom===Je)},[a,i,r,l,m,u]),h=_.useMemo(()=>d.reduce((f,g)=>g.type==="fungible-position"||g.balance.type==="unknown"?f:f+(g.balance.value??0),0),[d]);return{positions:d,totalValue:h,isLoading:o}}function gm(e){const t=new Map;for(const s of e){const o=k.denomToMetadata(s.denom),a={...s,metadata:o},r=t.get(o)??[];r.push(a),t.set(o,r)}return t}function _m(e,t){return e.map(s=>t.get(s)?.symbol||s).join("/")}function ym(e){const{dexUrl:t}=se();return E.useSuspenseQuery({queryKey:wn.checkLpTokens(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.post(`${t}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:V.MINUTE})}function xm(){const e=ce(),t=as(e),s=_.useMemo(()=>t.map(a=>a.denom),[t]),{data:o}=ym(s);return _.useMemo(()=>{const a=t.filter(r=>o.get(r.denom)===!0);return gm(a)},[t,o])}function bm(e){const{dexUrl:t}=se();return E.useSuspenseQuery({queryKey:wn.lpPrices(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.get(`${t}/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:V.MINUTE})}function wm(e,t,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of t){const c=i[0]?.denom;c&&c!==Je&&a.add(r)}for(const r of s.keys())a.add(r);for(const[r,i]of o){const c=i[0]?.denom;c&&c!==Je&&a.add(r)}return Array.from(a)}function vm(e){const t=[];for(const[,s]of e)s&&s!==Je&&t.push(s);return t}function jm(e,t,s){const o=t.get(e)??null,a=o?.symbol||e,r=yc(o,s),i=r.length>0&&r.some(l=>l),c=i?void 0:s.get(e)?.logoUrl;return{denom:e,symbol:a,totalAmount:0,totalValue:0,decimals:s.get(e)?.decimals??6,poolType:o?.pool_type,logoUrl:c,coinLogos:i?r:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0}}}function $o(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r)??i[0]?.denom;if(!c||c===Je)continue;const l=o.get(c);if(l)for(const u of i){const m=l.decimals,d=Number(k.fromBaseUnit(String(u.amount),{decimals:m})),h=s.get(c)??0,f=d*h;l.breakdown[a]+=d,l.totalAmount+=d,l.totalValue+=f}}}function Cm(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r);if(!c||c===Je)continue;const l=o.get(c);if(l)for(const u of i){const m=l.decimals,d=Number(k.fromBaseUnit(String(u.amount),{decimals:m})),h=s.get(c)??0,f=d*h;l.breakdown[a]+=d,l.totalAmount+=d,l.totalValue+=f}}}function km(e,t,s,o){for(const[a,r]of e){const i=k.denomToMetadata(a),c=t?.get(i),l=c?k.fromBaseUnit(c.amount,{decimals:it}):"0",u=s?.get(i),m=u?k.fromBaseUnit(u.amount,{decimals:it}):"0",d=Number(l)+Number(m);d<=0||(r.claimableInit={staking:l,lockStaking:m,total:String(d),totalValue:d*o})}}function Nm(e){return`#${e.replace(/^0x/,"").slice(-6)}`}function co(){const e=ce(),t=Qt(e),s=ie(),o=xm(),{data:a}=La(),{data:r}=Ra(),{data:i}=qa(),{data:c}=wc(),{data:l}=vc(),{data:u}=Pt(e),{data:m}=lm(s),d=_.useMemo(()=>{const F=new Map;for(const D of m){const Z=F.get(D.lpMetadata)??[];Z.push(D),F.set(D.lpMetadata,Z)}return F},[m]),h=_.useMemo(()=>Array.from(d.keys()),[d]),f=hm(h),g=um(h),p=_.useMemo(()=>m.map(F=>F.tokenAddress),[m]),y=dm(p),x=_.useMemo(()=>{const F=[];for(const D of m)for(const Z of D.incentives)F.push({tokenAddress:D.tokenAddress,incentiveAddress:Z.incentiveAddress});return F},[m]),b=mm(x),j=_.useMemo(()=>{const F=new Set;for(const D of m)for(const Z of D.incentives)F.add(Z.rewardMetadata);return Array.from(F)},[m]),v=Bs(j,{failSoft:!0}),w=_.useMemo(()=>wm(o,a,r,i),[o,a,r,i]),C=Bs(w),I=_.useMemo(()=>vm(C),[C]),{data:T}=bm(I),A=fm(I),$=_.useMemo(()=>{const F=new Map;for(const D of t)F.set(D.denom,D);return F},[t]),N=_.useMemo(()=>{const F=new Map;for(const D of u??[])F.set(D.id,D.price);return F},[u]),{rows:S,totalValue:P}=_.useMemo(()=>{const F=u?.find(W=>W.id===Je)?.price??0,D=new Map;for(const W of I)D.set(W,jm(W,A,$));$o(o,C,T,D,"deposit"),$o(a,C,T,D,"staking"),Cm(r,C,T,D,"lockStaking"),$o(i,C,T,D,"unstaking"),km(D,c,l,F);for(const W of h){const O=d.get(W)??[];if(O.length===0)continue;const J=f.get(W),Q=g.get(W),ee=rm(W),ue=J?.coins.map(le=>le.denom)??[],ye=J?yc(J,$).filter(Boolean):[],me=ue.map(le=>$.get(le)?.symbol||le),Ce=J?.symbol||me.join("-")||ee,Se=_m(ue,$),ke=O.map(le=>{let G,$t,Xt,Mt=!1,bt=0,en=0;try{const dt=om({tickLower:le.tickLower,tickUpper:le.tickUpper});G=dt.min,$t=dt.max}catch{G=void 0,$t=void 0}if(Q){try{const dt=Xd(BigInt(Q.sqrtPrice)),Ue=Gt(le.tickLower),nt=Gt(le.tickUpper),X=Number(Q.tickSpacing);Mt=Number.isFinite(X)&&X>0?zd(le.tickLower,le.tickUpper,X):!1,Xt=Mt||dt>=Ue&&dt<nt}catch{Xt=void 0,Mt=!1}if(J&&ue.length>0)try{tm({sqrtPrice:Q.sqrtPrice,tickLower:le.tickLower,tickUpper:le.tickUpper,liquidity:le.liquidity}).forEach((Ue,nt)=>{const X=J.coins[nt];if(!X)return;const ve=$.get(X.denom)?.decimals??6,Oe=N.get(X.denom)??0,mt=Number(k.fromBaseUnit(String(Ue),{decimals:ve}));bt+=mt*Oe})}catch{bt=0}}return J&&((y.get(le.tokenAddress)??[]).forEach((Ue,nt)=>{const X=J.coins[nt];if(!X)return;const ve=$.get(X.denom)?.decimals??6,Oe=N.get(X.denom)??0,mt=Number(k.fromBaseUnit(Ue,{decimals:ve}));en+=mt*Oe}),le.incentives.forEach(Ue=>{const nt=b.get(gc(le.tokenAddress,Ue.incentiveAddress))??"0",X=v.get(Ue.rewardMetadata);if(!X)return;const ve=$.get(X)?.decimals??6,Oe=N.get(X)??0,mt=Number(k.fromBaseUnit(nt,{decimals:ve}));en+=mt*Oe})),{tokenAddress:le.tokenAddress,positionId:Nm(le.tokenAddress),inRange:Xt,isFullRange:Mt,minPrice:G,maxPrice:$t,pricePairLabel:Se,rewardValue:en,value:bt}}),Et=ke.reduce((le,G)=>le+G.value,0),ut=ke.reduce((le,G)=>le+G.rewardValue,0),Re=ye.length>0;D.set(ee,{denom:ee,symbol:Ce,totalAmount:0,totalValue:Et,decimals:6,poolType:"CLAMM",logoUrl:void 0,coinLogos:Re?ye:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0},isClamm:!0,clamm:{lpMetadata:W,totalRewardValue:ut,positions:ke}})}const Z=Array.from(D.values()).filter(W=>W.totalAmount>0||W.isClamm).sort((W,O)=>O.totalValue-W.totalValue),K=Z.reduce((W,O)=>W+O.totalValue,0);return{rows:Z,totalValue:K}},[u,I,A,$,o,a,r,i,C,T,c,l,h,d,f,g,y,b,v,N]);return{totalValue:P,rows:S}}const Im=qe.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,t)=>[e,t]});function Am(e){return e.filter(t=>t.data.length>0).map(t=>{const s=t.data[0].bridge_id,o=t.data[0].version,a=t.data.reduce((r,i)=>r+i.claimed_reward,0);return{claimableReward:t.total_claimable_reward,claimedReward:a,initialReward:t.total_vesting_reward,lockedReward:t.total_locked_reward,requiredScore:t.required_score,rollup:{bridgeId:s,version:o}}}).filter(t=>t.initialReward>0).sort((t,s)=>s.initialReward-t.initialReward)}function jc(){const{vipUrl:e}=se(),t=ie();return E.useQuery({queryKey:Im.allVestingPositions(e,t).queryKey,queryFn:async()=>(await z.get(`${e}/vesting/positions/${t}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:V.MINUTE,enabled:!!t})}function Sm(){const e=_e();return _.useCallback(t=>e.find(({metadata:s})=>s?.op_bridge_id===String(t)),[e])}function lo(){const{data:e}=jc(),t=ce(),{data:s}=Pt(t),o=Sm(),a=_.useMemo(()=>s?.find(l=>l.id===Je)?.price??0,[s]),r=_.useMemo(()=>e?Am(e).map(l=>{const u=o(l.rollup.bridgeId),m=Number(k.fromBaseUnit(String(l.lockedReward),{decimals:it})),d=Number(k.fromBaseUnit(String(l.claimableReward),{decimals:it})),h=q(k.fromBaseUnit(String(l.lockedReward),{decimals:it})).times(a).toNumber(),f=q(k.fromBaseUnit(String(l.claimableReward),{decimals:it})).times(a).toNumber();return{bridgeId:l.rollup.bridgeId,version:l.rollup.version,name:u?.name??"",logoUrl:u?.logoUrl,lockedReward:m,lockedRewardValue:h,claimableReward:d,claimableRewardValue:f}}).filter(l=>l.lockedReward+l.claimableReward>0):[],[e,a,o]),i=_.useMemo(()=>r.reduce((c,l)=>c+l.lockedRewardValue+l.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function Cc(){const{totalValue:e}=co(),{data:t}=La(),{data:s}=Ra(),{data:o}=qa(),{data:a}=jc(),r=_.useMemo(()=>Array.from(s.keys()),[s]),i=Bs(r),c=ce(),{data:l}=Pt(c),u=_.useMemo(()=>l?.find(d=>d.id===Je)?.price??0,[l]);return _.useMemo(()=>{let m=0,d=0;const h=u??0;for(const[,g]of t)for(const{denom:p,amount:y}of g)p===Je&&(m+=Number(k.fromBaseUnit(y,{decimals:it}))*h);for(const[g,p]of s)if(i.get(g)===Je)for(const{amount:y}of p)d+=Number(k.fromBaseUnit(y,{decimals:it}))*h;for(const[,g]of o)for(const{denom:p,amount:y}of g)p===Je&&(m+=Number(k.fromBaseUnit(y,{decimals:it}))*h);let f=0;if(a)for(const g of a){const p=g.total_locked_reward??0,y=g.total_claimable_reward??0;f+=Number(k.fromBaseUnit(String(p+y),{decimals:it}))*h}return m+d+e+f},[t,s,i,o,a,u,e])}function Tm(){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"],t={"initia-wallet-widget:ethereum-public-keys":{prefix:he.PUBLIC_KEY,getSuffix:s=>k.InitiaAddress(s).bech32}};for(const s of e)localStorage.removeItem(s);for(const[s,{prefix:o,getSuffix:a}]of Object.entries(t)){const r=localStorage.getItem(s);if(r)try{const i=JSON.parse(r);for(const[c,l]of Object.entries(i)){const u=`${o}:${a(c)}`;localStorage.setItem(u,l)}localStorage.removeItem(s)}catch{}}}const Jo=qe.createQueryKeys("interwovenkit:minity",{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,t)=>[e,t],balances:(e,t,s)=>[e,t,s],initiaPositions:(e,t)=>[e,"initia",t],echelonPositions:(e,t)=>[e,"echelon",t],inertiaPositions:(e,t)=>[e,"inertia",t],ravePositions:(e,t,s)=>[e,"rave",t,s],yominetPositions:(e,t)=>[e,"yominet",t],chainPositions:(e,t,s)=>[e,t,s]});function Da(e,t){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=t[a],c=r.data;if(!(!i||!c)){for(const l of c)if(l.logoUrl&&!l.logoUrl.includes("undefined")){const u=`${i.chainId}:${l.denom}`;s.has(u)||s.set(u,l.logoUrl);const m=l.symbol.toUpperCase();o.has(m)||o.set(m,l.logoUrl)}}}return{denomLogos:s,symbolLogos:o}}function Ln(e){if(e.type==="fungible-position")return e.value??0;if(e.balance.type==="unknown")return 0;const t=e.balance.value??0;return e.type==="lending"&&e.direction==="borrow"?-t:t}function Em(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 $m(e,t=!1){switch(e){case"staking":return t?"INIT staking":"Staking";case"borrowing":return"Borrowing";case"lending":return"Lending";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function Mm(e){const t=new Map;for(const u of e){const m=Em(u);if(!m)continue;const d=t.get(m)??[];d.push(u),t.set(m,d)}const s=new Map,o=new Map;for(const[u,m]of t){const d=m.reduce((f,g)=>f+Ln(g),0),h=m.reduce((f,g)=>f+Math.abs(Ln(g)),0);s.set(u,d),o.set(u,h)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,c=[...t.keys()].sort((u,m)=>{const d=u==="lending"||u==="borrowing"?i:o.get(u)??0,h=m==="lending"||m==="borrowing"?i:o.get(m)??0;return(u==="lending"||u==="borrowing")&&(m==="lending"||m==="borrowing")?u==="lending"?-1:1:h-d}),l=new Map;for(const u of c)l.set(u,{positions:t.get(u),totalValue:s.get(u)??0});return l}function Lm(e){return e.type==="fungible-position"?e.title:e.balance.denom}function qm(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function Rm(e){return e.type==="fungible-position"?null:e.balance}function Pm(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 Dm(e){const t=new Map;for(const s of e){const o=t.get(s.type)??[];o.push(s),t.set(s.type,o)}return t}function Bm(e,t){return e.symbol===pt&&t.symbol===pt?0:e.symbol===pt?-1:t.symbol===pt?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function Fm(e){const t=new Map;for(const o of e){const a=Lm(o),r=t.get(a)??[];r.push(o),t.set(a,r)}return Array.from(t.entries()).map(([o,a])=>{const r=Rm(a[0]);let i=0;for(const c of a)c.type!=="fungible-position"&&c.balance.type!=="unknown"&&(i+=c.balance.formattedAmount);return{denom:o,symbol:qm(a[0]),positions:a,totalValue:a.reduce((c,l)=>c+Ln(l),0),totalAmount:i,balance:r}}).sort(Bm)}function kc(e,t){const s=new Map;return e.forEach((o,a)=>{const r=t[a]?.data;if(r&&r.length>0){const i=new Map(r.map(c=>[c.id,c.price]));s.set(o.chainId,i)}}),s}function Um(e,t){return e.map(s=>({...s,balances:s.balances.map(o=>{if(o.type==="unknown"||o.value!=null&&o.value>0)return o;const a=t.get(s.chainId);if(a){const r=a.get(o.denom)??0;if(r>0)return{...o,value:o.formattedAmount*r}}return o})}))}function Om(e,t){return e.symbol===pt&&t.symbol===pt?0:e.symbol===pt?-1:t.symbol===pt?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function Vm(e,t,s){return e.map(o=>{const a=o.assets.map(i=>{const c=i.symbol.toUpperCase(),l=`${i.chain.chainId}:${i.denom}`,u=t.get(l)??s.get(c)??"";return u!==i.logoUrl?{...i,logoUrl:u}: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 Km(e,t,s){const o=t?e.filter(i=>{const{symbol:c,assets:l}=i,u=t.toLowerCase();return c.toLowerCase().includes(u)||l.some(({denom:m})=>m.toLowerCase().includes(u))}):e,a=s?o.map(i=>{const c=i.assets.filter(({chain:l})=>l.chainId===s);return{...i,assets:c,totalValue:c.reduce((l,u)=>l+(u.value??0),0),totalAmount:c.reduce((l,u)=>l+Number(u.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,c)=>i+c.assets.reduce((l,u)=>l+(u.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Wm(e,t,s){const o=t?e.filter(({denom:a,address:r})=>{const i=t.toLowerCase();return a.toLowerCase().includes(i)||r?.toLowerCase().includes(i)}):e;return s?o.filter(({chain:a})=>a.chainId===s):o}function zm(e,t,s,o){const{filteredAssets:a,totalAssetsValue:r}=Km(e,s,o),i=Wm(t,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function Hm(e,t,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const c of e){const{chainName:l,chainId:u,balances:m}=c;if(!Array.isArray(m))continue;const d=t.get(l.toLowerCase()),h=d?.chainId??u??l,f=d?.prettyName??l,g=d?.logoUrl??"",p=s.get(h);for(const y of m){if(y.type==="unknown"){if(!y.amount||y.amount==="0")continue;r.push({symbol:y.denom,logoUrl:"",denom:y.denom,amount:y.amount,decimals:0,quantity:y.amount,value:void 0,unlisted:!0,chain:{chainId:h,name:f,logoUrl:g}});continue}if(y.type==="lp"||(y.value??0)<=0&&(y.formattedAmount??0)<=0)continue;let x=y.value;if((x==null||x<=0)&&p){const v=p.get(y.denom)??0;v>0&&(x=y.formattedAmount*v)}const b={symbol:y.symbol,logoUrl:"",denom:y.denom,amount:y.amount,decimals:y.decimals,quantity:String(y.formattedAmount),value:x,chain:{chainId:h,name:f,logoUrl:g}},j=a.get(y.symbol);j?j.push(b):a.set(y.symbol,[b])}}r.sort((c,l)=>{const u=c.chain.chainId===o,m=l.chain.chainId===o;if(u&&!m)return-1;if(!u&&m)return 1;const d=c.chain.name.localeCompare(l.chain.name);if(d!==0)return d;try{const h=BigInt(c.amount),f=BigInt(l.amount);if(h>f)return-1;if(h<f)return 1}catch{const h=c.amount.localeCompare(l.amount);if(h!==0)return-h}return c.denom.localeCompare(l.denom)});const i=[];for(const[c,l]of a){l.sort((d,h)=>(h.value??0)-(d.value??0));let u=0,m=0;for(const d of l)u+=d.value??0,m+=Number(d.quantity);i.push({symbol:c,logoUrl:"",assets:l,totalValue:u,totalAmount:m})}return i.sort(Om),{listedGroups:i,unlistedAssets:r}}function Ba(){return ce().network_type==="testnet"}function Zt(){return $e.useFormContext()}function Qm(){const e=et(),t=Ba(),s={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},o={...s,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},a={...s,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},r=L.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(he.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(he.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(he.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(he.BRIDGE_DST_DENOM),quantity:localStorage.getItem(he.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(he.BRIDGE_SLIPPAGE_PERCENT)});return{...t?o:a,...r,...e}}const Gm={balances:[],positions:[],isLoading:!0,isComplete:!1},Nc=H.atom(0),Ym=1e3;let br=0;function Zm(){const e=H.useSetAtom(Nc);_.useEffect(()=>{const t=Date.now();t-br>=Ym&&(br=t,e(s=>s+1))},[e])}function Jm(){const e=E.useQueryClient(),t=ie(),{minityUrl:s}=se(),o=Ba(),a=H.useAtomValue(Nc),r=_.useEffectEvent((l,u)=>{const m=Array.isArray(l.balances)?l.balances:[];u.set(l.chain,{chainName:l.chain,chainId:l.chainId,balances:m})}),i=_.useEffectEvent((l,u)=>{const m=Array.isArray(l.positions)?l.positions:[];u.set(l.chain,{chainName:l.chain,chainId:l.chainId,positions:m})}),c=_.useEffectEvent((l,u)=>{const m=Jo.ssePortfolio(t??"",s).queryKey,d=e.getQueryData(m)??Gm,h=l.size>0||u.size>0;e.setQueryData(m,{...d,balances:Array.from(l.values()),positions:Array.from(u.values()),isLoading:h?!1:d.isLoading,isComplete:!1})});_.useEffect(()=>{if(!t||o)return;const l=Jo.ssePortfolio(t,s).queryKey,u=e.getQueryData(l),m=new Map,d=new Map;for(const y of u?.balances??[])m.set(y.chainName,y);for(const y of u?.positions??[])d.set(y.chainName,y);const f=`${s}/v1/chain/all/${encodeURIComponent(t)}`;let g=null,p=!1;return e.setQueryData(l,{balances:u?.balances??[],positions:u?.positions??[],isLoading:!0,isComplete:!1}),g=new EventSource(f),g.onmessage=y=>{if(!p)try{const x=JSON.parse(y.data);x.type==="balances"?r(x,m):x.type==="positions"&&i(x,d),c(m,d)}catch{}},g.onerror=()=>{g?.close()},()=>{p=!0,g?.close()}},[t,o,a])}const wr={balances:[],positions:[],isLoading:!0,isComplete:!1};function ms(){const e=ie(),{minityUrl:t}=se(),s=Jo.ssePortfolio(e??"",t).queryKey,{data:o}=E.useQuery({queryKey:s,queryFn:()=>wr,enabled:!!e,staleTime:V.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??wr}function Xm(){const e=_e();return _.useMemo(()=>{const t=new Map;for(const s of e){const o=s.chain_name.toLowerCase();t.set(o,{chainId:s.chainId,chainName:s.chain_name,prettyName:s.name||s.chain_name,logoUrl:s.logoUrl||""})}return t},[e])}function eh(){const{balances:e,positions:t}=ms(),s=_e(),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((g,p)=>{if(p.type==="fungible-position")return g+(p.value??0);if(p.balance.type==="unknown")return g;const y=p.balance.value??0;return p.type==="lending"&&p.direction==="borrow"?g-y:g+y},0),c=new Map,l=Array.isArray(e)?e:[],u=Array.isArray(t)?t:[];for(const{chainName:f,balances:g}of l){if(!Array.isArray(g))continue;const p=g.reduce((y,x)=>y+r(x),0);c.set(f,(c.get(f)||0)+p)}for(const{chainName:f,positions:g}of u){if(!Array.isArray(g))continue;const p=g.reduce((y,x)=>y+i(x),0);c.set(f,(c.get(f)||0)+p)}const m=Array.from(c.values()).reduce((f,g)=>f+g,0),d=Array.from(c.entries()).filter(([,f])=>f>0).map(([f,g])=>{const p=o.get(f.toLowerCase());return{chainId:p?.chainId||"",chainName:p?.name||f,logoUrl:p?.logoUrl||"",totalBalance:g,percentage:m>0?g/m:0}}).filter(f=>f.chainId!==""),h=f=>f.chainName.toLowerCase()==="initia";return L.sortWith([L.descend(h),L.descend(L.prop("totalBalance"))],d)},[e,t,o])}function th(){const{balances:e}=ms(),t=_e(),s=_a(),o=_.useMemo(()=>kc(t,s),[t,s]);return _.useMemo(()=>{const a=l=>l.type==="unknown"?0:l.value??0;let r=0;const i=Array.isArray(e)?e:[],c=Um(i,o);for(const{balances:l}of c)if(Array.isArray(l))for(const u of l)u.type!=="lp"&&(r+=a(u));return r},[e,o])}function nh(){const{positions:e}=ms();return _.useMemo(()=>{const t=r=>r.positions.reduce((i,c)=>{if(c.type==="fungible-position")return i+(c.value??0);if(c.balance.type==="unknown")return i;const l=c.balance.value??0;return c.type==="lending"&&c.direction==="borrow"?i-l:i+l},0),s=["initia","civitia","yominet"];let o=0;const a=Array.isArray(e)?e:[];for(const{chainName:r,positions:i}of a){const c=r.toLowerCase();s.includes(c)||Array.isArray(i)&&(o+=i.reduce((l,u)=>l+t(u),0))}return o},[e])}const Ie=qe.createQueryKeys("interwovenkit:skip",{chains:null,allAssets:()=>["allAssets"],assets:e=>[e],asset:(e,t)=>[e,t],allBalances:(e,t)=>[e,t],balances:(e,t)=>[e,t],route:(e,t)=>[{...e,quantity:q(e.quantity||0).toString()},t],routeErrorInfo:e=>[e],txTrack:(e,t)=>[e,t],txStatus:(e,t)=>[e,t]});function Fe(){const{routerApiUrl:e}=se();return _.useMemo(()=>z.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.8.0"}}),[e])}function sh(){const e=Fe();E.usePrefetchQuery({queryKey:Ie.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),staleTime:V.MINUTE}),E.usePrefetchQuery({queryKey:Ie.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:V.MINUTE})}const oh=()=>(fu(),pu(),null),ah="_loader_1vxch_1",rh={loader:ah},It=({size:e=24,color:t="currentColor",border:s=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${t} ${t} transparent ${t}`,borderWidth:`${s}px`};return n.jsx("div",{className:rh.loader,style:o,role:"status","aria-label":"Loading"})},ih="_button_1q027_1",ch="_outline_1q027_28",lh="_sm_1q027_46",uh="_full_1q027_53",dh="_small_1q027_57",mh="_unpadded_1q027_88",un={button:ih,outline:ch,sm:lh,full:uh,small:dh,unpadded:mh},Ic=e=>{const{sm:t,fullWidth:s,loading:o,className:a,children:r,disabled:i,...c}=e;return n.jsx("button",{...c,className:B(un.button,{[un.sm]:t,[un.full]:s},a),disabled:!!o||i,"aria-busy":!!o,children:o?n.jsxs(n.Fragment,{children:[n.jsx(It,{color:"currentColor",size:16}),typeof o=="string"&&n.jsx("span",{className:un.loading,children:o})]}):r})},hh=({className:e,...t})=>n.jsx(Ic,{...t,className:B(un.outline,e)}),fh=({className:e,unpadded:t,...s})=>n.jsx("button",{...s,className:B(un.small,{[un.unpadded]:t},e)}),fe={White:Ic,Outline:hh,Small:fh},ph="_footer_1vp4h_1",gh="_actions_1vp4h_10",vr={footer:ph,actions:gh},Ae=({extra:e,className:t,children:s})=>n.jsxs("footer",{className:B(vr.footer,t),children:[e,n.jsx("div",{className:vr.actions,children:s})]}),_h="_scrollable_13su7_1",yh={scrollable:_h},yt=({className:e,children:t,ref:s})=>n.jsx("div",{ref:s,className:B(yh.scrollable,e),children:t}),xh="interwovenkit:";function bh(e){const[t]=e;return typeof t=="string"&&t.startsWith(xh)}function wh(e){e.removeQueries({predicate:t=>bh(t.queryKey)})}function uo(){return Ge.useMediaQuery("(max-width: 576px)")}const Xo="interwoven-kit";function Ac(){const e=document.querySelector(Xo)||document.body.appendChild(document.createElement(Xo));return e.shadowRoot||e.attachShadow({mode:"open"})}function Sc(){const{theme:e,container:t}=se();return _.useEffect(()=>{document.querySelector(Xo)?.setAttribute("data-theme",e)},[e]),t??Ac()}function vh(e){const t=Ac(),s=document.createElement("style");s.textContent=e,t.appendChild(s)}const mo=_.createContext(null);function _n(){const{container:e}=_.useContext(mo);return e}function Tc(e){const t=_n();return t?getComputedStyle(t).getPropertyValue(e):""}function jh(){return Ge.useScrollLock(),null}function Ch(e){return/^[A-F0-9]{64}$/i.test(e)}function kh(e,t){const{txHash:s,accountAddress:o,pathSuffix:a}=t;if(s)return Ch(s)?L.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!k.InitiaAddress.validate(o))return;const i=L.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function Nh(e){try{const t=new URL(e,window.location.href);if(!["http:","https:"].includes(t.protocol))throw new Error("Invalid protocol");return t.toString()}catch{return"#"}}const Ih="_link_j1lkz_1",jr={link:Ih},ho=({chainId:e,txHash:t,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:c,onClick:l,...u}=a,m=_t(e),d=kh(m,{txHash:t,accountAddress:s,pathSuffix:o}),h=t?k.truncate(t):s?k.truncate(s):"",f=c??h;return d?n.jsxs("a",{...u,href:Ul(Nh(d)),className:B(jr.link,i),onClick:l,target:"_blank",rel:"noopener noreferrer",children:[f,r&&n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})]}):n.jsx("span",{...u,className:B(jr.link,i),children:f})},Ec=_.createContext(null),hs=()=>_.useContext(Ec),Ah=()=>{const[e,t]=H.useAtom(ac),{showNotification:s,updateNotification:o,hideNotification:a}=hs();return _.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:c,error:l}=e,u=l?l.message:c?n.jsx(ho,{txHash:c,chainId:i,onClick:a,showIcon:!0,children:"View on Initia Scan"}):null;switch(r){case"loading":s({type:"loading",title:"Transaction is pending..."});break;case"error":o({type:"error",title:"Transaction failed",description:u}),t(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:u,autoHide:!0}),t(null);break}},[e,t,s,o,a]),null},Ws=({value:e,children:t})=>{const[s,o]=_.useState(!1);return t({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},Sh="_placeholder_10r3x_1",Th="_logo_10r3x_5",Cr={placeholder:Sh,logo:Th},re=({src:e,alt:t,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[c,l]=_.useState(void 0),{width:u,height:m}=i,d=s??n.jsx("div",{className:B(Cr.placeholder,o?.placeholder),style:{width:u,height:m,...a},"aria-hidden":"true"});return!e||c===e?d:n.jsx("img",{...i,className:B(i.className,{[Cr.logo]:r}),style:{width:u,height:m,...a},src:e,alt:t,loading:"lazy",onError:()=>l(e)})};function $c(){const{connector:e}=Qe.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const Eh="_header_1q8ju_1",$h="_account_1q8ju_17",Mh="_name_1q8ju_28",Lh="_address_1q8ju_32",qh="_icon_1q8ju_36",Rh="_copied_1q8ju_43",Ph="_button_1q8ju_58",Dh="_settings_1q8ju_69",Bh="_disconnect_1q8ju_73",Fh="_label_1q8ju_83",Uh="_expanded_1q8ju_91",st={header:Eh,account:$h,name:Mh,address:Lh,icon:qh,copied:Rh,button:Ph,settings:Dh,disconnect:Bh,label:Fh,expanded:Uh},Oh=()=>{const e=Fi(),{address:t,username:s}=tt(),o=$c(),a=s??t,[r,i]=_.useState(!1),c=_.useRef(null),l=Nt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),u=()=>{r?e():i(!0)},m=()=>{r&&(c.current=setTimeout(()=>{i(!1)},500))},d=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return _.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),t?n.jsxs("header",{className:st.header,children:[n.jsx(Ws,{value:t,children:({copy:h,copied:f})=>n.jsxs("button",{className:B(st.account,{[st.copied]:f}),onClick:h,"aria-label":f?"Copied":"Copy address",children:[n.jsx(re,{src:o,width:18,height:18}),n.jsx("div",{className:st.address,children:k.truncate(t)}),n.jsx("div",{className:st.name,children:k.truncate(a)}),n.jsx(M.IconCopy,{className:st.icon,size:12,"aria-hidden":"true"}),f?"Copied!":""]})}),n.jsx(mn,{to:"/settings",className:B(st.button,st.settings),"aria-label":"Open settings",children:n.jsx(M.IconSettingFilled,{size:16,"aria-hidden":"true"})}),n.jsxs(Nt.animated.button,{className:B(st.button,st.disconnect,{[st.expanded]:r}),style:l,onClick:u,onMouseLeave:m,onMouseEnter:d,"aria-label":"Disconnect wallet",children:[n.jsx(M.IconSignOut,{size:16,"aria-hidden":"true"}),n.jsx("span",{className:st.label,children:"Disconnect"})]})]}):null},Vh="_overlay_jij9g_1",Kh="_content_jij9g_28",Wh="_inner_jij9g_60",Mo={overlay:Vh,content:Kh,inner:Wh},zh=({children:e})=>{const{isDrawerOpen:t,closeDrawer:s}=Dt(),{setContainer:o}=_.useContext(mo),a=_.useCallback(p=>{p&&o(p)},[o]),r=uo(),i=Sc(),c=H.useAtomValue(ro),l=H.useAtomValue(rs),u=E.useIsMutating({mutationKey:[oc]}),m=()=>{const p=u?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),c?.reject(new Error(p)),l?.reject(new Error("User rejected"))},d=to(),h=Me(),f=E.useQueryClient(),g={fallbackRender:({error:p,resetErrorBoundary:y})=>{const x=()=>{d==="/bridge"&&(localStorage.removeItem(he.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(he.BRIDGE_SRC_DENOM),localStorage.removeItem(he.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(he.BRIDGE_DST_DENOM)),h("/"),wh(f),y()};return n.jsxs(yt,{children:[n.jsx(je,{error:!0,children:p.message}),n.jsx(Ae,{children:n.jsx(fe.White,{onClick:x,children:"Retry"})})]})}};return n.jsx(Be.Dialog.Root,{open:t,onOpenChange:p=>!p&&m(),modal:!1,children:n.jsxs(Be.Dialog.Portal,{container:i,children:[r&&n.jsx(Be.Dialog.Backdrop,{className:Mo.overlay,onClick:m,children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:[n.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"}),n.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"})]})}),n.jsx(Be.Dialog.Popup,{className:Mo.content,children:n.jsxs("div",{className:B(Mo.inner,"body"),ref:a,children:[r&&n.jsx(jh,{}),n.jsx(Ah,{}),n.jsx(Oh,{}),n.jsx(xe,{errorBoundaryProps:g,children:e})]})})]})})},Hh="_backdrop_1bqx9_1",Qh="_modal_1bqx9_12",Gh="_closeButton_1bqx9_44",Lo={backdrop:Hh,modal:Qh,closeButton:Gh},Yh=({children:e})=>{const{isModalOpen:t,closeModal:s}=Dn(),{setContainer:o}=_.useContext(mo),a=_.useCallback(i=>{i&&o(i)},[o]),r=Sc();return n.jsx(Be.Dialog.Root,{open:t,onOpenChange:i=>!i&&s(),children:n.jsxs(Be.Dialog.Portal,{container:r,children:[n.jsx(Be.Dialog.Backdrop,{className:Lo.backdrop,onClick:s}),n.jsxs(Be.Dialog.Popup,{className:Lo.modal,ref:a,children:[n.jsx("button",{className:Lo.closeButton,onClick:s,"aria-label":"Close",children:n.jsx(M.IconClose,{size:20})}),n.jsx(xe,{children:e})]})]})})},Mc=_.createContext(!1),Zh="_overlay_1iyfl_1",Jh="_fullscreen_1iyfl_15",Xh="_content_1iyfl_19",ef="_header_1iyfl_56",tf="_title_1iyfl_65",nf="_close_1iyfl_70",tn={overlay:Zh,fullscreen:Jh,content:Xh,header:ef,title:tf,close:nf},Lc=({title:e,children:t,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=_n(),c=_.useContext(Mc);return i?n.jsxs(Be.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&n.jsx(Be.Dialog.Trigger,{className:o,children:s}),n.jsxs(Be.Dialog.Portal,{container:i,children:[n.jsx(Be.Dialog.Backdrop,{className:B(tn.overlay,{[tn.fullscreen]:c}),onClick:()=>r(!1),forceRender:!0}),n.jsxs(Be.Dialog.Popup,{className:B(tn.content,{[tn.fullscreen]:c}),children:[e&&n.jsxs("header",{className:tn.header,children:[n.jsx(Be.Dialog.Title,{className:tn.title,children:e}),n.jsx(Be.Dialog.Close,{className:tn.close,"aria-label":"Close",children:n.jsx(M.IconClose,{size:20,"aria-hidden":"true"})})]}),t]})]})]}):null},ts=({children:e})=>{const t=_.useRef(null),[s,o]=_.useState(0),[a,r]=_.useState(!1),i=Nt.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return _.useEffect(()=>{const c=t.current;if(!c)return;const l=()=>{const{height:m}=c.getBoundingClientRect();o(m),r(!0)};l();const u=new ResizeObserver(l);return u.observe(c),()=>u.disconnect()},[e]),e?n.jsx(Nt.animated.div,{style:{overflow:"hidden",...i},children:n.jsx("div",{ref:t,children:e})}):null},sf="_help_qcmtq_1",of="_icon_qcmtq_10",af="_info_qcmtq_19",rf="_warning_qcmtq_23",cf="_error_qcmtq_27",lf="_success_qcmtq_33",qo={help:sf,icon:of,info:af,warning:rf,error:cf,success:lf},In=({level:e,className:t,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return n.jsx(It,{size:12});case"info":return n.jsx(M.IconInfoFilled,{size:12});case"warning":case"error":return n.jsx(M.IconWarningFilled,{size:12});default:return n.jsx(M.IconCheckCircleFilled,{size:12})}};return n.jsxs("div",{className:B(qo.help,e&&qo[e],t),style:{marginTop:s},role:e==="error"?"alert":"status",children:[n.jsx("div",{className:qo.icon,"aria-hidden":"true",children:a()}),o]})},uf="_stack_a6m7u_1",df="_help_a6m7u_6",mf="_info_a6m7u_14",hf="_warning_a6m7u_19",ff="_error_a6m7u_24",pf="_success_a6m7u_29",ea={stack:uf,help:df,info:mf,warning:hf,error:ff,success:pf},gf=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:n.jsx(ts,{children:n.jsx("div",{className:ea.stack,children:e})}),we=({mt:e=0,...t})=>n.jsx(In,{...t,className:B(ea.help,ea[t.level]),mt:e});we.Stack=gf;const _f="_root_16p5j_1",yf="_item_16p5j_10",xf="_chevron_16p5j_14",bf="_trigger_16p5j_19",wf="_content_16p5j_39",On={root:_f,item:yf,chevron:xf,trigger:bf,content:wf};function vf(e){const{list:t,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return n.jsxs(te.Accordion.Root,{className:On.root,type:"multiple",...i,children:[t.map((c,l)=>n.jsxs(te.Accordion.Item,{className:On.item,value:s?.(c)??String(l),children:[n.jsx(te.Accordion.Header,{children:n.jsxs(te.Accordion.Trigger,{className:On.trigger,children:[o(c),n.jsx(M.IconChevronDown,{className:On.chevron,size:16,"aria-hidden":"true"})]})}),n.jsx(te.Accordion.Content,{className:On.content,children:a(c)})]},s?.(c)??l)),r]})}const jf="_trigger_u613p_1",Cf="_icon_u613p_18",kf="_content_u613p_27",Nf="_item_u613p_36",If="_itemText_u613p_52",Af="_itemIndicator_u613p_57",Sf="_active_u613p_60",Ot={trigger:jf,icon:Cf,content:kf,item:Nf,itemText:If,itemIndicator:Af,active:Sf};function Fa({options:e,value:t,onChange:s,classNames:o}){const a=_n(),r=e.find(c=>c.value===t);if(!r)throw new Error("Selected option not found");const i=c=>{const l=e.find(u=>String(u.value)===c);if(!l)throw new Error(`Option not found: ${c}`);s(l.value)};return n.jsxs(Lt.Select.Root,{value:String(t),onValueChange:i,modal:!1,children:[n.jsxs(Lt.Select.Trigger,{className:B(Ot.trigger,o?.trigger),children:[n.jsx(Lt.Select.Value,{children:r.triggerLabel||r.label}),n.jsx(Lt.Select.Icon,{className:Ot.icon,children:n.jsx(M.IconChevronDown,{size:12,"aria-hidden":"true"})})]}),n.jsx(Lt.Select.Portal,{container:a,children:n.jsx(Lt.Select.Positioner,{className:Ot.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:n.jsx(Lt.Select.Popup,{className:Ot.popup,children:e.map(c=>n.jsxs(Lt.Select.Item,{className:B(Ot.item,o?.item),value:String(c.value),children:[n.jsx(Lt.Select.ItemText,{className:B(Ot.itemText,o?.itemText),children:c.label}),n.jsx(M.IconCheck,{size:12,className:B(Ot.itemIndicator,{[Ot.active]:c.value===t}),"aria-hidden":"true"})]},String(c.value)))})})})]})}const Tf="_root_1t37n_1",Ef="_trigger_1t37n_7",$f="_item_1t37n_11",Mf="_itemText_1t37n_17",kr={root:Tf,trigger:Ef,item:$f,itemText:Mf},Lf=({options:e,value:t,onChange:s})=>{const{txRequest:o}=ic(),a=_t(o.chainId),r=St(a),i=(g,p)=>{if(k.formatAmount(g,{decimals:p})==="0.000000")return 8},c=({amount:[{amount:g,denom:p}]})=>{if(q(g).isZero())return"0";const{symbol:y,decimals:x}=r(p),b=i(g,x);return`${k.formatAmount(g,{decimals:x,dp:b})} ${y}`},l=e.map(g=>{const[{denom:p}]=g.amount,{symbol:y}=r(p);return{value:p,label:c(g),triggerLabel:y}});if(e.length===1)return n.jsx("span",{className:"monospace",children:c(e[0])});const u=e.find(g=>g.amount[0].denom===t);if(!u)throw new Error("Fee option not found");const[{amount:m,denom:d}]=u.amount,{decimals:h}=r(d),f=i(m,h);return n.jsxs("div",{className:kr.root,children:[n.jsx("span",{className:"monospace",children:k.formatAmount(m,{decimals:h,dp:f})}),n.jsx(Fa,{options:l,value:t,onChange:s,classNames:kr})]})},qf="_root_16nr2_1",Rf="_trigger_16nr2_5",Pf="_chevron_16nr2_13",Df="_panel_16nr2_27",Bf="_details_16nr2_39",Ff="_row_16nr2_48",Cn={root:qf,trigger:Rf,chevron:Pf,panel:Df,details:Bf,row:Ff},Uf=({spend:e,fee:t,total:s,balance:o,symbol:a,decimals:r})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:t},e&&{label:"Required (spend + fee)",value:s},{label:"Balance",value:o}].filter(Boolean),c=r===6?void 0:8;return n.jsxs(Io.Collapsible.Root,{className:Cn.root,children:[n.jsxs(Io.Collapsible.Trigger,{className:Cn.trigger,children:[n.jsx("span",{children:"Insufficient balance for fee"}),n.jsx(M.IconChevronDown,{className:Cn.chevron,size:16})]}),n.jsx(Io.Collapsible.Panel,{className:Cn.panel,children:n.jsx("div",{className:Cn.details,children:i.map(({label:l,value:u})=>n.jsxs("div",{className:Cn.row,children:[n.jsx("span",{children:l}),n.jsxs("span",{children:[k.formatAmount(u,{decimals:r,dp:c})," ",a]})]},l))})})]})};function zs(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?de.toBase64(e):Array.isArray(e)?`[${e.map(zs).join(",")}]`:JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const Of="_container_1xzyq_1",Vf="_toggle_1xzyq_5",Kf="_list_1xzyq_11",Wf="_arg_1xzyq_16",zf="_type_1xzyq_21",Vn={container:Of,toggle:Vf,list:Kf,arg:Wf,type:zf},Hf=qe.createQueryKeys("interwovenkit:move",{abi:(e,t,s,o)=>[e,t,s,o]}),Qf=({type:e,arg:t})=>zs(k.resolveBcsType(e).parse(t)),Gf=({msg:e,chainId:t,fallback:s})=>{const[o,a]=Ge.useToggle(!1),{restUrl:r}=_t(t),{moduleAddress:i,moduleName:c,functionName:l,args:u}=e,{data:m}=E.useQuery({queryKey:Hf.abi(r,i,c,l).queryKey,queryFn:async()=>{const h=await z.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),g=JSON.parse(h.module.abi).exposed_functions.find(({name:p})=>p===l);if(!g)throw new Error(`Function ${l} not found in module ${c}`);return g.params.filter(p=>!p.startsWith("&"))},staleTime:V.INFINITY});if(!m)return s;const d=(h,f)=>{const g=m[f];return n.jsxs("div",{className:Vn.arg,children:[n.jsx("div",{className:Vn.type,children:g}),n.jsx(di.ErrorBoundary,{fallback:n.jsx("div",{className:"error",children:"Error decoding argument"}),children:n.jsx(Qf,{type:g,arg:h})})]},f)};return n.jsxs("div",{className:Vn.container,children:[n.jsx(fe.Small,{className:Vn.toggle,onClick:a,disabled:!m,children:o?"Encode":"Decode"}),o?n.jsx("div",{className:Vn.list,children:u.map(d)}):s]})},Yf="_list_oip9m_1",Zf="_key_oip9m_9",Jf="_value_oip9m_14",Ro={list:Yf,key:Zf,value:Jf},Xf=({message:e,chainId:t})=>{const{typeUrl:s,value:o}=e;return n.jsx("div",{className:Ro.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{children:[n.jsx("div",{className:Ro.key,children:a}),n.jsx("div",{className:Ro.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?n.jsx(Gf,{msg:o,chainId:t,fallback:zs(r)}):zs(r)})]},a))})},ep="_item_1n572_1",tp="_title_1n572_10",np="_content_1n572_14",Po={item:ep,title:tp,content:np},Do=({title:e,content:t})=>n.jsxs("div",{className:Po.item,children:[n.jsx("div",{className:Po.title,children:e}),n.jsx("div",{className:Po.content,children:t})]});function ae(e){const t=e?q(e).abs():void 0;if(t&&t.gt(0)&&t.lt(.01))return"< $0.01";const s=e&&q(e).lt(0),o=k.formatNumber(t?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function Ua(e,t){return t==null?"$-":ae(e??0)}function qc(e,t){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")){if(o.type==="coin_spent"){const r=o.attributes.find(c=>c.key==="spender")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===t&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const u=s[l]||BigInt(0);s[l]=u-BigInt(c)}}}if(o.type==="coin_received"){const r=o.attributes.find(c=>c.key==="receiver")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===t&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const u=s[l]||BigInt(0);s[l]=u+BigInt(c)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),denom:o}))}function Rc(e,t){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")&&o.type==="move"){const r=o.attributes.find(l=>l.key==="type_tag")?.value,i=o.attributes.find(l=>l.key==="data")?.value;if(!r||!i)continue;let c;try{c=JSON.parse(i)}catch{continue}if(r==="0x1::fungible_asset::WithdrawEvent"){const l=c.store_addr,u=c.amount,m=c.metadata_addr;if(l&&u&&m&&k.createUserDerivedObjectAddress(t,m)===l){const h=s[m]||BigInt(0);s[m]=h-BigInt(u)}}if(r==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,u=c.amount,m=c.metadata_addr;if(l&&u&&m&&k.createUserDerivedObjectAddress(t,m)===l){const h=s[m]||BigInt(0);s[m]=h+BigInt(u)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const Pc=({metadata:e,chain:t,children:s})=>{const{restUrl:o}=t,{data:a}=E.useSuspenseQuery({queryKey:$n.denom(o,e).queryKey,queryFn:()=>z.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:V.INFINITY});return s(a)},sp="_root_1p8a4_1",op="_title_1p8a4_8",ap="_changes_1p8a4_14",rp="_change_1p8a4_14",ip="_amount_1p8a4_35",cp="_text_1p8a4_42",lp="_value_1p8a4_49",dn={root:sp,title:op,changes:ap,change:rp,amount:ip,text:cp,value:lp},Dc=({amount:e,asset:t,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=t,c=k.formatAmount(e,{decimals:r}),l=s&&q(k.fromBaseUnit(e,{decimals:r})).times(s).abs();return n.jsxs("div",{className:dn.change,children:[n.jsxs("div",{className:dn.amount,children:[n.jsx(re,{src:i,width:14,height:14,logo:!0}),n.jsxs("span",{className:dn.text,children:[c," ",a||o]})]}),l&&n.jsx("div",{className:dn.value,children:ae(l)})]})},up=({changes:e,chain:t})=>{const s=St(t),{data:o}=Pt(t);return e.map(({amount:a,denom:r},i)=>{const c=s(r),l=o?.find(({id:u})=>u===r)?.price;return n.jsx(Dc,{amount:a,asset:c,price:l},i)})},dp=({changes:e,chain:t})=>{const s=St(t),{data:o}=Pt(t);return e.map(({amount:a,metadata:r},i)=>n.jsx(Pc,{metadata:r,chain:t,children:c=>{const l=o?.find(({id:u})=>u===c)?.price;return n.jsx(Dc,{amount:a,asset:s(c),price:l})}},i))};function mp(e,t){return typeof t=="bigint"?t.toString():t}const hp=qe.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,mp)]}),fp=({messages:e,memo:t,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=tt(),r=_t(s),{simulateTx:i}=io(),{data:c}=E.useSuspenseQuery({queryKey:hp.simulate({messages:e,memo:t,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:t,chainId:s}),staleTime:V.SECOND}),l=h=>n.jsxs("div",{className:dn.root,children:[n.jsx("h2",{className:dn.title,children:"Estimated changes"}),n.jsx("div",{className:dn.changes,children:h})]});if(!c)return null;const u=c.result?.events??[];if(u.length===0)return null;if(r.metadata?.is_l1||r.metadata?.minitia?.type==="minimove"){const h=Rc(u,a),[f]=Nr(h);return f.length===0?null:l(n.jsx(dp,{changes:f,chain:r}))}const m=qc(u,o),[d]=Nr(m);return d.length===0?null:l(n.jsx(up,{changes:d,chain:r}))};function Nr(e){return L.partition(t=>new q(t.amount).isNegative(),e)}const pp="_title_1d032_1",gp="_meta_1d032_7",_p="_footer_1d032_14",yp="_rejectButton_1d032_19",Ns={title:pp,meta:gp,footer:_p,rejectButton:yp},Bc=()=>{const{txRequest:e,resolve:t,reject:s}=ic(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:c,spendCoins:l}=e,u=_t(r),m=as(u),d=Ia(u),h=Aa(u),f=St(u),g=rc(),p=(e.gasPrices??d).map(({amount:A,denom:$})=>Le.calculateFee(Math.ceil(i*c),Le.GasPrice.fromString(A+$))),y=p.map(A=>A.amount[0]),x=A=>{const $=m.find(K=>K.denom===A)?.amount??"0",N=y.find(K=>K.denom===A)?.amount??"0",S=l.filter(K=>K.denom===A).reduce((K,W)=>q(K).plus(W.amount),q("0")),P=q(N).plus(S),F=q($).gte(P),{symbol:D,decimals:Z}=f(A);return{symbol:D,decimals:Z,spend:S.gt(0)?S.toFixed():null,fee:N,total:P.toFixed(),balance:$,isSufficient:F}},b=()=>{if(h&&x(h).isSufficient)return h;for(const{denom:A}of y)if(x(A).isSufficient)return A;return y[0]?.denom},[j,v]=_.useState(b),{mutate:w,isPending:C}=E.useMutation({mutationKey:[oc],mutationFn:async()=>{const A=p.find(N=>N.amount[0].denom===j);if(!A)throw new Error("Fee not found");const $=await g({chainId:r,messages:o,memo:a||"",fee:A,preferredFeeDenom:j,allowAutoSign:!e.internal,allowWalletDerivation:!0});await t($)},onError:async A=>{s(A)}}),I=x(j),T=!I.isSufficient;return n.jsxs(n.Fragment,{children:[n.jsxs(yt,{children:[n.jsx("h1",{className:Ns.title,children:"Confirm tx"}),n.jsxs("section",{className:Ns.meta,"aria-label":"Transaction metadata",children:[n.jsx(Do,{title:"Chain",content:r}),n.jsx(Do,{title:"Tx fee",content:n.jsx(Lf,{options:p,value:j,onChange:v})}),a&&n.jsx(Do,{title:"Memo",content:a}),T&&n.jsx(we,{level:"error",children:n.jsx(Uf,{...I})})]}),n.jsx(fp,{messages:o,memo:a,chainId:r}),n.jsx(vf,{list:o,renderHeader:({typeUrl:A})=>Ys.sentenceCase(A.split(".").pop().replace(/^Msg/,"")),renderContent:A=>n.jsx(Xf,{message:A,chainId:r})})]}),n.jsxs(Ae,{className:Ns.footer,children:[n.jsx(fe.Outline,{onClick:()=>s(new Error("User rejected")),disabled:C,className:Ns.rejectButton,"aria-label":"Reject",children:n.jsx(M.IconClose,{size:16})}),n.jsx(fe.White,{onClick:()=>w(),disabled:T,loading:C,children:"Approve"})]})]})},xp=({children:e})=>{const[{title:t,content:s,path:o},a]=_.useState({}),[r,i]=_.useState(!1),c=H.useAtomValue(ro),l=_.useCallback(d=>{a(d),i(!0)},[]),u=_.useCallback(()=>{a({}),i(!1)},[]),m=_.useCallback(d=>{d||(c?.reject(new Error("User rejected")),a({})),i(d)},[c]);return n.jsxs(tc.Provider,{value:{openModal:l,closeModal:u},children:[e,n.jsx(Lc,{title:t,open:r,onOpenChange:m,children:n.jsx(xe,{children:o==="/tx"?n.jsx(Bc,{}):s})})]})},bp="_container_1w1hx_1",wp="_toast_1w1hx_11",vp="_info_1w1hx_24",jp="_success_1w1hx_28",Cp="_error_1w1hx_32",kp="_icon_1w1hx_37",Np="_content_1w1hx_45",Ip="_title_1w1hx_48",Ap="_description_1w1hx_53",Sp="_close_1w1hx_75",Vt={container:bp,toast:wp,info:vp,success:jp,error:Cp,icon:kp,content:Np,title:Ip,description:Ap,close:Sp},Tp=({notification:e,onClose:t,...s})=>{const o=Nt.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 n.jsx(It,{size:16});case"info":case"success":return n.jsx(M.IconCheckCircleFilled,{size:16});case"error":return n.jsx(M.IconCloseCircleFilled,{size:16});default:return null}};return o((r,i)=>{if(!i)return null;const{type:c,title:l,description:u}=i,m=a(c);return n.jsx(Nt.animated.div,{style:r,className:Vt.container,children:n.jsxs("div",{className:B(Vt.toast,c&&Vt[c]),role:"alert",...s,children:[m&&n.jsx("div",{className:Vt.icon,"aria-hidden":"true",children:m}),n.jsxs("div",{className:Vt.content,children:[n.jsx("p",{className:Vt.title,children:l}),u&&n.jsx("div",{className:Vt.description,children:u})]}),n.jsx("button",{className:Vt.close,onClick:t,"aria-label":"Dismiss notification",children:n.jsx(M.IconClose,{size:14,"aria-hidden":"true"})})]})})})},Bo=5e3,Ep=({children:e})=>{const t=_n(),[s,o]=_.useState(null),a=_.useRef(null),r=_.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},c=_.useCallback(()=>{i(),o(null)},[]),l=_.useCallback(h=>{i(),o({...h,id:ir.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Bo))},[c]),u=_.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:ir.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Bo))},[c]),m=()=>{i(),r.current=!0},d=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>c(),Bo))};return _.useEffect(()=>()=>i(),[]),n.jsxs(Ec.Provider,{value:{showNotification:l,updateNotification:u,hideNotification:c},children:[e,t&&Ol.createPortal(n.jsx(Tp,{notification:s,onClose:c,onMouseEnter:m,onMouseLeave:d}),t)]})},$p=({children:e})=>{const[t,s]=_.useState(null);return n.jsx(mo.Provider,{value:{container:t,setContainer:s},children:e})};function Mp(e){const t=e.split(".");return t.length!==4?!1:t.every(s=>{if(!/^\d+$/.test(s))return!1;const o=Number(s);return o>=0&&o<=255})}function Fc(e){return Mp(e)||e.includes(":")}function ta(e){const t=Vl.parse(e);return"error"in t?null:t.domain}function Lp(e,t){return e===t||e===`www.${t}`}function qp(e){if(e.protocol!=="https:")return!1;const t=e.hostname.toLowerCase();return!t||!t.includes(".")||t==="localhost"||Fc(t)?!1:ta(t)!==null}function Rp(e,t){try{const s=new URL(e);if(!qp(s))return!1;const o=s.hostname.toLowerCase(),a=t.toLowerCase();if(!o||!a||Fc(a)||a==="localhost")return!1;const r=ta(o);if(!r)return!1;const i=ta(a);return!i||i!==r?!1:Lp(o,r)?a===r||a.endsWith(`.${r}`):a===o||a.endsWith(`.${o}`)}catch{return!1}}const Pp="_container_1422v_1",Dp="_title_1422v_7",Bp="_description_1422v_14",Fp="_sectionTitle_1422v_20",Up="_websiteInfo_1422v_27",Op="_favicon_1422v_37",Vp="_websiteTitle_1422v_42",Kp="_websiteHost_1422v_48",Wp="_warningContent_1422v_54",zp="_ignoreButton_1422v_61",Hp="_infoList_1422v_65",Qp="_infoItem_1422v_75",Gp="_label_1422v_84",Yp="_infoValue_1422v_94",Zp="_durationTrigger_1422v_100",Jp="_durationItem_1422v_101",Xp="_featureList_1422v_105",eg="_featureItem_1422v_113",tg="_checkIcon_1422v_123",ng="_learnMoreLink_1422v_127",sg="_feedbackContainer_1422v_140",og="_footer_1422v_146",pe={container:Pp,title:Dp,description:Bp,sectionTitle:Fp,websiteInfo:Up,favicon:Op,websiteTitle:Vp,websiteHost:Kp,warningContent:Wp,ignoreButton:zp,infoList:Hp,infoItem:Qp,label:Gp,infoValue:Yp,durationTrigger:Zp,durationItem:Jp,featureList:Xp,featureItem:eg,checkIcon:tg,learnMoreLink:ng,feedbackContainer:sg,footer:og};function ag(e){return e instanceof z.HTTPError&&e.response.status===404}const rg=qe.createQueryKeys("interwovenkit:account",{info:(e,t)=>({queryKey:[e,t],queryFn:async()=>{const s=z.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${t}`;try{return await s.get(o).json(),!0}catch(a){if(ag(a))return!1;throw a}}})}),ig=()=>{const[e,t]=H.useAtom(rs),[s,o]=_.useState(()=>e?.defaultDuration??Zo),[a,r]=_.useState(!1),i=lt(),c=_e(),{address:l,initiaAddress:u,username:m}=tt(),{mutate:d,isPending:h}=Ad(),{closeDrawer:f}=Dt();if(!e)throw new Error("Pending request not found");const{logoUrl:g,name:p,restUrl:y}=i(e.chainId),{data:x,isLoading:b,isError:j}=E.useQuery(rg.info(y,u)),v={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},w=c.find(P=>P.chainId===e.chainId),C=w?.website?Rp(w.website,window.location.hostname):!1,I=()=>{d(s)},T=()=>{e?.reject(new Error("User cancelled")),t(null),f()},A=!C&&!a,$=!b&&!j&&x===!1,N=!b&&j,S=A||b||j||x===!1;return n.jsxs(n.Fragment,{children:[n.jsxs(yt,{className:pe.container,children:[n.jsxs("header",{children:[n.jsx("h1",{className:pe.title,children:"Enable auto-signing"}),n.jsx("p",{className:pe.description,children:"An application is requesting to enable auto-signing"})]}),n.jsxs("section",{children:[n.jsx("h2",{className:pe.sectionTitle,children:"Requested by"}),n.jsxs("div",{className:pe.websiteInfo,children:[n.jsx("img",{src:v.favicon,alt:"",className:pe.favicon}),n.jsxs("div",{children:[n.jsx("div",{className:pe.websiteTitle,children:v.title}),n.jsx("div",{className:pe.websiteHost,children:v.hostname})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:pe.sectionTitle,children:"Applies to"}),n.jsxs("div",{className:pe.infoList,children:[n.jsxs("div",{className:pe.infoItem,children:[n.jsx("div",{className:pe.label,children:"Address"}),n.jsxs("div",{className:pe.infoValue,children:[n.jsx(M.IconWallet,{size:14}),n.jsx("span",{className:"monospace",children:k.truncate(m??l)})]})]}),n.jsxs("div",{className:pe.infoItem,children:[n.jsx("div",{className:pe.label,children:"Chain"}),n.jsxs("div",{className:pe.infoValue,children:[n.jsx(re,{src:g,width:14,height:14,logo:!0}),n.jsx("span",{children:p})]})]}),n.jsxs("div",{className:pe.infoItem,children:[n.jsx("div",{className:pe.label,children:"Duration"}),n.jsx(Fa,{options:Sa,value:s,onChange:o,classNames:{trigger:pe.durationTrigger,item:pe.durationItem}})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:pe.sectionTitle,children:"About auto-signing"}),n.jsx("ul",{className:pe.featureList,children:["Send transactions without confirmation pop-ups","Secured by your wallet signature","Revoke permissions any time in settings"].map(P=>n.jsxs("li",{className:pe.featureItem,children:[n.jsx(M.IconCheckCircle,{size:12,className:pe.checkIcon}),n.jsx("span",{children:P})]},P))}),n.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",rel:"noopener noreferrer",className:pe.learnMoreLink,children:["Learn more ",n.jsx(M.IconExternalLink,{size:12})]})]})]}),n.jsxs(Ae,{className:pe.footer,extra:n.jsxs("div",{className:pe.feedbackContainer,children:[$&&n.jsx(we,{level:"error",children:"Insufficient balance for fee"}),N&&n.jsx(we,{level:"warning",children:"Unable to verify account status. Try again."}),!C&&!a&&n.jsx(we,{level:"warning",children:n.jsxs("div",{className:pe.warningContent,children:[n.jsx("span",{children:"You are on an unverified website"}),n.jsx("button",{onClick:()=>r(!0),className:pe.ignoreButton,children:"Ignore"})]})})]}),children:[n.jsx(fe.Outline,{onClick:T,children:"Cancel"}),n.jsx(fe.White,{onClick:I,disabled:S,loading:h,children:"Enable"})]})]})},cg=()=>{const e=H.useAtomValue(rs);return e?n.jsx(ig,{},`${e.chainId}:${e.defaultDuration}`):null},lg="_container_mqvhs_1",ug="_badge_mqvhs_5",Ir={container:lg,badge:ug},Uc=e=>{const{offset:t=-4,disabled:s,children:o,className:a}=e;return n.jsxs("div",{className:B(Ir.container,a),children:[o,!s&&n.jsx("div",{className:Ir.badge,style:{right:t,top:t},"aria-hidden":"true"})]})},dg="_header_s7mee_1",mg="_back_s7mee_12",hg="_title_s7mee_24",Fo={header:dg,back:mg,title:hg},Tt=({title:e,backButton:t,extra:s,children:o})=>{const a=Ni();return n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Fo.header,children:[n.jsx(mn,{to:t??(a.length>1?-1:"/"),className:Fo.back,shouldReset:!!t,"aria-label":"Go back",children:n.jsx(M.IconBack,{size:16,"aria-hidden":"true"})}),n.jsx("h1",{className:Fo.title,children:e}),s]}),n.jsx(yt,{children:o})]})};function Oa(){const e=_e();return t=>e.some(s=>s.chain_id===t)}function fg(e,t){return t(e.chain_id)&&e.chain_name.toLowerCase()!=="initia"}function fs(){const e=Oa();return t=>e(t.chain_id)?"initia":t.chain_type}function yn(e){return fs()(e)}function fo(){const e=Fe(),{data:t}=E.useSuspenseQuery({queryKey:Ie.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>L.sortWith([L.descend(({chain_name:o})=>o==="initia"),L.ascend(({pretty_name:o})=>o)],s),staleTime:V.MINUTE});return t}function Bt(){const e=fo(),t=_i();return s=>{const o=e.find(r=>r.chain_id===s);if(o)return o;const a=t.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 Ye(e){return Bt()(e)}function pg(e,t){try{return de.fromBech32(e).prefix===t}catch{return!1}}function Oc(){const{initiaAddress:e,hexAddress:t}=tt(),s=Bt(),o=fs();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return t;default:return""}}}function Va(){const e=Bt(),t=fs();return(s,o)=>{const a=e(o);switch(t(a)){case"initia":return k.InitiaAddress.validate(s);case"evm":return kt.isAddress(s);case"cosmos":return a.bech32_prefix?pg(s,a.bech32_prefix):!1;default:return!1}}}function gg(){const e=Bt(),t=fs();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),c=t(i),l=e(a),u=t(l);if(c==="evm"&&u==="initia")return k.InitiaAddress(s).bech32;if(c==="initia"&&u==="evm")return k.InitiaAddress(s).hex;if(c===u)return s;if(r){if(u==="initia")return k.InitiaAddress(r).bech32;if(u==="evm")return k.InitiaAddress(r).hex}return""}}function _g(){const e=Fe();return E.useSuspenseQuery({queryKey:Ie.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:V.MINUTE})}function ps(){const{data:{chain_to_assets_map:e}}=_g(),t=fo(),s=E.useQueryClient();return _.useMemo(()=>{const o=[];for(const a in e){if(!t.some(i=>i.chain_id===a))continue;const{assets:r}=e[a]??{assets:[]};s.setQueryData(Ie.assets(a).queryKey,{chain_to_assets_map:{[a]:e[a]}});for(const i of r)s.setQueryData(Ie.asset(a,i.denom).queryKey,i);o.push(...r)}return o},[e,t,s])}function Hs(e){const t=Fe(),s=E.useQueryClient(),{data:o}=E.useSuspenseQuery({queryKey:Ie.assets(e).queryKey,queryFn:()=>t.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(Ie.asset(e,i.denom).queryKey,i);return r.slice().sort(L.descend(i=>i.symbol==="INIT"))},staleTime:V.MINUTE});return o}function Vc(e){const t=Hs(e);return s=>{const o=t.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function At(e,t){return Vc(t)(e)}const yg="_root_ekn9t_1",xg="_header_ekn9t_6",bg="_title_ekn9t_12",wg="_warning_ekn9t_18",vg="_content_ekn9t_22",jg="_footer_ekn9t_26",Cg="_secondary_ekn9t_36",nn={root:yg,header:xg,title:bg,warning:wg,content:vg,footer:jg,secondary:Cg},Kc=e=>{const{type:t,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return n.jsxs(yt,{className:nn.root,children:[n.jsxs("header",{className:B(nn.header,t&&nn[t]),children:[s,n.jsx("h1",{className:nn.title,children:o})]}),n.jsx("div",{className:nn.content,children:a}),n.jsxs("footer",{className:nn.footer,children:[n.jsx(fe.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),n.jsxs("button",{className:nn.secondary,onClick:i.onClick,children:[n.jsx("span",{children:i.label}),n.jsx(M.IconChevronRight,{size:14,"aria-hidden":"true"})]})]})]})},kg="_list_k4n3k_1",Ng="_row_k4n3k_9",Ig="_dt_k4n3k_20",Ag="_asset_k4n3k_26",Is={list:kg,row:Ng,dt:Ig,asset:Ag},Sg=({list:e,onNavigate:t,onDismiss:s})=>{const o=ce(),a=lt(),r=St(o);return n.jsx(Kc,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:t},secondaryButton:{label:"Do not show again",onClick:s},children:n.jsx("div",{className:Is.list,children:e.slice().sort((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:u})=>{const m=a(c),{decimals:d,symbol:h}=r(u),f=k.formatAmount(l,{decimals:d});return n.jsxs("div",{className:Is.row,children:[n.jsxs("div",{className:Is.dt,children:[n.jsx(re,{src:m.logoUrl,width:16,height:16,logo:!0}),n.jsx("span",{children:m.name})]}),n.jsxs("span",{className:Is.asset,children:[f," ",h]})]},i)})})})};function Uo(e,t){return e.chainId===t.chainId&&e.txHash===t.txHash}const As=({chainId:e,txHash:t})=>`${he.OP_REMINDER}:${e}:${t}`,Tg=Kl.atomWithStorage(he.OP_REMINDER,[]);function Fn(){const e=ie(),[t=[],s]=H.useAtom(Tg),o=_.useMemo(()=>t.map(l=>{const u=localStorage.getItem(As(l));return u?JSON.parse(u):null}).filter(l=>{if(!l)return!1;const{recipient:u,claimableAt:m}=l;return u!==e?!1:Xe.isPast(m)}),[e,t]),a=_.useCallback((l,u)=>{t.some(m=>Uo(m,l))||(s((m=[])=>[...m,l]),localStorage.setItem(As(l),JSON.stringify(u)))},[t,s]),r=_.useCallback(l=>{s((u=[])=>u.filter(m=>!Uo(m,l))),localStorage.removeItem(As(l))},[s]),i=_.useCallback(l=>{const u=l.filter(m=>!t.some(d=>Uo(d,m)));u.length!==0&&s((m=[])=>[...m,...u])},[t,s]),c=_.useCallback((l,u)=>{localStorage.setItem(As(l),JSON.stringify(u)),s((m=[])=>[...m])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:c}}function Wc(){const e=Me(),{openModal:t,closeModal:s}=ao(),{reminders:o,setReminder:a}=Fn();_.useEffect(()=>{const r=o.filter(l=>!l.dismissed);if(r.length===0)return;const i=()=>{const l=r.every(u=>u.chainId===r[0].chainId)?r[0].chainId:void 0;e("/op/withdrawals",{chainId:l}),c()},c=()=>{s();for(const l of r)a(l,{...l,dismissed:!0})};t({content:_.createElement(Sg,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,t,a])}const Eg="_wrapper_5ssm8_1",$g="_balance_5ssm8_11",Mg="_button_5ssm8_15",Oo={wrapper:Eg,balance:$g,button:Mg},zc=({onClick:e,children:t,disabled:s})=>n.jsxs("div",{className:Oo.wrapper,children:[n.jsx(M.IconWallet,{size:16,"aria-hidden":"true"}),n.jsx("span",{className:Oo.balance,children:t}),n.jsx("button",{type:"button",tabIndex:-1,className:Oo.button,onClick:()=>e(),disabled:s,"aria-label":"Use maximum balance",children:"MAX"})]}),Lg="_fieldset_up6fh_1",qg="_upper_up6fh_9",Rg="_select_up6fh_14",Pg="_account_up6fh_20",Dg="_lower_up6fh_25",Bg="_wrapper_up6fh_26",Fg="_balance_up6fh_33",Ug="_value_up6fh_37",Og="_error_up6fh_50",qt={fieldset:Lg,upper:qg,select:Rg,account:Pg,lower:Dg,wrapper:Bg,balance:Fg,value:Ug,error:Og},na=e=>{const{selectButton:t,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:c}=e;return n.jsxs("div",{className:qt.fieldset,children:[n.jsxs("div",{className:qt.upper,children:[n.jsx("div",{className:qt.select,children:t}),n.jsx("div",{className:qt.account,children:s})]}),!c&&n.jsxs("div",{className:qt.lower,children:[o,n.jsxs("div",{className:qt.wrapper,children:[n.jsx("div",{className:qt.balance,children:a}),r&&n.jsx("div",{className:qt.value,children:r})]}),i&&n.jsxs("footer",{className:qt.error,children:[n.jsx(M.IconWarningFilled,{size:12,"aria-hidden":"true"}),n.jsx("p",{role:"alert",children:i})]})]})]})},Hc=({quantity:e,balance:t,decimals:s})=>!e||t===void 0||s===void 0||q(e).isZero()?!1:q(k.toBaseUnit(e,{decimals:s})).gt(t);function gs(){const e=_.useRef(null),t=uo();return _.useEffect(()=>{t||e.current?.focus()},[t]),e}const Vg="_input_h8073_1",Kg={input:Vg};function Qc(e){const{name:t,control:s,dp:o=6,className:a,rules:r,...i}=e,c=gs();return n.jsx($e.Controller,{name:t,control:s,rules:r,render:({field:l})=>n.jsx(Wl.NumericFormat,{value:l.value,getInputRef:mi.mergeRefs([l.ref,c]),className:B(Kg.input,a),onValueChange:u=>{l.onChange(u.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const Wg="_input_19r9r_1",zg="_placeholder_19r9r_18",sa={input:Wg,placeholder:zg},Hg=({children:e})=>n.jsx("p",{className:B(sa.input,{[sa.placeholder]:q(e).isZero()}),children:e}),ns=({balance:e,decimals:t,className:s})=>{const{control:o}=$e.useFormContext(),a={required:"Enter amount",validate:r=>q(r).isZero()?"Enter amount":Hc({quantity:r,balance:e,decimals:t})?"Insufficient balance":!0};return n.jsx(Qc,{name:"quantity",control:o,className:B(sa.input,s),rules:a})};ns.ReadOnly=Hg;const qn=({title:e,content:t,children:s,className:o})=>{const[a,r]=_.useState(!1),i=()=>r(!1);return n.jsx(Lc,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:t(i)})},Qg="_tooltip_19kvs_1",Gg="_arrow_19kvs_44",Ar={tooltip:Qg,arrow:Gg},_s=({label:e,children:t,small:s,...o})=>n.jsxs(te.Tooltip.Root,{...o,children:[n.jsx(te.Tooltip.Trigger,{asChild:!0,children:t}),n.jsx(te.Tooltip.Portal,{container:_n(),children:n.jsxs(te.Tooltip.Content,{className:B(Ar.tooltip,{small:s}),collisionBoundary:_n(),collisionPadding:8,sideOffset:4,children:[e,n.jsx(te.Tooltip.Arrow,{className:Ar.arrow})]})})]});function po(e,t){const s=Fe(),o=Va(),a=!!t&&!!e&&o(e,t);return E.useQuery({queryKey:Ie.balances(t,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[t]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>a?r?r[t]?.denoms??{}:{}:{},enabled:a,staleTime:V.SECOND})}function Yg(e,t,s){const{data:o={}}=po(e,t);return L.path([s],o)}function Zg({sourceDenom:e,sourceBalance:t,amountIn:s,feeTokenDenoms:o,balancesByDenom:a,additionalFees:r=[]}){if(!o.includes(e)||t===void 0||s===void 0||a===void 0)return!1;const c=r.reduce((m,d)=>{if(d.amount===void 0)return m;const h=d.origin_asset.denom,f=m.get(h)??q(0);return m.set(h,f.plus(d.amount)),m},new Map);if(o.some(m=>{if(m===e)return!1;const d=q(a[m]?.amount??"0"),h=c.get(m);return h?d.gte(h):d.gt(0)}))return!1;const u=c.get(e)??q(0);return u.isZero()?!1:q(t).lt(q(s).plus(u))}const Jg=[["d",1440*60],["h",3600],["m",60],["s",1]];function ss(e){if(!e)return;const{formattedParts:t}=Jg.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 t.join(" ")}function Gc(e,t){return q(e).times(q(100).minus(t)).div(100).integerValue(q.ROUND_FLOOR).toFixed(0)}function Ka(e){return e?.map(t=>{const{amount:s,origin_asset:o}=t;return`${k.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function Yc(e,t,s,o){const{srcChainId:a,srcDenom:r,quantity:i,dstChainId:c,dstDenom:l}=s,u=t.getQueryData(Ie.asset(a,r).queryKey);if(!u||u.decimals==null)throw new Error("Failed to refresh route: source asset metadata is unavailable.");const m=u.decimals;return e.post("v2/fungible/route",{signal:o?.signal,json:{amount_in:k.toBaseUnit(i,{decimals:m}),source_asset_chain_id:a,source_asset_denom:r,dest_asset_chain_id:c,dest_asset_denom:l,is_op_withdraw:o?.isOpWithdraw}}).json()}function oa(e,t){const{watch:s}=Zt(),o=s(),a=Fe(),r={srcChainId:o.srcChainId,srcDenom:o.srcDenom,dstChainId:o.dstChainId,dstDenom:o.dstDenom,quantity:e},i=!r.srcChainId||!r.srcDenom||!r.dstChainId||!r.dstDenom,c=q(r.quantity||0),l=c.isFinite()&&c.gt(0),u=t?.refreshMs??1e4,m=l&&!t?.disabled&&!i,d=E.useQueryClient();return E.useQuery({queryKey:Ie.route(r,t?.isOpWithdraw).queryKey,queryFn:async({signal:h})=>Yc(a,d,r,{isOpWithdraw:t?.isOpWithdraw,signal:h}),enabled:m,staleTime:u,refetchInterval:m?u:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,refetchOnMount:"always"})}function Xg(e){return E.useQuery({queryKey:Ie.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof z.HTTPError))return null;const{response:t}=e;return(t.headers.get("content-type")??"").includes("application/json")?(await t.json()).info??null:null},enabled:!!e})}function e_(){const{watch:e}=Zt(),{srcChainId:t,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=Ye(t),i=yn(r),c=At(s,t),l=At(a,o),u=ce(),m=_e();return i==="initia"&&o===u.chainId&&c.symbol===l.symbol&&m.find(d=>d.chainId===t)?.metadata?.op_denoms?.includes(l.denom)}const t_="_label_t93ix_1",n_="_wrapper_t93ix_7",s_="_input_t93ix_10",o_="_clear_t93ix_18",Ss={label:t_,wrapper:n_,input:s_,clear:o_},Wa=({mode:e="onChange",myAddress:t,...s})=>{const{validate:o=k.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,c=gs(),{control:l,getValues:u,setValue:m,formState:d}=$e.useFormContext(),h=u("recipient"),[f,g]=_.useState(h),p=vi(),{data:y,isLoading:x,error:b}=E.useQuery({queryKey:Xs.address(p.restUrl,f).queryKey,queryFn:()=>p.getAddress(f),staleTime:V.MINUTE,enabled:p.validateUsername(f)}),j=y??(o(f)?f:""),v=t&&k.InitiaAddress.equals(j,t),w=async()=>{try{const T=await navigator.clipboard.readText();g(T.trim())}catch{}};_.useEffect(()=>{e==="onChange"&&(!f&&!d.dirtyFields.recipient||m("recipient",y??f,{shouldValidate:!0,shouldDirty:!0}))},[d.dirtyFields.recipient,f,e,m,y]);const C=()=>{x||b||(m("recipient",j,{shouldValidate:!0,shouldDirty:!0}),r?.())},I=()=>{if(x)return n.jsx(In,{level:"loading",children:"Resolving username..."});if(b)return n.jsx(In,{level:"error",children:b.message});if(y)return n.jsx(In,{level:"success",className:"monospace",children:y});if(e==="onSubmit"&&f&&!j)return n.jsx(In,{level:"error",children:"Invalid address"})};return n.jsxs("div",{children:[n.jsxs("label",{htmlFor:"recipient",className:Ss.label,children:[n.jsx("span",{children:"Recipient"}),n.jsx(fe.Small,{type:"button",tabIndex:-1,onClick:w,children:"Paste"})]}),n.jsxs("div",{className:Ss.wrapper,children:[n.jsx($e.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:T=>o(T)||"Invalid address"},render:()=>n.jsx("input",{id:"recipient",className:B(Ss.input,"monospace"),value:f,onChange:T=>g(T.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?mi.mergeRefs([i,c]):i})}),!!f&&n.jsx("button",{type:"button",className:Ss.clear,onClick:()=>g(""),"aria-label":"Clear recipient",children:n.jsx(M.IconCloseCircleFilled,{size:16})})]}),I(),v&&n.jsx(In,{children:"This is my address"}),e==="onSubmit"&&n.jsx(Ae,{extra:(!t||!!j&&!v)&&n.jsx(we,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:n.jsx(fe.White,{type:"button",onClick:C,disabled:x||!!b||!j,children:"Apply"})})]})},a_="_scrollable_vgj3r_1",r_="_list_vgj3r_5",i_="_item_vgj3r_9",c_="_name_vgj3r_22",Ts={scrollable:a_,list:r_,item:i_,name:c_};function Zc({onSelect:e,list:t,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:c}=s;return n.jsx(yt,{className:Ts.scrollable,children:n.jsx("div",{className:Ts.list,children:t.map(l=>n.jsxs("button",{className:Ts.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),"aria-busy":!!i?.(l),children:[n.jsx(re,{src:o(l),width:28,height:28}),n.jsx("span",{className:Ts.name,children:a(l)}),i?.(l)&&n.jsx(It,{size:16})]},r(l)))})})}function go(){const{cosmosWallets:e=[]}=se(),t=_.useMemo(()=>{const a=[{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"}].filter(r=>!e.some(i=>i.name===r.name));return[...e,...a]},[e]);return{list:t,find:o=>t.find(a=>a.name===o)}}const l_="_account_h04x1_8",u_="_clear_h04x1_28",d_="_white_h04x1_39",Kn={account:l_,clear:u_,white:d_},Sr=({type:e})=>{const{watch:t,setValue:s}=Zt(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=t(),c=t(e==="src"?"sender":"recipient"),l=yn(Ye(a)),{showNotification:u}=hs(),{list:m,find:d}=go(),h=d(r),f=Oc(),g=Va(),p=f(a),y=k.InitiaAddress.equals(c,p),x=()=>n.jsx(qn,{title:"Connect wallet",content:v=>n.jsx(Zc,{onSelect:async w=>{const C=w.getProvider();if(!C){w.fallbackUrl?window.open(w.fallbackUrl,"_blank"):u({type:"error",title:`${w.name} not available`,description:"Please install the wallet extension and try again."});return}try{const T=await C.getOfflineSigner(o).getAccounts();if(T.length===0)throw new Error("No accounts found");s("sender",T[0].address),s("cosmosWalletName",w.name),v()}catch(I){const T=I instanceof Error?I.message:"Unknown error";u({type:"error",title:`Failed to connect ${w.name}`,description:T})}},list:m,getImage:w=>w.image,getName:w=>w.name,getKey:w=>w.name}),className:B(Kn.account,{[Kn.white]:!c}),children:c?n.jsxs(n.Fragment,{children:[h&&n.jsx(re,{src:h.image,width:18,height:18}),n.jsx("span",{className:"monospace",children:k.truncate(c)})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"Connect wallet"}),n.jsx(M.IconChevronRight,{size:14,"aria-hidden":"true"})]})}),b=v=>n.jsx(qn,{title:"Recipient",content:w=>n.jsx(yt,{children:n.jsx(Wa,{mode:"onSubmit",myAddress:p,chainType:l,validate:C=>g(C,a),onApply:w})}),className:Kn.account,children:v}),j=()=>{switch(l){case"initia":case"evm":return y?b(n.jsx(M.IconWallet,{size:14})):n.jsxs("div",{className:Kn.account,children:[n.jsx("span",{className:"monospace",children:k.truncate(c)}),n.jsx("button",{type:"button",className:Kn.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:n.jsx(M.IconCloseCircleFilled,{size:14})})]});case"cosmos":return b(n.jsxs(n.Fragment,{children:[c?n.jsx("span",{className:"monospace",children:k.truncate(c)}):n.jsx("span",{children:"Recipient"}),n.jsx(M.IconEdit,{size:14,"aria-hidden":"true"})]}))}};switch(e){case"src":return x();case"dst":return j()}},m_="_images_cj4xz_1",Vo={images:m_},_o=({assetLogoUrl:e,assetLogoSize:t=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>n.jsxs("div",{className:B(Vo.images,r),style:{position:"relative"},"aria-hidden":"true",children:[n.jsx(re,{src:e,width:t,height:t,className:Vo.asset,logo:!0}),n.jsx(re,{src:s,width:o,height:o,className:Vo.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),h_="_root_6187w_1",f_="_content_6187w_10",p_="_details_6187w_20",g_="_symbol_6187w_26",__="_chain_6187w_34",y_="_chevron_6187w_43",sn={root:h_,content:f_,details:p_,symbol:g_,chain:__,chevron:y_},Jc=({asset:e,chain:t,readOnly:s})=>{const o=n.jsxs("div",{className:sn.content,children:[n.jsx(_o,{assetLogoUrl:e.logoUrl,chainLogoUrl:t.logoUrl}),n.jsxs("div",{className:sn.details,children:[n.jsx("div",{className:sn.symbol,children:e.symbol||e.denom}),n.jsxs("div",{className:sn.chain,children:["on ",t.name]})]})]});return s?n.jsx("div",{className:sn.root,children:o}):n.jsxs("div",{className:sn.root,children:[o,n.jsx(M.IconChevronDown,{size:16,className:sn.chevron,"aria-hidden":"true"})]})};function x_(e,t,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return L.any(L.includes(t.toLowerCase()),a)})}const b_="_root_1sh27_1",w_="_label_1sh27_8",v_="_input_1sh27_21",j_="_hasValue_1sh27_31",C_="_clear_1sh27_35",Wn={root:b_,label:w_,input:v_,hasValue:j_,clear:C_},ys=e=>{const{rootClassName:t,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return n.jsxs("div",{className:B(Wn.root,t,{[Wn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[n.jsx("label",{htmlFor:"search",className:Wn.label,children:n.jsx(M.IconSearch,{size:o})}),n.jsx("input",{className:Wn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&n.jsx("button",{type:"button",className:Wn.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:a,children:n.jsx(M.IconCloseCircleFilled,{size:o})})]})},k_="_container_5tajg_1",N_="_search_5tajg_7",I_="_list_5tajg_11",A_="_item_5tajg_15",S_="_logo_5tajg_37",T_="_info_5tajg_41",E_="_symbol_5tajg_47",$_="_name_5tajg_56",M_="_balance_5tajg_62",L_="_value_5tajg_69",rt={container:k_,search:N_,list:I_,item:A_,logo:S_,info:T_,symbol:E_,name:$_,balance:M_,value:L_},xs=e=>{const{assets:t,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=_.useState(""),i=x_(["symbol"],a,t);return n.jsxs("div",{className:rt.container,children:[n.jsx(ys,{value:a,onChange:c=>r(c.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:rt.search,padding:20,ref:gs()}),i.length===0?n.jsx(je,{children:"No assets"}):n.jsx("div",{className:rt.list,children:i.map(c=>n.jsx("button",{type:"button",className:rt.item,onClick:()=>s(c.denom),children:o(c,l=>{const{denom:u,logoUrl:m,symbol:d,name:h,balance:f,decimals:g,value:p=0}=l;return n.jsxs(n.Fragment,{children:[n.jsx(re,{src:m,width:32,height:32,className:rt.logo,logo:!0}),n.jsxs("div",{className:rt.info,children:[n.jsx("div",{className:rt.symbol,children:d||u}),n.jsx("div",{className:rt.name,children:h})]}),n.jsxs("div",{className:rt.balance,children:[f&&n.jsx("div",{children:k.formatAmount(f,{decimals:g})}),p>0&&n.jsx("div",{className:rt.value,children:ae(p)})]})]})})},c.denom))})]})},q_=()=>n.jsxs("div",{className:rt.container,children:[n.jsx(ys,{rootClassName:rt.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),n.jsx(je,{children:"Loading..."})]});xs.Placeholder=q_;const R_="_stack_16oqn_1",P_="_title_16oqn_9",D_="_grid_16oqn_16",B_="_item_16oqn_22",F_="_button_16oqn_26",U_="_active_16oqn_44",An={stack:R_,title:P_,grid:D_,item:B_,button:F_,active:U_},fn=({label:e,chains:t,value:s,onSelect:o,getShowIndicator:a})=>n.jsxs("div",{children:[e&&n.jsx("h2",{className:An.title,children:e}),n.jsx("div",{className:An.grid,children:t.map(({chainId:r,name:i,logoUrl:c})=>n.jsx(Uc,{offset:-2,disabled:!a?.(r),className:An.item,children:n.jsx(_s,{label:i,disableHoverableContent:!0,children:n.jsx("button",{type:"button","aria-label":i,className:B(An.button,{[An.active]:r===s}),onClick:()=>o(r),children:n.jsx(re,{src:c,width:28,height:28,logo:!0})})})},r))})]}),O_=({children:e})=>n.jsx("div",{className:An.stack,children:e});fn.Stack=O_;const V_=({address:e,chain:t,onSelect:s})=>{const o=Hs(t.chain_id),{data:a={}}=po(e,t.chain_id);return n.jsx(xs,{assets:L.sortWith([L.descend(r=>r.symbol==="INIT"),L.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>q(i).comparedTo(r)??0,L.ascend(r=>r.symbol.toLowerCase())],o.filter(r=>!r.hidden).map(r=>{const{denom:i,symbol:c=k.truncate(i),logo_uri:l}=r,u=a[i]??{};return{...r,symbol:c,decimals:r.decimals??0,logoUrl:l??"",name:r.name??"",balance:u.amount,value:Number(u.value_usd??0)}})),onSelect:s})},K_=({type:e,afterSelect:t})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=Yt(),i=fo(),{watch:c,setValue:l}=Zt(),u=c(a),m=c(s),d=c(o),[h,f]=_.useState(m),g=Ye(h),p=gg(),y=Oa(),[x,b]=L.partition(v=>y(v.chain_id),i.filter(v=>!v.hidden)),j=v=>{if(m===h&&d===v){t();return}l(s,h),l(o,v),t()};return n.jsxs(n.Fragment,{children:[n.jsxs(fn.Stack,{children:[n.jsx(fn,{label:"Interwoven Economy",chains:x.map(({chain_id:v,chain_name:w,pretty_name:C,logo_uri:I})=>({chainId:v,name:C||w,logoUrl:I??""})),value:h,onSelect:f}),n.jsx(fn,{label:"Chains",chains:b.map(({chain_id:v,chain_name:w,pretty_name:C,logo_uri:I})=>({chainId:v,name:C||w,logoUrl:I??""})),value:h,onSelect:f})]}),n.jsx(xe,{suspenseFallback:n.jsx(xs.Placeholder,{}),children:n.jsx(V_,{address:p({initialAddress:u,initialChainId:m,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:g,onSelect:j})},h)]})},Tr=({type:e})=>{const t=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=Zt(),r=a(t),i=a(s),c=Ye(r),l=At(i,r);return n.jsx(qn,{title:o,content:u=>n.jsx(K_,{type:e,afterSelect:u}),children:n.jsx(Jc,{asset:{denom:l.denom,decimals:l.decimals??0,symbol:l.symbol,logoUrl:l.logo_uri??""},chain:{chainId:c.chain_id,name:c.pretty_name||c.chain_name,logoUrl:c.logo_uri??""}})})},W_="_skeleton_1l4jn_1",z_={skeleton:W_},pn=({width:e="100%",height:t})=>n.jsx("div",{className:z_.skeleton,style:{width:e,height:t},"aria-hidden":"true"}),H_="_stack_oq1ir_1",Q_="_button_oq1ir_6",G_="_isLoading_oq1ir_19",Y_="_disabled_oq1ir_19",Z_="_checked_oq1ir_23",J_="_header_oq1ir_37",X_="_title_oq1ir_43",ey="_duration_oq1ir_52",ty="_warning_oq1ir_62",ny="_amount_oq1ir_66",sy="_value_oq1ir_67",at={stack:H_,button:Q_,isLoading:G_,disabled:Y_,checked:Z_,header:J_,title:X_,duration:ey,warning:ty,amount:ny,value:sy},oy=({children:e})=>n.jsx("div",{className:at.stack,role:"radiogroup","aria-label":"Route options",children:e}),Ps=({label:e,query:t,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=t,{watch:c}=Zt(),{dstChainId:l,dstDenom:u}=c(),m=At(u,l),d=!i&&a.checked,h=!i&&!r;return n.jsxs("button",{type:"button",className:B(at.button,{[at.isLoading]:i,[at.disabled]:h,[at.checked]:d}),onClick:()=>{i||h||o(s)},role:"radio","aria-checked":d,"aria-disabled":h,children:[n.jsxs("div",{className:at.header,children:[n.jsxs("div",{className:at.title,children:[n.jsx("span",{children:e}),d&&n.jsx(M.IconCheck,{size:14,"aria-hidden":"true"})]}),i?n.jsx(pn,{width:80,height:16}):r?n.jsxs("div",{className:B(at.duration,{[at.warning]:s==="op"}),children:[n.jsx(M.IconClockFilled,{size:12,"aria-hidden":"true"}),n.jsx("span",{children:ss(r.estimated_route_duration_seconds)})]}):n.jsx("div",{className:at.duration,children:"Not available"})]}),(i||r)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:at.amount,children:i?n.jsx(pn,{width:260,height:40}):r?k.formatAmount(r.amount_out,{decimals:m.decimals}):null}),n.jsx("div",{className:at.value,children:i?n.jsx(pn,{width:120,height:16}):r?r.usd_amount_out?ae(r.usd_amount_out):"$-":null})]})]})};Ps.Stack=oy;const ay="_description_nuyvt_1",ry="_presets_nuyvt_8",iy="_preset_nuyvt_8",cy="_active_nuyvt_29",ly="_custom_nuyvt_40",uy="_wrapper_nuyvt_47",dy="_percent_nuyvt_58",vt={description:ay,presets:ry,preset:iy,active:cy,custom:ly,wrapper:uy,percent:dy},Er=["0.1","0.5","1.0"],my=({afterConfirm:e})=>{const t=Zt(),s=t.getValues("slippagePercent"),[o,a]=_.useState(null),{control:r,watch:i,getValues:c,setValue:l}=$e.useForm({defaultValues:{value:s}}),u=i("value");_.useEffect(()=>{const p=Er.findIndex(y=>y===s);a(p>=0?p:null)},[s]);const m=(p,y)=>{l("value",p),a(y)},d=()=>{a(null)},h=_.useMemo(()=>Number(u)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(u)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(u)<.1?{type:"warning",text:"Your transaction may fail"}:null,[u]),f=h?.type==="error",g=({value:p})=>{t.setValue("slippagePercent",p),e()};return n.jsxs(yt,{children:[n.jsx("p",{className:vt.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."}),n.jsxs("div",{className:vt.presets,role:"radiogroup","aria-label":"Slippage presets",children:[Er.map((p,y)=>n.jsxs("button",{type:"button",className:B(vt.preset,{[vt.active]:o===y}),onClick:()=>m(p,y),role:"radio","aria-checked":o===y,children:[p,"%"]},p)),o!==null?n.jsx("button",{type:"button",className:B(vt.preset,vt.custom),onClick:()=>a(null),role:"radio","aria-checked":o===null,children:"Custom"}):n.jsxs("div",{className:vt.wrapper,children:[n.jsx(Qc,{name:"value",control:r,dp:2,onFocus:d,placeholder:"",className:B(vt.preset,vt.active)}),n.jsx("span",{className:vt.percent,children:"%"})]})]}),h&&n.jsx(we,{level:h.type,children:h.text}),n.jsx(Ae,{children:n.jsx(fe.White,{type:"button",onClick:()=>g(c()),disabled:f,children:"Confirm"})})]})},hy="_form_1owk5_1",fy="_arrow_1owk5_5",py="_divider_1owk5_14",gy="_flip_1owk5_23",_y="_meta_1owk5_41",yy="_row_1owk5_54",xy="_title_1owk5_60",by="_description_1owk5_64",wy="_icon_1owk5_71",vy="_edit_1owk5_76",jy="_link_1owk5_94",Cy="_warning_1owk5_99",Ve={form:hy,arrow:fy,divider:py,flip:gy,meta:_y,row:yy,title:xy,description:by,icon:wy,edit:vy,link:jy,warning:Cy};function ky({isLayer1Swap:e,isL2Swap:t}){return e?5e3:t?2e3:1e4}function Ny({srcChainType:e,chainFeeAssets:t,srcDenom:s}){switch(e){case"initia":case"cosmos":return t.map(({denom:o})=>o);case"evm":return kt.isAddress(s)?[]:[s];default:return[]}}const Iy=q(1),Ay=()=>{const e=Me(),t=uo(),s=Pn(),[o,a]=_.useState(void 0),[r,i]=_.useState(!1),[c,l]=Ge.useLocalStorage(he.BRIDGE_ROUTE_TYPE,"default"),{watch:u,setValue:m,handleSubmit:d,formState:h}=Zt(),f=u(),{srcChainId:g,srcDenom:p,dstChainId:y,dstDenom:x,quantity:b,sender:j,slippagePercent:v}=f,w=ce(),C=Ye(g),I=yn(C),T=Ye(y),A=yn(T),$=At(p,g),N=At(x,y),{data:S,isError:P}=po(j,g),F=Yg(j,g,p),D=S!==void 0,Z=F?.amount??(S?"0":void 0),K=!Z||q(Z).isZero(),[W]=Ge.useDebounceValue(b,300),O=Hc({quantity:W,balance:Z,decimals:$?.decimals}),J=g===y,Q=J&&g===w.chainId,ue=ky({isLayer1Swap:Q,isL2Swap:J&&I==="initia"&&!Q}),ye=I!=="initia"&&A!=="initia",me=e_(),Ce=oa(W,{disabled:ye,refreshMs:ue}),Se=oa(W,{isOpWithdraw:!0,disabled:!me,refreshMs:ue}),ke=me&&c==="op",Et=ke?Se:Ce,ut=ke?Ce:Se,Re=ke?!ye:me,le=Et.error&&Re?ut:Et,{data:G,isLoading:$t,error:Xt}=le,{data:Mt}=Xg(Xt),bt=W&&$t&&!r,en=()=>{m("srcChainId",y),m("srcDenom",x),m("dstChainId",g),m("dstDenom",p),m("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:dt,closeModal:Ue}=ao(),nt=d(async oe=>{a(void 0),i(!0);try{const Ne=await le.refetch();if(Ne.error||!Ne.data||!Ne.dataUpdatedAt){a(Ne.error instanceof Error?Ne.error.message:"Failed to refresh route. Please try again.");return}const Ft=Ne.data,Un=Ne.dataUpdatedAt;if(s("Bridge Simulation Success",{quantity:oe.quantity,srcChainId:oe.srcChainId,srcDenom:oe.srcDenom,dstChainId:oe.dstChainId,dstDenom:oe.dstDenom}),Ft.warning){const{type:Rl="",message:Pl}=Ft.warning??{};dt({content:n.jsx(Kc,{type:"warning",icon:n.jsx(M.IconWarningFilled,{size:40}),title:Ys.sentenceCase(Rl),primaryButton:{label:"Cancel",onClick:Ue},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:Ft,values:oe,quoteVerifiedAt:Un}),Ue()}},children:n.jsx("p",{className:Ve.warning,children:Pl})})});return}e("/bridge/preview",{route:Ft,values:oe,quoteVerifiedAt:Un})}finally{i(!1)}}),X=_.useMemo(()=>G?.estimated_fees?.filter(({fee_behavior:oe})=>oe==="FEE_BEHAVIOR_DEDUCTED")??[],[G]),ve=_.useMemo(()=>G?.estimated_fees?.filter(({fee_behavior:oe})=>oe==="FEE_BEHAVIOR_ADDITIONAL")??[],[G]),Oe=_.useMemo(()=>{if(D)for(const oe of ve){const Ne=S?.[oe.origin_asset.denom]?.amount??"0",Ft=G?.source_asset_denom===oe.origin_asset.denom?G.amount_in:"0";if(q(Ne).lt(q(Ft).plus(oe.amount??"0")))return`Insufficient ${oe.origin_asset.symbol} for fees`}},[ve,S,D,G]),mt=!!G&&ve.length>0&&!D,jo=G?k.formatAmount(G.amount_out,{decimals:N.decimals}):"0",ws=_.useMemo(()=>C.fee_assets??[],[C.fee_assets]),Co=_.useCallback((oe,Ne)=>{const Ft=q(S?.[oe]?.amount??"0"),Un=oe===(Ne?.sourceDenom??p)?q(Ne?.amountIn??G?.amount_in??"0"):q(0);return Ft.minus(Un)},[S,G?.amount_in,p]),ko=_.useMemo(()=>Ny({srcChainType:I,chainFeeAssets:ws,srcDenom:p}),[ws,I,p]),$l=Zg({sourceDenom:p,sourceBalance:Z,amountIn:G?.amount_in,feeTokenDenoms:ko,balancesByDenom:S,additionalFees:ve}),Ml=ko.some(oe=>Co(oe).gt(Iy)),er=D&&!!G&&ko.length>0&&!Ml||$l?"Insufficient balance for fees":void 0,Ll=!!o,tr=_.useMemo(()=>{if(!f.sender)return"Connect wallet";if(!f.quantity||!W)return"Enter amount";if(!f.recipient)return"Enter recipient address";if(h.errors.quantity)return h.errors.quantity.message;if(P)return"Failed to load balance";if(O)return"Insufficient balance";if(!G)return"Route not found";if(mt)return"Loading balances...";if(Oe)return Oe},[W,Oe,h,mt,P,O,G,f]),ql=_.useMemo(()=>r?"Refreshing route...":bt?"Simulating...":!1,[bt,r]),No=_.useCallback((oe,Ne)=>oe.length?n.jsxs("div",{className:Ve.description,children:[Ka(oe),!t&&n.jsx(_s,{label:Ne,children:n.jsx("span",{className:Ve.icon,children:n.jsx(M.IconInfoFilled,{size:12,"aria-hidden":"true"})})})]}):null,[t]),vs=q(b).gt(0)&&me&&Ce.data&&Se.data&&Se.data.estimated_route_duration_seconds>Ce.data.estimated_route_duration_seconds,nr=_.useMemo(()=>{if(!G)return[];const oe=Gc(G.amount_out,v);return[{condition:!!G.estimated_fees?.length,title:"Fees",content:n.jsxs("div",{children:[No(X,"Fee deducted from the amount you receive"),No(ve,"Fee charged in addition to the amount you enter")]})},{condition:!vs&&!!ss(G.estimated_route_duration_seconds),title:"Estimated time",content:n.jsx("span",{className:Ve.description,children:ss(G.estimated_route_duration_seconds)})},{condition:G.does_swap,title:"Slippage",content:n.jsxs("span",{className:Ve.description,children:[n.jsxs("span",{children:[v,"%"]}),n.jsx(qn,{title:"Slippage tolerance",content:Ne=>n.jsx(my,{afterConfirm:Ne}),className:Ve.edit,children:n.jsx(M.IconSettingFilled,{size:12,"aria-hidden":"true"})})]})},{condition:G.does_swap,title:"Minimum received",content:n.jsxs("span",{className:Ve.description,children:[n.jsx("img",{src:N.logo_uri,alt:N.symbol,width:12,height:12}),k.formatAmount(oe,{decimals:N.decimals})," ",N.symbol]})}].filter(Ne=>Ne.condition)},[ve,X,N,No,G,vs,v]);return n.jsxs("form",{className:Ve.form,onSubmit:nt,"aria-label":"Bridge and swap form",children:[n.jsx(na,{selectButton:n.jsx(Tr,{type:"src"}),accountButton:I==="cosmos"&&n.jsx(Sr,{type:"src"}),quantityInput:n.jsx(ns,{balance:Z,decimals:$?.decimals}),balanceButton:n.jsx(zc,{onClick:()=>m("quantity",k.fromBaseUnit(F?.amount,{decimals:$?.decimals??0}),{shouldValidate:!0}),disabled:K,children:k.formatAmount(Z??"0",{decimals:$.decimals})}),value:G?.usd_amount_in?ae(G.usd_amount_in):"$-"}),n.jsxs("div",{className:Ve.arrow,children:[n.jsx("div",{className:Ve.divider}),n.jsx("button",{type:"button",className:Ve.flip,onClick:()=>en(),"aria-label":"Swap source and destination",children:n.jsx(M.IconChevronDown,{size:16,"aria-hidden":"true"})})]}),n.jsx(na,{selectButton:n.jsx(Tr,{type:"dst"}),accountButton:n.jsx(Sr,{type:"dst"}),quantityInput:n.jsx(ns.ReadOnly,{children:jo}),value:G?.usd_amount_out?ae(G.usd_amount_out):"$-",hideNumbers:vs}),n.jsx(ts,{children:vs?n.jsxs(Ps.Stack,{children:[n.jsx(Ps,{label:"Fast",query:Ce,value:"default",onSelect:l,checked:c==="default"}),n.jsx(Ps,{label:"Lossless",query:Se,value:"op",onSelect:l,checked:c==="op"})]}):null}),n.jsx(Ae,{extra:n.jsxs(n.Fragment,{children:[n.jsxs(we.Stack,{children:[P&&n.jsx(we,{level:"error",children:"Failed to load balance"}),Ll&&n.jsx(we,{level:"error",children:o}),G?.extra_infos?.map(oe=>n.jsx(we,{level:"info",children:oe},oe)),Mt&&n.jsx(we,{level:"info",children:Mt}),er&&n.jsx(we,{level:"warning",children:er}),G?.warning&&n.jsx(we,{level:"warning",children:G.warning.message}),G?.extra_warnings?.map(oe=>n.jsx(we,{level:"warning",children:oe},oe))]}),n.jsx(ts,{children:nr.length>0&&n.jsx("section",{className:Ve.meta,"aria-label":"Route details",children:nr.map((oe,Ne)=>n.jsxs("div",{className:Ve.row,children:[n.jsx("span",{className:Ve.title,children:oe.title}),oe.content]},Ne))})})]}),children:n.jsx(fe.White,{loading:ql,disabled:!!tr||r,children:tr??"Preview route"})})]})},Sy=()=>{Wc();const e=Ni(),t=Me(),s=Yt(),o=Qm(),a=$e.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:c,dstChainId:l,srcDenom:u,dstDenom:m,quantity:d,slippagePercent:h,recipient:f}=r();r((S,{name:P})=>{(P==="srcChainId"||P==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const g=Oc(),p=g(c),y=g(l),b=Va()(f,l);_.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",p)},[c,p,i]),_.useEffect(()=>{b||i("recipient",y)},[y,b,i]);const{showNotification:j}=hs(),v=Ye(c),w=Ye(l),C=Hs(c),I=Hs(l),T=C.some(S=>S.denom===u),A=I.some(S=>S.denom===m);_.useEffect(()=>{C.length>0&&!T&&(i("srcDenom",C[0].denom),j({type:"info",title:`Switched to ${C[0].symbol}`,description:`The selected asset is not available on ${v.pretty_name}.`,autoHide:!0}))},[C,T,i,j,v.pretty_name]),_.useEffect(()=>{I.length>0&&!A&&(i("dstDenom",I[0].denom),j({type:"info",title:`Switched to ${I[0].symbol}`,description:`The selected asset is not available on ${w.pretty_name}.`,autoHide:!0}))},[I,A,i,j,w.pretty_name]),_.useEffect(()=>{!T||!A||(localStorage.setItem(he.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(he.BRIDGE_SRC_DENOM,u),localStorage.setItem(he.BRIDGE_DST_CHAIN_ID,l),localStorage.setItem(he.BRIDGE_DST_DENOM,m),localStorage.setItem(he.BRIDGE_QUANTITY,d),localStorage.setItem(he.BRIDGE_SLIPPAGE_PERCENT,h))},[c,u,l,m,d,h,T,A]);const $=e[0].path==="/bridge",{reminders:N}=Fn();return n.jsx(Tt,{title:"Bridge/Swap",backButton:$?"/":void 0,extra:n.jsxs(n.Fragment,{children:[n.jsx(fe.Small,{onClick:()=>t("/bridge/history"),unpadded:!0,"aria-label":"Bridge/Swap history",children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:[n.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"}),n.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),n.jsx(Uc,{offset:0,disabled:N.length===0,children:n.jsx(fe.Small,{onClick:()=>t("/op/withdrawals"),disabled:!s,children:n.jsx("span",{children:"Withdrawal status"})})})]}),children:T&&A&&n.jsx($e.FormProvider,{...a,children:n.jsx(xe,{children:n.jsx(Ay,{})})})})},Ty="_button_1crvp_1",Ey="_checkbox_1crvp_11",$y="_checked_1crvp_25",Es={button:Ty,checkbox:Ey,checked:$y},My=({checked:e,onClick:t,label:s,className:o})=>n.jsxs("button",{type:"button",className:B(Es.button,o),onClick:t,role:"checkbox","aria-checked":e,children:[n.jsx("div",{className:B(Es.checkbox,{[Es.checked]:e}),children:e&&n.jsx(M.IconCheck,{size:12,"aria-hidden":"true"})}),n.jsx("span",{className:Es.label,children:s})]}),Ly="_button_aoxv2_1",qy={button:Ly},Xc=({onClick:e,disabled:t})=>{const{ref:s,inView:o}=zl.useInView();return _.useEffect(()=>{o&&e()},[o,e]),n.jsxs("button",{className:qy.button,onClick:e,disabled:t,ref:s,children:[n.jsx("span",{children:"Load more"}),n.jsx(M.IconChevronDown,{size:12,"aria-hidden":"true"})]})};function el(e,t){return e.reduce((s,o)=>{const a=t(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 Ds=({chainId:e,txHash:t})=>`${he.BRIDGE_HISTORY}:${e}:${t}`,Qs=100,$r=10;function tl(){const[e,t]=Ge.useLocalStorage(he.BRIDGE_HISTORY,[]),s=_.useCallback((a,r)=>{localStorage.setItem(Ds(a),JSON.stringify(r));for(const i of e.slice(Qs-1))localStorage.removeItem(Ds(i));t((i=[])=>[a,...i.slice(0,Qs-1)])},[e,t]),o=_.useCallback(a=>{const r=localStorage.getItem(Ds(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function nl(e){return Ge.useLocalStorage(Ds(e),null)}const vn=qe.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,t)=>[e,t],latestOutput:e=>[e],output:(e,t)=>[e,t],outputResponse:(e,t)=>[e,t],withdrawalClaimed:(e,t)=>[e,t]});function yo(){const{restUrl:e}=ce();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function Ry(e){const t=yo(),{data:s}=E.useSuspenseQuery({queryKey:vn.bridge(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:V.INFINITY});return s}const Mr=20;function Py(e){const t=ie();return E.useSuspenseInfiniteQuery({queryKey:vn.withdrawals(e,t).queryKey,queryFn:async({pageParam:s})=>{if(!t)return[];const o={limit:Mr,offset:s,order:"desc"},{withdrawals:a}=await z.create({prefixUrl:e}).get(`withdrawals/${t}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=L.last(s)?.sequence;return s.length<Mr||!o||o<=1?null:o-1},initialPageParam:0,staleTime:V.SECOND})}function Dy(e){const t=yo(),{data:s}=E.useSuspenseQuery({queryKey:vn.latestOutput(e).queryKey,queryFn:()=>t.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:V.SECOND});return s}function By({bridge_id:e,output_index:t}){const s=yo(),{data:o}=E.useSuspenseQuery({queryKey:vn.output(e,t).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${t}`).json()}catch{return null}},staleTime:V.SECOND});return o}function Fy({bridge_id:e,sequence:t}){const o=_e().find(({metadata:l})=>l?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const r=lt()(o);if(!r)throw new Error(`Chain not found: ${o}`);const i=r.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${o}`);const{data:c}=E.useSuspenseQuery({queryKey:vn.outputResponse(i,t).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${t}`).json(),staleTime:V.SECOND});return c}function sl(e,t){const{bridge_id:s}=e,o=yo(),{data:a}=E.useSuspenseQuery({queryKey:vn.withdrawalClaimed(s,t).queryKey,queryFn:()=>o.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:t}}).json(),select:({claimed:r})=>r,staleTime:({state:{data:r}})=>r?.claimed?1/0:V.SECOND});return a}function zn(e){return Hl.sha3_256.create().update(e).digest()}function Ko(e,t){const s=new ArrayBuffer(t);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function ol(e){const{bridge_id:t,sequence:s,amount:o,from:a,to:r}=e,i=Ko(t.toString(),8),c=Ko(s.toString(),8),l=Ko(o.amount,8),u=ln.concatBytes(i,c,zn(ln.utf8ToBytes(a)),zn(ln.utf8ToBytes(r)),zn(ln.utf8ToBytes(o.denom)),l);return zn(zn(u))}async function Uy(e,t,s){try{return await z.get(`${e}/opinit/ophost/v1/bridges/${t}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function Oy(e,t){const s=z.create({prefixUrl:t}),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`)}function Vy({addressList:e,route:t,slippagePercent:s,signedOpHook:o}){return{address_list:e,amount_in:t.amount_in,amount_out:t.amount_out,source_asset_chain_id:t.source_asset_chain_id,source_asset_denom:t.source_asset_denom,dest_asset_chain_id:t.dest_asset_chain_id,dest_asset_denom:t.dest_asset_denom,slippage_tolerance_percent:s,operations:t.operations,signed_op_hook:o}}async function Ky(e,t){const s=Vy(t),{txs:o}=await e.post("v2/fungible/msgs",{json:s}).json();if(!o||o.length===0)throw new Error("No transaction data found");return o}function xo(e,t){if(!e?.length)throw new Error("Invalid transaction data");return e.map(({msg_type_url:s,msg:o})=>{if(!(s&&o))throw new Error("Invalid transaction data");const a=t.converters[s];if(!a)throw new Error(`Unsupported message type: ${s}`);return t.fromAmino({type:a.aminoType,value:JSON.parse(o)})})}function Wy({gas:e,gasPrices:t,gasAdjustment:s=Ht}){return t.reduce((o,{amount:a,denom:r})=>(o[r]=q(e).times(s).times(a).integerValue(q.ROUND_CEIL).toFixed(0),o),{})}function zy({balances:e,requiredFeeByDenom:t,sourceDenom:s,amountIn:o}){const a=Object.keys(t);return a.length===0?!0:a.some(r=>{const i=q(e[r]?.amount??"0"),c=q(r===s?o:0),l=q(t[r]??"0");return i.minus(c).gte(l)})}async function aa(e,t){const{chain_type:s,chain_id:o,chain_name:a,evm_fee_asset:r,rpc:i}=t;if(s!=="evm")throw new Error(`Chain is not an EVM chain: ${a}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}catch(c){if(L.path(["error","code"],c)!==4902)throw c;if(!r)throw new Error(`Fee asset is not defined for chain: ${a}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(o).toString(16)}`,chainName:a,nativeCurrency:r,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}}function xt(){return et()}function Hy(e,t){const{customFee:s,onCompleted:o}=t??{},a=Me(),{showNotification:r,updateNotification:i,hideNotification:c}=hs(),{addHistoryItem:l}=tl(),u=Pn(),{route:m,values:d}=xt(),{srcChainId:h,sender:f,recipient:g,cosmosWalletName:p}=d,y=Qi(),{requestTxSync:x,submitTxSync:b,waitForTxConfirmation:j}=tt(),{find:v}=go(),w=is(),C=cs(),I=bn(),T=Ye(h),A=yn(T),$=Vc(h),N=E.useQueryClient(),{registryUrl:S}=se(),P=lt(),F=ce(),{addReminder:D}=Fn(),Z=Fe();return E.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const K=xo(e.cosmos_tx.msgs,{converters:C,fromAmino:I.fromAmino.bind(I)});if(A==="initia"){const{srcDenom:ut,quantity:Re}=d,{decimals:le}=$(ut),G=s?await b({messages:K,chainId:h,fee:s}):await x({messages:K,chainId:h,internal:1,spendCoins:[{denom:ut,amount:k.toBaseUnit(Re,{decimals:le})}]}),$t=j({txHash:G,chainId:h});return{txHash:G,wait:$t}}const W=v(p)?.getProvider();if(!W)throw new Error("Wallet not connected");const O=W.getOfflineSignerOnlyAmino(h),J=await Le.SigningStargateClient.connectWithSigner(T.rpc,O,{registry:w,aminoTypes:I}),Q=await J.getAllBalances(f),ee=T.fee_assets.find(ut=>Q.some(Re=>Re.denom===ut.denom&&q(Re.amount).gt(0)));if(!ee){const Re=["Insufficient balance for fees.",`Available fee assets: ${T.fee_assets.map(le=>$(le.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Re)}const{denom:ue,gas_price:ye}=ee;if(!ye)throw new Error(`Gas price not found for ${ue}`);const me=await J.simulate(f,K,""),Ce=Le.GasPrice.fromString(ye.average+ue),Se=Le.calculateFee(Math.ceil(me*Ht),Ce),ke=await J.signAndBroadcastSync(f,K,Se),Et=cc({txHash:ke,client:J});return{txHash:ke,wait:Et}}if("evm_tx"in e){const{chain_id:K,to:W,value:O,data:J}=e.evm_tx,Q=await y(),ee=await Q.getSigner();await aa(Q,T);const ue=await ee.sendTransaction({chainId:K,to:W,value:O,data:`0x${J}`}),ye=Gi(ue.wait(),3e4,"Transaction was not confirmed in time. It may still be processing.");return{txHash:ue.hash,wait:ye}}throw new Error("Unlisted chain type")}catch(K){throw K instanceof hn?K:await ct(K)}},onSuccess:async({txHash:K,wait:W})=>{localStorage.removeItem(he.BRIDGE_QUANTITY),N.removeQueries({queryKey:Ie.route._def}),N.removeQueries({queryKey:Ie.routeErrorInfo._def}),o?o({txhash:K,chainId:h,timestamp:Date.now(),success:!0,route:m,values:d}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await W;const O=bo(m)==="OP Bridge withdrawal",J=O?{success:!0,error:null}:await Jy(Z,K,h);if(!o&&!J.success&&J.error){const me=J.error instanceof Error?J.error.message:String(J.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${me}. The transaction may still be processing.`,autoHide:!0})}const Q=J.success,ue=Lr({txHash:K,srcChainId:h,route:m,values:d,recipient:g},Q);l(ue.tx,ue.details),o||i(Gy(c));const ye=Wo(d,K);if(u("Bridge Transaction Success",ye),O){const me=P(h).metadata?.op_bridge_id;if(me&&!await Uy(F.restUrl,Number(me),m.dest_asset_denom)){const Se=Zy(ue.tx,m,g);D(ue.tx,Se)}}}catch(O){const J=O instanceof Error?O.message:String(O);if(O instanceof hn){const ee=Lr({txHash:K,srcChainId:h,route:m,values:d},!1);l(ee.tx,ee.details),o||i(Yy(c))}else o?o({success:!1,error:J,route:m,values:d}):i({type:"error",title:"Transaction not confirmed",description:J});u("Bridge Confirmation Failed",{...Wo(d,K),error:J,type:O instanceof hn?"timeout":"error"})}finally{N.invalidateQueries({queryKey:Ie.balances(h,f).queryKey})}},onError:async K=>{const W=A==="initia"?await Nn(K,P(h),S):K;o?o({success:!1,error:W.message,route:m,values:d}):r({type:"error",title:"Transaction failed",description:W.message});const O=Wo(d);u("Bridge Transaction Failed",{...O,error:W.message})}})}function Qy(){const e=Fe(),t=ie(),s=zi(),{route:o,values:a}=xt(),r=Bt(),i=cs(),c=bn();return E.useMutation({mutationFn:async()=>{try{const{chain_id:l,hook:u}=await e.post("op-hook",{json:{source_address:t,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:k.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await Oy(t,r(o.dest_asset_chain_id).rest);const m=xo(u,{converters:i,fromAmino:c.fromAmino.bind(c)}),d=await s(l,t,m,{amount:[],gas:"1"},"",{incrementSequence:l===a.srcChainId?2:0}),h=Ze.Tx.fromPartial({body:Ze.TxBody.decode(d.bodyBytes),authInfo:Ze.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:t,hook:de.toBase64(Ze.Tx.encode(h).finish())}}catch(l){throw await ct(l)}}})}function Gy(e){return{type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(mn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function Yy(e){return{type:"info",title:"Transaction pending",description:_.createElement(_.Fragment,null,"Confirmation is taking longer than expected. Check ",_.createElement(mn,{to:"/bridge/history",onClick:e},"the activity page")," for updates"),autoHide:!0}}function Wo(e,t){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:t}}function Lr(e,t){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},c=bo(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:c?"success":void 0,tracked:t},isOpWithdraw:c}}function Zy(e,t,s){return{...e,recipient:k.InitiaAddress(s).bech32,claimableAt:Date.now()+t.estimated_route_duration_seconds*1e3,amount:t.amount_out,denom:t.dest_asset_denom}}async function Jy(e,t,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:t,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await ct(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function al(e){const{chainId:t,txHash:s,tracked:o}=e,a=Fe();return E.useQuery({queryKey:Ie.txTrack(t,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:t}}).json()}catch(r){throw await ct(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:V.INFINITY,enabled:!o})}function rl(e){const{timestamp:t,chainId:s,txHash:o,tracked:a,state:r}=e,i=Fe();return E.useQuery({queryKey:Ie.txStatus(s,o).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:o,chain_id:s}}).json(),enabled:!!o&&a&&!r,refetchInterval:({state:{data:c}})=>{if(!c)return!1;const{status:l}=c;if(l==="STATE_COMPLETED")return!1;const u=t+e.route.estimated_route_duration_seconds*1e3,m=Date.now(),d=Math.floor((u-m)/1e3);return d<=0?1e3:d<=300?5e3:60*1e3},staleTime:V.INFINITY})}var Yn=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(Yn||{});function bo(e){const{operations:t,dest_asset_denom:s}=e;return L.has("op_init_transfer",L.head(t))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const Xy="_success_t4dfk_1",ex="_error_t4dfk_5",qr={success:Xy,error:ex},tx=({tx:e})=>{const[t,s]=nl(e);if(!t)throw new Error("Bridge history details not found");const{data:o}=rl(t),a=t.state??nx(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 n.jsx("div",{className:qr.error,children:n.jsx(M.IconCloseCircleFilled,{size:14})});case"success":return n.jsx("div",{className:qr.success,children:n.jsx(M.IconCheckCircleFilled,{size:14})});default:return n.jsx(It,{size:14})}};function nx(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 sx="_link_104m3_1",ox="_header_104m3_23",ax="_title_104m3_31",rx="_date_104m3_37",ix="_explorer_104m3_41",cx="_fees_104m3_57",lx="_label_104m3_65",ux="_content_104m3_69",dx="_route_104m3_75",mx="_row_104m3_80",hx="_asset_104m3_86",fx="_amount_104m3_94",px="_chain_104m3_99",gx="_account_104m3_108",_x="_arrow_104m3_115",Pe={link:sx,header:ox,title:ax,date:rx,explorer:ix,fees:cx,label:lx,content:ux,route:dx,row:mx,asset:hx,amount:fx,chain:px,account:gx,arrow:_x},yx=({tx:e})=>{const[t,s]=nl(e);if(!t)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:c,tracked:l}=t,{data:u}=al(t),{address:m="",connector:d}=Qe.useAccount(),{find:h}=go();_.useEffect(()=>{u&&s(D=>{if(!D)throw new Error("Bridge history details not found");return{...D,tracked:!0}})},[s,u]);const{amount_in:f,amount_out:g,source_asset_chain_id:p,source_asset_denom:y,dest_asset_chain_id:x,dest_asset_denom:b,estimated_fees:j=[]}=r,v=Ye(p),w=Ye(x),C=At(y,p),I=At(b,x),T=(D,Z)=>Z?n.jsx(re,{src:Z,width:12,height:12}):k.InitiaAddress.equals(D,m)?n.jsx(re,{src:d?.icon,width:12,height:12}):n.jsx(M.IconWallet,{size:12}),A=(D,{symbol:Z,decimals:K,logo_uri:W},{chain_name:O,pretty_name:J,...Q},ee,ue)=>n.jsxs("div",{className:Pe.row,children:[n.jsx(_o,{assetLogoUrl:W,chainLogoUrl:Q.logo_uri??void 0}),n.jsxs("div",{children:[n.jsxs("div",{className:Pe.asset,children:[n.jsx("span",{className:Pe.amount,children:k.formatAmount(D,{decimals:K})}),n.jsx("span",{children:Z})]}),n.jsxs("div",{className:Pe.chain,children:[n.jsxs("span",{children:["on ",J||O]}),n.jsxs("div",{className:Pe.account,children:[ue,n.jsx("span",{className:"monospace",children:k.truncate(ee)})]})]})]})]}),$=bo(r),N=_.useMemo(()=>{switch($){case Yn.SKIP:return"Skip Explorer";case Yn.OP_WITHDRAW:return"Initia Scan"}},[$]),S=n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Pe.header,children:[n.jsxs("div",{className:Pe.title,children:[l?n.jsx(tx,{tx:e}):n.jsx(It,{size:14}),n.jsx("div",{className:Pe.date,children:Xe.format(new Date(c),"h:mm a")})]}),n.jsxs("div",{className:Pe.explorer,children:[n.jsx("span",{children:N}),n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})]})]}),n.jsxs("div",{className:Pe.route,children:[A(f,C,v,i.sender,T(i.sender,h(i.cosmosWalletName)?.image)),n.jsx("div",{className:Pe.arrow,children:n.jsx(M.IconArrowDown,{size:12,"aria-hidden":"true"})}),A(g,I,w,i.recipient,T(i.recipient))]}),j.length>0&&n.jsxs("div",{className:Pe.fees,children:[n.jsx("span",{className:Pe.label,children:"Fees"}),n.jsx("span",{className:Pe.content,children:Ka(j)})]})]});if($===Yn.OP_WITHDRAW)return n.jsx(ho,{chainId:o,txHash:a,className:Pe.link,children:S});const P=new URLSearchParams({tx_hash:a,chain_id:o}),F=new URL(`?${P.toString()}`,"https://explorer.skip.build");return n.jsx("a",{href:F.toString(),className:Pe.link,target:"_blank",rel:"noopener noreferrer",children:S})},xx="_history_13u9z_1",bx="_header_13u9z_5",wx="_checkbox_13u9z_9",vx="_groups_13u9z_13",jx="_dateGroup_13u9z_21",Cx="_dateHeader_13u9z_26",kx="_list_13u9z_32",on={history:xx,header:bx,checkbox:wx,groups:vx,dateGroup:jx,dateHeader:Cx,list:kx},Nx=()=>{const{initiaAddress:e,hexAddress:t}=tt(),{history:s,getHistoryDetails:o}=tl(),a=s.filter(f=>o(f)),r=a.filter(f=>{const g=o(f);if(!g)return!1;const{values:p}=g,{sender:y,recipient:x}=p;return[y,x].some(b=>[e,t].includes(b))}),[i,c]=_.useState(1),[l,u]=Ge.useToggle(!r.length),m=l?a:r,d=m.slice(0,i*$r),h=_.useMemo(()=>el(d,f=>{const g=o(f);if(g)return new Date(g.timestamp)}),[d,o]);return n.jsx(Tt,{title:"Bridge/Swap activity",children:n.jsxs("div",{className:on.history,children:[a.length>0&&a.length!==r.length&&n.jsx("header",{className:on.header,children:n.jsx(My,{checked:l,onClick:u,label:"Show all transactions stored in this browser",className:on.checkbox})}),m.length===0?n.jsx(je,{children:"No bridge/swap activity"}):n.jsx("div",{className:on.groups,children:Object.entries(h).map(([f,g])=>n.jsxs("div",{className:on.dateGroup,children:[n.jsx("div",{className:on.dateHeader,children:f}),n.jsx("div",{className:on.list,children:g.map(p=>n.jsx(xe,{children:n.jsx(yx,{tx:p})},p.txHash))})]},f))}),m.length>i*$r?n.jsx(Xc,{onClick:()=>c(f=>f+1)}):s.length>=Qs&&n.jsxs(je,{children:["Only the latest ",Qs," items are stored. Older entries will be removed automatically."]})]})})};function il({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}){return{...e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}}function Ix({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return il({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!0})}function Ax({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return il({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!1})}const Sx=1e4;function ra(e){return e===void 0?"undefined":e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(ra).join(",")}]`:`{${Object.entries(e).sort(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${JSON.stringify(t)}:${ra(s)}`).join(",")}}`}function Rr(e){return ra({amount_in:e.amount_in,amount_out:e.amount_out,usd_amount_in:e.usd_amount_in,usd_amount_out:e.usd_amount_out,operations:e.operations,estimated_fees:e.estimated_fees,estimated_route_duration_seconds:e.estimated_route_duration_seconds,warning:e.warning,extra_infos:e.extra_infos,extra_warnings:e.extra_warnings,required_op_hook:e.required_op_hook})}function Tx(e,t,s){const o=Me(),a=et(),r=E.useQueryClient(),i=Fe(),[c,l]=_.useState(!1),[u,m]=_.useState(void 0),[d,h]=_.useState(s??0),f=_.useRef(null);return _.useEffect(()=>{h(s??0)},[s]),_.useEffect(()=>()=>{f.current?.abort()},[]),{refreshRouteIfNeeded:async()=>{const p=Math.max(s??0,d);if(Date.now()-p<=Sx)return!1;l(!0),m(void 0);const y=new AbortController;f.current=y;try{const x=await Yc(i,r,t,{isOpWithdraw:bo(e)===Yn.OP_WITHDRAW,signal:y.signal});if(y.signal.aborted)return!0;const b=Rr(x)!==Rr(e),j=Date.now();return b?(o(0,Ix({currentState:a,route:x,values:t,quoteVerifiedAt:j})),!0):(h(j),!1)}catch(x){return x instanceof DOMException&&x.name==="AbortError"||y.signal.aborted||m((await ct(x)).message),!0}finally{f.current===y&&(f.current=null),y.signal.aborted||l(!1)}},isRefreshing:c,refreshError:u,clearRefreshError:()=>m(void 0)}}function Ex(e,t){return t?"Confirm updated route":e||"Confirm"}function $x({error:e,warning:t,messageRefreshError:s,refreshError:o,requiresReconfirm:a}){if(e)return{level:"error",text:e};if(s)return{level:"error",text:s};if(o)return{level:"error",text:o};if(t)return{level:"warning",text:t};if(a)return{level:"info",text:"Route updated. Please review and confirm again."}}function Mx({isCheckingApprovals:e,isCheckingFeeBalance:t,isFetchingMessages:s,isEstimatingGas:o,isRouteTransitioning:a}){return a?"Refreshing route...":s?"Fetching messages...":t?"Checking fee balance...":e?"Checking approvals...":o?"Estimating gas...":!1}function Lx({isRefreshing:e,isPending:t,backgroundLoadingText:s}){return e?"Refreshing route...":t?"Signing transaction...":s}const za=({tx:e,fee:t,onCompleted:s,confirmMessage:o,error:a,warning:r,isCheckingApprovals:i,isCheckingFeeBalance:c,messageRefreshError:l,isRouteTransitioning:u,isFetchingMessages:m,isEstimatingGas:d})=>{const h=Me(),f=et(),{route:g,values:p,quoteVerifiedAt:y,requiresReconfirm:x}=xt(),{mutate:b,isPending:j}=Hy(e,{customFee:t,onCompleted:s}),{refreshRouteIfNeeded:v,isRefreshing:w,refreshError:C,clearRefreshError:I}=Tx(g,p,y),T=Mx({isCheckingApprovals:i,isCheckingFeeBalance:c,isFetchingMessages:m,isEstimatingGas:d,isRouteTransitioning:u}),A=async()=>{if(!(j||w||T||l)){if(x){h(0,Ax({currentState:f,route:g,values:p,quoteVerifiedAt:y??Date.now()}));return}await v()||(I(),b())}},$=$x({error:a,warning:r,messageRefreshError:l,refreshError:C,requiresReconfirm:x}),N=Lx({isRefreshing:w,isPending:j,backgroundLoadingText:T}),S=j||w||!!T||!!l;return n.jsx(Ae,{extra:$&&n.jsx(we,{level:$.level,children:$.text}),children:n.jsx(fe.White,{onClick:A,loading:N,disabled:!!a||!!r||S,children:Ex(o,!!x)})})};function qx({approvalError:e,approveTokens:t,exactFeeCheckError:s,isApproving:o,isCheckingApprovals:a,isCheckingFeeBalance:r,isFetchingMessages:i,messageRefreshError:c,requiresApproval:l}){return i||c?{kind:"preview",isFetchingMessages:i,messageRefreshError:c}:r?{kind:"preview",isCheckingFeeBalance:!0}:s?{kind:"preview",error:s}:a?{kind:"preview",isCheckingApprovals:!0}:l&&t?{kind:"approval",approvalError:e,approveTokens:t,isApproving:!!o}:{kind:"preview"}}const Rx="_content_1hzj2_1",Px="_info_1hzj2_6",Dx="_arrow_1hzj2_11",Bx="_divider_1hzj2_19",Fx="_type_1hzj2_27",Ux="_asset_1hzj2_47",Ox="_amount_1hzj2_55",Vx="_lower_1hzj2_60",Kx="_chain_1hzj2_66",Wx="_address_1hzj2_72",ot={content:Rx,info:Px,arrow:Dx,divider:Bx,type:Fx,asset:Ux,amount:Ox,lower:Vx,chain:Kx,address:Wx},cl=e=>{const{source:t,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:c}=e,{symbol:l=k.truncate(a),decimals:u=0,logo_uri:m=ya}=e,{chain_name:d,pretty_name:h,...f}=Ye(r);return n.jsxs("div",{children:[!t&&n.jsxs("div",{className:ot.arrow,children:[n.jsx("div",{className:ot.divider}),s?n.jsx(_s,{label:s,children:n.jsx("button",{className:ot.type,children:n.jsx(M.IconArrowDown,{size:12})})}):n.jsx("span",{className:ot.type,children:n.jsx(M.IconArrowDown,{size:12})}),n.jsx("div",{className:ot.divider})]}),n.jsxs("div",{className:ot.content,children:[n.jsx(_o,{assetLogoUrl:m,chainLogoUrl:f.logo_uri??void 0}),n.jsxs("div",{className:ot.info,children:[n.jsxs("div",{className:ot.asset,children:[n.jsx("span",{className:ot.amount,children:k.formatAmount(o,{decimals:u})}),n.jsx("span",{children:l})]}),n.jsxs("div",{className:ot.lower,children:[n.jsxs("div",{className:ot.chain,children:["on ",h||d]}),i&&n.jsx(Ws,{value:i,children:({copy:g,copied:p})=>n.jsxs("button",{className:ot.address,onClick:g,children:[c,p?n.jsx("span",{children:"Copied!"}):n.jsx("span",{className:"monospace",children:k.truncate(i)})]})})]})]})]})]})},Sn=e=>{const t=At(e.denom,e.chainId);return n.jsx(cl,{...e,...t})};Sn.Placeholder=cl;const zx="_root_1hbar_1",Hx="_flexEnd_1hbar_6",Qx="_toggle_1hbar_11",Gx="_route_1hbar_36",Yx="_content_1hbar_43",Hn={root:zx,flexEnd:Hx,toggle:Qx,route:Gx,content:Yx};function Zx(e){const t=({name:s})=>s==="initia-dex"?"Initia DEX":Ys.capitalCase(L.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(t).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(t).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 Jx=({addressList:e})=>{const{values:t,route:s}=xt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,c=L.zipObj(s.required_chain_addresses,e),{find:l}=go(),{connector:u,address:m=""}=Qe.useAccount(),[d,h]=Ge.useToggle(!1),f=i.length>1,g=n.jsx(re,{src:t.cosmosWalletName?l(t.cosmosWalletName)?.image:u?.icon,width:12,height:12}),p={amount:r,denom:o,chainId:a,address:t.sender,walletIcon:g},y=w=>k.InitiaAddress.equals(w,m)?g:n.jsx(M.IconWallet,{size:11}),x=w=>{const{label:C,amount_out:I,denom:T,denom_out:A=T,chain_id:$,from_chain_id:N,to_chain_id:S=$??N}=w,P=c[S];return{label:f&&!d?void 0:C,amount:I,denom:A,chainId:S,address:P,walletIcon:y(P)}},b=i.map(Zx).map(x),j=b.slice(0,-1),v=b[b.length-1];return n.jsxs(te.Collapsible.Root,{className:Hn.root,open:d,onOpenChange:h,children:[f&&n.jsx("div",{className:Hn.flexEnd,children:n.jsx(te.Collapsible.Trigger,{className:Hn.toggle,children:d?n.jsxs(n.Fragment,{children:[n.jsx(M.IconMinus,{size:12}),n.jsx("span",{children:"Hide details"})]}):n.jsxs(n.Fragment,{children:[n.jsx(M.IconList,{size:12}),n.jsx("span",{children:"Show details"})]})})}),n.jsxs("div",{className:Hn.route,children:[n.jsx(Sn,{...p,source:!0}),n.jsx(te.Collapsible.Content,{className:Hn.content,children:j.map((w,C)=>n.jsx(xe,{suspenseFallback:n.jsx(Sn.Placeholder,{...w}),errorBoundaryProps:{fallback:n.jsx(Sn.Placeholder,{...w})},children:n.jsx(Sn,{...w})},C))}),n.jsx(Sn,{...v})]})]})},ll=({error:e})=>{const t=Me();return n.jsx(Ae,{extra:n.jsx(we,{level:"error",children:e.message}),children:n.jsx(fe.White,{onClick:()=>t("/bridge"),children:"Home"})})},ul=({children:e})=>{const t=xt(),{route:s,values:o}=t,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:u,hexAddress:m}=tt(),d=ls(),h=Bt(),f=fs(),g=h(r),p=f(g),y=a.slice(0,-1).some(I=>{const T=h(I);return f(T)==="cosmos"})&&p!=="cosmos",[x,b]=_.useState(void 0),[j,v]=_.useState(!1),[w,C]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!y)return;if(!d)throw new Error("Wallet not connected");v(!0),C(null);const[{pubkey:T}]=await d.getAccounts();b(T)}catch(T){C(await ct(T))}finally{v(!1)}})()},[y,d]),w)return n.jsx(ll,{error:w});if(j)return n.jsx(Ae,{children:n.jsx(fe.White,{loading:j&&"Generating intermediary addresses..."})});if(!y||x){const I=a.map((T,A)=>{if(A===a.length-1){const F=h(i);return f(F)==="initia"?k.InitiaAddress(l).bech32:l}const $=h(T),N=f($),S=h(r),P=f(S);switch(N){case"initia":return u;case"evm":return m;case"cosmos":{if(P==="cosmos")return de.toBech32($.bech32_prefix,de.fromBech32(c).data);if(!x)throw new Error("Pubkey not found");return En.pubkeyToAddress(En.encodeSecp256k1Pubkey(x),$.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(I)}return null};function Xx(e){return"evm_tx"in e?JSON.stringify({approvals:e.evm_tx.required_erc20_approvals??[],chainId:e.evm_tx.chain_id,signerAddress:e.evm_tx.signer_address}):"non-evm"}function e1({currentKey:e,isPending:t,nextKey:s}){return!t&&e!==s}function t1(e,t){return typeof e=="function"?e(t):t.isCheckingApprovals?n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Checking approvals..."})}):t.requiresApproval&&t.approveTokens?n.jsx(Ae,{extra:n.jsx(we,{level:"error",children:t.approvalError}),children:n.jsx(fe.White,{onClick:t.approveTokens,loading:t.isApproving&&"Approving tokens...",children:"Approve tokens"})}):e}const dl=({tx:e,children:t})=>{const s=Qi(),o=Bt(),a=E.useQueryClient(),r=Xx(e),i=_.useRef(r),{data:c,isLoading:l}=E.useQuery({queryKey:["interwovenkit:erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:g,signer_address:p}=e.evm_tx,y=await s();await aa(y,o(g));const x=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async j=>{const{token_contract:v,spender:w}=j,I=await new kt.ethers.Contract(v,x,y).allowance(p,w);return{approval:j,currentAllowance:BigInt(I.toString())}}))).filter(({approval:j,currentAllowance:v})=>v<BigInt(j.amount)).map(({approval:j})=>j)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:u,data:m,isPending:d,error:h,reset:f}=E.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!c||c.length===0)throw new Error("No approvals needed");const{chain_id:g}=e.evm_tx,p=await s(),y=await p.getSigner();await aa(p,o(g));for(const x of c){const{token_contract:b,spender:j,amount:v}=x,w=["function approve(address spender, uint256 amount) external returns (bool)"],I=await new kt.ethers.Contract(b,w,y).approve(j,v);await Gi(I.wait(),3e4,"Approval was not confirmed in time. It may still be processing.")}return!0}catch(g){throw g instanceof hn?(a.invalidateQueries({queryKey:["interwovenkit:erc20-approvals-needed",e]}),g):await ct(g)}}});return _.useEffect(()=>{const g=i.current;e1({currentKey:g,isPending:d,nextKey:r})&&(i.current=r,f())},[r,d,f]),t1(t,{approvalError:h?.message,approveTokens:c&&c.length>0&&!m?()=>u():void 0,isApproving:d,isCheckingApprovals:l,requiresApproval:!!c&&c.length>0&&!m})};function n1({route:e,tx:t,isSrcInitia:s,isDstInitia:o,sender:a,recipient:r}){return!!e&&"cosmos_tx"in t&&!!t.cosmos_tx.msgs?.length&&!e.required_op_hook&&s&&o&&!!a&&!!r}function s1({hasBalances:e,hasChain:t,requiresExactFeeCheck:s}){return s&&e&&t}function o1({balances:e,feeDenoms:t}){return e?t.toSorted().map(s=>`${s}:${e[s]?.amount??"0"}`).join("|"):""}function a1({tx:e,children:t}){const{route:s,values:o}=xt(),{sender:a,recipient:r,srcChainId:i,srcDenom:c,dstChainId:l}=o,u=Ye(i),m=Ye(l),d=yn(u),h=yn(m),{data:f,isLoading:g,error:p}=po(a,i),y=cs(),x=bn(),b=us(),j=n1({route:s,tx:e,isSrcInitia:d==="initia",isDstInitia:h==="initia",sender:a,recipient:r}),{chain:v,error:w,isLoading:C}=au(i,j),I=v?Array.from(new Set([c,...v.fees.fee_tokens.map(({denom:P})=>P)])):[],T=o1({balances:f,feeDenoms:I}),A=s1({hasBalances:f!==void 0,hasChain:!!v,requiresExactFeeCheck:j}),{data:$,error:N,isLoading:S}=E.useQuery({queryKey:["interwovenkit:bridge-preview-fee-check",e,a,i,c,s.amount_in,T],queryFn:async()=>{try{if(!(j&&v&&"cosmos_tx"in e&&e.cosmos_tx.msgs?.length&&f))throw new Error("Invalid transaction data");const P=xo(e.cosmos_tx.msgs,{converters:y,fromAmino:x.fromAmino.bind(x)}),D=await(await b(i)).simulate(a,P,""),Z=await Na(v),K=Wy({gas:D,gasPrices:Z});return zy({balances:f,requiredFeeByDenom:K,sourceDenom:c,amountIn:s.amount_in})}catch(P){throw await ct(P)}},enabled:A,retry:!1});return t(j?w?{exactFeeCheckError:w.message,isCheckingFeeBalance:!1}:p?{exactFeeCheckError:p instanceof Error?p.message:"Failed to load balances",isCheckingFeeBalance:!1}:C||g||f===void 0||S?{isCheckingFeeBalance:!0}:N?{exactFeeCheckError:N.message,isCheckingFeeBalance:!1}:$?{isCheckingFeeBalance:!1}:{exactFeeCheckError:"Insufficient balance for fees",isCheckingFeeBalance:!1}:{isCheckingFeeBalance:!1})}function r1({addressList:e,operations:t,signedOpHook:s}){return JSON.stringify({addressList:e,operations:t,signedOpHook:s??null})}function i1({previousQuoteVerifiedAt:e,quoteVerifiedAt:t,hasValue:s,hasMessageRefreshError:o}){return s&&o&&e!==void 0&&t!==void 0&&t!==e}function c1({error:e,loading:t,value:s}){const o=s!==void 0;return{isFetchingMessages:t,messageRefreshError:!t&&o&&e?e.message:void 0,shouldRenderError:!!e&&!o,shouldRenderLoading:!o}}const ml=({addressList:e,signedOpHook:t,children:s})=>{const o=Fe(),{route:a,values:r,quoteVerifiedAt:i}=xt(),[c,l]=_.useState(void 0),[u,m]=_.useState(!1),[d,h]=_.useState(null),[f,g]=_.useState(0),p=_.useRef(i),y=r1({addressList:e,operations:a.operations,signedOpHook:t});_.useEffect(()=>{const b=p.current;i1({previousQuoteVerifiedAt:b,quoteVerifiedAt:i,hasValue:c!==void 0,hasMessageRefreshError:d!==null})&&g(j=>j+1),p.current=i},[i,c,d]),_.useEffect(()=>{let b=!1;return(async()=>{try{if(m(!0),h(null),a.required_op_hook&&!t)throw new Error("Op hook is required");const v=await Ky(o,{addressList:e,route:{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,operations:a.operations},slippagePercent:String(r.slippagePercent),signedOpHook:t});if(b)return;const[w]=v;l(w)}catch(v){if(b)return;h(await ct(v))}finally{b||m(!1)}})(),()=>{b=!0}},[y,f,a.amount_in,a.amount_out,a.source_asset_chain_id,a.source_asset_denom,a.dest_asset_chain_id,a.dest_asset_denom,a.required_op_hook,r.slippagePercent,o]);const x=c1({error:d,loading:u,value:c});return x.shouldRenderError&&d?n.jsx(ll,{error:d}):x.shouldRenderLoading?n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Fetching messages..."})}):s(c,{isFetchingMessages:x.isFetchingMessages,messageRefreshError:x.messageRefreshError})},hl=({children:e})=>{const{route:t}=xt(),s=Qy();return t.required_op_hook&&!s.data?n.jsx(Ae,{extra:n.jsx(we,{level:"error",children:s.error?.message}),children:n.jsx(fe.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)};function l1({approvalError:e,approveTokens:t,isApproving:s}){return n.jsx(Ae,{extra:e&&n.jsx(we,{level:"error",children:e}),children:n.jsx(fe.White,{onClick:t,loading:s&&"Approving tokens...",children:"Approve tokens"})})}const u1=()=>n.jsx(Tt,{title:"Route preview",children:n.jsx(ul,{children:e=>n.jsxs(n.Fragment,{children:[n.jsx(Jx,{addressList:e}),n.jsx(hl,{children:t=>n.jsx(ml,{addressList:e,signedOpHook:t,children:(s,{isFetchingMessages:o,messageRefreshError:a})=>n.jsx(a1,{tx:s,children:({exactFeeCheckError:r,isCheckingFeeBalance:i})=>n.jsx(dl,{tx:s,children:({approvalError:c,approveTokens:l,isApproving:u,isCheckingApprovals:m,requiresApproval:d})=>{const h=qx({approvalError:c,approveTokens:l,exactFeeCheckError:r,isApproving:u,isCheckingApprovals:m,isCheckingFeeBalance:i,isFetchingMessages:o,messageRefreshError:a,requiresApproval:d});return h.kind==="approval"?l1({approvalError:h.approvalError,approveTokens:h.approveTokens,isApproving:h.isApproving}):n.jsx(za,{tx:s,error:h.error,isCheckingApprovals:h.isCheckingApprovals,isCheckingFeeBalance:h.isCheckingFeeBalance,isFetchingMessages:h.isFetchingMessages,messageRefreshError:h.messageRefreshError})}})})})})]})})}),fl=_.createContext(null);function wo(){return _.useContext(fl)}const d1="_button_17r1o_1",m1="_claimed_17r1o_24",Pr={button:d1,claimed:m1},h1=()=>{const{withdrawalTx:e}=wo(),{bridge_id:t,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:c,to:l,version:u}=e,m=ce(),d=ie(),{requestTxSync:h,waitForTxConfirmation:f}=tt(),g=Fy(e),p=de.toBase64(ol(e)),y=sl(e,p),x=E.useQueryClient(),{mutate:b,isPending:j}=E.useMutation({mutationFn:async()=>{if(!g)throw new Error("Output not found");const{last_block_hash:v}=g;return h({chainId:m.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:d,bridgeId:BigInt(t),outputIndex:BigInt(a),withdrawalProofs:r.map(de.fromBase64),from:c,to:l,sequence:BigInt(s),amount:o,version:de.fromBase64(u),storageRoot:de.fromBase64(i),lastBlockHash:de.fromBase64(v)}}],internal:!0})},onSuccess:async v=>{await f({chainId:m.chain_id,txHash:v}),x.invalidateQueries({queryKey:vn.withdrawalClaimed(t,p).queryKey})}});return y?n.jsxs("div",{className:Pr.claimed,children:[n.jsx(M.IconCheckCircleFilled,{size:14}),n.jsx("span",{children:"Claimed"})]}):n.jsx("button",{className:Pr.button,onClick:()=>b(),disabled:j,children:"Claim"})},f1=({children:e})=>{const{withdrawalTx:t}=wo(),s=Ry(t.bridge_id),o=By(t),a=_.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Xe.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},pl=1e3,p1=60,g1=60,_1=24,ia=pl*p1,ca=ia*g1,Dr=ca*_1,y1=({date:e})=>{const t=_.useCallback(()=>{const u=new Date().getTime(),d=e.getTime()-u;if(d<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(d/Dr),f=Math.floor(d%Dr/ca),g=Math.floor(d%ca/ia),p=Math.floor(d%ia/pl);return{days:h,hours:f,minutes:g,seconds:p}},[e]),[s,o]=_.useState(t());_.useEffect(()=>{const u=window.setInterval(()=>{o(t())},1e3);return()=>window.clearInterval(u)},[t,e]);const a=u=>u.toString().padStart(2,"0"),{days:r,hours:i,minutes:c,seconds:l}=s;return n.jsx(_s,{label:e.toLocaleString(),children:n.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(c),"m ",a(l),"s"]})})},x1="_container_1lz3w_1",b1="_title_1lz3w_5",Br={container:x1,title:b1},w1=({date:e})=>n.jsxs("div",{className:Br.container,children:[n.jsx("div",{className:Br.title,children:"Claimable in"}),n.jsx(y1,{date:e})]}),v1="_container_1oldz_1",j1="_icon_1oldz_7",Fr={container:v1,icon:j1},C1="Withdrawal will begin within an hour",Ur=()=>{const e=uo();return n.jsxs("div",{className:Fr.container,children:[n.jsx("span",{children:"In progress"}),!e&&n.jsx(_s,{label:C1,children:n.jsx("span",{className:Fr.icon,children:n.jsx(M.IconInfoFilled,{size:12})})})]})},k1=({children:e})=>{const{withdrawalTx:t}=wo(),s=Dy(t.bridge_id),o=t.output_index>Number(s?.output_index);return e(o)},N1=({date:e,children:t})=>{const{chainId:s,withdrawalTx:o}=wo(),a=de.toBase64(ol(o)),r=sl(o,a),{setReminder:i,removeReminder:c}=Fn();return _.useEffect(()=>{const l={chainId:s,txHash:o.tx_hash};r?c(l):i(l,{...l,recipient:o.to,claimableAt:e.getTime(),amount:o.amount.amount,denom:o.amount.denom,dismissed:Xe.isPast(e.getTime())?!0:void 0})},[s,r,e,c,i,o]),t},I1=()=>n.jsx(k1,{children:e=>e?n.jsx(Ur,{}):n.jsx(f1,{children:t=>t?n.jsx(N1,{date:t,children:Xe.isFuture(t)?n.jsx(w1,{date:t}):n.jsx(h1,{})}):n.jsx(Ur,{})})}),A1="_asset_6h8u2_1",S1="_info_6h8u2_7",T1="_symbol_6h8u2_11",zo={asset:A1,info:S1,symbol:T1},E1=({amount:e,denom:t})=>{const s=ce(),o=bi(t,s),{symbol:a,logoUrl:r,decimals:i}=o;return n.jsxs("div",{className:zo.asset,children:[n.jsx(re,{src:r,width:32,height:32,logo:!0}),n.jsxs("div",{className:zo.info,children:[n.jsx("span",{className:"monospace",children:k.formatAmount(e,{decimals:i})}),n.jsx("span",{className:zo.symbol,children:a})]})]})},$1="_item_km5w2_1",M1={item:$1},L1=({chain:e})=>{const t=e.metadata?.executor_uri;if(!t)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:o,hasNextPage:a,isFetching:r}=Py(t),i=_.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:c}=Fn();return _.useEffect(()=>{const l=i.map(u=>({chainId:e.chainId,txHash:u.tx_hash}));c(l)},[e.chainId,i,c]),i.length?n.jsxs(n.Fragment,{children:[i.map(l=>{const{amount:u}=l;return n.jsxs("div",{className:M1.item,children:[n.jsx(E1,{...u}),n.jsx(xe,{suspenseFallback:null,children:n.jsx(fl.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:n.jsx(I1,{})})})]},l.sequence)}),a&&n.jsx(Xc,{onClick:()=>o(),disabled:r})]}):n.jsx(je,{children:"No withdrawals"})},q1="_content_dj1qm_1",R1="_title_dj1qm_5",Or={content:q1,title:R1},P1=()=>{const{chainId:e}=et(),t=_e(),s=xn(),[o,a]=_.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=lt(),{reminders:i}=Fn(),c=o?r(o):void 0;return n.jsxs(Tt,{title:"OP Bridge withdrawals",children:[n.jsx(fn,{chains:t.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:l=>i.some(u=>u.chainId===l)}),n.jsx("div",{className:Or.content,children:c?n.jsxs(n.Fragment,{children:[n.jsx("h2",{className:Or.title,children:c.name}),n.jsx(xe,{children:n.jsx(L1,{chain:c})},o)]}):n.jsx(we,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},Rn=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),D1="5722e7dffb709492cf5312446ceeff73",B1=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${D1}`,gl=["interwovenkit:walletconnect-wallets"],F1=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",_l=async e=>{const t=await z.get(B1,{signal:e}).json(),s=t!==null&&typeof t=="object"&&"listings"in t?t.listings:t;return Object.values(s??{}).filter(F1)},U1=()=>E.useQuery({queryKey:gl,queryFn:({signal:e})=>_l(e),staleTime:V.INFINITY,gcTime:V.INFINITY,retry:2}),O1="_page_13y8q_1",V1="_pageTop_13y8q_19",K1="_backButtonFixed_13y8q_63",W1="_listItem_13y8q_64",z1="_socialButton_13y8q_65",H1="_arrowIcon_13y8q_66",Q1="_searchInputUnderline_13y8q_67",G1="_header_13y8q_72",Y1="_title_13y8q_81",Z1="_headerSpacer_13y8q_116",J1="_icon_13y8q_120",X1="_installedText_13y8q_124",e0="_divider_13y8q_131",t0="_dividerText_13y8q_152",n0="_loading_13y8q_193",s0="_socialIcons_13y8q_198",o0="_socialText_13y8q_204",a0="_searchWrapper_13y8q_214",r0="_scrollable_13y8q_248",i0="_list_13y8q_64",c0="_listIconWrapper_13y8q_332",l0="_moreIconSmall_13y8q_342",u0="_externalLinkIcon_13y8q_364",d0="_listName_13y8q_368",m0="_listNameMuted_13y8q_381",h0="_recentBadge_13y8q_394",f0="_learnMoreLink_13y8q_408",U={page:O1,pageTop:V1,backButtonFixed:K1,listItem:W1,socialButton:z1,arrowIcon:H1,searchInputUnderline:Q1,header:G1,title:Y1,headerSpacer:Z1,icon:J1,installedText:X1,divider:e0,dividerText:t0,loading:n0,socialIcons:s0,socialText:o0,searchWrapper:a0,scrollable:r0,list:i0,listIconWrapper:c0,moreIconSmall:l0,externalLinkIcon:u0,listName:d0,listNameMuted:m0,recentBadge:h0,learnMoreLink:f0},p0=e=>{try{const t=new URL(e.trim());return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}},g0=({walletConnectors:e,isPending:t,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,c]=_.useState(""),{data:l=[],isError:u,isLoading:m,isFetching:d}=U1(),h=m||d&&l.length===0,f=_.useMemo(()=>{if(!i)return e;const p=i.toLowerCase();return e.filter(y=>y.name.toLowerCase().includes(p))},[e,i]),g=_.useMemo(()=>{const p=new Set(e.map(x=>Rn(x.name))),y=i.toLowerCase();return l.filter(x=>!p.has(Rn(x.name))).filter(x=>!i||x.name.toLowerCase().includes(y)).sort((x,b)=>x.name.localeCompare(b.name))},[l,e,i]);return n.jsxs("div",{className:U.pageTop,children:[n.jsx("button",{type:"button",className:U.backButtonFixed,onClick:r,"aria-label":"Back",children:n.jsx(M.IconBack,{size:16,"aria-hidden":"true"})}),n.jsxs("header",{className:U.header,children:[n.jsx("div",{className:U.headerSpacer}),n.jsx("h1",{className:U.title,children:"All Wallets"}),n.jsx("div",{className:U.headerSpacer})]}),n.jsx("div",{className:U.searchWrapper,children:n.jsx(ys,{rootClassName:U.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:p=>c(p.target.value),onClear:()=>c("")})}),n.jsx(yt,{className:U.scrollable,children:n.jsxs("div",{className:U.list,children:[f.map(p=>{const{name:y,icon:x,id:b}=p,j=o===b,v=s===b,w="ready"in p?!!p.ready:!0;return n.jsxs("button",{type:"button",className:B(U.listItem,{[U.loading]:v}),onClick:()=>a(p),disabled:t||!w,"aria-busy":v,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(re,{src:x,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listName,children:y}),v?n.jsx(It,{size:16}):j?n.jsx("span",{className:U.recentBadge,children:"Recent"}):w?n.jsx("span",{className:U.installedText,children:"Installed"}):null]},`connector:${b}`)}),h&&n.jsxs("div",{className:B(U.listItem,U.loading),role:"status","aria-live":"polite",children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(It,{size:16})}),n.jsx("span",{className:U.listNameMuted,children:"Loading more wallets..."})]}),g.map(p=>{const y=p.image_url?.sm||p.image_url?.md||p.image_url?.lg,x=y&&p0(y)?y:void 0;return n.jsxs("button",{type:"button",className:U.listItem,disabled:!0,"aria-label":`${p.name} (not installed)`,children:[n.jsx("div",{className:U.listIconWrapper,children:x&&n.jsx(re,{src:x,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listNameMuted,children:p.name})]},`wc:${p.id}`)}),u&&n.jsx(we,{level:"error",children:"Couldn't load additional wallets."})]})})]})},_0=(e,t,s,o)=>{if(e.length<=s)return[...e];const a=o?e.findIndex(d=>d.id===o):-1,r=a>=0?e[a]:void 0,i=a>=0?e.filter((d,h)=>h!==a):e,c=new Set(t.map(d=>d.id)),l=new Set(t.map(d=>Rn(d.name))),u=[],m=[];for(const d of i)c.has(d.id)||l.has(Rn(d.name))?u.push(d):m.push(d);return r?[r,...u,...m].slice(0,s):u.concat(m).slice(0,s)},y0=()=>n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"4",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"12",cy:"8",r:"1.5"})]}),x0=()=>n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",children:[n.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"}),n.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"}),n.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"}),n.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"})]}),b0=()=>n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.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"})}),w0=()=>n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),Vr=[{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"}],Kr=5,v0=({walletConnectors:e,privyConnector:t,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:c})=>{const l=e.filter(g=>!("ready"in g)||!!g.ready),u=_0(l,Vr,Kr,a),m=new Set(l.map(g=>g.id)),d=new Set(l.map(g=>Rn(g.name))),h=Math.max(0,Kr-u.length),f=Vr.filter(g=>!m.has(g.id)&&!d.has(Rn(g.name))).slice(0,h);return n.jsxs("div",{className:U.page,children:[n.jsxs("header",{className:U.header,children:[n.jsx("div",{className:U.headerSpacer}),n.jsx("h1",{className:U.title,children:"Sign In"}),n.jsx("div",{className:U.headerSpacer})]}),t&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",className:B(U.socialButton,{[U.loading]:o===t.id}),onClick:()=>r(t),disabled:s,"aria-busy":o===t.id,children:[n.jsx("span",{className:U.socialText,children:"Email / Socials"}),o===t.id?n.jsx(It,{size:16}):n.jsxs("div",{className:U.socialIcons,children:[n.jsx(x0,{}),n.jsx(w0,{}),n.jsx(b0,{})]})]}),n.jsx("div",{className:U.divider,children:n.jsx("span",{className:U.dividerText,children:"or"})})]}),n.jsx(yt,{className:U.scrollable,children:n.jsxs("div",{className:U.list,children:[u.map(g=>{const{icon:p,id:y,name:x,uid:b}=g,j=o===y,v=a===y;return n.jsxs("button",{type:"button",className:B(U.listItem,{[U.loading]:j}),onClick:()=>r(g),disabled:s,"aria-busy":j,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(re,{src:p,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listName,children:x}),j?n.jsx(It,{size:16}):v?n.jsx("span",{className:U.recentBadge,children:"Recent"}):n.jsx("span",{className:U.installedText,children:"Installed"})]},b)}),f.map(g=>n.jsxs("a",{className:U.listItem,href:g.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${g.name} (opens in new tab)`,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx(re,{src:g.icon,width:26,height:26,alt:"",className:U.icon})}),n.jsx("span",{className:U.listNameMuted,children:g.name}),n.jsx(M.IconExternalLink,{size:10,className:U.externalLinkIcon,"aria-hidden":"true"})]},g.id)),n.jsxs("button",{type:"button",className:U.listItem,onClick:i,onMouseEnter:c,onFocus:c,disabled:s,children:[n.jsx("div",{className:U.listIconWrapper,children:n.jsx("div",{className:U.moreIconSmall,children:n.jsx(y0,{})})}),n.jsx("span",{className:U.listNameMuted,children:"More wallets"}),n.jsx("span",{className:U.arrowIcon,"aria-hidden":"true",children:"→"})]})]})}),n.jsxs("a",{className:U.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",n.jsx(M.IconExternalLink,{size:14,"aria-hidden":"true"})]})]})},Wr=({onSuccess:e})=>{const{connectors:t,connectAsync:s}=Qe.useConnect(),o=Ge.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=_.useState(null),[i,c]=_.useState("signin"),l=E.useQueryClient(),u=()=>l.prefetchQuery({queryKey:gl,queryFn:({signal:p})=>_l(p),staleTime:V.INFINITY,gcTime:V.INFINITY}),{mutate:m,isPending:d}=E.useMutation({mutationFn:async p=>{try{await s({connector:p})}catch(y){throw await ct(y)}},onMutate:p=>{r(p.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),h=_.useMemo(()=>[...t].sort((p,y)=>p.id===o?-1:y.id===o?1:p.name.localeCompare(y.name)),[t,o]),f=_.useMemo(()=>h.find(p=>p.id===Jn.id),[h]),g=_.useMemo(()=>h.filter(p=>p.id!==Jn.id),[h]);return i==="all"?n.jsx(g0,{walletConnectors:g,isPending:d,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onBack:()=>c("signin")}):n.jsx(v0,{walletConnectors:g,privyConnector:f,isPending:d,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onShowAll:()=>c("all"),onPrefetchWallets:u})},j0="iUSD",zr="1",C0="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",k0="0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a",N0={[j0]:{externalSourceSymbols:["USDC","AUSD"],extraExternalOptions:[{chainId:zr,denom:C0},{chainId:zr,denom:k0}],extraInitiaSourceSymbols:["USDC"],externalChainListSource:"extra-options"}};function Hr(e,t,s){return e.chainId!==t?!1:e.denom.startsWith("0x")&&s.startsWith("0x")?e.denom.toLowerCase()===s.toLowerCase():e.denom===s}function I0(e){return N0[e]}function Qr(e){return e.pretty_name||e.chain_name}function Gr(e){return e.chain_type!=="cosmos"||e.bech32_prefix==="init"}const A0={data:[],isLoading:!1,supportedExternalChains:[],appchainSourceSymbols:[],externalSourceSymbols:[],localSymbol:""};function S0({chainIds:e,chains:t}){return Object.fromEntries(e.map(s=>[s,t?.[s]?.denoms??{}]))}const T0={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 bs(e){return T0[e]}function E0(){const e=Fe(),{data:t,error:s}=E.useQuery({queryKey:Ie.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:o})=>o.filter(({chain_type:a,bech32_prefix:r})=>a==="evm"||a==="cosmos"&&r==="init"),staleTime:V.MINUTE});return{chains:t??[],error:s}}function Ha(){const e=Fe(),t=Bn(),s=ie(),{chains:o,error:a}=E0(),r=_.useMemo(()=>o.map(({chain_id:u})=>u),[o]),{data:i,error:c,isLoading:l}=E.useQuery({queryKey:Ie.allBalances(r,[t,s]).queryKey,queryFn:()=>{const u=Object.fromEntries(o.map(m=>[m.chain_id,{address:m.chain_type==="evm"?t:s,denoms:[]}]));return e.post("v2/info/balances",{json:{chains:u}}).json()},select:({chains:u})=>S0({chainIds:r,chains:u}),enabled:!!s&&r.length>0,staleTime:V.SECOND});return{data:i,error:c,isLoading:l,chainsError:a}}function Qa(){const{localOptions:e=[]}=et(),t=E.useQueryClient(),s=Fe(),{data:o,isLoading:a}=E.useQuery({queryKey:Ie.allAssets().queryKey,queryFn:()=>s.get("v2/fungible/assets").json(),staleTime:V.MINUTE});return{data:_.useMemo(()=>{if(o){const i=Object.values(o.chain_to_assets_map).flatMap(l=>l?.assets??[]),c=new Map(i.map(l=>[`${l.chain_id}:${l.denom}`,l]));return e.map(({denom:l,chainId:u})=>{const m=c.get(`${u}:${l}`);return{denom:l,chain_id:u,symbol:m?.symbol??"",logo_uri:m?.logo_uri??""}})}return e.map(({denom:i,chainId:c})=>{const l=t.getQueryData($n.item(c,i).queryKey);return{denom:i,chain_id:c,symbol:l?.symbol??"",logo_uri:l?.logoUrl??""}})},[e,o,t]),isLoading:a}}function Ga(e){const{local:t}=bs(e),s=ps(),{watch:o}=Jt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function $0(e){const{external:t}=bs(e),s=ps(),{watch:o}=Jt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function yl(e){const t=ps(),s=fo(),o=Bt(),a=Oa(),{data:r,isLoading:i}=Ha(),{remoteOptions:c=[]}=et(),l=Ga(e);if(!l)return{...A0,isLoading:i};const u=I0(l.symbol),m=u?.externalSourceSymbols??[l.symbol],d=c.length>0,h=u?.extraExternalOptions??[],f=u?.extraInitiaSourceSymbols??[],g=u?.externalChainListSource??"supported-assets",p=new Map(s.map(w=>[w.chain_id,w])),y=t.filter(({symbol:w,denom:C,chain_id:I})=>{if(d)return c.some(P=>Hr(P,I,C));const T=h.some(P=>Hr(P,I,C)),A=p.get(I),$=!!A&&a(A.chain_id)&&f.includes(w),N=T||$;return w===l.symbol||N}).map(w=>{if(w.hidden||w.chain_id===l.chain_id)return null;const C=o(w.chain_id);if(!C||!Gr(C))return null;const I=r?.[C.chain_id]?.[w.denom];return{asset:w,chain:C,balance:I}}).filter(w=>w!==null),x=y.filter(({balance:w})=>e!=="deposit"||!!w&&Number(w.amount)>0),b=new Map;if(g==="extra-options")for(const{chainId:w}of h){const C=p.get(w);C&&Gr(C)&&(a(C.chain_id)||b.set(C.chain_id,C))}else for(const{chain:w}of x)a(w.chain_id)||b.set(w.chain_id,w);const j=Array.from(b.values()).sort((w,C)=>Qr(w).localeCompare(Qr(C))),v=[...new Set(y.filter(({chain:w})=>fg(w,a)).map(({asset:w})=>w.symbol))];return{data:x,isLoading:i,supportedExternalChains:j,appchainSourceSymbols:v,externalSourceSymbols:m,localSymbol:l.symbol}}function Jt(){return $e.useFormContext()}const M0="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",L0="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";function la(e){return e.length===0?"":e.length===1?e[0]:e.length===2?`${e[0]} or ${e[1]}`:`${e.slice(0,-1).join(", ")}, or ${e[e.length-1]}`}function q0(e,t,s){const o=[...new Set(e)],a=[],r=[...s,t];for(const c of r)o.includes(c)&&!a.includes(c)&&a.push(c);const i=o.filter(c=>!a.includes(c)).sort((c,l)=>c.localeCompare(l));return[...a,...i]}function R0(e,t,s){if(!e.length)return"";const o=q0(e,t,s);return o.length===1&&o[0]===t?"from any app":`using ${la(o)} from any app`}function P0({localSymbol:e,externalSourceSymbols:t,externalChainNames:s,appchainSourceSymbols:o}){const a=`No ${e} available to deposit.`,r=s.length>0,i=la(s),c=[...new Set(t)],l=la(c),u=R0(o,e,c),m=!!u,d=c.length!==1||c[0]!==e;if(r&&m){const h=d?`using ${l} from ${i}`:`from ${i}`;return{title:a,description:`You can deposit ${e} ${h}, or ${u}.`}}return r?d?{title:a,description:`You can deposit ${e} using ${l} from ${i}.`}:{title:a,description:`You can deposit ${e} from ${i}.`}:m?{title:a,description:`You can deposit ${e} ${u}.`}:{title:a,description:"No deposit sources are currently available."}}const D0="_container_pjkfr_1",B0="_title_pjkfr_5",F0="_close_pjkfr_12",U0="_emptyIcon_pjkfr_24",O0="_empty_pjkfr_24",V0="_emptyDescription_pjkfr_39",K0="_list_pjkfr_60",W0="_asset_pjkfr_75",z0="_placeholder_pjkfr_91",H0="_activeAsset_pjkfr_104",Q0="_iconContainer_pjkfr_108",G0="_assetIcon_pjkfr_118",Y0="_chainIcon_pjkfr_128",Z0="_assetPlaceholder_pjkfr_142",J0="_assetName_pjkfr_163",X0="_assetChain_pjkfr_178",e2="_balance_pjkfr_186",t2="_value_pjkfr_195",be={container:D0,title:B0,close:F0,emptyIcon:U0,empty:O0,emptyDescription:V0,list:K0,asset:W0,placeholder:z0,activeAsset:H0,iconContainer:Q0,assetIcon:G0,chainIcon:Y0,assetPlaceholder:Z0,assetName:J0,assetChain:X0,balance:e2,value:t2},n2=({mode:e})=>{const{external:t}=bs(e),{data:s,isLoading:o,supportedExternalChains:a,appchainSourceSymbols:r,externalSourceSymbols:i,localSymbol:c}=yl(e),{setValue:l,watch:u}=Jt(),m=Ga(e),{data:d}=Qa(),{theme:h}=se(),f=u(),g=f[t.denomKey],p=f[t.chainIdKey],x=!o&&s.length===1?`${s[0].chain.chain_id}:${s[0].asset.denom}`:"";function b(w,C){l(t.denomKey,w),l(t.chainIdKey,C),e==="deposit"&&l("quantity",""),l("page","fields")}const j=_.useEffectEvent(()=>{if(!x)return;const[{asset:w,chain:C}]=s;if(g===w.denom&&p===C.chain_id){l("page","fields");return}b(w.denom,C.chain_id)});_.useEffect(()=>{j()},[x]);function v(){const w=g&&p;return!w&&d.length<=1&&e==="deposit"?null:n.jsx("button",{className:be.close,onClick:()=>{e==="withdraw"||w?l("page","fields"):l("page","select-local")},children:n.jsx(M.IconBack,{size:20})})}if(!m)return n.jsx("div",{children:"No assets found"});if(!o&&!s.length){const w=a.map(T=>T.pretty_name||T.chain_name).filter(T=>!!T),C=P0({localSymbol:c,externalSourceSymbols:i,externalChainNames:w,appchainSourceSymbols:r}),I=e==="withdraw"?`No supported destinations to withdraw ${m.symbol}.`:C.title;return n.jsxs("div",{className:be.container,children:[v(),n.jsx("h4",{className:be.title,children:"No available assets"}),n.jsx("img",{src:h==="dark"?M0:L0,alt:"No assets",className:be.emptyIcon}),n.jsx("p",{className:be.empty,children:I}),e==="deposit"&&n.jsx("p",{className:be.emptyDescription,children:C.description})]})}return n.jsxs("div",{className:be.container,children:[v(),n.jsxs("h4",{className:be.title,children:[e==="withdraw"?"Select destination":`Deposit ${m.symbol}`," "]}),n.jsxs("div",{className:be.list,children:[o&&Array.from({length:5}).map((w,C)=>n.jsxs("div",{className:B(be.asset,be.placeholder),children:[n.jsxs("div",{className:be.iconContainer,children:[n.jsx("div",{className:be.assetIcon}),n.jsx("div",{className:be.chainIcon})]}),n.jsx("div",{className:be.assetPlaceholder})]},C)),!o&&s.sort(({balance:w},{balance:C})=>Number(C?.value_usd??0)-Number(w?.value_usd??0)).map(({asset:w,chain:C,balance:I})=>{const T=g===w.denom&&p===C.chain_id,A=Ua(I?.value_usd,I?.price);return n.jsxs("button",{className:B(be.asset,T&&be.activeAsset),onClick:()=>b(w.denom,C.chain_id),children:[n.jsxs("div",{className:be.iconContainer,children:[n.jsx("img",{src:w.logo_uri,alt:w.symbol,className:be.assetIcon}),n.jsx("img",{src:C.logo_uri||"",alt:C.chain_name,className:be.chainIcon})]}),n.jsxs("p",{className:be.assetName,children:[w.symbol," ",T&&n.jsx("span",{children:n.jsx(M.IconCheck,{size:16})})]}),n.jsxs("p",{className:be.assetChain,children:["on ",C.pretty_name]}),I&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:be.balance,children:k.formatAmount(I.amount,{decimals:I.decimals||6})}),n.jsx("p",{className:be.value,children:A})]})]},`${w.chain_id}-${w.denom}`)})]})]})},s2="_title_iequo_1",o2="_list_iequo_7",a2="_asset_iequo_15",r2="_imgPlaceholder_iequo_40",$s={title:s2,list:o2,asset:a2,imgPlaceholder:r2},i2=({mode:e})=>{const{local:t,external:s}=bs(e),{setValue:o}=Jt(),{data:a,isLoading:r}=Qa(),[i,c]=_.useTransition(),l=(m,d)=>{o(t.denomKey,m),o(t.chainIdKey,d),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),c(()=>{o("page",e==="withdraw"?"fields":"select-external")})},u=_.useEffectEvent(()=>{const{denom:m,chain_id:d}=a[0];l(m,d)});return _.useEffect(()=>{!r&&a.length===1&&u()},[a,r]),a.length?n.jsxs(n.Fragment,{children:[n.jsx("h3",{className:$s.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),n.jsx("div",{className:$s.list,"aria-busy":i,children:a.map(({denom:m,chain_id:d,symbol:h,logo_uri:f})=>n.jsxs("button",{className:$s.asset,onClick:()=>l(m,d),disabled:i,children:[f?n.jsx("img",{src:f,alt:h}):n.jsx("div",{className:$s.imgPlaceholder,"aria-hidden":"true"}),h]},`${m}-${d}`))})]}):n.jsx("div",{children:"No assets found"})},c2="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",l2="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",u2="_container_9k4hs_1",d2="_title_9k4hs_8",m2="_subtitle_9k4hs_14",h2="_linkContainer_9k4hs_30",f2="_link_9k4hs_30",p2="_separator_9k4hs_51",g2="_errorIcon_9k4hs_62",_2="_error_9k4hs_62",De={container:u2,title:d2,subtitle:m2,linkContainer:h2,link:f2,separator:p2,errorIcon:g2,error:_2};function y2(e){if(!e)return"pending";const t=e.state;return t==="STATE_COMPLETED_SUCCESS"?"success":t==="STATE_ABANDONED"||t==="STATE_COMPLETED_ERROR"||t==="STATE_PENDING_ERROR"?"failed":"pending"}function ua({type:e}){const{closeModal:t}=Dn(),{theme:s}=se(),{watch:o}=Jt(),{result:a}=o(),{openDrawer:r}=Dt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,c=i?"":a.txhash,l=i?"":a.chainId,u=i?0:a.timestamp??0,{route:m,values:d}=a,{srcDenom:h,srcChainId:f,quantity:g}=d,p=At(h,f),y=e==="deposit"?"Deposit":"Withdraw",{data:x}=al({chainId:l,txHash:c,tracked:!1}),{data:b}=rl({chainId:l,txHash:c,tracked:!!x,timestamp:u,route:m}),j=y2(b),v=s==="dark"?c2:l2,w=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,C=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return n.jsxs("div",{className:De.container,children:[n.jsxs("h3",{className:De.title,children:[y," failed"]}),n.jsx("img",{src:v,alt:"Failed",className:De.errorIcon}),n.jsx("p",{className:De.error,children:a?.error}),n.jsx(fe.White,{fullWidth:!0,onClick:t,children:"Close"})]});const I=ss(m.estimated_route_duration_seconds),T=new URLSearchParams({tx_hash:c,chain_id:l}),A=new URL(`?${T.toString()}`,"https://explorer.skip.build"),$=()=>n.jsxs("div",{className:De.linkContainer,children:[n.jsx("a",{href:A.toString(),target:"_blank",rel:"noopener noreferrer",className:De.link,children:"View transaction"}),n.jsx("div",{className:De.separator}),n.jsx("button",{className:De.link,onClick:()=>{t(),r("/bridge/history")},children:"Go to history"})]});return n.jsxs("div",{className:De.container,children:[j==="pending"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:De.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",g," ",p.symbol]}),n.jsx("video",{src:w,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),n.jsxs("p",{className:De.subtitle,children:["Estimated time: ",n.jsx("span",{children:I})]}),$(),n.jsx("p",{className:De.subtitle,children:"Your transaction will continue even if you close this"})]}),j==="success"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:De.title,children:[y," complete"]}),n.jsx("video",{src:C,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:N=>{const S=N.currentTarget;S.duration-S.currentTime<.1&&S.pause()}}),$(),n.jsx(fe.White,{fullWidth:!0,onClick:t,children:"Close"})]}),j==="failed"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:De.title,children:[y," failed"]}),n.jsx("img",{src:v,alt:"Failed",className:De.errorIcon}),n.jsx("p",{className:De.error,children:"Your transaction could not be completed"}),n.jsx(fe.White,{fullWidth:!0,onClick:t,children:"Close"})]})]})}const x2=qe.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),b2=({tx:e,children:t})=>{const{values:s}=xt(),{srcChainId:o}=s,a=ie(),r=cs(),i=bn(),c=us(),{data:l,isLoading:u,isFetching:m}=E.useQuery({queryKey:x2.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const f=xo(e.cosmos_tx.msgs,{converters:r,fromAmino:i.fromAmino.bind(i)});return{estimatedGas:await(await c(o)).simulate(a,f,""),messages:f}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if("cosmos_tx"in e&&!l&&u)return n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Estimating gas...",disabled:!0,fullWidth:!0})});const d=l?.estimatedGas??null,h="cosmos_tx"in e&&(u||m);return n.jsx(n.Fragment,{children:t(d,{isEstimatingGas:h})})};function w2(e,t){return e?k.InitiaAddress(e).hex:t}function v2({currentState:e,route:t,quoteVerifiedAt:s,hexAddress:o,values:a}){return{...e,route:t,quoteVerifiedAt:s,values:{sender:o,recipient:w2(e.recipientAddress,o),slippagePercent:"0.1",...a}}}function j2({hasBalancesSnapshot:e,hasBalanceQueryError:t,isBalancesLoading:s}){if(!e){if(s)return"loading";if(t)return"error"}}function C2({hasBalancesSnapshot:e,balance:t}){if(e)return t??"0"}function Yr(e){if(!e)return null;const t=q(e);return!t.isFinite()||t.lt(0)?null:t}function k2({balance:e,requiredAmount:t}){if(t==="0")return!0;const s=Yr(e??"0"),o=Yr(t);return!s||!o?!1:s.gte(o)}function N2({sourceDenom:e,feeDetailsByDenom:t}){const s=t.get(e);if(!s||s.isSufficient)return;for(const[a,r]of t)if(a!==e&&r.isSufficient)return;if(q(s.balance).gte(s.fee))return"Make sure to leave enough for transaction fee"}function I2({feeDenom:e,sourceDenom:t,feeWarning:s,hasSourceBalance:o,isFeeBalanceSufficient:a}){if(!o)return{error:"Insufficient balance"};const r=e===t?s:void 0;return r?{warning:r}:a?{}:{error:"Insufficient balance"}}const A2="_container_11kmm_1",S2="_back_11kmm_6",T2="_title_11kmm_18",E2="_divider_11kmm_26",$2="_label_11kmm_30",M2="_asset_11kmm_37",L2="_assetIcon_11kmm_55",q2="_chainIcon_11kmm_67",R2="_assetName_11kmm_80",P2="_chevron_11kmm_92",D2="_input_11kmm_96",B2="_balanceContainer_11kmm_108",F2="_value_11kmm_116",U2="_maxButton_11kmm_126",O2="_detail_11kmm_142",V2="_detailsContainer_11kmm_153",K2="_detailsButton_11kmm_163",W2="_expandableDetails_11kmm_184",z2="_detailValue_11kmm_192",H2="_detailToken_11kmm_202",Q2="_receiveSummary_11kmm_210",Y={container:A2,back:S2,title:T2,divider:E2,label:$2,asset:M2,assetIcon:L2,chainIcon:q2,assetName:R2,chevron:P2,input:D2,balanceContainer:B2,value:F2,maxButton:U2,detail:O2,detailsContainer:V2,detailsButton:K2,expandableDetails:W2,detailValue:z2,detailToken:H2,receiveSummary:Q2},xl=({renderFee:e})=>{const{route:t}=et(),{values:s}=xt(),{dstDenom:o,dstChainId:a}=s,i=ps().find(({denom:g,chain_id:p})=>g===o&&p===a),c=ie(),l=$c(),[u,m]=Ge.useToggle(!1),d=_.useId(),h=t&&t.estimated_route_duration_seconds>60;if(!t||!i)return null;const f=Gc(t.amount_out,s.slippagePercent);return n.jsxs("div",{className:Y.detailsContainer,children:[n.jsxs("div",{children:[n.jsxs("button",{type:"button",className:Y.detailsButton,onClick:m,"aria-expanded":u,"aria-controls":d,children:["Transaction details"," ",n.jsx(M.IconChevronDown,{size:12,style:{transform:u?"rotate(180deg)":"rotate(0deg)"},"aria-hidden":"true"})]}),n.jsx(ts,{children:n.jsx("div",{id:d,children:u&&n.jsxs("div",{className:Y.expandableDetails,children:[t.does_swap&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Slippage"}),n.jsxs("p",{className:Y.detailValue,children:[s.slippagePercent,"%"]})]}),!!t.estimated_fees?.length&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Bridge fee"}),n.jsx("div",{className:Y.detailValue,children:Ka(t.estimated_fees)})]}),e&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Tx fee"}),n.jsx("div",{className:Y.detailValue,children:e()})]}),c&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Receiving address"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:l,alt:"Wallet",height:12,width:12})," ",k.truncate(c)]})]}),t.does_swap&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Minimum received"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Y.detailToken})," ",k.formatAmount(f,{decimals:i.decimals})," ",i.symbol]})]})]})})})]}),n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Estimated time"}),n.jsx("p",{className:Y.detailValue,style:h?{color:"var(--warning)"}:void 0,children:ss(t.estimated_route_duration_seconds)})]}),n.jsxs("div",{className:B(Y.detail,Y.receiveSummary),children:[n.jsx("p",{className:Y.detailLabel,children:"Estimated received"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Y.detailToken})," ",k.formatAmount(t.amount_out,{decimals:i.decimals})," ",i.symbol]})]})]})},G2="_trigger_1c7d7_1",Y2="_item_1c7d7_5",Z2="_itemText_1c7d7_13",J2={trigger:G2,item:Y2,itemText:Z2};function X2(e){return!e.isFetchingMessages&&!e.messageRefreshError}function bl(e,t,s){return X2(s)?n.jsx(dl,{tx:e,children:t}):t}function eb({feeDetailsByDenom:e,feeOptions:t,lastUsedFeeDenom:s,preferredFeeDenom:o}){if(o&&e.get(o)?.isSufficient)return o;if(s&&e.get(s)?.isSufficient)return s;for(const a of t){const[{denom:r}]=a.amount;if(e.get(r)?.isSufficient)return r}return t[0]?.amount[0].denom}const tb=({tx:e,gas:t,confirmMessage:s,onCompleted:o,messageRefreshError:a,isRouteTransitioning:r,isFetchingMessages:i,isEstimatingGas:c})=>{const{values:l}=xt(),{srcChainId:u,srcDenom:m,quantity:d}=l,f=ps().find(({denom:Q,chain_id:ee})=>Q===m&&ee===u),g=_t(u),p=as(g),y=Ia(g),x=Aa(g),b=St(g),j=t==null?[]:y.map(({amount:Q,denom:ee})=>Le.calculateFee(Math.ceil(t*Ht),Le.GasPrice.fromString(Q+ee))),v=new Map(j.map(Q=>{const[{denom:ee}]=Q.amount;return[ee,Q]})),w=new Map(p.map(({denom:Q,amount:ee})=>[Q,ee])),C=f?q(d||"0").times(q(10).pow(f.decimals)).toFixed(0):"0",I=new Map(j.map(Q=>{const[{amount:ee,denom:ue}]=Q.amount,ye=w.get(ue)??"0",me=f&&m===ue?C:"0",Ce=q(ee).plus(me),{symbol:Se,decimals:ke}=b(ue);return[ue,{symbol:Se,decimals:ke,spend:q(me).gt(0)?me:null,fee:ee,total:Ce.toFixed(),balance:ye,isSufficient:q(ye).gte(Ce)}]})),[T,A]=_.useState(null),$={isRouteTransitioning:r,isFetchingMessages:i,isEstimatingGas:c,messageRefreshError:a},N=eb({feeDetailsByDenom:I,feeOptions:j,lastUsedFeeDenom:x,preferredFeeDenom:T}),S=N?v.get(N):void 0,P=N?I.get(N):null,F=N2({sourceDenom:m,feeDetailsByDenom:I}),D=k2({balance:w.get(m)??"0",requiredAmount:C}),Z=I2({feeDenom:N,sourceDenom:m,feeWarning:F,hasSourceBalance:D,isFeeBalanceSufficient:P?.isSufficient??!0}),K=n.jsx(za,{tx:e,fee:S,onCompleted:o,confirmMessage:s,error:Z.error,warning:Z.warning,...$}),W=(Q,ee)=>{if(k.formatAmount(Q,{decimals:ee})==="0.000000")return 8},O=Q=>{const[{amount:ee,denom:ue}]=Q.amount;if(q(ee).isZero())return"0";const{symbol:ye,decimals:me}=b(ue),Ce=W(ee,me);return`${k.formatAmount(ee,{decimals:me,dp:Ce})} ${ye}`},J=()=>{if(j.length===0)return null;if(j.length===1)return n.jsx("span",{className:"monospace",children:O(j[0])});if(!S||!N)return null;const Q=j.map(Ce=>{const[{denom:Se}]=Ce.amount,{symbol:ke}=b(Se);return{value:Se,label:O(Ce),triggerLabel:ke}}),[{amount:ee,denom:ue}]=S.amount,{decimals:ye}=b(ue),me=W(ee,ye);return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{className:"monospace",children:k.formatAmount(ee,{decimals:ye,dp:me})}),n.jsx(Fa,{options:Q,value:N,onChange:A,classNames:J2})]})};return n.jsxs(n.Fragment,{children:[n.jsx(xl,{renderFee:j.length>0?J:void 0}),bl(e,K,$)]})},nb=({tx:e,gas:t,mode:s,messageRefreshError:o,isRouteTransitioning:a,isFetchingMessages:r,isEstimatingGas:i})=>{const{setValue:c}=Jt(),l={isRouteTransitioning:a,isFetchingMessages:r,isEstimatingGas:i,messageRefreshError:o},u=h=>{c("page","completed"),c("result",h)},m=s==="withdraw"?"Withdraw":"Deposit",d=n.jsx(za,{tx:e,fee:void 0,onCompleted:u,confirmMessage:m,...l});return"cosmos_tx"in e?n.jsx(tb,{tx:e,gas:t,onCompleted:u,confirmMessage:m,...l}):n.jsxs(n.Fragment,{children:[n.jsx(xl,{}),bl(e,d,l)]})};function Zr(e){const t=e.values;return{recipient:t?.recipient,sender:t?.sender}}function sb({currentState:e,nextState:t}){if(e.route!==t.route||e.quoteVerifiedAt!==t.quoteVerifiedAt)return!0;const s=Zr(e),o=Zr(t);return s.sender!==o.sender||s.recipient!==o.recipient}function ob({disabledMessage:e,routeForState:t,routeError:s,isNoRouteError:o,isServerError:a}){return e?"disabled":t?"ready":s?o?"no-route":a?"server-error":"refresh-failed":"loading"}function ab({hasRouteState:e,routeStatus:t}){return e&&(t==="ready"||t==="loading")}function rb({routeStatus:e,disabledMessage:t,isRouteSynced:s}){if(e==="disabled")return t;if(e==="loading"||e==="ready"&&!s)return"Fetching route...";if(e==="no-route")return"No route found";if(e==="server-error")return"Server error";if(e==="refresh-failed")return"Failed to refresh route"}const ib=typeof window>"u"?_.useEffect:_.useLayoutEffect,cb=({mode:e})=>{const t=bs(e),s=Me(),o=et(),{data:a}=Qa(),r=Bt(),{data:i,error:c,chainsError:l,isLoading:u}=Ha(),m=Bn(),{watch:d,setValue:h,getValues:f}=Jt(),g=d(),{srcChainId:p,srcDenom:y,quantity:x=""}=g,{recipientAddress:b,route:j}=o,v=g[t.external.denomKey],w=g[t.external.chainIdKey],C=Ga(e),I=$0(e),{data:T,isLoading:A}=yl(e),$=!A&&T.length===1,N=e==="withdraw"&&!A&&T.length>0&&new Set(T.map(({chain:X})=>X.chain_id)).size===1,S=_.useMemo(()=>A||!T.length?null:$?T[0]:N?T.reduce((X,ve)=>{const Oe=Number(X.balance?.value_usd??0);return Number(ve.balance?.value_usd??0)>Oe?ve:X},T[0]):null,[T,$,N,A]),P=S?`${S.chain.chain_id}:${S.asset.denom}`:"",F=w?r(w):null,D=i?.[p]?.[y]?.amount,Z=i?.[p]?.[y]?.price,K=q(Z??0).times(x||0),[W]=Ge.useDebounceValue(x,300),O=e==="withdraw"?C:I,J=j2({hasBalancesSnapshot:i!==void 0,hasBalanceQueryError:!!(c||l),isBalancesLoading:u}),Q=C2({hasBalancesSnapshot:i!==void 0,balance:D}),ee=_.useMemo(()=>{if(e==="deposit"&&!I)return"Select asset";const X=q(x||0);if(!X.isFinite()||X.lte(0))return"Enter amount";if(e==="withdraw"&&!I)return"Select destination";if(J==="loading")return"Loading balances...";if(J==="error")return"Failed to load balances";if(Q!==void 0){const ve=k.fromBaseUnit(Q,{decimals:O?.decimals||6});if(X.gt(ve))return"Insufficient balance"}},[O,Q,J,I,e,x]),ue=_.useMemo(()=>{if(e==="deposit"&&!I)return!0;const X=q(x||0);if(!X.isFinite()||X.lte(0)||e==="withdraw"&&!I||J==="error")return!0;if(Q!==void 0){const ve=k.fromBaseUnit(Q,{decimals:O?.decimals||6});if(X.gt(ve))return!0}return!1},[O,Q,J,I,e,x]),{data:ye,error:me,dataUpdatedAt:Ce}=oa(W,{disabled:ue}),Se=me instanceof z.HTTPError&&me.response.status===400,ke=!ee&&!Se?ye:void 0,Et=ke&&Ce>0?Ce:void 0,ut=me instanceof z.HTTPError&&me.response.status===500,Re=ob({disabledMessage:ee,routeForState:ke,routeError:me,isNoRouteError:Se,isServerError:ut}),le=Re==="ready"&&o.route===ke,G=Re==="loading"||Re==="ready"&&!le,$t=ab({hasRouteState:!!o.route,routeStatus:Re}),Xt=rb({routeStatus:Re,disabledMessage:ee,isRouteSynced:le});ib(()=>{const X=v2({currentState:o,route:ke,quoteVerifiedAt:Et,hexAddress:m,values:f()});sb({currentState:o,nextState:X})&&s(0,X)},[j,f,m,s,Et,b,ke]);const Mt=_.useEffectEvent(()=>{if(!S||v&&w)return;const{asset:X,chain:ve}=S;h(t.external.denomKey,X.denom),h(t.external.chainIdKey,ve.chain_id),e==="deposit"&&h("quantity","")});if(_.useEffect(()=>{Mt()},[P]),!C||e==="deposit"&&!I)return null;const bt=O?.decimals||6,en=e==="withdraw"?"Select chain":"Select asset",dt=()=>{h("quantity",""),h(t.external.denomKey,""),h(t.external.chainIdKey,""),(e==="withdraw"||$)&&(h(t.local.denomKey,""),h(t.local.chainIdKey,"")),h("page",e==="withdraw"||$?"select-local":"select-external")},Ue=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:Y.label,children:e==="withdraw"?"Destination":"From"}),n.jsxs("button",{className:Y.asset,disabled:$,onClick:()=>h("page","select-external"),children:[n.jsx("div",{className:Y.assetIcon,children:I?n.jsxs(n.Fragment,{children:[n.jsx("img",{src:I.logo_uri,alt:I.symbol}),n.jsx("img",{src:F?.logo_uri||"",alt:F?.pretty_name,className:Y.chainIcon})]}):e==="withdraw"&&n.jsx("div",{className:Y.chainIcon})}),n.jsx("p",{className:Y.assetName,children:I?n.jsxs(n.Fragment,{children:[I.symbol,n.jsx("br",{}),n.jsxs("span",{children:["on ",F?.pretty_name]})]}):en}),!$&&n.jsx(M.IconChevronDown,{className:Y.chevron,size:16})]})]}),nt=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:Y.label,children:"Amount"}),n.jsx(ns,{balance:Q,decimals:bt,className:Y.input}),Q!==void 0&&n.jsxs("div",{className:Y.balanceContainer,children:[n.jsx("p",{className:Y.value,children:x?Ua(K.toString(),Z):"$-"}),n.jsxs("button",{className:Y.maxButton,onClick:()=>{const X=k.fromBaseUnit(Q,{decimals:bt});q(x||0).eq(X)||h("quantity",X)},children:[n.jsx(M.IconWallet,{size:16})," ",k.formatAmount(Q,{decimals:bt})," ",n.jsx("span",{children:"MAX"})]})]})]});return n.jsxs("section",{className:Y.container,"aria-label":"Transfer form",children:[a.length>1&&n.jsx("button",{type:"button","aria-label":"Back",className:Y.back,onClick:dt,children:n.jsx(M.IconBack,{size:20})}),n.jsxs("h3",{className:Y.title,children:[t.label," ",C.symbol]}),e==="withdraw"?n.jsxs(n.Fragment,{children:[nt,n.jsx("div",{className:Y.divider}),Ue]}):n.jsxs(n.Fragment,{children:[Ue,n.jsx("div",{className:Y.divider}),nt]}),(l||c)&&n.jsx(je,{error:!0,children:"Failed to load balances"}),$t?n.jsx(ul,{children:X=>n.jsx(hl,{children:ve=>n.jsx(ml,{addressList:X,signedOpHook:ve,children:(Oe,{isFetchingMessages:mt,messageRefreshError:jo})=>n.jsx(b2,{tx:Oe,children:(ws,{isEstimatingGas:Co})=>n.jsx(xe,{suspenseFallback:n.jsx(Ae,{children:n.jsx(fe.White,{loading:"Estimating gas...",disabled:!0,fullWidth:!0})}),children:n.jsx(nb,{tx:Oe,gas:ws,mode:e,isRouteTransitioning:G,isFetchingMessages:mt,isEstimatingGas:Co,messageRefreshError:jo})})})})})}):n.jsx(Ae,{children:n.jsx(fe.White,{type:"submit",loading:G&&"Fetching route...",disabled:!0,fullWidth:!0,children:Xt})})]})},lb="_container_7nl9j_1",ub="_page_7nl9j_5",Jr={container:lb,page:ub},wl=({mode:e})=>{const t=$e.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Ha(),n.jsx($e.FormProvider,{...t,children:n.jsx(db,{mode:e})})},db=({mode:e})=>{const{watch:t}=Jt(),s=t("page"),o=Nt.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 n.jsx(i2,{mode:e});case"select-external":return n.jsx(n2,{mode:e});case"fields":return n.jsx(cb,{mode:e});case"completed":return n.jsx(ua,{type:e})}};return n.jsx(ts,{children:n.jsx("div",{className:Jr.container,children:o((r,i)=>n.jsx(Nt.animated.div,{style:r,className:Jr.page,children:a(i)}))})})},mb=()=>n.jsx(wl,{mode:"deposit"}),hb=()=>n.jsx(wl,{mode:"withdraw"}),fb="_root_1lo0i_1",pb="_address_1lo0i_9",gb="_copy_1lo0i_19",_b="_labelWrapper_1lo0i_33",yb="_labelCopy_1lo0i_43",xb="_labelCopied_1lo0i_47",bb="_copied_1lo0i_55",wb="_derived_1lo0i_65",vb="_derivedLabel_1lo0i_79",jb="_derivedAddress_1lo0i_83",Cb="_hexAddress_1lo0i_89",kb="_derivedCopy_1lo0i_94",Ke={root:fb,address:pb,copy:gb,labelWrapper:_b,labelCopy:yb,labelCopied:xb,copied:bb,derived:wb,derivedLabel:vb,derivedAddress:jb,hexAddress:Cb,derivedCopy:kb},Nb=()=>{const e=_.useRef(null),t=_.useRef(null),{initiaAddress:s,hexAddress:o}=tt(),a=Tc("--gray-0");return _.useEffect(()=>{e.current&&(t.current?t.current.update({data:s}):(t.current=new Ql({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"}}),t.current.append(e.current)))},[s,a]),n.jsx(Tt,{title:"Receive",children:n.jsxs("div",{className:Ke.root,children:[n.jsx("div",{ref:e,style:{width:200,height:200}}),n.jsx("span",{className:Ke.address,children:s}),n.jsx(Ws,{value:s,children:({copy:r,copied:i})=>n.jsxs("button",{className:B(Ke.copy,{[Ke.copied]:i}),onClick:r,"aria-label":i?"Copied":"Copy address",children:[n.jsx(M.IconCopy,{size:12,"aria-hidden":"true"}),n.jsxs("div",{className:Ke.labelWrapper,children:[n.jsx("span",{className:Ke.labelCopy,children:"Copy address"}),n.jsx("span",{className:Ke.labelCopied,children:"Copied!"})]})]})}),n.jsx(Ws,{value:o,children:({copy:r,copied:i})=>n.jsxs("button",{className:B(Ke.derived,{[Ke.copied]:i}),onClick:r,"aria-label":i?"Copied":"Copy derived address",children:[n.jsx("span",{className:Ke.derivedLabel,children:"Derived from"}),n.jsxs("span",{className:Ke.derivedAddress,children:[n.jsx("span",{className:Ke.hexAddress,children:k.truncate(o)}),n.jsx(M.IconCopy,{size:12,className:Ke.derivedCopy,"aria-hidden":"true"}),i&&n.jsx("span",{className:Ke.copiedText,children:"Copied!"})]})]})})]})})};function Ib(e,t){return t==null?e:e.filter(s=>s.grantee===t)}function Ab(){const e=ie(),t=_e();return E.useQueries({queries:t.map(s=>({queryKey:Vs.grants(s.chainId,e).queryKey,queryFn:async()=>{const o=await Js(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:s.restUrl},"grants"),a=Yi(o),r=e?wa(e,s.chainId):null,i=Ib(a,r);return{chainId:s.chainId,grants:i}},enabled:!!e,staleTime:V.SECOND,retry:!1}))})}const Sb="_countdown_vfms8_1",Tb={countdown:Sb},Eb=({expiration:e})=>{const t=()=>{const a=new Date,r=Xe.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),c=Math.floor(r%(1440*60)/3600),l=Math.floor(r%3600/60),u=r%60,m=[];return i>0&&m.push(`${i}d`),(c>0||i>0)&&m.push(`${c}h`),(l>0||c>0||i>0)&&m.push(`${l}m`),m.push(`${u}s`),m.join(" ")},[s,o]=_.useState(t());return Ge.useInterval(()=>{o(t())},1e3),Xe.isPast(e)?"Expired":n.jsxs(n.Fragment,{children:["Expires in ",n.jsx("span",{className:Tb.countdown,children:s})]})},$b="_container_1l528_1",Mb="_info_1l528_11",Lb="_header_1l528_17",qb="_chainName_1l528_23",Rb="_expiration_1l528_29",Pb="_revokeButton_1l528_35",kn={container:$b,info:Mb,header:Lb,chainName:qb,expiration:Rb,revokeButton:Pb},Db=({chainId:e,grantee:t,expiration:s})=>{const o=_t(e),{mutate:a,isPending:r}=dc({grantee:t,internal:!0});return n.jsxs("div",{className:kn.container,children:[n.jsxs("div",{className:kn.info,children:[n.jsxs("div",{className:kn.header,children:[n.jsx(re,{src:o.logoUrl,width:16,height:16,logo:!0}),n.jsx("div",{className:kn.chainName,children:o.name})]}),n.jsx("div",{className:kn.expiration,children:s?n.jsx(Eb,{expiration:s}):"Until revoked"})]}),n.jsx("button",{className:kn.revokeButton,onClick:()=>a(e),disabled:r,"aria-busy":r,children:r?"Revoking...":"Revoke"})]})},Bb=({chainId:e,grants:t})=>{const s=new Map;for(const a of t){const r=s.get(a.grantee),i=a.expiration?new Date(a.expiration):void 0;if(!r){s.set(a.grantee,{grantee:a.grantee,expiration:i});continue}r.expiration=ka([r.expiration,i])}return[...s.values()].map(a=>_.createElement(Db,{...a,chainId:e,key:a.grantee}))},Fb="_content_q36qs_1",Ub={content:Fb},Ob=()=>{const e=Ab(),t=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?n.jsx(je,{children:"No permissions found"}):n.jsx("div",{className:Ub.content,children:s.map(({chainId:o,grants:a})=>n.jsx(Bb,{chainId:o,grants:a},o))})};return n.jsx(Tt,{title:"Manage auto-signing",backButton:"/settings",children:t()})},Vb="_version_1sf5y_1",Kb={version:Vb},Wb=()=>n.jsxs("aside",{className:Kb.version,children:["v","2.8.0"]}),zb="_link_se23z_1",Hb="_title_se23z_17",Qb="_subtitle_se23z_23",Gb="_icon_se23z_30",Ms={link:zb,title:Hb,subtitle:Qb,icon:Gb},vl=({title:e,subtitle:t,rightSection:s,onClick:o})=>n.jsxs("button",{className:Ms.link,onClick:o,children:[n.jsxs("div",{children:[n.jsx("p",{className:Ms.title,children:e}),t&&n.jsx("p",{className:Ms.subtitle,children:t})]}),n.jsx("div",{className:Ms.icon,children:s??n.jsx(M.IconChevronRight,{size:16,"aria-hidden":"true"})})]}),Yb="https://export.initia.xyz/",Zb=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return n.jsx(vl,{title:"Export private key",rightSection:n.jsx(M.IconExternalLink,{size:16}),onClick:()=>window.open(Yb,"_blank",e)})},Jb="_container_1vxr7_1",Xb="_separator_1vxr7_7",Xr={container:Jb,separator:Xb},ew=()=>{const e=Me(),{connector:t}=Qe.useAccount();return n.jsx(Tt,{title:"Settings",backButton:"/",children:n.jsxs("div",{className:Xr.container,children:[n.jsx(vl,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),t?.id===ga&&n.jsx(Zb,{}),n.jsx(Rt.Separator,{className:Xr.separator}),n.jsx(Wb,{})]})})},tw="_trigger_1yjkd_1",nw="_icon_1yjkd_23",sw="_full_1yjkd_27",ow="_triggerContent_1yjkd_32",aw="_triggerText_1yjkd_40",rw="_popoverBackdrop_1yjkd_51",iw="_popoverPositioner_1yjkd_70",cw="_popoverPopup_1yjkd_74",lw="_search_1yjkd_99",uw="_viewport_1yjkd_105",dw="_item_1yjkd_111",mw="_highlighted_1yjkd_127",hw="_active_1yjkd_131",fw="_itemContent_1yjkd_136",pw="_extra_1yjkd_142",gw="_connectedTag_1yjkd_149",Ee={trigger:tw,icon:nw,full:sw,triggerContent:ow,triggerText:aw,popoverBackdrop:rw,popoverPositioner:iw,popoverPopup:cw,search:lw,viewport:uw,item:dw,highlighted:mw,active:hw,itemContent:fw,extra:pw,connectedTag:gw},vo=({value:e,onChange:t,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=se(),[i,c]=_.useState(""),[l,u]=_.useState(!1),[m,d]=_.useState(0),[h,f]=_.useState(),g=_.useRef([]),p=_.useRef(null),y=_e(),x=s.map(N=>y.find(S=>S.chainId===N)).filter(Boolean),b=N=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:N,height:N,viewBox:"0 0 14 14",children:[n.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"}),n.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"})]}),j=_.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),v=_.useMemo(()=>{const N=[j,...x];if(!i)return N;const S=i.toLowerCase();return N.filter(P=>P.name.toLowerCase().includes(S)||P.chainId.toLowerCase().includes(S))},[x,i,j]),w=x.find(N=>N.chainId===e)||j,C=parseInt(Tc("--drawer-offset")),I=6,T=()=>{if(c(""),d(-1),p.current){const S=p.current.getBoundingClientRect().bottom+I,P=window.innerHeight-S-2*C;f(P)}u(!0)};_.useEffect(()=>{m>=0&&m<g.current.length&&g.current[m]?.scrollIntoView({block:"nearest",behavior:"auto"})},[m]);const A=_.useCallback(N=>{switch(N.key){case"ArrowDown":N.preventDefault(),d(S=>(S+1)%v.length);break;case"ArrowUp":N.preventDefault(),d(S=>(S-1+v.length)%v.length);break;case"Enter":N.preventDefault(),v[m]&&(t(v[m].chainId),u(!1));break;case"Escape":N.preventDefault(),u(!1);break}},[v,m,t,u]),$=N=>{t(N),u(!1)};return n.jsxs(jn.Popover.Root,{open:l,onOpenChange:T,modal:"trap-focus",children:[n.jsx(jn.Popover.Trigger,{render:n.jsxs("button",{className:B(Ee.trigger,{[Ee.full]:a}),"aria-expanded":l,role:"listbox",ref:p,children:[n.jsxs("div",{className:Ee.triggerContent,children:[typeof w.logoUrl=="string"?n.jsx(re,{src:w.logoUrl,width:14,height:14,logo:!0}):w.logoUrl(14),n.jsx("span",{className:Ee.triggerText,children:w.name})]}),n.jsx(M.IconChevronDown,{size:16,className:Ee.icon})]})}),n.jsxs(jn.Popover.Portal,{container:_n(),children:[n.jsx(jn.Popover.Backdrop,{className:Ee.popoverBackdrop,onClick:()=>u(!1)}),n.jsx(jn.Popover.Positioner,{className:Ee.popoverPositioner,align:"end",side:"bottom",sideOffset:I,collisionAvoidance:{side:"none"},children:n.jsxs(jn.Popover.Popup,{className:B(Ee.popoverPopup,{[Ee.full]:a}),style:{maxHeight:h},children:[n.jsx(ys,{value:i,onChange:N=>{c(N.target.value),d(0)},onClear:()=>c(""),onKeyDown:A,placeholder:"Search apps",rootClassName:Ee.search,ref:gs()}),n.jsx("div",{className:Ee.viewport,role:"listbox",children:v.length===0?n.jsx(je,{children:"No apps found"}):v.map(({chainId:N,name:S,logoUrl:P},F)=>n.jsxs("div",{className:B(Ee.item,{[Ee.highlighted]:F===m,[Ee.active]:e===N}),onClick:()=>$(N),onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),$(N))},onMouseEnter:()=>d(F),role:"option","aria-selected":e===N,tabIndex:-1,ref:D=>{D&&(g.current[F]=D)},children:[n.jsxs("div",{className:Ee.itemContent,children:[typeof P=="string"?n.jsx(re,{src:P,width:16,height:16,logo:!0}):P(16),n.jsx("span",{className:Ee.name,children:S}),N===r&&n.jsx("span",{className:Ee.connectedTag,children:"Connected"})]}),o&&n.jsx("span",{className:Ee.extra,children:o(N)})]},N))})]})})]})]})},_w="_container_1nap1_1",yw="_controls_1nap1_7",xw="_search_1nap1_13",Ya={container:_w,controls:yw,search:xw},bw=({children:e})=>n.jsx("div",{className:Ya.container,children:e}),ww=({children:e})=>n.jsx("div",{className:Ya.controls,children:e}),vw=e=>n.jsx(ys,{...e,rootClassName:Ya.search}),gt={Root:bw,Controls:ww,SearchInput:vw},jl=H.atom(""),Cl=H.atom(""),jw=H.atom(""),Cw=H.atom(""),kw=H.atom(""),Nw="_change_1nm9m_1",Iw="_positive_1nm9m_8",Aw="_negative_1nm9m_12",Ho={change:Nw,positive:Iw,negative:Aw},kl=({amount:e,asset:t})=>{const{denom:s,symbol:o,decimals:a}=t,r=new q(e).isPositive(),i=new q(e).abs().toString();return n.jsxs("div",{className:B(Ho.change,r?Ho.positive:Ho.negative),children:[r?"+":"-",k.formatAmount(i,{decimals:a})," ",o||s]})},Sw=({changes:e,chain:t})=>{const s=St(t);return e.map(({amount:o,denom:a},r)=>n.jsx(kl,{amount:o,asset:s(a)},r))},Tw=({changes:e,chain:t})=>{const s=St(t);return e.map(({amount:o,metadata:a},r)=>n.jsx(Pc,{metadata:a,chain:t,children:i=>n.jsx(kl,{amount:o,asset:s(i)})},r))},Ew=({events:e,chain:t})=>{const{initiaAddress:s,hexAddress:o}=tt();return t.metadata?.is_l1||t.metadata?.minitia?.type==="minimove"?n.jsx(Tw,{changes:Rc(e,o),chain:t}):n.jsx(Sw,{changes:qc(e,s),chain:t})},$w="_message_1qc8m_1",Mw="_more_1qc8m_9",ei={message:$w,more:Mw},Lw=({messages:e})=>n.jsxs(n.Fragment,{children:[e.slice(0,3).map((t,s)=>n.jsx("p",{className:ei.message,children:Ys.sentenceCase(t["@type"].split("Msg")[1])},s)),e.length>3&&n.jsx("footer",{className:ei.more,children:`+${e.length-3} more`})]}),qw="_link_1vbb0_1",Rw="_inner_1vbb0_16",Pw="_header_1vbb0_21",Dw="_time_1vbb0_30",Bw="_error_1vbb0_36",Fw="_timestamp_1vbb0_40",Uw="_chainInfo_1vbb0_45",Ow="_content_1vbb0_53",Vw="_messages_1vbb0_61",Kw="_changes_1vbb0_67",jt={link:qw,inner:Rw,header:Pw,time:Dw,error:Bw,timestamp:Fw,chainInfo:Uw,content:Ow,messages:Vw,changes:Kw},Ww=({txItem:e,chain:t})=>n.jsx(ho,{txHash:e.txhash,chainId:t.chainId,className:jt.link,children:n.jsxs("div",{className:jt.inner,children:[n.jsxs("div",{className:jt.header,children:[n.jsxs("div",{className:jt.time,children:[e.code!==0&&n.jsx(M.IconWarningFilled,{size:14,className:jt.error}),n.jsx("span",{className:jt.timestamp,children:Xe.format(new Date(e.timestamp),"h:mm a")})]}),n.jsxs("div",{className:jt.chainInfo,children:[n.jsx(re,{src:t.logoUrl,width:12,height:12,logo:!0}),n.jsx("span",{children:t.name})]})]}),n.jsxs("div",{className:jt.content,children:[n.jsx("div",{className:jt.messages,children:n.jsx(Lw,{messages:e.tx.body.messages})}),n.jsx("div",{className:jt.changes,children:n.jsx(xe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(Ew,{...e,chain:t})})})]})]})}),zw="_list_1mv55_1",Hw="_dateGroup_1mv55_7",Qw="_dateHeader_1mv55_12",Gw="_more_1mv55_18",Ls={list:zw,dateGroup:Hw,dateHeader:Qw,more:Gw},Yw=({list:e,chainId:t})=>{const s=ie(),o=_.useMemo(()=>el(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?n.jsx(je,{children:"No activity found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Ls.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{className:Ls.dateGroup,children:[n.jsx("div",{className:Ls.dateHeader,children:a}),r.map(i=>n.jsx(xe,{errorBoundaryProps:{fallback:null},children:n.jsx(Ww,{txItem:i,chain:i.chain})},i.txhash))]},a))}),n.jsx(ho,{chainId:t,accountAddress:s,pathSuffix:"/txs",className:Ls.more,showIcon:!0,children:"View more on Initia Scan"})]})},Zw=()=>{const{activities:e,isLoading:t}=hd(),[s,o]=H.useAtom(kw),a=ce(),r=_.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=_.useMemo(()=>s?e.filter(c=>c.chain.chainId===s):e,[e,s]);return t&&e.length===0?n.jsx(je,{children:"Loading activities..."}):!e.length&&!t?n.jsx(je,{children:"No activity yet"}):n.jsxs(gt.Root,{children:[n.jsx(gt.Controls,{children:n.jsx(vo,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),n.jsx(Yw,{list:i,chainId:s||a.chainId})]})},Jw="_thumbnail_1xyqw_1",Xw="_placeholder_1xyqw_18",ev="_clickable_1xyqw_24",Qn={thumbnail:Jw,placeholder:Xw,clickable:ev},tv=({nftInfo:e,size:t,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:c}=se(),l=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,c).toString();return s?n.jsx("button",{className:B(Qn.thumbnail,Qn.clickable),onClick:s,style:{width:t,height:t},children:n.jsx(re,{src:l,classNames:{placeholder:Qn.placeholder}})}):n.jsx("div",{className:Qn.thumbnail,style:{width:t,height:t},children:n.jsx(re,{src:l,classNames:{placeholder:Qn.placeholder}})})},nv="_collectionName_qs5tw_1",sv="_nftName_qs5tw_6",ov="_chainInfo_qs5tw_10",Qo={collectionName:nv,nftName:sv,chainInfo:ov},Za=({normalizedNft:e,onThumbnailClick:t,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:c}=e;return n.jsxs("div",{className:a?.root,children:[n.jsx(tv,{nftInfo:e,onClick:t,size:s}),n.jsxs("div",{children:[n.jsx("div",{className:B(Qo.collectionName,a?.collectionName),children:r}),n.jsx("div",{className:B(Qo.nftName,a?.nftName),children:i}),n.jsxs("div",{className:B(Qo.chainInfo,a?.chainInfo),children:[n.jsx(re,{src:c.logoUrl,width:o,height:o,logo:!0}),n.jsx("span",{children:c.name})]})]})]})},Ja=qe.createQueryKeys("interwovenkit:nft",{nfts:(e,t)=>[e,t],metadata:e=>[e]});function av(e,t){const{nft:s}=e,o=t.name??s.token_id;return{...e,...s,...t,name:o}}function rv(e,t){return e.flatMap((s,o)=>(t[o]??[]).map(r=>({...r,chain:s})))}const iv=()=>{const e=ie(),t=_e(),s=E.useQueries({queries:t.map(l=>({queryKey:Ja.nfts(l.indexerUrl,e).queryKey,queryFn:()=>Js(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:V.SECOND}))}),o=s.map(L.prop("data")),a=rv(t,o),r=a.reduce((l,{chain:u})=>({...l,[u.chainId]:(l[u.chainId]||0)+1}),{}),i=Object.values(r).reduce((l,u)=>l+u,0),c=s.some(l=>l.isLoading);return{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}};function cv(e){const t=ti(e);return E.useQuery({queryKey:Ja.metadata(t).queryKey,queryFn:async()=>{try{if(!t)return{};const s=await z.get(t).json();return{...s,image:ti(s.image)}}catch{return{}}},staleTime:V.INFINITY})}function ti(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const lv=({nftInfo:e,children:t})=>{const{data:s={}}=cv(e.nft.uri),o=av(e,s);return t(o)},uv="_grid_1wwdn_1",dv="_root_1wwdn_7",mv="_collectionName_1wwdn_15",hv="_nftName_1wwdn_23",fv="_chainInfo_1wwdn_32",ni={grid:uv,root:dv,collectionName:mv,nftName:hv,chainInfo:fv},pv=()=>{const[e,t]=H.useAtom(jw),[s,o]=H.useAtom(Cw),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=iv(),l=Me(),u=_.useMemo(()=>a.filter(({collection_addr:d,collection_name:h,nft:f,object_addr:g,chain:p})=>{if(s&&p.chainId!==s)return!1;if(e){const y=e.trim().toLowerCase();return d.toLowerCase().includes(y)||h.toLowerCase().includes(y)||f.token_id.toLowerCase().includes(y)||g.toLowerCase().includes(y)}return!0}),[a,s,e]),m=_.useMemo(()=>Array.from(new Set(a.map(({chain:d})=>d.chainId))),[a]);return c&&a.length===0?n.jsx(je,{children:"Loading NFTs..."}):!a.length&&!e&&!c?n.jsx(je,{children:"No NFTs"}):n.jsxs(gt.Root,{children:[n.jsxs(gt.Controls,{children:[n.jsx(gt.SearchInput,{value:e,onChange:d=>t(d.target.value),onClear:()=>t(""),placeholder:"Search NFTs"}),n.jsx(vo,{value:s,onChange:o,chainIds:m,renderExtra:d=>d?r[d]||0:i})]}),u.length===0?n.jsx(je,{children:"No NFTs found"}):n.jsx("div",{className:ni.grid,children:u.map(d=>{const{collection_addr:h,nft:f}=d;return n.jsx(lv,{nftInfo:d,children:g=>n.jsx(Za,{normalizedNft:g,onThumbnailClick:()=>l("/nft",g),classNames:ni})},h+f.token_id)})})]})},Nl=_.createContext(null);function Il(){return _.useContext(Nl)}const gv="_popup_nbecp_1",_v="_item_nbecp_19",qs={popup:gv,item:_v},Al=({asset:e,children:t})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:c,chain:l}=e,{chainId:u}=l,[m,d]=_.useState(!1),h=Me(),f=Il(),{showNotification:g}=hs(),{defaultChainId:p}=se(),{evm_chain_id:y}=xn(),x=Qe.useChainId(),{switchChainAsync:b}=Qe.useSwitchChain(),{watchAssetAsync:j}=Qe.useWatchAsset(),v=()=>{d(!1),h("/send",{denom:s,chain:l})},w=()=>{d(!1),h("/bridge",{srcChainId:u,srcDenom:s,quantity:""})},C=E.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const I=r;return await b({chainId:Number(y)}),j({type:"ERC20",options:{address:c,symbol:a,decimals:o,image:I}})},onSuccess:()=>{g({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:I=>{g({type:"error",title:"Asset addition failed",description:I.message})}});return n.jsxs(Rt.Menu.Root,{open:m,onOpenChange:d,modal:!1,children:[n.jsx(Rt.Menu.Trigger,{render:t}),n.jsx(Rt.Menu.Portal,{container:f,children:n.jsx(Rt.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:n.jsxs(Rt.Menu.Popup,{className:qs.popup,children:[n.jsxs(Rt.Menu.Item,{className:qs.item,onClick:v,children:[n.jsx(M.IconArrowRight,{size:16}),n.jsx("span",{children:"Send"})]}),n.jsxs(Rt.Menu.Item,{className:qs.item,onClick:w,disabled:i,children:[n.jsx(M.IconSwap,{size:16}),n.jsx("span",{children:"Bridge/Swap"})]}),u===p&&y===x&&!!c&&n.jsxs(Rt.Menu.Item,{className:qs.item,onClick:()=>C.mutate(),disabled:C.isPending||C.data,children:[C.data?n.jsx(M.IconCheck,{size:16}):n.jsx(M.IconPlus,{size:16}),n.jsx("span",{children:"Add to Wallet"})]})]})})})]})},yv="_item_38qhm_1",xv="_info_38qhm_23",bv="_images_38qhm_29",wv="_name_38qhm_33",vv="_value_38qhm_39",jv="_amount_38qhm_47",Cv="_usd_38qhm_53",an={item:yv,info:xv,images:bv,name:wv,value:vv,amount:jv,usd:Cv},kv=({asset:e})=>{const{amount:t,value:s,logoUrl:o,chain:a}=e,r=k.formatAmount(t,{decimals:e.decimals});return n.jsx(Al,{asset:e,children:n.jsxs("button",{className:an.item,children:[n.jsxs("div",{className:an.info,children:[n.jsx(_o,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:an.images}),n.jsx("span",{className:an.name,children:a.name})]}),n.jsxs("div",{className:an.value,children:[n.jsx("span",{className:an.amount,children:r}),Number(s)>0&&n.jsx("span",{className:an.usd,children:ae(s)})]})]})})},Nv="_container_ytg3p_1",Iv="_assetItem_ytg3p_6",Av="_expandIcon_ytg3p_22",Sv="_assetInfo_ytg3p_27",Tv="_logo_ytg3p_33",Ev="_details_ytg3p_37",$v="_symbol_ytg3p_42",Mv="_chainName_ytg3p_53",Lv="_chainInfos_ytg3p_59",qv="_chainLogos_ytg3p_65",Rv="_chainLogo_ytg3p_65",Pv="_moreChains_ytg3p_76",Dv="_expanded_ytg3p_93",Bv="_valueColumn_ytg3p_98",Fv="_amount_ytg3p_108",Uv="_value_ytg3p_98",Ov="_collapsibleContent_ytg3p_121",Vv="_chainsList_ytg3p_151",Te={container:Nv,assetItem:Iv,expandIcon:Av,assetInfo:Sv,logo:Tv,details:Ev,symbol:$v,chainName:Mv,chainInfos:Lv,chainLogos:qv,chainLogo:Rv,moreChains:Pv,expanded:Dv,valueColumn:Bv,amount:Fv,value:Uv,collapsibleContent:Ov,chainsList:Vv},Kv=H.atom([]),Xa=({assetGroup:e})=>{const{symbol:t,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=H.useAtom(Kv),c=_.useMemo(()=>Ed(e),[e]),l=_.useMemo(()=>mc(e),[e]),u=r.includes(t),m=()=>{i(h=>u?h.filter(f=>f!==t):[...new Set([...h,t])])},d=()=>n.jsxs("button",{className:Te.assetItem,children:[n.jsxs("div",{className:Te.assetInfo,children:[s&&n.jsx(re,{src:s,width:32,height:32,className:Te.logo,logo:!0}),n.jsxs("div",{className:Te.details,children:[n.jsx("div",{className:Te.symbol,children:t}),a?n.jsx("div",{className:Te.chainName,children:o[0].chain.name}):n.jsxs("div",{className:Te.chainInfos,children:[n.jsx("div",{className:Te.chainLogos,children:o.slice(0,5).map(({chain:h})=>n.jsx(re,{src:h.logoUrl,width:16,height:16,className:Te.chainLogo,logo:!0},h.chainId))}),o.length>5&&n.jsxs("span",{className:Te.moreChains,children:["+",o.length-5]}),n.jsx(M.IconChevronDown,{size:16,className:B(Te.expandIcon,{[Te.expanded]:u})})]})]})]}),n.jsxs("div",{className:Te.valueColumn,children:[n.jsx("div",{className:Te.amount,children:k.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&n.jsx("div",{className:Te.value,children:ae(l)})]})]});if(a){const[h]=o;return n.jsx("div",{className:Te.container,children:n.jsx(Al,{asset:h,children:d()})})}return n.jsx("div",{className:Te.container,children:n.jsxs(te.Collapsible.Root,{open:u,onOpenChange:m,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:d()}),n.jsx(te.Collapsible.Content,{className:Te.collapsibleContent,children:n.jsx("div",{className:Te.chainsList,children:o.map(h=>n.jsx(kv,{asset:h},h.chain.chainId))})})]})})},Wv="_collapsible_1g7rh_1",zv="_trigger_1g7rh_5",Hv="_divider_1g7rh_20",Qv="_label_1g7rh_28",Gv="_chevron_1g7rh_33",Yv="_content_1g7rh_41",Zv="_list_1g7rh_45",Kt={collapsible:Wv,trigger:zv,divider:Hv,label:Qv,chevron:Gv,content:Yv,list:Zv},Sl=({unlistedAssets:e})=>{const[t,s]=_.useState(!1),o=Il(),a=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{if(a.current){const d=a.current.scrollHeight;i(d)}},[e]);const c=_.useRef(null),l=d=>{s(d),d&&c.current&&o?.current&&window.setTimeout(()=>{if(!c.current||!a.current||!o?.current)return;const h=o.current,f=h.getBoundingClientRect(),g=c.current.getBoundingClientRect(),p=a.current.scrollHeight;if(g.bottom+p>f.bottom){const x=g.top-f.top+h.scrollTop-16;h.scrollTo({top:x,behavior:"smooth"})}},50)},u=Nt.useSpring({height:t?r:0,opacity:t?1:0,config:{tension:500,friction:30,clamp:!0}}),m=_.useMemo(()=>e.map(d=>({...d,assets:[d],totalValue:d.value??0,totalAmount:Number(d.quantity)})),[e]);return e.length===0?null:n.jsxs(te.Collapsible.Root,{open:t,onOpenChange:l,className:Kt.collapsible,children:[n.jsxs(te.Collapsible.Trigger,{ref:c,className:Kt.trigger,children:[n.jsx("div",{className:Kt.divider}),n.jsxs("span",{className:Kt.label,children:["Unlisted assets (",e.length,")"]}),n.jsx(M.IconChevronDown,{className:Kt.chevron,size:12,"data-state":t?"open":"closed"}),n.jsx("div",{className:Kt.divider})]}),n.jsx(te.Collapsible.Content,{forceMount:!0,asChild:!0,children:n.jsx(Nt.animated.div,{className:Kt.content,style:u,children:n.jsx("div",{className:Kt.list,ref:a,children:m.map(d=>n.jsx(Xa,{assetGroup:d},d.assets[0].denom))})})})]})},Jv="_container_15xfg_1",Xv="_header_15xfg_7",ej="_title_15xfg_13",tj="_totalValue_15xfg_19",nj="_list_15xfg_26",Tn={container:Jv,header:Xv,title:ej,totalValue:tj,list:nj},sj=()=>{const[e,t]=H.useAtom(jl),[s,o]=H.useAtom(Cl),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:c,isLoading:l}=Ta(),u=i.map(({chainId:h})=>h),m=_.useMemo(()=>{const h=e?a.filter(g=>{const{symbol:p,assets:y}=g;return p.toLowerCase().includes(e.toLowerCase())||y.some(({denom:x,address:b})=>x.toLowerCase().includes(e.toLowerCase())||b?.toLowerCase().includes(e.toLowerCase()))}):a;return s?h.map(g=>({...g,assets:g.assets.filter(({chain:p})=>p.chainId===s)})).filter(g=>g.assets.length>0):h},[a,e,s]),d=_.useMemo(()=>{const h=e?r.filter(({denom:g,address:p})=>g.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):r;return s?h.filter(({chain:g})=>g.chainId===s):h},[r,e,s]);return l&&a.length===0?n.jsx(je,{children:"Loading assets..."}):!m.length&&!d.length&&!e&&!s&&!l?n.jsx(je,{children:"No assets"}):n.jsxs(gt.Root,{children:[n.jsxs(gt.Controls,{children:[n.jsx(gt.SearchInput,{value:e,onChange:h=>t(h.target.value),onClear:()=>t(""),placeholder:"Search assets"}),n.jsx(vo,{value:s,onChange:o,chainIds:u,renderExtra:h=>{if(!h)return ae(c);const f=i.find(g=>g.chainId===h);return f?ae(f.value):null}})]}),n.jsx("div",{children:m.length===0&&d.length===0?n.jsx(je,{children:"No assets found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Tn.list,children:m.map(h=>n.jsx(Xa,{assetGroup:h},h.symbol))}),n.jsx(Sl,{unlistedAssets:d})]})})]})},oj="_container_11k2x_1",aj={container:oj},Ct=({height:e,length:t=1,width:s="100%"})=>{const o=Array.from({length:t},(a,r)=>r);return t===1?n.jsx(pn,{height:e,width:s}):n.jsx("div",{className:aj.container,"aria-hidden":"true",children:o.map(a=>n.jsx(pn,{height:e,width:s},a))})},rj=_.memo(({searchQuery:e,selectedChain:t,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:c}=ms(),l=ce(),{listedGroups:u,unlistedAssets:m}=_.useMemo(()=>Hm(i,a,r,l.chainId),[i,a,r,l.chainId]),d=_.useMemo(()=>Vm(u,s,o),[u,s,o]),{filteredAssets:h,totalAssetsValue:f,filteredUnlistedAssets:g}=_.useMemo(()=>zm(d,m,e,t),[d,m,e,t]);return n.jsxs("div",{className:Tn.container,children:[n.jsxs("div",{className:Tn.header,children:[n.jsx("span",{className:Tn.title,children:"Assets"}),h.length>0&&n.jsx("span",{className:Tn.totalValue,children:ae(f)})]}),h.length>0?n.jsxs("div",{children:[n.jsx("div",{className:Tn.list,children:h.map(p=>n.jsx(Xa,{assetGroup:p},p.symbol))}),n.jsx(Sl,{unlistedAssets:g})]}):d.length===0&&c?n.jsx(Ct,{height:56,length:3}):n.jsx(je,{children:"No liquid assets"})]})}),ij="_container_1n61l_1",cj="_section_1n61l_7",lj="_sectionHeader_1n61l_19",uj="_sectionTitle_1n61l_25",dj="_sectionLabel_1n61l_31",mj="_externalLink_1n61l_37",hj="_sectionValue_1n61l_49",fj="_tokenList_1n61l_56",pj="_stakingTokenList_1n61l_62",gj="_tokenRow_1n61l_72",_j="_tokenMain_1n61l_78",yj="_tokenTrigger_1n61l_84",xj="_tokenChevron_1n61l_100",bj="_expanded_1n61l_111",wj="_triggerValue_1n61l_115",vj="_tokenInfo_1n61l_122",jj="_tokenInfoLabel_1n61l_128",Cj="_tokenLogo_1n61l_134",kj="_tokenSymbol_1n61l_138",Nj="_tokenValues_1n61l_144",Ij="_tokenAmount_1n61l_150",Aj="_tokenValue_1n61l_144",Sj="_typeBreakdown_1n61l_164",Tj="_typeRow_1n61l_172",Ej="_typeLabel_1n61l_180",$j="_typeValues_1n61l_186",Mj="_typeAmount_1n61l_192",Lj="_typeValue_1n61l_186",qj="_collapsibleContent_1n61l_206",ne={container:ij,section:cj,sectionHeader:lj,sectionTitle:uj,sectionLabel:dj,externalLink:mj,sectionValue:hj,tokenList:fj,stakingTokenList:pj,tokenRow:gj,tokenMain:_j,tokenTrigger:yj,tokenChevron:xj,expanded:bj,triggerValue:wj,tokenInfo:vj,tokenInfoLabel:jj,tokenLogo:Cj,tokenSymbol:kj,tokenValues:Nj,tokenAmount:Ij,tokenValue:Aj,typeBreakdown:Sj,typeRow:Tj,typeLabel:Ej,typeValues:$j,typeAmount:Mj,typeValue:Lj,collapsibleContent:qj},Tl=({protocols:e,denomLogoMap:t,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=_.useMemo(()=>{const c=e.flatMap(l=>l.positions);return Mm(c)},[e]);return i.size===0?null:n.jsx("div",{className:ne.container,children:Array.from(i.entries()).map(([c,l])=>n.jsx(Rj,{sectionKey:c,sectionGroup:l,denomLogoMap:t,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},c))})},Rj=({sectionKey:e,sectionGroup:t,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:c,totalValue:l}=t,u=$m(e,o),m=_.useMemo(()=>Fm(c),[c]),d=e==="staking";return n.jsxs("section",{className:ne.section,"aria-label":u,children:[n.jsxs("div",{className:ne.sectionHeader,children:[n.jsxs("div",{className:ne.sectionTitle,children:[n.jsx("span",{className:ne.sectionLabel,children:u}),d&&a&&n.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:ne.externalLink,onClick:h=>h.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:ne.sectionValue,children:ae(l)})]}),n.jsx("div",{className:B(ne.tokenList,{[ne.stakingTokenList]:d}),children:m.map(h=>n.jsx(Pj,{group:h,showTypeBreakdown:d,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},h.denom))})]})},Pj=({group:e,showTypeBreakdown:t,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:c,totalValue:l,positions:u}=e,m=s.get(r),[d,h]=_.useState(!1),f=_.useMemo(()=>{if(!t)return null;const g=Dm(u);return g.size>0?g:null},[u,t]);return f?n.jsxs(te.Collapsible.Root,{open:d,onOpenChange:h,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:ne.tokenTrigger,children:[n.jsxs("div",{className:ne.tokenInfo,children:[n.jsx(M.IconChevronDown,{size:14,className:B(ne.tokenChevron,{[ne.expanded]:d}),"aria-hidden":"true"}),n.jsxs("div",{className:ne.tokenInfoLabel,children:[m?.assetLogo&&n.jsx(re,{src:m.assetLogo,width:20,height:20,className:ne.tokenLogo}),n.jsx("span",{className:ne.tokenSymbol,children:i})]})]}),n.jsx("span",{className:ne.triggerValue,children:ae(l)})]})}),n.jsx(te.Collapsible.Content,{className:ne.collapsibleContent,children:n.jsx(Dj,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):n.jsx("div",{className:ne.tokenRow,children:n.jsxs("div",{className:ne.tokenMain,children:[n.jsxs("div",{className:ne.tokenInfo,children:[m?.assetLogo&&n.jsx(re,{src:m.assetLogo,width:20,height:20,className:ne.tokenLogo}),n.jsx("span",{className:ne.tokenSymbol,children:i})]}),n.jsxs("div",{className:ne.tokenValues,children:[n.jsx("span",{className:ne.tokenAmount,children:k.formatNumber(c,{dp:6})}),n.jsx("span",{className:ne.tokenValue,children:ae(l)})]})]})})},Dj=({typeGroups:e,symbol:t,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=_.useMemo(()=>Array.from(e.entries()).map(([l,u])=>{const m=u.reduce((h,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?h:h+f.balance.formattedAmount,0),d=u.reduce((h,f)=>h+Ln(f),0);return{type:l,typeAmount:m,typeValue:d}}),[e]),i=_.useMemo(()=>{if(!o)return 0;let l=0;for(const{type:u}of r){const m=o(s,u);l+=Number(m)}return l},[s,o,r]),c=i>0;return n.jsxs("div",{className:ne.typeBreakdown,children:[r.map(({type:l,typeAmount:u,typeValue:m})=>n.jsxs("div",{className:ne.typeRow,children:[n.jsx("span",{className:ne.typeLabel,children:Pm(l)}),n.jsxs("div",{className:ne.typeValues,children:[n.jsxs("span",{className:ne.typeAmount,children:[k.formatNumber(u,{dp:6})," ",t]}),n.jsx("span",{className:ne.typeValue,children:ae(m)})]})]},l)),c&&n.jsxs("div",{className:ne.typeRow,children:[n.jsx("span",{className:ne.typeLabel,children:"Claimable rewards"}),n.jsxs("div",{className:ne.typeValues,children:[n.jsxs("span",{className:ne.typeAmount,children:[k.formatNumber(i,{dp:6})," ",pt]}),n.jsx("span",{className:ne.typeValue,children:ae(i*(a??0))})]})]})]})},Bj="_container_ymkoc_1",Fj="_trigger_ymkoc_6",Uj="_expandIcon_ymkoc_22",Oj="_chainInfo_ymkoc_27",Vj="_logo_ymkoc_33",Kj="_chainNameContainer_ymkoc_37",Wj="_chainName_ymkoc_37",zj="_externalLink_ymkoc_49",Hj="_externalIcon_ymkoc_53",Qj="_valueColumn_ymkoc_63",Gj="_value_ymkoc_63",Yj="_expanded_ymkoc_80",Zj="_collapsibleContent_ymkoc_85",Jj="_content_ymkoc_97",We={container:Bj,trigger:Fj,expandIcon:Uj,chainInfo:Oj,logo:Vj,chainNameContainer:Kj,chainName:Wj,externalLink:zj,externalIcon:Hj,valueColumn:Qj,value:Gj,expanded:Yj,collapsibleContent:Zj,content:Jj},Xj=H.atom([]),eC=({chainGroup:e})=>{const{chainId:t,chainLogo:s,protocols:o}=e,a=_e(),r=os(),{denomLogos:i,symbolLogos:c}=_.useMemo(()=>Da(r,a),[r,a]),l=_.useMemo(()=>{const u=new Map;for(const m of o)for(const d of m.positions){if(d.type==="fungible-position"||d.balance.type==="unknown")continue;const{denom:h,symbol:f}=d.balance,g=f.toUpperCase(),p=`${t}:${h}`,y=i.get(p)??c.get(g);y&&u.set(h,{assetLogo:y,chainLogo:s??""})}return u},[o,i,c,t,s]);return n.jsx(Tl,{protocols:o,denomLogoMap:l})},tC=({chainGroup:e})=>{const{chainName:t,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=H.useAtom(Xj),c=_.useMemo(()=>o.reduce((f,g)=>f+g.positions.reduce((p,y)=>p+Ln(y),0),0),[o]),l=["civitia","yominet"],u=r.includes(t),m=t?.toLowerCase(),d=l.includes(m),h=()=>{i(f=>u?f.filter(g=>g!==t):[...new Set([...f,t])])};return n.jsx("div",{className:We.container,children:n.jsxs(te.Collapsible.Root,{open:u,onOpenChange:h,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:We.trigger,children:[n.jsxs("div",{className:We.chainInfo,children:[s&&n.jsx(re,{src:s,width:32,height:32,className:We.logo,logo:!0}),n.jsxs("div",{className:We.chainNameContainer,children:[n.jsx("span",{className:We.chainName,children:t}),a&&n.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:We.externalLink,onClick:f=>f.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,className:We.externalIcon})})]})]}),n.jsxs("div",{className:We.valueColumn,children:[!d&&n.jsx("span",{className:We.value,children:ae(c)}),n.jsx(M.IconChevronDown,{size:16,className:B(We.expandIcon,{[We.expanded]:u})})]})]})}),n.jsx(te.Collapsible.Content,{className:We.collapsibleContent,children:n.jsx("div",{className:We.content,children:n.jsx(eC,{chainGroup:e})})})]})})},nC="_container_g7q2b_1",sC="_section_g7q2b_6",oC="_sectionHeader_g7q2b_14",aC="_sectionTitle_g7q2b_20",rC="_sectionLabel_g7q2b_26",iC="_externalLink_g7q2b_32",cC="_sectionValue_g7q2b_44",lC="_tokenList_g7q2b_51",uC="_tokenTrigger_g7q2b_63",dC="_tokenChevron_g7q2b_79",mC="_expanded_g7q2b_90",hC="_tokenInfo_g7q2b_94",fC="_tokenInfoLabel_g7q2b_100",pC="_tokenLogo_g7q2b_106",gC="_pairedLogos_g7q2b_110",_C="_coinLogo_g7q2b_115",yC="_tokenSymbol_g7q2b_133",xC="_triggerValue_g7q2b_139",bC="_clammBreakdownContent_g7q2b_146",wC="_clammPositionRow_g7q2b_154",vC="_statusDot_g7q2b_163",jC="_inRange_g7q2b_170",CC="_outRange_g7q2b_174",kC="_unknown_g7q2b_178",NC="_clammStatusValue_g7q2b_182",IC="_breakdownContent_g7q2b_192",AC="_breakdownRow_g7q2b_200",SC="_breakdownLabel_g7q2b_208",TC="_breakdownValues_g7q2b_214",EC="_breakdownAmount_g7q2b_220",$C="_breakdownValue_g7q2b_214",MC="_collapsibleContent_g7q2b_241",R={container:nC,section:sC,sectionHeader:oC,sectionTitle:aC,sectionLabel:rC,externalLink:iC,sectionValue:cC,tokenList:lC,tokenTrigger:uC,tokenChevron:dC,expanded:mC,tokenInfo:hC,tokenInfoLabel:fC,tokenLogo:pC,pairedLogos:gC,coinLogo:_C,tokenSymbol:yC,triggerValue:xC,clammBreakdownContent:bC,clammPositionRow:wC,statusDot:vC,inRange:jC,outRange:CC,unknown:kC,clammStatusValue:NC,breakdownContent:IC,breakdownRow:AC,breakdownLabel:SC,breakdownValues:TC,breakdownAmount:EC,breakdownValue:$C,collapsibleContent:MC},LC=({data:e,denomLogoMap:t})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:n.jsx("div",{className:R.container,children:n.jsxs("section",{className:R.section,"aria-label":"Liquidity positions",children:[n.jsxs("div",{className:R.sectionHeader,children:[n.jsxs("div",{className:R.sectionTitle,children:[n.jsx("span",{className:R.sectionLabel,children:"Liquidity"}),n.jsx("a",{href:va,target:"_blank",rel:"noopener noreferrer",className:R.externalLink,onClick:a=>a.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:R.sectionValue,children:ae(s)})]}),n.jsx("div",{className:R.tokenList,children:o.map(a=>n.jsx(UC,{row:a,denomLogoMap:t},a.denom))})]})})},qC={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"};function RC(e){return e===void 0?R.unknown:e?R.inRange:R.outRange}function PC(e){return e===void 0?"Status unavailable":e?"In range":"Out of range"}function si(e,t){return e===void 0?"-":`${k.formatNumber(e,{dp:6})} ${t}`}function El({isOpen:e,symbol:t,coinLogos:s,singleLogoUrl:o,rightContent:a}){const r=s&&s.length>0&&s.some(i=>i);return n.jsxs("button",{className:R.tokenTrigger,children:[n.jsxs("div",{className:R.tokenInfo,children:[n.jsx(M.IconChevronDown,{size:14,className:B(R.tokenChevron,{[R.expanded]:e}),"aria-hidden":"true"}),n.jsxs("div",{className:R.tokenInfoLabel,children:[r?n.jsx("div",{className:R.pairedLogos,children:s.map((i,c)=>n.jsx(re,{src:i,width:20,height:20,className:R.coinLogo,logo:!0},c))}):o&&n.jsx(re,{src:o,width:20,height:20,className:R.tokenLogo}),n.jsx("span",{className:R.tokenSymbol,children:t})]})]}),a]})}const DC=({position:e})=>{const t=RC(e.inRange),s=PC(e.inRange);return n.jsxs("div",{className:R.clammPositionRow,children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Position ID"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:e.positionId})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Deposit"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:ae(e.value)})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Status"}),n.jsxs("div",{className:R.clammStatusValue,children:[n.jsx("span",{className:B(R.statusDot,t)}),n.jsx("span",{children:s})]})]}),e.isFullRange?n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Range Bounds"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:"Full range"})})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Min"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:si(e.minPrice,e.pricePairLabel)})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Max"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:si(e.maxPrice,e.pricePairLabel)})})]})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:ae(e.rewardValue)})})]})]})},BC=({row:e,denomLogoMap:t})=>{const[s,o]=_.useState(!1),{denom:a,symbol:r,totalValue:i,coinLogos:c,logoUrl:l,clamm:u}=e,m=t.get(a);if(!u)return null;const d=l||m?.assetLogo;return n.jsxs(te.Collapsible.Root,{open:s,onOpenChange:o,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:El({isOpen:s,symbol:r,coinLogos:c,singleLogoUrl:d,rightContent:n.jsx("span",{className:R.triggerValue,children:ae(i)})})}),n.jsx(te.Collapsible.Content,{className:R.collapsibleContent,children:n.jsxs("div",{className:R.clammBreakdownContent,children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:ae(u.totalRewardValue)})})]}),u.positions.map(h=>n.jsx(DC,{position:h},h.tokenAddress))]})})]})},FC=({row:e,denomLogoMap:t})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:c,claimableInit:l}=e,[u,m]=_.useState(!1),d=t.get(s),h=i||d?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,g=_.useMemo(()=>Object.entries(r).filter(([,y])=>y>0),[r]),p=l&&Number(l.total)>0;return n.jsxs(te.Collapsible.Root,{open:u,onOpenChange:m,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:El({isOpen:u,symbol:o,coinLogos:c,singleLogoUrl:h,rightContent:n.jsx("span",{className:R.triggerValue,children:ae(a)})})}),n.jsx(te.Collapsible.Content,{className:R.collapsibleContent,children:n.jsxs("div",{className:R.breakdownContent,children:[g.map(([y,x])=>{const b=x*f;return n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:qC[y]}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[k.formatNumber(x,{dp:6})," LP"]}),n.jsx("span",{className:R.breakdownValue,children:ae(b)})]})]},y)}),p&&n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[k.formatNumber(Number(l.total),{dp:6})," ",pt]}),n.jsx("span",{className:R.breakdownValue,children:ae(l.totalValue)})]})]})]})})]})},UC=({row:e,denomLogoMap:t})=>e.clamm?n.jsx(BC,{row:e,denomLogoMap:t}):n.jsx(FC,{row:e,denomLogoMap:t}),OC="_container_1nijk_1",VC="_section_1nijk_6",KC="_sectionHeader_1nijk_14",WC="_sectionTitle_1nijk_20",zC="_sectionLabel_1nijk_26",HC="_externalLink_1nijk_32",QC="_sectionValue_1nijk_44",GC="_tokenList_1nijk_51",YC="_tokenTrigger_1nijk_63",ZC="_tokenChevron_1nijk_79",JC="_expanded_1nijk_90",XC="_tokenInfo_1nijk_94",ek="_tokenInfoLabel_1nijk_100",tk="_tokenLogo_1nijk_106",nk="_tokenName_1nijk_110",sk="_triggerValue_1nijk_116",ok="_breakdownContent_1nijk_123",ak="_breakdownRow_1nijk_131",rk="_breakdownLabel_1nijk_139",ik="_breakdownValues_1nijk_145",ck="_breakdownAmount_1nijk_151",lk="_breakdownValue_1nijk_145",uk="_collapsibleContent_1nijk_165",ge={container:OC,section:VC,sectionHeader:KC,sectionTitle:WC,sectionLabel:zC,externalLink:HC,sectionValue:QC,tokenList:GC,tokenTrigger:YC,tokenChevron:ZC,expanded:JC,tokenInfo:XC,tokenInfoLabel:ek,tokenLogo:tk,tokenName:nk,triggerValue:sk,breakdownContent:ok,breakdownRow:ak,breakdownLabel:rk,breakdownValues:ik,breakdownAmount:ck,breakdownValue:lk,collapsibleContent:uk},dk=({data:e})=>{const{totalValue:t,rows:s}=e;return s.length===0?null:n.jsx("div",{className:ge.container,children:n.jsxs("section",{className:ge.section,"aria-label":"VIP rewards",children:[n.jsxs("div",{className:ge.sectionHeader,children:[n.jsxs("div",{className:ge.sectionTitle,children:[n.jsx("span",{className:ge.sectionLabel,children:"VIP"}),n.jsx("a",{href:Bu,target:"_blank",rel:"noopener noreferrer",className:ge.externalLink,onClick:o=>o.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:ge.sectionValue,children:ae(t)})]}),n.jsx("div",{className:ge.tokenList,children:s.map(o=>n.jsx(mk,{row:o},`${o.bridgeId}-${o.version}`))})]})})},mk=({row:e})=>{const{name:t,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[c,l]=_.useState(!1),u=a+i;return n.jsxs(te.Collapsible.Root,{open:c,onOpenChange:l,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:ge.tokenTrigger,children:[n.jsxs("div",{className:ge.tokenInfo,children:[n.jsx(M.IconChevronDown,{size:14,className:B(ge.tokenChevron,{[ge.expanded]:c}),"aria-hidden":"true"}),n.jsxs("div",{className:ge.tokenInfoLabel,children:[s&&n.jsx(re,{src:s,width:20,height:20,className:ge.tokenLogo,logo:!0}),n.jsx("span",{className:ge.tokenName,children:t})]})]}),n.jsx("span",{className:ge.triggerValue,children:ae(u)})]})}),n.jsx(te.Collapsible.Content,{className:ge.collapsibleContent,children:n.jsxs("div",{className:ge.breakdownContent,children:[o>0&&n.jsxs("div",{className:ge.breakdownRow,children:[n.jsx("span",{className:ge.breakdownLabel,children:"Locked"}),n.jsxs("div",{className:ge.breakdownValues,children:[n.jsxs("span",{className:ge.breakdownAmount,children:[k.formatNumber(o,{dp:2})," INIT"]}),n.jsx("span",{className:ge.breakdownValue,children:ae(a)})]})]}),r>0&&n.jsxs("div",{className:ge.breakdownRow,children:[n.jsx("span",{className:ge.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:ge.breakdownValues,children:[n.jsxs("span",{className:ge.breakdownAmount,children:[k.formatNumber(r,{dp:2})," INIT"]}),n.jsx("span",{className:ge.breakdownValue,children:ae(i)})]})]})]})})]})},hk="_container_ymkoc_1",fk="_trigger_ymkoc_6",pk="_expandIcon_ymkoc_22",gk="_chainInfo_ymkoc_27",_k="_logo_ymkoc_33",yk="_chainNameContainer_ymkoc_37",xk="_chainName_ymkoc_37",bk="_externalLink_ymkoc_49",wk="_externalIcon_ymkoc_53",vk="_valueColumn_ymkoc_63",jk="_value_ymkoc_63",Ck="_expanded_ymkoc_80",kk="_collapsibleContent_ymkoc_85",Nk="_content_ymkoc_97",ze={container:hk,trigger:fk,expandIcon:pk,chainInfo:gk,logo:_k,chainNameContainer:yk,chainName:xk,externalLink:bk,externalIcon:wk,valueColumn:vk,value:jk,expanded:Ck,collapsibleContent:kk,content:Nk},Ik=H.atom(!1),Ak=()=>{const{totalValue:e}=Pa(),{totalValue:t}=co(),{totalValue:s}=lo(),o=e+t+s;return n.jsx("span",{className:ze.value,children:ae(o)})},Sk=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Pa(),{data:i}=wc(),{data:c}=vc(),l=_.useMemo(()=>{const d=new Map;for(const h of r){if(h.type==="fungible-position"||h.balance.type==="unknown")continue;const{denom:f,symbol:g}=h.balance,p=g.toUpperCase(),y=`${e}:${f}`,x=s.get(y)??o.get(p);x&&d.set(f,{assetLogo:x,chainLogo:t})}return d},[r,s,o,e,t]),u=_.useMemo(()=>(d,h)=>{const f=k.denomToMetadata(d);if(h==="staking"){const g=i?.get(f);return g?k.fromBaseUnit(g.amount,{decimals:it}):"0"}if(h==="lockstaking"){const g=c?.get(f);return g?k.fromBaseUnit(g.amount,{decimals:it}):"0"}return"0"},[i,c]),m=_.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:va,positions:r}],[r]);return m.length===0?null:n.jsx(Tl,{protocols:m,denomLogoMap:l,isInitia:!0,getClaimableInitByType:u,initPrice:a})},Tk=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o})=>{const a=co(),r=_.useMemo(()=>{const i=new Map;for(const c of a.rows){const{denom:l,symbol:u}=c,m=u.toUpperCase(),d=`${e}:${l}`,h=s.get(d)??o.get(m);h&&i.set(l,{assetLogo:h,chainLogo:t})}return i},[a.rows,s,o,e,t]);return a.rows.length===0?null:n.jsx(LC,{data:a,denomLogoMap:r})},Ek=()=>{const e=lo();return e.rows.length===0?null:n.jsx(dk,{data:e})},$k=({chainGroup:e})=>{const{chainId:t,chainName:s,chainLogo:o}=e,[a,r]=H.useAtom(Ik),i=_e(),c=os(),{denomLogos:l,symbolLogos:u}=_.useMemo(()=>Da(c,i),[c,i]),m=ce(),{data:d}=Pt(m),h=_.useMemo(()=>d?.find(g=>g.id===Je)?.price??0,[d]);return n.jsx("div",{className:ze.container,children:n.jsxs(te.Collapsible.Root,{open:a,onOpenChange:r,children:[n.jsx(te.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:ze.trigger,children:[n.jsxs("div",{className:ze.chainInfo,children:[o&&n.jsx(re,{src:o,width:32,height:32,className:ze.logo,logo:!0}),n.jsxs("div",{className:ze.chainNameContainer,children:[n.jsx("span",{className:ze.chainName,children:s}),n.jsx("a",{href:va,target:"_blank",rel:"noopener noreferrer",className:ze.externalLink,onClick:f=>f.stopPropagation(),children:n.jsx(M.IconExternalLink,{size:12,className:ze.externalIcon})})]})]}),n.jsxs("div",{className:ze.valueColumn,children:[n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:16,width:60,length:1}),children:n.jsx(Ak,{})}),n.jsx(M.IconChevronDown,{size:16,className:B(ze.expandIcon,{[ze.expanded]:a})})]})]})}),n.jsx(te.Collapsible.Content,{className:ze.collapsibleContent,children:n.jsxs("div",{className:ze.content,children:[n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:36,length:2}),children:n.jsx(Sk,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:u,initPrice:h})}),n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:36,length:2}),children:n.jsx(Tk,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:u})}),n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:36,length:1}),children:n.jsx(Ek,{})})]})})]})})},Mk="_totalValue_1v2ca_1",Lk={totalValue:Mk},qk=({filteredChainGroups:e})=>{const{totalValue:t}=Pa(),{totalValue:s}=co(),{totalValue:o}=lo(),a=t+s+o,r=_.useMemo(()=>{const i=e.some(l=>l.isInitia);return e.reduce((l,u)=>u.isInitia?l:l+u.totalValue,0)+(i?a:0)},[e,a]);return n.jsx("span",{className:Lk.totalValue,children:ae(r)})},Rk="_container_1eubu_1",Pk="_header_1eubu_7",Dk="_title_1eubu_13",Bk="_list_1eubu_19",Fk="_skeletonWrapper_1eubu_24",Gn={container:Rk,header:Pk,title:Dk,list:Bk,skeletonWrapper:Fk},Uk=_.memo(({searchQuery:e,selectedChain:t,chainInfoMap:s})=>{const{positions:o,isLoading:a}=ms(),r=ce(),i=_.useMemo(()=>{const l=[];for(const m of o){if(!Array.isArray(m.positions))continue;const d=s.get(m.chainName.toLowerCase()),h=m.chainName.toLowerCase();if(t&&d?.chainId!==t||!m.positions.some(x=>x.positions.some(b=>b.type!=="fungible-position"))||e&&!h.includes(e.toLowerCase()))continue;const g=m.positions.filter(x=>e&&!x.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(x.positions)&&x.positions.length>0),p=r.chainId===d?.chainId,y=g.reduce((x,b)=>x+b.positions.reduce((j,v)=>j+Ln(v),0),0);l.push({chainId:d?.chainId??"",chainName:d?.prettyName??m.chainName,chainLogo:d?.logoUrl??"",protocols:g,isInitia:p,totalValue:y})}const u=["civitia","yominet"];return L.sortWith([L.descend(m=>m.isInitia??!1),L.ascend(m=>u.includes(m.chainName.toLowerCase())),L.descend(m=>m.totalValue??0),L.ascend(m=>m.chainName.toLowerCase())],l)},[o,s,e,t,r.chainId]),c=i.length>0;return n.jsxs("div",{className:Gn.container,children:[n.jsxs("div",{className:Gn.header,children:[n.jsx("span",{className:Gn.title,children:"Positions"}),c&&n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:16,width:60,length:1}),children:n.jsx(qk,{filteredChainGroups:i})})]}),c?n.jsx("div",{className:Gn.list,children:i.map(l=>l.isInitia?n.jsx(xe,{suspenseFallback:n.jsx("div",{className:Gn.skeletonWrapper,children:n.jsx(Ct,{height:56,length:1})}),children:n.jsx($k,{chainGroup:l})},l.chainName):n.jsx(tC,{chainGroup:l},l.chainName))}):o.length===0&&a?n.jsx(Ct,{height:56,length:3}):n.jsx(je,{children:"No positions"})]})}),Ok="_content_1w1ad_1",Vk={content:Ok},Kk=({selectedChain:e,setSelectedChain:t})=>{const{defaultChainId:s}=se(),o=ce(),a=eh(),{totalValue:r}=lo(),{chainIds:i,chainIdToValueMap:c,totalBalance:l}=_.useMemo(()=>{const u=new Map;let m=0;for(const h of a)u.set(h.chainId,h.totalBalance),m+=h.totalBalance;return r>0&&(u.set(o.chainId,(u.get(o.chainId)??0)+r),m+=r),{chainIds:L.sortWith([L.descend(h=>h===s),L.descend(h=>h===o.chainId),L.descend(h=>u.get(h)??0)],a.map(h=>h.chainId)),chainIdToValueMap:u,totalBalance:m}},[a,s,o,r]);return n.jsx(vo,{value:e,onChange:t,chainIds:i,renderExtra:u=>ae(u?c.get(u)??0:l)})},Wk=()=>{const[e,t]=H.useAtom(jl),[s,o]=H.useAtom(Cl),a=_e(),r=os(),{denomLogos:i,symbolLogos:c}=_.useMemo(()=>Da(r,a),[r,a]),l=_a(),u=_.useMemo(()=>kc(a,l),[a,l]),m=Xm();return n.jsxs(gt.Root,{children:[n.jsxs(gt.Controls,{children:[n.jsx(gt.SearchInput,{value:e,onChange:d=>t(d.target.value),onClear:()=>t(""),placeholder:"Search portfolio"}),n.jsx(xe,{suspenseFallback:n.jsx(pn,{height:44,width:132}),children:n.jsx(Kk,{selectedChain:s,setSelectedChain:o})})]}),n.jsxs("section",{className:Vk.content,"aria-label":"Assets and positions",children:[n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:48,length:5}),children:n.jsx(rj,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:c,chainInfoMap:m,chainPrices:u})}),n.jsx(xe,{suspenseFallback:n.jsx(Ct,{height:56,length:3}),children:n.jsx(Uk,{searchQuery:e,selectedChain:s,chainInfoMap:m})})]})]})},zk="_totalValue_5pf7e_1",Hk="_totalLabel_5pf7e_7",Qk="_totalAmount_5pf7e_13",Gk="_loading_5pf7e_18",Yk="_skeletonWrapper_5pf7e_23",Zk="_nav_5pf7e_28",Jk="_item_5pf7e_34",Xk="_tabs_5pf7e_59",eN="_tab_5pf7e_59",He={totalValue:zk,totalLabel:Hk,totalAmount:Qk,loading:Gk,skeletonWrapper:Yk,nav:Zk,item:Jk,tabs:Xk,tab:eN},tN=()=>{const{totalValue:e,isLoading:t}=Ta();return n.jsx("div",{className:B(He.totalAmount,{[He.loading]:t}),children:ae(e)})},nN=()=>{const e=th(),t=nh(),s=Cc(),o=e+s+t;return n.jsx("div",{className:He.totalAmount,children:ae(o)})},sN=()=>{Wc(),Zm();const e=Ba(),t=Me(),s=to(),o=_.useRef(null);return n.jsx(Nl.Provider,{value:o,children:n.jsxs(yt,{ref:o,children:[n.jsxs("div",{className:He.totalValue,children:[n.jsx("div",{className:He.totalLabel,children:"Total value"}),n.jsx(xe,{suspenseFallback:n.jsx("div",{className:He.skeletonWrapper,children:n.jsx(pn,{height:48,width:120})}),children:e?n.jsx(tN,{}):n.jsx(nN,{})})]}),n.jsxs("nav",{className:He.nav,"aria-label":"Quick actions",children:[n.jsxs(mn,{to:"/send",className:He.item,children:[n.jsx(M.IconSend,{size:20}),n.jsx("span",{children:"Send"})]}),n.jsxs(mn,{to:"/bridge",className:He.item,children:[n.jsx(M.IconBridge,{size:20}),n.jsx("span",{children:"Bridge/Swap"})]}),n.jsxs(mn,{to:"/receive",className:He.item,children:[n.jsx(M.IconQrCode,{size:20}),n.jsx("span",{children:"Receive"})]})]}),n.jsxs(Ut.Tabs.Root,{value:s,onValueChange:t,children:[n.jsxs(Ut.Tabs.List,{className:He.tabs,children:[n.jsx(Ut.Tabs.Tab,{className:He.tab,value:"/",children:e?"Assets":"Portfolio"}),n.jsx(Ut.Tabs.Tab,{className:He.tab,value:"/nfts",children:"NFTs"}),n.jsx(Ut.Tabs.Tab,{className:He.tab,value:"/activity",children:"Activity"})]}),n.jsx(Ut.Tabs.Panel,{value:"/",children:e?n.jsx(sj,{}):n.jsx(Wk,{})}),n.jsx(Ut.Tabs.Panel,{value:"/nfts",children:n.jsx(pv,{})}),n.jsx(Ut.Tabs.Panel,{value:"/activity",children:n.jsx(Zw,{})})]})]})})},oN="_root_th990_1",aN="_collectionName_th990_9",rN="_nftName_th990_13",iN="_chainInfo_th990_17",cN="_attributes_th990_21",lN="_title_th990_24",uN="_count_th990_29",dN="_item_th990_33",mN="_type_th990_39",hN="_value_th990_45",rn={root:oN,collectionName:aN,nftName:rN,chainInfo:iN,attributes:cN,title:lN,count:uN,item:dN,type:mN,value:hN},fN=()=>{const e=Me(),t=et(),{attributes:s}=t;return n.jsxs(Tt,{title:"NFT details",children:[n.jsx(Za,{normalizedNft:t,chainIconSize:14,classNames:rn}),n.jsx(Ae,{children:n.jsx(fe.White,{onClick:()=>e("/nft/send",t),sm:!0,children:"Send"})}),s&&n.jsxs("div",{className:rn.attributes,children:[n.jsxs("header",{className:rn.title,children:["Traits ",n.jsxs("span",{className:rn.count,children:["(",s.length,")"]})]}),n.jsx("div",{children:s.map(({trait_type:o,value:a})=>n.jsxs("div",{className:rn.item,children:[n.jsx("div",{className:rn.type,children:o}),n.jsx("div",{className:rn.value,children:a})]},o))})]})]})};function pN({balances:e,gasPrices:t,gas:s}){return t.map(({denom:o,amount:a})=>{const r=q(a).times(s).toFixed(0,q.ROUND_CEIL),i=e.find(c=>c.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>q(a).gte(o))}function gN({denom:e,balances:t,gasPrices:s,lastFeeDenom:o,gas:a}){const r=t.find(u=>u.denom===e)?.amount??"0",i=pN({balances:t,gasPrices:s,gas:a}),c=i.find(u=>u.denom===o);if(i.length===0)return r;if(e===o&&c){const u=q(r).minus(c.amount);return q.max(u,0).toString()}const l=i.find(u=>u.denom!==e)||i[0];if(!c&&e===l.denom){const u=q(r).minus(l.amount);return q.max(u,0).toString()}return q(r).toString()}const _N=({chain:e,onSelect:t})=>{const s=mu(e);return n.jsx(xs,{assets:s,onSelect:t})},yN=({afterSelect:e})=>{const{watch:t,setValue:s}=$e.useFormContext(),{chainId:o,denom:a}=t(),{chainId:r}=t(),[i,c]=_.useState(r),l=_t(i),u=_e(),m=d=>{if(o===i&&a===d){e();return}s("chainId",i),s("denom",d),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return n.jsxs(n.Fragment,{children:[n.jsx(fn.Stack,{children:n.jsx(fn,{chains:u,value:i,onSelect:c})}),n.jsx(xe,{suspenseFallback:n.jsx(xs.Placeholder,{}),children:n.jsx(_N,{chain:l,onSelect:m})},i)]})},xN="_fields_brpej_1",bN="_divider_brpej_11",oi={fields:xN,divider:bN},wN=qe.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),vN=()=>{const{address:e,initiaAddress:t,estimateGas:s,requestTxSync:o}=tt(),{register:a,watch:r,setValue:i,handleSubmit:c,formState:l}=$e.useFormContext(),{errors:u}=l,{chainId:m,denom:d,recipient:h,quantity:f,memo:g}=r(),p=_t(m),y=as(p),x=Ia(p),b=Aa(p),j=bi(d,p),{data:v}=Pt(p),{decimals:w}=j,C=y.find(O=>O.denom===d)?.amount??"0",I=v?.find(({id:O})=>O===d)?.price,{data:T=0,isLoading:A}=E.useQuery({queryKey:wN.gas({chainId:m,denom:d,recipient:h,initiaAddress:t}).queryKey,queryFn:()=>{const O=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:cr.MsgSend.fromPartial({fromAddress:t,toAddress:k.InitiaAddress(h).bech32,amount:[{denom:d,amount:"1"}]})}];return s({messages:O,chainId:m})},enabled:k.InitiaAddress.validate(h),staleTime:V.INFINITY}),$=Math.ceil(T*Ht),N=gN({denom:d,balances:y,gasPrices:x,lastFeeDenom:b,gas:$}),S=q(C).isZero(),F=x.some(({denom:O})=>O===d)&&A,D=S||F,{mutate:Z,isPending:K}=E.useMutation({mutationFn:({chainId:O,denom:J,quantity:Q,recipient:ee,memo:ue})=>{const ye=k.toBaseUnit(Q,{decimals:w}),me=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:cr.MsgSend.fromPartial({fromAddress:t,toAddress:k.InitiaAddress(ee).bech32,amount:[{denom:J,amount:ye}]})}];return o({messages:me,memo:ue,chainId:O,gas:T,gasAdjustment:Ht,gasPrices:x,spendCoins:[{denom:J,amount:ye}],internal:"/"})}}),W=_.useMemo(()=>{if(!f)return"Enter amount";if(u.quantity)return u.quantity.message;if(!h)return"Enter recipient address";if(u.recipient)return u.recipient.message;if(u.memo)return u.memo.message},[f,h,u.quantity,u.recipient,u.memo]);return n.jsx(Tt,{title:"Send",children:n.jsxs("form",{onSubmit:c(O=>Z(O)),"aria-label":"Send token form",children:[n.jsxs("div",{className:oi.fields,children:[n.jsx(na,{selectButton:n.jsx(qn,{title:"Select chain and asset",content:O=>n.jsx(yN,{afterSelect:O}),children:n.jsx(Jc,{asset:j,chain:p})}),quantityInput:n.jsx(ns,{balance:C,decimals:w}),balanceButton:n.jsx(zc,{onClick:()=>i("quantity",k.fromBaseUnit(N,{decimals:w}),{shouldValidate:!0}),disabled:D,children:k.formatAmount(C??"0",{decimals:w})}),value:f?Ua(q(f).times(I??0),I):"$0"}),n.jsx("div",{className:oi.divider}),n.jsx(Wa,{myAddress:e}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),n.jsx("input",{...a("memo",{validate:O=>!O||new Blob([O]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),n.jsx(we.Stack,{children:!g&&n.jsx(we,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),n.jsx(Ae,{children:n.jsx(fe.White,{type:"submit",loading:(A?"Estimating gas...":!1)||K,disabled:!!W,children:W??"Confirm"})})]})})},jN=()=>{const e=et(),t=xn(),s=Qt(t),{chain:o=t}=e,a=L.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 n.jsx($e.FormProvider,{...i,children:n.jsx(vN,{})})};async function da(e,t){const s=e.replace("ibc/",""),{class_trace:o}=await z.create({prefixUrl:t}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function CN(e,t){const s=new kt.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await z.create({prefixUrl:t}).post("minievm/evm/v1/call",{json:{sender:k.InitiaAddress("0x1").bech32,contract_addr:k.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function kN(e,t,s){if(t.startsWith("evm/"))return e;const{token_infos:o}=await z.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${t}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function NN({collection_addr:e},{restUrl:t}){const s=await CN(e,t);if(!s.startsWith("ibc/"))return{class_id:`evm/${k.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await da(s,t);return o?{class_id:s,class_trace:o}:{class_id:`evm/${k.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function IN(e,t){const{data:s}=await z.create({prefixUrl:t}).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 AN({object_addr:e,collection_addr:t},{restUrl:s}){const o=await IN(t,s);return o.startsWith("ibc/")?k.InitiaAddress.equals(k.createObjectAddress("0x1",o),t)?{class_id:o,class_trace:await da(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await da(o,s)}:{class_id:`move/${t.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function SN(e,t){const s=de.toBase64(ln.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await z.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function TN(e,t){const{collection:s}=await z.create({prefixUrl:t}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function EN(e,t){const s=de.toBase64(ln.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function ai(e){const t=/^(.*channel-\d+)\/(.*)$/,s=e.match(t);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,o,a]=s;return[o,a]}async function $N({collection_addr:e},t,s){const o=k.InitiaAddress(e).bech32,a=await SN(o,t.restUrl),r=t.metadata?.ibc_channels?.find(({chain_id:p,version:y})=>p===s.chain_id&&y.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,c=i.split(".")[1],l=de.toBase64(ln.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:u}=await z.create({prefixUrl:t.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),m=u??o,d=await EN(c,t.restUrl),h=await TN(o,t.indexerUrl);if(m===o)return{class_id:m,class_trace:void 0,outgoing_proxy:d};if(u&&h!==i.replace("wasm.","")){const[p,y]=ai(u);return{class_id:o,class_trace:{path:p,base_class_id:y},outgoing_proxy:d}}const[f,g]=ai(a);return{class_id:o,class_trace:{path:f,base_class_id:g},outgoing_proxy:d}}const MN={minimove:AN,minievm:NN,miniwasm:$N};async function LN({nft:e,srcChain:t,intermediaryChain:s}){const o=t.metadata?.is_l1?"minimove":t.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const a=await MN[o](e,t,s);return Object.assign(a,o==="minievm"&&{token_ids:await kN([e.token_id],a.class_id,t.restUrl)})}const qN="_root_1tyvn_1",RN="_collectionName_1tyvn_10",PN="_nftName_1tyvn_15",DN="_chainInfo_1tyvn_19",BN="_fields_1tyvn_24",FN="_chain_1tyvn_19",Go={root:qN,collectionName:RN,nftName:PN,chainInfo:DN,fields:BN,chain:FN},UN=qe.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),ON=()=>{const e=_e(),t=et(),{chain:s,collection_addr:o}=t,{routerApiUrl:a}=se(),r=bn(),i=ce(),{address:c,initiaAddress:l,requestTxSync:u}=tt(),{watch:m,setValue:d,handleSubmit:h,formState:f}=$e.useFormContext(),{errors:g}=f,p=m(),{recipient:y,dstChainId:x}=p,b=_t(x),j=E.useQuery({queryKey:UN.simulation({collection_addr:o,nft:t,sender:l,recipient:y,srcChain:s,dstChain:b,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const N=Object.assign({from_address:l,from_chain_id:s.chainId,to_address:k.InitiaAddress(y).bech32,to_chain_id:b.chainId,collection_address:o,token_ids:[t.token_id],object_addresses:[t.object_addr]},s.chainId!==b.chainId&&await LN({nft:t,srcChain:s,intermediaryChain:i})),{msgs:S}=await z.create({prefixUrl:a}).post("nft",{json:N}).json();return S.map(P=>r.fromAmino(P))},enabled:k.InitiaAddress.validate(y)}),{data:v,isLoading:w,error:C}=j,I=E.useQueryClient(),{mutate:T,isPending:A}=E.useMutation({mutationFn:async()=>{if(!v)throw new Error("Route not found");await u({messages:v,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{I.invalidateQueries({queryKey:Ja.nfts._def})}}),$=_.useMemo(()=>{if(!y)return"Enter recipient address";if(g.recipient)return g.recipient.message;if(C)return"Route not found"},[y,g.recipient,C]);return n.jsxs("form",{onSubmit:h(()=>T()),children:[n.jsx(Za,{normalizedNft:t,thumbnailSize:80,classNames:Go}),n.jsxs("div",{className:Go.fields,children:[n.jsxs("div",{children:[n.jsx("div",{className:"label",children:"Destination app"}),n.jsxs(qn,{title:"Destination app",content:N=>n.jsx(Zc,{onSelect:({chainId:S})=>{d("dstChainId",S),N()},list:e,getImage:S=>S.logoUrl,getName:S=>S.name,getKey:S=>S.chainId}),className:B("input",Go.chain),children:[n.jsx(re,{src:b.logoUrl,width:20,height:20,logo:!0}),n.jsx("span",{children:b.name})]})]}),n.jsx(Wa,{myAddress:c,ref:gs()})]}),n.jsx(Ae,{children:n.jsx(fe.White,{loading:(w?"Finding route...":!1)||A,disabled:!!$,children:$??"Confirm"})})]})},VN=()=>{const{chain:e}=et(),t=$e.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return n.jsx(Tt,{title:"Send NFT",children:n.jsx($e.FormProvider,{...t,children:n.jsx(ON,{})})})},ma=()=>{const e=Me(),t=to(),s=Yt(),{closeDrawer:o}=Dt(),{closeModal:a}=ao();_.useEffect(()=>{a(),t.startsWith("/bridge/")&&t!=="/bridge/history"&&e("/bridge"),(t==="/collection"||t.startsWith("/nft"))&&e("/nfts")},[s]);const r=Pn();if(_.useEffect(()=>{r("Page View")},[t,r]),t==="/connect")return s?null:n.jsx(Wr,{onSuccess:o});if(t==="/blank")return null;if(!s)return n.jsx(Wr,{});switch(t){case"/":case"/nfts":case"/activity":return n.jsx(sN,{});case"/send":return n.jsx(jN,{},s);case"/receive":return n.jsx(Nb,{});case"/nft":return n.jsx(fN,{});case"/nft/send":return n.jsx(VN,{},s);case"/bridge":return n.jsx(Sy,{},s);case"/bridge/preview":return n.jsx(u1,{});case"/bridge/history":return n.jsx(Nx,{});case"/op/withdrawals":return n.jsx(P1,{});case"/tx":return n.jsx(Bc,{});case"/autosign/enable":return n.jsx(cg,{});case"/settings":return n.jsx(ew,{});case"/settings/autosign":return n.jsx(Ob,{});case"/deposit":return n.jsx(mb,{});case"/deposit/completed":return n.jsx(ua,{type:"deposit"});case"/withdraw":return n.jsx(hb,{});case"/withdraw/completed":return n.jsx(ua,{type:"withdraw"})}},KN="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",WN=()=>n.jsxs(n.Fragment,{children:[n.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),n.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),n.jsx("link",{rel:"stylesheet",href:KN}),n.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),zN=()=>(sh(),Lu(),ad(),_e(),Jm(),Cc(),os(),null),HN=({children:e,...t})=>(_.useEffect(()=>{Tm()},[]),Ge.useIsClient()?n.jsxs(n.Fragment,{children:[n.jsx(WN,{}),n.jsx(pi.Provider,{value:{...fi,...t},children:n.jsx(Ii,{children:n.jsx($p,{children:n.jsx(te.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:n.jsx(Ep,{children:n.jsxs(xp,{children:[e,n.jsx(oh,{}),n.jsx(xe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(zN,{})}),n.jsx(Yh,{children:n.jsx(ma,{})}),n.jsx(zh,{children:n.jsx(ma,{})})]})})})})})})]}):null),QN=({bridge:e})=>n.jsx(Ii,{initialEntry:{path:e?"/bridge":"/",state:e},children:n.jsx("div",{className:"body",children:n.jsx(Mc.Provider,{value:!!e,children:n.jsx(xe,{children:n.jsx(ma,{})})})})}),GN={1:"https://ethereum-rpc.publicnode.com",42161:"https://arbitrum-one-rpc.publicnode.com",8453:"https://base-rpc.publicnode.com"};function YN(e){const{id:t="testWallet",name:s="Test Wallet",rpcUrls:o,debug:a=!1,sendTransactionOverrides:r}=e;if("mnemonic"in e&&e.mnemonic==="")throw new Error("mnemonic must not be empty");if(!("mnemonic"in e&&e.mnemonic)&&!("privateKey"in e&&e.privateKey))throw new Error("Either mnemonic or privateKey is required");let i;try{i=e.mnemonic?lr.mnemonicToAccount(e.mnemonic):lr.privateKeyToAccount(e.privateKey)}catch(p){throw new Error(`[${t}] Failed to create account from ${e.mnemonic?"mnemonic":"privateKey"}`,{cause:p})}let c=1;const l={};function u(p,...y){l[p]?.forEach(x=>{x(...y)})}const m={...GN,...o},d={1:Gl.mainnet};function h(p){if(m[p])return m[p];const y=d[p];if(y)return y.rpcUrls.default.http[0];throw new Error(`[${t}] No RPC configured for chain ${p}`)}async function f(p,y){const x=h(c),b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:p,params:y??[]})});if(!b.ok)throw new Error(`[${t}] RPC "${p}" failed: HTTP ${b.status} ${b.statusText} (${x})`);let j;try{j=await b.json()}catch(v){throw new Error(`[${t}] RPC "${p}" returned non-JSON response (${x})`,{cause:v})}if(j.error)throw new ft.EIP1193ProviderRpcError(j.error.code,j.error.message);return j.result}const g={request:async({method:p,params:y})=>{switch(a&&console.log(`[${t}] ${p}`,y),p){case"eth_requestAccounts":case"eth_accounts":return[i.address];case"eth_chainId":return`0x${c.toString(16)}`;case"wallet_switchEthereumChain":{const[{chainId:x}]=y,b=Number(x);if(!d[b]&&!m[b])throw new ft.EIP1193ProviderRpcError(4902,"Unrecognized chain ID");return!d[b]&&m[b]&&(d[b]={id:b,name:`Chain ${b}`,nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[m[b]]}}}),c=b,u("chainChanged",x),null}case"wallet_addEthereumChain":{const[x]=y,b=x.rpcUrls?.[0];if(!b)throw new Error(`[${t}] wallet_addEthereumChain requires at least one RPC URL`);const j=Number(x.chainId);return d[j]?a&&console.log(`[${t}] Chain ${j} already registered, skipping`):d[j]={id:j,name:x.chainName??`Chain ${j}`,nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[b]}}},null}case"personal_sign":{const[x]=y;return i.signMessage({message:{raw:x}})}case"eth_signTypedData":case"eth_signTypedData_v4":{const[,x]=y;return i.signMessage({message:{raw:x}})}case"wallet_getPermissions":case"wallet_requestPermissions":return[{parentCapability:"eth_accounts"}];case"eth_sendTransaction":{const[x]=y,b=d[c];if(!b)throw new Error(`[${t}] No chain registered for chain ${c}. Call wallet_switchEthereumChain first.`);return ft.createWalletClient({account:i,chain:b,transport:ft.http(h(c))}).sendTransaction({to:x.to,value:x.value?BigInt(x.value):void 0,data:x.data,chainId:c,...r})}default:return f(p,y)}},on:(p,y)=>{(l[p]??=new Set).add(y)},removeListener:(p,y)=>{l[p]?.delete(y)},removeAllListeners:()=>{for(const p of Object.keys(l))delete l[p]}};return Yl.injected({target:()=>({id:t,name:s,provider:g})})}const ri={"noble-1":"noble",celestia:"celestia","neutron-1":"neutron","osmosis-1":"osmo"};function ZN(e){const{mnemonic:t,name:s="Test Cosmos Wallet",image:o,chains:a,debug:r=!1}=e;if(!t)throw new Error("mnemonic is required");const i=new Map;function c(d){return a?.[d]?a[d].prefix:ri[d]?ri[d]:d.replace(/-\d+$/,"")}function l(d){const h=c(d),f=i.get(h);if(f)return f;r&&console.log(`[${s}] Creating wallet for chain ${d} (prefix: ${h})`);const g=En.Secp256k1HdWallet.fromMnemonic(t,{prefix:h});return g.catch(p=>{i.delete(h),console.error(`[${s}] Failed to create wallet for prefix "${h}":`,p)}),i.set(h,g),g}function u(d){return{async getAccounts(){return(await l(d)).getAccounts()},async signAmino(h,f){return(await l(d)).signAmino(h,f)}}}const m={getOfflineSigner(d){return u(d)},getOfflineSignerOnlyAmino(d){return u(d)}};return{name:s,image:o,getProvider:()=>m}}exports.DEFAULT_GAS_ADJUSTMENT=Ht;exports.DEFAULT_GAS_PRICE_MULTIPLIER=hi;exports.InterwovenKit=QN;exports.InterwovenKitProvider=HN;exports.MAINNET=fi;exports.MoveError=nc;exports.PRIVY_APP_ID=ga;exports.TESTNET=Jl;exports.createTestCosmosWallet=ZN;exports.createTestWalletConnector=YN;exports.initiaPrivyWallet=eu;exports.initiaPrivyWalletConnector=Xl;exports.initiaPrivyWalletOptions=Jn;exports.injectStyles=vh;exports.useAddress=Yt;exports.useHexAddress=Bn;exports.useInitiaAddress=ie;exports.useInterwovenKit=tt;exports.usePortfolio=Ta;exports.useUsernameQuery=hc;