@initia/interwovenkit-react 2.0.5 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const pr=require("@privy-io/cross-app-connect/rainbow-kit"),xe=require("wagmi"),q=require("@tanstack/react-query"),w=require("@initia/utils"),Ge=require("cosmjs-types/cosmos/tx/v1beta1/tx"),zt=require("@cosmjs/amino"),$e=require("@cosmjs/stargate"),V=require("jotai"),t=require("react/jsx-runtime"),b=require("ramda"),f=require("react"),X=require("ky"),qe=require("@lukemorales/query-key-factory"),Je=require("ethers"),Mo=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),cn=require("@cosmjs/amino/build/signdoc"),ln=require("@cosmjs/crypto"),W=require("@cosmjs/encoding"),Mn=require("@cosmjs/math"),ys=require("@cosmjs/proto-signing"),On=require("@cosmjs/tendermint-rpc"),Kt=require("@initia/amino-converter"),dn=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Oo=require("cosmjs-types/cosmos/auth/v1beta1/auth"),Lo=require("cosmjs-types/google/protobuf/any"),gr=require("@amplitude/analytics-browser"),M=require("bignumber.js"),Uo=require("@mysten/bcs"),G=require("radix-ui"),Ce=require("usehooks-ts"),xr=require("react-error-boundary"),P=require("clsx"),Ln=require("nanoid"),zo=require("react-dom"),Ze=require("@react-spring/web"),T=require("@initia/icons-react"),we=require("@base-ui-components/react/dialog"),js=require("change-case"),De=require("@base-ui-components/react/select"),Ls=require("@base-ui-components/react/collapsible"),Ko=require("qr-code-styling"),Ho=require("xss"),Ke=require("@base-ui-components/react/tabs"),kt=require("date-fns"),Wo=require("jotai/utils"),vt=require("@base-ui-components/react/popover"),He=require("@base-ui-components/react"),ae=require("react-hook-form"),Un=require("cosmjs-types/cosmos/bank/v1beta1/tx"),yr=require("react-merge-refs"),Qo=require("react-intersection-observer"),ts=require("@noble/hashes/utils"),Vo=require("@noble/hashes/sha3");function Go(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 vn=Go(gr),Ht=1.4,jr=1.05,vr={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",glyphUrl:"https://glyph.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",theme:"dark"},Yo={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",glyphUrl:"https://glyph.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",theme:"dark",disableAnalytics:!0},vs={id:"cmbq1ozyc006al70lx4uciz0q",name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Jo=pr.toPrivyWalletConnector(vs),Zo=pr.toPrivyWallet(vs),br=f.createContext(null);function bs(){return f.useContext(br)}function wr(){const{location:e}=bs();return e}function ws(){const{path:e}=wr();return e}function mt(){const{state:e={}}=wr();return e}function Xo(){const{history:e}=bs();return e}function de(){const{navigate:e}=bs();return e}function Cr(){const{reset:e}=bs();return e}const Ir=({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=b.take(u,d);return c!==void 0?b.adjust(u-1,m=>({...m,state:c}),h):h})},[]),i=f.useCallback((l,c)=>{r([{path:l,state:c}])},[]);return t.jsx(br.Provider,{value:{location:o,history:n,navigate:a,reset:i},children:e})},bn=({to:e,state:s,shouldReset:n,children:r,onClick:o,...a})=>{const i=de(),l=Cr(),c=d=>{d.preventDefault(),o?.(d),n?l(e,s):i(e,s)};return t.jsx("button",{type:"button",...a,onClick:c,children:r})},Nr=f.createContext(null),Cs=()=>f.useContext(Nr),Sr=f.createContext(null);function ie(){const e=f.useContext(Sr);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const z={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function ea(e){if(e instanceof X.HTTPError){const{response:s}=e,n=s.headers.get("content-type")??"";if(b.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(b.path(["code"],e)===4001||b.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const s=b.path(["error","message"],e),n=b.path(["cause","message"],e),r=b.path(["shortMessage"],e);return s||n||r||e.message}return String(e)}async function Re(e){return new Error(await ea(e))}class kr 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 ta=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Us=new Map;function sa(e){const s=e.match(ta);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 na(e,s,n){const r=`${e}:${s}`;if(Us.has(r))return Us.get(r);try{const o=s==="0x1"?"0x1.json":`${e}/${s}.json`,a=`${n}/errors/${o}`,{errors:i={}}=await X.get(a).json();return Us.set(r,i),i}catch{return null}}function ra(e,s,n,r,o,a,i){return new kr(e,s,n,r,o,a,i)}async function Ct(e,s,n){if(!s.metadata?.is_l1&&s.metadata?.minitia?.type!=="minimove")return await Re(e);const r=sa(e.message);if(!r)return await Re(e);const o=await na(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 ra(c,e,r.moduleAddress,r.moduleName,r.errorCode,a,d)}const wn=qe.createQueryKeys("interwovenkit:chain",{list:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function ss(e){const s=b.path([0,"address"],e);if(!s)throw new Error("URL not found");return s}function oa(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,_=ss(d),g=ss(u),p=ss(m),y=i?.minitia?.type==="minievm"?ss(h):void 0;return{...e,chainId:s,name:l,logoUrl:c,rpcUrl:_,restUrl:g,indexerUrl:p,jsonRpcUrl:y}}function ne(){const{defaultChainId:e,registryUrl:s,customChain:n}=ie(),{data:r}=q.useSuspenseQuery({queryKey:wn.list(s).queryKey,queryFn:()=>X.create({prefixUrl:s}).get("chains.json").json(),select:o=>(n?[n,...o.filter(i=>i.chain_id!==n.chain_id)]:o).map(oa).toSorted(b.descend(i=>i.chainId===e)),staleTime:z.MINUTE});return r}function Xe(){const e=ne();return s=>{const n=e.find(r=>r.chain_id===s);if(!n)throw new Error(`Chain not found: ${s}`);return n}}function Me(e){return Xe()(e)}function Vt(){const{defaultChainId:e}=ie();return Me(e)}function ye(){const s=ne().find(n=>n.metadata?.is_l1);if(!s)throw new Error("Layer 1 not found");return s}function Ar(){return({chainId:e})=>q.queryOptions({queryKey:wn.prices(e).queryKey,queryFn:()=>X.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:z.SECOND})}function Is(e){const s=Ar();return q.useQuery(s(e))}function aa(){const e=ne(),s=Ar();return q.useQueries({queries:e.map(n=>s(n))})}function ia(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:s}=dn.PubKey.decode(e.value);return zt.encodeSecp256k1Pubkey(s)}return ys.decodeOptionalPubkey(e)}function ca({typeUrl:e,value:s}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:n,pubKey:r,accountNumber:o,sequence:a}=Oo.BaseAccount.decode(s),i=ia(r);return{address:n,pubkey:i,accountNumber:Number(o),sequence:Number(a)}}return $e.accountFromAny({typeUrl:e,value:s})}function la(e){return e.type==="initia/PubKeyEthSecp256k1"}const da={...zt.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function ua(e){if(la(e)){const s=dn.PubKey.fromPartial({key:W.fromBase64(e.value)});return Lo.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(dn.PubKey.encode(s).finish())})}return ys.encodePubkey(e)}function $r(e){if(e.length!==33||e[0]!==2&&e[0]!==3)throw new Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03");return{type:da.ethsecp256k1,value:W.toBase64(e)}}function ha(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:$r(e),signature:W.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`},Ns=()=>{const e=ie();return new ys.Registry([...Kt.protoRegistry,...e.protoTypes??[]])},Ss=()=>{const e=ie();return new $e.AminoTypes({...Kt.aminoConverters,...e.aminoConverters})};class ma{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=W.fromHex(n),W.fromHex(n);const r=await this.getPublicKey();return this.cachedPublicKey=r,localStorage.setItem(s,W.toHex(r)),r}async getPublicKey(){const s="Sign this message to identify your Initia account.",n=await this.signMessage(s),r=Je.ethers.hashMessage(s),o=Je.ethers.SigningKey.recoverPublicKey(r,n);return ln.Secp256k1.compressPubkey(W.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=cn.escapeCharacters(cn.sortedJsonStringify(n)),o=await this.signMessage(r),a=W.fromHex(o.replace("0x","")).subarray(0,-1),l=ln.Secp256k1Signature.fromFixedLength(a).toFixedLength(),c=ha(await this.getCachedPublicKey(),l);return{signed:n,signature:c}}}function Cn(){const e=Ns(),s=Ss(),n=At(),r=Er();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),[g]=await n.getAccounts(),p=ua($r(g.pubkey)),y=Mo.SignMode.SIGN_MODE_EIP_191,k=i.map(x=>s.toAmino(x)),S=cn.makeSignDoc(k,l,o,c,h,_),{signature:$,signed:v}=await n.signAmino(a,S),R={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:v.msgs.map(x=>s.fromAmino(x)),memo:c}},B=e.encode(R),C=Mn.Int53.fromString(v.fee.gas).toNumber(),j=Mn.Int53.fromString(v.sequence).toNumber(),I=ys.makeAuthInfoBytes([{pubkey:p,sequence:j}],v.fee.amount,C,v.fee.granter,v.fee.payer,y);return Ge.TxRaw.fromPartial({bodyBytes:B,authInfoBytes:I,signatures:[W.fromBase64($.signature)]})}}function At(){const e=re(),{signMessageAsync:s}=xe.useSignMessage();return f.useMemo(()=>new ma(e,n=>s({message:n})),[e,s])}const zs=new Map,Ks=new Map;function Tr(){const e=Xe();return async s=>{if(zs.has(s))return zs.get(s);const{rpcUrl:n}=e(s),r=await On.Comet38Client.create(new On.HttpClient(n));return zs.set(s,r),r}}function Er(){const e=Ns(),s=Ss(),n=At(),r=re(),o=Tr();return async a=>{const i=`${r}:${a}`;if(Ks.has(i))return Ks.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:ca,broadcastPollIntervalMs:500});return Ks.set(i,c),c}}function qr(){const{connector:e}=xe.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new Je.BrowserProvider(await e.getProvider())}}const _a="c33b940c24c17e95f7d9d525d508ac61";function fa(){const{disableAnalytics:e}=ie();f.useEffect(()=>{e||vn.init(_a,{autocapture:!1})},[e])}function pa(){const{connector:e}=xe.useAccount(),{defaultChainId:s,disableAnalytics:n}=ie();f.useEffect(()=>{const r=new gr.Identify;e?.name&&r.set("connector",e.name),s&&r.set("defaultChainId",s),vn.identify(r)},[s,e?.name,n])}function ks(){const e=ws();return f.useCallback((n,r)=>{vn.track(n,{path:e,...r})},[e])}const ga=V.atom(!1);function $t(){const e=Cr(),[s,n]=V.useAtom(ga),r=ks();return{isDrawerOpen:s,openDrawer:(i,l)=>{i&&e(i,l),n(!0),r("Widget Opened")},closeDrawer:()=>{n(!1),r("Widget Closed")}}}function Dr(){const e=de(),{closeDrawer:s}=$t(),{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 Pr="approve",As=V.atom(),Rr=V.atom(null);function Br(){const e=V.useAtomValue(As);if(!e)throw new Error("Tx request not found");return e}function Fr(){const e=de(),s=re(),{defaultChainId:n,registryUrl:r}=ie(),o=Xe(),{openDrawer:a,closeDrawer:i}=$t(),{openModal:l,closeModal:c}=Cs(),d=V.useSetAtom(As),u=V.useSetAtom(Rr),h=Tr(),m=Er(),_=At(),g=Ns(),p=async({messages:C,memo:j,chainId:I=n})=>{try{return await(await m(I)).simulate(s,C,j)}catch(x){throw await Ct(x,o(I),r)}},y=async({messages:C,memo:j,chainId:I=n})=>{const x=await h(I),E=$e.QueryClient.withExtensions(x,$e.setupTxExtension),N=C.map(oe=>g.encodeAsAny(oe)),[F]=await _.getAccounts(),A=zt.encodeSecp256k1Pubkey(F.pubkey),H=await m(I),{sequence:U}=await H.getSequence(s);return E.tx.simulate(N,j,A,U)},k=async({txRequest:C,broadcaster:j})=>{const x={...{memo:"",chainId:n,gas:C.gas||await p(C),gasAdjustment:Ht,gasPrices:null,spendCoins:[],internal:!1},...C};return new Promise((E,N)=>{d({txRequest:x,resolve:async A=>{try{const H=await m(x.chainId),U=await j(H,Ge.TxRaw.encode(A).finish());E(U),typeof x.internal=="string"&&e(x.internal)}catch(H){N(await Ct(H,o(x.chainId),r))}finally{F()}},reject:A=>{N(A),F()}}),x.internal?l({path:"/tx"}):a("/tx");const F=()=>{if(!x.internal){e("/blank"),i();return}c()}})},S=async C=>{const j=C.chainId??n;try{const I=await k({txRequest:C,broadcaster:async(x,E)=>await x.broadcastTxSync(E)});return C.internal&&typeof C.internal!="number"&&(u({txHash:I,chainId:j,status:"loading"}),B({txHash:I,chainId:C.chainId}).then(x=>{u({status:x.code===0?"success":"error",chainId:j,txHash:I})}).catch(()=>{u({status:"error",chainId:j,txHash:I})})),I}catch(I){throw C.internal&&typeof C.internal!="number"&&u({status:"error",chainId:j,error:I}),I}},$=(C,j=30*1e3,I=.5*1e3)=>k({txRequest:C,broadcaster:async(x,E)=>{const N=await x.broadcastTx(E,j,I);if(N.code!==0)throw new Error(N.rawLog);return N}}),v=Cn(),D=async C=>{const j=C.chainId??n;try{const{messages:I,memo:x="",fee:E}=C,N=await m(j),F=await v(j,s,I,E,x);return await N.broadcastTxSync(Ge.TxRaw.encode(F).finish())}catch(I){throw await Ct(I,o(j),r)}},R=async(C,j=30*1e3,I=.5*1e3)=>{const x=C.chainId??n;try{const{messages:E,memo:N="",fee:F}=C,A=await m(x),H=await v(x,s,E,F,N),U=await A.broadcastTx(Ge.TxRaw.encode(H).finish(),j,I);if(U.code!==0)throw new Error(U.rawLog);return U}catch(E){throw await Ct(E,o(x),r)}},B=async({chainId:C=n,...j})=>{try{const I=await m(C);return await Mr({...j,client:I})}catch(I){throw await Ct(I,o(C),r)}};return{estimateGas:p,simulateTx:y,requestTxSync:S,requestTxBlock:$,submitTxSync:D,submitTxBlock:R,waitForTxConfirmation:B}}async function Mr({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 xa(e){return e.pagination?.next_key??null}async function Or(e,s,n){const r=X.create(s),o=async(a,i)=>{const l=await r.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[n]??[],d=xa(l),u=[...a,...c];return d?o(u,d):u};return o([],null)}const ya=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Lo=require("@privy-io/cross-app-connect/rainbow-kit"),de=require("wagmi"),$=require("@tanstack/react-query"),v=require("@initia/utils"),F=require("bignumber.js"),b=require("ramda"),$e=require("@lukemorales/query-key-factory"),z=require("ky"),_=require("react"),V=require("@cosmjs/encoding"),ya=require("@mysten/bcs"),G=require("jotai"),zo=require("@amplitude/analytics-browser"),t=require("react/jsx-runtime"),yn=require("@cosmjs/amino/build/signdoc"),jn=require("@cosmjs/crypto"),so=require("@cosmjs/math"),Cs=require("@cosmjs/proto-signing"),Pe=require("@cosmjs/stargate"),no=require("@cosmjs/tendermint-rpc"),ja=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),st=require("cosmjs-types/cosmos/tx/v1beta1/tx"),We=require("ethers"),Ht=require("@initia/amino-converter"),Qt=require("@cosmjs/amino"),va=require("cosmjs-types/cosmos/auth/v1beta1/auth"),vn=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),wa=require("cosmjs-types/google/protobuf/any"),ke=require("date-fns"),qn=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),oo=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),ro=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),Ko=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),te=require("radix-ui"),Ie=require("usehooks-ts"),Wo=require("react-error-boundary"),D=require("clsx"),Se=require("@base-ui-components/react/dialog"),ba=require("xss"),N=require("@initia/icons-react"),ot=require("@react-spring/web"),Is=require("change-case"),Le=require("@base-ui-components/react/select"),Js=require("@base-ui-components/react/collapsible"),ao=require("nanoid"),Ca=require("react-dom"),ue=require("react-hook-form"),Ia=require("jotai/utils"),Ho=require("react-merge-refs"),Na=require("react-intersection-observer"),Sa=require("@noble/hashes/sha3"),_t=require("@noble/hashes/utils"),ka=require("qr-code-styling"),Ke=require("@base-ui-components/react"),Ze=require("@base-ui-components/react/tabs"),It=require("@base-ui-components/react/popover"),io=require("cosmjs-types/cosmos/bank/v1beta1/tx");function Aa(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(s,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return s.default=e,Object.freeze(s)}const Dn=Aa(zo),Vt=1.4,Qo=1.05,Vo={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",glyphUrl:"https://glyph.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",theme:"dark"},$a={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",glyphUrl:"https://glyph.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",theme:"dark",disableAnalytics:!0},Pn="cmbq1ozyc006al70lx4uciz0q",Ns={id:Pn,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Ta=Lo.toPrivyWalletConnector(Ns),Ea=Lo.toPrivyWallet(Ns),Go=_.createContext(null);function X(){const e=_.useContext(Go);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const W={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function qa(e){if(e instanceof z.HTTPError){const{response:s}=e,n=s.headers.get("content-type")??"";if(b.includes("application/json",n))try{const o=await s.json();if(o.message)return o.message}catch{return e.message}try{return await s.text()}catch{return e.message}}if(e instanceof Error){if(b.path(["code"],e)===4001||b.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const s=b.path(["error","message"],e),n=b.path(["cause","message"],e),o=b.path(["shortMessage"],e);return s||n||o||e.message}return String(e)}async function He(e){return new Error(await qa(e))}const Ss=$e.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function as(e){const s=b.path([0,"address"],e);if(!s)throw new Error("URL not found");return s}function Da(e){const{chain_id:s,chain_name:n,pretty_name:o,logo_URIs:r,apis:a,metadata:i}=e,c=o||n,l=r?.png??"",{rpc:d,rest:u,["json-rpc"]:m,indexer:h}=a,f=as(d),p=as(u),g=as(h),y=i?.minitia?.type==="minievm"?as(m):void 0;return{...e,chainId:s,name:c,logoUrl:l,rpcUrl:f,restUrl:p,indexerUrl:g,jsonRpcUrl:y}}function re(){const{defaultChainId:e,registryUrl:s,customChain:n}=X(),{data:o}=$.useSuspenseQuery({queryKey:Ss.list(s).queryKey,queryFn:()=>z.create({prefixUrl:s}).get("chains.json").json(),select:r=>(n?[n,...r.filter(i=>i.chain_id!==n.chain_id)]:r).map(Da).toSorted(b.descend(i=>i.chainId===e)),staleTime:W.MINUTE});return o}function Yo(){const{registryUrl:e}=X(),{data:s}=$.useSuspenseQuery({queryKey:Ss.profiles(e).queryKey,queryFn:()=>z.create({prefixUrl:e}).get("profiles.json").json(),staleTime:W.MINUTE});return s}function Te(){const e=_e(),s=re(),n=Yo();return o=>{const r=s.find(i=>i.chain_id===o);if(r)return r;const a=n.find(i=>i.chain_id===o);if(!a)throw new Error(`Chain not found: ${o}`);return{chain_id:a.chain_id,chain_name:a.name,pretty_name:a.pretty_name,network_type:e.network_type,bech32_prefix:"init",fees:{fee_tokens:[]},apis:{rpc:[],rest:[],indexer:[]},chainId:o,name:a.pretty_name,logoUrl:a.logo,rpcUrl:"",restUrl:"",indexerUrl:"",jsonRpcUrl:""}}}function Me(e){return Te()(e)}function Zt(){const{defaultChainId:e}=X();return Me(e)}function _e(){const s=re().find(n=>n.metadata?.is_l1);if(!s)throw new Error("Layer 1 not found");return s}function Jo(){return({chainId:e})=>$.queryOptions({queryKey:Ss.prices(e).queryKey,queryFn:()=>z.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:W.SECOND})}function ks(e){const s=Jo();return $.useQuery(s(e))}function Pa(){const e=re(),s=Jo();return $.useQueries({queries:e.map(n=>s(n))})}const Ra=`<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>`,ja=encodeURIComponent(ya),In=`data:image/svg+xml;utf8,${ja}`,_s=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 va(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??b.head(r)?.exponent??0,u=a?.png??"";return{denom:s,symbol:n,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function Lr(){const e=q.useQueryClient();return s=>{const n=s?.metadata?.assetlist;return q.queryOptions({queryKey:_s.list(n).queryKey,queryFn:async()=>n?X.get(n).json():{assets:[]},select:({assets:r})=>{if(!s)return[];const o=r.map(va);for(const a of o)e.setQueryData(_s.item(s.chainId,a.denom).queryKey,a);return o},staleTime:z.MINUTE})}}function Wt(e){const s=Lr(),{data:n}=q.useSuspenseQuery(s(e));return n}function ba(){const e=ne(),s=Lr();return q.useQueries({queries:e.map(n=>s(n))})}function Oe(e){const s=Wt(e),n=ye(),r=Wt(n),o=zr(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:In}}}function Ur(e,s){const n=Oe(s),o=q.useQueryClient().getQueryData(_s.item(s.chainId,e).queryKey);return o||n(e)}function zr(e){const s=ye(),n=Wt(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?w.getIbcDenom(o,r):""}}const zn="usernames";function wa({restUrl:e,moduleAddress:s}){const{viewFunction:n}=w.createMoveClient(e);async function r(i){if(!w.InitiaAddress.validate(i))return null;const l=await n({moduleAddress:s,moduleName:zn,functionName:"get_name_from_address",typeArgs:[],args:[W.toBase64(w.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:zn,functionName:"get_address_from_name",typeArgs:[],args:[Uo.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return l?w.InitiaAddress(l).bech32:null}return{restUrl:e,getUsername:r,getAddress:a,validateUsername:o}}const $s=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 Kr(){const{restUrl:e}=ye(),{usernamesModuleAddress:s}=ie();return wa({restUrl:e,moduleAddress:s})}function Hr(){const e=re();return s=>q.queryOptions({queryKey:$s.balances(s.restUrl,e).queryKey,queryFn:()=>Or(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:s.restUrl},"balances"),staleTime:z.SECOND})}function Nn(e){const s=Hr(),{data:n}=q.useSuspenseQuery(s(e));return n}function Ca(){const e=ne(),s=Hr();return q.useQueries({queries:e.map(n=>s(n))})}function Ia(e){const s=Nn(e),n=Wt(e),r=Oe(e),o=zr(e),{data:a}=Is(e),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>n.some(d=>d.denom===c);return b.sortWith([b.descend(({denom:c})=>o(c)==="uinit"),b.descend(({denom:c})=>i(c)),b.descend(({value:c})=>c),b.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>M(d).comparedTo(c)??0,b.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 Na="INIT",Sa="Initia";function Sn(e){return e.assets.reduce((s,{value:n})=>s+(n??0),0)}function ka(e){return e.assets.reduce((s,{quantity:n})=>s.plus(n),M(0)).toString()}function Aa(e,s){return{symbol:s?.symbol??e,logoUrl:s?.logoUrl??In}}function Kn(e){return b.pick(["chainId","name","logoUrl"],e)}function $a(e){return b.sortWith([b.descend(({symbol:s})=>s===Na),b.descend(Sn),b.descend(({assets:s})=>s.length),b.ascend(({symbol:s})=>s)])(e)}function Ta(e){return b.sortWith([b.descend(({value:s})=>s??0),b.descend(({quantity:s})=>Number(s)),b.ascend(({chain:s})=>s.name)])(e)}function Ea(e){return b.sortWith([b.descend(({chain:s})=>s.name===Sa),b.ascend(({chain:s})=>s.name),b.ascend(({denom:s})=>s)])(e)}function qa(e,s){return b.sortWith([b.descend(({chainId:n})=>n===s),b.descend(b.prop("value"))])(e)}function Da(e,s,n,r,o){const a={};for(const u of e){const h=u.chainId,m=s[h]??[],_=n[h],g=r[h],p=[];for(const{amount:y,denom:k}of m){if(!M(y).gt(0))continue;const S=_?.find(B=>B.denom===k),$=g?.find(B=>B.id===k)?.price,v=S?.decimals??0,D=w.fromBaseUnit(y,{decimals:v}),R=$?M(D).times($).toNumber():void 0;p.push({...Aa(k,S),amount:y,denom:k,decimals:v,quantity:D,price:$,value:R,address:S?.address,unlisted:!S,chain:Kn(u)})}a[h]=p}const i=new Map;for(const[u,h]of Object.entries(a)){if(h.length===0)continue;const m=e.find(g=>g.chainId===u);if(!m)continue;const _=h.reduce((g,{value:p})=>g+(p??0),0);i.set(u,{...Kn(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=b.head(h);if(!m)continue;const _=Ta(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:qa(Array.from(i.values()),o),assetGroups:$a(c),unlistedAssets:Ea(d),totalValue:c.reduce((u,h)=>u+Sn(h),0)}}function kn(){const{defaultChainId:e}=ie(),s=ne(),n=Ca(),r=ba(),o=aa(),a=s.map(m=>m.chainId),i=b.zipObj(a,n.map(b.prop("data"))),l=b.zipObj(a,r.map(b.prop("data"))),c=b.zipObj(a,o.map(b.prop("data"))),d=Da(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 re(){const e=Ts();return e?w.InitiaAddress(e).bech32:""}function Ts(){const{address:e}=xe.useAccount();return e?w.InitiaAddress(e).hex:""}function Tt(){const e=Vt(),s=re(),n=Ts();return e.metadata?.minitia?.type==="minievm"?n:s}function Wr(){const e=Tt(),s=Kr();return q.useQuery({queryKey:$s.username(s.restUrl,e).queryKey,queryFn:()=>s.getUsername(e),enabled:!!e,staleTime:z.MINUTE})}function je(){const e=Tt(),s=re(),n=Ts(),{data:r}=Wr(),o=At(),a=Dr(),{isDrawerOpen:i,openDrawer:l}=$t(),c=()=>{l("/")},d=()=>{l("/connect")},u=_=>{l("/bridge",_)},h=Fr();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 Pa(){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=>w.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 Ra="_status_tn9m1_1",Ba="_error_tn9m1_9",Hn={status:Ra,error:Ba},Z=({error:e,children:s})=>t.jsx("p",{className:P(Hn.status,{[Hn.error]:e}),children:s}),he=({errorBoundaryProps:e={fallbackRender:({error:r})=>t.jsx(Z,{error:!0,children:r.message})},suspenseFallback:s=t.jsx(Z,{children:"Loading..."}),children:n})=>t.jsx(xr.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 Le(){const{routerApiUrl:e}=ie();return f.useMemo(()=>X.create({prefixUrl:e}),[e])}function Qr(){const e=ne();return s=>e.some(n=>n.chain_id===s)}function Gt(){const e=Qr();return s=>e(s.chain_id)?"initia":s.chain_type}function Qt(e){return Gt()(e)}function An(){const e=Le(),{data:s}=q.useSuspenseQuery({queryKey:Te.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:n})=>b.sortWith([b.descend(({chain_name:r})=>r==="initia"),b.ascend(({pretty_name:r})=>r)],n),staleTime:z.MINUTE});return s}function _t(){const e=An();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 _t()(e)}function St(e){const s=Le(),n=q.useQueryClient(),{data:r}=q.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(b.descend(i=>i.symbol==="INIT"))},staleTime:z.MINUTE});return r}function Vr(e){const s=St(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 Vr(s)(e)}const $n=f.createContext(null);function ut(){const{container:e}=f.useContext($n);return e}function Gr(e){const s=ut();return s?getComputedStyle(s).getPropertyValue(e):""}const Fa=({children:e})=>{const[s,n]=f.useState(null);return t.jsx($n.Provider,{value:{container:s,setContainer:n},children:e})},Ma="_loader_4gdsk_1",Oa={loader:Ma},ft=({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:Oa.loader,style:r})},La="_container_1zg8z_1",Ua="_toast_1zg8z_10",za="_info_1zg8z_23",Ka="_success_1zg8z_27",Ha="_error_1zg8z_31",Wa="_icon_1zg8z_36",Qa="_content_1zg8z_43",Va="_title_1zg8z_46",Ga="_description_1zg8z_51",Ya="_close_1zg8z_72",We={container:La,toast:Ua,info:za,success:Ka,error:Ha,icon:Wa,content:Qa,title:Va,description:Ga,close:Ya},Ja=({notification:e,onClose:s,...n})=>{const r=Ze.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(ft,{size:16});case"info":case"success":return t.jsx(T.IconCheckCircleFilled,{size:16});case"error":return t.jsx(T.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(Ze.animated.div,{style:a,className:We.container,children:t.jsxs("div",{className:P(We.toast,l&&We[l]),...n,children:[u&&t.jsx("div",{className:We.icon,children:u}),t.jsxs("div",{className:We.content,children:[t.jsx("p",{className:We.title,children:c}),d&&t.jsx("div",{className:We.description,children:d})]}),t.jsx("button",{className:We.close,onClick:s,children:t.jsx(T.IconClose,{size:14})})]})})})},Yr=f.createContext(null),Tn=()=>f.useContext(Yr),Hs=5e3,Za=({children:e})=>{const s=ut(),[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:Ln.nanoid()}),m.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Hs))},[l]),d=f.useCallback(m=>{i(),r(_=>_?{..._,...m}:{...m,id:Ln.nanoid()}),m.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Hs))},[l]),u=()=>{i(),a.current=!0},h=()=>{i(),a.current=!1,n?.autoHide&&(o.current=setTimeout(()=>l(),Hs))};return f.useEffect(()=>()=>i(),[]),t.jsxs(Yr.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,s&&zo.createPortal(t.jsx(Ja,{notification:n,onClose:l,onMouseEnter:u,onMouseLeave:h}),s)]})},Jr=f.createContext(!1),Xa="_overlay_2lgi8_1",ei="_fullscreen_2lgi8_15",ti="_content_2lgi8_19",si="_header_2lgi8_54",ni="_title_2lgi8_63",ri="_close_2lgi8_68",nt={overlay:Xa,fullscreen:ei,content:ti,header:si,title:ni,close:ri},Zr=({title:e,children:s,trigger:n,className:r,open:o,onOpenChange:a})=>{const i=ut(),l=f.useContext(Jr);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:P(nt.overlay,{[nt.fullscreen]:l}),onClick:()=>a(!1),forceRender:!0}),t.jsxs(we.Dialog.Popup,{className:P(nt.content,{[nt.fullscreen]:l}),children:[e&&t.jsxs("header",{className:nt.header,children:[t.jsx(we.Dialog.Title,{className:nt.title,children:e}),t.jsx(we.Dialog.Close,{className:nt.close,children:t.jsx(T.IconClose,{size:20})})]}),s]})]})]}):null},oi=10;function Xr(){const e=re();return(s,n)=>q.queryOptions({queryKey:$s.txs(s.indexerUrl,e).queryKey,queryFn:async()=>{if(!n.enabled)return[];const r={"pagination.reverse":!0,"pagination.limit":oi},{txs:o}=await X.create({prefixUrl:s.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:r}).json();return o},staleTime:z.SECOND})}function ai(e,s){const n=Xr();return q.useSuspenseQuery(n(e,s))}function ii(e,s){const n=e.flatMap((r,o)=>(s[o]??[]).map(i=>({...i,chain:r})));return b.sortWith([b.descend(r=>new Date(r.timestamp).getTime())])(n)}const ci=()=>{const e=ne(),s=Xr(),n=q.useQueries({queries:e.map(i=>s(i,{enabled:!0}))}),r=n.map(b.prop("data")),o=ii(e,r),a=n.some(i=>i.isLoading);return{activities:o,isLoading:a}};function eo(e){const{data:s}=q.useSuspenseQuery({queryKey:wn.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:r}=await X.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return r.toSorted(b.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const i=o==="uinit"?1:jr;return{amount:M(a).times(i).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:r})=>{if(b.isNil(r))throw new Error(`${n} has no price`);return{amount:String(r),denom:n}})},staleTime:z.SECOND});return s}function to(e){const s=re(),{data:n}=ai(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=>w.InitiaAddress.equals(s,Je.computeAddress(`0x${W.toHex(ln.Secp256k1.uncompressPubkey(W.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??r}catch{return r}}const li="_root_hypwm_1",di="_item_hypwm_10",ui="_chevron_hypwm_14",hi="_trigger_hypwm_19",mi="_content_hypwm_39",Pt={root:li,item:di,chevron:ui,trigger:hi,content:mi};function _i(e){const{list:s,getKey:n,renderHeader:r,renderContent:o,footer:a,...i}=e;return t.jsxs(G.Accordion.Root,{className:Pt.root,type:"multiple",...i,children:[s.map((l,c)=>t.jsxs(G.Accordion.Item,{className:Pt.item,value:n?.(l)??String(c),children:[t.jsx(G.Accordion.Header,{children:t.jsxs(G.Accordion.Trigger,{className:Pt.trigger,children:[r(l),t.jsx(T.IconChevronDown,{className:Pt.chevron,size:16})]})}),t.jsx(G.Accordion.Content,{className:Pt.content,children:o(l)})]},n?.(l)??c)),a]})}const fi="_scrollable_abvhw_1",pi={scrollable:fi},Ue=({className:e,children:s,ref:n})=>t.jsx("div",{ref:n,className:P(pi.scrollable,e),children:s}),un=({children:e})=>{const s=f.useRef(null),[n,r]=f.useState(0),o=Ze.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(Ze.animated.div,{style:{overflow:"hidden",...o},children:t.jsx("div",{ref:s,children:e})}):null},gi="_help_7m3jv_1",xi="_icon_7m3jv_10",yi="_info_7m3jv_17",ji="_warning_7m3jv_21",vi="_error_7m3jv_25",bi="_success_7m3jv_31",Ws={help:gi,icon:xi,info:yi,warning:ji,error:vi,success:bi},Ve=({level:e,className:s,mt:n=8,children:r})=>{if(!r)return null;const o=()=>{switch(e){case"loading":return t.jsx(ft,{size:12});case"info":return t.jsx(T.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(T.IconWarningFilled,{size:12});default:return t.jsx(T.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:P(Ws.help,e&&Ws[e],s),style:{marginTop:n},children:[t.jsx("div",{className:Ws.icon,children:o()}),r]})},wi="_stack_14kq8_1",Ci="_help_14kq8_6",Ii="_info_14kq8_14",Ni="_warning_14kq8_19",Si="_error_14kq8_24",ki="_success_14kq8_29",hn={stack:wi,help:Ci,info:Ii,warning:Ni,error:Si,success:ki},Ai=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(un,{children:t.jsx("div",{className:hn.stack,children:e})}),te=e=>t.jsx(Ve,{...e,className:P(hn.help,hn[e.level]),mt:0});te.Stack=Ai;const $i="_footer_xif7g_1",Ti="_actions_xif7g_10",Wn={footer:$i,actions:Ti},se=({extra:e,className:s,children:n})=>t.jsxs("footer",{className:P(Wn.footer,s),children:[e,t.jsx("div",{className:Wn.actions,children:n})]}),Ei="_button_1n7c4_1",qi="_outline_1n7c4_25",Di="_sm_1n7c4_43",Pi="_full_1n7c4_49",Ri="_small_1n7c4_53",Bi="_unpadded_1n7c4_83",ct={button:Ei,outline:qi,sm:Di,full:Pi,small:Ri,unpadded:Bi},so=e=>{const{sm:s,fullWidth:n,loading:r,className:o,children:a,disabled:i,...l}=e;return t.jsx("button",{...l,className:P(ct.button,{[ct.sm]:s,[ct.full]:n},o),disabled:!!r||i,children:r?t.jsxs(t.Fragment,{children:[t.jsx(ft,{color:"currentColor",size:16}),typeof r=="string"&&t.jsx("span",{className:ct.loading,children:r})]}):a})},Fi=({className:e,...s})=>t.jsx(so,{...s,className:P(ct.outline,e)}),Mi=({className:e,unpadded:s,...n})=>t.jsx("button",{...n,className:P(ct.small,{[ct.unpadded]:s},e)}),Q={White:so,Outline:Fi,Small:Mi},Oi="_item_1n572_1",Li="_title_1n572_10",Ui="_content_1n572_14",Qs={item:Oi,title:Li,content:Ui},Vs=({title:e,content:s})=>t.jsxs("div",{className:Qs.item,children:[t.jsx("div",{className:Qs.title,children:e}),t.jsx("div",{className:Qs.content,children:s})]});function Fe(e){if(e&&M(e).gt(0)&&M(e).lt(.01))return"<$0.01";const s=w.formatNumber(e,{dp:2});return s?`$${s}`:""}const zi="_placeholder_10r3x_1",Ki="_logo_10r3x_5",Qn={placeholder:zi,logo:Ki},K=({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:P(Qn.placeholder,r?.placeholder),style:{width:d,height:u,...o}});return f.useEffect(()=>{c(!1)},[e]),!e||l?h:t.jsx("img",{...i,className:P(i.className,{[Qn.logo]:a}),style:{width:d,height:u,...o},src:e,alt:s,loading:"lazy",onError:()=>c(!0)})};function no(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 ro(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&&w.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&&w.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 oo=({metadata:e,chain:s,children:n})=>{const{restUrl:r}=s,{data:o}=q.useSuspenseQuery({queryKey:_s.denom(r,e).queryKey,queryFn:()=>X.create({prefixUrl:r}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:a})=>a,staleTime:z.INFINITY});return n(o)},Hi="_root_jioyr_1",Wi="_title_jioyr_7",Qi="_changes_jioyr_13",Vi="_change_jioyr_13",Gi="_amount_jioyr_34",Yi="_text_jioyr_40",Ji="_value_jioyr_47",lt={root:Hi,title:Wi,changes:Qi,change:Vi,amount:Gi,text:Yi,value:Ji},ao=({amount:e,asset:s,price:n})=>{const{denom:r,symbol:o,decimals:a,logoUrl:i}=s,l=w.formatAmount(e,{decimals:a}),c=n&&M(w.fromBaseUnit(e,{decimals:a})).times(n).abs();return t.jsxs("div",{className:lt.change,children:[t.jsxs("div",{className:lt.amount,children:[t.jsx(K,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:lt.text,children:[l," ",o||r]})]}),c&&t.jsx("div",{className:lt.value,children:Fe(c)})]})},Zi=({changes:e,chain:s})=>{const n=Oe(s),{data:r}=Is(s);return e.map(({amount:o,denom:a},i)=>{const l=n(a),c=r?.find(({id:d})=>d===a)?.price;return t.jsx(ao,{amount:o,asset:l,price:c},i)})},Xi=({changes:e,chain:s})=>{const n=Oe(s),{data:r}=Is(s);return e.map(({amount:o,metadata:a},i)=>t.jsx(oo,{metadata:a,chain:s,children:l=>{const c=r?.find(({id:d})=>d===l)?.price;return t.jsx(ao,{amount:o,asset:n(l),price:c})}},i))};function ec(e,s){return typeof s=="bigint"?s.toString():s}const tc=qe.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,ec)]}),sc=({messages:e,memo:s,chainId:n})=>{const{initiaAddress:r,hexAddress:o}=je(),a=Me(n),{simulateTx:i}=Fr(),{data:l}=q.useSuspenseQuery({queryKey:tc.simulate({messages:e,memo:s,chainId:n}).queryKey,queryFn:()=>i({messages:e,memo:s,chainId:n}),staleTime:z.SECOND}),c=m=>t.jsxs("div",{className:lt.root,children:[t.jsx("h2",{className:lt.title,children:"Estimated changes"}),t.jsx("div",{className:lt.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=ro(d,o),[_]=Vn(m);return _.length===0?null:c(t.jsx(Xi,{changes:_,chain:a}))}const u=no(d,r),[h]=Vn(u);return h.length===0?null:c(t.jsx(Zi,{changes:h,chain:a}))};function Vn(e){return b.partition(s=>new M(s.amount).isNegative(),e)}const nc="_value_9u3br_1",rc="_trigger_9u3br_7",oc="_icon_9u3br_23",ac="_content_9u3br_32",ic="_item_9u3br_40",Rt={value:nc,trigger:rc,icon:oc,content:ac,item:ic},cc=({options:e,value:s,onChange:n})=>{const r=ut(),{txRequest:o}=Br(),a=Me(o.chainId),i=Oe(a),l=(p,y)=>{if(w.formatAmount(p,{decimals:y})==="0.000000")return 8},c=({amount:[{amount:p,denom:y}]})=>{if(M(p).isZero())return"0";const{symbol:k,decimals:S}=i(y),$=l(p,S);return`${w.formatAmount(p,{decimals:S,dp:$})} ${k}`};if(e.length===1)return t.jsx("span",{className:"monospace",children:c(e[0])});const d=e.find(p=>p.amount[0].denom===s);if(!d)throw new Error("Fee option not found");const[{amount:u,denom:h}]=d.amount,{decimals:m,symbol:_}=i(h),g=l(u,m);return t.jsxs(De.Select.Root,{value:s,onValueChange:n,modal:!1,children:[t.jsxs("div",{className:Rt.value,children:[t.jsx("span",{className:"monospace",children:w.formatAmount(u,{decimals:m,dp:g})}),t.jsxs(De.Select.Trigger,{className:Rt.trigger,children:[t.jsx(De.Select.Value,{children:_}),t.jsx(De.Select.Icon,{className:Rt.icon,children:t.jsx(T.IconChevronDown,{size:16})})]})]}),t.jsx(De.Select.Portal,{container:r,children:t.jsx(De.Select.Positioner,{className:Rt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(De.Select.Popup,{children:e.map(p=>{const[{denom:y}]=p.amount;return t.jsx(De.Select.Item,{className:Rt.item,value:y,children:t.jsx(De.Select.ItemText,{children:c(p)})},y)})})})})]})},lc="_root_7u427_1",dc="_trigger_7u427_5",uc="_chevron_7u427_13",hc="_panel_7u427_27",mc="_details_7u427_38",_c="_row_7u427_47",bt={root:lc,trigger:dc,chevron:uc,panel:hc,details:mc,row:_c},fc=({spend:e,fee:s,total:n,balance:r,symbol:o,decimals:a})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:s},e&&{label:"Required (spend + fee)",value:n},{label:"Balance",value:r}].filter(Boolean),l=a===6?void 0:8;return t.jsxs(Ls.Collapsible.Root,{className:bt.root,children:[t.jsxs(Ls.Collapsible.Trigger,{className:bt.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(T.IconChevronDown,{className:bt.chevron,size:16})]}),t.jsx(Ls.Collapsible.Panel,{className:bt.panel,children:t.jsx("div",{className:bt.details,children:i.map(({label:c,value:d})=>t.jsxs("div",{className:bt.row,children:[t.jsx("span",{children:c}),t.jsxs("span",{children:[w.formatAmount(d,{decimals:a,dp:l})," ",o]})]},c))})})]})};function fs(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?W.toBase64(e):Array.isArray(e)?`[${e.map(fs).join(",")}]`:JSON.stringify(e,(s,n)=>typeof n=="bigint"?n.toString():n);default:return"unknown"}}const pc="_container_1xzyq_1",gc="_toggle_1xzyq_5",xc="_list_1xzyq_11",yc="_arg_1xzyq_16",jc="_type_1xzyq_21",Bt={container:pc,toggle:gc,list:xc,arg:yc,type:jc},vc=qe.createQueryKeys("interwovenkit:move",{abi:(e,s,n,r)=>[e,s,n,r]}),bc=({type:e,arg:s})=>fs(w.resolveBcsType(e).parse(s)),wc=({msg:e,chainId:s,fallback:n})=>{const[r,o]=Ce.useToggle(!1),{restUrl:a}=Me(s),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=q.useQuery({queryKey:vc.abi(a,i,l,c).queryKey,queryFn:async()=>{const m=await X.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:z.INFINITY});if(!u)return n;const h=(m,_)=>{const g=u[_];return t.jsxs("div",{className:Bt.arg,children:[t.jsx("div",{className:Bt.type,children:g}),t.jsx(xr.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(bc,{type:g,arg:m})})]},_)};return t.jsxs("div",{className:Bt.container,children:[t.jsx(Q.Small,{className:Bt.toggle,onClick:o,disabled:!u,children:r?"Encode":"Decode"}),r?t.jsx("div",{className:Bt.list,children:d.map(h)}):n]})},Cc="_list_r67rl_1",Ic="_key_r67rl_8",Nc="_value_r67rl_13",Gs={list:Cc,key:Ic,value:Nc},Sc=({message:e,chainId:s})=>{const{typeUrl:n,value:r}=e;return t.jsx("div",{className:Gs.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{children:[t.jsx("div",{className:Gs.key,children:o}),t.jsx("div",{className:Gs.value,children:n==="/initia.move.v1.MsgExecute"&&o==="args"?t.jsx(wc,{msg:r,chainId:s,fallback:fs(a)}):fs(a)})]},o))})},kc="_title_kspdu_1",Ac="_meta_kspdu_7",$c="_footer_kspdu_14",Ys={title:kc,meta:Ac,footer:$c},io=()=>{const{txRequest:e,resolve:s,reject:n}=Br(),{messages:r,memo:o,chainId:a,gas:i,gasAdjustment:l,spendCoins:c}=e,d=re(),u=At(),h=Cn(),m=Me(a),_=Nn(m),g=eo(m),p=to(m),y=Oe(m),k=(e.gasPrices??g).map(({amount:x,denom:E})=>$e.calculateFee(Math.ceil(i*l),$e.GasPrice.fromString(x+E))),S=k.map(x=>x.amount[0]),$=x=>{const E=_.find(Y=>Y.denom===x)?.amount??"0",N=S.find(Y=>Y.denom===x)?.amount??"0",F=c.filter(Y=>Y.denom===x).reduce((Y,tt)=>M(Y).plus(tt.amount),M("0")),A=M(N).plus(F),H=M(E).gte(A),{symbol:U,decimals:oe}=y(x);return{symbol:U,decimals:oe,spend:F.gt(0)?F.toFixed():null,fee:N,total:A.toFixed(),balance:E,isSufficient:H}},v=()=>{if(p&&$(p).isSufficient)return p;for(const{denom:x}of S)if($(x).isSufficient)return x;return S[0]?.denom},[D,R]=f.useState(v),{mutate:B,isPending:C}=q.useMutation({mutationKey:[Pr],mutationFn:async()=>{const x=k.find(N=>N.amount[0].denom===D);if(!x)throw new Error("Fee not found");if(!u)throw new Error("Signer not initialized");const E=await h(a,d,r,x,o);await s(E)},onError:async x=>{n(x)}}),j=$(D),I=!j.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(Ue,{children:[t.jsx("h1",{className:Ys.title,children:"Confirm tx"}),t.jsxs("div",{className:Ys.meta,children:[t.jsx(Vs,{title:"Chain",content:a}),t.jsx(Vs,{title:"Tx fee",content:t.jsx(cc,{options:k,value:D,onChange:R})}),o&&t.jsx(Vs,{title:"Memo",content:o}),I&&t.jsx(te,{level:"error",children:t.jsx(fc,{...j})})]}),t.jsx(sc,{messages:r,memo:o,chainId:a}),t.jsx(_i,{list:r,renderHeader:({typeUrl:x})=>js.sentenceCase(x.split(".").pop().replace(/^Msg/,"")),renderContent:x=>t.jsx(Sc,{message:x,chainId:a})})]}),t.jsxs(se,{className:Ys.footer,children:[t.jsx(Q.Outline,{onClick:()=>n(new Error("User rejected")),disabled:C,children:"Reject"}),t.jsx(Q.White,{onClick:()=>B(),disabled:I,loading:C,children:"Approve"})]})]})},Tc=({children:e})=>{const[{title:s,content:n,path:r},o]=f.useState({}),[a,i]=f.useState(!1),l=V.useAtomValue(As),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(Nr.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(Zr,{title:s,open:a,onOpenChange:u,children:t.jsx(he,{children:r==="/tx"?t.jsx(io,{}):n})})]})},Ec=()=>(fa(),pa(),null);function Es(){return Ce.useMediaQuery("(max-width: 576px)")}const mn="interwoven-kit";function co(){const e=document.querySelector(mn)||document.body.appendChild(document.createElement(mn));return e.shadowRoot||e.attachShadow({mode:"open"})}function qc(){const{theme:e,container:s}=ie();return f.useEffect(()=>{document.querySelector(mn)?.setAttribute("data-theme",e)},[e]),s??co()}function Dc(e){const s=co(),n=document.createElement("style");n.textContent=e,s.appendChild(n)}const ht=({title:e,content:s,children:n,className:r})=>{const[o,a]=f.useState(!1),i=()=>a(!1);return t.jsx(Zr,{title:e,trigger:n,className:r,open:o,onOpenChange:a,children:s(i)})},ps=({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})},Pc="_root_19tvg_1",Rc="_address_19tvg_9",Bc="_copy_19tvg_19",Fc="_labelWrapper_19tvg_33",Mc="_labelCopy_19tvg_43",Oc="_labelCopied_19tvg_47",Lc="_copied_19tvg_55",Uc="_derived_19tvg_65",zc="_derivedLabel_19tvg_78",Kc="_derivedAddress_19tvg_82",Hc="_hexAddress_19tvg_88",Wc="_derivedCopy_19tvg_93",ce={root:Pc,address:Rc,copy:Bc,labelWrapper:Fc,labelCopy:Mc,labelCopied:Oc,copied:Lc,derived:Uc,derivedLabel:zc,derivedAddress:Kc,hexAddress:Hc,derivedCopy:Wc},Qc=()=>{const e=f.useRef(null),s=f.useRef(null),{initiaAddress:n,hexAddress:r}=je(),o=Gr("--gray-0");return f.useEffect(()=>{e.current&&(s.current?s.current.update({data:n}):(s.current=new Ko({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:ce.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:ce.address,children:n}),t.jsx(ps,{value:n,children:({copy:a,copied:i})=>t.jsxs("button",{className:P(ce.copy,{[ce.copied]:i}),onClick:a,children:[t.jsx(T.IconCopy,{size:12}),t.jsxs("div",{className:ce.labelWrapper,children:[t.jsx("span",{className:ce.labelCopy,children:"Copy address"}),t.jsx("span",{className:ce.labelCopied,children:"Copied!"})]})]})}),t.jsx(ps,{value:r,children:({copy:a,copied:i})=>t.jsxs("button",{className:P(ce.derived,{[ce.copied]:i}),onClick:a,children:[t.jsx("span",{className:ce.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:ce.derivedAddress,children:[t.jsx("span",{className:ce.hexAddress,children:w.truncate(r)}),t.jsx(T.IconCopy,{size:12,className:ce.derivedCopy}),i&&t.jsx("span",{className:ce.copiedText,children:"Copied!"})]})]})})]})},Vc="_header_1cvtq_1",Gc="_account_1cvtq_16",Yc="_name_1cvtq_27",Jc="_address_1cvtq_31",Zc="_icon_1cvtq_35",Xc="_copied_1cvtq_42",el="_button_1cvtq_57",tl="_qr_1cvtq_68",sl="_disconnect_1cvtq_72",nl="_label_1cvtq_82",rl="_expanded_1cvtq_90",_e={header:Vc,account:Gc,name:Yc,address:Jc,icon:Zc,copied:Xc,button:el,qr:tl,disconnect:sl,label:nl,expanded:rl},ol=()=>{const e=Vt(),{connector:s}=xe.useAccount(),n=Dr(),{address:r,username:o}=je(),a=o??r,[i,l]=f.useState(!1),c=f.useRef(null),d=Ze.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(ps,{value:r,children:({copy:_,copied:g})=>t.jsxs("button",{className:P(_e.account,{[_e.copied]:g}),onClick:_,children:[t.jsx(K,{src:s.icon,width:18,height:18}),t.jsx("div",{className:_e.address,children:w.truncate(r)}),t.jsx("div",{className:_e.name,children:w.truncate(a)}),t.jsx(T.IconCopy,{className:_e.icon,size:12}),g?"Copied!":""]})}),e.metadata?.is_l1&&t.jsx(ht,{title:"Initia address",content:()=>t.jsx(Qc,{}),className:P(_e.button,_e.qr),children:t.jsx(T.IconQrCode,{size:16})}),t.jsxs(Ze.animated.button,{className:P(_e.button,_e.disconnect,{[_e.expanded]:i}),style:d,onClick:u,onMouseLeave:h,onMouseEnter:m,children:[t.jsx(T.IconSignOut,{size:16}),t.jsx("span",{className:_e.label,children:"Disconnect"})]})]}):null};function al(e){return/^[A-F0-9]{64}$/i.test(e)}function il(e,s){const{txHash:n,accountAddress:r,pathSuffix:o}=s;if(n)return al(n)?b.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,n):void 0;if(r){if(!w.InitiaAddress.validate(r))return;const i=b.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,r);return i&&o?i+o:i}}function cl(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 ll="_link_guafb_1",Gn={link:ll},qs=({chainId:e,txHash:s,accountAddress:n,pathSuffix:r,...o})=>{const{showIcon:a,className:i,children:l,onClick:c,...d}=o,u=Me(e),h=il(u,{txHash:s,accountAddress:n,pathSuffix:r}),m=s?w.truncate(s):n?w.truncate(n):"",_=l??m;return h?t.jsxs("a",{...d,href:Ho(cl(h)),className:P(Gn.link,i),onClick:c,target:"_blank",children:[_,a&&t.jsx(T.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:P(Gn.link,i),children:_})},dl=()=>{const[e,s]=V.useAtom(Rr),{showNotification:n,updateNotification:r,hideNotification:o}=Tn();return f.useEffect(()=>{if(!e)return;const{status:a,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(qs,{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 ul(){return Ce.useScrollLock(),null}const hl="_overlay_1dhd9_1",ml="_content_1dhd9_27",_l="_inner_1dhd9_58",Js={overlay:hl,content:ml,inner:_l},fl=({children:e})=>{const{isDrawerOpen:s,closeDrawer:n}=$t(),{setContainer:r}=f.useContext($n),o=Es(),a=qc(),i=V.useAtomValue(As),l=q.useIsMutating({mutationKey:[Pr]}),c=()=>{const _=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";n(),i?.reject(new Error(_))},d=ws(),u=de(),h=q.useQueryClient(),m={fallbackRender:({error:_,resetErrorBoundary:g})=>{const p=()=>{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(),g()};return t.jsxs(Ue,{children:[t.jsx(Z,{error:!0,children:_.message}),t.jsx(se,{children:t.jsx(Q.White,{onClick:p,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:Js.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:Js.content,children:t.jsxs("div",{className:P(Js.inner,"body"),ref:r,children:[o&&t.jsx(ul,{}),t.jsx(dl,{}),t.jsx(ol,{}),t.jsx(he,{errorBoundaryProps:m,children:e})]})})]})})},pl="_page_1f6wh_1",gl="_title_1f6wh_10",xl="_scrollable_1f6wh_17",yl="_list_1f6wh_22",jl="_item_1f6wh_32",vl="_name_1f6wh_56",bl="_dimmed_1f6wh_64",wl="_recent_1f6wh_68",Cl="_installed_1f6wh_69",ve={page:pl,title:gl,scrollable:xl,list:yl,item:jl,name:vl,dimmed:bl,recent:wl,installed:Cl},Il=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],Yn=({onSuccess:e})=>{const{connectors:s,connectAsync:n}=xe.useConnect(),r=Ce.useReadLocalStorage("wagmi.recentConnectorId"),[o,a]=f.useState(null),{mutate:i,isPending:l}=q.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(Ue,{className:ve.scrollable,children:t.jsxs("div",{className:ve.list,children:[s.toSorted(b.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(K,{src:u,width:24,height:24}),t.jsx("span",{className:ve.name,children:d}),o===h?t.jsx(ft,{size:16}):r===h?t.jsx("span",{className:ve.recent,children:"Recent"}):c.id===vs.id?null:t.jsx("span",{className:ve.installed,children:"Installed"})]},h)}),Il.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(K,{src:u,width:24,height:24}),t.jsx("span",{className:P(ve.name,ve.dimmed),children:c}),t.jsx(T.IconExternalLink,{size:10})]},c)})]})})]})},Nl="_root_xwz5z_1",Sl="_header_xwz5z_6",kl="_title_xwz5z_12",Al="_warning_xwz5z_18",$l="_content_xwz5z_22",Tl="_footer_xwz5z_26",El="_secondary_xwz5z_36",rt={root:Nl,header:Sl,title:kl,warning:Al,content:$l,footer:Tl,secondary:El},lo=e=>{const{type:s,icon:n,title:r,children:o,primaryButton:a,secondaryButton:i}=e;return t.jsxs(Ue,{className:rt.root,children:[t.jsxs("header",{className:P(rt.header,s&&rt[s]),children:[n,t.jsx("h1",{className:rt.title,children:r})]}),t.jsx("div",{className:rt.content,children:o}),t.jsxs("footer",{className:rt.footer,children:[t.jsx(Q.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),t.jsxs("button",{className:rt.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(T.IconChevronRight,{size:14})]})]})]})},ql="_list_tmcxc_1",Dl="_row_tmcxc_8",Pl="_dt_tmcxc_19",Rl="_asset_tmcxc_25",ns={list:ql,row:Dl,dt:Pl,asset:Rl},Bl=({list:e,onNavigate:s,onDismiss:n})=>{const r=ye(),o=Xe(),a=Oe(r);return t.jsx(lo,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:s},secondaryButton:{label:"Do not show again",onClick:n},children:t.jsx("div",{className:ns.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),_=w.formatAmount(c,{decimals:h});return t.jsxs("div",{className:ns.row,children:[t.jsxs("div",{className:ns.dt,children:[t.jsx(K,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:ns.asset,children:[_," ",m]})]},i)})})})};function Zs(e,s){return e.chainId===s.chainId&&e.txHash===s.txHash}const rs=({chainId:e,txHash:s})=>`${O.OP_REMINDER}:${e}:${s}`,Fl=Wo.atomWithStorage(O.OP_REMINDER,[]);function Et(){const e=re(),[s=[],n]=V.useAtom(Fl),r=f.useMemo(()=>s.map(c=>{const d=localStorage.getItem(rs(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:kt.isPast(u)}),[e,s]),o=f.useCallback((c,d)=>{s.some(u=>Zs(u,c))||(n((u=[])=>[...u,c]),localStorage.setItem(rs(c),JSON.stringify(d)))},[s,n]),a=f.useCallback(c=>{n((d=[])=>d.filter(u=>!Zs(u,c))),localStorage.removeItem(rs(c))},[n]),i=f.useCallback(c=>{const d=c.filter(u=>!s.some(h=>Zs(h,u)));d.length!==0&&n((u=[])=>[...u,...d])},[s,n]),l=f.useCallback((c,d)=>{localStorage.setItem(rs(c),JSON.stringify(d)),n((u=[])=>[...u])},[n]);return{reminders:r,addReminder:o,removeReminder:a,syncReminders:i,setReminder:l}}function uo(){const e=de(),{openModal:s,closeModal:n}=Cs(),{reminders:r,setReminder:o}=Et();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(Bl,{list:a,onNavigate:i,onDismiss:l})})},[r,n,e,s,o])}const ho=f.createContext(null);function mo(){return f.useContext(ho)}const Ml="_root_7yxgy_1",Ol="_label_7yxgy_7",Ll="_input_7yxgy_19",Ul="_hasValue_7yxgy_29",zl="_clear_7yxgy_33",Ft={root:Ml,label:Ol,input:Ll,hasValue:Ul,clear:zl},Ds=e=>{const{rootClassName:s,padding:n=16,iconSize:r=16,onClear:o,ref:a,...i}=e;return t.jsxs("div",{className:P(Ft.root,s,{[Ft.hasValue]:i.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${r}px`},children:[t.jsx("label",{htmlFor:"search",className:Ft.label,children:t.jsx(T.IconSearch,{size:r})}),t.jsx("input",{className:Ft.input,id:"search",type:"text",maxLength:100,ref:a,...i}),i.value&&t.jsx("button",{type:"button",className:Ft.clear,"aria-label":"Clear search",onMouseDown:l=>l.preventDefault(),onClick:o,children:t.jsx(T.IconCloseCircleFilled,{size:r})})]})},Kl="_container_t1267_1",Hl="_controls_t1267_7",Wl="_search_t1267_13",En={container:Kl,controls:Hl,search:Wl},Ql=({children:e})=>t.jsx("div",{className:En.container,children:e}),Vl=({children:e})=>t.jsx("div",{className:En.controls,children:e}),Gl=e=>t.jsx(Ds,{...e,rootClassName:En.search}),Ye={Root:Ql,Controls:Vl,SearchInput:Gl};function Yt(){const e=f.useRef(null),s=Es();return f.useEffect(()=>{s||e.current?.focus()},[s]),e}const Yl="_trigger_386xl_1",Jl="_icon_386xl_21",Zl="_full_386xl_25",Xl="_triggerContent_386xl_30",ed="_triggerText_386xl_38",td="_popoverBackdrop_386xl_49",sd="_popoverPositioner_386xl_84",nd="_popoverPopup_386xl_88",rd="_search_386xl_131",od="_viewport_386xl_136",ad="_item_386xl_141",id="_highlighted_386xl_155",cd="_itemContent_386xl_160",le={trigger:Yl,icon:Jl,full:Zl,triggerContent:Xl,triggerText:ed,popoverBackdrop:td,popoverPositioner:sd,popoverPopup:nd,search:rd,viewport:od,item:ad,highlighted:id,itemContent:cd},qn=({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),g=ne(),p=n.map(j=>g.find(I=>I.chainId===j)).filter(Boolean),y=j=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:j,height:j,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:y}),[]),S=f.useMemo(()=>{const j=[k,...p];if(!o)return j;const I=o.toLowerCase();return j.filter(x=>x.name.toLowerCase().includes(I)||x.chainId.toLowerCase().includes(I))},[p,o,k]),$=p.find(j=>j.chainId===e)||k,v=parseInt(Gr("--drawer-offset")),D=6,R=()=>{if(a(""),d(-1),_.current){const I=_.current.getBoundingClientRect().bottom+D,x=window.innerHeight-I-2*v;h(x)}l(!0)};f.useEffect(()=>{c>=0&&c<m.current.length&&m.current[c]?.scrollIntoView({block:"nearest",behavior:"auto"})},[c]);const B=f.useCallback(j=>{switch(j.key){case"ArrowDown":j.preventDefault(),d(I=>(I+1)%S.length);break;case"ArrowUp":j.preventDefault(),d(I=>(I-1+S.length)%S.length);break;case"Enter":j.preventDefault(),S[c]&&(s(S[c].chainId),l(!1));break;case"Escape":j.preventDefault(),l(!1);break}},[S,c,s,l]),C=j=>{s(j),l(!1)};return t.jsxs(vt.Popover.Root,{open:i,onOpenChange:R,modal:"trap-focus",children:[t.jsx(vt.Popover.Trigger,{render:t.jsxs("button",{className:P(le.trigger,{[le.full]:r}),"aria-expanded":i,role:"listbox",ref:_,children:[t.jsxs("div",{className:le.triggerContent,children:[typeof $.logoUrl=="string"?t.jsx(K,{src:$.logoUrl,width:14,height:14,logo:!0}):$.logoUrl(14),t.jsx("span",{className:le.triggerText,children:$.name})]}),t.jsx(T.IconChevronDown,{size:16,className:le.icon})]})}),t.jsxs(vt.Popover.Portal,{container:ut(),children:[t.jsx(vt.Popover.Backdrop,{className:le.popoverBackdrop,onClick:()=>l(!1)}),t.jsx(vt.Popover.Positioner,{className:le.popoverPositioner,align:"end",side:"bottom",sideOffset:D,children:t.jsxs(vt.Popover.Popup,{className:P(le.popoverPopup,{[le.full]:r}),style:{maxHeight:u},children:[t.jsx(Ds,{value:o,onChange:j=>{a(j.target.value),d(0)},onClear:()=>a(""),onKeyDown:B,placeholder:"Search appchains",rootClassName:le.search,ref:Yt()}),t.jsx("div",{className:le.viewport,role:"listbox",children:S.length===0?t.jsx(Z,{children:"No appchains found"}):S.map(({chainId:j,name:I,logoUrl:x},E)=>t.jsxs("div",{className:P(le.item,{[le.highlighted]:E===c}),onClick:()=>C(j),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),C(j))},onMouseEnter:()=>d(E),role:"option","aria-selected":e===j,tabIndex:-1,ref:N=>{N&&(m.current[E]=N)},children:[t.jsxs("div",{className:le.itemContent,children:[typeof x=="string"?t.jsx(K,{src:x,width:16,height:16,logo:!0}):x(16),t.jsx("span",{children:I})]}),e===j&&t.jsx(T.IconCheck,{size:16})]},j))})]})})]})]})},ld="2.0.5",dd="_version_1sf5y_1",ud={version:dd},hd=()=>t.jsxs("aside",{className:ud.version,children:["v",ld]}),md=V.atom(""),_d=V.atom(""),fd=V.atom(""),pd=V.atom(""),gd=V.atom(""),xd="_popup_nbecp_1",yd="_item_nbecp_19",os={popup:xd,item:yd},_o=({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=de(),_=mo(),{showNotification:g}=Tn(),{defaultChainId:p}=ie(),{evm_chain_id:y}=Vt(),k=xe.useChainId(),{switchChainAsync:S}=xe.useSwitchChain(),{watchAssetAsync:$}=xe.useWatchAsset(),v=()=>{h(!1),m("/send",{denom:n,chain:c})},D=()=>{h(!1),m("/bridge",{srcChainId:d,srcDenom:n,quantity:""})},R=q.useMutation({mutationFn:async()=>{if(!l)throw new Error("Address is required");const B=a;return await S({chainId:Number(y)}),$({type:"ERC20",options:{address:l,symbol:o,decimals:r,image:B}})},onSuccess:()=>{g({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:B=>{g({type:"error",title:"Asset addition failed",description:B.message})}});return t.jsxs(He.Menu.Root,{open:u,onOpenChange:h,modal:!1,children:[t.jsx(He.Menu.Trigger,{render:s}),t.jsx(He.Menu.Portal,{container:_.current,children:t.jsx(He.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(He.Menu.Popup,{className:os.popup,children:[t.jsxs(He.Menu.Item,{className:os.item,onClick:v,children:[t.jsx(T.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(He.Menu.Item,{className:os.item,onClick:D,disabled:i,children:[t.jsx(T.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===p&&y===k&&!!l&&t.jsxs(He.Menu.Item,{className:os.item,onClick:()=>R.mutate(),disabled:R.isPending||R.data,children:[R.data?t.jsx(T.IconCheck,{size:16}):t.jsx(T.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},jd="_images_cj4xz_1",Xs={images:jd},Ps=({assetLogoUrl:e,assetLogoSize:s=36,chainLogoUrl:n,chainLogoSize:r=18,chainLogoOffset:o=6,className:a})=>t.jsxs("div",{className:P(Xs.images,a),style:{position:"relative"},children:[t.jsx(K,{src:e,width:s,height:s,className:Xs.asset,logo:!0}),t.jsx(K,{src:n,width:r,height:r,className:Xs.chain,style:{position:"absolute",bottom:0,right:-1*o},logo:!0})]}),vd="_item_knoro_1",bd="_info_knoro_22",wd="_images_knoro_28",Cd="_name_knoro_32",Id="_value_knoro_38",Nd="_amount_knoro_46",Sd="_usd_knoro_52",ot={item:vd,info:bd,images:wd,name:Cd,value:Id,amount:Nd,usd:Sd},kd=({asset:e})=>{const{amount:s,value:n,logoUrl:r,chain:o}=e,a=w.formatAmount(s,{decimals:e.decimals});return t.jsx(_o,{asset:e,children:t.jsxs("button",{className:ot.item,children:[t.jsxs("div",{className:ot.info,children:[t.jsx(Ps,{assetLogoUrl:r,chainLogoUrl:o.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:ot.images}),t.jsx("span",{className:ot.name,children:o.name})]}),t.jsxs("div",{className:ot.value,children:[t.jsx("span",{className:ot.amount,children:a}),Number(n)>0&&t.jsx("span",{className:ot.usd,children:Fe(n)})]})]})})},Ad="_container_g5q73_1",$d="_assetItem_g5q73_6",Td="_assetInfo_g5q73_26",Ed="_logo_g5q73_32",qd="_symbol_g5q73_36",Dd="_chainName_g5q73_46",Pd="_chainInfos_g5q73_52",Rd="_chainLogos_g5q73_58",Bd="_chainLogo_g5q73_58",Fd="_moreChains_g5q73_69",Md="_expandIcon_g5q73_81",Od="_expanded_g5q73_85",Ld="_valueColumn_g5q73_90",Ud="_amount_g5q73_99",zd="_value_g5q73_90",Kd="_collapsibleContent_g5q73_112",Hd="_chainsList_g5q73_142",J={container:Ad,assetItem:$d,assetInfo:Td,logo:Ed,symbol:qd,chainName:Dd,chainInfos:Pd,chainLogos:Rd,chainLogo:Bd,moreChains:Fd,expandIcon:Md,expanded:Od,valueColumn:Ld,amount:Ud,value:zd,collapsibleContent:Kd,chainsList:Hd},Wd=V.atom([]),fo=({assetGroup:e})=>{const{symbol:s,logoUrl:n,assets:r}=e,o=r.length===1,[a,i]=V.useAtom(Wd),l=f.useMemo(()=>ka(e),[e]),c=f.useMemo(()=>Sn(e),[e]),d=a.includes(s),u=()=>{i(m=>d?b.without([s],m):b.uniq([...m,s]))},h=()=>t.jsxs("button",{className:J.assetItem,children:[t.jsxs("div",{className:J.assetInfo,children:[n&&t.jsx(K,{src:n,width:32,height:32,className:J.logo,logo:!0}),t.jsxs("div",{className:J.details,children:[t.jsx("div",{className:J.symbol,children:s}),o?t.jsx("div",{className:J.chainName,children:r[0].chain.name}):t.jsxs("div",{className:J.chainInfos,children:[t.jsx("div",{className:J.chainLogos,children:r.slice(0,5).map(({chain:m})=>t.jsx(K,{src:m.logoUrl,width:16,height:16,className:J.chainLogo,logo:!0},m.chainId))}),r.length>5&&t.jsxs("span",{className:J.moreChains,children:["+",r.length-5]}),t.jsx(T.IconChevronDown,{size:16,className:P(J.expandIcon,{[J.expanded]:d})})]})]})]}),t.jsxs("div",{className:J.valueColumn,children:[t.jsx("div",{className:J.amount,children:w.formatNumber(l,{dp:r[0].unlisted?0:6})}),c>0&&t.jsx("div",{className:J.value,children:Fe(c)})]})]});if(o){const[m]=r;return t.jsx("div",{className:J.container,children:t.jsx(_o,{asset:m,children:h()})})}return t.jsx("div",{className:J.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:J.collapsibleContent,children:t.jsx("div",{className:J.chainsList,children:r.map(m=>t.jsx(kd,{asset:m},m.chain.chainId))})})]})})},Qd="_collapsible_1spkj_1",Vd="_trigger_1spkj_5",Gd="_divider_1spkj_20",Yd="_label_1spkj_26",Jd="_chevron_1spkj_31",Zd="_content_1spkj_39",Xd="_list_1spkj_43",Qe={collapsible:Qd,trigger:Vd,divider:Gd,label:Yd,chevron:Jd,content:Zd,list:Xd},eu=({unlistedAssets:e})=>{const[s,n]=f.useState(!0),r=mo(),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=Ze.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:Qe.collapsible,children:[t.jsxs(G.Collapsible.Trigger,{className:Qe.trigger,children:[t.jsx("div",{className:Qe.divider}),t.jsxs("span",{className:Qe.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(T.IconChevronDown,{className:Qe.chevron,size:12,"data-state":s?"open":"closed"}),t.jsx("div",{className:Qe.divider})]}),t.jsx(G.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(Ze.animated.div,{className:Qe.content,style:c,children:t.jsx("div",{className:Qe.list,ref:o,children:e.map(d=>t.jsx(fo,{assetGroup:{...d,assets:[d]}},d.denom))})})})]})},tu="_list_szwvw_1",su={list:tu},nu=()=>{const[e,s]=V.useAtom(md),[n,r]=V.useAtom(_d),{assetGroups:o,unlistedAssets:a,chainsByValue:i,isLoading:l}=kn(),c=i.map(({chainId:h})=>h),d=f.useMemo(()=>{const h=e?o.filter(_=>{const{symbol:g,assets:p}=_;return g.toLowerCase().includes(e.toLowerCase())||p.some(({denom:y,address:k})=>y.toLowerCase().includes(e.toLowerCase())||k?.toLowerCase().includes(e.toLowerCase()))}):o;return n?h.map(_=>({..._,assets:_.assets.filter(({chain:g})=>g.chainId===n)})).filter(_=>_.assets.length>0):h},[o,e,n]),u=f.useMemo(()=>{const h=e?a.filter(({denom:_,address:g})=>_.toLowerCase().includes(e.toLowerCase())||g?.toLowerCase().includes(e.toLowerCase())):a;return n?h.filter(({chain:_})=>_.chainId===n):h},[a,e,n]);return l&&o.length===0?t.jsx(Z,{children:"Loading assets..."}):!d.length&&!u.length&&!e&&!n&&!l?t.jsx(Z,{children:"No assets"}):t.jsxs(t.Fragment,{children:[t.jsxs(Ye.Root,{children:[t.jsxs(Ye.Controls,{children:[t.jsx(Ye.SearchInput,{value:e,onChange:h=>s(h.target.value),onClear:()=>s(""),placeholder:"Search assets"}),t.jsx(qn,{value:n,onChange:r,chainIds:c})]}),t.jsx("div",{children:d.length===0&&u.length===0?t.jsx(Z,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:su.list,children:d.map(h=>t.jsx(fo,{assetGroup:h},h.symbol))}),t.jsx(eu,{unlistedAssets:u})]})})]}),t.jsx(hd,{})]})},po=qe.createQueryKeys("interwovenkit:nft",{nfts:(e,s)=>[e,s],metadata:e=>[e]});function ru(e,s){const{nft:n}=e,r=s.name??n.token_id;return{...e,...n,...s,name:r}}function ou(e,s){return e.flatMap((n,r)=>(s[r]??[]).map(a=>({...a,chain:n})))}const au=()=>{const e=re(),s=ne(),n=q.useQueries({queries:s.map(i=>({queryKey:po.nfts(i.indexerUrl,e).queryKey,queryFn:()=>Or(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:i.indexerUrl},"tokens"),staleTime:z.SECOND}))}),r=n.map(b.prop("data")),o=ou(s,r),a=n.some(i=>i.isLoading);return{nftInfos:o,isLoading:a}};function iu(e){const s=Jn(e);return q.useQuery({queryKey:po.metadata(s).queryKey,queryFn:async()=>{try{if(!s)return{};const n=await X.get(s).json();return{...n,image:Jn(n.image)}}catch{return{}}},staleTime:z.INFINITY})}function Jn(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const cu="_thumbnail_1lblb_1",lu="_placeholder_1lblb_16",du="_clickable_1lblb_22",Mt={thumbnail:cu,placeholder:lu,clickable:du},Dn=({nftInfo:e,size:s,onClick:n})=>{const{collection_addr:r,object_addr:o,nft:a,chain:i}=e,{glyphUrl:l}=ie(),c=new URL(`/v1/${i.chainId}/${r}/${o||a.token_id}`,l).toString();return n?t.jsx("button",{className:P(Mt.thumbnail,Mt.clickable),onClick:n,style:{width:s,height:s},children:t.jsx(K,{src:c,classNames:{placeholder:Mt.placeholder}})}):t.jsx("div",{className:Mt.thumbnail,style:{width:s,height:s},children:t.jsx(K,{src:c,classNames:{placeholder:Mt.placeholder}})})},uu="_nftItem_eopro_1",hu="_collectionName_eopro_9",mu="_nftName_eopro_19",_u="_chainInfo_eopro_29",as={nftItem:uu,collectionName:hu,nftName:mu,chainInfo:_u},fu=({normalizedNft:e})=>{const{collection_name:s,name:n,chain:r}=e,o=de();return t.jsxs("div",{className:as.nftItem,children:[t.jsx(Dn,{nftInfo:e,onClick:()=>o("/nft",e)}),t.jsxs("div",{children:[t.jsx("div",{className:as.collectionName,children:s}),t.jsx("div",{className:as.nftName,children:n}),t.jsxs("div",{className:as.chainInfo,children:[t.jsx(K,{src:r.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:r.name})]})]})]})},pu=({nftInfo:e,children:s})=>{const{data:n={}}=iu(e.nft.uri),r=ru(e,n);return s(r)},gu="_grid_a1fhu_1",xu={grid:gu},yu=()=>{const[e,s]=V.useAtom(fd),[n,r]=V.useAtom(pd),{nftInfos:o,isLoading:a}=au(),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(Z,{children:"Loading NFTs..."}):!o.length&&!e&&!a?t.jsx(Z,{children:"No NFTs"}):t.jsxs(Ye.Root,{children:[t.jsxs(Ye.Controls,{children:[t.jsx(Ye.SearchInput,{value:e,onChange:c=>s(c.target.value),onClear:()=>s(""),placeholder:"Search NFTs"}),t.jsx(qn,{value:n,onChange:r,chainIds:l})]}),i.length===0?t.jsx(Z,{children:"No NFTs found"}):t.jsx("div",{className:xu.grid,children:i.map(c=>{const{collection_addr:d,nft:u}=c;return t.jsx(pu,{nftInfo:c,children:h=>t.jsx(fu,{normalizedNft:h})},d+u.token_id)})})]})};function go(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 ju="_message_1g2hc_1",vu="_more_1g2hc_8",Zn={message:ju,more:vu},bu=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((s,n)=>t.jsx("p",{className:Zn.message,children:js.sentenceCase(s["@type"].split("Msg")[1])},n)),e.length>3&&t.jsx("footer",{className:Zn.more,children:`+${e.length-3} more`})]}),wu="_change_1x9v4_1",Cu="_positive_1x9v4_10",Iu="_negative_1x9v4_14",en={change:wu,positive:Cu,negative:Iu},xo=({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:P(en.change,a?en.positive:en.negative),children:[a?"+":"-",w.formatAmount(i,{decimals:o})," ",r||n]})},Nu=({changes:e,chain:s})=>{const n=Oe(s);return e.map(({amount:r,denom:o},a)=>t.jsx(xo,{amount:r,asset:n(o)},a))},Su=({changes:e,chain:s})=>{const n=Oe(s);return e.map(({amount:r,metadata:o},a)=>t.jsx(oo,{metadata:o,chain:s,children:i=>t.jsx(xo,{amount:r,asset:n(i)})},a))},ku=({events:e,chain:s})=>{const{initiaAddress:n,hexAddress:r}=je();return s.metadata?.is_l1||s.metadata?.minitia?.type==="minimove"?t.jsx(Su,{changes:ro(e,r),chain:s}):t.jsx(Nu,{changes:no(e,n),chain:s})},Au="_link_oq58b_1",$u="_inner_oq58b_15",Tu="_header_oq58b_20",Eu="_time_oq58b_29",qu="_error_oq58b_35",Du="_timestamp_oq58b_39",Pu="_chainInfo_oq58b_44",Ru="_content_oq58b_52",Bu="_messages_oq58b_59",Fu="_changes_oq58b_64",Se={link:Au,inner:$u,header:Tu,time:Eu,error:qu,timestamp:Du,chainInfo:Pu,content:Ru,messages:Bu,changes:Fu},Mu=({txItem:e,chain:s})=>t.jsx(qs,{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(T.IconWarningFilled,{size:14,className:Se.error}),t.jsx("span",{className:Se.timestamp,children:kt.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:Se.chainInfo,children:[t.jsx(K,{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(bu,{messages:e.tx.body.messages})}),t.jsx("div",{className:Se.changes,children:t.jsx(he,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(ku,{...e,chain:s})})})]})]})}),Ou="_list_1wa9p_1",Lu="_dateGroup_1wa9p_7",Uu="_dateHeader_1wa9p_12",zu="_more_1wa9p_18",is={list:Ou,dateGroup:Lu,dateHeader:Uu,more:zu},Ku=({list:e,chainId:s})=>{const n=re(),r=f.useMemo(()=>go(e,o=>{if(o.timestamp)return new Date(o.timestamp)}),[e]);return e.length===0?t.jsx(Z,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:is.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{className:is.dateGroup,children:[t.jsx("div",{className:is.dateHeader,children:o}),a.map(i=>t.jsx(he,{errorBoundaryProps:{fallback:null},children:t.jsx(Mu,{txItem:i,chain:i.chain})},i.txhash))]},o))}),t.jsx(qs,{chainId:s,accountAddress:n,pathSuffix:"/txs",className:is.more,showIcon:!0,children:"View more on Initia Scan"})]})},Hu=()=>{const{activities:e,isLoading:s}=ci(),[n,r]=V.useAtom(gd),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(Z,{children:"Loading activities..."}):!e.length&&!s?t.jsx(Z,{children:"No activity yet"}):t.jsxs(Ye.Root,{children:[t.jsx(Ye.Controls,{children:t.jsx(qn,{value:n,onChange:r,chainIds:a,fullWidth:!0})}),t.jsx(Ku,{list:i,chainId:n||o.chainId})]})},Wu="_totalValue_1udv1_1",Qu="_totalLabel_1udv1_7",Vu="_totalAmount_1udv1_13",Gu="_loading_1udv1_18",Yu="_nav_1udv1_23",Ju="_item_1udv1_28",Zu="_tabs_1udv1_51",Xu="_tab_1udv1_51",be={totalValue:Wu,totalLabel:Qu,totalAmount:Vu,loading:Gu,nav:Yu,item:Ju,tabs:Zu,tab:Xu},eh=()=>{uo();const e=de(),s=ws(),{totalValue:n,isLoading:r}=kn(),o=f.useRef(null);return t.jsx(ho.Provider,{value:o,children:t.jsxs(Ue,{ref:o,children:[t.jsxs("div",{className:be.totalValue,children:[t.jsx("div",{className:be.totalLabel,children:"Total value"}),t.jsx("div",{className:P(be.totalAmount,{[be.loading]:r}),children:Fe(n)})]}),t.jsxs("div",{className:be.nav,children:[t.jsxs(bn,{to:"/send",className:be.item,children:[t.jsx(T.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs("button",{className:be.item,onClick:()=>e("/bridge"),children:[t.jsx(T.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]})]}),t.jsxs(Ke.Tabs.Root,{value:s,onValueChange:e,children:[t.jsxs(Ke.Tabs.List,{className:be.tabs,children:[t.jsx(Ke.Tabs.Tab,{className:be.tab,value:"/",children:"Assets"}),t.jsx(Ke.Tabs.Tab,{className:be.tab,value:"/nfts",children:"NFTs"}),t.jsx(Ke.Tabs.Tab,{className:be.tab,value:"/activity",children:"Activity"})]}),t.jsx(Ke.Tabs.Panel,{value:"/",children:t.jsx(nu,{})}),t.jsx(Ke.Tabs.Panel,{value:"/nfts",children:t.jsx(yu,{})}),t.jsx(Ke.Tabs.Panel,{value:"/activity",children:t.jsx(Hu,{})})]})]})})},th="_header_acels_1",sh="_back_acels_11",nh="_title_acels_23",tn={header:th,back:sh,title:nh},pt=({title:e,backButton:s,extra:n,children:r})=>t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:tn.header,children:[t.jsx(bn,{to:s??-1,className:tn.back,shouldReset:!!s,children:t.jsx(T.IconBack,{size:16})}),t.jsx("h1",{className:tn.title,children:e}),n]}),t.jsx(Ue,{children:r})]}),rh="_fieldset_y241y_1",oh="_upper_y241y_9",ah="_select_y241y_14",ih="_account_y241y_19",ch="_lower_y241y_24",lh="_wrapper_y241y_25",dh="_balance_y241y_32",uh="_value_y241y_36",hh="_error_y241y_49",Pe={fieldset:rh,upper:oh,select:ah,account:ih,lower:ch,wrapper:lh,balance:dh,value:uh,error:hh},_n=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(T.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})},mh="_root_1ipwv_1",_h="_content_1ipwv_10",fh="_details_1ipwv_18",ph="_symbol_1ipwv_23",gh="_chain_1ipwv_31",xh="_chevron_1ipwv_40",at={root:mh,content:_h,details:fh,symbol:ph,chain:gh,chevron:xh},yo=({asset:e,chain:s,readOnly:n})=>{const r=t.jsxs("div",{className:at.content,children:[t.jsx(Ps,{assetLogoUrl:e.logoUrl,chainLogoUrl:s.logoUrl}),t.jsxs("div",{className:at.details,children:[t.jsx("div",{className:at.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:at.chain,children:["on ",s.name]})]})]});return n?t.jsx("div",{className:at.root,children:r}):t.jsxs("div",{className:at.root,children:[r,t.jsx(T.IconChevronDown,{size:16,className:at.chevron})]})},yh="_wrapper_5ssm8_1",jh="_balance_5ssm8_11",vh="_button_5ssm8_15",sn={wrapper:yh,balance:jh,button:vh},jo=({onClick:e,children:s,disabled:n})=>t.jsxs("div",{className:sn.wrapper,children:[t.jsx(T.IconWallet,{size:16}),t.jsx("span",{className:sn.balance,children:s}),t.jsx("button",{type:"button",tabIndex:-1,className:sn.button,onClick:()=>e(),disabled:n,children:"MAX"})]}),bh="_input_h8073_1",wh={input:bh};function Xn(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 vo(e){const{name:s,control:n,dp:r=6,className:o,rules:a,...i}=e,l=Yt();return t.jsx(ae.Controller,{name:s,control:n,rules:a,render:({field:c})=>t.jsx("input",{...c,className:P(wh.input,o),onChange:d=>c.onChange(Xn(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,""),_=Xn(m,r);c.onChange(_)},placeholder:"0",inputMode:"decimal",autoComplete:"off",...i,ref:yr.mergeRefs([c.ref,l])})})}const Ch="_input_qpv94_1",Ih="_placeholder_qpv94_18",fn={input:Ch,placeholder:Ih},Nh=({children:e})=>t.jsx("p",{className:P(fn.input,{[fn.placeholder]:M(e).isZero()}),children:e}),gs=({balance:e,decimals:s})=>{const{control:n}=ae.useFormContext(),r={required:"Enter amount",validate:o=>M(o).isZero()?"Enter amount":M(w.toBaseUnit(o,{decimals:s})).gt(e??0)?"Insufficient balance":!0};return t.jsx(vo,{name:"quantity",control:n,className:fn.input,rules:r})};gs.ReadOnly=Nh;const Sh="_label_9417z_1",kh="_wrapper_9417z_7",Ah="_input_9417z_10",$h="_clear_9417z_18",cs={label:Sh,wrapper:kh,input:Ah,clear:$h},Pn=({mode:e="onChange",myAddress:s,...n})=>{const{validate:r=w.InitiaAddress.validate,chainType:o="initia",onApply:a,ref:i}=n,l=Yt(),{control:c,getValues:d,setValue:u,formState:h}=ae.useFormContext(),m=d("recipient"),[_,g]=f.useState(m),p=Kr(),{data:y,isLoading:k,error:S}=q.useQuery({queryKey:$s.address(p.restUrl,_).queryKey,queryFn:()=>p.getAddress(_),staleTime:z.MINUTE,enabled:p.validateUsername(_)}),$=y??(r(_)?_:""),v=s&&w.InitiaAddress.equals($,s),D=async()=>{try{const C=await navigator.clipboard.readText();g(C.trim())}catch{}};f.useEffect(()=>{e==="onChange"&&(!_&&!h.dirtyFields.recipient||u("recipient",y??_,{shouldValidate:!0,shouldDirty:!0}))},[h.dirtyFields.recipient,_,e,u,y]);const R=()=>{k||S||(u("recipient",$,{shouldValidate:!0,shouldDirty:!0}),a?.())},B=()=>{if(k)return t.jsx(Ve,{level:"loading",children:"Resolving username..."});if(S)return t.jsx(Ve,{level:"error",children:S.message});if(y)return t.jsx(Ve,{level:"success",className:"monospace",children:y});if(e==="onSubmit"&&_&&!$)return t.jsx(Ve,{level:"error",children:"Invalid address"});if(e==="onChange")return t.jsx(Ve,{level:"error",children:h.errors.recipient?.message})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:cs.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(Q.Small,{type:"button",tabIndex:-1,onClick:D,children:"Paste"})]}),t.jsxs("div",{className:cs.wrapper,children:[t.jsx(ae.Controller,{name:"recipient",control:c,rules:{required:"Recipient address is required",validate:C=>r(C)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:P(cs.input,"monospace"),value:_,onChange:C=>g(C.target.value.trim()),placeholder:o==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":_?"true":void 0,ref:e==="onSubmit"?yr.mergeRefs([i,l]):i})}),!!_&&t.jsx("button",{type:"button",className:cs.clear,onClick:()=>g(""),"aria-label":"Clear recipient",children:t.jsx(T.IconCloseCircleFilled,{size:16})})]}),B(),v&&t.jsx(Ve,{children:"This is my address"}),e==="onSubmit"&&t.jsx(se,{extra:(!s||!!$&&!v)&&t.jsx(te,{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(Q.White,{type:"button",onClick:R,disabled:k||!!S||!$,children:"Apply"})})]})};function Th({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 Eh({denom:e,balances:s,gasPrices:n,lastFeeDenom:r,gas:o}){const a=s.find(d=>d.denom===e)?.amount??"0",i=Th({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 qh="_container_1a4ds_1",Dh="_badge_1a4ds_5",er={container:qh,badge:Dh},bo=e=>{const{offset:s=-4,disabled:n,children:r,className:o}=e;return t.jsxs("div",{className:P(er.container,o),children:[r,!n&&t.jsx("div",{className:er.badge,style:{right:s,top:s}})]})},Ph="_tooltip_6zakp_1",Rh="_arrow_6zakp_43",tr={tooltip:Ph,arrow:Rh},Jt=({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:ut(),children:t.jsxs(G.Tooltip.Content,{className:P(tr.tooltip,{small:n}),collisionBoundary:ut(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(G.Tooltip.Arrow,{className:tr.arrow})]})})]}),Bh="_stack_a3b9q_1",Fh="_title_a3b9q_8",Mh="_grid_a3b9q_15",Oh="_item_a3b9q_21",Lh="_button_a3b9q_25",Uh="_active_a3b9q_43",It={stack:Bh,title:Fh,grid:Mh,item:Oh,button:Lh,active:Uh},dt=({label:e,chains:s,value:n,onSelect:r,getShowIndicator:o})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:It.title,children:e}),t.jsx("div",{className:It.grid,children:s.map(({chainId:a,name:i,logoUrl:l})=>t.jsx(bo,{offset:-2,disabled:!o?.(a),className:It.item,children:t.jsx(Jt,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:P(It.button,{[It.active]:a===n}),onClick:()=>r(a),children:t.jsx(K,{src:l,width:28,height:28,logo:!0})})})},a))})]}),zh=({children:e})=>t.jsx("div",{className:It.stack,children:e});dt.Stack=zh;function Kh(e,s,n){return n.filter(r=>{const o=e.map(a=>r[a]).map(a=>String(a??"").toLowerCase());return b.any(b.includes(s.toLowerCase()),o)})}const Hh="_container_1voou_1",Wh="_search_1voou_6",Qh="_list_1voou_10",Vh="_item_1voou_14",Gh="_logo_1voou_35",Yh="_info_1voou_39",Jh="_symbol_1voou_44",Zh="_name_1voou_52",Xh="_balance_1voou_58",em="_value_1voou_65",ge={container:Hh,search:Wh,list:Qh,item:Vh,logo:Gh,info:Yh,symbol:Jh,name:Zh,balance:Xh,value:em},Zt=e=>{const{assets:s,onSelect:n,renderAsset:r=(l,c)=>c(l)}=e,[o,a]=f.useState(""),i=Kh(["symbol"],o,s);return t.jsxs("div",{className:ge.container,children:[t.jsx(Ds,{value:o,onChange:l=>a(l.target.value),onClear:()=>a(""),placeholder:"Search by symbol",rootClassName:ge.search,padding:20,ref:Yt()}),i.length===0?t.jsx(Z,{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:g,value:p=0}=c;return t.jsxs(t.Fragment,{children:[t.jsx(K,{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:w.formatAmount(_,{decimals:g})}),p>0&&t.jsx("div",{className:ge.value,children:Fe(p)})]})]})})},l.denom))})]})},tm=()=>t.jsxs("div",{className:ge.container,children:[t.jsx(Ds,{rootClassName:ge.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(Z,{children:"Loading..."})]});Zt.Placeholder=tm;const sm=({chain:e,onSelect:s})=>{const n=Ia(e);return t.jsx(Zt,{assets:n,onSelect:s})},nm=({afterSelect:e})=>{const{watch:s,setValue:n}=ae.useFormContext(),{chainId:r,denom:o}=s(),{chainId:a}=s(),[i,l]=f.useState(a),c=Me(i),d=ne(),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(dt.Stack,{children:t.jsx(dt,{chains:d,value:i,onSelect:l})}),t.jsx(he,{suspenseFallback:t.jsx(Zt.Placeholder,{}),children:t.jsx(sm,{chain:c,onSelect:u})},i)]})},rm="_fields_brpej_1",om="_divider_brpej_11",sr={fields:rm,divider:om},am=qe.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),im=()=>{const{address:e,initiaAddress:s,estimateGas:n,requestTxSync:r}=je(),{register:o,watch:a,setValue:i,handleSubmit:l,formState:c}=ae.useFormContext(),{chainId:d,denom:u,recipient:h,quantity:m,memo:_}=a(),g=Me(d),p=Nn(g),y=eo(g),k=to(g),S=Ur(u,g),{data:$}=Is(g),{decimals:v}=S,D=p.find(N=>N.denom===u)?.amount??"0",R=$?.find(({id:N})=>N===u)?.price,{data:B=0,isLoading:C}=q.useQuery({queryKey:am.gas({chainId:d,denom:u,recipient:h,initiaAddress:s}).queryKey,queryFn:()=>{const N=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Un.MsgSend.fromPartial({fromAddress:s,toAddress:w.InitiaAddress(h).bech32,amount:[{denom:u,amount:"1"}]})}];return n({messages:N,chainId:d})},enabled:w.InitiaAddress.validate(h),staleTime:z.INFINITY}),j=Math.ceil(B*Ht),I=Eh({denom:u,balances:p,gasPrices:y,lastFeeDenom:k,gas:j}),{mutate:x,isPending:E}=q.useMutation({mutationFn:({chainId:N,denom:F,quantity:A,recipient:H,memo:U})=>{const oe=w.toBaseUnit(A,{decimals:v}),Y=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Un.MsgSend.fromPartial({fromAddress:s,toAddress:w.InitiaAddress(H).bech32,amount:[{denom:F,amount:oe}]})}];return r({messages:Y,memo:U,chainId:N,gas:B,gasAdjustment:Ht,gasPrices:y,spendCoins:[{denom:F,amount:oe}],internal:"/"})}});return t.jsx(pt,{title:"Send",children:t.jsxs("form",{onSubmit:l(N=>x(N)),children:[t.jsxs("div",{className:sr.fields,children:[t.jsx(_n,{selectButton:t.jsx(ht,{title:"Select chain and asset",content:N=>t.jsx(nm,{afterSelect:N}),children:t.jsx(yo,{asset:S,chain:g})}),quantityInput:t.jsx(gs,{balance:D,decimals:v}),balanceButton:t.jsx(jo,{onClick:()=>i("quantity",w.fromBaseUnit(I,{decimals:v}),{shouldValidate:!0}),disabled:y.some(({denom:N})=>N===u)&&C,children:w.formatAmount(D??"0",{decimals:v})}),value:m?R?Fe(M(m).times(R)):"$-":"$0",errorMessage:c.errors.quantity?.message}),t.jsx("div",{className:sr.divider}),t.jsx(Pn,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...o("memo",{validate:N=>!N||new Blob([N]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"}),t.jsx(Ve,{level:"error",children:c.errors.memo?.message})]}),t.jsx(te.Stack,{children:!_&&t.jsx(te,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(se,{children:t.jsx(Q.White,{type:"submit",loading:C||E,disabled:!c.isValid,children:"Confirm"})})]})})},cm=()=>{const e=mt(),s=Vt(),n=Wt(s),[r]=n;if(!r)throw new Error("Asset list not found. This occurs during local development when asset list is not configured. Use asset-specific send buttons instead of the default send button, or register chain in Initia Registry with at least one asset defined.");const{chain:o=s,denom:a=r.denom}=e,i=ae.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:a,quantity:"",recipient:"",memo:""}});return t.jsx(ae.FormProvider,{...i,children:t.jsx(im,{})})},lm="_header_4z0mk_1",dm="_collectionName_4z0mk_6",um="_name_4z0mk_12",hm="_chainInfo_4z0mk_18",mm="_attributes_4z0mk_28",_m="_title_4z0mk_31",fm="_count_4z0mk_36",pm="_item_4z0mk_40",gm="_type_4z0mk_46",xm="_value_4z0mk_52",ke={header:lm,collectionName:dm,name:um,chainInfo:hm,attributes:mm,title:_m,count:fm,item:pm,type:gm,value:xm},ym=()=>{const e=de(),s=mt(),{collection_name:n,image:r,name:o,attributes:a,chain:i}=s;return t.jsxs(pt,{title:"NFT details",children:[t.jsxs("header",{className:ke.header,children:[r&&t.jsx(Dn,{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(K,{src:i.logoUrl,width:14,height:14,logo:!0}),t.jsx("span",{children:i.name})]})]})]}),t.jsx(se,{children:t.jsx(Q.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))})]})]})},jm="_scrollable_1p1lw_1",vm="_list_1p1lw_5",bm="_item_1p1lw_9",wm="_name_1p1lw_13",ls={scrollable:jm,list:vm,item:bm,name:wm};function wo({onSelect:e,list:s,...n}){const{getImage:r,getName:o,getKey:a,getIsLoading:i,getDisabled:l}=n;return t.jsx(Ue,{className:ls.scrollable,children:t.jsx("div",{className:ls.list,children:s.map(c=>t.jsxs("button",{className:ls.item,onClick:()=>e(c),disabled:i?.(c)||l?.(c),children:[t.jsx(K,{src:r(c),width:28,height:28}),t.jsx("span",{className:ls.name,children:o(c)}),i?.(c)&&t.jsx(ft,{size:16})]},a(c)))})})}const Cm="_header_5w36t_1",Im="_name_5w36t_8",Nm="_collection_5w36t_15",Sm="_nft_5w36t_20",km="_fields_5w36t_24",Am="_chain_5w36t_29",wt={header:Cm,name:Im,collection:Nm,nft:Sm,fields:km,chain:Am},$m=qe.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),Tm=()=>{const e=ne(),s=mt(),{chain:n,collection_addr:r,collection_name:o,image:a,name:i}=s,{routerApiUrl:l}=ie(),c=Ss(),d=ye(),{address:u,initiaAddress:h,requestTxSync:m}=je(),{watch:_,setValue:g,handleSubmit:p,formState:y}=ae.useFormContext(),k=_(),{recipient:S,dstChainId:$}=k,v=Me($),D=q.useQuery({queryKey:$m.simulation({collection_addr:r,nft:s,sender:h,recipient:S,srcChain:n,dstChain:v,layer1:d,routerApiUrl:l}).queryKey,queryFn:async()=>{const x={from_address:h,from_chain_id:n.chainId,to_address:w.InitiaAddress(S).bech32,to_chain_id:v.chainId,collection_address:r,token_ids:[s.token_id],object_addresses:[s.object_addr]},{msgs:E}=await X.create({prefixUrl:l}).post("nft",{json:x}).json();return E.map(N=>c.fromAmino(N))},enabled:w.InitiaAddress.validate(S)}),{data:R,isLoading:B,error:C}=D,{mutate:j,isPending:I}=q.useMutation({mutationFn:async()=>{if(!R)throw new Error("Route not found");await m({messages:R,chainId:n.chainId,internal:"/nfts"})}});return t.jsxs("form",{onSubmit:p(()=>j()),children:[t.jsxs("header",{className:wt.header,children:[a&&t.jsx(Dn,{nftInfo:s,size:80}),t.jsxs("div",{className:wt.name,children:[t.jsx("div",{className:wt.collection,children:o}),t.jsx("div",{className:wt.nft,children:i})]})]}),t.jsxs("div",{className:wt.fields,children:[t.jsx(G.VisuallyHidden.Root,{children:t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(ht,{title:"Destination appchain",content:x=>t.jsx(wo,{onSelect:({chainId:E})=>{g("dstChainId",E),x()},list:e,getImage:E=>E.logoUrl,getName:E=>E.name,getKey:E=>E.chainId}),className:P("input",wt.chain),children:[t.jsx(K,{src:v.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:v.name})]})]})}),t.jsx(Pn,{myAddress:u,ref:Yt()})]}),t.jsx(se,{children:t.jsx(Q.White,{loading:B||I,disabled:!y.isValid||!!C,children:C?"Route not found":"Confirm"})})]})},Em=()=>{const{chain:e}=mt(),s=ae.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(pt,{title:"Send NFT",children:t.jsx(ae.FormProvider,{...s,children:t.jsx(Tm,{})})})};function qm(){return ye().network_type==="testnet"}function et(){return ae.useFormContext()}function Dm(){const e=mt(),s=qm(),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=b.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 Co(){const{initiaAddress:e,hexAddress:s}=je(),n=_t(),r=Gt();return o=>{const a=n(o);switch(r(a)){case"initia":return e;case"evm":return s;default:return""}}}function Io(){const e=_t(),s=Gt();return(n,r)=>{const o=e(r);switch(s(o)){case"initia":return w.InitiaAddress.validate(n);case"evm":return Je.isAddress(n);case"cosmos":try{return W.fromBech32(n).prefix===o.bech32_prefix}catch{return!1}default:return!1}}}function Pm(){const e=_t(),s=Gt();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 w.InitiaAddress(n).bech32;if(l==="initia"&&d==="evm")return w.InitiaAddress(n).hex;if(l===d)return n;if(a){if(d==="initia")return w.InitiaAddress(a).bech32;if(d==="evm")return w.InitiaAddress(a).hex}return""}}const Rm=[["d",1440*60],["h",3600],["m",60],["s",1]];function pn(e){if(!e)return;const{formattedParts:s}=Rm.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 No(e){return e?.map(s=>{const{amount:n,origin_asset:r}=s;return`${w.formatAmount(n,{decimals:r.decimals??0})} ${r.symbol}`}).join(", ")}function nr(e,s){const{watch:n}=et(),r=n(),o=Le(),a=ks(),i={...r,quantity:e},l=q.useQueryClient();return q.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},g={amount_in:w.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},p=await o.post("v2/fungible/route",{json:g}).json(),y={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return a("Bridge Simulation Success",y),p},enabled:!!Number(i.quantity)&&!s?.disabled,staleTime:z.MINUTE})}function Bm(e){return q.useQuery({queryKey:Te.routeErrorInfo(e||new Error).queryKey,queryFn:async()=>{if(!e||!(e instanceof X.HTTPError))return null;const{response:s}=e;return(s.headers.get("content-type")??"").includes("application/json")?(await s.json()).info??null:null}})}function Fm(){const{watch:e}=et(),{srcChainId:s,srcDenom:n,dstChainId:r,dstDenom:o}=e(),a=Ee(s),i=Qt(a),l=Be(n,s),c=Be(o,r),d=ye(),u=ne();return i==="initia"&&r===d.chainId&&l.symbol===c.symbol&&u.find(h=>h.chainId===s)?.metadata?.op_denoms?.includes(c.denom)}function Rn(e,s){const n=Le();return q.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:z.SECOND})}function Mm(e,s,n){const{data:r={}}=Rn(e,s);return b.path([n],r)}const Om=({address:e,chain:s,onSelect:n})=>{const r=St(s.chain_id),{data:o={}}=Rn(e,s.chain_id);return t.jsx(Zt,{assets:b.sortWith([b.descend(a=>a.symbol==="INIT"),b.descend(a=>a.value),({balance:a="0"},{balance:i="0"})=>M(i).comparedTo(a)??0,b.ascend(a=>a.symbol.toLowerCase())],r.filter(a=>!a.hidden).map(a=>{const{denom:i,symbol:l=w.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})},Lm=({type:e,afterSelect:s})=>{const n=e==="src"?"srcChainId":"dstChainId",r=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"sender":"recipient",a=Tt(),i=An(),{watch:l,setValue:c}=et(),d=l(o),u=l(n),h=l(r),[m,_]=f.useState(u),g=Ee(m),p=Pm(),y=Qr(),[k,S]=b.partition(v=>y(v.chain_id),i.filter(v=>!v.hidden)),$=v=>{if(u===m&&h===v){s();return}c(n,m),c(r,v),s()};return t.jsxs(t.Fragment,{children:[t.jsxs(dt.Stack,{children:[t.jsx(dt,{label:"Interwoven Economy",chains:k.map(({chain_id:v,chain_name:D,pretty_name:R,logo_uri:B})=>({chainId:v,name:R||D,logoUrl:B??""})),value:m,onSelect:_}),t.jsx(dt,{label:"Chains",chains:S.map(({chain_id:v,chain_name:D,pretty_name:R,logo_uri:B})=>({chainId:v,name:R||D,logoUrl:B??""})),value:m,onSelect:_})]}),t.jsx(he,{suspenseFallback:t.jsx(Zt.Placeholder,{}),children:t.jsx(Om,{address:p({initialAddress:d,initialChainId:u,chainId:m,fallbackAddress:e==="src"?a:void 0}),chain:g,onSelect:$})},m)]})},rr=({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(ht,{title:r,content:d=>t.jsx(Lm,{type:e,afterSelect:d}),children:t.jsx(yo,{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 Rs(){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 Um="_account_iwrlj_8",zm="_clear_iwrlj_27",Km="_white_iwrlj_38",Ot={account:Um,clear:zm,white:Km},or=({type:e})=>{const{watch:s,setValue:n}=et(),{srcChainId:r,dstChainId:o,cosmosWalletName:a}=s(),l=s(e==="src"?"sender":"recipient"),c=Qt(Ee(o)),{list:d,find:u}=Rs(),h=u(a),m=Co(),_=Io(),g=m(o),p=w.InitiaAddress.equals(l,g),y=()=>t.jsx(ht,{title:"Connect wallet",content:$=>t.jsx(wo,{onSelect:async v=>{const D=v.getProvider();if(!D)return window.open(v.fallbackUrl,"_blank");const R=D.getOfflineSigner(r),[{address:B}]=await R.getAccounts();n("sender",B),n("cosmosWalletName",v.name),$()},list:d,getImage:v=>v.image,getName:v=>v.name,getKey:v=>v.name}),className:P(Ot.account,{[Ot.white]:!l}),children:l?t.jsxs(t.Fragment,{children:[h&&t.jsx(K,{src:h.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:w.truncate(l)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(T.IconChevronRight,{size:14})]})}),k=$=>t.jsx(ht,{title:"Recipient",content:v=>t.jsx(Ue,{children:t.jsx(Pn,{mode:"onSubmit",myAddress:g,chainType:c,validate:D=>_(D,o),onApply:v})}),className:Ot.account,children:$}),S=()=>{switch(c){case"initia":case"evm":return p?k(t.jsx(T.IconWallet,{size:14})):t.jsxs("div",{className:Ot.account,children:[t.jsx("span",{className:"monospace",children:w.truncate(l)}),t.jsx("button",{type:"button",className:Ot.clear,onClick:()=>n("recipient",g,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(T.IconCloseCircleFilled,{size:14})})]});case"cosmos":return k(t.jsxs(t.Fragment,{children:[l?t.jsx("span",{className:"monospace",children:w.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx(T.IconEdit,{size:14})]}))}};switch(e){case"src":return y();case"dst":return S()}},Hm="_description_l5bcv_1",Wm="_presets_l5bcv_8",Qm="_preset_l5bcv_8",Vm="_active_l5bcv_29",Gm="_custom_l5bcv_40",Ym="_wrapper_l5bcv_46",Jm="_percent_l5bcv_49",Ae={description:Hm,presets:Wm,preset:Qm,active:Vm,custom:Gm,wrapper:Ym,percent:Jm},ar=["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}=ae.useForm({defaultValues:{value:n}}),d=i("value");f.useEffect(()=>{const p=ar.findIndex(y=>y===n);o(p>=0?p:null)},[n]);const u=(p,y)=>{c("value",p),o(y)},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",g=({value:p})=>{s.setValue("slippagePercent",p),e()};return t.jsxs(Ue,{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:[ar.map((p,y)=>t.jsxs("button",{type:"button",className:P(Ae.preset,{[Ae.active]:r===y}),onClick:()=>u(p,y),children:[p,"%"]},p)),r!==null?t.jsx("button",{type:"button",className:P(Ae.preset,Ae.custom),onClick:()=>o(null),children:"Custom"}):t.jsxs("div",{className:Ae.wrapper,children:[t.jsx(vo,{name:"value",control:a,dp:2,onFocus:h,placeholder:"",className:P(Ae.preset,Ae.active)}),t.jsx("span",{className:Ae.percent,children:"%"})]})]}),m&&t.jsx(te,{level:m.type,children:m.text}),t.jsx(se,{children:t.jsx(Q.White,{type:"button",onClick:()=>g(l()),disabled:_,children:"Confirm"})})]})},Xm="_skeleton_1l4jn_1",e_={skeleton:Xm},nn=({width:e="100%",height:s})=>t.jsx("div",{className:e_.skeleton,style:{width:e,height:s}}),t_="_stack_1ip8h_1",s_="_button_1ip8h_6",n_="_isLoading_1ip8h_19",r_="_disabled_1ip8h_19",o_="_checked_1ip8h_23",a_="_header_1ip8h_37",i_="_title_1ip8h_43",c_="_duration_1ip8h_52",l_="_warning_1ip8h_62",d_="_amount_1ip8h_66",u_="_value_1ip8h_67",pe={stack:t_,button:s_,isLoading:n_,disabled:r_,checked:o_,header:a_,title:i_,duration:c_,warning:l_,amount:d_,value:u_},h_=({children:e})=>t.jsx("div",{className:pe.stack,children:e}),us=({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:P(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(T.IconCheck,{size:14})]}),i?t.jsx(nn,{width:80,height:16}):a?t.jsxs("div",{className:P(pe.duration,{[pe.warning]:n==="op"}),children:[t.jsx(T.IconClockFilled,{size:12}),t.jsx("span",{children:pn(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(nn,{width:260,height:40}):a?w.formatAmount(a.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:pe.value,children:i?t.jsx(nn,{width:120,height:16}):a?a.usd_amount_out?Fe(a.usd_amount_out):"$-":null})]})]})};us.Stack=h_;const m_="_form_1coq4_1",__="_arrow_1coq4_5",f_="_divider_1coq4_13",p_="_flip_1coq4_21",g_="_meta_1coq4_37",x_="_row_1coq4_50",y_="_title_1coq4_56",j_="_description_1coq4_60",v_="_icon_1coq4_67",b_="_edit_1coq4_72",w_="_warning_1coq4_93",ue={form:m_,arrow:__,divider:f_,flip:p_,meta:g_,row:x_,title:y_,description:j_,icon:v_,edit:b_,warning:w_},C_=()=>{const e=de(),s=Es(),[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:g,slippagePercent:p}=c,y=Xe(),k=Ee(d),S=Qt(k),$=Ee(h),v=Qt($),D=Be(u,d),R=Be(m,h),{data:B}=Rn(g,d),C=Mm(g,d,u),[j]=Ce.useDebounceValue(_,300),I=S!=="initia"&&v!=="initia",x=Fm(),E=nr(j,{disabled:I}),N=nr(j,{isOpWithdraw:!0,disabled:!x}),F=x&&n==="op"?N:E,{data:A,isLoading:H,isFetching:U,error:oe}=F,{data:Y}=Bm(oe),tt=j&&(H||U),Dt=()=>{a("srcChainId",h),a("srcDenom",m),a("dstChainId",d),a("dstDenom",u),a("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:xt,closeModal:yt}=Cs(),Ie=i(L=>{if(A?.warning){const{type:st="",message:Os}=A.warning??{};xt({content:t.jsx(lo,{type:"warning",icon:t.jsx(T.IconWarningFilled,{size:40}),title:js.sentenceCase(st),primaryButton:{label:"Cancel",onClick:yt},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:A,values:L}),yt()}},children:t.jsx("p",{className:ue.warning,children:Os})})});return}e("/bridge/preview",{route:A,values:L})}),me=f.useMemo(()=>A?.estimated_fees?.filter(({fee_behavior:L})=>L==="FEE_BEHAVIOR_DEDUCTED")??[],[A]),ze=f.useMemo(()=>A?.estimated_fees?.filter(({fee_behavior:L})=>L==="FEE_BEHAVIOR_ADDITIONAL")??[],[A]),jt=f.useMemo(()=>{for(const L of ze){const st=B?.[L.origin_asset.denom]?.amount??"0",Os=A?.source_asset_denom===L.origin_asset.denom?A.amount_in:"0";if(M(st).lt(M(Os).plus(L.amount??"0")))return`Insufficient ${L.origin_asset.symbol} for fees`}},[B,A,ze]),Xt=f.useMemo(()=>{if(!c.sender)return"Connect wallet";if(!c.quantity||!j)return"Enter amount";if(!c.recipient)return"Enter recipient address";if(l.errors.quantity)return l.errors.quantity.message;if(!A)return"Route not found";if(jt)return jt},[j,jt,l,A,c]),Ro=A?w.formatAmount(A.amount_out,{decimals:R.decimals}):"0",Bo=M(_).gt(0)&&M(_).isEqualTo(w.fromBaseUnit(C?.amount,{decimals:C?.decimals??0})),Fo=(()=>{switch(S){case"initia":return y(d).fees.fee_tokens.some(({denom:L})=>L===u);case"cosmos":return k.fee_assets.some(({denom:L})=>L===u);case"evm":return!Je.isAddress(u);default:return!1}})(),Ms=f.useCallback((L,st)=>L.length?t.jsxs("div",{className:ue.description,children:[No(L),!s&&t.jsx(Jt,{label:st,children:t.jsx("span",{className:ue.icon,children:t.jsx(T.IconInfoFilled,{size:12})})})]}):null,[s]),es=M(_).gt(0)&&x,Fn=f.useMemo(()=>A?[{condition:!!A.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Ms(me,"Fee deducted from the amount you receive"),Ms(ze,"Fee charged in addition to the amount you enter")]})},{condition:!es&&!!pn(A.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:ue.description,children:pn(A.estimated_route_duration_seconds)})},{condition:A.does_swap,title:"Slippage",content:t.jsxs("span",{className:ue.description,children:[t.jsxs("span",{children:[p,"%"]}),t.jsx(ht,{title:"Slippage tolerance",content:L=>t.jsx(Zm,{afterConfirm:L}),className:ue.edit,children:t.jsx(T.IconSettingFilled,{size:12})})]})}].filter(L=>L.condition):[],[ze,me,Ms,A,es,p]);return t.jsxs("form",{className:ue.form,onSubmit:Ie,children:[t.jsx(_n,{selectButton:t.jsx(rr,{type:"src"}),accountButton:S==="cosmos"&&t.jsx(or,{type:"src"}),quantityInput:t.jsx(gs,{balance:C?.amount,decimals:D?.decimals}),balanceButton:t.jsx(jo,{onClick:()=>a("quantity",w.fromBaseUnit(C?.amount,{decimals:D?.decimals??0}),{shouldValidate:!0}),children:w.formatAmount(C?.amount??"0",{decimals:D.decimals})}),value:A?A.usd_amount_in?Fe(A.usd_amount_in):"$-":"$0"}),t.jsxs("div",{className:ue.arrow,children:[t.jsx("div",{className:ue.divider}),t.jsx("button",{type:"button",className:ue.flip,onClick:()=>Dt(),children:t.jsx(T.IconChevronDown,{size:16})})]}),t.jsx(_n,{selectButton:t.jsx(rr,{type:"dst"}),accountButton:t.jsx(or,{type:"dst"}),quantityInput:t.jsx(gs.ReadOnly,{children:Ro}),value:A?A.usd_amount_out?Fe(A.usd_amount_out):"$-":"$0",hideNumbers:es}),t.jsx(un,{children:es?t.jsxs(us.Stack,{children:[t.jsx(us,{label:"Fast",query:E,value:"default",onSelect:r,checked:n==="default"}),t.jsx(us,{label:"Lossless",query:N,value:"op",onSelect:r,checked:n==="op"})]}):null}),t.jsx(se,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(te.Stack,{children:[A?.extra_infos?.map(L=>t.jsx(te,{level:"info",children:L},L)),Y&&t.jsx(te,{level:"info",children:Y}),Bo&&Fo&&t.jsx(te,{level:"warning",children:"Make sure to leave enough for transaction fee"}),A?.warning&&t.jsx(te,{level:"warning",children:A.warning.message}),A?.extra_warnings?.map(L=>t.jsx(te,{level:"warning",children:L},L))]}),t.jsx(un,{children:Fn.length>0&&t.jsx("div",{className:ue.meta,children:Fn.map((L,st)=>t.jsxs("div",{className:ue.row,children:[t.jsx("span",{className:ue.title,children:L.title}),L.content]},st))})})]}),children:t.jsx(Q.White,{loading:tt&&"Simulating...",disabled:!!Xt,children:Xt??"Preview route"})})]})},I_=()=>{uo();const e=Xo(),s=de(),{closeDrawer:n}=$t(),r=Tt(),o=Dm(),a=ae.useForm({mode:"onChange",defaultValues:o}),{watch:i,setValue:l}=a,{srcChainId:c,dstChainId:d,srcDenom:u,dstDenom:h,quantity:m,slippagePercent:_,recipient:g}=i();i((I,{name:x})=>{(x==="srcChainId"||x==="srcDenom")&&l("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=Co(),y=p(c),k=p(d),$=Io()(g,d);f.useEffect(()=>{l("cosmosWalletName",void 0),l("sender",y)},[c,y,l]),f.useEffect(()=>{$||l("recipient",k)},[k,$,l]);const v=St(c),D=St(d),R=f.useMemo(()=>{if(!v.find(I=>I.denom===u))return`${u} is not available for bridge/swap on ${c}`;if(!D.find(I=>I.denom===h))return`${h} is not available for bridge/swap on ${d}`},[D,d,h,v,c,u]);f.useEffect(()=>{R||(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,_,R]);const B=e[0].path==="/bridge",C=()=>t.jsxs(t.Fragment,{children:[t.jsx(Z,{error:!0,children:R}),t.jsx(se,{children:B?t.jsx(Q.White,{onClick:n,children:"Close"}):t.jsx(Q.White,{onClick:()=>s(-1),children:"Go back"})})]}),{reminders:j}=Et();return t.jsx(pt,{title:"Bridge/Swap",backButton:B?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(Q.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(bo,{offset:0,disabled:j.length===0,children:t.jsx(Q.Small,{onClick:()=>s("/op/withdrawals"),disabled:!r,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:R?C():t.jsx(ae.FormProvider,{...a,children:t.jsx(he,{children:t.jsx(C_,{})})})})},N_="_button_1iys9_1",S_={button:N_},So=({onClick:e,disabled:s})=>{const{ref:n,inView:r}=Qo.useInView();return f.useEffect(()=>{r&&e()},[r,e]),t.jsxs("button",{className:S_.button,onClick:e,disabled:s,ref:n,children:[t.jsx("span",{children:"Load more"}),t.jsx(T.IconChevronDown,{size:12})]})},gt=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 Bs(){const{restUrl:e}=ye();return f.useMemo(()=>X.create({prefixUrl:e}),[e])}function k_(e){const s=Bs(),{data:n}=q.useSuspenseQuery({queryKey:gt.bridge(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:z.INFINITY});return n}const ir=20;function A_(e){const s=re();return q.useSuspenseInfiniteQuery({queryKey:gt.withdrawals(e,s).queryKey,queryFn:async({pageParam:n})=>{if(!s)return[];const r={limit:ir,offset:n,order:"desc"},{withdrawals:o}=await X.create({prefixUrl:e}).get(`withdrawals/${s}`,{searchParams:r}).json();return o},getNextPageParam:n=>{const r=b.last(n)?.sequence;return n.length<ir||!r||r<=1?null:r-1},initialPageParam:0,staleTime:z.SECOND})}function $_(e){const s=Bs(),{data:n}=q.useSuspenseQuery({queryKey:gt.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:z.SECOND});return n}function T_({bridge_id:e,output_index:s}){const n=Bs(),{data:r}=q.useSuspenseQuery({queryKey:gt.output(e,s).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${e}/outputs/${s}`).json()}catch{return null}},staleTime:z.SECOND});return r}function E_({bridge_id:e,sequence:s}){const r=ne().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=Xe()(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}=q.useSuspenseQuery({queryKey:gt.outputResponse(i,s).queryKey,queryFn:()=>X.create({prefixUrl:i}).get(`withdrawal/${s}`).json(),staleTime:z.SECOND});return l}function ko(e,s){const{bridge_id:n}=e,r=Bs(),{data:o}=q.useSuspenseQuery({queryKey:gt.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:z.SECOND});return o}function Lt(e){return Vo.sha3_256.create().update(e).digest()}function rn(e,s){const n=new ArrayBuffer(s);return new DataView(n).setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}function Ao(e){const{bridge_id:s,sequence:n,amount:r,from:o,to:a}=e,i=rn(s.toString(),8),l=rn(n.toString(),8),c=rn(r.amount,8),d=ts.concatBytes(i,l,Lt(ts.utf8ToBytes(o)),Lt(ts.utf8ToBytes(a)),Lt(ts.utf8ToBytes(r.denom)),c);return Lt(Lt(d))}const $o=f.createContext(null);function Fs(){return f.useContext($o)}const q_="_asset_6h8u2_1",D_="_info_6h8u2_7",P_="_symbol_6h8u2_11",on={asset:q_,info:D_,symbol:P_},R_=({amount:e,denom:s})=>{const n=ye(),r=Ur(s,n),{symbol:o,logoUrl:a,decimals:i}=r;return t.jsxs("div",{className:on.asset,children:[t.jsx(K,{src:a,width:32,height:32,logo:!0}),t.jsxs("div",{className:on.info,children:[t.jsx("span",{className:"monospace",children:w.formatAmount(e,{decimals:i})}),t.jsx("span",{className:on.symbol,children:o})]})]})},B_=({children:e})=>{const{withdrawalTx:s}=Fs(),n=$_(s.bridge_id),r=s.output_index>Number(n?.output_index);return e(r)},F_="_container_1oldz_1",M_="_icon_1oldz_7",cr={container:F_,icon:M_},O_="Withdrawal will begin within an hour",lr=()=>{const e=Es();return t.jsxs("div",{className:cr.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Jt,{label:O_,children:t.jsx("span",{className:cr.icon,children:t.jsx(T.IconInfoFilled,{size:12})})})]})},To=1e3,L_=60,U_=60,z_=24,gn=To*L_,xn=gn*U_,dr=xn*z_,K_=({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/dr),_=Math.floor(h%dr/xn),g=Math.floor(h%xn/gn),p=Math.floor(h%gn/To);return{days:m,hours:_,minutes:g,seconds:p}},[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(Jt,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[a,"d ",o(i),"h ",o(l),"m ",o(c),"s"]})})},H_="_container_1lz3w_1",W_="_title_1lz3w_5",ur={container:H_,title:W_},Q_=({date:e})=>t.jsxs("div",{className:ur.container,children:[t.jsx("div",{className:ur.title,children:"Claimable in"}),t.jsx(K_,{date:e})]}),V_=({children:e})=>{const{withdrawalTx:s}=Fs(),n=k_(s.bridge_id),r=T_(s),o=f.useMemo(()=>{if(!r)return null;const{bridge_config:a}=n,{output_proposal:i}=r;return kt.addSeconds(new Date(i.l1_block_time),parseFloat(a.finalization_period))},[n,r]);return e(o)},G_=({date:e,children:s})=>{const{chainId:n,withdrawalTx:r}=Fs(),o=W.toBase64(Ao(r)),a=ko(r,o),{setReminder:i,removeReminder:l}=Et();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:kt.isPast(e.getTime())?!0:void 0})},[n,a,e,l,i,r]),s},Y_="_button_1btdg_1",J_="_claimed_1btdg_23",hr={button:Y_,claimed:J_},Z_=()=>{const{withdrawalTx:e}=Fs(),{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=re(),{requestTxSync:m,waitForTxConfirmation:_}=je(),g=E_(e),p=W.toBase64(Ao(e)),y=ko(e,p),k=q.useQueryClient(),{mutate:S,isPending:$}=q.useMutation({mutationFn:async()=>{if(!g)throw new Error("Output not found");const{last_block_hash:v}=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(W.fromBase64),from:l,to:c,sequence:BigInt(n),amount:r,version:W.fromBase64(d),storageRoot:W.fromBase64(i),lastBlockHash:W.fromBase64(v)}}],internal:!0})},onSuccess:async v=>{await _({chainId:u.chain_id,txHash:v}),k.invalidateQueries({queryKey:gt.withdrawalClaimed(s,p).queryKey})}});return y?t.jsxs("div",{className:hr.claimed,children:[t.jsx(T.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:hr.button,onClick:()=>S(),disabled:$,children:"Claim"})},X_=()=>t.jsx(B_,{children:e=>e?t.jsx(lr,{}):t.jsx(V_,{children:s=>s?t.jsx(G_,{date:s,children:kt.isFuture(s)?t.jsx(Q_,{date:s}):t.jsx(Z_,{})}):t.jsx(lr,{})})}),ef="_item_km5w2_1",tf={item:ef},sf=({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}=A_(s),i=f.useMemo(()=>n?.pages.flat()??[],[n]),{syncReminders:l}=Et();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:tf.item,children:[t.jsx(R_,{...d}),t.jsx(he,{suspenseFallback:null,children:t.jsx($o.Provider,{value:{chainId:e.chainId,withdrawalTx:c},children:t.jsx(X_,{})})})]},c.sequence)}),o&&t.jsx(So,{onClick:()=>r(),disabled:a})]}):t.jsx(Z,{children:"No withdrawals"})},nf="_content_dj1qm_1",rf="_title_dj1qm_5",mr={content:nf,title:rf},of=()=>{const{chainId:e}=mt(),s=ne(),n=Vt(),[r,o]=f.useState(e??(n.metadata?.is_l1?"":n.chainId)),a=Xe(),{reminders:i}=Et(),l=r?a(r):void 0;return t.jsxs(pt,{title:"OP Bridge withdrawals",children:[t.jsx(dt,{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:mr.content,children:l?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:mr.title,children:l.name}),t.jsx(he,{children:t.jsx(sf,{chain:l})},r)]}):t.jsx(te,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})};async function af(e,s){const n=X.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 hs=({chainId:e,txHash:s})=>`${O.BRIDGE_HISTORY}:${e}:${s}`,xs=100,_r=10;function Eo(){const[e,s]=Ce.useLocalStorage(O.BRIDGE_HISTORY,[]),n=f.useCallback((o,a)=>{localStorage.setItem(hs(o),JSON.stringify(a));for(const i of e.slice(xs-1))localStorage.removeItem(hs(i));s((i=[])=>[o,...i.slice(0,xs-1)])},[e,s]),r=f.useCallback(o=>{const a=localStorage.getItem(hs(o));return a?JSON.parse(a):null},[]);return{history:e,addHistoryItem:n,getHistoryDetails:r}}function qo(e){return Ce.useLocalStorage(hs(e),null)}async function yn(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(b.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 qt(){return mt()}function cf(e){const s=de(),{showNotification:n,updateNotification:r,hideNotification:o}=Tn(),{addHistoryItem:a}=Eo(),i=ks(),{route:l,values:c}=qt(),{srcChainId:d,sender:u,recipient:h,cosmosWalletName:m}=c,_=qr(),{requestTxSync:g,waitForTxConfirmation:p}=je(),{find:y}=Rs(),k=Ns(),S=Ss(),$=Ee(d),v=Qt($),D=Vr(d),R=q.useQueryClient(),{registryUrl:B}=ie(),C=Xe(),{addReminder:j}=Et(),I=Le();return q.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const x=e.cosmos_tx.msgs.map(({msg_type_url:Ie,msg:me})=>{if(!(Ie&&me))throw new Error("Invalid transaction data");return S.fromAmino({type:Kt.aminoConverters[Ie].aminoType,value:JSON.parse(me)})});if(v==="initia"){const{srcDenom:Ie,quantity:me}=c,{decimals:ze}=D(Ie),jt=await g({messages:x,chainId:d,internal:1,spendCoins:[{denom:Ie,amount:w.toBaseUnit(me,{decimals:ze})}]}),Xt=p({txHash:jt,chainId:d});return{txHash:jt,wait:Xt}}const E=y(m)?.getProvider();if(!E)throw new Error("Wallet not connected");const N=E.getOfflineSignerOnlyAmino(d),F=await $e.SigningStargateClient.connectWithSigner($.rpc,N,{registry:k,aminoTypes:S}),A=await F.getAllBalances(u),H=$.fee_assets.find(Ie=>A.some(me=>me.denom===Ie.denom&&M(me.amount).gt(0)));if(!H){const me=["Insufficient balance for fees.",`Available fee assets: ${$.fee_assets.map(ze=>D(ze.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(me)}const{denom:U,gas_price:oe}=H;if(!oe)throw new Error(`Gas price not found for ${U}`);const Y=await F.simulate(u,x,""),tt=$e.GasPrice.fromString(oe.average+U),Dt=$e.calculateFee(Math.ceil(Y*Ht),tt),xt=await F.signAndBroadcastSync(u,x,Dt),yt=Mr({txHash:xt,client:F});return{txHash:xt,wait:yt}}if("evm_tx"in e){const{chain_id:x,to:E,value:N,data:F}=e.evm_tx,A=await _(),H=await A.getSigner();await yn(A,$);const U=await H.sendTransaction({chainId:x,to:E,value:N,data:`0x${F}`});return{txHash:U.hash,wait:U.wait()}}throw new Error("Unlisted chain type")}catch(x){throw await Re(x)}},onSuccess:async({txHash:x,wait:E})=>{localStorage.removeItem(O.BRIDGE_QUANTITY),s(-1),n({type:"loading",title:"Transaction is pending..."});try{await E;const N=Bn(l)==="OP Bridge withdrawal",F=N?{success:!0,error:null}:await mf(I,x,d);if(!F.success&&F.error){const Y=F.error instanceof Error?F.error.message:String(F.error);n({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${Y}. The transaction may still be processing.`,autoHide:!0})}const A=F.success,U=uf({txHash:x,srcChainId:d,route:l,values:c,recipient:h},A);a(U.tx,U.details),r(df(o));const oe=an(c,x);if(i("Bridge Transaction Success",oe),N){const Y=hf(U.tx,l,h);j(U.tx,Y)}}catch(N){const F=N instanceof Error?N.message:String(N);r({type:"error",title:"Transaction not confirmed",description:F});const A={...an(c,x),error:F};i("Bridge Confirmation Failed",A)}finally{R.invalidateQueries({queryKey:Te.balances(d,u).queryKey})}},onError:async x=>{const E=v==="initia"?await Ct(x,C(d),B):x;n({type:"error",title:"Transaction failed",description:E.message});const N=an(c);i("Bridge Transaction Failed",{...N,error:E.message})}})}function lf(){const e=Le(),s=re(),n=Cn(),{route:r,values:o}=qt(),a=_t();return q.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:w.InitiaAddress(o.recipient).bech32,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom}}).json();await af(s,a(r.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:h,msg:m})=>Kt.aminoTypes.fromAmino({type:Kt.aminoConverters[h].aminoType,value:JSON.parse(m)})),d=await n(i,s,c,{amount:[],gas:"1"},"",{incrementSequence:i===o.srcChainId?2:0}),u=Ge.Tx.fromPartial({body:Ge.TxBody.decode(d.bodyBytes),authInfo:Ge.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:s,hook:W.toBase64(Ge.Tx.encode(u).finish())}}catch(i){throw await Re(i)}}})}function df(e){return{type:"info",title:"Transaction submitted",description:f.createElement(f.Fragment,null,"Check ",f.createElement(bn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function an(e,s){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:s}}function uf(e,s){const{txHash:n,srcChainId:r,route:o,values:a}=e,i={chainId:r,txHash:n},l=Bn(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 hf(e,s,n){return{...e,recipient:w.InitiaAddress(n).bech32,claimableAt:Date.now()+s.estimated_route_duration_seconds*1e3,amount:s.amount_out,denom:s.dest_asset_denom}}async function mf(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 _f(e){const{chainId:s,txHash:n,tracked:r}=e,o=Le();return q.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:z.INFINITY,enabled:!r})}function ff(e){const{timestamp:s,chainId:n,txHash:r,tracked:o,state:a}=e,i=Le();return q.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:z.INFINITY})}var ms=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(ms||{});function Bn(e){const{operations:s,dest_asset_denom:n}=e;return b.has("op_init_transfer",b.head(s))&&n==="uinit"?"OP Bridge withdrawal":"Skip"}const pf="_content_c0tee_1",gf="_info_c0tee_6",xf="_arrow_c0tee_11",yf="_divider_c0tee_19",jf="_type_c0tee_26",vf="_asset_c0tee_44",bf="_amount_c0tee_52",wf="_lower_c0tee_57",Cf="_chain_c0tee_63",If="_address_c0tee_69",fe={content:pf,info:gf,arrow:xf,divider:yf,type:jf,asset:vf,amount:bf,lower:wf,chain:Cf,address:If},Do=e=>{const{source:s,label:n,amount:r,denom:o,chainId:a,address:i,walletIcon:l}=e,{symbol:c=w.truncate(o),decimals:d=0,logo_uri:u=In}=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(Jt,{label:n,children:t.jsx("button",{className:fe.type,children:t.jsx(T.IconArrowDown,{size:12})})}):t.jsx("span",{className:fe.type,children:t.jsx(T.IconArrowDown,{size:12})}),t.jsx("div",{className:fe.divider})]}),t.jsxs("div",{className:fe.content,children:[t.jsx(Ps,{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:w.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(ps,{value:i,children:({copy:g,copied:p})=>t.jsxs("button",{className:fe.address,onClick:g,children:[l,p?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:w.truncate(i)})]})})]})]})]})]})},Nt=e=>{const s=Be(e.denom,e.chainId);return t.jsx(Do,{...e,...s})};Nt.Placeholder=Do;const Nf="_root_1l4he_1",Sf="_flexEnd_1l4he_6",kf="_toggle_1l4he_11",Af="_route_1l4he_34",$f="_content_1l4he_41",Ut={root:Nf,flexEnd:Sf,toggle:kf,route:Af,content:$f};function Tf(e){const s=({name:n})=>n==="initia-dex"?"Initia DEX":js.capitalCase(b.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 Ef=({addressList:e})=>{const{values:s,route:n}=qt(),{source_asset_denom:r,source_asset_chain_id:o,amount_in:a,operations:i}=n,l=b.zipObj(n.required_chain_addresses,e),{find:c}=Rs(),{connector:d,address:u=""}=xe.useAccount(),[h,m]=Ce.useToggle(!1),_=i.length>1,g=t.jsx(K,{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},y=D=>w.InitiaAddress.equals(D,u)?g:t.jsx(T.IconWallet,{size:11}),k=D=>{const{label:R,amount_out:B,denom:C,denom_out:j=C,chain_id:I,from_chain_id:x,to_chain_id:E=I??x}=D,N=l[E];return{label:_&&!h?void 0:R,amount:B,denom:j,chainId:E,address:N,walletIcon:y(N)}},S=i.map(Tf).map(k),$=S.slice(0,-1),v=S[S.length-1];return t.jsxs(G.Collapsible.Root,{className:Ut.root,open:h,onOpenChange:m,children:[_&&t.jsx("div",{className:Ut.flexEnd,children:t.jsx(G.Collapsible.Trigger,{className:Ut.toggle,children:h?t.jsxs(t.Fragment,{children:[t.jsx(T.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(T.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:Ut.route,children:[t.jsx(Nt,{...p,source:!0}),t.jsx(G.Collapsible.Content,{className:Ut.content,children:$.map((D,R)=>t.jsx(he,{suspenseFallback:t.jsx(Nt.Placeholder,{...D}),errorBoundaryProps:{fallback:t.jsx(Nt.Placeholder,{...D})},children:t.jsx(Nt,{...D})},R))}),t.jsx(Nt,{...v})]})]})},jn=({error:e})=>{const s=de();return t.jsx(se,{extra:t.jsx(te,{level:"error",children:e.message}),children:t.jsx(Q.White,{onClick:()=>s("/bridge"),children:"Home"})})},qf=({children:e})=>{const s=qt(),{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=At(),m=_t(),_=Gt(),g=m(a),p=_(g),y=o.slice(0,-1).some(B=>{const C=m(B);return _(C)==="cosmos"})&&p!=="cosmos",[k,S]=f.useState(void 0),[$,v]=f.useState(!1),[D,R]=f.useState(null);if(f.useEffect(()=>{(async()=>{try{if(!y)return;if(!h)throw new Error("Wallet not connected");v(!0),R(null);const[{pubkey:C}]=await h.getAccounts();S(C)}catch(C){R(await Re(C))}finally{v(!1)}})()},[y,h]),D)return t.jsx(jn,{error:D});if($)return t.jsx(se,{children:t.jsx(Q.White,{loading:$&&"Generating intermediary addresses..."})});if(!y||k){const B=o.map((C,j)=>{if(j===o.length-1){const F=m(i);return _(F)==="initia"?w.InitiaAddress(c).bech32:c}const I=m(C),x=_(I),E=m(a),N=_(E);switch(x){case"initia":return d;case"evm":return u;case"cosmos":{if(N==="cosmos")return W.toBech32(I.bech32_prefix,W.fromBech32(l).data);if(!k)throw new Error("Pubkey not found");return zt.pubkeyToAddress(zt.encodeSecp256k1Pubkey(k),I.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(B)}return null},Df=({addressList:e,signedOpHook:s,children:n})=>{const r=Le(),{route:o,values:a}=qt(),[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:g}=await r.post("v2/fungible/msgs",{json:_}).json();if(!g||g.length===0)throw new Error("No transaction data found");const[p]=g;l(p)}catch(_){h(_)}finally{d(!1)}})()},[o,a,e,s,r]),u?t.jsx(jn,{error:u}):c?t.jsx(se,{children:t.jsx(Q.White,{loading:c&&"Fetching messages..."})}):i?n(i):t.jsx(jn,{error:new Error("Failed to fetch messages")})},Pf=({children:e})=>{const{route:s}=qt(),n=lf();return s.required_op_hook&&!n.data?t.jsx(se,{extra:t.jsx(te,{level:"error",children:n.error?.message}),children:t.jsx(Q.White,{onClick:()=>n.mutate(),loading:n.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(n.data)},Rf=({tx:e,children:s})=>{const n=qr(),r=_t(),{data:o,isLoading:a}=q.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 yn(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 p=>{const{token_contract:y,spender:k}=p,$=await new Je.ethers.Contract(y,_,m).allowance(h,k);return{approval:p,currentAllowance:BigInt($.toString())}}))).filter(({approval:p,currentAllowance:y})=>y<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}=q.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 yn(h,r(u));for(const _ of o){const{token_contract:g,spender:p,amount:y}=_,k=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new Je.ethers.Contract(g,k,m).approve(p,y)).wait()}return!0}catch(u){throw await Re(u)}}});return a?t.jsx(se,{children:t.jsx(Q.White,{loading:"Checking approvals..."})}):o&&o.length>0&&!l?t.jsx(se,{extra:t.jsx(te,{level:"error",children:d?.message}),children:t.jsx(Q.White,{onClick:()=>i(),loading:c&&"Approving tokens...",children:"Approve tokens"})}):s},Bf=({tx:e})=>{const{mutate:s,isPending:n}=cf(e);return t.jsx(se,{children:t.jsx(Q.White,{onClick:()=>s(),loading:n&&"Signing transaction...",children:"Confirm"})})},Ff=()=>t.jsx(pt,{title:"Route preview",children:t.jsx(qf,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(Ef,{addressList:e}),t.jsx(Pf,{children:s=>t.jsx(Df,{addressList:e,signedOpHook:s,children:n=>t.jsx(Rf,{tx:n,children:t.jsx(Bf,{tx:n})})})})]})})}),Mf="_button_14cv7_1",Of="_checkbox_14cv7_10",Lf="_checked_14cv7_23",ds={button:Mf,checkbox:Of,checked:Lf},Uf=({checked:e,onClick:s,label:n,className:r})=>t.jsxs("button",{type:"button",className:P(ds.button,r),onClick:s,children:[t.jsx("div",{className:P(ds.checkbox,{[ds.checked]:e}),children:e&&t.jsx(T.IconCheck,{size:12})}),t.jsx("span",{className:ds.label,children:n})]}),zf="_success_t4dfk_1",Kf="_error_t4dfk_5",fr={success:zf,error:Kf},Hf=({tx:e})=>{const[s,n]=qo(e);if(!s)throw new Error("Bridge history details not found");const{data:r}=ff(s),o=s.state??Wf(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:fr.error,children:t.jsx(T.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:fr.success,children:t.jsx(T.IconCheckCircleFilled,{size:14})});default:return t.jsx(ft,{size:14})}};function Wf(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 Qf="_link_12p3n_1",Vf="_header_12p3n_22",Gf="_title_12p3n_30",Yf="_date_12p3n_36",Jf="_explorer_12p3n_40",Zf="_fees_12p3n_55",Xf="_label_12p3n_63",ep="_content_12p3n_67",tp="_route_12p3n_73",sp="_row_12p3n_78",np="_asset_12p3n_84",rp="_amount_12p3n_92",op="_chain_12p3n_97",ap="_account_12p3n_106",ip="_arrow_12p3n_113",ee={link:Qf,header:Vf,title:Gf,date:Yf,explorer:Jf,fees:Zf,label:Xf,content:ep,route:tp,row:sp,asset:np,amount:rp,chain:op,account:ap,arrow:ip},cp=({tx:e})=>{const[s,n]=qo(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}=_f(s),{address:u="",connector:h}=xe.useAccount(),{find:m}=Rs();f.useEffect(()=>{d&&n(A=>{if(!A)throw new Error("Bridge history details not found");return{...A,tracked:!0}})},[n,d]);const{amount_in:_,amount_out:g,source_asset_chain_id:p,source_asset_denom:y,dest_asset_chain_id:k,dest_asset_denom:S,estimated_fees:$=[]}=a,v=Ee(p),D=Ee(k),R=Be(y,p),B=Be(S,k),C=(A,H)=>H?t.jsx(K,{src:H,width:12,height:12}):w.InitiaAddress.equals(A,u)?t.jsx(K,{src:h?.icon,width:12,height:12}):t.jsx(T.IconWallet,{size:12}),j=(A,{symbol:H,decimals:U,logo_uri:oe},{chain_name:Y,pretty_name:tt,...Dt},xt,yt)=>t.jsxs("div",{className:ee.row,children:[t.jsx(Ps,{assetLogoUrl:oe,chainLogoUrl:Dt.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:ee.asset,children:[t.jsx("span",{className:ee.amount,children:w.formatAmount(A,{decimals:U})}),t.jsx("span",{children:H})]}),t.jsxs("div",{className:ee.chain,children:[t.jsxs("span",{children:["on ",tt||Y]}),t.jsxs("div",{className:ee.account,children:[yt,t.jsx("span",{className:"monospace",children:w.truncate(xt)})]})]})]})]}),I=Bn(a),x=f.useMemo(()=>{switch(I){case ms.SKIP:return"Skip Explorer";case ms.OP_WITHDRAW:return"Initia Scan"}},[I]),E=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:ee.header,children:[t.jsxs("div",{className:ee.title,children:[c?t.jsx(Hf,{tx:e}):t.jsx(ft,{size:14}),t.jsx("div",{className:ee.date,children:kt.format(new Date(l),"h:mm a")})]}),t.jsxs("div",{className:ee.explorer,children:[t.jsx("span",{children:x}),t.jsx(T.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:ee.route,children:[j(_,R,v,i.sender,C(i.sender,m(i.cosmosWalletName)?.image)),t.jsx("div",{className:ee.arrow,children:t.jsx(T.IconArrowDown,{size:12})}),j(g,B,D,i.recipient,C(i.recipient))]}),$.length>0&&t.jsxs("div",{className:ee.fees,children:[t.jsx("span",{className:ee.label,children:"Fees"}),t.jsx("span",{className:ee.content,children:No($)})]})]});if(I===ms.OP_WITHDRAW)return t.jsx(qs,{chainId:r,txHash:o,className:ee.link,children:E});const N=new URLSearchParams({tx_hash:o,chain_id:r}),F=new URL(`?${N.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:F.toString(),className:ee.link,target:"_blank",children:E})},lp="_history_13u9z_1",dp="_header_13u9z_5",up="_checkbox_13u9z_9",hp="_groups_13u9z_13",mp="_dateGroup_13u9z_21",_p="_dateHeader_13u9z_26",fp="_list_13u9z_32",it={history:lp,header:dp,checkbox:up,groups:hp,dateGroup:mp,dateHeader:_p,list:fp},pp=()=>{const{initiaAddress:e,hexAddress:s}=je(),{history:n,getHistoryDetails:r}=Eo(),o=n.filter(_=>r(_)),a=o.filter(_=>{const g=r(_);if(!g)return!1;const{values:p}=g,{sender:y,recipient:k}=p;return[y,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*_r),m=f.useMemo(()=>go(h,_=>{const g=r(_);if(g)return new Date(g.timestamp)}),[h,r]);return t.jsx(pt,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:it.history,children:[o.length>0&&o.length!==a.length&&t.jsx("header",{className:it.header,children:t.jsx(Uf,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:it.checkbox})}),u.length===0?t.jsx(Z,{children:"No bridge/swap activity"}):t.jsx("div",{className:it.groups,children:Object.entries(m).map(([_,g])=>t.jsxs("div",{className:it.dateGroup,children:[t.jsx("div",{className:it.dateHeader,children:_}),t.jsx("div",{className:it.list,children:g.map(p=>t.jsx(he,{children:t.jsx(cp,{tx:p})},p.txHash))})]},_))}),u.length>i*_r?t.jsx(So,{onClick:()=>l(_=>_+1)}):n.length>=xs&&t.jsxs(Z,{children:["Only the latest ",xs," items are stored. Older entries will be removed automatically."]})]})})},Po=()=>{const e=de(),s=ws(),n=Tt(),{closeDrawer:r}=$t(),{closeModal:o}=Cs();f.useEffect(()=>{o(),s.startsWith("/bridge/")&&e("/bridge"),(s==="/collection"||s.startsWith("/nft"))&&e("/nfts")},[n]);const a=ks();if(f.useEffect(()=>{a("Page View")},[s,a]),s==="/connect")return n?null:t.jsx(Yn,{onSuccess:r});if(s==="/blank")return null;if(!n)return t.jsx(Yn,{});switch(s){case"/":case"/nfts":case"/activity":return t.jsx(eh,{});case"/send":return t.jsx(cm,{},n);case"/nft":return t.jsx(ym,{});case"/nft/send":return t.jsx(Em,{},n);case"/bridge":return t.jsx(I_,{},n);case"/bridge/preview":return t.jsx(Ff,{});case"/bridge/history":return t.jsx(pp,{});case"/op/withdrawals":return t.jsx(of,{});case"/tx":return t.jsx(io,{})}},gp="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",xp=()=>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:gp}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),yp=()=>{ne();const e=ye();return An(),St(localStorage.getItem(O.BRIDGE_SRC_CHAIN_ID)??e.chainId),St(localStorage.getItem(O.BRIDGE_DST_CHAIN_ID)??e.chainId),null},jp=new q.QueryClient({defaultOptions:{queries:{retry:0}}}),vp=({children:e,...s})=>(f.useEffect(()=>{Pa()},[]),Ce.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(xp,{}),t.jsx(Sr.Provider,{value:{...vr,...s},children:t.jsx(Ir,{children:t.jsx(Fa,{children:t.jsx(G.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(Za,{children:t.jsxs(Tc,{children:[e,t.jsxs(q.QueryClientProvider,{client:jp,children:[t.jsx(Ec,{}),t.jsx(he,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(yp,{})}),t.jsx(fl,{children:t.jsx(Po,{})})]})]})})})})})})]}):null),bp=({bridge:e})=>t.jsx(Ir,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Jr.Provider,{value:!!e,children:t.jsx(he,{children:t.jsx(Po,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=Ht;exports.DEFAULT_GAS_PRICE_MULTIPLIER=jr;exports.InterwovenKit=bp;exports.InterwovenKitProvider=vp;exports.MAINNET=vr;exports.MoveError=kr;exports.TESTNET=Yo;exports.initiaPrivyWallet=Zo;exports.initiaPrivyWalletConnector=Jo;exports.initiaPrivyWalletOptions=vs;exports.injectStyles=Dc;exports.useAddress=Tt;exports.useHexAddress=Ts;exports.useInitiaAddress=re;exports.useInterwovenKit=je;exports.usePortfolio=kn;exports.useUsernameQuery=Wr;
4
+ </svg>`,Ba=encodeURIComponent(Ra),Rn=`data:image/svg+xml;utf8,${Ba}`,ys=$e.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:o=[],display:r,logo_URIs:a,name:i,address:c,traces:l}=e,d=o.find(m=>m.denom===r)?.exponent??o.find(m=>m.denom===s)?.exponent??b.head(o)?.exponent??0,u=a?.png??"";return{denom:s,symbol:n,decimals:d,logoUrl:u,name:i,address:c,traces:l}}function Zo(){const e=$.useQueryClient();return s=>{const n=s?.metadata?.assetlist;return $.queryOptions({queryKey:ys.list(n).queryKey,queryFn:async()=>n?z.get(n).json():{assets:[]},select:({assets:o})=>{if(!s)return[];const r=o.map(Ma);for(const a of r)e.setQueryData(ys.item(s.chainId,a.denom).queryKey,a);return r},staleTime:W.MINUTE})}}function Gt(e){const s=Zo(),{data:n}=$.useSuspenseQuery(s(e));return n}function Fa(){const e=re(),s=Zo();return $.useQueries({queries:e.map(n=>s(n))})}function Ve(e){const s=Gt(e),n=_e(),o=Gt(n),r=er(e);return a=>{const i=s.find(l=>l.denom===a);if(i)return i;const c=o.find(l=>l.denom===r(a));return c?{...c,denom:a}:{denom:a,symbol:"",decimals:0,logoUrl:Rn}}}function Xo(e,s){const n=Ve(s),r=$.useQueryClient().getQueryData(ys.item(s.chainId,e).queryKey);return r||n(e)}function er(e){const s=_e(),n=Gt(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const a=n.find(i=>i.denom===o)?.traces;if(a){for(const i of a)if(i.counterparty.chain_name===s.chain_name)return i.counterparty.base_denom}}const r=s.metadata?.ibc_channels?.find(({chain_id:a,version:i})=>a===e.chain_id&&i==="ics20-1")?.channel_id;return r?v.getIbcDenom(r,o):""}}function Oa(e){return e.pagination?.next_key??null}async function tr(e,s,n){const o=z.create(s),r=async(a,i)=>{const c=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),l=c[n]??[],d=Oa(c),u=[...a,...l];return d?r(u,d):u};return r([],null)}const co="usernames";function Ua({restUrl:e,moduleAddress:s}){const{viewFunction:n}=v.createMoveClient(e);async function o(i){if(!v.InitiaAddress.validate(i))return null;const c=await n({moduleAddress:s,moduleName:co,functionName:"get_name_from_address",typeArgs:[],args:[V.toBase64(v.InitiaAddress(i,32).bytes)]});return c?c+".init":null}function r(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function a(i){if(!r(i))return null;const c=await n({moduleAddress:s,moduleName:co,functionName:"get_address_from_name",typeArgs:[],args:[ya.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return c?v.InitiaAddress(c).bech32:null}return{restUrl:e,getUsername:o,getAddress:a,validateUsername:r}}const As=$e.createQueryKeys("interwovenkit:account",{username:(e,s)=>[e,s],address:(e,s)=>[e,s],balances:(e,s)=>[e,s],txs:(e,s)=>[e,s]});function sr(){const{restUrl:e}=_e(),{usernamesModuleAddress:s}=X();return Ua({restUrl:e,moduleAddress:s})}function nr(){const e=ne();return s=>$.queryOptions({queryKey:As.balances(s.restUrl,e).queryKey,queryFn:()=>tr(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:s.restUrl},"balances"),staleTime:W.SECOND})}function Bn(e){const s=nr(),{data:n}=$.useSuspenseQuery(s(e));return n}function La(){const e=re(),s=nr();return $.useQueries({queries:e.map(n=>s(n))})}function za(e){const s=Bn(e),n=Gt(e),o=Ve(e),r=er(e),{data:a}=ks(e),i=l=>e.fees.fee_tokens.some(d=>d.denom===l),c=l=>n.some(d=>d.denom===l);return b.sortWith([b.descend(({denom:l})=>r(l)==="uinit"),b.descend(({denom:l})=>i(l)),b.descend(({value:l})=>l),b.descend(({denom:l})=>c(l)),({balance:l},{balance:d})=>F(d).comparedTo(l)??0,b.descend(({symbol:l})=>l.toLowerCase())],s.filter(({amount:l})=>!F(l).isZero()).map(({amount:l,denom:d})=>{const u=o(d),m=a?.find(({id:f})=>f===u?.denom)?.price??0,h=F(l).times(m).div(F(10).pow(u.decimals)).toNumber();return{...u,balance:l,price:m,value:h}}))}const or=_.createContext(null);function $s(){return _.useContext(or)}function rr(){const{location:e}=$s();return e}function Ts(){const{path:e}=rr();return e}function jt(){const{state:e={}}=rr();return e}function Ka(){const{history:e}=$s();return e}function me(){const{navigate:e}=$s();return e}function ar(){const{reset:e}=$s();return e}const Et=({to:e,state:s,shouldReset:n,children:o,onClick:r,...a})=>{const i=me(),c=ar(),l=d=>{d.preventDefault(),r?.(d),n?c(e,s):i(e,s)};return t.jsx("button",{type:"button",...a,onClick:l,children:o})},ir=({children:e,initialEntry:s})=>{const[n,o]=_.useState([s??{path:"/"}]),r=n[n.length-1],a=_.useCallback((c,l)=>{o(d=>{if(typeof c=="string")return[...d,{path:c,state:l}];const u=d.length+c;if(u<1)return d;const m=b.take(u,d);return l!==void 0?b.adjust(u-1,h=>({...h,state:l}),m):m})},[]),i=_.useCallback((c,l)=>{o([{path:c,state:l}])},[]);return t.jsx(or.Provider,{value:{location:r,history:n,navigate:a,reset:i},children:e})},Wa="c33b940c24c17e95f7d9d525d508ac61";function Ha(){const{disableAnalytics:e}=X();_.useEffect(()=>{e||Dn.init(Wa,{autocapture:!1})},[e])}function Qa(){const{connector:e}=de.useAccount(),{defaultChainId:s,disableAnalytics:n}=X();_.useEffect(()=>{const o=new zo.Identify;e?.name&&o.set("connector",e.name),s&&o.set("defaultChainId",s),Dn.identify(o)},[s,e?.name,n])}function Es(){const e=Ts();return _.useCallback((n,o)=>{Dn.track(n,{path:e,...o})},[e])}const Ee="interwovenkit",Va=1e3,cr=60*Va,lr=60*cr,lo=24*lr,U={PUBLIC_KEY:`${Ee}:public-key`,BRIDGE_SRC_CHAIN_ID:`${Ee}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${Ee}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${Ee}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${Ee}:bridge:dst-denom`,BRIDGE_QUANTITY:`${Ee}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${Ee}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${Ee}:bridge:route-type`,BRIDGE_HISTORY:`${Ee}:bridge:history`,OP_REMINDER:`${Ee}:op:reminder`},Ga=G.atom(!1);function Ge(){const e=ar(),[s,n]=G.useAtom(Ga),o=Es();return{isDrawerOpen:s,openDrawer:(i,c)=>{i&&e(i,c),n(!0),o("Widget Opened")},closeDrawer:()=>{n(!1),o("Widget Closed")}}}function Mn(){const e=me(),{closeDrawer:s}=Ge(),{disconnect:n}=de.useDisconnect();return()=>{e("/blank"),s(),n(),localStorage.removeItem(U.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(U.BRIDGE_SRC_DENOM),localStorage.removeItem(U.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(U.BRIDGE_DST_DENOM),localStorage.removeItem(U.BRIDGE_QUANTITY),localStorage.removeItem(U.BRIDGE_SLIPPAGE_PERCENT)}}function Fn(){const{privyContext:e}=X(),{address:s}=de.useAccount();return e?s?!!e.privy.user?.linkedAccounts.map(o=>"address"in o&&o.address).filter(o=>!!o)?.some(o=>v.InitiaAddress.equals(o,s)):!1:!0}function Ya(){const{privyContext:e}=X(),s=Fn(),{address:n}=de.useAccount(),{signMessageAsync:o}=de.useSignMessage(),r=Mn(),a=!!e?.privy.ready,i=_.useRef(e);_.useEffect(()=>{i.current=e},[e]);const c=async l=>{try{if(!i.current)throw new Error("Privy context not found");i.current.privy.authenticated&&await i.current.privy.logout();const d=await i.current.siwe.generateSiweMessage({chainId:"eip155:1",address:l});if(!d)throw new Error("Failed to generate SIWE message");const u=await o({message:d});await i.current.siwe.loginWithSiwe({signature:u,message:d})}catch{r()}};_.useEffect(()=>{s||a&&n&&c(n)},[s,a,n])}function Ja(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:s}=vn.PubKey.decode(e.value);return Qt.encodeSecp256k1Pubkey(s)}return Cs.decodeOptionalPubkey(e)}function Za({typeUrl:e,value:s}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:n,pubKey:o,accountNumber:r,sequence:a}=va.BaseAccount.decode(s),i=Ja(o);return{address:n,pubkey:i,accountNumber:Number(r),sequence:Number(a)}}return Pe.accountFromAny({typeUrl:e,value:s})}function Xa(e){return e.type==="initia/PubKeyEthSecp256k1"}const ei={...Qt.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function ti(e){if(Xa(e)){const s=vn.PubKey.fromPartial({key:V.fromBase64(e.value)});return wa.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(vn.PubKey.encode(s).finish())})}return Cs.encodePubkey(e)}function dr(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:ei.ethsecp256k1,value:V.toBase64(e)}}function si(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:dr(e),signature:V.toBase64(s)}}const Xt=()=>{const e=X();return new Cs.Registry([...Ht.protoRegistry,...e.protoTypes??[]])},qs=()=>{const e=X();return new Pe.AminoTypes({...Ht.aminoConverters,...e.aminoConverters})};class ur{constructor(s,n,o){this.address=s,this.signMessage=n,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const s=`${U.PUBLIC_KEY}:${this.address}`,n=localStorage.getItem(s);if(n)return this.cachedPublicKey=V.fromHex(n),V.fromHex(n);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(s,V.toHex(o)),o;const r=await this.getPublicKey();return this.cachedPublicKey=r,localStorage.setItem(s,V.toHex(r)),r}async getPublicKeyFromRestApi(){try{const n=(await z.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return n?V.fromBase64(n):null}catch{return null}}async getPublicKey(){const s="Sign this message to identify your Initia account.",n=await this.signMessage(s),o=We.ethers.hashMessage(s),r=We.ethers.SigningKey.recoverPublicKey(o,n);return jn.Secp256k1.compressPubkey(V.fromHex(r.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 o=yn.escapeCharacters(yn.sortedJsonStringify(n)),r=await this.signMessage(o),a=V.fromHex(r.replace("0x","")).subarray(0,-1),c=jn.Secp256k1Signature.fromFixedLength(a).toFixedLength(),l=si(await this.getCachedPublicKey(),c);return{signed:n,signature:l}}}function Ds(){const e=Xt(),s=qs(),n=es(),o=hr();return async function(r,a,i,c,l,d){const u=d?.customSigner??n;if(!u)throw new Error("Signer not initialized");const m=await o(r),{accountNumber:h,...f}=await m.getSequence(a),p=f.sequence+(d?.incrementSequence??0),[g]=await u.getAccounts(),y=ti(dr(g.pubkey)),I=ja.SignMode.SIGN_MODE_EIP_191,S=i.map(x=>s.toAmino(x)),k=yn.makeSignDoc(S,c,r,l,h,p),{signature:w,signed:T}=await u.signAmino(a,k),R={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:T.msgs.map(x=>s.fromAmino(x)),memo:l}},B=e.encode(R),K=so.Int53.fromString(T.fee.gas).toNumber(),j=so.Int53.fromString(T.sequence).toNumber(),C=Cs.makeAuthInfoBytes([{pubkey:y,sequence:j}],T.fee.amount,K,T.fee.granter,T.fee.payer,I);return st.TxRaw.fromPartial({bodyBytes:B,authInfoBytes:C,signatures:[V.fromBase64(w.signature)]})}}function es(){const e=ne(),{signMessageAsync:s}=de.useSignMessage(),n=_e();return _.useMemo(()=>new ur(e,o=>s({message:o}),n.restUrl),[e,s,n.restUrl])}const Zs=new Map,Xs=new Map;function mr(){const e=Te();return async s=>{if(Zs.has(s))return Zs.get(s);const{rpcUrl:n}=e(s),o=await no.Comet38Client.create(new no.HttpClient(n));return Zs.set(s,o),o}}function hr(){const e=Xt(),s=qs(),n=es(),o=ne(),r=mr();return async a=>{const i=`${o}:${a}`;if(Xs.has(i))return Xs.get(i);if(!n)throw new Error("Signer not initialized");const c=await r(a),l=await Pe.SigningStargateClient.createWithSigner(c,n,{registry:e,aminoTypes:s,accountParser:Za,broadcastPollIntervalMs:500});return Xs.set(i,l),l}}function fr(){const{connector:e}=de.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new We.BrowserProvider(await e.getProvider())}}function _r(){const{privyContext:e}=X(),s=Fn();if(!(!e||!s))return e.wallets.find(n=>n.connectorType==="embedded")}function Ps(){const e=_r();return e?.address?v.InitiaAddress(e.address).bech32:void 0}function pr(){const e=_r(),s=Ps(),n=Xt(),o=Te(),r=Ds();return async(a,i,c,l,d)=>{if(!e||!s)throw new Error("Embedded wallet not initialized");const u=[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:qn.MsgExec.fromPartial({grantee:s,msgs:c.map(f=>({typeUrl:f.typeUrl,value:n.encode(f)}))})}],m={...l,granter:i},h=new ur(s,e.sign,o(a).restUrl);return await r(a,s,u,m,d,{customSigner:h})}}const Yt=$e.createQueryKeys("interwovenkit:autosign",{expirations:(e,s)=>[e,s],grants:(e,s)=>[e,s]});function Rs(){const e=X(),s=Zt(),{enableAutoSign:n,defaultChainId:o}=e;if(!n)return{[o]:[]};if(typeof n!="boolean")return n;switch(s.metadata?.minitia?.type){case"minievm":return{[o]:["/minievm.evm.v1.MsgCall"]};case"miniwasm":return{[o]:["/cosmwasm.wasm.v1.MsgExecuteContract"]};default:return{[o]:["/initia.move.v1.MsgExecute"]}}}function gr(){const{data:e}=On(),s=Rs();return async(n,o)=>{const r=o.every(i=>{const c=s[n];return c?c.includes(i.typeUrl):!1}),a=e?.isEnabledByChain[n]??!1;return r&&a}}function On(){const e=ne(),s=Ps(),n=Te(),o=Rs();return $.useQuery({queryKey:Yt.expirations(e,s).queryKey,queryFn:async()=>{if(!e||!s)return{expiredAtByChain:{},isEnabledByChain:{}};const r={};for(const[i,c]of Object.entries(o))try{const l=n(i),d=z.create({prefixUrl:l.restUrl}),u=await d.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:s}}).json();if(!c.every(I=>u.grants.some(S=>S.authorization?.msg===I))){r[i]=null;continue}const h=await d.get(`cosmos/feegrant/v1beta1/allowance/${e}/${s}`).json(),f=u.grants.filter(I=>c.includes(I.authorization.msg)).map(I=>I.expiration),p=h.allowance.allowance.expiration,g=[...f,p],y=Un(g);r[i]=y?new Date(y):void 0}catch{r[i]=null}const a={};for(const[i,c]of Object.entries(r))switch(c){case null:a[i]=!1;break;case void 0:a[i]=!0;break;default:a[i]=ke.isFuture(c);break}return{expiredAtByChain:r,isEnabledByChain:a}},staleTime:W.INFINITY,retry:!1})}function ni(){const{data:e,refetch:s}=On();_.useEffect(()=>{if(!e)return;const n=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&ke.isFuture(c));if(o.length===0)return;const a=Un(o).getTime()-n.getTime();if(a<=0)return;const i=setTimeout(()=>{s()},a+100);return()=>clearTimeout(i)},[e,s])}function Un(e){return e.filter(s=>s!==void 0).toSorted((s,n)=>new Date(s).getTime()-new Date(n).getTime())[0]}const xr=_.createContext(null),Bs=()=>_.useContext(xr);class yr extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(s,n,o,r,a,i,c){super(s),this.name="MoveError",this.originalError=n,this.moduleAddress=o,this.moduleName=r,this.errorCode=a,this.errorCodeHex=i,this.isFromRegistry=c}}const oi=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,en=new Map;function ri(e){const s=e.match(oi);if(!s)return null;const[,n,o,r]=s;return{moduleAddress:`0x${n.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:r.replace(/^0+/,"")||"0"}}async function ai(e,s,n){const o=`${e}:${s}`;if(en.has(o))return en.get(o);try{const r=s==="0x1"?"0x1.json":`${e}/${s}.json`,a=`${n}/errors/${r}`,{errors:i={}}=await z.get(a).json();return en.set(o,i),i}catch{return null}}function ii(e,s,n,o,r,a,i){return new yr(e,s,n,o,r,a,i)}async function kt(e,s,n){if(!s.metadata?.is_l1&&s.metadata?.minitia?.type!=="minimove")return await He(e);const o=ri(e.message);if(!o)return await He(e);const r=await ai(s.chain_name,o.moduleAddress,n),a=`0x${parseInt(o.errorCode,10).toString(16)}`,i=`Failed with code ${a} in module ${o.moduleName} at ${o.moduleAddress}`,c=r?.[o.moduleName]?.[o.errorCode],l=c||i,d=!!c;return ii(l,e,o.moduleAddress,o.moduleName,o.errorCode,a,d)}const jr="approve",Ms=G.atom(),vr=G.atom(null);function wr(){const e=G.useAtomValue(Ms);if(!e)throw new Error("Tx request not found");return e}function Fs(){const e=me(),s=ne(),{defaultChainId:n,registryUrl:o}=X(),r=Te(),{openDrawer:a,closeDrawer:i}=Ge(),{openModal:c,closeModal:l}=Bs(),d=G.useSetAtom(Ms),u=G.useSetAtom(vr),m=mr(),h=hr(),f=es(),p=Xt(),g=gr(),y=pr(),I=Ds(),S=async({messages:j,memo:C,chainId:x=n})=>{try{return await(await h(x)).simulate(s,j,C)}catch(A){throw await kt(A,r(x),o)}},k=async({messages:j,memo:C,chainId:x=n})=>{const A=await m(x),q=Pe.QueryClient.withExtensions(A,Pe.setupTxExtension),M=j.map(Z=>p.encodeAsAny(Z)),[E]=await f.getAccounts(),H=Qt.encodeSecp256k1Pubkey(E.pubkey),ee=await h(x),{sequence:O}=await ee.getSequence(s);return q.tx.simulate(M,C,H,O)},w=async({txRequest:j,broadcaster:C})=>{const A={...{memo:"",chainId:n,gas:j.gas||await S(j),gasAdjustment:Vt,gasPrices:null,spendCoins:[],internal:!1},...j};return new Promise((q,M)=>{d({txRequest:A,resolve:async H=>{try{const ee=await h(A.chainId),O=await C(ee,st.TxRaw.encode(H).finish());q(O),typeof A.internal=="string"&&e(A.internal)}catch(ee){M(await kt(ee,r(A.chainId),o))}finally{E()}},reject:H=>{M(H),E()}}),A.internal?c({path:"/tx"}):a("/tx");const E=()=>{if(!A.internal){e("/blank"),i();return}l()}})},T=async j=>{const C=j.chainId??n;try{const x=await w({txRequest:j,broadcaster:async(A,q)=>await A.broadcastTxSync(q)});return j.internal&&typeof j.internal!="number"&&(u({txHash:x,chainId:C,status:"loading"}),K({txHash:x,chainId:j.chainId}).then(A=>{u({status:A.code===0?"success":"error",chainId:C,txHash:x})}).catch(()=>{u({status:"error",chainId:C,txHash:x})})),x}catch(x){throw j.internal&&typeof j.internal!="number"&&u({status:"error",chainId:C,error:x}),x}},P=(j,C=30*1e3,x=.5*1e3)=>w({txRequest:j,broadcaster:async(A,q)=>{const M=await A.broadcastTx(q,C,x);if(M.code!==0)throw new Error(M.rawLog);return M}}),R=async j=>{const C=j.chainId??n;try{const{messages:x,memo:A="",fee:q}=j,M=await h(C),H=await g(C,x)?await y(C,s,x,q,A):await I(C,s,x,q,A);return await M.broadcastTxSync(st.TxRaw.encode(H).finish())}catch(x){throw await kt(x,r(C),o)}},B=async(j,C=30*1e3,x=.5*1e3)=>{const A=j.chainId??n;try{const{messages:q,memo:M="",fee:E}=j,H=await h(A),O=await g(A,q)?await y(A,s,q,E,M):await I(A,s,q,E,M),Z=await H.broadcastTx(st.TxRaw.encode(O).finish(),C,x);if(Z.code!==0)throw new Error(Z.rawLog);return Z}catch(q){throw await kt(q,r(A),o)}},K=async({chainId:j=n,...C})=>{try{const x=await h(j);return await br({...C,client:x})}catch(x){throw await kt(x,r(j),o)}};return{estimateGas:S,simulateTx:k,requestTxSync:T,requestTxBlock:P,submitTxSync:R,submitTxBlock:B,waitForTxConfirmation:K}}async function br({txHash:e,client:s,timeoutMs:n=30*1e3,intervalMs:o=.5*1e3}){const r=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()-r>=n)throw new Error(`Transaction was submitted, but not found on the chain within ${n/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const Os=G.atom(null);function ci(){const{privyContext:e}=X(),s=ne(),n=Ps(),o=Rs(),{requestTxBlock:r}=Fs(),a=$.useQueryClient(),[i,c]=G.useAtom(Os),{closeDrawer:l}=Ge(),d=async()=>{if(n)return n;if(!e)throw new Error("Privy context not available");const u=await e.createWallet({createAdditional:!1});return v.InitiaAddress(u.address).bech32};return $.useMutation({mutationFn:async u=>{if(!i)throw new Error("No pending request");const{chainId:m}=i,h=await d();if(!s||!h)throw new Error("Wallets not initialized");const f=u===0?void 0:ke.addMilliseconds(new Date,u),p={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:Ko.MsgGrantAllowance.fromPartial({granter:s,grantee:h,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:ro.BasicAllowance.encode(ro.BasicAllowance.fromPartial({expiration:f})).finish()}})},g=o[m].map(I=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:qn.MsgGrant.fromPartial({granter:s,grantee:h,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:oo.GenericAuthorization.encode(oo.GenericAuthorization.fromPartial({msg:I})).finish()},expiration:f}})})),y=[p,...g];await r({messages:y,chainId:m,internal:!0})},onSuccess:async()=>{await a.invalidateQueries({queryKey:Yt.expirations._def}),i?.resolve()},onError:u=>{i?.reject(u)},onSettled:()=>{c(null),l()}})}function Cr(e){const s=X(),n=ne(),o=Ps(),r=e?.grantee||o,a=Rs(),i=e?.messageTypes||a,{requestTxBlock:c}=Fs(),l=$.useQueryClient();return $.useMutation({mutationFn:async(d=s.defaultChainId)=>{if(!n||!r)throw new Error("Wallets not initialized");const u={typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:Ko.MsgRevokeAllowance.fromPartial({granter:n,grantee:r})},m=i[d].map(f=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:qn.MsgRevoke.fromPartial({granter:n,grantee:r,msgTypeUrl:f})})),h=[u,...m];await c({messages:h,chainId:d,internal:e?.internal})},onSuccess:async()=>{const d=[Yt.expirations._def,Yt.grants._def];for(const u of d)await l.invalidateQueries({queryKey:u})}})}function li(){const{defaultChainId:e}=X(),{openDrawer:s}=Ge(),n=G.useSetAtom(Os),o=Cr(),{data:r={expiredAtByChain:{},isEnabledByChain:{}},isLoading:a}=On();return{...r,isLoading:a,enable:async(l=e)=>new Promise((d,u)=>{n({chainId:l,resolve:d,reject:u}),s("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}const di="INIT",ui="Initia";function Ln(e){return e.assets.reduce((s,{value:n})=>s+(n??0),0)}function mi(e){return e.assets.reduce((s,{quantity:n})=>s.plus(n),F(0)).toString()}function hi(e,s){return{symbol:s?.symbol??e,logoUrl:s?.logoUrl??Rn}}function uo(e){return b.pick(["chainId","name","logoUrl"],e)}function fi(e){return b.sortWith([b.descend(({symbol:s})=>s===di),b.descend(Ln),b.descend(({assets:s})=>s.length),b.ascend(({symbol:s})=>s)])(e)}function _i(e){return b.sortWith([b.descend(({value:s})=>s??0),b.descend(({quantity:s})=>Number(s)),b.ascend(({chain:s})=>s.name)])(e)}function pi(e){return b.sortWith([b.descend(({chain:s})=>s.name===ui),b.ascend(({chain:s})=>s.name),b.ascend(({denom:s})=>s)])(e)}function gi(e,s){return b.sortWith([b.descend(({chainId:n})=>n===s),b.descend(b.prop("value"))])(e)}function xi(e,s,n,o,r){const a={};for(const u of e){const m=u.chainId,h=s[m]??[],f=n[m],p=o[m],g=[];for(const{amount:y,denom:I}of h){if(!F(y).gt(0))continue;const S=f?.find(R=>R.denom===I),k=p?.find(R=>R.id===I)?.price,w=S?.decimals??0,T=v.fromBaseUnit(y,{decimals:w}),P=k?F(T).times(k).toNumber():void 0;g.push({...hi(I,S),amount:y,denom:I,decimals:w,quantity:T,price:k,value:P,address:S?.address,unlisted:!S,chain:uo(u)})}a[m]=g}const i=new Map;for(const[u,m]of Object.entries(a)){if(m.length===0)continue;const h=e.find(p=>p.chainId===u);if(!h)continue;const f=m.reduce((p,{value:g})=>p+(g??0),0);i.set(u,{...uo(h),value:f})}const c=new Map;for(const u of Object.values(a))for(const m of u)if(!m.unlisted){const{symbol:h}=m,f=c.get(h)??[];c.set(h,[...f,m])}const l=[];for(const[u,m]of c){const h=b.head(m);if(!h)continue;const f=_i(m);l.push({symbol:u,logoUrl:h.logoUrl,assets:f})}const d=[];for(const u of Object.values(a))for(const m of u)m.unlisted&&d.push(m);return{chainsByValue:gi(Array.from(i.values()),r),assetGroups:fi(l),unlistedAssets:pi(d),totalValue:l.reduce((u,m)=>u+Ln(m),0)}}function zn(){const{defaultChainId:e}=X(),s=re(),n=La(),o=Fa(),r=Pa(),a=s.map(h=>h.chainId),i=b.zipObj(a,n.map(b.prop("data"))),c=b.zipObj(a,o.map(b.prop("data"))),l=b.zipObj(a,r.map(b.prop("data"))),d=xi(s,i,c,l,e),u=[n,o,r].flat().some(({isLoading:h})=>h);return{...d,isLoading:u,refetch:()=>{n.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),r.forEach(({refetch:h})=>h())}}}function ne(){const e=Us();return e?v.InitiaAddress(e).bech32:""}function Us(){const{address:e}=de.useAccount(),s=Fn();return!e||!s?"":v.InitiaAddress(e).hex}function Pt(){const e=Zt(),s=ne(),n=Us();return e.metadata?.minitia?.type==="minievm"?n:s}function Ir(){const e=Pt(),s=sr();return $.useQuery({queryKey:As.username(s.restUrl,e).queryKey,queryFn:()=>s.getUsername(e),enabled:!!e,staleTime:W.MINUTE})}function xe(){const e=Pt(),s=ne(),n=Us(),{data:o}=Ir(),r=es(),a=Mn(),i=li(),{isDrawerOpen:c,openDrawer:l}=Ge(),d=()=>{l("/")},u=()=>{l("/connect")},m=p=>{l("/bridge",p)},h=Fs();return{address:e,initiaAddress:s,hexAddress:n,username:o,offlineSigner:r,isConnected:!!e,isOpen:c,openConnect:u,openWallet:d,openBridge:m,disconnect:a,autoSign:i,...h}}const yi="_status_tn9m1_1",ji="_error_tn9m1_9",mo={status:yi,error:ji},se=({error:e,children:s})=>t.jsx("p",{className:D(mo.status,{[mo.error]:e}),children:s}),ye=({errorBoundaryProps:e={fallbackRender:({error:o})=>t.jsx(se,{error:!0,children:o.message})},suspenseFallback:s=t.jsx(se,{children:"Loading..."}),children:n})=>t.jsx(Wo.ErrorBoundary,{...e,children:t.jsx(_.Suspense,{fallback:s,children:n})});function vi(){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:U.PUBLIC_KEY,getSuffix:n=>v.InitiaAddress(n).bech32}};for(const n of e)localStorage.removeItem(n);for(const[n,{prefix:o,getSuffix:r}]of Object.entries(s)){const a=localStorage.getItem(n);if(a)try{const i=JSON.parse(a);for(const[c,l]of Object.entries(i)){const d=`${o}:${r(c)}`;localStorage.setItem(d,l)}localStorage.removeItem(n)}catch{}}}const Re=$e.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 Ye(){const{routerApiUrl:e}=X();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function qt(e){const s=Ye(),n=$.useQueryClient(),{data:o}=$.useSuspenseQuery({queryKey:Re.assets(e).queryKey,queryFn:()=>s.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:r})=>{const{assets:a}=r[e]??{assets:[]};for(const i of a)n.setQueryData(Re.asset(e,i.denom).queryKey,i);return a.toSorted(b.descend(i=>i.symbol==="INIT"))},staleTime:W.MINUTE});return o}function Nr(e){const s=qt(e);return n=>{const o=s.find(r=>r.denom===n);if(!o)throw new Error(`Asset not found: ${n}`);return o}}function Qe(e,s){return Nr(s)(e)}function Sr(){const e=re();return s=>e.some(n=>n.chain_id===s)}function ts(){const e=Sr();return s=>e(s.chain_id)?"initia":s.chain_type}function Jt(e){return ts()(e)}function Kn(){const e=Ye(),{data:s}=$.useSuspenseQuery({queryKey:Re.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:n})=>b.sortWith([b.descend(({chain_name:o})=>o==="initia"),b.ascend(({pretty_name:o})=>o)],n),staleTime:W.MINUTE});return s}function vt(){const e=Kn(),s=Yo();return n=>{const o=e.find(a=>a.chain_id===n);if(o)return o;const r=s.find(a=>a.chain_id===n);if(!r)throw new Error(`Chain not found: ${n}`);return{chain_id:r.chain_id,chain_name:r.name,pretty_name:r.pretty_name,logo_uri:r.logo,chain_type:"cosmos",rpc:"",rest:""}}}function Be(e){return vt()(e)}const wi=()=>(Ha(),Qa(),null),bi="_loader_4gdsk_1",Ci={loader:bi},wt=({size:e=24,color:s="currentColor",border:n=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${s} ${s} transparent ${s}`,borderWidth:`${n}px`};return t.jsx("div",{className:Ci.loader,style:o})},Ii="_button_1w43o_1",Ni="_outline_1w43o_27",Si="_sm_1w43o_45",ki="_full_1w43o_51",Ai="_small_1w43o_55",$i="_unpadded_1w43o_85",pt={button:Ii,outline:Ni,sm:Si,full:ki,small:Ai,unpadded:$i},kr=e=>{const{sm:s,fullWidth:n,loading:o,className:r,children:a,disabled:i,...c}=e;return t.jsx("button",{...c,className:D(pt.button,{[pt.sm]:s,[pt.full]:n},r),disabled:!!o||i,children:o?t.jsxs(t.Fragment,{children:[t.jsx(wt,{color:"currentColor",size:16}),typeof o=="string"&&t.jsx("span",{className:pt.loading,children:o})]}):a})},Ti=({className:e,...s})=>t.jsx(kr,{...s,className:D(pt.outline,e)}),Ei=({className:e,unpadded:s,...n})=>t.jsx("button",{...n,className:D(pt.small,{[pt.unpadded]:s},e)}),J={White:kr,Outline:Ti,Small:Ei},qi="_footer_1vp4h_1",Di="_actions_1vp4h_10",ho={footer:qi,actions:Di},ie=({extra:e,className:s,children:n})=>t.jsxs("footer",{className:D(ho.footer,s),children:[e,t.jsx("div",{className:ho.actions,children:n})]}),Pi="_scrollable_abvhw_1",Ri={scrollable:Pi},Fe=({className:e,children:s,ref:n})=>t.jsx("div",{ref:n,className:D(Ri.scrollable,e),children:s});function Ls(){return Ie.useMediaQuery("(max-width: 576px)")}const wn="interwoven-kit";function Ar(){const e=document.querySelector(wn)||document.body.appendChild(document.createElement(wn));return e.shadowRoot||e.attachShadow({mode:"open"})}function Bi(){const{theme:e,container:s}=X();return _.useEffect(()=>{document.querySelector(wn)?.setAttribute("data-theme",e)},[e]),s??Ar()}function Mi(e){const s=Ar(),n=document.createElement("style");n.textContent=e,s.appendChild(n)}const Wn=_.createContext(null);function yt(){const{container:e}=_.useContext(Wn);return e}function $r(e){const s=yt();return s?getComputedStyle(s).getPropertyValue(e):""}function Fi(){return Ie.useScrollLock(),null}function Oi(e){return/^[A-F0-9]{64}$/i.test(e)}function Ui(e,s){const{txHash:n,accountAddress:o,pathSuffix:r}=s;if(n)return Oi(n)?b.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,n):void 0;if(o){if(!v.InitiaAddress.validate(o))return;const i=b.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&r?i+r:i}}function Li(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 zi="_link_guafb_1",fo={link:zi},zs=({chainId:e,txHash:s,accountAddress:n,pathSuffix:o,...r})=>{const{showIcon:a,className:i,children:c,onClick:l,...d}=r,u=Me(e),m=Ui(u,{txHash:s,accountAddress:n,pathSuffix:o}),h=s?v.truncate(s):n?v.truncate(n):"",f=c??h;return m?t.jsxs("a",{...d,href:ba(Li(m)),className:D(fo.link,i),onClick:l,target:"_blank",children:[f,a&&t.jsx(N.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:D(fo.link,i),children:f})},Tr=_.createContext(null),Hn=()=>_.useContext(Tr),Ki=()=>{const[e,s]=G.useAtom(vr),{showNotification:n,updateNotification:o,hideNotification:r}=Hn();return _.useEffect(()=>{if(!e)return;const{status:a,chainId:i,txHash:c,error:l}=e,d=l?l.message:c?t.jsx(zs,{txHash:c,chainId:i,onClick:r,showIcon:!0,children:"View on Initia Scan"}):null;switch(a){case"loading":n({type:"loading",title:"Transaction is pending..."});break;case"error":o({type:"error",title:"Transaction failed",description:d}),s(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),s(null);break}},[e,s,n,o,r]),null},js=({value:e,children:s})=>{const[n,o]=_.useState(!1);return s({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:n})},Wi="_placeholder_10r3x_1",Hi="_logo_10r3x_5",_o={placeholder:Wi,logo:Hi},Y=({src:e,alt:s,placeholder:n,classNames:o,style:r,logo:a,...i})=>{const[c,l]=_.useState(void 0),{width:d,height:u}=i,m=n??t.jsx("div",{className:D(_o.placeholder,o?.placeholder),style:{width:d,height:u,...r}});return!e||c===e?m:t.jsx("img",{...i,className:D(i.className,{[_o.logo]:a}),style:{width:d,height:u,...r},src:e,alt:s,loading:"lazy",onError:()=>l(e)})},Qi="_header_1ajhc_1",Vi="_account_1ajhc_16",Gi="_name_1ajhc_27",Yi="_address_1ajhc_31",Ji="_icon_1ajhc_35",Zi="_copied_1ajhc_42",Xi="_button_1ajhc_57",ec="_settings_1ajhc_68",tc="_disconnect_1ajhc_72",sc="_label_1ajhc_82",nc="_expanded_1ajhc_90",je={header:Qi,account:Vi,name:Gi,address:Yi,icon:Ji,copied:Zi,button:Xi,settings:ec,disconnect:tc,label:sc,expanded:nc},oc=()=>{const{connector:e}=de.useAccount(),s=Mn(),{address:n,username:o}=xe(),r=o??n,[a,i]=_.useState(!1),c=_.useRef(null),l=ot.useSpring({width:a?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{a?s():i(!0)},u=()=>{a&&(c.current=setTimeout(()=>{i(!1)},500))},m=()=>{c.current&&(clearTimeout(c.current),c.current=null)};if(_.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),!e||!n)return null;const h=e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon;return t.jsxs("header",{className:je.header,children:[t.jsx(js,{value:n,children:({copy:f,copied:p})=>t.jsxs("button",{className:D(je.account,{[je.copied]:p}),onClick:f,children:[t.jsx(Y,{src:h,width:18,height:18}),t.jsx("div",{className:je.address,children:v.truncate(n)}),t.jsx("div",{className:je.name,children:v.truncate(r)}),t.jsx(N.IconCopy,{className:je.icon,size:12}),p?"Copied!":""]})}),t.jsx(Et,{to:"/settings",className:D(je.button,je.settings),"aria-label":"Open settings",children:t.jsx(N.IconSettingFilled,{size:16})}),t.jsxs(ot.animated.button,{className:D(je.button,je.disconnect,{[je.expanded]:a}),style:l,onClick:d,onMouseLeave:u,onMouseEnter:m,children:[t.jsx(N.IconSignOut,{size:16}),t.jsx("span",{className:je.label,children:"Disconnect"})]})]})},rc="_overlay_1dhd9_1",ac="_content_1dhd9_27",ic="_inner_1dhd9_58",tn={overlay:rc,content:ac,inner:ic},cc=({children:e})=>{const{isDrawerOpen:s,closeDrawer:n}=Ge(),{setContainer:o}=_.useContext(Wn),r=Ls(),a=Bi(),i=G.useAtomValue(Ms),c=G.useAtomValue(Os),l=$.useIsMutating({mutationKey:[jr]}),d=()=>{const p=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";n(),i?.reject(new Error(p)),c?.reject(new Error("User rejected"))},u=Ts(),m=me(),h=$.useQueryClient(),f={fallbackRender:({error:p,resetErrorBoundary:g})=>{const y=()=>{u==="/bridge"&&(localStorage.removeItem(U.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(U.BRIDGE_SRC_DENOM),localStorage.removeItem(U.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(U.BRIDGE_DST_DENOM)),m("/"),h.clear(),g()};return t.jsxs(Fe,{children:[t.jsx(se,{error:!0,children:p.message}),t.jsx(ie,{children:t.jsx(J.White,{onClick:y,children:"Retry"})})]})}};return t.jsx(Se.Dialog.Root,{open:s,onOpenChange:p=>!p&&d(),modal:!1,children:t.jsxs(Se.Dialog.Portal,{container:a,children:[r&&t.jsx(Se.Dialog.Backdrop,{className:tn.overlay,onClick:d,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[t.jsx("path",{d:"M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z"}),t.jsx("path",{d:"M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z"})]})}),t.jsx(Se.Dialog.Popup,{className:tn.content,children:t.jsxs("div",{className:D(tn.inner,"body"),ref:o,children:[r&&t.jsx(Fi,{}),t.jsx(Ki,{}),t.jsx(oc,{}),t.jsx(ye,{errorBoundaryProps:f,children:e})]})})]})})},Er=_.createContext(!1),lc="_overlay_2lgi8_1",dc="_fullscreen_2lgi8_15",uc="_content_2lgi8_19",mc="_header_2lgi8_54",hc="_title_2lgi8_63",fc="_close_2lgi8_68",lt={overlay:lc,fullscreen:dc,content:uc,header:mc,title:hc,close:fc},qr=({title:e,children:s,trigger:n,className:o,open:r,onOpenChange:a})=>{const i=yt(),c=_.useContext(Er);return i?t.jsxs(Se.Dialog.Root,{open:r,onOpenChange:a,modal:!1,children:[n&&t.jsx(Se.Dialog.Trigger,{className:o,children:n}),t.jsxs(Se.Dialog.Portal,{container:i,children:[t.jsx(Se.Dialog.Backdrop,{className:D(lt.overlay,{[lt.fullscreen]:c}),onClick:()=>a(!1),forceRender:!0}),t.jsxs(Se.Dialog.Popup,{className:D(lt.content,{[lt.fullscreen]:c}),children:[e&&t.jsxs("header",{className:lt.header,children:[t.jsx(Se.Dialog.Title,{className:lt.title,children:e}),t.jsx(Se.Dialog.Close,{className:lt.close,children:t.jsx(N.IconClose,{size:20})})]}),s]})]})]}):null},bn=({children:e})=>{const s=_.useRef(null),[n,o]=_.useState(0),r=ot.useSpring({height:n,config:{tension:500,friction:30,clamp:!0}});return _.useEffect(()=>{if(s.current){const{height:a}=s.current.getBoundingClientRect();o(a)}},[e]),e?t.jsx(ot.animated.div,{style:{overflow:"hidden",...r},children:t.jsx("div",{ref:s,children:e})}):null},_c="_help_7m3jv_1",pc="_icon_7m3jv_10",gc="_info_7m3jv_17",xc="_warning_7m3jv_21",yc="_error_7m3jv_25",jc="_success_7m3jv_31",sn={help:_c,icon:pc,info:gc,warning:xc,error:yc,success:jc},At=({level:e,className:s,mt:n=8,children:o})=>{if(!o)return null;const r=()=>{switch(e){case"loading":return t.jsx(wt,{size:12});case"info":return t.jsx(N.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(N.IconWarningFilled,{size:12});default:return t.jsx(N.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:D(sn.help,e&&sn[e],s),style:{marginTop:n},children:[t.jsx("div",{className:sn.icon,children:r()}),o]})},vc="_stack_14kq8_1",wc="_help_14kq8_6",bc="_info_14kq8_14",Cc="_warning_14kq8_19",Ic="_error_14kq8_24",Nc="_success_14kq8_29",Cn={stack:vc,help:wc,info:bc,warning:Cc,error:Ic,success:Nc},Sc=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(bn,{children:t.jsx("div",{className:Cn.stack,children:e})}),ae=({mt:e=0,...s})=>t.jsx(At,{...s,className:D(Cn.help,Cn[s.level]),mt:e});ae.Stack=Sc;const kc="_root_hypwm_1",Ac="_item_hypwm_10",$c="_chevron_hypwm_14",Tc="_trigger_hypwm_19",Ec="_content_hypwm_39",Ft={root:kc,item:Ac,chevron:$c,trigger:Tc,content:Ec};function qc(e){const{list:s,getKey:n,renderHeader:o,renderContent:r,footer:a,...i}=e;return t.jsxs(te.Accordion.Root,{className:Ft.root,type:"multiple",...i,children:[s.map((c,l)=>t.jsxs(te.Accordion.Item,{className:Ft.item,value:n?.(c)??String(l),children:[t.jsx(te.Accordion.Header,{children:t.jsxs(te.Accordion.Trigger,{className:Ft.trigger,children:[o(c),t.jsx(N.IconChevronDown,{className:Ft.chevron,size:16})]})}),t.jsx(te.Accordion.Content,{className:Ft.content,children:r(c)})]},n?.(c)??l)),a]})}const Dc=10;function Dr(){const e=ne();return(s,n)=>$.queryOptions({queryKey:As.txs(s.indexerUrl,e).queryKey,queryFn:async()=>{if(!n.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Dc},{txs:r}=await z.create({prefixUrl:s.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return r},staleTime:W.SECOND})}function Pc(e,s){const n=Dr();return $.useSuspenseQuery(n(e,s))}function Rc(e,s){const n=e.flatMap((o,r)=>(s[r]??[]).map(i=>({...i,chain:o})));return b.sortWith([b.descend(o=>new Date(o.timestamp).getTime())])(n)}const Bc=()=>{const e=re(),s=Dr(),n=$.useQueries({queries:e.map(i=>s(i,{enabled:!0}))}),o=n.map(b.prop("data")),r=Rc(e,o),a=n.some(i=>i.isLoading);return{activities:r,isLoading:a}};function Pr(e){const{data:s}=$.useSuspenseQuery({queryKey:Ss.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:o}=await z.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return o.toSorted(b.descend(({denom:r})=>r==="uinit")).map(({denom:r,amount:a})=>{const i=r==="uinit"?1:Qo;return{amount:F(a).times(i).toFixed(18),denom:r}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:o})=>{if(b.isNil(o))throw new Error(`${n} has no price`);return{amount:String(o),denom:n}})},staleTime:W.SECOND});return s}function Rr(e){const s=ne(),{data:n}=Pc(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const o=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return o;try{return n.find(({tx:a})=>a.auth_info.signer_infos.some(i=>v.InitiaAddress.equals(s,We.computeAddress(`0x${V.toHex(jn.Secp256k1.uncompressPubkey(V.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const Mc="_trigger_1ti2t_1",Fc="_icon_1ti2t_18",Oc="_content_1ti2t_27",Uc="_item_1ti2t_35",Lc="_itemText_1ti2t_51",zc="_itemIndicator_1ti2t_56",Kc="_active_1ti2t_59",Xe={trigger:Mc,icon:Fc,content:Oc,item:Uc,itemText:Lc,itemIndicator:zc,active:Kc};function Br({options:e,value:s,onChange:n,classNames:o}){const r=yt(),a=e.find(c=>c.value===s);if(!a)throw new Error("Selected option not found");const i=c=>{const l=e.find(d=>String(d.value)===c);if(!l)throw new Error(`Option not found: ${c}`);n(l.value)};return t.jsxs(Le.Select.Root,{value:String(s),onValueChange:i,modal:!1,children:[t.jsxs(Le.Select.Trigger,{className:D(Xe.trigger,o?.trigger),children:[t.jsx(Le.Select.Value,{children:a.triggerLabel||a.label}),t.jsx(Le.Select.Icon,{className:Xe.icon,children:t.jsx(N.IconChevronDown,{size:12})})]}),t.jsx(Le.Select.Portal,{container:r,children:t.jsx(Le.Select.Positioner,{className:Xe.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(Le.Select.Popup,{className:Xe.popup,children:e.map(c=>t.jsxs(Le.Select.Item,{className:D(Xe.item,o?.item),value:String(c.value),children:[t.jsx(Le.Select.ItemText,{className:D(Xe.itemText,o?.itemText),children:c.label}),t.jsx(N.IconCheck,{size:12,className:D(Xe.itemIndicator,{[Xe.active]:c.value===s})})]},String(c.value)))})})})]})}const Wc="_root_epb1d_1",Hc="_trigger_epb1d_7",Qc="_item_epb1d_11",Vc="_itemText_epb1d_16",po={root:Wc,trigger:Hc,item:Qc,itemText:Vc},Gc=({options:e,value:s,onChange:n})=>{const{txRequest:o}=wr(),r=Me(o.chainId),a=Ve(r),i=(p,g)=>{if(v.formatAmount(p,{decimals:g})==="0.000000")return 8},c=({amount:[{amount:p,denom:g}]})=>{if(F(p).isZero())return"0";const{symbol:y,decimals:I}=a(g),S=i(p,I);return`${v.formatAmount(p,{decimals:I,dp:S})} ${y}`},l=e.map(p=>{const[{denom:g}]=p.amount,{symbol:y}=a(g);return{value:g,label:c(p),triggerLabel:y}});if(e.length===1)return t.jsx("span",{className:"monospace",children:c(e[0])});const d=e.find(p=>p.amount[0].denom===s);if(!d)throw new Error("Fee option not found");const[{amount:u,denom:m}]=d.amount,{decimals:h}=a(m),f=i(u,h);return t.jsxs("div",{className:po.root,children:[t.jsx("span",{className:"monospace",children:v.formatAmount(u,{decimals:h,dp:f})}),t.jsx(Br,{options:l,value:s,onChange:n,classNames:po})]})},Yc="_root_7u427_1",Jc="_trigger_7u427_5",Zc="_chevron_7u427_13",Xc="_panel_7u427_27",el="_details_7u427_38",tl="_row_7u427_47",Nt={root:Yc,trigger:Jc,chevron:Zc,panel:Xc,details:el,row:tl},sl=({spend:e,fee:s,total:n,balance:o,symbol:r,decimals:a})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:s},e&&{label:"Required (spend + fee)",value:n},{label:"Balance",value:o}].filter(Boolean),c=a===6?void 0:8;return t.jsxs(Js.Collapsible.Root,{className:Nt.root,children:[t.jsxs(Js.Collapsible.Trigger,{className:Nt.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(N.IconChevronDown,{className:Nt.chevron,size:16})]}),t.jsx(Js.Collapsible.Panel,{className:Nt.panel,children:t.jsx("div",{className:Nt.details,children:i.map(({label:l,value:d})=>t.jsxs("div",{className:Nt.row,children:[t.jsx("span",{children:l}),t.jsxs("span",{children:[v.formatAmount(d,{decimals:a,dp:c})," ",r]})]},l))})})]})};function vs(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?V.toBase64(e):Array.isArray(e)?`[${e.map(vs).join(",")}]`:JSON.stringify(e,(s,n)=>typeof n=="bigint"?n.toString():n);default:return"unknown"}}const nl="_container_1xzyq_1",ol="_toggle_1xzyq_5",rl="_list_1xzyq_11",al="_arg_1xzyq_16",il="_type_1xzyq_21",Ot={container:nl,toggle:ol,list:rl,arg:al,type:il},cl=$e.createQueryKeys("interwovenkit:move",{abi:(e,s,n,o)=>[e,s,n,o]}),ll=({type:e,arg:s})=>vs(v.resolveBcsType(e).parse(s)),dl=({msg:e,chainId:s,fallback:n})=>{const[o,r]=Ie.useToggle(!1),{restUrl:a}=Me(s),{moduleAddress:i,moduleName:c,functionName:l,args:d}=e,{data:u}=$.useQuery({queryKey:cl.abi(a,i,c,l).queryKey,queryFn:async()=>{const h=await z.create({prefixUrl:a}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),p=JSON.parse(h.module.abi).exposed_functions.find(({name:g})=>g===l);if(!p)throw new Error(`Function ${l} not found in module ${c}`);return p.params.filter(g=>!g.startsWith("&"))},staleTime:W.INFINITY});if(!u)return n;const m=(h,f)=>{const p=u[f];return t.jsxs("div",{className:Ot.arg,children:[t.jsx("div",{className:Ot.type,children:p}),t.jsx(Wo.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(ll,{type:p,arg:h})})]},f)};return t.jsxs("div",{className:Ot.container,children:[t.jsx(J.Small,{className:Ot.toggle,onClick:r,disabled:!u,children:o?"Encode":"Decode"}),o?t.jsx("div",{className:Ot.list,children:d.map(m)}):n]})},ul="_list_r67rl_1",ml="_key_r67rl_8",hl="_value_r67rl_13",nn={list:ul,key:ml,value:hl},fl=({message:e,chainId:s})=>{const{typeUrl:n,value:o}=e;return t.jsx("div",{className:nn.list,children:Object.entries(o).map(([r,a])=>t.jsxs("div",{children:[t.jsx("div",{className:nn.key,children:r}),t.jsx("div",{className:nn.value,children:n==="/initia.move.v1.MsgExecute"&&r==="args"?t.jsx(dl,{msg:o,chainId:s,fallback:vs(a)}):vs(a)})]},r))})},_l="_item_1n572_1",pl="_title_1n572_10",gl="_content_1n572_14",on={item:_l,title:pl,content:gl},rn=({title:e,content:s})=>t.jsxs("div",{className:on.item,children:[t.jsx("div",{className:on.title,children:e}),t.jsx("div",{className:on.content,children:s})]});function Ae(e){if(e&&F(e).gt(0)&&F(e).lt(.01))return"<$0.01";const s=v.formatNumber(e,{dp:2});return s?`$${s}`:""}function Mr(e,s){const n={};for(const o of e)if(o.attributes.some(a=>a.key==="msg_index")){if(o.type==="coin_spent"){const a=o.attributes.find(c=>c.key==="spender")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(a===s&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=n[l]||BigInt(0);n[l]=d-BigInt(c)}}}if(o.type==="coin_received"){const a=o.attributes.find(c=>c.key==="receiver")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(a===s&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=n[l]||BigInt(0);n[l]=d+BigInt(c)}}}}return Object.entries(n).filter(([,o])=>o!==BigInt(0)).map(([o,r])=>({amount:r.toString(),denom:o}))}function Fr(e,s){const n={};for(const o of e)if(o.attributes.some(a=>a.key==="msg_index")&&o.type==="move"){const a=o.attributes.find(l=>l.key==="type_tag")?.value,i=o.attributes.find(l=>l.key==="data")?.value;if(!a||!i)continue;let c;try{c=JSON.parse(i)}catch{continue}if(a==="0x1::fungible_asset::WithdrawEvent"){const l=c.store_addr,d=c.amount,u=c.metadata_addr;if(l&&d&&u&&v.createUserDerivedObjectAddress(s,u)===l){const h=n[u]||BigInt(0);n[u]=h-BigInt(d)}}if(a==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,d=c.amount,u=c.metadata_addr;if(l&&d&&u&&v.createUserDerivedObjectAddress(s,u)===l){const h=n[u]||BigInt(0);n[u]=h+BigInt(d)}}}return Object.entries(n).filter(([,o])=>o!==BigInt(0)).map(([o,r])=>({amount:r.toString(),metadata:o}))}const Or=({metadata:e,chain:s,children:n})=>{const{restUrl:o}=s,{data:r}=$.useSuspenseQuery({queryKey:ys.denom(o,e).queryKey,queryFn:()=>z.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:a})=>a,staleTime:W.INFINITY});return n(r)},xl="_root_jioyr_1",yl="_title_jioyr_7",jl="_changes_jioyr_13",vl="_change_jioyr_13",wl="_amount_jioyr_34",bl="_text_jioyr_40",Cl="_value_jioyr_47",gt={root:xl,title:yl,changes:jl,change:vl,amount:wl,text:bl,value:Cl},Ur=({amount:e,asset:s,price:n})=>{const{denom:o,symbol:r,decimals:a,logoUrl:i}=s,c=v.formatAmount(e,{decimals:a}),l=n&&F(v.fromBaseUnit(e,{decimals:a})).times(n).abs();return t.jsxs("div",{className:gt.change,children:[t.jsxs("div",{className:gt.amount,children:[t.jsx(Y,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:gt.text,children:[c," ",r||o]})]}),l&&t.jsx("div",{className:gt.value,children:Ae(l)})]})},Il=({changes:e,chain:s})=>{const n=Ve(s),{data:o}=ks(s);return e.map(({amount:r,denom:a},i)=>{const c=n(a),l=o?.find(({id:d})=>d===a)?.price;return t.jsx(Ur,{amount:r,asset:c,price:l},i)})},Nl=({changes:e,chain:s})=>{const n=Ve(s),{data:o}=ks(s);return e.map(({amount:r,metadata:a},i)=>t.jsx(Or,{metadata:a,chain:s,children:c=>{const l=o?.find(({id:d})=>d===c)?.price;return t.jsx(Ur,{amount:r,asset:n(c),price:l})}},i))};function Sl(e,s){return typeof s=="bigint"?s.toString():s}const kl=$e.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Sl)]}),Al=({messages:e,memo:s,chainId:n})=>{const{initiaAddress:o,hexAddress:r}=xe(),a=Me(n),{simulateTx:i}=Fs(),{data:c}=$.useSuspenseQuery({queryKey:kl.simulate({messages:e,memo:s,chainId:n}).queryKey,queryFn:()=>i({messages:e,memo:s,chainId:n}),staleTime:W.SECOND}),l=h=>t.jsxs("div",{className:gt.root,children:[t.jsx("h2",{className:gt.title,children:"Estimated changes"}),t.jsx("div",{className:gt.changes,children:h})]});if(!c)return null;const d=c.result?.events??[];if(d.length===0)return null;if(a.metadata?.is_l1||a.metadata?.minitia?.type==="minimove"){const h=Fr(d,r),[f]=go(h);return f.length===0?null:l(t.jsx(Nl,{changes:f,chain:a}))}const u=Mr(d,o),[m]=go(u);return m.length===0?null:l(t.jsx(Il,{changes:m,chain:a}))};function go(e){return b.partition(s=>new F(s.amount).isNegative(),e)}const $l="_title_cxswl_1",Tl="_meta_cxswl_7",El="_footer_cxswl_14",ql="_rejectButton_cxswl_19",is={title:$l,meta:Tl,footer:El,rejectButton:ql},Lr=()=>{const{txRequest:e,resolve:s,reject:n}=wr(),{messages:o,memo:r,chainId:a,gas:i,gasAdjustment:c,spendCoins:l}=e,d=ne(),u=Ds(),m=Me(a),h=Bn(m),f=Pr(m),p=Rr(m),g=Ve(m),y=gr(),I=pr(),S=(e.gasPrices??f).map(({amount:x,denom:A})=>Pe.calculateFee(Math.ceil(i*c),Pe.GasPrice.fromString(x+A))),k=S.map(x=>x.amount[0]),w=x=>{const A=h.find(Z=>Z.denom===x)?.amount??"0",q=k.find(Z=>Z.denom===x)?.amount??"0",M=l.filter(Z=>Z.denom===x).reduce((Z,Ue)=>F(Z).plus(Ue.amount),F("0")),E=F(q).plus(M),H=F(A).gte(E),{symbol:ee,decimals:O}=g(x);return{symbol:ee,decimals:O,spend:M.gt(0)?M.toFixed():null,fee:q,total:E.toFixed(),balance:A,isSufficient:H}},T=()=>{if(p&&w(p).isSufficient)return p;for(const{denom:x}of k)if(w(x).isSufficient)return x;return k[0]?.denom},[P,R]=_.useState(T),{mutate:B,isPending:K}=$.useMutation({mutationKey:[jr],mutationFn:async()=>{const x=S.find(M=>M.amount[0].denom===P);if(!x)throw new Error("Fee not found");const q=!e.internal&&await y(a,o)?await I(a,d,o,x,r||""):await u(a,d,o,x,r);await s(q)},onError:async x=>{n(x)}}),j=w(P),C=!j.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(Fe,{children:[t.jsx("h1",{className:is.title,children:"Confirm tx"}),t.jsxs("div",{className:is.meta,children:[t.jsx(rn,{title:"Chain",content:a}),t.jsx(rn,{title:"Tx fee",content:t.jsx(Gc,{options:S,value:P,onChange:R})}),r&&t.jsx(rn,{title:"Memo",content:r}),C&&t.jsx(ae,{level:"error",children:t.jsx(sl,{...j})})]}),t.jsx(Al,{messages:o,memo:r,chainId:a}),t.jsx(qc,{list:o,renderHeader:({typeUrl:x})=>Is.sentenceCase(x.split(".").pop().replace(/^Msg/,"")),renderContent:x=>t.jsx(fl,{message:x,chainId:a})})]}),t.jsxs(ie,{className:is.footer,children:[t.jsx(J.Outline,{onClick:()=>n(new Error("User rejected")),disabled:K,className:is.rejectButton,children:t.jsx(N.IconClose,{size:16})}),t.jsx(J.White,{onClick:()=>B(),disabled:C,loading:K,children:"Approve"})]})]})},Dl=({children:e})=>{const[{title:s,content:n,path:o},r]=_.useState({}),[a,i]=_.useState(!1),c=G.useAtomValue(Ms),l=_.useCallback(m=>{r(m),i(!0)},[]),d=_.useCallback(()=>{r({}),i(!1)},[]),u=_.useCallback(m=>{m||(c?.reject(new Error("User rejected")),r({})),i(m)},[c]);return t.jsxs(xr.Provider,{value:{openModal:l,closeModal:d},children:[e,t.jsx(qr,{title:s,open:a,onOpenChange:u,children:t.jsx(ye,{children:o==="/tx"?t.jsx(Lr,{}):n})})]})},Pl="_container_1zg8z_1",Rl="_toast_1zg8z_10",Bl="_info_1zg8z_23",Ml="_success_1zg8z_27",Fl="_error_1zg8z_31",Ol="_icon_1zg8z_36",Ul="_content_1zg8z_43",Ll="_title_1zg8z_46",zl="_description_1zg8z_51",Kl="_close_1zg8z_72",et={container:Pl,toast:Rl,info:Bl,success:Ml,error:Fl,icon:Ol,content:Ul,title:Ll,description:zl,close:Kl},Wl=({notification:e,onClose:s,...n})=>{const o=ot.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}}),r=a=>{switch(a){case"loading":return t.jsx(wt,{size:16});case"info":case"success":return t.jsx(N.IconCheckCircleFilled,{size:16});case"error":return t.jsx(N.IconCloseCircleFilled,{size:16});default:return null}};return o((a,i)=>{if(!i)return null;const{type:c,title:l,description:d}=i,u=r(c);return t.jsx(ot.animated.div,{style:a,className:et.container,children:t.jsxs("div",{className:D(et.toast,c&&et[c]),...n,children:[u&&t.jsx("div",{className:et.icon,children:u}),t.jsxs("div",{className:et.content,children:[t.jsx("p",{className:et.title,children:l}),d&&t.jsx("div",{className:et.description,children:d})]}),t.jsx("button",{className:et.close,onClick:s,children:t.jsx(N.IconClose,{size:14})})]})})})},an=5e3,Hl=({children:e})=>{const s=yt(),[n,o]=_.useState(null),r=_.useRef(null),a=_.useRef(!1),i=()=>{r.current&&(clearTimeout(r.current),r.current=null)},c=_.useCallback(()=>{i(),o(null)},[]),l=_.useCallback(h=>{i(),o({...h,id:ao.nanoid()}),h.autoHide&&!a.current&&(r.current=setTimeout(()=>c(),an))},[c]),d=_.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:ao.nanoid()}),h.autoHide&&!a.current&&(r.current=setTimeout(()=>c(),an))},[c]),u=()=>{i(),a.current=!0},m=()=>{i(),a.current=!1,n?.autoHide&&(r.current=setTimeout(()=>c(),an))};return _.useEffect(()=>()=>i(),[]),t.jsxs(Tr.Provider,{value:{showNotification:l,updateNotification:d,hideNotification:c},children:[e,s&&Ca.createPortal(t.jsx(Wl,{notification:n,onClose:c,onMouseEnter:u,onMouseLeave:m}),s)]})},Ql=({children:e})=>{const[s,n]=_.useState(null);return t.jsx(Wn.Provider,{value:{container:s,setContainer:n},children:e})},zr=[{value:10*cr,label:"for 10 minutes"},{value:lr,label:"for 1 hour"},{value:lo,label:"for 1 day"},{value:7*lo,label:"for 7 days"},{value:0,label:"until revoked"}],Vl=zr[0].value,Gl="_container_t8r4b_1",Yl="_title_t8r4b_7",Jl="_description_t8r4b_14",Zl="_sectionTitle_t8r4b_20",Xl="_websiteInfo_t8r4b_27",ed="_favicon_t8r4b_37",td="_websiteTitle_t8r4b_42",sd="_websiteHost_t8r4b_48",nd="_warningContent_t8r4b_54",od="_ignoreButton_t8r4b_60",rd="_infoList_t8r4b_64",ad="_infoItem_t8r4b_74",id="_label_t8r4b_83",cd="_infoValue_t8r4b_92",ld="_durationTrigger_t8r4b_98",dd="_durationItem_t8r4b_99",ud="_featureList_t8r4b_103",md="_featureItem_t8r4b_111",hd="_checkIcon_t8r4b_121",fd="_learnMoreLink_t8r4b_125",_d="_footer_t8r4b_138",Q={container:Gl,title:Yl,description:Jl,sectionTitle:Zl,websiteInfo:Xl,favicon:ed,websiteTitle:td,websiteHost:sd,warningContent:nd,ignoreButton:od,infoList:rd,infoItem:ad,label:id,infoValue:cd,durationTrigger:ld,durationItem:dd,featureList:ud,featureItem:md,checkIcon:hd,learnMoreLink:fd,footer:_d};function pd(){const[e,s]=_.useState(Vl),[n,o]=G.useAtom(Os),[r,a]=_.useState(!1),i=Te(),c=re(),{address:l,username:d}=xe(),{mutate:u,isPending:m}=ci(),{closeDrawer:h}=Ge(),f={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},p=c.some(w=>{if(!w.website)return!1;const T=xo(new URL(w.website).hostname),P=xo(window.location.hostname);return T===P});if(!n)return null;const{logoUrl:g,name:y}=i(n.chainId),I=()=>{u(e)},S=()=>{n?.reject(new Error("User cancelled")),o(null),h()},k=!p&&!r;return t.jsxs(t.Fragment,{children:[t.jsxs(Fe,{className:Q.container,children:[t.jsxs("header",{children:[t.jsx("h1",{className:Q.title,children:"Enable auto-signing"}),t.jsx("p",{className:Q.description,children:"An application is requesting to enable auto-signing"})]}),t.jsxs("section",{children:[t.jsx("h2",{className:Q.sectionTitle,children:"Requested by"}),t.jsxs("div",{className:Q.websiteInfo,children:[t.jsx("img",{src:f.favicon,alt:"",className:Q.favicon}),t.jsxs("div",{children:[t.jsx("div",{className:Q.websiteTitle,children:f.title}),t.jsx("div",{className:Q.websiteHost,children:f.hostname})]})]}),!p&&!r&&t.jsx(ae,{level:"warning",mt:8,children:t.jsxs("div",{className:Q.warningContent,children:[t.jsx("span",{children:"You are on an unverified website"}),t.jsx("button",{onClick:()=>a(!0),className:Q.ignoreButton,children:"Ignore"})]})})]}),t.jsxs("section",{children:[t.jsx("h2",{className:Q.sectionTitle,children:"Applies to"}),t.jsxs("div",{className:Q.infoList,children:[t.jsxs("div",{className:Q.infoItem,children:[t.jsx("div",{className:Q.label,children:"Address"}),t.jsxs("div",{className:Q.infoValue,children:[t.jsx(N.IconWallet,{size:14}),t.jsx("span",{className:"monospace",children:v.truncate(d??l)})]})]}),t.jsxs("div",{className:Q.infoItem,children:[t.jsx("div",{className:Q.label,children:"Chain"}),t.jsxs("div",{className:Q.infoValue,children:[t.jsx(Y,{src:g,width:14,height:14,logo:!0}),t.jsx("span",{children:y})]})]}),t.jsxs("div",{className:Q.infoItem,children:[t.jsx("div",{className:Q.label,children:"Duration"}),t.jsx(Br,{options:zr,value:e,onChange:s,classNames:{trigger:Q.durationTrigger,item:Q.durationItem}})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:Q.sectionTitle,children:"About auto-signing"}),t.jsx("ul",{className:Q.featureList,children:["Send transactions without confirmation pop-ups","Protected by Privy embedded wallet","Revoke permissions any time in settings"].map(w=>t.jsxs("li",{className:Q.featureItem,children:[t.jsx(N.IconCheckCircle,{size:12,className:Q.checkIcon}),t.jsx("span",{children:w})]},w))}),t.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",className:Q.learnMoreLink,children:["Learn more ",t.jsx(N.IconExternalLink,{size:12})]})]})]}),t.jsxs(ie,{className:Q.footer,children:[t.jsx(J.Outline,{onClick:S,children:"Cancel"}),t.jsx(J.White,{onClick:I,disabled:k,loading:m,children:"Enable"})]})]})}function xo(e){const s=e.split(".");return s.length<2?e:s.slice(-2).join(".")}const gd="_container_1a4ds_1",xd="_badge_1a4ds_5",yo={container:gd,badge:xd},Kr=e=>{const{offset:s=-4,disabled:n,children:o,className:r}=e;return t.jsxs("div",{className:D(yo.container,r),children:[o,!n&&t.jsx("div",{className:yo.badge,style:{right:s,top:s}})]})},yd="_header_acels_1",jd="_back_acels_11",vd="_title_acels_23",cn={header:yd,back:jd,title:vd},Oe=({title:e,backButton:s,extra:n,children:o})=>t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:cn.header,children:[t.jsx(Et,{to:s??-1,className:cn.back,shouldReset:!!s,children:t.jsx(N.IconBack,{size:16})}),t.jsx("h1",{className:cn.title,children:e}),n]}),t.jsx(Fe,{children:o})]});function Wr(){const{initiaAddress:e,hexAddress:s}=xe(),n=vt(),o=ts();return r=>{const a=n(r);switch(o(a)){case"initia":return e;case"evm":return s;default:return""}}}function Hr(){const e=vt(),s=ts();return(n,o)=>{const r=e(o);switch(s(r)){case"initia":return v.InitiaAddress.validate(n);case"evm":return We.isAddress(n);case"cosmos":try{return V.fromBech32(n).prefix===r.bech32_prefix}catch{return!1}default:return!1}}}function wd(){const e=vt(),s=ts();return({initialAddress:n,initialChainId:o,chainId:r,fallbackAddress:a})=>{const i=e(o),c=s(i),l=e(r),d=s(l);if(c==="evm"&&d==="initia")return v.InitiaAddress(n).bech32;if(c==="initia"&&d==="evm")return v.InitiaAddress(n).hex;if(c===d)return n;if(a){if(d==="initia")return v.InitiaAddress(a).bech32;if(d==="evm")return v.InitiaAddress(a).hex}return""}}function bd(){return _e().network_type==="testnet"}function rt(){return ue.useFormContext()}function Cd(){const e=jt(),s=bd(),n={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},o={...n,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},r={...n,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},a=b.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(U.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(U.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(U.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(U.BRIDGE_DST_DENOM),quantity:localStorage.getItem(U.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(U.BRIDGE_SLIPPAGE_PERCENT)});return{...s?o:r,...a,...e}}const Id="_root_xwz5z_1",Nd="_header_xwz5z_6",Sd="_title_xwz5z_12",kd="_warning_xwz5z_18",Ad="_content_xwz5z_22",$d="_footer_xwz5z_26",Td="_secondary_xwz5z_36",dt={root:Id,header:Nd,title:Sd,warning:kd,content:Ad,footer:$d,secondary:Td},Qr=e=>{const{type:s,icon:n,title:o,children:r,primaryButton:a,secondaryButton:i}=e;return t.jsxs(Fe,{className:dt.root,children:[t.jsxs("header",{className:D(dt.header,s&&dt[s]),children:[n,t.jsx("h1",{className:dt.title,children:o})]}),t.jsx("div",{className:dt.content,children:r}),t.jsxs("footer",{className:dt.footer,children:[t.jsx(J.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),t.jsxs("button",{className:dt.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(N.IconChevronRight,{size:14})]})]})]})},Ed="_list_tmcxc_1",qd="_row_tmcxc_8",Dd="_dt_tmcxc_19",Pd="_asset_tmcxc_25",cs={list:Ed,row:qd,dt:Dd,asset:Pd},Rd=({list:e,onNavigate:s,onDismiss:n})=>{const o=_e(),r=Te(),a=Ve(o);return t.jsx(Qr,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:s},secondaryButton:{label:"Do not show again",onClick:n},children:t.jsx("div",{className:cs.list,children:e.toSorted((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:d})=>{const u=r(c),{decimals:m,symbol:h}=a(d),f=v.formatAmount(l,{decimals:m});return t.jsxs("div",{className:cs.row,children:[t.jsxs("div",{className:cs.dt,children:[t.jsx(Y,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:cs.asset,children:[f," ",h]})]},i)})})})};function ln(e,s){return e.chainId===s.chainId&&e.txHash===s.txHash}const ls=({chainId:e,txHash:s})=>`${U.OP_REMINDER}:${e}:${s}`,Bd=Ia.atomWithStorage(U.OP_REMINDER,[]);function Rt(){const e=ne(),[s=[],n]=G.useAtom(Bd),o=_.useMemo(()=>s.map(l=>{const d=localStorage.getItem(ls(l));return d?JSON.parse(d):null}).filter(l=>{if(!l)return!1;const{recipient:d,claimableAt:u}=l;return d!==e?!1:ke.isPast(u)}),[e,s]),r=_.useCallback((l,d)=>{s.some(u=>ln(u,l))||(n((u=[])=>[...u,l]),localStorage.setItem(ls(l),JSON.stringify(d)))},[s,n]),a=_.useCallback(l=>{n((d=[])=>d.filter(u=>!ln(u,l))),localStorage.removeItem(ls(l))},[n]),i=_.useCallback(l=>{const d=l.filter(u=>!s.some(m=>ln(m,u)));d.length!==0&&n((u=[])=>[...u,...d])},[s,n]),c=_.useCallback((l,d)=>{localStorage.setItem(ls(l),JSON.stringify(d)),n((u=[])=>[...u])},[n]);return{reminders:o,addReminder:r,removeReminder:a,syncReminders:i,setReminder:c}}function Vr(){const e=me(),{openModal:s,closeModal:n}=Bs(),{reminders:o,setReminder:r}=Rt();_.useEffect(()=>{const a=o.filter(l=>!l.dismissed);if(a.length===0)return;const i=()=>{const l=a.every(d=>d.chainId===a[0].chainId)?a[0].chainId:void 0;e("/op/withdrawals",{chainId:l}),c()},c=()=>{n();for(const l of a)r(l,{...l,dismissed:!0})};s({content:_.createElement(Rd,{list:a,onNavigate:i,onDismiss:c})})},[o,n,e,s,r])}const Md="_wrapper_5ssm8_1",Fd="_balance_5ssm8_11",Od="_button_5ssm8_15",dn={wrapper:Md,balance:Fd,button:Od},Gr=({onClick:e,children:s,disabled:n})=>t.jsxs("div",{className:dn.wrapper,children:[t.jsx(N.IconWallet,{size:16}),t.jsx("span",{className:dn.balance,children:s}),t.jsx("button",{type:"button",tabIndex:-1,className:dn.button,onClick:()=>e(),disabled:n,children:"MAX"})]}),Ud="_fieldset_y241y_1",Ld="_upper_y241y_9",zd="_select_y241y_14",Kd="_account_y241y_19",Wd="_lower_y241y_24",Hd="_wrapper_y241y_25",Qd="_balance_y241y_32",Vd="_value_y241y_36",Gd="_error_y241y_49",ze={fieldset:Ud,upper:Ld,select:zd,account:Kd,lower:Wd,wrapper:Hd,balance:Qd,value:Vd,error:Gd},In=e=>{const{selectButton:s,accountButton:n,quantityInput:o,balanceButton:r,value:a,errorMessage:i,hideNumbers:c}=e;return t.jsxs("div",{className:ze.fieldset,children:[t.jsxs("div",{className:ze.upper,children:[t.jsx("div",{className:ze.select,children:s}),t.jsx("div",{className:ze.account,children:n})]}),!c&&t.jsxs("div",{className:ze.lower,children:[o,t.jsxs("div",{className:ze.wrapper,children:[t.jsx("div",{className:ze.balance,children:r}),a&&t.jsx("div",{className:ze.value,children:a})]}),i&&t.jsxs("footer",{className:ze.error,children:[t.jsx(N.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function ss(){const e=_.useRef(null),s=Ls();return _.useEffect(()=>{s||e.current?.focus()},[s]),e}const Yd="_input_h8073_1",Jd={input:Yd};function jo(e,s){const n=e.replace(/[^0-9.]/g,""),[o,...r]=n.split(".");return r.length===0?o:`${o}.${r.join("").slice(0,s)}`}function Yr(e){const{name:s,control:n,dp:o=6,className:r,rules:a,...i}=e,c=ss();return t.jsx(ue.Controller,{name:s,control:n,rules:a,render:({field:l})=>t.jsx("input",{...l,className:D(Jd.input,r),onChange:d=>l.onChange(jo(d.target.value,o)),onPaste:d=>{d.preventDefault();const u=d.clipboardData.getData("text");if(!/^[0-9,]+(\.[0-9]+)?$/.test(u))return;const h=u.replace(/,/g,""),f=jo(h,o);l.onChange(f)},placeholder:"0",inputMode:"decimal",autoComplete:"off",...i,ref:Ho.mergeRefs([l.ref,c])})})}const Zd="_input_qpv94_1",Xd="_placeholder_qpv94_18",Nn={input:Zd,placeholder:Xd},eu=({children:e})=>t.jsx("p",{className:D(Nn.input,{[Nn.placeholder]:F(e).isZero()}),children:e}),ws=({balance:e,decimals:s})=>{const{control:n}=ue.useFormContext(),o={required:"Enter amount",validate:r=>F(r).isZero()?"Enter amount":F(v.toBaseUnit(r,{decimals:s})).gt(e??0)?"Insufficient balance":!0};return t.jsx(Yr,{name:"quantity",control:n,className:Nn.input,rules:o})};ws.ReadOnly=eu;const Dt=({title:e,content:s,children:n,className:o})=>{const[r,a]=_.useState(!1),i=()=>a(!1);return t.jsx(qr,{title:e,trigger:n,className:o,open:r,onOpenChange:a,children:s(i)})},tu="_tooltip_6zakp_1",su="_arrow_6zakp_43",vo={tooltip:tu,arrow:su},ns=({label:e,children:s,small:n,...o})=>t.jsxs(te.Tooltip.Root,{...o,children:[t.jsx(te.Tooltip.Trigger,{asChild:!0,children:s}),t.jsx(te.Tooltip.Portal,{container:yt(),children:t.jsxs(te.Tooltip.Content,{className:D(vo.tooltip,{small:n}),collisionBoundary:yt(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(te.Tooltip.Arrow,{className:vo.arrow})]})})]});function Qn(e,s){const n=Ye();return $.useQuery({queryKey:Re.balances(s,e).queryKey,queryFn:()=>n.post("v2/info/balances",{json:{chains:{[s]:{address:e,denoms:[]}}}}).json(),select:({chains:o})=>e?o?o[s].denoms??{}:{}:{},enabled:!!e,staleTime:W.SECOND})}function nu(e,s,n){const{data:o={}}=Qn(e,s);return b.path([n],o)}const ou=[["d",1440*60],["h",3600],["m",60],["s",1]];function Sn(e){if(!e)return;const{formattedParts:s}=ou.reduce(({remainingSeconds:n,formattedParts:o},[r,a])=>{const i=Math.floor(n/a);return{remainingSeconds:n-i*a,formattedParts:i>0?[...o,`${i}${r}`]:o}},{remainingSeconds:e,formattedParts:[]});return s.join(" ")}function Jr(e){return e?.map(s=>{const{amount:n,origin_asset:o}=s;return`${v.formatAmount(n,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function wo(e,s){const{watch:n}=rt(),o=n(),r=Ye(),a=Es(),i={...o,quantity:e},c=$.useQueryClient();return $.useQuery({queryKey:Re.route(i,s?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:l,srcDenom:d,quantity:u,dstChainId:m,dstDenom:h}=i,{decimals:f}=c.getQueryData(Re.asset(l,d).queryKey)??{decimals:0},p={amount_in:v.toBaseUnit(u,{decimals:f}),source_asset_chain_id:l,source_asset_denom:d,dest_asset_chain_id:m,dest_asset_denom:h,is_op_withdraw:s?.isOpWithdraw},g=await r.post("v2/fungible/route",{json:p}).json(),y={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return a("Bridge Simulation Success",y),g},enabled:!!Number(i.quantity)&&!s?.disabled,staleTime:W.MINUTE})}function ru(e){return $.useQuery({queryKey:Re.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 au(){const{watch:e}=rt(),{srcChainId:s,srcDenom:n,dstChainId:o,dstDenom:r}=e(),a=Be(s),i=Jt(a),c=Qe(n,s),l=Qe(r,o),d=_e(),u=re();return i==="initia"&&o===d.chainId&&c.symbol===l.symbol&&u.find(m=>m.chainId===s)?.metadata?.op_denoms?.includes(l.denom)}const iu="_label_9417z_1",cu="_wrapper_9417z_7",lu="_input_9417z_10",du="_clear_9417z_18",ds={label:iu,wrapper:cu,input:lu,clear:du},Vn=({mode:e="onChange",myAddress:s,...n})=>{const{validate:o=v.InitiaAddress.validate,chainType:r="initia",onApply:a,ref:i}=n,c=ss(),{control:l,getValues:d,setValue:u,formState:m}=ue.useFormContext(),h=d("recipient"),[f,p]=_.useState(h),g=sr(),{data:y,isLoading:I,error:S}=$.useQuery({queryKey:As.address(g.restUrl,f).queryKey,queryFn:()=>g.getAddress(f),staleTime:W.MINUTE,enabled:g.validateUsername(f)}),k=y??(o(f)?f:""),w=s&&v.InitiaAddress.equals(k,s),T=async()=>{try{const B=await navigator.clipboard.readText();p(B.trim())}catch{}};_.useEffect(()=>{e==="onChange"&&(!f&&!m.dirtyFields.recipient||u("recipient",y??f,{shouldValidate:!0,shouldDirty:!0}))},[m.dirtyFields.recipient,f,e,u,y]);const P=()=>{I||S||(u("recipient",k,{shouldValidate:!0,shouldDirty:!0}),a?.())},R=()=>{if(I)return t.jsx(At,{level:"loading",children:"Resolving username..."});if(S)return t.jsx(At,{level:"error",children:S.message});if(y)return t.jsx(At,{level:"success",className:"monospace",children:y});if(e==="onSubmit"&&f&&!k)return t.jsx(At,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:ds.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(J.Small,{type:"button",tabIndex:-1,onClick:T,children:"Paste"})]}),t.jsxs("div",{className:ds.wrapper,children:[t.jsx(ue.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:B=>o(B)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:D(ds.input,"monospace"),value:f,onChange:B=>p(B.target.value.trim()),placeholder:r==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?Ho.mergeRefs([i,c]):i})}),!!f&&t.jsx("button",{type:"button",className:ds.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:t.jsx(N.IconCloseCircleFilled,{size:16})})]}),R(),w&&t.jsx(At,{children:"This is my address"}),e==="onSubmit"&&t.jsx(ie,{extra:(!s||!!k&&!w)&&t.jsx(ae,{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(J.White,{type:"button",onClick:P,disabled:I||!!S||!k,children:"Apply"})})]})},uu="_scrollable_1p1lw_1",mu="_list_1p1lw_5",hu="_item_1p1lw_9",fu="_name_1p1lw_13",us={scrollable:uu,list:mu,item:hu,name:fu};function Zr({onSelect:e,list:s,...n}){const{getImage:o,getName:r,getKey:a,getIsLoading:i,getDisabled:c}=n;return t.jsx(Fe,{className:us.scrollable,children:t.jsx("div",{className:us.list,children:s.map(l=>t.jsxs("button",{className:us.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),children:[t.jsx(Y,{src:o(l),width:28,height:28}),t.jsx("span",{className:us.name,children:r(l)}),i?.(l)&&t.jsx(wt,{size:16})]},a(l)))})})}function Ks(){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(o=>o.name===n)}}const _u="_account_iwrlj_8",pu="_clear_iwrlj_27",gu="_white_iwrlj_38",Ut={account:_u,clear:pu,white:gu},bo=({type:e})=>{const{watch:s,setValue:n}=rt(),{srcChainId:o,dstChainId:r,cosmosWalletName:a}=s(),c=s(e==="src"?"sender":"recipient"),l=Jt(Be(r)),{list:d,find:u}=Ks(),m=u(a),h=Wr(),f=Hr(),p=h(r),g=v.InitiaAddress.equals(c,p),y=()=>t.jsx(Dt,{title:"Connect wallet",content:k=>t.jsx(Zr,{onSelect:async w=>{const T=w.getProvider();if(!T)return window.open(w.fallbackUrl,"_blank");const P=T.getOfflineSigner(o),[{address:R}]=await P.getAccounts();n("sender",R),n("cosmosWalletName",w.name),k()},list:d,getImage:w=>w.image,getName:w=>w.name,getKey:w=>w.name}),className:D(Ut.account,{[Ut.white]:!c}),children:c?t.jsxs(t.Fragment,{children:[m&&t.jsx(Y,{src:m.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:v.truncate(c)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(N.IconChevronRight,{size:14})]})}),I=k=>t.jsx(Dt,{title:"Recipient",content:w=>t.jsx(Fe,{children:t.jsx(Vn,{mode:"onSubmit",myAddress:p,chainType:l,validate:T=>f(T,r),onApply:w})}),className:Ut.account,children:k}),S=()=>{switch(l){case"initia":case"evm":return g?I(t.jsx(N.IconWallet,{size:14})):t.jsxs("div",{className:Ut.account,children:[t.jsx("span",{className:"monospace",children:v.truncate(c)}),t.jsx("button",{type:"button",className:Ut.clear,onClick:()=>n("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(N.IconCloseCircleFilled,{size:14})})]});case"cosmos":return I(t.jsxs(t.Fragment,{children:[c?t.jsx("span",{className:"monospace",children:v.truncate(c)}):t.jsx("span",{children:"Recipient"}),t.jsx(N.IconEdit,{size:14})]}))}};switch(e){case"src":return y();case"dst":return S()}},xu="_images_cj4xz_1",un={images:xu},Ws=({assetLogoUrl:e,assetLogoSize:s=36,chainLogoUrl:n,chainLogoSize:o=18,chainLogoOffset:r=6,className:a})=>t.jsxs("div",{className:D(un.images,a),style:{position:"relative"},children:[t.jsx(Y,{src:e,width:s,height:s,className:un.asset,logo:!0}),t.jsx(Y,{src:n,width:o,height:o,className:un.chain,style:{position:"absolute",bottom:0,right:-1*r},logo:!0})]}),yu="_root_1ipwv_1",ju="_content_1ipwv_10",vu="_details_1ipwv_18",wu="_symbol_1ipwv_23",bu="_chain_1ipwv_31",Cu="_chevron_1ipwv_40",ut={root:yu,content:ju,details:vu,symbol:wu,chain:bu,chevron:Cu},Xr=({asset:e,chain:s,readOnly:n})=>{const o=t.jsxs("div",{className:ut.content,children:[t.jsx(Ws,{assetLogoUrl:e.logoUrl,chainLogoUrl:s.logoUrl}),t.jsxs("div",{className:ut.details,children:[t.jsx("div",{className:ut.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:ut.chain,children:["on ",s.name]})]})]});return n?t.jsx("div",{className:ut.root,children:o}):t.jsxs("div",{className:ut.root,children:[o,t.jsx(N.IconChevronDown,{size:16,className:ut.chevron})]})};function Iu(e,s,n){return n.filter(o=>{const r=e.map(a=>o[a]).map(a=>String(a??"").toLowerCase());return b.any(b.includes(s.toLowerCase()),r)})}const Nu="_root_7yxgy_1",Su="_label_7yxgy_7",ku="_input_7yxgy_19",Au="_hasValue_7yxgy_29",$u="_clear_7yxgy_33",Lt={root:Nu,label:Su,input:ku,hasValue:Au,clear:$u},Hs=e=>{const{rootClassName:s,padding:n=16,iconSize:o=16,onClear:r,ref:a,...i}=e;return t.jsxs("div",{className:D(Lt.root,s,{[Lt.hasValue]:i.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${o}px`},children:[t.jsx("label",{htmlFor:"search",className:Lt.label,children:t.jsx(N.IconSearch,{size:o})}),t.jsx("input",{className:Lt.input,id:"search",type:"text",maxLength:100,ref:a,...i}),i.value&&t.jsx("button",{type:"button",className:Lt.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:r,children:t.jsx(N.IconCloseCircleFilled,{size:o})})]})},Tu="_container_1voou_1",Eu="_search_1voou_6",qu="_list_1voou_10",Du="_item_1voou_14",Pu="_logo_1voou_35",Ru="_info_1voou_39",Bu="_symbol_1voou_44",Mu="_name_1voou_52",Fu="_balance_1voou_58",Ou="_value_1voou_65",Ce={container:Tu,search:Eu,list:qu,item:Du,logo:Pu,info:Ru,symbol:Bu,name:Mu,balance:Fu,value:Ou},os=e=>{const{assets:s,onSelect:n,renderAsset:o=(c,l)=>l(c)}=e,[r,a]=_.useState(""),i=Iu(["symbol"],r,s);return t.jsxs("div",{className:Ce.container,children:[t.jsx(Hs,{value:r,onChange:c=>a(c.target.value),onClear:()=>a(""),placeholder:"Search by symbol",rootClassName:Ce.search,padding:20,ref:ss()}),i.length===0?t.jsx(se,{children:"No assets"}):t.jsx("div",{className:Ce.list,children:i.map(c=>t.jsx("button",{type:"button",className:Ce.item,onClick:()=>n(c.denom),children:o(c,l=>{const{denom:d,logoUrl:u,symbol:m,name:h,balance:f,decimals:p,value:g=0}=l;return t.jsxs(t.Fragment,{children:[t.jsx(Y,{src:u,width:32,height:32,className:Ce.logo,logo:!0}),t.jsxs("div",{className:Ce.info,children:[t.jsx("div",{className:Ce.symbol,children:m||d}),t.jsx("div",{className:Ce.name,children:h})]}),t.jsxs("div",{className:Ce.balance,children:[f&&t.jsx("div",{children:v.formatAmount(f,{decimals:p})}),g>0&&t.jsx("div",{className:Ce.value,children:Ae(g)})]})]})})},c.denom))})]})},Uu=()=>t.jsxs("div",{className:Ce.container,children:[t.jsx(Hs,{rootClassName:Ce.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(se,{children:"Loading..."})]});os.Placeholder=Uu;const Lu="_stack_a3b9q_1",zu="_title_a3b9q_8",Ku="_grid_a3b9q_15",Wu="_item_a3b9q_21",Hu="_button_a3b9q_25",Qu="_active_a3b9q_43",$t={stack:Lu,title:zu,grid:Ku,item:Wu,button:Hu,active:Qu},xt=({label:e,chains:s,value:n,onSelect:o,getShowIndicator:r})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:$t.title,children:e}),t.jsx("div",{className:$t.grid,children:s.map(({chainId:a,name:i,logoUrl:c})=>t.jsx(Kr,{offset:-2,disabled:!r?.(a),className:$t.item,children:t.jsx(ns,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:D($t.button,{[$t.active]:a===n}),onClick:()=>o(a),children:t.jsx(Y,{src:c,width:28,height:28,logo:!0})})})},a))})]}),Vu=({children:e})=>t.jsx("div",{className:$t.stack,children:e});xt.Stack=Vu;const Gu=({address:e,chain:s,onSelect:n})=>{const o=qt(s.chain_id),{data:r={}}=Qn(e,s.chain_id);return t.jsx(os,{assets:b.sortWith([b.descend(a=>a.symbol==="INIT"),b.descend(a=>a.value),({balance:a="0"},{balance:i="0"})=>F(i).comparedTo(a)??0,b.ascend(a=>a.symbol.toLowerCase())],o.filter(a=>!a.hidden).map(a=>{const{denom:i,symbol:c=v.truncate(i),logo_uri:l}=a,d=r[i]??{};return{...a,symbol:c,decimals:a.decimals??0,logoUrl:l??"",name:a.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:n})},Yu=({type:e,afterSelect:s})=>{const n=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",r=e==="src"?"sender":"recipient",a=Pt(),i=Kn(),{watch:c,setValue:l}=rt(),d=c(r),u=c(n),m=c(o),[h,f]=_.useState(u),p=Be(h),g=wd(),y=Sr(),[I,S]=b.partition(w=>y(w.chain_id),i.filter(w=>!w.hidden)),k=w=>{if(u===h&&m===w){s();return}l(n,h),l(o,w),s()};return t.jsxs(t.Fragment,{children:[t.jsxs(xt.Stack,{children:[t.jsx(xt,{label:"Interwoven Economy",chains:I.map(({chain_id:w,chain_name:T,pretty_name:P,logo_uri:R})=>({chainId:w,name:P||T,logoUrl:R??""})),value:h,onSelect:f}),t.jsx(xt,{label:"Chains",chains:S.map(({chain_id:w,chain_name:T,pretty_name:P,logo_uri:R})=>({chainId:w,name:P||T,logoUrl:R??""})),value:h,onSelect:f})]}),t.jsx(ye,{suspenseFallback:t.jsx(os.Placeholder,{}),children:t.jsx(Gu,{address:g({initialAddress:d,initialChainId:u,chainId:h,fallbackAddress:e==="src"?a:void 0}),chain:p,onSelect:k})},h)]})},Co=({type:e})=>{const s=e==="src"?"srcChainId":"dstChainId",n=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:r}=rt(),a=r(s),i=r(n),c=Be(a),l=Qe(i,a);return t.jsx(Dt,{title:o,content:d=>t.jsx(Yu,{type:e,afterSelect:d}),children:t.jsx(Xr,{asset:{denom:l.denom,decimals:l.decimals??0,symbol:l.symbol,logoUrl:l.logo_uri??""},chain:{chainId:c.chain_id,name:c.pretty_name||c.chain_name,logoUrl:c.logo_uri??""}})})},Ju="_skeleton_1l4jn_1",Zu={skeleton:Ju},mn=({width:e="100%",height:s})=>t.jsx("div",{className:Zu.skeleton,style:{width:e,height:s}}),Xu="_stack_1ip8h_1",em="_button_1ip8h_6",tm="_isLoading_1ip8h_19",sm="_disabled_1ip8h_19",nm="_checked_1ip8h_23",om="_header_1ip8h_37",rm="_title_1ip8h_43",am="_duration_1ip8h_52",im="_warning_1ip8h_62",cm="_amount_1ip8h_66",lm="_value_1ip8h_67",be={stack:Xu,button:em,isLoading:tm,disabled:sm,checked:nm,header:om,title:rm,duration:am,warning:im,amount:cm,value:lm},dm=({children:e})=>t.jsx("div",{className:be.stack,children:e}),ps=({label:e,query:s,value:n,onSelect:o,...r})=>{const{data:a,isLoading:i}=s,{watch:c}=rt(),{dstChainId:l,dstDenom:d}=c(),u=Qe(d,l),m=!i&&r.checked,h=!i&&!a;return t.jsxs("button",{type:"button",className:D(be.button,{[be.isLoading]:i,[be.disabled]:h,[be.checked]:m}),onClick:()=>{i||h||o(n)},children:[t.jsxs("div",{className:be.header,children:[t.jsxs("div",{className:be.title,children:[t.jsx("span",{children:e}),m&&t.jsx(N.IconCheck,{size:14})]}),i?t.jsx(mn,{width:80,height:16}):a?t.jsxs("div",{className:D(be.duration,{[be.warning]:n==="op"}),children:[t.jsx(N.IconClockFilled,{size:12}),t.jsx("span",{children:Sn(a.estimated_route_duration_seconds)})]}):t.jsx("div",{className:be.duration,children:"Not available"})]}),(i||a)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:be.amount,children:i?t.jsx(mn,{width:260,height:40}):a?v.formatAmount(a.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:be.value,children:i?t.jsx(mn,{width:120,height:16}):a?a.usd_amount_out?Ae(a.usd_amount_out):"$-":null})]})]})};ps.Stack=dm;const um="_description_s1yto_1",mm="_presets_s1yto_8",hm="_preset_s1yto_8",fm="_active_s1yto_28",_m="_custom_s1yto_39",pm="_wrapper_s1yto_45",gm="_percent_s1yto_54",qe={description:um,presets:mm,preset:hm,active:fm,custom:_m,wrapper:pm,percent:gm},Io=["0.1","0.5","1.0"],xm=({afterConfirm:e})=>{const s=rt(),n=s.getValues("slippagePercent"),[o,r]=_.useState(null),{control:a,watch:i,getValues:c,setValue:l}=ue.useForm({defaultValues:{value:n}}),d=i("value");_.useEffect(()=>{const g=Io.findIndex(y=>y===n);r(g>=0?g:null)},[n]);const u=(g,y)=>{l("value",g),r(y)},m=()=>{r(null)},h=_.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),f=h?.type==="error",p=({value:g})=>{s.setValue("slippagePercent",g),e()};return t.jsxs(Fe,{children:[t.jsx("p",{className:qe.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:qe.presets,children:[Io.map((g,y)=>t.jsxs("button",{type:"button",className:D(qe.preset,{[qe.active]:o===y}),onClick:()=>u(g,y),children:[g,"%"]},g)),o!==null?t.jsx("button",{type:"button",className:D(qe.preset,qe.custom),onClick:()=>r(null),children:"Custom"}):t.jsxs("div",{className:qe.wrapper,children:[t.jsx(Yr,{name:"value",control:a,dp:2,onFocus:m,placeholder:"",className:D(qe.preset,qe.active)}),t.jsx("span",{className:qe.percent,children:"%"})]})]}),h&&t.jsx(ae,{level:h.type,children:h.text}),t.jsx(ie,{children:t.jsx(J.White,{type:"button",onClick:()=>p(c()),disabled:f,children:"Confirm"})})]})},ym="_form_1coq4_1",jm="_arrow_1coq4_5",vm="_divider_1coq4_13",wm="_flip_1coq4_21",bm="_meta_1coq4_37",Cm="_row_1coq4_50",Im="_title_1coq4_56",Nm="_description_1coq4_60",Sm="_icon_1coq4_67",km="_edit_1coq4_72",Am="_warning_1coq4_93",ge={form:ym,arrow:jm,divider:vm,flip:wm,meta:bm,row:Cm,title:Im,description:Nm,icon:Sm,edit:km,warning:Am},$m=()=>{const e=me(),s=Ls(),[n,o]=Ie.useLocalStorage(U.BRIDGE_ROUTE_TYPE,"default"),{watch:r,setValue:a,handleSubmit:i,formState:c}=rt(),l=r(),{srcChainId:d,srcDenom:u,dstChainId:m,dstDenom:h,quantity:f,sender:p,slippagePercent:g}=l,y=Te(),I=Be(d),S=Jt(I),k=Be(m),w=Jt(k),T=Qe(u,d),P=Qe(h,m),{data:R}=Qn(p,d),B=nu(p,d,u),K=!B?.amount||F(B.amount).isZero(),[j]=Ie.useDebounceValue(f,300),C=S!=="initia"&&w!=="initia",x=au(),A=wo(j,{disabled:C}),q=wo(j,{isOpWithdraw:!0,disabled:!x}),M=x&&n==="op"?q:A,{data:E,isLoading:H,isFetching:ee,error:O}=M,{data:Z}=ru(O),Ue=j&&(H||ee),Je=()=>{a("srcChainId",m),a("srcDenom",h),a("dstChainId",d),a("dstDenom",u),a("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:at,closeModal:he}=Bs(),pe=i(L=>{if(E?.warning){const{type:ct="",message:Ys}=E.warning??{};at({content:t.jsx(Qr,{type:"warning",icon:t.jsx(N.IconWarningFilled,{size:40}),title:Is.sentenceCase(ct),primaryButton:{label:"Cancel",onClick:he},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:E,values:L}),he()}},children:t.jsx("p",{className:ge.warning,children:Ys})})});return}e("/bridge/preview",{route:E,values:L})}),Ct=_.useMemo(()=>E?.estimated_fees?.filter(({fee_behavior:L})=>L==="FEE_BEHAVIOR_DEDUCTED")??[],[E]),it=_.useMemo(()=>E?.estimated_fees?.filter(({fee_behavior:L})=>L==="FEE_BEHAVIOR_ADDITIONAL")??[],[E]),Mt=_.useMemo(()=>{for(const L of it){const ct=R?.[L.origin_asset.denom]?.amount??"0",Ys=E?.source_asset_denom===L.origin_asset.denom?E.amount_in:"0";if(F(ct).lt(F(Ys).plus(L.amount??"0")))return`Insufficient ${L.origin_asset.symbol} for fees`}},[R,E,it]),eo=_.useMemo(()=>{if(!l.sender)return"Connect wallet";if(!l.quantity||!j)return"Enter amount";if(!l.recipient)return"Enter recipient address";if(c.errors.quantity)return c.errors.quantity.message;if(!E)return"Route not found";if(Mt)return Mt},[j,Mt,c,E,l]),pa=E?v.formatAmount(E.amount_out,{decimals:P.decimals}):"0",ga=F(f).gt(0)&&F(f).isEqualTo(v.fromBaseUnit(B?.amount,{decimals:B?.decimals??0})),xa=(()=>{switch(S){case"initia":return y(d).fees.fee_tokens.some(({denom:L})=>L===u);case"cosmos":return I.fee_assets.some(({denom:L})=>L===u);case"evm":return!We.isAddress(u);default:return!1}})(),Gs=_.useCallback((L,ct)=>L.length?t.jsxs("div",{className:ge.description,children:[Jr(L),!s&&t.jsx(ns,{label:ct,children:t.jsx("span",{className:ge.icon,children:t.jsx(N.IconInfoFilled,{size:12})})})]}):null,[s]),rs=F(f).gt(0)&&x,to=_.useMemo(()=>E?[{condition:!!E.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Gs(Ct,"Fee deducted from the amount you receive"),Gs(it,"Fee charged in addition to the amount you enter")]})},{condition:!rs&&!!Sn(E.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:ge.description,children:Sn(E.estimated_route_duration_seconds)})},{condition:E.does_swap,title:"Slippage",content:t.jsxs("span",{className:ge.description,children:[t.jsxs("span",{children:[g,"%"]}),t.jsx(Dt,{title:"Slippage tolerance",content:L=>t.jsx(xm,{afterConfirm:L}),className:ge.edit,children:t.jsx(N.IconSettingFilled,{size:12})})]})}].filter(L=>L.condition):[],[it,Ct,Gs,E,rs,g]);return t.jsxs("form",{className:ge.form,onSubmit:pe,children:[t.jsx(In,{selectButton:t.jsx(Co,{type:"src"}),accountButton:S==="cosmos"&&t.jsx(bo,{type:"src"}),quantityInput:t.jsx(ws,{balance:B?.amount,decimals:T?.decimals}),balanceButton:t.jsx(Gr,{onClick:()=>a("quantity",v.fromBaseUnit(B?.amount,{decimals:T?.decimals??0}),{shouldValidate:!0}),disabled:K,children:v.formatAmount(B?.amount??"0",{decimals:T.decimals})}),value:E?E.usd_amount_in?Ae(E.usd_amount_in):"$-":"$0"}),t.jsxs("div",{className:ge.arrow,children:[t.jsx("div",{className:ge.divider}),t.jsx("button",{type:"button",className:ge.flip,onClick:()=>Je(),children:t.jsx(N.IconChevronDown,{size:16})})]}),t.jsx(In,{selectButton:t.jsx(Co,{type:"dst"}),accountButton:t.jsx(bo,{type:"dst"}),quantityInput:t.jsx(ws.ReadOnly,{children:pa}),value:E?E.usd_amount_out?Ae(E.usd_amount_out):"$-":"$0",hideNumbers:rs}),t.jsx(bn,{children:rs?t.jsxs(ps.Stack,{children:[t.jsx(ps,{label:"Fast",query:A,value:"default",onSelect:o,checked:n==="default"}),t.jsx(ps,{label:"Lossless",query:q,value:"op",onSelect:o,checked:n==="op"})]}):null}),t.jsx(ie,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(ae.Stack,{children:[E?.extra_infos?.map(L=>t.jsx(ae,{level:"info",children:L},L)),Z&&t.jsx(ae,{level:"info",children:Z}),ga&&xa&&t.jsx(ae,{level:"warning",children:"Make sure to leave enough for transaction fee"}),E?.warning&&t.jsx(ae,{level:"warning",children:E.warning.message}),E?.extra_warnings?.map(L=>t.jsx(ae,{level:"warning",children:L},L))]}),t.jsx(bn,{children:to.length>0&&t.jsx("div",{className:ge.meta,children:to.map((L,ct)=>t.jsxs("div",{className:ge.row,children:[t.jsx("span",{className:ge.title,children:L.title}),L.content]},ct))})})]}),children:t.jsx(J.White,{loading:Ue&&"Simulating...",disabled:!!eo,children:eo??"Preview route"})})]})},Tm=()=>{Vr();const e=Ka(),s=me(),{closeDrawer:n}=Ge(),o=Pt(),r=Cd(),a=ue.useForm({mode:"onChange",defaultValues:r}),{watch:i,setValue:c}=a,{srcChainId:l,dstChainId:d,srcDenom:u,dstDenom:m,quantity:h,slippagePercent:f,recipient:p}=i();i((j,{name:C})=>{(C==="srcChainId"||C==="srcDenom")&&c("quantity","",{shouldTouch:!1,shouldDirty:!1})});const g=Wr(),y=g(l),I=g(d),k=Hr()(p,d);_.useEffect(()=>{c("cosmosWalletName",void 0),c("sender",y)},[l,y,c]),_.useEffect(()=>{k||c("recipient",I)},[I,k,c]);const w=qt(l),T=qt(d),P=_.useMemo(()=>{if(!w.find(j=>j.denom===u))return`${u} is not available for bridge/swap on ${l}`;if(!T.find(j=>j.denom===m))return`${m} is not available for bridge/swap on ${d}`},[T,d,m,w,l,u]);_.useEffect(()=>{P||(localStorage.setItem(U.BRIDGE_SRC_CHAIN_ID,l),localStorage.setItem(U.BRIDGE_SRC_DENOM,u),localStorage.setItem(U.BRIDGE_DST_CHAIN_ID,d),localStorage.setItem(U.BRIDGE_DST_DENOM,m),localStorage.setItem(U.BRIDGE_QUANTITY,h),localStorage.setItem(U.BRIDGE_SLIPPAGE_PERCENT,f))},[l,u,d,m,h,f,P]);const R=e[0].path==="/bridge",B=()=>t.jsxs(t.Fragment,{children:[t.jsx(se,{error:!0,children:P}),t.jsx(ie,{children:R?t.jsx(J.White,{onClick:n,children:"Close"}):t.jsx(J.White,{onClick:()=>s(-1),children:"Go back"})})]}),{reminders:K}=Rt();return t.jsx(Oe,{title:"Bridge/Swap",backButton:R?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(J.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(Kr,{offset:0,disabled:K.length===0,children:t.jsx(J.Small,{onClick:()=>s("/op/withdrawals"),disabled:!o,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:P?B():t.jsx(ue.FormProvider,{...a,children:t.jsx(ye,{children:t.jsx($m,{})})})})},Em="_button_14cv7_1",qm="_checkbox_14cv7_10",Dm="_checked_14cv7_23",ms={button:Em,checkbox:qm,checked:Dm},Pm=({checked:e,onClick:s,label:n,className:o})=>t.jsxs("button",{type:"button",className:D(ms.button,o),onClick:s,children:[t.jsx("div",{className:D(ms.checkbox,{[ms.checked]:e}),children:e&&t.jsx(N.IconCheck,{size:12})}),t.jsx("span",{className:ms.label,children:n})]}),Rm="_button_1iys9_1",Bm={button:Rm},ea=({onClick:e,disabled:s})=>{const{ref:n,inView:o}=Na.useInView();return _.useEffect(()=>{o&&e()},[o,e]),t.jsxs("button",{className:Bm.button,onClick:e,disabled:s,ref:n,children:[t.jsx("span",{children:"Load more"}),t.jsx(N.IconChevronDown,{size:12})]})};function ta(e,s){return e.reduce((n,o)=>{const r=s(o);if(!r)return n;const a=r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=n[a]||[];return{...n,[a]:[...i,o]}},{})}const gs=({chainId:e,txHash:s})=>`${U.BRIDGE_HISTORY}:${e}:${s}`,bs=100,No=10;function sa(){const[e,s]=Ie.useLocalStorage(U.BRIDGE_HISTORY,[]),n=_.useCallback((r,a)=>{localStorage.setItem(gs(r),JSON.stringify(a));for(const i of e.slice(bs-1))localStorage.removeItem(gs(i));s((i=[])=>[r,...i.slice(0,bs-1)])},[e,s]),o=_.useCallback(r=>{const a=localStorage.getItem(gs(r));return a?JSON.parse(a):null},[]);return{history:e,addHistoryItem:n,getHistoryDetails:o}}function na(e){return Ie.useLocalStorage(gs(e),null)}async function Mm(e,s){const n=z.create({prefixUrl:s}),o=`cosmos/auth/v1beta1/account_info/${e}`;for(let r=1;r<=24;r++)try{return await n.get(o).json()}catch{await new Promise(a=>setTimeout(a,5e3))}throw new Error(`Timeout: ${e} not found`)}async function kn(e,s){const{chain_type:n,chain_id:o,chain_name:r,evm_fee_asset:a,rpc:i}=s;if(n!=="evm")throw new Error(`Chain is not an EVM chain: ${r}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}catch(c){if(b.path(["error","code"],c)!==4902)throw c;if(!a)throw new Error(`Fee asset is not defined for chain: ${r}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(o).toString(16)}`,chainName:r,nativeCurrency:a,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}}function Bt(){return jt()}function Fm(e){const s=me(),{showNotification:n,updateNotification:o,hideNotification:r}=Hn(),{addHistoryItem:a}=sa(),i=Es(),{route:c,values:l}=Bt(),{srcChainId:d,sender:u,recipient:m,cosmosWalletName:h}=l,f=fr(),{requestTxSync:p,waitForTxConfirmation:g}=xe(),{find:y}=Ks(),I=Xt(),S=qs(),k=Be(d),w=Jt(k),T=Nr(d),P=$.useQueryClient(),{registryUrl:R}=X(),B=Te(),{addReminder:K}=Rt(),j=Ye();return $.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const C=e.cosmos_tx.msgs.map(({msg_type_url:he,msg:pe})=>{if(!(he&&pe))throw new Error("Invalid transaction data");return S.fromAmino({type:Ht.aminoConverters[he].aminoType,value:JSON.parse(pe)})});if(w==="initia"){const{srcDenom:he,quantity:pe}=l,{decimals:Ct}=T(he),it=await p({messages:C,chainId:d,internal:1,spendCoins:[{denom:he,amount:v.toBaseUnit(pe,{decimals:Ct})}]}),Mt=g({txHash:it,chainId:d});return{txHash:it,wait:Mt}}const x=y(h)?.getProvider();if(!x)throw new Error("Wallet not connected");const A=x.getOfflineSignerOnlyAmino(d),q=await Pe.SigningStargateClient.connectWithSigner(k.rpc,A,{registry:I,aminoTypes:S}),M=await q.getAllBalances(u),E=k.fee_assets.find(he=>M.some(pe=>pe.denom===he.denom&&F(pe.amount).gt(0)));if(!E){const pe=["Insufficient balance for fees.",`Available fee assets: ${k.fee_assets.map(Ct=>T(Ct.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(pe)}const{denom:H,gas_price:ee}=E;if(!ee)throw new Error(`Gas price not found for ${H}`);const O=await q.simulate(u,C,""),Z=Pe.GasPrice.fromString(ee.average+H),Ue=Pe.calculateFee(Math.ceil(O*Vt),Z),Je=await q.signAndBroadcastSync(u,C,Ue),at=br({txHash:Je,client:q});return{txHash:Je,wait:at}}if("evm_tx"in e){const{chain_id:C,to:x,value:A,data:q}=e.evm_tx,M=await f(),E=await M.getSigner();await kn(M,k);const H=await E.sendTransaction({chainId:C,to:x,value:A,data:`0x${q}`});return{txHash:H.hash,wait:H.wait()}}throw new Error("Unlisted chain type")}catch(C){throw await He(C)}},onSuccess:async({txHash:C,wait:x})=>{localStorage.removeItem(U.BRIDGE_QUANTITY),s(-1),n({type:"loading",title:"Transaction is pending..."});try{await x;const A=Gn(c)==="OP Bridge withdrawal",q=A?{success:!0,error:null}:await Km(j,C,d);if(!q.success&&q.error){const O=q.error instanceof Error?q.error.message:String(q.error);n({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${O}. The transaction may still be processing.`,autoHide:!0})}const M=q.success,H=Lm({txHash:C,srcChainId:d,route:c,values:l,recipient:m},M);a(H.tx,H.details),o(Um(r));const ee=hn(l,C);if(i("Bridge Transaction Success",ee),A){const O=zm(H.tx,c,m);K(H.tx,O)}}catch(A){const q=A instanceof Error?A.message:String(A);o({type:"error",title:"Transaction not confirmed",description:q});const M={...hn(l,C),error:q};i("Bridge Confirmation Failed",M)}finally{P.invalidateQueries({queryKey:Re.balances(d,u).queryKey})}},onError:async C=>{const x=w==="initia"?await kt(C,B(d),R):C;n({type:"error",title:"Transaction failed",description:x.message});const A=hn(l);i("Bridge Transaction Failed",{...A,error:x.message})}})}function Om(){const e=Ye(),s=ne(),n=Ds(),{route:o,values:r}=Bt(),a=vt();return $.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:c}=await e.post("op-hook",{json:{source_address:s,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:v.InitiaAddress(r.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await Mm(s,a(o.dest_asset_chain_id).rest);const l=c.map(({msg_type_url:m,msg:h})=>Ht.aminoTypes.fromAmino({type:Ht.aminoConverters[m].aminoType,value:JSON.parse(h)})),d=await n(i,s,l,{amount:[],gas:"1"},"",{incrementSequence:i===r.srcChainId?2:0}),u=st.Tx.fromPartial({body:st.TxBody.decode(d.bodyBytes),authInfo:st.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:s,hook:V.toBase64(st.Tx.encode(u).finish())}}catch(i){throw await He(i)}}})}function Um(e){return{type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(Et,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function hn(e,s){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:s}}function Lm(e,s){const{txHash:n,srcChainId:o,route:r,values:a}=e,i={chainId:o,txHash:n},c=Gn(r)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:r,values:a,state:c?"success":void 0,tracked:s},isOpWithdraw:c}}function zm(e,s,n){return{...e,recipient:v.InitiaAddress(n).bech32,claimableAt:Date.now()+s.estimated_route_duration_seconds*1e3,amount:s.amount_out,denom:s.dest_asset_denom}}async function Km(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 He(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Wm(e){const{chainId:s,txHash:n,tracked:o}=e,r=Ye();return $.useQuery({queryKey:Re.txTrack(s,n).queryKey,queryFn:async()=>{try{return await r.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json()}catch(a){throw await He(a)}},select:({tx_hash:a})=>a,retry:6,retryDelay:5e3,staleTime:W.INFINITY,enabled:!o})}function Hm(e){const{timestamp:s,chainId:n,txHash:o,tracked:r,state:a}=e,i=Ye();return $.useQuery({queryKey:Re.txStatus(n,o).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:o,chain_id:n}}).json(),enabled:!!o&&r&&!a,refetchInterval:({state:{data:c}})=>{if(!c)return!1;const{status:l}=c;if(l==="STATE_COMPLETED")return!1;const d=s+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),m=Math.floor((d-u)/1e3);return m<=0?1e3:m<=300?5e3:60*1e3},staleTime:W.INFINITY})}var xs=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(xs||{});function Gn(e){const{operations:s,dest_asset_denom:n}=e;return b.has("op_init_transfer",b.head(s))&&n==="uinit"?"OP Bridge withdrawal":"Skip"}const Qm="_success_t4dfk_1",Vm="_error_t4dfk_5",So={success:Qm,error:Vm},Gm=({tx:e})=>{const[s,n]=na(e);if(!s)throw new Error("Bridge history details not found");const{data:o}=Hm(s),r=s.state??Ym(o);switch(_.useEffect(()=>{r!=="loading"&&n(a=>{if(!a)throw new Error("Bridge history details not found");return{...a,tracked:!0,state:r}})},[n,r]),r){case"error":return t.jsx("div",{className:So.error,children:t.jsx(N.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:So.success,children:t.jsx(N.IconCheckCircleFilled,{size:14})});default:return t.jsx(wt,{size:14})}};function Ym(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 Jm="_link_12p3n_1",Zm="_header_12p3n_22",Xm="_title_12p3n_30",eh="_date_12p3n_36",th="_explorer_12p3n_40",sh="_fees_12p3n_55",nh="_label_12p3n_63",oh="_content_12p3n_67",rh="_route_12p3n_73",ah="_row_12p3n_78",ih="_asset_12p3n_84",ch="_amount_12p3n_92",lh="_chain_12p3n_97",dh="_account_12p3n_106",uh="_arrow_12p3n_113",ce={link:Jm,header:Zm,title:Xm,date:eh,explorer:th,fees:sh,label:nh,content:oh,route:rh,row:ah,asset:ih,amount:ch,chain:lh,account:dh,arrow:uh},mh=({tx:e})=>{const[s,n]=na(e);if(!s)throw new Error("Bridge history details not found");const{chainId:o,txHash:r,route:a,values:i,timestamp:c,tracked:l}=s,{data:d}=Wm(s),{address:u="",connector:m}=de.useAccount(),{find:h}=Ks();_.useEffect(()=>{d&&n(M=>{if(!M)throw new Error("Bridge history details not found");return{...M,tracked:!0}})},[n,d]);const{amount_in:f,amount_out:p,source_asset_chain_id:g,source_asset_denom:y,dest_asset_chain_id:I,dest_asset_denom:S,estimated_fees:k=[]}=a,w=Be(g),T=Be(I),P=Qe(y,g),R=Qe(S,I),B=(M,E)=>E?t.jsx(Y,{src:E,width:12,height:12}):v.InitiaAddress.equals(M,u)?t.jsx(Y,{src:m?.icon,width:12,height:12}):t.jsx(N.IconWallet,{size:12}),K=(M,{symbol:E,decimals:H,logo_uri:ee},{chain_name:O,pretty_name:Z,...Ue},Je,at)=>t.jsxs("div",{className:ce.row,children:[t.jsx(Ws,{assetLogoUrl:ee,chainLogoUrl:Ue.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:ce.asset,children:[t.jsx("span",{className:ce.amount,children:v.formatAmount(M,{decimals:H})}),t.jsx("span",{children:E})]}),t.jsxs("div",{className:ce.chain,children:[t.jsxs("span",{children:["on ",Z||O]}),t.jsxs("div",{className:ce.account,children:[at,t.jsx("span",{className:"monospace",children:v.truncate(Je)})]})]})]})]}),j=Gn(a),C=_.useMemo(()=>{switch(j){case xs.SKIP:return"Skip Explorer";case xs.OP_WITHDRAW:return"Initia Scan"}},[j]),x=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:ce.header,children:[t.jsxs("div",{className:ce.title,children:[l?t.jsx(Gm,{tx:e}):t.jsx(wt,{size:14}),t.jsx("div",{className:ce.date,children:ke.format(new Date(c),"h:mm a")})]}),t.jsxs("div",{className:ce.explorer,children:[t.jsx("span",{children:C}),t.jsx(N.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:ce.route,children:[K(f,P,w,i.sender,B(i.sender,h(i.cosmosWalletName)?.image)),t.jsx("div",{className:ce.arrow,children:t.jsx(N.IconArrowDown,{size:12})}),K(p,R,T,i.recipient,B(i.recipient))]}),k.length>0&&t.jsxs("div",{className:ce.fees,children:[t.jsx("span",{className:ce.label,children:"Fees"}),t.jsx("span",{className:ce.content,children:Jr(k)})]})]});if(j===xs.OP_WITHDRAW)return t.jsx(zs,{chainId:o,txHash:r,className:ce.link,children:x});const A=new URLSearchParams({tx_hash:r,chain_id:o}),q=new URL(`?${A.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:q.toString(),className:ce.link,target:"_blank",children:x})},hh="_history_13u9z_1",fh="_header_13u9z_5",_h="_checkbox_13u9z_9",ph="_groups_13u9z_13",gh="_dateGroup_13u9z_21",xh="_dateHeader_13u9z_26",yh="_list_13u9z_32",mt={history:hh,header:fh,checkbox:_h,groups:ph,dateGroup:gh,dateHeader:xh,list:yh},jh=()=>{const{initiaAddress:e,hexAddress:s}=xe(),{history:n,getHistoryDetails:o}=sa(),r=n.filter(f=>o(f)),a=r.filter(f=>{const p=o(f);if(!p)return!1;const{values:g}=p,{sender:y,recipient:I}=g;return[y,I].some(S=>[e,s].includes(S))}),[i,c]=_.useState(1),[l,d]=Ie.useToggle(!a.length),u=l?r:a,m=u.slice(0,i*No),h=_.useMemo(()=>ta(m,f=>{const p=o(f);if(p)return new Date(p.timestamp)}),[m,o]);return t.jsx(Oe,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:mt.history,children:[r.length>0&&r.length!==a.length&&t.jsx("header",{className:mt.header,children:t.jsx(Pm,{checked:l,onClick:d,label:"Show all transactions stored in this browser",className:mt.checkbox})}),u.length===0?t.jsx(se,{children:"No bridge/swap activity"}):t.jsx("div",{className:mt.groups,children:Object.entries(h).map(([f,p])=>t.jsxs("div",{className:mt.dateGroup,children:[t.jsx("div",{className:mt.dateHeader,children:f}),t.jsx("div",{className:mt.list,children:p.map(g=>t.jsx(ye,{children:t.jsx(mh,{tx:g})},g.txHash))})]},f))}),u.length>i*No?t.jsx(ea,{onClick:()=>c(f=>f+1)}):n.length>=bs&&t.jsxs(se,{children:["Only the latest ",bs," items are stored. Older entries will be removed automatically."]})]})})},vh=({tx:e})=>{const{mutate:s,isPending:n}=Fm(e);return t.jsx(ie,{children:t.jsx(J.White,{onClick:()=>s(),loading:n&&"Signing transaction...",children:"Confirm"})})},wh="_content_c0tee_1",bh="_info_c0tee_6",Ch="_arrow_c0tee_11",Ih="_divider_c0tee_19",Nh="_type_c0tee_26",Sh="_asset_c0tee_44",kh="_amount_c0tee_52",Ah="_lower_c0tee_57",$h="_chain_c0tee_63",Th="_address_c0tee_69",ve={content:wh,info:bh,arrow:Ch,divider:Ih,type:Nh,asset:Sh,amount:kh,lower:Ah,chain:$h,address:Th},oa=e=>{const{source:s,label:n,amount:o,denom:r,chainId:a,address:i,walletIcon:c}=e,{symbol:l=v.truncate(r),decimals:d=0,logo_uri:u=Rn}=e,{chain_name:m,pretty_name:h,...f}=Be(a);return t.jsxs("div",{children:[!s&&t.jsxs("div",{className:ve.arrow,children:[t.jsx("div",{className:ve.divider}),n?t.jsx(ns,{label:n,children:t.jsx("button",{className:ve.type,children:t.jsx(N.IconArrowDown,{size:12})})}):t.jsx("span",{className:ve.type,children:t.jsx(N.IconArrowDown,{size:12})}),t.jsx("div",{className:ve.divider})]}),t.jsxs("div",{className:ve.content,children:[t.jsx(Ws,{assetLogoUrl:u,chainLogoUrl:f.logo_uri??void 0}),t.jsxs("div",{className:ve.info,children:[t.jsxs("div",{className:ve.asset,children:[t.jsx("span",{className:ve.amount,children:v.formatAmount(o,{decimals:d})}),t.jsx("span",{children:l})]}),t.jsxs("div",{className:ve.lower,children:[t.jsxs("div",{className:ve.chain,children:["on ",h||m]}),i&&t.jsx(js,{value:i,children:({copy:p,copied:g})=>t.jsxs("button",{className:ve.address,onClick:p,children:[c,g?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:v.truncate(i)})]})})]})]})]})]})},Tt=e=>{const s=Qe(e.denom,e.chainId);return t.jsx(oa,{...e,...s})};Tt.Placeholder=oa;const Eh="_root_1l4he_1",qh="_flexEnd_1l4he_6",Dh="_toggle_1l4he_11",Ph="_route_1l4he_34",Rh="_content_1l4he_41",zt={root:Eh,flexEnd:qh,toggle:Dh,route:Ph,content:Rh};function Bh(e){const s=({name:n})=>n==="initia-dex"?"Initia DEX":Is.capitalCase(b.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 Mh=({addressList:e})=>{const{values:s,route:n}=Bt(),{source_asset_denom:o,source_asset_chain_id:r,amount_in:a,operations:i}=n,c=b.zipObj(n.required_chain_addresses,e),{find:l}=Ks(),{connector:d,address:u=""}=de.useAccount(),[m,h]=Ie.useToggle(!1),f=i.length>1,p=t.jsx(Y,{src:s.cosmosWalletName?l(s.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:a,denom:o,chainId:r,address:s.sender,walletIcon:p},y=T=>v.InitiaAddress.equals(T,u)?p:t.jsx(N.IconWallet,{size:11}),I=T=>{const{label:P,amount_out:R,denom:B,denom_out:K=B,chain_id:j,from_chain_id:C,to_chain_id:x=j??C}=T,A=c[x];return{label:f&&!m?void 0:P,amount:R,denom:K,chainId:x,address:A,walletIcon:y(A)}},S=i.map(Bh).map(I),k=S.slice(0,-1),w=S[S.length-1];return t.jsxs(te.Collapsible.Root,{className:zt.root,open:m,onOpenChange:h,children:[f&&t.jsx("div",{className:zt.flexEnd,children:t.jsx(te.Collapsible.Trigger,{className:zt.toggle,children:m?t.jsxs(t.Fragment,{children:[t.jsx(N.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(N.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:zt.route,children:[t.jsx(Tt,{...g,source:!0}),t.jsx(te.Collapsible.Content,{className:zt.content,children:k.map((T,P)=>t.jsx(ye,{suspenseFallback:t.jsx(Tt.Placeholder,{...T}),errorBoundaryProps:{fallback:t.jsx(Tt.Placeholder,{...T})},children:t.jsx(Tt,{...T})},P))}),t.jsx(Tt,{...w})]})]})},An=({error:e})=>{const s=me();return t.jsx(ie,{extra:t.jsx(ae,{level:"error",children:e.message}),children:t.jsx(J.White,{onClick:()=>s("/bridge"),children:"Home"})})},Fh=({children:e})=>{const s=Bt(),{route:n,values:o}=s,{required_chain_addresses:r}=n,{srcChainId:a,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:d,hexAddress:u}=xe(),m=es(),h=vt(),f=ts(),p=h(a),g=f(p),y=r.slice(0,-1).some(R=>{const B=h(R);return f(B)==="cosmos"})&&g!=="cosmos",[I,S]=_.useState(void 0),[k,w]=_.useState(!1),[T,P]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!y)return;if(!m)throw new Error("Wallet not connected");w(!0),P(null);const[{pubkey:B}]=await m.getAccounts();S(B)}catch(B){P(await He(B))}finally{w(!1)}})()},[y,m]),T)return t.jsx(An,{error:T});if(k)return t.jsx(ie,{children:t.jsx(J.White,{loading:k&&"Generating intermediary addresses..."})});if(!y||I){const R=r.map((B,K)=>{if(K===r.length-1){const q=h(i);return f(q)==="initia"?v.InitiaAddress(l).bech32:l}const j=h(B),C=f(j),x=h(a),A=f(x);switch(C){case"initia":return d;case"evm":return u;case"cosmos":{if(A==="cosmos")return V.toBech32(j.bech32_prefix,V.fromBech32(c).data);if(!I)throw new Error("Pubkey not found");return Qt.pubkeyToAddress(Qt.encodeSecp256k1Pubkey(I),j.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(R)}return null},Oh=({tx:e,children:s})=>{const n=fr(),o=vt(),{data:r,isLoading:a}=$.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:m}=e.evm_tx,h=await n();await kn(h,o(u));const f=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async g=>{const{token_contract:y,spender:I}=g,k=await new We.ethers.Contract(y,f,h).allowance(m,I);return{approval:g,currentAllowance:BigInt(k.toString())}}))).filter(({approval:g,currentAllowance:y})=>y<BigInt(g.amount)).map(({approval:g})=>g)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:c,isPending:l,error:d}=$.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!r||r.length===0)throw new Error("No approvals needed");const{chain_id:u}=e.evm_tx,m=await n(),h=await m.getSigner();await kn(m,o(u));for(const f of r){const{token_contract:p,spender:g,amount:y}=f,I=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new We.ethers.Contract(p,I,h).approve(g,y)).wait()}return!0}catch(u){throw await He(u)}}});return a?t.jsx(ie,{children:t.jsx(J.White,{loading:"Checking approvals..."})}):r&&r.length>0&&!c?t.jsx(ie,{extra:t.jsx(ae,{level:"error",children:d?.message}),children:t.jsx(J.White,{onClick:()=>i(),loading:l&&"Approving tokens...",children:"Approve tokens"})}):s},Uh=({addressList:e,signedOpHook:s,children:n})=>{const o=Ye(),{route:r,values:a}=Bt(),[i,c]=_.useState(void 0),[l,d]=_.useState(!1),[u,m]=_.useState(null);return _.useEffect(()=>{(async()=>{try{if(r.required_op_hook&&!s)throw new Error("Op hook is required");d(!0),m(null);const f={address_list:e,amount_in:r.amount_in,amount_out:r.amount_out,source_asset_chain_id:r.source_asset_chain_id,source_asset_denom:r.source_asset_denom,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom,slippage_tolerance_percent:a.slippagePercent,operations:r.operations,signed_op_hook:s},{txs:p}=await o.post("v2/fungible/msgs",{json:f}).json();if(!p||p.length===0)throw new Error("No transaction data found");const[g]=p;c(g)}catch(f){m(f)}finally{d(!1)}})()},[r,a,e,s,o]),u?t.jsx(An,{error:u}):l?t.jsx(ie,{children:t.jsx(J.White,{loading:l&&"Fetching messages..."})}):i?n(i):t.jsx(An,{error:new Error("Failed to fetch messages")})},Lh=({children:e})=>{const{route:s}=Bt(),n=Om();return s.required_op_hook&&!n.data?t.jsx(ie,{extra:t.jsx(ae,{level:"error",children:n.error?.message}),children:t.jsx(J.White,{onClick:()=>n.mutate(),loading:n.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(n.data)},zh=()=>t.jsx(Oe,{title:"Route preview",children:t.jsx(Fh,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(Mh,{addressList:e}),t.jsx(Lh,{children:s=>t.jsx(Uh,{addressList:e,signedOpHook:s,children:n=>t.jsx(Oh,{tx:n,children:t.jsx(vh,{tx:n})})})})]})})}),ra=_.createContext(null);function Qs(){return _.useContext(ra)}const bt=$e.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 Vs(){const{restUrl:e}=_e();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function Kh(e){const s=Vs(),{data:n}=$.useSuspenseQuery({queryKey:bt.bridge(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:W.INFINITY});return n}const ko=20;function Wh(e){const s=ne();return $.useSuspenseInfiniteQuery({queryKey:bt.withdrawals(e,s).queryKey,queryFn:async({pageParam:n})=>{if(!s)return[];const o={limit:ko,offset:n,order:"desc"},{withdrawals:r}=await z.create({prefixUrl:e}).get(`withdrawals/${s}`,{searchParams:o}).json();return r},getNextPageParam:n=>{const o=b.last(n)?.sequence;return n.length<ko||!o||o<=1?null:o-1},initialPageParam:0,staleTime:W.SECOND})}function Hh(e){const s=Vs(),{data:n}=$.useSuspenseQuery({queryKey:bt.latestOutput(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:o})=>{const[r]=o;return r||null},staleTime:W.SECOND});return n}function Qh({bridge_id:e,output_index:s}){const n=Vs(),{data:o}=$.useSuspenseQuery({queryKey:bt.output(e,s).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${e}/outputs/${s}`).json()}catch{return null}},staleTime:W.SECOND});return o}function Vh({bridge_id:e,sequence:s}){const o=re().find(({metadata:l})=>l?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const a=Te()(o);if(!a)throw new Error(`Chain not found: ${o}`);const i=a.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${o}`);const{data:c}=$.useSuspenseQuery({queryKey:bt.outputResponse(i,s).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${s}`).json(),staleTime:W.SECOND});return c}function aa(e,s){const{bridge_id:n}=e,o=Vs(),{data:r}=$.useSuspenseQuery({queryKey:bt.withdrawalClaimed(n,s).queryKey,queryFn:()=>o.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:W.SECOND});return r}function Kt(e){return Sa.sha3_256.create().update(e).digest()}function fn(e,s){const n=new ArrayBuffer(s);return new DataView(n).setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}function ia(e){const{bridge_id:s,sequence:n,amount:o,from:r,to:a}=e,i=fn(s.toString(),8),c=fn(n.toString(),8),l=fn(o.amount,8),d=_t.concatBytes(i,c,Kt(_t.utf8ToBytes(r)),Kt(_t.utf8ToBytes(a)),Kt(_t.utf8ToBytes(o.denom)),l);return Kt(Kt(d))}const Gh="_button_1btdg_1",Yh="_claimed_1btdg_23",Ao={button:Gh,claimed:Yh},Jh=()=>{const{withdrawalTx:e}=Qs(),{bridge_id:s,sequence:n,amount:o,output_index:r,withdrawal_proofs:a,storage_root:i,from:c,to:l,version:d}=e,u=_e(),m=ne(),{requestTxSync:h,waitForTxConfirmation:f}=xe(),p=Vh(e),g=V.toBase64(ia(e)),y=aa(e,g),I=$.useQueryClient(),{mutate:S,isPending:k}=$.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:w}=p;return h({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:m,bridgeId:BigInt(s),outputIndex:BigInt(r),withdrawalProofs:a.map(V.fromBase64),from:c,to:l,sequence:BigInt(n),amount:o,version:V.fromBase64(d),storageRoot:V.fromBase64(i),lastBlockHash:V.fromBase64(w)}}],internal:!0})},onSuccess:async w=>{await f({chainId:u.chain_id,txHash:w}),I.invalidateQueries({queryKey:bt.withdrawalClaimed(s,g).queryKey})}});return y?t.jsxs("div",{className:Ao.claimed,children:[t.jsx(N.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:Ao.button,onClick:()=>S(),disabled:k,children:"Claim"})},Zh=({children:e})=>{const{withdrawalTx:s}=Qs(),n=Kh(s.bridge_id),o=Qh(s),r=_.useMemo(()=>{if(!o)return null;const{bridge_config:a}=n,{output_proposal:i}=o;return ke.addSeconds(new Date(i.l1_block_time),parseFloat(a.finalization_period))},[n,o]);return e(r)},ca=1e3,Xh=60,ef=60,tf=24,$n=ca*Xh,Tn=$n*ef,$o=Tn*tf,sf=({date:e})=>{const s=_.useCallback(()=>{const d=new Date().getTime(),m=e.getTime()-d;if(m<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(m/$o),f=Math.floor(m%$o/Tn),p=Math.floor(m%Tn/$n),g=Math.floor(m%$n/ca);return{days:h,hours:f,minutes:p,seconds:g}},[e]),[n,o]=_.useState(s());_.useEffect(()=>{const d=window.setInterval(()=>{o(s())},1e3);return()=>window.clearInterval(d)},[s,e]);const r=d=>d.toString().padStart(2,"0"),{days:a,hours:i,minutes:c,seconds:l}=n;return t.jsx(ns,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[a,"d ",r(i),"h ",r(c),"m ",r(l),"s"]})})},nf="_container_1lz3w_1",of="_title_1lz3w_5",To={container:nf,title:of},rf=({date:e})=>t.jsxs("div",{className:To.container,children:[t.jsx("div",{className:To.title,children:"Claimable in"}),t.jsx(sf,{date:e})]}),af="_container_1oldz_1",cf="_icon_1oldz_7",Eo={container:af,icon:cf},lf="Withdrawal will begin within an hour",qo=()=>{const e=Ls();return t.jsxs("div",{className:Eo.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(ns,{label:lf,children:t.jsx("span",{className:Eo.icon,children:t.jsx(N.IconInfoFilled,{size:12})})})]})},df=({children:e})=>{const{withdrawalTx:s}=Qs(),n=Hh(s.bridge_id),o=s.output_index>Number(n?.output_index);return e(o)},uf=({date:e,children:s})=>{const{chainId:n,withdrawalTx:o}=Qs(),r=V.toBase64(ia(o)),a=aa(o,r),{setReminder:i,removeReminder:c}=Rt();return _.useEffect(()=>{const l={chainId:n,txHash:o.tx_hash};a?c(l):i(l,{...l,recipient:o.to,claimableAt:e.getTime(),amount:o.amount.amount,denom:o.amount.denom,dismissed:ke.isPast(e.getTime())?!0:void 0})},[n,a,e,c,i,o]),s},mf=()=>t.jsx(df,{children:e=>e?t.jsx(qo,{}):t.jsx(Zh,{children:s=>s?t.jsx(uf,{date:s,children:ke.isFuture(s)?t.jsx(rf,{date:s}):t.jsx(Jh,{})}):t.jsx(qo,{})})}),hf="_asset_6h8u2_1",ff="_info_6h8u2_7",_f="_symbol_6h8u2_11",_n={asset:hf,info:ff,symbol:_f},pf=({amount:e,denom:s})=>{const n=_e(),o=Xo(s,n),{symbol:r,logoUrl:a,decimals:i}=o;return t.jsxs("div",{className:_n.asset,children:[t.jsx(Y,{src:a,width:32,height:32,logo:!0}),t.jsxs("div",{className:_n.info,children:[t.jsx("span",{className:"monospace",children:v.formatAmount(e,{decimals:i})}),t.jsx("span",{className:_n.symbol,children:r})]})]})},gf="_item_km5w2_1",xf={item:gf},yf=({chain:e})=>{const s=e.metadata?.executor_uri;if(!s)throw new Error("Executor URL is not defined");const{data:n,fetchNextPage:o,hasNextPage:r,isFetching:a}=Wh(s),i=_.useMemo(()=>n?.pages.flat()??[],[n]),{syncReminders:c}=Rt();return _.useEffect(()=>{const l=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));c(l)},[e.chainId,i,c]),i.length?t.jsxs(t.Fragment,{children:[i.map(l=>{const{amount:d}=l;return t.jsxs("div",{className:xf.item,children:[t.jsx(pf,{...d}),t.jsx(ye,{suspenseFallback:null,children:t.jsx(ra.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:t.jsx(mf,{})})})]},l.sequence)}),r&&t.jsx(ea,{onClick:()=>o(),disabled:a})]}):t.jsx(se,{children:"No withdrawals"})},jf="_content_dj1qm_1",vf="_title_dj1qm_5",Do={content:jf,title:vf},wf=()=>{const{chainId:e}=jt(),s=re(),n=Zt(),[o,r]=_.useState(e??(n.metadata?.is_l1?"":n.chainId)),a=Te(),{reminders:i}=Rt(),c=o?a(o):void 0;return t.jsxs(Oe,{title:"OP Bridge withdrawals",children:[t.jsx(xt,{chains:s.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:o,onSelect:r,getShowIndicator:l=>i.some(d=>d.chainId===l)}),t.jsx("div",{className:Do.content,children:c?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:Do.title,children:c.name}),t.jsx(ye,{children:t.jsx(yf,{chain:c})},o)]}):t.jsx(ae,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},bf="_page_1f6wh_1",Cf="_title_1f6wh_10",If="_scrollable_1f6wh_17",Nf="_list_1f6wh_22",Sf="_item_1f6wh_32",kf="_name_1f6wh_56",Af="_dimmed_1f6wh_64",$f="_recent_1f6wh_68",Tf="_installed_1f6wh_69",Ne={page:bf,title:Cf,scrollable:If,list:Nf,item:Sf,name:kf,dimmed:Af,recent:$f,installed:Tf},Ef=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],Po=({onSuccess:e})=>{const{connectors:s,connectAsync:n}=de.useConnect(),o=Ie.useReadLocalStorage("wagmi.recentConnectorId"),[r,a]=_.useState(null),{mutate:i,isPending:c}=$.useMutation({mutationFn:async l=>{a(l.id);try{await n({connector:l})}catch(d){throw await He(d)}},onSettled:()=>{a(null)},onSuccess:()=>{e?.()}});return t.jsxs("div",{className:Ne.page,children:[t.jsx("h1",{className:Ne.title,children:"Connect wallet"}),t.jsx(Fe,{className:Ne.scrollable,children:t.jsxs("div",{className:Ne.list,children:[s.toSorted(b.descend(l=>l.id===o)).map(l=>{const{name:d,icon:u,id:m}=l;return t.jsxs("button",{className:Ne.item,onClick:()=>i(l),disabled:c,children:[t.jsx(Y,{src:u,width:24,height:24}),t.jsx("span",{className:Ne.name,children:d}),r===m?t.jsx(wt,{size:16}):o===m?t.jsx("span",{className:Ne.recent,children:"Recent"}):l.id===Ns.id?null:t.jsx("span",{className:Ne.installed,children:"Installed"})]},m)}),Ef.filter(({name:l})=>!s.some(d=>d.name.includes(l))).map(({name:l,url:d})=>{const u=`https://assets.initia.xyz/images/wallets/${l}.webp`;return t.jsxs("a",{href:d,className:Ne.item,target:"_blank",children:[t.jsx(Y,{src:u,width:24,height:24}),t.jsx("span",{className:D(Ne.name,Ne.dimmed),children:l}),t.jsx(N.IconExternalLink,{size:10})]},l)})]})})]})},qf="_root_19tvg_1",Df="_address_19tvg_9",Pf="_copy_19tvg_19",Rf="_labelWrapper_19tvg_33",Bf="_labelCopy_19tvg_43",Mf="_labelCopied_19tvg_47",Ff="_copied_19tvg_55",Of="_derived_19tvg_65",Uf="_derivedLabel_19tvg_78",Lf="_derivedAddress_19tvg_82",zf="_hexAddress_19tvg_88",Kf="_derivedCopy_19tvg_93",fe={root:qf,address:Df,copy:Pf,labelWrapper:Rf,labelCopy:Bf,labelCopied:Mf,copied:Ff,derived:Of,derivedLabel:Uf,derivedAddress:Lf,hexAddress:zf,derivedCopy:Kf},Wf=()=>{const e=_.useRef(null),s=_.useRef(null),{initiaAddress:n,hexAddress:o}=xe(),r=$r("--gray-0");return _.useEffect(()=>{e.current&&(s.current?s.current.update({data:n}):(s.current=new ka({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:r},cornersSquareOptions:{type:"extra-rounded",color:r},cornersDotOptions:{type:"dot",color:r},backgroundOptions:{color:"transparent"}}),s.current.append(e.current)))},[n,r]),t.jsx(Oe,{title:"Receive",children:t.jsxs("div",{className:fe.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:fe.address,children:n}),t.jsx(js,{value:n,children:({copy:a,copied:i})=>t.jsxs("button",{className:D(fe.copy,{[fe.copied]:i}),onClick:a,children:[t.jsx(N.IconCopy,{size:12}),t.jsxs("div",{className:fe.labelWrapper,children:[t.jsx("span",{className:fe.labelCopy,children:"Copy address"}),t.jsx("span",{className:fe.labelCopied,children:"Copied!"})]})]})}),t.jsx(js,{value:o,children:({copy:a,copied:i})=>t.jsxs("button",{className:D(fe.derived,{[fe.copied]:i}),onClick:a,children:[t.jsx("span",{className:fe.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:fe.derivedAddress,children:[t.jsx("span",{className:fe.hexAddress,children:v.truncate(o)}),t.jsx(N.IconCopy,{size:12,className:fe.derivedCopy}),i&&t.jsx("span",{className:fe.copiedText,children:"Copied!"})]})]})})]})})};function Hf(){const e=ne(),s=re();return $.useQueries({queries:s.map(n=>({queryKey:Yt.grants(n.chainId,e).queryKey,queryFn:async()=>{const{grants:o}=await z.create({prefixUrl:n.restUrl}).get(`cosmos/authz/v1beta1/grants/granter/${e}`).json();return{chainId:n.chainId,grants:o}},enabled:!!e,staleTime:W.SECOND,retry:!1}))})}const Qf="_countdown_vfms8_1",Vf={countdown:Qf},Gf=({expiration:e})=>{const s=()=>{const r=new Date,a=ke.differenceInSeconds(e,r),i=Math.floor(a/(1440*60)),c=Math.floor(a%(1440*60)/3600),l=Math.floor(a%3600/60),d=a%60,u=[];return i>0&&u.push(`${i}d`),(c>0||i>0)&&u.push(`${c}h`),(l>0||c>0||i>0)&&u.push(`${l}m`),u.push(`${d}s`),u.join(" ")},[n,o]=_.useState(s());return Ie.useInterval(()=>{o(s())},1e3),ke.isPast(e)?"Expired":t.jsxs(t.Fragment,{children:["Expires in ",t.jsx("span",{className:Vf.countdown,children:n})]})},Yf="_container_ksj5a_1",Jf="_info_ksj5a_11",Zf="_header_ksj5a_17",Xf="_chainName_ksj5a_23",e_="_expiration_ksj5a_29",t_="_revokeButton_ksj5a_35",St={container:Yf,info:Jf,header:Zf,chainName:Xf,expiration:e_,revokeButton:t_},s_=({chainId:e,grantee:s,messageTypes:n,expiration:o})=>{const r=Me(e),{mutate:a,isPending:i}=Cr({grantee:s,messageTypes:{[e]:n},internal:!0});return t.jsxs("div",{className:St.container,children:[t.jsxs("div",{className:St.info,children:[t.jsxs("div",{className:St.header,children:[t.jsx(Y,{src:r.logoUrl,width:16,height:16,logo:!0}),t.jsx("div",{className:St.chainName,children:r.name})]}),t.jsx("div",{className:St.expiration,children:o?t.jsx(Gf,{expiration:o}):"Until revoked"})]}),t.jsx("button",{className:St.revokeButton,onClick:()=>a(e),disabled:i,children:i?"Revoking...":"Revoke"})]})},n_=({chainId:e,grants:s})=>Object.values(s.reduce((o,r)=>{const a=o[r.grantee];return a?{...o,[r.grantee]:{...a,messageTypes:[...a.messageTypes,r.authorization.msg],expiration:Un([a.expiration,r.expiration?new Date(r.expiration):void 0])}}:{...o,[r.grantee]:{grantee:r.grantee,messageTypes:[r.authorization.msg],expiration:r.expiration?new Date(r.expiration):void 0}}},{})).map(o=>_.createElement(s_,{...o,chainId:e,key:o.grantee})),o_="_content_q36qs_1",r_={content:o_},a_=()=>{const e=Hf(),s=()=>{const n=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return n.length===0?t.jsx(se,{children:"No permissions found"}):t.jsx("div",{className:r_.content,children:n.map(({chainId:o,grants:r})=>t.jsx(n_,{chainId:o,grants:r},o))})};return t.jsx(Oe,{title:"Manage auto-signing",backButton:"/settings",children:s()})},i_="2.1.0",c_="_version_1sf5y_1",l_={version:c_},d_=()=>t.jsxs("aside",{className:l_.version,children:["v",i_]}),u_="_link_1vmyo_1",m_="_title_1vmyo_17",h_="_subtitle_1vmyo_23",f_="_icon_1vmyo_30",hs={link:u_,title:m_,subtitle:h_,icon:f_},la=({title:e,subtitle:s,rightSection:n,onClick:o})=>t.jsxs("button",{className:hs.link,onClick:o,children:[t.jsxs("div",{children:[t.jsx("p",{className:hs.title,children:e}),s&&t.jsx("p",{className:hs.subtitle,children:s})]}),t.jsx("div",{className:hs.icon,children:n??t.jsx(N.IconChevronRight,{size:16})})]}),__="https://export.initia.xyz/",p_=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return t.jsx(la,{title:"Export private key",rightSection:t.jsx(N.IconExternalLink,{size:16}),onClick:()=>window.open(__,"_blank",e)})},g_="_container_1rkl8_1",x_="_separator_1rkl8_7",Ro={container:g_,separator:x_},y_=()=>{const e=me(),{connector:s}=de.useAccount();return t.jsx(Oe,{title:"Settings",backButton:"/",children:t.jsxs("div",{className:Ro.container,children:[t.jsx(la,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),s?.id===Pn&&t.jsx(p_,{}),t.jsx(Ke.Separator,{className:Ro.separator}),t.jsx(d_,{})]})})},j_="_trigger_kivvl_1",v_="_icon_kivvl_21",w_="_full_kivvl_25",b_="_triggerContent_kivvl_30",C_="_triggerText_kivvl_38",I_="_popoverBackdrop_kivvl_49",N_="_popoverPositioner_kivvl_68",S_="_popoverPopup_kivvl_72",k_="_search_kivvl_96",A_="_viewport_kivvl_101",$_="_item_kivvl_106",T_="_highlighted_kivvl_120",E_="_active_kivvl_124",q_="_name_kivvl_129",D_="_extra_kivvl_133",le={trigger:j_,icon:v_,full:w_,triggerContent:b_,triggerText:C_,popoverBackdrop:I_,popoverPositioner:N_,popoverPopup:S_,search:k_,viewport:A_,item:$_,highlighted:T_,active:E_,name:q_,extra:D_},Yn=({value:e,onChange:s,chainIds:n,renderExtra:o,fullWidth:r})=>{const[a,i]=_.useState(""),[c,l]=_.useState(!1),[d,u]=_.useState(0),[m,h]=_.useState(),f=_.useRef([]),p=_.useRef(null),g=re(),y=n.map(j=>g.find(C=>C.chainId===j)).filter(Boolean),I=j=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:j,height:j,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"})]}),S=_.useMemo(()=>({chainId:"",name:"All",logoUrl:I}),[]),k=_.useMemo(()=>{const j=[S,...y];if(!a)return j;const C=a.toLowerCase();return j.filter(x=>x.name.toLowerCase().includes(C)||x.chainId.toLowerCase().includes(C))},[y,a,S]),w=y.find(j=>j.chainId===e)||S,T=parseInt($r("--drawer-offset")),P=6,R=()=>{if(i(""),u(-1),p.current){const C=p.current.getBoundingClientRect().bottom+P,x=window.innerHeight-C-2*T;h(x)}l(!0)};_.useEffect(()=>{d>=0&&d<f.current.length&&f.current[d]?.scrollIntoView({block:"nearest",behavior:"auto"})},[d]);const B=_.useCallback(j=>{switch(j.key){case"ArrowDown":j.preventDefault(),u(C=>(C+1)%k.length);break;case"ArrowUp":j.preventDefault(),u(C=>(C-1+k.length)%k.length);break;case"Enter":j.preventDefault(),k[d]&&(s(k[d].chainId),l(!1));break;case"Escape":j.preventDefault(),l(!1);break}},[k,d,s,l]),K=j=>{s(j),l(!1)};return t.jsxs(It.Popover.Root,{open:c,onOpenChange:R,modal:"trap-focus",children:[t.jsx(It.Popover.Trigger,{render:t.jsxs("button",{className:D(le.trigger,{[le.full]:r}),"aria-expanded":c,role:"listbox",ref:p,children:[t.jsxs("div",{className:le.triggerContent,children:[typeof w.logoUrl=="string"?t.jsx(Y,{src:w.logoUrl,width:14,height:14,logo:!0}):w.logoUrl(14),t.jsx("span",{className:le.triggerText,children:w.name})]}),t.jsx(N.IconChevronDown,{size:16,className:le.icon})]})}),t.jsxs(It.Popover.Portal,{container:yt(),children:[t.jsx(It.Popover.Backdrop,{className:le.popoverBackdrop,onClick:()=>l(!1)}),t.jsx(It.Popover.Positioner,{className:le.popoverPositioner,align:"end",side:"bottom",sideOffset:P,collisionAvoidance:{side:"none"},children:t.jsxs(It.Popover.Popup,{className:D(le.popoverPopup,{[le.full]:r}),style:{maxHeight:m},children:[t.jsx(Hs,{value:a,onChange:j=>{i(j.target.value),u(0)},onClear:()=>i(""),onKeyDown:B,placeholder:"Search appchains",rootClassName:le.search,ref:ss()}),t.jsx("div",{className:le.viewport,role:"listbox",children:k.length===0?t.jsx(se,{children:"No appchains found"}):k.map(({chainId:j,name:C,logoUrl:x},A)=>t.jsxs("div",{className:D(le.item,{[le.highlighted]:A===d,[le.active]:e===j}),onClick:()=>K(j),onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),K(j))},onMouseEnter:()=>u(A),role:"option","aria-selected":e===j,tabIndex:-1,ref:q=>{q&&(f.current[A]=q)},children:[typeof x=="string"?t.jsx(Y,{src:x,width:16,height:16,logo:!0}):x(16),t.jsx("span",{className:le.name,children:C}),o&&t.jsx("span",{className:le.extra,children:o(j)})]},j))})]})})]})]})},P_="_container_t1267_1",R_="_controls_t1267_7",B_="_search_t1267_13",Jn={container:P_,controls:R_,search:B_},M_=({children:e})=>t.jsx("div",{className:Jn.container,children:e}),F_=({children:e})=>t.jsx("div",{className:Jn.controls,children:e}),O_=e=>t.jsx(Hs,{...e,rootClassName:Jn.search}),nt={Root:M_,Controls:F_,SearchInput:O_},U_=G.atom(""),L_=G.atom(""),z_=G.atom(""),K_=G.atom(""),W_=G.atom(""),H_="_change_1x9v4_1",Q_="_positive_1x9v4_10",V_="_negative_1x9v4_14",pn={change:H_,positive:Q_,negative:V_},da=({amount:e,asset:s})=>{const{denom:n,symbol:o,decimals:r}=s,a=new F(e).isPositive(),i=new F(e).abs().toString();return t.jsxs("div",{className:D(pn.change,a?pn.positive:pn.negative),children:[a?"+":"-",v.formatAmount(i,{decimals:r})," ",o||n]})},G_=({changes:e,chain:s})=>{const n=Ve(s);return e.map(({amount:o,denom:r},a)=>t.jsx(da,{amount:o,asset:n(r)},a))},Y_=({changes:e,chain:s})=>{const n=Ve(s);return e.map(({amount:o,metadata:r},a)=>t.jsx(Or,{metadata:r,chain:s,children:i=>t.jsx(da,{amount:o,asset:n(i)})},a))},J_=({events:e,chain:s})=>{const{initiaAddress:n,hexAddress:o}=xe();return s.metadata?.is_l1||s.metadata?.minitia?.type==="minimove"?t.jsx(Y_,{changes:Fr(e,o),chain:s}):t.jsx(G_,{changes:Mr(e,n),chain:s})},Z_="_message_1g2hc_1",X_="_more_1g2hc_8",Bo={message:Z_,more:X_},ep=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((s,n)=>t.jsx("p",{className:Bo.message,children:Is.sentenceCase(s["@type"].split("Msg")[1])},n)),e.length>3&&t.jsx("footer",{className:Bo.more,children:`+${e.length-3} more`})]}),tp="_link_oq58b_1",sp="_inner_oq58b_15",np="_header_oq58b_20",op="_time_oq58b_29",rp="_error_oq58b_35",ap="_timestamp_oq58b_39",ip="_chainInfo_oq58b_44",cp="_content_oq58b_52",lp="_messages_oq58b_59",dp="_changes_oq58b_64",De={link:tp,inner:sp,header:np,time:op,error:rp,timestamp:ap,chainInfo:ip,content:cp,messages:lp,changes:dp},up=({txItem:e,chain:s})=>t.jsx(zs,{txHash:e.txhash,chainId:s.chainId,className:De.link,children:t.jsxs("div",{className:De.inner,children:[t.jsxs("div",{className:De.header,children:[t.jsxs("div",{className:De.time,children:[e.code!==0&&t.jsx(N.IconWarningFilled,{size:14,className:De.error}),t.jsx("span",{className:De.timestamp,children:ke.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:De.chainInfo,children:[t.jsx(Y,{src:s.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:s.name})]})]}),t.jsxs("div",{className:De.content,children:[t.jsx("div",{className:De.messages,children:t.jsx(ep,{messages:e.tx.body.messages})}),t.jsx("div",{className:De.changes,children:t.jsx(ye,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(J_,{...e,chain:s})})})]})]})}),mp="_list_1wa9p_1",hp="_dateGroup_1wa9p_7",fp="_dateHeader_1wa9p_12",_p="_more_1wa9p_18",fs={list:mp,dateGroup:hp,dateHeader:fp,more:_p},pp=({list:e,chainId:s})=>{const n=ne(),o=_.useMemo(()=>ta(e,r=>{if(r.timestamp)return new Date(r.timestamp)}),[e]);return e.length===0?t.jsx(se,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:fs.list,children:Object.entries(o).map(([r,a])=>t.jsxs("div",{className:fs.dateGroup,children:[t.jsx("div",{className:fs.dateHeader,children:r}),a.map(i=>t.jsx(ye,{errorBoundaryProps:{fallback:null},children:t.jsx(up,{txItem:i,chain:i.chain})},i.txhash))]},r))}),t.jsx(zs,{chainId:s,accountAddress:n,pathSuffix:"/txs",className:fs.more,showIcon:!0,children:"View more on Initia Scan"})]})},gp=()=>{const{activities:e,isLoading:s}=Bc(),[n,o]=G.useAtom(W_),r=_e(),a=_.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=_.useMemo(()=>n?e.filter(c=>c.chain.chainId===n):e,[e,n]);return s&&e.length===0?t.jsx(se,{children:"Loading activities..."}):!e.length&&!s?t.jsx(se,{children:"No activity yet"}):t.jsxs(nt.Root,{children:[t.jsx(nt.Controls,{children:t.jsx(Yn,{value:n,onChange:o,chainIds:a,fullWidth:!0})}),t.jsx(pp,{list:i,chainId:n||r.chainId})]})},ua=_.createContext(null);function ma(){return _.useContext(ua)}const xp="_popup_nbecp_1",yp="_item_nbecp_19",_s={popup:xp,item:yp},ha=({asset:e,children:s})=>{const{denom:n,decimals:o,symbol:r,logoUrl:a,unlisted:i,address:c,chain:l}=e,{chainId:d}=l,[u,m]=_.useState(!1),h=me(),f=ma(),{showNotification:p}=Hn(),{defaultChainId:g}=X(),{evm_chain_id:y}=Zt(),I=de.useChainId(),{switchChainAsync:S}=de.useSwitchChain(),{watchAssetAsync:k}=de.useWatchAsset(),w=()=>{m(!1),h("/send",{denom:n,chain:l})},T=()=>{m(!1),h("/bridge",{srcChainId:d,srcDenom:n,quantity:""})},P=$.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const R=a;return await S({chainId:Number(y)}),k({type:"ERC20",options:{address:c,symbol:r,decimals:o,image:R}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:R=>{p({type:"error",title:"Asset addition failed",description:R.message})}});return t.jsxs(Ke.Menu.Root,{open:u,onOpenChange:m,modal:!1,children:[t.jsx(Ke.Menu.Trigger,{render:s}),t.jsx(Ke.Menu.Portal,{container:f,children:t.jsx(Ke.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(Ke.Menu.Popup,{className:_s.popup,children:[t.jsxs(Ke.Menu.Item,{className:_s.item,onClick:w,children:[t.jsx(N.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(Ke.Menu.Item,{className:_s.item,onClick:T,disabled:i,children:[t.jsx(N.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===g&&y===I&&!!c&&t.jsxs(Ke.Menu.Item,{className:_s.item,onClick:()=>P.mutate(),disabled:P.isPending||P.data,children:[P.data?t.jsx(N.IconCheck,{size:16}):t.jsx(N.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},jp="_item_knoro_1",vp="_info_knoro_22",wp="_images_knoro_28",bp="_name_knoro_32",Cp="_value_knoro_38",Ip="_amount_knoro_46",Np="_usd_knoro_52",ht={item:jp,info:vp,images:wp,name:bp,value:Cp,amount:Ip,usd:Np},Sp=({asset:e})=>{const{amount:s,value:n,logoUrl:o,chain:r}=e,a=v.formatAmount(s,{decimals:e.decimals});return t.jsx(ha,{asset:e,children:t.jsxs("button",{className:ht.item,children:[t.jsxs("div",{className:ht.info,children:[t.jsx(Ws,{assetLogoUrl:o,chainLogoUrl:r.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:ht.images}),t.jsx("span",{className:ht.name,children:r.name})]}),t.jsxs("div",{className:ht.value,children:[t.jsx("span",{className:ht.amount,children:a}),Number(n)>0&&t.jsx("span",{className:ht.usd,children:Ae(n)})]})]})})},kp="_container_g5q73_1",Ap="_assetItem_g5q73_6",$p="_assetInfo_g5q73_26",Tp="_logo_g5q73_32",Ep="_symbol_g5q73_36",qp="_chainName_g5q73_46",Dp="_chainInfos_g5q73_52",Pp="_chainLogos_g5q73_58",Rp="_chainLogo_g5q73_58",Bp="_moreChains_g5q73_69",Mp="_expandIcon_g5q73_81",Fp="_expanded_g5q73_85",Op="_valueColumn_g5q73_90",Up="_amount_g5q73_99",Lp="_value_g5q73_90",zp="_collapsibleContent_g5q73_112",Kp="_chainsList_g5q73_142",oe={container:kp,assetItem:Ap,assetInfo:$p,logo:Tp,symbol:Ep,chainName:qp,chainInfos:Dp,chainLogos:Pp,chainLogo:Rp,moreChains:Bp,expandIcon:Mp,expanded:Fp,valueColumn:Op,amount:Up,value:Lp,collapsibleContent:zp,chainsList:Kp},Wp=G.atom([]),fa=({assetGroup:e})=>{const{symbol:s,logoUrl:n,assets:o}=e,r=o.length===1,[a,i]=G.useAtom(Wp),c=_.useMemo(()=>mi(e),[e]),l=_.useMemo(()=>Ln(e),[e]),d=a.includes(s),u=()=>{i(h=>d?b.without([s],h):b.uniq([...h,s]))},m=()=>t.jsxs("button",{className:oe.assetItem,children:[t.jsxs("div",{className:oe.assetInfo,children:[n&&t.jsx(Y,{src:n,width:32,height:32,className:oe.logo,logo:!0}),t.jsxs("div",{className:oe.details,children:[t.jsx("div",{className:oe.symbol,children:s}),r?t.jsx("div",{className:oe.chainName,children:o[0].chain.name}):t.jsxs("div",{className:oe.chainInfos,children:[t.jsx("div",{className:oe.chainLogos,children:o.slice(0,5).map(({chain:h})=>t.jsx(Y,{src:h.logoUrl,width:16,height:16,className:oe.chainLogo,logo:!0},h.chainId))}),o.length>5&&t.jsxs("span",{className:oe.moreChains,children:["+",o.length-5]}),t.jsx(N.IconChevronDown,{size:16,className:D(oe.expandIcon,{[oe.expanded]:d})})]})]})]}),t.jsxs("div",{className:oe.valueColumn,children:[t.jsx("div",{className:oe.amount,children:v.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&t.jsx("div",{className:oe.value,children:Ae(l)})]})]});if(r){const[h]=o;return t.jsx("div",{className:oe.container,children:t.jsx(ha,{asset:h,children:m()})})}return t.jsx("div",{className:oe.container,children:t.jsxs(te.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(te.Collapsible.Trigger,{asChild:!0,children:m()}),t.jsx(te.Collapsible.Content,{className:oe.collapsibleContent,children:t.jsx("div",{className:oe.chainsList,children:o.map(h=>t.jsx(Sp,{asset:h},h.chain.chainId))})})]})})},Hp="_collapsible_1spkj_1",Qp="_trigger_1spkj_5",Vp="_divider_1spkj_20",Gp="_label_1spkj_26",Yp="_chevron_1spkj_31",Jp="_content_1spkj_39",Zp="_list_1spkj_43",tt={collapsible:Hp,trigger:Qp,divider:Vp,label:Gp,chevron:Yp,content:Jp,list:Zp},Xp=({unlistedAssets:e})=>{const[s,n]=_.useState(!0),o=ma(),r=_.useRef(null),[a,i]=_.useState(0);_.useEffect(()=>{if(r.current){const d=r.current.scrollHeight;i(d)}},[e]);const c=d=>{if(d&&!s&&o?.current){const u=o.current;u.scrollTo({top:u.scrollHeight,behavior:"auto"}),window.setTimeout(()=>{u.scrollTo({top:u.scrollHeight,behavior:"smooth"})},150)}n(d)},l=ot.useSpring({height:s?a:0,opacity:s?1:0,config:{tension:500,friction:30,clamp:!0}});return e.length===0?null:t.jsxs(te.Collapsible.Root,{open:s,onOpenChange:c,className:tt.collapsible,children:[t.jsxs(te.Collapsible.Trigger,{className:tt.trigger,children:[t.jsx("div",{className:tt.divider}),t.jsxs("span",{className:tt.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(N.IconChevronDown,{className:tt.chevron,size:12,"data-state":s?"open":"closed"}),t.jsx("div",{className:tt.divider})]}),t.jsx(te.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(ot.animated.div,{className:tt.content,style:l,children:t.jsx("div",{className:tt.list,ref:r,children:e.map(d=>t.jsx(fa,{assetGroup:{...d,assets:[d]}},d.denom))})})})]})},eg="_list_szwvw_1",tg={list:eg},sg=()=>{const[e,s]=G.useAtom(U_),[n,o]=G.useAtom(L_),{assetGroups:r,unlistedAssets:a,chainsByValue:i,totalValue:c,isLoading:l}=zn(),d=i.map(({chainId:h})=>h),u=_.useMemo(()=>{const h=e?r.filter(p=>{const{symbol:g,assets:y}=p;return g.toLowerCase().includes(e.toLowerCase())||y.some(({denom:I,address:S})=>I.toLowerCase().includes(e.toLowerCase())||S?.toLowerCase().includes(e.toLowerCase()))}):r;return n?h.map(p=>({...p,assets:p.assets.filter(({chain:g})=>g.chainId===n)})).filter(p=>p.assets.length>0):h},[r,e,n]),m=_.useMemo(()=>{const h=e?a.filter(({denom:p,address:g})=>p.toLowerCase().includes(e.toLowerCase())||g?.toLowerCase().includes(e.toLowerCase())):a;return n?h.filter(({chain:p})=>p.chainId===n):h},[a,e,n]);return l&&r.length===0?t.jsx(se,{children:"Loading assets..."}):!u.length&&!m.length&&!e&&!n&&!l?t.jsx(se,{children:"No assets"}):t.jsxs(nt.Root,{children:[t.jsxs(nt.Controls,{children:[t.jsx(nt.SearchInput,{value:e,onChange:h=>s(h.target.value),onClear:()=>s(""),placeholder:"Search assets"}),t.jsx(Yn,{value:n,onChange:o,chainIds:d,renderExtra:h=>{if(!h)return Ae(c);const f=i.find(p=>p.chainId===h);return f?Ae(f.value):null}})]}),t.jsx("div",{children:u.length===0&&m.length===0?t.jsx(se,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:tg.list,children:u.map(h=>t.jsx(fa,{assetGroup:h},h.symbol))}),t.jsx(Xp,{unlistedAssets:m})]})})]})},ng="_thumbnail_1tdri_1",og="_placeholder_1tdri_18",rg="_clickable_1tdri_24",Wt={thumbnail:ng,placeholder:og,clickable:rg},ag=({nftInfo:e,size:s,onClick:n})=>{const{collection_addr:o,object_addr:r,nft:a,chain:i}=e,{glyphUrl:c}=X(),l=new URL(`/v1/${i.chainId}/${o}/${r||a.token_id}`,c).toString();return n?t.jsx("button",{className:D(Wt.thumbnail,Wt.clickable),onClick:n,style:{width:s,height:s},children:t.jsx(Y,{src:l,classNames:{placeholder:Wt.placeholder}})}):t.jsx("div",{className:Wt.thumbnail,style:{width:s,height:s},children:t.jsx(Y,{src:l,classNames:{placeholder:Wt.placeholder}})})},ig="_collectionName_p9jco_1",cg="_nftName_p9jco_6",lg="_chainInfo_p9jco_10",gn={collectionName:ig,nftName:cg,chainInfo:lg},Zn=({normalizedNft:e,onThumbnailClick:s,thumbnailSize:n,chainIconSize:o=12,classNames:r})=>{const{collection_name:a,name:i,chain:c}=e;return t.jsxs("div",{className:r?.root,children:[t.jsx(ag,{nftInfo:e,onClick:s,size:n}),t.jsxs("div",{children:[t.jsx("div",{className:D(gn.collectionName,r?.collectionName),children:a}),t.jsx("div",{className:D(gn.nftName,r?.nftName),children:i}),t.jsxs("div",{className:D(gn.chainInfo,r?.chainInfo),children:[t.jsx(Y,{src:c.logoUrl,width:o,height:o,logo:!0}),t.jsx("span",{children:c.name})]})]})]})},Xn=$e.createQueryKeys("interwovenkit:nft",{nfts:(e,s)=>[e,s],metadata:e=>[e]});function dg(e,s){const{nft:n}=e,o=s.name??n.token_id;return{...e,...n,...s,name:o}}function ug(e,s){return e.flatMap((n,o)=>(s[o]??[]).map(a=>({...a,chain:n})))}const mg=()=>{const e=ne(),s=re(),n=$.useQueries({queries:s.map(l=>({queryKey:Xn.nfts(l.indexerUrl,e).queryKey,queryFn:()=>tr(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:W.SECOND}))}),o=n.map(b.prop("data")),r=ug(s,o),a=r.reduce((l,{chain:d})=>({...l,[d.chainId]:(l[d.chainId]||0)+1}),{}),i=Object.values(a).reduce((l,d)=>l+d,0),c=n.some(l=>l.isLoading);return{nftInfos:r,chainCounts:a,totalCount:i,isLoading:c}};function hg(e){const s=Mo(e);return $.useQuery({queryKey:Xn.metadata(s).queryKey,queryFn:async()=>{try{if(!s)return{};const n=await z.get(s).json();return{...n,image:Mo(n.image)}}catch{return{}}},staleTime:W.INFINITY})}function Mo(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const fg=({nftInfo:e,children:s})=>{const{data:n={}}=hg(e.nft.uri),o=dg(e,n);return s(o)},_g="_grid_1wwdn_1",pg="_root_1wwdn_7",gg="_collectionName_1wwdn_15",xg="_nftName_1wwdn_23",yg="_chainInfo_1wwdn_32",Fo={grid:_g,root:pg,collectionName:gg,nftName:xg,chainInfo:yg},jg=()=>{const[e,s]=G.useAtom(z_),[n,o]=G.useAtom(K_),{nftInfos:r,chainCounts:a,totalCount:i,isLoading:c}=mg(),l=me(),d=_.useMemo(()=>r.filter(({collection_addr:m,collection_name:h,nft:f,object_addr:p,chain:g})=>{if(n&&g.chainId!==n)return!1;if(e){const y=e.trim().toLowerCase();return m.toLowerCase().includes(y)||h.toLowerCase().includes(y)||f.token_id.toLowerCase().includes(y)||p.toLowerCase().includes(y)}return!0}),[r,n,e]),u=_.useMemo(()=>Array.from(new Set(r.map(({chain:m})=>m.chainId))),[r]);return c&&r.length===0?t.jsx(se,{children:"Loading NFTs..."}):!r.length&&!e&&!c?t.jsx(se,{children:"No NFTs"}):t.jsxs(nt.Root,{children:[t.jsxs(nt.Controls,{children:[t.jsx(nt.SearchInput,{value:e,onChange:m=>s(m.target.value),onClear:()=>s(""),placeholder:"Search NFTs"}),t.jsx(Yn,{value:n,onChange:o,chainIds:u,renderExtra:m=>m?a[m]||0:i})]}),d.length===0?t.jsx(se,{children:"No NFTs found"}):t.jsx("div",{className:Fo.grid,children:d.map(m=>{const{collection_addr:h,nft:f}=m;return t.jsx(fg,{nftInfo:m,children:p=>t.jsx(Zn,{normalizedNft:p,onThumbnailClick:()=>l("/nft",p),classNames:Fo})},h+f.token_id)})})]})},vg="_totalValue_19cj3_1",wg="_totalLabel_19cj3_7",bg="_totalAmount_19cj3_13",Cg="_loading_19cj3_18",Ig="_nav_19cj3_23",Ng="_item_19cj3_28",Sg="_tabs_19cj3_53",kg="_tab_19cj3_53",we={totalValue:vg,totalLabel:wg,totalAmount:bg,loading:Cg,nav:Ig,item:Ng,tabs:Sg,tab:kg},Ag=()=>{Vr();const e=me(),s=Ts(),{totalValue:n,isLoading:o}=zn(),r=_.useRef(null);return t.jsx(ua.Provider,{value:r,children:t.jsxs(Fe,{ref:r,children:[t.jsxs("div",{className:we.totalValue,children:[t.jsx("div",{className:we.totalLabel,children:"Total value"}),t.jsx("div",{className:D(we.totalAmount,{[we.loading]:o}),children:Ae(n)})]}),t.jsxs("div",{className:we.nav,children:[t.jsxs(Et,{to:"/send",className:we.item,children:[t.jsx(N.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(Et,{to:"/bridge",className:we.item,children:[t.jsx(N.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),t.jsxs(Et,{to:"/receive",className:we.item,children:[t.jsx(N.IconQrCode,{size:16}),t.jsx("span",{children:"Receive"})]})]}),t.jsxs(Ze.Tabs.Root,{value:s,onValueChange:e,children:[t.jsxs(Ze.Tabs.List,{className:we.tabs,children:[t.jsx(Ze.Tabs.Tab,{className:we.tab,value:"/",children:"Assets"}),t.jsx(Ze.Tabs.Tab,{className:we.tab,value:"/nfts",children:"NFTs"}),t.jsx(Ze.Tabs.Tab,{className:we.tab,value:"/activity",children:"Activity"})]}),t.jsx(Ze.Tabs.Panel,{value:"/",children:t.jsx(sg,{})}),t.jsx(Ze.Tabs.Panel,{value:"/nfts",children:t.jsx(jg,{})}),t.jsx(Ze.Tabs.Panel,{value:"/activity",children:t.jsx(gp,{})})]})]})})},$g="_root_9688k_1",Tg="_collectionName_9688k_8",Eg="_nftName_9688k_12",qg="_chainInfo_9688k_16",Dg="_attributes_9688k_20",Pg="_title_9688k_23",Rg="_count_9688k_28",Bg="_item_9688k_32",Mg="_type_9688k_38",Fg="_value_9688k_44",ft={root:$g,collectionName:Tg,nftName:Eg,chainInfo:qg,attributes:Dg,title:Pg,count:Rg,item:Bg,type:Mg,value:Fg},Og=()=>{const e=me(),s=jt(),{attributes:n}=s;return t.jsxs(Oe,{title:"NFT details",children:[t.jsx(Zn,{normalizedNft:s,chainIconSize:14,classNames:ft}),t.jsx(ie,{children:t.jsx(J.White,{onClick:()=>e("/nft/send",s),sm:!0,children:"Send"})}),n&&t.jsxs("div",{className:ft.attributes,children:[t.jsxs("header",{className:ft.title,children:["Traits ",t.jsxs("span",{className:ft.count,children:["(",n.length,")"]})]}),t.jsx("div",{children:n.map(({trait_type:o,value:r})=>t.jsxs("div",{className:ft.item,children:[t.jsx("div",{className:ft.type,children:o}),t.jsx("div",{className:ft.value,children:r})]},o))})]})]})};function Ug({balances:e,gasPrices:s,gas:n}){return s.map(({denom:o,amount:r})=>{const a=F(r).times(n).toFixed(0,F.ROUND_CEIL),i=e.find(c=>c.denom===o)?.amount??"0";return{amount:a,denom:o,balance:i}}).filter(({amount:o,balance:r})=>F(r).gte(o))}function Lg({denom:e,balances:s,gasPrices:n,lastFeeDenom:o,gas:r}){const a=s.find(d=>d.denom===e)?.amount??"0",i=Ug({balances:s,gasPrices:n,gas:r}),c=i.find(d=>d.denom===o);if(i.length===0)return a;if(e===o&&c){const d=F(a).minus(c.amount);return F.max(d,0).toString()}const l=i.find(d=>d.denom!==e)||i[0];if(!c&&e===l.denom){const d=F(a).minus(l.amount);return F.max(d,0).toString()}return F(a).toString()}const zg=({chain:e,onSelect:s})=>{const n=za(e);return t.jsx(os,{assets:n,onSelect:s})},Kg=({afterSelect:e})=>{const{watch:s,setValue:n}=ue.useFormContext(),{chainId:o,denom:r}=s(),{chainId:a}=s(),[i,c]=_.useState(a),l=Me(i),d=re(),u=m=>{if(o===i&&r===m){e();return}n("chainId",i),n("denom",m),n("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(xt.Stack,{children:t.jsx(xt,{chains:d,value:i,onSelect:c})}),t.jsx(ye,{suspenseFallback:t.jsx(os.Placeholder,{}),children:t.jsx(zg,{chain:l,onSelect:u})},i)]})},Wg="_fields_brpej_1",Hg="_divider_brpej_11",Oo={fields:Wg,divider:Hg},Qg=$e.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Vg=()=>{const{address:e,initiaAddress:s,estimateGas:n,requestTxSync:o}=xe(),{register:r,watch:a,setValue:i,handleSubmit:c,formState:l}=ue.useFormContext(),{errors:d}=l,{chainId:u,denom:m,recipient:h,quantity:f,memo:p}=a(),g=Me(u),y=Bn(g),I=Pr(g),S=Rr(g),k=Xo(m,g),{data:w}=ks(g),{decimals:T}=k,P=y.find(O=>O.denom===m)?.amount??"0",R=w?.find(({id:O})=>O===m)?.price,{data:B=0,isLoading:K}=$.useQuery({queryKey:Qg.gas({chainId:u,denom:m,recipient:h,initiaAddress:s}).queryKey,queryFn:()=>{const O=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:io.MsgSend.fromPartial({fromAddress:s,toAddress:v.InitiaAddress(h).bech32,amount:[{denom:m,amount:"1"}]})}];return n({messages:O,chainId:u})},enabled:v.InitiaAddress.validate(h),staleTime:W.INFINITY}),j=Math.ceil(B*Vt),C=Lg({denom:m,balances:y,gasPrices:I,lastFeeDenom:S,gas:j}),x=F(P).isZero(),q=I.some(({denom:O})=>O===m)&&K,M=x||q,{mutate:E,isPending:H}=$.useMutation({mutationFn:({chainId:O,denom:Z,quantity:Ue,recipient:Je,memo:at})=>{const he=v.toBaseUnit(Ue,{decimals:T}),pe=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:io.MsgSend.fromPartial({fromAddress:s,toAddress:v.InitiaAddress(Je).bech32,amount:[{denom:Z,amount:he}]})}];return o({messages:pe,memo:at,chainId:O,gas:B,gasAdjustment:Vt,gasPrices:I,spendCoins:[{denom:Z,amount:he}],internal:"/"})}}),ee=_.useMemo(()=>{if(!f)return"Enter amount";if(d.quantity)return d.quantity.message;if(!h)return"Enter recipient address";if(d.recipient)return d.recipient.message;if(d.memo)return d.memo.message},[f,h,d.quantity,d.recipient,d.memo]);return t.jsx(Oe,{title:"Send",children:t.jsxs("form",{onSubmit:c(O=>E(O)),children:[t.jsxs("div",{className:Oo.fields,children:[t.jsx(In,{selectButton:t.jsx(Dt,{title:"Select chain and asset",content:O=>t.jsx(Kg,{afterSelect:O}),children:t.jsx(Xr,{asset:k,chain:g})}),quantityInput:t.jsx(ws,{balance:P,decimals:T}),balanceButton:t.jsx(Gr,{onClick:()=>i("quantity",v.fromBaseUnit(C,{decimals:T}),{shouldValidate:!0}),disabled:M,children:v.formatAmount(P??"0",{decimals:T})}),value:f?R?Ae(F(f).times(R)):"$-":"$0"}),t.jsx("div",{className:Oo.divider}),t.jsx(Vn,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...r("memo",{validate:O=>!O||new Blob([O]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),t.jsx(ae.Stack,{children:!p&&t.jsx(ae,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(ie,{children:t.jsx(J.White,{type:"submit",loading:(K?"Estimating gas...":!1)||H,disabled:!!ee,children:ee??"Confirm"})})]})})},Gg=()=>{const e=jt(),s=Zt(),n=Gt(s),{chain:o=s}=e,r=b.head(n);if(!e.denom&&!r)throw new Error("Asset list not found. This occurs during local development when asset list is not configured. Use asset-specific send buttons instead of the default send button, or register chain in Initia Registry with at least one asset defined.");const a=e.denom??r?.denom,i=ue.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:a,quantity:"",recipient:"",memo:""}});return t.jsx(ue.FormProvider,{...i,children:t.jsx(Vg,{})})};async function En(e,s){const n=e.replace("ibc/",""),{class_trace:o}=await z.create({prefixUrl:s}).get(`ibc/apps/nft_transfer/v1/class_traces/${n}`).json();return o}async function Yg(e,s){const n=new We.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await z.create({prefixUrl:s}).post("minievm/evm/v1/call",{json:{sender:v.InitiaAddress("0x1").bech32,contract_addr:v.InitiaAddress(e).hex,input:n.encodeFunctionData("name")}}).json();return n.decodeFunctionResult("name",o)[0]}async function Jg(e,s,n){if(s.startsWith("evm/"))return e;const{token_infos:o}=await z.create({prefixUrl:n}).get(`minievm/evm/v1/erc721/origin_token_infos/${s}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:r})=>r)}async function Zg({collection_addr:e},{restUrl:s}){const n=await Yg(e,s);if(!n.startsWith("ibc/"))return{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await En(n,s);return o?{class_id:n,class_trace:o}:{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function Xg(e,s){const{data:n}=await z.create({prefixUrl:s}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(n)}async function ex({object_addr:e,collection_addr:s},{restUrl:n}){const o=await Xg(s,n);return o.startsWith("ibc/")?v.InitiaAddress.equals(v.createObjectAddress("0x1",o),s)?{class_id:o,class_trace:await En(o,n)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await En(o,n)}:{class_id:`move/${s.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function tx(e,s){const n=V.toBase64(_t.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await z.create({prefixUrl:s}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${n}`).json();return o.name}async function sx(e,s){const{collection:n}=await z.create({prefixUrl:s}).get(`indexer/nft/v1/collections/${e}`).json();return n.collection.creator}async function nx(e,s){const n=V.toBase64(_t.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:s}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${n}`).json();return o}function Uo(e){const s=/^(.*channel-\d+)\/(.*)$/,n=e.match(s);if(!n)throw new Error("Pattern `channel-{number}/` not found.");const[,o,r]=n;return[o,r]}async function ox({collection_addr:e},s,n){const o=v.InitiaAddress(e).bech32,r=await tx(o,s.restUrl),a=s.metadata?.ibc_channels?.find(({chain_id:g,version:y})=>g===n.chain_id&&y.includes("ics721-1"));if(!a)throw new Error("Channel not found");const i=a.port_id,c=i.split(".")[1],l=V.toBase64(_t.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await z.create({prefixUrl:s.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),u=d??o,m=await nx(c,s.restUrl),h=await sx(o,s.indexerUrl);if(u===o)return{class_id:u,class_trace:void 0,outgoing_proxy:m};if(d&&h!==i.replace("wasm.","")){const[g,y]=Uo(d);return{class_id:o,class_trace:{path:g,base_class_id:y},outgoing_proxy:m}}const[f,p]=Uo(r);return{class_id:o,class_trace:{path:f,base_class_id:p},outgoing_proxy:m}}const rx={minimove:ex,minievm:Zg,miniwasm:ox};async function ax({nft:e,srcChain:s,intermediaryChain:n}){const o=s.metadata?.is_l1?"minimove":s.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const r=await rx[o](e,s,n);return Object.assign(r,o==="minievm"&&{token_ids:await Jg([e.token_id],r.class_id,s.restUrl)})}const ix="_root_17hg0_1",cx="_collectionName_17hg0_9",lx="_nftName_17hg0_14",dx="_chainInfo_17hg0_18",ux="_fields_17hg0_23",mx="_chain_17hg0_18",xn={root:ix,collectionName:cx,nftName:lx,chainInfo:dx,fields:ux,chain:mx},hx=$e.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),fx=()=>{const e=re(),s=jt(),{chain:n,collection_addr:o}=s,{routerApiUrl:r}=X(),a=qs(),i=_e(),{address:c,initiaAddress:l,requestTxSync:d}=xe(),{watch:u,setValue:m,handleSubmit:h,formState:f}=ue.useFormContext(),{errors:p}=f,g=u(),{recipient:y,dstChainId:I}=g,S=Me(I),k=$.useQuery({queryKey:hx.simulation({collection_addr:o,nft:s,sender:l,recipient:y,srcChain:n,dstChain:S,layer1:i,routerApiUrl:r}).queryKey,queryFn:async()=>{const C=Object.assign({from_address:l,from_chain_id:n.chainId,to_address:v.InitiaAddress(y).bech32,to_chain_id:S.chainId,collection_address:o,token_ids:[s.token_id],object_addresses:[s.object_addr]},n.chainId!==S.chainId&&await ax({nft:s,srcChain:n,intermediaryChain:i})),{msgs:x}=await z.create({prefixUrl:r}).post("nft",{json:C}).json();return x.map(A=>a.fromAmino(A))},enabled:v.InitiaAddress.validate(y)}),{data:w,isLoading:T,error:P}=k,R=$.useQueryClient(),{mutate:B,isPending:K}=$.useMutation({mutationFn:async()=>{if(!w)throw new Error("Route not found");await d({messages:w,chainId:n.chainId,internal:"/nfts"})},onSuccess:()=>{R.invalidateQueries({queryKey:Xn.nfts._def})}}),j=_.useMemo(()=>{if(!y)return"Enter recipient address";if(p.recipient)return p.recipient.message;if(P)return"Route not found"},[y,p.recipient,P]);return t.jsxs("form",{onSubmit:h(()=>B()),children:[t.jsx(Zn,{normalizedNft:s,thumbnailSize:80,classNames:xn}),t.jsxs("div",{className:xn.fields,children:[t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(Dt,{title:"Destination appchain",content:C=>t.jsx(Zr,{onSelect:({chainId:x})=>{m("dstChainId",x),C()},list:e,getImage:x=>x.logoUrl,getName:x=>x.name,getKey:x=>x.chainId}),className:D("input",xn.chain),children:[t.jsx(Y,{src:S.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:S.name})]})]}),t.jsx(Vn,{myAddress:c,ref:ss()})]}),t.jsx(ie,{children:t.jsx(J.White,{loading:(T?"Finding route...":!1)||K,disabled:!!j,children:j??"Confirm"})})]})},_x=()=>{const{chain:e}=jt(),s=ue.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(Oe,{title:"Send NFT",children:t.jsx(ue.FormProvider,{...s,children:t.jsx(fx,{})})})},_a=()=>{const e=me(),s=Ts(),n=Pt(),{closeDrawer:o}=Ge(),{closeModal:r}=Bs();_.useEffect(()=>{r(),s.startsWith("/bridge/")&&e("/bridge"),(s==="/collection"||s.startsWith("/nft"))&&e("/nfts")},[n]);const a=Es();if(_.useEffect(()=>{a("Page View")},[s,a]),s==="/connect")return n?null:t.jsx(Po,{onSuccess:o});if(s==="/blank")return null;if(!n)return t.jsx(Po,{});switch(s){case"/":case"/nfts":case"/activity":return t.jsx(Ag,{});case"/send":return t.jsx(Gg,{},n);case"/receive":return t.jsx(Wf,{});case"/nft":return t.jsx(Og,{});case"/nft/send":return t.jsx(_x,{},n);case"/bridge":return t.jsx(Tm,{},n);case"/bridge/preview":return t.jsx(zh,{});case"/bridge/history":return t.jsx(jh,{});case"/op/withdrawals":return t.jsx(wf,{});case"/tx":return t.jsx(Lr,{});case"/autosign/enable":return t.jsx(pd,{});case"/settings":return t.jsx(y_,{});case"/settings/autosign":return t.jsx(a_,{})}},px="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",gx=()=>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:px}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),xx=()=>{Ya(),ni(),re();const e=_e();return Kn(),qt(localStorage.getItem(U.BRIDGE_SRC_CHAIN_ID)??e.chainId),qt(localStorage.getItem(U.BRIDGE_DST_CHAIN_ID)??e.chainId),null},yx=({children:e,...s})=>(_.useEffect(()=>{vi()},[]),Ie.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(gx,{}),t.jsx(Go.Provider,{value:{...Vo,...s},children:t.jsx(ir,{children:t.jsx(Ql,{children:t.jsx(te.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(Hl,{children:t.jsxs(Dl,{children:[e,t.jsx(wi,{}),t.jsx(ye,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(xx,{})}),t.jsx(cc,{children:t.jsx(_a,{})})]})})})})})})]}):null),jx=({bridge:e})=>t.jsx(ir,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Er.Provider,{value:!!e,children:t.jsx(ye,{children:t.jsx(_a,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=Vt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=Qo;exports.InterwovenKit=jx;exports.InterwovenKitProvider=yx;exports.MAINNET=Vo;exports.MoveError=yr;exports.PRIVY_APP_ID=Pn;exports.TESTNET=$a;exports.initiaPrivyWallet=Ea;exports.initiaPrivyWalletConnector=Ta;exports.initiaPrivyWalletOptions=Ns;exports.injectStyles=Mi;exports.useAddress=Pt;exports.useHexAddress=Us;exports.useInitiaAddress=ne;exports.useInterwovenKit=xe;exports.usePortfolio=zn;exports.useUsernameQuery=Ir;