@initia/interwovenkit-react 2.0.5 → 2.0.6
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 +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4759 -4641
- package/dist/styles.css +1 -1
- package/dist/styles.js +1 -1
- package/package.json +34 -34
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 xr=require("@privy-io/cross-app-connect/rainbow-kit"),ve=require("wagmi"),A=require("@tanstack/react-query"),w=require("@initia/utils"),M=require("bignumber.js"),v=require("ramda"),ke=require("@lukemorales/query-key-factory"),Z=require("ky"),f=require("react"),W=require("@cosmjs/encoding"),Uo=require("@mysten/bcs"),ln=require("@cosmjs/amino/build/signdoc"),dn=require("@cosmjs/crypto"),Un=require("@cosmjs/math"),js=require("@cosmjs/proto-signing"),qe=require("@cosmjs/stargate"),Ln=require("@cosmjs/tendermint-rpc"),Lo=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Ge=require("cosmjs-types/cosmos/tx/v1beta1/tx"),Ze=require("ethers"),Kt=require("@initia/amino-converter"),Ht=require("@cosmjs/amino"),zo=require("cosmjs-types/cosmos/auth/v1beta1/auth"),un=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Ko=require("cosmjs-types/google/protobuf/any"),G=require("jotai"),t=require("react/jsx-runtime"),yr=require("@amplitude/analytics-browser"),Y=require("radix-ui"),Ne=require("usehooks-ts"),jr=require("react-error-boundary"),B=require("clsx"),Ie=require("@base-ui-components/react/dialog"),Ho=require("xss"),k=require("@initia/icons-react"),Je=require("@react-spring/web"),Wo=require("qr-code-styling"),vs=require("change-case"),Re=require("@base-ui-components/react/select"),Ls=require("@base-ui-components/react/collapsible"),zn=require("nanoid"),Qo=require("react-dom"),ce=require("react-hook-form"),At=require("date-fns"),Vo=require("jotai/utils"),vr=require("react-merge-refs"),Go=require("react-intersection-observer"),Yo=require("@noble/hashes/sha3"),ss=require("@noble/hashes/utils"),He=require("@base-ui-components/react/tabs"),vt=require("@base-ui-components/react/popover"),We=require("@base-ui-components/react"),Kn=require("cosmjs-types/cosmos/bank/v1beta1/tx");function Zo(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 bn=Zo(yr),Wt=1.4,br=1.05,wr={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",glyphUrl:"https://glyph.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",theme:"dark"},Jo={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},bs={id:"cmbq1ozyc006al70lx4uciz0q",name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Xo=xr.toPrivyWalletConnector(bs),ea=xr.toPrivyWallet(bs),Cr=f.createContext(null);function ee(){const e=f.useContext(Cr);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const K={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function ta(e){if(e instanceof Z.HTTPError){const{response:s}=e,n=s.headers.get("content-type")??"";if(v.includes("application/json",n))try{const r=await s.json();if(r.message)return r.message}catch{return e.message}try{return await s.text()}catch{return e.message}}if(e instanceof Error){if(v.path(["code"],e)===4001||v.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const s=v.path(["error","message"],e),n=v.path(["cause","message"],e),r=v.path(["shortMessage"],e);return s||n||r||e.message}return String(e)}async function Fe(e){return new Error(await ta(e))}const ws=ke.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function ns(e){const s=v.path([0,"address"],e);if(!s)throw new Error("URL not found");return s}function sa(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"]:m,indexer:h}=a,_=ns(d),g=ns(u),p=ns(h),j=i?.minitia?.type==="minievm"?ns(m):void 0;return{...e,chainId:s,name:l,logoUrl:c,rpcUrl:_,restUrl:g,indexerUrl:p,jsonRpcUrl:j}}function oe(){const{defaultChainId:e,registryUrl:s,customChain:n}=ee(),{data:r}=A.useSuspenseQuery({queryKey:ws.list(s).queryKey,queryFn:()=>Z.create({prefixUrl:s}).get("chains.json").json(),select:o=>(n?[n,...o.filter(i=>i.chain_id!==n.chain_id)]:o).map(sa).toSorted(v.descend(i=>i.chainId===e)),staleTime:K.MINUTE});return r}function Ir(){const{registryUrl:e}=ee(),{data:s}=A.useSuspenseQuery({queryKey:ws.profiles(e).queryKey,queryFn:()=>Z.create({prefixUrl:e}).get("profiles.json").json(),staleTime:K.MINUTE});return s}function Xe(){const e=le(),s=oe(),n=Ir();return r=>{const o=s.find(i=>i.chain_id===r);if(o)return o;const a=n.find(i=>i.chain_id===r);if(!a)throw new Error(`Chain not found: ${r}`);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:r,name:a.pretty_name,logoUrl:a.logo,rpcUrl:"",restUrl:"",indexerUrl:"",jsonRpcUrl:""}}}function Oe(e){return Xe()(e)}function Gt(){const{defaultChainId:e}=ee();return Oe(e)}function le(){const s=oe().find(n=>n.metadata?.is_l1);if(!s)throw new Error("Layer 1 not found");return s}function Nr(){return({chainId:e})=>A.queryOptions({queryKey:ws.prices(e).queryKey,queryFn:()=>Z.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:K.SECOND})}function Cs(e){const s=Nr();return A.useQuery(s(e))}function na(){const e=oe(),s=Nr();return A.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>`,oa=encodeURIComponent(ra),wn=`data:image/svg+xml;utf8,${oa}`,fs=ke.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 aa(e){const{base:s,symbol:n,denom_units:r=[],display:o,logo_URIs:a,name:i,address:l,traces:c}=e,d=r.find(m=>m.denom===o)?.exponent??r.find(m=>m.denom===s)?.exponent??v.head(r)?.exponent??0,u=a?.png??"";return{denom:s,symbol:n,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function Sr(){const e=A.useQueryClient();return s=>{const n=s?.metadata?.assetlist;return A.queryOptions({queryKey:fs.list(n).queryKey,queryFn:async()=>n?Z.get(n).json():{assets:[]},select:({assets:r})=>{if(!s)return[];const o=r.map(aa);for(const a of o)e.setQueryData(fs.item(s.chainId,a.denom).queryKey,a);return o},staleTime:K.MINUTE})}}function Qt(e){const s=Sr(),{data:n}=A.useSuspenseQuery(s(e));return n}function ia(){const e=oe(),s=Sr();return A.useQueries({queries:e.map(n=>s(n))})}function Ue(e){const s=Qt(e),n=le(),r=Qt(n),o=Ar(e);return a=>{const i=s.find(c=>c.denom===a);if(i)return i;const l=r.find(c=>c.denom===o(a));return l?{...l,denom:a}:{denom:a,symbol:"",decimals:0,logoUrl:wn}}}function kr(e,s){const n=Ue(s),o=A.useQueryClient().getQueryData(fs.item(s.chainId,e).queryKey);return o||n(e)}function Ar(e){const s=le(),n=Qt(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):""}}function ca(e){return e.pagination?.next_key??null}async function $r(e,s,n){const r=Z.create(s),o=async(a,i)=>{const l=await r.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[n]??[],d=ca(l),u=[...a,...c];return d?o(u,d):u};return o([],null)}const Hn="usernames";function la({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:Hn,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:Hn,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 Is=ke.createQueryKeys("interwovenkit:account",{username:(e,s)=>[e,s],address:(e,s)=>[e,s],balances:(e,s)=>[e,s],txs:(e,s)=>[e,s]});function Tr(){const{restUrl:e}=le(),{usernamesModuleAddress:s}=ee();return la({restUrl:e,moduleAddress:s})}function Er(){const e=ae();return s=>A.queryOptions({queryKey:Is.balances(s.restUrl,e).queryKey,queryFn:()=>$r(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:s.restUrl},"balances"),staleTime:K.SECOND})}function Cn(e){const s=Er(),{data:n}=A.useSuspenseQuery(s(e));return n}function da(){const e=oe(),s=Er();return A.useQueries({queries:e.map(n=>s(n))})}function ua(e){const s=Cn(e),n=Qt(e),r=Ue(e),o=Ar(e),{data:a}=Cs(e),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>n.some(d=>d.denom===c);return v.sortWith([v.descend(({denom:c})=>o(c)==="uinit"),v.descend(({denom:c})=>i(c)),v.descend(({value:c})=>c),v.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>M(d).comparedTo(c)??0,v.descend(({symbol:c})=>c.toLowerCase())],s.filter(({amount:c})=>!M(c).isZero()).map(({amount:c,denom:d})=>{const u=r(d),m=a?.find(({id:_})=>_===u?.denom)?.price??0,h=M(c).times(m).div(M(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:m,value:h}}))}function ha(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:s}=un.PubKey.decode(e.value);return Ht.encodeSecp256k1Pubkey(s)}return js.decodeOptionalPubkey(e)}function ma({typeUrl:e,value:s}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:n,pubKey:r,accountNumber:o,sequence:a}=zo.BaseAccount.decode(s),i=ha(r);return{address:n,pubkey:i,accountNumber:Number(o),sequence:Number(a)}}return qe.accountFromAny({typeUrl:e,value:s})}function _a(e){return e.type==="initia/PubKeyEthSecp256k1"}const fa={...Ht.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function pa(e){if(_a(e)){const s=un.PubKey.fromPartial({key:W.fromBase64(e.value)});return Ko.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(un.PubKey.encode(s).finish())})}return js.encodePubkey(e)}function qr(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:fa.ethsecp256k1,value:W.toBase64(e)}}function ga(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:qr(e),signature:W.toBase64(s)}}const Ae="interwovenkit",U={PUBLIC_KEY:`${Ae}:public-key`,BRIDGE_SRC_CHAIN_ID:`${Ae}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${Ae}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${Ae}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${Ae}:bridge:dst-denom`,BRIDGE_QUANTITY:`${Ae}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${Ae}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${Ae}:bridge:route-type`,BRIDGE_HISTORY:`${Ae}:bridge:history`,OP_REMINDER:`${Ae}:op:reminder`},Ns=()=>{const e=ee();return new js.Registry([...Kt.protoRegistry,...e.protoTypes??[]])},Yt=()=>{const e=ee();return new qe.AminoTypes({...Kt.aminoConverters,...e.aminoConverters})};class xa{constructor(s,n,r){this.address=s,this.signMessage=n,this.layer1RestUrl=r}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=W.fromHex(n),W.fromHex(n);const r=await this.getPublicKeyFromRestApi();if(r)return this.cachedPublicKey=r,localStorage.setItem(s,W.toHex(r)),r;const o=await this.getPublicKey();return this.cachedPublicKey=o,localStorage.setItem(s,W.toHex(o)),o}async getPublicKeyFromRestApi(){try{const n=(await Z.create({prefixUrl:this.layer1RestUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return n?W.fromBase64(n):null}catch{return null}}async getPublicKey(){const s="Sign this message to identify your Initia account.",n=await this.signMessage(s),r=Ze.ethers.hashMessage(s),o=Ze.ethers.SigningKey.recoverPublicKey(r,n);return dn.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=ln.escapeCharacters(ln.sortedJsonStringify(n)),o=await this.signMessage(r),a=W.fromHex(o.replace("0x","")).subarray(0,-1),l=dn.Secp256k1Signature.fromFixedLength(a).toFixedLength(),c=ga(await this.getCachedPublicKey(),l);return{signed:n,signature:c}}}function In(){const e=Ns(),s=Yt(),n=$t(),r=Pr();return async function(o,a,i,l,c,d){if(!n)throw new Error("Signer not initialized");const u=await r(o),{accountNumber:m,...h}=await u.getSequence(a),_=h.sequence+(d?.incrementSequence??0),[g]=await n.getAccounts(),p=pa(qr(g.pubkey)),j=Lo.SignMode.SIGN_MODE_EIP_191,S=i.map(x=>s.toAmino(x)),N=ln.makeSignDoc(S,l,o,c,m,_),{signature:I,signed:b}=await n.signAmino(a,N),D={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:b.msgs.map(x=>s.fromAmino(x)),memo:c}},F=e.encode(D),C=Un.Int53.fromString(b.fee.gas).toNumber(),P=Un.Int53.fromString(b.sequence).toNumber(),y=js.makeAuthInfoBytes([{pubkey:p,sequence:P}],b.fee.amount,C,b.fee.granter,b.fee.payer,j);return Ge.TxRaw.fromPartial({bodyBytes:F,authInfoBytes:y,signatures:[W.fromBase64(I.signature)]})}}function $t(){const e=ae(),{signMessageAsync:s}=ve.useSignMessage(),n=le();return f.useMemo(()=>new xa(e,r=>s({message:r}),n.restUrl),[e,s,n.restUrl])}const zs=new Map,Ks=new Map;function Dr(){const e=Xe();return async s=>{if(zs.has(s))return zs.get(s);const{rpcUrl:n}=e(s),r=await Ln.Comet38Client.create(new Ln.HttpClient(n));return zs.set(s,r),r}}function Pr(){const e=Ns(),s=Yt(),n=$t(),r=ae(),o=Dr();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 qe.SigningStargateClient.createWithSigner(l,n,{registry:e,aminoTypes:s,accountParser:ma,broadcastPollIntervalMs:500});return Ks.set(i,c),c}}function Rr(){const{connector:e}=ve.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new Ze.BrowserProvider(await e.getProvider())}}const Br=f.createContext(null);function Ss(){return f.useContext(Br)}function Fr(){const{location:e}=Ss();return e}function ks(){const{path:e}=Fr();return e}function ft(){const{state:e={}}=Fr();return e}function ya(){const{history:e}=Ss();return e}function he(){const{navigate:e}=Ss();return e}function Mr(){const{reset:e}=Ss();return e}const Nn=({to:e,state:s,shouldReset:n,children:r,onClick:o,...a})=>{const i=he(),l=Mr(),c=d=>{d.preventDefault(),o?.(d),n?l(e,s):i(e,s)};return t.jsx("button",{type:"button",...a,onClick:c,children:r})},Or=({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 m=v.take(u,d);return c!==void 0?v.adjust(u-1,h=>({...h,state:c}),m):m})},[]),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})},Ur=f.createContext(null),As=()=>f.useContext(Ur);class Lr 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 ja=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Hs=new Map;function va(e){const s=e.match(ja);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 ba(e,s,n){const r=`${e}:${s}`;if(Hs.has(r))return Hs.get(r);try{const o=s==="0x1"?"0x1.json":`${e}/${s}.json`,a=`${n}/errors/${o}`,{errors:i={}}=await Z.get(a).json();return Hs.set(r,i),i}catch{return null}}function wa(e,s,n,r,o,a,i){return new Lr(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 Fe(e);const r=va(e.message);if(!r)return await Fe(e);const o=await ba(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 wa(c,e,r.moduleAddress,r.moduleName,r.errorCode,a,d)}const Ca="c33b940c24c17e95f7d9d525d508ac61";function Ia(){const{disableAnalytics:e}=ee();f.useEffect(()=>{e||bn.init(Ca,{autocapture:!1})},[e])}function Na(){const{connector:e}=ve.useAccount(),{defaultChainId:s,disableAnalytics:n}=ee();f.useEffect(()=>{const r=new yr.Identify;e?.name&&r.set("connector",e.name),s&&r.set("defaultChainId",s),bn.identify(r)},[s,e?.name,n])}function $s(){const e=ks();return f.useCallback((n,r)=>{bn.track(n,{path:e,...r})},[e])}const Sa=G.atom(!1);function Tt(){const e=Mr(),[s,n]=G.useAtom(Sa),r=$s();return{isDrawerOpen:s,openDrawer:(i,l)=>{i&&e(i,l),n(!0),r("Widget Opened")},closeDrawer:()=>{n(!1),r("Widget Closed")}}}function zr(){const e=he(),{closeDrawer:s}=Tt(),{disconnect:n}=ve.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)}}const Kr="approve",Ts=G.atom(),Hr=G.atom(null);function Wr(){const e=G.useAtomValue(Ts);if(!e)throw new Error("Tx request not found");return e}function Sn(){const e=he(),s=ae(),{defaultChainId:n,registryUrl:r}=ee(),o=Xe(),{openDrawer:a,closeDrawer:i}=Tt(),{openModal:l,closeModal:c}=As(),d=G.useSetAtom(Ts),u=G.useSetAtom(Hr),m=Dr(),h=Pr(),_=$t(),g=Ns(),p=async({messages:C,memo:P,chainId:y=n})=>{try{return await(await h(y)).simulate(s,C,P)}catch(x){throw await Ct(x,o(y),r)}},j=async({messages:C,memo:P,chainId:y=n})=>{const x=await m(y),$=qe.QueryClient.withExtensions(x,qe.setupTxExtension),T=C.map(ie=>g.encodeAsAny(ie)),[R]=await _.getAccounts(),L=Ht.encodeSecp256k1Pubkey(R.pubkey),q=await h(y),{sequence:H}=await q.getSequence(s);return $.tx.simulate(T,P,L,H)},S=async({txRequest:C,broadcaster:P})=>{const x={...{memo:"",chainId:n,gas:C.gas||await p(C),gasAdjustment:Wt,gasPrices:null,spendCoins:[],internal:!1},...C};return new Promise(($,T)=>{d({txRequest:x,resolve:async L=>{try{const q=await h(x.chainId),H=await P(q,Ge.TxRaw.encode(L).finish());$(H),typeof x.internal=="string"&&e(x.internal)}catch(q){T(await Ct(q,o(x.chainId),r))}finally{R()}},reject:L=>{T(L),R()}}),x.internal?l({path:"/tx"}):a("/tx");const R=()=>{if(!x.internal){e("/blank"),i();return}c()}})},N=async C=>{const P=C.chainId??n;try{const y=await S({txRequest:C,broadcaster:async(x,$)=>await x.broadcastTxSync($)});return C.internal&&typeof C.internal!="number"&&(u({txHash:y,chainId:P,status:"loading"}),F({txHash:y,chainId:C.chainId}).then(x=>{u({status:x.code===0?"success":"error",chainId:P,txHash:y})}).catch(()=>{u({status:"error",chainId:P,txHash:y})})),y}catch(y){throw C.internal&&typeof C.internal!="number"&&u({status:"error",chainId:P,error:y}),y}},I=(C,P=30*1e3,y=.5*1e3)=>S({txRequest:C,broadcaster:async(x,$)=>{const T=await x.broadcastTx($,P,y);if(T.code!==0)throw new Error(T.rawLog);return T}}),b=In(),E=async C=>{const P=C.chainId??n;try{const{messages:y,memo:x="",fee:$}=C,T=await h(P),R=await b(P,s,y,$,x);return await T.broadcastTxSync(Ge.TxRaw.encode(R).finish())}catch(y){throw await Ct(y,o(P),r)}},D=async(C,P=30*1e3,y=.5*1e3)=>{const x=C.chainId??n;try{const{messages:$,memo:T="",fee:R}=C,L=await h(x),q=await b(x,s,$,R,T),H=await L.broadcastTx(Ge.TxRaw.encode(q).finish(),P,y);if(H.code!==0)throw new Error(H.rawLog);return H}catch($){throw await Ct($,o(x),r)}},F=async({chainId:C=n,...P})=>{try{const y=await h(C);return await Qr({...P,client:y})}catch(y){throw await Ct(y,o(C),r)}};return{estimateGas:p,simulateTx:j,requestTxSync:N,requestTxBlock:I,submitTxSync:E,submitTxBlock:D,waitForTxConfirmation:F}}async function Qr({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))}}const ka="INIT",Aa="Initia";function kn(e){return e.assets.reduce((s,{value:n})=>s+(n??0),0)}function $a(e){return e.assets.reduce((s,{quantity:n})=>s.plus(n),M(0)).toString()}function Ta(e,s){return{symbol:s?.symbol??e,logoUrl:s?.logoUrl??wn}}function Wn(e){return v.pick(["chainId","name","logoUrl"],e)}function Ea(e){return v.sortWith([v.descend(({symbol:s})=>s===ka),v.descend(kn),v.descend(({assets:s})=>s.length),v.ascend(({symbol:s})=>s)])(e)}function qa(e){return v.sortWith([v.descend(({value:s})=>s??0),v.descend(({quantity:s})=>Number(s)),v.ascend(({chain:s})=>s.name)])(e)}function Da(e){return v.sortWith([v.descend(({chain:s})=>s.name===Aa),v.ascend(({chain:s})=>s.name),v.ascend(({denom:s})=>s)])(e)}function Pa(e,s){return v.sortWith([v.descend(({chainId:n})=>n===s),v.descend(v.prop("value"))])(e)}function Ra(e,s,n,r,o){const a={};for(const u of e){const m=u.chainId,h=s[m]??[],_=n[m],g=r[m],p=[];for(const{amount:j,denom:S}of h){if(!M(j).gt(0))continue;const N=_?.find(F=>F.denom===S),I=g?.find(F=>F.id===S)?.price,b=N?.decimals??0,E=w.fromBaseUnit(j,{decimals:b}),D=I?M(E).times(I).toNumber():void 0;p.push({...Ta(S,N),amount:j,denom:S,decimals:b,quantity:E,price:I,value:D,address:N?.address,unlisted:!N,chain:Wn(u)})}a[m]=p}const i=new Map;for(const[u,m]of Object.entries(a)){if(m.length===0)continue;const h=e.find(g=>g.chainId===u);if(!h)continue;const _=m.reduce((g,{value:p})=>g+(p??0),0);i.set(u,{...Wn(h),value:_})}const l=new Map;for(const u of Object.values(a))for(const m of u)if(!m.unlisted){const{symbol:h}=m,_=l.get(h)??[];l.set(h,[..._,m])}const c=[];for(const[u,m]of l){const h=v.head(m);if(!h)continue;const _=qa(m);c.push({symbol:u,logoUrl:h.logoUrl,assets:_})}const d=[];for(const u of Object.values(a))for(const m of u)m.unlisted&&d.push(m);return{chainsByValue:Pa(Array.from(i.values()),o),assetGroups:Ea(c),unlistedAssets:Da(d),totalValue:c.reduce((u,m)=>u+kn(m),0)}}function An(){const{defaultChainId:e}=ee(),s=oe(),n=da(),r=ia(),o=na(),a=s.map(h=>h.chainId),i=v.zipObj(a,n.map(v.prop("data"))),l=v.zipObj(a,r.map(v.prop("data"))),c=v.zipObj(a,o.map(v.prop("data"))),d=Ra(s,i,l,c,e),u=[n,r,o].flat().some(({isLoading:h})=>h);return{...d,isLoading:u,refetch:()=>{n.forEach(({refetch:h})=>h()),r.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h())}}}function ae(){const e=Es();return e?w.InitiaAddress(e).bech32:""}function Es(){const{address:e}=ve.useAccount();return e?w.InitiaAddress(e).hex:""}function Et(){const e=Gt(),s=ae(),n=Es();return e.metadata?.minitia?.type==="minievm"?n:s}function Vr(){const e=Et(),s=Tr();return A.useQuery({queryKey:Is.username(s.restUrl,e).queryKey,queryFn:()=>s.getUsername(e),enabled:!!e,staleTime:K.MINUTE})}function fe(){const e=Et(),s=ae(),n=Es(),{data:r}=Vr(),o=$t(),a=zr(),{isDrawerOpen:i,openDrawer:l}=Tt(),c=()=>{l("/")},d=()=>{l("/connect")},u=_=>{l("/bridge",_)},m=Sn();return{address:e,initiaAddress:s,hexAddress:n,username:r,offlineSigner:o,isConnected:!!e,isOpen:i,openConnect:d,openWallet:c,openBridge:u,disconnect:a,...m}}const Ba="_status_tn9m1_1",Fa="_error_tn9m1_9",Qn={status:Ba,error:Fa},X=({error:e,children:s})=>t.jsx("p",{className:B(Qn.status,{[Qn.error]:e}),children:s}),pe=({errorBoundaryProps:e={fallbackRender:({error:r})=>t.jsx(X,{error:!0,children:r.message})},suspenseFallback:s=t.jsx(X,{children:"Loading..."}),children:n})=>t.jsx(jr.ErrorBoundary,{...e,children:t.jsx(f.Suspense,{fallback:s,children:n})});function Ma(){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=>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 De=ke.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}=ee();return f.useMemo(()=>Z.create({prefixUrl:e}),[e])}function kt(e){const s=Le(),n=A.useQueryClient(),{data:r}=A.useSuspenseQuery({queryKey:De.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(De.asset(e,i.denom).queryKey,i);return a.toSorted(v.descend(i=>i.symbol==="INIT"))},staleTime:K.MINUTE});return r}function Gr(e){const s=kt(e);return n=>{const r=s.find(o=>o.denom===n);if(!r)throw new Error(`Asset not found: ${n}`);return r}}function Me(e,s){return Gr(s)(e)}function Yr(){const e=oe();return s=>e.some(n=>n.chain_id===s)}function Zt(){const e=Yr();return s=>e(s.chain_id)?"initia":s.chain_type}function Vt(e){return Zt()(e)}function $n(){const e=Le(),{data:s}=A.useSuspenseQuery({queryKey:De.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:n})=>v.sortWith([v.descend(({chain_name:r})=>r==="initia"),v.ascend(({pretty_name:r})=>r)],n),staleTime:K.MINUTE});return s}function pt(){const e=$n(),s=Ir();return n=>{const r=e.find(a=>a.chain_id===n);if(r)return r;const o=s.find(a=>a.chain_id===n);if(!o)throw new Error(`Chain not found: ${n}`);return{chain_id:o.chain_id,chain_name:o.name,pretty_name:o.pretty_name,logo_uri:o.logo,chain_type:"cosmos",rpc:"",rest:""}}}function Pe(e){return pt()(e)}const Oa=()=>(Ia(),Na(),null),Ua="_loader_4gdsk_1",La={loader:Ua},gt=({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:La.loader,style:r})},za="_button_1n7c4_1",Ka="_outline_1n7c4_25",Ha="_sm_1n7c4_43",Wa="_full_1n7c4_49",Qa="_small_1n7c4_53",Va="_unpadded_1n7c4_83",dt={button:za,outline:Ka,sm:Ha,full:Wa,small:Qa,unpadded:Va},Zr=e=>{const{sm:s,fullWidth:n,loading:r,className:o,children:a,disabled:i,...l}=e;return t.jsx("button",{...l,className:B(dt.button,{[dt.sm]:s,[dt.full]:n},o),disabled:!!r||i,children:r?t.jsxs(t.Fragment,{children:[t.jsx(gt,{color:"currentColor",size:16}),typeof r=="string"&&t.jsx("span",{className:dt.loading,children:r})]}):a})},Ga=({className:e,...s})=>t.jsx(Zr,{...s,className:B(dt.outline,e)}),Ya=({className:e,unpadded:s,...n})=>t.jsx("button",{...n,className:B(dt.small,{[dt.unpadded]:s},e)}),V={White:Zr,Outline:Ga,Small:Ya},Za="_footer_xif7g_1",Ja="_actions_xif7g_10",Vn={footer:Za,actions:Ja},re=({extra:e,className:s,children:n})=>t.jsxs("footer",{className:B(Vn.footer,s),children:[e,t.jsx("div",{className:Vn.actions,children:n})]}),Xa="_scrollable_abvhw_1",ei={scrollable:Xa},ze=({className:e,children:s,ref:n})=>t.jsx("div",{ref:n,className:B(ei.scrollable,e),children:s});function qs(){return Ne.useMediaQuery("(max-width: 576px)")}const hn="interwoven-kit";function Jr(){const e=document.querySelector(hn)||document.body.appendChild(document.createElement(hn));return e.shadowRoot||e.attachShadow({mode:"open"})}function ti(){const{theme:e,container:s}=ee();return f.useEffect(()=>{document.querySelector(hn)?.setAttribute("data-theme",e)},[e]),s??Jr()}function si(e){const s=Jr(),n=document.createElement("style");n.textContent=e,s.appendChild(n)}const Tn=f.createContext(null);function mt(){const{container:e}=f.useContext(Tn);return e}function Xr(e){const s=mt();return s?getComputedStyle(s).getPropertyValue(e):""}function ni(){return Ne.useScrollLock(),null}function ri(e){return/^[A-F0-9]{64}$/i.test(e)}function oi(e,s){const{txHash:n,accountAddress:r,pathSuffix:o}=s;if(n)return ri(n)?v.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,n):void 0;if(r){if(!w.InitiaAddress.validate(r))return;const i=v.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,r);return i&&o?i+o:i}}function ai(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 ii="_link_guafb_1",Gn={link:ii},Ds=({chainId:e,txHash:s,accountAddress:n,pathSuffix:r,...o})=>{const{showIcon:a,className:i,children:l,onClick:c,...d}=o,u=Oe(e),m=oi(u,{txHash:s,accountAddress:n,pathSuffix:r}),h=s?w.truncate(s):n?w.truncate(n):"",_=l??h;return m?t.jsxs("a",{...d,href:Ho(ai(m)),className:B(Gn.link,i),onClick:c,target:"_blank",children:[_,a&&t.jsx(k.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:B(Gn.link,i),children:_})},eo=f.createContext(null),En=()=>f.useContext(eo),ci=()=>{const[e,s]=G.useAtom(Hr),{showNotification:n,updateNotification:r,hideNotification:o}=En();return f.useEffect(()=>{if(!e)return;const{status:a,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(Ds,{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},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})},li="_placeholder_10r3x_1",di="_logo_10r3x_5",Yn={placeholder:li,logo:di},Q=({src:e,alt:s,placeholder:n,classNames:r,style:o,logo:a,...i})=>{const[l,c]=f.useState(void 0),{width:d,height:u}=i,m=n??t.jsx("div",{className:B(Yn.placeholder,r?.placeholder),style:{width:d,height:u,...o}});return!e||l===e?m:t.jsx("img",{...i,className:B(i.className,{[Yn.logo]:a}),style:{width:d,height:u,...o},src:e,alt:s,loading:"lazy",onError:()=>c(e)})},to=f.createContext(!1),ui="_overlay_2lgi8_1",hi="_fullscreen_2lgi8_15",mi="_content_2lgi8_19",_i="_header_2lgi8_54",fi="_title_2lgi8_63",pi="_close_2lgi8_68",ot={overlay:ui,fullscreen:hi,content:mi,header:_i,title:fi,close:pi},so=({title:e,children:s,trigger:n,className:r,open:o,onOpenChange:a})=>{const i=mt(),l=f.useContext(to);return i?t.jsxs(Ie.Dialog.Root,{open:o,onOpenChange:a,modal:!1,children:[n&&t.jsx(Ie.Dialog.Trigger,{className:r,children:n}),t.jsxs(Ie.Dialog.Portal,{container:i,children:[t.jsx(Ie.Dialog.Backdrop,{className:B(ot.overlay,{[ot.fullscreen]:l}),onClick:()=>a(!1),forceRender:!0}),t.jsxs(Ie.Dialog.Popup,{className:B(ot.content,{[ot.fullscreen]:l}),children:[e&&t.jsxs("header",{className:ot.header,children:[t.jsx(Ie.Dialog.Title,{className:ot.title,children:e}),t.jsx(Ie.Dialog.Close,{className:ot.close,children:t.jsx(k.IconClose,{size:20})})]}),s]})]})]}):null},_t=({title:e,content:s,children:n,className:r})=>{const[o,a]=f.useState(!1),i=()=>a(!1);return t.jsx(so,{title:e,trigger:n,className:r,open:o,onOpenChange:a,children:s(i)})},gi="_root_19tvg_1",xi="_address_19tvg_9",yi="_copy_19tvg_19",ji="_labelWrapper_19tvg_33",vi="_labelCopy_19tvg_43",bi="_labelCopied_19tvg_47",wi="_copied_19tvg_55",Ci="_derived_19tvg_65",Ii="_derivedLabel_19tvg_78",Ni="_derivedAddress_19tvg_82",Si="_hexAddress_19tvg_88",ki="_derivedCopy_19tvg_93",ue={root:gi,address:xi,copy:yi,labelWrapper:ji,labelCopy:vi,labelCopied:bi,copied:wi,derived:Ci,derivedLabel:Ii,derivedAddress:Ni,hexAddress:Si,derivedCopy:ki},Ai=()=>{const e=f.useRef(null),s=f.useRef(null),{initiaAddress:n,hexAddress:r}=fe(),o=Xr("--gray-0");return f.useEffect(()=>{e.current&&(s.current?s.current.update({data:n}):(s.current=new Wo({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:ue.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:ue.address,children:n}),t.jsx(ps,{value:n,children:({copy:a,copied:i})=>t.jsxs("button",{className:B(ue.copy,{[ue.copied]:i}),onClick:a,children:[t.jsx(k.IconCopy,{size:12}),t.jsxs("div",{className:ue.labelWrapper,children:[t.jsx("span",{className:ue.labelCopy,children:"Copy address"}),t.jsx("span",{className:ue.labelCopied,children:"Copied!"})]})]})}),t.jsx(ps,{value:r,children:({copy:a,copied:i})=>t.jsxs("button",{className:B(ue.derived,{[ue.copied]:i}),onClick:a,children:[t.jsx("span",{className:ue.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:ue.derivedAddress,children:[t.jsx("span",{className:ue.hexAddress,children:w.truncate(r)}),t.jsx(k.IconCopy,{size:12,className:ue.derivedCopy}),i&&t.jsx("span",{className:ue.copiedText,children:"Copied!"})]})]})})]})},$i="_header_1cvtq_1",Ti="_account_1cvtq_16",Ei="_name_1cvtq_27",qi="_address_1cvtq_31",Di="_icon_1cvtq_35",Pi="_copied_1cvtq_42",Ri="_button_1cvtq_57",Bi="_qr_1cvtq_68",Fi="_disconnect_1cvtq_72",Mi="_label_1cvtq_82",Oi="_expanded_1cvtq_90",ge={header:$i,account:Ti,name:Ei,address:qi,icon:Di,copied:Pi,button:Ri,qr:Bi,disconnect:Fi,label:Mi,expanded:Oi},Ui=()=>{const e=Gt(),{connector:s}=ve.useAccount(),n=zr(),{address:r,username:o}=fe(),a=o??r,[i,l]=f.useState(!1),c=f.useRef(null),d=Je.useSpring({width:i?140:52,config:{tension:500,friction:30,clamp:!0}}),u=()=>{i?n():l(!0)},m=()=>{i&&(c.current=setTimeout(()=>{l(!1)},500))},h=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return f.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),s?t.jsxs("header",{className:ge.header,children:[t.jsx(ps,{value:r,children:({copy:_,copied:g})=>t.jsxs("button",{className:B(ge.account,{[ge.copied]:g}),onClick:_,children:[t.jsx(Q,{src:s.icon,width:18,height:18}),t.jsx("div",{className:ge.address,children:w.truncate(r)}),t.jsx("div",{className:ge.name,children:w.truncate(a)}),t.jsx(k.IconCopy,{className:ge.icon,size:12}),g?"Copied!":""]})}),e.metadata?.is_l1&&t.jsx(_t,{title:"Initia address",content:()=>t.jsx(Ai,{}),className:B(ge.button,ge.qr),children:t.jsx(k.IconQrCode,{size:16})}),t.jsxs(Je.animated.button,{className:B(ge.button,ge.disconnect,{[ge.expanded]:i}),style:d,onClick:u,onMouseLeave:m,onMouseEnter:h,children:[t.jsx(k.IconSignOut,{size:16}),t.jsx("span",{className:ge.label,children:"Disconnect"})]})]}):null},Li="_overlay_1dhd9_1",zi="_content_1dhd9_27",Ki="_inner_1dhd9_58",Ws={overlay:Li,content:zi,inner:Ki},Hi=({children:e})=>{const{isDrawerOpen:s,closeDrawer:n}=Tt(),{setContainer:r}=f.useContext(Tn),o=qs(),a=ti(),i=G.useAtomValue(Ts),l=A.useIsMutating({mutationKey:[Kr]}),c=()=>{const _=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";n(),i?.reject(new Error(_))},d=ks(),u=he(),m=A.useQueryClient(),h={fallbackRender:({error:_,resetErrorBoundary:g})=>{const p=()=>{d==="/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)),u("/"),m.clear(),g()};return t.jsxs(ze,{children:[t.jsx(X,{error:!0,children:_.message}),t.jsx(re,{children:t.jsx(V.White,{onClick:p,children:"Retry"})})]})}};return t.jsx(Ie.Dialog.Root,{open:s,onOpenChange:_=>!_&&c(),modal:!1,children:t.jsxs(Ie.Dialog.Portal,{container:a,children:[o&&t.jsx(Ie.Dialog.Backdrop,{className:Ws.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(Ie.Dialog.Popup,{className:Ws.content,children:t.jsxs("div",{className:B(Ws.inner,"body"),ref:r,children:[o&&t.jsx(ni,{}),t.jsx(ci,{}),t.jsx(Ui,{}),t.jsx(pe,{errorBoundaryProps:h,children:e})]})})]})})},mn=({children:e})=>{const s=f.useRef(null),[n,r]=f.useState(0),o=Je.useSpring({height:n,config:{tension:500,friction:30,clamp:!0}});return f.useEffect(()=>{if(s.current){const{height:a}=s.current.getBoundingClientRect();r(a)}},[e]),e?t.jsx(Je.animated.div,{style:{overflow:"hidden",...o},children:t.jsx("div",{ref:s,children:e})}):null},Wi="_help_7m3jv_1",Qi="_icon_7m3jv_10",Vi="_info_7m3jv_17",Gi="_warning_7m3jv_21",Yi="_error_7m3jv_25",Zi="_success_7m3jv_31",Qs={help:Wi,icon:Qi,info:Vi,warning:Gi,error:Yi,success:Zi},It=({level:e,className:s,mt:n=8,children:r})=>{if(!r)return null;const o=()=>{switch(e){case"loading":return t.jsx(gt,{size:12});case"info":return t.jsx(k.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(k.IconWarningFilled,{size:12});default:return t.jsx(k.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:B(Qs.help,e&&Qs[e],s),style:{marginTop:n},children:[t.jsx("div",{className:Qs.icon,children:o()}),r]})},Ji="_stack_14kq8_1",Xi="_help_14kq8_6",ec="_info_14kq8_14",tc="_warning_14kq8_19",sc="_error_14kq8_24",nc="_success_14kq8_29",_n={stack:Ji,help:Xi,info:ec,warning:tc,error:sc,success:nc},rc=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(mn,{children:t.jsx("div",{className:_n.stack,children:e})}),ne=e=>t.jsx(It,{...e,className:B(_n.help,_n[e.level]),mt:0});ne.Stack=rc;const oc="_root_hypwm_1",ac="_item_hypwm_10",ic="_chevron_hypwm_14",cc="_trigger_hypwm_19",lc="_content_hypwm_39",Rt={root:oc,item:ac,chevron:ic,trigger:cc,content:lc};function dc(e){const{list:s,getKey:n,renderHeader:r,renderContent:o,footer:a,...i}=e;return t.jsxs(Y.Accordion.Root,{className:Rt.root,type:"multiple",...i,children:[s.map((l,c)=>t.jsxs(Y.Accordion.Item,{className:Rt.item,value:n?.(l)??String(c),children:[t.jsx(Y.Accordion.Header,{children:t.jsxs(Y.Accordion.Trigger,{className:Rt.trigger,children:[r(l),t.jsx(k.IconChevronDown,{className:Rt.chevron,size:16})]})}),t.jsx(Y.Accordion.Content,{className:Rt.content,children:o(l)})]},n?.(l)??c)),a]})}const uc=10;function no(){const e=ae();return(s,n)=>A.queryOptions({queryKey:Is.txs(s.indexerUrl,e).queryKey,queryFn:async()=>{if(!n.enabled)return[];const r={"pagination.reverse":!0,"pagination.limit":uc},{txs:o}=await Z.create({prefixUrl:s.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:r}).json();return o},staleTime:K.SECOND})}function hc(e,s){const n=no();return A.useSuspenseQuery(n(e,s))}function mc(e,s){const n=e.flatMap((r,o)=>(s[o]??[]).map(i=>({...i,chain:r})));return v.sortWith([v.descend(r=>new Date(r.timestamp).getTime())])(n)}const _c=()=>{const e=oe(),s=no(),n=A.useQueries({queries:e.map(i=>s(i,{enabled:!0}))}),r=n.map(v.prop("data")),o=mc(e,r),a=n.some(i=>i.isLoading);return{activities:o,isLoading:a}};function ro(e){const{data:s}=A.useSuspenseQuery({queryKey:ws.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:r}=await Z.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return r.toSorted(v.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const i=o==="uinit"?1:br;return{amount:M(a).times(i).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:r})=>{if(v.isNil(r))throw new Error(`${n} has no price`);return{amount:String(r),denom:n}})},staleTime:K.SECOND});return s}function oo(e){const s=ae(),{data:n}=hc(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,Ze.computeAddress(`0x${W.toHex(dn.Secp256k1.uncompressPubkey(W.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??r}catch{return r}}const fc="_value_9u3br_1",pc="_trigger_9u3br_7",gc="_icon_9u3br_23",xc="_content_9u3br_32",yc="_item_9u3br_40",Bt={value:fc,trigger:pc,icon:gc,content:xc,item:yc},jc=({options:e,value:s,onChange:n})=>{const r=mt(),{txRequest:o}=Wr(),a=Oe(o.chainId),i=Ue(a),l=(p,j)=>{if(w.formatAmount(p,{decimals:j})==="0.000000")return 8},c=({amount:[{amount:p,denom:j}]})=>{if(M(p).isZero())return"0";const{symbol:S,decimals:N}=i(j),I=l(p,N);return`${w.formatAmount(p,{decimals:N,dp:I})} ${S}`};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,symbol:_}=i(m),g=l(u,h);return t.jsxs(Re.Select.Root,{value:s,onValueChange:n,modal:!1,children:[t.jsxs("div",{className:Bt.value,children:[t.jsx("span",{className:"monospace",children:w.formatAmount(u,{decimals:h,dp:g})}),t.jsxs(Re.Select.Trigger,{className:Bt.trigger,children:[t.jsx(Re.Select.Value,{children:_}),t.jsx(Re.Select.Icon,{className:Bt.icon,children:t.jsx(k.IconChevronDown,{size:16})})]})]}),t.jsx(Re.Select.Portal,{container:r,children:t.jsx(Re.Select.Positioner,{className:Bt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(Re.Select.Popup,{children:e.map(p=>{const[{denom:j}]=p.amount;return t.jsx(Re.Select.Item,{className:Bt.item,value:j,children:t.jsx(Re.Select.ItemText,{children:c(p)})},j)})})})})]})},vc="_root_7u427_1",bc="_trigger_7u427_5",wc="_chevron_7u427_13",Cc="_panel_7u427_27",Ic="_details_7u427_38",Nc="_row_7u427_47",bt={root:vc,trigger:bc,chevron:wc,panel:Cc,details:Ic,row:Nc},Sc=({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(k.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 gs(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(gs).join(",")}]`:JSON.stringify(e,(s,n)=>typeof n=="bigint"?n.toString():n);default:return"unknown"}}const kc="_container_1xzyq_1",Ac="_toggle_1xzyq_5",$c="_list_1xzyq_11",Tc="_arg_1xzyq_16",Ec="_type_1xzyq_21",Ft={container:kc,toggle:Ac,list:$c,arg:Tc,type:Ec},qc=ke.createQueryKeys("interwovenkit:move",{abi:(e,s,n,r)=>[e,s,n,r]}),Dc=({type:e,arg:s})=>gs(w.resolveBcsType(e).parse(s)),Pc=({msg:e,chainId:s,fallback:n})=>{const[r,o]=Ne.useToggle(!1),{restUrl:a}=Oe(s),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=A.useQuery({queryKey:qc.abi(a,i,l,c).queryKey,queryFn:async()=>{const h=await Z.create({prefixUrl:a}).get(`initia/move/v1/accounts/${i}/modules/${l}`).json(),g=JSON.parse(h.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:K.INFINITY});if(!u)return n;const m=(h,_)=>{const g=u[_];return t.jsxs("div",{className:Ft.arg,children:[t.jsx("div",{className:Ft.type,children:g}),t.jsx(jr.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(Dc,{type:g,arg:h})})]},_)};return t.jsxs("div",{className:Ft.container,children:[t.jsx(V.Small,{className:Ft.toggle,onClick:o,disabled:!u,children:r?"Encode":"Decode"}),r?t.jsx("div",{className:Ft.list,children:d.map(m)}):n]})},Rc="_list_r67rl_1",Bc="_key_r67rl_8",Fc="_value_r67rl_13",Vs={list:Rc,key:Bc,value:Fc},Mc=({message:e,chainId:s})=>{const{typeUrl:n,value:r}=e;return t.jsx("div",{className:Vs.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{children:[t.jsx("div",{className:Vs.key,children:o}),t.jsx("div",{className:Vs.value,children:n==="/initia.move.v1.MsgExecute"&&o==="args"?t.jsx(Pc,{msg:r,chainId:s,fallback:gs(a)}):gs(a)})]},o))})},Oc="_item_1n572_1",Uc="_title_1n572_10",Lc="_content_1n572_14",Gs={item:Oc,title:Uc,content:Lc},Ys=({title:e,content:s})=>t.jsxs("div",{className:Gs.item,children:[t.jsx("div",{className:Gs.title,children:e}),t.jsx("div",{className:Gs.content,children:s})]});function Se(e){if(e&&M(e).gt(0)&&M(e).lt(.01))return"<$0.01";const s=w.formatNumber(e,{dp:2});return s?`$${s}`:""}function ao(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 io(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 h=n[u]||BigInt(0);n[u]=h-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 h=n[u]||BigInt(0);n[u]=h+BigInt(d)}}}return Object.entries(n).filter(([,r])=>r!==BigInt(0)).map(([r,o])=>({amount:o.toString(),metadata:r}))}const co=({metadata:e,chain:s,children:n})=>{const{restUrl:r}=s,{data:o}=A.useSuspenseQuery({queryKey:fs.denom(r,e).queryKey,queryFn:()=>Z.create({prefixUrl:r}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:a})=>a,staleTime:K.INFINITY});return n(o)},zc="_root_jioyr_1",Kc="_title_jioyr_7",Hc="_changes_jioyr_13",Wc="_change_jioyr_13",Qc="_amount_jioyr_34",Vc="_text_jioyr_40",Gc="_value_jioyr_47",ut={root:zc,title:Kc,changes:Hc,change:Wc,amount:Qc,text:Vc,value:Gc},lo=({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:ut.change,children:[t.jsxs("div",{className:ut.amount,children:[t.jsx(Q,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:ut.text,children:[l," ",o||r]})]}),c&&t.jsx("div",{className:ut.value,children:Se(c)})]})},Yc=({changes:e,chain:s})=>{const n=Ue(s),{data:r}=Cs(s);return e.map(({amount:o,denom:a},i)=>{const l=n(a),c=r?.find(({id:d})=>d===a)?.price;return t.jsx(lo,{amount:o,asset:l,price:c},i)})},Zc=({changes:e,chain:s})=>{const n=Ue(s),{data:r}=Cs(s);return e.map(({amount:o,metadata:a},i)=>t.jsx(co,{metadata:a,chain:s,children:l=>{const c=r?.find(({id:d})=>d===l)?.price;return t.jsx(lo,{amount:o,asset:n(l),price:c})}},i))};function Jc(e,s){return typeof s=="bigint"?s.toString():s}const Xc=ke.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Jc)]}),el=({messages:e,memo:s,chainId:n})=>{const{initiaAddress:r,hexAddress:o}=fe(),a=Oe(n),{simulateTx:i}=Sn(),{data:l}=A.useSuspenseQuery({queryKey:Xc.simulate({messages:e,memo:s,chainId:n}).queryKey,queryFn:()=>i({messages:e,memo:s,chainId:n}),staleTime:K.SECOND}),c=h=>t.jsxs("div",{className:ut.root,children:[t.jsx("h2",{className:ut.title,children:"Estimated changes"}),t.jsx("div",{className:ut.changes,children:h})]});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 h=io(d,o),[_]=Zn(h);return _.length===0?null:c(t.jsx(Zc,{changes:_,chain:a}))}const u=ao(d,r),[m]=Zn(u);return m.length===0?null:c(t.jsx(Yc,{changes:m,chain:a}))};function Zn(e){return v.partition(s=>new M(s.amount).isNegative(),e)}const tl="_title_kspdu_1",sl="_meta_kspdu_7",nl="_footer_kspdu_14",Zs={title:tl,meta:sl,footer:nl},uo=()=>{const{txRequest:e,resolve:s,reject:n}=Wr(),{messages:r,memo:o,chainId:a,gas:i,gasAdjustment:l,spendCoins:c}=e,d=ae(),u=$t(),m=In(),h=Oe(a),_=Cn(h),g=ro(h),p=oo(h),j=Ue(h),S=(e.gasPrices??g).map(({amount:x,denom:$})=>qe.calculateFee(Math.ceil(i*l),qe.GasPrice.fromString(x+$))),N=S.map(x=>x.amount[0]),I=x=>{const $=_.find(O=>O.denom===x)?.amount??"0",T=N.find(O=>O.denom===x)?.amount??"0",R=c.filter(O=>O.denom===x).reduce((O,be)=>M(O).plus(be.amount),M("0")),L=M(T).plus(R),q=M($).gte(L),{symbol:H,decimals:ie}=j(x);return{symbol:H,decimals:ie,spend:R.gt(0)?R.toFixed():null,fee:T,total:L.toFixed(),balance:$,isSufficient:q}},b=()=>{if(p&&I(p).isSufficient)return p;for(const{denom:x}of N)if(I(x).isSufficient)return x;return N[0]?.denom},[E,D]=f.useState(b),{mutate:F,isPending:C}=A.useMutation({mutationKey:[Kr],mutationFn:async()=>{const x=S.find(T=>T.amount[0].denom===E);if(!x)throw new Error("Fee not found");if(!u)throw new Error("Signer not initialized");const $=await m(a,d,r,x,o);await s($)},onError:async x=>{n(x)}}),P=I(E),y=!P.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(ze,{children:[t.jsx("h1",{className:Zs.title,children:"Confirm tx"}),t.jsxs("div",{className:Zs.meta,children:[t.jsx(Ys,{title:"Chain",content:a}),t.jsx(Ys,{title:"Tx fee",content:t.jsx(jc,{options:S,value:E,onChange:D})}),o&&t.jsx(Ys,{title:"Memo",content:o}),y&&t.jsx(ne,{level:"error",children:t.jsx(Sc,{...P})})]}),t.jsx(el,{messages:r,memo:o,chainId:a}),t.jsx(dc,{list:r,renderHeader:({typeUrl:x})=>vs.sentenceCase(x.split(".").pop().replace(/^Msg/,"")),renderContent:x=>t.jsx(Mc,{message:x,chainId:a})})]}),t.jsxs(re,{className:Zs.footer,children:[t.jsx(V.Outline,{onClick:()=>n(new Error("User rejected")),disabled:C,children:"Reject"}),t.jsx(V.White,{onClick:()=>F(),disabled:y,loading:C,children:"Approve"})]})]})},rl=({children:e})=>{const[{title:s,content:n,path:r},o]=f.useState({}),[a,i]=f.useState(!1),l=G.useAtomValue(Ts),c=f.useCallback(m=>{o(m),i(!0)},[]),d=f.useCallback(()=>{o({}),i(!1)},[]),u=f.useCallback(m=>{m||(l?.reject(new Error("User rejected")),o({})),i(m)},[l]);return t.jsxs(Ur.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(so,{title:s,open:a,onOpenChange:u,children:t.jsx(pe,{children:r==="/tx"?t.jsx(uo,{}):n})})]})},ol="_container_1zg8z_1",al="_toast_1zg8z_10",il="_info_1zg8z_23",cl="_success_1zg8z_27",ll="_error_1zg8z_31",dl="_icon_1zg8z_36",ul="_content_1zg8z_43",hl="_title_1zg8z_46",ml="_description_1zg8z_51",_l="_close_1zg8z_72",Qe={container:ol,toast:al,info:il,success:cl,error:ll,icon:dl,content:ul,title:hl,description:ml,close:_l},fl=({notification:e,onClose:s,...n})=>{const r=Je.useTransition(e,{keys:a=>a?.id||"empty",from:{transform:"translateY(-52px)",opacity:0},enter:{transform:"translateY(0px)",opacity:1},leave:{transform:"translateY(-52px)",opacity:0},config:{tension:500,friction:30,clamp:!0}}),o=a=>{switch(a){case"loading":return t.jsx(gt,{size:16});case"info":case"success":return t.jsx(k.IconCheckCircleFilled,{size:16});case"error":return t.jsx(k.IconCloseCircleFilled,{size:16});default:return null}};return r((a,i)=>{if(!i)return null;const{type:l,title:c,description:d}=i,u=o(l);return t.jsx(Je.animated.div,{style:a,className:Qe.container,children:t.jsxs("div",{className:B(Qe.toast,l&&Qe[l]),...n,children:[u&&t.jsx("div",{className:Qe.icon,children:u}),t.jsxs("div",{className:Qe.content,children:[t.jsx("p",{className:Qe.title,children:c}),d&&t.jsx("div",{className:Qe.description,children:d})]}),t.jsx("button",{className:Qe.close,onClick:s,children:t.jsx(k.IconClose,{size:14})})]})})})},Js=5e3,pl=({children:e})=>{const s=mt(),[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(h=>{i(),r({...h,id:zn.nanoid()}),h.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Js))},[l]),d=f.useCallback(h=>{i(),r(_=>_?{..._,...h}:{...h,id:zn.nanoid()}),h.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Js))},[l]),u=()=>{i(),a.current=!0},m=()=>{i(),a.current=!1,n?.autoHide&&(o.current=setTimeout(()=>l(),Js))};return f.useEffect(()=>()=>i(),[]),t.jsxs(eo.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,s&&Qo.createPortal(t.jsx(fl,{notification:n,onClose:l,onMouseEnter:u,onMouseLeave:m}),s)]})},gl=({children:e})=>{const[s,n]=f.useState(null);return t.jsx(Tn.Provider,{value:{container:s,setContainer:n},children:e})},xl="_container_1a4ds_1",yl="_badge_1a4ds_5",Jn={container:xl,badge:yl},ho=e=>{const{offset:s=-4,disabled:n,children:r,className:o}=e;return t.jsxs("div",{className:B(Jn.container,o),children:[r,!n&&t.jsx("div",{className:Jn.badge,style:{right:s,top:s}})]})},jl="_header_acels_1",vl="_back_acels_11",bl="_title_acels_23",Xs={header:jl,back:vl,title:bl},xt=({title:e,backButton:s,extra:n,children:r})=>t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Xs.header,children:[t.jsx(Nn,{to:s??-1,className:Xs.back,shouldReset:!!s,children:t.jsx(k.IconBack,{size:16})}),t.jsx("h1",{className:Xs.title,children:e}),n]}),t.jsx(ze,{children:r})]});function mo(){const{initiaAddress:e,hexAddress:s}=fe(),n=pt(),r=Zt();return o=>{const a=n(o);switch(r(a)){case"initia":return e;case"evm":return s;default:return""}}}function _o(){const e=pt(),s=Zt();return(n,r)=>{const o=e(r);switch(s(o)){case"initia":return w.InitiaAddress.validate(n);case"evm":return Ze.isAddress(n);case"cosmos":try{return W.fromBech32(n).prefix===o.bech32_prefix}catch{return!1}default:return!1}}}function wl(){const e=pt(),s=Zt();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""}}function Cl(){return le().network_type==="testnet"}function et(){return ce.useFormContext()}function Il(){const e=ft(),s=Cl(),n={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},r={...n,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},o={...n,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},a=v.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(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?r:o,...a,...e}}const 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",at={root:Nl,header:Sl,title:kl,warning:Al,content:$l,footer:Tl,secondary:El},fo=e=>{const{type:s,icon:n,title:r,children:o,primaryButton:a,secondaryButton:i}=e;return t.jsxs(ze,{className:at.root,children:[t.jsxs("header",{className:B(at.header,s&&at[s]),children:[n,t.jsx("h1",{className:at.title,children:r})]}),t.jsx("div",{className:at.content,children:o}),t.jsxs("footer",{className:at.footer,children:[t.jsx(V.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),t.jsxs("button",{className:at.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(k.IconChevronRight,{size:14})]})]})]})},ql="_list_tmcxc_1",Dl="_row_tmcxc_8",Pl="_dt_tmcxc_19",Rl="_asset_tmcxc_25",rs={list:ql,row:Dl,dt:Pl,asset:Rl},Bl=({list:e,onNavigate:s,onDismiss:n})=>{const r=le(),o=Xe(),a=Ue(r);return t.jsx(fo,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:s},secondaryButton:{label:"Do not show again",onClick:n},children:t.jsx("div",{className:rs.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:m,symbol:h}=a(d),_=w.formatAmount(c,{decimals:m});return t.jsxs("div",{className:rs.row,children:[t.jsxs("div",{className:rs.dt,children:[t.jsx(Q,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:rs.asset,children:[_," ",h]})]},i)})})})};function en(e,s){return e.chainId===s.chainId&&e.txHash===s.txHash}const os=({chainId:e,txHash:s})=>`${U.OP_REMINDER}:${e}:${s}`,Fl=Vo.atomWithStorage(U.OP_REMINDER,[]);function qt(){const e=ae(),[s=[],n]=G.useAtom(Fl),r=f.useMemo(()=>s.map(c=>{const d=localStorage.getItem(os(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:At.isPast(u)}),[e,s]),o=f.useCallback((c,d)=>{s.some(u=>en(u,c))||(n((u=[])=>[...u,c]),localStorage.setItem(os(c),JSON.stringify(d)))},[s,n]),a=f.useCallback(c=>{n((d=[])=>d.filter(u=>!en(u,c))),localStorage.removeItem(os(c))},[n]),i=f.useCallback(c=>{const d=c.filter(u=>!s.some(m=>en(m,u)));d.length!==0&&n((u=[])=>[...u,...d])},[s,n]),l=f.useCallback((c,d)=>{localStorage.setItem(os(c),JSON.stringify(d)),n((u=[])=>[...u])},[n]);return{reminders:r,addReminder:o,removeReminder:a,syncReminders:i,setReminder:l}}function po(){const e=he(),{openModal:s,closeModal:n}=As(),{reminders:r,setReminder:o}=qt();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 Ml="_wrapper_5ssm8_1",Ol="_balance_5ssm8_11",Ul="_button_5ssm8_15",tn={wrapper:Ml,balance:Ol,button:Ul},go=({onClick:e,children:s,disabled:n})=>t.jsxs("div",{className:tn.wrapper,children:[t.jsx(k.IconWallet,{size:16}),t.jsx("span",{className:tn.balance,children:s}),t.jsx("button",{type:"button",tabIndex:-1,className:tn.button,onClick:()=>e(),disabled:n,children:"MAX"})]}),Ll="_fieldset_y241y_1",zl="_upper_y241y_9",Kl="_select_y241y_14",Hl="_account_y241y_19",Wl="_lower_y241y_24",Ql="_wrapper_y241y_25",Vl="_balance_y241y_32",Gl="_value_y241y_36",Yl="_error_y241y_49",Be={fieldset:Ll,upper:zl,select:Kl,account:Hl,lower:Wl,wrapper:Ql,balance:Vl,value:Gl,error:Yl},fn=e=>{const{selectButton:s,accountButton:n,quantityInput:r,balanceButton:o,value:a,errorMessage:i,hideNumbers:l}=e;return t.jsxs("div",{className:Be.fieldset,children:[t.jsxs("div",{className:Be.upper,children:[t.jsx("div",{className:Be.select,children:s}),t.jsx("div",{className:Be.account,children:n})]}),!l&&t.jsxs("div",{className:Be.lower,children:[r,t.jsxs("div",{className:Be.wrapper,children:[t.jsx("div",{className:Be.balance,children:o}),a&&t.jsx("div",{className:Be.value,children:a})]}),i&&t.jsxs("footer",{className:Be.error,children:[t.jsx(k.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function Jt(){const e=f.useRef(null),s=qs();return f.useEffect(()=>{s||e.current?.focus()},[s]),e}const Zl="_input_h8073_1",Jl={input:Zl};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 xo(e){const{name:s,control:n,dp:r=6,className:o,rules:a,...i}=e,l=Jt();return t.jsx(ce.Controller,{name:s,control:n,rules:a,render:({field:c})=>t.jsx("input",{...c,className:B(Jl.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 h=u.replace(/,/g,""),_=Xn(h,r);c.onChange(_)},placeholder:"0",inputMode:"decimal",autoComplete:"off",...i,ref:vr.mergeRefs([c.ref,l])})})}const Xl="_input_qpv94_1",ed="_placeholder_qpv94_18",pn={input:Xl,placeholder:ed},td=({children:e})=>t.jsx("p",{className:B(pn.input,{[pn.placeholder]:M(e).isZero()}),children:e}),xs=({balance:e,decimals:s})=>{const{control:n}=ce.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(xo,{name:"quantity",control:n,className:pn.input,rules:r})};xs.ReadOnly=td;const sd="_tooltip_6zakp_1",nd="_arrow_6zakp_43",er={tooltip:sd,arrow:nd},Xt=({label:e,children:s,small:n,...r})=>t.jsxs(Y.Tooltip.Root,{...r,children:[t.jsx(Y.Tooltip.Trigger,{asChild:!0,children:s}),t.jsx(Y.Tooltip.Portal,{container:mt(),children:t.jsxs(Y.Tooltip.Content,{className:B(er.tooltip,{small:n}),collisionBoundary:mt(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(Y.Tooltip.Arrow,{className:er.arrow})]})})]});function qn(e,s){const n=Le();return A.useQuery({queryKey:De.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:K.SECOND})}function rd(e,s,n){const{data:r={}}=qn(e,s);return v.path([n],r)}const od=[["d",1440*60],["h",3600],["m",60],["s",1]];function gn(e){if(!e)return;const{formattedParts:s}=od.reduce(({remainingSeconds:n,formattedParts:r},[o,a])=>{const i=Math.floor(n/a);return{remainingSeconds:n-i*a,formattedParts:i>0?[...r,`${i}${o}`]:r}},{remainingSeconds:e,formattedParts:[]});return s.join(" ")}function yo(e){return e?.map(s=>{const{amount:n,origin_asset:r}=s;return`${w.formatAmount(n,{decimals:r.decimals??0})} ${r.symbol}`}).join(", ")}function tr(e,s){const{watch:n}=et(),r=n(),o=Le(),a=$s(),i={...r,quantity:e},l=A.useQueryClient();return A.useQuery({queryKey:De.route(i,s?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:c,srcDenom:d,quantity:u,dstChainId:m,dstDenom:h}=i,{decimals:_}=l.getQueryData(De.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:m,dest_asset_denom:h,is_op_withdraw:s?.isOpWithdraw},p=await o.post("v2/fungible/route",{json:g}).json(),j={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return a("Bridge Simulation Success",j),p},enabled:!!Number(i.quantity)&&!s?.disabled,staleTime:K.MINUTE})}function ad(e){return A.useQuery({queryKey:De.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 id(){const{watch:e}=et(),{srcChainId:s,srcDenom:n,dstChainId:r,dstDenom:o}=e(),a=Pe(s),i=Vt(a),l=Me(n,s),c=Me(o,r),d=le(),u=oe();return i==="initia"&&r===d.chainId&&l.symbol===c.symbol&&u.find(m=>m.chainId===s)?.metadata?.op_denoms?.includes(c.denom)}const cd="_label_9417z_1",ld="_wrapper_9417z_7",dd="_input_9417z_10",ud="_clear_9417z_18",as={label:cd,wrapper:ld,input:dd,clear:ud},Dn=({mode:e="onChange",myAddress:s,...n})=>{const{validate:r=w.InitiaAddress.validate,chainType:o="initia",onApply:a,ref:i}=n,l=Jt(),{control:c,getValues:d,setValue:u,formState:m}=ce.useFormContext(),h=d("recipient"),[_,g]=f.useState(h),p=Tr(),{data:j,isLoading:S,error:N}=A.useQuery({queryKey:Is.address(p.restUrl,_).queryKey,queryFn:()=>p.getAddress(_),staleTime:K.MINUTE,enabled:p.validateUsername(_)}),I=j??(r(_)?_:""),b=s&&w.InitiaAddress.equals(I,s),E=async()=>{try{const C=await navigator.clipboard.readText();g(C.trim())}catch{}};f.useEffect(()=>{e==="onChange"&&(!_&&!m.dirtyFields.recipient||u("recipient",j??_,{shouldValidate:!0,shouldDirty:!0}))},[m.dirtyFields.recipient,_,e,u,j]);const D=()=>{S||N||(u("recipient",I,{shouldValidate:!0,shouldDirty:!0}),a?.())},F=()=>{if(S)return t.jsx(It,{level:"loading",children:"Resolving username..."});if(N)return t.jsx(It,{level:"error",children:N.message});if(j)return t.jsx(It,{level:"success",className:"monospace",children:j});if(e==="onSubmit"&&_&&!I)return t.jsx(It,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:as.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(V.Small,{type:"button",tabIndex:-1,onClick:E,children:"Paste"})]}),t.jsxs("div",{className:as.wrapper,children:[t.jsx(ce.Controller,{name:"recipient",control:c,rules:{required:"Recipient address is required",validate:C=>r(C)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:B(as.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"?vr.mergeRefs([i,l]):i})}),!!_&&t.jsx("button",{type:"button",className:as.clear,onClick:()=>g(""),"aria-label":"Clear recipient",children:t.jsx(k.IconCloseCircleFilled,{size:16})})]}),F(),b&&t.jsx(It,{children:"This is my address"}),e==="onSubmit"&&t.jsx(re,{extra:(!s||!!I&&!b)&&t.jsx(ne,{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(V.White,{type:"button",onClick:D,disabled:S||!!N||!I,children:"Apply"})})]})},hd="_scrollable_1p1lw_1",md="_list_1p1lw_5",_d="_item_1p1lw_9",fd="_name_1p1lw_13",is={scrollable:hd,list:md,item:_d,name:fd};function jo({onSelect:e,list:s,...n}){const{getImage:r,getName:o,getKey:a,getIsLoading:i,getDisabled:l}=n;return t.jsx(ze,{className:is.scrollable,children:t.jsx("div",{className:is.list,children:s.map(c=>t.jsxs("button",{className:is.item,onClick:()=>e(c),disabled:i?.(c)||l?.(c),children:[t.jsx(Q,{src:r(c),width:28,height:28}),t.jsx("span",{className:is.name,children:o(c)}),i?.(c)&&t.jsx(gt,{size:16})]},a(c)))})})}function Ps(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:n=>e.find(r=>r.name===n)}}const pd="_account_iwrlj_8",gd="_clear_iwrlj_27",xd="_white_iwrlj_38",Mt={account:pd,clear:gd,white:xd},sr=({type:e})=>{const{watch:s,setValue:n}=et(),{srcChainId:r,dstChainId:o,cosmosWalletName:a}=s(),l=s(e==="src"?"sender":"recipient"),c=Vt(Pe(o)),{list:d,find:u}=Ps(),m=u(a),h=mo(),_=_o(),g=h(o),p=w.InitiaAddress.equals(l,g),j=()=>t.jsx(_t,{title:"Connect wallet",content:I=>t.jsx(jo,{onSelect:async b=>{const E=b.getProvider();if(!E)return window.open(b.fallbackUrl,"_blank");const D=E.getOfflineSigner(r),[{address:F}]=await D.getAccounts();n("sender",F),n("cosmosWalletName",b.name),I()},list:d,getImage:b=>b.image,getName:b=>b.name,getKey:b=>b.name}),className:B(Mt.account,{[Mt.white]:!l}),children:l?t.jsxs(t.Fragment,{children:[m&&t.jsx(Q,{src:m.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(k.IconChevronRight,{size:14})]})}),S=I=>t.jsx(_t,{title:"Recipient",content:b=>t.jsx(ze,{children:t.jsx(Dn,{mode:"onSubmit",myAddress:g,chainType:c,validate:E=>_(E,o),onApply:b})}),className:Mt.account,children:I}),N=()=>{switch(c){case"initia":case"evm":return p?S(t.jsx(k.IconWallet,{size:14})):t.jsxs("div",{className:Mt.account,children:[t.jsx("span",{className:"monospace",children:w.truncate(l)}),t.jsx("button",{type:"button",className:Mt.clear,onClick:()=>n("recipient",g,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(k.IconCloseCircleFilled,{size:14})})]});case"cosmos":return S(t.jsxs(t.Fragment,{children:[l?t.jsx("span",{className:"monospace",children:w.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx(k.IconEdit,{size:14})]}))}};switch(e){case"src":return j();case"dst":return N()}},yd="_images_cj4xz_1",sn={images:yd},Rs=({assetLogoUrl:e,assetLogoSize:s=36,chainLogoUrl:n,chainLogoSize:r=18,chainLogoOffset:o=6,className:a})=>t.jsxs("div",{className:B(sn.images,a),style:{position:"relative"},children:[t.jsx(Q,{src:e,width:s,height:s,className:sn.asset,logo:!0}),t.jsx(Q,{src:n,width:r,height:r,className:sn.chain,style:{position:"absolute",bottom:0,right:-1*o},logo:!0})]}),jd="_root_1ipwv_1",vd="_content_1ipwv_10",bd="_details_1ipwv_18",wd="_symbol_1ipwv_23",Cd="_chain_1ipwv_31",Id="_chevron_1ipwv_40",it={root:jd,content:vd,details:bd,symbol:wd,chain:Cd,chevron:Id},vo=({asset:e,chain:s,readOnly:n})=>{const r=t.jsxs("div",{className:it.content,children:[t.jsx(Rs,{assetLogoUrl:e.logoUrl,chainLogoUrl:s.logoUrl}),t.jsxs("div",{className:it.details,children:[t.jsx("div",{className:it.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:it.chain,children:["on ",s.name]})]})]});return n?t.jsx("div",{className:it.root,children:r}):t.jsxs("div",{className:it.root,children:[r,t.jsx(k.IconChevronDown,{size:16,className:it.chevron})]})};function Nd(e,s,n){return n.filter(r=>{const o=e.map(a=>r[a]).map(a=>String(a??"").toLowerCase());return v.any(v.includes(s.toLowerCase()),o)})}const Sd="_root_7yxgy_1",kd="_label_7yxgy_7",Ad="_input_7yxgy_19",$d="_hasValue_7yxgy_29",Td="_clear_7yxgy_33",Ot={root:Sd,label:kd,input:Ad,hasValue:$d,clear:Td},Bs=e=>{const{rootClassName:s,padding:n=16,iconSize:r=16,onClear:o,ref:a,...i}=e;return t.jsxs("div",{className:B(Ot.root,s,{[Ot.hasValue]:i.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${r}px`},children:[t.jsx("label",{htmlFor:"search",className:Ot.label,children:t.jsx(k.IconSearch,{size:r})}),t.jsx("input",{className:Ot.input,id:"search",type:"text",maxLength:100,ref:a,...i}),i.value&&t.jsx("button",{type:"button",className:Ot.clear,"aria-label":"Clear search",onMouseDown:l=>l.preventDefault(),onClick:o,children:t.jsx(k.IconCloseCircleFilled,{size:r})})]})},Ed="_container_1voou_1",qd="_search_1voou_6",Dd="_list_1voou_10",Pd="_item_1voou_14",Rd="_logo_1voou_35",Bd="_info_1voou_39",Fd="_symbol_1voou_44",Md="_name_1voou_52",Od="_balance_1voou_58",Ud="_value_1voou_65",je={container:Ed,search:qd,list:Dd,item:Pd,logo:Rd,info:Bd,symbol:Fd,name:Md,balance:Od,value:Ud},es=e=>{const{assets:s,onSelect:n,renderAsset:r=(l,c)=>c(l)}=e,[o,a]=f.useState(""),i=Nd(["symbol"],o,s);return t.jsxs("div",{className:je.container,children:[t.jsx(Bs,{value:o,onChange:l=>a(l.target.value),onClear:()=>a(""),placeholder:"Search by symbol",rootClassName:je.search,padding:20,ref:Jt()}),i.length===0?t.jsx(X,{children:"No assets"}):t.jsx("div",{className:je.list,children:i.map(l=>t.jsx("button",{type:"button",className:je.item,onClick:()=>n(l.denom),children:r(l,c=>{const{denom:d,logoUrl:u,symbol:m,name:h,balance:_,decimals:g,value:p=0}=c;return t.jsxs(t.Fragment,{children:[t.jsx(Q,{src:u,width:32,height:32,className:je.logo,logo:!0}),t.jsxs("div",{className:je.info,children:[t.jsx("div",{className:je.symbol,children:m||d}),t.jsx("div",{className:je.name,children:h})]}),t.jsxs("div",{className:je.balance,children:[_&&t.jsx("div",{children:w.formatAmount(_,{decimals:g})}),p>0&&t.jsx("div",{className:je.value,children:Se(p)})]})]})})},l.denom))})]})},Ld=()=>t.jsxs("div",{className:je.container,children:[t.jsx(Bs,{rootClassName:je.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(X,{children:"Loading..."})]});es.Placeholder=Ld;const zd="_stack_a3b9q_1",Kd="_title_a3b9q_8",Hd="_grid_a3b9q_15",Wd="_item_a3b9q_21",Qd="_button_a3b9q_25",Vd="_active_a3b9q_43",Nt={stack:zd,title:Kd,grid:Hd,item:Wd,button:Qd,active:Vd},ht=({label:e,chains:s,value:n,onSelect:r,getShowIndicator:o})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:Nt.title,children:e}),t.jsx("div",{className:Nt.grid,children:s.map(({chainId:a,name:i,logoUrl:l})=>t.jsx(ho,{offset:-2,disabled:!o?.(a),className:Nt.item,children:t.jsx(Xt,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:B(Nt.button,{[Nt.active]:a===n}),onClick:()=>r(a),children:t.jsx(Q,{src:l,width:28,height:28,logo:!0})})})},a))})]}),Gd=({children:e})=>t.jsx("div",{className:Nt.stack,children:e});ht.Stack=Gd;const Yd=({address:e,chain:s,onSelect:n})=>{const r=kt(s.chain_id),{data:o={}}=qn(e,s.chain_id);return t.jsx(es,{assets:v.sortWith([v.descend(a=>a.symbol==="INIT"),v.descend(a=>a.value),({balance:a="0"},{balance:i="0"})=>M(i).comparedTo(a)??0,v.ascend(a=>a.symbol.toLowerCase())],r.filter(a=>!a.hidden).map(a=>{const{denom:i,symbol:l=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})},Zd=({type:e,afterSelect:s})=>{const n=e==="src"?"srcChainId":"dstChainId",r=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"sender":"recipient",a=Et(),i=$n(),{watch:l,setValue:c}=et(),d=l(o),u=l(n),m=l(r),[h,_]=f.useState(u),g=Pe(h),p=wl(),j=Yr(),[S,N]=v.partition(b=>j(b.chain_id),i.filter(b=>!b.hidden)),I=b=>{if(u===h&&m===b){s();return}c(n,h),c(r,b),s()};return t.jsxs(t.Fragment,{children:[t.jsxs(ht.Stack,{children:[t.jsx(ht,{label:"Interwoven Economy",chains:S.map(({chain_id:b,chain_name:E,pretty_name:D,logo_uri:F})=>({chainId:b,name:D||E,logoUrl:F??""})),value:h,onSelect:_}),t.jsx(ht,{label:"Chains",chains:N.map(({chain_id:b,chain_name:E,pretty_name:D,logo_uri:F})=>({chainId:b,name:D||E,logoUrl:F??""})),value:h,onSelect:_})]}),t.jsx(pe,{suspenseFallback:t.jsx(es.Placeholder,{}),children:t.jsx(Yd,{address:p({initialAddress:d,initialChainId:u,chainId:h,fallbackAddress:e==="src"?a:void 0}),chain:g,onSelect:I})},h)]})},nr=({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=Pe(a),c=Me(i,a);return t.jsx(_t,{title:r,content:d=>t.jsx(Zd,{type:e,afterSelect:d}),children:t.jsx(vo,{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??""}})})},Jd="_skeleton_1l4jn_1",Xd={skeleton:Jd},nn=({width:e="100%",height:s})=>t.jsx("div",{className:Xd.skeleton,style:{width:e,height:s}}),eu="_stack_1ip8h_1",tu="_button_1ip8h_6",su="_isLoading_1ip8h_19",nu="_disabled_1ip8h_19",ru="_checked_1ip8h_23",ou="_header_1ip8h_37",au="_title_1ip8h_43",iu="_duration_1ip8h_52",cu="_warning_1ip8h_62",lu="_amount_1ip8h_66",du="_value_1ip8h_67",ye={stack:eu,button:tu,isLoading:su,disabled:nu,checked:ru,header:ou,title:au,duration:iu,warning:cu,amount:lu,value:du},uu=({children:e})=>t.jsx("div",{className:ye.stack,children:e}),hs=({label:e,query:s,value:n,onSelect:r,...o})=>{const{data:a,isLoading:i}=s,{watch:l}=et(),{dstChainId:c,dstDenom:d}=l(),u=Me(d,c),m=!i&&o.checked,h=!i&&!a;return t.jsxs("button",{type:"button",className:B(ye.button,{[ye.isLoading]:i,[ye.disabled]:h,[ye.checked]:m}),onClick:()=>{i||h||r(n)},children:[t.jsxs("div",{className:ye.header,children:[t.jsxs("div",{className:ye.title,children:[t.jsx("span",{children:e}),m&&t.jsx(k.IconCheck,{size:14})]}),i?t.jsx(nn,{width:80,height:16}):a?t.jsxs("div",{className:B(ye.duration,{[ye.warning]:n==="op"}),children:[t.jsx(k.IconClockFilled,{size:12}),t.jsx("span",{children:gn(a.estimated_route_duration_seconds)})]}):t.jsx("div",{className:ye.duration,children:"Not available"})]}),(i||a)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ye.amount,children:i?t.jsx(nn,{width:260,height:40}):a?w.formatAmount(a.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:ye.value,children:i?t.jsx(nn,{width:120,height:16}):a?a.usd_amount_out?Se(a.usd_amount_out):"$-":null})]})]})};hs.Stack=uu;const hu="_description_s1yto_1",mu="_presets_s1yto_8",_u="_preset_s1yto_8",fu="_active_s1yto_28",pu="_custom_s1yto_39",gu="_wrapper_s1yto_45",xu="_percent_s1yto_54",$e={description:hu,presets:mu,preset:_u,active:fu,custom:pu,wrapper:gu,percent:xu},rr=["0.1","0.5","1.0"],yu=({afterConfirm:e})=>{const s=et(),n=s.getValues("slippagePercent"),[r,o]=f.useState(null),{control:a,watch:i,getValues:l,setValue:c}=ce.useForm({defaultValues:{value:n}}),d=i("value");f.useEffect(()=>{const p=rr.findIndex(j=>j===n);o(p>=0?p:null)},[n]);const u=(p,j)=>{c("value",p),o(j)},m=()=>{o(null)},h=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]),_=h?.type==="error",g=({value:p})=>{s.setValue("slippagePercent",p),e()};return t.jsxs(ze,{children:[t.jsx("p",{className:$e.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:$e.presets,children:[rr.map((p,j)=>t.jsxs("button",{type:"button",className:B($e.preset,{[$e.active]:r===j}),onClick:()=>u(p,j),children:[p,"%"]},p)),r!==null?t.jsx("button",{type:"button",className:B($e.preset,$e.custom),onClick:()=>o(null),children:"Custom"}):t.jsxs("div",{className:$e.wrapper,children:[t.jsx(xo,{name:"value",control:a,dp:2,onFocus:m,placeholder:"",className:B($e.preset,$e.active)}),t.jsx("span",{className:$e.percent,children:"%"})]})]}),h&&t.jsx(ne,{level:h.type,children:h.text}),t.jsx(re,{children:t.jsx(V.White,{type:"button",onClick:()=>g(l()),disabled:_,children:"Confirm"})})]})},ju="_form_1coq4_1",vu="_arrow_1coq4_5",bu="_divider_1coq4_13",wu="_flip_1coq4_21",Cu="_meta_1coq4_37",Iu="_row_1coq4_50",Nu="_title_1coq4_56",Su="_description_1coq4_60",ku="_icon_1coq4_67",Au="_edit_1coq4_72",$u="_warning_1coq4_93",_e={form:ju,arrow:vu,divider:bu,flip:wu,meta:Cu,row:Iu,title:Nu,description:Su,icon:ku,edit:Au,warning:$u},Tu=()=>{const e=he(),s=qs(),[n,r]=Ne.useLocalStorage(U.BRIDGE_ROUTE_TYPE,"default"),{watch:o,setValue:a,handleSubmit:i,formState:l}=et(),c=o(),{srcChainId:d,srcDenom:u,dstChainId:m,dstDenom:h,quantity:_,sender:g,slippagePercent:p}=c,j=Xe(),S=Pe(d),N=Vt(S),I=Pe(m),b=Vt(I),E=Me(u,d),D=Me(h,m),{data:F}=qn(g,d),C=rd(g,d,u),P=!C?.amount||M(C.amount).isZero(),[y]=Ne.useDebounceValue(_,300),x=N!=="initia"&&b!=="initia",$=id(),T=tr(y,{disabled:x}),R=tr(y,{isOpWithdraw:!0,disabled:!$}),L=$&&n==="op"?R:T,{data:q,isLoading:H,isFetching:ie,error:O}=L,{data:be}=ad(O),tt=y&&(H||ie),Ke=()=>{a("srcChainId",m),a("srcDenom",h),a("dstChainId",d),a("dstDenom",u),a("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:st,closeModal:de}=As(),me=i(z=>{if(q?.warning){const{type:rt="",message:Us}=q.warning??{};st({content:t.jsx(fo,{type:"warning",icon:t.jsx(k.IconWarningFilled,{size:40}),title:vs.sentenceCase(rt),primaryButton:{label:"Cancel",onClick:de},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:q,values:z}),de()}},children:t.jsx("p",{className:_e.warning,children:Us})})});return}e("/bridge/preview",{route:q,values:z})}),jt=f.useMemo(()=>q?.estimated_fees?.filter(({fee_behavior:z})=>z==="FEE_BEHAVIOR_DEDUCTED")??[],[q]),nt=f.useMemo(()=>q?.estimated_fees?.filter(({fee_behavior:z})=>z==="FEE_BEHAVIOR_ADDITIONAL")??[],[q]),Pt=f.useMemo(()=>{for(const z of nt){const rt=F?.[z.origin_asset.denom]?.amount??"0",Us=q?.source_asset_denom===z.origin_asset.denom?q.amount_in:"0";if(M(rt).lt(M(Us).plus(z.amount??"0")))return`Insufficient ${z.origin_asset.symbol} for fees`}},[F,q,nt]),Mn=f.useMemo(()=>{if(!c.sender)return"Connect wallet";if(!c.quantity||!y)return"Enter amount";if(!c.recipient)return"Enter recipient address";if(l.errors.quantity)return l.errors.quantity.message;if(!q)return"Route not found";if(Pt)return Pt},[y,Pt,l,q,c]),Fo=q?w.formatAmount(q.amount_out,{decimals:D.decimals}):"0",Mo=M(_).gt(0)&&M(_).isEqualTo(w.fromBaseUnit(C?.amount,{decimals:C?.decimals??0})),Oo=(()=>{switch(N){case"initia":return j(d).fees.fee_tokens.some(({denom:z})=>z===u);case"cosmos":return S.fee_assets.some(({denom:z})=>z===u);case"evm":return!Ze.isAddress(u);default:return!1}})(),Os=f.useCallback((z,rt)=>z.length?t.jsxs("div",{className:_e.description,children:[yo(z),!s&&t.jsx(Xt,{label:rt,children:t.jsx("span",{className:_e.icon,children:t.jsx(k.IconInfoFilled,{size:12})})})]}):null,[s]),ts=M(_).gt(0)&&$,On=f.useMemo(()=>q?[{condition:!!q.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Os(jt,"Fee deducted from the amount you receive"),Os(nt,"Fee charged in addition to the amount you enter")]})},{condition:!ts&&!!gn(q.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:_e.description,children:gn(q.estimated_route_duration_seconds)})},{condition:q.does_swap,title:"Slippage",content:t.jsxs("span",{className:_e.description,children:[t.jsxs("span",{children:[p,"%"]}),t.jsx(_t,{title:"Slippage tolerance",content:z=>t.jsx(yu,{afterConfirm:z}),className:_e.edit,children:t.jsx(k.IconSettingFilled,{size:12})})]})}].filter(z=>z.condition):[],[nt,jt,Os,q,ts,p]);return t.jsxs("form",{className:_e.form,onSubmit:me,children:[t.jsx(fn,{selectButton:t.jsx(nr,{type:"src"}),accountButton:N==="cosmos"&&t.jsx(sr,{type:"src"}),quantityInput:t.jsx(xs,{balance:C?.amount,decimals:E?.decimals}),balanceButton:t.jsx(go,{onClick:()=>a("quantity",w.fromBaseUnit(C?.amount,{decimals:E?.decimals??0}),{shouldValidate:!0}),disabled:P,children:w.formatAmount(C?.amount??"0",{decimals:E.decimals})}),value:q?q.usd_amount_in?Se(q.usd_amount_in):"$-":"$0"}),t.jsxs("div",{className:_e.arrow,children:[t.jsx("div",{className:_e.divider}),t.jsx("button",{type:"button",className:_e.flip,onClick:()=>Ke(),children:t.jsx(k.IconChevronDown,{size:16})})]}),t.jsx(fn,{selectButton:t.jsx(nr,{type:"dst"}),accountButton:t.jsx(sr,{type:"dst"}),quantityInput:t.jsx(xs.ReadOnly,{children:Fo}),value:q?q.usd_amount_out?Se(q.usd_amount_out):"$-":"$0",hideNumbers:ts}),t.jsx(mn,{children:ts?t.jsxs(hs.Stack,{children:[t.jsx(hs,{label:"Fast",query:T,value:"default",onSelect:r,checked:n==="default"}),t.jsx(hs,{label:"Lossless",query:R,value:"op",onSelect:r,checked:n==="op"})]}):null}),t.jsx(re,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(ne.Stack,{children:[q?.extra_infos?.map(z=>t.jsx(ne,{level:"info",children:z},z)),be&&t.jsx(ne,{level:"info",children:be}),Mo&&Oo&&t.jsx(ne,{level:"warning",children:"Make sure to leave enough for transaction fee"}),q?.warning&&t.jsx(ne,{level:"warning",children:q.warning.message}),q?.extra_warnings?.map(z=>t.jsx(ne,{level:"warning",children:z},z))]}),t.jsx(mn,{children:On.length>0&&t.jsx("div",{className:_e.meta,children:On.map((z,rt)=>t.jsxs("div",{className:_e.row,children:[t.jsx("span",{className:_e.title,children:z.title}),z.content]},rt))})})]}),children:t.jsx(V.White,{loading:tt&&"Simulating...",disabled:!!Mn,children:Mn??"Preview route"})})]})},Eu=()=>{po();const e=ya(),s=he(),{closeDrawer:n}=Tt(),r=Et(),o=Il(),a=ce.useForm({mode:"onChange",defaultValues:o}),{watch:i,setValue:l}=a,{srcChainId:c,dstChainId:d,srcDenom:u,dstDenom:m,quantity:h,slippagePercent:_,recipient:g}=i();i((y,{name:x})=>{(x==="srcChainId"||x==="srcDenom")&&l("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=mo(),j=p(c),S=p(d),I=_o()(g,d);f.useEffect(()=>{l("cosmosWalletName",void 0),l("sender",j)},[c,j,l]),f.useEffect(()=>{I||l("recipient",S)},[S,I,l]);const b=kt(c),E=kt(d),D=f.useMemo(()=>{if(!b.find(y=>y.denom===u))return`${u} is not available for bridge/swap on ${c}`;if(!E.find(y=>y.denom===m))return`${m} is not available for bridge/swap on ${d}`},[E,d,m,b,c,u]);f.useEffect(()=>{D||(localStorage.setItem(U.BRIDGE_SRC_CHAIN_ID,c),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,_))},[c,u,d,m,h,_,D]);const F=e[0].path==="/bridge",C=()=>t.jsxs(t.Fragment,{children:[t.jsx(X,{error:!0,children:D}),t.jsx(re,{children:F?t.jsx(V.White,{onClick:n,children:"Close"}):t.jsx(V.White,{onClick:()=>s(-1),children:"Go back"})})]}),{reminders:P}=qt();return t.jsx(xt,{title:"Bridge/Swap",backButton:F?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(V.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(ho,{offset:0,disabled:P.length===0,children:t.jsx(V.Small,{onClick:()=>s("/op/withdrawals"),disabled:!r,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:D?C():t.jsx(ce.FormProvider,{...a,children:t.jsx(pe,{children:t.jsx(Tu,{})})})})},qu="_button_14cv7_1",Du="_checkbox_14cv7_10",Pu="_checked_14cv7_23",cs={button:qu,checkbox:Du,checked:Pu},Ru=({checked:e,onClick:s,label:n,className:r})=>t.jsxs("button",{type:"button",className:B(cs.button,r),onClick:s,children:[t.jsx("div",{className:B(cs.checkbox,{[cs.checked]:e}),children:e&&t.jsx(k.IconCheck,{size:12})}),t.jsx("span",{className:cs.label,children:n})]}),Bu="_button_1iys9_1",Fu={button:Bu},bo=({onClick:e,disabled:s})=>{const{ref:n,inView:r}=Go.useInView();return f.useEffect(()=>{r&&e()},[r,e]),t.jsxs("button",{className:Fu.button,onClick:e,disabled:s,ref:n,children:[t.jsx("span",{children:"Load more"}),t.jsx(k.IconChevronDown,{size:12})]})};function wo(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 ms=({chainId:e,txHash:s})=>`${U.BRIDGE_HISTORY}:${e}:${s}`,ys=100,or=10;function Co(){const[e,s]=Ne.useLocalStorage(U.BRIDGE_HISTORY,[]),n=f.useCallback((o,a)=>{localStorage.setItem(ms(o),JSON.stringify(a));for(const i of e.slice(ys-1))localStorage.removeItem(ms(i));s((i=[])=>[o,...i.slice(0,ys-1)])},[e,s]),r=f.useCallback(o=>{const a=localStorage.getItem(ms(o));return a?JSON.parse(a):null},[]);return{history:e,addHistoryItem:n,getHistoryDetails:r}}function Io(e){return Ne.useLocalStorage(ms(e),null)}async function Mu(e,s){const n=Z.create({prefixUrl:s}),r=`cosmos/auth/v1beta1/account_info/${e}`;for(let o=1;o<=24;o++)try{return await n.get(r).json()}catch{await new Promise(a=>setTimeout(a,5e3))}throw new Error(`Timeout: ${e} not found`)}async function xn(e,s){const{chain_type:n,chain_id:r,chain_name:o,evm_fee_asset:a,rpc:i}=s;if(n!=="evm")throw new Error(`Chain is not an EVM chain: ${o}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}catch(l){if(v.path(["error","code"],l)!==4902)throw l;if(!a)throw new Error(`Fee asset is not defined for chain: ${o}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(r).toString(16)}`,chainName:o,nativeCurrency:a,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}}function Dt(){return ft()}function Ou(e){const s=he(),{showNotification:n,updateNotification:r,hideNotification:o}=En(),{addHistoryItem:a}=Co(),i=$s(),{route:l,values:c}=Dt(),{srcChainId:d,sender:u,recipient:m,cosmosWalletName:h}=c,_=Rr(),{requestTxSync:g,waitForTxConfirmation:p}=fe(),{find:j}=Ps(),S=Ns(),N=Yt(),I=Pe(d),b=Vt(I),E=Gr(d),D=A.useQueryClient(),{registryUrl:F}=ee(),C=Xe(),{addReminder:P}=qt(),y=Le();return A.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:de,msg:me})=>{if(!(de&&me))throw new Error("Invalid transaction data");return N.fromAmino({type:Kt.aminoConverters[de].aminoType,value:JSON.parse(me)})});if(b==="initia"){const{srcDenom:de,quantity:me}=c,{decimals:jt}=E(de),nt=await g({messages:x,chainId:d,internal:1,spendCoins:[{denom:de,amount:w.toBaseUnit(me,{decimals:jt})}]}),Pt=p({txHash:nt,chainId:d});return{txHash:nt,wait:Pt}}const $=j(h)?.getProvider();if(!$)throw new Error("Wallet not connected");const T=$.getOfflineSignerOnlyAmino(d),R=await qe.SigningStargateClient.connectWithSigner(I.rpc,T,{registry:S,aminoTypes:N}),L=await R.getAllBalances(u),q=I.fee_assets.find(de=>L.some(me=>me.denom===de.denom&&M(me.amount).gt(0)));if(!q){const me=["Insufficient balance for fees.",`Available fee assets: ${I.fee_assets.map(jt=>E(jt.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(me)}const{denom:H,gas_price:ie}=q;if(!ie)throw new Error(`Gas price not found for ${H}`);const O=await R.simulate(u,x,""),be=qe.GasPrice.fromString(ie.average+H),tt=qe.calculateFee(Math.ceil(O*Wt),be),Ke=await R.signAndBroadcastSync(u,x,tt),st=Qr({txHash:Ke,client:R});return{txHash:Ke,wait:st}}if("evm_tx"in e){const{chain_id:x,to:$,value:T,data:R}=e.evm_tx,L=await _(),q=await L.getSigner();await xn(L,I);const H=await q.sendTransaction({chainId:x,to:$,value:T,data:`0x${R}`});return{txHash:H.hash,wait:H.wait()}}throw new Error("Unlisted chain type")}catch(x){throw await Fe(x)}},onSuccess:async({txHash:x,wait:$})=>{localStorage.removeItem(U.BRIDGE_QUANTITY),s(-1),n({type:"loading",title:"Transaction is pending..."});try{await $;const T=Pn(l)==="OP Bridge withdrawal",R=T?{success:!0,error:null}:await Hu(y,x,d);if(!R.success&&R.error){const O=R.error instanceof Error?R.error.message:String(R.error);n({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${O}. The transaction may still be processing.`,autoHide:!0})}const L=R.success,H=zu({txHash:x,srcChainId:d,route:l,values:c,recipient:m},L);a(H.tx,H.details),r(Lu(o));const ie=rn(c,x);if(i("Bridge Transaction Success",ie),T){const O=Ku(H.tx,l,m);P(H.tx,O)}}catch(T){const R=T instanceof Error?T.message:String(T);r({type:"error",title:"Transaction not confirmed",description:R});const L={...rn(c,x),error:R};i("Bridge Confirmation Failed",L)}finally{D.invalidateQueries({queryKey:De.balances(d,u).queryKey})}},onError:async x=>{const $=b==="initia"?await Ct(x,C(d),F):x;n({type:"error",title:"Transaction failed",description:$.message});const T=rn(c);i("Bridge Transaction Failed",{...T,error:$.message})}})}function Uu(){const e=Le(),s=ae(),n=In(),{route:r,values:o}=Dt(),a=pt();return A.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 Mu(s,a(r.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:m,msg:h})=>Kt.aminoTypes.fromAmino({type:Kt.aminoConverters[m].aminoType,value:JSON.parse(h)})),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 Fe(i)}}})}function Lu(e){return{type:"info",title:"Transaction submitted",description:f.createElement(f.Fragment,null,"Check ",f.createElement(Nn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function rn(e,s){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:s}}function zu(e,s){const{txHash:n,srcChainId:r,route:o,values:a}=e,i={chainId:r,txHash:n},l=Pn(o)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:o,values:a,state:l?"success":void 0,tracked:s},isOpWithdraw:l}}function Ku(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 Hu(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 Fe(i)};await new Promise(l=>setTimeout(l,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Wu(e){const{chainId:s,txHash:n,tracked:r}=e,o=Le();return A.useQuery({queryKey:De.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 Fe(a)}},select:({tx_hash:a})=>a,retry:6,retryDelay:5e3,staleTime:K.INFINITY,enabled:!r})}function Qu(e){const{timestamp:s,chainId:n,txHash:r,tracked:o,state:a}=e,i=Le();return A.useQuery({queryKey:De.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(),m=Math.floor((d-u)/1e3);return m<=0?1e3:m<=300?5e3:60*1e3},staleTime:K.INFINITY})}var _s=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(_s||{});function Pn(e){const{operations:s,dest_asset_denom:n}=e;return v.has("op_init_transfer",v.head(s))&&n==="uinit"?"OP Bridge withdrawal":"Skip"}const Vu="_success_t4dfk_1",Gu="_error_t4dfk_5",ar={success:Vu,error:Gu},Yu=({tx:e})=>{const[s,n]=Io(e);if(!s)throw new Error("Bridge history details not found");const{data:r}=Qu(s),o=s.state??Zu(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:ar.error,children:t.jsx(k.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:ar.success,children:t.jsx(k.IconCheckCircleFilled,{size:14})});default:return t.jsx(gt,{size:14})}};function Zu(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 Ju="_link_12p3n_1",Xu="_header_12p3n_22",eh="_title_12p3n_30",th="_date_12p3n_36",sh="_explorer_12p3n_40",nh="_fees_12p3n_55",rh="_label_12p3n_63",oh="_content_12p3n_67",ah="_route_12p3n_73",ih="_row_12p3n_78",ch="_asset_12p3n_84",lh="_amount_12p3n_92",dh="_chain_12p3n_97",uh="_account_12p3n_106",hh="_arrow_12p3n_113",te={link:Ju,header:Xu,title:eh,date:th,explorer:sh,fees:nh,label:rh,content:oh,route:ah,row:ih,asset:ch,amount:lh,chain:dh,account:uh,arrow:hh},mh=({tx:e})=>{const[s,n]=Io(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}=Wu(s),{address:u="",connector:m}=ve.useAccount(),{find:h}=Ps();f.useEffect(()=>{d&&n(L=>{if(!L)throw new Error("Bridge history details not found");return{...L,tracked:!0}})},[n,d]);const{amount_in:_,amount_out:g,source_asset_chain_id:p,source_asset_denom:j,dest_asset_chain_id:S,dest_asset_denom:N,estimated_fees:I=[]}=a,b=Pe(p),E=Pe(S),D=Me(j,p),F=Me(N,S),C=(L,q)=>q?t.jsx(Q,{src:q,width:12,height:12}):w.InitiaAddress.equals(L,u)?t.jsx(Q,{src:m?.icon,width:12,height:12}):t.jsx(k.IconWallet,{size:12}),P=(L,{symbol:q,decimals:H,logo_uri:ie},{chain_name:O,pretty_name:be,...tt},Ke,st)=>t.jsxs("div",{className:te.row,children:[t.jsx(Rs,{assetLogoUrl:ie,chainLogoUrl:tt.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:te.asset,children:[t.jsx("span",{className:te.amount,children:w.formatAmount(L,{decimals:H})}),t.jsx("span",{children:q})]}),t.jsxs("div",{className:te.chain,children:[t.jsxs("span",{children:["on ",be||O]}),t.jsxs("div",{className:te.account,children:[st,t.jsx("span",{className:"monospace",children:w.truncate(Ke)})]})]})]})]}),y=Pn(a),x=f.useMemo(()=>{switch(y){case _s.SKIP:return"Skip Explorer";case _s.OP_WITHDRAW:return"Initia Scan"}},[y]),$=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:te.header,children:[t.jsxs("div",{className:te.title,children:[c?t.jsx(Yu,{tx:e}):t.jsx(gt,{size:14}),t.jsx("div",{className:te.date,children:At.format(new Date(l),"h:mm a")})]}),t.jsxs("div",{className:te.explorer,children:[t.jsx("span",{children:x}),t.jsx(k.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:te.route,children:[P(_,D,b,i.sender,C(i.sender,h(i.cosmosWalletName)?.image)),t.jsx("div",{className:te.arrow,children:t.jsx(k.IconArrowDown,{size:12})}),P(g,F,E,i.recipient,C(i.recipient))]}),I.length>0&&t.jsxs("div",{className:te.fees,children:[t.jsx("span",{className:te.label,children:"Fees"}),t.jsx("span",{className:te.content,children:yo(I)})]})]});if(y===_s.OP_WITHDRAW)return t.jsx(Ds,{chainId:r,txHash:o,className:te.link,children:$});const T=new URLSearchParams({tx_hash:o,chain_id:r}),R=new URL(`?${T.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:R.toString(),className:te.link,target:"_blank",children:$})},_h="_history_13u9z_1",fh="_header_13u9z_5",ph="_checkbox_13u9z_9",gh="_groups_13u9z_13",xh="_dateGroup_13u9z_21",yh="_dateHeader_13u9z_26",jh="_list_13u9z_32",ct={history:_h,header:fh,checkbox:ph,groups:gh,dateGroup:xh,dateHeader:yh,list:jh},vh=()=>{const{initiaAddress:e,hexAddress:s}=fe(),{history:n,getHistoryDetails:r}=Co(),o=n.filter(_=>r(_)),a=o.filter(_=>{const g=r(_);if(!g)return!1;const{values:p}=g,{sender:j,recipient:S}=p;return[j,S].some(N=>[e,s].includes(N))}),[i,l]=f.useState(1),[c,d]=Ne.useToggle(!a.length),u=c?o:a,m=u.slice(0,i*or),h=f.useMemo(()=>wo(m,_=>{const g=r(_);if(g)return new Date(g.timestamp)}),[m,r]);return t.jsx(xt,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:ct.history,children:[o.length>0&&o.length!==a.length&&t.jsx("header",{className:ct.header,children:t.jsx(Ru,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:ct.checkbox})}),u.length===0?t.jsx(X,{children:"No bridge/swap activity"}):t.jsx("div",{className:ct.groups,children:Object.entries(h).map(([_,g])=>t.jsxs("div",{className:ct.dateGroup,children:[t.jsx("div",{className:ct.dateHeader,children:_}),t.jsx("div",{className:ct.list,children:g.map(p=>t.jsx(pe,{children:t.jsx(mh,{tx:p})},p.txHash))})]},_))}),u.length>i*or?t.jsx(bo,{onClick:()=>l(_=>_+1)}):n.length>=ys&&t.jsxs(X,{children:["Only the latest ",ys," items are stored. Older entries will be removed automatically."]})]})})},bh=({tx:e})=>{const{mutate:s,isPending:n}=Ou(e);return t.jsx(re,{children:t.jsx(V.White,{onClick:()=>s(),loading:n&&"Signing transaction...",children:"Confirm"})})},wh="_content_c0tee_1",Ch="_info_c0tee_6",Ih="_arrow_c0tee_11",Nh="_divider_c0tee_19",Sh="_type_c0tee_26",kh="_asset_c0tee_44",Ah="_amount_c0tee_52",$h="_lower_c0tee_57",Th="_chain_c0tee_63",Eh="_address_c0tee_69",xe={content:wh,info:Ch,arrow:Ih,divider:Nh,type:Sh,asset:kh,amount:Ah,lower:$h,chain:Th,address:Eh},No=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=wn}=e,{chain_name:m,pretty_name:h,..._}=Pe(a);return t.jsxs("div",{children:[!s&&t.jsxs("div",{className:xe.arrow,children:[t.jsx("div",{className:xe.divider}),n?t.jsx(Xt,{label:n,children:t.jsx("button",{className:xe.type,children:t.jsx(k.IconArrowDown,{size:12})})}):t.jsx("span",{className:xe.type,children:t.jsx(k.IconArrowDown,{size:12})}),t.jsx("div",{className:xe.divider})]}),t.jsxs("div",{className:xe.content,children:[t.jsx(Rs,{assetLogoUrl:u,chainLogoUrl:_.logo_uri??void 0}),t.jsxs("div",{className:xe.info,children:[t.jsxs("div",{className:xe.asset,children:[t.jsx("span",{className:xe.amount,children:w.formatAmount(r,{decimals:d})}),t.jsx("span",{children:c})]}),t.jsxs("div",{className:xe.lower,children:[t.jsxs("div",{className:xe.chain,children:["on ",h||m]}),i&&t.jsx(ps,{value:i,children:({copy:g,copied:p})=>t.jsxs("button",{className:xe.address,onClick:g,children:[l,p?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:w.truncate(i)})]})})]})]})]})]})},St=e=>{const s=Me(e.denom,e.chainId);return t.jsx(No,{...e,...s})};St.Placeholder=No;const qh="_root_1l4he_1",Dh="_flexEnd_1l4he_6",Ph="_toggle_1l4he_11",Rh="_route_1l4he_34",Bh="_content_1l4he_41",Ut={root:qh,flexEnd:Dh,toggle:Ph,route:Rh,content:Bh};function Fh(e){const s=({name:n})=>n==="initia-dex"?"Initia DEX":vs.capitalCase(v.head(n?.split("-")??[])??"");if("transfer"in e)return{label:"Bridge via IBC",...e,...e.transfer};if("bank_send"in e)return{label:"Send",...e,...e.bank_send};if("swap"in e){const n=e.swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...e,...e.swap}}if("axelar_transfer"in e)return{label:"Bridge via Axelar",...e,...e.axelar_transfer};if("cctp_transfer"in e)return{label:"Bridge via CCTP",...e,...e.cctp_transfer};if("hyperlane_transfer"in e)return{label:"Bridge via Hyperlane",...e,...e.hyperlane_transfer};if("evm_swap"in e){const n=e.evm_swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...e,...e.evm_swap}}if("op_init_transfer"in e)return{label:"Bridge via OP Bridge",...e,...e.op_init_transfer};if("go_fast_transfer"in e)return{label:"Bridge via Go Fast",...e,...e.go_fast_transfer};if("eureka_transfer"in e)return{label:"Bridge via Eureka",...e,...e.eureka_transfer};if("stargate_transfer"in e)return{label:"Bridge via Stargate",...e,...e.stargate_transfer};if("layer_zero_transfer"in e)return{label:"Bridge via LayerZero",...e,...e.layer_zero_transfer};throw new Error("Unknown operation type")}const Mh=({addressList:e})=>{const{values:s,route:n}=Dt(),{source_asset_denom:r,source_asset_chain_id:o,amount_in:a,operations:i}=n,l=v.zipObj(n.required_chain_addresses,e),{find:c}=Ps(),{connector:d,address:u=""}=ve.useAccount(),[m,h]=Ne.useToggle(!1),_=i.length>1,g=t.jsx(Q,{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},j=E=>w.InitiaAddress.equals(E,u)?g:t.jsx(k.IconWallet,{size:11}),S=E=>{const{label:D,amount_out:F,denom:C,denom_out:P=C,chain_id:y,from_chain_id:x,to_chain_id:$=y??x}=E,T=l[$];return{label:_&&!m?void 0:D,amount:F,denom:P,chainId:$,address:T,walletIcon:j(T)}},N=i.map(Fh).map(S),I=N.slice(0,-1),b=N[N.length-1];return t.jsxs(Y.Collapsible.Root,{className:Ut.root,open:m,onOpenChange:h,children:[_&&t.jsx("div",{className:Ut.flexEnd,children:t.jsx(Y.Collapsible.Trigger,{className:Ut.toggle,children:m?t.jsxs(t.Fragment,{children:[t.jsx(k.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(k.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:Ut.route,children:[t.jsx(St,{...p,source:!0}),t.jsx(Y.Collapsible.Content,{className:Ut.content,children:I.map((E,D)=>t.jsx(pe,{suspenseFallback:t.jsx(St.Placeholder,{...E}),errorBoundaryProps:{fallback:t.jsx(St.Placeholder,{...E})},children:t.jsx(St,{...E})},D))}),t.jsx(St,{...b})]})]})},yn=({error:e})=>{const s=he();return t.jsx(re,{extra:t.jsx(ne,{level:"error",children:e.message}),children:t.jsx(V.White,{onClick:()=>s("/bridge"),children:"Home"})})},Oh=({children:e})=>{const s=Dt(),{route:n,values:r}=s,{required_chain_addresses:o}=n,{srcChainId:a,dstChainId:i,sender:l,recipient:c}=r,{initiaAddress:d,hexAddress:u}=fe(),m=$t(),h=pt(),_=Zt(),g=h(a),p=_(g),j=o.slice(0,-1).some(F=>{const C=h(F);return _(C)==="cosmos"})&&p!=="cosmos",[S,N]=f.useState(void 0),[I,b]=f.useState(!1),[E,D]=f.useState(null);if(f.useEffect(()=>{(async()=>{try{if(!j)return;if(!m)throw new Error("Wallet not connected");b(!0),D(null);const[{pubkey:C}]=await m.getAccounts();N(C)}catch(C){D(await Fe(C))}finally{b(!1)}})()},[j,m]),E)return t.jsx(yn,{error:E});if(I)return t.jsx(re,{children:t.jsx(V.White,{loading:I&&"Generating intermediary addresses..."})});if(!j||S){const F=o.map((C,P)=>{if(P===o.length-1){const R=h(i);return _(R)==="initia"?w.InitiaAddress(c).bech32:c}const y=h(C),x=_(y),$=h(a),T=_($);switch(x){case"initia":return d;case"evm":return u;case"cosmos":{if(T==="cosmos")return W.toBech32(y.bech32_prefix,W.fromBech32(l).data);if(!S)throw new Error("Pubkey not found");return Ht.pubkeyToAddress(Ht.encodeSecp256k1Pubkey(S),y.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(F)}return null},Uh=({tx:e,children:s})=>{const n=Rr(),r=pt(),{data:o,isLoading:a}=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 xn(h,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:j,spender:S}=p,I=await new Ze.ethers.Contract(j,_,h).allowance(m,S);return{approval:p,currentAllowance:BigInt(I.toString())}}))).filter(({approval:p,currentAllowance:j})=>j<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}=A.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,m=await n(),h=await m.getSigner();await xn(m,r(u));for(const _ of o){const{token_contract:g,spender:p,amount:j}=_,S=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new Ze.ethers.Contract(g,S,h).approve(p,j)).wait()}return!0}catch(u){throw await Fe(u)}}});return a?t.jsx(re,{children:t.jsx(V.White,{loading:"Checking approvals..."})}):o&&o.length>0&&!l?t.jsx(re,{extra:t.jsx(ne,{level:"error",children:d?.message}),children:t.jsx(V.White,{onClick:()=>i(),loading:c&&"Approving tokens...",children:"Approve tokens"})}):s},Lh=({addressList:e,signedOpHook:s,children:n})=>{const r=Le(),{route:o,values:a}=Dt(),[i,l]=f.useState(void 0),[c,d]=f.useState(!1),[u,m]=f.useState(null);return f.useEffect(()=>{(async()=>{try{if(o.required_op_hook&&!s)throw new Error("Op hook is required");d(!0),m(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(_){m(_)}finally{d(!1)}})()},[o,a,e,s,r]),u?t.jsx(yn,{error:u}):c?t.jsx(re,{children:t.jsx(V.White,{loading:c&&"Fetching messages..."})}):i?n(i):t.jsx(yn,{error:new Error("Failed to fetch messages")})},zh=({children:e})=>{const{route:s}=Dt(),n=Uu();return s.required_op_hook&&!n.data?t.jsx(re,{extra:t.jsx(ne,{level:"error",children:n.error?.message}),children:t.jsx(V.White,{onClick:()=>n.mutate(),loading:n.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(n.data)},Kh=()=>t.jsx(xt,{title:"Route preview",children:t.jsx(Oh,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(Mh,{addressList:e}),t.jsx(zh,{children:s=>t.jsx(Lh,{addressList:e,signedOpHook:s,children:n=>t.jsx(Uh,{tx:n,children:t.jsx(bh,{tx:n})})})})]})})}),So=f.createContext(null);function Fs(){return f.useContext(So)}const yt=ke.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 Ms(){const{restUrl:e}=le();return f.useMemo(()=>Z.create({prefixUrl:e}),[e])}function Hh(e){const s=Ms(),{data:n}=A.useSuspenseQuery({queryKey:yt.bridge(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:K.INFINITY});return n}const ir=20;function Wh(e){const s=ae();return A.useSuspenseInfiniteQuery({queryKey:yt.withdrawals(e,s).queryKey,queryFn:async({pageParam:n})=>{if(!s)return[];const r={limit:ir,offset:n,order:"desc"},{withdrawals:o}=await Z.create({prefixUrl:e}).get(`withdrawals/${s}`,{searchParams:r}).json();return o},getNextPageParam:n=>{const r=v.last(n)?.sequence;return n.length<ir||!r||r<=1?null:r-1},initialPageParam:0,staleTime:K.SECOND})}function Qh(e){const s=Ms(),{data:n}=A.useSuspenseQuery({queryKey:yt.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:K.SECOND});return n}function Vh({bridge_id:e,output_index:s}){const n=Ms(),{data:r}=A.useSuspenseQuery({queryKey:yt.output(e,s).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${e}/outputs/${s}`).json()}catch{return null}},staleTime:K.SECOND});return r}function Gh({bridge_id:e,sequence:s}){const r=oe().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}=A.useSuspenseQuery({queryKey:yt.outputResponse(i,s).queryKey,queryFn:()=>Z.create({prefixUrl:i}).get(`withdrawal/${s}`).json(),staleTime:K.SECOND});return l}function ko(e,s){const{bridge_id:n}=e,r=Ms(),{data:o}=A.useSuspenseQuery({queryKey:yt.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:K.SECOND});return o}function Lt(e){return Yo.sha3_256.create().update(e).digest()}function on(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=on(s.toString(),8),l=on(n.toString(),8),c=on(r.amount,8),d=ss.concatBytes(i,l,Lt(ss.utf8ToBytes(o)),Lt(ss.utf8ToBytes(a)),Lt(ss.utf8ToBytes(r.denom)),c);return Lt(Lt(d))}const Yh="_button_1btdg_1",Zh="_claimed_1btdg_23",cr={button:Yh,claimed:Zh},Jh=()=>{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=le(),m=ae(),{requestTxSync:h,waitForTxConfirmation:_}=fe(),g=Gh(e),p=W.toBase64(Ao(e)),j=ko(e,p),S=A.useQueryClient(),{mutate:N,isPending:I}=A.useMutation({mutationFn:async()=>{if(!g)throw new Error("Output not found");const{last_block_hash:b}=g;return h({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:m,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(b)}}],internal:!0})},onSuccess:async b=>{await _({chainId:u.chain_id,txHash:b}),S.invalidateQueries({queryKey:yt.withdrawalClaimed(s,p).queryKey})}});return j?t.jsxs("div",{className:cr.claimed,children:[t.jsx(k.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:cr.button,onClick:()=>N(),disabled:I,children:"Claim"})},Xh=({children:e})=>{const{withdrawalTx:s}=Fs(),n=Hh(s.bridge_id),r=Vh(s),o=f.useMemo(()=>{if(!r)return null;const{bridge_config:a}=n,{output_proposal:i}=r;return At.addSeconds(new Date(i.l1_block_time),parseFloat(a.finalization_period))},[n,r]);return e(o)},$o=1e3,em=60,tm=60,sm=24,jn=$o*em,vn=jn*tm,lr=vn*sm,nm=({date:e})=>{const s=f.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/lr),_=Math.floor(m%lr/vn),g=Math.floor(m%vn/jn),p=Math.floor(m%jn/$o);return{days:h,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(Xt,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[a,"d ",o(i),"h ",o(l),"m ",o(c),"s"]})})},rm="_container_1lz3w_1",om="_title_1lz3w_5",dr={container:rm,title:om},am=({date:e})=>t.jsxs("div",{className:dr.container,children:[t.jsx("div",{className:dr.title,children:"Claimable in"}),t.jsx(nm,{date:e})]}),im="_container_1oldz_1",cm="_icon_1oldz_7",ur={container:im,icon:cm},lm="Withdrawal will begin within an hour",hr=()=>{const e=qs();return t.jsxs("div",{className:ur.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Xt,{label:lm,children:t.jsx("span",{className:ur.icon,children:t.jsx(k.IconInfoFilled,{size:12})})})]})},dm=({children:e})=>{const{withdrawalTx:s}=Fs(),n=Qh(s.bridge_id),r=s.output_index>Number(n?.output_index);return e(r)},um=({date:e,children:s})=>{const{chainId:n,withdrawalTx:r}=Fs(),o=W.toBase64(Ao(r)),a=ko(r,o),{setReminder:i,removeReminder:l}=qt();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:At.isPast(e.getTime())?!0:void 0})},[n,a,e,l,i,r]),s},hm=()=>t.jsx(dm,{children:e=>e?t.jsx(hr,{}):t.jsx(Xh,{children:s=>s?t.jsx(um,{date:s,children:At.isFuture(s)?t.jsx(am,{date:s}):t.jsx(Jh,{})}):t.jsx(hr,{})})}),mm="_asset_6h8u2_1",_m="_info_6h8u2_7",fm="_symbol_6h8u2_11",an={asset:mm,info:_m,symbol:fm},pm=({amount:e,denom:s})=>{const n=le(),r=kr(s,n),{symbol:o,logoUrl:a,decimals:i}=r;return t.jsxs("div",{className:an.asset,children:[t.jsx(Q,{src:a,width:32,height:32,logo:!0}),t.jsxs("div",{className:an.info,children:[t.jsx("span",{className:"monospace",children:w.formatAmount(e,{decimals:i})}),t.jsx("span",{className:an.symbol,children:o})]})]})},gm="_item_km5w2_1",xm={item:gm},ym=({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}=Wh(s),i=f.useMemo(()=>n?.pages.flat()??[],[n]),{syncReminders:l}=qt();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:xm.item,children:[t.jsx(pm,{...d}),t.jsx(pe,{suspenseFallback:null,children:t.jsx(So.Provider,{value:{chainId:e.chainId,withdrawalTx:c},children:t.jsx(hm,{})})})]},c.sequence)}),o&&t.jsx(bo,{onClick:()=>r(),disabled:a})]}):t.jsx(X,{children:"No withdrawals"})},jm="_content_dj1qm_1",vm="_title_dj1qm_5",mr={content:jm,title:vm},bm=()=>{const{chainId:e}=ft(),s=oe(),n=Gt(),[r,o]=f.useState(e??(n.metadata?.is_l1?"":n.chainId)),a=Xe(),{reminders:i}=qt(),l=r?a(r):void 0;return t.jsxs(xt,{title:"OP Bridge withdrawals",children:[t.jsx(ht,{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(pe,{children:t.jsx(ym,{chain:l})},r)]}):t.jsx(ne,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},wm="_page_1f6wh_1",Cm="_title_1f6wh_10",Im="_scrollable_1f6wh_17",Nm="_list_1f6wh_22",Sm="_item_1f6wh_32",km="_name_1f6wh_56",Am="_dimmed_1f6wh_64",$m="_recent_1f6wh_68",Tm="_installed_1f6wh_69",we={page:wm,title:Cm,scrollable:Im,list:Nm,item:Sm,name:km,dimmed:Am,recent:$m,installed:Tm},Em=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],_r=({onSuccess:e})=>{const{connectors:s,connectAsync:n}=ve.useConnect(),r=Ne.useReadLocalStorage("wagmi.recentConnectorId"),[o,a]=f.useState(null),{mutate:i,isPending:l}=A.useMutation({mutationFn:async c=>{a(c.id);try{await n({connector:c})}catch(d){throw await Fe(d)}},onSettled:()=>{a(null)},onSuccess:()=>{e?.()}});return t.jsxs("div",{className:we.page,children:[t.jsx("h1",{className:we.title,children:"Connect wallet"}),t.jsx(ze,{className:we.scrollable,children:t.jsxs("div",{className:we.list,children:[s.toSorted(v.descend(c=>c.id===r)).map(c=>{const{name:d,icon:u,id:m}=c;return t.jsxs("button",{className:we.item,onClick:()=>i(c),disabled:l,children:[t.jsx(Q,{src:u,width:24,height:24}),t.jsx("span",{className:we.name,children:d}),o===m?t.jsx(gt,{size:16}):r===m?t.jsx("span",{className:we.recent,children:"Recent"}):c.id===bs.id?null:t.jsx("span",{className:we.installed,children:"Installed"})]},m)}),Em.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:we.item,target:"_blank",children:[t.jsx(Q,{src:u,width:24,height:24}),t.jsx("span",{className:B(we.name,we.dimmed),children:c}),t.jsx(k.IconExternalLink,{size:10})]},c)})]})})]})},qm="_trigger_kivvl_1",Dm="_icon_kivvl_21",Pm="_full_kivvl_25",Rm="_triggerContent_kivvl_30",Bm="_triggerText_kivvl_38",Fm="_popoverBackdrop_kivvl_49",Mm="_popoverPositioner_kivvl_68",Om="_popoverPopup_kivvl_72",Um="_search_kivvl_96",Lm="_viewport_kivvl_101",zm="_item_kivvl_106",Km="_highlighted_kivvl_120",Hm="_active_kivvl_124",Wm="_name_kivvl_129",Qm="_extra_kivvl_133",se={trigger:qm,icon:Dm,full:Pm,triggerContent:Rm,triggerText:Bm,popoverBackdrop:Fm,popoverPositioner:Mm,popoverPopup:Om,search:Um,viewport:Lm,item:zm,highlighted:Km,active:Hm,name:Wm,extra:Qm},Rn=({value:e,onChange:s,chainIds:n,renderExtra:r,fullWidth:o})=>{const[a,i]=f.useState(""),[l,c]=f.useState(!1),[d,u]=f.useState(0),[m,h]=f.useState(),_=f.useRef([]),g=f.useRef(null),p=oe(),j=n.map(y=>p.find(x=>x.chainId===y)).filter(Boolean),S=y=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:y,height:y,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"})]}),N=f.useMemo(()=>({chainId:"",name:"All",logoUrl:S}),[]),I=f.useMemo(()=>{const y=[N,...j];if(!a)return y;const x=a.toLowerCase();return y.filter($=>$.name.toLowerCase().includes(x)||$.chainId.toLowerCase().includes(x))},[j,a,N]),b=j.find(y=>y.chainId===e)||N,E=parseInt(Xr("--drawer-offset")),D=6,F=()=>{if(i(""),u(-1),g.current){const x=g.current.getBoundingClientRect().bottom+D,$=window.innerHeight-x-2*E;h($)}c(!0)};f.useEffect(()=>{d>=0&&d<_.current.length&&_.current[d]?.scrollIntoView({block:"nearest",behavior:"auto"})},[d]);const C=f.useCallback(y=>{switch(y.key){case"ArrowDown":y.preventDefault(),u(x=>(x+1)%I.length);break;case"ArrowUp":y.preventDefault(),u(x=>(x-1+I.length)%I.length);break;case"Enter":y.preventDefault(),I[d]&&(s(I[d].chainId),c(!1));break;case"Escape":y.preventDefault(),c(!1);break}},[I,d,s,c]),P=y=>{s(y),c(!1)};return t.jsxs(vt.Popover.Root,{open:l,onOpenChange:F,modal:"trap-focus",children:[t.jsx(vt.Popover.Trigger,{render:t.jsxs("button",{className:B(se.trigger,{[se.full]:o}),"aria-expanded":l,role:"listbox",ref:g,children:[t.jsxs("div",{className:se.triggerContent,children:[typeof b.logoUrl=="string"?t.jsx(Q,{src:b.logoUrl,width:14,height:14,logo:!0}):b.logoUrl(14),t.jsx("span",{className:se.triggerText,children:b.name})]}),t.jsx(k.IconChevronDown,{size:16,className:se.icon})]})}),t.jsxs(vt.Popover.Portal,{container:mt(),children:[t.jsx(vt.Popover.Backdrop,{className:se.popoverBackdrop,onClick:()=>c(!1)}),t.jsx(vt.Popover.Positioner,{className:se.popoverPositioner,align:"end",side:"bottom",sideOffset:D,collisionAvoidance:{side:"none"},children:t.jsxs(vt.Popover.Popup,{className:B(se.popoverPopup,{[se.full]:o}),style:{maxHeight:m},children:[t.jsx(Bs,{value:a,onChange:y=>{i(y.target.value),u(0)},onClear:()=>i(""),onKeyDown:C,placeholder:"Search appchains",rootClassName:se.search,ref:Jt()}),t.jsx("div",{className:se.viewport,role:"listbox",children:I.length===0?t.jsx(X,{children:"No appchains found"}):I.map(({chainId:y,name:x,logoUrl:$},T)=>t.jsxs("div",{className:B(se.item,{[se.highlighted]:T===d,[se.active]:e===y}),onClick:()=>P(y),onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),P(y))},onMouseEnter:()=>u(T),role:"option","aria-selected":e===y,tabIndex:-1,ref:R=>{R&&(_.current[T]=R)},children:[typeof $=="string"?t.jsx(Q,{src:$,width:16,height:16,logo:!0}):$(16),t.jsx("span",{className:se.name,children:x}),r&&t.jsx("span",{className:se.extra,children:r(y)})]},y))})]})})]})]})},Vm="_container_t1267_1",Gm="_controls_t1267_7",Ym="_search_t1267_13",Bn={container:Vm,controls:Gm,search:Ym},Zm=({children:e})=>t.jsx("div",{className:Bn.container,children:e}),Jm=({children:e})=>t.jsx("div",{className:Bn.controls,children:e}),Xm=e=>t.jsx(Bs,{...e,rootClassName:Bn.search}),Ye={Root:Zm,Controls:Jm,SearchInput:Xm},e_=G.atom(""),t_=G.atom(""),s_=G.atom(""),n_=G.atom(""),r_=G.atom(""),o_="_change_1x9v4_1",a_="_positive_1x9v4_10",i_="_negative_1x9v4_14",cn={change:o_,positive:a_,negative:i_},To=({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:B(cn.change,a?cn.positive:cn.negative),children:[a?"+":"-",w.formatAmount(i,{decimals:o})," ",r||n]})},c_=({changes:e,chain:s})=>{const n=Ue(s);return e.map(({amount:r,denom:o},a)=>t.jsx(To,{amount:r,asset:n(o)},a))},l_=({changes:e,chain:s})=>{const n=Ue(s);return e.map(({amount:r,metadata:o},a)=>t.jsx(co,{metadata:o,chain:s,children:i=>t.jsx(To,{amount:r,asset:n(i)})},a))},d_=({events:e,chain:s})=>{const{initiaAddress:n,hexAddress:r}=fe();return s.metadata?.is_l1||s.metadata?.minitia?.type==="minimove"?t.jsx(l_,{changes:io(e,r),chain:s}):t.jsx(c_,{changes:ao(e,n),chain:s})},u_="_message_1g2hc_1",h_="_more_1g2hc_8",fr={message:u_,more:h_},m_=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((s,n)=>t.jsx("p",{className:fr.message,children:vs.sentenceCase(s["@type"].split("Msg")[1])},n)),e.length>3&&t.jsx("footer",{className:fr.more,children:`+${e.length-3} more`})]}),__="_link_oq58b_1",f_="_inner_oq58b_15",p_="_header_oq58b_20",g_="_time_oq58b_29",x_="_error_oq58b_35",y_="_timestamp_oq58b_39",j_="_chainInfo_oq58b_44",v_="_content_oq58b_52",b_="_messages_oq58b_59",w_="_changes_oq58b_64",Te={link:__,inner:f_,header:p_,time:g_,error:x_,timestamp:y_,chainInfo:j_,content:v_,messages:b_,changes:w_},C_=({txItem:e,chain:s})=>t.jsx(Ds,{txHash:e.txhash,chainId:s.chainId,className:Te.link,children:t.jsxs("div",{className:Te.inner,children:[t.jsxs("div",{className:Te.header,children:[t.jsxs("div",{className:Te.time,children:[e.code!==0&&t.jsx(k.IconWarningFilled,{size:14,className:Te.error}),t.jsx("span",{className:Te.timestamp,children:At.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:Te.chainInfo,children:[t.jsx(Q,{src:s.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:s.name})]})]}),t.jsxs("div",{className:Te.content,children:[t.jsx("div",{className:Te.messages,children:t.jsx(m_,{messages:e.tx.body.messages})}),t.jsx("div",{className:Te.changes,children:t.jsx(pe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(d_,{...e,chain:s})})})]})]})}),I_="_list_1wa9p_1",N_="_dateGroup_1wa9p_7",S_="_dateHeader_1wa9p_12",k_="_more_1wa9p_18",ls={list:I_,dateGroup:N_,dateHeader:S_,more:k_},A_=({list:e,chainId:s})=>{const n=ae(),r=f.useMemo(()=>wo(e,o=>{if(o.timestamp)return new Date(o.timestamp)}),[e]);return e.length===0?t.jsx(X,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ls.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{className:ls.dateGroup,children:[t.jsx("div",{className:ls.dateHeader,children:o}),a.map(i=>t.jsx(pe,{errorBoundaryProps:{fallback:null},children:t.jsx(C_,{txItem:i,chain:i.chain})},i.txhash))]},o))}),t.jsx(Ds,{chainId:s,accountAddress:n,pathSuffix:"/txs",className:ls.more,showIcon:!0,children:"View more on Initia Scan"})]})},$_=()=>{const{activities:e,isLoading:s}=_c(),[n,r]=G.useAtom(r_),o=le(),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(X,{children:"Loading activities..."}):!e.length&&!s?t.jsx(X,{children:"No activity yet"}):t.jsxs(Ye.Root,{children:[t.jsx(Ye.Controls,{children:t.jsx(Rn,{value:n,onChange:r,chainIds:a,fullWidth:!0})}),t.jsx(A_,{list:i,chainId:n||o.chainId})]})},T_="2.0.6",E_="_version_1sf5y_1",q_={version:E_},D_=()=>t.jsxs("aside",{className:q_.version,children:["v",T_]}),Eo=f.createContext(null);function qo(){return f.useContext(Eo)}const P_="_popup_nbecp_1",R_="_item_nbecp_19",ds={popup:P_,item:R_},Do=({asset:e,children:s})=>{const{denom:n,decimals:r,symbol:o,logoUrl:a,unlisted:i,address:l,chain:c}=e,{chainId:d}=c,[u,m]=f.useState(!1),h=he(),_=qo(),{showNotification:g}=En(),{defaultChainId:p}=ee(),{evm_chain_id:j}=Gt(),S=ve.useChainId(),{switchChainAsync:N}=ve.useSwitchChain(),{watchAssetAsync:I}=ve.useWatchAsset(),b=()=>{m(!1),h("/send",{denom:n,chain:c})},E=()=>{m(!1),h("/bridge",{srcChainId:d,srcDenom:n,quantity:""})},D=A.useMutation({mutationFn:async()=>{if(!l)throw new Error("Address is required");const F=a;return await N({chainId:Number(j)}),I({type:"ERC20",options:{address:l,symbol:o,decimals:r,image:F}})},onSuccess:()=>{g({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:F=>{g({type:"error",title:"Asset addition failed",description:F.message})}});return t.jsxs(We.Menu.Root,{open:u,onOpenChange:m,modal:!1,children:[t.jsx(We.Menu.Trigger,{render:s}),t.jsx(We.Menu.Portal,{container:_,children:t.jsx(We.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(We.Menu.Popup,{className:ds.popup,children:[t.jsxs(We.Menu.Item,{className:ds.item,onClick:b,children:[t.jsx(k.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(We.Menu.Item,{className:ds.item,onClick:E,disabled:i,children:[t.jsx(k.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===p&&j===S&&!!l&&t.jsxs(We.Menu.Item,{className:ds.item,onClick:()=>D.mutate(),disabled:D.isPending||D.data,children:[D.data?t.jsx(k.IconCheck,{size:16}):t.jsx(k.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},B_="_item_knoro_1",F_="_info_knoro_22",M_="_images_knoro_28",O_="_name_knoro_32",U_="_value_knoro_38",L_="_amount_knoro_46",z_="_usd_knoro_52",lt={item:B_,info:F_,images:M_,name:O_,value:U_,amount:L_,usd:z_},K_=({asset:e})=>{const{amount:s,value:n,logoUrl:r,chain:o}=e,a=w.formatAmount(s,{decimals:e.decimals});return t.jsx(Do,{asset:e,children:t.jsxs("button",{className:lt.item,children:[t.jsxs("div",{className:lt.info,children:[t.jsx(Rs,{assetLogoUrl:r,chainLogoUrl:o.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:lt.images}),t.jsx("span",{className:lt.name,children:o.name})]}),t.jsxs("div",{className:lt.value,children:[t.jsx("span",{className:lt.amount,children:a}),Number(n)>0&&t.jsx("span",{className:lt.usd,children:Se(n)})]})]})})},H_="_container_g5q73_1",W_="_assetItem_g5q73_6",Q_="_assetInfo_g5q73_26",V_="_logo_g5q73_32",G_="_symbol_g5q73_36",Y_="_chainName_g5q73_46",Z_="_chainInfos_g5q73_52",J_="_chainLogos_g5q73_58",X_="_chainLogo_g5q73_58",ef="_moreChains_g5q73_69",tf="_expandIcon_g5q73_81",sf="_expanded_g5q73_85",nf="_valueColumn_g5q73_90",rf="_amount_g5q73_99",of="_value_g5q73_90",af="_collapsibleContent_g5q73_112",cf="_chainsList_g5q73_142",J={container:H_,assetItem:W_,assetInfo:Q_,logo:V_,symbol:G_,chainName:Y_,chainInfos:Z_,chainLogos:J_,chainLogo:X_,moreChains:ef,expandIcon:tf,expanded:sf,valueColumn:nf,amount:rf,value:of,collapsibleContent:af,chainsList:cf},lf=G.atom([]),Po=({assetGroup:e})=>{const{symbol:s,logoUrl:n,assets:r}=e,o=r.length===1,[a,i]=G.useAtom(lf),l=f.useMemo(()=>$a(e),[e]),c=f.useMemo(()=>kn(e),[e]),d=a.includes(s),u=()=>{i(h=>d?v.without([s],h):v.uniq([...h,s]))},m=()=>t.jsxs("button",{className:J.assetItem,children:[t.jsxs("div",{className:J.assetInfo,children:[n&&t.jsx(Q,{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:h})=>t.jsx(Q,{src:h.logoUrl,width:16,height:16,className:J.chainLogo,logo:!0},h.chainId))}),r.length>5&&t.jsxs("span",{className:J.moreChains,children:["+",r.length-5]}),t.jsx(k.IconChevronDown,{size:16,className:B(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:Se(c)})]})]});if(o){const[h]=r;return t.jsx("div",{className:J.container,children:t.jsx(Do,{asset:h,children:m()})})}return t.jsx("div",{className:J.container,children:t.jsxs(Y.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(Y.Collapsible.Trigger,{asChild:!0,children:m()}),t.jsx(Y.Collapsible.Content,{className:J.collapsibleContent,children:t.jsx("div",{className:J.chainsList,children:r.map(h=>t.jsx(K_,{asset:h},h.chain.chainId))})})]})})},df="_collapsible_1spkj_1",uf="_trigger_1spkj_5",hf="_divider_1spkj_20",mf="_label_1spkj_26",_f="_chevron_1spkj_31",ff="_content_1spkj_39",pf="_list_1spkj_43",Ve={collapsible:df,trigger:uf,divider:hf,label:mf,chevron:_f,content:ff,list:pf},gf=({unlistedAssets:e})=>{const[s,n]=f.useState(!0),r=qo(),o=f.useRef(null),[a,i]=f.useState(0);f.useEffect(()=>{if(o.current){const d=o.current.scrollHeight;i(d)}},[e]);const l=d=>{if(d&&!s&&r?.current){const u=r.current;u.scrollTo({top:u.scrollHeight,behavior:"auto"}),window.setTimeout(()=>{u.scrollTo({top:u.scrollHeight,behavior:"smooth"})},150)}n(d)},c=Je.useSpring({height:s?a:0,opacity:s?1:0,config:{tension:500,friction:30,clamp:!0}});return e.length===0?null:t.jsxs(Y.Collapsible.Root,{open:s,onOpenChange:l,className:Ve.collapsible,children:[t.jsxs(Y.Collapsible.Trigger,{className:Ve.trigger,children:[t.jsx("div",{className:Ve.divider}),t.jsxs("span",{className:Ve.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(k.IconChevronDown,{className:Ve.chevron,size:12,"data-state":s?"open":"closed"}),t.jsx("div",{className:Ve.divider})]}),t.jsx(Y.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(Je.animated.div,{className:Ve.content,style:c,children:t.jsx("div",{className:Ve.list,ref:o,children:e.map(d=>t.jsx(Po,{assetGroup:{...d,assets:[d]}},d.denom))})})})]})},xf="_list_szwvw_1",yf={list:xf},jf=()=>{const[e,s]=G.useAtom(e_),[n,r]=G.useAtom(t_),{assetGroups:o,unlistedAssets:a,chainsByValue:i,totalValue:l,isLoading:c}=An(),d=i.map(({chainId:h})=>h),u=f.useMemo(()=>{const h=e?o.filter(g=>{const{symbol:p,assets:j}=g;return p.toLowerCase().includes(e.toLowerCase())||j.some(({denom:S,address:N})=>S.toLowerCase().includes(e.toLowerCase())||N?.toLowerCase().includes(e.toLowerCase()))}):o;return n?h.map(g=>({...g,assets:g.assets.filter(({chain:p})=>p.chainId===n)})).filter(g=>g.assets.length>0):h},[o,e,n]),m=f.useMemo(()=>{const h=e?a.filter(({denom:g,address:p})=>g.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):a;return n?h.filter(({chain:g})=>g.chainId===n):h},[a,e,n]);return c&&o.length===0?t.jsx(X,{children:"Loading assets..."}):!u.length&&!m.length&&!e&&!n&&!c?t.jsx(X,{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(Rn,{value:n,onChange:r,chainIds:d,renderExtra:h=>{if(!h)return Se(l);const _=i.find(g=>g.chainId===h);return _?Se(_.value):null}})]}),t.jsx("div",{children:u.length===0&&m.length===0?t.jsx(X,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:yf.list,children:u.map(h=>t.jsx(Po,{assetGroup:h},h.symbol))}),t.jsx(gf,{unlistedAssets:m})]})})]}),t.jsx(D_,{})]})},vf="_thumbnail_1lblb_1",bf="_placeholder_1lblb_16",wf="_clickable_1lblb_22",zt={thumbnail:vf,placeholder:bf,clickable:wf},Fn=({nftInfo:e,size:s,onClick:n})=>{const{collection_addr:r,object_addr:o,nft:a,chain:i}=e,{glyphUrl:l}=ee(),c=new URL(`/v1/${i.chainId}/${r}/${o||a.token_id}`,l).toString();return n?t.jsx("button",{className:B(zt.thumbnail,zt.clickable),onClick:n,style:{width:s,height:s},children:t.jsx(Q,{src:c,classNames:{placeholder:zt.placeholder}})}):t.jsx("div",{className:zt.thumbnail,style:{width:s,height:s},children:t.jsx(Q,{src:c,classNames:{placeholder:zt.placeholder}})})},Cf="_nftItem_eopro_1",If="_collectionName_eopro_9",Nf="_nftName_eopro_19",Sf="_chainInfo_eopro_29",us={nftItem:Cf,collectionName:If,nftName:Nf,chainInfo:Sf},kf=({normalizedNft:e})=>{const{collection_name:s,name:n,chain:r}=e,o=he();return t.jsxs("div",{className:us.nftItem,children:[t.jsx(Fn,{nftInfo:e,onClick:()=>o("/nft",e)}),t.jsxs("div",{children:[t.jsx("div",{className:us.collectionName,children:s}),t.jsx("div",{className:us.nftName,children:n}),t.jsxs("div",{className:us.chainInfo,children:[t.jsx(Q,{src:r.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:r.name})]})]})]})},Ro=ke.createQueryKeys("interwovenkit:nft",{nfts:(e,s)=>[e,s],metadata:e=>[e]});function Af(e,s){const{nft:n}=e,r=s.name??n.token_id;return{...e,...n,...s,name:r}}function $f(e,s){return e.flatMap((n,r)=>(s[r]??[]).map(a=>({...a,chain:n})))}const Tf=()=>{const e=ae(),s=oe(),n=A.useQueries({queries:s.map(c=>({queryKey:Ro.nfts(c.indexerUrl,e).queryKey,queryFn:()=>$r(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:c.indexerUrl},"tokens"),staleTime:K.SECOND}))}),r=n.map(v.prop("data")),o=$f(s,r),a=o.reduce((c,{chain:d})=>({...c,[d.chainId]:(c[d.chainId]||0)+1}),{}),i=Object.values(a).reduce((c,d)=>c+d,0),l=n.some(c=>c.isLoading);return{nftInfos:o,chainCounts:a,totalCount:i,isLoading:l}};function Ef(e){const s=pr(e);return A.useQuery({queryKey:Ro.metadata(s).queryKey,queryFn:async()=>{try{if(!s)return{};const n=await Z.get(s).json();return{...n,image:pr(n.image)}}catch{return{}}},staleTime:K.INFINITY})}function pr(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const qf=({nftInfo:e,children:s})=>{const{data:n={}}=Ef(e.nft.uri),r=Af(e,n);return s(r)},Df="_grid_a1fhu_1",Pf={grid:Df},Rf=()=>{const[e,s]=G.useAtom(s_),[n,r]=G.useAtom(n_),{nftInfos:o,chainCounts:a,totalCount:i,isLoading:l}=Tf(),c=f.useMemo(()=>o.filter(({collection_addr:u,collection_name:m,nft:h,object_addr:_,chain:g})=>{if(n&&g.chainId!==n)return!1;if(e){const p=e.trim().toLowerCase();return u.toLowerCase().includes(p)||m.toLowerCase().includes(p)||h.token_id.toLowerCase().includes(p)||_.toLowerCase().includes(p)}return!0}),[o,n,e]),d=f.useMemo(()=>Array.from(new Set(o.map(({chain:u})=>u.chainId))),[o]);return l&&o.length===0?t.jsx(X,{children:"Loading NFTs..."}):!o.length&&!e&&!l?t.jsx(X,{children:"No NFTs"}):t.jsxs(Ye.Root,{children:[t.jsxs(Ye.Controls,{children:[t.jsx(Ye.SearchInput,{value:e,onChange:u=>s(u.target.value),onClear:()=>s(""),placeholder:"Search NFTs"}),t.jsx(Rn,{value:n,onChange:r,chainIds:d,renderExtra:u=>u?a[u]||0:i})]}),c.length===0?t.jsx(X,{children:"No NFTs found"}):t.jsx("div",{className:Pf.grid,children:c.map(u=>{const{collection_addr:m,nft:h}=u;return t.jsx(qf,{nftInfo:u,children:_=>t.jsx(kf,{normalizedNft:_})},m+h.token_id)})})]})},Bf="_totalValue_1udv1_1",Ff="_totalLabel_1udv1_7",Mf="_totalAmount_1udv1_13",Of="_loading_1udv1_18",Uf="_nav_1udv1_23",Lf="_item_1udv1_28",zf="_tabs_1udv1_51",Kf="_tab_1udv1_51",Ce={totalValue:Bf,totalLabel:Ff,totalAmount:Mf,loading:Of,nav:Uf,item:Lf,tabs:zf,tab:Kf},Hf=()=>{po();const e=he(),s=ks(),{totalValue:n,isLoading:r}=An(),o=f.useRef(null);return t.jsx(Eo.Provider,{value:o,children:t.jsxs(ze,{ref:o,children:[t.jsxs("div",{className:Ce.totalValue,children:[t.jsx("div",{className:Ce.totalLabel,children:"Total value"}),t.jsx("div",{className:B(Ce.totalAmount,{[Ce.loading]:r}),children:Se(n)})]}),t.jsxs("div",{className:Ce.nav,children:[t.jsxs(Nn,{to:"/send",className:Ce.item,children:[t.jsx(k.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs("button",{className:Ce.item,onClick:()=>e("/bridge"),children:[t.jsx(k.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]})]}),t.jsxs(He.Tabs.Root,{value:s,onValueChange:e,children:[t.jsxs(He.Tabs.List,{className:Ce.tabs,children:[t.jsx(He.Tabs.Tab,{className:Ce.tab,value:"/",children:"Assets"}),t.jsx(He.Tabs.Tab,{className:Ce.tab,value:"/nfts",children:"NFTs"}),t.jsx(He.Tabs.Tab,{className:Ce.tab,value:"/activity",children:"Activity"})]}),t.jsx(He.Tabs.Panel,{value:"/",children:t.jsx(jf,{})}),t.jsx(He.Tabs.Panel,{value:"/nfts",children:t.jsx(Rf,{})}),t.jsx(He.Tabs.Panel,{value:"/activity",children:t.jsx($_,{})})]})]})})},Wf="_header_4z0mk_1",Qf="_collectionName_4z0mk_6",Vf="_name_4z0mk_12",Gf="_chainInfo_4z0mk_18",Yf="_attributes_4z0mk_28",Zf="_title_4z0mk_31",Jf="_count_4z0mk_36",Xf="_item_4z0mk_40",ep="_type_4z0mk_46",tp="_value_4z0mk_52",Ee={header:Wf,collectionName:Qf,name:Vf,chainInfo:Gf,attributes:Yf,title:Zf,count:Jf,item:Xf,type:ep,value:tp},sp=ke.createQueryKeys("interwovenkit:nft-details",{validation:e=>[e]}),np=()=>{const e=he(),s=ft(),{collection_name:n,name:r,attributes:o,chain:a,collection_addr:i,token_id:l,object_addr:c}=s,{routerApiUrl:d}=ee(),u=Yt(),m=le(),{initiaAddress:h}=fe(),{simulateTx:_}=Sn(),g=A.useQuery({queryKey:sp.validation({collection_addr:i,nft:s,token_id:l,object_addr:c,sender:h,recipient:h,srcChain:a,dstChain:a,layer1:m,routerApiUrl:d}).queryKey,queryFn:async()=>{const p={from_address:h,from_chain_id:a.chainId,to_address:h,to_chain_id:a.chainId,collection_address:i,token_ids:[l],object_addresses:[c]},{msgs:j}=await Z.create({prefixUrl:d}).post("nft",{json:p}).json(),S=j.map(N=>u.fromAmino(N));return await _({messages:S,chainId:a.chainId})},staleTime:K.INFINITY});return t.jsxs(xt,{title:"NFT details",children:[t.jsxs("header",{className:Ee.header,children:[t.jsx(Fn,{nftInfo:s}),t.jsxs("div",{children:[t.jsx("div",{className:Ee.collectionName,children:n}),t.jsx("h2",{className:Ee.name,children:r}),t.jsxs("div",{className:Ee.chainInfo,children:[t.jsx(Q,{src:a.logoUrl,width:14,height:14,logo:!0}),t.jsx("span",{children:a.name})]})]})]}),t.jsx(re,{children:t.jsx(V.White,{onClick:()=>e("/nft/send",s),disabled:!g.data,loading:g.isLoading?"Checking transferability...":void 0,sm:!0,children:g.error?"Non-transferable NFT":"Send"})}),o&&t.jsxs("div",{className:Ee.attributes,children:[t.jsxs("header",{className:Ee.title,children:["Traits ",t.jsxs("span",{className:Ee.count,children:["(",o.length,")"]})]}),t.jsx("div",{children:o.map(({trait_type:p,value:j})=>t.jsxs("div",{className:Ee.item,children:[t.jsx("div",{className:Ee.type,children:p}),t.jsx("div",{className:Ee.value,children:j})]},p))})]})]})};function rp({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 op({denom:e,balances:s,gasPrices:n,lastFeeDenom:r,gas:o}){const a=s.find(d=>d.denom===e)?.amount??"0",i=rp({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 ap=({chain:e,onSelect:s})=>{const n=ua(e);return t.jsx(es,{assets:n,onSelect:s})},ip=({afterSelect:e})=>{const{watch:s,setValue:n}=ce.useFormContext(),{chainId:r,denom:o}=s(),{chainId:a}=s(),[i,l]=f.useState(a),c=Oe(i),d=oe(),u=m=>{if(r===i&&o===m){e();return}n("chainId",i),n("denom",m),n("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(ht.Stack,{children:t.jsx(ht,{chains:d,value:i,onSelect:l})}),t.jsx(pe,{suspenseFallback:t.jsx(es.Placeholder,{}),children:t.jsx(ap,{chain:c,onSelect:u})},i)]})},cp="_fields_brpej_1",lp="_divider_brpej_11",gr={fields:cp,divider:lp},dp=ke.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),up=()=>{const{address:e,initiaAddress:s,estimateGas:n,requestTxSync:r}=fe(),{register:o,watch:a,setValue:i,handleSubmit:l,formState:c}=ce.useFormContext(),{errors:d}=c,{chainId:u,denom:m,recipient:h,quantity:_,memo:g}=a(),p=Oe(u),j=Cn(p),S=ro(p),N=oo(p),I=kr(m,p),{data:b}=Cs(p),{decimals:E}=I,D=j.find(O=>O.denom===m)?.amount??"0",F=b?.find(({id:O})=>O===m)?.price,{data:C=0,isLoading:P}=A.useQuery({queryKey:dp.gas({chainId:u,denom:m,recipient:h,initiaAddress:s}).queryKey,queryFn:()=>{const O=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Kn.MsgSend.fromPartial({fromAddress:s,toAddress:w.InitiaAddress(h).bech32,amount:[{denom:m,amount:"1"}]})}];return n({messages:O,chainId:u})},enabled:w.InitiaAddress.validate(h),staleTime:K.INFINITY}),y=Math.ceil(C*Wt),x=op({denom:m,balances:j,gasPrices:S,lastFeeDenom:N,gas:y}),$=M(D).isZero(),R=S.some(({denom:O})=>O===m)&&P,L=$||R,{mutate:q,isPending:H}=A.useMutation({mutationFn:({chainId:O,denom:be,quantity:tt,recipient:Ke,memo:st})=>{const de=w.toBaseUnit(tt,{decimals:E}),me=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Kn.MsgSend.fromPartial({fromAddress:s,toAddress:w.InitiaAddress(Ke).bech32,amount:[{denom:be,amount:de}]})}];return r({messages:me,memo:st,chainId:O,gas:C,gasAdjustment:Wt,gasPrices:S,spendCoins:[{denom:be,amount:de}],internal:"/"})}}),ie=f.useMemo(()=>{if(!_)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},[_,h,d.quantity,d.recipient,d.memo]);return t.jsx(xt,{title:"Send",children:t.jsxs("form",{onSubmit:l(O=>q(O)),children:[t.jsxs("div",{className:gr.fields,children:[t.jsx(fn,{selectButton:t.jsx(_t,{title:"Select chain and asset",content:O=>t.jsx(ip,{afterSelect:O}),children:t.jsx(vo,{asset:I,chain:p})}),quantityInput:t.jsx(xs,{balance:D,decimals:E}),balanceButton:t.jsx(go,{onClick:()=>i("quantity",w.fromBaseUnit(x,{decimals:E}),{shouldValidate:!0}),disabled:L,children:w.formatAmount(D??"0",{decimals:E})}),value:_?F?Se(M(_).times(F)):"$-":"$0"}),t.jsx("div",{className:gr.divider}),t.jsx(Dn,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...o("memo",{validate:O=>!O||new Blob([O]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),t.jsx(ne.Stack,{children:!g&&t.jsx(ne,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(re,{children:t.jsx(V.White,{type:"submit",loading:(P?"Estimating gas...":!1)||H,disabled:!!ie,children:ie??"Confirm"})})]})})},hp=()=>{const e=ft(),s=Gt(),n=Qt(s),{chain:r=s}=e,o=v.head(n);if(!e.denom&&!o)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??o?.denom,i=ce.useForm({mode:"onChange",defaultValues:{chainId:r.chainId,denom:a,quantity:"",recipient:"",memo:""}});return t.jsx(ce.FormProvider,{...i,children:t.jsx(up,{})})},mp="_header_5w36t_1",_p="_name_5w36t_8",fp="_collection_5w36t_15",pp="_nft_5w36t_20",gp="_fields_5w36t_24",xp="_chain_5w36t_29",wt={header:mp,name:_p,collection:fp,nft:pp,fields:gp,chain:xp},yp=ke.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),jp=()=>{const e=oe(),s=ft(),{chain:n,collection_addr:r,collection_name:o,name:a}=s,{routerApiUrl:i}=ee(),l=Yt(),c=le(),{address:d,initiaAddress:u,requestTxSync:m}=fe(),{watch:h,setValue:_,handleSubmit:g,formState:p}=ce.useFormContext(),{errors:j}=p,S=h(),{recipient:N,dstChainId:I}=S,b=Oe(I),E=A.useQuery({queryKey:yp.simulation({collection_addr:r,nft:s,sender:u,recipient:N,srcChain:n,dstChain:b,layer1:c,routerApiUrl:i}).queryKey,queryFn:async()=>{const $={from_address:u,from_chain_id:n.chainId,to_address:w.InitiaAddress(N).bech32,to_chain_id:b.chainId,collection_address:r,token_ids:[s.token_id],object_addresses:[s.object_addr]},{msgs:T}=await Z.create({prefixUrl:i}).post("nft",{json:$}).json();return T.map(R=>l.fromAmino(R))},enabled:w.InitiaAddress.validate(N)}),{data:D,isLoading:F,error:C}=E,{mutate:P,isPending:y}=A.useMutation({mutationFn:async()=>{if(!D)throw new Error("Route not found");await m({messages:D,chainId:n.chainId,internal:"/nfts"})}}),x=f.useMemo(()=>{if(!N)return"Enter recipient address";if(j.recipient)return j.recipient.message;if(C)return"Route not found"},[N,j.recipient,C]);return t.jsxs("form",{onSubmit:g(()=>P()),children:[t.jsxs("header",{className:wt.header,children:[t.jsx(Fn,{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:a})]})]}),t.jsxs("div",{className:wt.fields,children:[t.jsx(Y.VisuallyHidden.Root,{children:t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(_t,{title:"Destination appchain",content:$=>t.jsx(jo,{onSelect:({chainId:T})=>{_("dstChainId",T),$()},list:e,getImage:T=>T.logoUrl,getName:T=>T.name,getKey:T=>T.chainId}),className:B("input",wt.chain),children:[t.jsx(Q,{src:b.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:b.name})]})]})}),t.jsx(Dn,{myAddress:d,ref:Jt()})]}),t.jsx(re,{children:t.jsx(V.White,{loading:(F?"Finding route...":!1)||y,disabled:!!x,children:x??"Confirm"})})]})},vp=()=>{const{chain:e}=ft(),s=ce.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(xt,{title:"Send NFT",children:t.jsx(ce.FormProvider,{...s,children:t.jsx(jp,{})})})},Bo=()=>{const e=he(),s=ks(),n=Et(),{closeDrawer:r}=Tt(),{closeModal:o}=As();f.useEffect(()=>{o(),s.startsWith("/bridge/")&&e("/bridge"),(s==="/collection"||s.startsWith("/nft"))&&e("/nfts")},[n]);const a=$s();if(f.useEffect(()=>{a("Page View")},[s,a]),s==="/connect")return n?null:t.jsx(_r,{onSuccess:r});if(s==="/blank")return null;if(!n)return t.jsx(_r,{});switch(s){case"/":case"/nfts":case"/activity":return t.jsx(Hf,{});case"/send":return t.jsx(hp,{},n);case"/nft":return t.jsx(np,{});case"/nft/send":return t.jsx(vp,{},n);case"/bridge":return t.jsx(Eu,{},n);case"/bridge/preview":return t.jsx(Kh,{});case"/bridge/history":return t.jsx(vh,{});case"/op/withdrawals":return t.jsx(bm,{});case"/tx":return t.jsx(uo,{})}},bp="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",wp=()=>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:bp}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),Cp=()=>{oe();const e=le();return $n(),kt(localStorage.getItem(U.BRIDGE_SRC_CHAIN_ID)??e.chainId),kt(localStorage.getItem(U.BRIDGE_DST_CHAIN_ID)??e.chainId),null},Ip=new A.QueryClient({defaultOptions:{queries:{retry:0}}}),Np=({children:e,...s})=>(f.useEffect(()=>{Ma()},[]),Ne.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(wp,{}),t.jsx(Cr.Provider,{value:{...wr,...s},children:t.jsx(Or,{children:t.jsx(gl,{children:t.jsx(Y.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(pl,{children:t.jsxs(rl,{children:[e,t.jsxs(A.QueryClientProvider,{client:Ip,children:[t.jsx(Oa,{}),t.jsx(pe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(Cp,{})}),t.jsx(Hi,{children:t.jsx(Bo,{})})]})]})})})})})})]}):null),Sp=({bridge:e})=>t.jsx(Or,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(to.Provider,{value:!!e,children:t.jsx(pe,{children:t.jsx(Bo,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=Wt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=br;exports.InterwovenKit=Sp;exports.InterwovenKitProvider=Np;exports.MAINNET=wr;exports.MoveError=Lr;exports.TESTNET=Jo;exports.initiaPrivyWallet=ea;exports.initiaPrivyWalletConnector=Xo;exports.initiaPrivyWalletOptions=bs;exports.injectStyles=si;exports.useAddress=Et;exports.useHexAddress=Es;exports.useInitiaAddress=ae;exports.useInterwovenKit=fe;exports.usePortfolio=An;exports.useUsernameQuery=Vr;
|