@initia/interwovenkit-react 2.0.0-rc.4 → 2.0.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Go=Object.defineProperty;var Yo=(e,n,s)=>n in e?Go(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var ut=(e,n,s)=>Yo(e,typeof n!="symbol"?n+"":n,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Se=require("ethers"),z=require("@cosmjs/encoding"),H=require("ky"),hr=require("@mysten/bcs"),_r=require("@privy-io/cross-app-connect/rainbow-kit"),ye=require("wagmi"),$=require("@tanstack/react-query"),pt=require("cosmjs-types/cosmos/tx/v1beta1/tx"),Bt=require("@cosmjs/amino"),Ie=require("@cosmjs/stargate"),_e=require("jotai"),xt=require("@initia/amino-converter"),t=require("react/jsx-runtime"),A=require("ramda"),f=require("react"),fr=require("jotai/utils"),qe=require("@lukemorales/query-key-factory"),Jo=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Yn=require("@cosmjs/amino/build/signdoc"),Jn=require("@cosmjs/crypto"),Ps=require("@cosmjs/math"),hn=require("@cosmjs/proto-signing"),Bs=require("@cosmjs/tendermint-rpc"),Zn=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Zo=require("cosmjs-types/cosmos/auth/v1beta1/auth"),Xo=require("cosmjs-types/google/protobuf/any"),F=require("bignumber.js"),nt=require("@noble/hashes/utils"),ea=require("@noble/hashes/sha2"),ms=require("@noble/hashes/sha3"),T=require("radix-ui"),ue=require("usehooks-ts"),pr=require("react-error-boundary"),R=require("clsx"),Fs=require("nanoid"),gr=require("react-dom"),je=require("@react-spring/web"),b=require("@initia/icons-react"),Ot=require("change-case"),D=require("@initia/utils"),ta=require("qr-code-styling"),xr=require("xss"),jt=require("date-fns"),J=require("zod"),oe=require("react-hook-form"),hs=require("@hookform/resolvers/zod"),na=require("cosmjs-types/cosmos/bank/v1beta1/tx"),yr=require("react-merge-refs"),sa=require("react-intersection-observer"),ra=require("@initia/opinit.proto/opinit/ophost/v1/tx"),M={toBytes(e,n=20){if(!e)throw new Error("address is required");if(e.match(/^(0x)?[0-9a-fA-F]+$/)){const r=e.replace(/^0x/,"").padStart(n*2,"0");return z.fromHex(r)}const{data:s}=z.fromBech32(e);return s.length>=n?s:new Uint8Array([...Array(n-s.length).fill(0),...s])},toBech32(e,n="init"){return e?z.toBech32(n,M.toBytes(e)):""},toHex(e){return e?z.toHex(M.toBytes(e)):""},toPrefixedHex(e){if(!e)return"";const n=Se.getAddress(M.toHex(e)),s=M.toBytes(e),r=s[s.length-1];return s.subarray(0,s.length-1).every(o=>o===0)&&r<16?n.replace(/^0x0+/,"0x"):n},validate(e,n="init"){if(Se.isAddress(e))return!0;try{return z.fromBech32(e).prefix===n}catch{return!1}},equals(e,n){return M.toBech32(e)===M.toBech32(n)}},Rs="usernames";function jr({restUrl:e,moduleAddress:n}){const s=H.create({prefixUrl:e});async function r(l){const{moduleAddress:c,moduleName:d,functionName:u,typeArgs:m,args:h}=l,_=`initia/move/v1/accounts/${c}/modules/${d}/view_functions/${u}`,p={type_args:m,args:h},{data:g,message:y}=await s.post(_,{json:p}).json();if(y)throw new Error(y);return JSON.parse(g)}async function a(l){if(!M.validate(l))return null;const c=await r({moduleAddress:n,moduleName:Rs,functionName:"get_name_from_address",typeArgs:[],args:[z.toBase64(M.toBytes(l,32))]});return c?c+".init":null}function o(l){return/^[A-Za-z0-9-]{3,64}\.init$/.test(l)}async function i(l){if(!o(l))return null;const c=await r({moduleAddress:n,moduleName:Rs,functionName:"get_address_from_name",typeArgs:[],args:[hr.bcs.string().serialize(l.toLowerCase().replace(".init","")).toBase64()]});return c?M.toBech32(c):null}return{restUrl:e,getUsername:a,getAddress:i,validateUsername:o}}const _s=1.4,vr=1.03,wr={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",theme:"dark"},oa={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",theme:"dark"},fs={id:"cmbq1ozyc006al70lx4uciz0q",name:"Google",iconUrl:"https://assets.initia.xyz/images/wallets/Google.webp",iconBackground:"#ffffff"},aa=_r.toPrivyWalletConnector(fs),ia=_r.toPrivyWallet(fs),br=f.createContext(null);function _n(){return f.useContext(br)}function Cr(){const{location:e}=_n();return e}function Nr(){const{path:e}=Cr();return e}function Ue(){const{state:e={}}=Cr();return e}function ca(){const{history:e}=_n();return e}function ie(){const{navigate:e}=_n();return e}function la(){const{reset:e}=_n();return e}const Ir=({children:e,initialEntry:n})=>{const[s,r]=f.useState([n??{path:"/"}]),a=s[s.length-1],o=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=A.take(u,d);return c!==void 0?A.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:a,history:s,navigate:o,reset:i},children:e})},Ut=({to:e,state:n,children:s,onClick:r,...a})=>{const o=ie(),i=l=>{l.preventDefault(),r==null||r(l),o(e,n)};return t.jsx("button",{type:"button",...a,onClick:i,children:s})},Sr=f.createContext(null),zt=()=>f.useContext(Sr),$r=f.createContext(null);function ne(){return f.useContext($r)}const L={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function ze(e){if(e instanceof H.HTTPError){const{response:n}=e,s=n.headers.get("content-type")??"";if(A.includes("application/json",s))try{const r=await n.json();if(r.message)return r.message}catch{return e.message}try{return await n.text()}catch{return e.message}}if(e instanceof Error){if(A.path(["code"],e)===4001||A.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const n=A.path(["error","message"],e),s=A.path(["cause","message"],e),r=A.path(["shortMessage"],e);return n||s||r||e.message}return String(e)}class da extends Error{constructor(s,r,a,o,i){super(s);ut(this,"originalError");ut(this,"moduleAddress");ut(this,"moduleName");ut(this,"errorCode");this.name="MoveError",this.originalError=r,this.moduleAddress=a,this.moduleName=o,this.errorCode=i}}const ua=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,An=new Map;function ma(e){const n=e.match(ua);if(!n)return null;const[,s,r,a]=n;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:r,errorCode:a.replace(/^0+/,"")||"0"}}async function ha(e,n,s){const r=`${e}:${n}`;if(An.has(r))return An.get(r);try{const a=n==="0x1"?"0x1.json":`${e}/${n}.json`,o=`${s}/errors/${a}`,{errors:i={}}=await H.get(o).json();return An.set(r,i),i}catch{return null}}function _a(e,n,s,r,a){return new da(e,n,s,r,a)}async function Xn(e,n,s){var c,d,u,m;if(!((c=n.metadata)!=null&&c.is_l1)&&((u=(d=n.metadata)==null?void 0:d.minitia)==null?void 0:u.type)!=="minimove")return e;const r=ma(e.message);if(!r)return e;const a=await ha(n.chain_name,r.moduleAddress,s),i=`Failed with code ${`0x${parseInt(r.errorCode,10).toString(16)}`} in module ${r.moduleName} at ${r.moduleAddress}`,l=((m=a==null?void 0:a[r.moduleName])==null?void 0:m[r.errorCode])||i;return _a(l,e,r.moduleAddress,r.moduleName,r.errorCode)}const de="interwovenkit",U={ADDED_CHAIN_IDS:`${de}:chain-ids:added`,OPENED_CHAIN_IDS:`${de}:chain-ids:opened`,ACTIVITY_CHAIN_ID:`${de}:activity:chain-id`,PUBLIC_KEY:`${de}:public-key`,BRIDGE_SRC_CHAIN_ID:`${de}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${de}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${de}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${de}:bridge:dst-denom`,BRIDGE_QUANTITY:`${de}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${de}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${de}:bridge:route-type`,BRIDGE_HISTORY:`${de}:bridge:history`,OP_REMINDER:`${de}:op:reminder`},ps=qe.createQueryKeys("interwovenkit:chain",{list:e=>[e],prices:e=>[e],gasPrices:e=>[e]}),fa=fr.atomWithStorage(U.ADDED_CHAIN_IDS,[]);function Qt(e){const n=A.path([0,"address"],e);if(!n)throw new Error("URL not found");return n}function pa(e){var C;const{chain_id:n,chain_name:s,pretty_name:r,logo_URIs:a,apis:o,metadata:i}=e,l=r||s,c=(a==null?void 0:a.png)??"",{rpc:d,rest:u,api:m,["json-rpc"]:h}=o,_=Qt(d),p=Qt(u),g=i!=null&&i.is_l1?Qt(m):p,y=((C=i==null?void 0:i.minitia)==null?void 0:C.type)==="minievm"?Qt(h):void 0;return{...e,chainId:n,name:l,logoUrl:c,rpcUrl:_,restUrl:p,indexerUrl:g,jsonRpcUrl:y}}function Ke(){const{defaultChainId:e,registryUrl:n,customChain:s}=ne(),{data:r}=$.useSuspenseQuery({queryKey:ps.list(n).queryKey,queryFn:()=>H.create({prefixUrl:n}).get("chains.json").json(),select:a=>(s?[s,...a.filter(i=>i.chain_id!==s.chain_id)]:a).map(pa).toSorted(A.descend(i=>i.chainId===e)),staleTime:L.MINUTE});return r}function De(){const e=Ke();return n=>{const s=e.find(r=>r.chain_id===n);if(!s)throw new Error(`Chain not found: ${n}`);return s}}function ve(e){return De()(e)}function Kt(){const{defaultChainId:e}=ne();return ve(e)}function we(){const n=Ke().find(s=>{var r;return(r=s.metadata)==null?void 0:r.is_l1});if(!n)throw new Error("Layer 1 not found");return n}function fn(e){return $.useQuery({queryKey:ps.prices(e).queryKey,queryFn:()=>H.create({prefixUrl:"https://celatone-api-prod.alleslabs.dev"}).get(`v1/initia/${e}/assets`,{searchParams:{with_prices:!0}}).json(),staleTime:L.SECOND})}function vt(){const e=Ke(),{defaultChainId:n}=ne(),[s,r]=_e.useAtom(fa),a=d=>A.uniq([n,...d]),o=a(s).map(d=>e.find(u=>u.chainId===d)).filter(Boolean),i=e.filter(d=>!a(s).includes(d.chainId));return{chains:e,addedChains:o,notAddedChains:i,addChain:d=>{r(u=>a([...u,d]))},removeChain:d=>{r(u=>a(u.filter(m=>m!==d)))}}}function ga(e){if((e==null?void 0:e.typeUrl)==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:n}=Zn.PubKey.decode(e.value);return Bt.encodeSecp256k1Pubkey(n)}return hn.decodeOptionalPubkey(e)}function xa({typeUrl:e,value:n}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:r,accountNumber:a,sequence:o}=Zo.BaseAccount.decode(n),i=ga(r);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(o)}}return Ie.accountFromAny({typeUrl:e,value:n})}function ya(e){return e.type==="initia/PubKeyEthSecp256k1"}const ja={...Bt.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function va(e){if(ya(e)){const n=Zn.PubKey.fromPartial({key:z.fromBase64(e.value)});return Xo.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(Zn.PubKey.encode(n).finish())})}return hn.encodePubkey(e)}function kr(e){if(e.length!==33||e[0]!==2&&e[0]!==3)throw new Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03");return{type:ja.ethsecp256k1,value:z.toBase64(e)}}function wa(e,n){if(n.length!==64)throw new Error("Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s.");return{pub_key:kr(e),signature:z.toBase64(n)}}const gs=()=>{const e=ne();return new hn.Registry([...xt.protoRegistry,...e.protoTypes??[]])},pn=()=>{const e=ne();return new Ie.AminoTypes({...xt.aminoConverters,...e.aminoConverters})};class ba{constructor(n,s){ut(this,"cachedPublicKey",null);this.address=n,this.signMessage=s}async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const n=`${U.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(n);if(s)return this.cachedPublicKey=z.fromHex(s),z.fromHex(s);const r=await this.getPublicKey();return this.cachedPublicKey=r,localStorage.setItem(n,z.toHex(r)),r}async getPublicKey(){const n="Sign this message to identify your Initia account.",s=await this.signMessage(n),r=Se.ethers.hashMessage(n),a=Se.ethers.SigningKey.recoverPublicKey(r,s);return Jn.Secp256k1.compressPubkey(z.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(n,s){if(this.address!==n)throw new Error("Signer address does not match the provided address");const r=Yn.escapeCharacters(Yn.sortedJsonStringify(s)),a=await this.signMessage(r),o=z.fromHex(a.replace("0x","")).subarray(0,-1),l=Jn.Secp256k1Signature.fromFixedLength(o).toFixedLength(),c=wa(await this.getCachedPublicKey(),l);return{signed:s,signature:c}}}function Er(){const e=gs(),n=pn(),s=wt(),r=Tr();return async function(a,o,i,l,c){if(!s)throw new Error("Signer not initialized");const d=await r(a),{accountNumber:u,sequence:m}=await d.getSequence(o),[h]=await s.getAccounts(),_=va(kr(h.pubkey)),p=Jo.SignMode.SIGN_MODE_EIP_191,g=i.map(x=>n.toAmino(x)),y=Yn.makeSignDoc(g,l,a,c,u,m),{signature:C,signed:N}=await s.signAmino(o,y),j={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:N.msgs.map(x=>n.fromAmino(x)),memo:c}},S=e.encode(j),w=Ps.Int53.fromString(N.fee.gas).toNumber(),v=Ps.Int53.fromString(N.sequence).toNumber(),E=hn.makeAuthInfoBytes([{pubkey:_,sequence:v}],N.fee.amount,w,N.fee.granter,N.fee.payer,p);return pt.TxRaw.fromPartial({bodyBytes:S,authInfoBytes:E,signatures:[z.fromBase64(C.signature)]})}}function wt(){const e=Z(),{signMessageAsync:n}=ye.useSignMessage();return f.useMemo(()=>new ba(e,s=>n({message:s})),[e,n])}const Tn=new Map,qn=new Map;function Ar(){const e=De();return async n=>{if(Tn.has(n))return Tn.get(n);const{rpcUrl:s}=e(n),r=await Bs.Comet38Client.create(new Bs.HttpClient(s));return Tn.set(n,r),r}}function Tr(){const e=gs(),n=pn(),s=wt(),r=Z(),a=Ar();return async o=>{const i=`${r}:${o}`;if(qn.has(i))return qn.get(i);if(!s)throw new Error("Signer not initialized");const l=await a(o),c=await Ie.SigningStargateClient.createWithSigner(l,s,{registry:e,aminoTypes:n,accountParser:xa,broadcastPollIntervalMs:1e3});return qn.set(i,c),c}}function qr(){const{connector:e}=ye.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new Se.BrowserProvider(await e.getProvider())}}const Ca=_e.atom(!1);function bt(){const e=la(),[n,s]=_e.useAtom(Ca);return{isDrawerOpen:n,openDrawer:(o,i)=>{o&&e(o,i),s(!0)},closeDrawer:()=>{s(!1)}}}const Dr="approve",gn=_e.atom(),Pr=_e.atom(null);function Br(){const e=_e.useAtomValue(gn);if(!e)throw new Error("Tx request not found");return e}function Fr(){const e=ie(),n=Z(),{defaultChainId:s,registryUrl:r}=ne(),a=De(),{openDrawer:o,closeDrawer:i}=bt(),{openModal:l,closeModal:c}=zt(),d=_e.useSetAtom(gn),u=_e.useSetAtom(Pr),m=Ar(),h=Tr(),_=wt(),p=async({messages:j,memo:S,chainId:w=s})=>{try{return await(await h(w)).simulate(n,j,S)}catch(v){throw new Error(await ze(v))}},g=async({messages:j,memo:S,chainId:w=s})=>{const v=await m(w),E=Ie.QueryClient.withExtensions(v,Ie.setupTxExtension),x=j.map(W=>xt.registry.encodeAsAny(W)),[k]=await _.getAccounts(),O=Bt.encodeSecp256k1Pubkey(k.pubkey),B=await h(w),{sequence:P}=await B.getSequence(n);return E.tx.simulate(x,S,O,P)},y=async({txRequest:j,broadcaster:S})=>{const v={...{memo:"",chainId:s,gas:j.gas||await p(j),gasAdjustment:_s,gasPrices:null,spendCoins:[],internal:!1},...j};return new Promise((E,x)=>{d({txRequest:v,resolve:async O=>{try{const B=await h(v.chainId),P=await S(B,pt.TxRaw.encode(O).finish());E(P),typeof v.internal=="string"&&e(v.internal)}catch(B){x(await Xn(B,a(v.chainId),r))}finally{k()}},reject:O=>{x(O),k()}}),v.internal?l({path:"/tx"}):o("/tx");const k=()=>{if(!v.internal){e("/blank"),i();return}c()}})},C=async j=>{const S=j.chainId??s;try{const w=await y({txRequest:j,broadcaster:async(v,E)=>await v.broadcastTxSync(E)});return j.internal&&typeof j.internal!="number"&&(u({txHash:w,chainId:S,status:"loading"}),q({txHash:w,chainId:j.chainId}).then(v=>{u({status:v.code===0?"success":"error",chainId:S,txHash:w})}).catch(()=>{u({status:"error",chainId:S,txHash:w})})),w}catch(w){throw j.internal&&typeof j.internal!="number"&&u({status:"error",chainId:S,error:w}),w}},N=j=>y({txRequest:j,broadcaster:async(S,w)=>{const v=await S.broadcastTx(w);if(v.code!==0)throw new Error(v.rawLog);return v}}),q=async({chainId:j=s,...S})=>{try{const w=await h(j);return await Rr({...S,client:w})}catch(w){throw await Xn(w,a(j),r)}};return{estimateGas:p,simulateTx:g,requestTxSync:C,requestTxBlock:N,waitForTxConfirmation:q}}async function Rr({txHash:e,client:n,timeoutSeconds:s=30,intervalSeconds:r=1}){const a=Date.now(),o=s*1e3;for(;;){const i=await n.getTx(e);if(i){if(i.code!==0)throw new Error(i.rawLog);return i}if(Date.now()-a>=o)throw new Error(`Transaction was submitted, but not found on the chain within ${s} seconds.`);await new Promise(l=>setTimeout(l,r*1e3))}}const Na=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ar=require("@privy-io/cross-app-connect/rainbow-kit"),xe=require("wagmi"),$=require("@tanstack/react-query"),y=require("@initia/utils"),mt=require("cosmjs-types/cosmos/tx/v1beta1/tx"),Et=require("@cosmjs/amino"),Ce=require("@cosmjs/stargate"),_e=require("jotai"),e=require("react/jsx-runtime"),E=require("ramda"),_=require("react"),G=require("ky"),ir=require("jotai/utils"),Ne=require("@lukemorales/query-key-factory"),nt=require("ethers"),Do=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Vs=require("@cosmjs/amino/build/signdoc"),Gs=require("@cosmjs/crypto"),L=require("@cosmjs/encoding"),$n=require("@cosmjs/math"),us=require("@cosmjs/proto-signing"),An=require("@cosmjs/tendermint-rpc"),Tt=require("@initia/amino-converter"),Ys=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Po=require("cosmjs-types/cosmos/auth/v1beta1/auth"),Ro=require("cosmjs-types/google/protobuf/any"),F=require("bignumber.js"),Fo=require("@mysten/bcs"),R=require("radix-ui"),de=require("usehooks-ts"),cr=require("react-error-boundary"),D=require("clsx"),En=require("nanoid"),un=require("react-dom"),le=require("@react-spring/web"),b=require("@initia/icons-react"),Bt=require("change-case"),Bo=require("qr-code-styling"),lr=require("xss"),ft=require("date-fns"),V=require("zod"),oe=require("react-hook-form"),mn=require("@hookform/resolvers/zod"),Tn=require("cosmjs-types/cosmos/bank/v1beta1/tx"),dr=require("react-merge-refs"),Mo=require("react-intersection-observer"),Wt=require("@noble/hashes/utils"),Oo=require("@noble/hashes/sha3"),zo=require("@initia/opinit.proto/opinit/ophost/v1/tx"),qt=1.4,ur=1.03,mr={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",theme:"dark"},Uo={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",theme:"dark"},hn={id:"cmbq1ozyc006al70lx4uciz0q",name:"Google",iconUrl:"https://assets.initia.xyz/images/wallets/Google.webp",iconBackground:"#ffffff"},Ko=ar.toPrivyWalletConnector(hn),Lo=ar.toPrivyWallet(hn),hr=_.createContext(null);function ms(){return _.useContext(hr)}function _r(){const{location:t}=ms();return t}function fr(){const{path:t}=_r();return t}function Me(){const{state:t={}}=_r();return t}function Ho(){const{history:t}=ms();return t}function ie(){const{navigate:t}=ms();return t}function Wo(){const{reset:t}=ms();return t}const pr=({children:t,initialEntry:s})=>{const[n,r]=_.useState([s??{path:"/"}]),o=n[n.length-1],a=_.useCallback((l,c)=>{r(d=>{if(typeof l=="string")return[...d,{path:l,state:c}];const u=d.length+l;if(u<1)return d;const m=E.take(u,d);return c!==void 0?E.adjust(u-1,h=>({...h,state:c}),m):m})},[]),i=_.useCallback((l,c)=>{r([{path:l,state:c}])},[]);return e.jsx(hr.Provider,{value:{location:o,history:n,navigate:a,reset:i},children:t})},Mt=({to:t,state:s,children:n,onClick:r,...o})=>{const a=ie(),i=l=>{l.preventDefault(),r?.(l),a(t,s)};return e.jsx("button",{type:"button",...o,onClick:i,children:n})},gr=_.createContext(null),Ot=()=>_.useContext(gr),xr=_.createContext(null);function te(){return _.useContext(xr)}const U={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function Oe(t){if(t instanceof G.HTTPError){const{response:s}=t,n=s.headers.get("content-type")??"";if(E.includes("application/json",n))try{const r=await s.json();if(r.message)return r.message}catch{return t.message}try{return await s.text()}catch{return t.message}}if(t instanceof Error){if(E.path(["code"],t)===4001||E.path(["code"],t)==="ACTION_REJECTED")return"User rejected";const s=E.path(["error","message"],t),n=E.path(["cause","message"],t),r=E.path(["shortMessage"],t);return s||n||r||t.message}return String(t)}class Qo extends Error{originalError;moduleAddress;moduleName;errorCode;constructor(s,n,r,o,a){super(s),this.name="MoveError",this.originalError=n,this.moduleAddress=r,this.moduleName=o,this.errorCode=a}}const Vo=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,$s=new Map;function Go(t){const s=t.match(Vo);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 Yo(t,s,n){const r=`${t}:${s}`;if($s.has(r))return $s.get(r);try{const o=s==="0x1"?"0x1.json":`${t}/${s}.json`,a=`${n}/errors/${o}`,{errors:i={}}=await G.get(a).json();return $s.set(r,i),i}catch{return null}}function Jo(t,s,n,r,o){return new Qo(t,s,n,r,o)}async function Js(t,s,n){if(!s.metadata?.is_l1&&s.metadata?.minitia?.type!=="minimove")return t;const r=Go(t.message);if(!r)return t;const o=await Yo(s.chain_name,r.moduleAddress,n),i=`Failed with code ${`0x${parseInt(r.errorCode,10).toString(16)}`} in module ${r.moduleName} at ${r.moduleAddress}`,l=o?.[r.moduleName]?.[r.errorCode]||i;return Jo(l,t,r.moduleAddress,r.moduleName,r.errorCode)}const ce="interwovenkit",M={ADDED_CHAIN_IDS:`${ce}:chain-ids:added`,OPENED_CHAIN_IDS:`${ce}:chain-ids:opened`,ACTIVITY_CHAIN_ID:`${ce}:activity:chain-id`,PUBLIC_KEY:`${ce}:public-key`,BRIDGE_SRC_CHAIN_ID:`${ce}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${ce}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${ce}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${ce}:bridge:dst-denom`,BRIDGE_QUANTITY:`${ce}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${ce}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${ce}:bridge:route-type`,BRIDGE_HISTORY:`${ce}:bridge:history`,OP_REMINDER:`${ce}:op:reminder`},_n=Ne.createQueryKeys("interwovenkit:chain",{list:t=>[t],prices:t=>[t],gasPrices:t=>[t]}),Zo=ir.atomWithStorage(M.ADDED_CHAIN_IDS,[]);function Qt(t){const s=E.path([0,"address"],t);if(!s)throw new Error("URL not found");return s}function Xo(t){const{chain_id:s,chain_name:n,pretty_name:r,logo_URIs:o,apis:a,metadata:i}=t,l=r||n,c=o?.png??"",{rpc:d,rest:u,api:m,["json-rpc"]:h}=a,f=Qt(d),p=Qt(u),g=i?.is_l1?Qt(m):p,C=i?.minitia?.type==="minievm"?Qt(h):void 0;return{...t,chainId:s,name:l,logoUrl:c,rpcUrl:f,restUrl:p,indexerUrl:g,jsonRpcUrl:C}}function ze(){const{defaultChainId:t,registryUrl:s,customChain:n}=te(),{data:r}=$.useSuspenseQuery({queryKey:_n.list(s).queryKey,queryFn:()=>G.create({prefixUrl:s}).get("chains.json").json(),select:o=>(n?[n,...o.filter(i=>i.chain_id!==n.chain_id)]:o).map(Xo).toSorted(E.descend(i=>i.chainId===t)),staleTime:U.MINUTE});return r}function Te(){const t=ze();return s=>{const n=t.find(r=>r.chain_id===s);if(!n)throw new Error(`Chain not found: ${s}`);return n}}function ye(t){return Te()(t)}function zt(){const{defaultChainId:t}=te();return ye(t)}function je(){const s=ze().find(n=>n.metadata?.is_l1);if(!s)throw new Error("Layer 1 not found");return s}function hs(t){return $.useQuery({queryKey:_n.prices(t).queryKey,queryFn:()=>G.create({prefixUrl:"https://celatone-api-prod.alleslabs.dev"}).get(`v1/initia/${t}/assets`,{searchParams:{with_prices:!0}}).json(),staleTime:U.SECOND})}function pt(){const t=ze(),{defaultChainId:s}=te(),[n,r]=_e.useAtom(Zo),o=d=>E.uniq([s,...d]),a=o(n).map(d=>t.find(u=>u.chainId===d)).filter(Boolean),i=t.filter(d=>!o(n).includes(d.chainId));return{chains:t,addedChains:a,notAddedChains:i,addChain:d=>{r(u=>o([...u,d]))},removeChain:d=>{r(u=>o(u.filter(m=>m!==d)))}}}function ea(t){if(t?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:s}=Ys.PubKey.decode(t.value);return Et.encodeSecp256k1Pubkey(s)}return us.decodeOptionalPubkey(t)}function ta({typeUrl:t,value:s}){if(t==="/cosmos.auth.v1beta1.BaseAccount"){const{address:n,pubKey:r,accountNumber:o,sequence:a}=Po.BaseAccount.decode(s),i=ea(r);return{address:n,pubkey:i,accountNumber:Number(o),sequence:Number(a)}}return Ce.accountFromAny({typeUrl:t,value:s})}function sa(t){return t.type==="initia/PubKeyEthSecp256k1"}const na={...Et.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function ra(t){if(sa(t)){const s=Ys.PubKey.fromPartial({key:L.fromBase64(t.value)});return Ro.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(Ys.PubKey.encode(s).finish())})}return us.encodePubkey(t)}function yr(t){if(t.length!==33||t[0]!==2&&t[0]!==3)throw new Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03");return{type:na.ethsecp256k1,value:L.toBase64(t)}}function oa(t,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:yr(t),signature:L.toBase64(s)}}const _s=()=>{const t=te();return new us.Registry([...Tt.protoRegistry,...t.protoTypes??[]])},fs=()=>{const t=te();return new Ce.AminoTypes({...Tt.aminoConverters,...t.aminoConverters})};class aa{constructor(s,n){this.address=s,this.signMessage=n}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const s=`${M.PUBLIC_KEY}:${this.address}`,n=localStorage.getItem(s);if(n)return this.cachedPublicKey=L.fromHex(n),L.fromHex(n);const r=await this.getPublicKey();return this.cachedPublicKey=r,localStorage.setItem(s,L.toHex(r)),r}async getPublicKey(){const s="Sign this message to identify your Initia account.",n=await this.signMessage(s),r=nt.ethers.hashMessage(s),o=nt.ethers.SigningKey.recoverPublicKey(r,n);return Gs.Secp256k1.compressPubkey(L.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=Vs.escapeCharacters(Vs.sortedJsonStringify(n)),o=await this.signMessage(r),a=L.fromHex(o.replace("0x","")).subarray(0,-1),l=Gs.Secp256k1Signature.fromFixedLength(a).toFixedLength(),c=oa(await this.getCachedPublicKey(),l);return{signed:n,signature:c}}}function jr(){const t=_s(),s=fs(),n=gt(),r=vr();return async function(o,a,i,l,c){if(!n)throw new Error("Signer not initialized");const d=await r(o),{accountNumber:u,sequence:m}=await d.getSequence(a),[h]=await n.getAccounts(),f=ra(yr(h.pubkey)),p=Do.SignMode.SIGN_MODE_EIP_191,g=i.map(j=>s.toAmino(j)),C=Vs.makeSignDoc(g,l,o,c,u,m),{signature:S,signed:I}=await n.signAmino(a,C),A={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:I.msgs.map(j=>s.fromAmino(j)),memo:c}},x=t.encode(A),k=$n.Int53.fromString(I.fee.gas).toNumber(),v=$n.Int53.fromString(I.sequence).toNumber(),w=us.makeAuthInfoBytes([{pubkey:f,sequence:v}],I.fee.amount,k,I.fee.granter,I.fee.payer,p);return mt.TxRaw.fromPartial({bodyBytes:x,authInfoBytes:w,signatures:[L.fromBase64(S.signature)]})}}function gt(){const t=Y(),{signMessageAsync:s}=xe.useSignMessage();return _.useMemo(()=>new aa(t,n=>s({message:n})),[t,s])}const As=new Map,Es=new Map;function br(){const t=Te();return async s=>{if(As.has(s))return As.get(s);const{rpcUrl:n}=t(s),r=await An.Comet38Client.create(new An.HttpClient(n));return As.set(s,r),r}}function vr(){const t=_s(),s=fs(),n=gt(),r=Y(),o=br();return async a=>{const i=`${r}:${a}`;if(Es.has(i))return Es.get(i);if(!n)throw new Error("Signer not initialized");const l=await o(a),c=await Ce.SigningStargateClient.createWithSigner(l,n,{registry:t,aminoTypes:s,accountParser:ta,broadcastPollIntervalMs:1e3});return Es.set(i,c),c}}function wr(){const{connector:t}=xe.useAccount();return async()=>{if(!t)throw new Error("Wallet not connected");return new nt.BrowserProvider(await t.getProvider())}}const ia=_e.atom(!1);function xt(){const t=Wo(),[s,n]=_e.useAtom(ia);return{isDrawerOpen:s,openDrawer:(a,i)=>{a&&t(a,i),n(!0)},closeDrawer:()=>{n(!1)}}}const Cr="approve",ps=_e.atom(),Ir=_e.atom(null);function Nr(){const t=_e.useAtomValue(ps);if(!t)throw new Error("Tx request not found");return t}function Sr(){const t=ie(),s=Y(),{defaultChainId:n,registryUrl:r}=te(),o=Te(),{openDrawer:a,closeDrawer:i}=xt(),{openModal:l,closeModal:c}=Ot(),d=_e.useSetAtom(ps),u=_e.useSetAtom(Ir),m=br(),h=vr(),f=gt(),p=_s(),g=async({messages:x,memo:k,chainId:v=n})=>{try{return await(await h(v)).simulate(s,x,k)}catch(w){throw new Error(await Oe(w))}},C=async({messages:x,memo:k,chainId:v=n})=>{const w=await m(v),j=Ce.QueryClient.withExtensions(w,Ce.setupTxExtension),q=x.map(Q=>p.encodeAsAny(Q)),[O]=await f.getAccounts(),T=Et.encodeSecp256k1Pubkey(O.pubkey),N=await h(v),{sequence:K}=await N.getSequence(s);return j.tx.simulate(q,k,T,K)},S=async({txRequest:x,broadcaster:k})=>{const w={...{memo:"",chainId:n,gas:x.gas||await g(x),gasAdjustment:qt,gasPrices:null,spendCoins:[],internal:!1},...x};return new Promise((j,q)=>{d({txRequest:w,resolve:async T=>{try{const N=await h(w.chainId),K=await k(N,mt.TxRaw.encode(T).finish());j(K),typeof w.internal=="string"&&t(w.internal)}catch(N){q(await Js(N,o(w.chainId),r))}finally{O()}},reject:T=>{q(T),O()}}),w.internal?l({path:"/tx"}):a("/tx");const O=()=>{if(!w.internal){t("/blank"),i();return}c()}})},I=async x=>{const k=x.chainId??n;try{const v=await S({txRequest:x,broadcaster:async(w,j)=>await w.broadcastTxSync(j)});return x.internal&&typeof x.internal!="number"&&(u({txHash:v,chainId:k,status:"loading"}),A({txHash:v,chainId:x.chainId}).then(w=>{u({status:w.code===0?"success":"error",chainId:k,txHash:v})}).catch(()=>{u({status:"error",chainId:k,txHash:v})})),v}catch(v){throw x.internal&&typeof x.internal!="number"&&u({status:"error",chainId:k,error:v}),v}},P=x=>S({txRequest:x,broadcaster:async(k,v)=>{const w=await k.broadcastTx(v);if(w.code!==0)throw new Error(w.rawLog);return w}}),A=async({chainId:x=n,...k})=>{try{const v=await h(x);return await kr({...k,client:v})}catch(v){throw await Js(v,o(x),r)}};return{estimateGas:g,simulateTx:C,requestTxSync:I,requestTxBlock:P,waitForTxConfirmation:A}}async function kr({txHash:t,client:s,timeoutSeconds:n=30,intervalSeconds:r=1}){const o=Date.now(),a=n*1e3;for(;;){const i=await s.getTx(t);if(i){if(i.code!==0)throw new Error(i.rawLog);return i}if(Date.now()-o>=a)throw new Error(`Transaction was submitted, but not found on the chain within ${n} seconds.`);await new Promise(l=>setTimeout(l,r*1e3))}}const ca=`<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>`,Ia=encodeURIComponent(Na),Mr=`data:image/svg+xml;utf8,${Ia}`,at=qe.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,n)=>[e,n],resource:(e,n)=>[e.chainId,n.denom],denom:(e,n)=>[e,n],metadata:(e,n)=>[e,n]});function Sa(e){var m,h,_;const{base:n,symbol:s,denom_units:r=[],display:a,logo_URIs:o,name:i,address:l,traces:c}=e,d=((m=r.find(p=>p.denom===a))==null?void 0:m.exponent)??((h=r.find(p=>p.denom===n))==null?void 0:h.exponent)??((_=A.head(r))==null?void 0:_.exponent)??0,u=(o==null?void 0:o.png)??"";return{denom:n,symbol:s,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function Ft(e){var a;const n=(a=e==null?void 0:e.metadata)==null?void 0:a.assetlist,s=$.useQueryClient(),{data:r}=$.useSuspenseQuery({queryKey:at.list(n).queryKey,queryFn:async()=>n?H.get(n).json():{assets:[]},select:({assets:o})=>{if(!e)return[];const i=o.map(Sa);for(const l of i)s.setQueryData(at.item(e.chainId,l.denom).queryKey,l);return i},staleTime:L.MINUTE});return r}function He(e){const n=Ft(e),s=we(),r=Ft(s),a=Or(e);return o=>{const i=n.find(c=>c.denom===o);if(i)return i;const l=r.find(c=>c.denom===a(o));return l?{...l,denom:o}:{denom:o,symbol:"",decimals:0,logoUrl:Mr}}}function xs(e,n){const s=He(n),a=$.useQueryClient().getQueryData(at.item(n.chainId,e).queryKey);return a||s(e)}function Or(e){const n=we(),s=Ft(e);return r=>{var o,i,l,c,d;if((o=e.metadata)!=null&&o.is_l1)return r;if(r.startsWith("l2/")||r.startsWith("ibc/")){const u=(i=s.find(m=>m.denom===r))==null?void 0:i.traces;if(u){for(const m of u)if(m.counterparty.chain_name===n.chain_name)return m.counterparty.base_denom}}const a=(d=(c=(l=n.metadata)==null?void 0:l.ibc_channels)==null?void 0:c.find(({chain_id:u,version:m})=>u===e.chain_id&&m==="ics20-1"))==null?void 0:d.channel_id;return a?ka(a,r):""}}function Ms(e,n){const r=M.toBytes(e,32),a=M.toBytes(n,32),o=new Uint8Array([...r,...a,252]);return z.toHex(ms.sha3_256.create().update(o).digest())}function Ur(e,n){const r=M.toBytes(e,32),a=nt.toBytes(n),o=new Uint8Array([...r,...a,254]);return z.toHex(ms.sha3_256.create().update(o).digest())}function $a(e){return e?e.startsWith("move/")?`0x${e.slice(5)}`:`0x${Ur("0x1",e)}`:""}function ka(e,n){const s=`transfer/${e}/${n}`;return`ibc/${z.toHex(ea.sha256(s)).toUpperCase()}`}const Ht=qe.createQueryKeys("interwovenkit:account",{username:(e,n)=>[e,n],address:(e,n)=>[e,n],balances:(e,n)=>[e,n],txs:(e,n)=>[e,n]});function zr(){const{restUrl:e}=we(),{usernamesModuleAddress:n}=ne();return jr({restUrl:e,moduleAddress:n})}function ys(e){const n=Z(),{restUrl:s}=e,{data:r}=$.useSuspenseQuery({queryKey:Ht.balances(s,n).queryKey,queryFn:()=>H.create({prefixUrl:s}).get(`cosmos/bank/v1beta1/balances/${n}`).json(),select:({balances:a})=>a,staleTime:L.SECOND});return r}function Kr(e){const n=ys(e),s=Ft(e),r=He(e),a=Or(e),{data:o}=fn(e.chainId),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>s.some(d=>d.denom===c);return A.sortWith([A.descend(({denom:c})=>a(c)==="uinit"),A.descend(({denom:c})=>i(c)),A.descend(({value:c})=>c),A.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>F(d).comparedTo(c)??0,A.descend(({symbol:c})=>c.toLowerCase())],n.filter(({amount:c})=>!F(c).isZero()).map(({amount:c,denom:d})=>{var _;const u=r(d),m=((_=o==null?void 0:o.find(({id:p})=>p===(u==null?void 0:u.denom)))==null?void 0:_.price)??0,h=F(c).times(m).div(F(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:m,value:h}}))}function Z(){const e=xn();return e?M.toBech32(e):""}function xn(){const{address:e}=ye.useAccount();return e?M.toPrefixedHex(e):""}function Ct(){var r,a;const e=Kt(),n=Z(),s=xn();return((a=(r=e.metadata)==null?void 0:r.minitia)==null?void 0:a.type)==="minievm"?s:n}function Hr(){const e=Ct(),n=zr();return $.useQuery({queryKey:Ht.username(n.restUrl,e).queryKey,queryFn:()=>n.getUsername(e),enabled:!!e,staleTime:L.MINUTE})}function pe(){const e=Ct(),n=Z(),s=xn(),{data:r}=Hr(),a=wt(),{openDrawer:o}=bt(),i=()=>{o("/")},l=()=>{o("/connect")},c=u=>{o("/bridge",u)},d=Fr();return{address:e,initiaAddress:n,hexAddress:s,username:r,offlineSigner:a,openConnect:l,openWallet:i,openBridge:c,...d}}function Ea(){const e=["initia-wallet-widget:last-connected-wallet","initia-wallet-widget:fee-denoms"],n={"initia-wallet-widget:chain-ids":U.ADDED_CHAIN_IDS,"initia-wallet-widget:opened-layers-assets":`${U.OPENED_CHAIN_IDS}:assets`,"initia-wallet-widget:opened-layers-nft":`${U.OPENED_CHAIN_IDS}:nfts`},s={"initia-wallet-widget:ethereum-public-keys":{prefix:U.PUBLIC_KEY,getSuffix:M.toBech32}};for(const r of e)localStorage.removeItem(r);for(const[r,a]of Object.entries(n)){const o=localStorage.getItem(r);o&&(localStorage.setItem(a,o),localStorage.removeItem(r))}for(const[r,{prefix:a,getSuffix:o}]of Object.entries(s)){const i=localStorage.getItem(r);if(i)try{const l=JSON.parse(i);for(const[c,d]of Object.entries(l)){const u=`${a}:${o(c)}`;localStorage.setItem(u,d)}localStorage.removeItem(r)}catch{}}}const Aa="_status_tn9m1_1",Ta="_error_tn9m1_9",Os={status:Aa,error:Ta},ae=({error:e,children:n})=>t.jsx("p",{className:R(Os.status,{[Os.error]:e}),children:n}),se=({errorBoundaryProps:e={fallbackRender:({error:r})=>t.jsx(ae,{error:!0,children:r.message})},suspenseFallback:n=t.jsx(ae,{children:"Loading..."}),children:s})=>t.jsx(pr.ErrorBoundary,{...e,children:t.jsx(f.Suspense,{fallback:n,children:s})}),fe=qe.createQueryKeys("interwovenkit:skip",{chains:null,assets:e=>[e],asset:(e,n)=>[e,n],balances:(e,n)=>[e,n],route:(e,n)=>[e,n],routeErrorInfo:e=>[e],txTrack:(e,n)=>[e,n],txStatus:(e,n)=>[e,n]});function Le(){const{routerApiUrl:e}=ne();return f.useMemo(()=>H.create({prefixUrl:e}),[e])}function Lr(){const e=Ke();return n=>e.some(s=>s.chain_id===n)}function Lt(){const e=Lr();return n=>e(n.chain_id)?"initia":n.chain_type}function Rt(e){return Lt()(e)}function js(){const e=Le(),{data:n}=$.useSuspenseQuery({queryKey:fe.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>A.sortWith([A.descend(({chain_name:r})=>r==="initia"),A.ascend(({pretty_name:r})=>r)],s),staleTime:L.MINUTE});return n}function ct(){const e=js();return n=>{const s=e.find(r=>r.chain_id===n);if(!s)throw new Error(`Chain not found: ${n}`);return s}}function $e(e){return ct()(e)}function yt(e){const n=Le(),s=$.useQueryClient(),{data:r}=$.useSuspenseQuery({queryKey:fe.assets(e).queryKey,queryFn:()=>n.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:a})=>{const{assets:o}=a[e]??{assets:[]};for(const i of o)s.setQueryData(fe.asset(e,i.denom).queryKey,i);return o.toSorted(A.descend(i=>i.symbol==="INIT"))},staleTime:L.MINUTE});return r}function Wr(e){const n=yt(e);return s=>{const r=n.find(a=>a.denom===s);if(!r)throw new Error(`Asset not found: ${s}`);return r}}function Te(e,n){return Wr(n)(e)}const vs=f.createContext(null);function Mt(){const{container:e}=f.useContext(vs);return e}const qa=({children:e})=>{const[n,s]=f.useState(null);return t.jsx(vs.Provider,{value:{container:n,setContainer:s},children:e})},Da="_loader_4gdsk_1",Pa={loader:Da},We=({size:e=24,color:n="currentColor",border:s=2})=>{const r={width:`${e}px`,height:`${e}px`,borderColor:`${n} ${n} transparent ${n}`,borderWidth:`${s}px`};return t.jsx("div",{className:Pa.loader,style:r})},Ba="_container_4qmbg_1",Fa="_toast_4qmbg_10",Ra="_info_4qmbg_23",Ma="_success_4qmbg_27",Oa="_error_4qmbg_31",Ua="_icon_4qmbg_36",za="_content_4qmbg_43",Ka="_title_4qmbg_46",Ha="_description_4qmbg_51",La="_close_4qmbg_72",Fe={container:Ba,toast:Fa,info:Ra,success:Ma,error:Oa,icon:Ua,content:za,title:Ka,description:Ha,close:La},Wa=({notification:e,onClose:n,...s})=>{const r=je.useTransition(e,{keys:o=>(o==null?void 0:o.id)||"empty",from:{transform:"translateY(-52px)",opacity:0},enter:{transform:"translateY(0px)",opacity:1},leave:{transform:"translateY(-52px)",opacity:0},config:{...je.config.wobbly,clamp:!0}}),a=o=>{switch(o){case"loading":return t.jsx(We,{size:16});case"info":case"success":return t.jsx(b.IconCheckCircleFilled,{size:16});case"error":return t.jsx(b.IconCloseCircleFilled,{size:16});default:return null}};return r((o,i)=>{if(!i)return null;const{type:l,title:c,description:d}=i,u=a(l);return t.jsx(je.animated.div,{style:o,className:Fe.container,children:t.jsxs("div",{className:R(Fe.toast,l&&Fe[l]),...s,children:[u&&t.jsx("div",{className:Fe.icon,children:u}),t.jsxs("div",{className:Fe.content,children:[t.jsx("p",{className:Fe.title,children:c}),d&&t.jsx("div",{className:Fe.description,children:d})]}),t.jsx("button",{className:Fe.close,onClick:n,children:t.jsx(b.IconClose,{size:14})})]})})})},Qr=f.createContext(null),Vr=()=>f.useContext(Qr),Dn=5e3,Qa=({children:e})=>{const n=Mt(),[s,r]=f.useState(null),a=f.useRef(null),o=f.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},l=f.useCallback(()=>{i(),r(null)},[]),c=f.useCallback(h=>{i(),r({...h,id:Fs.nanoid()}),h.autoHide&&!o.current&&(a.current=setTimeout(()=>l(),Dn))},[l]),d=f.useCallback(h=>{i(),r(_=>_?{..._,...h}:{...h,id:Fs.nanoid()}),h.autoHide&&!o.current&&(a.current=setTimeout(()=>l(),Dn))},[l]),u=()=>{i(),o.current=!0},m=()=>{i(),o.current=!1,s!=null&&s.autoHide&&(a.current=setTimeout(()=>l(),Dn))};return f.useEffect(()=>()=>i(),[]),t.jsxs(Qr.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,n&&gr.createPortal(t.jsx(Wa,{notification:s,onClose:l,onMouseEnter:u,onMouseLeave:m}),n)]})},Gr=f.createContext(!1),Va="_overlay_1eoyl_1",Ga="_fullscreen_1eoyl_12",Ya="_content_1eoyl_16",Ja="_header_1eoyl_73",Za="_title_1eoyl_82",Xa="_close_1eoyl_87",Ge={overlay:Va,fullscreen:Ga,content:Ya,header:Ja,title:Za,close:Xa},Yr=({title:e,children:n,trigger:s,open:r,onOpenChange:a})=>{const o=f.useContext(Gr);return t.jsxs(T.Dialog.Root,{open:r,onOpenChange:a,children:[s&&t.jsx(T.Dialog.Trigger,{asChild:!0,children:s}),t.jsxs(T.Dialog.Portal,{container:Mt(),children:[t.jsx("div",{className:R(Ge.overlay,{[Ge.fullscreen]:o})}),t.jsxs(T.Dialog.Content,{className:R(Ge.content,{[Ge.fullscreen]:o}),children:[e&&t.jsxs("header",{className:Ge.header,children:[t.jsx(T.Dialog.Title,{className:Ge.title,children:e}),t.jsx(T.Dialog.Close,{className:Ge.close,children:t.jsx(b.IconClose,{size:20})})]}),n]})]})]})};function Jr({indexerUrl:e}){const n=Z();return $.useSuspenseQuery({queryKey:Ht.txs(e,n).queryKey,queryFn:async()=>{const s={"pagination.reverse":!0};return H.create({prefixUrl:e}).get(`indexer/tx/v1/txs/by_account/${n}`,{searchParams:s}).json()},select:s=>s.txs,staleTime:L.SECOND})}function Zr(e){const{data:n}=$.useSuspenseQuery({queryKey:ps.gasPrices(e).queryKey,queryFn:async()=>{var s;if((s=e.metadata)!=null&&s.is_l1){const{restUrl:r}=e,{gas_prices:a}=await H.create({prefixUrl:r}).get("initia/tx/v1/gas_prices").json();return a.toSorted(A.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:i})=>{const l=o==="uinit"?1:vr;return{amount:F(i).times(l).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:r,fixed_min_gas_price:a})=>{if(A.isNil(a))throw new Error(`${r} has no price`);return{amount:String(a),denom:r}})},staleTime:L.SECOND});return n}function Xr(e){var a;const n=Z(),{data:s}=Jr(e);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{const o=s.find(({tx:i})=>i.auth_info.signer_infos.some(l=>M.equals(n,Se.computeAddress(`0x${z.toHex(Jn.Secp256k1.uncompressPubkey(z.fromBase64(l.public_key.key)))}`))));return((a=o==null?void 0:o.tx.auth_info.fee.amount[0])==null?void 0:a.denom)??r}catch{return r}}const ei="_root_1wwaf_1",ti="_item_1wwaf_10",ni="_chevron_1wwaf_14",si="_trigger_1wwaf_19",ri="_content_1wwaf_39",kt={root:ei,item:ti,chevron:ni,trigger:si,content:ri};function eo(e){const{list:n,getKey:s,renderHeader:r,renderContent:a,footer:o,...i}=e;return t.jsxs(T.Accordion.Root,{className:kt.root,type:"multiple",...i,children:[n.map((l,c)=>t.jsxs(T.Accordion.Item,{className:kt.item,value:(s==null?void 0:s(l))??String(c),children:[t.jsx(T.Accordion.Header,{children:t.jsxs(T.Accordion.Trigger,{className:kt.trigger,children:[r(l),t.jsx(b.IconChevronDown,{className:kt.chevron,size:16})]})}),t.jsx(T.Accordion.Content,{className:kt.content,children:a(l)})]},(s==null?void 0:s(l))??c)),o]})}const oi="_scrollable_yv81n_1",ai={scrollable:oi},Pe=({className:e,children:n})=>t.jsx("div",{className:R(ai.scrollable,e),children:n}),es=({children:e})=>{const n=f.useRef(null),[s,r]=f.useState(0),a=je.useSpring({height:s,config:{...je.config.stiff,clamp:!0}});return f.useEffect(()=>{if(n.current){const{height:o}=n.current.getBoundingClientRect();r(o)}},[e]),e?t.jsx(je.animated.div,{style:{overflow:"hidden",...a},children:t.jsx("div",{ref:n,children:e})}):null},ii="_help_7m3jv_1",ci="_icon_7m3jv_10",li="_info_7m3jv_17",di="_warning_7m3jv_21",ui="_error_7m3jv_25",mi="_success_7m3jv_31",Pn={help:ii,icon:ci,info:li,warning:di,error:ui,success:mi},Oe=({level:e,className:n,mt:s=8,children:r})=>{if(!r)return null;const a=()=>{switch(e){case"loading":return t.jsx(We,{size:12});case"info":return t.jsx(b.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(b.IconWarningFilled,{size:12});default:return t.jsx(b.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:R(Pn.help,e&&Pn[e],n),style:{marginTop:s},children:[t.jsx("div",{className:Pn.icon,children:a()}),t.jsx("p",{children:r})]})},hi="_stack_14kq8_1",_i="_help_14kq8_6",fi="_info_14kq8_14",pi="_warning_14kq8_19",gi="_error_14kq8_24",xi="_success_14kq8_29",ts={stack:hi,help:_i,info:fi,warning:pi,error:gi,success:xi},yi=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(es,{children:t.jsx("div",{className:ts.stack,children:e})}),te=e=>t.jsx(Oe,{...e,className:R(ts.help,ts[e.level]),mt:0});te.Stack=yi;const ji="_footer_xif7g_1",vi="_actions_xif7g_10",Us={footer:ji,actions:vi},re=({extra:e,className:n,children:s})=>t.jsxs("footer",{className:R(Us.footer,n),children:[e,t.jsx("div",{className:Us.actions,children:s})]}),wi="_button_7llhj_1",bi="_outline_7llhj_24",Ci="_sm_7llhj_42",Ni="_full_7llhj_48",Ii="_small_7llhj_52",Si="_unpadded_7llhj_82",st={button:wi,outline:bi,sm:Ci,full:Ni,small:Ii,unpadded:Si},to=e=>{const{sm:n,fullWidth:s,loading:r,className:a,children:o,disabled:i,...l}=e;return t.jsx("button",{...l,className:R(st.button,{[st.sm]:n,[st.full]:s},a),disabled:!!r||i,children:r?t.jsxs(t.Fragment,{children:[t.jsx(We,{color:"currentColor",size:16}),typeof r=="string"&&t.jsx("span",{className:st.loading,children:r})]}):o})},$i=({className:e,...n})=>t.jsx(to,{...n,className:R(st.outline,e)}),ki=({className:e,unpadded:n,...s})=>t.jsx("button",{...s,className:R(st.small,{[st.unpadded]:n},e)}),G={White:to,Outline:$i,Small:ki},Ei="_item_1n572_1",Ai="_title_1n572_10",Ti="_content_1n572_14",Bn={item:Ei,title:Ai,content:Ti},Fn=({title:e,content:n})=>t.jsxs("div",{className:Bn.item,children:[t.jsx("div",{className:Bn.title,children:e}),t.jsx("div",{className:Bn.content,children:n})]}),qi="_placeholder_80nya_1",Di="_circle_80nya_5",zs={placeholder:qi,circle:Di},Y=({src:e,alt:n,placeholder:s,classNames:r,circle:a,...o})=>{const[i,l]=f.useState(!1),{width:c,height:d}=o,u=s??t.jsx("div",{className:R(zs.placeholder,r==null?void 0:r.placeholder),style:{width:c,height:d}});return f.useEffect(()=>{l(!1)},[e]),!e||i?u:t.jsx("img",{...o,className:R(o.className,{[zs.circle]:a}),style:{width:c,height:d},src:e,alt:n,loading:"lazy",onError:()=>l(!0)})};function no(e,n){var r,a,o,i,l,c;const s={};for(const d of e)if(d.attributes.some(m=>m.key==="msg_index")){if(d.type==="coin_spent"){const m=(r=d.attributes.find(_=>_.key==="spender"))==null?void 0:r.value,h=(a=d.attributes.find(_=>_.key==="amount"))==null?void 0:a.value;if(m===n&&h){const[_,p]=((o=h.match(/^(\d+)(.+)$/))==null?void 0:o.slice(1))||[];if(_&&p){const g=s[p]||BigInt(0);s[p]=g-BigInt(_)}}}if(d.type==="coin_received"){const m=(i=d.attributes.find(_=>_.key==="receiver"))==null?void 0:i.value,h=(l=d.attributes.find(_=>_.key==="amount"))==null?void 0:l.value;if(m===n&&h){const[_,p]=((c=h.match(/^(\d+)(.+)$/))==null?void 0:c.slice(1))||[];if(_&&p){const g=s[p]||BigInt(0);s[p]=g+BigInt(_)}}}}return Object.entries(s).filter(([,d])=>d!==BigInt(0)).map(([d,u])=>({amount:u.toString(),denom:d}))}function so(e,n){var r,a;const s={};for(const o of e)if(o.attributes.some(l=>l.key==="msg_index")&&o.type==="move"){const l=(r=o.attributes.find(u=>u.key==="type_tag"))==null?void 0:r.value,c=(a=o.attributes.find(u=>u.key==="data"))==null?void 0:a.value;if(!l||!c)continue;let d;try{d=JSON.parse(c)}catch{continue}if(l==="0x1::fungible_asset::WithdrawEvent"){const u=d.store_addr,m=d.amount,h=d.metadata_addr;if(u&&m&&h){const _=n.startsWith("0x")?n.slice(2):n;if(`0x${Ms(_,h)}`===u){const g=s[h]||BigInt(0);s[h]=g-BigInt(m)}}}if(l==="0x1::fungible_asset::DepositEvent"){const u=d.store_addr,m=d.amount,h=d.metadata_addr;if(u&&m&&h){const _=n.startsWith("0x")?n.slice(2):n;if(`0x${Ms(_,h)}`===u){const g=s[h]||BigInt(0);s[h]=g+BigInt(m)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,i])=>({amount:i.toString(),metadata:o}))}const ro=({metadata:e,chain:n,children:s})=>{const{restUrl:r}=n,{data:a}=$.useSuspenseQuery({queryKey:at.denom(r,e).queryKey,queryFn:()=>H.create({prefixUrl:r}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:o})=>o,staleTime:L.INFINITY});return s(a)},yn=({chain:e,asset:n,children:s})=>{const r=$.useQueryClient(),{data:a}=$.useQuery({queryKey:at.resource(e,n).queryKey,queryFn:async()=>{var c,d,u;if(n.symbol||!((c=e.metadata)!=null&&c.is_l1||((u=(d=e.metadata)==null?void 0:d.minitia)==null?void 0:u.type)==="minimove"))return null;const o=$a(n.denom),{resource:i}=await H.create({prefixUrl:e.restUrl}).get(`initia/move/v1/accounts/${o}/resources/by_struct_tag`,{searchParams:{struct_tag:"0x1::fungible_asset::Metadata"}}).json(),{data:l}=JSON.parse(i.move_resource);return r.setQueryData(at.item(e.chainId,n.denom).queryKey,{...n,...l}),l},staleTime:L.INFINITY});return s({...n,...a})},Pi="_root_jioyr_1",Bi="_title_jioyr_7",Fi="_changes_jioyr_13",Ri="_change_jioyr_13",Mi="_amount_jioyr_34",Oi="_text_jioyr_40",Ui="_value_jioyr_47",rt={root:Pi,title:Bi,changes:Fi,change:Ri,amount:Mi,text:Oi,value:Ui},oo=({amount:e,asset:n,price:s})=>{const{denom:r,symbol:a,decimals:o,logoUrl:i}=n,l=D.formatAmount(e,{decimals:o}),c=s&&F(e).times(s).abs();return t.jsxs("div",{className:rt.change,children:[t.jsxs("div",{className:rt.amount,children:[t.jsx(Y,{src:i,width:14,height:14}),t.jsxs("span",{className:rt.text,children:[l," ",a??D.truncate(r)]})]}),c&&t.jsxs("div",{className:rt.value,children:["$",D.formatAmount(c,{decimals:o,dp:2})]})]})},zi=({changes:e,chain:n})=>{const s=He(n),{data:r}=fn(n.chainId);return e.map(({amount:a,denom:o},i)=>{var d;const l=s(o),c=(d=r==null?void 0:r.find(({id:u})=>u===o))==null?void 0:d.price;return t.jsx(oo,{amount:a,asset:l,price:c},i)})},Ki=({changes:e,chain:n})=>{const s=He(n),{data:r}=fn(n.chainId);return e.map(({amount:a,metadata:o},i)=>t.jsx(ro,{metadata:o,chain:n,children:l=>{var d;const c=(d=r==null?void 0:r.find(({id:u})=>u===l))==null?void 0:d.price;return t.jsx(yn,{asset:s(l),chain:n,children:u=>t.jsx(oo,{amount:a,asset:u,price:c})})}},i))};function Hi(e,n){return typeof n=="bigint"?n.toString():n}const Li=qe.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Hi)]}),Wi=({messages:e,memo:n,chainId:s})=>{var h,_,p,g;const{initiaAddress:r,hexAddress:a}=pe(),o=ve(s),{simulateTx:i}=Fr(),{data:l}=$.useSuspenseQuery({queryKey:Li.simulate({messages:e,memo:n,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:n,chainId:s}),staleTime:L.SECOND}),c=y=>t.jsxs("div",{className:rt.root,children:[t.jsx("h2",{className:rt.title,children:"Estimated changes"}),t.jsx("div",{className:rt.changes,children:y})]});if(!l)return null;const d=((h=l.result)==null?void 0:h.events)??[];if(d.length===0)return null;if((_=o.metadata)!=null&&_.is_l1||((g=(p=o.metadata)==null?void 0:p.minitia)==null?void 0:g.type)==="minimove"){const y=so(d,a),[C]=Ks(y);return C.length===0?null:c(t.jsx(Ki,{changes:C,chain:o}))}const u=no(d,r),[m]=Ks(u);return m.length===0?null:c(t.jsx(zi,{changes:m,chain:o}))};function Ks(e){return A.partition(n=>new F(n.amount).isNegative(),e)}const Qi="_trigger_13rgr_1",Vi="_icon_13rgr_5",Gi="_content_13rgr_16",Yi="_item_13rgr_24",Vt={trigger:Qi,icon:Vi,content:Gi,item:Yi},Ji=({options:e,value:n,onChange:s})=>{const r=Mt(),{txRequest:a}=Br(),o=ve(a.chainId),i=He(o),l=({amount:[{amount:c,denom:d}]})=>{if(F(c).isZero())return"0";const{symbol:u,decimals:m}=i(d);return`${D.formatAmount(c,{decimals:m})} ${u}`};return e.length===1?l(e[0]):t.jsxs(T.Select.Root,{value:n,onValueChange:s,children:[t.jsxs(T.Select.Trigger,{className:Vt.trigger,children:[t.jsx(T.Select.Value,{}),t.jsx(T.Select.Icon,{className:Vt.icon,children:t.jsx(b.IconChevronDown,{size:16})})]}),t.jsx(T.Select.Portal,{container:r,children:t.jsx(T.Select.Content,{className:Vt.content,position:"popper",sideOffset:6,align:"end",children:t.jsx(T.Select.Viewport,{children:e.map(c=>{const[{denom:d}]=c.amount;return t.jsx(T.Select.Item,{className:Vt.item,value:d,children:t.jsx(T.Select.ItemText,{children:l(c)})},d)})})})})]})};function ln(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?z.toBase64(e):Array.isArray(e)?`[${e.map(ln).join(",")}]`:JSON.stringify(e,(n,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const gt={...hr.bcs,address:Hs,object:Hs,bigdecimal:Zi};function ao(e){const n=e.replaceAll(/0x1::(\w+)::(\w+)/g,"$2").toLowerCase();if(n.startsWith("object"))return gt.object();const s=n.match(/(\w+)<(.+)>$/);if(s){const[,r,a]=s,o=ao(a);return gt[r](o)}return gt[n]()}function Hs(e){return gt.bytes(32,e).transform({input:n=>M.toBytes(n,32),output:n=>`0x${z.toHex(n)}`})}function Zi(e){return gt.vector(gt.u8(e)).transform({input:n=>{const s=F.BigNumber(n).times(F.BigNumber(10).pow(18)).toFixed(0,F.BigNumber.ROUND_DOWN);return Xi(BigInt(s))},output:n=>{const s=ec(new Uint8Array(n));return F.BigNumber(s).div(F.BigNumber(10).pow(18)).toFixed()}})}function Xi(e){if(e<0n)throw new Error("negative values are not supported");if(e===0n)return new Uint8Array([0]);const n=[];let s=e;for(;s>0n;)n.push(Number(s&0xffn)),s>>=8n;return new Uint8Array(n)}function ec(e){let n=0n;for(let s=0;s<e.length;s++)n+=BigInt(e[s])<<BigInt(8*s);return n}const tc="_container_1xzyq_1",nc="_toggle_1xzyq_5",sc="_list_1xzyq_11",rc="_arg_1xzyq_16",oc="_type_1xzyq_21",Et={container:tc,toggle:nc,list:sc,arg:rc,type:oc},ac=qe.createQueryKeys("interwovenkit:move",{abi:(e,n,s,r)=>[e,n,s,r]}),ic=({type:e,arg:n})=>ln(ao(e).parse(n)),cc=({msg:e,chainId:n,fallback:s})=>{const[r,a]=ue.useToggle(!1),{restUrl:o}=ve(n),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=$.useQuery({queryKey:ac.abi(o,i,l,c).queryKey,queryFn:async()=>{const h=await H.create({prefixUrl:o}).get(`initia/move/v1/accounts/${i}/modules/${l}`).json(),p=JSON.parse(h.module.abi).exposed_functions.find(({name:g})=>g===c);if(!p)throw new Error(`Function ${c} not found in module ${l}`);return p.params.filter(g=>!g.startsWith("&"))},staleTime:L.INFINITY});if(!u)return s;const m=(h,_)=>{const p=u[_];return t.jsxs("div",{className:Et.arg,children:[t.jsx("div",{className:Et.type,children:p}),t.jsx(pr.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(ic,{type:p,arg:h})})]},_)};return t.jsxs("div",{className:Et.container,children:[t.jsx(G.Small,{className:Et.toggle,onClick:a,disabled:!u,children:r?"Encode":"Decode"}),r?t.jsx("div",{className:Et.list,children:d.map(m)}):s]})},lc="_list_r67rl_1",dc="_key_r67rl_8",uc="_value_r67rl_13",Rn={list:lc,key:dc,value:uc},mc=({message:e,chainId:n})=>{const{typeUrl:s,value:r}=e;return t.jsx("div",{className:Rn.list,children:Object.entries(r).map(([a,o])=>t.jsxs("div",{children:[t.jsx("div",{className:Rn.key,children:a}),t.jsx("div",{className:Rn.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?t.jsx(cc,{msg:r,chainId:n,fallback:ln(o)}):ln(o)})]},a))})},hc="_title_kspdu_1",_c="_meta_kspdu_7",fc="_footer_kspdu_14",Mn={title:hc,meta:_c,footer:fc},io=()=>{const{txRequest:e,resolve:n,reject:s}=Br(),{messages:r,memo:a,chainId:o,gas:i,gasAdjustment:l,spendCoins:c}=e,d=Z(),u=wt(),m=Er(),h=ve(o),_=ys(h),p=Zr(h),g=Xr(h),y=(e.gasPrices??p).map(({amount:x,denom:k})=>Ie.calculateFee(Math.ceil(i*l),Ie.GasPrice.fromString(x+k))),C=y.map(x=>x.amount[0]),N=x=>{var P,W;const k=((P=_.find(Q=>Q.denom===x))==null?void 0:P.amount)??0,O=((W=C.find(Q=>Q.denom===x))==null?void 0:W.amount)??0,B=c.filter(Q=>Q.denom===x).reduce((Q,V)=>F(Q).plus(V.amount),F(0));if(B.gt(0)){const Q=F(O).plus(B);return F(k).gte(Q)}return F(k).gte(O)},q=()=>{var x;if(g&&N(g))return g;for(const{denom:k}of C)if(N(k))return k;return(x=C[0])==null?void 0:x.denom},[j,S]=f.useState(q),{mutate:w,isPending:v}=$.useMutation({mutationKey:[Dr],mutationFn:async()=>{const x=y.find(O=>O.amount[0].denom===j);if(!x)throw new Error("Fee not found");if(!u)throw new Error("Signer not initialized");const k=await m(o,d,r,x,a);await n(k)},onError:async x=>{s(new Error(await ze(x)))}}),E=!N(j);return t.jsxs(t.Fragment,{children:[t.jsxs(Pe,{children:[t.jsx("h1",{className:Mn.title,children:"Confirm tx"}),t.jsxs("div",{className:Mn.meta,children:[t.jsx(Fn,{title:"Chain",content:o}),t.jsx(Fn,{title:"Tx fee",content:t.jsx(Ji,{options:y,value:j,onChange:S})}),a&&t.jsx(Fn,{title:"Memo",content:a}),E&&t.jsx(te,{level:"error",children:"Insufficient balance for fee"})]}),t.jsx(Wi,{messages:r,memo:a,chainId:o}),t.jsx(eo,{list:r,renderHeader:({typeUrl:x})=>Ot.sentenceCase(x.split(".").pop().replace(/^Msg/,"")),renderContent:x=>t.jsx(mc,{message:x,chainId:o})})]}),t.jsxs(re,{className:Mn.footer,children:[t.jsx(G.Outline,{onClick:()=>s(new Error("User rejected")),disabled:v,children:"Reject"}),t.jsx(G.White,{onClick:()=>w(),disabled:E,loading:v,children:"Approve"})]})]})},pc=({children:e})=>{const[{title:n,content:s,path:r},a]=f.useState({}),[o,i]=f.useState(!1),l=_e.useAtomValue(gn),c=f.useCallback(m=>{a(m),i(!0)},[]),d=f.useCallback(()=>{a({}),i(!1)},[]),u=f.useCallback(m=>{m||(l==null||l.reject(new Error("User rejected")),a({})),i(m)},[l]);return t.jsxs(Sr.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(Yr,{title:n,open:o,onOpenChange:u,children:t.jsx(se,{children:r==="/tx"?t.jsx(io,{}):s})})]})};function jn(){return ue.useMediaQuery("(max-width: 576px)")}const ns="interwoven-kit";function co(){const e=document.querySelector(ns)||document.body.appendChild(document.createElement(ns));return e.shadowRoot||e.attachShadow({mode:"open"})}function gc(){const{theme:e,container:n}=ne();return f.useEffect(()=>{const s=document.querySelector(ns);s==null||s.setAttribute("data-theme",e)},[e]),n??co()}function xc(e){const n=co(),s=document.createElement("style");s.textContent=e,n.appendChild(s)}const ws=({value:e,children:n})=>{const[s,r]=f.useState(!1);return n({copy:async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1e3)}catch{}},copied:s})},yc="_tooltip_6zakp_1",jc="_arrow_6zakp_43",Ls={tooltip:yc,arrow:jc},Nt=({label:e,children:n,small:s,...r})=>t.jsxs(T.Tooltip.Root,{...r,children:[t.jsx(T.Tooltip.Trigger,{asChild:!0,children:n}),t.jsx(T.Tooltip.Portal,{container:Mt(),children:t.jsxs(T.Tooltip.Content,{className:R(Ls.tooltip,{small:s}),collisionBoundary:Mt(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(T.Tooltip.Arrow,{className:Ls.arrow})]})})]}),vc="_root_gwc8h_1",wc="_address_gwc8h_9",bc="_copy_gwc8h_18",Cc="_labelWrapper_gwc8h_32",Nc="_labelCopy_gwc8h_42",Ic="_labelCopied_gwc8h_46",Sc="_copied_gwc8h_54",Ye={root:vc,address:wc,copy:bc,labelWrapper:Cc,labelCopy:Nc,labelCopied:Ic,copied:Sc},$c=()=>{const e=f.useRef(null),n=f.useRef(null),{initiaAddress:s,hexAddress:r}=pe();return f.useEffect(()=>{if(!e.current)return;const o=getComputedStyle(e.current).getPropertyValue("--gray-0");n.current?n.current.update({data:s}):(n.current=new ta({type:"canvas",width:400,height:400,margin:0,data:s,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:o},cornersSquareOptions:{type:"extra-rounded",color:o},cornersDotOptions:{type:"dot",color:o},backgroundOptions:{color:"transparent"}}),n.current.append(e.current))},[s]),t.jsxs("div",{className:Ye.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx(Nt,{label:`Derived from ${D.truncate(r)}`,children:t.jsx("span",{className:Ye.address,children:s})}),t.jsx(ws,{value:s,children:({copy:a,copied:o})=>t.jsxs("button",{className:R(Ye.copy,{[Ye.copied]:o}),onClick:a,children:[t.jsx(b.IconCopy,{size:12}),t.jsxs("div",{className:Ye.labelWrapper,children:[t.jsx("span",{className:Ye.labelCopy,children:"Copy address"}),t.jsx("span",{className:Ye.labelCopied,children:"Copied!"})]})]})})]})},kc="_header_1n4q3_1",Ec="_account_1n4q3_10",Ac="_name_1n4q3_21",Tc="_address_1n4q3_25",qc="_icon_1n4q3_29",Dc="_copied_1n4q3_36",Pc="_button_1n4q3_51",Bc="_disconnect_1n4q3_62",Fc="_label_1n4q3_72",Rc="_expanded_1n4q3_80",ge={header:kc,account:Ec,name:Ac,address:Tc,icon:qc,copied:Dc,button:Pc,disconnect:Bc,label:Fc,expanded:Rc},Mc=()=>{var y;const e=ie(),n=Kt(),{connector:s}=ye.useAccount(),{disconnect:r}=ye.useDisconnect(),{address:a,username:o}=pe(),{closeDrawer:i}=bt(),{openModal:l}=zt(),c=o??a,[d,u]=f.useState(!1),m=f.useRef(null),h=je.useSpring({width:d?140:52,config:{tension:300,friction:30,clamp:!0}}),_=()=>{d?(e("/blank"),i(),r(),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)):u(!0)},p=()=>{d&&(m.current=setTimeout(()=>{u(!1)},500))},g=()=>{m.current&&(clearTimeout(m.current),m.current=null)};return f.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),s?t.jsxs("header",{className:ge.header,children:[t.jsx(ws,{value:a,children:({copy:C,copied:N})=>t.jsxs("button",{className:R(ge.account,{[ge.copied]:N}),onClick:C,children:[t.jsx(Y,{src:s.icon,width:18,height:18}),t.jsx("div",{className:ge.address,children:D.truncate(a)}),t.jsx("div",{className:ge.name,children:D.truncate(c)}),t.jsx(b.IconCopy,{className:ge.icon,size:12}),N?"Copied!":""]})}),((y=n.metadata)==null?void 0:y.is_l1)&&t.jsx("button",{className:ge.button,onClick:()=>l({title:"Address",content:t.jsx($c,{})}),children:t.jsx(b.IconQrCode,{size:16})}),t.jsxs(je.animated.button,{className:R(ge.button,ge.disconnect,{[ge.expanded]:d}),style:h,onClick:_,onMouseLeave:p,onMouseEnter:g,children:[t.jsx(b.IconSignOut,{size:16}),t.jsx("span",{className:ge.label,children:"Disconnect"})]})]}):null};function Oc(e){return/^[A-F0-9]{64}$/i.test(e)}function Uc(e,n){const{txHash:s,accountAddress:r,pathSuffix:a}=n;if(s){if(!Oc(s))return;const o=A.path(["explorers",0,"tx_page"],e);return o==null?void 0:o.replace(/\$\{txHash\}/g,s)}if(r){if(!M.validate(r))return;const o=A.path(["explorers",0,"account_page"],e),i=o==null?void 0:o.replace(/\$\{accountAddress\}/g,r);return i&&a?i+a:i}}function zc(e){try{const n=new URL(e,window.location.href);if(!["http:","https:"].includes(n.protocol))throw new Error("Invalid protocol");return n.toString()}catch{return"#"}}const Kc="_link_guafb_1",Hc={link:Kc},vn=({chainId:e,txHash:n,accountAddress:s,pathSuffix:r,...a})=>{const{showIcon:o,className:i,children:l,onClick:c,...d}=a,u=ve(e),m=Uc(u,{txHash:n,accountAddress:s,pathSuffix:r}),h=n?D.truncate(n):s?D.truncate(s):"",_=l??h;return m?t.jsxs("a",{...d,href:xr(zc(m)),className:R(Hc.link,i),onClick:c,target:"_blank",children:[_,o&&t.jsx(b.IconExternalLink,{size:12})]}):t.jsx("span",{...d,children:_})},Lc=()=>{const[e,n]=_e.useAtom(Pr),{showNotification:s,updateNotification:r,hideNotification:a}=Vr();return f.useEffect(()=>{if(!e)return;const{status:o,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(vn,{txHash:l,chainId:i,onClick:a,showIcon:!0,children:"View on Initia Scan"}):null;switch(o){case"loading":s({type:"loading",title:"Transaction is pending..."});break;case"error":r({type:"error",title:"Transaction failed",description:d}),n(null);break;case"success":r({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),n(null);break}},[e,n,s,r,a]),null};function Wc(){return ue.useScrollLock(),null}const Qc="_overlay_1ks72_1",Vc="_content_1ks72_49",Gc="_inner_1ks72_69",On={overlay:Qc,content:Vc,inner:Gc},Yc=({children:e})=>{const{isDrawerOpen:n,closeDrawer:s}=bt(),{setContainer:r}=f.useContext(vs),a=jn(),o=_e.useAtomValue(gn),i=$.useIsMutating({mutationKey:[Dr]}),l=()=>{const h=i?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),o==null||o.reject(new Error(h))},c=ie(),d=$.useQueryClient(),u={fallbackRender:({error:h,resetErrorBoundary:_})=>{const p=()=>{c("/"),d.clear(),_()};return t.jsxs(Pe,{children:[t.jsx(ae,{error:!0,children:h.message}),t.jsx(re,{children:t.jsx(G.White,{onClick:p,children:"Retry"})})]})}},m=je.useTransition(n,{from:{transform:a?"translateY(100%)":"translateX(100%)"},enter:{transform:a?"translateY(0%)":"translateX(0%)"},leave:{transform:a?"translateY(100%)":"translateX(100%)"},config:{tension:500,friction:35,clamp:!0}});return gr.createPortal(t.jsxs(t.Fragment,{children:[m((h,_)=>_?t.jsx(je.animated.button,{style:h,className:On.overlay,onClick:l,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"})]})}):null),m((h,_)=>_?t.jsx(je.animated.div,{style:h,className:R(On.content),children:t.jsxs("div",{className:R(On.inner,"body"),ref:r,children:[a&&t.jsx(Wc,{}),t.jsx(Lc,{}),t.jsx(Mc,{}),t.jsx(se,{errorBoundaryProps:u,children:e})]})}):null)]}),gc())},Jc="_page_1f6wh_1",Zc="_title_1f6wh_10",Xc="_scrollable_1f6wh_17",el="_list_1f6wh_22",tl="_item_1f6wh_32",nl="_name_1f6wh_56",sl="_dimmed_1f6wh_64",rl="_recent_1f6wh_68",ol="_installed_1f6wh_69",xe={page:Jc,title:Zc,scrollable:Xc,list:el,item:tl,name:nl,dimmed:sl,recent:rl,installed:ol},al=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],Ws=({onSuccess:e})=>{const{connectors:n,connectAsync:s}=ye.useConnect(),r=ue.useReadLocalStorage("wagmi.recentConnectorId"),[a,o]=f.useState(null),{mutate:i,isPending:l}=$.useMutation({mutationFn:async c=>{o(c.id);try{await s({connector:c})}catch(d){throw new Error(await ze(d))}},onSettled:()=>{o(null)},onSuccess:()=>{e==null||e()}});return t.jsxs("div",{className:xe.page,children:[t.jsx("h1",{className:xe.title,children:"Connect wallet"}),t.jsx(Pe,{className:xe.scrollable,children:t.jsxs("div",{className:xe.list,children:[n.toSorted(A.descend(c=>c.id===r)).map(c=>{const{name:d,icon:u,id:m}=c;return t.jsxs("button",{className:xe.item,onClick:()=>i(c),disabled:l,children:[t.jsx(Y,{src:u,width:24,height:24}),t.jsx("span",{className:xe.name,children:d}),a===m?t.jsx(We,{size:16}):r===m?t.jsx("span",{className:xe.recent,children:"Recent"}):t.jsx("span",{className:xe.installed,children:"Installed"})]},m)}),al.filter(({name:c})=>!n.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:xe.item,target:"_blank",children:[t.jsx(Y,{src:u,width:24,height:24}),t.jsx("span",{className:R(xe.name,xe.dimmed),children:c}),t.jsx(b.IconExternalLink,{size:10})]},c)})]})})]})},il="_root_xwz5z_1",cl="_header_xwz5z_6",ll="_title_xwz5z_12",dl="_warning_xwz5z_18",ul="_content_xwz5z_22",ml="_footer_xwz5z_26",hl="_secondary_xwz5z_36",Je={root:il,header:cl,title:ll,warning:dl,content:ul,footer:ml,secondary:hl},lo=e=>{const{type:n,icon:s,title:r,children:a,primaryButton:o,secondaryButton:i}=e;return t.jsxs(Pe,{className:Je.root,children:[t.jsxs("header",{className:R(Je.header,n&&Je[n]),children:[s,t.jsx("h1",{className:Je.title,children:r})]}),t.jsx("div",{className:Je.content,children:a}),t.jsxs("footer",{className:Je.footer,children:[t.jsx(G.White,{onClick:o.onClick,sm:!0,fullWidth:!0,children:o.label}),t.jsxs("button",{className:Je.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(b.IconChevronRight,{size:14})]})]})]})},_l="_list_tmcxc_1",fl="_row_tmcxc_8",pl="_dt_tmcxc_19",gl="_asset_tmcxc_25",Gt={list:_l,row:fl,dt:pl,asset:gl},xl=({list:e,onNavigate:n,onDismiss:s})=>{const r=we(),a=De(),o=He(r);return t.jsx(lo,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:n},secondaryButton:{label:"Do not show again",onClick:s},children:t.jsx("div",{className:Gt.list,children:e.toSorted((i,l)=>i.chainId.localeCompare(l.chainId)).map(({txHash:i,chainId:l,amount:c,denom:d})=>{const u=a(l),{decimals:m,symbol:h}=o(d),_=D.formatAmount(c,{decimals:m});return t.jsxs("div",{className:Gt.row,children:[t.jsxs("div",{className:Gt.dt,children:[t.jsx(Y,{src:u.logoUrl,width:16,height:16}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:Gt.asset,children:[_," ",h]})]},i)})})})};function Un(e,n){return e.chainId===n.chainId&&e.txHash===n.txHash}const Yt=({chainId:e,txHash:n})=>`${U.OP_REMINDER}:${e}:${n}`,yl=fr.atomWithStorage(U.OP_REMINDER,[]);function It(){const e=Z(),[n=[],s]=_e.useAtom(yl),r=f.useMemo(()=>n.map(c=>{const d=localStorage.getItem(Yt(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:jt.isPast(u)}),[e,n]),a=f.useCallback((c,d)=>{n.some(u=>Un(u,c))||(s((u=[])=>[...u,c]),localStorage.setItem(Yt(c),JSON.stringify(d)))},[n,s]),o=f.useCallback(c=>{s((d=[])=>d.filter(u=>!Un(u,c))),localStorage.removeItem(Yt(c))},[s]),i=f.useCallback(c=>{const d=c.filter(u=>!n.some(m=>Un(m,u)));d.length!==0&&s((u=[])=>[...u,...d])},[n,s]),l=f.useCallback((c,d)=>{localStorage.setItem(Yt(c),JSON.stringify(d)),s((u=[])=>[...u])},[s]);return{reminders:r,addReminder:a,removeReminder:o,syncReminders:i,setReminder:l}}function uo(){const e=ie(),{openModal:n,closeModal:s}=zt(),{reminders:r,setReminder:a}=It();f.useEffect(()=>{const o=r.filter(c=>!c.dismissed);if(o.length===0)return;const i=()=>{const c=o.every(d=>d.chainId===o[0].chainId)?o[0].chainId:void 0;e("/op/withdrawals",{chainId:c}),l()},l=()=>{s();for(const c of o)a(c,{...c,dismissed:!0})};n({content:f.createElement(xl,{list:o,onNavigate:i,onDismiss:l})})},[r,s,e,n,a])}const jl="2.0.0-rc.4",vl="_flex_1v8wv_1",wl={flex:vl},ss=({mt:e,mb:n,children:s})=>t.jsx("div",{className:wl.flex,style:{marginTop:e,marginBottom:n},children:s}),bl="_toggle_grhff_1",Cl="_name_grhff_7",Nl="_rollups_grhff_11",Il="_version_grhff_29",Jt={toggle:bl,name:Cl,rollups:Nl,version:Il},mo=({renderContent:e,storageKey:n})=>{const{defaultChainId:s}=ne(),{addedChains:r}=vt(),[a,o]=ue.useLocalStorage(`${U.OPENED_CHAIN_IDS}:${n}`,[s]),i=a.length===0,l=()=>{o(i?r.map(c=>c.chainId):[])};return t.jsxs(t.Fragment,{children:[t.jsx(ss,{mb:6,children:t.jsxs(G.Small,{className:Jt.toggle,onClick:l,children:[t.jsx("span",{children:i?"Expand all":"Collapse all"}),i?t.jsx(b.IconChevronDown,{size:10}):t.jsx(b.IconChevronUp,{size:10})]})}),t.jsx(eo,{list:r,getKey:({chainId:c})=>c,renderHeader:({name:c,logoUrl:d})=>t.jsxs(t.Fragment,{children:[t.jsx(Y,{src:d,width:16,height:16}),t.jsx("span",{className:Jt.name,children:c})]}),renderContent:e,value:a,onValueChange:o,footer:t.jsxs(Ut,{className:Jt.rollups,to:"/rollups",children:[t.jsx(b.IconSettingFilled,{size:12}),t.jsx("span",{children:"Manage rollup list"})]})}),t.jsx(ss,{mt:8,children:t.jsxs("span",{className:Jt.version,children:["v",jl]})})]})},Sl="_asset_1dxy8_1",$l="_token_1dxy8_23",kl="_symbol_1dxy8_28",El="_name_1dxy8_29",Al="_balance_1dxy8_40",Tl="_amount_1dxy8_45",ql="_value_1dxy8_49",Ze={asset:Sl,token:$l,symbol:kl,name:El,balance:Al,amount:Tl,value:ql},Dl=e=>{const{denom:n,symbol:s,name:r,logoUrl:a,decimals:o,balance:i="0",value:l=0}=e;return t.jsxs("div",{className:Ze.asset,children:[t.jsx(Y,{src:a,width:24,height:24}),t.jsxs("div",{className:Ze.token,children:[t.jsx("div",{className:Ze.symbol,children:s??D.truncate(n)}),r&&t.jsx("div",{className:Ze.name,children:r})]}),F(i).gt(0)&&t.jsxs("div",{className:Ze.balance,children:[t.jsx("div",{className:Ze.amount,children:D.formatAmount(i,{decimals:o})}),l>0&&t.jsxs("div",{className:Ze.value,children:["$",D.formatNumber(l)]})]})]})},Pl="_actions_180l3_1",Bl="_button_180l3_8",Fl="_add_180l3_25",At={actions:Pl,button:Bl,add:Fl},Rl=({denom:e,chain:n})=>{const s=ie(),{defaultChainId:r}=ne(),{evm_chain_id:a}=Kt(),{address:o="",symbol:i,decimals:l,logoUrl:c}=xs(e,n),{connector:d}=ye.useAccount(),{switchChainAsync:u}=ye.useSwitchChain(),{watchAssetAsync:m}=ye.useWatchAsset(),{chainId:h}=n,_=()=>{s("/send",{denom:e,chain:n})},p=()=>{s("/bridge",{srcChainId:h,srcDenom:e})},g=$.useMutation({mutationFn:async()=>(await u({chainId:Number(a)}),m({type:"ERC20",options:{address:o,symbol:i,decimals:l,image:c}}))});return t.jsxs("nav",{className:At.actions,children:[t.jsx("button",{className:At.button,onClick:_,children:"Send"}),t.jsx("button",{className:At.button,onClick:p,children:"Bridge/Swap"}),h===r&&!!o&&t.jsxs("button",{className:R(At.button,At.add),onClick:()=>g.mutate(),disabled:g.isPending||g.data,children:[g.data?t.jsx(b.IconCheck,{size:10}):t.jsx(b.IconPlus,{size:10}),t.jsx(Y,{src:d==null?void 0:d.icon,width:16,height:16})]})]})},Ml="_list_wod0u_1",Ol="_item_wod0u_8",Ul="_trigger_wod0u_19",zl="_content_wod0u_24",Zt={list:Ml,item:Ol,trigger:Ul,content:zl},Kl=e=>{const n=Kr(e);return n.length?t.jsx(T.Accordion.Root,{type:"single",collapsible:!0,className:Zt.list,children:n.map(s=>t.jsxs(T.Accordion.Item,{className:Zt.item,value:s.denom,children:[t.jsx(T.Accordion.Header,{children:t.jsx(T.Accordion.Trigger,{className:Zt.trigger,children:t.jsx(yn,{asset:s,chain:e,children:r=>t.jsx(Dl,{...r})})})}),t.jsx(T.Accordion.Content,{className:Zt.content,children:t.jsx(Rl,{denom:s.denom,chain:e})})]},s.denom))}):t.jsx(ae,{children:"No assets"})},Hl=()=>t.jsx(mo,{renderContent:e=>t.jsx(se,{children:t.jsx(Kl,{...e})}),storageKey:"assets"});function ho(e,n){var a;const s=((a=n==null?void 0:n.pages)==null?void 0:a.map(o=>o[e]??[]).flat())??[],r=A.pathOr(0,[0,"pagination","total"],n==null?void 0:n.pages);return{list:s,count:r}}function _o(e){return e.pagination.next_key}async function Ll(e,n,s){const r=H.create(n),a=async(o,i)=>{const l=await r.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[s]??[],d=_o(l),u=[...o,...c];return d?a(u,d):u};return a([],null)}const bs=qe.createQueryKeys("interwovenkit:nft",{collections:(e,n)=>[e,n],collection:(e,n,s)=>[e,n,s],metadata:e=>[e]});function Wl(e){const{object_addr:n,collection:s}=e;return{object_addr:n,...s}}function Ql(e,n){const{collection_addr:s,collection_name:r,nft:a,object_addr:o}=e,i=n.name??a.token_id;return{collection_addr:s,collection_name:r,...a,object_addr:o,...n,name:i}}function Vl(e){const{indexerUrl:n}=e,s=Z(),{data:r}=$.useSuspenseQuery({queryKey:bs.collections(n,s).queryKey,queryFn:()=>Ll(`indexer/nft/v1/collections/by_account/${s}`,{prefixUrl:n},"collections"),select:a=>a.map(Wl),staleTime:L.SECOND});return r}function fo({chain:e,collection:n}){const s=Z(),{object_addr:r}=n,{indexerUrl:a}=e;return $.useSuspenseInfiniteQuery({queryKey:bs.collection(a,s,r).queryKey,queryFn:({pageParam:o=""})=>H.create({prefixUrl:a}).get(`indexer/nft/v1/tokens/by_account/${s}`,{searchParams:{collection_addr:r,"pagination.key":o||"","pagination.limit":9}}).json(),initialPageParam:"",getNextPageParam:_o,staleTime:L.SECOND})}function Qs(e){return e==null?void 0:e.replace("ipfs://","https://ipfs.io/ipfs/")}function Gl(e){const n=Qs(e);return $.useQuery({queryKey:bs.metadata(n).queryKey,queryFn:async()=>{try{if(!n)return{};const s=await H.get(n).json();return{...s,image:Qs(s.image)}}catch{return{}}},staleTime:L.INFINITY})}const po=({nftResponse:e,children:n})=>{const{data:s={}}=Gl(e.nft.uri),r=Ql(e,s);return n(r)},Yl="_thumbnail_1se9u_1",Jl="_placeholder_1se9u_15",Zl="_clickable_1se9u_21",Tt={thumbnail:Yl,placeholder:Jl,clickable:Zl},wn=({chain:e,collection:n,nft:s,size:r,onClick:a})=>{const o=new URL(`/v1/${e.chainId}/${n.object_addr}/${s.object_addr||s.token_id}`,"https://glyph.initia.xyz").toString();return a?t.jsx("button",{className:R(Tt.thumbnail,Tt.clickable),onClick:a,style:{width:r,height:r},children:t.jsx(Y,{src:o,classNames:{placeholder:Tt.placeholder}})}):t.jsx("div",{className:Tt.thumbnail,style:{width:r,height:r},children:t.jsx(Y,{src:o,classNames:{placeholder:Tt.placeholder}})})},Xl="_item_1rdda_1",ed="_content_1rdda_15",td="_name_1rdda_21",nd="_count_1rdda_27",sd="_chevron_1rdda_33",qt={item:Xl,content:ed,name:td,count:nd,chevron:sd},rd=({chain:e,collection:n})=>{const{data:s}=fo({chain:e,collection:n}),{list:r,count:a}=ho("tokens",s),[o]=r;return t.jsxs(Ut,{className:qt.item,to:"/collection",state:{collection:n,chain:e},children:[o&&t.jsx(po,{nftResponse:o,children:i=>t.jsx(wn,{chain:e,collection:n,nft:i,size:58})}),t.jsxs("div",{className:qt.content,children:[t.jsx("div",{className:qt.name,children:n.name}),a>0&&t.jsx("div",{className:qt.count,children:a})]}),t.jsx("div",{className:qt.chevron,children:t.jsx(b.IconChevronRight,{})})]})},od="_list_1lv70_1",ad={list:od},id=({chain:e})=>{const n=Vl(e);return n.length?t.jsx("div",{className:ad.list,children:n.map(s=>t.jsx(rd,{collection:s,chain:e},s.object_addr))}):t.jsx(ae,{children:"No collections"})},cd=()=>t.jsx(mo,{renderContent:e=>t.jsx(se,{children:t.jsx(id,{chain:e})}),storageKey:"nfts"}),it=({title:e,content:n,children:s,className:r})=>{const[a,o]=f.useState(!1),i=()=>o(!1);return t.jsx(Yr,{title:e,trigger:t.jsx("button",{className:r,children:s}),open:a,onOpenChange:o,children:n(i)})},ld="_scrollable_1p1lw_1",dd="_list_1p1lw_5",ud="_item_1p1lw_9",md="_name_1p1lw_13",Xt={scrollable:ld,list:dd,item:ud,name:md};function go({onSelect:e,list:n,...s}){const{getImage:r,getName:a,getKey:o,getIsLoading:i,getDisabled:l}=s;return t.jsx(Pe,{className:Xt.scrollable,children:t.jsx("div",{className:Xt.list,children:n.map(c=>t.jsxs("button",{className:Xt.item,onClick:()=>e(c),disabled:(i==null?void 0:i(c))||(l==null?void 0:l(c)),children:[t.jsx(Y,{src:r(c),width:28,height:28}),t.jsx("span",{className:Xt.name,children:a(c)}),(i==null?void 0:i(c))&&t.jsx(We,{size:16})]},o(c)))})})}const xo=({onSelect:e})=>{const{addedChains:n}=vt();return t.jsx(go,{onSelect:s=>e(s.chainId),list:n,getImage:s=>s.logoUrl,getName:s=>s.name,getKey:s=>s.chainId})},hd="_button_1uc4x_1",_d="_name_1uc4x_9",fd="_icon_1uc4x_13",zn={button:hd,name:_d,icon:fd},pd=({value:e,onSelect:n})=>{const{logoUrl:s,name:r}=ve(e);return t.jsxs(it,{title:"Select rollup",content:a=>t.jsx(xo,{onSelect:o=>{n(o),a()}}),className:R("input",zn.button),children:[t.jsx(Y,{src:s,width:16,height:16}),t.jsx("span",{className:zn.name,children:r}),t.jsx(b.IconChevronDown,{size:16,className:zn.icon})]})},gd="_message_1g2hc_1",xd="_more_1g2hc_8",Vs={message:gd,more:xd},yd=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((n,s)=>t.jsx("p",{className:Vs.message,children:Ot.sentenceCase(n["@type"].split("Msg")[1])},s)),e.length>3&&t.jsx("footer",{className:Vs.more,children:`+${e.length-3} more`})]}),jd="_change_nbl45_1",vd="_positive_nbl45_9",wd="_negative_nbl45_13",Kn={change:jd,positive:vd,negative:wd},yo=({amount:e,asset:n})=>{const{denom:s,symbol:r,decimals:a}=n,o=new F(e).isPositive(),i=new F(e).abs().toString();return t.jsxs("div",{className:R(Kn.change,o?Kn.positive:Kn.negative),children:[o?"+":"-",D.formatAmount(i,{decimals:a})," ",r??D.truncate(s)]})},bd=({changes:e,chain:n})=>{const s=He(n);return e.map(({amount:r,denom:a},o)=>t.jsx(yo,{amount:r,asset:s(a)},o))},Cd=({changes:e,chain:n})=>{const s=He(n);return e.map(({amount:r,metadata:a},o)=>t.jsx(ro,{metadata:a,chain:n,children:i=>t.jsx(yn,{asset:s(i),chain:n,children:l=>t.jsx(yo,{amount:r,asset:l})})},o))},Nd=({events:e,chain:n})=>{var a,o,i;const{initiaAddress:s,hexAddress:r}=pe();return(a=n.metadata)!=null&&a.is_l1||((i=(o=n.metadata)==null?void 0:o.minitia)==null?void 0:i.type)==="minimove"?t.jsx(Cd,{changes:so(e,r),chain:n}):t.jsx(bd,{changes:no(e,s),chain:n})},Id="_link_qkpto_1",Sd="_inner_qkpto_14",$d="_timestamp_qkpto_23",kd="_content_qkpto_39",Ed="_messages_qkpto_45",Ad="_changes_qkpto_50",Td="_error_qkpto_57",Xe={link:Id,inner:Sd,timestamp:$d,content:kd,messages:Ed,changes:Ad,error:Td},qd=({txItem:e,chain:n})=>t.jsx(vn,{txHash:e.txhash,chainId:n.chainId,className:Xe.link,children:t.jsxs("div",{className:Xe.inner,children:[t.jsx("div",{className:Xe.timestamp,children:Ot.sentenceCase(jt.intlFormatDistance(new Date(e.timestamp),new Date,{locale:"en-US"}))}),t.jsxs("div",{className:Xe.content,children:[t.jsx("div",{className:Xe.messages,children:t.jsx(yd,{messages:e.tx.body.messages})}),t.jsx("div",{className:Xe.changes,children:t.jsx(se,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(Nd,{...e,chain:n})})})]}),e.code!==0&&t.jsxs("div",{className:Xe.error,children:[t.jsx(b.IconWarningFilled,{size:12}),t.jsx("span",{children:"Failed"})]})]})}),Dd="_list_si737_1",Pd="_more_si737_7",Gs={list:Dd,more:Pd},Bd=({chain:e})=>{const n=Z(),{data:s}=Jr(e);return s.length?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Gs.list,children:s.map(r=>t.jsx(qd,{txItem:r,chain:e},r.txhash))}),t.jsx(vn,{chainId:e.chainId,accountAddress:n,pathSuffix:"/txs",className:Gs.more,showIcon:!0,children:"View more on Initia Scan"})]}):t.jsx(ae,{children:"No activity yet"})},Fd=()=>{const{defaultChainId:e}=ne(),[n,s]=ue.useLocalStorage(U.ACTIVITY_CHAIN_ID,e),r=ve(n);return t.jsxs(t.Fragment,{children:[t.jsx(pd,{value:n,onSelect:s}),t.jsx(se,{children:t.jsx(Bd,{chain:r})},n)]})},Rd="_nav_1ldnv_1",Md="_item_1ldnv_6",Od="_tabs_1ldnv_28",Ud="_tab_1ldnv_28",et={nav:Rd,item:Md,tabs:Od,tab:Ud},zd=()=>{uo();const e=ie(),n=Nr();return t.jsxs(Pe,{children:[t.jsxs("div",{className:et.nav,children:[t.jsxs(Ut,{to:"/send",className:et.item,children:[t.jsx(b.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs("button",{className:et.item,onClick:()=>e("/bridge"),children:[t.jsx(b.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]})]}),t.jsxs(T.Tabs.Root,{value:n,onValueChange:e,children:[t.jsxs(T.Tabs.List,{className:et.tabs,children:[t.jsx(T.Tabs.Trigger,{className:et.tab,value:"/",children:"Assets"}),t.jsx(T.Tabs.Trigger,{className:et.tab,value:"/nfts",children:"NFTs"}),t.jsx(T.Tabs.Trigger,{className:et.tab,value:"/activity",children:"Activity"})]}),t.jsx(T.Tabs.Content,{value:"/",children:t.jsx(Hl,{})}),t.jsx(T.Tabs.Content,{value:"/nfts",children:t.jsx(cd,{})}),t.jsx(T.Tabs.Content,{value:"/activity",children:t.jsx(Fd,{})})]})]})};function jo({quantity:e,balance:n,decimals:s},r){if(F.BigNumber(e).isZero()){r.addIssue({code:J.z.ZodIssueCode.custom,message:"Enter amount",path:["quantity"]});return}if(!n||F.BigNumber(D.toBaseUnit(e,{decimals:s})).gt(n)){r.addIssue({code:J.z.ZodIssueCode.custom,message:"Insufficient balance",path:["quantity"]});return}}const vo=J.z.string().nonempty("Recipient address is required").refine(e=>M.validate(e),"Invalid address"),Kd="_header_acels_1",Hd="_back_acels_11",Ld="_title_acels_23",Hn={header:Kd,back:Hd,title:Ld},Be=({title:e,returnTo:n,extra:s,children:r})=>t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Hn.header,children:[n!==!1&&t.jsx(Ut,{to:n??-1,className:Hn.back,children:t.jsx(b.IconBack,{size:16})}),t.jsx("h1",{className:Hn.title,children:e}),s]}),t.jsx(Pe,{children:r})]}),Wd="_fieldset_y241y_1",Qd="_upper_y241y_9",Vd="_select_y241y_14",Gd="_account_y241y_19",Yd="_lower_y241y_24",Jd="_wrapper_y241y_25",Zd="_balance_y241y_32",Xd="_value_y241y_36",eu="_error_y241y_49",Ee={fieldset:Wd,upper:Qd,select:Vd,account:Gd,lower:Yd,wrapper:Jd,balance:Zd,value:Xd,error:eu},rs=e=>{const{selectButton:n,accountButton:s,quantityInput:r,balanceButton:a,value:o,errorMessage:i}=e;return t.jsxs("div",{className:Ee.fieldset,children:[t.jsxs("div",{className:Ee.upper,children:[t.jsx("div",{className:Ee.select,children:n}),t.jsx("div",{className:Ee.account,children:s})]}),t.jsxs("div",{className:Ee.lower,children:[r,t.jsxs("div",{className:Ee.wrapper,children:[t.jsx("div",{className:Ee.balance,children:a}),o&&t.jsxs("div",{className:Ee.value,children:["$",o]})]}),i&&t.jsxs("footer",{className:Ee.error,children:[t.jsx(b.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})},tu="_images_1txea_1",nu="_chain_1txea_5",Ys={images:tu,chain:nu},Cs=({assetLogoUrl:e,chainLogoUrl:n})=>t.jsxs("div",{className:Ys.images,children:[t.jsx(Y,{src:e,width:36,height:36}),t.jsx(Y,{src:n,width:18,height:18,className:Ys.chain})]}),su="_root_1ipwv_1",ru="_content_1ipwv_10",ou="_details_1ipwv_18",au="_symbol_1ipwv_23",iu="_chain_1ipwv_31",cu="_chevron_1ipwv_40",tt={root:su,content:ru,details:ou,symbol:au,chain:iu,chevron:cu},wo=({asset:e,chain:n,readOnly:s})=>{const r=t.jsxs("div",{className:tt.content,children:[t.jsx(Cs,{assetLogoUrl:e.logoUrl,chainLogoUrl:n.logoUrl}),t.jsxs("div",{className:tt.details,children:[t.jsx("div",{className:tt.symbol,children:e.symbol}),t.jsxs("div",{className:tt.chain,children:["on ",n.name]})]})]});return s?t.jsx("div",{className:tt.root,children:r}):t.jsxs("div",{className:tt.root,children:[r,t.jsx(b.IconChevronDown,{size:16,className:tt.chevron})]})},lu="_wrapper_5vodt_1",du="_balance_5vodt_11",uu="_button_5vodt_15",Ln={wrapper:lu,balance:du,button:uu},bo=({onClick:e,children:n})=>t.jsxs("div",{className:Ln.wrapper,children:[t.jsx(b.IconWallet,{size:16}),t.jsx("span",{className:Ln.balance,children:n}),t.jsx("button",{type:"button",className:Ln.button,onClick:()=>e(),children:"MAX"})]});function bn(){const e=f.useRef(null),n=jn();return f.useEffect(()=>{var s;n||(s=e.current)==null||s.focus()},[n]),e}const mu="_input_h8073_1",hu={input:mu};function _u(e,n){const s=e.replace(/[^0-9.]/g,""),[r,...a]=s.split(".");return a.length===0?r:`${r}.${a.join("").slice(0,n)}`}function Co(e){const{name:n,control:s,dp:r=6,className:a,...o}=e,i=bn();return t.jsx(oe.Controller,{name:n,control:s,render:({field:l})=>t.jsx("input",{...l,className:R(hu.input,a),onChange:c=>l.onChange(_u(c.target.value,r)),placeholder:"0",inputMode:"decimal",autoComplete:"off",...o,ref:yr.mergeRefs([l.ref,i])})})}const fu="_input_qpv94_1",pu="_placeholder_qpv94_18",os={input:fu,placeholder:pu},gu=({children:e})=>t.jsx("p",{className:R(os.input,{[os.placeholder]:F(e).isZero()}),children:e}),dn=()=>{const{control:e}=oe.useFormContext();return t.jsx(Co,{name:"quantity",control:e,className:os.input})};dn.ReadOnly=gu;const xu="_label_9417z_1",yu="_wrapper_9417z_7",ju="_input_9417z_10",vu="_clear_9417z_18",en={label:xu,wrapper:yu,input:ju,clear:vu},Ns=({mode:e="onChange",myAddress:n,...s})=>{const{validate:r=M.validate,chainType:a="initia",onApply:o,ref:i}=s,l=bn(),{getValues:c,setValue:d,formState:u}=oe.useFormContext(),m=c("recipient"),[h,_]=f.useState(m),p=zr(),{data:g,isLoading:y,error:C}=$.useQuery({queryKey:Ht.address(p.restUrl,h).queryKey,queryFn:()=>p.getAddress(h),staleTime:L.MINUTE,enabled:p.validateUsername(h)}),N=g??(r(h)?h:""),q=n&&M.equals(N,n),j=async()=>{try{const v=await navigator.clipboard.readText();_(v.trim())}catch{}};f.useEffect(()=>{e==="onChange"&&h&&d("recipient",g??h,{shouldValidate:!0})},[h,e,d,g]);const S=()=>{y||C||(d("recipient",N,{shouldValidate:!0}),o==null||o())},w=()=>{var v;if(y)return t.jsx(Oe,{level:"loading",children:"Resolving username..."});if(C)return t.jsx(Oe,{level:"error",children:C.message});if(g)return t.jsx(Oe,{level:"success",className:"monospace",children:g});if(e==="onSubmit"&&h&&!N)return t.jsx(Oe,{level:"error",children:"Invalid address"});if(e==="onChange")return t.jsx(Oe,{level:"error",children:(v=u.errors.recipient)==null?void 0:v.message})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:en.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(G.Small,{type:"button",onClick:j,children:"Paste"})]}),t.jsxs("div",{className:en.wrapper,children:[t.jsx("input",{id:"recipient",className:R(en.input,"monospace"),value:h,onChange:v=>_(v.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":h?"true":void 0,ref:e==="onSubmit"?yr.mergeRefs([i,l]):i}),!!h&&t.jsx("button",{type:"button",className:en.clear,onClick:()=>_(""),"aria-label":"Clear recipient",children:t.jsx(b.IconCloseCircleFilled,{size:16})})]}),w(),q&&t.jsx(Oe,{children:"This is my address"}),e==="onSubmit"&&t.jsx(re,{extra:(!n||!!N&&!q)&&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(G.White,{type:"button",onClick:S,disabled:y||!!C||!N,children:"Apply"})})]})},No=2e5;function wu({balances:e,gasPrices:n}){return n.map(({denom:s,amount:r})=>{var i;const a=F(r).times(No).toFixed(0,F.ROUND_CEIL),o=((i=e.find(l=>l.denom===s))==null?void 0:i.amount)??"0";return{amount:a,denom:s,balance:o}}).filter(({amount:s,balance:r})=>F(r).gte(s))}function bu({denom:e,balances:n,gasPrices:s,lastFeeDenom:r}){var c;const a=((c=n.find(d=>d.denom===e))==null?void 0:c.amount)??"0",o=wu({balances:n,gasPrices:s}),i=o.find(d=>d.denom===r);if(o.length===0)return"0";if(e===r&&i){const d=F(a).minus(i.amount);return F.max(d,0).toString()}const[l]=o;if(!i&&e===l.denom){const d=F(a).minus(l.amount);return F.max(d,0).toString()}return F(a).toString()}const Cu="_container_1a4ds_1",Nu="_badge_1a4ds_5",Js={container:Cu,badge:Nu},Io=e=>{const{offset:n=-4,disabled:s,children:r,className:a}=e;return t.jsxs("div",{className:R(Js.container,a),children:[r,!s&&t.jsx("div",{className:Js.badge,style:{right:n,top:n}})]})},Iu="_stack_a3b9q_1",Su="_title_a3b9q_8",$u="_grid_a3b9q_15",ku="_item_a3b9q_21",Eu="_button_a3b9q_25",Au="_active_a3b9q_43",_t={stack:Iu,title:Su,grid:$u,item:ku,button:Eu,active:Au},ot=({label:e,chains:n,value:s,onSelect:r,getShowIndicator:a})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:_t.title,children:e}),t.jsx("div",{className:_t.grid,children:n.map(({chainId:o,name:i,logoUrl:l})=>t.jsx(Io,{offset:-2,disabled:!(a!=null&&a(o)),className:_t.item,children:t.jsx(Nt,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:R(_t.button,{[_t.active]:o===s}),onClick:()=>r(o),children:t.jsx(Y,{src:l,width:28,height:28,circle:!0})})})},o))})]}),Tu=({children:e})=>t.jsx("div",{className:_t.stack,children:e});ot.Stack=Tu;function So(e,n,s){return s.filter(r=>{const a=e.map(o=>r[o]).map(o=>String(o??"").toLowerCase());return A.any(A.includes(n.toLowerCase()),a)})}const qu="_root_qd12v_1",Du="_label_qd12v_8",Pu="_input_qd12v_14",Bu="_clear_qd12v_20",tn={root:qu,label:Du,input:Pu,clear:Bu},Is=({value:e="",onChange:n,placeholder:s="Search",className:r})=>t.jsxs("div",{className:R(tn.root,r),children:[t.jsx("label",{htmlFor:"search",className:tn.label,children:t.jsx(b.IconSearch,{size:16})}),t.jsx("input",{id:"search",type:"text",className:tn.input,value:e,onChange:a=>n==null?void 0:n(a.target.value),placeholder:s,readOnly:!n,ref:bn()}),e&&t.jsx("button",{className:tn.clear,onClick:()=>n==null?void 0:n(""),children:t.jsx(b.IconCloseCircleFilled,{size:20})})]}),Fu="_container_17tpb_1",Ru="_list_17tpb_6",Mu="_item_17tpb_12",Ou="_logo_17tpb_31",Uu="_info_17tpb_35",zu="_symbol_17tpb_40",Ku="_name_17tpb_44",Hu="_balance_17tpb_50",Lu="_value_17tpb_58",Ne={container:Fu,list:Ru,item:Mu,logo:Ou,info:Uu,symbol:zu,name:Ku,balance:Hu,value:Lu},Wt=e=>{const{assets:n,onSelect:s,renderAsset:r=(l,c)=>c(l)}=e,[a,o]=f.useState(""),i=So(["symbol"],a,n);return t.jsxs("div",{className:Ne.container,children:[t.jsx(Is,{value:a,onChange:o,placeholder:"Search by symbol"}),i.length===0?t.jsx(ae,{children:"No assets"}):t.jsx("div",{className:Ne.list,children:i.map(l=>t.jsx("button",{type:"button",className:Ne.item,onClick:()=>s(l.denom),children:r(l,({logoUrl:c,symbol:d,name:u,balance:m,decimals:h,value:_=0})=>t.jsxs(t.Fragment,{children:[t.jsx(Y,{src:c,width:32,height:32,className:Ne.logo}),t.jsxs("div",{className:Ne.info,children:[t.jsx("div",{className:Ne.symbol,children:d}),t.jsx("div",{className:Ne.name,children:u})]}),t.jsxs("div",{className:Ne.balance,children:[m&&t.jsx("div",{children:D.formatAmount(m,{decimals:h})}),_>0&&t.jsxs("div",{className:Ne.value,children:["$",D.formatNumber(_)]})]})]}))},l.denom))})]})},Wu=()=>t.jsxs("div",{className:Ne.container,children:[t.jsx(Is,{placeholder:"Search by symbol"}),t.jsx(ae,{children:"Loading..."})]});Wt.Placeholder=Wu;const Qu=({chain:e,onSelect:n})=>{const s=Kr(e);return s.length===0?t.jsx(ae,{children:"No assets"}):t.jsx(Wt,{assets:s,onSelect:n,renderAsset:(r,a)=>t.jsx(yn,{asset:r,chain:e,children:o=>a(o)})})},Vu=({afterSelect:e})=>{const{watch:n,setValue:s}=oe.useFormContext(),{chainId:r}=n(),[a,o]=f.useState(r),i=ve(a),{addedChains:l}=vt(),c=d=>{s("chainId",a),s("denom",d),e()};return t.jsxs(t.Fragment,{children:[l.length>1&&t.jsx(ot.Stack,{children:t.jsx(ot,{chains:l,value:a,onSelect:o})}),t.jsx(se,{suspenseFallback:t.jsx(Wt.Placeholder,{}),children:t.jsx(Qu,{chain:i,onSelect:c})},a)]})},Gu="_fields_brpej_1",Yu="_divider_brpej_11",Zs={fields:Gu,divider:Yu},Ju=()=>{var x,k,O,B;const{address:e,initiaAddress:n,requestTxSync:s}=pe(),{register:r,watch:a,setValue:o,handleSubmit:i,formState:l}=oe.useFormContext(),{chainId:c,denom:d,quantity:u,memo:m}=a(),{addedChains:h}=vt(),_=ve(c),p=ys(_),g=Zr(_),y=Xr(_),C=xs(d,_),{data:N}=fn(_.chainId),{decimals:q}=C,j=((x=p.find(P=>P.denom===d))==null?void 0:x.amount)??"0",S=(k=N==null?void 0:N.find(({id:P})=>P===d))==null?void 0:k.price,w=bu({denom:d,balances:p,gasPrices:g,lastFeeDenom:y}),{mutate:v,isPending:E}=$.useMutation({mutationFn:({chainId:P,denom:W,quantity:Q,recipient:V,memo:ce})=>{const be=D.toBaseUnit(Q,{decimals:q}),ke=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:na.MsgSend.fromPartial({fromAddress:n,toAddress:M.toBech32(V),amount:[{denom:W,amount:be}]})}];return s({messages:ke,memo:ce,chainId:P,gas:No,gasAdjustment:1,gasPrices:g,spendCoins:[{denom:W,amount:be}],internal:"/"})}});return t.jsx(Be,{title:"Send",children:t.jsxs("form",{onSubmit:i(P=>v(P)),children:[t.jsxs("div",{className:Zs.fields,children:[t.jsx(rs,{selectButton:t.jsx(it,{title:h.length>1?"Select chain and asset":"Select asset",content:P=>t.jsx(Vu,{afterSelect:P}),children:t.jsx(wo,{asset:C,chain:_})}),quantityInput:t.jsx(dn,{}),balanceButton:t.jsx(bo,{onClick:()=>o("quantity",D.fromBaseUnit(w,{decimals:q}),{shouldValidate:!0}),children:D.formatAmount(j,{decimals:q})}),value:u?S?D.formatNumber(F(u).times(S)):"-":"0",errorMessage:(O=l.errors.quantity)==null?void 0:O.message}),t.jsx("div",{className:Zs.divider}),t.jsx(Ns,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...r("memo"),id:"memo",autoComplete:"off"}),t.jsx(Oe,{level:"error",children:(B=l.errors.memo)==null?void 0:B.message})]}),t.jsx(te.Stack,{children:!m&&t.jsx(te,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(re,{children:t.jsx(G.White,{type:"submit",loading:E,disabled:!l.isValid,children:"Confirm"})})]})})},Zu=J.z.object({chainId:J.z.string().nonempty(),denom:J.z.string().nonempty(),quantity:J.z.string().nonempty("Amount is required"),recipient:vo,memo:J.z.string().optional().refine(e=>!e||new Blob([e]).size<=256,"Memo is too long")}),Xu=()=>{const e=Ue(),n=Kt(),s=Ft(n),[r]=s,{chain:a=n,denom:o=r.denom}=e,i=De(),l=Z(),c=$.useQueryClient(),d=oe.useForm({mode:"onChange",defaultValues:{chainId:a.chainId,denom:o,quantity:"",recipient:"",memo:""},resolver:hs.zodResolver(Zu.superRefine(({chainId:u,denom:m,quantity:h},_)=>{var N;const p=i(u),{decimals:g}=c.getQueryData(at.item(u,m).queryKey)??{decimals:0},{balances:y}=c.getQueryData(Ht.balances(p.restUrl,l).queryKey)??{balances:[]},C=(N=y.find(q=>q.denom===m))==null?void 0:N.amount;jo({quantity:h,balance:C,decimals:g},_)}))});return t.jsx(oe.FormProvider,{...d,children:t.jsx(Ju,{})})},em="_button_1iys9_1",tm={button:em},Ss=({onClick:e,disabled:n})=>{const{ref:s,inView:r}=sa.useInView();return f.useEffect(()=>{r&&e()},[r,e]),t.jsxs("button",{className:tm.button,onClick:e,disabled:n,ref:s,children:[t.jsx("span",{children:"Load more"}),t.jsx(b.IconChevronDown,{size:12})]})},nm="_grid_4j669_1",sm="_item_4j669_7",rm="_name_4j669_15",Wn={grid:nm,item:sm,name:rm},om=()=>{const e=ie(),{collection:n,chain:s}=Ue(),{data:r,hasNextPage:a,isFetching:o,fetchNextPage:i}=fo({chain:s,collection:n}),{list:l}=ho("tokens",r);return t.jsxs(Be,{title:n.name,children:[t.jsx("div",{className:Wn.grid,children:l.map(c=>t.jsx(po,{nftResponse:c,children:d=>t.jsxs("div",{className:Wn.item,children:[t.jsx(wn,{chain:s,collection:n,nft:d,onClick:()=>e("/nft",{collection:n,nft:d,chain:s})}),t.jsx("div",{className:Wn.name,children:d.name})]})},c.object_addr))}),a&&t.jsx(Ss,{onClick:()=>i(),disabled:o})]})},am="_header_196nx_1",im="_name_196nx_6",cm="_attributes_196nx_12",lm="_title_196nx_15",dm="_list_196nx_21",um="_item_196nx_25",mm="_type_196nx_34",hm="_value_196nx_40",Re={header:am,name:im,attributes:cm,title:lm,list:dm,item:um,type:mm,value:hm},_m=()=>{const e=ie(),n=Ue(),{collection:s,nft:r,chain:a}=n,{image:o,name:i,attributes:l}=r;return t.jsxs(Be,{title:s.name,children:[t.jsxs("header",{className:Re.header,children:[o&&t.jsx(wn,{chain:a,collection:s,nft:r}),t.jsx("h2",{className:Re.name,children:i})]}),t.jsx(re,{children:t.jsx(G.White,{onClick:()=>e("/nft/send",n),children:"Send"})}),l&&t.jsxs("div",{className:Re.attributes,children:[t.jsxs("header",{className:Re.title,children:["Traits (",l.length,")"]}),t.jsx("div",{className:Re.list,children:l.map(({trait_type:c,value:d})=>t.jsxs("div",{className:Re.item,children:[t.jsx("div",{className:Re.type,children:c}),t.jsx("div",{className:Re.value,children:d})]},c))})]})]})};async function fm({object_addr:e},{restUrl:n}){const s=await pm(e,n);return s.startsWith("ibc/")?Ur("0x1",s)===e.replace("0x","").padStart(64,"0")?{class_id:s,class_trace:await as(s,n)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await as(s,n)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:null}}async function pm(e,n){const{data:s}=await H.create({prefixUrl:n}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(s)}async function gm({object_addr:e},{restUrl:n}){const s=await xm(e,n);if(!s.startsWith("ibc/"))return{class_id:`evm/${M.toHex(e)}`,class_trace:null};const r=await as(s,n);return r?{class_id:s,class_trace:r}:{class_id:`evm/${M.toHex(e)}`,class_trace:null}}async function xm(e,n){const s=new Se.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:r}=await H.create({prefixUrl:n}).post("minievm/evm/v1/call",{json:{sender:M.toBech32("0x1"),contract_addr:M.toPrefixedHex(e),input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",r)[0]}async function ym({creator_addr:e,object_addr:n},s,r){var p,g;const a=await jm(n,s.restUrl),o=(g=(p=s.metadata)==null?void 0:p.ibc_channels)==null?void 0:g.find(({chain_id:y,version:C})=>y===r.chain_id&&C.includes("ics721-1"));if(!o)throw new Error("Channel not found");const i=o.port_id,l=i.split(".")[1],c=z.toBase64(nt.toBytes(JSON.stringify({class_id:{contract:n}}))),d=`cosmwasm/wasm/v1/contract/${l}/smart/${c}`,{data:u}=await H.create({prefixUrl:s.restUrl}).get(d).json(),m=u??n;if(u&&e!==i.replace("wasm.","")){const[y,C]=Xs(u);return{class_id:n,class_trace:{path:y,base_class_id:C}}}const[h,_]=Xs(a);return{class_id:m,class_trace:{path:h,base_class_id:_}}}async function jm(e,n){const s=z.toBase64(nt.utf8ToBytes(JSON.stringify({contract_info:{}}))),{name:r}=await H.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return r}const vm={minimove:fm,minievm:gm,miniwasm:ym};async function wm({collection:e,nft:n,srcChain:s,intermediaryChain:r}){var i,l,c;const a=(i=s.metadata)!=null&&i.is_l1?"minimove":(c=(l=s.metadata)==null?void 0:l.minitia)==null?void 0:c.type;if(!(a==="minimove"||a==="minievm"||a==="miniwasm"))throw new Error(`Unsupported minitia type: ${a}`);const o=await vm[a](e,s,r);return Object.assign(o,a==="minievm"&&{token_ids:await bm([n.token_id],o.class_id,s.restUrl)})}async function as(e,n){const s=e.replace("ibc/",""),{class_trace:r}=await H.create({prefixUrl:n}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return r}async function bm(e,n,s){const{token_infos:r}=await H.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${n}`,{searchParams:{token_ids:e.join(",")}}).json();return r.map(({token_origin_id:a})=>a)}function Xs(e){const n=/^(.*channel-\d+)\/(.*)$/,s=e.match(n);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,r,a]=s;return[r,a]}const Cm="_header_5w36t_1",Nm="_name_5w36t_8",Im="_collection_5w36t_15",Sm="_nft_5w36t_20",$m="_fields_5w36t_24",km="_chain_5w36t_29",mt={header:Cm,name:Nm,collection:Im,nft:Sm,fields:$m,chain:km},Em=qe.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),Am=()=>{const{chain:e,collection:n,nft:s}=Ue(),{routerApiUrl:r}=ne(),a=pn(),o=we(),{address:i,initiaAddress:l,requestTxSync:c}=pe(),{watch:d,setValue:u,handleSubmit:m,formState:h}=oe.useFormContext(),_=d(),{recipient:p,dstChainId:g}=_,y=ve(g),C=$.useQuery({queryKey:Em.simulation({collection:n,nft:s,sender:l,recipient:p,srcChain:e,dstChainId:g,layer1:o,routerApiUrl:r}).queryKey,queryFn:async()=>{const v=Object.assign({from_address:l,from_chain_id:e.chainId,to_address:M.toBech32(p),to_chain_id:g,collection_address:n.object_addr,token_ids:[s.token_id],object_addresses:[s.object_addr]},e.chainId!==g&&await wm({collection:n,nft:s,srcChain:e,intermediaryChain:o})),{msgs:E}=await H.create({prefixUrl:r}).post("nft",{json:v}).json();return E.map(x=>a.fromAmino(x))},enabled:!!p}),{data:N,isLoading:q,error:j}=C,{mutate:S,isPending:w}=$.useMutation({mutationFn:async()=>{if(!N)throw new Error("Route not found");await c({messages:N,chainId:e.chainId,internal:"/nfts"})}});return t.jsxs("form",{onSubmit:m(()=>S()),children:[t.jsxs("header",{className:mt.header,children:[s.image&&t.jsx(wn,{chain:e,collection:n,nft:s,size:80}),t.jsxs("div",{className:mt.name,children:[t.jsx("div",{className:mt.collection,children:n.name}),t.jsx("div",{className:mt.nft,children:s.name})]})]}),t.jsxs("div",{className:mt.fields,children:[t.jsx(T.VisuallyHidden.Root,{children:t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination rollup"}),t.jsxs(it,{title:"Destination rollup",content:v=>t.jsx(xo,{onSelect:E=>{u("dstChainId",E),v()}}),className:R("input",mt.chain),children:[t.jsx(Y,{src:y.logoUrl,width:20,height:20}),t.jsx("span",{children:y.name})]})]})}),t.jsx(Ns,{myAddress:i,ref:bn()})]}),t.jsx(re,{children:t.jsx(G.White,{loading:q||w,disabled:!h.isValid,children:j?"Route not found":"Confirm"})})]})},Tm=J.z.object({dstChainId:J.z.string().nonempty(),recipient:vo}),qm=()=>{const{chain:e}=Ue(),n=oe.useForm({defaultValues:{dstChainId:e.chainId},resolver:hs.zodResolver(Tm)});return t.jsx(Be,{title:"Send NFT",children:t.jsx(oe.FormProvider,{...n,children:t.jsx(Am,{})})})},Dm="_item_ny5a8_1",Pm="_header_ny5a8_11",Bm="_name_ny5a8_19",Fm="_link_ny5a8_24",Rm="_button_ny5a8_40",ht={item:Dm,header:Pm,name:Bm,link:Fm,button:Rm},Qn=e=>{var h;const{chainId:n,name:s,logoUrl:r,website:a,metadata:o}=e,{defaultChainId:i}=ne(),{addedChains:l,addChain:c,removeChain:d}=vt(),u=l.find(_=>_.chainId===n),m=()=>n===i?null:u?t.jsx("button",{className:ht.button,onClick:()=>d(n),children:t.jsx(b.IconMinus,{size:14})}):t.jsx("button",{className:ht.button,onClick:()=>c(n),children:t.jsx(b.IconPlus,{size:14})});return t.jsxs("div",{className:ht.item,children:[t.jsx(Y,{src:r,width:32,height:32,title:(h=o==null?void 0:o.minitia)==null?void 0:h.type}),t.jsxs("header",{className:ht.header,children:[t.jsx("h3",{className:ht.name,children:s}),a&&t.jsx("a",{className:ht.link,href:xr(a),target:"_blank",children:t.jsx(b.IconExternalLink,{size:12})})]}),m()]})},Mm="_content_14twd_1",Om="_search_14twd_5",Um="_title_14twd_9",zm="_count_14twd_18",Km="_list_14twd_23",Me={content:Mm,search:Om,title:Um,count:zm,list:Km},Hm=()=>{const[e,n]=f.useState(""),{chains:s,addedChains:r,notAddedChains:a}=vt(),o=So(["chainId","name"],e,s);return t.jsx(Be,{title:"Manage rollup list",children:t.jsxs("div",{className:Me.content,children:[t.jsx(Is,{value:e,onChange:n,className:Me.search}),e?o.length===0?t.jsx(ae,{children:"No chains"}):o.map(i=>f.createElement(Qn,{...i,key:i.chainId})):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Me.list,children:[t.jsxs("h2",{className:Me.title,children:[t.jsx("span",{children:"Shown"}),t.jsxs("span",{className:Me.count,children:["(",r.length,")"]})]}),r.map(i=>f.createElement(Qn,{...i,key:i.chainId}))]}),t.jsxs("div",{className:Me.list,children:[t.jsxs("h2",{className:Me.title,children:[t.jsx("span",{children:"Hidden"}),t.jsxs("span",{className:Me.count,children:["(",a.length,")"]})]}),a.map(i=>f.createElement(Qn,{...i,key:i.chainId}))]})]})]})})};function Lm(){return we().network_type==="testnet"}const $o=J.z.object({srcChainId:J.z.string().nonempty(),srcDenom:J.z.string().nonempty(),dstChainId:J.z.string().nonempty(),dstDenom:J.z.string().nonempty(),quantity:J.z.string().nonempty("Amount is required"),sender:J.z.string().nonempty(),cosmosWalletName:J.z.string().optional(),recipient:J.z.string().nonempty("Recipient address is required"),slippagePercent:J.z.string().nonempty()});function Qe(){return oe.useFormContext()}function Wm(){const e=Ue(),n=Lm(),s={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},r={...s,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},a={...s,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},o=A.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{...n?r:a,...o,...e}}function ko(){const{initiaAddress:e,hexAddress:n}=pe(),s=ct(),r=Lt();return a=>{const o=s(a);switch(r(o)){case"initia":return e;case"evm":return n;default:return""}}}function is(){const e=ct(),n=Lt();return(s,r)=>{const a=e(r);switch(n(a)){case"initia":return M.validate(s);case"evm":return Se.isAddress(s);case"cosmos":try{return z.fromBech32(s).prefix===a.bech32_prefix}catch{return!1}default:return!1}}}function Qm(){const e=ct(),n=Lt();return({initialAddress:s,initialChainId:r,chainId:a,fallbackAddress:o})=>{const i=e(r),l=n(i),c=e(a),d=n(c);if(l==="evm"&&d==="initia")return M.toBech32(s);if(l==="initia"&&d==="evm")return M.toPrefixedHex(s);if(l===d)return s;if(o){if(d==="initia")return M.toBech32(o);if(d==="evm")return M.toPrefixedHex(o)}return""}}const Vm=[["d",1440*60],["h",3600],["m",60],["s",1]];function cs(e){if(!e)return;const{formattedParts:n}=Vm.reduce(({remainingSeconds:s,formattedParts:r},[a,o])=>{const i=Math.floor(s/o);return{remainingSeconds:s-i*o,formattedParts:i>0?[...r,`${i}${a}`]:r}},{remainingSeconds:e,formattedParts:[]});return n.join(" ")}function Eo(e){return e==null?void 0:e.map(n=>{const{amount:s,origin_asset:r}=n;return`${D.formatAmount(s,{decimals:r.decimals??0})} ${r.symbol}`}).join(", ")}function er(e,n){const{watch:s}=Qe(),r=s(),a=Le(),o={...r,quantity:e},i=$.useQueryClient();return $.useQuery({queryKey:fe.route(o,n==null?void 0:n.isOpWithdraw).queryKey,queryFn:()=>{const{srcChainId:l,srcDenom:c,quantity:d,dstChainId:u,dstDenom:m}=o,{decimals:h}=i.getQueryData(fe.asset(l,c).queryKey)??{decimals:0},_={amount_in:D.toBaseUnit(d,{decimals:h}),source_asset_chain_id:l,source_asset_denom:c,dest_asset_chain_id:u,dest_asset_denom:m,is_op_withdraw:n==null?void 0:n.isOpWithdraw};return a.post("v2/fungible/route",{json:_}).json()},enabled:!!Number(o.quantity)&&!(n!=null&&n.disabled),staleTime:L.MINUTE})}function Gm(e){return $.useQuery({queryKey:fe.routeErrorInfo(e||new Error).queryKey,queryFn:async()=>{if(!e||!(e instanceof H.HTTPError))return null;const{response:n}=e;return(n.headers.get("content-type")??"").includes("application/json")?(await n.json()).info??null:null}})}function Ym(){var m,h,_;const{watch:e}=Qe(),{srcChainId:n,srcDenom:s,dstChainId:r,dstDenom:a}=e(),o=$e(n),i=Rt(o),l=Te(s,n),c=Te(a,r),d=we(),u=Ke();return i==="initia"&&r===d.chainId&&l.symbol===c.symbol&&((_=(h=(m=u.find(p=>p.chainId===n))==null?void 0:m.metadata)==null?void 0:h.op_denoms)==null?void 0:_.includes(c.denom))}var ls=(e=>(e.FEE_BEHAVIOR_DEDUCTED="FEE_BEHAVIOR_DEDUCTED",e.FEE_BEHAVIOR_ADDITIONAL="FEE_BEHAVIOR_ADDITIONAL",e))(ls||{});function $s(e,n){const s=Le();return $.useQuery({queryKey:fe.balances(n,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[n]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>e?r?r[n].denoms??{}:{}:{},enabled:!!e,staleTime:L.SECOND})}function Jm(e,n,s){const{data:r={}}=$s(e,n);return A.path([s],r)}const Zm=({address:e,chain:n,onSelect:s})=>{const r=yt(n.chain_id),{data:a={}}=$s(e,n.chain_id);return t.jsx(Wt,{assets:A.sortWith([A.descend(o=>o.symbol==="INIT"),A.descend(o=>o.value),({balance:o="0"},{balance:i="0"})=>F(i).comparedTo(o)??0,A.ascend(o=>o.symbol.toLowerCase())],r.filter(o=>!o.hidden).map(o=>{const{denom:i,symbol:l=D.truncate(i),logo_uri:c}=o,d=a[i]??{};return{...o,symbol:l,decimals:o.decimals??0,logoUrl:c??"",name:o.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:s})},Xm=({type:e,afterSelect:n})=>{const s=e==="src"?"srcChainId":"dstChainId",r=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",o=Ct(),i=js(),{watch:l,setValue:c,trigger:d}=Qe(),u=l("quantity"),m=l(a),h=l(s),[_,p]=f.useState(h),g=$e(_),y=Qm(),C=Lr(),[N,q]=A.partition(S=>C(S.chain_id),i.filter(S=>!S.hidden)),j=S=>{c(s,_),c(r,S),Number(u)&&d(),n()};return t.jsxs(t.Fragment,{children:[t.jsxs(ot.Stack,{children:[t.jsx(ot,{label:"Interwoven Economy",chains:N.map(({chain_id:S,chain_name:w,pretty_name:v,logo_uri:E})=>({chainId:S,name:v||w,logoUrl:E??""})),value:_,onSelect:p}),t.jsx(ot,{label:"Chains",chains:q.map(({chain_id:S,chain_name:w,pretty_name:v,logo_uri:E})=>({chainId:S,name:v||w,logoUrl:E??""})),value:_,onSelect:p})]}),t.jsx(se,{suspenseFallback:t.jsx(Wt.Placeholder,{}),children:t.jsx(Zm,{address:y({initialAddress:m,initialChainId:h,chainId:_,fallbackAddress:e==="src"?o:void 0}),chain:g,onSelect:j})},_)]})},tr=({type:e})=>{const n=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",r=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=Qe(),o=a(n),i=a(s),l=$e(o),c=Te(i,o);return t.jsx(it,{title:r,content:d=>t.jsx(Xm,{type:e,afterSelect:d}),children:t.jsx(wo,{asset:{denom:c.denom,decimals:c.decimals??0,symbol:c.symbol??D.truncate(c.denom),logoUrl:c.logo_uri??""},chain:{chainId:l.chain_id,name:l.pretty_name||l.chain_name,logoUrl:l.logo_uri??""}})})};function Cn(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:s=>e.find(r=>r.name===s)}}const eh="_account_iwrlj_8",th="_clear_iwrlj_27",nh="_white_iwrlj_38",Dt={account:eh,clear:th,white:nh},nr=({type:e})=>{const{watch:n,setValue:s}=Qe(),{srcChainId:r,dstChainId:a,cosmosWalletName:o}=n(),l=n(e==="src"?"sender":"recipient"),c=Rt($e(a)),{list:d,find:u}=Cn(),m=u(o),h=ko(),_=is(),p=h(a),g=M.equals(l,p),y=()=>t.jsx(it,{title:"Connect wallet",content:q=>t.jsx(go,{onSelect:async j=>{const S=j.getProvider();if(!S)return window.open(j.fallbackUrl,"_blank");const w=S.getOfflineSigner(r),[{address:v}]=await w.getAccounts();s("sender",v),s("cosmosWalletName",j.name),q()},list:d,getImage:j=>j.image,getName:j=>j.name,getKey:j=>j.name}),className:R(Dt.account,{[Dt.white]:!l}),children:l?t.jsxs(t.Fragment,{children:[m&&t.jsx(Y,{src:m.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:D.truncate(l)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(b.IconChevronRight,{size:14})]})}),C=q=>t.jsx(it,{title:"Recipient",content:j=>t.jsx(Pe,{children:t.jsx(Ns,{mode:"onSubmit",myAddress:p,chainType:c,validate:S=>_(S,a),onApply:j})}),className:Dt.account,children:q}),N=()=>{switch(c){case"initia":case"evm":return g?C(t.jsx(b.IconWallet,{size:14})):t.jsxs("div",{className:Dt.account,children:[t.jsx("span",{className:"monospace",children:D.truncate(l)}),t.jsx("button",{type:"button",className:Dt.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(b.IconCloseCircleFilled,{size:14})})]});case"cosmos":return C(t.jsxs(t.Fragment,{children:[l?t.jsx("span",{className:"monospace",children:D.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx(b.IconEdit,{size:14})]}))}};switch(e){case"src":return y();case"dst":return N()}},sh="_description_l5bcv_1",rh="_presets_l5bcv_8",oh="_preset_l5bcv_8",ah="_active_l5bcv_29",ih="_custom_l5bcv_40",ch="_wrapper_l5bcv_46",lh="_percent_l5bcv_49",Ce={description:sh,presets:rh,preset:oh,active:ah,custom:ih,wrapper:ch,percent:lh},sr=["0.1","0.5","1.0"],dh=({afterConfirm:e})=>{const n=Qe(),s=n.getValues("slippagePercent"),[r,a]=f.useState(null),{control:o,watch:i,getValues:l,setValue:c}=oe.useForm({defaultValues:{value:s}}),d=i("value");f.useEffect(()=>{const g=sr.findIndex(y=>y===s);a(g>=0?g:null)},[s]);const u=(g,y)=>{c("value",g),a(y)},m=()=>{a(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)<.5?{type:"warning",text:"Your transaction may fail"}:null,[d]),_=(h==null?void 0:h.type)==="error",p=({value:g})=>{n.setValue("slippagePercent",g),e()};return t.jsxs(Pe,{children:[t.jsx("p",{className:Ce.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:Ce.presets,children:[sr.map((g,y)=>t.jsxs("button",{type:"button",className:R(Ce.preset,{[Ce.active]:r===y}),onClick:()=>u(g,y),children:[g,"%"]},g)),r!==null?t.jsx("button",{type:"button",className:R(Ce.preset,Ce.custom),onClick:()=>a(null),children:"Custom"}):t.jsxs("div",{className:Ce.wrapper,children:[t.jsx(Co,{name:"value",control:o,dp:2,onFocus:m,placeholder:"",className:R(Ce.preset,Ce.active)}),t.jsx("span",{className:Ce.percent,children:"%"})]})]}),h&&t.jsx(te,{level:h.type,children:h.text}),t.jsx(re,{children:t.jsx(G.White,{type:"button",onClick:()=>p(l()),disabled:_,children:"Confirm"})})]})},uh="_stack_hvmmo_1",mh="_button_hvmmo_6",hh="_checked_hvmmo_14",_h="_checkmark_hvmmo_20",fh="_inner_hvmmo_30",ph="_info_hvmmo_42",gh="_duration_hvmmo_51",xh="_amount_hvmmo_61",yh="_symbol_hvmmo_71",Ae={stack:uh,button:mh,checked:hh,checkmark:_h,inner:fh,info:ph,duration:gh,amount:xh,symbol:yh},jh=({children:e})=>t.jsx("div",{className:Ae.stack,children:e}),on=({label:e,query:n,value:s,onSelect:r,checked:a})=>{const{data:o,isLoading:i}=n,{watch:l}=Qe(),{dstChainId:c,dstDenom:d}=l(),u=Te(d,c);return t.jsxs("button",{type:"button",className:R(Ae.button,{[Ae.checked]:a}),onClick:()=>r(s),children:[t.jsx("div",{className:Ae.checkmark,children:a&&t.jsx("span",{className:Ae.inner})}),t.jsxs("div",{className:Ae.info,children:[t.jsx("div",{children:e}),t.jsxs("div",{className:Ae.duration,children:[t.jsx(b.IconClockFilled,{size:12}),o?cs(o.estimated_route_duration_seconds):"Not available"]})]}),t.jsx("div",{className:Ae.amount,children:i?t.jsx(We,{size:14}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:D.formatAmount(o==null?void 0:o.amount_out,{decimals:u.decimals})}),t.jsx("span",{className:Ae.symbol,children:u.symbol})]})})]})};on.Stack=jh;const vh="_form_lelld_1",wh="_arrow_lelld_5",bh="_divider_lelld_13",Ch="_flip_lelld_21",Nh="_meta_lelld_37",Ih="_row_lelld_50",Sh="_title_lelld_56",$h="_description_lelld_60",kh="_icon_lelld_67",Eh="_edit_lelld_72",Ah="_warning_lelld_93",X={form:vh,arrow:wh,divider:bh,flip:Ch,meta:Nh,row:Ih,title:Sh,description:$h,icon:kh,edit:Eh,warning:Ah},Th=()=>{var Ts,qs,Ds;const e=ie(),n=jn(),[s,r]=ue.useLocalStorage(U.BRIDGE_ROUTE_TYPE,"default"),{watch:a,setValue:o,handleSubmit:i,trigger:l,formState:c}=Qe(),d=a(),{srcChainId:u,srcDenom:m,dstChainId:h,dstDenom:_,quantity:p,sender:g,slippagePercent:y}=d,C=De(),N=$e(u),q=Rt(N),j=$e(h),S=Rt(j),w=Te(m,u),v=Te(_,h),{data:E}=$s(g,u),x=Jm(g,u,m);f.useEffect(()=>{Number(p)&&l()},[x,p,l]);const[k]=ue.useDebounceValue(p,300),O=q!=="initia"&&S!=="initia",B=Ym(),P=er(k,{disabled:O}),W=er(k,{isOpWithdraw:!0,disabled:!B}),Q=B&&s==="op"?W:P,{data:V,isLoading:ce,isFetching:be,isFetched:ke,error:dt}=Q,{data:Ve}=Gm(dt),[$t,le]=f.useState(V);f.useEffect(()=>{V&&le({...V,amount_out:"0",usd_amount_in:"0",usd_amount_out:"0"})},[V]),f.useEffect(()=>{le(void 0)},[u,m,h,_]);const I=ke?V:k&&!dt?$t:void 0,Sn=k&&(ce||be),Uo=()=>{o("srcChainId",h),o("srcDenom",_),o("dstChainId",u),o("dstDenom",m),Number(p)&&l()},{openModal:zo,closeModal:ks}=zt(),Ko=i(K=>{if(I!=null&&I.warning){const{type:me="",message:En}=I.warning??{};zo({content:t.jsx(lo,{type:"warning",icon:t.jsx(b.IconWarningFilled,{size:40}),title:Ot.sentenceCase(me),primaryButton:{label:"Cancel",onClick:ks},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:I,values:K}),ks()}},children:t.jsx("p",{className:X.warning,children:En})})});return}e("/bridge/preview",{route:I,values:K})}),Ho=f.useMemo(()=>{var K;return((K=I==null?void 0:I.estimated_fees)==null?void 0:K.filter(({fee_behavior:me})=>me===ls.FEE_BEHAVIOR_DEDUCTED))??[]},[I]),$n=f.useMemo(()=>{var K;return((K=I==null?void 0:I.estimated_fees)==null?void 0:K.filter(({fee_behavior:me})=>me===ls.FEE_BEHAVIOR_ADDITIONAL))??[]},[I]),kn=f.useMemo(()=>{var K;for(const me of $n){const En=((K=E==null?void 0:E[me.origin_asset.denom])==null?void 0:K.amount)??"0",Vo=(I==null?void 0:I.source_asset_denom)===me.origin_asset.denom?I.amount_in:"0";if(F(En).lt(F(Vo).plus(me.amount??"0")))return`Insufficient ${me.origin_asset.symbol} for fees`}},[E,I,$n]),Es=f.useMemo(()=>{if(!d.sender)return"Connect wallet";if(!d.quantity||!k)return"Enter amount";if(!d.recipient)return"Enter recipient address";if(c.errors.quantity)return c.errors.quantity.message;const K=$o.safeParse(d);if(!K.success)return`Invalid ${K.error.issues[0].path}`;if(!I)return"Route not found";if(kn)return kn},[k,kn,c,I,d]),Lo=I?D.formatAmount(I.amount_out,{decimals:v.decimals}):"0",Wo=F(p).gt(0)&&F(p).isEqualTo(D.fromBaseUnit(x==null?void 0:x.amount,{decimals:(x==null?void 0:x.decimals)??0})),Qo=(()=>{switch(q){case"initia":return C(u).fees.fee_tokens.some(({denom:K})=>K===m);case"cosmos":return N.fee_assets.some(({denom:K})=>K===m);case"evm":return!Se.isAddress(m);default:return!1}})(),As=(K,me)=>K.length?t.jsxs("div",{className:X.description,children:[Eo(K),!n&&t.jsx(Nt,{label:me,children:t.jsx("span",{className:X.icon,children:t.jsx(b.IconInfoFilled,{size:12})})})]}):null;return t.jsxs("form",{className:X.form,onSubmit:Ko,children:[t.jsx(rs,{selectButton:t.jsx(tr,{type:"src"}),accountButton:q==="cosmos"&&t.jsx(nr,{type:"src"}),quantityInput:t.jsx(dn,{}),balanceButton:t.jsx(bo,{onClick:()=>o("quantity",D.fromBaseUnit(x==null?void 0:x.amount,{decimals:(w==null?void 0:w.decimals)??0}),{shouldValidate:!0}),children:D.formatAmount(x==null?void 0:x.amount,{decimals:w.decimals})}),value:I?I.usd_amount_in?D.formatNumber(I.usd_amount_in):"-":"0"}),t.jsxs("div",{className:X.arrow,children:[t.jsx("div",{className:X.divider}),t.jsx("button",{type:"button",className:X.flip,onClick:()=>Uo(),children:t.jsx(b.IconChevronDown,{size:16})})]}),t.jsx(rs,{selectButton:t.jsx(tr,{type:"dst"}),accountButton:t.jsx(nr,{type:"dst"}),quantityInput:t.jsx(dn.ReadOnly,{children:Lo}),value:I?I.usd_amount_out?D.formatNumber(I.usd_amount_out):"-":"0"}),t.jsx(re,{extra:t.jsxs(t.Fragment,{children:[t.jsx(es,{children:F(p).gt(0)&&B?t.jsxs(on.Stack,{children:[t.jsx(on,{label:"Minitswap",query:P,value:"default",onSelect:r,checked:s==="default"}),t.jsx(on,{label:"OP Bridge",query:W,value:"op",onSelect:r,checked:s==="op"})]}):null}),t.jsxs(te.Stack,{children:[(Ts=I==null?void 0:I.extra_infos)==null?void 0:Ts.map(K=>t.jsx(te,{level:"info",children:K},K)),Ve&&t.jsx(te,{level:"info",children:Ve}),Wo&&Qo&&t.jsx(te,{level:"warning",children:"Make sure to leave enough for transaction fee"}),(I==null?void 0:I.warning)&&t.jsx(te,{level:"warning",children:I.warning.message}),(qs=I==null?void 0:I.extra_warnings)==null?void 0:qs.map(K=>t.jsx(te,{level:"warning",children:K},K))]}),t.jsx(es,{children:I&&t.jsxs("div",{className:X.meta,children:[!!((Ds=I.estimated_fees)!=null&&Ds.length)&&t.jsxs("div",{className:X.row,children:[t.jsx("span",{className:X.title,children:"Fees"}),t.jsxs("div",{children:[As(Ho,"Fee deducted from the amount you receive"),As($n,"Fee charged in addition to the amount you enter")]})]}),cs(I.estimated_route_duration_seconds)&&t.jsxs("div",{className:X.row,children:[t.jsx("span",{className:X.title,children:"Estimated time"}),t.jsx("span",{className:X.description,children:cs(I.estimated_route_duration_seconds)})]}),I.does_swap&&t.jsxs("div",{className:X.row,children:[t.jsx("span",{className:X.title,children:"Slippage"}),t.jsxs("span",{className:X.description,children:[t.jsxs("span",{children:[y,"%"]}),t.jsx(it,{title:"Slippage tolerance",content:K=>t.jsx(dh,{afterConfirm:K}),className:X.edit,children:t.jsx(b.IconSettingFilled,{size:12})})]})]})]})})]}),children:t.jsx(G.White,{loading:Sn&&"Simulating...",disabled:!!Es,children:Es??"Preview route"})})]})},qh=()=>{uo();const e=ca(),n=ie(),{closeDrawer:s}=bt(),r=Ct(),a=Wm(),o=is(),i=$.useQueryClient(),l=oe.useForm({mode:"onChange",defaultValues:a,resolver:hs.zodResolver($o.superRefine(({srcChainId:B,srcDenom:P,quantity:W,sender:Q},V)=>{const ce=i.getQueryData(fe.balances(B,Q).queryKey),be=A.pathOr("0",["chains",B,"denoms",P,"amount"],ce),{decimals:ke}=i.getQueryData(fe.asset(B,P).queryKey)??{decimals:0};jo({quantity:W,balance:be,decimals:ke},V)}).superRefine(({dstChainId:B,recipient:P},W)=>{if(!o(P,B)){W.addIssue({code:J.z.ZodIssueCode.custom,message:"Invalid address",path:["recipient"]});return}}))}),{watch:c,setValue:d}=l,{srcChainId:u,dstChainId:m,srcDenom:h,dstDenom:_,quantity:p,slippagePercent:g,recipient:y}=c();c((B,{name:P})=>{(P==="srcChainId"||P==="srcDenom")&&d("quantity","")});const C=ko(),N=C(u),q=C(m),S=is()(y,m);f.useEffect(()=>{d("cosmosWalletName",void 0),d("sender",N)},[u,N,d]),f.useEffect(()=>{S||d("recipient",q)},[q,S,d]);const w=yt(u),v=yt(m),E=f.useMemo(()=>{if(!w.find(B=>B.denom===h))return`${h} is not available for bridge/swap on ${u}`;if(!v.find(B=>B.denom===_))return`${_} is not available for bridge/swap on ${m}`},[v,m,_,w,u,h]);f.useEffect(()=>{E||(localStorage.setItem(U.BRIDGE_SRC_CHAIN_ID,u),localStorage.setItem(U.BRIDGE_SRC_DENOM,h),localStorage.setItem(U.BRIDGE_DST_CHAIN_ID,m),localStorage.setItem(U.BRIDGE_DST_DENOM,_),localStorage.setItem(U.BRIDGE_QUANTITY,p),localStorage.setItem(U.BRIDGE_SLIPPAGE_PERCENT,g))},[u,h,m,_,p,g,E]);const x=e[0].path==="/bridge",k=()=>t.jsxs(t.Fragment,{children:[t.jsx(ae,{error:!0,children:E}),t.jsx(re,{children:x?t.jsx(G.White,{onClick:s,children:"Close"}):t.jsx(G.White,{onClick:()=>n(-1),children:"Go back"})})]}),{reminders:O}=It();return t.jsx(Be,{title:"Bridge/Swap",returnTo:x?!1:"/",extra:t.jsxs(t.Fragment,{children:[t.jsx(G.Small,{onClick:()=>n("/bridge/history"),unpadded:!0,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[t.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),t.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),t.jsx(Io,{offset:0,disabled:O.length===0,children:t.jsx(G.Small,{onClick:()=>n("/op/withdrawals"),disabled:!r,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:E?k():t.jsx(oe.FormProvider,{...l,children:t.jsx(se,{children:t.jsx(Th,{})})})})},lt=qe.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,n)=>[e,n],latestOutput:e=>[e],output:(e,n)=>[e,n],outputResponse:(e,n)=>[e,n],withdrawalClaimed:(e,n)=>[e,n]});function Nn(){const{restUrl:e}=we();return f.useMemo(()=>H.create({prefixUrl:e}),[e])}function Dh(e){const n=Nn(),{data:s}=$.useSuspenseQuery({queryKey:lt.bridge(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:L.INFINITY});return s}const rr=20;function Ph(e){const n=Z();return $.useSuspenseInfiniteQuery({queryKey:lt.withdrawals(e,n).queryKey,queryFn:async({pageParam:s})=>{if(!n)return[];const r={limit:rr,offset:s,order:"desc"},{withdrawals:a}=await H.create({prefixUrl:e}).get(`withdrawals/${n}`,{searchParams:r}).json();return a},getNextPageParam:s=>{var a;const r=(a=A.last(s))==null?void 0:a.sequence;return s.length<rr||!r||r<=1?null:r-1},initialPageParam:0,staleTime:L.SECOND})}function Bh(e){const n=Nn(),{data:s}=$.useSuspenseQuery({queryKey:lt.latestOutput(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:r})=>{const[a]=r;return a||null},staleTime:L.SECOND});return s}function Fh({bridge_id:e,output_index:n}){const s=Nn(),{data:r}=$.useSuspenseQuery({queryKey:lt.output(e,n).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${n}`).json()}catch{return null}},staleTime:L.SECOND});return r}function Rh({bridge_id:e,sequence:n}){var c,d;const r=(c=Ke().find(({metadata:u})=>(u==null?void 0:u.op_bridge_id)===e.toString()))==null?void 0:c.chain_id;if(!r)throw new Error(`Chain not found for bridge_id: ${e}`);const o=De()(r);if(!o)throw new Error(`Chain not found: ${r}`);const i=(d=o.metadata)==null?void 0:d.executor_uri;if(!i)throw new Error(`Executor URL not found: ${r}`);const{data:l}=$.useSuspenseQuery({queryKey:lt.outputResponse(i,n).queryKey,queryFn:()=>H.create({prefixUrl:i}).get(`withdrawal/${n}`).json(),staleTime:L.SECOND});return l}function Ao(e,n){const{bridge_id:s}=e,r=Nn(),{data:a}=$.useSuspenseQuery({queryKey:lt.withdrawalClaimed(s,n).queryKey,queryFn:()=>r.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:n}}).json(),select:({claimed:o})=>o,staleTime:({state:{data:o}})=>o!=null&&o.claimed?1/0:L.SECOND});return a}function Pt(e){return ms.sha3_256.create().update(e).digest()}function Vn(e,n){const s=new ArrayBuffer(n);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function To(e){const{bridge_id:n,sequence:s,amount:r,from:a,to:o}=e,i=Vn(n.toString(),8),l=Vn(s.toString(),8),c=Vn(r.amount,8),d=nt.concatBytes(i,l,Pt(nt.toBytes(a)),Pt(nt.toBytes(o)),Pt(nt.toBytes(r.denom)),c);return Pt(Pt(d))}const qo=f.createContext(null);function In(){return f.useContext(qo)}const Mh="_asset_6h8u2_1",Oh="_info_6h8u2_7",Uh="_symbol_6h8u2_11",Gn={asset:Mh,info:Oh,symbol:Uh},zh=({amount:e,denom:n})=>{const s=we(),r=xs(n,s),{symbol:a,logoUrl:o,decimals:i}=r;return t.jsxs("div",{className:Gn.asset,children:[t.jsx(Y,{src:o,width:32,height:32}),t.jsxs("div",{className:Gn.info,children:[t.jsx("span",{className:"monospace",children:D.formatAmount(e,{decimals:i})}),t.jsx("span",{className:Gn.symbol,children:a})]})]})},Kh=({children:e})=>{const{withdrawalTx:n}=In(),s=Bh(n.bridge_id),r=n.output_index>Number(s==null?void 0:s.output_index);return e(r)},Hh="_container_1oldz_1",Lh="_icon_1oldz_7",or={container:Hh,icon:Lh},Wh="Withdrawal will begin within an hour",ar=()=>{const e=jn();return t.jsxs("div",{className:or.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Nt,{label:Wh,children:t.jsx("span",{className:or.icon,children:t.jsx(b.IconInfoFilled,{size:12})})})]})},Do=1e3,Qh=60,Vh=60,Gh=24,ds=Do*Qh,us=ds*Vh,ir=us*Gh,Yh=({date:e})=>{const n=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/ir),_=Math.floor(m%ir/us),p=Math.floor(m%us/ds),g=Math.floor(m%ds/Do);return{days:h,hours:_,minutes:p,seconds:g}},[e]),[s,r]=f.useState(n());f.useEffect(()=>{const d=window.setInterval(()=>{r(n())},1e3);return()=>window.clearInterval(d)},[n,e]);const a=d=>d.toString().padStart(2,"0"),{days:o,hours:i,minutes:l,seconds:c}=s;return t.jsx(Nt,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[o,"d ",a(i),"h ",a(l),"m ",a(c),"s"]})})},Jh="_container_1lz3w_1",Zh="_title_1lz3w_5",cr={container:Jh,title:Zh},Xh=({date:e})=>t.jsxs("div",{className:cr.container,children:[t.jsx("div",{className:cr.title,children:"Claimable in"}),t.jsx(Yh,{date:e})]}),e_=({children:e})=>{const{withdrawalTx:n}=In(),s=Dh(n.bridge_id),r=Fh(n),a=f.useMemo(()=>{if(!r)return null;const{bridge_config:o}=s,{output_proposal:i}=r;return jt.addSeconds(new Date(i.l1_block_time),parseFloat(o.finalization_period))},[s,r]);return e(a)},t_=({date:e,children:n})=>{const{chainId:s,withdrawalTx:r}=In(),a=z.toBase64(To(r)),o=Ao(r,a),{setReminder:i,removeReminder:l}=It();return f.useEffect(()=>{const c={chainId:s,txHash:r.tx_hash};o?l(c):i(c,{...c,recipient:r.to,claimableAt:e.getTime(),amount:r.amount.amount,denom:r.amount.denom,dismissed:jt.isPast(e.getTime())?!0:void 0})},[s,o,e,l,i,r]),n},n_="_button_1btdg_1",s_="_claimed_1btdg_23",lr={button:n_,claimed:s_},r_=()=>{const{withdrawalTx:e}=In(),{bridge_id:n,sequence:s,amount:r,output_index:a,withdrawal_proofs:o,storage_root:i,from:l,to:c,version:d}=e,u=we(),m=Z(),{requestTxSync:h,waitForTxConfirmation:_}=pe(),p=Rh(e),g=z.toBase64(To(e)),y=Ao(e,g),C=$.useQueryClient(),{mutate:N,isPending:q}=$.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:j}=p;return h({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:ra.MsgFinalizeTokenWithdrawal.fromPartial({sender:m,bridgeId:BigInt(n),outputIndex:BigInt(a),withdrawalProofs:o.map(z.fromBase64),from:l,to:c,sequence:BigInt(s),amount:r,version:z.fromBase64(d),storageRoot:z.fromBase64(i),lastBlockHash:z.fromBase64(j)})}],internal:!0})},onSuccess:async j=>{await _({chainId:u.chain_id,txHash:j}),C.invalidateQueries({queryKey:lt.withdrawalClaimed(n,g).queryKey})}});return y?t.jsxs("div",{className:lr.claimed,children:[t.jsx(b.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:lr.button,onClick:()=>N(),disabled:q,children:"Claim"})},o_=()=>t.jsx(Kh,{children:e=>e?t.jsx(ar,{}):t.jsx(e_,{children:n=>n?t.jsx(t_,{date:n,children:jt.isFuture(n)?t.jsx(Xh,{date:n}):t.jsx(r_,{})}):t.jsx(ar,{})})}),a_="_item_km5w2_1",i_={item:a_},c_=({chain:e})=>{var c;const n=(c=e.metadata)==null?void 0:c.executor_uri;if(!n)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:r,hasNextPage:a,isFetching:o}=Ph(n),i=f.useMemo(()=>(s==null?void 0:s.pages.flat())??[],[s]),{syncReminders:l}=It();return f.useEffect(()=>{const d=i.map(u=>({chainId:e.chainId,txHash:u.tx_hash}));l(d)},[e.chainId,i,l]),i.length?t.jsxs(t.Fragment,{children:[i.map(d=>{const{amount:u}=d;return t.jsxs("div",{className:i_.item,children:[t.jsx(zh,{...u}),t.jsx(se,{suspenseFallback:null,children:t.jsx(qo.Provider,{value:{chainId:e.chainId,withdrawalTx:d},children:t.jsx(o_,{})})})]},d.sequence)}),a&&t.jsx(Ss,{onClick:()=>r(),disabled:o})]}):t.jsx(ae,{children:"No withdrawals"})},l_="_content_dj1qm_1",d_="_title_dj1qm_5",dr={content:l_,title:d_},u_=()=>{var c;const{chainId:e}=Ue(),n=Ke(),s=Kt(),[r,a]=f.useState(e??((c=s.metadata)!=null&&c.is_l1?"":s.chainId)),o=De(),{reminders:i}=It(),l=r?o(r):void 0;return t.jsxs(Be,{title:"OP Bridge withdrawals",children:[t.jsx(ot,{chains:n.filter(({metadata:d})=>{var u;return!(d!=null&&d.is_l1)&&((u=d==null?void 0:d.op_denoms)==null?void 0:u.length)}),value:r,onSelect:a,getShowIndicator:d=>i.some(u=>u.chainId===d)}),t.jsx("div",{className:dr.content,children:l?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:dr.title,children:l.name}),t.jsx(se,{children:t.jsx(c_,{chain:l})},r)]}):t.jsx(te,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})};async function m_(e,n){const s=H.create({prefixUrl:n}),r=`cosmos/auth/v1beta1/account_info/${e}`;for(let a=1;a<=24;a++)try{return await s.get(r).json()}catch{await new Promise(o=>setTimeout(o,5e3))}throw new Error(`Timeout: ${e} not found`)}const an=({chainId:e,txHash:n})=>`${U.BRIDGE_HISTORY}:${e}:${n}`,un=100,ur=10;function Po(){const[e,n]=ue.useLocalStorage(U.BRIDGE_HISTORY,[]),s=f.useCallback((a,o)=>{localStorage.setItem(an(a),JSON.stringify(o));for(const i of e.slice(un-1))localStorage.removeItem(an(i));n((i=[])=>[a,...i.slice(0,un-1)])},[e,n]),r=f.useCallback(a=>{const o=localStorage.getItem(an(a));return o?JSON.parse(o):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:r}}function Bo(e){return ue.useLocalStorage(an(e),null)}async function Fo(e,n){const{chain_type:s,chain_id:r,chain_name:a,evm_fee_asset:o,rpc:i}=n;if(s!=="evm")throw new Error(`Chain is not an EVM chain: ${a}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}catch(l){if(A.path(["error","code"],l)!==4902)throw l;if(!o)throw new Error(`Fee asset is not defined for chain: ${a}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(r).toString(16)}`,chainName:a,nativeCurrency:o,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}}function St(){return Ue()}function h_(e){const n=ie(),{showNotification:s,updateNotification:r,hideNotification:a}=Vr(),{addHistoryItem:o}=Po(),{route:i,values:l}=St(),{srcChainId:c,sender:d,recipient:u,cosmosWalletName:m}=l,h=qr(),{requestTxSync:_,waitForTxConfirmation:p}=pe(),{find:g}=Cn(),y=gs(),C=pn(),N=$e(c),q=Rt(N),j=Wr(c),S=$.useQueryClient(),{registryUrl:w}=ne(),v=De(),{addReminder:E}=It();return $.useMutation({mutationFn:async()=>{var x;try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const k=e.cosmos_tx.msgs.map(({msg_type_url:le,msg:I})=>{if(!(le&&I))throw new Error("Invalid transaction data");return C.fromAmino({type:xt.aminoConverters[le].aminoType,value:JSON.parse(I)})});if(q==="initia"){const le=await _({messages:k,chainId:c,internal:1}),I=p({txHash:le,chainId:c});return{txHash:le,wait:I}}const O=(x=g(m))==null?void 0:x.getProvider();if(!O)throw new Error("Wallet not connected");const B=O.getOfflineSignerOnlyAmino(c),P=await Ie.SigningStargateClient.connectWithSigner(N.rpc,B,{registry:y,aminoTypes:C}),W=await P.getAllBalances(d),Q=N.fee_assets.find(le=>W.some(I=>I.denom===le.denom&&F(I.amount).gt(0)));if(!Q){const I=["Insufficient balance for fees.",`Available fee assets: ${N.fee_assets.map(Sn=>j(Sn.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(I)}const{denom:V,gas_price:ce}=Q;if(!ce)throw new Error(`Gas price not found for ${V}`);const be=await P.simulate(d,k,""),ke=Ie.GasPrice.fromString(ce.average+V),dt=Ie.calculateFee(Math.ceil(be*_s),ke),Ve=await P.signAndBroadcastSync(d,k,dt),$t=Rr({txHash:Ve,client:P});return{txHash:Ve,wait:$t}}if("evm_tx"in e){const{chain_id:k,to:O,value:B,data:P}=e.evm_tx,W=await h(),Q=await W.getSigner();await Fo(W,N);const V=await Q.sendTransaction({chainId:k,to:O,value:B,data:`0x${P}`});return{txHash:V.hash,wait:V.wait()}}throw new Error("Unsupported chain type")}catch(k){throw new Error(await ze(k))}},onSuccess:({txHash:x,wait:k})=>{localStorage.removeItem(U.BRIDGE_QUANTITY),n(-1,{quantity:""}),s({type:"loading",title:"Transaction is pending..."}),k.then(()=>{const O={chainId:c,txHash:x},B=Ro(i)==="OP Bridge withdrawal";o(O,{...O,timestamp:Date.now(),route:i,values:l,state:B?"success":void 0}),r({type:"info",title:"Transaction submitted",description:f.createElement(f.Fragment,null,"Check ",f.createElement(Ut,{to:"/bridge/history",onClick:a},"the activity page")," for transaction status"),autoHide:!0}),B&&E(O,{...O,recipient:M.toBech32(u),claimableAt:Date.now()+i.estimated_route_duration_seconds*1e3,amount:i.amount_out,denom:i.dest_asset_denom})}).catch(O=>{r({type:"error",title:"Transaction failed",description:O.message})}).finally(()=>{S.invalidateQueries({queryKey:fe.balances(c,d).queryKey})})},onError:async x=>{const k=q==="initia"?await Xn(x,v(c),w):x;s({type:"error",title:"Transaction failed",description:k.message})}})}function __(){const e=Le(),n=Z(),s=Er(),{route:r,values:a}=St(),o=ct();return $.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:l}=await e.post("op-hook",{json:{source_address:n,source_asset_chain_id:r.source_asset_chain_id,source_asset_denom:r.source_asset_denom,dest_address:M.toBech32(a.recipient),dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom}}).json();await m_(n,o(r.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:m,msg:h})=>xt.aminoTypes.fromAmino({type:xt.aminoConverters[m].aminoType,value:JSON.parse(h)})),d=await s(i,n,c,{amount:[],gas:"1"},""),u=pt.Tx.fromPartial({body:pt.TxBody.decode(d.bodyBytes),authInfo:pt.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:n,hook:z.toBase64(pt.Tx.encode(u).finish())}}catch(i){throw new Error(await ze(i))}}})}function f_(e){const{chainId:n,txHash:s,tracked:r}=e,a=Le();return $.useQuery({queryKey:fe.txTrack(n,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:n}}).json()}catch(o){throw new Error(await ze(o))}},select:({tx_hash:o})=>o,retry:6,retryDelay:5e3,staleTime:L.INFINITY,enabled:!r})}function p_(e){const{timestamp:n,chainId:s,txHash:r,tracked:a,state:o}=e,i=Le();return $.useQuery({queryKey:fe.txStatus(s,r).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:r,chain_id:s}}).json(),enabled:!!r&&a&&!o,refetchInterval:({state:{data:l}})=>{if(!l)return!1;const{status:c}=l;if(c==="STATE_COMPLETED")return!1;const d=n+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),m=Math.floor((d-u)/1e3);return m<=0?1e3:m<=300?5e3:60*1e3},staleTime:L.INFINITY})}var cn=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(cn||{});function Ro(e){const{operations:n,dest_asset_denom:s}=e;return A.has("op_init_transfer",A.head(n))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const g_="_content_c0tee_1",x_="_info_c0tee_6",y_="_arrow_c0tee_11",j_="_divider_c0tee_19",v_="_type_c0tee_26",w_="_asset_c0tee_44",b_="_amount_c0tee_52",C_="_lower_c0tee_57",N_="_chain_c0tee_63",I_="_address_c0tee_69",he={content:g_,info:x_,arrow:y_,divider:j_,type:v_,asset:w_,amount:b_,lower:C_,chain:N_,address:I_},Mo=e=>{const{source:n,label:s,amount:r,denom:a,chainId:o,address:i,walletIcon:l}=e,{symbol:c=D.truncate(a),decimals:d=0,logo_uri:u=Mr}=e,{chain_name:m,pretty_name:h,..._}=$e(o);return t.jsxs("div",{children:[!n&&t.jsxs("div",{className:he.arrow,children:[t.jsx("div",{className:he.divider}),s?t.jsx(Nt,{label:s,children:t.jsx("button",{className:he.type,children:t.jsx(b.IconArrowDown,{size:12})})}):t.jsx("span",{className:he.type,children:t.jsx(b.IconArrowDown,{size:12})}),t.jsx("div",{className:he.divider})]}),t.jsxs("div",{className:he.content,children:[t.jsx(Cs,{assetLogoUrl:u,chainLogoUrl:_.logo_uri??void 0}),t.jsxs("div",{className:he.info,children:[t.jsxs("div",{className:he.asset,children:[t.jsx("span",{className:he.amount,children:D.formatAmount(r,{decimals:d})}),t.jsx("span",{children:c})]}),t.jsxs("div",{className:he.lower,children:[t.jsxs("div",{className:he.chain,children:["on ",h||m]}),i&&t.jsx(ws,{value:i,children:({copy:p,copied:g})=>t.jsxs("button",{className:he.address,onClick:p,children:[l,g?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:D.truncate(i)})]})})]})]})]})]})},ft=e=>{const n=Te(e.denom,e.chainId);return t.jsx(Mo,{...e,...n})};ft.Placeholder=Mo;const S_="_root_133os_1",$_="_toggle_133os_6",k_="_route_133os_29",E_="_content_133os_36",nn={root:S_,toggle:$_,route:k_,content:E_};function A_(e){var s,r,a,o;const n=({name:i})=>i==="initia-dex"?"Initia DEX":Ot.capitalCase(A.head((i==null?void 0:i.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 i=(r=(s=e.swap)==null?void 0:s.swap_venues)==null?void 0:r.map(n).join(", ");return{label:i?`Swap on ${i}`:"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 i=(o=(a=e.evm_swap)==null?void 0:a.swap_venues)==null?void 0:o.map(n).join(", ");return{label:i?`Swap on ${i}`:"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 T_=({addressList:e})=>{var S;const{values:n,route:s}=St(),{source_asset_denom:r,source_asset_chain_id:a,amount_in:o,operations:i}=s,l=A.zipObj(s.required_chain_addresses,e),{find:c}=Cn(),{connector:d,address:u=""}=ye.useAccount(),[m,h]=ue.useToggle(!1),_=i.length>1,p=t.jsx(Y,{src:n.cosmosWalletName?(S=c(n.cosmosWalletName))==null?void 0:S.image:d==null?void 0:d.icon,width:12,height:12}),g={amount:o,denom:r,chainId:a,address:n.sender,walletIcon:p},y=w=>M.equals(w,u)?p:t.jsx(b.IconWallet,{size:11}),C=w=>{const{label:v,amount_out:E,denom:x,denom_out:k=x,chain_id:O,from_chain_id:B,to_chain_id:P=O??B}=w,W=l[P];return{label:_&&!m?void 0:v,amount:E,denom:k,chainId:P,address:W,walletIcon:y(W)}},N=i.map(A_).map(C),q=N.slice(0,-1),j=N[N.length-1];return t.jsxs(T.Collapsible.Root,{className:nn.root,open:m,onOpenChange:h,children:[_&&t.jsx(T.Collapsible.Trigger,{asChild:!0,children:t.jsx(ss,{children:t.jsx("button",{className:nn.toggle,onClick:h,children:m?t.jsxs(t.Fragment,{children:[t.jsx(b.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(b.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})})}),t.jsxs("div",{className:nn.route,children:[t.jsx(ft,{...g,source:!0}),t.jsx(T.Collapsible.Content,{className:nn.content,children:q.map((w,v)=>t.jsx(se,{suspenseFallback:t.jsx(ft.Placeholder,{...w}),errorBoundaryProps:{fallback:t.jsx(ft.Placeholder,{...w})},children:t.jsx(ft,{...w})},v))}),t.jsx(ft,{...j})]})]})},mn=({error:e})=>{const n=ie();return t.jsx(re,{extra:t.jsx(te,{level:"error",children:e.message}),children:t.jsx(G.White,{onClick:()=>n("/bridge"),children:"Home"})})},q_=({children:e})=>{const n=St(),{route:s,values:r}=n,{required_chain_addresses:a}=s,{srcChainId:o,dstChainId:i,sender:l,recipient:c}=r,{initiaAddress:d,hexAddress:u}=pe(),m=wt(),h=ct(),_=Lt(),p=h(o),g=_(p),y=a.slice(0,-1).some(v=>{const E=h(v);return _(E)==="cosmos"})&&g!=="cosmos",[C,N]=f.useState(void 0),[q,j]=f.useState(!1),[S,w]=f.useState(null);if(f.useEffect(()=>{(async()=>{try{if(!y)return;if(!m)throw new Error("Wallet not connected");j(!0),w(null);const[{pubkey:E}]=await m.getAccounts();N(E)}catch(E){w(new Error(await ze(E)))}finally{j(!1)}})()},[y,m]),S)return t.jsx(mn,{error:S});if(q)return t.jsx(re,{children:t.jsx(G.White,{loading:q&&"Generating intermediary addresses..."})});if(!y||C){const v=a.map((E,x)=>{if(x===a.length-1){const W=h(i);return _(W)==="initia"?M.toBech32(c):c}const k=h(E),O=_(k),B=h(o),P=_(B);switch(O){case"initia":return d;case"evm":return u;case"cosmos":{if(P==="cosmos")return z.toBech32(k.bech32_prefix,z.fromBech32(l).data);if(!C)throw new Error("Pubkey not found");return Bt.pubkeyToAddress(Bt.encodeSecp256k1Pubkey(C),k.bech32_prefix)}default:throw new Error("Unsupported chain type")}});return e(v)}return t.jsx(mn,{error:new Error("Failed to generate intermediary addresses")})},D_=({addressList:e,signedOpHook:n,children:s})=>{const r=Le(),{route:a,values:o}=St(),[i,l]=f.useState(void 0),[c,d]=f.useState(!1),[u,m]=f.useState(null);return f.useEffect(()=>{(async()=>{try{if(a.required_op_hook&&!n)throw new Error("Op hook is required");d(!0),m(null);const _={address_list:e,amount_in:a.amount_in,amount_out:a.amount_out,source_asset_chain_id:a.source_asset_chain_id,source_asset_denom:a.source_asset_denom,dest_asset_chain_id:a.dest_asset_chain_id,dest_asset_denom:a.dest_asset_denom,slippage_tolerance_percent:o.slippagePercent,operations:a.operations,signed_op_hook:n},{txs:p}=await r.post("v2/fungible/msgs",{json:_}).json();if(!p||p.length===0)throw new Error("No transaction data found");const[g]=p;l(g)}catch(_){m(_)}finally{d(!1)}})()},[a,o,e,n,r]),u?t.jsx(mn,{error:u}):c?t.jsx(re,{children:t.jsx(G.White,{loading:c&&"Fetching messages..."})}):i?s(i):t.jsx(mn,{error:new Error("Failed to fetch messages")})},P_=({children:e})=>{var r;const{route:n}=St(),s=__();return n.required_op_hook&&!s.data?t.jsx(re,{extra:t.jsx(te,{level:"error",children:(r=s.error)==null?void 0:r.message}),children:t.jsx(G.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)},B_=({tx:e,children:n})=>{const s=qr(),r=ct(),{mutate:a,data:o,isPending:i,error:l}=$.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!e.evm_tx.required_erc20_approvals)throw new Error("No approvals required");const{chain_id:c}=e.evm_tx,d=await s(),u=await d.getSigner();await Fo(d,r(c));for(const m of e.evm_tx.required_erc20_approvals){const{token_contract:h,spender:_,amount:p}=m,g=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new Se.ethers.Contract(h,g,u).approve(_,p)).wait()}return!0}catch(c){throw new Error(await ze(c))}}});return"evm_tx"in e&&e.evm_tx.required_erc20_approvals&&e.evm_tx.required_erc20_approvals.length>0&&!o?t.jsx(re,{extra:t.jsx(te,{level:"error",children:l==null?void 0:l.message}),children:t.jsx(G.White,{onClick:()=>a(),loading:i&&"Approving tokens...",children:"Approve tokens"})}):n},F_=({tx:e})=>{const{mutate:n,isPending:s}=h_(e);return t.jsx(re,{children:t.jsx(G.White,{onClick:()=>n(),loading:s&&"Signing transaction...",children:"Confirm"})})},R_=()=>t.jsx(Be,{title:"Route preview",children:t.jsx(q_,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(T_,{addressList:e}),t.jsx(P_,{children:n=>t.jsx(D_,{addressList:e,signedOpHook:n,children:s=>t.jsx(B_,{tx:s,children:t.jsx(F_,{tx:s})})})})]})})}),M_="_button_14cv7_1",O_="_checkbox_14cv7_10",U_="_checked_14cv7_23",sn={button:M_,checkbox:O_,checked:U_},z_=({checked:e,onClick:n,label:s,className:r})=>t.jsxs("button",{type:"button",className:R(sn.button,r),onClick:n,children:[t.jsx("div",{className:R(sn.checkbox,{[sn.checked]:e}),children:e&&t.jsx(b.IconCheck,{size:12})}),t.jsx("span",{className:sn.label,children:s})]}),K_="_success_t4dfk_1",H_="_error_t4dfk_5",mr={success:K_,error:H_},L_=({tx:e})=>{const[n,s]=Bo(e);if(!n)throw new Error("Bridge history details not found");const{data:r}=p_(n),a=n.state??W_(r);switch(f.useEffect(()=>{a!=="loading"&&s(o=>{if(!o)throw new Error("Bridge history details not found");return{...o,tracked:!0,state:a}})},[s,a]),a){case"error":return t.jsx("div",{className:mr.error,children:t.jsx(b.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:mr.success,children:t.jsx(b.IconCheckCircleFilled,{size:14})});default:return t.jsx(We,{size:14})}};function W_(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 Q_="_link_1uidr_1",V_="_header_1uidr_22",G_="_title_1uidr_30",Y_="_date_1uidr_36",J_="_explorer_1uidr_40",Z_="_fees_1uidr_55",X_="_label_1uidr_63",ef="_content_1uidr_67",tf="_route_1uidr_73",nf="_row_1uidr_78",sf="_asset_1uidr_84",rf="_amount_1uidr_92",of="_chain_1uidr_97",af="_account_1uidr_106",cf="_arrow_1uidr_113",ee={link:Q_,header:V_,title:G_,date:Y_,explorer:J_,fees:Z_,label:X_,content:ef,route:tf,row:nf,asset:sf,amount:rf,chain:of,account:af,arrow:cf},lf=({tx:e})=>{var Q;const[n,s]=Bo(e);if(!n)throw new Error("Bridge history details not found");const{chainId:r,txHash:a,route:o,values:i,timestamp:l,tracked:c}=n,{data:d}=f_(n),{address:u="",connector:m}=ye.useAccount(),{find:h}=Cn();f.useEffect(()=>{d&&s(V=>{if(!V)throw new Error("Bridge history details not found");return{...V,tracked:!0}})},[s,d]);const{amount_in:_,amount_out:p,source_asset_chain_id:g,source_asset_denom:y,dest_asset_chain_id:C,dest_asset_denom:N,estimated_fees:q=[]}=o,j=$e(g),S=$e(C),w=Te(y,g),v=Te(N,C),E=(V,ce)=>ce?t.jsx(Y,{src:ce,width:12,height:12}):M.equals(V,u)?t.jsx(Y,{src:m==null?void 0:m.icon,width:12,height:12}):t.jsx(b.IconWallet,{size:12}),x=(V,{symbol:ce,decimals:be,logo_uri:ke},{chain_name:dt,pretty_name:Ve,...$t},le,I)=>t.jsxs("div",{className:ee.row,children:[t.jsx(Cs,{assetLogoUrl:ke,chainLogoUrl:$t.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:ee.asset,children:[t.jsx("span",{className:ee.amount,children:D.formatAmount(V,{decimals:be})}),t.jsx("span",{children:ce})]}),t.jsxs("div",{className:ee.chain,children:[t.jsxs("span",{children:["on ",Ve||dt]}),t.jsxs("div",{className:ee.account,children:[I,t.jsx("span",{className:"monospace",children:D.truncate(le)})]})]})]})]}),k=Ro(o),O=f.useMemo(()=>{switch(k){case cn.SKIP:return"Skip Explorer";case cn.OP_WITHDRAW:return"Initia Scan"}},[k]),B=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:ee.header,children:[t.jsxs("div",{className:ee.title,children:[c?t.jsx(L_,{tx:e}):t.jsx(We,{size:14}),t.jsx("div",{className:ee.date,children:jt.intlFormatDistance(new Date(l),new Date,{locale:"en-US"})})]}),t.jsxs("div",{className:ee.explorer,children:[t.jsx("span",{children:O}),t.jsx(b.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:ee.route,children:[x(_,w,j,i.sender,E(i.sender,(Q=h(i.cosmosWalletName))==null?void 0:Q.image)),t.jsx("div",{className:ee.arrow,children:t.jsx(b.IconArrowDown,{size:12})}),x(p,v,S,i.recipient,E(i.recipient))]}),q.length>0&&t.jsxs("div",{className:ee.fees,children:[t.jsx("span",{className:ee.label,children:"Fees"}),t.jsx("span",{className:ee.content,children:Eo(q)})]})]});if(k===cn.OP_WITHDRAW)return t.jsx(vn,{chainId:r,txHash:a,className:ee.link,children:B});const P=new URLSearchParams({tx_hash:a,chain_id:r}),W=new URL(`?${P.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:W.toString(),className:ee.link,target:"_blank",children:B})},df="_list_1q71m_1",uf="_header_1q71m_5",mf="_checkbox_1q71m_9",hf="_item_1q71m_13",rn={list:df,header:uf,checkbox:mf,item:hf},_f=()=>{const{initiaAddress:e,hexAddress:n}=pe(),{history:s,getHistoryDetails:r}=Po(),a=s.filter(h=>r(h)),o=a.filter(h=>{const _=r(h);if(!_)return!1;const{values:p}=_,{sender:g,recipient:y}=p;return[g,y].some(C=>[e,n].includes(C))}),[i,l]=f.useState(1),[c,d]=ue.useToggle(!o.length),u=c?a:o,m=u.slice(0,i*ur);return t.jsx(Be,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:rn.list,children:[a.length>0&&a.length!==o.length&&t.jsx("header",{className:rn.header,children:t.jsx(z_,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:rn.checkbox})}),u.length===0?t.jsx(ae,{children:"No bridge/swap activity"}):m.map((h,_)=>t.jsx("div",{className:rn.item,children:t.jsx(se,{children:t.jsx(lf,{tx:h})})},_)),u.length>i*ur?t.jsx(Ss,{onClick:()=>l(h=>h+1)}):s.length>=un&&t.jsxs(ae,{children:["Only the latest ",un," items are stored. Older entries will be removed automatically."]})]})})},Oo=()=>{const e=ie(),n=Nr(),s=Ct(),{closeDrawer:r}=bt(),{closeModal:a}=zt();if(f.useEffect(()=>{a(),n.startsWith("/bridge/")&&e("/bridge"),(n==="/collection"||n.startsWith("/nft"))&&e("/nfts")},[s]),n==="/connect")return s?null:t.jsx(Ws,{onSuccess:r});if(n==="/blank")return null;if(!s)return t.jsx(Ws,{});switch(n){case"/":case"/nfts":case"/activity":return t.jsx(zd,{});case"/send":return t.jsx(Xu,{},s);case"/collection":return t.jsx(om,{});case"/nft":return t.jsx(_m,{});case"/nft/send":return t.jsx(qm,{},s);case"/rollups":return t.jsx(Hm,{});case"/bridge":return t.jsx(qh,{},s);case"/bridge/preview":return t.jsx(R_,{});case"/bridge/history":return t.jsx(_f,{});case"/op/withdrawals":return t.jsx(u_,{});case"/tx":return t.jsx(io,{})}},ff="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",pf=()=>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:ff}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),gf=()=>{Ke();const e=we();return js(),yt(localStorage.getItem(U.BRIDGE_SRC_CHAIN_ID)??e.chainId),yt(localStorage.getItem(U.BRIDGE_DST_CHAIN_ID)??e.chainId),null},xf=({children:e,...n})=>(f.useEffect(()=>{Ea()},[]),ue.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(pf,{}),t.jsxs($r.Provider,{value:{...wr,...n},children:[t.jsx(se,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(gf,{})}),t.jsx(Ir,{children:t.jsx(qa,{children:t.jsx(T.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(Qa,{children:t.jsxs(pc,{children:[e,t.jsx(Yc,{children:t.jsx(Oo,{})})]})})})})})]})]}):null),yf=({bridge:e})=>t.jsx(Ir,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Gr.Provider,{value:!!e,children:t.jsx(se,{children:t.jsx(Oo,{})})})})});exports.AddressUtils=M;exports.DEFAULT_GAS_ADJUSTMENT=_s;exports.DEFAULT_GAS_PRICE_MULTIPLIER=vr;exports.InterwovenKit=yf;exports.InterwovenKitProvider=xf;exports.MAINNET=wr;exports.TESTNET=oa;exports.createUsernameClient=jr;exports.initiaPrivyWallet=ia;exports.initiaPrivyWalletConnector=aa;exports.initiaPrivyWalletOptions=fs;exports.injectStyles=xc;exports.useAddress=Ct;exports.useHexAddress=xn;exports.useInitiaAddress=Z;exports.useInterwovenKit=pe;exports.useUsernameQuery=Hr;
4
+ </svg>`,la=encodeURIComponent(ca),$r=`data:image/svg+xml;utf8,${la}`,Dt=Ne.createQueryKeys("interwovenkit:asset",{list:t=>[t],item:(t,s)=>[t,s],resource:(t,s)=>[t.chainId,s.denom],denom:(t,s)=>[t,s],metadata:(t,s)=>[t,s]});function da(t){const{base:s,symbol:n,denom_units:r=[],display:o,logo_URIs:a,name:i,address:l,traces:c}=t,d=r.find(m=>m.denom===o)?.exponent??r.find(m=>m.denom===s)?.exponent??E.head(r)?.exponent??0,u=a?.png??"";return{denom:s,symbol:n,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function Pt(t){const s=t?.metadata?.assetlist,n=$.useQueryClient(),{data:r}=$.useSuspenseQuery({queryKey:Dt.list(s).queryKey,queryFn:async()=>s?G.get(s).json():{assets:[]},select:({assets:o})=>{if(!t)return[];const a=o.map(da);for(const i of a)n.setQueryData(Dt.item(t.chainId,i.denom).queryKey,i);return a},staleTime:U.MINUTE});return r}function Ue(t){const s=Pt(t),n=je(),r=Pt(n),o=Ar(t);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:$r}}}function fn(t,s){const n=Ue(s),o=$.useQueryClient().getQueryData(Dt.item(s.chainId,t).queryKey);return o||n(t)}function Ar(t){const s=je(),n=Pt(t);return r=>{if(t.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===t.chain_id&&i==="ics20-1")?.channel_id;return o?y.getIbcDenom(o,r):""}}const qn="usernames";function ua({restUrl:t,moduleAddress:s}){const n=G.create({prefixUrl:t});async function r(l){const{moduleAddress:c,moduleName:d,functionName:u,typeArgs:m,args:h}=l,f=`initia/move/v1/accounts/${c}/modules/${d}/view_functions/${u}`,p={type_args:m,args:h},{data:g,message:C}=await n.post(f,{json:p}).json();if(C)throw new Error(C);return JSON.parse(g)}async function o(l){if(!y.InitiaAddress.validate(l))return null;const c=await r({moduleAddress:s,moduleName:qn,functionName:"get_name_from_address",typeArgs:[],args:[L.toBase64(y.InitiaAddress(l,32).bytes)]});return c?c+".init":null}function a(l){return/^[A-Za-z0-9-]{3,64}\.init$/.test(l)}async function i(l){if(!a(l))return null;const c=await r({moduleAddress:s,moduleName:qn,functionName:"get_address_from_name",typeArgs:[],args:[Fo.bcs.string().serialize(l.toLowerCase().replace(".init","")).toBase64()]});return c?y.InitiaAddress(c).bech32:null}return{restUrl:t,getUsername:o,getAddress:i,validateUsername:a}}const Ut=Ne.createQueryKeys("interwovenkit:account",{username:(t,s)=>[t,s],address:(t,s)=>[t,s],balances:(t,s)=>[t,s],txs:(t,s)=>[t,s]});function Er(){const{restUrl:t}=je(),{usernamesModuleAddress:s}=te();return ua({restUrl:t,moduleAddress:s})}function pn(t){const s=Y(),{restUrl:n}=t,{data:r}=$.useSuspenseQuery({queryKey:Ut.balances(n,s).queryKey,queryFn:()=>G.create({prefixUrl:n}).get(`cosmos/bank/v1beta1/balances/${s}`).json(),select:({balances:o})=>o,staleTime:U.SECOND});return r}function Tr(t){const s=pn(t),n=Pt(t),r=Ue(t),o=Ar(t),{data:a}=hs(t.chainId),i=c=>t.fees.fee_tokens.some(d=>d.denom===c),l=c=>n.some(d=>d.denom===c);return E.sortWith([E.descend(({denom:c})=>o(c)==="uinit"),E.descend(({denom:c})=>i(c)),E.descend(({value:c})=>c),E.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>F(d).comparedTo(c)??0,E.descend(({symbol:c})=>c.toLowerCase())],s.filter(({amount:c})=>!F(c).isZero()).map(({amount:c,denom:d})=>{const u=r(d),m=a?.find(({id:f})=>f===u?.denom)?.price??0,h=F(c).times(m).div(F(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:m,value:h}}))}function Y(){const t=gs();return t?y.InitiaAddress(t).bech32:""}function gs(){const{address:t}=xe.useAccount();return t?y.InitiaAddress(t).hex:""}function yt(){const t=zt(),s=Y(),n=gs();return t.metadata?.minitia?.type==="minievm"?n:s}function qr(){const t=yt(),s=Er();return $.useQuery({queryKey:Ut.username(s.restUrl,t).queryKey,queryFn:()=>s.getUsername(t),enabled:!!t,staleTime:U.MINUTE})}function pe(){const t=yt(),s=Y(),n=gs(),{data:r}=qr(),o=gt(),{isDrawerOpen:a,openDrawer:i}=xt(),l=()=>{i("/")},c=()=>{i("/connect")},d=m=>{i("/bridge",m)},u=Sr();return{address:t,initiaAddress:s,hexAddress:n,username:r,offlineSigner:o,isOpen:a,openConnect:c,openWallet:l,openBridge:d,...u}}function ma(){const t=["initia-wallet-widget:last-connected-wallet","initia-wallet-widget:fee-denoms"],s={"initia-wallet-widget:chain-ids":M.ADDED_CHAIN_IDS,"initia-wallet-widget:opened-layers-assets":`${M.OPENED_CHAIN_IDS}:assets`,"initia-wallet-widget:opened-layers-nft":`${M.OPENED_CHAIN_IDS}:nfts`},n={"initia-wallet-widget:ethereum-public-keys":{prefix:M.PUBLIC_KEY,getSuffix:r=>y.InitiaAddress(r).bech32}};for(const r of t)localStorage.removeItem(r);for(const[r,o]of Object.entries(s)){const a=localStorage.getItem(r);a&&(localStorage.setItem(o,a),localStorage.removeItem(r))}for(const[r,{prefix:o,getSuffix:a}]of Object.entries(n)){const i=localStorage.getItem(r);if(i)try{const l=JSON.parse(i);for(const[c,d]of Object.entries(l)){const u=`${o}:${a(c)}`;localStorage.setItem(u,d)}localStorage.removeItem(r)}catch{}}}const ha="_status_tn9m1_1",_a="_error_tn9m1_9",Dn={status:ha,error:_a},ae=({error:t,children:s})=>e.jsx("p",{className:D(Dn.status,{[Dn.error]:t}),children:s}),se=({errorBoundaryProps:t={fallbackRender:({error:r})=>e.jsx(ae,{error:!0,children:r.message})},suspenseFallback:s=e.jsx(ae,{children:"Loading..."}),children:n})=>e.jsx(cr.ErrorBoundary,{...t,children:e.jsx(_.Suspense,{fallback:s,children:n})}),fe=Ne.createQueryKeys("interwovenkit:skip",{chains:null,assets:t=>[t],asset:(t,s)=>[t,s],balances:(t,s)=>[t,s],route:(t,s)=>[t,s],routeErrorInfo:t=>[t],txTrack:(t,s)=>[t,s],txStatus:(t,s)=>[t,s]});function Ke(){const{routerApiUrl:t}=te();return _.useMemo(()=>G.create({prefixUrl:t}),[t])}function Dr(){const t=ze();return s=>t.some(n=>n.chain_id===s)}function Kt(){const t=Dr();return s=>t(s.chain_id)?"initia":s.chain_type}function Rt(t){return Kt()(t)}function gn(){const t=Ke(),{data:s}=$.useSuspenseQuery({queryKey:fe.chains.queryKey,queryFn:()=>t.get("v2/info/chains").json(),select:({chains:n})=>E.sortWith([E.descend(({chain_name:r})=>r==="initia"),E.ascend(({pretty_name:r})=>r)],n),staleTime:U.MINUTE});return s}function ot(){const t=gn();return s=>{const n=t.find(r=>r.chain_id===s);if(!n)throw new Error(`Chain not found: ${s}`);return n}}function Ie(t){return ot()(t)}function ht(t){const s=Ke(),n=$.useQueryClient(),{data:r}=$.useSuspenseQuery({queryKey:fe.assets(t).queryKey,queryFn:()=>s.get("v2/fungible/assets",{searchParams:{chain_ids:t}}).json(),select:({chain_to_assets_map:o})=>{const{assets:a}=o[t]??{assets:[]};for(const i of a)n.setQueryData(fe.asset(t,i.denom).queryKey,i);return a.toSorted(E.descend(i=>i.symbol==="INIT"))},staleTime:U.MINUTE});return r}function Pr(t){const s=ht(t);return n=>{const r=s.find(o=>o.denom===n);if(!r)throw new Error(`Asset not found: ${n}`);return r}}function Ee(t,s){return Pr(s)(t)}const xn=_.createContext(null);function _t(){const{container:t}=_.useContext(xn);return t}function fa(t){const s=_t();return s?getComputedStyle(s).getPropertyValue(t):""}const pa=({children:t})=>{const[s,n]=_.useState(null);return e.jsx(xn.Provider,{value:{container:s,setContainer:n},children:t})},ga="_loader_4gdsk_1",xa={loader:ga},Le=({size:t=24,color:s="currentColor",border:n=2})=>{const r={width:`${t}px`,height:`${t}px`,borderColor:`${s} ${s} transparent ${s}`,borderWidth:`${n}px`};return e.jsx("div",{className:xa.loader,style:r})},ya="_container_4qmbg_1",ja="_toast_4qmbg_10",ba="_info_4qmbg_23",va="_success_4qmbg_27",wa="_error_4qmbg_31",Ca="_icon_4qmbg_36",Ia="_content_4qmbg_43",Na="_title_4qmbg_46",Sa="_description_4qmbg_51",ka="_close_4qmbg_72",Pe={container:ya,toast:ja,info:ba,success:va,error:wa,icon:Ca,content:Ia,title:Na,description:Sa,close:ka},$a=({notification:t,onClose:s,...n})=>{const r=le.useTransition(t,{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 e.jsx(Le,{size:16});case"info":case"success":return e.jsx(b.IconCheckCircleFilled,{size:16});case"error":return e.jsx(b.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 e.jsx(le.animated.div,{style:a,className:Pe.container,children:e.jsxs("div",{className:D(Pe.toast,l&&Pe[l]),...n,children:[u&&e.jsx("div",{className:Pe.icon,children:u}),e.jsxs("div",{className:Pe.content,children:[e.jsx("p",{className:Pe.title,children:c}),d&&e.jsx("div",{className:Pe.description,children:d})]}),e.jsx("button",{className:Pe.close,onClick:s,children:e.jsx(b.IconClose,{size:14})})]})})})},Rr=_.createContext(null),Fr=()=>_.useContext(Rr),Ts=5e3,Aa=({children:t})=>{const s=_t(),[n,r]=_.useState(null),o=_.useRef(null),a=_.useRef(!1),i=()=>{o.current&&(clearTimeout(o.current),o.current=null)},l=_.useCallback(()=>{i(),r(null)},[]),c=_.useCallback(h=>{i(),r({...h,id:En.nanoid()}),h.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Ts))},[l]),d=_.useCallback(h=>{i(),r(f=>f?{...f,...h}:{...h,id:En.nanoid()}),h.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Ts))},[l]),u=()=>{i(),a.current=!0},m=()=>{i(),a.current=!1,n?.autoHide&&(o.current=setTimeout(()=>l(),Ts))};return _.useEffect(()=>()=>i(),[]),e.jsxs(Rr.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[t,s&&un.createPortal(e.jsx($a,{notification:n,onClose:l,onMouseEnter:u,onMouseLeave:m}),s)]})},Br=_.createContext(!1),Ea="_overlay_16e1z_1",Ta="_fullscreen_16e1z_12",qa="_content_16e1z_16",Da="_header_16e1z_43",Pa="_title_16e1z_52",Ra="_close_16e1z_57",Qe={overlay:Ea,fullscreen:Ta,content:qa,header:Da,title:Pa,close:Ra},Mr=({title:t,children:s,trigger:n,className:r,open:o,onOpenChange:a})=>{const i=_t(),l=_.useContext(Br);_.useEffect(()=>{if(!o)return;const u=m=>{m.key==="Escape"&&a(!1)};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[a,o]);const c=le.useTransition(o,{from:{opacity:0},enter:{opacity:1},leave:{opacity:0},config:{tension:500,friction:30,clamp:!0}}),d=le.useTransition(o,{from:{opacity:0,transform:"translateY(24px)"},enter:{opacity:1,transform:"translateY(0px)"},leave:{opacity:0,transform:"translateY(24px)"},config:{tension:500,friction:30,clamp:!0}});return i?e.jsxs(e.Fragment,{children:[n&&e.jsx("button",{type:"button",className:r,onClick:()=>a(!0),children:n}),un.createPortal(e.jsxs(e.Fragment,{children:[c((u,m)=>m&&e.jsx(le.animated.div,{style:u,className:D(Qe.overlay,{[Qe.fullscreen]:l}),onClick:()=>a(!1),onKeyDown:()=>a(!1),role:"button",tabIndex:0})),d((u,m)=>m&&e.jsxs(le.animated.div,{style:u,className:D(Qe.content,{[Qe.fullscreen]:l}),children:[t&&e.jsxs("header",{className:Qe.header,children:[e.jsx("h2",{className:Qe.title,children:t}),e.jsx("button",{type:"button",className:Qe.close,onClick:()=>a(!1),children:e.jsx(b.IconClose,{size:20})})]}),s]}))]}),i)]}):null};function Or({indexerUrl:t}){const s=Y();return $.useSuspenseQuery({queryKey:Ut.txs(t,s).queryKey,queryFn:async()=>{const n={"pagination.reverse":!0};return G.create({prefixUrl:t}).get(`indexer/tx/v1/txs/by_account/${s}`,{searchParams:n}).json()},select:n=>n.txs,staleTime:U.SECOND})}function zr(t){const{data:s}=$.useSuspenseQuery({queryKey:_n.gasPrices(t).queryKey,queryFn:async()=>{if(t.metadata?.is_l1){const{restUrl:n}=t,{gas_prices:r}=await G.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return r.toSorted(E.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const i=o==="uinit"?1:ur;return{amount:F(a).times(i).toFixed(18),denom:o}})}return t.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:r})=>{if(E.isNil(r))throw new Error(`${n} has no price`);return{amount:String(r),denom:n}})},staleTime:U.SECOND});return s}function Ur(t){const s=Y(),{data:n}=Or(t);if(t.fees.fee_tokens.length===0)return null;const r=t.fees.fee_tokens[0].denom;if(t.fees.fee_tokens.length===1)return r;try{return n.find(({tx:a})=>a.auth_info.signer_infos.some(i=>y.InitiaAddress.equals(s,nt.computeAddress(`0x${L.toHex(Gs.Secp256k1.uncompressPubkey(L.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??r}catch{return r}}const Fa="_root_1wwaf_1",Ba="_item_1wwaf_10",Ma="_chevron_1wwaf_14",Oa="_trigger_1wwaf_19",za="_content_1wwaf_39",Ct={root:Fa,item:Ba,chevron:Ma,trigger:Oa,content:za};function Kr(t){const{list:s,getKey:n,renderHeader:r,renderContent:o,footer:a,...i}=t;return e.jsxs(R.Accordion.Root,{className:Ct.root,type:"multiple",...i,children:[s.map((l,c)=>e.jsxs(R.Accordion.Item,{className:Ct.item,value:n?.(l)??String(c),children:[e.jsx(R.Accordion.Header,{children:e.jsxs(R.Accordion.Trigger,{className:Ct.trigger,children:[r(l),e.jsx(b.IconChevronDown,{className:Ct.chevron,size:16})]})}),e.jsx(R.Accordion.Content,{className:Ct.content,children:o(l)})]},n?.(l)??c)),a]})}const Ua="_scrollable_abvhw_1",Ka={scrollable:Ua},qe=({className:t,children:s})=>e.jsx("div",{className:D(Ka.scrollable,t),children:s}),Zs=({children:t})=>{const s=_.useRef(null),[n,r]=_.useState(0),o=le.useSpring({height:n,config:{tension:500,friction:30,clamp:!0}});return _.useEffect(()=>{if(s.current){const{height:a}=s.current.getBoundingClientRect();r(a)}},[t]),t?e.jsx(le.animated.div,{style:{overflow:"hidden",...o},children:e.jsx("div",{ref:s,children:t})}):null},La="_help_7m3jv_1",Ha="_icon_7m3jv_10",Wa="_info_7m3jv_17",Qa="_warning_7m3jv_21",Va="_error_7m3jv_25",Ga="_success_7m3jv_31",qs={help:La,icon:Ha,info:Wa,warning:Qa,error:Va,success:Ga},Be=({level:t,className:s,mt:n=8,children:r})=>{if(!r)return null;const o=()=>{switch(t){case"loading":return e.jsx(Le,{size:12});case"info":return e.jsx(b.IconInfoFilled,{size:12});case"warning":case"error":return e.jsx(b.IconWarningFilled,{size:12});default:return e.jsx(b.IconCheckCircleFilled,{size:12})}};return e.jsxs("div",{className:D(qs.help,t&&qs[t],s),style:{marginTop:n},children:[e.jsx("div",{className:qs.icon,children:o()}),e.jsx("p",{children:r})]})},Ya="_stack_14kq8_1",Ja="_help_14kq8_6",Za="_info_14kq8_14",Xa="_warning_14kq8_19",ei="_error_14kq8_24",ti="_success_14kq8_29",Xs={stack:Ya,help:Ja,info:Za,warning:Xa,error:ei,success:ti},si=({children:t})=>!t||Array.isArray(t)&&t.filter(Boolean).length===0?null:e.jsx(Zs,{children:e.jsx("div",{className:Xs.stack,children:t})}),ee=t=>e.jsx(Be,{...t,className:D(Xs.help,Xs[t.level]),mt:0});ee.Stack=si;const ni="_footer_xif7g_1",ri="_actions_xif7g_10",Pn={footer:ni,actions:ri},ne=({extra:t,className:s,children:n})=>e.jsxs("footer",{className:D(Pn.footer,s),children:[t,e.jsx("div",{className:Pn.actions,children:n})]}),oi="_button_7llhj_1",ai="_outline_7llhj_24",ii="_sm_7llhj_42",ci="_full_7llhj_48",li="_small_7llhj_52",di="_unpadded_7llhj_82",et={button:oi,outline:ai,sm:ii,full:ci,small:li,unpadded:di},Lr=t=>{const{sm:s,fullWidth:n,loading:r,className:o,children:a,disabled:i,...l}=t;return e.jsx("button",{...l,className:D(et.button,{[et.sm]:s,[et.full]:n},o),disabled:!!r||i,children:r?e.jsxs(e.Fragment,{children:[e.jsx(Le,{color:"currentColor",size:16}),typeof r=="string"&&e.jsx("span",{className:et.loading,children:r})]}):a})},ui=({className:t,...s})=>e.jsx(Lr,{...s,className:D(et.outline,t)}),mi=({className:t,unpadded:s,...n})=>e.jsx("button",{...n,className:D(et.small,{[et.unpadded]:s},t)}),H={White:Lr,Outline:ui,Small:mi},hi="_item_1n572_1",_i="_title_1n572_10",fi="_content_1n572_14",Ds={item:hi,title:_i,content:fi},Ps=({title:t,content:s})=>e.jsxs("div",{className:Ds.item,children:[e.jsx("div",{className:Ds.title,children:t}),e.jsx("div",{className:Ds.content,children:s})]});function Ft(t){if(t&&F(t).gt(0)&&F(t).lt(.01))return"<$0.01";const s=y.formatNumber(t,{dp:2});return s?`$${s}`:""}const pi="_placeholder_80nya_1",gi="_circle_80nya_5",Rn={placeholder:pi,circle:gi},W=({src:t,alt:s,placeholder:n,classNames:r,circle:o,...a})=>{const[i,l]=_.useState(!1),{width:c,height:d}=a,u=n??e.jsx("div",{className:D(Rn.placeholder,r?.placeholder),style:{width:c,height:d}});return _.useEffect(()=>{l(!1)},[t]),!t||i?u:e.jsx("img",{...a,className:D(a.className,{[Rn.circle]:o}),style:{width:c,height:d},src:t,alt:s,loading:"lazy",onError:()=>l(!0)})};function Hr(t,s){const n={};for(const r of t)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 Wr(t,s){const n={};for(const r of t)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&&y.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&&y.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 Qr=({metadata:t,chain:s,children:n})=>{const{restUrl:r}=s,{data:o}=$.useSuspenseQuery({queryKey:Dt.denom(r,t).queryKey,queryFn:()=>G.create({prefixUrl:r}).get("initia/move/v1/denom",{searchParams:{metadata:t}}).json(),select:({denom:a})=>a,staleTime:U.INFINITY});return n(o)},xi="_root_jioyr_1",yi="_title_jioyr_7",ji="_changes_jioyr_13",bi="_change_jioyr_13",vi="_amount_jioyr_34",wi="_text_jioyr_40",Ci="_value_jioyr_47",tt={root:xi,title:yi,changes:ji,change:bi,amount:vi,text:wi,value:Ci},Vr=({amount:t,asset:s,price:n})=>{const{denom:r,symbol:o,decimals:a,logoUrl:i}=s,l=y.formatAmount(t,{decimals:a}),c=n&&F(y.fromBaseUnit(t,{decimals:a})).times(n).abs();return e.jsxs("div",{className:tt.change,children:[e.jsxs("div",{className:tt.amount,children:[e.jsx(W,{src:i,width:14,height:14}),e.jsxs("span",{className:tt.text,children:[l," ",o||r]})]}),c&&e.jsx("div",{className:tt.value,children:Ft(c)})]})},Ii=({changes:t,chain:s})=>{const n=Ue(s),{data:r}=hs(s.chainId);return t.map(({amount:o,denom:a},i)=>{const l=n(a),c=r?.find(({id:d})=>d===a)?.price;return e.jsx(Vr,{amount:o,asset:l,price:c},i)})},Ni=({changes:t,chain:s})=>{const n=Ue(s),{data:r}=hs(s.chainId);return t.map(({amount:o,metadata:a},i)=>e.jsx(Qr,{metadata:a,chain:s,children:l=>{const c=r?.find(({id:d})=>d===l)?.price;return e.jsx(Vr,{amount:o,asset:n(l),price:c})}},i))};function Si(t,s){return typeof s=="bigint"?s.toString():s}const ki=Ne.createQueryKeys("interwovenkit:tx",{simulate:t=>[JSON.stringify(t,Si)]}),$i=({messages:t,memo:s,chainId:n})=>{const{initiaAddress:r,hexAddress:o}=pe(),a=ye(n),{simulateTx:i}=Sr(),{data:l}=$.useSuspenseQuery({queryKey:ki.simulate({messages:t,memo:s,chainId:n}).queryKey,queryFn:()=>i({messages:t,memo:s,chainId:n}),staleTime:U.SECOND}),c=h=>e.jsxs("div",{className:tt.root,children:[e.jsx("h2",{className:tt.title,children:"Estimated changes"}),e.jsx("div",{className:tt.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=Wr(d,o),[f]=Fn(h);return f.length===0?null:c(e.jsx(Ni,{changes:f,chain:a}))}const u=Hr(d,r),[m]=Fn(u);return m.length===0?null:c(e.jsx(Ii,{changes:m,chain:a}))};function Fn(t){return E.partition(s=>new F(s.amount).isNegative(),t)}const Ai="_trigger_13rgr_1",Ei="_icon_13rgr_5",Ti="_content_13rgr_16",qi="_item_13rgr_24",Vt={trigger:Ai,icon:Ei,content:Ti,item:qi},Di=({options:t,value:s,onChange:n})=>{const r=_t(),{txRequest:o}=Nr(),a=ye(o.chainId),i=Ue(a),l=({amount:[{amount:c,denom:d}]})=>{if(F(c).isZero())return"0";const{symbol:u,decimals:m}=i(d);return`${y.formatAmount(c,{decimals:m})} ${u}`};return t.length===1?l(t[0]):e.jsxs(R.Select.Root,{value:s,onValueChange:n,children:[e.jsxs(R.Select.Trigger,{className:Vt.trigger,children:[e.jsx(R.Select.Value,{}),e.jsx(R.Select.Icon,{className:Vt.icon,children:e.jsx(b.IconChevronDown,{size:16})})]}),e.jsx(R.Select.Portal,{container:r,children:e.jsx(R.Select.Content,{className:Vt.content,position:"popper",sideOffset:6,align:"end",children:e.jsx(R.Select.Viewport,{children:t.map(c=>{const[{denom:d}]=c.amount;return e.jsx(R.Select.Item,{className:Vt.item,value:d,children:e.jsx(R.Select.ItemText,{children:l(c)})},d)})})})})]})};function cs(t){switch(typeof t){case"string":return t;case"number":case"bigint":return t.toString();case"boolean":return t?"true":"false";case"object":return t===null?"null":t instanceof Uint8Array?L.toBase64(t):Array.isArray(t)?`[${t.map(cs).join(",")}]`:JSON.stringify(t,(s,n)=>typeof n=="bigint"?n.toString():n);default:return"unknown"}}const Pi="_container_1xzyq_1",Ri="_toggle_1xzyq_5",Fi="_list_1xzyq_11",Bi="_arg_1xzyq_16",Mi="_type_1xzyq_21",It={container:Pi,toggle:Ri,list:Fi,arg:Bi,type:Mi},Oi=Ne.createQueryKeys("interwovenkit:move",{abi:(t,s,n,r)=>[t,s,n,r]}),zi=({type:t,arg:s})=>cs(y.resolveBcsType(t).parse(s)),Ui=({msg:t,chainId:s,fallback:n})=>{const[r,o]=de.useToggle(!1),{restUrl:a}=ye(s),{moduleAddress:i,moduleName:l,functionName:c,args:d}=t,{data:u}=$.useQuery({queryKey:Oi.abi(a,i,l,c).queryKey,queryFn:async()=>{const h=await G.create({prefixUrl:a}).get(`initia/move/v1/accounts/${i}/modules/${l}`).json(),p=JSON.parse(h.module.abi).exposed_functions.find(({name:g})=>g===c);if(!p)throw new Error(`Function ${c} not found in module ${l}`);return p.params.filter(g=>!g.startsWith("&"))},staleTime:U.INFINITY});if(!u)return n;const m=(h,f)=>{const p=u[f];return e.jsxs("div",{className:It.arg,children:[e.jsx("div",{className:It.type,children:p}),e.jsx(cr.ErrorBoundary,{fallback:e.jsx("div",{className:"error",children:"Error decoding argument"}),children:e.jsx(zi,{type:p,arg:h})})]},f)};return e.jsxs("div",{className:It.container,children:[e.jsx(H.Small,{className:It.toggle,onClick:o,disabled:!u,children:r?"Encode":"Decode"}),r?e.jsx("div",{className:It.list,children:d.map(m)}):n]})},Ki="_list_r67rl_1",Li="_key_r67rl_8",Hi="_value_r67rl_13",Rs={list:Ki,key:Li,value:Hi},Wi=({message:t,chainId:s})=>{const{typeUrl:n,value:r}=t;return e.jsx("div",{className:Rs.list,children:Object.entries(r).map(([o,a])=>e.jsxs("div",{children:[e.jsx("div",{className:Rs.key,children:o}),e.jsx("div",{className:Rs.value,children:n==="/initia.move.v1.MsgExecute"&&o==="args"?e.jsx(Ui,{msg:r,chainId:s,fallback:cs(a)}):cs(a)})]},o))})},Qi="_title_kspdu_1",Vi="_meta_kspdu_7",Gi="_footer_kspdu_14",Fs={title:Qi,meta:Vi,footer:Gi},Gr=()=>{const{txRequest:t,resolve:s,reject:n}=Nr(),{messages:r,memo:o,chainId:a,gas:i,gasAdjustment:l,spendCoins:c}=t,d=Y(),u=gt(),m=jr(),h=ye(a),f=pn(h),p=zr(h),g=Ur(h),C=(t.gasPrices??p).map(({amount:j,denom:q})=>Ce.calculateFee(Math.ceil(i*l),Ce.GasPrice.fromString(j+q))),S=C.map(j=>j.amount[0]),I=j=>{const q=f.find(N=>N.denom===j)?.amount??0,O=S.find(N=>N.denom===j)?.amount??0,T=c.filter(N=>N.denom===j).reduce((N,K)=>F(N).plus(K.amount),F(0));if(T.gt(0)){const N=F(O).plus(T);return F(q).gte(N)}return F(q).gte(O)},P=()=>{if(g&&I(g))return g;for(const{denom:j}of S)if(I(j))return j;return S[0]?.denom},[A,x]=_.useState(P),{mutate:k,isPending:v}=$.useMutation({mutationKey:[Cr],mutationFn:async()=>{const j=C.find(O=>O.amount[0].denom===A);if(!j)throw new Error("Fee not found");if(!u)throw new Error("Signer not initialized");const q=await m(a,d,r,j,o);await s(q)},onError:async j=>{n(new Error(await Oe(j)))}}),w=!I(A);return e.jsxs(e.Fragment,{children:[e.jsxs(qe,{children:[e.jsx("h1",{className:Fs.title,children:"Confirm tx"}),e.jsxs("div",{className:Fs.meta,children:[e.jsx(Ps,{title:"Chain",content:a}),e.jsx(Ps,{title:"Tx fee",content:e.jsx(Di,{options:C,value:A,onChange:x})}),o&&e.jsx(Ps,{title:"Memo",content:o}),w&&e.jsx(ee,{level:"error",children:"Insufficient balance for fee"})]}),e.jsx($i,{messages:r,memo:o,chainId:a}),e.jsx(Kr,{list:r,renderHeader:({typeUrl:j})=>Bt.sentenceCase(j.split(".").pop().replace(/^Msg/,"")),renderContent:j=>e.jsx(Wi,{message:j,chainId:a})})]}),e.jsxs(ne,{className:Fs.footer,children:[e.jsx(H.Outline,{onClick:()=>n(new Error("User rejected")),disabled:v,children:"Reject"}),e.jsx(H.White,{onClick:()=>k(),disabled:w,loading:v,children:"Approve"})]})]})},Yi=({children:t})=>{const[{title:s,content:n,path:r},o]=_.useState({}),[a,i]=_.useState(!1),l=_e.useAtomValue(ps),c=_.useCallback(m=>{o(m),i(!0)},[]),d=_.useCallback(()=>{o({}),i(!1)},[]),u=_.useCallback(m=>{m||(l?.reject(new Error("User rejected")),o({})),i(m)},[l]);return e.jsxs(gr.Provider,{value:{openModal:c,closeModal:d},children:[t,e.jsx(Mr,{title:s,open:a,onOpenChange:u,children:e.jsx(se,{children:r==="/tx"?e.jsx(Gr,{}):n})})]})};function xs(){return de.useMediaQuery("(max-width: 576px)")}const en="interwoven-kit";function Yr(){const t=document.querySelector(en)||document.body.appendChild(document.createElement(en));return t.shadowRoot||t.attachShadow({mode:"open"})}function Ji(){const{theme:t,container:s}=te();return _.useEffect(()=>{document.querySelector(en)?.setAttribute("data-theme",t)},[t]),s??Yr()}function Zi(t){const s=Yr(),n=document.createElement("style");n.textContent=t,s.appendChild(n)}const yn=({value:t,children:s})=>{const[n,r]=_.useState(!1);return s({copy:async()=>{try{await navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),1e3)}catch{}},copied:n})},Xi="_tooltip_6zakp_1",ec="_arrow_6zakp_43",Bn={tooltip:Xi,arrow:ec},jt=({label:t,children:s,small:n,...r})=>e.jsxs(R.Tooltip.Root,{...r,children:[e.jsx(R.Tooltip.Trigger,{asChild:!0,children:s}),e.jsx(R.Tooltip.Portal,{container:_t(),children:e.jsxs(R.Tooltip.Content,{className:D(Bn.tooltip,{small:n}),collisionBoundary:_t(),collisionPadding:8,sideOffset:4,children:[t,e.jsx(R.Tooltip.Arrow,{className:Bn.arrow})]})})]}),tc="_root_1pbnr_1",sc="_address_1pbnr_9",nc="_copy_1pbnr_19",rc="_labelWrapper_1pbnr_33",oc="_labelCopy_1pbnr_43",ac="_labelCopied_1pbnr_47",ic="_copied_1pbnr_55",Ve={root:tc,address:sc,copy:nc,labelWrapper:rc,labelCopy:oc,labelCopied:ac,copied:ic},cc=()=>{const t=_.useRef(null),s=_.useRef(null),{initiaAddress:n,hexAddress:r}=pe(),o=fa("--gray-0");return _.useEffect(()=>{t.current&&(s.current?s.current.update({data:n}):(s.current=new Bo({type:"canvas",width:400,height:400,margin:0,data:n,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:o},cornersSquareOptions:{type:"extra-rounded",color:o},cornersDotOptions:{type:"dot",color:o},backgroundOptions:{color:"transparent"}}),s.current.append(t.current)))},[n,o]),e.jsxs("div",{className:Ve.root,children:[e.jsx("div",{ref:t,style:{width:200,height:200}}),e.jsx(jt,{label:`Derived from ${y.truncate(r)}`,children:e.jsx("span",{className:Ve.address,children:n})}),e.jsx(yn,{value:n,children:({copy:a,copied:i})=>e.jsxs("button",{className:D(Ve.copy,{[Ve.copied]:i}),onClick:a,children:[e.jsx(b.IconCopy,{size:12}),e.jsxs("div",{className:Ve.labelWrapper,children:[e.jsx("span",{className:Ve.labelCopy,children:"Copy address"}),e.jsx("span",{className:Ve.labelCopied,children:"Copied!"})]})]})})]})},lc="_header_1bgzn_1",dc="_account_1bgzn_12",uc="_name_1bgzn_23",mc="_address_1bgzn_27",hc="_icon_1bgzn_31",_c="_copied_1bgzn_38",fc="_button_1bgzn_53",pc="_qr_1bgzn_64",gc="_disconnect_1bgzn_68",xc="_label_1bgzn_78",yc="_expanded_1bgzn_86",me={header:lc,account:dc,name:uc,address:mc,icon:hc,copied:_c,button:fc,qr:pc,disconnect:gc,label:xc,expanded:yc},jc=()=>{const t=ie(),s=zt(),{connector:n}=xe.useAccount(),{disconnect:r}=xe.useDisconnect(),{address:o,username:a}=pe(),{closeDrawer:i}=xt(),{openModal:l}=Ot(),c=a??o,[d,u]=_.useState(!1),m=_.useRef(null),h=le.useSpring({width:d?140:52,config:{tension:500,friction:30,clamp:!0}}),f=()=>{d?(t("/blank"),i(),r(),localStorage.removeItem(M.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(M.BRIDGE_SRC_DENOM),localStorage.removeItem(M.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(M.BRIDGE_DST_DENOM),localStorage.removeItem(M.BRIDGE_QUANTITY),localStorage.removeItem(M.BRIDGE_SLIPPAGE_PERCENT)):u(!0)},p=()=>{d&&(m.current=setTimeout(()=>{u(!1)},500))},g=()=>{m.current&&(clearTimeout(m.current),m.current=null)};return _.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),n?e.jsxs("header",{className:me.header,children:[e.jsx(yn,{value:o,children:({copy:C,copied:S})=>e.jsxs("button",{className:D(me.account,{[me.copied]:S}),onClick:C,children:[e.jsx(W,{src:n.icon,width:18,height:18}),e.jsx("div",{className:me.address,children:y.truncate(o)}),e.jsx("div",{className:me.name,children:y.truncate(c)}),e.jsx(b.IconCopy,{className:me.icon,size:12}),S?"Copied!":""]})}),s.metadata?.is_l1&&e.jsx("button",{className:D(me.button,me.qr),onClick:()=>l({title:"Initia address",content:e.jsx(cc,{})}),children:e.jsx(b.IconQrCode,{size:16})}),e.jsxs(le.animated.button,{className:D(me.button,me.disconnect,{[me.expanded]:d}),style:h,onClick:f,onMouseLeave:p,onMouseEnter:g,children:[e.jsx(b.IconSignOut,{size:16}),e.jsx("span",{className:me.label,children:"Disconnect"})]})]}):null};function bc(t){return/^[A-F0-9]{64}$/i.test(t)}function vc(t,s){const{txHash:n,accountAddress:r,pathSuffix:o}=s;if(n)return bc(n)?E.path(["explorers",0,"tx_page"],t)?.replace(/\$\{txHash\}/g,n):void 0;if(r){if(!y.InitiaAddress.validate(r))return;const i=E.path(["explorers",0,"account_page"],t)?.replace(/\$\{accountAddress\}/g,r);return i&&o?i+o:i}}function wc(t){try{const s=new URL(t,window.location.href);if(!["http:","https:"].includes(s.protocol))throw new Error("Invalid protocol");return s.toString()}catch{return"#"}}const Cc="_link_guafb_1",Mn={link:Cc},ys=({chainId:t,txHash:s,accountAddress:n,pathSuffix:r,...o})=>{const{showIcon:a,className:i,children:l,onClick:c,...d}=o,u=ye(t),m=vc(u,{txHash:s,accountAddress:n,pathSuffix:r}),h=s?y.truncate(s):n?y.truncate(n):"",f=l??h;return m?e.jsxs("a",{...d,href:lr(wc(m)),className:D(Mn.link,i),onClick:c,target:"_blank",children:[f,a&&e.jsx(b.IconExternalLink,{size:12})]}):e.jsx("span",{...d,className:D(Mn.link,i),children:f})},Ic=()=>{const[t,s]=_e.useAtom(Ir),{showNotification:n,updateNotification:r,hideNotification:o}=Fr();return _.useEffect(()=>{if(!t)return;const{status:a,chainId:i,txHash:l,error:c}=t,d=c?c.message:l?e.jsx(ys,{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}},[t,s,n,r,o]),null};function Nc(){return de.useScrollLock(),null}const Sc="_overlay_1mu2p_1",kc="_content_1mu2p_49",$c="_inner_1mu2p_68",Bs={overlay:Sc,content:kc,inner:$c},Ac=({children:t})=>{const{isDrawerOpen:s,closeDrawer:n}=xt(),{setContainer:r}=_.useContext(xn),o=xs(),a=_e.useAtomValue(ps),i=$.useIsMutating({mutationKey:[Cr]}),l=()=>{const h=i?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";n(),a?.reject(new Error(h))},c=ie(),d=$.useQueryClient(),u={fallbackRender:({error:h,resetErrorBoundary:f})=>{const p=()=>{c("/"),d.clear(),f()};return e.jsxs(qe,{children:[e.jsx(ae,{error:!0,children:h.message}),e.jsx(ne,{children:e.jsx(H.White,{onClick:p,children:"Retry"})})]})}},m=le.useTransition(s,{from:{transform:o?"translateY(100%)":"translateX(100%)"},enter:{transform:o?"translateY(0%)":"translateX(0%)"},leave:{transform:o?"translateY(100%)":"translateX(100%)"},config:{tension:500,friction:30,clamp:!0}});return un.createPortal(e.jsxs(e.Fragment,{children:[m((h,f)=>f?e.jsx(le.animated.button,{style:h,className:Bs.overlay,onClick:l,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[e.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"}),e.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"})]})}):null),m((h,f)=>f?e.jsx(le.animated.div,{style:h,className:D(Bs.content),children:e.jsxs("div",{className:D(Bs.inner,"body"),ref:r,children:[o&&e.jsx(Nc,{}),e.jsx(Ic,{}),e.jsx(jc,{}),e.jsx(se,{errorBoundaryProps:u,children:t})]})}):null)]}),Ji())},Ec="_page_1f6wh_1",Tc="_title_1f6wh_10",qc="_scrollable_1f6wh_17",Dc="_list_1f6wh_22",Pc="_item_1f6wh_32",Rc="_name_1f6wh_56",Fc="_dimmed_1f6wh_64",Bc="_recent_1f6wh_68",Mc="_installed_1f6wh_69",ge={page:Ec,title:Tc,scrollable:qc,list:Dc,item:Pc,name:Rc,dimmed:Fc,recent:Bc,installed:Mc},Oc=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],On=({onSuccess:t})=>{const{connectors:s,connectAsync:n}=xe.useConnect(),r=de.useReadLocalStorage("wagmi.recentConnectorId"),[o,a]=_.useState(null),{mutate:i,isPending:l}=$.useMutation({mutationFn:async c=>{a(c.id);try{await n({connector:c})}catch(d){throw new Error(await Oe(d))}},onSettled:()=>{a(null)},onSuccess:()=>{t?.()}});return e.jsxs("div",{className:ge.page,children:[e.jsx("h1",{className:ge.title,children:"Connect wallet"}),e.jsx(qe,{className:ge.scrollable,children:e.jsxs("div",{className:ge.list,children:[s.toSorted(E.descend(c=>c.id===r)).map(c=>{const{name:d,icon:u,id:m}=c;return e.jsxs("button",{className:ge.item,onClick:()=>i(c),disabled:l,children:[e.jsx(W,{src:u,width:24,height:24}),e.jsx("span",{className:ge.name,children:d}),o===m?e.jsx(Le,{size:16}):r===m?e.jsx("span",{className:ge.recent,children:"Recent"}):e.jsx("span",{className:ge.installed,children:"Installed"})]},m)}),Oc.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 e.jsxs("a",{href:d,className:ge.item,target:"_blank",children:[e.jsx(W,{src:u,width:24,height:24}),e.jsx("span",{className:D(ge.name,ge.dimmed),children:c}),e.jsx(b.IconExternalLink,{size:10})]},c)})]})})]})},zc="_root_xwz5z_1",Uc="_header_xwz5z_6",Kc="_title_xwz5z_12",Lc="_warning_xwz5z_18",Hc="_content_xwz5z_22",Wc="_footer_xwz5z_26",Qc="_secondary_xwz5z_36",Ge={root:zc,header:Uc,title:Kc,warning:Lc,content:Hc,footer:Wc,secondary:Qc},Jr=t=>{const{type:s,icon:n,title:r,children:o,primaryButton:a,secondaryButton:i}=t;return e.jsxs(qe,{className:Ge.root,children:[e.jsxs("header",{className:D(Ge.header,s&&Ge[s]),children:[n,e.jsx("h1",{className:Ge.title,children:r})]}),e.jsx("div",{className:Ge.content,children:o}),e.jsxs("footer",{className:Ge.footer,children:[e.jsx(H.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),e.jsxs("button",{className:Ge.secondary,onClick:i.onClick,children:[e.jsx("span",{children:i.label}),e.jsx(b.IconChevronRight,{size:14})]})]})]})},Vc="_list_tmcxc_1",Gc="_row_tmcxc_8",Yc="_dt_tmcxc_19",Jc="_asset_tmcxc_25",Gt={list:Vc,row:Gc,dt:Yc,asset:Jc},Zc=({list:t,onNavigate:s,onDismiss:n})=>{const r=je(),o=Te(),a=Ue(r);return e.jsx(Jr,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:s},secondaryButton:{label:"Do not show again",onClick:n},children:e.jsx("div",{className:Gt.list,children:t.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),f=y.formatAmount(c,{decimals:m});return e.jsxs("div",{className:Gt.row,children:[e.jsxs("div",{className:Gt.dt,children:[e.jsx(W,{src:u.logoUrl,width:16,height:16}),e.jsx("span",{children:u.name})]}),e.jsxs("span",{className:Gt.asset,children:[f," ",h]})]},i)})})})};function Ms(t,s){return t.chainId===s.chainId&&t.txHash===s.txHash}const Yt=({chainId:t,txHash:s})=>`${M.OP_REMINDER}:${t}:${s}`,Xc=ir.atomWithStorage(M.OP_REMINDER,[]);function bt(){const t=Y(),[s=[],n]=_e.useAtom(Xc),r=_.useMemo(()=>s.map(c=>{const d=localStorage.getItem(Yt(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==t?!1:ft.isPast(u)}),[t,s]),o=_.useCallback((c,d)=>{s.some(u=>Ms(u,c))||(n((u=[])=>[...u,c]),localStorage.setItem(Yt(c),JSON.stringify(d)))},[s,n]),a=_.useCallback(c=>{n((d=[])=>d.filter(u=>!Ms(u,c))),localStorage.removeItem(Yt(c))},[n]),i=_.useCallback(c=>{const d=c.filter(u=>!s.some(m=>Ms(m,u)));d.length!==0&&n((u=[])=>[...u,...d])},[s,n]),l=_.useCallback((c,d)=>{localStorage.setItem(Yt(c),JSON.stringify(d)),n((u=[])=>[...u])},[n]);return{reminders:r,addReminder:o,removeReminder:a,syncReminders:i,setReminder:l}}function Zr(){const t=ie(),{openModal:s,closeModal:n}=Ot(),{reminders:r,setReminder:o}=bt();_.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;t("/op/withdrawals",{chainId:c}),l()},l=()=>{n();for(const c of a)o(c,{...c,dismissed:!0})};s({content:_.createElement(Zc,{list:a,onNavigate:i,onDismiss:l})})},[r,n,t,s,o])}const el="2.0.0-rc.5",tl="_flex_1v8wv_1",sl={flex:tl},tn=({mt:t,mb:s,children:n})=>e.jsx("div",{className:sl.flex,style:{marginTop:t,marginBottom:s},children:n}),nl="_toggle_grhff_1",rl="_name_grhff_7",ol="_rollups_grhff_11",al="_version_grhff_29",Jt={toggle:nl,name:rl,rollups:ol,version:al},Xr=({renderContent:t,storageKey:s})=>{const{defaultChainId:n}=te(),{addedChains:r}=pt(),[o,a]=de.useLocalStorage(`${M.OPENED_CHAIN_IDS}:${s}`,[n]),i=o.length===0,l=()=>{a(i?r.map(c=>c.chainId):[])};return e.jsxs(e.Fragment,{children:[e.jsx(tn,{mb:6,children:e.jsxs(H.Small,{className:Jt.toggle,onClick:l,children:[e.jsx("span",{children:i?"Expand all":"Collapse all"}),i?e.jsx(b.IconChevronDown,{size:10}):e.jsx(b.IconChevronUp,{size:10})]})}),e.jsx(Kr,{list:r,getKey:({chainId:c})=>c,renderHeader:({name:c,logoUrl:d})=>e.jsxs(e.Fragment,{children:[e.jsx(W,{src:d,width:16,height:16}),e.jsx("span",{className:Jt.name,children:c})]}),renderContent:t,value:o,onValueChange:a,footer:e.jsxs(Mt,{className:Jt.rollups,to:"/rollups",children:[e.jsx(b.IconSettingFilled,{size:12}),e.jsx("span",{children:"Manage rollup list"})]})}),e.jsx(tn,{mt:8,children:e.jsxs("span",{className:Jt.version,children:["v",el]})})]})},il="_asset_1dxy8_1",cl="_token_1dxy8_23",ll="_symbol_1dxy8_28",dl="_name_1dxy8_29",ul="_balance_1dxy8_40",ml="_amount_1dxy8_45",hl="_value_1dxy8_49",Ye={asset:il,token:cl,symbol:ll,name:dl,balance:ul,amount:ml,value:hl},_l=t=>{const{denom:s,symbol:n,name:r,logoUrl:o,decimals:a,balance:i="0",value:l=0}=t;return e.jsxs("div",{className:Ye.asset,children:[e.jsx(W,{src:o,width:24,height:24}),e.jsxs("div",{className:Ye.token,children:[e.jsx("div",{className:Ye.symbol,children:n||s}),r&&e.jsx("div",{className:Ye.name,children:r})]}),F(i).gt(0)&&e.jsxs("div",{className:Ye.balance,children:[e.jsx("div",{className:Ye.amount,children:y.formatAmount(i,{decimals:a})}),l>0&&e.jsxs("div",{className:Ye.value,children:["$",y.formatNumber(l)]})]})]})},fl="_actions_180l3_1",pl="_button_180l3_8",gl="_add_180l3_25",Nt={actions:fl,button:pl,add:gl},xl=({denom:t,chain:s})=>{const n=ie(),{defaultChainId:r}=te(),{evm_chain_id:o}=zt(),{address:a="",symbol:i,decimals:l,logoUrl:c}=fn(t,s),{connector:d}=xe.useAccount(),{switchChainAsync:u}=xe.useSwitchChain(),{watchAssetAsync:m}=xe.useWatchAsset(),{chainId:h}=s,f=()=>{n("/send",{denom:t,chain:s})},p=()=>{n("/bridge",{srcChainId:h,srcDenom:t})},g=$.useMutation({mutationFn:async()=>(await u({chainId:Number(o)}),m({type:"ERC20",options:{address:a,symbol:i,decimals:l,image:c}}))});return e.jsxs("nav",{className:Nt.actions,children:[e.jsx("button",{className:Nt.button,onClick:f,children:"Send"}),e.jsx("button",{className:Nt.button,onClick:p,children:"Bridge/Swap"}),h===r&&!!a&&e.jsxs("button",{className:D(Nt.button,Nt.add),onClick:()=>g.mutate(),disabled:g.isPending||g.data,children:[g.data?e.jsx(b.IconCheck,{size:10}):e.jsx(b.IconPlus,{size:10}),e.jsx(W,{src:d?.icon,width:16,height:16})]})]})},yl="_list_wod0u_1",jl="_item_wod0u_8",bl="_trigger_wod0u_19",vl="_content_wod0u_24",Zt={list:yl,item:jl,trigger:bl,content:vl},wl=t=>{const s=Tr(t);return s.length?e.jsx(R.Accordion.Root,{type:"single",collapsible:!0,className:Zt.list,children:s.map(n=>e.jsxs(R.Accordion.Item,{className:Zt.item,value:n.denom,children:[e.jsx(R.Accordion.Header,{children:e.jsx(R.Accordion.Trigger,{className:Zt.trigger,children:e.jsx(_l,{...n})})}),e.jsx(R.Accordion.Content,{className:Zt.content,children:e.jsx(xl,{denom:n.denom,chain:t})})]},n.denom))}):e.jsx(ae,{children:"No assets"})},Cl=()=>e.jsx(Xr,{renderContent:t=>e.jsx(se,{children:e.jsx(wl,{...t})}),storageKey:"assets"});function eo(t,s){const n=s?.pages?.map(o=>o[t]??[]).flat()??[],r=E.pathOr(0,[0,"pagination","total"],s?.pages);return{list:n,count:r}}function to(t){return t.pagination.next_key}async function Il(t,s,n){const r=G.create(s),o=async(a,i)=>{const l=await r.extend(i?{searchParams:{"pagination.key":i}}:{}).get(t).json(),c=l[n]??[],d=to(l),u=[...a,...c];return d?o(u,d):u};return o([],null)}const jn=Ne.createQueryKeys("interwovenkit:nft",{collections:(t,s)=>[t,s],collection:(t,s,n)=>[t,s,n],metadata:t=>[t]});function Nl(t){const{object_addr:s,collection:n}=t;return{object_addr:s,...n}}function Sl(t,s){const{collection_addr:n,collection_name:r,nft:o,object_addr:a}=t,i=s.name??o.token_id;return{collection_addr:n,collection_name:r,...o,object_addr:a,...s,name:i}}function kl(t){const{indexerUrl:s}=t,n=Y(),{data:r}=$.useSuspenseQuery({queryKey:jn.collections(s,n).queryKey,queryFn:()=>Il(`indexer/nft/v1/collections/by_account/${n}`,{prefixUrl:s},"collections"),select:o=>o.map(Nl),staleTime:U.SECOND});return r}function so({chain:t,collection:s}){const n=Y(),{object_addr:r}=s,{indexerUrl:o}=t;return $.useSuspenseInfiniteQuery({queryKey:jn.collection(o,n,r).queryKey,queryFn:({pageParam:a=""})=>G.create({prefixUrl:o}).get(`indexer/nft/v1/tokens/by_account/${n}`,{searchParams:{collection_addr:r,"pagination.key":a||"","pagination.limit":9}}).json(),initialPageParam:"",getNextPageParam:to,staleTime:U.SECOND})}function zn(t){return t?.replace("ipfs://","https://ipfs.io/ipfs/")}function $l(t){const s=zn(t);return $.useQuery({queryKey:jn.metadata(s).queryKey,queryFn:async()=>{try{if(!s)return{};const n=await G.get(s).json();return{...n,image:zn(n.image)}}catch{return{}}},staleTime:U.INFINITY})}const no=({nftResponse:t,children:s})=>{const{data:n={}}=$l(t.nft.uri),r=Sl(t,n);return s(r)},Al="_thumbnail_1se9u_1",El="_placeholder_1se9u_15",Tl="_clickable_1se9u_21",St={thumbnail:Al,placeholder:El,clickable:Tl},js=({chain:t,collection:s,nft:n,size:r,onClick:o})=>{const a=new URL(`/v1/${t.chainId}/${s.object_addr}/${n.object_addr||n.token_id}`,"https://glyph.initia.xyz").toString();return o?e.jsx("button",{className:D(St.thumbnail,St.clickable),onClick:o,style:{width:r,height:r},children:e.jsx(W,{src:a,classNames:{placeholder:St.placeholder}})}):e.jsx("div",{className:St.thumbnail,style:{width:r,height:r},children:e.jsx(W,{src:a,classNames:{placeholder:St.placeholder}})})},ql="_item_1rdda_1",Dl="_content_1rdda_15",Pl="_name_1rdda_21",Rl="_count_1rdda_27",Fl="_chevron_1rdda_33",kt={item:ql,content:Dl,name:Pl,count:Rl,chevron:Fl},Bl=({chain:t,collection:s})=>{const{data:n}=so({chain:t,collection:s}),{list:r,count:o}=eo("tokens",n),[a]=r;return e.jsxs(Mt,{className:kt.item,to:"/collection",state:{collection:s,chain:t},children:[a&&e.jsx(no,{nftResponse:a,children:i=>e.jsx(js,{chain:t,collection:s,nft:i,size:58})}),e.jsxs("div",{className:kt.content,children:[e.jsx("div",{className:kt.name,children:s.name}),o>0&&e.jsx("div",{className:kt.count,children:o})]}),e.jsx("div",{className:kt.chevron,children:e.jsx(b.IconChevronRight,{})})]})},Ml="_list_1lv70_1",Ol={list:Ml},zl=({chain:t})=>{const s=kl(t);return s.length?e.jsx("div",{className:Ol.list,children:s.map(n=>e.jsx(Bl,{collection:n,chain:t},n.object_addr))}):e.jsx(ae,{children:"No collections"})},Ul=()=>e.jsx(Xr,{renderContent:t=>e.jsx(se,{children:e.jsx(zl,{chain:t})}),storageKey:"nfts"}),rt=({title:t,content:s,children:n,className:r})=>{const[o,a]=_.useState(!1),i=()=>a(!1);return e.jsx(Mr,{title:t,trigger:n,className:r,open:o,onOpenChange:a,children:s(i)})},Kl="_scrollable_1p1lw_1",Ll="_list_1p1lw_5",Hl="_item_1p1lw_9",Wl="_name_1p1lw_13",Xt={scrollable:Kl,list:Ll,item:Hl,name:Wl};function ro({onSelect:t,list:s,...n}){const{getImage:r,getName:o,getKey:a,getIsLoading:i,getDisabled:l}=n;return e.jsx(qe,{className:Xt.scrollable,children:e.jsx("div",{className:Xt.list,children:s.map(c=>e.jsxs("button",{className:Xt.item,onClick:()=>t(c),disabled:i?.(c)||l?.(c),children:[e.jsx(W,{src:r(c),width:28,height:28}),e.jsx("span",{className:Xt.name,children:o(c)}),i?.(c)&&e.jsx(Le,{size:16})]},a(c)))})})}const oo=({onSelect:t})=>{const{addedChains:s}=pt();return e.jsx(ro,{onSelect:n=>t(n.chainId),list:s,getImage:n=>n.logoUrl,getName:n=>n.name,getKey:n=>n.chainId})},Ql="_button_1uc4x_1",Vl="_name_1uc4x_9",Gl="_icon_1uc4x_13",Os={button:Ql,name:Vl,icon:Gl},Yl=({value:t,onSelect:s})=>{const{logoUrl:n,name:r}=ye(t);return e.jsxs(rt,{title:"Select rollup",content:o=>e.jsx(oo,{onSelect:a=>{s(a),o()}}),className:D("input",Os.button),children:[e.jsx(W,{src:n,width:16,height:16}),e.jsx("span",{className:Os.name,children:r}),e.jsx(b.IconChevronDown,{size:16,className:Os.icon})]})},Jl="_message_1g2hc_1",Zl="_more_1g2hc_8",Un={message:Jl,more:Zl},Xl=({messages:t})=>e.jsxs(e.Fragment,{children:[t.slice(0,3).map((s,n)=>e.jsx("p",{className:Un.message,children:Bt.sentenceCase(s["@type"].split("Msg")[1])},n)),t.length>3&&e.jsx("footer",{className:Un.more,children:`+${t.length-3} more`})]}),ed="_change_nbl45_1",td="_positive_nbl45_9",sd="_negative_nbl45_13",zs={change:ed,positive:td,negative:sd},ao=({amount:t,asset:s})=>{const{denom:n,symbol:r,decimals:o}=s,a=new F(t).isPositive(),i=new F(t).abs().toString();return e.jsxs("div",{className:D(zs.change,a?zs.positive:zs.negative),children:[a?"+":"-",y.formatAmount(i,{decimals:o})," ",r||n]})},nd=({changes:t,chain:s})=>{const n=Ue(s);return t.map(({amount:r,denom:o},a)=>e.jsx(ao,{amount:r,asset:n(o)},a))},rd=({changes:t,chain:s})=>{const n=Ue(s);return t.map(({amount:r,metadata:o},a)=>e.jsx(Qr,{metadata:o,chain:s,children:i=>e.jsx(ao,{amount:r,asset:n(i)})},a))},od=({events:t,chain:s})=>{const{initiaAddress:n,hexAddress:r}=pe();return s.metadata?.is_l1||s.metadata?.minitia?.type==="minimove"?e.jsx(rd,{changes:Wr(t,r),chain:s}):e.jsx(nd,{changes:Hr(t,n),chain:s})},ad="_link_qkpto_1",id="_inner_qkpto_14",cd="_timestamp_qkpto_23",ld="_content_qkpto_39",dd="_messages_qkpto_45",ud="_changes_qkpto_50",md="_error_qkpto_57",Je={link:ad,inner:id,timestamp:cd,content:ld,messages:dd,changes:ud,error:md},hd=({txItem:t,chain:s})=>e.jsx(ys,{txHash:t.txhash,chainId:s.chainId,className:Je.link,children:e.jsxs("div",{className:Je.inner,children:[e.jsx("div",{className:Je.timestamp,children:Bt.sentenceCase(ft.intlFormatDistance(new Date(t.timestamp),new Date,{locale:"en-US"}))}),e.jsxs("div",{className:Je.content,children:[e.jsx("div",{className:Je.messages,children:e.jsx(Xl,{messages:t.tx.body.messages})}),e.jsx("div",{className:Je.changes,children:e.jsx(se,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:e.jsx(od,{...t,chain:s})})})]}),t.code!==0&&e.jsxs("div",{className:Je.error,children:[e.jsx(b.IconWarningFilled,{size:12}),e.jsx("span",{children:"Failed"})]})]})}),_d="_list_si737_1",fd="_more_si737_7",Kn={list:_d,more:fd},pd=({chain:t})=>{const s=Y(),{data:n}=Or(t);return n.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:Kn.list,children:n.map(r=>e.jsx(hd,{txItem:r,chain:t},r.txhash))}),e.jsx(ys,{chainId:t.chainId,accountAddress:s,pathSuffix:"/txs",className:Kn.more,showIcon:!0,children:"View more on Initia Scan"})]}):e.jsx(ae,{children:"No activity yet"})},gd=()=>{const{defaultChainId:t}=te(),[s,n]=de.useLocalStorage(M.ACTIVITY_CHAIN_ID,t),r=ye(s);return e.jsxs(e.Fragment,{children:[e.jsx(Yl,{value:s,onSelect:n}),e.jsx(se,{children:e.jsx(pd,{chain:r})},s)]})},xd="_nav_1ldnv_1",yd="_item_1ldnv_6",jd="_tabs_1ldnv_28",bd="_tab_1ldnv_28",Ze={nav:xd,item:yd,tabs:jd,tab:bd},vd=()=>{Zr();const t=ie(),s=fr();return e.jsxs(qe,{children:[e.jsxs("div",{className:Ze.nav,children:[e.jsxs(Mt,{to:"/send",className:Ze.item,children:[e.jsx(b.IconArrowRight,{size:16}),e.jsx("span",{children:"Send"})]}),e.jsxs("button",{className:Ze.item,onClick:()=>t("/bridge"),children:[e.jsx(b.IconSwap,{size:16}),e.jsx("span",{children:"Bridge/Swap"})]})]}),e.jsxs(R.Tabs.Root,{value:s,onValueChange:t,children:[e.jsxs(R.Tabs.List,{className:Ze.tabs,children:[e.jsx(R.Tabs.Trigger,{className:Ze.tab,value:"/",children:"Assets"}),e.jsx(R.Tabs.Trigger,{className:Ze.tab,value:"/nfts",children:"NFTs"}),e.jsx(R.Tabs.Trigger,{className:Ze.tab,value:"/activity",children:"Activity"})]}),e.jsx(R.Tabs.Content,{value:"/",children:e.jsx(Cl,{})}),e.jsx(R.Tabs.Content,{value:"/nfts",children:e.jsx(Ul,{})}),e.jsx(R.Tabs.Content,{value:"/activity",children:e.jsx(gd,{})})]})]})};function io({quantity:t,balance:s,decimals:n},r){if(F.BigNumber(t).isZero()){r.addIssue({code:V.z.ZodIssueCode.custom,message:"Enter amount",path:["quantity"]});return}if(!s||F.BigNumber(y.toBaseUnit(t,{decimals:n})).gt(s)){r.addIssue({code:V.z.ZodIssueCode.custom,message:"Insufficient balance",path:["quantity"]});return}}const co=V.z.string().nonempty("Recipient address is required").refine(t=>y.InitiaAddress.validate(t),"Invalid address"),wd="_header_acels_1",Cd="_back_acels_11",Id="_title_acels_23",Us={header:wd,back:Cd,title:Id},De=({title:t,returnTo:s,extra:n,children:r})=>e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:Us.header,children:[s!==!1&&e.jsx(Mt,{to:s??-1,className:Us.back,children:e.jsx(b.IconBack,{size:16})}),e.jsx("h1",{className:Us.title,children:t}),n]}),e.jsx(qe,{children:r})]}),Nd="_fieldset_y241y_1",Sd="_upper_y241y_9",kd="_select_y241y_14",$d="_account_y241y_19",Ad="_lower_y241y_24",Ed="_wrapper_y241y_25",Td="_balance_y241y_32",qd="_value_y241y_36",Dd="_error_y241y_49",$e={fieldset:Nd,upper:Sd,select:kd,account:$d,lower:Ad,wrapper:Ed,balance:Td,value:qd,error:Dd},sn=t=>{const{selectButton:s,accountButton:n,quantityInput:r,balanceButton:o,value:a,errorMessage:i}=t;return e.jsxs("div",{className:$e.fieldset,children:[e.jsxs("div",{className:$e.upper,children:[e.jsx("div",{className:$e.select,children:s}),e.jsx("div",{className:$e.account,children:n})]}),e.jsxs("div",{className:$e.lower,children:[r,e.jsxs("div",{className:$e.wrapper,children:[e.jsx("div",{className:$e.balance,children:o}),a&&e.jsx("div",{className:$e.value,children:a})]}),i&&e.jsxs("footer",{className:$e.error,children:[e.jsx(b.IconWarningFilled,{size:12}),e.jsx("p",{children:i})]})]})]})},Pd="_images_1txea_1",Rd="_chain_1txea_5",Ln={images:Pd,chain:Rd},bn=({assetLogoUrl:t,chainLogoUrl:s})=>e.jsxs("div",{className:Ln.images,children:[e.jsx(W,{src:t,width:36,height:36}),e.jsx(W,{src:s,width:18,height:18,className:Ln.chain})]}),Fd="_root_1ipwv_1",Bd="_content_1ipwv_10",Md="_details_1ipwv_18",Od="_symbol_1ipwv_23",zd="_chain_1ipwv_31",Ud="_chevron_1ipwv_40",Xe={root:Fd,content:Bd,details:Md,symbol:Od,chain:zd,chevron:Ud},lo=({asset:t,chain:s,readOnly:n})=>{const r=e.jsxs("div",{className:Xe.content,children:[e.jsx(bn,{assetLogoUrl:t.logoUrl,chainLogoUrl:s.logoUrl}),e.jsxs("div",{className:Xe.details,children:[e.jsx("div",{className:Xe.symbol,children:t.symbol||t.denom}),e.jsxs("div",{className:Xe.chain,children:["on ",s.name]})]})]});return n?e.jsx("div",{className:Xe.root,children:r}):e.jsxs("div",{className:Xe.root,children:[r,e.jsx(b.IconChevronDown,{size:16,className:Xe.chevron})]})},Kd="_wrapper_5ssm8_1",Ld="_balance_5ssm8_11",Hd="_button_5ssm8_15",Ks={wrapper:Kd,balance:Ld,button:Hd},uo=({onClick:t,children:s,disabled:n})=>e.jsxs("div",{className:Ks.wrapper,children:[e.jsx(b.IconWallet,{size:16}),e.jsx("span",{className:Ks.balance,children:s}),e.jsx("button",{type:"button",className:Ks.button,onClick:()=>t(),disabled:n,children:"MAX"})]});function bs(){const t=_.useRef(null),s=xs();return _.useEffect(()=>{s||t.current?.focus()},[s]),t}const Wd="_input_h8073_1",Qd={input:Wd};function Vd(t,s){const n=t.replace(/[^0-9.]/g,""),[r,...o]=n.split(".");return o.length===0?r:`${r}.${o.join("").slice(0,s)}`}function mo(t){const{name:s,control:n,dp:r=6,className:o,...a}=t,i=bs();return e.jsx(oe.Controller,{name:s,control:n,render:({field:l})=>e.jsx("input",{...l,className:D(Qd.input,o),onChange:c=>l.onChange(Vd(c.target.value,r)),placeholder:"0",inputMode:"decimal",autoComplete:"off",...a,ref:dr.mergeRefs([l.ref,i])})})}const Gd="_input_qpv94_1",Yd="_placeholder_qpv94_18",nn={input:Gd,placeholder:Yd},Jd=({children:t})=>e.jsx("p",{className:D(nn.input,{[nn.placeholder]:F(t).isZero()}),children:t}),ls=()=>{const{control:t}=oe.useFormContext();return e.jsx(mo,{name:"quantity",control:t,className:nn.input})};ls.ReadOnly=Jd;const Zd="_label_9417z_1",Xd="_wrapper_9417z_7",eu="_input_9417z_10",tu="_clear_9417z_18",es={label:Zd,wrapper:Xd,input:eu,clear:tu},vn=({mode:t="onChange",myAddress:s,...n})=>{const{validate:r=y.InitiaAddress.validate,chainType:o="initia",onApply:a,ref:i}=n,l=bs(),{getValues:c,setValue:d,formState:u}=oe.useFormContext(),m=c("recipient"),[h,f]=_.useState(m),p=Er(),{data:g,isLoading:C,error:S}=$.useQuery({queryKey:Ut.address(p.restUrl,h).queryKey,queryFn:()=>p.getAddress(h),staleTime:U.MINUTE,enabled:p.validateUsername(h)}),I=g??(r(h)?h:""),P=s&&y.InitiaAddress.equals(I,s),A=async()=>{try{const v=await navigator.clipboard.readText();f(v.trim())}catch{}};_.useEffect(()=>{t==="onChange"&&h&&d("recipient",g??h,{shouldValidate:!0})},[h,t,d,g]);const x=()=>{C||S||(d("recipient",I,{shouldValidate:!0}),a?.())},k=()=>{if(C)return e.jsx(Be,{level:"loading",children:"Resolving username..."});if(S)return e.jsx(Be,{level:"error",children:S.message});if(g)return e.jsx(Be,{level:"success",className:"monospace",children:g});if(t==="onSubmit"&&h&&!I)return e.jsx(Be,{level:"error",children:"Invalid address"});if(t==="onChange")return e.jsx(Be,{level:"error",children:u.errors.recipient?.message})};return e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"recipient",className:es.label,children:[e.jsx("span",{children:"Recipient"}),e.jsx(H.Small,{type:"button",onClick:A,children:"Paste"})]}),e.jsxs("div",{className:es.wrapper,children:[e.jsx("input",{id:"recipient",className:D(es.input,"monospace"),value:h,onChange:v=>f(v.target.value.trim()),placeholder:o==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":h?"true":void 0,ref:t==="onSubmit"?dr.mergeRefs([i,l]):i}),!!h&&e.jsx("button",{type:"button",className:es.clear,onClick:()=>f(""),"aria-label":"Clear recipient",children:e.jsx(b.IconCloseCircleFilled,{size:16})})]}),k(),P&&e.jsx(Be,{children:"This is my address"}),t==="onSubmit"&&e.jsx(ne,{extra:(!s||!!I&&!P)&&e.jsx(ee,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:e.jsx(H.White,{type:"button",onClick:x,disabled:C||!!S||!I,children:"Apply"})})]})};function su({balances:t,gasPrices:s,gas:n}){return s.map(({denom:r,amount:o})=>{const a=F(o).times(n).toFixed(0,F.ROUND_CEIL),i=t.find(l=>l.denom===r)?.amount??"0";return{amount:a,denom:r,balance:i}}).filter(({amount:r,balance:o})=>F(o).gte(r))}function nu({denom:t,balances:s,gasPrices:n,lastFeeDenom:r,gas:o}){const a=s.find(d=>d.denom===t)?.amount??"0",i=su({balances:s,gasPrices:n,gas:o}),l=i.find(d=>d.denom===r);if(i.length===0)return a;if(t===r&&l){const d=F(a).minus(l.amount);return F.max(d,0).toString()}const c=i.find(d=>d.denom!==t)||i[0];if(!l&&t===c.denom){const d=F(a).minus(c.amount);return F.max(d,0).toString()}return F(a).toString()}const ru="_container_1a4ds_1",ou="_badge_1a4ds_5",Hn={container:ru,badge:ou},ho=t=>{const{offset:s=-4,disabled:n,children:r,className:o}=t;return e.jsxs("div",{className:D(Hn.container,o),children:[r,!n&&e.jsx("div",{className:Hn.badge,style:{right:s,top:s}})]})},au="_stack_a3b9q_1",iu="_title_a3b9q_8",cu="_grid_a3b9q_15",lu="_item_a3b9q_21",du="_button_a3b9q_25",uu="_active_a3b9q_43",dt={stack:au,title:iu,grid:cu,item:lu,button:du,active:uu},st=({label:t,chains:s,value:n,onSelect:r,getShowIndicator:o})=>e.jsxs("div",{children:[t&&e.jsx("h2",{className:dt.title,children:t}),e.jsx("div",{className:dt.grid,children:s.map(({chainId:a,name:i,logoUrl:l})=>e.jsx(ho,{offset:-2,disabled:!o?.(a),className:dt.item,children:e.jsx(jt,{label:i,disableHoverableContent:!0,children:e.jsx("button",{type:"button",className:D(dt.button,{[dt.active]:a===n}),onClick:()=>r(a),children:e.jsx(W,{src:l,width:28,height:28,circle:!0})})})},a))})]}),mu=({children:t})=>e.jsx("div",{className:dt.stack,children:t});st.Stack=mu;function _o(t,s,n){return n.filter(r=>{const o=t.map(a=>r[a]).map(a=>String(a??"").toLowerCase());return E.any(E.includes(s.toLowerCase()),o)})}const hu="_root_qd12v_1",_u="_label_qd12v_8",fu="_input_qd12v_14",pu="_clear_qd12v_20",ts={root:hu,label:_u,input:fu,clear:pu},wn=({value:t="",onChange:s,placeholder:n="Search",className:r})=>e.jsxs("div",{className:D(ts.root,r),children:[e.jsx("label",{htmlFor:"search",className:ts.label,children:e.jsx(b.IconSearch,{size:16})}),e.jsx("input",{id:"search",type:"text",className:ts.input,value:t,onChange:o=>s?.(o.target.value),placeholder:n,readOnly:!s,ref:bs()}),t&&e.jsx("button",{className:ts.clear,onClick:()=>s?.(""),children:e.jsx(b.IconCloseCircleFilled,{size:20})})]}),gu="_container_hhze4_1",xu="_list_hhze4_6",yu="_item_hhze4_12",ju="_logo_hhze4_31",bu="_info_hhze4_35",vu="_symbol_hhze4_40",wu="_name_hhze4_47",Cu="_balance_hhze4_53",Iu="_value_hhze4_61",we={container:gu,list:xu,item:yu,logo:ju,info:bu,symbol:vu,name:wu,balance:Cu,value:Iu},Lt=t=>{const{assets:s,onSelect:n,renderAsset:r=(l,c)=>c(l)}=t,[o,a]=_.useState(""),i=_o(["symbol"],o,s);return e.jsxs("div",{className:we.container,children:[e.jsx(wn,{value:o,onChange:a,placeholder:"Search by symbol"}),i.length===0?e.jsx(ae,{children:"No assets"}):e.jsx("div",{className:we.list,children:i.map(l=>e.jsx("button",{type:"button",className:we.item,onClick:()=>n(l.denom),children:r(l,c=>{const{denom:d,logoUrl:u,symbol:m,name:h,balance:f,decimals:p,value:g=0}=c;return e.jsxs(e.Fragment,{children:[e.jsx(W,{src:u,width:32,height:32,className:we.logo}),e.jsxs("div",{className:we.info,children:[e.jsx("div",{className:we.symbol,children:m||d}),e.jsx("div",{className:we.name,children:h})]}),e.jsxs("div",{className:we.balance,children:[f&&e.jsx("div",{children:y.formatAmount(f,{decimals:p})}),g>0&&e.jsx("div",{className:we.value,children:Ft(g)})]})]})})},l.denom))})]})},Nu=()=>e.jsxs("div",{className:we.container,children:[e.jsx(wn,{placeholder:"Search by symbol"}),e.jsx(ae,{children:"Loading..."})]});Lt.Placeholder=Nu;const Su=({chain:t,onSelect:s})=>{const n=Tr(t);return n.length===0?e.jsx(ae,{children:"No assets"}):e.jsx(Lt,{assets:n,onSelect:s})},ku=({afterSelect:t})=>{const{watch:s,setValue:n}=oe.useFormContext(),{chainId:r}=s(),[o,a]=_.useState(r),i=ye(o),{addedChains:l}=pt(),c=d=>{n("chainId",o),n("denom",d),t()};return e.jsxs(e.Fragment,{children:[l.length>1&&e.jsx(st.Stack,{children:e.jsx(st,{chains:l,value:o,onSelect:a})}),e.jsx(se,{suspenseFallback:e.jsx(Lt.Placeholder,{}),children:e.jsx(Su,{chain:i,onSelect:c})},o)]})},$u="_fields_brpej_1",Au="_divider_brpej_11",Wn={fields:$u,divider:Au},Eu=Ne.createQueryKeys("interwovenkit:send",{gas:t=>[t]}),Tu=()=>{const{address:t,initiaAddress:s,estimateGas:n,requestTxSync:r}=pe(),{register:o,watch:a,setValue:i,handleSubmit:l,formState:c}=oe.useFormContext(),{chainId:d,denom:u,quantity:m,memo:h}=a(),{addedChains:f}=pt(),p=ye(d),g=pn(p),C=zr(p),S=Ur(p),I=fn(u,p),{data:P}=hs(p.chainId),{decimals:A}=I,x=g.find(N=>N.denom===u)?.amount??"0",k=P?.find(({id:N})=>N===u)?.price,{data:v=2e5,isLoading:w}=$.useQuery({queryKey:Eu.gas({chainId:d,denom:u,initiaAddress:s}).queryKey,queryFn:()=>{const N=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Tn.MsgSend.fromPartial({fromAddress:s,toAddress:y.InitiaAddress(s).bech32,amount:[{denom:u,amount:"1"}]})}];return n({messages:N,chainId:d})},staleTime:U.INFINITY}),j=Math.ceil(v*qt),q=nu({denom:u,balances:g,gasPrices:C,lastFeeDenom:S,gas:j}),{mutate:O,isPending:T}=$.useMutation({mutationFn:({chainId:N,denom:K,quantity:Q,recipient:J,memo:Se})=>{const be=y.toBaseUnit(Q,{decimals:A}),ke=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Tn.MsgSend.fromPartial({fromAddress:s,toAddress:y.InitiaAddress(J).bech32,amount:[{denom:K,amount:be}]})}];return r({messages:ke,memo:Se,chainId:N,gas:v,gasAdjustment:qt,gasPrices:C,spendCoins:[{denom:K,amount:be}],internal:"/"})}});return e.jsx(De,{title:"Send",children:e.jsxs("form",{onSubmit:l(N=>O(N)),children:[e.jsxs("div",{className:Wn.fields,children:[e.jsx(sn,{selectButton:e.jsx(rt,{title:f.length>1?"Select chain and asset":"Select asset",content:N=>e.jsx(ku,{afterSelect:N}),children:e.jsx(lo,{asset:I,chain:p})}),quantityInput:e.jsx(ls,{}),balanceButton:e.jsx(uo,{onClick:()=>i("quantity",y.fromBaseUnit(q,{decimals:A}),{shouldValidate:!0}),disabled:C.some(({denom:N})=>N===u)&&w,children:y.formatAmount(x??"0",{decimals:A})}),value:m?k?Ft(F(m).times(k)):"$-":"$0",errorMessage:c.errors.quantity?.message}),e.jsx("div",{className:Wn.divider}),e.jsx(vn,{myAddress:t}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),e.jsx("input",{...o("memo"),id:"memo",autoComplete:"off"}),e.jsx(Be,{level:"error",children:c.errors.memo?.message})]}),e.jsx(ee.Stack,{children:!h&&e.jsx(ee,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),e.jsx(ne,{children:e.jsx(H.White,{type:"submit",loading:T,disabled:!c.isValid,children:"Confirm"})})]})})},qu=V.z.object({chainId:V.z.string().nonempty(),denom:V.z.string().nonempty(),quantity:V.z.string().nonempty("Amount is required"),recipient:co,memo:V.z.string().optional().refine(t=>!t||new Blob([t]).size<=256,"Memo is too long")}),Du=()=>{const t=Me(),s=zt(),n=Pt(s),[r]=n,{chain:o=s,denom:a=r.denom}=t,i=Te(),l=Y(),c=$.useQueryClient(),d=oe.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:a,quantity:"",recipient:"",memo:""},resolver:mn.zodResolver(qu.superRefine(({chainId:u,denom:m,quantity:h},f)=>{const p=i(u),{decimals:g}=c.getQueryData(Dt.item(u,m).queryKey)??{decimals:0},{balances:C}=c.getQueryData(Ut.balances(p.restUrl,l).queryKey)??{balances:[]},S=C.find(I=>I.denom===m)?.amount;io({quantity:h,balance:S,decimals:g},f)}))});return e.jsx(oe.FormProvider,{...d,children:e.jsx(Tu,{})})},Pu="_button_1iys9_1",Ru={button:Pu},Cn=({onClick:t,disabled:s})=>{const{ref:n,inView:r}=Mo.useInView();return _.useEffect(()=>{r&&t()},[r,t]),e.jsxs("button",{className:Ru.button,onClick:t,disabled:s,ref:n,children:[e.jsx("span",{children:"Load more"}),e.jsx(b.IconChevronDown,{size:12})]})},Fu="_grid_4j669_1",Bu="_item_4j669_7",Mu="_name_4j669_15",Ls={grid:Fu,item:Bu,name:Mu},Ou=()=>{const t=ie(),{collection:s,chain:n}=Me(),{data:r,hasNextPage:o,isFetching:a,fetchNextPage:i}=so({chain:n,collection:s}),{list:l}=eo("tokens",r);return e.jsxs(De,{title:s.name,children:[e.jsx("div",{className:Ls.grid,children:l.map(c=>e.jsx(no,{nftResponse:c,children:d=>e.jsxs("div",{className:Ls.item,children:[e.jsx(js,{chain:n,collection:s,nft:d,onClick:()=>t("/nft",{collection:s,nft:d,chain:n})}),e.jsx("div",{className:Ls.name,children:d.name})]})},c.object_addr))}),o&&e.jsx(Cn,{onClick:()=>i(),disabled:a})]})},zu="_header_196nx_1",Uu="_name_196nx_6",Ku="_attributes_196nx_12",Lu="_title_196nx_15",Hu="_list_196nx_21",Wu="_item_196nx_25",Qu="_type_196nx_34",Vu="_value_196nx_40",Re={header:zu,name:Uu,attributes:Ku,title:Lu,list:Hu,item:Wu,type:Qu,value:Vu},Gu=()=>{const t=ie(),s=Me(),{collection:n,nft:r,chain:o}=s,{image:a,name:i,attributes:l}=r;return e.jsxs(De,{title:n.name,children:[e.jsxs("header",{className:Re.header,children:[a&&e.jsx(js,{chain:o,collection:n,nft:r}),e.jsx("h2",{className:Re.name,children:i})]}),e.jsx(ne,{children:e.jsx(H.White,{onClick:()=>t("/nft/send",s),children:"Send"})}),l&&e.jsxs("div",{className:Re.attributes,children:[e.jsxs("header",{className:Re.title,children:["Traits (",l.length,")"]}),e.jsx("div",{className:Re.list,children:l.map(({trait_type:c,value:d})=>e.jsxs("div",{className:Re.item,children:[e.jsx("div",{className:Re.type,children:c}),e.jsx("div",{className:Re.value,children:d})]},c))})]})]})},Yu="_header_5w36t_1",Ju="_name_5w36t_8",Zu="_collection_5w36t_15",Xu="_nft_5w36t_20",em="_fields_5w36t_24",tm="_chain_5w36t_29",ct={header:Yu,name:Ju,collection:Zu,nft:Xu,fields:em,chain:tm},sm=Ne.createQueryKeys("interwovenkit:send-nft",{simulation:t=>[t]}),nm=()=>{const{chain:t,collection:s,nft:n}=Me(),{routerApiUrl:r}=te(),o=fs(),a=je(),{address:i,initiaAddress:l,requestTxSync:c}=pe(),{watch:d,setValue:u,handleSubmit:m,formState:h}=oe.useFormContext(),f=d(),{recipient:p,dstChainId:g}=f,C=ye(g),S=$.useQuery({queryKey:sm.simulation({collection:s,nft:n,sender:l,recipient:p,srcChain:t,dstChainId:g,layer1:a,routerApiUrl:r}).queryKey,queryFn:async()=>{const v={from_address:l,from_chain_id:t.chainId,to_address:y.InitiaAddress(p).bech32,to_chain_id:g,collection_address:s.object_addr,token_ids:[n.token_id],object_addresses:[n.object_addr]},{msgs:w}=await G.create({prefixUrl:r}).post("nft",{json:v}).json();return w.map(j=>o.fromAmino(j))},enabled:!!p}),{data:I,isLoading:P,error:A}=S,{mutate:x,isPending:k}=$.useMutation({mutationFn:async()=>{if(!I)throw new Error("Route not found");await c({messages:I,chainId:t.chainId,internal:"/nfts"})}});return e.jsxs("form",{onSubmit:m(()=>x()),children:[e.jsxs("header",{className:ct.header,children:[n.image&&e.jsx(js,{chain:t,collection:s,nft:n,size:80}),e.jsxs("div",{className:ct.name,children:[e.jsx("div",{className:ct.collection,children:s.name}),e.jsx("div",{className:ct.nft,children:n.name})]})]}),e.jsxs("div",{className:ct.fields,children:[e.jsx(R.VisuallyHidden.Root,{children:e.jsxs("div",{children:[e.jsx("div",{className:"label",children:"Destination rollup"}),e.jsxs(rt,{title:"Destination rollup",content:v=>e.jsx(oo,{onSelect:w=>{u("dstChainId",w),v()}}),className:D("input",ct.chain),children:[e.jsx(W,{src:C.logoUrl,width:20,height:20}),e.jsx("span",{children:C.name})]})]})}),e.jsx(vn,{myAddress:i,ref:bs()})]}),e.jsx(ne,{children:e.jsx(H.White,{loading:P||k,disabled:!h.isValid,children:A?"Route not found":"Confirm"})})]})},rm=V.z.object({dstChainId:V.z.string().nonempty(),recipient:co}),om=()=>{const{chain:t}=Me(),s=oe.useForm({defaultValues:{dstChainId:t.chainId},resolver:mn.zodResolver(rm)});return e.jsx(De,{title:"Send NFT",children:e.jsx(oe.FormProvider,{...s,children:e.jsx(nm,{})})})},am="_item_ny5a8_1",im="_header_ny5a8_11",cm="_name_ny5a8_19",lm="_link_ny5a8_24",dm="_button_ny5a8_40",lt={item:am,header:im,name:cm,link:lm,button:dm},Hs=t=>{const{chainId:s,name:n,logoUrl:r,website:o,metadata:a}=t,{defaultChainId:i}=te(),{addedChains:l,addChain:c,removeChain:d}=pt(),u=l.find(h=>h.chainId===s),m=()=>s===i?null:u?e.jsx("button",{className:lt.button,onClick:()=>d(s),children:e.jsx(b.IconMinus,{size:14})}):e.jsx("button",{className:lt.button,onClick:()=>c(s),children:e.jsx(b.IconPlus,{size:14})});return e.jsxs("div",{className:lt.item,children:[e.jsx(W,{src:r,width:32,height:32,title:a?.minitia?.type}),e.jsxs("header",{className:lt.header,children:[e.jsx("h3",{className:lt.name,children:n}),o&&e.jsx("a",{className:lt.link,href:lr(o),target:"_blank",children:e.jsx(b.IconExternalLink,{size:12})})]}),m()]})},um="_content_14twd_1",mm="_search_14twd_5",hm="_title_14twd_9",_m="_count_14twd_18",fm="_list_14twd_23",Fe={content:um,search:mm,title:hm,count:_m,list:fm},pm=()=>{const[t,s]=_.useState(""),{chains:n,addedChains:r,notAddedChains:o}=pt(),a=_o(["chainId","name"],t,n);return e.jsx(De,{title:"Manage rollup list",children:e.jsxs("div",{className:Fe.content,children:[e.jsx(wn,{value:t,onChange:s,className:Fe.search}),t?a.length===0?e.jsx(ae,{children:"No chains"}):a.map(i=>_.createElement(Hs,{...i,key:i.chainId})):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:Fe.list,children:[e.jsxs("h2",{className:Fe.title,children:[e.jsx("span",{children:"Shown"}),e.jsxs("span",{className:Fe.count,children:["(",r.length,")"]})]}),r.map(i=>_.createElement(Hs,{...i,key:i.chainId}))]}),e.jsxs("div",{className:Fe.list,children:[e.jsxs("h2",{className:Fe.title,children:[e.jsx("span",{children:"Hidden"}),e.jsxs("span",{className:Fe.count,children:["(",o.length,")"]})]}),o.map(i=>_.createElement(Hs,{...i,key:i.chainId}))]})]})]})})};function gm(){return je().network_type==="testnet"}const fo=V.z.object({srcChainId:V.z.string().nonempty(),srcDenom:V.z.string().nonempty(),dstChainId:V.z.string().nonempty(),dstDenom:V.z.string().nonempty(),quantity:V.z.string().nonempty("Amount is required"),sender:V.z.string().nonempty(),cosmosWalletName:V.z.string().optional(),recipient:V.z.string().nonempty("Recipient address is required"),slippagePercent:V.z.string().nonempty()});function He(){return oe.useFormContext()}function xm(){const t=Me(),s=gm(),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=E.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(M.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(M.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(M.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(M.BRIDGE_DST_DENOM),quantity:localStorage.getItem(M.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(M.BRIDGE_SLIPPAGE_PERCENT)});return{...s?r:o,...a,...t}}function po(){const{initiaAddress:t,hexAddress:s}=pe(),n=ot(),r=Kt();return o=>{const a=n(o);switch(r(a)){case"initia":return t;case"evm":return s;default:return""}}}function rn(){const t=ot(),s=Kt();return(n,r)=>{const o=t(r);switch(s(o)){case"initia":return y.InitiaAddress.validate(n);case"evm":return nt.isAddress(n);case"cosmos":try{return L.fromBech32(n).prefix===o.bech32_prefix}catch{return!1}default:return!1}}}function ym(){const t=ot(),s=Kt();return({initialAddress:n,initialChainId:r,chainId:o,fallbackAddress:a})=>{const i=t(r),l=s(i),c=t(o),d=s(c);if(l==="evm"&&d==="initia")return y.InitiaAddress(n).bech32;if(l==="initia"&&d==="evm")return y.InitiaAddress(n).hex;if(l===d)return n;if(a){if(d==="initia")return y.InitiaAddress(a).bech32;if(d==="evm")return y.InitiaAddress(a).hex}return""}}const jm=[["d",1440*60],["h",3600],["m",60],["s",1]];function on(t){if(!t)return;const{formattedParts:s}=jm.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:t,formattedParts:[]});return s.join(" ")}function go(t){return t?.map(s=>{const{amount:n,origin_asset:r}=s;return`${y.formatAmount(n,{decimals:r.decimals??0})} ${r.symbol}`}).join(", ")}function Qn(t,s){const{watch:n}=He(),r=n(),o=Ke(),a={...r,quantity:t},i=$.useQueryClient();return $.useQuery({queryKey:fe.route(a,s?.isOpWithdraw).queryKey,queryFn:()=>{const{srcChainId:l,srcDenom:c,quantity:d,dstChainId:u,dstDenom:m}=a,{decimals:h}=i.getQueryData(fe.asset(l,c).queryKey)??{decimals:0},f={amount_in:y.toBaseUnit(d,{decimals:h}),source_asset_chain_id:l,source_asset_denom:c,dest_asset_chain_id:u,dest_asset_denom:m,is_op_withdraw:s?.isOpWithdraw};return o.post("v2/fungible/route",{json:f}).json()},enabled:!!Number(a.quantity)&&!s?.disabled,staleTime:U.MINUTE})}function bm(t){return $.useQuery({queryKey:fe.routeErrorInfo(t||new Error).queryKey,queryFn:async()=>{if(!t||!(t instanceof G.HTTPError))return null;const{response:s}=t;return(s.headers.get("content-type")??"").includes("application/json")?(await s.json()).info??null:null}})}function vm(){const{watch:t}=He(),{srcChainId:s,srcDenom:n,dstChainId:r,dstDenom:o}=t(),a=Ie(s),i=Rt(a),l=Ee(n,s),c=Ee(o,r),d=je(),u=ze();return i==="initia"&&r===d.chainId&&l.symbol===c.symbol&&u.find(m=>m.chainId===s)?.metadata?.op_denoms?.includes(c.denom)}var an=(t=>(t.FEE_BEHAVIOR_DEDUCTED="FEE_BEHAVIOR_DEDUCTED",t.FEE_BEHAVIOR_ADDITIONAL="FEE_BEHAVIOR_ADDITIONAL",t))(an||{});function In(t,s){const n=Ke();return $.useQuery({queryKey:fe.balances(s,t).queryKey,queryFn:()=>n.post("v2/info/balances",{json:{chains:{[s]:{address:t,denoms:[]}}}}).json(),select:({chains:r})=>t?r?r[s].denoms??{}:{}:{},enabled:!!t,staleTime:U.SECOND})}function wm(t,s,n){const{data:r={}}=In(t,s);return E.path([n],r)}const Cm=({address:t,chain:s,onSelect:n})=>{const r=ht(s.chain_id),{data:o={}}=In(t,s.chain_id);return e.jsx(Lt,{assets:E.sortWith([E.descend(a=>a.symbol==="INIT"),E.descend(a=>a.value),({balance:a="0"},{balance:i="0"})=>F(i).comparedTo(a)??0,E.ascend(a=>a.symbol.toLowerCase())],r.filter(a=>!a.hidden).map(a=>{const{denom:i,symbol:l=y.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})},Im=({type:t,afterSelect:s})=>{const n=t==="src"?"srcChainId":"dstChainId",r=t==="src"?"srcDenom":"dstDenom",o=t==="src"?"sender":"recipient",a=yt(),i=gn(),{watch:l,setValue:c,trigger:d}=He(),u=l("quantity"),m=l(o),h=l(n),[f,p]=_.useState(h),g=Ie(f),C=ym(),S=Dr(),[I,P]=E.partition(x=>S(x.chain_id),i.filter(x=>!x.hidden)),A=x=>{c(n,f),c(r,x),Number(u)&&d(),s()};return e.jsxs(e.Fragment,{children:[e.jsxs(st.Stack,{children:[e.jsx(st,{label:"Interwoven Economy",chains:I.map(({chain_id:x,chain_name:k,pretty_name:v,logo_uri:w})=>({chainId:x,name:v||k,logoUrl:w??""})),value:f,onSelect:p}),e.jsx(st,{label:"Chains",chains:P.map(({chain_id:x,chain_name:k,pretty_name:v,logo_uri:w})=>({chainId:x,name:v||k,logoUrl:w??""})),value:f,onSelect:p})]}),e.jsx(se,{suspenseFallback:e.jsx(Lt.Placeholder,{}),children:e.jsx(Cm,{address:C({initialAddress:m,initialChainId:h,chainId:f,fallbackAddress:t==="src"?a:void 0}),chain:g,onSelect:A})},f)]})},Vn=({type:t})=>{const s=t==="src"?"srcChainId":"dstChainId",n=t==="src"?"srcDenom":"dstDenom",r=t==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:o}=He(),a=o(s),i=o(n),l=Ie(a),c=Ee(i,a);return e.jsx(rt,{title:r,content:d=>e.jsx(Im,{type:t,afterSelect:d}),children:e.jsx(lo,{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 vs(){const t=[{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:t,find:n=>t.find(r=>r.name===n)}}const Nm="_account_iwrlj_8",Sm="_clear_iwrlj_27",km="_white_iwrlj_38",$t={account:Nm,clear:Sm,white:km},Gn=({type:t})=>{const{watch:s,setValue:n}=He(),{srcChainId:r,dstChainId:o,cosmosWalletName:a}=s(),l=s(t==="src"?"sender":"recipient"),c=Rt(Ie(o)),{list:d,find:u}=vs(),m=u(a),h=po(),f=rn(),p=h(o),g=y.InitiaAddress.equals(l,p),C=()=>e.jsx(rt,{title:"Connect wallet",content:P=>e.jsx(ro,{onSelect:async A=>{const x=A.getProvider();if(!x)return window.open(A.fallbackUrl,"_blank");const k=x.getOfflineSigner(r),[{address:v}]=await k.getAccounts();n("sender",v),n("cosmosWalletName",A.name),P()},list:d,getImage:A=>A.image,getName:A=>A.name,getKey:A=>A.name}),className:D($t.account,{[$t.white]:!l}),children:l?e.jsxs(e.Fragment,{children:[m&&e.jsx(W,{src:m.image,width:18,height:18}),e.jsx("span",{className:"monospace",children:y.truncate(l)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"Connect wallet"}),e.jsx(b.IconChevronRight,{size:14})]})}),S=P=>e.jsx(rt,{title:"Recipient",content:A=>e.jsx(qe,{children:e.jsx(vn,{mode:"onSubmit",myAddress:p,chainType:c,validate:x=>f(x,o),onApply:A})}),className:$t.account,children:P}),I=()=>{switch(c){case"initia":case"evm":return g?S(e.jsx(b.IconWallet,{size:14})):e.jsxs("div",{className:$t.account,children:[e.jsx("span",{className:"monospace",children:y.truncate(l)}),e.jsx("button",{type:"button",className:$t.clear,onClick:()=>n("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:e.jsx(b.IconCloseCircleFilled,{size:14})})]});case"cosmos":return S(e.jsxs(e.Fragment,{children:[l?e.jsx("span",{className:"monospace",children:y.truncate(l)}):e.jsx("span",{children:"Recipient"}),e.jsx(b.IconEdit,{size:14})]}))}};switch(t){case"src":return C();case"dst":return I()}},$m="_description_l5bcv_1",Am="_presets_l5bcv_8",Em="_preset_l5bcv_8",Tm="_active_l5bcv_29",qm="_custom_l5bcv_40",Dm="_wrapper_l5bcv_46",Pm="_percent_l5bcv_49",ve={description:$m,presets:Am,preset:Em,active:Tm,custom:qm,wrapper:Dm,percent:Pm},Yn=["0.1","0.5","1.0"],Rm=({afterConfirm:t})=>{const s=He(),n=s.getValues("slippagePercent"),[r,o]=_.useState(null),{control:a,watch:i,getValues:l,setValue:c}=oe.useForm({defaultValues:{value:n}}),d=i("value");_.useEffect(()=>{const g=Yn.findIndex(C=>C===n);o(g>=0?g:null)},[n]);const u=(g,C)=>{c("value",g),o(C)},m=()=>{o(null)},h=_.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.5?{type:"warning",text:"Your transaction may fail"}:null,[d]),f=h?.type==="error",p=({value:g})=>{s.setValue("slippagePercent",g),t()};return e.jsxs(qe,{children:[e.jsx("p",{className:ve.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."}),e.jsxs("div",{className:ve.presets,children:[Yn.map((g,C)=>e.jsxs("button",{type:"button",className:D(ve.preset,{[ve.active]:r===C}),onClick:()=>u(g,C),children:[g,"%"]},g)),r!==null?e.jsx("button",{type:"button",className:D(ve.preset,ve.custom),onClick:()=>o(null),children:"Custom"}):e.jsxs("div",{className:ve.wrapper,children:[e.jsx(mo,{name:"value",control:a,dp:2,onFocus:m,placeholder:"",className:D(ve.preset,ve.active)}),e.jsx("span",{className:ve.percent,children:"%"})]})]}),h&&e.jsx(ee,{level:h.type,children:h.text}),e.jsx(ne,{children:e.jsx(H.White,{type:"button",onClick:()=>p(l()),disabled:f,children:"Confirm"})})]})},Fm="_stack_hvmmo_1",Bm="_button_hvmmo_6",Mm="_checked_hvmmo_14",Om="_checkmark_hvmmo_20",zm="_inner_hvmmo_30",Um="_info_hvmmo_42",Km="_duration_hvmmo_51",Lm="_amount_hvmmo_61",Hm="_symbol_hvmmo_71",Ae={stack:Fm,button:Bm,checked:Mm,checkmark:Om,inner:zm,info:Um,duration:Km,amount:Lm,symbol:Hm},Wm=({children:t})=>e.jsx("div",{className:Ae.stack,children:t}),os=({label:t,query:s,value:n,onSelect:r,checked:o})=>{const{data:a,isLoading:i}=s,{watch:l}=He(),{dstChainId:c,dstDenom:d}=l(),u=Ee(d,c);return e.jsxs("button",{type:"button",className:D(Ae.button,{[Ae.checked]:o}),onClick:()=>r(n),children:[e.jsx("div",{className:Ae.checkmark,children:o&&e.jsx("span",{className:Ae.inner})}),e.jsxs("div",{className:Ae.info,children:[e.jsx("div",{children:t}),e.jsxs("div",{className:Ae.duration,children:[e.jsx(b.IconClockFilled,{size:12}),a?on(a.estimated_route_duration_seconds):"Not available"]})]}),e.jsx("div",{className:Ae.amount,children:i?e.jsx(Le,{size:14}):a?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:y.formatAmount(a.amount_out,{decimals:u.decimals})}),e.jsx("span",{className:Ae.symbol,children:u.symbol})]}):null})]})};os.Stack=Wm;const Qm="_form_lelld_1",Vm="_arrow_lelld_5",Gm="_divider_lelld_13",Ym="_flip_lelld_21",Jm="_meta_lelld_37",Zm="_row_lelld_50",Xm="_title_lelld_56",eh="_description_lelld_60",th="_icon_lelld_67",sh="_edit_lelld_72",nh="_warning_lelld_93",Z={form:Qm,arrow:Vm,divider:Gm,flip:Ym,meta:Jm,row:Zm,title:Xm,description:eh,icon:th,edit:sh,warning:nh},rh=()=>{const t=ie(),s=xs(),[n,r]=de.useLocalStorage(M.BRIDGE_ROUTE_TYPE,"default"),{watch:o,setValue:a,handleSubmit:i,trigger:l,formState:c}=He(),d=o(),{srcChainId:u,srcDenom:m,dstChainId:h,dstDenom:f,quantity:p,sender:g,slippagePercent:C}=d,S=Te(),I=Ie(u),P=Rt(I),A=Ie(h),x=Rt(A),k=Ee(m,u),v=Ee(f,h),{data:w}=In(g,u),j=wm(g,u,m);_.useEffect(()=>{Number(p)&&l()},[j,p,l]);const[q]=de.useDebounceValue(p,300),O=P!=="initia"&&x!=="initia",T=vm(),N=Qn(q,{disabled:O}),K=Qn(q,{isOpWithdraw:!0,disabled:!T}),Q=T&&n==="op"?K:N,{data:J,isLoading:Se,isFetching:be,isFetched:ke,error:We}=Q,{data:it}=bm(We),[ue,re]=_.useState(J);_.useEffect(()=>{J&&re({...J,amount_out:"0",usd_amount_in:"0",usd_amount_out:"0"})},[J]),_.useEffect(()=>{re(void 0)},[u,m,h,f]);const B=ke?J:q&&!We?ue:void 0,Ht=q&&(Se||be),Is=()=>{a("srcChainId",h),a("srcDenom",f),a("dstChainId",u),a("dstDenom",m),Number(p)&&l()},{openModal:ko,closeModal:Nn}=Ot(),$o=i(z=>{if(B?.warning){const{type:wt="",message:ks}=B.warning??{};ko({content:e.jsx(Jr,{type:"warning",icon:e.jsx(b.IconWarningFilled,{size:40}),title:Bt.sentenceCase(wt),primaryButton:{label:"Cancel",onClick:Nn},secondaryButton:{label:"Proceed anyway",onClick:()=>{t("/bridge/preview",{route:B,values:z}),Nn()}},children:e.jsx("p",{className:Z.warning,children:ks})})});return}t("/bridge/preview",{route:B,values:z})}),Ao=_.useMemo(()=>B?.estimated_fees?.filter(({fee_behavior:z})=>z===an.FEE_BEHAVIOR_DEDUCTED)??[],[B]),Ns=_.useMemo(()=>B?.estimated_fees?.filter(({fee_behavior:z})=>z===an.FEE_BEHAVIOR_ADDITIONAL)??[],[B]),Ss=_.useMemo(()=>{for(const z of Ns){const wt=w?.[z.origin_asset.denom]?.amount??"0",ks=B?.source_asset_denom===z.origin_asset.denom?B.amount_in:"0";if(F(wt).lt(F(ks).plus(z.amount??"0")))return`Insufficient ${z.origin_asset.symbol} for fees`}},[w,B,Ns]),Sn=_.useMemo(()=>{if(!d.sender)return"Connect wallet";if(!d.quantity||!q)return"Enter amount";if(!d.recipient)return"Enter recipient address";if(c.errors.quantity)return c.errors.quantity.message;const z=fo.safeParse(d);if(!z.success)return`Invalid ${z.error.issues[0].path}`;if(!B)return"Route not found";if(Ss)return Ss},[q,Ss,c,B,d]),Eo=B?y.formatAmount(B.amount_out,{decimals:v.decimals}):"0",To=F(p).gt(0)&&F(p).isEqualTo(y.fromBaseUnit(j?.amount,{decimals:j?.decimals??0})),qo=(()=>{switch(P){case"initia":return S(u).fees.fee_tokens.some(({denom:z})=>z===m);case"cosmos":return I.fee_assets.some(({denom:z})=>z===m);case"evm":return!nt.isAddress(m);default:return!1}})(),kn=(z,wt)=>z.length?e.jsxs("div",{className:Z.description,children:[go(z),!s&&e.jsx(jt,{label:wt,children:e.jsx("span",{className:Z.icon,children:e.jsx(b.IconInfoFilled,{size:12})})})]}):null;return e.jsxs("form",{className:Z.form,onSubmit:$o,children:[e.jsx(sn,{selectButton:e.jsx(Vn,{type:"src"}),accountButton:P==="cosmos"&&e.jsx(Gn,{type:"src"}),quantityInput:e.jsx(ls,{}),balanceButton:e.jsx(uo,{onClick:()=>a("quantity",y.fromBaseUnit(j?.amount,{decimals:k?.decimals??0}),{shouldValidate:!0}),children:y.formatAmount(j?.amount??"0",{decimals:k.decimals})}),value:B?B.usd_amount_in?Ft(B.usd_amount_in):"$-":"$0"}),e.jsxs("div",{className:Z.arrow,children:[e.jsx("div",{className:Z.divider}),e.jsx("button",{type:"button",className:Z.flip,onClick:()=>Is(),children:e.jsx(b.IconChevronDown,{size:16})})]}),e.jsx(sn,{selectButton:e.jsx(Vn,{type:"dst"}),accountButton:e.jsx(Gn,{type:"dst"}),quantityInput:e.jsx(ls.ReadOnly,{children:Eo}),value:B?B.usd_amount_out?Ft(B.usd_amount_out):"$-":"$0"}),e.jsx(ne,{extra:e.jsxs(e.Fragment,{children:[e.jsx(Zs,{children:F(p).gt(0)&&T?e.jsxs(os.Stack,{children:[e.jsx(os,{label:"Minitswap",query:N,value:"default",onSelect:r,checked:n==="default"}),e.jsx(os,{label:"OP Bridge",query:K,value:"op",onSelect:r,checked:n==="op"})]}):null}),e.jsxs(ee.Stack,{children:[B?.extra_infos?.map(z=>e.jsx(ee,{level:"info",children:z},z)),it&&e.jsx(ee,{level:"info",children:it}),To&&qo&&e.jsx(ee,{level:"warning",children:"Make sure to leave enough for transaction fee"}),B?.warning&&e.jsx(ee,{level:"warning",children:B.warning.message}),B?.extra_warnings?.map(z=>e.jsx(ee,{level:"warning",children:z},z))]}),e.jsx(Zs,{children:B&&e.jsxs("div",{className:Z.meta,children:[!!B.estimated_fees?.length&&e.jsxs("div",{className:Z.row,children:[e.jsx("span",{className:Z.title,children:"Fees"}),e.jsxs("div",{children:[kn(Ao,"Fee deducted from the amount you receive"),kn(Ns,"Fee charged in addition to the amount you enter")]})]}),on(B.estimated_route_duration_seconds)&&e.jsxs("div",{className:Z.row,children:[e.jsx("span",{className:Z.title,children:"Estimated time"}),e.jsx("span",{className:Z.description,children:on(B.estimated_route_duration_seconds)})]}),B.does_swap&&e.jsxs("div",{className:Z.row,children:[e.jsx("span",{className:Z.title,children:"Slippage"}),e.jsxs("span",{className:Z.description,children:[e.jsxs("span",{children:[C,"%"]}),e.jsx(rt,{title:"Slippage tolerance",content:z=>e.jsx(Rm,{afterConfirm:z}),className:Z.edit,children:e.jsx(b.IconSettingFilled,{size:12})})]})]})]})})]}),children:e.jsx(H.White,{loading:Ht&&"Simulating...",disabled:!!Sn,children:Sn??"Preview route"})})]})},oh=()=>{Zr();const t=Ho(),s=ie(),{closeDrawer:n}=xt(),r=yt(),o=xm(),a=rn(),i=$.useQueryClient(),l=oe.useForm({mode:"onChange",defaultValues:o,resolver:mn.zodResolver(fo.superRefine(({srcChainId:T,srcDenom:N,quantity:K,sender:Q},J)=>{const Se=i.getQueryData(fe.balances(T,Q).queryKey),be=E.pathOr("0",["chains",T,"denoms",N,"amount"],Se),{decimals:ke}=i.getQueryData(fe.asset(T,N).queryKey)??{decimals:0};io({quantity:K,balance:be,decimals:ke},J)}).superRefine(({dstChainId:T,recipient:N},K)=>{if(!a(N,T)){K.addIssue({code:V.z.ZodIssueCode.custom,message:"Invalid address",path:["recipient"]});return}}))}),{watch:c,setValue:d}=l,{srcChainId:u,dstChainId:m,srcDenom:h,dstDenom:f,quantity:p,slippagePercent:g,recipient:C}=c();c((T,{name:N})=>{(N==="srcChainId"||N==="srcDenom")&&d("quantity","")});const S=po(),I=S(u),P=S(m),x=rn()(C,m);_.useEffect(()=>{d("cosmosWalletName",void 0),d("sender",I)},[u,I,d]),_.useEffect(()=>{x||d("recipient",P)},[P,x,d]);const k=ht(u),v=ht(m),w=_.useMemo(()=>{if(!k.find(T=>T.denom===h))return`${h} is not available for bridge/swap on ${u}`;if(!v.find(T=>T.denom===f))return`${f} is not available for bridge/swap on ${m}`},[v,m,f,k,u,h]);_.useEffect(()=>{w||(localStorage.setItem(M.BRIDGE_SRC_CHAIN_ID,u),localStorage.setItem(M.BRIDGE_SRC_DENOM,h),localStorage.setItem(M.BRIDGE_DST_CHAIN_ID,m),localStorage.setItem(M.BRIDGE_DST_DENOM,f),localStorage.setItem(M.BRIDGE_QUANTITY,p),localStorage.setItem(M.BRIDGE_SLIPPAGE_PERCENT,g))},[u,h,m,f,p,g,w]);const j=t[0].path==="/bridge",q=()=>e.jsxs(e.Fragment,{children:[e.jsx(ae,{error:!0,children:w}),e.jsx(ne,{children:j?e.jsx(H.White,{onClick:n,children:"Close"}):e.jsx(H.White,{onClick:()=>s(-1),children:"Go back"})})]}),{reminders:O}=bt();return e.jsx(De,{title:"Bridge/Swap",returnTo:j?!1:"/",extra:e.jsxs(e.Fragment,{children:[e.jsx(H.Small,{onClick:()=>s("/bridge/history"),unpadded:!0,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[e.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"}),e.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),e.jsx(ho,{offset:0,disabled:O.length===0,children:e.jsx(H.Small,{onClick:()=>s("/op/withdrawals"),disabled:!r,children:e.jsx("span",{children:"Withdrawal status"})})})]}),children:w?q():e.jsx(oe.FormProvider,{...l,children:e.jsx(se,{children:e.jsx(rh,{})})})})},at=Ne.createQueryKeys("interwovenkit:op",{bridge:t=>[t],withdrawals:(t,s)=>[t,s],latestOutput:t=>[t],output:(t,s)=>[t,s],outputResponse:(t,s)=>[t,s],withdrawalClaimed:(t,s)=>[t,s]});function ws(){const{restUrl:t}=je();return _.useMemo(()=>G.create({prefixUrl:t}),[t])}function ah(t){const s=ws(),{data:n}=$.useSuspenseQuery({queryKey:at.bridge(t).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${t}`).json(),staleTime:U.INFINITY});return n}const Jn=20;function ih(t){const s=Y();return $.useSuspenseInfiniteQuery({queryKey:at.withdrawals(t,s).queryKey,queryFn:async({pageParam:n})=>{if(!s)return[];const r={limit:Jn,offset:n,order:"desc"},{withdrawals:o}=await G.create({prefixUrl:t}).get(`withdrawals/${s}`,{searchParams:r}).json();return o},getNextPageParam:n=>{const r=E.last(n)?.sequence;return n.length<Jn||!r||r<=1?null:r-1},initialPageParam:0,staleTime:U.SECOND})}function ch(t){const s=ws(),{data:n}=$.useSuspenseQuery({queryKey:at.latestOutput(t).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${t}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:r})=>{const[o]=r;return o||null},staleTime:U.SECOND});return n}function lh({bridge_id:t,output_index:s}){const n=ws(),{data:r}=$.useSuspenseQuery({queryKey:at.output(t,s).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${t}/outputs/${s}`).json()}catch{return null}},staleTime:U.SECOND});return r}function dh({bridge_id:t,sequence:s}){const r=ze().find(({metadata:c})=>c?.op_bridge_id===t.toString())?.chain_id;if(!r)throw new Error(`Chain not found for bridge_id: ${t}`);const a=Te()(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}=$.useSuspenseQuery({queryKey:at.outputResponse(i,s).queryKey,queryFn:()=>G.create({prefixUrl:i}).get(`withdrawal/${s}`).json(),staleTime:U.SECOND});return l}function xo(t,s){const{bridge_id:n}=t,r=ws(),{data:o}=$.useSuspenseQuery({queryKey:at.withdrawalClaimed(n,s).queryKey,queryFn:()=>r.get(`opinit/ophost/v1/bridges/${n}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:s}}).json(),select:({claimed:a})=>a,staleTime:({state:{data:a}})=>a?.claimed?1/0:U.SECOND});return o}function At(t){return Oo.sha3_256.create().update(t).digest()}function Ws(t,s){const n=new ArrayBuffer(s);return new DataView(n).setBigUint64(0,BigInt(t),!1),new Uint8Array(n)}function yo(t){const{bridge_id:s,sequence:n,amount:r,from:o,to:a}=t,i=Ws(s.toString(),8),l=Ws(n.toString(),8),c=Ws(r.amount,8),d=Wt.concatBytes(i,l,At(Wt.toBytes(o)),At(Wt.toBytes(a)),At(Wt.toBytes(r.denom)),c);return At(At(d))}const jo=_.createContext(null);function Cs(){return _.useContext(jo)}const uh="_asset_6h8u2_1",mh="_info_6h8u2_7",hh="_symbol_6h8u2_11",Qs={asset:uh,info:mh,symbol:hh},_h=({amount:t,denom:s})=>{const n=je(),r=fn(s,n),{symbol:o,logoUrl:a,decimals:i}=r;return e.jsxs("div",{className:Qs.asset,children:[e.jsx(W,{src:a,width:32,height:32}),e.jsxs("div",{className:Qs.info,children:[e.jsx("span",{className:"monospace",children:y.formatAmount(t,{decimals:i})}),e.jsx("span",{className:Qs.symbol,children:o})]})]})},fh=({children:t})=>{const{withdrawalTx:s}=Cs(),n=ch(s.bridge_id),r=s.output_index>Number(n?.output_index);return t(r)},ph="_container_1oldz_1",gh="_icon_1oldz_7",Zn={container:ph,icon:gh},xh="Withdrawal will begin within an hour",Xn=()=>{const t=xs();return e.jsxs("div",{className:Zn.container,children:[e.jsx("span",{children:"In progress"}),!t&&e.jsx(jt,{label:xh,children:e.jsx("span",{className:Zn.icon,children:e.jsx(b.IconInfoFilled,{size:12})})})]})},bo=1e3,yh=60,jh=60,bh=24,cn=bo*yh,ln=cn*jh,er=ln*bh,vh=({date:t})=>{const s=_.useCallback(()=>{const d=new Date().getTime(),m=t.getTime()-d;if(m<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(m/er),f=Math.floor(m%er/ln),p=Math.floor(m%ln/cn),g=Math.floor(m%cn/bo);return{days:h,hours:f,minutes:p,seconds:g}},[t]),[n,r]=_.useState(s());_.useEffect(()=>{const d=window.setInterval(()=>{r(s())},1e3);return()=>window.clearInterval(d)},[s,t]);const o=d=>d.toString().padStart(2,"0"),{days:a,hours:i,minutes:l,seconds:c}=n;return e.jsx(jt,{label:t.toLocaleString(),children:e.jsxs("span",{className:"monospace",children:[a,"d ",o(i),"h ",o(l),"m ",o(c),"s"]})})},wh="_container_1lz3w_1",Ch="_title_1lz3w_5",tr={container:wh,title:Ch},Ih=({date:t})=>e.jsxs("div",{className:tr.container,children:[e.jsx("div",{className:tr.title,children:"Claimable in"}),e.jsx(vh,{date:t})]}),Nh=({children:t})=>{const{withdrawalTx:s}=Cs(),n=ah(s.bridge_id),r=lh(s),o=_.useMemo(()=>{if(!r)return null;const{bridge_config:a}=n,{output_proposal:i}=r;return ft.addSeconds(new Date(i.l1_block_time),parseFloat(a.finalization_period))},[n,r]);return t(o)},Sh=({date:t,children:s})=>{const{chainId:n,withdrawalTx:r}=Cs(),o=L.toBase64(yo(r)),a=xo(r,o),{setReminder:i,removeReminder:l}=bt();return _.useEffect(()=>{const c={chainId:n,txHash:r.tx_hash};a?l(c):i(c,{...c,recipient:r.to,claimableAt:t.getTime(),amount:r.amount.amount,denom:r.amount.denom,dismissed:ft.isPast(t.getTime())?!0:void 0})},[n,a,t,l,i,r]),s},kh="_button_1btdg_1",$h="_claimed_1btdg_23",sr={button:kh,claimed:$h},Ah=()=>{const{withdrawalTx:t}=Cs(),{bridge_id:s,sequence:n,amount:r,output_index:o,withdrawal_proofs:a,storage_root:i,from:l,to:c,version:d}=t,u=je(),m=Y(),{requestTxSync:h,waitForTxConfirmation:f}=pe(),p=dh(t),g=L.toBase64(yo(t)),C=xo(t,g),S=$.useQueryClient(),{mutate:I,isPending:P}=$.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:A}=p;return h({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:zo.MsgFinalizeTokenWithdrawal.fromPartial({sender:m,bridgeId:BigInt(s),outputIndex:BigInt(o),withdrawalProofs:a.map(L.fromBase64),from:l,to:c,sequence:BigInt(n),amount:r,version:L.fromBase64(d),storageRoot:L.fromBase64(i),lastBlockHash:L.fromBase64(A)})}],internal:!0})},onSuccess:async A=>{await f({chainId:u.chain_id,txHash:A}),S.invalidateQueries({queryKey:at.withdrawalClaimed(s,g).queryKey})}});return C?e.jsxs("div",{className:sr.claimed,children:[e.jsx(b.IconCheckCircleFilled,{size:14}),e.jsx("span",{children:"Claimed"})]}):e.jsx("button",{className:sr.button,onClick:()=>I(),disabled:P,children:"Claim"})},Eh=()=>e.jsx(fh,{children:t=>t?e.jsx(Xn,{}):e.jsx(Nh,{children:s=>s?e.jsx(Sh,{date:s,children:ft.isFuture(s)?e.jsx(Ih,{date:s}):e.jsx(Ah,{})}):e.jsx(Xn,{})})}),Th="_item_km5w2_1",qh={item:Th},Dh=({chain:t})=>{const s=t.metadata?.executor_uri;if(!s)throw new Error("Executor URL is not defined");const{data:n,fetchNextPage:r,hasNextPage:o,isFetching:a}=ih(s),i=_.useMemo(()=>n?.pages.flat()??[],[n]),{syncReminders:l}=bt();return _.useEffect(()=>{const c=i.map(d=>({chainId:t.chainId,txHash:d.tx_hash}));l(c)},[t.chainId,i,l]),i.length?e.jsxs(e.Fragment,{children:[i.map(c=>{const{amount:d}=c;return e.jsxs("div",{className:qh.item,children:[e.jsx(_h,{...d}),e.jsx(se,{suspenseFallback:null,children:e.jsx(jo.Provider,{value:{chainId:t.chainId,withdrawalTx:c},children:e.jsx(Eh,{})})})]},c.sequence)}),o&&e.jsx(Cn,{onClick:()=>r(),disabled:a})]}):e.jsx(ae,{children:"No withdrawals"})},Ph="_content_dj1qm_1",Rh="_title_dj1qm_5",nr={content:Ph,title:Rh},Fh=()=>{const{chainId:t}=Me(),s=ze(),n=zt(),[r,o]=_.useState(t??(n.metadata?.is_l1?"":n.chainId)),a=Te(),{reminders:i}=bt(),l=r?a(r):void 0;return e.jsxs(De,{title:"OP Bridge withdrawals",children:[e.jsx(st,{chains:s.filter(({metadata:c})=>!c?.is_l1&&c?.op_denoms?.length),value:r,onSelect:o,getShowIndicator:c=>i.some(d=>d.chainId===c)}),e.jsx("div",{className:nr.content,children:l?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:nr.title,children:l.name}),e.jsx(se,{children:e.jsx(Dh,{chain:l})},r)]}):e.jsx(ee,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})};async function Bh(t,s){const n=G.create({prefixUrl:s}),r=`cosmos/auth/v1beta1/account_info/${t}`;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: ${t} not found`)}const as=({chainId:t,txHash:s})=>`${M.BRIDGE_HISTORY}:${t}:${s}`,ds=100,rr=10;function vo(){const[t,s]=de.useLocalStorage(M.BRIDGE_HISTORY,[]),n=_.useCallback((o,a)=>{localStorage.setItem(as(o),JSON.stringify(a));for(const i of t.slice(ds-1))localStorage.removeItem(as(i));s((i=[])=>[o,...i.slice(0,ds-1)])},[t,s]),r=_.useCallback(o=>{const a=localStorage.getItem(as(o));return a?JSON.parse(a):null},[]);return{history:t,addHistoryItem:n,getHistoryDetails:r}}function wo(t){return de.useLocalStorage(as(t),null)}async function Co(t,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 t.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}catch(l){if(E.path(["error","code"],l)!==4902)throw l;if(!a)throw new Error(`Fee asset is not defined for chain: ${o}`);await t.send("wallet_addEthereumChain",[{chainId:`0x${Number(r).toString(16)}`,chainName:o,nativeCurrency:a,rpcUrls:[i]}]),await t.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}}function vt(){return Me()}function Mh(t){const s=ie(),{showNotification:n,updateNotification:r,hideNotification:o}=Fr(),{addHistoryItem:a}=vo(),{route:i,values:l}=vt(),{srcChainId:c,sender:d,recipient:u,cosmosWalletName:m}=l,h=wr(),{requestTxSync:f,waitForTxConfirmation:p}=pe(),{find:g}=vs(),C=_s(),S=fs(),I=Ie(c),P=Rt(I),A=Pr(c),x=$.useQueryClient(),{registryUrl:k}=te(),v=Te(),{addReminder:w}=bt();return $.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in t){if(!t.cosmos_tx.msgs)throw new Error("Invalid transaction data");const j=t.cosmos_tx.msgs.map(({msg_type_url:ue,msg:re})=>{if(!(ue&&re))throw new Error("Invalid transaction data");return S.fromAmino({type:Tt.aminoConverters[ue].aminoType,value:JSON.parse(re)})});if(P==="initia"){const{srcDenom:ue,quantity:re}=l,{decimals:B}=A(ue),Ht=await f({messages:j,chainId:c,internal:1,spendCoins:[{denom:ue,amount:y.toBaseUnit(re,{decimals:B})}]}),Is=p({txHash:Ht,chainId:c});return{txHash:Ht,wait:Is}}const q=g(m)?.getProvider();if(!q)throw new Error("Wallet not connected");const O=q.getOfflineSignerOnlyAmino(c),T=await Ce.SigningStargateClient.connectWithSigner(I.rpc,O,{registry:C,aminoTypes:S}),N=await T.getAllBalances(d),K=I.fee_assets.find(ue=>N.some(re=>re.denom===ue.denom&&F(re.amount).gt(0)));if(!K){const re=["Insufficient balance for fees.",`Available fee assets: ${I.fee_assets.map(B=>A(B.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(re)}const{denom:Q,gas_price:J}=K;if(!J)throw new Error(`Gas price not found for ${Q}`);const Se=await T.simulate(d,j,""),be=Ce.GasPrice.fromString(J.average+Q),ke=Ce.calculateFee(Math.ceil(Se*qt),be),We=await T.signAndBroadcastSync(d,j,ke),it=kr({txHash:We,client:T});return{txHash:We,wait:it}}if("evm_tx"in t){const{chain_id:j,to:q,value:O,data:T}=t.evm_tx,N=await h(),K=await N.getSigner();await Co(N,I);const Q=await K.sendTransaction({chainId:j,to:q,value:O,data:`0x${T}`});return{txHash:Q.hash,wait:Q.wait()}}throw new Error("Unsupported chain type")}catch(j){throw new Error(await Oe(j))}},onSuccess:({txHash:j,wait:q})=>{localStorage.removeItem(M.BRIDGE_QUANTITY),s(-1),n({type:"loading",title:"Transaction is pending..."}),q.then(()=>{const O={chainId:c,txHash:j},T=Io(i)==="OP Bridge withdrawal";a(O,{...O,timestamp:Date.now(),route:i,values:l,state:T?"success":void 0}),r({type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(Mt,{to:"/bridge/history",onClick:o},"the activity page")," for transaction status"),autoHide:!0}),T&&w(O,{...O,recipient:y.InitiaAddress(u).bech32,claimableAt:Date.now()+i.estimated_route_duration_seconds*1e3,amount:i.amount_out,denom:i.dest_asset_denom})}).catch(O=>{r({type:"error",title:"Transaction failed",description:O.message})}).finally(()=>{x.invalidateQueries({queryKey:fe.balances(c,d).queryKey})})},onError:async j=>{const q=P==="initia"?await Js(j,v(c),k):j;n({type:"error",title:"Transaction failed",description:q.message})}})}function Oh(){const t=Ke(),s=Y(),n=jr(),{route:r,values:o}=vt(),a=ot();return $.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:l}=await t.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:y.InitiaAddress(o.recipient).bech32,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom}}).json();await Bh(s,a(r.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:m,msg:h})=>Tt.aminoTypes.fromAmino({type:Tt.aminoConverters[m].aminoType,value:JSON.parse(h)})),d=await n(i,s,c,{amount:[],gas:"1"},""),u=mt.Tx.fromPartial({body:mt.TxBody.decode(d.bodyBytes),authInfo:mt.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:s,hook:L.toBase64(mt.Tx.encode(u).finish())}}catch(i){throw new Error(await Oe(i))}}})}function zh(t){const{chainId:s,txHash:n,tracked:r}=t,o=Ke();return $.useQuery({queryKey:fe.txTrack(s,n).queryKey,queryFn:async()=>{try{return await o.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json()}catch(a){throw new Error(await Oe(a))}},select:({tx_hash:a})=>a,retry:6,retryDelay:5e3,staleTime:U.INFINITY,enabled:!r})}function Uh(t){const{timestamp:s,chainId:n,txHash:r,tracked:o,state:a}=t,i=Ke();return $.useQuery({queryKey:fe.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+t.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:U.INFINITY})}var is=(t=>(t.OP_WITHDRAW="OP Bridge withdrawal",t.SKIP="Skip",t))(is||{});function Io(t){const{operations:s,dest_asset_denom:n}=t;return E.has("op_init_transfer",E.head(s))&&n==="uinit"?"OP Bridge withdrawal":"Skip"}const Kh="_content_c0tee_1",Lh="_info_c0tee_6",Hh="_arrow_c0tee_11",Wh="_divider_c0tee_19",Qh="_type_c0tee_26",Vh="_asset_c0tee_44",Gh="_amount_c0tee_52",Yh="_lower_c0tee_57",Jh="_chain_c0tee_63",Zh="_address_c0tee_69",he={content:Kh,info:Lh,arrow:Hh,divider:Wh,type:Qh,asset:Vh,amount:Gh,lower:Yh,chain:Jh,address:Zh},No=t=>{const{source:s,label:n,amount:r,denom:o,chainId:a,address:i,walletIcon:l}=t,{symbol:c=y.truncate(o),decimals:d=0,logo_uri:u=$r}=t,{chain_name:m,pretty_name:h,...f}=Ie(a);return e.jsxs("div",{children:[!s&&e.jsxs("div",{className:he.arrow,children:[e.jsx("div",{className:he.divider}),n?e.jsx(jt,{label:n,children:e.jsx("button",{className:he.type,children:e.jsx(b.IconArrowDown,{size:12})})}):e.jsx("span",{className:he.type,children:e.jsx(b.IconArrowDown,{size:12})}),e.jsx("div",{className:he.divider})]}),e.jsxs("div",{className:he.content,children:[e.jsx(bn,{assetLogoUrl:u,chainLogoUrl:f.logo_uri??void 0}),e.jsxs("div",{className:he.info,children:[e.jsxs("div",{className:he.asset,children:[e.jsx("span",{className:he.amount,children:y.formatAmount(r,{decimals:d})}),e.jsx("span",{children:c})]}),e.jsxs("div",{className:he.lower,children:[e.jsxs("div",{className:he.chain,children:["on ",h||m]}),i&&e.jsx(yn,{value:i,children:({copy:p,copied:g})=>e.jsxs("button",{className:he.address,onClick:p,children:[l,g?e.jsx("span",{children:"Copied!"}):e.jsx("span",{className:"monospace",children:y.truncate(i)})]})})]})]})]})]})},ut=t=>{const s=Ee(t.denom,t.chainId);return e.jsx(No,{...t,...s})};ut.Placeholder=No;const Xh="_root_133os_1",e_="_toggle_133os_6",t_="_route_133os_29",s_="_content_133os_36",ss={root:Xh,toggle:e_,route:t_,content:s_};function n_(t){const s=({name:n})=>n==="initia-dex"?"Initia DEX":Bt.capitalCase(E.head(n?.split("-")??[])??"");if("transfer"in t)return{label:"Bridge via IBC",...t,...t.transfer};if("bank_send"in t)return{label:"Send",...t,...t.bank_send};if("swap"in t){const n=t.swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...t,...t.swap}}if("axelar_transfer"in t)return{label:"Bridge via Axelar",...t,...t.axelar_transfer};if("cctp_transfer"in t)return{label:"Bridge via CCTP",...t,...t.cctp_transfer};if("hyperlane_transfer"in t)return{label:"Bridge via Hyperlane",...t,...t.hyperlane_transfer};if("evm_swap"in t){const n=t.evm_swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...t,...t.evm_swap}}if("op_init_transfer"in t)return{label:"Bridge via OP Bridge",...t,...t.op_init_transfer};if("go_fast_transfer"in t)return{label:"Bridge via Go Fast",...t,...t.go_fast_transfer};if("eureka_transfer"in t)return{label:"Bridge via Eureka",...t,...t.eureka_transfer};if("stargate_transfer"in t)return{label:"Bridge via Stargate",...t,...t.stargate_transfer};if("layer_zero_transfer"in t)return{label:"Bridge via LayerZero",...t,...t.layer_zero_transfer};throw new Error("Unknown operation type")}const r_=({addressList:t})=>{const{values:s,route:n}=vt(),{source_asset_denom:r,source_asset_chain_id:o,amount_in:a,operations:i}=n,l=E.zipObj(n.required_chain_addresses,t),{find:c}=vs(),{connector:d,address:u=""}=xe.useAccount(),[m,h]=de.useToggle(!1),f=i.length>1,p=e.jsx(W,{src:s.cosmosWalletName?c(s.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:a,denom:r,chainId:o,address:s.sender,walletIcon:p},C=x=>y.InitiaAddress.equals(x,u)?p:e.jsx(b.IconWallet,{size:11}),S=x=>{const{label:k,amount_out:v,denom:w,denom_out:j=w,chain_id:q,from_chain_id:O,to_chain_id:T=q??O}=x,N=l[T];return{label:f&&!m?void 0:k,amount:v,denom:j,chainId:T,address:N,walletIcon:C(N)}},I=i.map(n_).map(S),P=I.slice(0,-1),A=I[I.length-1];return e.jsxs(R.Collapsible.Root,{className:ss.root,open:m,onOpenChange:h,children:[f&&e.jsx(R.Collapsible.Trigger,{asChild:!0,children:e.jsx(tn,{children:e.jsx("button",{className:ss.toggle,onClick:h,children:m?e.jsxs(e.Fragment,{children:[e.jsx(b.IconMinus,{size:12}),e.jsx("span",{children:"Hide details"})]}):e.jsxs(e.Fragment,{children:[e.jsx(b.IconList,{size:12}),e.jsx("span",{children:"Show details"})]})})})}),e.jsxs("div",{className:ss.route,children:[e.jsx(ut,{...g,source:!0}),e.jsx(R.Collapsible.Content,{className:ss.content,children:P.map((x,k)=>e.jsx(se,{suspenseFallback:e.jsx(ut.Placeholder,{...x}),errorBoundaryProps:{fallback:e.jsx(ut.Placeholder,{...x})},children:e.jsx(ut,{...x})},k))}),e.jsx(ut,{...A})]})]})},dn=({error:t})=>{const s=ie();return e.jsx(ne,{extra:e.jsx(ee,{level:"error",children:t.message}),children:e.jsx(H.White,{onClick:()=>s("/bridge"),children:"Home"})})},o_=({children:t})=>{const s=vt(),{route:n,values:r}=s,{required_chain_addresses:o}=n,{srcChainId:a,dstChainId:i,sender:l,recipient:c}=r,{initiaAddress:d,hexAddress:u}=pe(),m=gt(),h=ot(),f=Kt(),p=h(a),g=f(p),C=o.slice(0,-1).some(v=>{const w=h(v);return f(w)==="cosmos"})&&g!=="cosmos",[S,I]=_.useState(void 0),[P,A]=_.useState(!1),[x,k]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!C)return;if(!m)throw new Error("Wallet not connected");A(!0),k(null);const[{pubkey:w}]=await m.getAccounts();I(w)}catch(w){k(new Error(await Oe(w)))}finally{A(!1)}})()},[C,m]),x)return e.jsx(dn,{error:x});if(P)return e.jsx(ne,{children:e.jsx(H.White,{loading:P&&"Generating intermediary addresses..."})});if(!C||S){const v=o.map((w,j)=>{if(j===o.length-1){const K=h(i);return f(K)==="initia"?y.InitiaAddress(c).bech32:c}const q=h(w),O=f(q),T=h(a),N=f(T);switch(O){case"initia":return d;case"evm":return u;case"cosmos":{if(N==="cosmos")return L.toBech32(q.bech32_prefix,L.fromBech32(l).data);if(!S)throw new Error("Pubkey not found");return Et.pubkeyToAddress(Et.encodeSecp256k1Pubkey(S),q.bech32_prefix)}default:throw new Error("Unsupported chain type")}});return t(v)}return null},a_=({addressList:t,signedOpHook:s,children:n})=>{const r=Ke(),{route:o,values:a}=vt(),[i,l]=_.useState(void 0),[c,d]=_.useState(!1),[u,m]=_.useState(null);return _.useEffect(()=>{(async()=>{try{if(o.required_op_hook&&!s)throw new Error("Op hook is required");d(!0),m(null);const f={address_list:t,amount_in:o.amount_in,amount_out:o.amount_out,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom,slippage_tolerance_percent:a.slippagePercent,operations:o.operations,signed_op_hook:s},{txs:p}=await r.post("v2/fungible/msgs",{json:f}).json();if(!p||p.length===0)throw new Error("No transaction data found");const[g]=p;l(g)}catch(f){m(f)}finally{d(!1)}})()},[o,a,t,s,r]),u?e.jsx(dn,{error:u}):c?e.jsx(ne,{children:e.jsx(H.White,{loading:c&&"Fetching messages..."})}):i?n(i):e.jsx(dn,{error:new Error("Failed to fetch messages")})},i_=({children:t})=>{const{route:s}=vt(),n=Oh();return s.required_op_hook&&!n.data?e.jsx(ne,{extra:e.jsx(ee,{level:"error",children:n.error?.message}),children:e.jsx(H.White,{onClick:()=>n.mutate(),loading:n.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):t(n.data)},c_=({tx:t,children:s})=>{const n=wr(),r=ot(),{mutate:o,data:a,isPending:i,error:l}=$.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in t))throw new Error("Transaction is not EVM");if(!t.evm_tx.required_erc20_approvals)throw new Error("No approvals required");const{chain_id:c}=t.evm_tx,d=await n(),u=await d.getSigner();await Co(d,r(c));for(const m of t.evm_tx.required_erc20_approvals){const{token_contract:h,spender:f,amount:p}=m,g=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new nt.ethers.Contract(h,g,u).approve(f,p)).wait()}return!0}catch(c){throw new Error(await Oe(c))}}});return"evm_tx"in t&&t.evm_tx.required_erc20_approvals&&t.evm_tx.required_erc20_approvals.length>0&&!a?e.jsx(ne,{extra:e.jsx(ee,{level:"error",children:l?.message}),children:e.jsx(H.White,{onClick:()=>o(),loading:i&&"Approving tokens...",children:"Approve tokens"})}):s},l_=({tx:t})=>{const{mutate:s,isPending:n}=Mh(t);return e.jsx(ne,{children:e.jsx(H.White,{onClick:()=>s(),loading:n&&"Signing transaction...",children:"Confirm"})})},d_=()=>e.jsx(De,{title:"Route preview",children:e.jsx(o_,{children:t=>e.jsxs(e.Fragment,{children:[e.jsx(r_,{addressList:t}),e.jsx(i_,{children:s=>e.jsx(a_,{addressList:t,signedOpHook:s,children:n=>e.jsx(c_,{tx:n,children:e.jsx(l_,{tx:n})})})})]})})}),u_="_button_14cv7_1",m_="_checkbox_14cv7_10",h_="_checked_14cv7_23",ns={button:u_,checkbox:m_,checked:h_},__=({checked:t,onClick:s,label:n,className:r})=>e.jsxs("button",{type:"button",className:D(ns.button,r),onClick:s,children:[e.jsx("div",{className:D(ns.checkbox,{[ns.checked]:t}),children:t&&e.jsx(b.IconCheck,{size:12})}),e.jsx("span",{className:ns.label,children:n})]}),f_="_success_t4dfk_1",p_="_error_t4dfk_5",or={success:f_,error:p_},g_=({tx:t})=>{const[s,n]=wo(t);if(!s)throw new Error("Bridge history details not found");const{data:r}=Uh(s),o=s.state??x_(r);switch(_.useEffect(()=>{o!=="loading"&&n(a=>{if(!a)throw new Error("Bridge history details not found");return{...a,tracked:!0,state:o}})},[n,o]),o){case"error":return e.jsx("div",{className:or.error,children:e.jsx(b.IconCloseCircleFilled,{size:14})});case"success":return e.jsx("div",{className:or.success,children:e.jsx(b.IconCheckCircleFilled,{size:14})});default:return e.jsx(Le,{size:14})}};function x_(t){if(!t)return"loading";switch(t.state){case"STATE_ABANDONED":case"STATE_COMPLETED_ERROR":case"STATE_PENDING_ERROR":return"error";case"STATE_COMPLETED_SUCCESS":return"success";default:return"loading"}}const y_="_link_1uidr_1",j_="_header_1uidr_22",b_="_title_1uidr_30",v_="_date_1uidr_36",w_="_explorer_1uidr_40",C_="_fees_1uidr_55",I_="_label_1uidr_63",N_="_content_1uidr_67",S_="_route_1uidr_73",k_="_row_1uidr_78",$_="_asset_1uidr_84",A_="_amount_1uidr_92",E_="_chain_1uidr_97",T_="_account_1uidr_106",q_="_arrow_1uidr_113",X={link:y_,header:j_,title:b_,date:v_,explorer:w_,fees:C_,label:I_,content:N_,route:S_,row:k_,asset:$_,amount:A_,chain:E_,account:T_,arrow:q_},D_=({tx:t})=>{const[s,n]=wo(t);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}=zh(s),{address:u="",connector:m}=xe.useAccount(),{find:h}=vs();_.useEffect(()=>{d&&n(Q=>{if(!Q)throw new Error("Bridge history details not found");return{...Q,tracked:!0}})},[n,d]);const{amount_in:f,amount_out:p,source_asset_chain_id:g,source_asset_denom:C,dest_asset_chain_id:S,dest_asset_denom:I,estimated_fees:P=[]}=a,A=Ie(g),x=Ie(S),k=Ee(C,g),v=Ee(I,S),w=(Q,J)=>J?e.jsx(W,{src:J,width:12,height:12}):y.InitiaAddress.equals(Q,u)?e.jsx(W,{src:m?.icon,width:12,height:12}):e.jsx(b.IconWallet,{size:12}),j=(Q,{symbol:J,decimals:Se,logo_uri:be},{chain_name:ke,pretty_name:We,...it},ue,re)=>e.jsxs("div",{className:X.row,children:[e.jsx(bn,{assetLogoUrl:be,chainLogoUrl:it.logo_uri??void 0}),e.jsxs("div",{children:[e.jsxs("div",{className:X.asset,children:[e.jsx("span",{className:X.amount,children:y.formatAmount(Q,{decimals:Se})}),e.jsx("span",{children:J})]}),e.jsxs("div",{className:X.chain,children:[e.jsxs("span",{children:["on ",We||ke]}),e.jsxs("div",{className:X.account,children:[re,e.jsx("span",{className:"monospace",children:y.truncate(ue)})]})]})]})]}),q=Io(a),O=_.useMemo(()=>{switch(q){case is.SKIP:return"Skip Explorer";case is.OP_WITHDRAW:return"Initia Scan"}},[q]),T=e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:X.header,children:[e.jsxs("div",{className:X.title,children:[c?e.jsx(g_,{tx:t}):e.jsx(Le,{size:14}),e.jsx("div",{className:X.date,children:ft.intlFormatDistance(new Date(l),new Date,{locale:"en-US"})})]}),e.jsxs("div",{className:X.explorer,children:[e.jsx("span",{children:O}),e.jsx(b.IconExternalLink,{size:12})]})]}),e.jsxs("div",{className:X.route,children:[j(f,k,A,i.sender,w(i.sender,h(i.cosmosWalletName)?.image)),e.jsx("div",{className:X.arrow,children:e.jsx(b.IconArrowDown,{size:12})}),j(p,v,x,i.recipient,w(i.recipient))]}),P.length>0&&e.jsxs("div",{className:X.fees,children:[e.jsx("span",{className:X.label,children:"Fees"}),e.jsx("span",{className:X.content,children:go(P)})]})]});if(q===is.OP_WITHDRAW)return e.jsx(ys,{chainId:r,txHash:o,className:X.link,children:T});const N=new URLSearchParams({tx_hash:o,chain_id:r}),K=new URL(`?${N.toString()}`,"https://explorer.skip.build");return e.jsx("a",{href:K.toString(),className:X.link,target:"_blank",children:T})},P_="_list_1q71m_1",R_="_header_1q71m_5",F_="_checkbox_1q71m_9",B_="_item_1q71m_13",rs={list:P_,header:R_,checkbox:F_,item:B_},M_=()=>{const{initiaAddress:t,hexAddress:s}=pe(),{history:n,getHistoryDetails:r}=vo(),o=n.filter(h=>r(h)),a=o.filter(h=>{const f=r(h);if(!f)return!1;const{values:p}=f,{sender:g,recipient:C}=p;return[g,C].some(S=>[t,s].includes(S))}),[i,l]=_.useState(1),[c,d]=de.useToggle(!a.length),u=c?o:a,m=u.slice(0,i*rr);return e.jsx(De,{title:"Bridge/Swap activity",children:e.jsxs("div",{className:rs.list,children:[o.length>0&&o.length!==a.length&&e.jsx("header",{className:rs.header,children:e.jsx(__,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:rs.checkbox})}),u.length===0?e.jsx(ae,{children:"No bridge/swap activity"}):m.map((h,f)=>e.jsx("div",{className:rs.item,children:e.jsx(se,{children:e.jsx(D_,{tx:h})})},f)),u.length>i*rr?e.jsx(Cn,{onClick:()=>l(h=>h+1)}):n.length>=ds&&e.jsxs(ae,{children:["Only the latest ",ds," items are stored. Older entries will be removed automatically."]})]})})},So=()=>{const t=ie(),s=fr(),n=yt(),{closeDrawer:r}=xt(),{closeModal:o}=Ot();if(_.useEffect(()=>{o(),s.startsWith("/bridge/")&&t("/bridge"),(s==="/collection"||s.startsWith("/nft"))&&t("/nfts")},[n]),s==="/connect")return n?null:e.jsx(On,{onSuccess:r});if(s==="/blank")return null;if(!n)return e.jsx(On,{});switch(s){case"/":case"/nfts":case"/activity":return e.jsx(vd,{});case"/send":return e.jsx(Du,{},n);case"/collection":return e.jsx(Ou,{});case"/nft":return e.jsx(Gu,{});case"/nft/send":return e.jsx(om,{},n);case"/rollups":return e.jsx(pm,{});case"/bridge":return e.jsx(oh,{},n);case"/bridge/preview":return e.jsx(d_,{});case"/bridge/history":return e.jsx(M_,{});case"/op/withdrawals":return e.jsx(Fh,{});case"/tx":return e.jsx(Gr,{})}},O_="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",z_=()=>e.jsxs(e.Fragment,{children:[e.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),e.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),e.jsx("link",{rel:"stylesheet",href:O_}),e.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),U_=()=>{ze();const t=je();return gn(),ht(localStorage.getItem(M.BRIDGE_SRC_CHAIN_ID)??t.chainId),ht(localStorage.getItem(M.BRIDGE_DST_CHAIN_ID)??t.chainId),null},K_=({children:t,...s})=>(_.useEffect(()=>{ma()},[]),de.useIsClient()?e.jsxs(e.Fragment,{children:[e.jsx(z_,{}),e.jsxs(xr.Provider,{value:{...mr,...s},children:[e.jsx(se,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:e.jsx(U_,{})}),e.jsx(pr,{children:e.jsx(pa,{children:e.jsx(R.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:e.jsx(Aa,{children:e.jsxs(Yi,{children:[t,e.jsx(Ac,{children:e.jsx(So,{})})]})})})})})]})]}):null),L_=({bridge:t})=>e.jsx(pr,{initialEntry:{path:t?"/bridge":"/",state:t},children:e.jsx("div",{className:"body",children:e.jsx(Br.Provider,{value:!!t,children:e.jsx(se,{children:e.jsx(So,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=qt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=ur;exports.InterwovenKit=L_;exports.InterwovenKitProvider=K_;exports.MAINNET=mr;exports.TESTNET=Uo;exports.initiaPrivyWallet=Lo;exports.initiaPrivyWalletConnector=Ko;exports.initiaPrivyWalletOptions=hn;exports.injectStyles=Zi;exports.useAddress=yt;exports.useHexAddress=gs;exports.useInitiaAddress=Y;exports.useInterwovenKit=pe;exports.useUsernameQuery=qr;