@initia/interwovenkit-react 2.0.2 → 2.0.4

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,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const lr=require("@privy-io/cross-app-connect/rainbow-kit"),fe=require("wagmi"),T=require("@tanstack/react-query"),b=require("@initia/utils"),vt=require("cosmjs-types/cosmos/tx/v1beta1/tx"),Ft=require("@cosmjs/amino"),Ae=require("@cosmjs/stargate"),H=require("jotai"),t=require("react/jsx-runtime"),y=require("ramda"),_=require("react"),Y=require("ky"),Ee=require("@lukemorales/query-key-factory"),He=require("ethers"),Eo=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),tn=require("@cosmjs/amino/build/signdoc"),sn=require("@cosmjs/crypto"),K=require("@cosmjs/encoding"),En=require("@cosmjs/math"),gs=require("@cosmjs/proto-signing"),qn=require("@cosmjs/tendermint-rpc"),Ot=require("@initia/amino-converter"),nn=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),qo=require("cosmjs-types/cosmos/auth/v1beta1/auth"),Do=require("cosmjs-types/google/protobuf/any"),dr=require("@amplitude/analytics-browser"),M=require("bignumber.js"),Po=require("@mysten/bcs"),Q=require("radix-ui"),be=require("usehooks-ts"),ur=require("react-error-boundary"),R=require("clsx"),Dn=require("nanoid"),Ro=require("react-dom"),Qe=require("@react-spring/web"),$=require("@initia/icons-react"),we=require("@base-ui-components/react/dialog"),xs=require("change-case"),qe=require("@base-ui-components/react/select"),Bo=require("qr-code-styling"),Mo=require("xss"),Oe=require("@base-ui-components/react/tabs"),bt=require("date-fns"),Fo=require("jotai/utils"),gt=require("@base-ui-components/react/popover"),Le=require("@base-ui-components/react"),re=require("react-hook-form"),Pn=require("cosmjs-types/cosmos/bank/v1beta1/tx"),hr=require("react-merge-refs"),Oo=require("react-intersection-observer"),Yt=require("@noble/hashes/utils"),Lo=require("@noble/hashes/sha3");function Uo(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(s,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return s.default=e,Object.freeze(s)}const fn=Uo(dr),Lt=1.4,mr=1.05,_r={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",theme:"dark"},zo={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",theme:"dark",disableAnalytics:!0},ys={id:"cmbq1ozyc006al70lx4uciz0q",name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Ko=lr.toPrivyWalletConnector(ys),Wo=lr.toPrivyWallet(ys),fr=_.createContext(null);function js(){return _.useContext(fr)}function pr(){const{location:e}=js();return e}function vs(){const{path:e}=pr();return e}function dt(){const{state:e={}}=pr();return e}function Ho(){const{history:e}=js();return e}function ce(){const{navigate:e}=js();return e}function gr(){const{reset:e}=js();return e}const xr=({children:e,initialEntry:s})=>{const[n,r]=_.useState([s??{path:"/"}]),o=n[n.length-1],a=_.useCallback((l,c)=>{r(d=>{if(typeof l=="string")return[...d,{path:l,state:c}];const u=d.length+l;if(u<1)return d;const h=y.take(u,d);return c!==void 0?y.adjust(u-1,m=>({...m,state:c}),h):h})},[]),i=_.useCallback((l,c)=>{r([{path:l,state:c}])},[]);return t.jsx(fr.Provider,{value:{location:o,history:n,navigate:a,reset:i},children:e})},pn=({to:e,state:s,shouldReset:n,children:r,onClick:o,...a})=>{const i=ce(),l=gr(),c=d=>{d.preventDefault(),o?.(d),n?l(e,s):i(e,s)};return t.jsx("button",{type:"button",...a,onClick:c,children:r})},yr=_.createContext(null),ws=()=>_.useContext(yr),jr=_.createContext(null);function le(){const e=_.useContext(jr);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}class vr extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(s,n,r,o,a,i,l){super(s),this.name="MoveError",this.originalError=n,this.moduleAddress=r,this.moduleName=o,this.errorCode=a,this.errorCodeHex=i,this.isFromRegistry=l}}const Qo=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Ms=new Map;function Vo(e){const s=e.match(Qo);if(!s)return null;const[,n,r,o]=s;return{moduleAddress:`0x${n.replace(/^0+/,"")||"0"}`,moduleName:r,errorCode:o.replace(/^0+/,"")||"0"}}async function Go(e,s,n){const r=`${e}:${s}`;if(Ms.has(r))return Ms.get(r);try{const o=s==="0x1"?"0x1.json":`${e}/${s}.json`,a=`${n}/errors/${o}`,{errors:i={}}=await Y.get(a).json();return Ms.set(r,i),i}catch{return null}}function Yo(e,s,n,r,o,a,i){return new vr(e,s,n,r,o,a,i)}async function cs(e,s,n){if(!s.metadata?.is_l1&&s.metadata?.minitia?.type!=="minimove")return e;const r=Vo(e.message);if(!r)return e;const o=await Go(s.chain_name,r.moduleAddress,n),a=`0x${parseInt(r.errorCode,10).toString(16)}`,i=`Failed with code ${a} in module ${r.moduleName} at ${r.moduleAddress}`,l=o?.[r.moduleName]?.[r.errorCode],c=l||i,d=!!l;return Yo(c,e,r.moduleAddress,r.moduleName,r.errorCode,a,d)}const U={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function Ge(e){if(e instanceof Y.HTTPError){const{response:s}=e,n=s.headers.get("content-type")??"";if(y.includes("application/json",n))try{const r=await s.json();if(r.message)return r.message}catch{return e.message}try{return await s.text()}catch{return e.message}}if(e instanceof Error){if(y.path(["code"],e)===4001||y.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const s=y.path(["error","message"],e),n=y.path(["cause","message"],e),r=y.path(["shortMessage"],e);return s||n||r||e.message}return String(e)}const gn=Ee.createQueryKeys("interwovenkit:chain",{list:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function Jt(e){const s=y.path([0,"address"],e);if(!s)throw new Error("URL not found");return s}function Jo(e){const{chain_id:s,chain_name:n,pretty_name:r,logo_URIs:o,apis:a,metadata:i}=e,l=r||n,c=o?.png??"",{rpc:d,rest:u,["json-rpc"]:h,indexer:m}=a,f=Jt(d),g=Jt(u),p=Jt(m),v=i?.minitia?.type==="minievm"?Jt(h):void 0;return{...e,chainId:s,name:l,logoUrl:c,rpcUrl:f,restUrl:g,indexerUrl:p,jsonRpcUrl:v}}function se(){const{defaultChainId:e,registryUrl:s,customChain:n}=le(),{data:r}=T.useSuspenseQuery({queryKey:gn.list(s).queryKey,queryFn:()=>Y.create({prefixUrl:s}).get("chains.json").json(),select:o=>(n?[n,...o.filter(i=>i.chain_id!==n.chain_id)]:o).map(Jo).toSorted(y.descend(i=>i.chainId===e)),staleTime:U.MINUTE});return r}function Ye(){const e=se();return s=>{const n=e.find(r=>r.chain_id===s);if(!n)throw new Error(`Chain not found: ${s}`);return n}}function Be(e){return Ye()(e)}function Kt(){const{defaultChainId:e}=le();return Be(e)}function pe(){const s=se().find(n=>n.metadata?.is_l1);if(!s)throw new Error("Layer 1 not found");return s}function wr(){return({chainId:e})=>T.queryOptions({queryKey:gn.prices(e).queryKey,queryFn:()=>Y.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:U.SECOND})}function bs(e){const s=wr();return T.useQuery(s(e))}function Zo(){const e=se(),s=wr();return T.useQueries({queries:e.map(n=>s(n))})}function Xo(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:s}=nn.PubKey.decode(e.value);return Ft.encodeSecp256k1Pubkey(s)}return gs.decodeOptionalPubkey(e)}function ea({typeUrl:e,value:s}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:n,pubKey:r,accountNumber:o,sequence:a}=qo.BaseAccount.decode(s),i=Xo(r);return{address:n,pubkey:i,accountNumber:Number(o),sequence:Number(a)}}return Ae.accountFromAny({typeUrl:e,value:s})}function ta(e){return e.type==="initia/PubKeyEthSecp256k1"}const sa={...Ft.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function na(e){if(ta(e)){const s=nn.PubKey.fromPartial({key:K.fromBase64(e.value)});return Do.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(nn.PubKey.encode(s).finish())})}return gs.encodePubkey(e)}function br(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:sa.ethsecp256k1,value:K.toBase64(e)}}function ra(e,s){if(s.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:br(e),signature:K.toBase64(s)}}const Ie="interwovenkit",F={PUBLIC_KEY:`${Ie}:public-key`,BRIDGE_SRC_CHAIN_ID:`${Ie}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${Ie}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${Ie}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${Ie}:bridge:dst-denom`,BRIDGE_QUANTITY:`${Ie}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${Ie}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${Ie}:bridge:route-type`,BRIDGE_HISTORY:`${Ie}:bridge:history`,OP_REMINDER:`${Ie}:op:reminder`},Cs=()=>{const e=le();return new gs.Registry([...Ot.protoRegistry,...e.protoTypes??[]])},Is=()=>{const e=le();return new Ae.AminoTypes({...Ot.aminoConverters,...e.aminoConverters})};class oa{constructor(s,n){this.address=s,this.signMessage=n}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const s=`${F.PUBLIC_KEY}:${this.address}`,n=localStorage.getItem(s);if(n)return this.cachedPublicKey=K.fromHex(n),K.fromHex(n);const r=await this.getPublicKey();return this.cachedPublicKey=r,localStorage.setItem(s,K.toHex(r)),r}async getPublicKey(){const s="Sign this message to identify your Initia account.",n=await this.signMessage(s),r=He.ethers.hashMessage(s),o=He.ethers.SigningKey.recoverPublicKey(r,n);return sn.Secp256k1.compressPubkey(K.fromHex(o.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(s,n){if(this.address!==s)throw new Error("Signer address does not match the provided address");const r=tn.escapeCharacters(tn.sortedJsonStringify(n)),o=await this.signMessage(r),a=K.fromHex(o.replace("0x","")).subarray(0,-1),l=sn.Secp256k1Signature.fromFixedLength(a).toFixedLength(),c=ra(await this.getCachedPublicKey(),l);return{signed:n,signature:c}}}function Cr(){const e=Cs(),s=Is(),n=Ct(),r=Nr();return async function(o,a,i,l,c){if(!n)throw new Error("Signer not initialized");const d=await r(o),{accountNumber:u,sequence:h}=await d.getSequence(a),[m]=await n.getAccounts(),f=na(br(m.pubkey)),g=Eo.SignMode.SIGN_MODE_EIP_191,p=i.map(x=>s.toAmino(x)),v=tn.makeSignDoc(p,l,o,c,u,h),{signature:k,signed:I}=await n.signAmino(a,v),w={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:I.msgs.map(x=>s.fromAmino(x)),memo:c}},j=e.encode(w),A=En.Int53.fromString(I.fee.gas).toNumber(),C=En.Int53.fromString(I.sequence).toNumber(),N=gs.makeAuthInfoBytes([{pubkey:f,sequence:C}],I.fee.amount,A,I.fee.granter,I.fee.payer,g);return vt.TxRaw.fromPartial({bodyBytes:j,authInfoBytes:N,signatures:[K.fromBase64(k.signature)]})}}function Ct(){const e=ne(),{signMessageAsync:s}=fe.useSignMessage();return _.useMemo(()=>new oa(e,n=>s({message:n})),[e,s])}const Fs=new Map,Os=new Map;function Ir(){const e=Ye();return async s=>{if(Fs.has(s))return Fs.get(s);const{rpcUrl:n}=e(s),r=await qn.Comet38Client.create(new qn.HttpClient(n));return Fs.set(s,r),r}}function Nr(){const e=Cs(),s=Is(),n=Ct(),r=ne(),o=Ir();return async a=>{const i=`${r}:${a}`;if(Os.has(i))return Os.get(i);if(!n)throw new Error("Signer not initialized");const l=await o(a),c=await Ae.SigningStargateClient.createWithSigner(l,n,{registry:e,aminoTypes:s,accountParser:ea,broadcastPollIntervalMs:1e3});return Os.set(i,c),c}}function Sr(){const{connector:e}=fe.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new He.BrowserProvider(await e.getProvider())}}const aa="c33b940c24c17e95f7d9d525d508ac61";function ia(){const{disableAnalytics:e}=le();_.useEffect(()=>{e||fn.init(aa,{autocapture:!1})},[e])}function ca(){const{connector:e}=fe.useAccount(),{defaultChainId:s,disableAnalytics:n}=le();_.useEffect(()=>{const r=new dr.Identify;e?.name&&r.set("connector",e.name),s&&r.set("defaultChainId",s),fn.identify(r)},[s,e?.name,n])}function Ns(){const e=vs();return _.useCallback((n,r)=>{fn.track(n,{path:e,...r})},[e])}const la=H.atom(!1);function It(){const e=gr(),[s,n]=H.useAtom(la),r=Ns();return{isDrawerOpen:s,openDrawer:(i,l)=>{i&&e(i,l),n(!0),r("Widget Opened")},closeDrawer:()=>{n(!1),r("Widget Closed")}}}function kr(){const e=ce(),{closeDrawer:s}=It(),{disconnect:n}=fe.useDisconnect();return()=>{e("/blank"),s(),n(),localStorage.removeItem(F.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(F.BRIDGE_SRC_DENOM),localStorage.removeItem(F.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(F.BRIDGE_DST_DENOM),localStorage.removeItem(F.BRIDGE_QUANTITY),localStorage.removeItem(F.BRIDGE_SLIPPAGE_PERCENT)}}const Ar="approve",Ss=H.atom(),$r=H.atom(null);function Tr(){const e=H.useAtomValue(Ss);if(!e)throw new Error("Tx request not found");return e}function Er(){const e=ce(),s=ne(),{defaultChainId:n,registryUrl:r}=le(),o=Ye(),{openDrawer:a,closeDrawer:i}=It(),{openModal:l,closeModal:c}=ws(),d=H.useSetAtom(Ss),u=H.useSetAtom($r),h=Ir(),m=Nr(),f=Ct(),g=Cs(),p=async({messages:j,memo:A,chainId:C=n})=>{try{return await(await m(C)).simulate(s,j,A)}catch(N){throw await cs(N,o(C),r)}},v=async({messages:j,memo:A,chainId:C=n})=>{const N=await h(C),x=Ae.QueryClient.withExtensions(N,Ae.setupTxExtension),P=j.map(D=>g.encodeAsAny(D)),[q]=await f.getAccounts(),B=Ft.encodeSecp256k1Pubkey(q.pubkey),S=await m(C),{sequence:O}=await S.getSequence(s);return x.tx.simulate(P,A,B,O)},k=async({txRequest:j,broadcaster:A})=>{const N={...{memo:"",chainId:n,gas:j.gas||await p(j),gasAdjustment:Lt,gasPrices:null,spendCoins:[],internal:!1},...j};return new Promise((x,P)=>{d({txRequest:N,resolve:async B=>{try{const S=await m(N.chainId),O=await A(S,vt.TxRaw.encode(B).finish());x(O),typeof N.internal=="string"&&e(N.internal)}catch(S){P(await cs(S,o(N.chainId),r))}finally{q()}},reject:B=>{P(B),q()}}),N.internal?l({path:"/tx"}):a("/tx");const q=()=>{if(!N.internal){e("/blank"),i();return}c()}})},I=async j=>{const A=j.chainId??n;try{const C=await k({txRequest:j,broadcaster:async(N,x)=>await N.broadcastTxSync(x)});return j.internal&&typeof j.internal!="number"&&(u({txHash:C,chainId:A,status:"loading"}),w({txHash:C,chainId:j.chainId}).then(N=>{u({status:N.code===0?"success":"error",chainId:A,txHash:C})}).catch(()=>{u({status:"error",chainId:A,txHash:C})})),C}catch(C){throw j.internal&&typeof j.internal!="number"&&u({status:"error",chainId:A,error:C}),C}},E=j=>k({txRequest:j,broadcaster:async(A,C)=>{const N=await A.broadcastTx(C);if(N.code!==0)throw new Error(N.rawLog);return N}}),w=async({chainId:j=n,...A})=>{try{const C=await m(j);return await qr({...A,client:C})}catch(C){throw await cs(C,o(j),r)}};return{estimateGas:p,simulateTx:v,requestTxSync:I,requestTxBlock:E,waitForTxConfirmation:w}}async function qr({txHash:e,client:s,timeoutSeconds:n=30,intervalSeconds:r=1}){const o=Date.now(),a=n*1e3;for(;;){const i=await s.getTx(e);if(i){if(i.code!==0)throw new Error(i.rawLog);return i}if(Date.now()-o>=a)throw new Error(`Transaction was submitted, but not found on the chain within ${n} seconds.`);await new Promise(l=>setTimeout(l,r*1e3))}}function da(e){return e.pagination?.next_key??null}async function Dr(e,s,n){const r=Y.create(s),o=async(a,i)=>{const l=await r.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[n]??[],d=da(l),u=[...a,...c];return d?o(u,d):u};return o([],null)}const ua=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _r=require("@privy-io/cross-app-connect/rainbow-kit"),xe=require("wagmi"),E=require("@tanstack/react-query"),N=require("@initia/utils"),Ve=require("cosmjs-types/cosmos/tx/v1beta1/tx"),Ut=require("@cosmjs/amino"),$e=require("@cosmjs/stargate"),Q=require("jotai"),t=require("react/jsx-runtime"),v=require("ramda"),f=require("react"),Z=require("ky"),qe=require("@lukemorales/query-key-factory"),Ye=require("ethers"),Bo=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),on=require("@cosmjs/amino/build/signdoc"),an=require("@cosmjs/crypto"),H=require("@cosmjs/encoding"),Bn=require("@cosmjs/math"),xs=require("@cosmjs/proto-signing"),Mn=require("@cosmjs/tendermint-rpc"),zt=require("@initia/amino-converter"),cn=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Mo=require("cosmjs-types/cosmos/auth/v1beta1/auth"),Fo=require("cosmjs-types/google/protobuf/any"),fr=require("@amplitude/analytics-browser"),M=require("bignumber.js"),Oo=require("@mysten/bcs"),G=require("radix-ui"),Ce=require("usehooks-ts"),pr=require("react-error-boundary"),R=require("clsx"),Fn=require("nanoid"),Lo=require("react-dom"),Je=require("@react-spring/web"),A=require("@initia/icons-react"),we=require("@base-ui-components/react/dialog"),ys=require("change-case"),De=require("@base-ui-components/react/select"),Uo=require("qr-code-styling"),zo=require("xss"),ze=require("@base-ui-components/react/tabs"),Nt=require("date-fns"),Ko=require("jotai/utils"),jt=require("@base-ui-components/react/popover"),Ke=require("@base-ui-components/react"),re=require("react-hook-form"),On=require("cosmjs-types/cosmos/bank/v1beta1/tx"),gr=require("react-merge-refs"),Ho=require("react-intersection-observer"),es=require("@noble/hashes/utils"),Wo=require("@noble/hashes/sha3");function Qo(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(s,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return s.default=e,Object.freeze(s)}const yn=Qo(fr),Kt=1.4,xr=1.05,yr={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",theme:"dark"},Vo={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",theme:"dark",disableAnalytics:!0},js={id:"cmbq1ozyc006al70lx4uciz0q",name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Go=_r.toPrivyWalletConnector(js),Yo=_r.toPrivyWallet(js),jr=f.createContext(null);function vs(){return f.useContext(jr)}function vr(){const{location:e}=vs();return e}function bs(){const{path:e}=vr();return e}function ht(){const{state:e={}}=vr();return e}function Jo(){const{history:e}=vs();return e}function ie(){const{navigate:e}=vs();return e}function br(){const{reset:e}=vs();return e}const wr=({children:e,initialEntry:s})=>{const[n,r]=f.useState([s??{path:"/"}]),o=n[n.length-1],a=f.useCallback((l,c)=>{r(d=>{if(typeof l=="string")return[...d,{path:l,state:c}];const u=d.length+l;if(u<1)return d;const h=v.take(u,d);return c!==void 0?v.adjust(u-1,m=>({...m,state:c}),h):h})},[]),i=f.useCallback((l,c)=>{r([{path:l,state:c}])},[]);return t.jsx(jr.Provider,{value:{location:o,history:n,navigate:a,reset:i},children:e})},jn=({to:e,state:s,shouldReset:n,children:r,onClick:o,...a})=>{const i=ie(),l=br(),c=d=>{d.preventDefault(),o?.(d),n?l(e,s):i(e,s)};return t.jsx("button",{type:"button",...a,onClick:c,children:r})},Cr=f.createContext(null),ws=()=>f.useContext(Cr),Ir=f.createContext(null);function ce(){const e=f.useContext(Ir);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const U={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function Zo(e){if(e instanceof Z.HTTPError){const{response:s}=e,n=s.headers.get("content-type")??"";if(v.includes("application/json",n))try{const r=await s.json();if(r.message)return r.message}catch{return e.message}try{return await s.text()}catch{return e.message}}if(e instanceof Error){if(v.path(["code"],e)===4001||v.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const s=v.path(["error","message"],e),n=v.path(["cause","message"],e),r=v.path(["shortMessage"],e);return s||n||r||e.message}return String(e)}async function Re(e){return new Error(await Zo(e))}class Nr extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(s,n,r,o,a,i,l){super(s),this.name="MoveError",this.originalError=n,this.moduleAddress=r,this.moduleName=o,this.errorCode=a,this.errorCodeHex=i,this.isFromRegistry=l}}const Xo=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Os=new Map;function ea(e){const s=e.match(Xo);if(!s)return null;const[,n,r,o]=s;return{moduleAddress:`0x${n.replace(/^0+/,"")||"0"}`,moduleName:r,errorCode:o.replace(/^0+/,"")||"0"}}async function ta(e,s,n){const r=`${e}:${s}`;if(Os.has(r))return Os.get(r);try{const o=s==="0x1"?"0x1.json":`${e}/${s}.json`,a=`${n}/errors/${o}`,{errors:i={}}=await Z.get(a).json();return Os.set(r,i),i}catch{return null}}function sa(e,s,n,r,o,a,i){return new Nr(e,s,n,r,o,a,i)}async function bt(e,s,n){if(!s.metadata?.is_l1&&s.metadata?.minitia?.type!=="minimove")return await Re(e);const r=ea(e.message);if(!r)return await Re(e);const o=await ta(s.chain_name,r.moduleAddress,n),a=`0x${parseInt(r.errorCode,10).toString(16)}`,i=`Failed with code ${a} in module ${r.moduleName} at ${r.moduleAddress}`,l=o?.[r.moduleName]?.[r.errorCode],c=l||i,d=!!l;return sa(c,e,r.moduleAddress,r.moduleName,r.errorCode,a,d)}const vn=qe.createQueryKeys("interwovenkit:chain",{list:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function ts(e){const s=v.path([0,"address"],e);if(!s)throw new Error("URL not found");return s}function na(e){const{chain_id:s,chain_name:n,pretty_name:r,logo_URIs:o,apis:a,metadata:i}=e,l=r||n,c=o?.png??"",{rpc:d,rest:u,["json-rpc"]:h,indexer:m}=a,_=ts(d),p=ts(u),g=ts(m),b=i?.minitia?.type==="minievm"?ts(h):void 0;return{...e,chainId:s,name:l,logoUrl:c,rpcUrl:_,restUrl:p,indexerUrl:g,jsonRpcUrl:b}}function se(){const{defaultChainId:e,registryUrl:s,customChain:n}=ce(),{data:r}=E.useSuspenseQuery({queryKey:vn.list(s).queryKey,queryFn:()=>Z.create({prefixUrl:s}).get("chains.json").json(),select:o=>(n?[n,...o.filter(i=>i.chain_id!==n.chain_id)]:o).map(na).toSorted(v.descend(i=>i.chainId===e)),staleTime:U.MINUTE});return r}function Ze(){const e=se();return s=>{const n=e.find(r=>r.chain_id===s);if(!n)throw new Error(`Chain not found: ${s}`);return n}}function Fe(e){return Ze()(e)}function Qt(){const{defaultChainId:e}=ce();return Fe(e)}function ye(){const s=se().find(n=>n.metadata?.is_l1);if(!s)throw new Error("Layer 1 not found");return s}function Sr(){return({chainId:e})=>E.queryOptions({queryKey:vn.prices(e).queryKey,queryFn:()=>Z.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:U.SECOND})}function Cs(e){const s=Sr();return E.useQuery(s(e))}function ra(){const e=se(),s=Sr();return E.useQueries({queries:e.map(n=>s(n))})}function oa(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:s}=cn.PubKey.decode(e.value);return Ut.encodeSecp256k1Pubkey(s)}return xs.decodeOptionalPubkey(e)}function aa({typeUrl:e,value:s}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:n,pubKey:r,accountNumber:o,sequence:a}=Mo.BaseAccount.decode(s),i=oa(r);return{address:n,pubkey:i,accountNumber:Number(o),sequence:Number(a)}}return $e.accountFromAny({typeUrl:e,value:s})}function ia(e){return e.type==="initia/PubKeyEthSecp256k1"}const ca={...Ut.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function la(e){if(ia(e)){const s=cn.PubKey.fromPartial({key:H.fromBase64(e.value)});return Fo.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(cn.PubKey.encode(s).finish())})}return xs.encodePubkey(e)}function kr(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:ca.ethsecp256k1,value:H.toBase64(e)}}function da(e,s){if(s.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:kr(e),signature:H.toBase64(s)}}const Ne="interwovenkit",O={PUBLIC_KEY:`${Ne}:public-key`,BRIDGE_SRC_CHAIN_ID:`${Ne}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${Ne}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${Ne}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${Ne}:bridge:dst-denom`,BRIDGE_QUANTITY:`${Ne}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${Ne}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${Ne}:bridge:route-type`,BRIDGE_HISTORY:`${Ne}:bridge:history`,OP_REMINDER:`${Ne}:op:reminder`},Is=()=>{const e=ce();return new xs.Registry([...zt.protoRegistry,...e.protoTypes??[]])},Ns=()=>{const e=ce();return new $e.AminoTypes({...zt.aminoConverters,...e.aminoConverters})};class ua{constructor(s,n){this.address=s,this.signMessage=n}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const s=`${O.PUBLIC_KEY}:${this.address}`,n=localStorage.getItem(s);if(n)return this.cachedPublicKey=H.fromHex(n),H.fromHex(n);const r=await this.getPublicKey();return this.cachedPublicKey=r,localStorage.setItem(s,H.toHex(r)),r}async getPublicKey(){const s="Sign this message to identify your Initia account.",n=await this.signMessage(s),r=Ye.ethers.hashMessage(s),o=Ye.ethers.SigningKey.recoverPublicKey(r,n);return an.Secp256k1.compressPubkey(H.fromHex(o.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(s,n){if(this.address!==s)throw new Error("Signer address does not match the provided address");const r=on.escapeCharacters(on.sortedJsonStringify(n)),o=await this.signMessage(r),a=H.fromHex(o.replace("0x","")).subarray(0,-1),l=an.Secp256k1Signature.fromFixedLength(a).toFixedLength(),c=da(await this.getCachedPublicKey(),l);return{signed:n,signature:c}}}function bn(){const e=Is(),s=Ns(),n=St(),r=$r();return async function(o,a,i,l,c,d){if(!n)throw new Error("Signer not initialized");const u=await r(o),{accountNumber:h,...m}=await u.getSequence(a),_=m.sequence+(d?.incrementSequence??0),[p]=await n.getAccounts(),g=la(kr(p.pubkey)),b=Bo.SignMode.SIGN_MODE_EIP_191,k=i.map(y=>s.toAmino(y)),S=on.makeSignDoc(k,l,o,c,h,_),{signature:T,signed:j}=await n.signAmino(a,S),B={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:j.msgs.map(y=>s.fromAmino(y)),memo:c}},P=e.encode(B),I=Bn.Int53.fromString(j.fee.gas).toNumber(),x=Bn.Int53.fromString(j.sequence).toNumber(),w=xs.makeAuthInfoBytes([{pubkey:g,sequence:x}],j.fee.amount,I,j.fee.granter,j.fee.payer,b);return Ve.TxRaw.fromPartial({bodyBytes:P,authInfoBytes:w,signatures:[H.fromBase64(T.signature)]})}}function St(){const e=ne(),{signMessageAsync:s}=xe.useSignMessage();return f.useMemo(()=>new ua(e,n=>s({message:n})),[e,s])}const Ls=new Map,Us=new Map;function Ar(){const e=Ze();return async s=>{if(Ls.has(s))return Ls.get(s);const{rpcUrl:n}=e(s),r=await Mn.Comet38Client.create(new Mn.HttpClient(n));return Ls.set(s,r),r}}function $r(){const e=Is(),s=Ns(),n=St(),r=ne(),o=Ar();return async a=>{const i=`${r}:${a}`;if(Us.has(i))return Us.get(i);if(!n)throw new Error("Signer not initialized");const l=await o(a),c=await $e.SigningStargateClient.createWithSigner(l,n,{registry:e,aminoTypes:s,accountParser:aa,broadcastPollIntervalMs:500});return Us.set(i,c),c}}function Tr(){const{connector:e}=xe.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new Ye.BrowserProvider(await e.getProvider())}}const ha="c33b940c24c17e95f7d9d525d508ac61";function ma(){const{disableAnalytics:e}=ce();f.useEffect(()=>{e||yn.init(ha,{autocapture:!1})},[e])}function _a(){const{connector:e}=xe.useAccount(),{defaultChainId:s,disableAnalytics:n}=ce();f.useEffect(()=>{const r=new fr.Identify;e?.name&&r.set("connector",e.name),s&&r.set("defaultChainId",s),yn.identify(r)},[s,e?.name,n])}function Ss(){const e=bs();return f.useCallback((n,r)=>{yn.track(n,{path:e,...r})},[e])}const fa=Q.atom(!1);function kt(){const e=br(),[s,n]=Q.useAtom(fa),r=Ss();return{isDrawerOpen:s,openDrawer:(i,l)=>{i&&e(i,l),n(!0),r("Widget Opened")},closeDrawer:()=>{n(!1),r("Widget Closed")}}}function Er(){const e=ie(),{closeDrawer:s}=kt(),{disconnect:n}=xe.useDisconnect();return()=>{e("/blank"),s(),n(),localStorage.removeItem(O.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(O.BRIDGE_SRC_DENOM),localStorage.removeItem(O.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(O.BRIDGE_DST_DENOM),localStorage.removeItem(O.BRIDGE_QUANTITY),localStorage.removeItem(O.BRIDGE_SLIPPAGE_PERCENT)}}const qr="approve",ks=Q.atom(),Dr=Q.atom(null);function Pr(){const e=Q.useAtomValue(ks);if(!e)throw new Error("Tx request not found");return e}function Rr(){const e=ie(),s=ne(),{defaultChainId:n,registryUrl:r}=ce(),o=Ze(),{openDrawer:a,closeDrawer:i}=kt(),{openModal:l,closeModal:c}=ws(),d=Q.useSetAtom(ks),u=Q.useSetAtom(Dr),h=Ar(),m=$r(),_=St(),p=Is(),g=async({messages:I,memo:x,chainId:w=n})=>{try{return await(await m(w)).simulate(s,I,x)}catch(y){throw await bt(y,o(w),r)}},b=async({messages:I,memo:x,chainId:w=n})=>{const y=await h(w),q=$e.QueryClient.withExtensions(y,$e.setupTxExtension),C=I.map(le=>p.encodeAsAny(le)),[F]=await _.getAccounts(),$=Ut.encodeSecp256k1Pubkey(F.pubkey),V=await m(w),{sequence:K}=await V.getSequence(s);return q.tx.simulate(C,x,$,K)},k=async({txRequest:I,broadcaster:x})=>{const y={...{memo:"",chainId:n,gas:I.gas||await g(I),gasAdjustment:Kt,gasPrices:null,spendCoins:[],internal:!1},...I};return new Promise((q,C)=>{d({txRequest:y,resolve:async $=>{try{const V=await m(y.chainId),K=await x(V,Ve.TxRaw.encode($).finish());q(K),typeof y.internal=="string"&&e(y.internal)}catch(V){C(await bt(V,o(y.chainId),r))}finally{F()}},reject:$=>{C($),F()}}),y.internal?l({path:"/tx"}):a("/tx");const F=()=>{if(!y.internal){e("/blank"),i();return}c()}})},S=async I=>{const x=I.chainId??n;try{const w=await k({txRequest:I,broadcaster:async(y,q)=>await y.broadcastTxSync(q)});return I.internal&&typeof I.internal!="number"&&(u({txHash:w,chainId:x,status:"loading"}),P({txHash:w,chainId:I.chainId}).then(y=>{u({status:y.code===0?"success":"error",chainId:x,txHash:w})}).catch(()=>{u({status:"error",chainId:x,txHash:w})})),w}catch(w){throw I.internal&&typeof I.internal!="number"&&u({status:"error",chainId:x,error:w}),w}},T=(I,x=30*1e3,w=.5*1e3)=>k({txRequest:I,broadcaster:async(y,q)=>{const C=await y.broadcastTx(q,x,w);if(C.code!==0)throw new Error(C.rawLog);return C}}),j=bn(),D=async I=>{const x=I.chainId??n;try{const{messages:w,memo:y="",fee:q}=I,C=await m(x),F=await j(x,s,w,q,y);return await C.broadcastTxSync(Ve.TxRaw.encode(F).finish())}catch(w){throw await bt(w,o(x),r)}},B=async(I,x=30*1e3,w=.5*1e3)=>{const y=I.chainId??n;try{const{messages:q,memo:C="",fee:F}=I,$=await m(y),V=await j(y,s,q,F,C),K=await $.broadcastTx(Ve.TxRaw.encode(V).finish(),x,w);if(K.code!==0)throw new Error(K.rawLog);return K}catch(q){throw await bt(q,o(y),r)}},P=async({chainId:I=n,...x})=>{try{const w=await m(I);return await Br({...x,client:w})}catch(w){throw await bt(w,o(I),r)}};return{estimateGas:g,simulateTx:b,requestTxSync:S,requestTxBlock:T,submitTxSync:D,submitTxBlock:B,waitForTxConfirmation:P}}async function Br({txHash:e,client:s,timeoutMs:n=30*1e3,intervalMs:r=.5*1e3}){const o=Date.now();for(;;){const a=await s.getTx(e);if(a){if(a.code!==0)throw new Error(a.rawLog);return a}if(Date.now()-o>=n)throw new Error(`Transaction was submitted, but not found on the chain within ${n/1e3} seconds.`);await new Promise(i=>setTimeout(i,r))}}function pa(e){return e.pagination?.next_key??null}async function Mr(e,s,n){const r=Z.create(s),o=async(a,i)=>{const l=await r.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[n]??[],d=pa(l),u=[...a,...c];return d?o(u,d):u};return o([],null)}const ga=`<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>`,ha=encodeURIComponent(ua),xn=`data:image/svg+xml;utf8,${ha}`,hs=Ee.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,s)=>[e,s],resource:(e,s)=>[e.chainId,s.denom],denom:(e,s)=>[e,s],metadata:(e,s)=>[e,s]});function ma(e){const{base:s,symbol:n,denom_units:r=[],display:o,logo_URIs:a,name:i,address:l,traces:c}=e,d=r.find(h=>h.denom===o)?.exponent??r.find(h=>h.denom===s)?.exponent??y.head(r)?.exponent??0,u=a?.png??"";return{denom:s,symbol:n,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function Pr(){const e=T.useQueryClient();return s=>{const n=s?.metadata?.assetlist;return T.queryOptions({queryKey:hs.list(n).queryKey,queryFn:async()=>n?Y.get(n).json():{assets:[]},select:({assets:r})=>{if(!s)return[];const o=r.map(ma);for(const a of o)e.setQueryData(hs.item(s.chainId,a.denom).queryKey,a);return o},staleTime:U.MINUTE})}}function Ut(e){const s=Pr(),{data:n}=T.useSuspenseQuery(s(e));return n}function _a(){const e=se(),s=Pr();return T.useQueries({queries:e.map(n=>s(n))})}function Je(e){const s=Ut(e),n=pe(),r=Ut(n),o=Br(e);return a=>{const i=s.find(c=>c.denom===a);if(i)return i;const l=r.find(c=>c.denom===o(a));return l?{...l,denom:a}:{denom:a,symbol:"",decimals:0,logoUrl:xn}}}function Rr(e,s){const n=Je(s),o=T.useQueryClient().getQueryData(hs.item(s.chainId,e).queryKey);return o||n(e)}function Br(e){const s=pe(),n=Ut(e);return r=>{if(e.metadata?.is_l1)return r;if(r.startsWith("l2/")||r.startsWith("ibc/")){const a=n.find(i=>i.denom===r)?.traces;if(a){for(const i of a)if(i.counterparty.chain_name===s.chain_name)return i.counterparty.base_denom}}const o=s.metadata?.ibc_channels?.find(({chain_id:a,version:i})=>a===e.chain_id&&i==="ics20-1")?.channel_id;return o?b.getIbcDenom(o,r):""}}const Rn="usernames";function fa({restUrl:e,moduleAddress:s}){const{viewFunction:n}=b.createMoveClient(e);async function r(i){if(!b.InitiaAddress.validate(i))return null;const l=await n({moduleAddress:s,moduleName:Rn,functionName:"get_name_from_address",typeArgs:[],args:[K.toBase64(b.InitiaAddress(i,32).bytes)]});return l?l+".init":null}function o(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function a(i){if(!o(i))return null;const l=await n({moduleAddress:s,moduleName:Rn,functionName:"get_address_from_name",typeArgs:[],args:[Po.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return l?b.InitiaAddress(l).bech32:null}return{restUrl:e,getUsername:r,getAddress:a,validateUsername:o}}const ks=Ee.createQueryKeys("interwovenkit:account",{username:(e,s)=>[e,s],address:(e,s)=>[e,s],balances:(e,s)=>[e,s],txs:(e,s)=>[e,s]});function Mr(){const{restUrl:e}=pe(),{usernamesModuleAddress:s}=le();return fa({restUrl:e,moduleAddress:s})}function Fr(){const e=ne();return s=>T.queryOptions({queryKey:ks.balances(s.restUrl,e).queryKey,queryFn:()=>Dr(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:s.restUrl},"balances"),staleTime:U.SECOND})}function yn(e){const s=Fr(),{data:n}=T.useSuspenseQuery(s(e));return n}function pa(){const e=se(),s=Fr();return T.useQueries({queries:e.map(n=>s(n))})}function ga(e){const s=yn(e),n=Ut(e),r=Je(e),o=Br(e),{data:a}=bs(e),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>n.some(d=>d.denom===c);return y.sortWith([y.descend(({denom:c})=>o(c)==="uinit"),y.descend(({denom:c})=>i(c)),y.descend(({value:c})=>c),y.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>M(d).comparedTo(c)??0,y.descend(({symbol:c})=>c.toLowerCase())],s.filter(({amount:c})=>!M(c).isZero()).map(({amount:c,denom:d})=>{const u=r(d),h=a?.find(({id:f})=>f===u?.denom)?.price??0,m=M(c).times(h).div(M(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:h,value:m}}))}const xa="INIT",ya="Initia";function jn(e){return e.assets.reduce((s,{value:n})=>s+(n??0),0)}function ja(e){return e.assets.reduce((s,{quantity:n})=>s.plus(n),M(0)).toString()}function va(e,s){return{symbol:s?.symbol??e,logoUrl:s?.logoUrl??xn}}function Bn(e){return y.pick(["chainId","name","logoUrl"],e)}function wa(e){return y.sortWith([y.descend(({symbol:s})=>s===xa),y.descend(jn),y.descend(({assets:s})=>s.length),y.ascend(({symbol:s})=>s)])(e)}function ba(e){return y.sortWith([y.descend(({value:s})=>s??0),y.descend(({quantity:s})=>Number(s)),y.ascend(({chain:s})=>s.name)])(e)}function Ca(e){return y.sortWith([y.descend(({chain:s})=>s.name===ya),y.ascend(({chain:s})=>s.name),y.ascend(({denom:s})=>s)])(e)}function Ia(e,s){return y.sortWith([y.descend(({chainId:n})=>n===s),y.descend(y.prop("value"))])(e)}function Na(e,s,n,r,o){const a={};for(const u of e){const h=u.chainId,m=s[h]??[],f=n[h],g=r[h],p=[];for(const{amount:v,denom:k}of m){if(!M(v).gt(0))continue;const I=f?.find(C=>C.denom===k),E=g?.find(C=>C.id===k)?.price,w=I?.decimals??0,j=b.fromBaseUnit(v,{decimals:w}),A=E?M(j).times(E).toNumber():void 0;p.push({...va(k,I),amount:v,denom:k,decimals:w,quantity:j,price:E,value:A,address:I?.address,unlisted:!I,chain:Bn(u)})}a[h]=p}const i=new Map;for(const[u,h]of Object.entries(a)){const m=e.find(g=>g.chainId===u);if(!m)continue;const f=h.reduce((g,{value:p})=>g+(p??0),0);i.set(u,{...Bn(m),value:f})}const l=new Map;for(const u of Object.values(a))for(const h of u)if(!h.unlisted){const{symbol:m}=h,f=l.get(m)??[];l.set(m,[...f,h])}const c=[];for(const[u,h]of l){const m=y.head(h);if(!m)continue;const f=ba(h);c.push({symbol:u,logoUrl:m.logoUrl,assets:f})}const d=[];for(const u of Object.values(a))for(const h of u)h.unlisted&&d.push(h);return{chainsByValue:Ia(Array.from(i.values()),o),assetGroups:wa(c),unlistedAssets:Ca(d),totalValue:c.reduce((u,h)=>u+jn(h),0)}}function vn(){const{defaultChainId:e}=le(),s=se(),n=pa(),r=_a(),o=Zo(),a=s.map(m=>m.chainId),i=y.zipObj(a,n.map(y.prop("data"))),l=y.zipObj(a,r.map(y.prop("data"))),c=y.zipObj(a,o.map(y.prop("data"))),d=Na(s,i,l,c,e),u=[n,r,o].flat().some(({isLoading:m})=>m);return{...d,isLoading:u,refetch:()=>{n.forEach(({refetch:m})=>m()),r.forEach(({refetch:m})=>m()),o.forEach(({refetch:m})=>m())}}}function ne(){const e=As();return e?b.InitiaAddress(e).bech32:""}function As(){const{address:e}=fe.useAccount();return e?b.InitiaAddress(e).hex:""}function Nt(){const e=Kt(),s=ne(),n=As();return e.metadata?.minitia?.type==="minievm"?n:s}function Or(){const e=Nt(),s=Mr();return T.useQuery({queryKey:ks.username(s.restUrl,e).queryKey,queryFn:()=>s.getUsername(e),enabled:!!e,staleTime:U.MINUTE})}function ge(){const e=Nt(),s=ne(),n=As(),{data:r}=Or(),o=Ct(),a=kr(),{isDrawerOpen:i,openDrawer:l}=It(),c=()=>{l("/")},d=()=>{l("/connect")},u=f=>{l("/bridge",f)},h=Er();return{address:e,initiaAddress:s,hexAddress:n,username:r,offlineSigner:o,isConnected:!!e,isOpen:i,openConnect:d,openWallet:c,openBridge:u,disconnect:a,...h}}function Sa(){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"],s={"initia-wallet-widget:ethereum-public-keys":{prefix:F.PUBLIC_KEY,getSuffix:n=>b.InitiaAddress(n).bech32}};for(const n of e)localStorage.removeItem(n);for(const[n,{prefix:r,getSuffix:o}]of Object.entries(s)){const a=localStorage.getItem(n);if(a)try{const i=JSON.parse(a);for(const[l,c]of Object.entries(i)){const d=`${r}:${o(l)}`;localStorage.setItem(d,c)}localStorage.removeItem(n)}catch{}}}const ka="_status_tn9m1_1",Aa="_error_tn9m1_9",Mn={status:ka,error:Aa},G=({error:e,children:s})=>t.jsx("p",{className:R(Mn.status,{[Mn.error]:e}),children:s}),de=({errorBoundaryProps:e={fallbackRender:({error:r})=>t.jsx(G,{error:!0,children:r.message})},suspenseFallback:s=t.jsx(G,{children:"Loading..."}),children:n})=>t.jsx(ur.ErrorBoundary,{...e,children:t.jsx(_.Suspense,{fallback:s,children:n})}),$e=Ee.createQueryKeys("interwovenkit:skip",{chains:null,assets:e=>[e],asset:(e,s)=>[e,s],balances:(e,s)=>[e,s],route:(e,s)=>[e,s],routeErrorInfo:e=>[e],txTrack:(e,s)=>[e,s],txStatus:(e,s)=>[e,s]});function Me(){const{routerApiUrl:e}=le();return _.useMemo(()=>Y.create({prefixUrl:e}),[e])}function Lr(){const e=se();return s=>e.some(n=>n.chain_id===s)}function Wt(){const e=Lr();return s=>e(s.chain_id)?"initia":s.chain_type}function zt(e){return Wt()(e)}function wn(){const e=Me(),{data:s}=T.useSuspenseQuery({queryKey:$e.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:n})=>y.sortWith([y.descend(({chain_name:r})=>r==="initia"),y.ascend(({pretty_name:r})=>r)],n),staleTime:U.MINUTE});return s}function ut(){const e=wn();return s=>{const n=e.find(r=>r.chain_id===s);if(!n)throw new Error(`Chain not found: ${s}`);return n}}function Te(e){return ut()(e)}function wt(e){const s=Me(),n=T.useQueryClient(),{data:r}=T.useSuspenseQuery({queryKey:$e.assets(e).queryKey,queryFn:()=>s.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:o})=>{const{assets:a}=o[e]??{assets:[]};for(const i of a)n.setQueryData($e.asset(e,i.denom).queryKey,i);return a.toSorted(y.descend(i=>i.symbol==="INIT"))},staleTime:U.MINUTE});return r}function Ur(e){const s=wt(e);return n=>{const r=s.find(o=>o.denom===n);if(!r)throw new Error(`Asset not found: ${n}`);return r}}function Re(e,s){return Ur(s)(e)}const bn=_.createContext(null);function ct(){const{container:e}=_.useContext(bn);return e}function zr(e){const s=ct();return s?getComputedStyle(s).getPropertyValue(e):""}const $a=({children:e})=>{const[s,n]=_.useState(null);return t.jsx(bn.Provider,{value:{container:s,setContainer:n},children:e})},Ta="_loader_4gdsk_1",Ea={loader:Ta},Ze=({size:e=24,color:s="currentColor",border:n=2})=>{const r={width:`${e}px`,height:`${e}px`,borderColor:`${s} ${s} transparent ${s}`,borderWidth:`${n}px`};return t.jsx("div",{className:Ea.loader,style:r})},qa="_container_1zg8z_1",Da="_toast_1zg8z_10",Pa="_info_1zg8z_23",Ra="_success_1zg8z_27",Ba="_error_1zg8z_31",Ma="_icon_1zg8z_36",Fa="_content_1zg8z_43",Oa="_title_1zg8z_46",La="_description_1zg8z_51",Ua="_close_1zg8z_72",Ue={container:qa,toast:Da,info:Pa,success:Ra,error:Ba,icon:Ma,content:Fa,title:Oa,description:La,close:Ua},za=({notification:e,onClose:s,...n})=>{const r=Qe.useTransition(e,{keys:a=>a?.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}}),o=a=>{switch(a){case"loading":return t.jsx(Ze,{size:16});case"info":case"success":return t.jsx($.IconCheckCircleFilled,{size:16});case"error":return t.jsx($.IconCloseCircleFilled,{size:16});default:return null}};return r((a,i)=>{if(!i)return null;const{type:l,title:c,description:d}=i,u=o(l);return t.jsx(Qe.animated.div,{style:a,className:Ue.container,children:t.jsxs("div",{className:R(Ue.toast,l&&Ue[l]),...n,children:[u&&t.jsx("div",{className:Ue.icon,children:u}),t.jsxs("div",{className:Ue.content,children:[t.jsx("p",{className:Ue.title,children:c}),d&&t.jsx("div",{className:Ue.description,children:d})]}),t.jsx("button",{className:Ue.close,onClick:s,children:t.jsx($.IconClose,{size:14})})]})})})},Kr=_.createContext(null),Cn=()=>_.useContext(Kr),Ls=5e3,Ka=({children:e})=>{const s=ct(),[n,r]=_.useState(null),o=_.useRef(null),a=_.useRef(!1),i=()=>{o.current&&(clearTimeout(o.current),o.current=null)},l=_.useCallback(()=>{i(),r(null)},[]),c=_.useCallback(m=>{i(),r({...m,id:Dn.nanoid()}),m.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Ls))},[l]),d=_.useCallback(m=>{i(),r(f=>f?{...f,...m}:{...m,id:Dn.nanoid()}),m.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Ls))},[l]),u=()=>{i(),a.current=!0},h=()=>{i(),a.current=!1,n?.autoHide&&(o.current=setTimeout(()=>l(),Ls))};return _.useEffect(()=>()=>i(),[]),t.jsxs(Kr.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,s&&Ro.createPortal(t.jsx(za,{notification:n,onClose:l,onMouseEnter:u,onMouseLeave:h}),s)]})},Wr=_.createContext(!1),Wa="_overlay_2lgi8_1",Ha="_fullscreen_2lgi8_15",Qa="_content_2lgi8_19",Va="_header_2lgi8_54",Ga="_title_2lgi8_63",Ya="_close_2lgi8_68",tt={overlay:Wa,fullscreen:Ha,content:Qa,header:Va,title:Ga,close:Ya},Hr=({title:e,children:s,trigger:n,className:r,open:o,onOpenChange:a})=>{const i=ct(),l=_.useContext(Wr);return i?t.jsxs(we.Dialog.Root,{open:o,onOpenChange:a,modal:!1,children:[n&&t.jsx(we.Dialog.Trigger,{className:r,children:n}),t.jsxs(we.Dialog.Portal,{container:i,children:[t.jsx(we.Dialog.Backdrop,{className:R(tt.overlay,{[tt.fullscreen]:l}),onClick:()=>a(!1),forceRender:!0}),t.jsxs(we.Dialog.Popup,{className:R(tt.content,{[tt.fullscreen]:l}),children:[e&&t.jsxs("header",{className:tt.header,children:[t.jsx(we.Dialog.Title,{className:tt.title,children:e}),t.jsx(we.Dialog.Close,{className:tt.close,children:t.jsx($.IconClose,{size:20})})]}),s]})]})]}):null},Ja=10;function Qr(){const e=ne();return(s,n)=>T.queryOptions({queryKey:ks.txs(s.indexerUrl,e).queryKey,queryFn:async()=>{if(!n.enabled)return[];const r={"pagination.reverse":!0,"pagination.limit":Ja},{txs:o}=await Y.create({prefixUrl:s.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:r}).json();return o},staleTime:U.SECOND})}function Za(e,s){const n=Qr();return T.useSuspenseQuery(n(e,s))}function Xa(e,s){const n=e.flatMap((r,o)=>(s[o]??[]).map(i=>({...i,chain:r})));return y.sortWith([y.descend(r=>new Date(r.timestamp).getTime())])(n)}const ei=()=>{const e=se(),s=Qr(),n=T.useQueries({queries:e.map(i=>s(i,{enabled:!0}))}),r=n.map(y.prop("data")),o=Xa(e,r),a=n.some(i=>i.isLoading);return{activities:o,isLoading:a}};function Vr(e){const{data:s}=T.useSuspenseQuery({queryKey:gn.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:r}=await Y.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return r.toSorted(y.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const i=o==="uinit"?1:mr;return{amount:M(a).times(i).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:r})=>{if(y.isNil(r))throw new Error(`${n} has no price`);return{amount:String(r),denom:n}})},staleTime:U.SECOND});return s}function Gr(e){const s=ne(),{data:n}=Za(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const r=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return r;try{return n.find(({tx:a})=>a.auth_info.signer_infos.some(i=>b.InitiaAddress.equals(s,He.computeAddress(`0x${K.toHex(sn.Secp256k1.uncompressPubkey(K.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??r}catch{return r}}const ti="_root_hypwm_1",si="_item_hypwm_10",ni="_chevron_hypwm_14",ri="_trigger_hypwm_19",oi="_content_hypwm_39",Et={root:ti,item:si,chevron:ni,trigger:ri,content:oi};function ai(e){const{list:s,getKey:n,renderHeader:r,renderContent:o,footer:a,...i}=e;return t.jsxs(Q.Accordion.Root,{className:Et.root,type:"multiple",...i,children:[s.map((l,c)=>t.jsxs(Q.Accordion.Item,{className:Et.item,value:n?.(l)??String(c),children:[t.jsx(Q.Accordion.Header,{children:t.jsxs(Q.Accordion.Trigger,{className:Et.trigger,children:[r(l),t.jsx($.IconChevronDown,{className:Et.chevron,size:16})]})}),t.jsx(Q.Accordion.Content,{className:Et.content,children:o(l)})]},n?.(l)??c)),a]})}const ii="_scrollable_abvhw_1",ci={scrollable:ii},Fe=({className:e,children:s,ref:n})=>t.jsx("div",{ref:n,className:R(ci.scrollable,e),children:s}),rn=({children:e})=>{const s=_.useRef(null),[n,r]=_.useState(0),o=Qe.useSpring({height:n,config:{tension:500,friction:30,clamp:!0}});return _.useEffect(()=>{if(s.current){const{height:a}=s.current.getBoundingClientRect();r(a)}},[e]),e?t.jsx(Qe.animated.div,{style:{overflow:"hidden",...o},children:t.jsx("div",{ref:s,children:e})}):null},li="_help_7m3jv_1",di="_icon_7m3jv_10",ui="_info_7m3jv_17",hi="_warning_7m3jv_21",mi="_error_7m3jv_25",_i="_success_7m3jv_31",Us={help:li,icon:di,info:ui,warning:hi,error:mi,success:_i},Ke=({level:e,className:s,mt:n=8,children:r})=>{if(!r)return null;const o=()=>{switch(e){case"loading":return t.jsx(Ze,{size:12});case"info":return t.jsx($.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx($.IconWarningFilled,{size:12});default:return t.jsx($.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:R(Us.help,e&&Us[e],s),style:{marginTop:n},children:[t.jsx("div",{className:Us.icon,children:o()}),t.jsx("p",{children:r})]})},fi="_stack_14kq8_1",pi="_help_14kq8_6",gi="_info_14kq8_14",xi="_warning_14kq8_19",yi="_error_14kq8_24",ji="_success_14kq8_29",on={stack:fi,help:pi,info:gi,warning:xi,error:yi,success:ji},vi=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(rn,{children:t.jsx("div",{className:on.stack,children:e})}),ee=e=>t.jsx(Ke,{...e,className:R(on.help,on[e.level]),mt:0});ee.Stack=vi;const wi="_footer_xif7g_1",bi="_actions_xif7g_10",Fn={footer:wi,actions:bi},te=({extra:e,className:s,children:n})=>t.jsxs("footer",{className:R(Fn.footer,s),children:[e,t.jsx("div",{className:Fn.actions,children:n})]}),Ci="_button_1n7c4_1",Ii="_outline_1n7c4_25",Ni="_sm_1n7c4_43",Si="_full_1n7c4_49",ki="_small_1n7c4_53",Ai="_unpadded_1n7c4_83",ot={button:Ci,outline:Ii,sm:Ni,full:Si,small:ki,unpadded:Ai},Yr=e=>{const{sm:s,fullWidth:n,loading:r,className:o,children:a,disabled:i,...l}=e;return t.jsx("button",{...l,className:R(ot.button,{[ot.sm]:s,[ot.full]:n},o),disabled:!!r||i,children:r?t.jsxs(t.Fragment,{children:[t.jsx(Ze,{color:"currentColor",size:16}),typeof r=="string"&&t.jsx("span",{className:ot.loading,children:r})]}):a})},$i=({className:e,...s})=>t.jsx(Yr,{...s,className:R(ot.outline,e)}),Ti=({className:e,unpadded:s,...n})=>t.jsx("button",{...n,className:R(ot.small,{[ot.unpadded]:s},e)}),W={White:Yr,Outline:$i,Small:Ti},Ei="_item_1n572_1",qi="_title_1n572_10",Di="_content_1n572_14",zs={item:Ei,title:qi,content:Di},Ks=({title:e,content:s})=>t.jsxs("div",{className:zs.item,children:[t.jsx("div",{className:zs.title,children:e}),t.jsx("div",{className:zs.content,children:s})]});function Ve(e){if(e&&M(e).gt(0)&&M(e).lt(.01))return"<$0.01";const s=b.formatNumber(e,{dp:2});return s?`$${s}`:""}const Pi="_placeholder_yluz4_1",Ri="_logo_yluz4_5",On={placeholder:Pi,logo:Ri},z=({src:e,alt:s,placeholder:n,classNames:r,style:o,logo:a,...i})=>{const[l,c]=_.useState(!1),{width:d,height:u}=i,h=n??t.jsx("div",{className:R(On.placeholder,r?.placeholder),style:{width:d,height:u,...o}});return _.useEffect(()=>{c(!1)},[e]),!e||l?h:t.jsx("img",{...i,className:R(i.className,{[On.logo]:a}),style:{width:d,height:u,...o},src:e,alt:s,loading:"lazy",onError:()=>c(!0)})};function Jr(e,s){const n={};for(const r of e)if(r.attributes.some(a=>a.key==="msg_index")){if(r.type==="coin_spent"){const a=r.attributes.find(l=>l.key==="spender")?.value,i=r.attributes.find(l=>l.key==="amount")?.value;if(a===s&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=n[c]||BigInt(0);n[c]=d-BigInt(l)}}}if(r.type==="coin_received"){const a=r.attributes.find(l=>l.key==="receiver")?.value,i=r.attributes.find(l=>l.key==="amount")?.value;if(a===s&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=n[c]||BigInt(0);n[c]=d+BigInt(l)}}}}return Object.entries(n).filter(([,r])=>r!==BigInt(0)).map(([r,o])=>({amount:o.toString(),denom:r}))}function Zr(e,s){const n={};for(const r of e)if(r.attributes.some(a=>a.key==="msg_index")&&r.type==="move"){const a=r.attributes.find(c=>c.key==="type_tag")?.value,i=r.attributes.find(c=>c.key==="data")?.value;if(!a||!i)continue;let l;try{l=JSON.parse(i)}catch{continue}if(a==="0x1::fungible_asset::WithdrawEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&b.createUserDerivedObjectAddress(s,u)===c){const m=n[u]||BigInt(0);n[u]=m-BigInt(d)}}if(a==="0x1::fungible_asset::DepositEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&b.createUserDerivedObjectAddress(s,u)===c){const m=n[u]||BigInt(0);n[u]=m+BigInt(d)}}}return Object.entries(n).filter(([,r])=>r!==BigInt(0)).map(([r,o])=>({amount:o.toString(),metadata:r}))}const Xr=({metadata:e,chain:s,children:n})=>{const{restUrl:r}=s,{data:o}=T.useSuspenseQuery({queryKey:hs.denom(r,e).queryKey,queryFn:()=>Y.create({prefixUrl:r}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:a})=>a,staleTime:U.INFINITY});return n(o)},Bi="_root_jioyr_1",Mi="_title_jioyr_7",Fi="_changes_jioyr_13",Oi="_change_jioyr_13",Li="_amount_jioyr_34",Ui="_text_jioyr_40",zi="_value_jioyr_47",at={root:Bi,title:Mi,changes:Fi,change:Oi,amount:Li,text:Ui,value:zi},eo=({amount:e,asset:s,price:n})=>{const{denom:r,symbol:o,decimals:a,logoUrl:i}=s,l=b.formatAmount(e,{decimals:a}),c=n&&M(b.fromBaseUnit(e,{decimals:a})).times(n).abs();return t.jsxs("div",{className:at.change,children:[t.jsxs("div",{className:at.amount,children:[t.jsx(z,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:at.text,children:[l," ",o||r]})]}),c&&t.jsx("div",{className:at.value,children:Ve(c)})]})},Ki=({changes:e,chain:s})=>{const n=Je(s),{data:r}=bs(s);return e.map(({amount:o,denom:a},i)=>{const l=n(a),c=r?.find(({id:d})=>d===a)?.price;return t.jsx(eo,{amount:o,asset:l,price:c},i)})},Wi=({changes:e,chain:s})=>{const n=Je(s),{data:r}=bs(s);return e.map(({amount:o,metadata:a},i)=>t.jsx(Xr,{metadata:a,chain:s,children:l=>{const c=r?.find(({id:d})=>d===l)?.price;return t.jsx(eo,{amount:o,asset:n(l),price:c})}},i))};function Hi(e,s){return typeof s=="bigint"?s.toString():s}const Qi=Ee.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Hi)]}),Vi=({messages:e,memo:s,chainId:n})=>{const{initiaAddress:r,hexAddress:o}=ge(),a=Be(n),{simulateTx:i}=Er(),{data:l}=T.useSuspenseQuery({queryKey:Qi.simulate({messages:e,memo:s,chainId:n}).queryKey,queryFn:()=>i({messages:e,memo:s,chainId:n}),staleTime:U.SECOND}),c=m=>t.jsxs("div",{className:at.root,children:[t.jsx("h2",{className:at.title,children:"Estimated changes"}),t.jsx("div",{className:at.changes,children:m})]});if(!l)return null;const d=l.result?.events??[];if(d.length===0)return null;if(a.metadata?.is_l1||a.metadata?.minitia?.type==="minimove"){const m=Zr(d,o),[f]=Ln(m);return f.length===0?null:c(t.jsx(Wi,{changes:f,chain:a}))}const u=Jr(d,r),[h]=Ln(u);return h.length===0?null:c(t.jsx(Ki,{changes:h,chain:a}))};function Ln(e){return y.partition(s=>new M(s.amount).isNegative(),e)}const Gi="_trigger_j95m4_1",Yi="_icon_j95m4_10",Ji="_content_j95m4_21",Zi="_item_j95m4_29",Zt={trigger:Gi,icon:Yi,content:Ji,item:Zi},Xi=({options:e,value:s,onChange:n})=>{const r=ct(),{txRequest:o}=Tr(),a=Be(o.chainId),i=Je(a),l=d=>{const u=e.find(h=>h.amount[0].denom===d);if(!u)throw new Error(`Option not found for denom: ${d}`);return u},c=({amount:[{amount:d,denom:u}]})=>{if(M(d).isZero())return"0";const{symbol:h,decimals:m}=i(u);return`${b.formatAmount(d,{decimals:m})} ${h}`};return e.length===1?c(e[0]):t.jsxs(qe.Select.Root,{value:s,onValueChange:n,modal:!1,children:[t.jsxs(qe.Select.Trigger,{className:Zt.trigger,children:[t.jsx(qe.Select.Value,{children:d=>c(l(d))}),t.jsx(qe.Select.Icon,{className:Zt.icon,children:t.jsx($.IconChevronDown,{size:16})})]}),t.jsx(qe.Select.Portal,{container:r,children:t.jsx(qe.Select.Positioner,{className:Zt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(qe.Select.Popup,{children:e.map(d=>{const[{denom:u}]=d.amount;return t.jsx(qe.Select.Item,{className:Zt.item,value:u,children:t.jsx(qe.Select.ItemText,{children:c(d)})},u)})})})})]})};function ms(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?K.toBase64(e):Array.isArray(e)?`[${e.map(ms).join(",")}]`:JSON.stringify(e,(s,n)=>typeof n=="bigint"?n.toString():n);default:return"unknown"}}const ec="_container_1xzyq_1",tc="_toggle_1xzyq_5",sc="_list_1xzyq_11",nc="_arg_1xzyq_16",rc="_type_1xzyq_21",qt={container:ec,toggle:tc,list:sc,arg:nc,type:rc},oc=Ee.createQueryKeys("interwovenkit:move",{abi:(e,s,n,r)=>[e,s,n,r]}),ac=({type:e,arg:s})=>ms(b.resolveBcsType(e).parse(s)),ic=({msg:e,chainId:s,fallback:n})=>{const[r,o]=be.useToggle(!1),{restUrl:a}=Be(s),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=T.useQuery({queryKey:oc.abi(a,i,l,c).queryKey,queryFn:async()=>{const m=await Y.create({prefixUrl:a}).get(`initia/move/v1/accounts/${i}/modules/${l}`).json(),g=JSON.parse(m.module.abi).exposed_functions.find(({name:p})=>p===c);if(!g)throw new Error(`Function ${c} not found in module ${l}`);return g.params.filter(p=>!p.startsWith("&"))},staleTime:U.INFINITY});if(!u)return n;const h=(m,f)=>{const g=u[f];return t.jsxs("div",{className:qt.arg,children:[t.jsx("div",{className:qt.type,children:g}),t.jsx(ur.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(ac,{type:g,arg:m})})]},f)};return t.jsxs("div",{className:qt.container,children:[t.jsx(W.Small,{className:qt.toggle,onClick:o,disabled:!u,children:r?"Encode":"Decode"}),r?t.jsx("div",{className:qt.list,children:d.map(h)}):n]})},cc="_list_r67rl_1",lc="_key_r67rl_8",dc="_value_r67rl_13",Ws={list:cc,key:lc,value:dc},uc=({message:e,chainId:s})=>{const{typeUrl:n,value:r}=e;return t.jsx("div",{className:Ws.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{children:[t.jsx("div",{className:Ws.key,children:o}),t.jsx("div",{className:Ws.value,children:n==="/initia.move.v1.MsgExecute"&&o==="args"?t.jsx(ic,{msg:r,chainId:s,fallback:ms(a)}):ms(a)})]},o))})},hc="_title_kspdu_1",mc="_meta_kspdu_7",_c="_footer_kspdu_14",Hs={title:hc,meta:mc,footer:_c},to=()=>{const{txRequest:e,resolve:s,reject:n}=Tr(),{messages:r,memo:o,chainId:a,gas:i,gasAdjustment:l,spendCoins:c}=e,d=ne(),u=Ct(),h=Cr(),m=Be(a),f=yn(m),g=Vr(m),p=Gr(m),v=(e.gasPrices??g).map(({amount:x,denom:P})=>Ae.calculateFee(Math.ceil(i*l),Ae.GasPrice.fromString(x+P))),k=v.map(x=>x.amount[0]),I=x=>{const P=f.find(S=>S.denom===x)?.amount??0,q=k.find(S=>S.denom===x)?.amount??0,B=c.filter(S=>S.denom===x).reduce((S,O)=>M(S).plus(O.amount),M(0));if(B.gt(0)){const S=M(q).plus(B);return M(P).gte(S)}return M(P).gte(q)},E=()=>{if(p&&I(p))return p;for(const{denom:x}of k)if(I(x))return x;return k[0]?.denom},[w,j]=_.useState(E),{mutate:A,isPending:C}=T.useMutation({mutationKey:[Ar],mutationFn:async()=>{const x=v.find(q=>q.amount[0].denom===w);if(!x)throw new Error("Fee not found");if(!u)throw new Error("Signer not initialized");const P=await h(a,d,r,x,o);await s(P)},onError:async x=>{n(new Error(await Ge(x)))}}),N=!I(w);return t.jsxs(t.Fragment,{children:[t.jsxs(Fe,{children:[t.jsx("h1",{className:Hs.title,children:"Confirm tx"}),t.jsxs("div",{className:Hs.meta,children:[t.jsx(Ks,{title:"Chain",content:a}),t.jsx(Ks,{title:"Tx fee",content:t.jsx(Xi,{options:v,value:w,onChange:j})}),o&&t.jsx(Ks,{title:"Memo",content:o}),N&&t.jsx(ee,{level:"error",children:"Insufficient balance for fee"})]}),t.jsx(Vi,{messages:r,memo:o,chainId:a}),t.jsx(ai,{list:r,renderHeader:({typeUrl:x})=>xs.sentenceCase(x.split(".").pop().replace(/^Msg/,"")),renderContent:x=>t.jsx(uc,{message:x,chainId:a})})]}),t.jsxs(te,{className:Hs.footer,children:[t.jsx(W.Outline,{onClick:()=>n(new Error("User rejected")),disabled:C,children:"Reject"}),t.jsx(W.White,{onClick:()=>A(),disabled:N,loading:C,children:"Approve"})]})]})},fc=({children:e})=>{const[{title:s,content:n,path:r},o]=_.useState({}),[a,i]=_.useState(!1),l=H.useAtomValue(Ss),c=_.useCallback(h=>{o(h),i(!0)},[]),d=_.useCallback(()=>{o({}),i(!1)},[]),u=_.useCallback(h=>{h||(l?.reject(new Error("User rejected")),o({})),i(h)},[l]);return t.jsxs(yr.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(Hr,{title:s,open:a,onOpenChange:u,children:t.jsx(de,{children:r==="/tx"?t.jsx(to,{}):n})})]})},pc=()=>(ia(),ca(),null);function $s(){return be.useMediaQuery("(max-width: 576px)")}const an="interwoven-kit";function so(){const e=document.querySelector(an)||document.body.appendChild(document.createElement(an));return e.shadowRoot||e.attachShadow({mode:"open"})}function gc(){const{theme:e,container:s}=le();return _.useEffect(()=>{document.querySelector(an)?.setAttribute("data-theme",e)},[e]),s??so()}function xc(e){const s=so(),n=document.createElement("style");n.textContent=e,s.appendChild(n)}const lt=({title:e,content:s,children:n,className:r})=>{const[o,a]=_.useState(!1),i=()=>a(!1);return t.jsx(Hr,{title:e,trigger:n,className:r,open:o,onOpenChange:a,children:s(i)})},_s=({value:e,children:s})=>{const[n,r]=_.useState(!1);return s({copy:async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1e3)}catch{}},copied:n})},yc="_root_19tvg_1",jc="_address_19tvg_9",vc="_copy_19tvg_19",wc="_labelWrapper_19tvg_33",bc="_labelCopy_19tvg_43",Cc="_labelCopied_19tvg_47",Ic="_copied_19tvg_55",Nc="_derived_19tvg_65",Sc="_derivedLabel_19tvg_78",kc="_derivedAddress_19tvg_82",Ac="_hexAddress_19tvg_88",$c="_derivedCopy_19tvg_93",ae={root:yc,address:jc,copy:vc,labelWrapper:wc,labelCopy:bc,labelCopied:Cc,copied:Ic,derived:Nc,derivedLabel:Sc,derivedAddress:kc,hexAddress:Ac,derivedCopy:$c},Tc=()=>{const e=_.useRef(null),s=_.useRef(null),{initiaAddress:n,hexAddress:r}=ge(),o=zr("--gray-0");return _.useEffect(()=>{e.current&&(s.current?s.current.update({data:n}):(s.current=new Bo({type:"canvas",width:400,height:400,margin:0,data:n,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:o},cornersSquareOptions:{type:"extra-rounded",color:o},cornersDotOptions:{type:"dot",color:o},backgroundOptions:{color:"transparent"}}),s.current.append(e.current)))},[n,o]),t.jsxs("div",{className:ae.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:ae.address,children:n}),t.jsx(_s,{value:n,children:({copy:a,copied:i})=>t.jsxs("button",{className:R(ae.copy,{[ae.copied]:i}),onClick:a,children:[t.jsx($.IconCopy,{size:12}),t.jsxs("div",{className:ae.labelWrapper,children:[t.jsx("span",{className:ae.labelCopy,children:"Copy address"}),t.jsx("span",{className:ae.labelCopied,children:"Copied!"})]})]})}),t.jsx(_s,{value:r,children:({copy:a,copied:i})=>t.jsxs("button",{className:R(ae.derived,{[ae.copied]:i}),onClick:a,children:[t.jsx("span",{className:ae.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:ae.derivedAddress,children:[t.jsx("span",{className:ae.hexAddress,children:b.truncate(r)}),t.jsx($.IconCopy,{size:12,className:ae.derivedCopy}),i&&t.jsx("span",{className:ae.copiedText,children:"Copied!"})]})]})})]})},Ec="_header_1cvtq_1",qc="_account_1cvtq_16",Dc="_name_1cvtq_27",Pc="_address_1cvtq_31",Rc="_icon_1cvtq_35",Bc="_copied_1cvtq_42",Mc="_button_1cvtq_57",Fc="_qr_1cvtq_68",Oc="_disconnect_1cvtq_72",Lc="_label_1cvtq_82",Uc="_expanded_1cvtq_90",he={header:Ec,account:qc,name:Dc,address:Pc,icon:Rc,copied:Bc,button:Mc,qr:Fc,disconnect:Oc,label:Lc,expanded:Uc},zc=()=>{const e=Kt(),{connector:s}=fe.useAccount(),n=kr(),{address:r,username:o}=ge(),a=o??r,[i,l]=_.useState(!1),c=_.useRef(null),d=Qe.useSpring({width:i?140:52,config:{tension:500,friction:30,clamp:!0}}),u=()=>{i?n():l(!0)},h=()=>{i&&(c.current=setTimeout(()=>{l(!1)},500))},m=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return _.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),s?t.jsxs("header",{className:he.header,children:[t.jsx(_s,{value:r,children:({copy:f,copied:g})=>t.jsxs("button",{className:R(he.account,{[he.copied]:g}),onClick:f,children:[t.jsx(z,{src:s.icon,width:18,height:18}),t.jsx("div",{className:he.address,children:b.truncate(r)}),t.jsx("div",{className:he.name,children:b.truncate(a)}),t.jsx($.IconCopy,{className:he.icon,size:12}),g?"Copied!":""]})}),e.metadata?.is_l1&&t.jsx(lt,{title:"Initia address",content:()=>t.jsx(Tc,{}),className:R(he.button,he.qr),children:t.jsx($.IconQrCode,{size:16})}),t.jsxs(Qe.animated.button,{className:R(he.button,he.disconnect,{[he.expanded]:i}),style:d,onClick:u,onMouseLeave:h,onMouseEnter:m,children:[t.jsx($.IconSignOut,{size:16}),t.jsx("span",{className:he.label,children:"Disconnect"})]})]}):null};function Kc(e){return/^[A-F0-9]{64}$/i.test(e)}function Wc(e,s){const{txHash:n,accountAddress:r,pathSuffix:o}=s;if(n)return Kc(n)?y.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,n):void 0;if(r){if(!b.InitiaAddress.validate(r))return;const i=y.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,r);return i&&o?i+o:i}}function Hc(e){try{const s=new URL(e,window.location.href);if(!["http:","https:"].includes(s.protocol))throw new Error("Invalid protocol");return s.toString()}catch{return"#"}}const Qc="_link_guafb_1",Un={link:Qc},Ts=({chainId:e,txHash:s,accountAddress:n,pathSuffix:r,...o})=>{const{showIcon:a,className:i,children:l,onClick:c,...d}=o,u=Be(e),h=Wc(u,{txHash:s,accountAddress:n,pathSuffix:r}),m=s?b.truncate(s):n?b.truncate(n):"",f=l??m;return h?t.jsxs("a",{...d,href:Mo(Hc(h)),className:R(Un.link,i),onClick:c,target:"_blank",children:[f,a&&t.jsx($.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:R(Un.link,i),children:f})},Vc=()=>{const[e,s]=H.useAtom($r),{showNotification:n,updateNotification:r,hideNotification:o}=Cn();return _.useEffect(()=>{if(!e)return;const{status:a,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(Ts,{txHash:l,chainId:i,onClick:o,showIcon:!0,children:"View on Initia Scan"}):null;switch(a){case"loading":n({type:"loading",title:"Transaction is pending..."});break;case"error":r({type:"error",title:"Transaction failed",description:d}),s(null);break;case"success":r({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),s(null);break}},[e,s,n,r,o]),null};function Gc(){return be.useScrollLock(),null}const Yc="_overlay_1dhd9_1",Jc="_content_1dhd9_27",Zc="_inner_1dhd9_58",Qs={overlay:Yc,content:Jc,inner:Zc},Xc=({children:e})=>{const{isDrawerOpen:s,closeDrawer:n}=It(),{setContainer:r}=_.useContext(bn),o=$s(),a=gc(),i=H.useAtomValue(Ss),l=T.useIsMutating({mutationKey:[Ar]}),c=()=>{const f=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";n(),i?.reject(new Error(f))},d=vs(),u=ce(),h=T.useQueryClient(),m={fallbackRender:({error:f,resetErrorBoundary:g})=>{const p=()=>{d==="/bridge"&&(localStorage.removeItem(F.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(F.BRIDGE_SRC_DENOM),localStorage.removeItem(F.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(F.BRIDGE_DST_DENOM)),u("/"),h.clear(),g()};return t.jsxs(Fe,{children:[t.jsx(G,{error:!0,children:f.message}),t.jsx(te,{children:t.jsx(W.White,{onClick:p,children:"Retry"})})]})}};return t.jsx(we.Dialog.Root,{open:s,onOpenChange:f=>!f&&c(),modal:!1,children:t.jsxs(we.Dialog.Portal,{container:a,children:[o&&t.jsx(we.Dialog.Backdrop,{className:Qs.overlay,onClick:c,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[t.jsx("path",{d:"M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z"}),t.jsx("path",{d:"M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z"})]})}),t.jsx(we.Dialog.Popup,{className:Qs.content,children:t.jsxs("div",{className:R(Qs.inner,"body"),ref:r,children:[o&&t.jsx(Gc,{}),t.jsx(Vc,{}),t.jsx(zc,{}),t.jsx(de,{errorBoundaryProps:m,children:e})]})})]})})},el="_page_1f6wh_1",tl="_title_1f6wh_10",sl="_scrollable_1f6wh_17",nl="_list_1f6wh_22",rl="_item_1f6wh_32",ol="_name_1f6wh_56",al="_dimmed_1f6wh_64",il="_recent_1f6wh_68",cl="_installed_1f6wh_69",je={page:el,title:tl,scrollable:sl,list:nl,item:rl,name:ol,dimmed:al,recent:il,installed:cl},ll=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],zn=({onSuccess:e})=>{const{connectors:s,connectAsync:n}=fe.useConnect(),r=be.useReadLocalStorage("wagmi.recentConnectorId"),[o,a]=_.useState(null),{mutate:i,isPending:l}=T.useMutation({mutationFn:async c=>{a(c.id);try{await n({connector:c})}catch(d){throw new Error(await Ge(d))}},onSettled:()=>{a(null)},onSuccess:()=>{e?.()}});return t.jsxs("div",{className:je.page,children:[t.jsx("h1",{className:je.title,children:"Connect wallet"}),t.jsx(Fe,{className:je.scrollable,children:t.jsxs("div",{className:je.list,children:[s.toSorted(y.descend(c=>c.id===r)).map(c=>{const{name:d,icon:u,id:h}=c;return t.jsxs("button",{className:je.item,onClick:()=>i(c),disabled:l,children:[t.jsx(z,{src:u,width:24,height:24}),t.jsx("span",{className:je.name,children:d}),o===h?t.jsx(Ze,{size:16}):r===h?t.jsx("span",{className:je.recent,children:"Recent"}):c.id===ys.id?null:t.jsx("span",{className:je.installed,children:"Installed"})]},h)}),ll.filter(({name:c})=>!s.some(d=>d.name.includes(c))).map(({name:c,url:d})=>{const u=`https://assets.initia.xyz/images/wallets/${c}.webp`;return t.jsxs("a",{href:d,className:je.item,target:"_blank",children:[t.jsx(z,{src:u,width:24,height:24}),t.jsx("span",{className:R(je.name,je.dimmed),children:c}),t.jsx($.IconExternalLink,{size:10})]},c)})]})})]})},dl="_root_xwz5z_1",ul="_header_xwz5z_6",hl="_title_xwz5z_12",ml="_warning_xwz5z_18",_l="_content_xwz5z_22",fl="_footer_xwz5z_26",pl="_secondary_xwz5z_36",st={root:dl,header:ul,title:hl,warning:ml,content:_l,footer:fl,secondary:pl},no=e=>{const{type:s,icon:n,title:r,children:o,primaryButton:a,secondaryButton:i}=e;return t.jsxs(Fe,{className:st.root,children:[t.jsxs("header",{className:R(st.header,s&&st[s]),children:[n,t.jsx("h1",{className:st.title,children:r})]}),t.jsx("div",{className:st.content,children:o}),t.jsxs("footer",{className:st.footer,children:[t.jsx(W.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),t.jsxs("button",{className:st.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx($.IconChevronRight,{size:14})]})]})]})},gl="_list_tmcxc_1",xl="_row_tmcxc_8",yl="_dt_tmcxc_19",jl="_asset_tmcxc_25",Xt={list:gl,row:xl,dt:yl,asset:jl},vl=({list:e,onNavigate:s,onDismiss:n})=>{const r=pe(),o=Ye(),a=Je(r);return t.jsx(no,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:s},secondaryButton:{label:"Do not show again",onClick:n},children:t.jsx("div",{className:Xt.list,children:e.toSorted((i,l)=>i.chainId.localeCompare(l.chainId)).map(({txHash:i,chainId:l,amount:c,denom:d})=>{const u=o(l),{decimals:h,symbol:m}=a(d),f=b.formatAmount(c,{decimals:h});return t.jsxs("div",{className:Xt.row,children:[t.jsxs("div",{className:Xt.dt,children:[t.jsx(z,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:Xt.asset,children:[f," ",m]})]},i)})})})};function Vs(e,s){return e.chainId===s.chainId&&e.txHash===s.txHash}const es=({chainId:e,txHash:s})=>`${F.OP_REMINDER}:${e}:${s}`,wl=Fo.atomWithStorage(F.OP_REMINDER,[]);function St(){const e=ne(),[s=[],n]=H.useAtom(wl),r=_.useMemo(()=>s.map(c=>{const d=localStorage.getItem(es(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:bt.isPast(u)}),[e,s]),o=_.useCallback((c,d)=>{s.some(u=>Vs(u,c))||(n((u=[])=>[...u,c]),localStorage.setItem(es(c),JSON.stringify(d)))},[s,n]),a=_.useCallback(c=>{n((d=[])=>d.filter(u=>!Vs(u,c))),localStorage.removeItem(es(c))},[n]),i=_.useCallback(c=>{const d=c.filter(u=>!s.some(h=>Vs(h,u)));d.length!==0&&n((u=[])=>[...u,...d])},[s,n]),l=_.useCallback((c,d)=>{localStorage.setItem(es(c),JSON.stringify(d)),n((u=[])=>[...u])},[n]);return{reminders:r,addReminder:o,removeReminder:a,syncReminders:i,setReminder:l}}function ro(){const e=ce(),{openModal:s,closeModal:n}=ws(),{reminders:r,setReminder:o}=St();_.useEffect(()=>{const a=r.filter(c=>!c.dismissed);if(a.length===0)return;const i=()=>{const c=a.every(d=>d.chainId===a[0].chainId)?a[0].chainId:void 0;e("/op/withdrawals",{chainId:c}),l()},l=()=>{n();for(const c of a)o(c,{...c,dismissed:!0})};s({content:_.createElement(vl,{list:a,onNavigate:i,onDismiss:l})})},[r,n,e,s,o])}const oo=_.createContext(null);function ao(){return _.useContext(oo)}const bl="_root_7yxgy_1",Cl="_label_7yxgy_7",Il="_input_7yxgy_19",Nl="_hasValue_7yxgy_29",Sl="_clear_7yxgy_33",Dt={root:bl,label:Cl,input:Il,hasValue:Nl,clear:Sl},Es=e=>{const{rootClassName:s,padding:n=16,iconSize:r=16,onClear:o,ref:a,...i}=e;return t.jsxs("div",{className:R(Dt.root,s,{[Dt.hasValue]:i.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${r}px`},children:[t.jsx("label",{htmlFor:"search",className:Dt.label,children:t.jsx($.IconSearch,{size:r})}),t.jsx("input",{className:Dt.input,id:"search",type:"text",maxLength:100,ref:a,...i}),i.value&&t.jsx("button",{type:"button",className:Dt.clear,"aria-label":"Clear search",onMouseDown:l=>l.preventDefault(),onClick:o,children:t.jsx($.IconCloseCircleFilled,{size:r})})]})},kl="_container_t1267_1",Al="_controls_t1267_7",$l="_search_t1267_13",In={container:kl,controls:Al,search:$l},Tl=({children:e})=>t.jsx("div",{className:In.container,children:e}),El=({children:e})=>t.jsx("div",{className:In.controls,children:e}),ql=e=>t.jsx(Es,{...e,rootClassName:In.search}),We={Root:Tl,Controls:El,SearchInput:ql};function Ht(){const e=_.useRef(null),s=$s();return _.useEffect(()=>{s||e.current?.focus()},[s]),e}const Dl="_trigger_386xl_1",Pl="_icon_386xl_21",Rl="_full_386xl_25",Bl="_triggerContent_386xl_30",Ml="_triggerText_386xl_38",Fl="_popoverBackdrop_386xl_49",Ol="_popoverPositioner_386xl_84",Ll="_popoverPopup_386xl_88",Ul="_search_386xl_131",zl="_viewport_386xl_136",Kl="_item_386xl_141",Wl="_highlighted_386xl_155",Hl="_itemContent_386xl_160",ie={trigger:Dl,icon:Pl,full:Rl,triggerContent:Bl,triggerText:Ml,popoverBackdrop:Fl,popoverPositioner:Ol,popoverPopup:Ll,search:Ul,viewport:zl,item:Kl,highlighted:Wl,itemContent:Hl},Nn=({value:e,onChange:s,chainIds:n,fullWidth:r})=>{const[o,a]=_.useState(""),[i,l]=_.useState(!1),[c,d]=_.useState(0),[u,h]=_.useState(),m=_.useRef([]),f=_.useRef(null),g=se(),p=n.map(x=>g.find(P=>P.chainId===x)).filter(Boolean),v=x=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:x,height:x,viewBox:"0 0 14 14",children:[t.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),t.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),k=_.useMemo(()=>({chainId:"",name:"All",logoUrl:v}),[]),I=_.useMemo(()=>{const x=[k,...p];if(!o)return x;const P=o.toLowerCase();return x.filter(q=>q.name.toLowerCase().includes(P)||q.chainId.toLowerCase().includes(P))},[p,o,k]),E=p.find(x=>x.chainId===e)||k,w=parseInt(zr("--drawer-offset")),j=6,A=()=>{if(a(""),d(-1),f.current){const P=f.current.getBoundingClientRect().bottom+j,q=window.innerHeight-P-2*w;h(q)}l(!0)};_.useEffect(()=>{c>=0&&c<m.current.length&&m.current[c]?.scrollIntoView({block:"nearest",behavior:"auto"})},[c]);const C=_.useCallback(x=>{switch(x.key){case"ArrowDown":x.preventDefault(),d(P=>(P+1)%I.length);break;case"ArrowUp":x.preventDefault(),d(P=>(P-1+I.length)%I.length);break;case"Enter":x.preventDefault(),I[c]&&(s(I[c].chainId),l(!1));break;case"Escape":x.preventDefault(),l(!1);break}},[I,c,s,l]),N=x=>{s(x),l(!1)};return t.jsxs(gt.Popover.Root,{open:i,onOpenChange:A,modal:!1,children:[t.jsx(gt.Popover.Trigger,{render:t.jsxs("button",{className:R(ie.trigger,{[ie.full]:r}),"aria-expanded":i,role:"listbox",ref:f,children:[t.jsxs("div",{className:ie.triggerContent,children:[typeof E.logoUrl=="string"?t.jsx(z,{src:E.logoUrl,width:14,height:14,logo:!0}):E.logoUrl(14),t.jsx("span",{className:ie.triggerText,children:E.name})]}),t.jsx($.IconChevronDown,{size:16,className:ie.icon})]})}),t.jsxs(gt.Popover.Portal,{container:ct(),children:[t.jsx(gt.Popover.Backdrop,{className:ie.popoverBackdrop,onClick:()=>l(!1)}),t.jsx(gt.Popover.Positioner,{className:ie.popoverPositioner,align:"end",side:"bottom",sideOffset:j,children:t.jsxs(gt.Popover.Popup,{className:R(ie.popoverPopup,{[ie.full]:r}),style:{maxHeight:u},children:[t.jsx(Es,{value:o,onChange:x=>{a(x.target.value),d(0)},onClear:()=>a(""),onKeyDown:C,placeholder:"Search appchains",rootClassName:ie.search,ref:Ht()}),t.jsx("div",{className:ie.viewport,role:"listbox",children:I.length===0?t.jsx(G,{children:"No appchains found"}):I.map(({chainId:x,name:P,logoUrl:q},B)=>t.jsxs("div",{className:R(ie.item,{[ie.highlighted]:B===c}),onClick:()=>N(x),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),N(x))},onMouseEnter:()=>d(B),role:"option","aria-selected":e===x,tabIndex:-1,ref:S=>{S&&(m.current[B]=S)},children:[t.jsxs("div",{className:ie.itemContent,children:[typeof q=="string"?t.jsx(z,{src:q,width:16,height:16,logo:!0}):q(16),t.jsx("span",{children:P})]}),e===x&&t.jsx($.IconCheck,{size:16})]},x))})]})})]})]})},Ql="2.0.2",Vl="_version_1sf5y_1",Gl={version:Vl},Yl=()=>t.jsxs("aside",{className:Gl.version,children:["v",Ql]}),Jl=H.atom(""),Zl=H.atom(""),Xl=H.atom(""),ed=H.atom(""),td=H.atom(""),sd="_popup_nbecp_1",nd="_item_nbecp_19",ts={popup:sd,item:nd},io=({asset:e,children:s})=>{const{denom:n,decimals:r,symbol:o,logoUrl:a,unlisted:i,address:l,chain:c}=e,{chainId:d}=c,[u,h]=_.useState(!1),m=ce(),f=ao(),{showNotification:g}=Cn(),{defaultChainId:p}=le(),{evm_chain_id:v}=Kt(),k=fe.useChainId(),{switchChainAsync:I}=fe.useSwitchChain(),{watchAssetAsync:E}=fe.useWatchAsset(),w=()=>{h(!1),m("/send",{denom:n,chain:c})},j=()=>{h(!1),m("/bridge",{srcChainId:d,srcDenom:n,quantity:""})},A=T.useMutation({mutationFn:async()=>{if(!l)throw new Error("Address is required");const C=a;return await I({chainId:Number(v)}),E({type:"ERC20",options:{address:l,symbol:o,decimals:r,image:C}})},onSuccess:()=>{g({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:C=>{g({type:"error",title:"Asset addition failed",description:C.message})}});return t.jsxs(Le.Menu.Root,{open:u,onOpenChange:h,modal:!1,children:[t.jsx(Le.Menu.Trigger,{render:s}),t.jsx(Le.Menu.Portal,{container:f.current,children:t.jsx(Le.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(Le.Menu.Popup,{className:ts.popup,children:[t.jsxs(Le.Menu.Item,{className:ts.item,onClick:w,children:[t.jsx($.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(Le.Menu.Item,{className:ts.item,onClick:j,disabled:i,children:[t.jsx($.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===p&&v===k&&!!l&&t.jsxs(Le.Menu.Item,{className:ts.item,onClick:()=>A.mutate(),disabled:A.isPending||A.data,children:[A.data?t.jsx($.IconCheck,{size:16}):t.jsx($.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},rd="_images_cj4xz_1",Gs={images:rd},qs=({assetLogoUrl:e,assetLogoSize:s=36,chainLogoUrl:n,chainLogoSize:r=18,chainLogoOffset:o=6,className:a})=>t.jsxs("div",{className:R(Gs.images,a),style:{position:"relative"},children:[t.jsx(z,{src:e,width:s,height:s,className:Gs.asset,logo:!0}),t.jsx(z,{src:n,width:r,height:r,className:Gs.chain,style:{position:"absolute",bottom:0,right:-1*o},logo:!0})]}),od="_item_knoro_1",ad="_info_knoro_22",id="_images_knoro_28",cd="_name_knoro_32",ld="_value_knoro_38",dd="_amount_knoro_46",ud="_usd_knoro_52",nt={item:od,info:ad,images:id,name:cd,value:ld,amount:dd,usd:ud},hd=({asset:e})=>{const{amount:s,value:n,logoUrl:r,chain:o}=e,a=b.formatAmount(s,{decimals:e.decimals});return t.jsx(io,{asset:e,children:t.jsxs("button",{className:nt.item,children:[t.jsxs("div",{className:nt.info,children:[t.jsx(qs,{assetLogoUrl:r,chainLogoUrl:o.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:nt.images}),t.jsx("span",{className:nt.name,children:o.name})]}),t.jsxs("div",{className:nt.value,children:[t.jsx("span",{className:nt.amount,children:a}),Number(n)>0&&t.jsx("span",{className:nt.usd,children:Ve(n)})]})]})})},md="_container_g5q73_1",_d="_assetItem_g5q73_6",fd="_assetInfo_g5q73_26",pd="_logo_g5q73_32",gd="_symbol_g5q73_36",xd="_chainName_g5q73_46",yd="_chainInfos_g5q73_52",jd="_chainLogos_g5q73_58",vd="_chainLogo_g5q73_58",wd="_moreChains_g5q73_69",bd="_expandIcon_g5q73_81",Cd="_expanded_g5q73_85",Id="_valueColumn_g5q73_90",Nd="_amount_g5q73_99",Sd="_value_g5q73_90",kd="_collapsibleContent_g5q73_112",Ad="_chainsList_g5q73_142",V={container:md,assetItem:_d,assetInfo:fd,logo:pd,symbol:gd,chainName:xd,chainInfos:yd,chainLogos:jd,chainLogo:vd,moreChains:wd,expandIcon:bd,expanded:Cd,valueColumn:Id,amount:Nd,value:Sd,collapsibleContent:kd,chainsList:Ad},$d=H.atom([]),co=({assetGroup:e})=>{const{symbol:s,logoUrl:n,assets:r}=e,o=r.length===1,[a,i]=H.useAtom($d),l=_.useMemo(()=>ja(e),[e]),c=_.useMemo(()=>jn(e),[e]),d=a.includes(s),u=()=>{i(m=>d?y.without([s],m):y.uniq([...m,s]))},h=()=>t.jsxs("button",{className:V.assetItem,children:[t.jsxs("div",{className:V.assetInfo,children:[n&&t.jsx(z,{src:n,width:32,height:32,className:V.logo,logo:!0}),t.jsxs("div",{className:V.details,children:[t.jsx("div",{className:V.symbol,children:s}),o?t.jsx("div",{className:V.chainName,children:r[0].chain.name}):t.jsxs("div",{className:V.chainInfos,children:[t.jsx("div",{className:V.chainLogos,children:r.slice(0,5).map(({chain:m})=>t.jsx(z,{src:m.logoUrl,width:16,height:16,className:V.chainLogo,logo:!0},m.chainId))}),r.length>5&&t.jsxs("span",{className:V.moreChains,children:["+",r.length-5]}),t.jsx($.IconChevronDown,{size:16,className:R(V.expandIcon,{[V.expanded]:d})})]})]})]}),t.jsxs("div",{className:V.valueColumn,children:[t.jsx("div",{className:V.amount,children:b.formatNumber(l,{dp:r[0].unlisted?0:6})}),c>0&&t.jsx("div",{className:V.value,children:Ve(c)})]})]});if(o){const[m]=r;return t.jsx("div",{className:V.container,children:t.jsx(io,{asset:m,children:h()})})}return t.jsx("div",{className:V.container,children:t.jsxs(Q.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(Q.Collapsible.Trigger,{asChild:!0,children:h()}),t.jsx(Q.Collapsible.Content,{className:V.collapsibleContent,children:t.jsx("div",{className:V.chainsList,children:r.map(m=>t.jsx(hd,{asset:m},m.chain.chainId))})})]})})},Td="_collapsible_1spkj_1",Ed="_trigger_1spkj_5",qd="_divider_1spkj_20",Dd="_label_1spkj_26",Pd="_chevron_1spkj_31",Rd="_content_1spkj_39",Bd="_list_1spkj_43",ze={collapsible:Td,trigger:Ed,divider:qd,label:Dd,chevron:Pd,content:Rd,list:Bd},Md=({unlistedAssets:e})=>{const[s,n]=_.useState(!0),r=ao(),o=_.useRef(null),[a,i]=_.useState(0);_.useEffect(()=>{if(o.current){const d=o.current.scrollHeight;i(d)}},[e]);const l=d=>{if(d&&!s&&r?.current){const u=r.current;u.scrollTo({top:u.scrollHeight,behavior:"auto"}),window.setTimeout(()=>{u.scrollTo({top:u.scrollHeight,behavior:"smooth"})},150)}n(d)},c=Qe.useSpring({height:s?a:0,opacity:s?1:0,config:{tension:500,friction:30,clamp:!0}});return e.length===0?null:t.jsxs(Q.Collapsible.Root,{open:s,onOpenChange:l,className:ze.collapsible,children:[t.jsxs(Q.Collapsible.Trigger,{className:ze.trigger,children:[t.jsx("div",{className:ze.divider}),t.jsxs("span",{className:ze.label,children:["Unlisted assets (",e.length,")"]}),t.jsx($.IconChevronDown,{className:ze.chevron,size:12,"data-state":s?"open":"closed"}),t.jsx("div",{className:ze.divider})]}),t.jsx(Q.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(Qe.animated.div,{className:ze.content,style:c,children:t.jsx("div",{className:ze.list,ref:o,children:e.map(d=>t.jsx(co,{assetGroup:{...d,assets:[d]}},d.denom))})})})]})},Fd="_list_szwvw_1",Od={list:Fd},Ld=()=>{const[e,s]=H.useAtom(Jl),[n,r]=H.useAtom(Zl),{assetGroups:o,unlistedAssets:a,chainsByValue:i,isLoading:l}=vn(),c=i.filter(({value:h})=>h).map(({chainId:h})=>h),d=_.useMemo(()=>{const h=e?o.filter(f=>{const{symbol:g,assets:p}=f;return g.toLowerCase().includes(e.toLowerCase())||p.some(({denom:v,address:k})=>v.toLowerCase().includes(e.toLowerCase())||k?.toLowerCase().includes(e.toLowerCase()))}):o;return n?h.map(f=>({...f,assets:f.assets.filter(({chain:g})=>g.chainId===n)})).filter(f=>f.assets.length>0):h},[o,e,n]),u=_.useMemo(()=>{const h=e?a.filter(({denom:f,address:g})=>f.toLowerCase().includes(e.toLowerCase())||g?.toLowerCase().includes(e.toLowerCase())):a;return n?h.filter(({chain:f})=>f.chainId===n):h},[a,e,n]);return l&&o.length===0?t.jsx(G,{children:"Loading assets..."}):!d.length&&!u.length&&!e&&!n&&!l?t.jsx(G,{children:"No assets"}):t.jsxs(t.Fragment,{children:[t.jsxs(We.Root,{children:[t.jsxs(We.Controls,{children:[t.jsx(We.SearchInput,{value:e,onChange:h=>s(h.target.value),onClear:()=>s(""),placeholder:"Search assets"}),t.jsx(Nn,{value:n,onChange:r,chainIds:c})]}),t.jsx("div",{children:d.length===0&&u.length===0?t.jsx(G,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Od.list,children:d.map(h=>t.jsx(co,{assetGroup:h},h.symbol))}),t.jsx(Md,{unlistedAssets:u})]})})]}),t.jsx(Yl,{})]})},lo=Ee.createQueryKeys("interwovenkit:nft",{nfts:(e,s)=>[e,s],metadata:e=>[e]});function Ud(e,s){const{nft:n}=e,r=s.name??n.token_id;return{...e,...n,...s,name:r}}function zd(e,s){return e.flatMap((n,r)=>(s[r]??[]).map(a=>({...a,chain:n})))}const Kd=()=>{const e=ne(),s=se(),n=T.useQueries({queries:s.map(i=>({queryKey:lo.nfts(i.indexerUrl,e).queryKey,queryFn:()=>Dr(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:i.indexerUrl},"tokens"),staleTime:U.SECOND}))}),r=n.map(y.prop("data")),o=zd(s,r),a=n.some(i=>i.isLoading);return{nftInfos:o,isLoading:a}};function Wd(e){const s=Kn(e);return T.useQuery({queryKey:lo.metadata(s).queryKey,queryFn:async()=>{try{if(!s)return{};const n=await Y.get(s).json();return{...n,image:Kn(n.image)}}catch{return{}}},staleTime:U.INFINITY})}function Kn(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const Hd="_thumbnail_1lblb_1",Qd="_placeholder_1lblb_16",Vd="_clickable_1lblb_22",Pt={thumbnail:Hd,placeholder:Qd,clickable:Vd},Sn=({nftInfo:e,size:s,onClick:n})=>{const{collection_addr:r,object_addr:o,nft:a,chain:i}=e,l=new URL(`/v1/${i.chainId}/${r}/${o||a.token_id}`,"https://glyph.initia.xyz").toString();return n?t.jsx("button",{className:R(Pt.thumbnail,Pt.clickable),onClick:n,style:{width:s,height:s},children:t.jsx(z,{src:l,classNames:{placeholder:Pt.placeholder}})}):t.jsx("div",{className:Pt.thumbnail,style:{width:s,height:s},children:t.jsx(z,{src:l,classNames:{placeholder:Pt.placeholder}})})},Gd="_nftItem_eopro_1",Yd="_collectionName_eopro_9",Jd="_nftName_eopro_19",Zd="_chainInfo_eopro_29",ss={nftItem:Gd,collectionName:Yd,nftName:Jd,chainInfo:Zd},Xd=({normalizedNft:e})=>{const{collection_name:s,name:n,chain:r}=e,o=ce();return t.jsxs("div",{className:ss.nftItem,children:[t.jsx(Sn,{nftInfo:e,onClick:()=>o("/nft",e)}),t.jsxs("div",{children:[t.jsx("div",{className:ss.collectionName,children:s}),t.jsx("div",{className:ss.nftName,children:n}),t.jsxs("div",{className:ss.chainInfo,children:[t.jsx(z,{src:r.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:r.name})]})]})]})},eu=({nftInfo:e,children:s})=>{const{data:n={}}=Wd(e.nft.uri),r=Ud(e,n);return s(r)},tu="_grid_a1fhu_1",su={grid:tu},nu=()=>{const[e,s]=H.useAtom(Xl),[n,r]=H.useAtom(ed),{nftInfos:o,isLoading:a}=Kd(),i=_.useMemo(()=>o.filter(({collection_addr:c,collection_name:d,nft:u,object_addr:h,chain:m})=>{if(n&&m.chainId!==n)return!1;if(e){const f=e.trim().toLowerCase();return c.toLowerCase().includes(f)||d.toLowerCase().includes(f)||u.token_id.toLowerCase().includes(f)||h.toLowerCase().includes(f)}return!0}),[o,n,e]),l=_.useMemo(()=>Array.from(new Set(o.map(({chain:c})=>c.chainId))),[o]);return a&&o.length===0?t.jsx(G,{children:"Loading NFTs..."}):!o.length&&!e&&!a?t.jsx(G,{children:"No NFTs"}):t.jsxs(We.Root,{children:[t.jsxs(We.Controls,{children:[t.jsx(We.SearchInput,{value:e,onChange:c=>s(c.target.value),onClear:()=>s(""),placeholder:"Search NFTs"}),t.jsx(Nn,{value:n,onChange:r,chainIds:l})]}),i.length===0?t.jsx(G,{children:"No NFTs found"}):t.jsx("div",{className:su.grid,children:i.map(c=>{const{collection_addr:d,nft:u}=c;return t.jsx(eu,{nftInfo:c,children:h=>t.jsx(Xd,{normalizedNft:h})},d+u.token_id)})})]})},ru="_message_1g2hc_1",ou="_more_1g2hc_8",Wn={message:ru,more:ou},au=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((s,n)=>t.jsx("p",{className:Wn.message,children:xs.sentenceCase(s["@type"].split("Msg")[1])},n)),e.length>3&&t.jsx("footer",{className:Wn.more,children:`+${e.length-3} more`})]}),iu="_change_1x9v4_1",cu="_positive_1x9v4_10",lu="_negative_1x9v4_14",Ys={change:iu,positive:cu,negative:lu},uo=({amount:e,asset:s})=>{const{denom:n,symbol:r,decimals:o}=s,a=new M(e).isPositive(),i=new M(e).abs().toString();return t.jsxs("div",{className:R(Ys.change,a?Ys.positive:Ys.negative),children:[a?"+":"-",b.formatAmount(i,{decimals:o})," ",r||n]})},du=({changes:e,chain:s})=>{const n=Je(s);return e.map(({amount:r,denom:o},a)=>t.jsx(uo,{amount:r,asset:n(o)},a))},uu=({changes:e,chain:s})=>{const n=Je(s);return e.map(({amount:r,metadata:o},a)=>t.jsx(Xr,{metadata:o,chain:s,children:i=>t.jsx(uo,{amount:r,asset:n(i)})},a))},hu=({events:e,chain:s})=>{const{initiaAddress:n,hexAddress:r}=ge();return s.metadata?.is_l1||s.metadata?.minitia?.type==="minimove"?t.jsx(uu,{changes:Zr(e,r),chain:s}):t.jsx(du,{changes:Jr(e,n),chain:s})},mu="_link_oq58b_1",_u="_inner_oq58b_15",fu="_header_oq58b_20",pu="_time_oq58b_29",gu="_error_oq58b_35",xu="_timestamp_oq58b_39",yu="_chainInfo_oq58b_44",ju="_content_oq58b_52",vu="_messages_oq58b_59",wu="_changes_oq58b_64",Ne={link:mu,inner:_u,header:fu,time:pu,error:gu,timestamp:xu,chainInfo:yu,content:ju,messages:vu,changes:wu},bu=({txItem:e,chain:s})=>t.jsx(Ts,{txHash:e.txhash,chainId:s.chainId,className:Ne.link,children:t.jsxs("div",{className:Ne.inner,children:[t.jsxs("div",{className:Ne.header,children:[t.jsxs("div",{className:Ne.time,children:[e.code!==0&&t.jsx($.IconWarningFilled,{size:14,className:Ne.error}),t.jsx("span",{className:Ne.timestamp,children:bt.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:Ne.chainInfo,children:[t.jsx(z,{src:s.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:s.name})]})]}),t.jsxs("div",{className:Ne.content,children:[t.jsx("div",{className:Ne.messages,children:t.jsx(au,{messages:e.tx.body.messages})}),t.jsx("div",{className:Ne.changes,children:t.jsx(de,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(hu,{...e,chain:s})})})]})]})}),Cu="_list_1wa9p_1",Iu="_dateGroup_1wa9p_7",Nu="_dateHeader_1wa9p_12",Su="_more_1wa9p_18",ns={list:Cu,dateGroup:Iu,dateHeader:Nu,more:Su},ku=({list:e,chainId:s})=>{const n=ne(),r=_.useMemo(()=>e.reduce((o,a)=>{if(!a.timestamp)return o;const l=new Date(a.timestamp).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),c=o[l]||[];return{...o,[l]:[...c,a]}},{}),[e]);return e.length===0?t.jsx(G,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ns.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{className:ns.dateGroup,children:[t.jsx("div",{className:ns.dateHeader,children:o}),a.map(i=>t.jsx(de,{errorBoundaryProps:{fallback:null},children:t.jsx(bu,{txItem:i,chain:i.chain})},i.txhash))]},o))}),t.jsx(Ts,{chainId:s,accountAddress:n,pathSuffix:"/txs",className:ns.more,showIcon:!0,children:"View more on Initia Scan"})]})},Au=()=>{const{activities:e,isLoading:s}=ei(),[n,r]=H.useAtom(td),o=pe(),a=_.useMemo(()=>Array.from(new Set(e.map(l=>l.chain.chainId))),[e]),i=_.useMemo(()=>n?e.filter(l=>l.chain.chainId===n):e,[e,n]);return s&&e.length===0?t.jsx(G,{children:"Loading activities..."}):!e.length&&!s?t.jsx(G,{children:"No activity yet"}):t.jsxs(We.Root,{children:[t.jsx(We.Controls,{children:t.jsx(Nn,{value:n,onChange:r,chainIds:a,fullWidth:!0})}),t.jsx(ku,{list:i,chainId:n||o.chainId})]})},$u="_totalValue_1udv1_1",Tu="_totalLabel_1udv1_7",Eu="_totalAmount_1udv1_13",qu="_loading_1udv1_18",Du="_nav_1udv1_23",Pu="_item_1udv1_28",Ru="_tabs_1udv1_51",Bu="_tab_1udv1_51",ve={totalValue:$u,totalLabel:Tu,totalAmount:Eu,loading:qu,nav:Du,item:Pu,tabs:Ru,tab:Bu},Mu=()=>{ro();const e=ce(),s=vs(),{totalValue:n,isLoading:r}=vn(),o=_.useRef(null);return t.jsx(oo.Provider,{value:o,children:t.jsxs(Fe,{ref:o,children:[t.jsxs("div",{className:ve.totalValue,children:[t.jsx("div",{className:ve.totalLabel,children:"Total value"}),t.jsx("div",{className:R(ve.totalAmount,{[ve.loading]:r}),children:Ve(n)})]}),t.jsxs("div",{className:ve.nav,children:[t.jsxs(pn,{to:"/send",className:ve.item,children:[t.jsx($.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs("button",{className:ve.item,onClick:()=>e("/bridge"),children:[t.jsx($.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]})]}),t.jsxs(Oe.Tabs.Root,{value:s,onValueChange:e,children:[t.jsxs(Oe.Tabs.List,{className:ve.tabs,children:[t.jsx(Oe.Tabs.Tab,{className:ve.tab,value:"/",children:"Assets"}),t.jsx(Oe.Tabs.Tab,{className:ve.tab,value:"/nfts",children:"NFTs"}),t.jsx(Oe.Tabs.Tab,{className:ve.tab,value:"/activity",children:"Activity"})]}),t.jsx(Oe.Tabs.Panel,{value:"/",children:t.jsx(Ld,{})}),t.jsx(Oe.Tabs.Panel,{value:"/nfts",children:t.jsx(nu,{})}),t.jsx(Oe.Tabs.Panel,{value:"/activity",children:t.jsx(Au,{})})]})]})})},Fu="_header_acels_1",Ou="_back_acels_11",Lu="_title_acels_23",Js={header:Fu,back:Ou,title:Lu},ht=({title:e,backButton:s,extra:n,children:r})=>t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Js.header,children:[t.jsx(pn,{to:s??-1,className:Js.back,shouldReset:!!s,children:t.jsx($.IconBack,{size:16})}),t.jsx("h1",{className:Js.title,children:e}),n]}),t.jsx(Fe,{children:r})]}),Uu="_fieldset_y241y_1",zu="_upper_y241y_9",Ku="_select_y241y_14",Wu="_account_y241y_19",Hu="_lower_y241y_24",Qu="_wrapper_y241y_25",Vu="_balance_y241y_32",Gu="_value_y241y_36",Yu="_error_y241y_49",De={fieldset:Uu,upper:zu,select:Ku,account:Wu,lower:Hu,wrapper:Qu,balance:Vu,value:Gu,error:Yu},cn=e=>{const{selectButton:s,accountButton:n,quantityInput:r,balanceButton:o,value:a,errorMessage:i}=e;return t.jsxs("div",{className:De.fieldset,children:[t.jsxs("div",{className:De.upper,children:[t.jsx("div",{className:De.select,children:s}),t.jsx("div",{className:De.account,children:n})]}),t.jsxs("div",{className:De.lower,children:[r,t.jsxs("div",{className:De.wrapper,children:[t.jsx("div",{className:De.balance,children:o}),a&&t.jsx("div",{className:De.value,children:a})]}),i&&t.jsxs("footer",{className:De.error,children:[t.jsx($.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})},Ju="_root_1ipwv_1",Zu="_content_1ipwv_10",Xu="_details_1ipwv_18",eh="_symbol_1ipwv_23",th="_chain_1ipwv_31",sh="_chevron_1ipwv_40",rt={root:Ju,content:Zu,details:Xu,symbol:eh,chain:th,chevron:sh},ho=({asset:e,chain:s,readOnly:n})=>{const r=t.jsxs("div",{className:rt.content,children:[t.jsx(qs,{assetLogoUrl:e.logoUrl,chainLogoUrl:s.logoUrl}),t.jsxs("div",{className:rt.details,children:[t.jsx("div",{className:rt.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:rt.chain,children:["on ",s.name]})]})]});return n?t.jsx("div",{className:rt.root,children:r}):t.jsxs("div",{className:rt.root,children:[r,t.jsx($.IconChevronDown,{size:16,className:rt.chevron})]})},nh="_wrapper_5ssm8_1",rh="_balance_5ssm8_11",oh="_button_5ssm8_15",Zs={wrapper:nh,balance:rh,button:oh},mo=({onClick:e,children:s,disabled:n})=>t.jsxs("div",{className:Zs.wrapper,children:[t.jsx($.IconWallet,{size:16}),t.jsx("span",{className:Zs.balance,children:s}),t.jsx("button",{type:"button",className:Zs.button,onClick:()=>e(),disabled:n,children:"MAX"})]}),ah="_input_h8073_1",ih={input:ah};function ch(e,s){const n=e.replace(/[^0-9.]/g,""),[r,...o]=n.split(".");return o.length===0?r:`${r}.${o.join("").slice(0,s)}`}function _o(e){const{name:s,control:n,dp:r=6,className:o,rules:a,...i}=e,l=Ht();return t.jsx(re.Controller,{name:s,control:n,rules:a,render:({field:c})=>t.jsx("input",{...c,className:R(ih.input,o),onChange:d=>c.onChange(ch(d.target.value,r)),placeholder:"0",inputMode:"decimal",autoComplete:"off",...i,ref:hr.mergeRefs([c.ref,l])})})}const lh="_input_qpv94_1",dh="_placeholder_qpv94_18",ln={input:lh,placeholder:dh},uh=({children:e})=>t.jsx("p",{className:R(ln.input,{[ln.placeholder]:M(e).isZero()}),children:e}),fs=({balance:e,decimals:s})=>{const{control:n}=re.useFormContext(),r={required:"Enter amount",validate:o=>M(o).isZero()?"Enter amount":M(b.toBaseUnit(o,{decimals:s})).gt(e??0)?"Insufficient balance":!0};return t.jsx(_o,{name:"quantity",control:n,className:ln.input,rules:r})};fs.ReadOnly=uh;const hh="_label_9417z_1",mh="_wrapper_9417z_7",_h="_input_9417z_10",fh="_clear_9417z_18",rs={label:hh,wrapper:mh,input:_h,clear:fh},kn=({mode:e="onChange",myAddress:s,...n})=>{const{validate:r=b.InitiaAddress.validate,chainType:o="initia",onApply:a,ref:i}=n,l=Ht(),{control:c,getValues:d,setValue:u,formState:h}=re.useFormContext(),m=d("recipient"),[f,g]=_.useState(m),p=Mr(),{data:v,isLoading:k,error:I}=T.useQuery({queryKey:ks.address(p.restUrl,f).queryKey,queryFn:()=>p.getAddress(f),staleTime:U.MINUTE,enabled:p.validateUsername(f)}),E=v??(r(f)?f:""),w=s&&b.InitiaAddress.equals(E,s),j=async()=>{try{const N=await navigator.clipboard.readText();g(N.trim())}catch{}};_.useEffect(()=>{e==="onChange"&&(!f&&!h.dirtyFields.recipient||u("recipient",v??f,{shouldValidate:!0,shouldDirty:!0}))},[h.dirtyFields.recipient,f,e,u,v]);const A=()=>{k||I||(u("recipient",E,{shouldValidate:!0,shouldDirty:!0}),a?.())},C=()=>{if(k)return t.jsx(Ke,{level:"loading",children:"Resolving username..."});if(I)return t.jsx(Ke,{level:"error",children:I.message});if(v)return t.jsx(Ke,{level:"success",className:"monospace",children:v});if(e==="onSubmit"&&f&&!E)return t.jsx(Ke,{level:"error",children:"Invalid address"});if(e==="onChange")return t.jsx(Ke,{level:"error",children:h.errors.recipient?.message})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:rs.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(W.Small,{type:"button",onClick:j,children:"Paste"})]}),t.jsxs("div",{className:rs.wrapper,children:[t.jsx(re.Controller,{name:"recipient",control:c,rules:{required:"Recipient address is required",validate:N=>r(N)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:R(rs.input,"monospace"),value:f,onChange:N=>g(N.target.value.trim()),placeholder:o==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?hr.mergeRefs([i,l]):i})}),!!f&&t.jsx("button",{type:"button",className:rs.clear,onClick:()=>g(""),"aria-label":"Clear recipient",children:t.jsx($.IconCloseCircleFilled,{size:16})})]}),C(),w&&t.jsx(Ke,{children:"This is my address"}),e==="onSubmit"&&t.jsx(te,{extra:(!s||!!E&&!w)&&t.jsx(ee,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:t.jsx(W.White,{type:"button",onClick:A,disabled:k||!!I||!E,children:"Apply"})})]})};function ph({balances:e,gasPrices:s,gas:n}){return s.map(({denom:r,amount:o})=>{const a=M(o).times(n).toFixed(0,M.ROUND_CEIL),i=e.find(l=>l.denom===r)?.amount??"0";return{amount:a,denom:r,balance:i}}).filter(({amount:r,balance:o})=>M(o).gte(r))}function gh({denom:e,balances:s,gasPrices:n,lastFeeDenom:r,gas:o}){const a=s.find(d=>d.denom===e)?.amount??"0",i=ph({balances:s,gasPrices:n,gas:o}),l=i.find(d=>d.denom===r);if(i.length===0)return a;if(e===r&&l){const d=M(a).minus(l.amount);return M.max(d,0).toString()}const c=i.find(d=>d.denom!==e)||i[0];if(!l&&e===c.denom){const d=M(a).minus(c.amount);return M.max(d,0).toString()}return M(a).toString()}const xh="_container_1a4ds_1",yh="_badge_1a4ds_5",Hn={container:xh,badge:yh},fo=e=>{const{offset:s=-4,disabled:n,children:r,className:o}=e;return t.jsxs("div",{className:R(Hn.container,o),children:[r,!n&&t.jsx("div",{className:Hn.badge,style:{right:s,top:s}})]})},jh="_tooltip_6zakp_1",vh="_arrow_6zakp_43",Qn={tooltip:jh,arrow:vh},Qt=({label:e,children:s,small:n,...r})=>t.jsxs(Q.Tooltip.Root,{...r,children:[t.jsx(Q.Tooltip.Trigger,{asChild:!0,children:s}),t.jsx(Q.Tooltip.Portal,{container:ct(),children:t.jsxs(Q.Tooltip.Content,{className:R(Qn.tooltip,{small:n}),collisionBoundary:ct(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(Q.Tooltip.Arrow,{className:Qn.arrow})]})})]}),wh="_stack_a3b9q_1",bh="_title_a3b9q_8",Ch="_grid_a3b9q_15",Ih="_item_a3b9q_21",Nh="_button_a3b9q_25",Sh="_active_a3b9q_43",yt={stack:wh,title:bh,grid:Ch,item:Ih,button:Nh,active:Sh},it=({label:e,chains:s,value:n,onSelect:r,getShowIndicator:o})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:yt.title,children:e}),t.jsx("div",{className:yt.grid,children:s.map(({chainId:a,name:i,logoUrl:l})=>t.jsx(fo,{offset:-2,disabled:!o?.(a),className:yt.item,children:t.jsx(Qt,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:R(yt.button,{[yt.active]:a===n}),onClick:()=>r(a),children:t.jsx(z,{src:l,width:28,height:28,logo:!0})})})},a))})]}),kh=({children:e})=>t.jsx("div",{className:yt.stack,children:e});it.Stack=kh;function Ah(e,s,n){return n.filter(r=>{const o=e.map(a=>r[a]).map(a=>String(a??"").toLowerCase());return y.any(y.includes(s.toLowerCase()),o)})}const $h="_container_1voou_1",Th="_search_1voou_6",Eh="_list_1voou_10",qh="_item_1voou_14",Dh="_logo_1voou_35",Ph="_info_1voou_39",Rh="_symbol_1voou_44",Bh="_name_1voou_52",Mh="_balance_1voou_58",Fh="_value_1voou_65",_e={container:$h,search:Th,list:Eh,item:qh,logo:Dh,info:Ph,symbol:Rh,name:Bh,balance:Mh,value:Fh},Vt=e=>{const{assets:s,onSelect:n,renderAsset:r=(l,c)=>c(l)}=e,[o,a]=_.useState(""),i=Ah(["symbol"],o,s);return t.jsxs("div",{className:_e.container,children:[t.jsx(Es,{value:o,onChange:l=>a(l.target.value),onClear:()=>a(""),placeholder:"Search by symbol",rootClassName:_e.search,padding:20,ref:Ht()}),i.length===0?t.jsx(G,{children:"No assets"}):t.jsx("div",{className:_e.list,children:i.map(l=>t.jsx("button",{type:"button",className:_e.item,onClick:()=>n(l.denom),children:r(l,c=>{const{denom:d,logoUrl:u,symbol:h,name:m,balance:f,decimals:g,value:p=0}=c;return t.jsxs(t.Fragment,{children:[t.jsx(z,{src:u,width:32,height:32,className:_e.logo,logo:!0}),t.jsxs("div",{className:_e.info,children:[t.jsx("div",{className:_e.symbol,children:h||d}),t.jsx("div",{className:_e.name,children:m})]}),t.jsxs("div",{className:_e.balance,children:[f&&t.jsx("div",{children:b.formatAmount(f,{decimals:g})}),p>0&&t.jsx("div",{className:_e.value,children:Ve(p)})]})]})})},l.denom))})]})},Oh=()=>t.jsxs("div",{className:_e.container,children:[t.jsx(Es,{rootClassName:_e.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(G,{children:"Loading..."})]});Vt.Placeholder=Oh;const Lh=({chain:e,onSelect:s})=>{const n=ga(e);return t.jsx(Vt,{assets:n,onSelect:s})},Uh=({afterSelect:e})=>{const{watch:s,setValue:n}=re.useFormContext(),{chainId:r,denom:o}=s(),{chainId:a}=s(),[i,l]=_.useState(a),c=Be(i),d=se(),u=h=>{if(r===i&&o===h){e();return}n("chainId",i),n("denom",h),n("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(it.Stack,{children:t.jsx(it,{chains:d,value:i,onSelect:l})}),t.jsx(de,{suspenseFallback:t.jsx(Vt.Placeholder,{}),children:t.jsx(Lh,{chain:c,onSelect:u})},i)]})},zh="_fields_brpej_1",Kh="_divider_brpej_11",Vn={fields:zh,divider:Kh},Wh=Ee.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Hh=()=>{const{address:e,initiaAddress:s,estimateGas:n,requestTxSync:r}=ge(),{register:o,watch:a,setValue:i,handleSubmit:l,formState:c}=re.useFormContext(),{chainId:d,denom:u,recipient:h,quantity:m,memo:f}=a(),g=Be(d),p=yn(g),v=Vr(g),k=Gr(g),I=Rr(u,g),{data:E}=bs(g),{decimals:w}=I,j=p.find(S=>S.denom===u)?.amount??"0",A=E?.find(({id:S})=>S===u)?.price,{data:C=0,isLoading:N}=T.useQuery({queryKey:Wh.gas({chainId:d,denom:u,recipient:h,initiaAddress:s}).queryKey,queryFn:()=>{const S=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Pn.MsgSend.fromPartial({fromAddress:s,toAddress:b.InitiaAddress(h).bech32,amount:[{denom:u,amount:"1"}]})}];return n({messages:S,chainId:d})},enabled:b.InitiaAddress.validate(h),staleTime:U.INFINITY}),x=Math.ceil(C*Lt),P=gh({denom:u,balances:p,gasPrices:v,lastFeeDenom:k,gas:x}),{mutate:q,isPending:B}=T.useMutation({mutationFn:({chainId:S,denom:O,quantity:D,recipient:oe,memo:Z})=>{const xe=b.toBaseUnit(D,{decimals:w}),ue=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Pn.MsgSend.fromPartial({fromAddress:s,toAddress:b.InitiaAddress(oe).bech32,amount:[{denom:O,amount:xe}]})}];return r({messages:ue,memo:Z,chainId:S,gas:C,gasAdjustment:Lt,gasPrices:v,spendCoins:[{denom:O,amount:xe}],internal:"/"})}});return t.jsx(ht,{title:"Send",children:t.jsxs("form",{onSubmit:l(S=>q(S)),children:[t.jsxs("div",{className:Vn.fields,children:[t.jsx(cn,{selectButton:t.jsx(lt,{title:"Select chain and asset",content:S=>t.jsx(Uh,{afterSelect:S}),children:t.jsx(ho,{asset:I,chain:g})}),quantityInput:t.jsx(fs,{balance:j,decimals:w}),balanceButton:t.jsx(mo,{onClick:()=>i("quantity",b.fromBaseUnit(P,{decimals:w}),{shouldValidate:!0}),disabled:v.some(({denom:S})=>S===u)&&N,children:b.formatAmount(j??"0",{decimals:w})}),value:m?A?Ve(M(m).times(A)):"$-":"$0",errorMessage:c.errors.quantity?.message}),t.jsx("div",{className:Vn.divider}),t.jsx(kn,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...o("memo",{validate:S=>!S||new Blob([S]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"}),t.jsx(Ke,{level:"error",children:c.errors.memo?.message})]}),t.jsx(ee.Stack,{children:!f&&t.jsx(ee,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(te,{children:t.jsx(W.White,{type:"submit",loading:N||B,disabled:!c.isValid,children:"Confirm"})})]})})},Qh=()=>{const e=dt(),s=Kt(),n=Ut(s),[r]=n,{chain:o=s,denom:a=r.denom}=e,i=re.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:a,quantity:"",recipient:"",memo:""}});return t.jsx(re.FormProvider,{...i,children:t.jsx(Hh,{})})},Vh="_header_4z0mk_1",Gh="_collectionName_4z0mk_6",Yh="_name_4z0mk_12",Jh="_chainInfo_4z0mk_18",Zh="_attributes_4z0mk_28",Xh="_title_4z0mk_31",em="_count_4z0mk_36",tm="_item_4z0mk_40",sm="_type_4z0mk_46",nm="_value_4z0mk_52",Se={header:Vh,collectionName:Gh,name:Yh,chainInfo:Jh,attributes:Zh,title:Xh,count:em,item:tm,type:sm,value:nm},rm=()=>{const e=ce(),s=dt(),{collection_name:n,image:r,name:o,attributes:a,chain:i}=s;return t.jsxs(ht,{title:"NFT details",children:[t.jsxs("header",{className:Se.header,children:[r&&t.jsx(Sn,{nftInfo:s}),t.jsxs("div",{children:[t.jsx("div",{className:Se.collectionName,children:n}),t.jsx("h2",{className:Se.name,children:o}),t.jsxs("div",{className:Se.chainInfo,children:[t.jsx(z,{src:i.logoUrl,width:14,height:14,logo:!0}),t.jsx("span",{children:i.name})]})]})]}),t.jsx(te,{children:t.jsx(W.White,{onClick:()=>e("/nft/send",s),sm:!0,children:"Send"})}),a&&t.jsxs("div",{className:Se.attributes,children:[t.jsxs("header",{className:Se.title,children:["Traits ",t.jsxs("span",{className:Se.count,children:["(",a.length,")"]})]}),t.jsx("div",{children:a.map(({trait_type:l,value:c})=>t.jsxs("div",{className:Se.item,children:[t.jsx("div",{className:Se.type,children:l}),t.jsx("div",{className:Se.value,children:c})]},l))})]})]})},om="_scrollable_1p1lw_1",am="_list_1p1lw_5",im="_item_1p1lw_9",cm="_name_1p1lw_13",os={scrollable:om,list:am,item:im,name:cm};function po({onSelect:e,list:s,...n}){const{getImage:r,getName:o,getKey:a,getIsLoading:i,getDisabled:l}=n;return t.jsx(Fe,{className:os.scrollable,children:t.jsx("div",{className:os.list,children:s.map(c=>t.jsxs("button",{className:os.item,onClick:()=>e(c),disabled:i?.(c)||l?.(c),children:[t.jsx(z,{src:r(c),width:28,height:28}),t.jsx("span",{className:os.name,children:o(c)}),i?.(c)&&t.jsx(Ze,{size:16})]},a(c)))})})}const lm="_header_5w36t_1",dm="_name_5w36t_8",um="_collection_5w36t_15",hm="_nft_5w36t_20",mm="_fields_5w36t_24",_m="_chain_5w36t_29",xt={header:lm,name:dm,collection:um,nft:hm,fields:mm,chain:_m},fm=Ee.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),pm=()=>{const e=se(),s=dt(),{chain:n,collection_addr:r,collection_name:o,image:a,name:i}=s,{routerApiUrl:l}=le(),c=Is(),d=pe(),{address:u,initiaAddress:h,requestTxSync:m}=ge(),{watch:f,setValue:g,handleSubmit:p,formState:v}=re.useFormContext(),k=f(),{recipient:I,dstChainId:E}=k,w=Be(E),j=T.useQuery({queryKey:fm.simulation({collection_addr:r,nft:s,sender:h,recipient:I,srcChain:n,dstChain:w,layer1:d,routerApiUrl:l}).queryKey,queryFn:async()=>{const q={from_address:h,from_chain_id:n.chainId,to_address:b.InitiaAddress(I).bech32,to_chain_id:w.chainId,collection_address:r,token_ids:[s.token_id],object_addresses:[s.object_addr]},{msgs:B}=await Y.create({prefixUrl:l}).post("nft",{json:q}).json();return B.map(S=>c.fromAmino(S))},enabled:b.InitiaAddress.validate(I)}),{data:A,isLoading:C,error:N}=j,{mutate:x,isPending:P}=T.useMutation({mutationFn:async()=>{if(!A)throw new Error("Route not found");await m({messages:A,chainId:n.chainId,internal:"/nfts"})}});return t.jsxs("form",{onSubmit:p(()=>x()),children:[t.jsxs("header",{className:xt.header,children:[a&&t.jsx(Sn,{nftInfo:s,size:80}),t.jsxs("div",{className:xt.name,children:[t.jsx("div",{className:xt.collection,children:o}),t.jsx("div",{className:xt.nft,children:i})]})]}),t.jsxs("div",{className:xt.fields,children:[t.jsx(Q.VisuallyHidden.Root,{children:t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(lt,{title:"Destination appchain",content:q=>t.jsx(po,{onSelect:({chainId:B})=>{g("dstChainId",B),q()},list:e,getImage:B=>B.logoUrl,getName:B=>B.name,getKey:B=>B.chainId}),className:R("input",xt.chain),children:[t.jsx(z,{src:w.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:w.name})]})]})}),t.jsx(kn,{myAddress:u,ref:Ht()})]}),t.jsx(te,{children:t.jsx(W.White,{loading:C||P,disabled:!v.isValid||!!N,children:N?"Route not found":"Confirm"})})]})},gm=()=>{const{chain:e}=dt(),s=re.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(ht,{title:"Send NFT",children:t.jsx(re.FormProvider,{...s,children:t.jsx(pm,{})})})};function xm(){return pe().network_type==="testnet"}function Xe(){return re.useFormContext()}function ym(){const e=dt(),s=xm(),n={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},r={...n,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},o={...n,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},a=y.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(F.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(F.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(F.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(F.BRIDGE_DST_DENOM),quantity:localStorage.getItem(F.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(F.BRIDGE_SLIPPAGE_PERCENT)});return{...s?r:o,...a,...e}}function go(){const{initiaAddress:e,hexAddress:s}=ge(),n=ut(),r=Wt();return o=>{const a=n(o);switch(r(a)){case"initia":return e;case"evm":return s;default:return""}}}function xo(){const e=ut(),s=Wt();return(n,r)=>{const o=e(r);switch(s(o)){case"initia":return b.InitiaAddress.validate(n);case"evm":return He.isAddress(n);case"cosmos":try{return K.fromBech32(n).prefix===o.bech32_prefix}catch{return!1}default:return!1}}}function jm(){const e=ut(),s=Wt();return({initialAddress:n,initialChainId:r,chainId:o,fallbackAddress:a})=>{const i=e(r),l=s(i),c=e(o),d=s(c);if(l==="evm"&&d==="initia")return b.InitiaAddress(n).bech32;if(l==="initia"&&d==="evm")return b.InitiaAddress(n).hex;if(l===d)return n;if(a){if(d==="initia")return b.InitiaAddress(a).bech32;if(d==="evm")return b.InitiaAddress(a).hex}return""}}const vm=[["d",1440*60],["h",3600],["m",60],["s",1]];function dn(e){if(!e)return;const{formattedParts:s}=vm.reduce(({remainingSeconds:n,formattedParts:r},[o,a])=>{const i=Math.floor(n/a);return{remainingSeconds:n-i*a,formattedParts:i>0?[...r,`${i}${o}`]:r}},{remainingSeconds:e,formattedParts:[]});return s.join(" ")}function yo(e){return e?.map(s=>{const{amount:n,origin_asset:r}=s;return`${b.formatAmount(n,{decimals:r.decimals??0})} ${r.symbol}`}).join(", ")}function Gn(e,s){const{watch:n}=Xe(),r=n(),o=Me(),a=Ns(),i={...r,quantity:e},l=T.useQueryClient();return T.useQuery({queryKey:$e.route(i,s?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:c,srcDenom:d,quantity:u,dstChainId:h,dstDenom:m}=i,{decimals:f}=l.getQueryData($e.asset(c,d).queryKey)??{decimals:0},g={amount_in:b.toBaseUnit(u,{decimals:f}),source_asset_chain_id:c,source_asset_denom:d,dest_asset_chain_id:h,dest_asset_denom:m,is_op_withdraw:s?.isOpWithdraw},p=await o.post("v2/fungible/route",{json:g}).json(),v={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return a("Bridge Simulation Success",v),p},enabled:!!Number(i.quantity)&&!s?.disabled,staleTime:U.MINUTE})}function wm(e){return T.useQuery({queryKey:$e.routeErrorInfo(e||new Error).queryKey,queryFn:async()=>{if(!e||!(e instanceof Y.HTTPError))return null;const{response:s}=e;return(s.headers.get("content-type")??"").includes("application/json")?(await s.json()).info??null:null}})}function bm(){const{watch:e}=Xe(),{srcChainId:s,srcDenom:n,dstChainId:r,dstDenom:o}=e(),a=Te(s),i=zt(a),l=Re(n,s),c=Re(o,r),d=pe(),u=se();return i==="initia"&&r===d.chainId&&l.symbol===c.symbol&&u.find(h=>h.chainId===s)?.metadata?.op_denoms?.includes(c.denom)}function An(e,s){const n=Me();return T.useQuery({queryKey:$e.balances(s,e).queryKey,queryFn:()=>n.post("v2/info/balances",{json:{chains:{[s]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>e?r?r[s].denoms??{}:{}:{},enabled:!!e,staleTime:U.SECOND})}function Cm(e,s,n){const{data:r={}}=An(e,s);return y.path([n],r)}const Im=({address:e,chain:s,onSelect:n})=>{const r=wt(s.chain_id),{data:o={}}=An(e,s.chain_id);return t.jsx(Vt,{assets:y.sortWith([y.descend(a=>a.symbol==="INIT"),y.descend(a=>a.value),({balance:a="0"},{balance:i="0"})=>M(i).comparedTo(a)??0,y.ascend(a=>a.symbol.toLowerCase())],r.filter(a=>!a.hidden).map(a=>{const{denom:i,symbol:l=b.truncate(i),logo_uri:c}=a,d=o[i]??{};return{...a,symbol:l,decimals:a.decimals??0,logoUrl:c??"",name:a.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:n})},Nm=({type:e,afterSelect:s})=>{const n=e==="src"?"srcChainId":"dstChainId",r=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"sender":"recipient",a=Nt(),i=wn(),{watch:l,setValue:c}=Xe(),d=l(o),u=l(n),h=l(r),[m,f]=_.useState(u),g=Te(m),p=jm(),v=Lr(),[k,I]=y.partition(w=>v(w.chain_id),i.filter(w=>!w.hidden)),E=w=>{if(u===m&&h===w){s();return}c(n,m),c(r,w),s()};return t.jsxs(t.Fragment,{children:[t.jsxs(it.Stack,{children:[t.jsx(it,{label:"Interwoven Economy",chains:k.map(({chain_id:w,chain_name:j,pretty_name:A,logo_uri:C})=>({chainId:w,name:A||j,logoUrl:C??""})),value:m,onSelect:f}),t.jsx(it,{label:"Chains",chains:I.map(({chain_id:w,chain_name:j,pretty_name:A,logo_uri:C})=>({chainId:w,name:A||j,logoUrl:C??""})),value:m,onSelect:f})]}),t.jsx(de,{suspenseFallback:t.jsx(Vt.Placeholder,{}),children:t.jsx(Im,{address:p({initialAddress:d,initialChainId:u,chainId:m,fallbackAddress:e==="src"?a:void 0}),chain:g,onSelect:E})},m)]})},Yn=({type:e})=>{const s=e==="src"?"srcChainId":"dstChainId",n=e==="src"?"srcDenom":"dstDenom",r=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:o}=Xe(),a=o(s),i=o(n),l=Te(a),c=Re(i,a);return t.jsx(lt,{title:r,content:d=>t.jsx(Nm,{type:e,afterSelect:d}),children:t.jsx(ho,{asset:{denom:c.denom,decimals:c.decimals??0,symbol:c.symbol,logoUrl:c.logo_uri??""},chain:{chainId:l.chain_id,name:l.pretty_name||l.chain_name,logoUrl:l.logo_uri??""}})})};function Ds(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:n=>e.find(r=>r.name===n)}}const Sm="_account_iwrlj_8",km="_clear_iwrlj_27",Am="_white_iwrlj_38",Rt={account:Sm,clear:km,white:Am},Jn=({type:e})=>{const{watch:s,setValue:n}=Xe(),{srcChainId:r,dstChainId:o,cosmosWalletName:a}=s(),l=s(e==="src"?"sender":"recipient"),c=zt(Te(o)),{list:d,find:u}=Ds(),h=u(a),m=go(),f=xo(),g=m(o),p=b.InitiaAddress.equals(l,g),v=()=>t.jsx(lt,{title:"Connect wallet",content:E=>t.jsx(po,{onSelect:async w=>{const j=w.getProvider();if(!j)return window.open(w.fallbackUrl,"_blank");const A=j.getOfflineSigner(r),[{address:C}]=await A.getAccounts();n("sender",C),n("cosmosWalletName",w.name),E()},list:d,getImage:w=>w.image,getName:w=>w.name,getKey:w=>w.name}),className:R(Rt.account,{[Rt.white]:!l}),children:l?t.jsxs(t.Fragment,{children:[h&&t.jsx(z,{src:h.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:b.truncate(l)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx($.IconChevronRight,{size:14})]})}),k=E=>t.jsx(lt,{title:"Recipient",content:w=>t.jsx(Fe,{children:t.jsx(kn,{mode:"onSubmit",myAddress:g,chainType:c,validate:j=>f(j,o),onApply:w})}),className:Rt.account,children:E}),I=()=>{switch(c){case"initia":case"evm":return p?k(t.jsx($.IconWallet,{size:14})):t.jsxs("div",{className:Rt.account,children:[t.jsx("span",{className:"monospace",children:b.truncate(l)}),t.jsx("button",{type:"button",className:Rt.clear,onClick:()=>n("recipient",g,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx($.IconCloseCircleFilled,{size:14})})]});case"cosmos":return k(t.jsxs(t.Fragment,{children:[l?t.jsx("span",{className:"monospace",children:b.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx($.IconEdit,{size:14})]}))}};switch(e){case"src":return v();case"dst":return I()}},$m="_description_l5bcv_1",Tm="_presets_l5bcv_8",Em="_preset_l5bcv_8",qm="_active_l5bcv_29",Dm="_custom_l5bcv_40",Pm="_wrapper_l5bcv_46",Rm="_percent_l5bcv_49",ke={description:$m,presets:Tm,preset:Em,active:qm,custom:Dm,wrapper:Pm,percent:Rm},Zn=["0.1","0.5","1.0"],Bm=({afterConfirm:e})=>{const s=Xe(),n=s.getValues("slippagePercent"),[r,o]=_.useState(null),{control:a,watch:i,getValues:l,setValue:c}=re.useForm({defaultValues:{value:n}}),d=i("value");_.useEffect(()=>{const p=Zn.findIndex(v=>v===n);o(p>=0?p:null)},[n]);const u=(p,v)=>{c("value",p),o(v)},h=()=>{o(null)},m=_.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),f=m?.type==="error",g=({value:p})=>{s.setValue("slippagePercent",p),e()};return t.jsxs(Fe,{children:[t.jsx("p",{className:ke.description,children:"Slippage is how much price movement you can tolerate between the time you send out a transaction and the time it's executed."}),t.jsxs("div",{className:ke.presets,children:[Zn.map((p,v)=>t.jsxs("button",{type:"button",className:R(ke.preset,{[ke.active]:r===v}),onClick:()=>u(p,v),children:[p,"%"]},p)),r!==null?t.jsx("button",{type:"button",className:R(ke.preset,ke.custom),onClick:()=>o(null),children:"Custom"}):t.jsxs("div",{className:ke.wrapper,children:[t.jsx(_o,{name:"value",control:a,dp:2,onFocus:h,placeholder:"",className:R(ke.preset,ke.active)}),t.jsx("span",{className:ke.percent,children:"%"})]})]}),m&&t.jsx(ee,{level:m.type,children:m.text}),t.jsx(te,{children:t.jsx(W.White,{type:"button",onClick:()=>g(l()),disabled:f,children:"Confirm"})})]})},Mm="_stack_hvmmo_1",Fm="_button_hvmmo_6",Om="_checked_hvmmo_14",Lm="_checkmark_hvmmo_20",Um="_inner_hvmmo_30",zm="_info_hvmmo_42",Km="_duration_hvmmo_51",Wm="_amount_hvmmo_61",Hm="_symbol_hvmmo_71",Pe={stack:Mm,button:Fm,checked:Om,checkmark:Lm,inner:Um,info:zm,duration:Km,amount:Wm,symbol:Hm},Qm=({children:e})=>t.jsx("div",{className:Pe.stack,children:e}),ls=({label:e,query:s,value:n,onSelect:r,checked:o})=>{const{data:a,isLoading:i}=s,{watch:l}=Xe(),{dstChainId:c,dstDenom:d}=l(),u=Re(d,c);return t.jsxs("button",{type:"button",className:R(Pe.button,{[Pe.checked]:o}),onClick:()=>r(n),children:[t.jsx("div",{className:Pe.checkmark,children:o&&t.jsx("span",{className:Pe.inner})}),t.jsxs("div",{className:Pe.info,children:[t.jsx("div",{children:e}),t.jsxs("div",{className:Pe.duration,children:[t.jsx($.IconClockFilled,{size:12}),a?dn(a.estimated_route_duration_seconds):"Not available"]})]}),t.jsx("div",{className:Pe.amount,children:i?t.jsx(Ze,{size:14}):a?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:b.formatAmount(a.amount_out,{decimals:u.decimals})}),t.jsx("span",{className:Pe.symbol,children:u.symbol})]}):null})]})};ls.Stack=Qm;const Vm="_form_1coq4_1",Gm="_arrow_1coq4_5",Ym="_divider_1coq4_13",Jm="_flip_1coq4_21",Zm="_meta_1coq4_37",Xm="_row_1coq4_50",e_="_title_1coq4_56",t_="_description_1coq4_60",s_="_icon_1coq4_67",n_="_edit_1coq4_72",r_="_warning_1coq4_93",J={form:Vm,arrow:Gm,divider:Ym,flip:Jm,meta:Zm,row:Xm,title:e_,description:t_,icon:s_,edit:n_,warning:r_},o_=()=>{const e=ce(),s=$s(),[n,r]=be.useLocalStorage(F.BRIDGE_ROUTE_TYPE,"default"),{watch:o,setValue:a,handleSubmit:i,formState:l}=Xe(),c=o(),{srcChainId:d,srcDenom:u,dstChainId:h,dstDenom:m,quantity:f,sender:g,slippagePercent:p}=c,v=Ye(),k=Te(d),I=zt(k),E=Te(h),w=zt(E),j=Re(u,d),A=Re(m,h),{data:C}=An(g,d),N=Cm(g,d,u),[x]=be.useDebounceValue(f,300),P=I!=="initia"&&w!=="initia",q=bm(),B=Gn(x,{disabled:P}),S=Gn(x,{isOpWithdraw:!0,disabled:!q}),O=q&&n==="op"?S:B,{data:D,isLoading:oe,isFetching:Z,error:xe}=O,{data:ue}=wm(xe),At=x&&(oe||Z),$t=()=>{a("srcChainId",h),a("srcDenom",m),a("dstChainId",d),a("dstDenom",u),a("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:_t,closeModal:ft}=ws(),Ce=i(L=>{if(D?.warning){const{type:Tt="",message:Bs}=D.warning??{};_t({content:t.jsx(no,{type:"warning",icon:t.jsx($.IconWarningFilled,{size:40}),title:xs.sentenceCase(Tt),primaryButton:{label:"Cancel",onClick:ft},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:D,values:L}),ft()}},children:t.jsx("p",{className:J.warning,children:Bs})})});return}e("/bridge/preview",{route:D,values:L})}),ye=_.useMemo(()=>D?.estimated_fees?.filter(({fee_behavior:L})=>L==="FEE_BEHAVIOR_DEDUCTED")??[],[D]),et=_.useMemo(()=>D?.estimated_fees?.filter(({fee_behavior:L})=>L==="FEE_BEHAVIOR_ADDITIONAL")??[],[D]),pt=_.useMemo(()=>{for(const L of et){const Tt=C?.[L.origin_asset.denom]?.amount??"0",Bs=D?.source_asset_denom===L.origin_asset.denom?D.amount_in:"0";if(M(Tt).lt(M(Bs).plus(L.amount??"0")))return`Insufficient ${L.origin_asset.symbol} for fees`}},[C,D,et]),Gt=_.useMemo(()=>{if(!c.sender)return"Connect wallet";if(!c.quantity||!x)return"Enter amount";if(!c.recipient)return"Enter recipient address";if(l.errors.quantity)return l.errors.quantity.message;if(!D)return"Route not found";if(pt)return pt},[x,pt,l,D,c]),Ao=D?b.formatAmount(D.amount_out,{decimals:A.decimals}):"0",$o=M(f).gt(0)&&M(f).isEqualTo(b.fromBaseUnit(N?.amount,{decimals:N?.decimals??0})),To=(()=>{switch(I){case"initia":return v(d).fees.fee_tokens.some(({denom:L})=>L===u);case"cosmos":return k.fee_assets.some(({denom:L})=>L===u);case"evm":return!He.isAddress(u);default:return!1}})(),Tn=(L,Tt)=>L.length?t.jsxs("div",{className:J.description,children:[yo(L),!s&&t.jsx(Qt,{label:Tt,children:t.jsx("span",{className:J.icon,children:t.jsx($.IconInfoFilled,{size:12})})})]}):null;return t.jsxs("form",{className:J.form,onSubmit:Ce,children:[t.jsx(cn,{selectButton:t.jsx(Yn,{type:"src"}),accountButton:I==="cosmos"&&t.jsx(Jn,{type:"src"}),quantityInput:t.jsx(fs,{balance:N?.amount,decimals:j?.decimals}),balanceButton:t.jsx(mo,{onClick:()=>a("quantity",b.fromBaseUnit(N?.amount,{decimals:j?.decimals??0}),{shouldValidate:!0}),children:b.formatAmount(N?.amount??"0",{decimals:j.decimals})}),value:D?D.usd_amount_in?Ve(D.usd_amount_in):"$-":"$0"}),t.jsxs("div",{className:J.arrow,children:[t.jsx("div",{className:J.divider}),t.jsx("button",{type:"button",className:J.flip,onClick:()=>$t(),children:t.jsx($.IconChevronDown,{size:16})})]}),t.jsx(cn,{selectButton:t.jsx(Yn,{type:"dst"}),accountButton:t.jsx(Jn,{type:"dst"}),quantityInput:t.jsx(fs.ReadOnly,{children:Ao}),value:D?D.usd_amount_out?Ve(D.usd_amount_out):"$-":"$0"}),t.jsx(te,{extra:t.jsxs(t.Fragment,{children:[t.jsx(rn,{children:M(f).gt(0)&&q?t.jsxs(ls.Stack,{children:[t.jsx(ls,{label:"Minitswap",query:B,value:"default",onSelect:r,checked:n==="default"}),t.jsx(ls,{label:"OP Bridge",query:S,value:"op",onSelect:r,checked:n==="op"})]}):null}),t.jsxs(ee.Stack,{children:[D?.extra_infos?.map(L=>t.jsx(ee,{level:"info",children:L},L)),ue&&t.jsx(ee,{level:"info",children:ue}),$o&&To&&t.jsx(ee,{level:"warning",children:"Make sure to leave enough for transaction fee"}),D?.warning&&t.jsx(ee,{level:"warning",children:D.warning.message}),D?.extra_warnings?.map(L=>t.jsx(ee,{level:"warning",children:L},L))]}),t.jsx(rn,{children:D&&t.jsxs("div",{className:J.meta,children:[!!D.estimated_fees?.length&&t.jsxs("div",{className:J.row,children:[t.jsx("span",{className:J.title,children:"Fees"}),t.jsxs("div",{children:[Tn(ye,"Fee deducted from the amount you receive"),Tn(et,"Fee charged in addition to the amount you enter")]})]}),dn(D.estimated_route_duration_seconds)&&t.jsxs("div",{className:J.row,children:[t.jsx("span",{className:J.title,children:"Estimated time"}),t.jsx("span",{className:J.description,children:dn(D.estimated_route_duration_seconds)})]}),D.does_swap&&t.jsxs("div",{className:J.row,children:[t.jsx("span",{className:J.title,children:"Slippage"}),t.jsxs("span",{className:J.description,children:[t.jsxs("span",{children:[p,"%"]}),t.jsx(lt,{title:"Slippage tolerance",content:L=>t.jsx(Bm,{afterConfirm:L}),className:J.edit,children:t.jsx($.IconSettingFilled,{size:12})})]})]})]})})]}),children:t.jsx(W.White,{loading:At&&"Simulating...",disabled:!!Gt,children:Gt??"Preview route"})})]})},a_=()=>{ro();const e=Ho(),s=ce(),{closeDrawer:n}=It(),r=Nt(),o=ym(),a=re.useForm({mode:"onChange",defaultValues:o}),{watch:i,setValue:l}=a,{srcChainId:c,dstChainId:d,srcDenom:u,dstDenom:h,quantity:m,slippagePercent:f,recipient:g}=i();i((P,{name:q})=>{(q==="srcChainId"||q==="srcDenom")&&l("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=go(),v=p(c),k=p(d),E=xo()(g,d);_.useEffect(()=>{l("cosmosWalletName",void 0),l("sender",v)},[c,v,l]),_.useEffect(()=>{E||l("recipient",k)},[k,E,l]);const w=wt(c),j=wt(d),A=_.useMemo(()=>{if(!w.find(P=>P.denom===u))return`${u} is not available for bridge/swap on ${c}`;if(!j.find(P=>P.denom===h))return`${h} is not available for bridge/swap on ${d}`},[j,d,h,w,c,u]);_.useEffect(()=>{A||(localStorage.setItem(F.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(F.BRIDGE_SRC_DENOM,u),localStorage.setItem(F.BRIDGE_DST_CHAIN_ID,d),localStorage.setItem(F.BRIDGE_DST_DENOM,h),localStorage.setItem(F.BRIDGE_QUANTITY,m),localStorage.setItem(F.BRIDGE_SLIPPAGE_PERCENT,f))},[c,u,d,h,m,f,A]);const C=e[0].path==="/bridge",N=()=>t.jsxs(t.Fragment,{children:[t.jsx(G,{error:!0,children:A}),t.jsx(te,{children:C?t.jsx(W.White,{onClick:n,children:"Close"}):t.jsx(W.White,{onClick:()=>s(-1),children:"Go back"})})]}),{reminders:x}=St();return t.jsx(ht,{title:"Bridge/Swap",backButton:C?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(W.Small,{onClick:()=>s("/bridge/history"),unpadded:!0,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[t.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),t.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),t.jsx(fo,{offset:0,disabled:x.length===0,children:t.jsx(W.Small,{onClick:()=>s("/op/withdrawals"),disabled:!r,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:A?N():t.jsx(re.FormProvider,{...a,children:t.jsx(de,{children:t.jsx(o_,{})})})})},i_="_button_1iys9_1",c_={button:i_},jo=({onClick:e,disabled:s})=>{const{ref:n,inView:r}=Oo.useInView();return _.useEffect(()=>{r&&e()},[r,e]),t.jsxs("button",{className:c_.button,onClick:e,disabled:s,ref:n,children:[t.jsx("span",{children:"Load more"}),t.jsx($.IconChevronDown,{size:12})]})},mt=Ee.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,s)=>[e,s],latestOutput:e=>[e],output:(e,s)=>[e,s],outputResponse:(e,s)=>[e,s],withdrawalClaimed:(e,s)=>[e,s]});function Ps(){const{restUrl:e}=pe();return _.useMemo(()=>Y.create({prefixUrl:e}),[e])}function l_(e){const s=Ps(),{data:n}=T.useSuspenseQuery({queryKey:mt.bridge(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:U.INFINITY});return n}const Xn=20;function d_(e){const s=ne();return T.useSuspenseInfiniteQuery({queryKey:mt.withdrawals(e,s).queryKey,queryFn:async({pageParam:n})=>{if(!s)return[];const r={limit:Xn,offset:n,order:"desc"},{withdrawals:o}=await Y.create({prefixUrl:e}).get(`withdrawals/${s}`,{searchParams:r}).json();return o},getNextPageParam:n=>{const r=y.last(n)?.sequence;return n.length<Xn||!r||r<=1?null:r-1},initialPageParam:0,staleTime:U.SECOND})}function u_(e){const s=Ps(),{data:n}=T.useSuspenseQuery({queryKey:mt.latestOutput(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:r})=>{const[o]=r;return o||null},staleTime:U.SECOND});return n}function h_({bridge_id:e,output_index:s}){const n=Ps(),{data:r}=T.useSuspenseQuery({queryKey:mt.output(e,s).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${e}/outputs/${s}`).json()}catch{return null}},staleTime:U.SECOND});return r}function m_({bridge_id:e,sequence:s}){const r=se().find(({metadata:c})=>c?.op_bridge_id===e.toString())?.chain_id;if(!r)throw new Error(`Chain not found for bridge_id: ${e}`);const a=Ye()(r);if(!a)throw new Error(`Chain not found: ${r}`);const i=a.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${r}`);const{data:l}=T.useSuspenseQuery({queryKey:mt.outputResponse(i,s).queryKey,queryFn:()=>Y.create({prefixUrl:i}).get(`withdrawal/${s}`).json(),staleTime:U.SECOND});return l}function vo(e,s){const{bridge_id:n}=e,r=Ps(),{data:o}=T.useSuspenseQuery({queryKey:mt.withdrawalClaimed(n,s).queryKey,queryFn:()=>r.get(`opinit/ophost/v1/bridges/${n}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:s}}).json(),select:({claimed:a})=>a,staleTime:({state:{data:a}})=>a?.claimed?1/0:U.SECOND});return o}function Bt(e){return Lo.sha3_256.create().update(e).digest()}function Xs(e,s){const n=new ArrayBuffer(s);return new DataView(n).setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}function wo(e){const{bridge_id:s,sequence:n,amount:r,from:o,to:a}=e,i=Xs(s.toString(),8),l=Xs(n.toString(),8),c=Xs(r.amount,8),d=Yt.concatBytes(i,l,Bt(Yt.utf8ToBytes(o)),Bt(Yt.utf8ToBytes(a)),Bt(Yt.utf8ToBytes(r.denom)),c);return Bt(Bt(d))}const bo=_.createContext(null);function Rs(){return _.useContext(bo)}const __="_asset_6h8u2_1",f_="_info_6h8u2_7",p_="_symbol_6h8u2_11",en={asset:__,info:f_,symbol:p_},g_=({amount:e,denom:s})=>{const n=pe(),r=Rr(s,n),{symbol:o,logoUrl:a,decimals:i}=r;return t.jsxs("div",{className:en.asset,children:[t.jsx(z,{src:a,width:32,height:32,logo:!0}),t.jsxs("div",{className:en.info,children:[t.jsx("span",{className:"monospace",children:b.formatAmount(e,{decimals:i})}),t.jsx("span",{className:en.symbol,children:o})]})]})},x_=({children:e})=>{const{withdrawalTx:s}=Rs(),n=u_(s.bridge_id),r=s.output_index>Number(n?.output_index);return e(r)},y_="_container_1oldz_1",j_="_icon_1oldz_7",er={container:y_,icon:j_},v_="Withdrawal will begin within an hour",tr=()=>{const e=$s();return t.jsxs("div",{className:er.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Qt,{label:v_,children:t.jsx("span",{className:er.icon,children:t.jsx($.IconInfoFilled,{size:12})})})]})},Co=1e3,w_=60,b_=60,C_=24,un=Co*w_,hn=un*b_,sr=hn*C_,I_=({date:e})=>{const s=_.useCallback(()=>{const d=new Date().getTime(),h=e.getTime()-d;if(h<=0)return{days:0,hours:0,minutes:0,seconds:0};const m=Math.floor(h/sr),f=Math.floor(h%sr/hn),g=Math.floor(h%hn/un),p=Math.floor(h%un/Co);return{days:m,hours:f,minutes:g,seconds:p}},[e]),[n,r]=_.useState(s());_.useEffect(()=>{const d=window.setInterval(()=>{r(s())},1e3);return()=>window.clearInterval(d)},[s,e]);const o=d=>d.toString().padStart(2,"0"),{days:a,hours:i,minutes:l,seconds:c}=n;return t.jsx(Qt,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[a,"d ",o(i),"h ",o(l),"m ",o(c),"s"]})})},N_="_container_1lz3w_1",S_="_title_1lz3w_5",nr={container:N_,title:S_},k_=({date:e})=>t.jsxs("div",{className:nr.container,children:[t.jsx("div",{className:nr.title,children:"Claimable in"}),t.jsx(I_,{date:e})]}),A_=({children:e})=>{const{withdrawalTx:s}=Rs(),n=l_(s.bridge_id),r=h_(s),o=_.useMemo(()=>{if(!r)return null;const{bridge_config:a}=n,{output_proposal:i}=r;return bt.addSeconds(new Date(i.l1_block_time),parseFloat(a.finalization_period))},[n,r]);return e(o)},$_=({date:e,children:s})=>{const{chainId:n,withdrawalTx:r}=Rs(),o=K.toBase64(wo(r)),a=vo(r,o),{setReminder:i,removeReminder:l}=St();return _.useEffect(()=>{const c={chainId:n,txHash:r.tx_hash};a?l(c):i(c,{...c,recipient:r.to,claimableAt:e.getTime(),amount:r.amount.amount,denom:r.amount.denom,dismissed:bt.isPast(e.getTime())?!0:void 0})},[n,a,e,l,i,r]),s},T_="_button_1btdg_1",E_="_claimed_1btdg_23",rr={button:T_,claimed:E_},q_=()=>{const{withdrawalTx:e}=Rs(),{bridge_id:s,sequence:n,amount:r,output_index:o,withdrawal_proofs:a,storage_root:i,from:l,to:c,version:d}=e,u=pe(),h=ne(),{requestTxSync:m,waitForTxConfirmation:f}=ge(),g=m_(e),p=K.toBase64(wo(e)),v=vo(e,p),k=T.useQueryClient(),{mutate:I,isPending:E}=T.useMutation({mutationFn:async()=>{if(!g)throw new Error("Output not found");const{last_block_hash:w}=g;return m({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:h,bridgeId:BigInt(s),outputIndex:BigInt(o),withdrawalProofs:a.map(K.fromBase64),from:l,to:c,sequence:BigInt(n),amount:r,version:K.fromBase64(d),storageRoot:K.fromBase64(i),lastBlockHash:K.fromBase64(w)}}],internal:!0})},onSuccess:async w=>{await f({chainId:u.chain_id,txHash:w}),k.invalidateQueries({queryKey:mt.withdrawalClaimed(s,p).queryKey})}});return v?t.jsxs("div",{className:rr.claimed,children:[t.jsx($.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:rr.button,onClick:()=>I(),disabled:E,children:"Claim"})},D_=()=>t.jsx(x_,{children:e=>e?t.jsx(tr,{}):t.jsx(A_,{children:s=>s?t.jsx($_,{date:s,children:bt.isFuture(s)?t.jsx(k_,{date:s}):t.jsx(q_,{})}):t.jsx(tr,{})})}),P_="_item_km5w2_1",R_={item:P_},B_=({chain:e})=>{const s=e.metadata?.executor_uri;if(!s)throw new Error("Executor URL is not defined");const{data:n,fetchNextPage:r,hasNextPage:o,isFetching:a}=d_(s),i=_.useMemo(()=>n?.pages.flat()??[],[n]),{syncReminders:l}=St();return _.useEffect(()=>{const c=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));l(c)},[e.chainId,i,l]),i.length?t.jsxs(t.Fragment,{children:[i.map(c=>{const{amount:d}=c;return t.jsxs("div",{className:R_.item,children:[t.jsx(g_,{...d}),t.jsx(de,{suspenseFallback:null,children:t.jsx(bo.Provider,{value:{chainId:e.chainId,withdrawalTx:c},children:t.jsx(D_,{})})})]},c.sequence)}),o&&t.jsx(jo,{onClick:()=>r(),disabled:a})]}):t.jsx(G,{children:"No withdrawals"})},M_="_content_dj1qm_1",F_="_title_dj1qm_5",or={content:M_,title:F_},O_=()=>{const{chainId:e}=dt(),s=se(),n=Kt(),[r,o]=_.useState(e??(n.metadata?.is_l1?"":n.chainId)),a=Ye(),{reminders:i}=St(),l=r?a(r):void 0;return t.jsxs(ht,{title:"OP Bridge withdrawals",children:[t.jsx(it,{chains:s.filter(({metadata:c})=>!c?.is_l1&&c?.op_denoms?.length),value:r,onSelect:o,getShowIndicator:c=>i.some(d=>d.chainId===c)}),t.jsx("div",{className:or.content,children:l?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:or.title,children:l.name}),t.jsx(de,{children:t.jsx(B_,{chain:l})},r)]}):t.jsx(ee,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})};async function L_(e,s){const n=Y.create({prefixUrl:s}),r=`cosmos/auth/v1beta1/account_info/${e}`;for(let o=1;o<=24;o++)try{return await n.get(r).json()}catch{await new Promise(a=>setTimeout(a,5e3))}throw new Error(`Timeout: ${e} not found`)}const ds=({chainId:e,txHash:s})=>`${F.BRIDGE_HISTORY}:${e}:${s}`,ps=100,ar=10;function Io(){const[e,s]=be.useLocalStorage(F.BRIDGE_HISTORY,[]),n=_.useCallback((o,a)=>{localStorage.setItem(ds(o),JSON.stringify(a));for(const i of e.slice(ps-1))localStorage.removeItem(ds(i));s((i=[])=>[o,...i.slice(0,ps-1)])},[e,s]),r=_.useCallback(o=>{const a=localStorage.getItem(ds(o));return a?JSON.parse(a):null},[]);return{history:e,addHistoryItem:n,getHistoryDetails:r}}function No(e){return be.useLocalStorage(ds(e),null)}async function mn(e,s){const{chain_type:n,chain_id:r,chain_name:o,evm_fee_asset:a,rpc:i}=s;if(n!=="evm")throw new Error(`Chain is not an EVM chain: ${o}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}catch(l){if(y.path(["error","code"],l)!==4902)throw l;if(!a)throw new Error(`Fee asset is not defined for chain: ${o}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(r).toString(16)}`,chainName:o,nativeCurrency:a,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}}function kt(){return dt()}function U_(e){const s=ce(),{showNotification:n,updateNotification:r,hideNotification:o}=Cn(),{addHistoryItem:a}=Io(),i=Ns(),{route:l,values:c}=kt(),{srcChainId:d,sender:u,recipient:h,cosmosWalletName:m}=c,f=Sr(),{requestTxSync:g,waitForTxConfirmation:p}=ge(),{find:v}=Ds(),k=Cs(),I=Is(),E=Te(d),w=zt(E),j=Ur(d),A=T.useQueryClient(),{registryUrl:C}=le(),N=Ye(),{addReminder:x}=St(),P=Me();return T.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const q=e.cosmos_tx.msgs.map(({msg_type_url:Ce,msg:ye})=>{if(!(Ce&&ye))throw new Error("Invalid transaction data");return I.fromAmino({type:Ot.aminoConverters[Ce].aminoType,value:JSON.parse(ye)})});if(w==="initia"){const{srcDenom:Ce,quantity:ye}=c,{decimals:et}=j(Ce),pt=await g({messages:q,chainId:d,internal:1,spendCoins:[{denom:Ce,amount:b.toBaseUnit(ye,{decimals:et})}]}),Gt=p({txHash:pt,chainId:d});return{txHash:pt,wait:Gt}}const B=v(m)?.getProvider();if(!B)throw new Error("Wallet not connected");const S=B.getOfflineSignerOnlyAmino(d),O=await Ae.SigningStargateClient.connectWithSigner(E.rpc,S,{registry:k,aminoTypes:I}),D=await O.getAllBalances(u),oe=E.fee_assets.find(Ce=>D.some(ye=>ye.denom===Ce.denom&&M(ye.amount).gt(0)));if(!oe){const ye=["Insufficient balance for fees.",`Available fee assets: ${E.fee_assets.map(et=>j(et.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(ye)}const{denom:Z,gas_price:xe}=oe;if(!xe)throw new Error(`Gas price not found for ${Z}`);const ue=await O.simulate(u,q,""),At=Ae.GasPrice.fromString(xe.average+Z),$t=Ae.calculateFee(Math.ceil(ue*Lt),At),_t=await O.signAndBroadcastSync(u,q,$t),ft=qr({txHash:_t,client:O});return{txHash:_t,wait:ft}}if("evm_tx"in e){const{chain_id:q,to:B,value:S,data:O}=e.evm_tx,D=await f(),oe=await D.getSigner();await mn(D,E);const Z=await oe.sendTransaction({chainId:q,to:B,value:S,data:`0x${O}`});return{txHash:Z.hash,wait:Z.wait()}}throw new Error("Unlisted chain type")}catch(q){throw new Error(await Ge(q))}},onSuccess:async({txHash:q,wait:B})=>{localStorage.removeItem(F.BRIDGE_QUANTITY),s(-1),n({type:"loading",title:"Transaction is pending..."});try{await B;const S=$n(l)==="OP Bridge withdrawal",O=S?{success:!0,error:null}:await Q_(P,q,d);if(!O.success&&O.error){const ue=O.error instanceof Error?O.error.message:String(O.error);n({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${ue}. The transaction may still be processing.`,autoHide:!0})}const D=O.success,Z=W_({txHash:q,srcChainId:d,route:l,values:c,recipient:h},D);a(Z.tx,Z.details),r(K_(o));const xe=ir(c,q);if(i("Bridge Transaction Success",xe),S){const ue=H_(Z.tx,l,h);x(Z.tx,ue)}}catch(S){const O=S instanceof Error?S.message:String(S);r({type:"error",title:"Transaction failed",description:O});const D={...ir(c,q),error:O};i("Bridge Transaction Failed",D)}finally{A.invalidateQueries({queryKey:$e.balances(d,u).queryKey})}},onError:async q=>{const B=w==="initia"?await cs(q,N(d),C):q;n({type:"error",title:"Transaction failed",description:B.message})}})}function z_(){const e=Me(),s=ne(),n=Cr(),{route:r,values:o}=kt(),a=ut();return T.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:l}=await e.post("op-hook",{json:{source_address:s,source_asset_chain_id:r.source_asset_chain_id,source_asset_denom:r.source_asset_denom,dest_address:b.InitiaAddress(o.recipient).bech32,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom}}).json();await L_(s,a(r.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:h,msg:m})=>Ot.aminoTypes.fromAmino({type:Ot.aminoConverters[h].aminoType,value:JSON.parse(m)})),d=await n(i,s,c,{amount:[],gas:"1"},""),u=vt.Tx.fromPartial({body:vt.TxBody.decode(d.bodyBytes),authInfo:vt.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:s,hook:K.toBase64(vt.Tx.encode(u).finish())}}catch(i){throw new Error(await Ge(i))}}})}function K_(e){return{type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(pn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function ir(e,s){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:s}}function W_(e,s){const{txHash:n,srcChainId:r,route:o,values:a}=e,i={chainId:r,txHash:n},l=$n(o)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:o,values:a,state:l?"success":void 0,tracked:s},isOpWithdraw:l}}function H_(e,s,n){return{...e,recipient:b.InitiaAddress(n).bech32,claimableAt:Date.now()+s.estimated_route_duration_seconds*1e3,amount:s.amount_out,denom:s.dest_asset_denom}}async function Q_(e,s,n){for(let a=0;a<=30;a++)try{return await e.post("v2/tx/track",{json:{tx_hash:s,chain_id:n}}).json(),{success:!0,error:null}}catch(i){if(a===30)return{success:!1,error:await Ge(i)};await new Promise(l=>setTimeout(l,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function V_(e){const{chainId:s,txHash:n,tracked:r}=e,o=Me();return T.useQuery({queryKey:$e.txTrack(s,n).queryKey,queryFn:async()=>{try{return await o.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json()}catch(a){throw new Error(await Ge(a))}},select:({tx_hash:a})=>a,retry:6,retryDelay:5e3,staleTime:U.INFINITY,enabled:!r})}function G_(e){const{timestamp:s,chainId:n,txHash:r,tracked:o,state:a}=e,i=Me();return T.useQuery({queryKey:$e.txStatus(n,r).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:r,chain_id:n}}).json(),enabled:!!r&&o&&!a,refetchInterval:({state:{data:l}})=>{if(!l)return!1;const{status:c}=l;if(c==="STATE_COMPLETED")return!1;const d=s+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),h=Math.floor((d-u)/1e3);return h<=0?1e3:h<=300?5e3:60*1e3},staleTime:U.INFINITY})}var us=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(us||{});function $n(e){const{operations:s,dest_asset_denom:n}=e;return y.has("op_init_transfer",y.head(s))&&n==="uinit"?"OP Bridge withdrawal":"Skip"}const Y_="_content_c0tee_1",J_="_info_c0tee_6",Z_="_arrow_c0tee_11",X_="_divider_c0tee_19",ef="_type_c0tee_26",tf="_asset_c0tee_44",sf="_amount_c0tee_52",nf="_lower_c0tee_57",rf="_chain_c0tee_63",of="_address_c0tee_69",me={content:Y_,info:J_,arrow:Z_,divider:X_,type:ef,asset:tf,amount:sf,lower:nf,chain:rf,address:of},So=e=>{const{source:s,label:n,amount:r,denom:o,chainId:a,address:i,walletIcon:l}=e,{symbol:c=b.truncate(o),decimals:d=0,logo_uri:u=xn}=e,{chain_name:h,pretty_name:m,...f}=Te(a);return t.jsxs("div",{children:[!s&&t.jsxs("div",{className:me.arrow,children:[t.jsx("div",{className:me.divider}),n?t.jsx(Qt,{label:n,children:t.jsx("button",{className:me.type,children:t.jsx($.IconArrowDown,{size:12})})}):t.jsx("span",{className:me.type,children:t.jsx($.IconArrowDown,{size:12})}),t.jsx("div",{className:me.divider})]}),t.jsxs("div",{className:me.content,children:[t.jsx(qs,{assetLogoUrl:u,chainLogoUrl:f.logo_uri??void 0}),t.jsxs("div",{className:me.info,children:[t.jsxs("div",{className:me.asset,children:[t.jsx("span",{className:me.amount,children:b.formatAmount(r,{decimals:d})}),t.jsx("span",{children:c})]}),t.jsxs("div",{className:me.lower,children:[t.jsxs("div",{className:me.chain,children:["on ",m||h]}),i&&t.jsx(_s,{value:i,children:({copy:g,copied:p})=>t.jsxs("button",{className:me.address,onClick:g,children:[l,p?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:b.truncate(i)})]})})]})]})]})]})},jt=e=>{const s=Re(e.denom,e.chainId);return t.jsx(So,{...e,...s})};jt.Placeholder=So;const af="_root_1l4he_1",cf="_flexEnd_1l4he_6",lf="_toggle_1l4he_11",df="_route_1l4he_34",uf="_content_1l4he_41",Mt={root:af,flexEnd:cf,toggle:lf,route:df,content:uf};function hf(e){const s=({name:n})=>n==="initia-dex"?"Initia DEX":xs.capitalCase(y.head(n?.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 n=e.swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"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 n=e.evm_swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"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 mf=({addressList:e})=>{const{values:s,route:n}=kt(),{source_asset_denom:r,source_asset_chain_id:o,amount_in:a,operations:i}=n,l=y.zipObj(n.required_chain_addresses,e),{find:c}=Ds(),{connector:d,address:u=""}=fe.useAccount(),[h,m]=be.useToggle(!1),f=i.length>1,g=t.jsx(z,{src:s.cosmosWalletName?c(s.cosmosWalletName)?.image:d?.icon,width:12,height:12}),p={amount:a,denom:r,chainId:o,address:s.sender,walletIcon:g},v=j=>b.InitiaAddress.equals(j,u)?g:t.jsx($.IconWallet,{size:11}),k=j=>{const{label:A,amount_out:C,denom:N,denom_out:x=N,chain_id:P,from_chain_id:q,to_chain_id:B=P??q}=j,S=l[B];return{label:f&&!h?void 0:A,amount:C,denom:x,chainId:B,address:S,walletIcon:v(S)}},I=i.map(hf).map(k),E=I.slice(0,-1),w=I[I.length-1];return t.jsxs(Q.Collapsible.Root,{className:Mt.root,open:h,onOpenChange:m,children:[f&&t.jsx("div",{className:Mt.flexEnd,children:t.jsx(Q.Collapsible.Trigger,{className:Mt.toggle,children:h?t.jsxs(t.Fragment,{children:[t.jsx($.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx($.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:Mt.route,children:[t.jsx(jt,{...p,source:!0}),t.jsx(Q.Collapsible.Content,{className:Mt.content,children:E.map((j,A)=>t.jsx(de,{suspenseFallback:t.jsx(jt.Placeholder,{...j}),errorBoundaryProps:{fallback:t.jsx(jt.Placeholder,{...j})},children:t.jsx(jt,{...j})},A))}),t.jsx(jt,{...w})]})]})},_n=({error:e})=>{const s=ce();return t.jsx(te,{extra:t.jsx(ee,{level:"error",children:e.message}),children:t.jsx(W.White,{onClick:()=>s("/bridge"),children:"Home"})})},_f=({children:e})=>{const s=kt(),{route:n,values:r}=s,{required_chain_addresses:o}=n,{srcChainId:a,dstChainId:i,sender:l,recipient:c}=r,{initiaAddress:d,hexAddress:u}=ge(),h=Ct(),m=ut(),f=Wt(),g=m(a),p=f(g),v=o.slice(0,-1).some(C=>{const N=m(C);return f(N)==="cosmos"})&&p!=="cosmos",[k,I]=_.useState(void 0),[E,w]=_.useState(!1),[j,A]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!v)return;if(!h)throw new Error("Wallet not connected");w(!0),A(null);const[{pubkey:N}]=await h.getAccounts();I(N)}catch(N){A(new Error(await Ge(N)))}finally{w(!1)}})()},[v,h]),j)return t.jsx(_n,{error:j});if(E)return t.jsx(te,{children:t.jsx(W.White,{loading:E&&"Generating intermediary addresses..."})});if(!v||k){const C=o.map((N,x)=>{if(x===o.length-1){const O=m(i);return f(O)==="initia"?b.InitiaAddress(c).bech32:c}const P=m(N),q=f(P),B=m(a),S=f(B);switch(q){case"initia":return d;case"evm":return u;case"cosmos":{if(S==="cosmos")return K.toBech32(P.bech32_prefix,K.fromBech32(l).data);if(!k)throw new Error("Pubkey not found");return Ft.pubkeyToAddress(Ft.encodeSecp256k1Pubkey(k),P.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(C)}return null},ff=({addressList:e,signedOpHook:s,children:n})=>{const r=Me(),{route:o,values:a}=kt(),[i,l]=_.useState(void 0),[c,d]=_.useState(!1),[u,h]=_.useState(null);return _.useEffect(()=>{(async()=>{try{if(o.required_op_hook&&!s)throw new Error("Op hook is required");d(!0),h(null);const f={address_list:e,amount_in:o.amount_in,amount_out:o.amount_out,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom,slippage_tolerance_percent:a.slippagePercent,operations:o.operations,signed_op_hook:s},{txs:g}=await r.post("v2/fungible/msgs",{json:f}).json();if(!g||g.length===0)throw new Error("No transaction data found");const[p]=g;l(p)}catch(f){h(f)}finally{d(!1)}})()},[o,a,e,s,r]),u?t.jsx(_n,{error:u}):c?t.jsx(te,{children:t.jsx(W.White,{loading:c&&"Fetching messages..."})}):i?n(i):t.jsx(_n,{error:new Error("Failed to fetch messages")})},pf=({children:e})=>{const{route:s}=kt(),n=z_();return s.required_op_hook&&!n.data?t.jsx(te,{extra:t.jsx(ee,{level:"error",children:n.error?.message}),children:t.jsx(W.White,{onClick:()=>n.mutate(),loading:n.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(n.data)},gf=({tx:e,children:s})=>{const n=Sr(),r=ut(),{data:o,isLoading:a}=T.useQuery({queryKey:["erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:u,signer_address:h}=e.evm_tx,m=await n();await mn(m,r(u));const f=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async p=>{const{token_contract:v,spender:k}=p,E=await new He.ethers.Contract(v,f,m).allowance(h,k);return{approval:p,currentAllowance:BigInt(E.toString())}}))).filter(({approval:p,currentAllowance:v})=>v<BigInt(p.amount)).map(({approval:p})=>p)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:l,isPending:c,error:d}=T.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!o||o.length===0)throw new Error("No approvals needed");const{chain_id:u}=e.evm_tx,h=await n(),m=await h.getSigner();await mn(h,r(u));for(const f of o){const{token_contract:g,spender:p,amount:v}=f,k=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new He.ethers.Contract(g,k,m).approve(p,v)).wait()}return!0}catch(u){throw new Error(await Ge(u))}}});return a?t.jsx(te,{children:t.jsx(W.White,{loading:"Checking approvals..."})}):o&&o.length>0&&!l?t.jsx(te,{extra:t.jsx(ee,{level:"error",children:d?.message}),children:t.jsx(W.White,{onClick:()=>i(),loading:c&&"Approving tokens...",children:"Approve tokens"})}):s},xf=({tx:e})=>{const{mutate:s,isPending:n}=U_(e);return t.jsx(te,{children:t.jsx(W.White,{onClick:()=>s(),loading:n&&"Signing transaction...",children:"Confirm"})})},yf=()=>t.jsx(ht,{title:"Route preview",children:t.jsx(_f,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(mf,{addressList:e}),t.jsx(pf,{children:s=>t.jsx(ff,{addressList:e,signedOpHook:s,children:n=>t.jsx(gf,{tx:n,children:t.jsx(xf,{tx:n})})})})]})})}),jf="_button_14cv7_1",vf="_checkbox_14cv7_10",wf="_checked_14cv7_23",as={button:jf,checkbox:vf,checked:wf},bf=({checked:e,onClick:s,label:n,className:r})=>t.jsxs("button",{type:"button",className:R(as.button,r),onClick:s,children:[t.jsx("div",{className:R(as.checkbox,{[as.checked]:e}),children:e&&t.jsx($.IconCheck,{size:12})}),t.jsx("span",{className:as.label,children:n})]}),Cf="_success_t4dfk_1",If="_error_t4dfk_5",cr={success:Cf,error:If},Nf=({tx:e})=>{const[s,n]=No(e);if(!s)throw new Error("Bridge history details not found");const{data:r}=G_(s),o=s.state??Sf(r);switch(_.useEffect(()=>{o!=="loading"&&n(a=>{if(!a)throw new Error("Bridge history details not found");return{...a,tracked:!0,state:o}})},[n,o]),o){case"error":return t.jsx("div",{className:cr.error,children:t.jsx($.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:cr.success,children:t.jsx($.IconCheckCircleFilled,{size:14})});default:return t.jsx(Ze,{size:14})}};function Sf(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 kf="_link_1uidr_1",Af="_header_1uidr_22",$f="_title_1uidr_30",Tf="_date_1uidr_36",Ef="_explorer_1uidr_40",qf="_fees_1uidr_55",Df="_label_1uidr_63",Pf="_content_1uidr_67",Rf="_route_1uidr_73",Bf="_row_1uidr_78",Mf="_asset_1uidr_84",Ff="_amount_1uidr_92",Of="_chain_1uidr_97",Lf="_account_1uidr_106",Uf="_arrow_1uidr_113",X={link:kf,header:Af,title:$f,date:Tf,explorer:Ef,fees:qf,label:Df,content:Pf,route:Rf,row:Bf,asset:Mf,amount:Ff,chain:Of,account:Lf,arrow:Uf},zf=({tx:e})=>{const[s,n]=No(e);if(!s)throw new Error("Bridge history details not found");const{chainId:r,txHash:o,route:a,values:i,timestamp:l,tracked:c}=s,{data:d}=V_(s),{address:u="",connector:h}=fe.useAccount(),{find:m}=Ds();_.useEffect(()=>{d&&n(D=>{if(!D)throw new Error("Bridge history details not found");return{...D,tracked:!0}})},[n,d]);const{amount_in:f,amount_out:g,source_asset_chain_id:p,source_asset_denom:v,dest_asset_chain_id:k,dest_asset_denom:I,estimated_fees:E=[]}=a,w=Te(p),j=Te(k),A=Re(v,p),C=Re(I,k),N=(D,oe)=>oe?t.jsx(z,{src:oe,width:12,height:12}):b.InitiaAddress.equals(D,u)?t.jsx(z,{src:h?.icon,width:12,height:12}):t.jsx($.IconWallet,{size:12}),x=(D,{symbol:oe,decimals:Z,logo_uri:xe},{chain_name:ue,pretty_name:At,...$t},_t,ft)=>t.jsxs("div",{className:X.row,children:[t.jsx(qs,{assetLogoUrl:xe,chainLogoUrl:$t.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:X.asset,children:[t.jsx("span",{className:X.amount,children:b.formatAmount(D,{decimals:Z})}),t.jsx("span",{children:oe})]}),t.jsxs("div",{className:X.chain,children:[t.jsxs("span",{children:["on ",At||ue]}),t.jsxs("div",{className:X.account,children:[ft,t.jsx("span",{className:"monospace",children:b.truncate(_t)})]})]})]})]}),P=$n(a),q=_.useMemo(()=>{switch(P){case us.SKIP:return"Skip Explorer";case us.OP_WITHDRAW:return"Initia Scan"}},[P]),B=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:X.header,children:[t.jsxs("div",{className:X.title,children:[c?t.jsx(Nf,{tx:e}):t.jsx(Ze,{size:14}),t.jsx("div",{className:X.date,children:bt.intlFormatDistance(new Date(l),new Date,{locale:"en-US"})})]}),t.jsxs("div",{className:X.explorer,children:[t.jsx("span",{children:q}),t.jsx($.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:X.route,children:[x(f,A,w,i.sender,N(i.sender,m(i.cosmosWalletName)?.image)),t.jsx("div",{className:X.arrow,children:t.jsx($.IconArrowDown,{size:12})}),x(g,C,j,i.recipient,N(i.recipient))]}),E.length>0&&t.jsxs("div",{className:X.fees,children:[t.jsx("span",{className:X.label,children:"Fees"}),t.jsx("span",{className:X.content,children:yo(E)})]})]});if(P===us.OP_WITHDRAW)return t.jsx(Ts,{chainId:r,txHash:o,className:X.link,children:B});const S=new URLSearchParams({tx_hash:o,chain_id:r}),O=new URL(`?${S.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:O.toString(),className:X.link,target:"_blank",children:B})},Kf="_list_1q71m_1",Wf="_header_1q71m_5",Hf="_checkbox_1q71m_9",Qf="_item_1q71m_13",is={list:Kf,header:Wf,checkbox:Hf,item:Qf},Vf=()=>{const{initiaAddress:e,hexAddress:s}=ge(),{history:n,getHistoryDetails:r}=Io(),o=n.filter(m=>r(m)),a=o.filter(m=>{const f=r(m);if(!f)return!1;const{values:g}=f,{sender:p,recipient:v}=g;return[p,v].some(k=>[e,s].includes(k))}),[i,l]=_.useState(1),[c,d]=be.useToggle(!a.length),u=c?o:a,h=u.slice(0,i*ar);return t.jsx(ht,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:is.list,children:[o.length>0&&o.length!==a.length&&t.jsx("header",{className:is.header,children:t.jsx(bf,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:is.checkbox})}),u.length===0?t.jsx(G,{children:"No bridge/swap activity"}):h.map((m,f)=>t.jsx("div",{className:is.item,children:t.jsx(de,{children:t.jsx(zf,{tx:m})})},f)),u.length>i*ar?t.jsx(jo,{onClick:()=>l(m=>m+1)}):n.length>=ps&&t.jsxs(G,{children:["Only the latest ",ps," items are stored. Older entries will be removed automatically."]})]})})},ko=()=>{const e=ce(),s=vs(),n=Nt(),{closeDrawer:r}=It(),{closeModal:o}=ws();_.useEffect(()=>{o(),s.startsWith("/bridge/")&&e("/bridge"),(s==="/collection"||s.startsWith("/nft"))&&e("/nfts")},[n]);const a=Ns();if(_.useEffect(()=>{a("Page View")},[s,a]),s==="/connect")return n?null:t.jsx(zn,{onSuccess:r});if(s==="/blank")return null;if(!n)return t.jsx(zn,{});switch(s){case"/":case"/nfts":case"/activity":return t.jsx(Mu,{});case"/send":return t.jsx(Qh,{},n);case"/nft":return t.jsx(rm,{});case"/nft/send":return t.jsx(gm,{},n);case"/bridge":return t.jsx(a_,{},n);case"/bridge/preview":return t.jsx(yf,{});case"/bridge/history":return t.jsx(Vf,{});case"/op/withdrawals":return t.jsx(O_,{});case"/tx":return t.jsx(to,{})}},Gf="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",Yf=()=>t.jsxs(t.Fragment,{children:[t.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),t.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),t.jsx("link",{rel:"stylesheet",href:Gf}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),Jf=()=>{se();const e=pe();return wn(),wt(localStorage.getItem(F.BRIDGE_SRC_CHAIN_ID)??e.chainId),wt(localStorage.getItem(F.BRIDGE_DST_CHAIN_ID)??e.chainId),null},Zf=new T.QueryClient({defaultOptions:{queries:{retry:0}}}),Xf=({children:e,...s})=>(_.useEffect(()=>{Sa()},[]),be.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(Yf,{}),t.jsx(jr.Provider,{value:{..._r,...s},children:t.jsx(xr,{children:t.jsx($a,{children:t.jsx(Q.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(Ka,{children:t.jsxs(fc,{children:[e,t.jsxs(T.QueryClientProvider,{client:Zf,children:[t.jsx(pc,{}),t.jsx(de,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(Jf,{})}),t.jsx(Xc,{children:t.jsx(ko,{})})]})]})})})})})})]}):null),ep=({bridge:e})=>t.jsx(xr,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Wr.Provider,{value:!!e,children:t.jsx(de,{children:t.jsx(ko,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=Lt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=mr;exports.InterwovenKit=ep;exports.InterwovenKitProvider=Xf;exports.MAINNET=_r;exports.MoveError=vr;exports.TESTNET=zo;exports.initiaPrivyWallet=Wo;exports.initiaPrivyWalletConnector=Ko;exports.initiaPrivyWalletOptions=ys;exports.injectStyles=xc;exports.useAddress=Nt;exports.useHexAddress=As;exports.useInitiaAddress=ne;exports.useInterwovenKit=ge;exports.usePortfolio=vn;exports.useUsernameQuery=Or;
4
+ </svg>`,xa=encodeURIComponent(ga),wn=`data:image/svg+xml;utf8,${xa}`,ms=qe.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,s)=>[e,s],resource:(e,s)=>[e.chainId,s.denom],denom:(e,s)=>[e,s],metadata:(e,s)=>[e,s]});function ya(e){const{base:s,symbol:n,denom_units:r=[],display:o,logo_URIs:a,name:i,address:l,traces:c}=e,d=r.find(h=>h.denom===o)?.exponent??r.find(h=>h.denom===s)?.exponent??v.head(r)?.exponent??0,u=a?.png??"";return{denom:s,symbol:n,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function Fr(){const e=E.useQueryClient();return s=>{const n=s?.metadata?.assetlist;return E.queryOptions({queryKey:ms.list(n).queryKey,queryFn:async()=>n?Z.get(n).json():{assets:[]},select:({assets:r})=>{if(!s)return[];const o=r.map(ya);for(const a of o)e.setQueryData(ms.item(s.chainId,a.denom).queryKey,a);return o},staleTime:U.MINUTE})}}function Ht(e){const s=Fr(),{data:n}=E.useSuspenseQuery(s(e));return n}function ja(){const e=se(),s=Fr();return E.useQueries({queries:e.map(n=>s(n))})}function Xe(e){const s=Ht(e),n=ye(),r=Ht(n),o=Lr(e);return a=>{const i=s.find(c=>c.denom===a);if(i)return i;const l=r.find(c=>c.denom===o(a));return l?{...l,denom:a}:{denom:a,symbol:"",decimals:0,logoUrl:wn}}}function Or(e,s){const n=Xe(s),o=E.useQueryClient().getQueryData(ms.item(s.chainId,e).queryKey);return o||n(e)}function Lr(e){const s=ye(),n=Ht(e);return r=>{if(e.metadata?.is_l1)return r;if(r.startsWith("l2/")||r.startsWith("ibc/")){const a=n.find(i=>i.denom===r)?.traces;if(a){for(const i of a)if(i.counterparty.chain_name===s.chain_name)return i.counterparty.base_denom}}const o=s.metadata?.ibc_channels?.find(({chain_id:a,version:i})=>a===e.chain_id&&i==="ics20-1")?.channel_id;return o?N.getIbcDenom(o,r):""}}const Ln="usernames";function va({restUrl:e,moduleAddress:s}){const{viewFunction:n}=N.createMoveClient(e);async function r(i){if(!N.InitiaAddress.validate(i))return null;const l=await n({moduleAddress:s,moduleName:Ln,functionName:"get_name_from_address",typeArgs:[],args:[H.toBase64(N.InitiaAddress(i,32).bytes)]});return l?l+".init":null}function o(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function a(i){if(!o(i))return null;const l=await n({moduleAddress:s,moduleName:Ln,functionName:"get_address_from_name",typeArgs:[],args:[Oo.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return l?N.InitiaAddress(l).bech32:null}return{restUrl:e,getUsername:r,getAddress:a,validateUsername:o}}const As=qe.createQueryKeys("interwovenkit:account",{username:(e,s)=>[e,s],address:(e,s)=>[e,s],balances:(e,s)=>[e,s],txs:(e,s)=>[e,s]});function Ur(){const{restUrl:e}=ye(),{usernamesModuleAddress:s}=ce();return va({restUrl:e,moduleAddress:s})}function zr(){const e=ne();return s=>E.queryOptions({queryKey:As.balances(s.restUrl,e).queryKey,queryFn:()=>Mr(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:s.restUrl},"balances"),staleTime:U.SECOND})}function Cn(e){const s=zr(),{data:n}=E.useSuspenseQuery(s(e));return n}function ba(){const e=se(),s=zr();return E.useQueries({queries:e.map(n=>s(n))})}function wa(e){const s=Cn(e),n=Ht(e),r=Xe(e),o=Lr(e),{data:a}=Cs(e),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>n.some(d=>d.denom===c);return v.sortWith([v.descend(({denom:c})=>o(c)==="uinit"),v.descend(({denom:c})=>i(c)),v.descend(({value:c})=>c),v.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>M(d).comparedTo(c)??0,v.descend(({symbol:c})=>c.toLowerCase())],s.filter(({amount:c})=>!M(c).isZero()).map(({amount:c,denom:d})=>{const u=r(d),h=a?.find(({id:_})=>_===u?.denom)?.price??0,m=M(c).times(h).div(M(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:h,value:m}}))}const Ca="INIT",Ia="Initia";function In(e){return e.assets.reduce((s,{value:n})=>s+(n??0),0)}function Na(e){return e.assets.reduce((s,{quantity:n})=>s.plus(n),M(0)).toString()}function Sa(e,s){return{symbol:s?.symbol??e,logoUrl:s?.logoUrl??wn}}function Un(e){return v.pick(["chainId","name","logoUrl"],e)}function ka(e){return v.sortWith([v.descend(({symbol:s})=>s===Ca),v.descend(In),v.descend(({assets:s})=>s.length),v.ascend(({symbol:s})=>s)])(e)}function Aa(e){return v.sortWith([v.descend(({value:s})=>s??0),v.descend(({quantity:s})=>Number(s)),v.ascend(({chain:s})=>s.name)])(e)}function $a(e){return v.sortWith([v.descend(({chain:s})=>s.name===Ia),v.ascend(({chain:s})=>s.name),v.ascend(({denom:s})=>s)])(e)}function Ta(e,s){return v.sortWith([v.descend(({chainId:n})=>n===s),v.descend(v.prop("value"))])(e)}function Ea(e,s,n,r,o){const a={};for(const u of e){const h=u.chainId,m=s[h]??[],_=n[h],p=r[h],g=[];for(const{amount:b,denom:k}of m){if(!M(b).gt(0))continue;const S=_?.find(P=>P.denom===k),T=p?.find(P=>P.id===k)?.price,j=S?.decimals??0,D=N.fromBaseUnit(b,{decimals:j}),B=T?M(D).times(T).toNumber():void 0;g.push({...Sa(k,S),amount:b,denom:k,decimals:j,quantity:D,price:T,value:B,address:S?.address,unlisted:!S,chain:Un(u)})}a[h]=g}const i=new Map;for(const[u,h]of Object.entries(a)){const m=e.find(p=>p.chainId===u);if(!m)continue;const _=h.reduce((p,{value:g})=>p+(g??0),0);i.set(u,{...Un(m),value:_})}const l=new Map;for(const u of Object.values(a))for(const h of u)if(!h.unlisted){const{symbol:m}=h,_=l.get(m)??[];l.set(m,[..._,h])}const c=[];for(const[u,h]of l){const m=v.head(h);if(!m)continue;const _=Aa(h);c.push({symbol:u,logoUrl:m.logoUrl,assets:_})}const d=[];for(const u of Object.values(a))for(const h of u)h.unlisted&&d.push(h);return{chainsByValue:Ta(Array.from(i.values()),o),assetGroups:ka(c),unlistedAssets:$a(d),totalValue:c.reduce((u,h)=>u+In(h),0)}}function Nn(){const{defaultChainId:e}=ce(),s=se(),n=ba(),r=ja(),o=ra(),a=s.map(m=>m.chainId),i=v.zipObj(a,n.map(v.prop("data"))),l=v.zipObj(a,r.map(v.prop("data"))),c=v.zipObj(a,o.map(v.prop("data"))),d=Ea(s,i,l,c,e),u=[n,r,o].flat().some(({isLoading:m})=>m);return{...d,isLoading:u,refetch:()=>{n.forEach(({refetch:m})=>m()),r.forEach(({refetch:m})=>m()),o.forEach(({refetch:m})=>m())}}}function ne(){const e=$s();return e?N.InitiaAddress(e).bech32:""}function $s(){const{address:e}=xe.useAccount();return e?N.InitiaAddress(e).hex:""}function At(){const e=Qt(),s=ne(),n=$s();return e.metadata?.minitia?.type==="minievm"?n:s}function Kr(){const e=At(),s=Ur();return E.useQuery({queryKey:As.username(s.restUrl,e).queryKey,queryFn:()=>s.getUsername(e),enabled:!!e,staleTime:U.MINUTE})}function je(){const e=At(),s=ne(),n=$s(),{data:r}=Kr(),o=St(),a=Er(),{isDrawerOpen:i,openDrawer:l}=kt(),c=()=>{l("/")},d=()=>{l("/connect")},u=_=>{l("/bridge",_)},h=Rr();return{address:e,initiaAddress:s,hexAddress:n,username:r,offlineSigner:o,isConnected:!!e,isOpen:i,openConnect:d,openWallet:c,openBridge:u,disconnect:a,...h}}function qa(){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"],s={"initia-wallet-widget:ethereum-public-keys":{prefix:O.PUBLIC_KEY,getSuffix:n=>N.InitiaAddress(n).bech32}};for(const n of e)localStorage.removeItem(n);for(const[n,{prefix:r,getSuffix:o}]of Object.entries(s)){const a=localStorage.getItem(n);if(a)try{const i=JSON.parse(a);for(const[l,c]of Object.entries(i)){const d=`${r}:${o(l)}`;localStorage.setItem(d,c)}localStorage.removeItem(n)}catch{}}}const Da="_status_tn9m1_1",Pa="_error_tn9m1_9",zn={status:Da,error:Pa},J=({error:e,children:s})=>t.jsx("p",{className:R(zn.status,{[zn.error]:e}),children:s}),ue=({errorBoundaryProps:e={fallbackRender:({error:r})=>t.jsx(J,{error:!0,children:r.message})},suspenseFallback:s=t.jsx(J,{children:"Loading..."}),children:n})=>t.jsx(pr.ErrorBoundary,{...e,children:t.jsx(f.Suspense,{fallback:s,children:n})}),Te=qe.createQueryKeys("interwovenkit:skip",{chains:null,assets:e=>[e],asset:(e,s)=>[e,s],balances:(e,s)=>[e,s],route:(e,s)=>[e,s],routeErrorInfo:e=>[e],txTrack:(e,s)=>[e,s],txStatus:(e,s)=>[e,s]});function Oe(){const{routerApiUrl:e}=ce();return f.useMemo(()=>Z.create({prefixUrl:e}),[e])}function Hr(){const e=se();return s=>e.some(n=>n.chain_id===s)}function Vt(){const e=Hr();return s=>e(s.chain_id)?"initia":s.chain_type}function Wt(e){return Vt()(e)}function Sn(){const e=Oe(),{data:s}=E.useSuspenseQuery({queryKey:Te.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:n})=>v.sortWith([v.descend(({chain_name:r})=>r==="initia"),v.ascend(({pretty_name:r})=>r)],n),staleTime:U.MINUTE});return s}function mt(){const e=Sn();return s=>{const n=e.find(r=>r.chain_id===s);if(!n)throw new Error(`Chain not found: ${s}`);return n}}function Ee(e){return mt()(e)}function It(e){const s=Oe(),n=E.useQueryClient(),{data:r}=E.useSuspenseQuery({queryKey:Te.assets(e).queryKey,queryFn:()=>s.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:o})=>{const{assets:a}=o[e]??{assets:[]};for(const i of a)n.setQueryData(Te.asset(e,i.denom).queryKey,i);return a.toSorted(v.descend(i=>i.symbol==="INIT"))},staleTime:U.MINUTE});return r}function Wr(e){const s=It(e);return n=>{const r=s.find(o=>o.denom===n);if(!r)throw new Error(`Asset not found: ${n}`);return r}}function Be(e,s){return Wr(s)(e)}const kn=f.createContext(null);function dt(){const{container:e}=f.useContext(kn);return e}function Qr(e){const s=dt();return s?getComputedStyle(s).getPropertyValue(e):""}const Ra=({children:e})=>{const[s,n]=f.useState(null);return t.jsx(kn.Provider,{value:{container:s,setContainer:n},children:e})},Ba="_loader_4gdsk_1",Ma={loader:Ba},_t=({size:e=24,color:s="currentColor",border:n=2})=>{const r={width:`${e}px`,height:`${e}px`,borderColor:`${s} ${s} transparent ${s}`,borderWidth:`${n}px`};return t.jsx("div",{className:Ma.loader,style:r})},Fa="_container_1zg8z_1",Oa="_toast_1zg8z_10",La="_info_1zg8z_23",Ua="_success_1zg8z_27",za="_error_1zg8z_31",Ka="_icon_1zg8z_36",Ha="_content_1zg8z_43",Wa="_title_1zg8z_46",Qa="_description_1zg8z_51",Va="_close_1zg8z_72",He={container:Fa,toast:Oa,info:La,success:Ua,error:za,icon:Ka,content:Ha,title:Wa,description:Qa,close:Va},Ga=({notification:e,onClose:s,...n})=>{const r=Je.useTransition(e,{keys:a=>a?.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}}),o=a=>{switch(a){case"loading":return t.jsx(_t,{size:16});case"info":case"success":return t.jsx(A.IconCheckCircleFilled,{size:16});case"error":return t.jsx(A.IconCloseCircleFilled,{size:16});default:return null}};return r((a,i)=>{if(!i)return null;const{type:l,title:c,description:d}=i,u=o(l);return t.jsx(Je.animated.div,{style:a,className:He.container,children:t.jsxs("div",{className:R(He.toast,l&&He[l]),...n,children:[u&&t.jsx("div",{className:He.icon,children:u}),t.jsxs("div",{className:He.content,children:[t.jsx("p",{className:He.title,children:c}),d&&t.jsx("div",{className:He.description,children:d})]}),t.jsx("button",{className:He.close,onClick:s,children:t.jsx(A.IconClose,{size:14})})]})})})},Vr=f.createContext(null),An=()=>f.useContext(Vr),zs=5e3,Ya=({children:e})=>{const s=dt(),[n,r]=f.useState(null),o=f.useRef(null),a=f.useRef(!1),i=()=>{o.current&&(clearTimeout(o.current),o.current=null)},l=f.useCallback(()=>{i(),r(null)},[]),c=f.useCallback(m=>{i(),r({...m,id:Fn.nanoid()}),m.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),zs))},[l]),d=f.useCallback(m=>{i(),r(_=>_?{..._,...m}:{...m,id:Fn.nanoid()}),m.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),zs))},[l]),u=()=>{i(),a.current=!0},h=()=>{i(),a.current=!1,n?.autoHide&&(o.current=setTimeout(()=>l(),zs))};return f.useEffect(()=>()=>i(),[]),t.jsxs(Vr.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,s&&Lo.createPortal(t.jsx(Ga,{notification:n,onClose:l,onMouseEnter:u,onMouseLeave:h}),s)]})},Gr=f.createContext(!1),Ja="_overlay_2lgi8_1",Za="_fullscreen_2lgi8_15",Xa="_content_2lgi8_19",ei="_header_2lgi8_54",ti="_title_2lgi8_63",si="_close_2lgi8_68",st={overlay:Ja,fullscreen:Za,content:Xa,header:ei,title:ti,close:si},Yr=({title:e,children:s,trigger:n,className:r,open:o,onOpenChange:a})=>{const i=dt(),l=f.useContext(Gr);return i?t.jsxs(we.Dialog.Root,{open:o,onOpenChange:a,modal:"trap-focus",children:[n&&t.jsx(we.Dialog.Trigger,{className:r,children:n}),t.jsxs(we.Dialog.Portal,{container:i,children:[t.jsx(we.Dialog.Backdrop,{className:R(st.overlay,{[st.fullscreen]:l}),onClick:()=>a(!1),forceRender:!0}),t.jsxs(we.Dialog.Popup,{className:R(st.content,{[st.fullscreen]:l}),children:[e&&t.jsxs("header",{className:st.header,children:[t.jsx(we.Dialog.Title,{className:st.title,children:e}),t.jsx(we.Dialog.Close,{className:st.close,children:t.jsx(A.IconClose,{size:20})})]}),s]})]})]}):null},ni=10;function Jr(){const e=ne();return(s,n)=>E.queryOptions({queryKey:As.txs(s.indexerUrl,e).queryKey,queryFn:async()=>{if(!n.enabled)return[];const r={"pagination.reverse":!0,"pagination.limit":ni},{txs:o}=await Z.create({prefixUrl:s.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:r}).json();return o},staleTime:U.SECOND})}function ri(e,s){const n=Jr();return E.useSuspenseQuery(n(e,s))}function oi(e,s){const n=e.flatMap((r,o)=>(s[o]??[]).map(i=>({...i,chain:r})));return v.sortWith([v.descend(r=>new Date(r.timestamp).getTime())])(n)}const ai=()=>{const e=se(),s=Jr(),n=E.useQueries({queries:e.map(i=>s(i,{enabled:!0}))}),r=n.map(v.prop("data")),o=oi(e,r),a=n.some(i=>i.isLoading);return{activities:o,isLoading:a}};function Zr(e){const{data:s}=E.useSuspenseQuery({queryKey:vn.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:r}=await Z.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return r.toSorted(v.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const i=o==="uinit"?1:xr;return{amount:M(a).times(i).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:r})=>{if(v.isNil(r))throw new Error(`${n} has no price`);return{amount:String(r),denom:n}})},staleTime:U.SECOND});return s}function Xr(e){const s=ne(),{data:n}=ri(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const r=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return r;try{return n.find(({tx:a})=>a.auth_info.signer_infos.some(i=>N.InitiaAddress.equals(s,Ye.computeAddress(`0x${H.toHex(an.Secp256k1.uncompressPubkey(H.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??r}catch{return r}}const ii="_root_hypwm_1",ci="_item_hypwm_10",li="_chevron_hypwm_14",di="_trigger_hypwm_19",ui="_content_hypwm_39",Dt={root:ii,item:ci,chevron:li,trigger:di,content:ui};function hi(e){const{list:s,getKey:n,renderHeader:r,renderContent:o,footer:a,...i}=e;return t.jsxs(G.Accordion.Root,{className:Dt.root,type:"multiple",...i,children:[s.map((l,c)=>t.jsxs(G.Accordion.Item,{className:Dt.item,value:n?.(l)??String(c),children:[t.jsx(G.Accordion.Header,{children:t.jsxs(G.Accordion.Trigger,{className:Dt.trigger,children:[r(l),t.jsx(A.IconChevronDown,{className:Dt.chevron,size:16})]})}),t.jsx(G.Accordion.Content,{className:Dt.content,children:o(l)})]},n?.(l)??c)),a]})}const mi="_scrollable_abvhw_1",_i={scrollable:mi},Le=({className:e,children:s,ref:n})=>t.jsx("div",{ref:n,className:R(_i.scrollable,e),children:s}),ln=({children:e})=>{const s=f.useRef(null),[n,r]=f.useState(0),o=Je.useSpring({height:n,config:{tension:500,friction:30,clamp:!0}});return f.useEffect(()=>{if(s.current){const{height:a}=s.current.getBoundingClientRect();r(a)}},[e]),e?t.jsx(Je.animated.div,{style:{overflow:"hidden",...o},children:t.jsx("div",{ref:s,children:e})}):null},fi="_help_7m3jv_1",pi="_icon_7m3jv_10",gi="_info_7m3jv_17",xi="_warning_7m3jv_21",yi="_error_7m3jv_25",ji="_success_7m3jv_31",Ks={help:fi,icon:pi,info:gi,warning:xi,error:yi,success:ji},Qe=({level:e,className:s,mt:n=8,children:r})=>{if(!r)return null;const o=()=>{switch(e){case"loading":return t.jsx(_t,{size:12});case"info":return t.jsx(A.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(A.IconWarningFilled,{size:12});default:return t.jsx(A.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:R(Ks.help,e&&Ks[e],s),style:{marginTop:n},children:[t.jsx("div",{className:Ks.icon,children:o()}),t.jsx("p",{children:r})]})},vi="_stack_14kq8_1",bi="_help_14kq8_6",wi="_info_14kq8_14",Ci="_warning_14kq8_19",Ii="_error_14kq8_24",Ni="_success_14kq8_29",dn={stack:vi,help:bi,info:wi,warning:Ci,error:Ii,success:Ni},Si=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(ln,{children:t.jsx("div",{className:dn.stack,children:e})}),ee=e=>t.jsx(Qe,{...e,className:R(dn.help,dn[e.level]),mt:0});ee.Stack=Si;const ki="_footer_xif7g_1",Ai="_actions_xif7g_10",Kn={footer:ki,actions:Ai},te=({extra:e,className:s,children:n})=>t.jsxs("footer",{className:R(Kn.footer,s),children:[e,t.jsx("div",{className:Kn.actions,children:n})]}),$i="_button_1n7c4_1",Ti="_outline_1n7c4_25",Ei="_sm_1n7c4_43",qi="_full_1n7c4_49",Di="_small_1n7c4_53",Pi="_unpadded_1n7c4_83",it={button:$i,outline:Ti,sm:Ei,full:qi,small:Di,unpadded:Pi},eo=e=>{const{sm:s,fullWidth:n,loading:r,className:o,children:a,disabled:i,...l}=e;return t.jsx("button",{...l,className:R(it.button,{[it.sm]:s,[it.full]:n},o),disabled:!!r||i,children:r?t.jsxs(t.Fragment,{children:[t.jsx(_t,{color:"currentColor",size:16}),typeof r=="string"&&t.jsx("span",{className:it.loading,children:r})]}):a})},Ri=({className:e,...s})=>t.jsx(eo,{...s,className:R(it.outline,e)}),Bi=({className:e,unpadded:s,...n})=>t.jsx("button",{...n,className:R(it.small,{[it.unpadded]:s},e)}),W={White:eo,Outline:Ri,Small:Bi},Mi="_item_1n572_1",Fi="_title_1n572_10",Oi="_content_1n572_14",Hs={item:Mi,title:Fi,content:Oi},Ws=({title:e,content:s})=>t.jsxs("div",{className:Hs.item,children:[t.jsx("div",{className:Hs.title,children:e}),t.jsx("div",{className:Hs.content,children:s})]});function Me(e){if(e&&M(e).gt(0)&&M(e).lt(.01))return"<$0.01";const s=N.formatNumber(e,{dp:2});return s?`$${s}`:""}const Li="_placeholder_yluz4_1",Ui="_logo_yluz4_5",Hn={placeholder:Li,logo:Ui},z=({src:e,alt:s,placeholder:n,classNames:r,style:o,logo:a,...i})=>{const[l,c]=f.useState(!1),{width:d,height:u}=i,h=n??t.jsx("div",{className:R(Hn.placeholder,r?.placeholder),style:{width:d,height:u,...o}});return f.useEffect(()=>{c(!1)},[e]),!e||l?h:t.jsx("img",{...i,className:R(i.className,{[Hn.logo]:a}),style:{width:d,height:u,...o},src:e,alt:s,loading:"lazy",onError:()=>c(!0)})};function to(e,s){const n={};for(const r of e)if(r.attributes.some(a=>a.key==="msg_index")){if(r.type==="coin_spent"){const a=r.attributes.find(l=>l.key==="spender")?.value,i=r.attributes.find(l=>l.key==="amount")?.value;if(a===s&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=n[c]||BigInt(0);n[c]=d-BigInt(l)}}}if(r.type==="coin_received"){const a=r.attributes.find(l=>l.key==="receiver")?.value,i=r.attributes.find(l=>l.key==="amount")?.value;if(a===s&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=n[c]||BigInt(0);n[c]=d+BigInt(l)}}}}return Object.entries(n).filter(([,r])=>r!==BigInt(0)).map(([r,o])=>({amount:o.toString(),denom:r}))}function so(e,s){const n={};for(const r of e)if(r.attributes.some(a=>a.key==="msg_index")&&r.type==="move"){const a=r.attributes.find(c=>c.key==="type_tag")?.value,i=r.attributes.find(c=>c.key==="data")?.value;if(!a||!i)continue;let l;try{l=JSON.parse(i)}catch{continue}if(a==="0x1::fungible_asset::WithdrawEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&N.createUserDerivedObjectAddress(s,u)===c){const m=n[u]||BigInt(0);n[u]=m-BigInt(d)}}if(a==="0x1::fungible_asset::DepositEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&N.createUserDerivedObjectAddress(s,u)===c){const m=n[u]||BigInt(0);n[u]=m+BigInt(d)}}}return Object.entries(n).filter(([,r])=>r!==BigInt(0)).map(([r,o])=>({amount:o.toString(),metadata:r}))}const no=({metadata:e,chain:s,children:n})=>{const{restUrl:r}=s,{data:o}=E.useSuspenseQuery({queryKey:ms.denom(r,e).queryKey,queryFn:()=>Z.create({prefixUrl:r}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:a})=>a,staleTime:U.INFINITY});return n(o)},zi="_root_jioyr_1",Ki="_title_jioyr_7",Hi="_changes_jioyr_13",Wi="_change_jioyr_13",Qi="_amount_jioyr_34",Vi="_text_jioyr_40",Gi="_value_jioyr_47",ct={root:zi,title:Ki,changes:Hi,change:Wi,amount:Qi,text:Vi,value:Gi},ro=({amount:e,asset:s,price:n})=>{const{denom:r,symbol:o,decimals:a,logoUrl:i}=s,l=N.formatAmount(e,{decimals:a}),c=n&&M(N.fromBaseUnit(e,{decimals:a})).times(n).abs();return t.jsxs("div",{className:ct.change,children:[t.jsxs("div",{className:ct.amount,children:[t.jsx(z,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:ct.text,children:[l," ",o||r]})]}),c&&t.jsx("div",{className:ct.value,children:Me(c)})]})},Yi=({changes:e,chain:s})=>{const n=Xe(s),{data:r}=Cs(s);return e.map(({amount:o,denom:a},i)=>{const l=n(a),c=r?.find(({id:d})=>d===a)?.price;return t.jsx(ro,{amount:o,asset:l,price:c},i)})},Ji=({changes:e,chain:s})=>{const n=Xe(s),{data:r}=Cs(s);return e.map(({amount:o,metadata:a},i)=>t.jsx(no,{metadata:a,chain:s,children:l=>{const c=r?.find(({id:d})=>d===l)?.price;return t.jsx(ro,{amount:o,asset:n(l),price:c})}},i))};function Zi(e,s){return typeof s=="bigint"?s.toString():s}const Xi=qe.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Zi)]}),ec=({messages:e,memo:s,chainId:n})=>{const{initiaAddress:r,hexAddress:o}=je(),a=Fe(n),{simulateTx:i}=Rr(),{data:l}=E.useSuspenseQuery({queryKey:Xi.simulate({messages:e,memo:s,chainId:n}).queryKey,queryFn:()=>i({messages:e,memo:s,chainId:n}),staleTime:U.SECOND}),c=m=>t.jsxs("div",{className:ct.root,children:[t.jsx("h2",{className:ct.title,children:"Estimated changes"}),t.jsx("div",{className:ct.changes,children:m})]});if(!l)return null;const d=l.result?.events??[];if(d.length===0)return null;if(a.metadata?.is_l1||a.metadata?.minitia?.type==="minimove"){const m=so(d,o),[_]=Wn(m);return _.length===0?null:c(t.jsx(Ji,{changes:_,chain:a}))}const u=to(d,r),[h]=Wn(u);return h.length===0?null:c(t.jsx(Yi,{changes:h,chain:a}))};function Wn(e){return v.partition(s=>new M(s.amount).isNegative(),e)}const tc="_value_9u3br_1",sc="_trigger_9u3br_7",nc="_icon_9u3br_23",rc="_content_9u3br_32",oc="_item_9u3br_40",Pt={value:tc,trigger:sc,icon:nc,content:rc,item:oc},ac=({options:e,value:s,onChange:n})=>{const r=dt(),{txRequest:o}=Pr(),a=Fe(o.chainId),i=Xe(a),l=({amount:[{amount:_,denom:p}]})=>{if(M(_).isZero())return"0";const{symbol:g,decimals:b}=i(p);return`${N.formatAmount(_,{decimals:b})} ${g}`};if(e.length===1)return l(e[0]);const c=e.find(_=>_.amount[0].denom===s);if(!c)throw new Error("Fee option not found");const[{amount:d,denom:u}]=c.amount,{decimals:h,symbol:m}=i(u);return t.jsxs(De.Select.Root,{value:s,onValueChange:n,modal:!1,children:[t.jsxs("div",{className:Pt.value,children:[t.jsx("span",{className:"monospace",children:N.formatAmount(d,{decimals:h})}),t.jsxs(De.Select.Trigger,{className:Pt.trigger,children:[t.jsx(De.Select.Value,{children:m}),t.jsx(De.Select.Icon,{className:Pt.icon,children:t.jsx(A.IconChevronDown,{size:16})})]})]}),t.jsx(De.Select.Portal,{container:r,children:t.jsx(De.Select.Positioner,{className:Pt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(De.Select.Popup,{children:e.map(_=>{const[{denom:p}]=_.amount;return t.jsx(De.Select.Item,{className:Pt.item,value:p,children:t.jsx(De.Select.ItemText,{children:l(_)})},p)})})})})]})};function _s(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?H.toBase64(e):Array.isArray(e)?`[${e.map(_s).join(",")}]`:JSON.stringify(e,(s,n)=>typeof n=="bigint"?n.toString():n);default:return"unknown"}}const ic="_container_1xzyq_1",cc="_toggle_1xzyq_5",lc="_list_1xzyq_11",dc="_arg_1xzyq_16",uc="_type_1xzyq_21",Rt={container:ic,toggle:cc,list:lc,arg:dc,type:uc},hc=qe.createQueryKeys("interwovenkit:move",{abi:(e,s,n,r)=>[e,s,n,r]}),mc=({type:e,arg:s})=>_s(N.resolveBcsType(e).parse(s)),_c=({msg:e,chainId:s,fallback:n})=>{const[r,o]=Ce.useToggle(!1),{restUrl:a}=Fe(s),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=E.useQuery({queryKey:hc.abi(a,i,l,c).queryKey,queryFn:async()=>{const m=await Z.create({prefixUrl:a}).get(`initia/move/v1/accounts/${i}/modules/${l}`).json(),p=JSON.parse(m.module.abi).exposed_functions.find(({name:g})=>g===c);if(!p)throw new Error(`Function ${c} not found in module ${l}`);return p.params.filter(g=>!g.startsWith("&"))},staleTime:U.INFINITY});if(!u)return n;const h=(m,_)=>{const p=u[_];return t.jsxs("div",{className:Rt.arg,children:[t.jsx("div",{className:Rt.type,children:p}),t.jsx(pr.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(mc,{type:p,arg:m})})]},_)};return t.jsxs("div",{className:Rt.container,children:[t.jsx(W.Small,{className:Rt.toggle,onClick:o,disabled:!u,children:r?"Encode":"Decode"}),r?t.jsx("div",{className:Rt.list,children:d.map(h)}):n]})},fc="_list_r67rl_1",pc="_key_r67rl_8",gc="_value_r67rl_13",Qs={list:fc,key:pc,value:gc},xc=({message:e,chainId:s})=>{const{typeUrl:n,value:r}=e;return t.jsx("div",{className:Qs.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{children:[t.jsx("div",{className:Qs.key,children:o}),t.jsx("div",{className:Qs.value,children:n==="/initia.move.v1.MsgExecute"&&o==="args"?t.jsx(_c,{msg:r,chainId:s,fallback:_s(a)}):_s(a)})]},o))})},yc="_title_kspdu_1",jc="_meta_kspdu_7",vc="_footer_kspdu_14",Vs={title:yc,meta:jc,footer:vc},oo=()=>{const{txRequest:e,resolve:s,reject:n}=Pr(),{messages:r,memo:o,chainId:a,gas:i,gasAdjustment:l,spendCoins:c}=e,d=ne(),u=St(),h=bn(),m=Fe(a),_=Cn(m),p=Zr(m),g=Xr(m),b=(e.gasPrices??p).map(({amount:x,denom:w})=>$e.calculateFee(Math.ceil(i*l),$e.GasPrice.fromString(x+w))),k=b.map(x=>x.amount[0]),S=x=>{const w=_.find(C=>C.denom===x)?.amount??0,y=k.find(C=>C.denom===x)?.amount??0,q=c.filter(C=>C.denom===x).reduce((C,F)=>M(C).plus(F.amount),M(0));if(q.gt(0)){const C=M(y).plus(q);return M(w).gte(C)}return M(w).gte(y)},T=()=>{if(g&&S(g))return g;for(const{denom:x}of k)if(S(x))return x;return k[0]?.denom},[j,D]=f.useState(T),{mutate:B,isPending:P}=E.useMutation({mutationKey:[qr],mutationFn:async()=>{const x=b.find(y=>y.amount[0].denom===j);if(!x)throw new Error("Fee not found");if(!u)throw new Error("Signer not initialized");const w=await h(a,d,r,x,o);await s(w)},onError:async x=>{n(x)}}),I=!S(j);return t.jsxs(t.Fragment,{children:[t.jsxs(Le,{children:[t.jsx("h1",{className:Vs.title,children:"Confirm tx"}),t.jsxs("div",{className:Vs.meta,children:[t.jsx(Ws,{title:"Chain",content:a}),t.jsx(Ws,{title:"Tx fee",content:t.jsx(ac,{options:b,value:j,onChange:D})}),o&&t.jsx(Ws,{title:"Memo",content:o}),I&&t.jsx(ee,{level:"error",children:"Insufficient balance for fee"})]}),t.jsx(ec,{messages:r,memo:o,chainId:a}),t.jsx(hi,{list:r,renderHeader:({typeUrl:x})=>ys.sentenceCase(x.split(".").pop().replace(/^Msg/,"")),renderContent:x=>t.jsx(xc,{message:x,chainId:a})})]}),t.jsxs(te,{className:Vs.footer,children:[t.jsx(W.Outline,{onClick:()=>n(new Error("User rejected")),disabled:P,children:"Reject"}),t.jsx(W.White,{onClick:()=>B(),disabled:I,loading:P,children:"Approve"})]})]})},bc=({children:e})=>{const[{title:s,content:n,path:r},o]=f.useState({}),[a,i]=f.useState(!1),l=Q.useAtomValue(ks),c=f.useCallback(h=>{o(h),i(!0)},[]),d=f.useCallback(()=>{o({}),i(!1)},[]),u=f.useCallback(h=>{h||(l?.reject(new Error("User rejected")),o({})),i(h)},[l]);return t.jsxs(Cr.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(Yr,{title:s,open:a,onOpenChange:u,children:t.jsx(ue,{children:r==="/tx"?t.jsx(oo,{}):n})})]})},wc=()=>(ma(),_a(),null);function Ts(){return Ce.useMediaQuery("(max-width: 576px)")}const un="interwoven-kit";function ao(){const e=document.querySelector(un)||document.body.appendChild(document.createElement(un));return e.shadowRoot||e.attachShadow({mode:"open"})}function Cc(){const{theme:e,container:s}=ce();return f.useEffect(()=>{document.querySelector(un)?.setAttribute("data-theme",e)},[e]),s??ao()}function Ic(e){const s=ao(),n=document.createElement("style");n.textContent=e,s.appendChild(n)}const ut=({title:e,content:s,children:n,className:r})=>{const[o,a]=f.useState(!1),i=()=>a(!1);return t.jsx(Yr,{title:e,trigger:n,className:r,open:o,onOpenChange:a,children:s(i)})},fs=({value:e,children:s})=>{const[n,r]=f.useState(!1);return s({copy:async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1e3)}catch{}},copied:n})},Nc="_root_19tvg_1",Sc="_address_19tvg_9",kc="_copy_19tvg_19",Ac="_labelWrapper_19tvg_33",$c="_labelCopy_19tvg_43",Tc="_labelCopied_19tvg_47",Ec="_copied_19tvg_55",qc="_derived_19tvg_65",Dc="_derivedLabel_19tvg_78",Pc="_derivedAddress_19tvg_82",Rc="_hexAddress_19tvg_88",Bc="_derivedCopy_19tvg_93",oe={root:Nc,address:Sc,copy:kc,labelWrapper:Ac,labelCopy:$c,labelCopied:Tc,copied:Ec,derived:qc,derivedLabel:Dc,derivedAddress:Pc,hexAddress:Rc,derivedCopy:Bc},Mc=()=>{const e=f.useRef(null),s=f.useRef(null),{initiaAddress:n,hexAddress:r}=je(),o=Qr("--gray-0");return f.useEffect(()=>{e.current&&(s.current?s.current.update({data:n}):(s.current=new Uo({type:"canvas",width:400,height:400,margin:0,data:n,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:o},cornersSquareOptions:{type:"extra-rounded",color:o},cornersDotOptions:{type:"dot",color:o},backgroundOptions:{color:"transparent"}}),s.current.append(e.current)))},[n,o]),t.jsxs("div",{className:oe.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:oe.address,children:n}),t.jsx(fs,{value:n,children:({copy:a,copied:i})=>t.jsxs("button",{className:R(oe.copy,{[oe.copied]:i}),onClick:a,children:[t.jsx(A.IconCopy,{size:12}),t.jsxs("div",{className:oe.labelWrapper,children:[t.jsx("span",{className:oe.labelCopy,children:"Copy address"}),t.jsx("span",{className:oe.labelCopied,children:"Copied!"})]})]})}),t.jsx(fs,{value:r,children:({copy:a,copied:i})=>t.jsxs("button",{className:R(oe.derived,{[oe.copied]:i}),onClick:a,children:[t.jsx("span",{className:oe.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:oe.derivedAddress,children:[t.jsx("span",{className:oe.hexAddress,children:N.truncate(r)}),t.jsx(A.IconCopy,{size:12,className:oe.derivedCopy}),i&&t.jsx("span",{className:oe.copiedText,children:"Copied!"})]})]})})]})},Fc="_header_1cvtq_1",Oc="_account_1cvtq_16",Lc="_name_1cvtq_27",Uc="_address_1cvtq_31",zc="_icon_1cvtq_35",Kc="_copied_1cvtq_42",Hc="_button_1cvtq_57",Wc="_qr_1cvtq_68",Qc="_disconnect_1cvtq_72",Vc="_label_1cvtq_82",Gc="_expanded_1cvtq_90",_e={header:Fc,account:Oc,name:Lc,address:Uc,icon:zc,copied:Kc,button:Hc,qr:Wc,disconnect:Qc,label:Vc,expanded:Gc},Yc=()=>{const e=Qt(),{connector:s}=xe.useAccount(),n=Er(),{address:r,username:o}=je(),a=o??r,[i,l]=f.useState(!1),c=f.useRef(null),d=Je.useSpring({width:i?140:52,config:{tension:500,friction:30,clamp:!0}}),u=()=>{i?n():l(!0)},h=()=>{i&&(c.current=setTimeout(()=>{l(!1)},500))},m=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return f.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),s?t.jsxs("header",{className:_e.header,children:[t.jsx(fs,{value:r,children:({copy:_,copied:p})=>t.jsxs("button",{className:R(_e.account,{[_e.copied]:p}),onClick:_,children:[t.jsx(z,{src:s.icon,width:18,height:18}),t.jsx("div",{className:_e.address,children:N.truncate(r)}),t.jsx("div",{className:_e.name,children:N.truncate(a)}),t.jsx(A.IconCopy,{className:_e.icon,size:12}),p?"Copied!":""]})}),e.metadata?.is_l1&&t.jsx(ut,{title:"Initia address",content:()=>t.jsx(Mc,{}),className:R(_e.button,_e.qr),children:t.jsx(A.IconQrCode,{size:16})}),t.jsxs(Je.animated.button,{className:R(_e.button,_e.disconnect,{[_e.expanded]:i}),style:d,onClick:u,onMouseLeave:h,onMouseEnter:m,children:[t.jsx(A.IconSignOut,{size:16}),t.jsx("span",{className:_e.label,children:"Disconnect"})]})]}):null};function Jc(e){return/^[A-F0-9]{64}$/i.test(e)}function Zc(e,s){const{txHash:n,accountAddress:r,pathSuffix:o}=s;if(n)return Jc(n)?v.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,n):void 0;if(r){if(!N.InitiaAddress.validate(r))return;const i=v.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,r);return i&&o?i+o:i}}function Xc(e){try{const s=new URL(e,window.location.href);if(!["http:","https:"].includes(s.protocol))throw new Error("Invalid protocol");return s.toString()}catch{return"#"}}const el="_link_guafb_1",Qn={link:el},Es=({chainId:e,txHash:s,accountAddress:n,pathSuffix:r,...o})=>{const{showIcon:a,className:i,children:l,onClick:c,...d}=o,u=Fe(e),h=Zc(u,{txHash:s,accountAddress:n,pathSuffix:r}),m=s?N.truncate(s):n?N.truncate(n):"",_=l??m;return h?t.jsxs("a",{...d,href:zo(Xc(h)),className:R(Qn.link,i),onClick:c,target:"_blank",children:[_,a&&t.jsx(A.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:R(Qn.link,i),children:_})},tl=()=>{const[e,s]=Q.useAtom(Dr),{showNotification:n,updateNotification:r,hideNotification:o}=An();return f.useEffect(()=>{if(!e)return;const{status:a,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(Es,{txHash:l,chainId:i,onClick:o,showIcon:!0,children:"View on Initia Scan"}):null;switch(a){case"loading":n({type:"loading",title:"Transaction is pending..."});break;case"error":r({type:"error",title:"Transaction failed",description:d}),s(null);break;case"success":r({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),s(null);break}},[e,s,n,r,o]),null};function sl(){return Ce.useScrollLock(),null}const nl="_overlay_1dhd9_1",rl="_content_1dhd9_27",ol="_inner_1dhd9_58",Gs={overlay:nl,content:rl,inner:ol},al=({children:e})=>{const{isDrawerOpen:s,closeDrawer:n}=kt(),{setContainer:r}=f.useContext(kn),o=Ts(),a=Cc(),i=Q.useAtomValue(ks),l=E.useIsMutating({mutationKey:[qr]}),c=()=>{const _=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";n(),i?.reject(new Error(_))},d=bs(),u=ie(),h=E.useQueryClient(),m={fallbackRender:({error:_,resetErrorBoundary:p})=>{const g=()=>{d==="/bridge"&&(localStorage.removeItem(O.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(O.BRIDGE_SRC_DENOM),localStorage.removeItem(O.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(O.BRIDGE_DST_DENOM)),u("/"),h.clear(),p()};return t.jsxs(Le,{children:[t.jsx(J,{error:!0,children:_.message}),t.jsx(te,{children:t.jsx(W.White,{onClick:g,children:"Retry"})})]})}};return t.jsx(we.Dialog.Root,{open:s,onOpenChange:_=>!_&&c(),modal:!1,children:t.jsxs(we.Dialog.Portal,{container:a,children:[o&&t.jsx(we.Dialog.Backdrop,{className:Gs.overlay,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[t.jsx("path",{d:"M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z"}),t.jsx("path",{d:"M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z"})]})}),t.jsx(we.Dialog.Popup,{className:Gs.content,children:t.jsxs("div",{className:R(Gs.inner,"body"),ref:r,children:[o&&t.jsx(sl,{}),t.jsx(tl,{}),t.jsx(Yc,{}),t.jsx(ue,{errorBoundaryProps:m,children:e})]})})]})})},il="_page_1f6wh_1",cl="_title_1f6wh_10",ll="_scrollable_1f6wh_17",dl="_list_1f6wh_22",ul="_item_1f6wh_32",hl="_name_1f6wh_56",ml="_dimmed_1f6wh_64",_l="_recent_1f6wh_68",fl="_installed_1f6wh_69",ve={page:il,title:cl,scrollable:ll,list:dl,item:ul,name:hl,dimmed:ml,recent:_l,installed:fl},pl=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],Vn=({onSuccess:e})=>{const{connectors:s,connectAsync:n}=xe.useConnect(),r=Ce.useReadLocalStorage("wagmi.recentConnectorId"),[o,a]=f.useState(null),{mutate:i,isPending:l}=E.useMutation({mutationFn:async c=>{a(c.id);try{await n({connector:c})}catch(d){throw await Re(d)}},onSettled:()=>{a(null)},onSuccess:()=>{e?.()}});return t.jsxs("div",{className:ve.page,children:[t.jsx("h1",{className:ve.title,children:"Connect wallet"}),t.jsx(Le,{className:ve.scrollable,children:t.jsxs("div",{className:ve.list,children:[s.toSorted(v.descend(c=>c.id===r)).map(c=>{const{name:d,icon:u,id:h}=c;return t.jsxs("button",{className:ve.item,onClick:()=>i(c),disabled:l,children:[t.jsx(z,{src:u,width:24,height:24}),t.jsx("span",{className:ve.name,children:d}),o===h?t.jsx(_t,{size:16}):r===h?t.jsx("span",{className:ve.recent,children:"Recent"}):c.id===js.id?null:t.jsx("span",{className:ve.installed,children:"Installed"})]},h)}),pl.filter(({name:c})=>!s.some(d=>d.name.includes(c))).map(({name:c,url:d})=>{const u=`https://assets.initia.xyz/images/wallets/${c}.webp`;return t.jsxs("a",{href:d,className:ve.item,target:"_blank",children:[t.jsx(z,{src:u,width:24,height:24}),t.jsx("span",{className:R(ve.name,ve.dimmed),children:c}),t.jsx(A.IconExternalLink,{size:10})]},c)})]})})]})},gl="_root_xwz5z_1",xl="_header_xwz5z_6",yl="_title_xwz5z_12",jl="_warning_xwz5z_18",vl="_content_xwz5z_22",bl="_footer_xwz5z_26",wl="_secondary_xwz5z_36",nt={root:gl,header:xl,title:yl,warning:jl,content:vl,footer:bl,secondary:wl},io=e=>{const{type:s,icon:n,title:r,children:o,primaryButton:a,secondaryButton:i}=e;return t.jsxs(Le,{className:nt.root,children:[t.jsxs("header",{className:R(nt.header,s&&nt[s]),children:[n,t.jsx("h1",{className:nt.title,children:r})]}),t.jsx("div",{className:nt.content,children:o}),t.jsxs("footer",{className:nt.footer,children:[t.jsx(W.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),t.jsxs("button",{className:nt.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(A.IconChevronRight,{size:14})]})]})]})},Cl="_list_tmcxc_1",Il="_row_tmcxc_8",Nl="_dt_tmcxc_19",Sl="_asset_tmcxc_25",ss={list:Cl,row:Il,dt:Nl,asset:Sl},kl=({list:e,onNavigate:s,onDismiss:n})=>{const r=ye(),o=Ze(),a=Xe(r);return t.jsx(io,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:s},secondaryButton:{label:"Do not show again",onClick:n},children:t.jsx("div",{className:ss.list,children:e.toSorted((i,l)=>i.chainId.localeCompare(l.chainId)).map(({txHash:i,chainId:l,amount:c,denom:d})=>{const u=o(l),{decimals:h,symbol:m}=a(d),_=N.formatAmount(c,{decimals:h});return t.jsxs("div",{className:ss.row,children:[t.jsxs("div",{className:ss.dt,children:[t.jsx(z,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:ss.asset,children:[_," ",m]})]},i)})})})};function Ys(e,s){return e.chainId===s.chainId&&e.txHash===s.txHash}const ns=({chainId:e,txHash:s})=>`${O.OP_REMINDER}:${e}:${s}`,Al=Ko.atomWithStorage(O.OP_REMINDER,[]);function $t(){const e=ne(),[s=[],n]=Q.useAtom(Al),r=f.useMemo(()=>s.map(c=>{const d=localStorage.getItem(ns(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:Nt.isPast(u)}),[e,s]),o=f.useCallback((c,d)=>{s.some(u=>Ys(u,c))||(n((u=[])=>[...u,c]),localStorage.setItem(ns(c),JSON.stringify(d)))},[s,n]),a=f.useCallback(c=>{n((d=[])=>d.filter(u=>!Ys(u,c))),localStorage.removeItem(ns(c))},[n]),i=f.useCallback(c=>{const d=c.filter(u=>!s.some(h=>Ys(h,u)));d.length!==0&&n((u=[])=>[...u,...d])},[s,n]),l=f.useCallback((c,d)=>{localStorage.setItem(ns(c),JSON.stringify(d)),n((u=[])=>[...u])},[n]);return{reminders:r,addReminder:o,removeReminder:a,syncReminders:i,setReminder:l}}function co(){const e=ie(),{openModal:s,closeModal:n}=ws(),{reminders:r,setReminder:o}=$t();f.useEffect(()=>{const a=r.filter(c=>!c.dismissed);if(a.length===0)return;const i=()=>{const c=a.every(d=>d.chainId===a[0].chainId)?a[0].chainId:void 0;e("/op/withdrawals",{chainId:c}),l()},l=()=>{n();for(const c of a)o(c,{...c,dismissed:!0})};s({content:f.createElement(kl,{list:a,onNavigate:i,onDismiss:l})})},[r,n,e,s,o])}const lo=f.createContext(null);function uo(){return f.useContext(lo)}const $l="_root_7yxgy_1",Tl="_label_7yxgy_7",El="_input_7yxgy_19",ql="_hasValue_7yxgy_29",Dl="_clear_7yxgy_33",Bt={root:$l,label:Tl,input:El,hasValue:ql,clear:Dl},qs=e=>{const{rootClassName:s,padding:n=16,iconSize:r=16,onClear:o,ref:a,...i}=e;return t.jsxs("div",{className:R(Bt.root,s,{[Bt.hasValue]:i.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${r}px`},children:[t.jsx("label",{htmlFor:"search",className:Bt.label,children:t.jsx(A.IconSearch,{size:r})}),t.jsx("input",{className:Bt.input,id:"search",type:"text",maxLength:100,ref:a,...i}),i.value&&t.jsx("button",{type:"button",className:Bt.clear,"aria-label":"Clear search",onMouseDown:l=>l.preventDefault(),onClick:o,children:t.jsx(A.IconCloseCircleFilled,{size:r})})]})},Pl="_container_t1267_1",Rl="_controls_t1267_7",Bl="_search_t1267_13",$n={container:Pl,controls:Rl,search:Bl},Ml=({children:e})=>t.jsx("div",{className:$n.container,children:e}),Fl=({children:e})=>t.jsx("div",{className:$n.controls,children:e}),Ol=e=>t.jsx(qs,{...e,rootClassName:$n.search}),Ge={Root:Ml,Controls:Fl,SearchInput:Ol};function Gt(){const e=f.useRef(null),s=Ts();return f.useEffect(()=>{s||e.current?.focus()},[s]),e}const Ll="_trigger_386xl_1",Ul="_icon_386xl_21",zl="_full_386xl_25",Kl="_triggerContent_386xl_30",Hl="_triggerText_386xl_38",Wl="_popoverBackdrop_386xl_49",Ql="_popoverPositioner_386xl_84",Vl="_popoverPopup_386xl_88",Gl="_search_386xl_131",Yl="_viewport_386xl_136",Jl="_item_386xl_141",Zl="_highlighted_386xl_155",Xl="_itemContent_386xl_160",ae={trigger:Ll,icon:Ul,full:zl,triggerContent:Kl,triggerText:Hl,popoverBackdrop:Wl,popoverPositioner:Ql,popoverPopup:Vl,search:Gl,viewport:Yl,item:Jl,highlighted:Zl,itemContent:Xl},Tn=({value:e,onChange:s,chainIds:n,fullWidth:r})=>{const[o,a]=f.useState(""),[i,l]=f.useState(!1),[c,d]=f.useState(0),[u,h]=f.useState(),m=f.useRef([]),_=f.useRef(null),p=se(),g=n.map(x=>p.find(w=>w.chainId===x)).filter(Boolean),b=x=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:x,height:x,viewBox:"0 0 14 14",children:[t.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),t.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),k=f.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),S=f.useMemo(()=>{const x=[k,...g];if(!o)return x;const w=o.toLowerCase();return x.filter(y=>y.name.toLowerCase().includes(w)||y.chainId.toLowerCase().includes(w))},[g,o,k]),T=g.find(x=>x.chainId===e)||k,j=parseInt(Qr("--drawer-offset")),D=6,B=()=>{if(a(""),d(-1),_.current){const w=_.current.getBoundingClientRect().bottom+D,y=window.innerHeight-w-2*j;h(y)}l(!0)};f.useEffect(()=>{c>=0&&c<m.current.length&&m.current[c]?.scrollIntoView({block:"nearest",behavior:"auto"})},[c]);const P=f.useCallback(x=>{switch(x.key){case"ArrowDown":x.preventDefault(),d(w=>(w+1)%S.length);break;case"ArrowUp":x.preventDefault(),d(w=>(w-1+S.length)%S.length);break;case"Enter":x.preventDefault(),S[c]&&(s(S[c].chainId),l(!1));break;case"Escape":x.preventDefault(),l(!1);break}},[S,c,s,l]),I=x=>{s(x),l(!1)};return t.jsxs(jt.Popover.Root,{open:i,onOpenChange:B,modal:"trap-focus",children:[t.jsx(jt.Popover.Trigger,{render:t.jsxs("button",{className:R(ae.trigger,{[ae.full]:r}),"aria-expanded":i,role:"listbox",ref:_,children:[t.jsxs("div",{className:ae.triggerContent,children:[typeof T.logoUrl=="string"?t.jsx(z,{src:T.logoUrl,width:14,height:14,logo:!0}):T.logoUrl(14),t.jsx("span",{className:ae.triggerText,children:T.name})]}),t.jsx(A.IconChevronDown,{size:16,className:ae.icon})]})}),t.jsxs(jt.Popover.Portal,{container:dt(),children:[t.jsx(jt.Popover.Backdrop,{className:ae.popoverBackdrop,onClick:()=>l(!1)}),t.jsx(jt.Popover.Positioner,{className:ae.popoverPositioner,align:"end",side:"bottom",sideOffset:D,children:t.jsxs(jt.Popover.Popup,{className:R(ae.popoverPopup,{[ae.full]:r}),style:{maxHeight:u},children:[t.jsx(qs,{value:o,onChange:x=>{a(x.target.value),d(0)},onClear:()=>a(""),onKeyDown:P,placeholder:"Search appchains",rootClassName:ae.search,ref:Gt()}),t.jsx("div",{className:ae.viewport,role:"listbox",children:S.length===0?t.jsx(J,{children:"No appchains found"}):S.map(({chainId:x,name:w,logoUrl:y},q)=>t.jsxs("div",{className:R(ae.item,{[ae.highlighted]:q===c}),onClick:()=>I(x),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),I(x))},onMouseEnter:()=>d(q),role:"option","aria-selected":e===x,tabIndex:-1,ref:C=>{C&&(m.current[q]=C)},children:[t.jsxs("div",{className:ae.itemContent,children:[typeof y=="string"?t.jsx(z,{src:y,width:16,height:16,logo:!0}):y(16),t.jsx("span",{children:w})]}),e===x&&t.jsx(A.IconCheck,{size:16})]},x))})]})})]})]})},ed="2.0.4",td="_version_1sf5y_1",sd={version:td},nd=()=>t.jsxs("aside",{className:sd.version,children:["v",ed]}),rd=Q.atom(""),od=Q.atom(""),ad=Q.atom(""),id=Q.atom(""),cd=Q.atom(""),ld="_popup_nbecp_1",dd="_item_nbecp_19",rs={popup:ld,item:dd},ho=({asset:e,children:s})=>{const{denom:n,decimals:r,symbol:o,logoUrl:a,unlisted:i,address:l,chain:c}=e,{chainId:d}=c,[u,h]=f.useState(!1),m=ie(),_=uo(),{showNotification:p}=An(),{defaultChainId:g}=ce(),{evm_chain_id:b}=Qt(),k=xe.useChainId(),{switchChainAsync:S}=xe.useSwitchChain(),{watchAssetAsync:T}=xe.useWatchAsset(),j=()=>{h(!1),m("/send",{denom:n,chain:c})},D=()=>{h(!1),m("/bridge",{srcChainId:d,srcDenom:n,quantity:""})},B=E.useMutation({mutationFn:async()=>{if(!l)throw new Error("Address is required");const P=a;return await S({chainId:Number(b)}),T({type:"ERC20",options:{address:l,symbol:o,decimals:r,image:P}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:P=>{p({type:"error",title:"Asset addition failed",description:P.message})}});return t.jsxs(Ke.Menu.Root,{open:u,onOpenChange:h,modal:!1,children:[t.jsx(Ke.Menu.Trigger,{render:s}),t.jsx(Ke.Menu.Portal,{container:_.current,children:t.jsx(Ke.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(Ke.Menu.Popup,{className:rs.popup,children:[t.jsxs(Ke.Menu.Item,{className:rs.item,onClick:j,children:[t.jsx(A.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(Ke.Menu.Item,{className:rs.item,onClick:D,disabled:i,children:[t.jsx(A.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===g&&b===k&&!!l&&t.jsxs(Ke.Menu.Item,{className:rs.item,onClick:()=>B.mutate(),disabled:B.isPending||B.data,children:[B.data?t.jsx(A.IconCheck,{size:16}):t.jsx(A.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},ud="_images_cj4xz_1",Js={images:ud},Ds=({assetLogoUrl:e,assetLogoSize:s=36,chainLogoUrl:n,chainLogoSize:r=18,chainLogoOffset:o=6,className:a})=>t.jsxs("div",{className:R(Js.images,a),style:{position:"relative"},children:[t.jsx(z,{src:e,width:s,height:s,className:Js.asset,logo:!0}),t.jsx(z,{src:n,width:r,height:r,className:Js.chain,style:{position:"absolute",bottom:0,right:-1*o},logo:!0})]}),hd="_item_knoro_1",md="_info_knoro_22",_d="_images_knoro_28",fd="_name_knoro_32",pd="_value_knoro_38",gd="_amount_knoro_46",xd="_usd_knoro_52",rt={item:hd,info:md,images:_d,name:fd,value:pd,amount:gd,usd:xd},yd=({asset:e})=>{const{amount:s,value:n,logoUrl:r,chain:o}=e,a=N.formatAmount(s,{decimals:e.decimals});return t.jsx(ho,{asset:e,children:t.jsxs("button",{className:rt.item,children:[t.jsxs("div",{className:rt.info,children:[t.jsx(Ds,{assetLogoUrl:r,chainLogoUrl:o.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:rt.images}),t.jsx("span",{className:rt.name,children:o.name})]}),t.jsxs("div",{className:rt.value,children:[t.jsx("span",{className:rt.amount,children:a}),Number(n)>0&&t.jsx("span",{className:rt.usd,children:Me(n)})]})]})})},jd="_container_g5q73_1",vd="_assetItem_g5q73_6",bd="_assetInfo_g5q73_26",wd="_logo_g5q73_32",Cd="_symbol_g5q73_36",Id="_chainName_g5q73_46",Nd="_chainInfos_g5q73_52",Sd="_chainLogos_g5q73_58",kd="_chainLogo_g5q73_58",Ad="_moreChains_g5q73_69",$d="_expandIcon_g5q73_81",Td="_expanded_g5q73_85",Ed="_valueColumn_g5q73_90",qd="_amount_g5q73_99",Dd="_value_g5q73_90",Pd="_collapsibleContent_g5q73_112",Rd="_chainsList_g5q73_142",Y={container:jd,assetItem:vd,assetInfo:bd,logo:wd,symbol:Cd,chainName:Id,chainInfos:Nd,chainLogos:Sd,chainLogo:kd,moreChains:Ad,expandIcon:$d,expanded:Td,valueColumn:Ed,amount:qd,value:Dd,collapsibleContent:Pd,chainsList:Rd},Bd=Q.atom([]),mo=({assetGroup:e})=>{const{symbol:s,logoUrl:n,assets:r}=e,o=r.length===1,[a,i]=Q.useAtom(Bd),l=f.useMemo(()=>Na(e),[e]),c=f.useMemo(()=>In(e),[e]),d=a.includes(s),u=()=>{i(m=>d?v.without([s],m):v.uniq([...m,s]))},h=()=>t.jsxs("button",{className:Y.assetItem,children:[t.jsxs("div",{className:Y.assetInfo,children:[n&&t.jsx(z,{src:n,width:32,height:32,className:Y.logo,logo:!0}),t.jsxs("div",{className:Y.details,children:[t.jsx("div",{className:Y.symbol,children:s}),o?t.jsx("div",{className:Y.chainName,children:r[0].chain.name}):t.jsxs("div",{className:Y.chainInfos,children:[t.jsx("div",{className:Y.chainLogos,children:r.slice(0,5).map(({chain:m})=>t.jsx(z,{src:m.logoUrl,width:16,height:16,className:Y.chainLogo,logo:!0},m.chainId))}),r.length>5&&t.jsxs("span",{className:Y.moreChains,children:["+",r.length-5]}),t.jsx(A.IconChevronDown,{size:16,className:R(Y.expandIcon,{[Y.expanded]:d})})]})]})]}),t.jsxs("div",{className:Y.valueColumn,children:[t.jsx("div",{className:Y.amount,children:N.formatNumber(l,{dp:r[0].unlisted?0:6})}),c>0&&t.jsx("div",{className:Y.value,children:Me(c)})]})]});if(o){const[m]=r;return t.jsx("div",{className:Y.container,children:t.jsx(ho,{asset:m,children:h()})})}return t.jsx("div",{className:Y.container,children:t.jsxs(G.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(G.Collapsible.Trigger,{asChild:!0,children:h()}),t.jsx(G.Collapsible.Content,{className:Y.collapsibleContent,children:t.jsx("div",{className:Y.chainsList,children:r.map(m=>t.jsx(yd,{asset:m},m.chain.chainId))})})]})})},Md="_collapsible_1spkj_1",Fd="_trigger_1spkj_5",Od="_divider_1spkj_20",Ld="_label_1spkj_26",Ud="_chevron_1spkj_31",zd="_content_1spkj_39",Kd="_list_1spkj_43",We={collapsible:Md,trigger:Fd,divider:Od,label:Ld,chevron:Ud,content:zd,list:Kd},Hd=({unlistedAssets:e})=>{const[s,n]=f.useState(!0),r=uo(),o=f.useRef(null),[a,i]=f.useState(0);f.useEffect(()=>{if(o.current){const d=o.current.scrollHeight;i(d)}},[e]);const l=d=>{if(d&&!s&&r?.current){const u=r.current;u.scrollTo({top:u.scrollHeight,behavior:"auto"}),window.setTimeout(()=>{u.scrollTo({top:u.scrollHeight,behavior:"smooth"})},150)}n(d)},c=Je.useSpring({height:s?a:0,opacity:s?1:0,config:{tension:500,friction:30,clamp:!0}});return e.length===0?null:t.jsxs(G.Collapsible.Root,{open:s,onOpenChange:l,className:We.collapsible,children:[t.jsxs(G.Collapsible.Trigger,{className:We.trigger,children:[t.jsx("div",{className:We.divider}),t.jsxs("span",{className:We.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(A.IconChevronDown,{className:We.chevron,size:12,"data-state":s?"open":"closed"}),t.jsx("div",{className:We.divider})]}),t.jsx(G.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(Je.animated.div,{className:We.content,style:c,children:t.jsx("div",{className:We.list,ref:o,children:e.map(d=>t.jsx(mo,{assetGroup:{...d,assets:[d]}},d.denom))})})})]})},Wd="_list_szwvw_1",Qd={list:Wd},Vd=()=>{const[e,s]=Q.useAtom(rd),[n,r]=Q.useAtom(od),{assetGroups:o,unlistedAssets:a,chainsByValue:i,isLoading:l}=Nn(),c=i.filter(({value:h})=>h).map(({chainId:h})=>h),d=f.useMemo(()=>{const h=e?o.filter(_=>{const{symbol:p,assets:g}=_;return p.toLowerCase().includes(e.toLowerCase())||g.some(({denom:b,address:k})=>b.toLowerCase().includes(e.toLowerCase())||k?.toLowerCase().includes(e.toLowerCase()))}):o;return n?h.map(_=>({..._,assets:_.assets.filter(({chain:p})=>p.chainId===n)})).filter(_=>_.assets.length>0):h},[o,e,n]),u=f.useMemo(()=>{const h=e?a.filter(({denom:_,address:p})=>_.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):a;return n?h.filter(({chain:_})=>_.chainId===n):h},[a,e,n]);return l&&o.length===0?t.jsx(J,{children:"Loading assets..."}):!d.length&&!u.length&&!e&&!n&&!l?t.jsx(J,{children:"No assets"}):t.jsxs(t.Fragment,{children:[t.jsxs(Ge.Root,{children:[t.jsxs(Ge.Controls,{children:[t.jsx(Ge.SearchInput,{value:e,onChange:h=>s(h.target.value),onClear:()=>s(""),placeholder:"Search assets"}),t.jsx(Tn,{value:n,onChange:r,chainIds:c})]}),t.jsx("div",{children:d.length===0&&u.length===0?t.jsx(J,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Qd.list,children:d.map(h=>t.jsx(mo,{assetGroup:h},h.symbol))}),t.jsx(Hd,{unlistedAssets:u})]})})]}),t.jsx(nd,{})]})},_o=qe.createQueryKeys("interwovenkit:nft",{nfts:(e,s)=>[e,s],metadata:e=>[e]});function Gd(e,s){const{nft:n}=e,r=s.name??n.token_id;return{...e,...n,...s,name:r}}function Yd(e,s){return e.flatMap((n,r)=>(s[r]??[]).map(a=>({...a,chain:n})))}const Jd=()=>{const e=ne(),s=se(),n=E.useQueries({queries:s.map(i=>({queryKey:_o.nfts(i.indexerUrl,e).queryKey,queryFn:()=>Mr(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:i.indexerUrl},"tokens"),staleTime:U.SECOND}))}),r=n.map(v.prop("data")),o=Yd(s,r),a=n.some(i=>i.isLoading);return{nftInfos:o,isLoading:a}};function Zd(e){const s=Gn(e);return E.useQuery({queryKey:_o.metadata(s).queryKey,queryFn:async()=>{try{if(!s)return{};const n=await Z.get(s).json();return{...n,image:Gn(n.image)}}catch{return{}}},staleTime:U.INFINITY})}function Gn(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const Xd="_thumbnail_1lblb_1",eu="_placeholder_1lblb_16",tu="_clickable_1lblb_22",Mt={thumbnail:Xd,placeholder:eu,clickable:tu},En=({nftInfo:e,size:s,onClick:n})=>{const{collection_addr:r,object_addr:o,nft:a,chain:i}=e,l=new URL(`/v1/${i.chainId}/${r}/${o||a.token_id}`,"https://glyph.initia.xyz").toString();return n?t.jsx("button",{className:R(Mt.thumbnail,Mt.clickable),onClick:n,style:{width:s,height:s},children:t.jsx(z,{src:l,classNames:{placeholder:Mt.placeholder}})}):t.jsx("div",{className:Mt.thumbnail,style:{width:s,height:s},children:t.jsx(z,{src:l,classNames:{placeholder:Mt.placeholder}})})},su="_nftItem_eopro_1",nu="_collectionName_eopro_9",ru="_nftName_eopro_19",ou="_chainInfo_eopro_29",os={nftItem:su,collectionName:nu,nftName:ru,chainInfo:ou},au=({normalizedNft:e})=>{const{collection_name:s,name:n,chain:r}=e,o=ie();return t.jsxs("div",{className:os.nftItem,children:[t.jsx(En,{nftInfo:e,onClick:()=>o("/nft",e)}),t.jsxs("div",{children:[t.jsx("div",{className:os.collectionName,children:s}),t.jsx("div",{className:os.nftName,children:n}),t.jsxs("div",{className:os.chainInfo,children:[t.jsx(z,{src:r.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:r.name})]})]})]})},iu=({nftInfo:e,children:s})=>{const{data:n={}}=Zd(e.nft.uri),r=Gd(e,n);return s(r)},cu="_grid_a1fhu_1",lu={grid:cu},du=()=>{const[e,s]=Q.useAtom(ad),[n,r]=Q.useAtom(id),{nftInfos:o,isLoading:a}=Jd(),i=f.useMemo(()=>o.filter(({collection_addr:c,collection_name:d,nft:u,object_addr:h,chain:m})=>{if(n&&m.chainId!==n)return!1;if(e){const _=e.trim().toLowerCase();return c.toLowerCase().includes(_)||d.toLowerCase().includes(_)||u.token_id.toLowerCase().includes(_)||h.toLowerCase().includes(_)}return!0}),[o,n,e]),l=f.useMemo(()=>Array.from(new Set(o.map(({chain:c})=>c.chainId))),[o]);return a&&o.length===0?t.jsx(J,{children:"Loading NFTs..."}):!o.length&&!e&&!a?t.jsx(J,{children:"No NFTs"}):t.jsxs(Ge.Root,{children:[t.jsxs(Ge.Controls,{children:[t.jsx(Ge.SearchInput,{value:e,onChange:c=>s(c.target.value),onClear:()=>s(""),placeholder:"Search NFTs"}),t.jsx(Tn,{value:n,onChange:r,chainIds:l})]}),i.length===0?t.jsx(J,{children:"No NFTs found"}):t.jsx("div",{className:lu.grid,children:i.map(c=>{const{collection_addr:d,nft:u}=c;return t.jsx(iu,{nftInfo:c,children:h=>t.jsx(au,{normalizedNft:h})},d+u.token_id)})})]})};function fo(e,s){return e.reduce((n,r)=>{const o=s(r);if(!o)return n;const a=o.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=n[a]||[];return{...n,[a]:[...i,r]}},{})}const uu="_message_1g2hc_1",hu="_more_1g2hc_8",Yn={message:uu,more:hu},mu=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((s,n)=>t.jsx("p",{className:Yn.message,children:ys.sentenceCase(s["@type"].split("Msg")[1])},n)),e.length>3&&t.jsx("footer",{className:Yn.more,children:`+${e.length-3} more`})]}),_u="_change_1x9v4_1",fu="_positive_1x9v4_10",pu="_negative_1x9v4_14",Zs={change:_u,positive:fu,negative:pu},po=({amount:e,asset:s})=>{const{denom:n,symbol:r,decimals:o}=s,a=new M(e).isPositive(),i=new M(e).abs().toString();return t.jsxs("div",{className:R(Zs.change,a?Zs.positive:Zs.negative),children:[a?"+":"-",N.formatAmount(i,{decimals:o})," ",r||n]})},gu=({changes:e,chain:s})=>{const n=Xe(s);return e.map(({amount:r,denom:o},a)=>t.jsx(po,{amount:r,asset:n(o)},a))},xu=({changes:e,chain:s})=>{const n=Xe(s);return e.map(({amount:r,metadata:o},a)=>t.jsx(no,{metadata:o,chain:s,children:i=>t.jsx(po,{amount:r,asset:n(i)})},a))},yu=({events:e,chain:s})=>{const{initiaAddress:n,hexAddress:r}=je();return s.metadata?.is_l1||s.metadata?.minitia?.type==="minimove"?t.jsx(xu,{changes:so(e,r),chain:s}):t.jsx(gu,{changes:to(e,n),chain:s})},ju="_link_oq58b_1",vu="_inner_oq58b_15",bu="_header_oq58b_20",wu="_time_oq58b_29",Cu="_error_oq58b_35",Iu="_timestamp_oq58b_39",Nu="_chainInfo_oq58b_44",Su="_content_oq58b_52",ku="_messages_oq58b_59",Au="_changes_oq58b_64",Se={link:ju,inner:vu,header:bu,time:wu,error:Cu,timestamp:Iu,chainInfo:Nu,content:Su,messages:ku,changes:Au},$u=({txItem:e,chain:s})=>t.jsx(Es,{txHash:e.txhash,chainId:s.chainId,className:Se.link,children:t.jsxs("div",{className:Se.inner,children:[t.jsxs("div",{className:Se.header,children:[t.jsxs("div",{className:Se.time,children:[e.code!==0&&t.jsx(A.IconWarningFilled,{size:14,className:Se.error}),t.jsx("span",{className:Se.timestamp,children:Nt.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:Se.chainInfo,children:[t.jsx(z,{src:s.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:s.name})]})]}),t.jsxs("div",{className:Se.content,children:[t.jsx("div",{className:Se.messages,children:t.jsx(mu,{messages:e.tx.body.messages})}),t.jsx("div",{className:Se.changes,children:t.jsx(ue,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(yu,{...e,chain:s})})})]})]})}),Tu="_list_1wa9p_1",Eu="_dateGroup_1wa9p_7",qu="_dateHeader_1wa9p_12",Du="_more_1wa9p_18",as={list:Tu,dateGroup:Eu,dateHeader:qu,more:Du},Pu=({list:e,chainId:s})=>{const n=ne(),r=f.useMemo(()=>fo(e,o=>{if(o.timestamp)return new Date(o.timestamp)}),[e]);return e.length===0?t.jsx(J,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:as.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{className:as.dateGroup,children:[t.jsx("div",{className:as.dateHeader,children:o}),a.map(i=>t.jsx(ue,{errorBoundaryProps:{fallback:null},children:t.jsx($u,{txItem:i,chain:i.chain})},i.txhash))]},o))}),t.jsx(Es,{chainId:s,accountAddress:n,pathSuffix:"/txs",className:as.more,showIcon:!0,children:"View more on Initia Scan"})]})},Ru=()=>{const{activities:e,isLoading:s}=ai(),[n,r]=Q.useAtom(cd),o=ye(),a=f.useMemo(()=>Array.from(new Set(e.map(l=>l.chain.chainId))),[e]),i=f.useMemo(()=>n?e.filter(l=>l.chain.chainId===n):e,[e,n]);return s&&e.length===0?t.jsx(J,{children:"Loading activities..."}):!e.length&&!s?t.jsx(J,{children:"No activity yet"}):t.jsxs(Ge.Root,{children:[t.jsx(Ge.Controls,{children:t.jsx(Tn,{value:n,onChange:r,chainIds:a,fullWidth:!0})}),t.jsx(Pu,{list:i,chainId:n||o.chainId})]})},Bu="_totalValue_1udv1_1",Mu="_totalLabel_1udv1_7",Fu="_totalAmount_1udv1_13",Ou="_loading_1udv1_18",Lu="_nav_1udv1_23",Uu="_item_1udv1_28",zu="_tabs_1udv1_51",Ku="_tab_1udv1_51",be={totalValue:Bu,totalLabel:Mu,totalAmount:Fu,loading:Ou,nav:Lu,item:Uu,tabs:zu,tab:Ku},Hu=()=>{co();const e=ie(),s=bs(),{totalValue:n,isLoading:r}=Nn(),o=f.useRef(null);return t.jsx(lo.Provider,{value:o,children:t.jsxs(Le,{ref:o,children:[t.jsxs("div",{className:be.totalValue,children:[t.jsx("div",{className:be.totalLabel,children:"Total value"}),t.jsx("div",{className:R(be.totalAmount,{[be.loading]:r}),children:Me(n)})]}),t.jsxs("div",{className:be.nav,children:[t.jsxs(jn,{to:"/send",className:be.item,children:[t.jsx(A.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs("button",{className:be.item,onClick:()=>e("/bridge"),children:[t.jsx(A.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]})]}),t.jsxs(ze.Tabs.Root,{value:s,onValueChange:e,children:[t.jsxs(ze.Tabs.List,{className:be.tabs,children:[t.jsx(ze.Tabs.Tab,{className:be.tab,value:"/",children:"Assets"}),t.jsx(ze.Tabs.Tab,{className:be.tab,value:"/nfts",children:"NFTs"}),t.jsx(ze.Tabs.Tab,{className:be.tab,value:"/activity",children:"Activity"})]}),t.jsx(ze.Tabs.Panel,{value:"/",children:t.jsx(Vd,{})}),t.jsx(ze.Tabs.Panel,{value:"/nfts",children:t.jsx(du,{})}),t.jsx(ze.Tabs.Panel,{value:"/activity",children:t.jsx(Ru,{})})]})]})})},Wu="_header_acels_1",Qu="_back_acels_11",Vu="_title_acels_23",Xs={header:Wu,back:Qu,title:Vu},ft=({title:e,backButton:s,extra:n,children:r})=>t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Xs.header,children:[t.jsx(jn,{to:s??-1,className:Xs.back,shouldReset:!!s,children:t.jsx(A.IconBack,{size:16})}),t.jsx("h1",{className:Xs.title,children:e}),n]}),t.jsx(Le,{children:r})]}),Gu="_fieldset_y241y_1",Yu="_upper_y241y_9",Ju="_select_y241y_14",Zu="_account_y241y_19",Xu="_lower_y241y_24",eh="_wrapper_y241y_25",th="_balance_y241y_32",sh="_value_y241y_36",nh="_error_y241y_49",Pe={fieldset:Gu,upper:Yu,select:Ju,account:Zu,lower:Xu,wrapper:eh,balance:th,value:sh,error:nh},hn=e=>{const{selectButton:s,accountButton:n,quantityInput:r,balanceButton:o,value:a,errorMessage:i,hideNumbers:l}=e;return t.jsxs("div",{className:Pe.fieldset,children:[t.jsxs("div",{className:Pe.upper,children:[t.jsx("div",{className:Pe.select,children:s}),t.jsx("div",{className:Pe.account,children:n})]}),!l&&t.jsxs("div",{className:Pe.lower,children:[r,t.jsxs("div",{className:Pe.wrapper,children:[t.jsx("div",{className:Pe.balance,children:o}),a&&t.jsx("div",{className:Pe.value,children:a})]}),i&&t.jsxs("footer",{className:Pe.error,children:[t.jsx(A.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})},rh="_root_1ipwv_1",oh="_content_1ipwv_10",ah="_details_1ipwv_18",ih="_symbol_1ipwv_23",ch="_chain_1ipwv_31",lh="_chevron_1ipwv_40",ot={root:rh,content:oh,details:ah,symbol:ih,chain:ch,chevron:lh},go=({asset:e,chain:s,readOnly:n})=>{const r=t.jsxs("div",{className:ot.content,children:[t.jsx(Ds,{assetLogoUrl:e.logoUrl,chainLogoUrl:s.logoUrl}),t.jsxs("div",{className:ot.details,children:[t.jsx("div",{className:ot.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:ot.chain,children:["on ",s.name]})]})]});return n?t.jsx("div",{className:ot.root,children:r}):t.jsxs("div",{className:ot.root,children:[r,t.jsx(A.IconChevronDown,{size:16,className:ot.chevron})]})},dh="_wrapper_5ssm8_1",uh="_balance_5ssm8_11",hh="_button_5ssm8_15",en={wrapper:dh,balance:uh,button:hh},xo=({onClick:e,children:s,disabled:n})=>t.jsxs("div",{className:en.wrapper,children:[t.jsx(A.IconWallet,{size:16}),t.jsx("span",{className:en.balance,children:s}),t.jsx("button",{type:"button",tabIndex:-1,className:en.button,onClick:()=>e(),disabled:n,children:"MAX"})]}),mh="_input_h8073_1",_h={input:mh};function Jn(e,s){const n=e.replace(/[^0-9.]/g,""),[r,...o]=n.split(".");return o.length===0?r:`${r}.${o.join("").slice(0,s)}`}function yo(e){const{name:s,control:n,dp:r=6,className:o,rules:a,...i}=e,l=Gt();return t.jsx(re.Controller,{name:s,control:n,rules:a,render:({field:c})=>t.jsx("input",{...c,className:R(_h.input,o),onChange:d=>c.onChange(Jn(d.target.value,r)),onPaste:d=>{d.preventDefault();const u=d.clipboardData.getData("text");if(!/^[0-9,]+(\.[0-9]+)?$/.test(u))return;const m=u.replace(/,/g,""),_=Jn(m,r);c.onChange(_)},placeholder:"0",inputMode:"decimal",autoComplete:"off",...i,ref:gr.mergeRefs([c.ref,l])})})}const fh="_input_qpv94_1",ph="_placeholder_qpv94_18",mn={input:fh,placeholder:ph},gh=({children:e})=>t.jsx("p",{className:R(mn.input,{[mn.placeholder]:M(e).isZero()}),children:e}),ps=({balance:e,decimals:s})=>{const{control:n}=re.useFormContext(),r={required:"Enter amount",validate:o=>M(o).isZero()?"Enter amount":M(N.toBaseUnit(o,{decimals:s})).gt(e??0)?"Insufficient balance":!0};return t.jsx(yo,{name:"quantity",control:n,className:mn.input,rules:r})};ps.ReadOnly=gh;const xh="_label_9417z_1",yh="_wrapper_9417z_7",jh="_input_9417z_10",vh="_clear_9417z_18",is={label:xh,wrapper:yh,input:jh,clear:vh},qn=({mode:e="onChange",myAddress:s,...n})=>{const{validate:r=N.InitiaAddress.validate,chainType:o="initia",onApply:a,ref:i}=n,l=Gt(),{control:c,getValues:d,setValue:u,formState:h}=re.useFormContext(),m=d("recipient"),[_,p]=f.useState(m),g=Ur(),{data:b,isLoading:k,error:S}=E.useQuery({queryKey:As.address(g.restUrl,_).queryKey,queryFn:()=>g.getAddress(_),staleTime:U.MINUTE,enabled:g.validateUsername(_)}),T=b??(r(_)?_:""),j=s&&N.InitiaAddress.equals(T,s),D=async()=>{try{const I=await navigator.clipboard.readText();p(I.trim())}catch{}};f.useEffect(()=>{e==="onChange"&&(!_&&!h.dirtyFields.recipient||u("recipient",b??_,{shouldValidate:!0,shouldDirty:!0}))},[h.dirtyFields.recipient,_,e,u,b]);const B=()=>{k||S||(u("recipient",T,{shouldValidate:!0,shouldDirty:!0}),a?.())},P=()=>{if(k)return t.jsx(Qe,{level:"loading",children:"Resolving username..."});if(S)return t.jsx(Qe,{level:"error",children:S.message});if(b)return t.jsx(Qe,{level:"success",className:"monospace",children:b});if(e==="onSubmit"&&_&&!T)return t.jsx(Qe,{level:"error",children:"Invalid address"});if(e==="onChange")return t.jsx(Qe,{level:"error",children:h.errors.recipient?.message})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:is.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(W.Small,{type:"button",tabIndex:-1,onClick:D,children:"Paste"})]}),t.jsxs("div",{className:is.wrapper,children:[t.jsx(re.Controller,{name:"recipient",control:c,rules:{required:"Recipient address is required",validate:I=>r(I)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:R(is.input,"monospace"),value:_,onChange:I=>p(I.target.value.trim()),placeholder:o==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":_?"true":void 0,ref:e==="onSubmit"?gr.mergeRefs([i,l]):i})}),!!_&&t.jsx("button",{type:"button",className:is.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:t.jsx(A.IconCloseCircleFilled,{size:16})})]}),P(),j&&t.jsx(Qe,{children:"This is my address"}),e==="onSubmit"&&t.jsx(te,{extra:(!s||!!T&&!j)&&t.jsx(ee,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:t.jsx(W.White,{type:"button",onClick:B,disabled:k||!!S||!T,children:"Apply"})})]})};function bh({balances:e,gasPrices:s,gas:n}){return s.map(({denom:r,amount:o})=>{const a=M(o).times(n).toFixed(0,M.ROUND_CEIL),i=e.find(l=>l.denom===r)?.amount??"0";return{amount:a,denom:r,balance:i}}).filter(({amount:r,balance:o})=>M(o).gte(r))}function wh({denom:e,balances:s,gasPrices:n,lastFeeDenom:r,gas:o}){const a=s.find(d=>d.denom===e)?.amount??"0",i=bh({balances:s,gasPrices:n,gas:o}),l=i.find(d=>d.denom===r);if(i.length===0)return a;if(e===r&&l){const d=M(a).minus(l.amount);return M.max(d,0).toString()}const c=i.find(d=>d.denom!==e)||i[0];if(!l&&e===c.denom){const d=M(a).minus(c.amount);return M.max(d,0).toString()}return M(a).toString()}const Ch="_container_1a4ds_1",Ih="_badge_1a4ds_5",Zn={container:Ch,badge:Ih},jo=e=>{const{offset:s=-4,disabled:n,children:r,className:o}=e;return t.jsxs("div",{className:R(Zn.container,o),children:[r,!n&&t.jsx("div",{className:Zn.badge,style:{right:s,top:s}})]})},Nh="_tooltip_6zakp_1",Sh="_arrow_6zakp_43",Xn={tooltip:Nh,arrow:Sh},Yt=({label:e,children:s,small:n,...r})=>t.jsxs(G.Tooltip.Root,{...r,children:[t.jsx(G.Tooltip.Trigger,{asChild:!0,children:s}),t.jsx(G.Tooltip.Portal,{container:dt(),children:t.jsxs(G.Tooltip.Content,{className:R(Xn.tooltip,{small:n}),collisionBoundary:dt(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(G.Tooltip.Arrow,{className:Xn.arrow})]})})]}),kh="_stack_a3b9q_1",Ah="_title_a3b9q_8",$h="_grid_a3b9q_15",Th="_item_a3b9q_21",Eh="_button_a3b9q_25",qh="_active_a3b9q_43",wt={stack:kh,title:Ah,grid:$h,item:Th,button:Eh,active:qh},lt=({label:e,chains:s,value:n,onSelect:r,getShowIndicator:o})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:wt.title,children:e}),t.jsx("div",{className:wt.grid,children:s.map(({chainId:a,name:i,logoUrl:l})=>t.jsx(jo,{offset:-2,disabled:!o?.(a),className:wt.item,children:t.jsx(Yt,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:R(wt.button,{[wt.active]:a===n}),onClick:()=>r(a),children:t.jsx(z,{src:l,width:28,height:28,logo:!0})})})},a))})]}),Dh=({children:e})=>t.jsx("div",{className:wt.stack,children:e});lt.Stack=Dh;function Ph(e,s,n){return n.filter(r=>{const o=e.map(a=>r[a]).map(a=>String(a??"").toLowerCase());return v.any(v.includes(s.toLowerCase()),o)})}const Rh="_container_1voou_1",Bh="_search_1voou_6",Mh="_list_1voou_10",Fh="_item_1voou_14",Oh="_logo_1voou_35",Lh="_info_1voou_39",Uh="_symbol_1voou_44",zh="_name_1voou_52",Kh="_balance_1voou_58",Hh="_value_1voou_65",ge={container:Rh,search:Bh,list:Mh,item:Fh,logo:Oh,info:Lh,symbol:Uh,name:zh,balance:Kh,value:Hh},Jt=e=>{const{assets:s,onSelect:n,renderAsset:r=(l,c)=>c(l)}=e,[o,a]=f.useState(""),i=Ph(["symbol"],o,s);return t.jsxs("div",{className:ge.container,children:[t.jsx(qs,{value:o,onChange:l=>a(l.target.value),onClear:()=>a(""),placeholder:"Search by symbol",rootClassName:ge.search,padding:20,ref:Gt()}),i.length===0?t.jsx(J,{children:"No assets"}):t.jsx("div",{className:ge.list,children:i.map(l=>t.jsx("button",{type:"button",className:ge.item,onClick:()=>n(l.denom),children:r(l,c=>{const{denom:d,logoUrl:u,symbol:h,name:m,balance:_,decimals:p,value:g=0}=c;return t.jsxs(t.Fragment,{children:[t.jsx(z,{src:u,width:32,height:32,className:ge.logo,logo:!0}),t.jsxs("div",{className:ge.info,children:[t.jsx("div",{className:ge.symbol,children:h||d}),t.jsx("div",{className:ge.name,children:m})]}),t.jsxs("div",{className:ge.balance,children:[_&&t.jsx("div",{children:N.formatAmount(_,{decimals:p})}),g>0&&t.jsx("div",{className:ge.value,children:Me(g)})]})]})})},l.denom))})]})},Wh=()=>t.jsxs("div",{className:ge.container,children:[t.jsx(qs,{rootClassName:ge.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(J,{children:"Loading..."})]});Jt.Placeholder=Wh;const Qh=({chain:e,onSelect:s})=>{const n=wa(e);return t.jsx(Jt,{assets:n,onSelect:s})},Vh=({afterSelect:e})=>{const{watch:s,setValue:n}=re.useFormContext(),{chainId:r,denom:o}=s(),{chainId:a}=s(),[i,l]=f.useState(a),c=Fe(i),d=se(),u=h=>{if(r===i&&o===h){e();return}n("chainId",i),n("denom",h),n("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(lt.Stack,{children:t.jsx(lt,{chains:d,value:i,onSelect:l})}),t.jsx(ue,{suspenseFallback:t.jsx(Jt.Placeholder,{}),children:t.jsx(Qh,{chain:c,onSelect:u})},i)]})},Gh="_fields_brpej_1",Yh="_divider_brpej_11",er={fields:Gh,divider:Yh},Jh=qe.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Zh=()=>{const{address:e,initiaAddress:s,estimateGas:n,requestTxSync:r}=je(),{register:o,watch:a,setValue:i,handleSubmit:l,formState:c}=re.useFormContext(),{chainId:d,denom:u,recipient:h,quantity:m,memo:_}=a(),p=Fe(d),g=Cn(p),b=Zr(p),k=Xr(p),S=Or(u,p),{data:T}=Cs(p),{decimals:j}=S,D=g.find(C=>C.denom===u)?.amount??"0",B=T?.find(({id:C})=>C===u)?.price,{data:P=0,isLoading:I}=E.useQuery({queryKey:Jh.gas({chainId:d,denom:u,recipient:h,initiaAddress:s}).queryKey,queryFn:()=>{const C=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:On.MsgSend.fromPartial({fromAddress:s,toAddress:N.InitiaAddress(h).bech32,amount:[{denom:u,amount:"1"}]})}];return n({messages:C,chainId:d})},enabled:N.InitiaAddress.validate(h),staleTime:U.INFINITY}),x=Math.ceil(P*Kt),w=wh({denom:u,balances:g,gasPrices:b,lastFeeDenom:k,gas:x}),{mutate:y,isPending:q}=E.useMutation({mutationFn:({chainId:C,denom:F,quantity:$,recipient:V,memo:K})=>{const le=N.toBaseUnit($,{decimals:j}),he=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:On.MsgSend.fromPartial({fromAddress:s,toAddress:N.InitiaAddress(V).bech32,amount:[{denom:F,amount:le}]})}];return r({messages:he,memo:K,chainId:C,gas:P,gasAdjustment:Kt,gasPrices:b,spendCoins:[{denom:F,amount:le}],internal:"/"})}});return t.jsx(ft,{title:"Send",children:t.jsxs("form",{onSubmit:l(C=>y(C)),children:[t.jsxs("div",{className:er.fields,children:[t.jsx(hn,{selectButton:t.jsx(ut,{title:"Select chain and asset",content:C=>t.jsx(Vh,{afterSelect:C}),children:t.jsx(go,{asset:S,chain:p})}),quantityInput:t.jsx(ps,{balance:D,decimals:j}),balanceButton:t.jsx(xo,{onClick:()=>i("quantity",N.fromBaseUnit(w,{decimals:j}),{shouldValidate:!0}),disabled:b.some(({denom:C})=>C===u)&&I,children:N.formatAmount(D??"0",{decimals:j})}),value:m?B?Me(M(m).times(B)):"$-":"$0",errorMessage:c.errors.quantity?.message}),t.jsx("div",{className:er.divider}),t.jsx(qn,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...o("memo",{validate:C=>!C||new Blob([C]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"}),t.jsx(Qe,{level:"error",children:c.errors.memo?.message})]}),t.jsx(ee.Stack,{children:!_&&t.jsx(ee,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(te,{children:t.jsx(W.White,{type:"submit",loading:I||q,disabled:!c.isValid,children:"Confirm"})})]})})},Xh=()=>{const e=ht(),s=Qt(),n=Ht(s),[r]=n,{chain:o=s,denom:a=r.denom}=e,i=re.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:a,quantity:"",recipient:"",memo:""}});return t.jsx(re.FormProvider,{...i,children:t.jsx(Zh,{})})},em="_header_4z0mk_1",tm="_collectionName_4z0mk_6",sm="_name_4z0mk_12",nm="_chainInfo_4z0mk_18",rm="_attributes_4z0mk_28",om="_title_4z0mk_31",am="_count_4z0mk_36",im="_item_4z0mk_40",cm="_type_4z0mk_46",lm="_value_4z0mk_52",ke={header:em,collectionName:tm,name:sm,chainInfo:nm,attributes:rm,title:om,count:am,item:im,type:cm,value:lm},dm=()=>{const e=ie(),s=ht(),{collection_name:n,image:r,name:o,attributes:a,chain:i}=s;return t.jsxs(ft,{title:"NFT details",children:[t.jsxs("header",{className:ke.header,children:[r&&t.jsx(En,{nftInfo:s}),t.jsxs("div",{children:[t.jsx("div",{className:ke.collectionName,children:n}),t.jsx("h2",{className:ke.name,children:o}),t.jsxs("div",{className:ke.chainInfo,children:[t.jsx(z,{src:i.logoUrl,width:14,height:14,logo:!0}),t.jsx("span",{children:i.name})]})]})]}),t.jsx(te,{children:t.jsx(W.White,{onClick:()=>e("/nft/send",s),sm:!0,children:"Send"})}),a&&t.jsxs("div",{className:ke.attributes,children:[t.jsxs("header",{className:ke.title,children:["Traits ",t.jsxs("span",{className:ke.count,children:["(",a.length,")"]})]}),t.jsx("div",{children:a.map(({trait_type:l,value:c})=>t.jsxs("div",{className:ke.item,children:[t.jsx("div",{className:ke.type,children:l}),t.jsx("div",{className:ke.value,children:c})]},l))})]})]})},um="_scrollable_1p1lw_1",hm="_list_1p1lw_5",mm="_item_1p1lw_9",_m="_name_1p1lw_13",cs={scrollable:um,list:hm,item:mm,name:_m};function vo({onSelect:e,list:s,...n}){const{getImage:r,getName:o,getKey:a,getIsLoading:i,getDisabled:l}=n;return t.jsx(Le,{className:cs.scrollable,children:t.jsx("div",{className:cs.list,children:s.map(c=>t.jsxs("button",{className:cs.item,onClick:()=>e(c),disabled:i?.(c)||l?.(c),children:[t.jsx(z,{src:r(c),width:28,height:28}),t.jsx("span",{className:cs.name,children:o(c)}),i?.(c)&&t.jsx(_t,{size:16})]},a(c)))})})}const fm="_header_5w36t_1",pm="_name_5w36t_8",gm="_collection_5w36t_15",xm="_nft_5w36t_20",ym="_fields_5w36t_24",jm="_chain_5w36t_29",vt={header:fm,name:pm,collection:gm,nft:xm,fields:ym,chain:jm},vm=qe.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),bm=()=>{const e=se(),s=ht(),{chain:n,collection_addr:r,collection_name:o,image:a,name:i}=s,{routerApiUrl:l}=ce(),c=Ns(),d=ye(),{address:u,initiaAddress:h,requestTxSync:m}=je(),{watch:_,setValue:p,handleSubmit:g,formState:b}=re.useFormContext(),k=_(),{recipient:S,dstChainId:T}=k,j=Fe(T),D=E.useQuery({queryKey:vm.simulation({collection_addr:r,nft:s,sender:h,recipient:S,srcChain:n,dstChain:j,layer1:d,routerApiUrl:l}).queryKey,queryFn:async()=>{const y={from_address:h,from_chain_id:n.chainId,to_address:N.InitiaAddress(S).bech32,to_chain_id:j.chainId,collection_address:r,token_ids:[s.token_id],object_addresses:[s.object_addr]},{msgs:q}=await Z.create({prefixUrl:l}).post("nft",{json:y}).json();return q.map(C=>c.fromAmino(C))},enabled:N.InitiaAddress.validate(S)}),{data:B,isLoading:P,error:I}=D,{mutate:x,isPending:w}=E.useMutation({mutationFn:async()=>{if(!B)throw new Error("Route not found");await m({messages:B,chainId:n.chainId,internal:"/nfts"})}});return t.jsxs("form",{onSubmit:g(()=>x()),children:[t.jsxs("header",{className:vt.header,children:[a&&t.jsx(En,{nftInfo:s,size:80}),t.jsxs("div",{className:vt.name,children:[t.jsx("div",{className:vt.collection,children:o}),t.jsx("div",{className:vt.nft,children:i})]})]}),t.jsxs("div",{className:vt.fields,children:[t.jsx(G.VisuallyHidden.Root,{children:t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(ut,{title:"Destination appchain",content:y=>t.jsx(vo,{onSelect:({chainId:q})=>{p("dstChainId",q),y()},list:e,getImage:q=>q.logoUrl,getName:q=>q.name,getKey:q=>q.chainId}),className:R("input",vt.chain),children:[t.jsx(z,{src:j.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:j.name})]})]})}),t.jsx(qn,{myAddress:u,ref:Gt()})]}),t.jsx(te,{children:t.jsx(W.White,{loading:P||w,disabled:!b.isValid||!!I,children:I?"Route not found":"Confirm"})})]})},wm=()=>{const{chain:e}=ht(),s=re.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(ft,{title:"Send NFT",children:t.jsx(re.FormProvider,{...s,children:t.jsx(bm,{})})})};function Cm(){return ye().network_type==="testnet"}function et(){return re.useFormContext()}function Im(){const e=ht(),s=Cm(),n={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},r={...n,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},o={...n,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},a=v.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(O.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(O.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(O.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(O.BRIDGE_DST_DENOM),quantity:localStorage.getItem(O.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(O.BRIDGE_SLIPPAGE_PERCENT)});return{...s?r:o,...a,...e}}function bo(){const{initiaAddress:e,hexAddress:s}=je(),n=mt(),r=Vt();return o=>{const a=n(o);switch(r(a)){case"initia":return e;case"evm":return s;default:return""}}}function wo(){const e=mt(),s=Vt();return(n,r)=>{const o=e(r);switch(s(o)){case"initia":return N.InitiaAddress.validate(n);case"evm":return Ye.isAddress(n);case"cosmos":try{return H.fromBech32(n).prefix===o.bech32_prefix}catch{return!1}default:return!1}}}function Nm(){const e=mt(),s=Vt();return({initialAddress:n,initialChainId:r,chainId:o,fallbackAddress:a})=>{const i=e(r),l=s(i),c=e(o),d=s(c);if(l==="evm"&&d==="initia")return N.InitiaAddress(n).bech32;if(l==="initia"&&d==="evm")return N.InitiaAddress(n).hex;if(l===d)return n;if(a){if(d==="initia")return N.InitiaAddress(a).bech32;if(d==="evm")return N.InitiaAddress(a).hex}return""}}const Sm=[["d",1440*60],["h",3600],["m",60],["s",1]];function _n(e){if(!e)return;const{formattedParts:s}=Sm.reduce(({remainingSeconds:n,formattedParts:r},[o,a])=>{const i=Math.floor(n/a);return{remainingSeconds:n-i*a,formattedParts:i>0?[...r,`${i}${o}`]:r}},{remainingSeconds:e,formattedParts:[]});return s.join(" ")}function Co(e){return e?.map(s=>{const{amount:n,origin_asset:r}=s;return`${N.formatAmount(n,{decimals:r.decimals??0})} ${r.symbol}`}).join(", ")}function tr(e,s){const{watch:n}=et(),r=n(),o=Oe(),a=Ss(),i={...r,quantity:e},l=E.useQueryClient();return E.useQuery({queryKey:Te.route(i,s?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:c,srcDenom:d,quantity:u,dstChainId:h,dstDenom:m}=i,{decimals:_}=l.getQueryData(Te.asset(c,d).queryKey)??{decimals:0},p={amount_in:N.toBaseUnit(u,{decimals:_}),source_asset_chain_id:c,source_asset_denom:d,dest_asset_chain_id:h,dest_asset_denom:m,is_op_withdraw:s?.isOpWithdraw},g=await o.post("v2/fungible/route",{json:p}).json(),b={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return a("Bridge Simulation Success",b),g},enabled:!!Number(i.quantity)&&!s?.disabled,staleTime:U.MINUTE})}function km(e){return E.useQuery({queryKey:Te.routeErrorInfo(e||new Error).queryKey,queryFn:async()=>{if(!e||!(e instanceof Z.HTTPError))return null;const{response:s}=e;return(s.headers.get("content-type")??"").includes("application/json")?(await s.json()).info??null:null}})}function Am(){const{watch:e}=et(),{srcChainId:s,srcDenom:n,dstChainId:r,dstDenom:o}=e(),a=Ee(s),i=Wt(a),l=Be(n,s),c=Be(o,r),d=ye(),u=se();return i==="initia"&&r===d.chainId&&l.symbol===c.symbol&&u.find(h=>h.chainId===s)?.metadata?.op_denoms?.includes(c.denom)}function Dn(e,s){const n=Oe();return E.useQuery({queryKey:Te.balances(s,e).queryKey,queryFn:()=>n.post("v2/info/balances",{json:{chains:{[s]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>e?r?r[s].denoms??{}:{}:{},enabled:!!e,staleTime:U.SECOND})}function $m(e,s,n){const{data:r={}}=Dn(e,s);return v.path([n],r)}const Tm=({address:e,chain:s,onSelect:n})=>{const r=It(s.chain_id),{data:o={}}=Dn(e,s.chain_id);return t.jsx(Jt,{assets:v.sortWith([v.descend(a=>a.symbol==="INIT"),v.descend(a=>a.value),({balance:a="0"},{balance:i="0"})=>M(i).comparedTo(a)??0,v.ascend(a=>a.symbol.toLowerCase())],r.filter(a=>!a.hidden).map(a=>{const{denom:i,symbol:l=N.truncate(i),logo_uri:c}=a,d=o[i]??{};return{...a,symbol:l,decimals:a.decimals??0,logoUrl:c??"",name:a.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:n})},Em=({type:e,afterSelect:s})=>{const n=e==="src"?"srcChainId":"dstChainId",r=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"sender":"recipient",a=At(),i=Sn(),{watch:l,setValue:c}=et(),d=l(o),u=l(n),h=l(r),[m,_]=f.useState(u),p=Ee(m),g=Nm(),b=Hr(),[k,S]=v.partition(j=>b(j.chain_id),i.filter(j=>!j.hidden)),T=j=>{if(u===m&&h===j){s();return}c(n,m),c(r,j),s()};return t.jsxs(t.Fragment,{children:[t.jsxs(lt.Stack,{children:[t.jsx(lt,{label:"Interwoven Economy",chains:k.map(({chain_id:j,chain_name:D,pretty_name:B,logo_uri:P})=>({chainId:j,name:B||D,logoUrl:P??""})),value:m,onSelect:_}),t.jsx(lt,{label:"Chains",chains:S.map(({chain_id:j,chain_name:D,pretty_name:B,logo_uri:P})=>({chainId:j,name:B||D,logoUrl:P??""})),value:m,onSelect:_})]}),t.jsx(ue,{suspenseFallback:t.jsx(Jt.Placeholder,{}),children:t.jsx(Tm,{address:g({initialAddress:d,initialChainId:u,chainId:m,fallbackAddress:e==="src"?a:void 0}),chain:p,onSelect:T})},m)]})},sr=({type:e})=>{const s=e==="src"?"srcChainId":"dstChainId",n=e==="src"?"srcDenom":"dstDenom",r=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:o}=et(),a=o(s),i=o(n),l=Ee(a),c=Be(i,a);return t.jsx(ut,{title:r,content:d=>t.jsx(Em,{type:e,afterSelect:d}),children:t.jsx(go,{asset:{denom:c.denom,decimals:c.decimals??0,symbol:c.symbol,logoUrl:c.logo_uri??""},chain:{chainId:l.chain_id,name:l.pretty_name||l.chain_name,logoUrl:l.logo_uri??""}})})};function Ps(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:n=>e.find(r=>r.name===n)}}const qm="_account_iwrlj_8",Dm="_clear_iwrlj_27",Pm="_white_iwrlj_38",Ft={account:qm,clear:Dm,white:Pm},nr=({type:e})=>{const{watch:s,setValue:n}=et(),{srcChainId:r,dstChainId:o,cosmosWalletName:a}=s(),l=s(e==="src"?"sender":"recipient"),c=Wt(Ee(o)),{list:d,find:u}=Ps(),h=u(a),m=bo(),_=wo(),p=m(o),g=N.InitiaAddress.equals(l,p),b=()=>t.jsx(ut,{title:"Connect wallet",content:T=>t.jsx(vo,{onSelect:async j=>{const D=j.getProvider();if(!D)return window.open(j.fallbackUrl,"_blank");const B=D.getOfflineSigner(r),[{address:P}]=await B.getAccounts();n("sender",P),n("cosmosWalletName",j.name),T()},list:d,getImage:j=>j.image,getName:j=>j.name,getKey:j=>j.name}),className:R(Ft.account,{[Ft.white]:!l}),children:l?t.jsxs(t.Fragment,{children:[h&&t.jsx(z,{src:h.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:N.truncate(l)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(A.IconChevronRight,{size:14})]})}),k=T=>t.jsx(ut,{title:"Recipient",content:j=>t.jsx(Le,{children:t.jsx(qn,{mode:"onSubmit",myAddress:p,chainType:c,validate:D=>_(D,o),onApply:j})}),className:Ft.account,children:T}),S=()=>{switch(c){case"initia":case"evm":return g?k(t.jsx(A.IconWallet,{size:14})):t.jsxs("div",{className:Ft.account,children:[t.jsx("span",{className:"monospace",children:N.truncate(l)}),t.jsx("button",{type:"button",className:Ft.clear,onClick:()=>n("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(A.IconCloseCircleFilled,{size:14})})]});case"cosmos":return k(t.jsxs(t.Fragment,{children:[l?t.jsx("span",{className:"monospace",children:N.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx(A.IconEdit,{size:14})]}))}};switch(e){case"src":return b();case"dst":return S()}},Rm="_description_l5bcv_1",Bm="_presets_l5bcv_8",Mm="_preset_l5bcv_8",Fm="_active_l5bcv_29",Om="_custom_l5bcv_40",Lm="_wrapper_l5bcv_46",Um="_percent_l5bcv_49",Ae={description:Rm,presets:Bm,preset:Mm,active:Fm,custom:Om,wrapper:Lm,percent:Um},rr=["0.1","0.5","1.0"],zm=({afterConfirm:e})=>{const s=et(),n=s.getValues("slippagePercent"),[r,o]=f.useState(null),{control:a,watch:i,getValues:l,setValue:c}=re.useForm({defaultValues:{value:n}}),d=i("value");f.useEffect(()=>{const g=rr.findIndex(b=>b===n);o(g>=0?g:null)},[n]);const u=(g,b)=>{c("value",g),o(b)},h=()=>{o(null)},m=f.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),_=m?.type==="error",p=({value:g})=>{s.setValue("slippagePercent",g),e()};return t.jsxs(Le,{children:[t.jsx("p",{className:Ae.description,children:"Slippage is how much price movement you can tolerate between the time you send out a transaction and the time it's executed."}),t.jsxs("div",{className:Ae.presets,children:[rr.map((g,b)=>t.jsxs("button",{type:"button",className:R(Ae.preset,{[Ae.active]:r===b}),onClick:()=>u(g,b),children:[g,"%"]},g)),r!==null?t.jsx("button",{type:"button",className:R(Ae.preset,Ae.custom),onClick:()=>o(null),children:"Custom"}):t.jsxs("div",{className:Ae.wrapper,children:[t.jsx(yo,{name:"value",control:a,dp:2,onFocus:h,placeholder:"",className:R(Ae.preset,Ae.active)}),t.jsx("span",{className:Ae.percent,children:"%"})]})]}),m&&t.jsx(ee,{level:m.type,children:m.text}),t.jsx(te,{children:t.jsx(W.White,{type:"button",onClick:()=>p(l()),disabled:_,children:"Confirm"})})]})},Km="_skeleton_1l4jn_1",Hm={skeleton:Km},tn=({width:e="100%",height:s})=>t.jsx("div",{className:Hm.skeleton,style:{width:e,height:s}}),Wm="_stack_1ip8h_1",Qm="_button_1ip8h_6",Vm="_isLoading_1ip8h_19",Gm="_disabled_1ip8h_19",Ym="_checked_1ip8h_23",Jm="_header_1ip8h_37",Zm="_title_1ip8h_43",Xm="_duration_1ip8h_52",e_="_warning_1ip8h_62",t_="_amount_1ip8h_66",s_="_value_1ip8h_67",pe={stack:Wm,button:Qm,isLoading:Vm,disabled:Gm,checked:Ym,header:Jm,title:Zm,duration:Xm,warning:e_,amount:t_,value:s_},n_=({children:e})=>t.jsx("div",{className:pe.stack,children:e}),ds=({label:e,query:s,value:n,onSelect:r,...o})=>{const{data:a,isLoading:i}=s,{watch:l}=et(),{dstChainId:c,dstDenom:d}=l(),u=Be(d,c),h=!i&&o.checked,m=!i&&!a;return t.jsxs("button",{type:"button",className:R(pe.button,{[pe.isLoading]:i,[pe.disabled]:m,[pe.checked]:h}),onClick:()=>{i||m||r(n)},children:[t.jsxs("div",{className:pe.header,children:[t.jsxs("div",{className:pe.title,children:[t.jsx("span",{children:e}),h&&t.jsx(A.IconCheck,{size:14})]}),i?t.jsx(tn,{width:80,height:16}):a?t.jsxs("div",{className:R(pe.duration,{[pe.warning]:n==="op"}),children:[t.jsx(A.IconClockFilled,{size:12}),t.jsx("span",{children:_n(a.estimated_route_duration_seconds)})]}):t.jsx("div",{className:pe.duration,children:"Not available"})]}),(i||a)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:pe.amount,children:i?t.jsx(tn,{width:260,height:40}):a?N.formatAmount(a.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:pe.value,children:i?t.jsx(tn,{width:120,height:16}):a?a.usd_amount_out?Me(a.usd_amount_out):"$-":null})]})]})};ds.Stack=n_;const r_="_form_1coq4_1",o_="_arrow_1coq4_5",a_="_divider_1coq4_13",i_="_flip_1coq4_21",c_="_meta_1coq4_37",l_="_row_1coq4_50",d_="_title_1coq4_56",u_="_description_1coq4_60",h_="_icon_1coq4_67",m_="_edit_1coq4_72",__="_warning_1coq4_93",de={form:r_,arrow:o_,divider:a_,flip:i_,meta:c_,row:l_,title:d_,description:u_,icon:h_,edit:m_,warning:__},f_=()=>{const e=ie(),s=Ts(),[n,r]=Ce.useLocalStorage(O.BRIDGE_ROUTE_TYPE,"default"),{watch:o,setValue:a,handleSubmit:i,formState:l}=et(),c=o(),{srcChainId:d,srcDenom:u,dstChainId:h,dstDenom:m,quantity:_,sender:p,slippagePercent:g}=c,b=Ze(),k=Ee(d),S=Wt(k),T=Ee(h),j=Wt(T),D=Be(u,d),B=Be(m,h),{data:P}=Dn(p,d),I=$m(p,d,u),[x]=Ce.useDebounceValue(_,300),w=S!=="initia"&&j!=="initia",y=Am(),q=tr(x,{disabled:w}),C=tr(x,{isOpWithdraw:!0,disabled:!y}),F=y&&n==="op"?C:q,{data:$,isLoading:V,isFetching:K,error:le}=F,{data:he}=km(le),Et=x&&(V||K),qt=()=>{a("srcChainId",h),a("srcDenom",m),a("dstChainId",d),a("dstDenom",u),a("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:gt,closeModal:xt}=ws(),Ie=i(L=>{if($?.warning){const{type:tt="",message:Fs}=$.warning??{};gt({content:t.jsx(io,{type:"warning",icon:t.jsx(A.IconWarningFilled,{size:40}),title:ys.sentenceCase(tt),primaryButton:{label:"Cancel",onClick:xt},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:$,values:L}),xt()}},children:t.jsx("p",{className:de.warning,children:Fs})})});return}e("/bridge/preview",{route:$,values:L})}),me=f.useMemo(()=>$?.estimated_fees?.filter(({fee_behavior:L})=>L==="FEE_BEHAVIOR_DEDUCTED")??[],[$]),Ue=f.useMemo(()=>$?.estimated_fees?.filter(({fee_behavior:L})=>L==="FEE_BEHAVIOR_ADDITIONAL")??[],[$]),yt=f.useMemo(()=>{for(const L of Ue){const tt=P?.[L.origin_asset.denom]?.amount??"0",Fs=$?.source_asset_denom===L.origin_asset.denom?$.amount_in:"0";if(M(tt).lt(M(Fs).plus(L.amount??"0")))return`Insufficient ${L.origin_asset.symbol} for fees`}},[P,$,Ue]),Zt=f.useMemo(()=>{if(!c.sender)return"Connect wallet";if(!c.quantity||!x)return"Enter amount";if(!c.recipient)return"Enter recipient address";if(l.errors.quantity)return l.errors.quantity.message;if(!$)return"Route not found";if(yt)return yt},[x,yt,l,$,c]),Do=$?N.formatAmount($.amount_out,{decimals:B.decimals}):"0",Po=M(_).gt(0)&&M(_).isEqualTo(N.fromBaseUnit(I?.amount,{decimals:I?.decimals??0})),Ro=(()=>{switch(S){case"initia":return b(d).fees.fee_tokens.some(({denom:L})=>L===u);case"cosmos":return k.fee_assets.some(({denom:L})=>L===u);case"evm":return!Ye.isAddress(u);default:return!1}})(),Ms=f.useCallback((L,tt)=>L.length?t.jsxs("div",{className:de.description,children:[Co(L),!s&&t.jsx(Yt,{label:tt,children:t.jsx("span",{className:de.icon,children:t.jsx(A.IconInfoFilled,{size:12})})})]}):null,[s]),Xt=M(_).gt(0)&&y,Rn=f.useMemo(()=>$?[{condition:!!$.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Ms(me,"Fee deducted from the amount you receive"),Ms(Ue,"Fee charged in addition to the amount you enter")]})},{condition:!Xt&&!!_n($.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:de.description,children:_n($.estimated_route_duration_seconds)})},{condition:$.does_swap,title:"Slippage",content:t.jsxs("span",{className:de.description,children:[t.jsxs("span",{children:[g,"%"]}),t.jsx(ut,{title:"Slippage tolerance",content:L=>t.jsx(zm,{afterConfirm:L}),className:de.edit,children:t.jsx(A.IconSettingFilled,{size:12})})]})}].filter(L=>L.condition):[],[Ue,me,Ms,$,Xt,g]);return t.jsxs("form",{className:de.form,onSubmit:Ie,children:[t.jsx(hn,{selectButton:t.jsx(sr,{type:"src"}),accountButton:S==="cosmos"&&t.jsx(nr,{type:"src"}),quantityInput:t.jsx(ps,{balance:I?.amount,decimals:D?.decimals}),balanceButton:t.jsx(xo,{onClick:()=>a("quantity",N.fromBaseUnit(I?.amount,{decimals:D?.decimals??0}),{shouldValidate:!0}),children:N.formatAmount(I?.amount??"0",{decimals:D.decimals})}),value:$?$.usd_amount_in?Me($.usd_amount_in):"$-":"$0"}),t.jsxs("div",{className:de.arrow,children:[t.jsx("div",{className:de.divider}),t.jsx("button",{type:"button",className:de.flip,onClick:()=>qt(),children:t.jsx(A.IconChevronDown,{size:16})})]}),t.jsx(hn,{selectButton:t.jsx(sr,{type:"dst"}),accountButton:t.jsx(nr,{type:"dst"}),quantityInput:t.jsx(ps.ReadOnly,{children:Do}),value:$?$.usd_amount_out?Me($.usd_amount_out):"$-":"$0",hideNumbers:Xt}),t.jsx(ln,{children:Xt?t.jsxs(ds.Stack,{children:[t.jsx(ds,{label:"Fast",query:q,value:"default",onSelect:r,checked:n==="default"}),t.jsx(ds,{label:"Lossless",query:C,value:"op",onSelect:r,checked:n==="op"})]}):null}),t.jsx(te,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(ee.Stack,{children:[$?.extra_infos?.map(L=>t.jsx(ee,{level:"info",children:L},L)),he&&t.jsx(ee,{level:"info",children:he}),Po&&Ro&&t.jsx(ee,{level:"warning",children:"Make sure to leave enough for transaction fee"}),$?.warning&&t.jsx(ee,{level:"warning",children:$.warning.message}),$?.extra_warnings?.map(L=>t.jsx(ee,{level:"warning",children:L},L))]}),t.jsx(ln,{children:Rn.length>0&&t.jsx("div",{className:de.meta,children:Rn.map((L,tt)=>t.jsxs("div",{className:de.row,children:[t.jsx("span",{className:de.title,children:L.title}),L.content]},tt))})})]}),children:t.jsx(W.White,{loading:Et&&"Simulating...",disabled:!!Zt,children:Zt??"Preview route"})})]})},p_=()=>{co();const e=Jo(),s=ie(),{closeDrawer:n}=kt(),r=At(),o=Im(),a=re.useForm({mode:"onChange",defaultValues:o}),{watch:i,setValue:l}=a,{srcChainId:c,dstChainId:d,srcDenom:u,dstDenom:h,quantity:m,slippagePercent:_,recipient:p}=i();i((w,{name:y})=>{(y==="srcChainId"||y==="srcDenom")&&l("quantity","",{shouldTouch:!1,shouldDirty:!1})});const g=bo(),b=g(c),k=g(d),T=wo()(p,d);f.useEffect(()=>{l("cosmosWalletName",void 0),l("sender",b)},[c,b,l]),f.useEffect(()=>{T||l("recipient",k)},[k,T,l]);const j=It(c),D=It(d),B=f.useMemo(()=>{if(!j.find(w=>w.denom===u))return`${u} is not available for bridge/swap on ${c}`;if(!D.find(w=>w.denom===h))return`${h} is not available for bridge/swap on ${d}`},[D,d,h,j,c,u]);f.useEffect(()=>{B||(localStorage.setItem(O.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(O.BRIDGE_SRC_DENOM,u),localStorage.setItem(O.BRIDGE_DST_CHAIN_ID,d),localStorage.setItem(O.BRIDGE_DST_DENOM,h),localStorage.setItem(O.BRIDGE_QUANTITY,m),localStorage.setItem(O.BRIDGE_SLIPPAGE_PERCENT,_))},[c,u,d,h,m,_,B]);const P=e[0].path==="/bridge",I=()=>t.jsxs(t.Fragment,{children:[t.jsx(J,{error:!0,children:B}),t.jsx(te,{children:P?t.jsx(W.White,{onClick:n,children:"Close"}):t.jsx(W.White,{onClick:()=>s(-1),children:"Go back"})})]}),{reminders:x}=$t();return t.jsx(ft,{title:"Bridge/Swap",backButton:P?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(W.Small,{onClick:()=>s("/bridge/history"),unpadded:!0,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[t.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),t.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),t.jsx(jo,{offset:0,disabled:x.length===0,children:t.jsx(W.Small,{onClick:()=>s("/op/withdrawals"),disabled:!r,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:B?I():t.jsx(re.FormProvider,{...a,children:t.jsx(ue,{children:t.jsx(f_,{})})})})},g_="_button_1iys9_1",x_={button:g_},Io=({onClick:e,disabled:s})=>{const{ref:n,inView:r}=Ho.useInView();return f.useEffect(()=>{r&&e()},[r,e]),t.jsxs("button",{className:x_.button,onClick:e,disabled:s,ref:n,children:[t.jsx("span",{children:"Load more"}),t.jsx(A.IconChevronDown,{size:12})]})},pt=qe.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,s)=>[e,s],latestOutput:e=>[e],output:(e,s)=>[e,s],outputResponse:(e,s)=>[e,s],withdrawalClaimed:(e,s)=>[e,s]});function Rs(){const{restUrl:e}=ye();return f.useMemo(()=>Z.create({prefixUrl:e}),[e])}function y_(e){const s=Rs(),{data:n}=E.useSuspenseQuery({queryKey:pt.bridge(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:U.INFINITY});return n}const or=20;function j_(e){const s=ne();return E.useSuspenseInfiniteQuery({queryKey:pt.withdrawals(e,s).queryKey,queryFn:async({pageParam:n})=>{if(!s)return[];const r={limit:or,offset:n,order:"desc"},{withdrawals:o}=await Z.create({prefixUrl:e}).get(`withdrawals/${s}`,{searchParams:r}).json();return o},getNextPageParam:n=>{const r=v.last(n)?.sequence;return n.length<or||!r||r<=1?null:r-1},initialPageParam:0,staleTime:U.SECOND})}function v_(e){const s=Rs(),{data:n}=E.useSuspenseQuery({queryKey:pt.latestOutput(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:r})=>{const[o]=r;return o||null},staleTime:U.SECOND});return n}function b_({bridge_id:e,output_index:s}){const n=Rs(),{data:r}=E.useSuspenseQuery({queryKey:pt.output(e,s).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${e}/outputs/${s}`).json()}catch{return null}},staleTime:U.SECOND});return r}function w_({bridge_id:e,sequence:s}){const r=se().find(({metadata:c})=>c?.op_bridge_id===e.toString())?.chain_id;if(!r)throw new Error(`Chain not found for bridge_id: ${e}`);const a=Ze()(r);if(!a)throw new Error(`Chain not found: ${r}`);const i=a.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${r}`);const{data:l}=E.useSuspenseQuery({queryKey:pt.outputResponse(i,s).queryKey,queryFn:()=>Z.create({prefixUrl:i}).get(`withdrawal/${s}`).json(),staleTime:U.SECOND});return l}function No(e,s){const{bridge_id:n}=e,r=Rs(),{data:o}=E.useSuspenseQuery({queryKey:pt.withdrawalClaimed(n,s).queryKey,queryFn:()=>r.get(`opinit/ophost/v1/bridges/${n}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:s}}).json(),select:({claimed:a})=>a,staleTime:({state:{data:a}})=>a?.claimed?1/0:U.SECOND});return o}function Ot(e){return Wo.sha3_256.create().update(e).digest()}function sn(e,s){const n=new ArrayBuffer(s);return new DataView(n).setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}function So(e){const{bridge_id:s,sequence:n,amount:r,from:o,to:a}=e,i=sn(s.toString(),8),l=sn(n.toString(),8),c=sn(r.amount,8),d=es.concatBytes(i,l,Ot(es.utf8ToBytes(o)),Ot(es.utf8ToBytes(a)),Ot(es.utf8ToBytes(r.denom)),c);return Ot(Ot(d))}const ko=f.createContext(null);function Bs(){return f.useContext(ko)}const C_="_asset_6h8u2_1",I_="_info_6h8u2_7",N_="_symbol_6h8u2_11",nn={asset:C_,info:I_,symbol:N_},S_=({amount:e,denom:s})=>{const n=ye(),r=Or(s,n),{symbol:o,logoUrl:a,decimals:i}=r;return t.jsxs("div",{className:nn.asset,children:[t.jsx(z,{src:a,width:32,height:32,logo:!0}),t.jsxs("div",{className:nn.info,children:[t.jsx("span",{className:"monospace",children:N.formatAmount(e,{decimals:i})}),t.jsx("span",{className:nn.symbol,children:o})]})]})},k_=({children:e})=>{const{withdrawalTx:s}=Bs(),n=v_(s.bridge_id),r=s.output_index>Number(n?.output_index);return e(r)},A_="_container_1oldz_1",$_="_icon_1oldz_7",ar={container:A_,icon:$_},T_="Withdrawal will begin within an hour",ir=()=>{const e=Ts();return t.jsxs("div",{className:ar.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Yt,{label:T_,children:t.jsx("span",{className:ar.icon,children:t.jsx(A.IconInfoFilled,{size:12})})})]})},Ao=1e3,E_=60,q_=60,D_=24,fn=Ao*E_,pn=fn*q_,cr=pn*D_,P_=({date:e})=>{const s=f.useCallback(()=>{const d=new Date().getTime(),h=e.getTime()-d;if(h<=0)return{days:0,hours:0,minutes:0,seconds:0};const m=Math.floor(h/cr),_=Math.floor(h%cr/pn),p=Math.floor(h%pn/fn),g=Math.floor(h%fn/Ao);return{days:m,hours:_,minutes:p,seconds:g}},[e]),[n,r]=f.useState(s());f.useEffect(()=>{const d=window.setInterval(()=>{r(s())},1e3);return()=>window.clearInterval(d)},[s,e]);const o=d=>d.toString().padStart(2,"0"),{days:a,hours:i,minutes:l,seconds:c}=n;return t.jsx(Yt,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[a,"d ",o(i),"h ",o(l),"m ",o(c),"s"]})})},R_="_container_1lz3w_1",B_="_title_1lz3w_5",lr={container:R_,title:B_},M_=({date:e})=>t.jsxs("div",{className:lr.container,children:[t.jsx("div",{className:lr.title,children:"Claimable in"}),t.jsx(P_,{date:e})]}),F_=({children:e})=>{const{withdrawalTx:s}=Bs(),n=y_(s.bridge_id),r=b_(s),o=f.useMemo(()=>{if(!r)return null;const{bridge_config:a}=n,{output_proposal:i}=r;return Nt.addSeconds(new Date(i.l1_block_time),parseFloat(a.finalization_period))},[n,r]);return e(o)},O_=({date:e,children:s})=>{const{chainId:n,withdrawalTx:r}=Bs(),o=H.toBase64(So(r)),a=No(r,o),{setReminder:i,removeReminder:l}=$t();return f.useEffect(()=>{const c={chainId:n,txHash:r.tx_hash};a?l(c):i(c,{...c,recipient:r.to,claimableAt:e.getTime(),amount:r.amount.amount,denom:r.amount.denom,dismissed:Nt.isPast(e.getTime())?!0:void 0})},[n,a,e,l,i,r]),s},L_="_button_1btdg_1",U_="_claimed_1btdg_23",dr={button:L_,claimed:U_},z_=()=>{const{withdrawalTx:e}=Bs(),{bridge_id:s,sequence:n,amount:r,output_index:o,withdrawal_proofs:a,storage_root:i,from:l,to:c,version:d}=e,u=ye(),h=ne(),{requestTxSync:m,waitForTxConfirmation:_}=je(),p=w_(e),g=H.toBase64(So(e)),b=No(e,g),k=E.useQueryClient(),{mutate:S,isPending:T}=E.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:j}=p;return m({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:h,bridgeId:BigInt(s),outputIndex:BigInt(o),withdrawalProofs:a.map(H.fromBase64),from:l,to:c,sequence:BigInt(n),amount:r,version:H.fromBase64(d),storageRoot:H.fromBase64(i),lastBlockHash:H.fromBase64(j)}}],internal:!0})},onSuccess:async j=>{await _({chainId:u.chain_id,txHash:j}),k.invalidateQueries({queryKey:pt.withdrawalClaimed(s,g).queryKey})}});return b?t.jsxs("div",{className:dr.claimed,children:[t.jsx(A.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:dr.button,onClick:()=>S(),disabled:T,children:"Claim"})},K_=()=>t.jsx(k_,{children:e=>e?t.jsx(ir,{}):t.jsx(F_,{children:s=>s?t.jsx(O_,{date:s,children:Nt.isFuture(s)?t.jsx(M_,{date:s}):t.jsx(z_,{})}):t.jsx(ir,{})})}),H_="_item_km5w2_1",W_={item:H_},Q_=({chain:e})=>{const s=e.metadata?.executor_uri;if(!s)throw new Error("Executor URL is not defined");const{data:n,fetchNextPage:r,hasNextPage:o,isFetching:a}=j_(s),i=f.useMemo(()=>n?.pages.flat()??[],[n]),{syncReminders:l}=$t();return f.useEffect(()=>{const c=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));l(c)},[e.chainId,i,l]),i.length?t.jsxs(t.Fragment,{children:[i.map(c=>{const{amount:d}=c;return t.jsxs("div",{className:W_.item,children:[t.jsx(S_,{...d}),t.jsx(ue,{suspenseFallback:null,children:t.jsx(ko.Provider,{value:{chainId:e.chainId,withdrawalTx:c},children:t.jsx(K_,{})})})]},c.sequence)}),o&&t.jsx(Io,{onClick:()=>r(),disabled:a})]}):t.jsx(J,{children:"No withdrawals"})},V_="_content_dj1qm_1",G_="_title_dj1qm_5",ur={content:V_,title:G_},Y_=()=>{const{chainId:e}=ht(),s=se(),n=Qt(),[r,o]=f.useState(e??(n.metadata?.is_l1?"":n.chainId)),a=Ze(),{reminders:i}=$t(),l=r?a(r):void 0;return t.jsxs(ft,{title:"OP Bridge withdrawals",children:[t.jsx(lt,{chains:s.filter(({metadata:c})=>!c?.is_l1&&c?.op_denoms?.length),value:r,onSelect:o,getShowIndicator:c=>i.some(d=>d.chainId===c)}),t.jsx("div",{className:ur.content,children:l?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:ur.title,children:l.name}),t.jsx(ue,{children:t.jsx(Q_,{chain:l})},r)]}):t.jsx(ee,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})};async function J_(e,s){const n=Z.create({prefixUrl:s}),r=`cosmos/auth/v1beta1/account_info/${e}`;for(let o=1;o<=24;o++)try{return await n.get(r).json()}catch{await new Promise(a=>setTimeout(a,5e3))}throw new Error(`Timeout: ${e} not found`)}const us=({chainId:e,txHash:s})=>`${O.BRIDGE_HISTORY}:${e}:${s}`,gs=100,hr=10;function $o(){const[e,s]=Ce.useLocalStorage(O.BRIDGE_HISTORY,[]),n=f.useCallback((o,a)=>{localStorage.setItem(us(o),JSON.stringify(a));for(const i of e.slice(gs-1))localStorage.removeItem(us(i));s((i=[])=>[o,...i.slice(0,gs-1)])},[e,s]),r=f.useCallback(o=>{const a=localStorage.getItem(us(o));return a?JSON.parse(a):null},[]);return{history:e,addHistoryItem:n,getHistoryDetails:r}}function To(e){return Ce.useLocalStorage(us(e),null)}async function gn(e,s){const{chain_type:n,chain_id:r,chain_name:o,evm_fee_asset:a,rpc:i}=s;if(n!=="evm")throw new Error(`Chain is not an EVM chain: ${o}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}catch(l){if(v.path(["error","code"],l)!==4902)throw l;if(!a)throw new Error(`Fee asset is not defined for chain: ${o}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(r).toString(16)}`,chainName:o,nativeCurrency:a,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}}function Tt(){return ht()}function Z_(e){const s=ie(),{showNotification:n,updateNotification:r,hideNotification:o}=An(),{addHistoryItem:a}=$o(),i=Ss(),{route:l,values:c}=Tt(),{srcChainId:d,sender:u,recipient:h,cosmosWalletName:m}=c,_=Tr(),{requestTxSync:p,waitForTxConfirmation:g}=je(),{find:b}=Ps(),k=Is(),S=Ns(),T=Ee(d),j=Wt(T),D=Wr(d),B=E.useQueryClient(),{registryUrl:P}=ce(),I=Ze(),{addReminder:x}=$t(),w=Oe();return E.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const y=e.cosmos_tx.msgs.map(({msg_type_url:Ie,msg:me})=>{if(!(Ie&&me))throw new Error("Invalid transaction data");return S.fromAmino({type:zt.aminoConverters[Ie].aminoType,value:JSON.parse(me)})});if(j==="initia"){const{srcDenom:Ie,quantity:me}=c,{decimals:Ue}=D(Ie),yt=await p({messages:y,chainId:d,internal:1,spendCoins:[{denom:Ie,amount:N.toBaseUnit(me,{decimals:Ue})}]}),Zt=g({txHash:yt,chainId:d});return{txHash:yt,wait:Zt}}const q=b(m)?.getProvider();if(!q)throw new Error("Wallet not connected");const C=q.getOfflineSignerOnlyAmino(d),F=await $e.SigningStargateClient.connectWithSigner(T.rpc,C,{registry:k,aminoTypes:S}),$=await F.getAllBalances(u),V=T.fee_assets.find(Ie=>$.some(me=>me.denom===Ie.denom&&M(me.amount).gt(0)));if(!V){const me=["Insufficient balance for fees.",`Available fee assets: ${T.fee_assets.map(Ue=>D(Ue.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(me)}const{denom:K,gas_price:le}=V;if(!le)throw new Error(`Gas price not found for ${K}`);const he=await F.simulate(u,y,""),Et=$e.GasPrice.fromString(le.average+K),qt=$e.calculateFee(Math.ceil(he*Kt),Et),gt=await F.signAndBroadcastSync(u,y,qt),xt=Br({txHash:gt,client:F});return{txHash:gt,wait:xt}}if("evm_tx"in e){const{chain_id:y,to:q,value:C,data:F}=e.evm_tx,$=await _(),V=await $.getSigner();await gn($,T);const K=await V.sendTransaction({chainId:y,to:q,value:C,data:`0x${F}`});return{txHash:K.hash,wait:K.wait()}}throw new Error("Unlisted chain type")}catch(y){throw await Re(y)}},onSuccess:async({txHash:y,wait:q})=>{localStorage.removeItem(O.BRIDGE_QUANTITY),s(-1),n({type:"loading",title:"Transaction is pending..."});try{await q;const C=Pn(l)==="OP Bridge withdrawal",F=C?{success:!0,error:null}:await nf(w,y,d);if(!F.success&&F.error){const he=F.error instanceof Error?F.error.message:String(F.error);n({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${he}. The transaction may still be processing.`,autoHide:!0})}const $=F.success,K=tf({txHash:y,srcChainId:d,route:l,values:c,recipient:h},$);a(K.tx,K.details),r(ef(o));const le=rn(c,y);if(i("Bridge Transaction Success",le),C){const he=sf(K.tx,l,h);x(K.tx,he)}}catch(C){const F=C instanceof Error?C.message:String(C);r({type:"error",title:"Transaction not confirmed",description:F});const $={...rn(c,y),error:F};i("Bridge Confirmation Failed",$)}finally{B.invalidateQueries({queryKey:Te.balances(d,u).queryKey})}},onError:async y=>{const q=j==="initia"?await bt(y,I(d),P):y;n({type:"error",title:"Transaction failed",description:q.message});const C=rn(c);i("Bridge Transaction Failed",{...C,error:q.message})}})}function X_(){const e=Oe(),s=ne(),n=bn(),{route:r,values:o}=Tt(),a=mt();return E.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:l}=await e.post("op-hook",{json:{source_address:s,source_asset_chain_id:r.source_asset_chain_id,source_asset_denom:r.source_asset_denom,dest_address:N.InitiaAddress(o.recipient).bech32,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom}}).json();await J_(s,a(r.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:h,msg:m})=>zt.aminoTypes.fromAmino({type:zt.aminoConverters[h].aminoType,value:JSON.parse(m)})),d=await n(i,s,c,{amount:[],gas:"1"},"",{incrementSequence:i===o.srcChainId?2:0}),u=Ve.Tx.fromPartial({body:Ve.TxBody.decode(d.bodyBytes),authInfo:Ve.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:s,hook:H.toBase64(Ve.Tx.encode(u).finish())}}catch(i){throw await Re(i)}}})}function ef(e){return{type:"info",title:"Transaction submitted",description:f.createElement(f.Fragment,null,"Check ",f.createElement(jn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function rn(e,s){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:s}}function tf(e,s){const{txHash:n,srcChainId:r,route:o,values:a}=e,i={chainId:r,txHash:n},l=Pn(o)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:o,values:a,state:l?"success":void 0,tracked:s},isOpWithdraw:l}}function sf(e,s,n){return{...e,recipient:N.InitiaAddress(n).bech32,claimableAt:Date.now()+s.estimated_route_duration_seconds*1e3,amount:s.amount_out,denom:s.dest_asset_denom}}async function nf(e,s,n){for(let a=0;a<=30;a++)try{return await e.post("v2/tx/track",{json:{tx_hash:s,chain_id:n}}).json(),{success:!0,error:null}}catch(i){if(a===30)return{success:!1,error:await Re(i)};await new Promise(l=>setTimeout(l,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function rf(e){const{chainId:s,txHash:n,tracked:r}=e,o=Oe();return E.useQuery({queryKey:Te.txTrack(s,n).queryKey,queryFn:async()=>{try{return await o.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json()}catch(a){throw await Re(a)}},select:({tx_hash:a})=>a,retry:6,retryDelay:5e3,staleTime:U.INFINITY,enabled:!r})}function of(e){const{timestamp:s,chainId:n,txHash:r,tracked:o,state:a}=e,i=Oe();return E.useQuery({queryKey:Te.txStatus(n,r).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:r,chain_id:n}}).json(),enabled:!!r&&o&&!a,refetchInterval:({state:{data:l}})=>{if(!l)return!1;const{status:c}=l;if(c==="STATE_COMPLETED")return!1;const d=s+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),h=Math.floor((d-u)/1e3);return h<=0?1e3:h<=300?5e3:60*1e3},staleTime:U.INFINITY})}var hs=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(hs||{});function Pn(e){const{operations:s,dest_asset_denom:n}=e;return v.has("op_init_transfer",v.head(s))&&n==="uinit"?"OP Bridge withdrawal":"Skip"}const af="_content_c0tee_1",cf="_info_c0tee_6",lf="_arrow_c0tee_11",df="_divider_c0tee_19",uf="_type_c0tee_26",hf="_asset_c0tee_44",mf="_amount_c0tee_52",_f="_lower_c0tee_57",ff="_chain_c0tee_63",pf="_address_c0tee_69",fe={content:af,info:cf,arrow:lf,divider:df,type:uf,asset:hf,amount:mf,lower:_f,chain:ff,address:pf},Eo=e=>{const{source:s,label:n,amount:r,denom:o,chainId:a,address:i,walletIcon:l}=e,{symbol:c=N.truncate(o),decimals:d=0,logo_uri:u=wn}=e,{chain_name:h,pretty_name:m,..._}=Ee(a);return t.jsxs("div",{children:[!s&&t.jsxs("div",{className:fe.arrow,children:[t.jsx("div",{className:fe.divider}),n?t.jsx(Yt,{label:n,children:t.jsx("button",{className:fe.type,children:t.jsx(A.IconArrowDown,{size:12})})}):t.jsx("span",{className:fe.type,children:t.jsx(A.IconArrowDown,{size:12})}),t.jsx("div",{className:fe.divider})]}),t.jsxs("div",{className:fe.content,children:[t.jsx(Ds,{assetLogoUrl:u,chainLogoUrl:_.logo_uri??void 0}),t.jsxs("div",{className:fe.info,children:[t.jsxs("div",{className:fe.asset,children:[t.jsx("span",{className:fe.amount,children:N.formatAmount(r,{decimals:d})}),t.jsx("span",{children:c})]}),t.jsxs("div",{className:fe.lower,children:[t.jsxs("div",{className:fe.chain,children:["on ",m||h]}),i&&t.jsx(fs,{value:i,children:({copy:p,copied:g})=>t.jsxs("button",{className:fe.address,onClick:p,children:[l,g?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:N.truncate(i)})]})})]})]})]})]})},Ct=e=>{const s=Be(e.denom,e.chainId);return t.jsx(Eo,{...e,...s})};Ct.Placeholder=Eo;const gf="_root_1l4he_1",xf="_flexEnd_1l4he_6",yf="_toggle_1l4he_11",jf="_route_1l4he_34",vf="_content_1l4he_41",Lt={root:gf,flexEnd:xf,toggle:yf,route:jf,content:vf};function bf(e){const s=({name:n})=>n==="initia-dex"?"Initia DEX":ys.capitalCase(v.head(n?.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 n=e.swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"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 n=e.evm_swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"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 wf=({addressList:e})=>{const{values:s,route:n}=Tt(),{source_asset_denom:r,source_asset_chain_id:o,amount_in:a,operations:i}=n,l=v.zipObj(n.required_chain_addresses,e),{find:c}=Ps(),{connector:d,address:u=""}=xe.useAccount(),[h,m]=Ce.useToggle(!1),_=i.length>1,p=t.jsx(z,{src:s.cosmosWalletName?c(s.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:a,denom:r,chainId:o,address:s.sender,walletIcon:p},b=D=>N.InitiaAddress.equals(D,u)?p:t.jsx(A.IconWallet,{size:11}),k=D=>{const{label:B,amount_out:P,denom:I,denom_out:x=I,chain_id:w,from_chain_id:y,to_chain_id:q=w??y}=D,C=l[q];return{label:_&&!h?void 0:B,amount:P,denom:x,chainId:q,address:C,walletIcon:b(C)}},S=i.map(bf).map(k),T=S.slice(0,-1),j=S[S.length-1];return t.jsxs(G.Collapsible.Root,{className:Lt.root,open:h,onOpenChange:m,children:[_&&t.jsx("div",{className:Lt.flexEnd,children:t.jsx(G.Collapsible.Trigger,{className:Lt.toggle,children:h?t.jsxs(t.Fragment,{children:[t.jsx(A.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(A.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:Lt.route,children:[t.jsx(Ct,{...g,source:!0}),t.jsx(G.Collapsible.Content,{className:Lt.content,children:T.map((D,B)=>t.jsx(ue,{suspenseFallback:t.jsx(Ct.Placeholder,{...D}),errorBoundaryProps:{fallback:t.jsx(Ct.Placeholder,{...D})},children:t.jsx(Ct,{...D})},B))}),t.jsx(Ct,{...j})]})]})},xn=({error:e})=>{const s=ie();return t.jsx(te,{extra:t.jsx(ee,{level:"error",children:e.message}),children:t.jsx(W.White,{onClick:()=>s("/bridge"),children:"Home"})})},Cf=({children:e})=>{const s=Tt(),{route:n,values:r}=s,{required_chain_addresses:o}=n,{srcChainId:a,dstChainId:i,sender:l,recipient:c}=r,{initiaAddress:d,hexAddress:u}=je(),h=St(),m=mt(),_=Vt(),p=m(a),g=_(p),b=o.slice(0,-1).some(P=>{const I=m(P);return _(I)==="cosmos"})&&g!=="cosmos",[k,S]=f.useState(void 0),[T,j]=f.useState(!1),[D,B]=f.useState(null);if(f.useEffect(()=>{(async()=>{try{if(!b)return;if(!h)throw new Error("Wallet not connected");j(!0),B(null);const[{pubkey:I}]=await h.getAccounts();S(I)}catch(I){B(await Re(I))}finally{j(!1)}})()},[b,h]),D)return t.jsx(xn,{error:D});if(T)return t.jsx(te,{children:t.jsx(W.White,{loading:T&&"Generating intermediary addresses..."})});if(!b||k){const P=o.map((I,x)=>{if(x===o.length-1){const F=m(i);return _(F)==="initia"?N.InitiaAddress(c).bech32:c}const w=m(I),y=_(w),q=m(a),C=_(q);switch(y){case"initia":return d;case"evm":return u;case"cosmos":{if(C==="cosmos")return H.toBech32(w.bech32_prefix,H.fromBech32(l).data);if(!k)throw new Error("Pubkey not found");return Ut.pubkeyToAddress(Ut.encodeSecp256k1Pubkey(k),w.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(P)}return null},If=({addressList:e,signedOpHook:s,children:n})=>{const r=Oe(),{route:o,values:a}=Tt(),[i,l]=f.useState(void 0),[c,d]=f.useState(!1),[u,h]=f.useState(null);return f.useEffect(()=>{(async()=>{try{if(o.required_op_hook&&!s)throw new Error("Op hook is required");d(!0),h(null);const _={address_list:e,amount_in:o.amount_in,amount_out:o.amount_out,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom,slippage_tolerance_percent:a.slippagePercent,operations:o.operations,signed_op_hook:s},{txs:p}=await r.post("v2/fungible/msgs",{json:_}).json();if(!p||p.length===0)throw new Error("No transaction data found");const[g]=p;l(g)}catch(_){h(_)}finally{d(!1)}})()},[o,a,e,s,r]),u?t.jsx(xn,{error:u}):c?t.jsx(te,{children:t.jsx(W.White,{loading:c&&"Fetching messages..."})}):i?n(i):t.jsx(xn,{error:new Error("Failed to fetch messages")})},Nf=({children:e})=>{const{route:s}=Tt(),n=X_();return s.required_op_hook&&!n.data?t.jsx(te,{extra:t.jsx(ee,{level:"error",children:n.error?.message}),children:t.jsx(W.White,{onClick:()=>n.mutate(),loading:n.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(n.data)},Sf=({tx:e,children:s})=>{const n=Tr(),r=mt(),{data:o,isLoading:a}=E.useQuery({queryKey:["erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:u,signer_address:h}=e.evm_tx,m=await n();await gn(m,r(u));const _=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async g=>{const{token_contract:b,spender:k}=g,T=await new Ye.ethers.Contract(b,_,m).allowance(h,k);return{approval:g,currentAllowance:BigInt(T.toString())}}))).filter(({approval:g,currentAllowance:b})=>b<BigInt(g.amount)).map(({approval:g})=>g)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:l,isPending:c,error:d}=E.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!o||o.length===0)throw new Error("No approvals needed");const{chain_id:u}=e.evm_tx,h=await n(),m=await h.getSigner();await gn(h,r(u));for(const _ of o){const{token_contract:p,spender:g,amount:b}=_,k=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new Ye.ethers.Contract(p,k,m).approve(g,b)).wait()}return!0}catch(u){throw await Re(u)}}});return a?t.jsx(te,{children:t.jsx(W.White,{loading:"Checking approvals..."})}):o&&o.length>0&&!l?t.jsx(te,{extra:t.jsx(ee,{level:"error",children:d?.message}),children:t.jsx(W.White,{onClick:()=>i(),loading:c&&"Approving tokens...",children:"Approve tokens"})}):s},kf=({tx:e})=>{const{mutate:s,isPending:n}=Z_(e);return t.jsx(te,{children:t.jsx(W.White,{onClick:()=>s(),loading:n&&"Signing transaction...",children:"Confirm"})})},Af=()=>t.jsx(ft,{title:"Route preview",children:t.jsx(Cf,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(wf,{addressList:e}),t.jsx(Nf,{children:s=>t.jsx(If,{addressList:e,signedOpHook:s,children:n=>t.jsx(Sf,{tx:n,children:t.jsx(kf,{tx:n})})})})]})})}),$f="_button_14cv7_1",Tf="_checkbox_14cv7_10",Ef="_checked_14cv7_23",ls={button:$f,checkbox:Tf,checked:Ef},qf=({checked:e,onClick:s,label:n,className:r})=>t.jsxs("button",{type:"button",className:R(ls.button,r),onClick:s,children:[t.jsx("div",{className:R(ls.checkbox,{[ls.checked]:e}),children:e&&t.jsx(A.IconCheck,{size:12})}),t.jsx("span",{className:ls.label,children:n})]}),Df="_success_t4dfk_1",Pf="_error_t4dfk_5",mr={success:Df,error:Pf},Rf=({tx:e})=>{const[s,n]=To(e);if(!s)throw new Error("Bridge history details not found");const{data:r}=of(s),o=s.state??Bf(r);switch(f.useEffect(()=>{o!=="loading"&&n(a=>{if(!a)throw new Error("Bridge history details not found");return{...a,tracked:!0,state:o}})},[n,o]),o){case"error":return t.jsx("div",{className:mr.error,children:t.jsx(A.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:mr.success,children:t.jsx(A.IconCheckCircleFilled,{size:14})});default:return t.jsx(_t,{size:14})}};function Bf(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 Mf="_link_12p3n_1",Ff="_header_12p3n_22",Of="_title_12p3n_30",Lf="_date_12p3n_36",Uf="_explorer_12p3n_40",zf="_fees_12p3n_55",Kf="_label_12p3n_63",Hf="_content_12p3n_67",Wf="_route_12p3n_73",Qf="_row_12p3n_78",Vf="_asset_12p3n_84",Gf="_amount_12p3n_92",Yf="_chain_12p3n_97",Jf="_account_12p3n_106",Zf="_arrow_12p3n_113",X={link:Mf,header:Ff,title:Of,date:Lf,explorer:Uf,fees:zf,label:Kf,content:Hf,route:Wf,row:Qf,asset:Vf,amount:Gf,chain:Yf,account:Jf,arrow:Zf},Xf=({tx:e})=>{const[s,n]=To(e);if(!s)throw new Error("Bridge history details not found");const{chainId:r,txHash:o,route:a,values:i,timestamp:l,tracked:c}=s,{data:d}=rf(s),{address:u="",connector:h}=xe.useAccount(),{find:m}=Ps();f.useEffect(()=>{d&&n($=>{if(!$)throw new Error("Bridge history details not found");return{...$,tracked:!0}})},[n,d]);const{amount_in:_,amount_out:p,source_asset_chain_id:g,source_asset_denom:b,dest_asset_chain_id:k,dest_asset_denom:S,estimated_fees:T=[]}=a,j=Ee(g),D=Ee(k),B=Be(b,g),P=Be(S,k),I=($,V)=>V?t.jsx(z,{src:V,width:12,height:12}):N.InitiaAddress.equals($,u)?t.jsx(z,{src:h?.icon,width:12,height:12}):t.jsx(A.IconWallet,{size:12}),x=($,{symbol:V,decimals:K,logo_uri:le},{chain_name:he,pretty_name:Et,...qt},gt,xt)=>t.jsxs("div",{className:X.row,children:[t.jsx(Ds,{assetLogoUrl:le,chainLogoUrl:qt.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:X.asset,children:[t.jsx("span",{className:X.amount,children:N.formatAmount($,{decimals:K})}),t.jsx("span",{children:V})]}),t.jsxs("div",{className:X.chain,children:[t.jsxs("span",{children:["on ",Et||he]}),t.jsxs("div",{className:X.account,children:[xt,t.jsx("span",{className:"monospace",children:N.truncate(gt)})]})]})]})]}),w=Pn(a),y=f.useMemo(()=>{switch(w){case hs.SKIP:return"Skip Explorer";case hs.OP_WITHDRAW:return"Initia Scan"}},[w]),q=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:X.header,children:[t.jsxs("div",{className:X.title,children:[c?t.jsx(Rf,{tx:e}):t.jsx(_t,{size:14}),t.jsx("div",{className:X.date,children:Nt.format(new Date(l),"h:mm a")})]}),t.jsxs("div",{className:X.explorer,children:[t.jsx("span",{children:y}),t.jsx(A.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:X.route,children:[x(_,B,j,i.sender,I(i.sender,m(i.cosmosWalletName)?.image)),t.jsx("div",{className:X.arrow,children:t.jsx(A.IconArrowDown,{size:12})}),x(p,P,D,i.recipient,I(i.recipient))]}),T.length>0&&t.jsxs("div",{className:X.fees,children:[t.jsx("span",{className:X.label,children:"Fees"}),t.jsx("span",{className:X.content,children:Co(T)})]})]});if(w===hs.OP_WITHDRAW)return t.jsx(Es,{chainId:r,txHash:o,className:X.link,children:q});const C=new URLSearchParams({tx_hash:o,chain_id:r}),F=new URL(`?${C.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:F.toString(),className:X.link,target:"_blank",children:q})},ep="_history_13u9z_1",tp="_header_13u9z_5",sp="_checkbox_13u9z_9",np="_groups_13u9z_13",rp="_dateGroup_13u9z_21",op="_dateHeader_13u9z_26",ap="_list_13u9z_32",at={history:ep,header:tp,checkbox:sp,groups:np,dateGroup:rp,dateHeader:op,list:ap},ip=()=>{const{initiaAddress:e,hexAddress:s}=je(),{history:n,getHistoryDetails:r}=$o(),o=n.filter(_=>r(_)),a=o.filter(_=>{const p=r(_);if(!p)return!1;const{values:g}=p,{sender:b,recipient:k}=g;return[b,k].some(S=>[e,s].includes(S))}),[i,l]=f.useState(1),[c,d]=Ce.useToggle(!a.length),u=c?o:a,h=u.slice(0,i*hr),m=f.useMemo(()=>fo(h,_=>{const p=r(_);if(p)return new Date(p.timestamp)}),[h,r]);return t.jsx(ft,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:at.history,children:[o.length>0&&o.length!==a.length&&t.jsx("header",{className:at.header,children:t.jsx(qf,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:at.checkbox})}),u.length===0?t.jsx(J,{children:"No bridge/swap activity"}):t.jsx("div",{className:at.groups,children:Object.entries(m).map(([_,p])=>t.jsxs("div",{className:at.dateGroup,children:[t.jsx("div",{className:at.dateHeader,children:_}),t.jsx("div",{className:at.list,children:p.map(g=>t.jsx(ue,{children:t.jsx(Xf,{tx:g})},g.txHash))})]},_))}),u.length>i*hr?t.jsx(Io,{onClick:()=>l(_=>_+1)}):n.length>=gs&&t.jsxs(J,{children:["Only the latest ",gs," items are stored. Older entries will be removed automatically."]})]})})},qo=()=>{const e=ie(),s=bs(),n=At(),{closeDrawer:r}=kt(),{closeModal:o}=ws();f.useEffect(()=>{o(),s.startsWith("/bridge/")&&e("/bridge"),(s==="/collection"||s.startsWith("/nft"))&&e("/nfts")},[n]);const a=Ss();if(f.useEffect(()=>{a("Page View")},[s,a]),s==="/connect")return n?null:t.jsx(Vn,{onSuccess:r});if(s==="/blank")return null;if(!n)return t.jsx(Vn,{});switch(s){case"/":case"/nfts":case"/activity":return t.jsx(Hu,{});case"/send":return t.jsx(Xh,{},n);case"/nft":return t.jsx(dm,{});case"/nft/send":return t.jsx(wm,{},n);case"/bridge":return t.jsx(p_,{},n);case"/bridge/preview":return t.jsx(Af,{});case"/bridge/history":return t.jsx(ip,{});case"/op/withdrawals":return t.jsx(Y_,{});case"/tx":return t.jsx(oo,{})}},cp="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",lp=()=>t.jsxs(t.Fragment,{children:[t.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),t.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),t.jsx("link",{rel:"stylesheet",href:cp}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),dp=()=>{se();const e=ye();return Sn(),It(localStorage.getItem(O.BRIDGE_SRC_CHAIN_ID)??e.chainId),It(localStorage.getItem(O.BRIDGE_DST_CHAIN_ID)??e.chainId),null},up=new E.QueryClient({defaultOptions:{queries:{retry:0}}}),hp=({children:e,...s})=>(f.useEffect(()=>{qa()},[]),Ce.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(lp,{}),t.jsx(Ir.Provider,{value:{...yr,...s},children:t.jsx(wr,{children:t.jsx(Ra,{children:t.jsx(G.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(Ya,{children:t.jsxs(bc,{children:[e,t.jsxs(E.QueryClientProvider,{client:up,children:[t.jsx(wc,{}),t.jsx(ue,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(dp,{})}),t.jsx(al,{children:t.jsx(qo,{})})]})]})})})})})})]}):null),mp=({bridge:e})=>t.jsx(wr,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Gr.Provider,{value:!!e,children:t.jsx(ue,{children:t.jsx(qo,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=Kt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=xr;exports.InterwovenKit=mp;exports.InterwovenKitProvider=hp;exports.MAINNET=yr;exports.MoveError=Nr;exports.TESTNET=Vo;exports.initiaPrivyWallet=Yo;exports.initiaPrivyWalletConnector=Go;exports.initiaPrivyWalletOptions=js;exports.injectStyles=Ic;exports.useAddress=At;exports.useHexAddress=$s;exports.useInitiaAddress=ne;exports.useInterwovenKit=je;exports.usePortfolio=Nn;exports.useUsernameQuery=Kr;