@initia/interwovenkit-react 2.0.0-rc.6 → 2.0.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const cr=require("@privy-io/cross-app-connect/rainbow-kit"),we=require("wagmi"),$=require("@tanstack/react-query"),j=require("@initia/utils"),xt=require("cosmjs-types/cosmos/tx/v1beta1/tx"),Pt=require("@cosmjs/amino"),Ae=require("@cosmjs/stargate"),W=require("jotai"),t=require("react/jsx-runtime"),v=require("ramda"),h=require("react"),Z=require("ky"),$e=require("@lukemorales/query-key-factory"),it=require("ethers"),Po=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Gs=require("@cosmjs/amino/build/signdoc"),Ys=require("@cosmjs/crypto"),H=require("@cosmjs/encoding"),Tn=require("@cosmjs/math"),hs=require("@cosmjs/proto-signing"),qn=require("@cosmjs/tendermint-rpc"),Rt=require("@initia/amino-converter"),Js=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Ro=require("cosmjs-types/cosmos/auth/v1beta1/auth"),Bo=require("cosmjs-types/google/protobuf/any"),B=require("bignumber.js"),Fo=require("@mysten/bcs"),U=require("radix-ui"),be=require("usehooks-ts"),lr=require("react-error-boundary"),D=require("clsx"),Dn=require("nanoid"),un=require("react-dom"),oe=require("@react-spring/web"),A=require("@initia/icons-react"),_s=require("change-case"),Mo=require("qr-code-styling"),Oo=require("xss"),Oe=require("@base-ui-components/react/tabs"),Ut=require("date-fns"),Uo=require("jotai/utils"),_t=require("@base-ui-components/react/popover"),Ue=require("@base-ui-components/react"),G=require("zod"),le=require("react-hook-form"),mn=require("@hookform/resolvers/zod"),Pn=require("cosmjs-types/cosmos/bank/v1beta1/tx"),dr=require("react-merge-refs"),Lo=require("react-intersection-observer"),Gt=require("@noble/hashes/utils"),zo=require("@noble/hashes/sha3"),Ko=require("@initia/opinit.proto/opinit/ophost/v1/tx"),Bt=1.4,ur=1.05,mr={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",theme:"dark"},Ho={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"},Wo=cr.toPrivyWalletConnector(hn),Qo=cr.toPrivyWallet(hn),hr=h.createContext(null);function ps(){return h.useContext(hr)}function _r(){const{location:e}=ps();return e}function _n(){const{path:e}=_r();return e}function lt(){const{state:e={}}=_r();return e}function Vo(){const{history:e}=ps();return e}function de(){const{navigate:e}=ps();return e}function Go(){const{reset:e}=ps();return e}const pr=({children:e,initialEntry:s})=>{const[n,r]=h.useState([s??{path:"/"}]),o=n[n.length-1],a=h.useCallback((l,c)=>{r(d=>{if(typeof l=="string")return[...d,{path:l,state:c}];const u=d.length+l;if(u<1)return d;const m=v.take(u,d);return c!==void 0?v.adjust(u-1,_=>({..._,state:c}),m):m})},[]),i=h.useCallback((l,c)=>{r([{path:l,state:c}])},[]);return t.jsx(hr.Provider,{value:{location:o,history:n,navigate:a,reset:i},children:e})},pn=({to:e,state:s,children:n,onClick:r,...o})=>{const a=de(),i=l=>{l.preventDefault(),r?.(l),a(e,s)};return t.jsx("button",{type:"button",...o,onClick:i,children:n})},fr=h.createContext(null),Lt=()=>h.useContext(fr),gr=h.createContext(null);function fe(){return h.useContext(gr)}const z={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function Ve(e){if(e instanceof Z.HTTPError){const{response:s}=e,n=s.headers.get("content-type")??"";if(v.includes("application/json",n))try{const r=await s.json();if(r.message)return r.message}catch{return e.message}try{return await s.text()}catch{return e.message}}if(e instanceof Error){if(v.path(["code"],e)===4001||v.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const s=v.path(["error","message"],e),n=v.path(["cause","message"],e),r=v.path(["shortMessage"],e);return s||n||r||e.message}return String(e)}class Yo 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 Jo=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Ts=new Map;function Zo(e){const s=e.match(Jo);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 Xo(e,s,n){const r=`${e}:${s}`;if(Ts.has(r))return Ts.get(r);try{const o=s==="0x1"?"0x1.json":`${e}/${s}.json`,a=`${n}/errors/${o}`,{errors:i={}}=await Z.get(a).json();return Ts.set(r,i),i}catch{return null}}function ea(e,s,n,r,o){return new Yo(e,s,n,r,o)}async function Zs(e,s,n){if(!s.metadata?.is_l1&&s.metadata?.minitia?.type!=="minimove")return e;const r=Zo(e.message);if(!r)return e;const o=await Xo(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 ea(l,e,r.moduleAddress,r.moduleName,r.errorCode)}const fn=$e.createQueryKeys("interwovenkit:chain",{list:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function Yt(e){const s=v.path([0,"address"],e);if(!s)throw new Error("URL not found");return s}function ta(e){const{chain_id:s,chain_name:n,pretty_name:r,logo_URIs:o,apis:a,metadata:i}=e,l=r||n,c=o?.png??"",{rpc:d,rest:u,api:m,["json-rpc"]:_}=a,p=Yt(d),f=Yt(u),g=i?.is_l1?Yt(m):f,b=i?.minitia?.type==="minievm"?Yt(_):void 0;return{...e,chainId:s,name:l,logoUrl:c,rpcUrl:p,restUrl:f,indexerUrl:g,jsonRpcUrl:b}}function re(){const{defaultChainId:e,registryUrl:s,customChain:n}=fe(),{data:r}=$.useSuspenseQuery({queryKey:fn.list(s).queryKey,queryFn:()=>Z.create({prefixUrl:s}).get("chains.json").json(),select:o=>(n?[n,...o.filter(i=>i.chain_id!==n.chain_id)]:o).map(ta).toSorted(v.descend(i=>i.chainId===e)),staleTime:z.MINUTE});return r}function Be(){const e=re();return s=>{const n=e.find(r=>r.chain_id===s);if(!n)throw new Error(`Chain not found: ${s}`);return n}}function Fe(e){return Be()(e)}function zt(){const{defaultChainId:e}=fe();return Fe(e)}function ge(){const s=re().find(n=>n.metadata?.is_l1);if(!s)throw new Error("Layer 1 not found");return s}function xr(){return({chainId:e})=>$.queryOptions({queryKey:fn.prices(e).queryKey,queryFn:()=>Z.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:z.SECOND})}function fs(e){const s=xr();return $.useQuery(s(e))}function sa(){const e=re(),s=xr();return $.useQueries({queries:e.map(n=>s(n))})}function na(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:s}=Js.PubKey.decode(e.value);return Pt.encodeSecp256k1Pubkey(s)}return hs.decodeOptionalPubkey(e)}function ra({typeUrl:e,value:s}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:n,pubKey:r,accountNumber:o,sequence:a}=Ro.BaseAccount.decode(s),i=na(r);return{address:n,pubkey:i,accountNumber:Number(o),sequence:Number(a)}}return Ae.accountFromAny({typeUrl:e,value:s})}function oa(e){return e.type==="initia/PubKeyEthSecp256k1"}const aa={...Pt.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function ia(e){if(oa(e)){const s=Js.PubKey.fromPartial({key:H.fromBase64(e.value)});return Bo.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(Js.PubKey.encode(s).finish())})}return hs.encodePubkey(e)}function yr(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:aa.ethsecp256k1,value:H.toBase64(e)}}function ca(e,s){if(s.length!==64)throw new Error("Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s.");return{pub_key:yr(e),signature:H.toBase64(s)}}const Ie="interwovenkit",O={PUBLIC_KEY:`${Ie}:public-key`,BRIDGE_SRC_CHAIN_ID:`${Ie}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${Ie}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${Ie}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${Ie}:bridge:dst-denom`,BRIDGE_QUANTITY:`${Ie}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${Ie}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${Ie}:bridge:route-type`,BRIDGE_HISTORY:`${Ie}:bridge:history`,OP_REMINDER:`${Ie}:op:reminder`},gs=()=>{const e=fe();return new hs.Registry([...Rt.protoRegistry,...e.protoTypes??[]])},xs=()=>{const e=fe();return new Ae.AminoTypes({...Rt.aminoConverters,...e.aminoConverters})};class la{constructor(s,n){this.address=s,this.signMessage=n}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const s=`${O.PUBLIC_KEY}:${this.address}`,n=localStorage.getItem(s);if(n)return this.cachedPublicKey=H.fromHex(n),H.fromHex(n);const r=await this.getPublicKey();return this.cachedPublicKey=r,localStorage.setItem(s,H.toHex(r)),r}async getPublicKey(){const s="Sign this message to identify your Initia account.",n=await this.signMessage(s),r=it.ethers.hashMessage(s),o=it.ethers.SigningKey.recoverPublicKey(r,n);return Ys.Secp256k1.compressPubkey(H.fromHex(o.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(s,n){if(this.address!==s)throw new Error("Signer address does not match the provided address");const r=Gs.escapeCharacters(Gs.sortedJsonStringify(n)),o=await this.signMessage(r),a=H.fromHex(o.replace("0x","")).subarray(0,-1),l=Ys.Secp256k1Signature.fromFixedLength(a).toFixedLength(),c=ca(await this.getCachedPublicKey(),l);return{signed:n,signature:c}}}function jr(){const e=gs(),s=xs(),n=vt(),r=wr();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),[_]=await n.getAccounts(),p=ia(yr(_.pubkey)),f=Po.SignMode.SIGN_MODE_EIP_191,g=i.map(x=>s.toAmino(x)),b=Gs.makeSignDoc(g,l,o,c,u,m),{signature:C,signed:w}=await n.signAmino(a,b),E={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:w.msgs.map(x=>s.fromAmino(x)),memo:c}},y=e.encode(E),T=Tn.Int53.fromString(w.fee.gas).toNumber(),N=Tn.Int53.fromString(w.sequence).toNumber(),I=hs.makeAuthInfoBytes([{pubkey:p,sequence:N}],w.fee.amount,T,w.fee.granter,w.fee.payer,f);return xt.TxRaw.fromPartial({bodyBytes:y,authInfoBytes:I,signatures:[H.fromBase64(C.signature)]})}}function vt(){const e=te(),{signMessageAsync:s}=we.useSignMessage();return h.useMemo(()=>new la(e,n=>s({message:n})),[e,s])}const qs=new Map,Ds=new Map;function vr(){const e=Be();return async s=>{if(qs.has(s))return qs.get(s);const{rpcUrl:n}=e(s),r=await qn.Comet38Client.create(new qn.HttpClient(n));return qs.set(s,r),r}}function wr(){const e=gs(),s=xs(),n=vt(),r=te(),o=vr();return async a=>{const i=`${r}:${a}`;if(Ds.has(i))return Ds.get(i);if(!n)throw new Error("Signer not initialized");const l=await o(a),c=await Ae.SigningStargateClient.createWithSigner(l,n,{registry:e,aminoTypes:s,accountParser:ra,broadcastPollIntervalMs:1e3});return Ds.set(i,c),c}}function br(){const{connector:e}=we.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new it.BrowserProvider(await e.getProvider())}}const da=W.atom(!1);function wt(){const e=Go(),[s,n]=W.useAtom(da);return{isDrawerOpen:s,openDrawer:(a,i)=>{a&&e(a,i),n(!0)},closeDrawer:()=>{n(!1)}}}const Cr="approve",ys=W.atom(),Ir=W.atom(null);function Nr(){const e=W.useAtomValue(ys);if(!e)throw new Error("Tx request not found");return e}function Sr(){const e=de(),s=te(),{defaultChainId:n,registryUrl:r}=fe(),o=Be(),{openDrawer:a,closeDrawer:i}=wt(),{openModal:l,closeModal:c}=Lt(),d=W.useSetAtom(ys),u=W.useSetAtom(Ir),m=vr(),_=wr(),p=vt(),f=gs(),g=async({messages:y,memo:T,chainId:N=n})=>{try{return await(await _(N)).simulate(s,y,T)}catch(I){throw new Error(await Ve(I))}},b=async({messages:y,memo:T,chainId:N=n})=>{const I=await m(N),x=Ae.QueryClient.withExtensions(I,Ae.setupTxExtension),k=y.map(Q=>f.encodeAsAny(Q)),[R]=await p.getAccounts(),S=Pt.encodeSecp256k1Pubkey(R.pubkey),q=await _(N),{sequence:F}=await q.getSequence(s);return x.tx.simulate(k,T,S,F)},C=async({txRequest:y,broadcaster:T})=>{const I={...{memo:"",chainId:n,gas:y.gas||await g(y),gasAdjustment:Bt,gasPrices:null,spendCoins:[],internal:!1},...y};return new Promise((x,k)=>{d({txRequest:I,resolve:async S=>{try{const q=await _(I.chainId),F=await T(q,xt.TxRaw.encode(S).finish());x(F),typeof I.internal=="string"&&e(I.internal)}catch(q){k(await Zs(q,o(I.chainId),r))}finally{R()}},reject:S=>{k(S),R()}}),I.internal?l({path:"/tx"}):a("/tx");const R=()=>{if(!I.internal){e("/blank"),i();return}c()}})},w=async y=>{const T=y.chainId??n;try{const N=await C({txRequest:y,broadcaster:async(I,x)=>await I.broadcastTxSync(x)});return y.internal&&typeof y.internal!="number"&&(u({txHash:N,chainId:T,status:"loading"}),E({txHash:N,chainId:y.chainId}).then(I=>{u({status:I.code===0?"success":"error",chainId:T,txHash:N})}).catch(()=>{u({status:"error",chainId:T,txHash:N})})),N}catch(N){throw y.internal&&typeof y.internal!="number"&&u({status:"error",chainId:T,error:N}),N}},P=y=>C({txRequest:y,broadcaster:async(T,N)=>{const I=await T.broadcastTx(N);if(I.code!==0)throw new Error(I.rawLog);return I}}),E=async({chainId:y=n,...T})=>{try{const N=await _(y);return await Ar({...T,client:N})}catch(N){throw await Zs(N,o(y),r)}};return{estimateGas:g,simulateTx:b,requestTxSync:w,requestTxBlock:P,waitForTxConfirmation:E}}async function Ar({txHash:e,client:s,timeoutSeconds:n=30,intervalSeconds:r=1}){const o=Date.now(),a=n*1e3;for(;;){const i=await s.getTx(e);if(i){if(i.code!==0)throw new Error(i.rawLog);return i}if(Date.now()-o>=a)throw new Error(`Transaction was submitted, but not found on the chain within ${n} seconds.`);await new Promise(l=>setTimeout(l,r*1e3))}}function ua(e){return e.pagination.next_key}async function kr(e,s,n){const r=Z.create(s),o=async(a,i)=>{const l=await r.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[n]??[],d=ua(l),u=[...a,...c];return d?o(u,d):u};return o([],null)}const ma=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const lr=require("@privy-io/cross-app-connect/rainbow-kit"),_e=require("wagmi"),T=require("@tanstack/react-query"),w=require("@initia/utils"),gt=require("cosmjs-types/cosmos/tx/v1beta1/tx"),Rt=require("@cosmjs/amino"),ke=require("@cosmjs/stargate"),Q=require("jotai"),t=require("react/jsx-runtime"),y=require("ramda"),f=require("react"),J=require("ky"),Te=require("@lukemorales/query-key-factory"),at=require("ethers"),Do=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Xs=require("@cosmjs/amino/build/signdoc"),en=require("@cosmjs/crypto"),W=require("@cosmjs/encoding"),En=require("@cosmjs/math"),hs=require("@cosmjs/proto-signing"),qn=require("@cosmjs/tendermint-rpc"),Mt=require("@initia/amino-converter"),tn=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Po=require("cosmjs-types/cosmos/auth/v1beta1/auth"),Bo=require("cosmjs-types/google/protobuf/any"),dr=require("@amplitude/analytics-browser"),R=require("bignumber.js"),Ro=require("@mysten/bcs"),U=require("radix-ui"),be=require("usehooks-ts"),ur=require("react-error-boundary"),P=require("clsx"),Dn=require("nanoid"),hn=require("react-dom"),re=require("@react-spring/web"),A=require("@initia/icons-react"),fs=require("change-case"),Mo=require("qr-code-styling"),Fo=require("xss"),Fe=require("@base-ui-components/react/tabs"),Lt=require("date-fns"),Oo=require("jotai/utils"),ht=require("@base-ui-components/react/popover"),Oe=require("@base-ui-components/react"),oe=require("react-hook-form"),Pn=require("cosmjs-types/cosmos/bank/v1beta1/tx"),mr=require("react-merge-refs"),Uo=require("react-intersection-observer"),Vt=require("@noble/hashes/utils"),Lo=require("@noble/hashes/sha3");function zo(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(s,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return s.default=e,Object.freeze(s)}const hr=zo(dr),Ft=1.4,fr=1.05,_r={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",theme:"dark"},Ko={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",theme:"dark"},fn={id:"cmbq1ozyc006al70lx4uciz0q",name:"Google",iconUrl:"https://assets.initia.xyz/images/wallets/Google.webp",iconBackground:"#ffffff"},Ho=lr.toPrivyWalletConnector(fn),Wo=lr.toPrivyWallet(fn),pr=f.createContext(null);function _s(){return f.useContext(pr)}function gr(){const{location:e}=_s();return e}function ps(){const{path:e}=gr();return e}function ct(){const{state:e={}}=gr();return e}function Qo(){const{history:e}=_s();return e}function le(){const{navigate:e}=_s();return e}function xr(){const{reset:e}=_s();return e}const yr=({children:e,initialEntry:s})=>{const[n,r]=f.useState([s??{path:"/"}]),o=n[n.length-1],a=f.useCallback((l,c)=>{r(d=>{if(typeof l=="string")return[...d,{path:l,state:c}];const u=d.length+l;if(u<1)return d;const m=y.take(u,d);return c!==void 0?y.adjust(u-1,h=>({...h,state:c}),m):m})},[]),i=f.useCallback((l,c)=>{r([{path:l,state:c}])},[]);return t.jsx(pr.Provider,{value:{location:o,history:n,navigate:a,reset:i},children:e})},gs=({to:e,state:s,shouldReset:n,children:r,onClick:o,...a})=>{const i=le(),l=xr(),c=d=>{d.preventDefault(),o?.(d),n?l(e,s):i(e,s)};return t.jsx("button",{type:"button",...a,onClick:c,children:r})},jr=f.createContext(null),zt=()=>f.useContext(jr),vr=f.createContext(null);function de(){return f.useContext(vr)}const K={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function Pe(e){if(e instanceof J.HTTPError){const{response:s}=e,n=s.headers.get("content-type")??"";if(y.includes("application/json",n))try{const r=await s.json();if(r.message)return r.message}catch{return e.message}try{return await s.text()}catch{return e.message}}if(e instanceof Error){if(y.path(["code"],e)===4001||y.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const s=y.path(["error","message"],e),n=y.path(["cause","message"],e),r=y.path(["shortMessage"],e);return s||n||r||e.message}return String(e)}class Vo 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 Go=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Bs=new Map;function Yo(e){const s=e.match(Go);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 Jo(e,s,n){const r=`${e}:${s}`;if(Bs.has(r))return Bs.get(r);try{const o=s==="0x1"?"0x1.json":`${e}/${s}.json`,a=`${n}/errors/${o}`,{errors:i={}}=await J.get(a).json();return Bs.set(r,i),i}catch{return null}}function Zo(e,s,n,r,o){return new Vo(e,s,n,r,o)}async function sn(e,s,n){if(!s.metadata?.is_l1&&s.metadata?.minitia?.type!=="minimove")return e;const r=Yo(e.message);if(!r)return e;const o=await Jo(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 Zo(l,e,r.moduleAddress,r.moduleName,r.errorCode)}const _n=Te.createQueryKeys("interwovenkit:chain",{list:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function Gt(e){const s=y.path([0,"address"],e);if(!s)throw new Error("URL not found");return s}function Xo(e){const{chain_id:s,chain_name:n,pretty_name:r,logo_URIs:o,apis:a,metadata:i}=e,l=r||n,c=o?.png??"",{rpc:d,rest:u,api:m,["json-rpc"]:h}=a,_=Gt(d),p=Gt(u),g=i?.is_l1?Gt(m):p,C=i?.minitia?.type==="minievm"?Gt(h):void 0;return{...e,chainId:s,name:l,logoUrl:c,rpcUrl:_,restUrl:p,indexerUrl:g,jsonRpcUrl:C}}function se(){const{defaultChainId:e,registryUrl:s,customChain:n}=de(),{data:r}=T.useSuspenseQuery({queryKey:_n.list(s).queryKey,queryFn:()=>J.create({prefixUrl:s}).get("chains.json").json(),select:o=>(n?[n,...o.filter(i=>i.chain_id!==n.chain_id)]:o).map(Xo).toSorted(y.descend(i=>i.chainId===e)),staleTime:K.MINUTE});return r}function Qe(){const e=se();return s=>{const n=e.find(r=>r.chain_id===s);if(!n)throw new Error(`Chain not found: ${s}`);return n}}function Be(e){return Qe()(e)}function Kt(){const{defaultChainId:e}=de();return Be(e)}function pe(){const s=se().find(n=>n.metadata?.is_l1);if(!s)throw new Error("Layer 1 not found");return s}function wr(){return({chainId:e})=>T.queryOptions({queryKey:_n.prices(e).queryKey,queryFn:()=>J.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:K.SECOND})}function xs(e){const s=wr();return T.useQuery(s(e))}function ea(){const e=se(),s=wr();return T.useQueries({queries:e.map(n=>s(n))})}function ta(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:s}=tn.PubKey.decode(e.value);return Rt.encodeSecp256k1Pubkey(s)}return hs.decodeOptionalPubkey(e)}function sa({typeUrl:e,value:s}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:n,pubKey:r,accountNumber:o,sequence:a}=Po.BaseAccount.decode(s),i=ta(r);return{address:n,pubkey:i,accountNumber:Number(o),sequence:Number(a)}}return ke.accountFromAny({typeUrl:e,value:s})}function na(e){return e.type==="initia/PubKeyEthSecp256k1"}const ra={...Rt.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function oa(e){if(na(e)){const s=tn.PubKey.fromPartial({key:W.fromBase64(e.value)});return Bo.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(tn.PubKey.encode(s).finish())})}return hs.encodePubkey(e)}function br(e){if(e.length!==33||e[0]!==2&&e[0]!==3)throw new Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03");return{type:ra.ethsecp256k1,value:W.toBase64(e)}}function aa(e,s){if(s.length!==64)throw new Error("Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s.");return{pub_key:br(e),signature:W.toBase64(s)}}const Ie="interwovenkit",F={PUBLIC_KEY:`${Ie}:public-key`,BRIDGE_SRC_CHAIN_ID:`${Ie}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${Ie}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${Ie}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${Ie}:bridge:dst-denom`,BRIDGE_QUANTITY:`${Ie}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${Ie}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${Ie}:bridge:route-type`,BRIDGE_HISTORY:`${Ie}:bridge:history`,OP_REMINDER:`${Ie}:op:reminder`},ys=()=>{const e=de();return new hs.Registry([...Mt.protoRegistry,...e.protoTypes??[]])},js=()=>{const e=de();return new ke.AminoTypes({...Mt.aminoConverters,...e.aminoConverters})};class ia{constructor(s,n){this.address=s,this.signMessage=n}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const s=`${F.PUBLIC_KEY}:${this.address}`,n=localStorage.getItem(s);if(n)return this.cachedPublicKey=W.fromHex(n),W.fromHex(n);const r=await this.getPublicKey();return this.cachedPublicKey=r,localStorage.setItem(s,W.toHex(r)),r}async getPublicKey(){const s="Sign this message to identify your Initia account.",n=await this.signMessage(s),r=at.ethers.hashMessage(s),o=at.ethers.SigningKey.recoverPublicKey(r,n);return en.Secp256k1.compressPubkey(W.fromHex(o.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(s,n){if(this.address!==s)throw new Error("Signer address does not match the provided address");const r=Xs.escapeCharacters(Xs.sortedJsonStringify(n)),o=await this.signMessage(r),a=W.fromHex(o.replace("0x","")).subarray(0,-1),l=en.Secp256k1Signature.fromFixedLength(a).toFixedLength(),c=aa(await this.getCachedPublicKey(),l);return{signed:n,signature:c}}}function Cr(){const e=ys(),s=js(),n=jt(),r=Nr();return async function(o,a,i,l,c){if(!n)throw new Error("Signer not initialized");const d=await r(o),{accountNumber:u,sequence:m}=await d.getSequence(a),[h]=await n.getAccounts(),_=oa(br(h.pubkey)),p=Do.SignMode.SIGN_MODE_EIP_191,g=i.map(x=>s.toAmino(x)),C=Xs.makeSignDoc(g,l,o,c,u,m),{signature:$,signed:N}=await n.signAmino(a,C),v={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:N.msgs.map(x=>s.fromAmino(x)),memo:c}},j=e.encode(v),k=En.Int53.fromString(N.fee.gas).toNumber(),b=En.Int53.fromString(N.sequence).toNumber(),I=hs.makeAuthInfoBytes([{pubkey:_,sequence:b}],N.fee.amount,k,N.fee.granter,N.fee.payer,p);return gt.TxRaw.fromPartial({bodyBytes:j,authInfoBytes:I,signatures:[W.fromBase64($.signature)]})}}function jt(){const e=ne(),{signMessageAsync:s}=_e.useSignMessage();return f.useMemo(()=>new ia(e,n=>s({message:n})),[e,s])}const Rs=new Map,Ms=new Map;function Ir(){const e=Qe();return async s=>{if(Rs.has(s))return Rs.get(s);const{rpcUrl:n}=e(s),r=await qn.Comet38Client.create(new qn.HttpClient(n));return Rs.set(s,r),r}}function Nr(){const e=ys(),s=js(),n=jt(),r=ne(),o=Ir();return async a=>{const i=`${r}:${a}`;if(Ms.has(i))return Ms.get(i);if(!n)throw new Error("Signer not initialized");const l=await o(a),c=await ke.SigningStargateClient.createWithSigner(l,n,{registry:e,aminoTypes:s,accountParser:sa,broadcastPollIntervalMs:1e3});return Ms.set(i,c),c}}function Sr(){const{connector:e}=_e.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new at.BrowserProvider(await e.getProvider())}}function ca(){const{disableAnalytics:e}=de();f.useEffect(()=>{},[e])}function la(){const{connector:e}=_e.useAccount(),{defaultChainId:s,disableAnalytics:n}=de();f.useEffect(()=>{const r=new dr.Identify;e?.name&&r.set("connector",e.name),s&&r.set("defaultChainId",s),hr.identify(r)},[s,e?.name,n])}function vs(){const e=ps();return f.useCallback((n,r)=>{hr.track(n,{path:e,...r})},[e])}const da=Q.atom(!1);function vt(){const e=xr(),[s,n]=Q.useAtom(da),r=vs();return{isDrawerOpen:s,openDrawer:(i,l)=>{i&&e(i,l),n(!0),r("Widget Opened")},closeDrawer:()=>{n(!1),r("Widget Closed")}}}function kr(){const e=le(),{closeDrawer:s}=vt(),{disconnect:n}=_e.useDisconnect();return()=>{e("/blank"),s(),n(),localStorage.removeItem(F.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(F.BRIDGE_SRC_DENOM),localStorage.removeItem(F.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(F.BRIDGE_DST_DENOM),localStorage.removeItem(F.BRIDGE_QUANTITY),localStorage.removeItem(F.BRIDGE_SLIPPAGE_PERCENT)}}const Ar="approve",ws=Q.atom(),$r=Q.atom(null);function Tr(){const e=Q.useAtomValue(ws);if(!e)throw new Error("Tx request not found");return e}function Er(){const e=le(),s=ne(),{defaultChainId:n,registryUrl:r}=de(),o=Qe(),{openDrawer:a,closeDrawer:i}=vt(),{openModal:l,closeModal:c}=zt(),d=Q.useSetAtom(ws),u=Q.useSetAtom($r),m=Ir(),h=Nr(),_=jt(),p=ys(),g=async({messages:j,memo:k,chainId:b=n})=>{try{return await(await h(b)).simulate(s,j,k)}catch(I){throw new Error(await Pe(I))}},C=async({messages:j,memo:k,chainId:b=n})=>{const I=await m(b),x=ke.QueryClient.withExtensions(I,ke.setupTxExtension),D=j.map(L=>p.encodeAsAny(L)),[E]=await _.getAccounts(),B=Rt.encodeSecp256k1Pubkey(E.pubkey),S=await h(b),{sequence:O}=await S.getSequence(s);return x.tx.simulate(D,k,B,O)},$=async({txRequest:j,broadcaster:k})=>{const I={...{memo:"",chainId:n,gas:j.gas||await g(j),gasAdjustment:Ft,gasPrices:null,spendCoins:[],internal:!1},...j};return new Promise((x,D)=>{d({txRequest:I,resolve:async B=>{try{const S=await h(I.chainId),O=await k(S,gt.TxRaw.encode(B).finish());x(O),typeof I.internal=="string"&&e(I.internal)}catch(S){D(await sn(S,o(I.chainId),r))}finally{E()}},reject:B=>{D(B),E()}}),I.internal?l({path:"/tx"}):a("/tx");const E=()=>{if(!I.internal){e("/blank"),i();return}c()}})},N=async j=>{const k=j.chainId??n;try{const b=await $({txRequest:j,broadcaster:async(I,x)=>await I.broadcastTxSync(x)});return j.internal&&typeof j.internal!="number"&&(u({txHash:b,chainId:k,status:"loading"}),v({txHash:b,chainId:j.chainId}).then(I=>{u({status:I.code===0?"success":"error",chainId:k,txHash:b})}).catch(()=>{u({status:"error",chainId:k,txHash:b})})),b}catch(b){throw j.internal&&typeof j.internal!="number"&&u({status:"error",chainId:k,error:b}),b}},q=j=>$({txRequest:j,broadcaster:async(k,b)=>{const I=await k.broadcastTx(b);if(I.code!==0)throw new Error(I.rawLog);return I}}),v=async({chainId:j=n,...k})=>{try{const b=await h(j);return await qr({...k,client:b})}catch(b){throw await sn(b,o(j),r)}};return{estimateGas:g,simulateTx:C,requestTxSync:N,requestTxBlock:q,waitForTxConfirmation:v}}async function qr({txHash:e,client:s,timeoutSeconds:n=30,intervalSeconds:r=1}){const o=Date.now(),a=n*1e3;for(;;){const i=await s.getTx(e);if(i){if(i.code!==0)throw new Error(i.rawLog);return i}if(Date.now()-o>=a)throw new Error(`Transaction was submitted, but not found on the chain within ${n} seconds.`);await new Promise(l=>setTimeout(l,r*1e3))}}function ua(e){return e.pagination?.next_key??null}async function Dr(e,s,n){const r=J.create(s),o=async(a,i)=>{const l=await r.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[n]??[],d=ua(l),u=[...a,...c];return d?o(u,d):u};return o([],null)}const ma=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
2
2
  <circle fill="#2F3337" cx="30" cy="30" r="30"/>
3
3
  <path fill="#757C82" d="M26.328 34.288v-.48c0-2.048 1.024-2.816 4.128-4.16 3.104-1.28 3.712-1.952 3.712-3.488v-.128c0-1.664-1.344-2.464-4.224-2.464-2.816 0-4.416.736-4.768 3.296h-5.248c.416-5.536 4.416-7.584 9.888-7.584h.352c6.208 0 9.28 2.496 9.28 6.24v.352c0 3.392-1.28 4.96-5.376 6.592-1.504.64-2.048 1.024-2.208 1.824h-5.536ZM26.168 42v-5.152h5.792V42h-5.792Z"/>
4
- </svg>`,ha=encodeURIComponent(ma),gn=`data:image/svg+xml;utf8,${ha}`,Ft=$e.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,s)=>[e,s],resource:(e,s)=>[e.chainId,s.denom],denom:(e,s)=>[e,s],metadata:(e,s)=>[e,s]});function _a(e){const{base:s,symbol:n,denom_units:r=[],display:o,logo_URIs:a,name:i,address:l,traces:c}=e,d=r.find(m=>m.denom===o)?.exponent??r.find(m=>m.denom===s)?.exponent??v.head(r)?.exponent??0,u=a?.png??"";return{denom:s,symbol:n,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function $r(){const e=$.useQueryClient();return s=>{const n=s?.metadata?.assetlist;return $.queryOptions({queryKey:Ft.list(n).queryKey,queryFn:async()=>n?Z.get(n).json():{assets:[]},select:({assets:r})=>{if(!s)return[];const o=r.map(_a);for(const a of o)e.setQueryData(Ft.item(s.chainId,a.denom).queryKey,a);return o},staleTime:z.MINUTE})}}function Mt(e){const s=$r(),{data:n}=$.useSuspenseQuery(s(e));return n}function pa(){const e=re(),s=$r();return $.useQueries({queries:e.map(n=>s(n))})}function Ge(e){const s=Mt(e),n=ge(),r=Mt(n),o=Er(e);return a=>{const i=s.find(c=>c.denom===a);if(i)return i;const l=r.find(c=>c.denom===o(a));return l?{...l,denom:a}:{denom:a,symbol:"",decimals:0,logoUrl:gn}}}function xn(e,s){const n=Ge(s),o=$.useQueryClient().getQueryData(Ft.item(s.chainId,e).queryKey);return o||n(e)}function Er(e){const s=ge(),n=Mt(e);return r=>{if(e.metadata?.is_l1)return r;if(r.startsWith("l2/")||r.startsWith("ibc/")){const a=n.find(i=>i.denom===r)?.traces;if(a){for(const i of a)if(i.counterparty.chain_name===s.chain_name)return i.counterparty.base_denom}}const o=s.metadata?.ibc_channels?.find(({chain_id:a,version:i})=>a===e.chain_id&&i==="ics20-1")?.channel_id;return o?j.getIbcDenom(o,r):""}}const Rn="usernames";function fa({restUrl:e,moduleAddress:s}){const n=Z.create({prefixUrl:e});async function r(l){const{moduleAddress:c,moduleName:d,functionName:u,typeArgs:m,args:_}=l,p=`initia/move/v1/accounts/${c}/modules/${d}/view_functions/${u}`,f={type_args:m,args:_},{data:g,message:b}=await n.post(p,{json:f}).json();if(b)throw new Error(b);return JSON.parse(g)}async function o(l){if(!j.InitiaAddress.validate(l))return null;const c=await r({moduleAddress:s,moduleName:Rn,functionName:"get_name_from_address",typeArgs:[],args:[H.toBase64(j.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:Rn,functionName:"get_address_from_name",typeArgs:[],args:[Fo.bcs.string().serialize(l.toLowerCase().replace(".init","")).toBase64()]});return c?j.InitiaAddress(c).bech32:null}return{restUrl:e,getUsername:o,getAddress:i,validateUsername:a}}const Kt=$e.createQueryKeys("interwovenkit:account",{username:(e,s)=>[e,s],address:(e,s)=>[e,s],balances:(e,s)=>[e,s],txs:(e,s)=>[e,s]});function Tr(){const{restUrl:e}=ge(),{usernamesModuleAddress:s}=fe();return fa({restUrl:e,moduleAddress:s})}function qr(){const e=te();return s=>$.queryOptions({queryKey:Kt.balances(s.restUrl,e).queryKey,queryFn:()=>kr(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:s.restUrl},"balances"),staleTime:z.SECOND})}function yn(e){const s=qr(),{data:n}=$.useSuspenseQuery(s(e));return n}function ga(){const e=re(),s=qr();return $.useQueries({queries:e.map(n=>s(n))})}function xa(e){const s=yn(e),n=Mt(e),r=Ge(e),o=Er(e),{data:a}=fs(e),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>n.some(d=>d.denom===c);return v.sortWith([v.descend(({denom:c})=>o(c)==="uinit"),v.descend(({denom:c})=>i(c)),v.descend(({value:c})=>c),v.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>B(d).comparedTo(c)??0,v.descend(({symbol:c})=>c.toLowerCase())],s.filter(({amount:c})=>!B(c).isZero()).map(({amount:c,denom:d})=>{const u=r(d),m=a?.find(({id:p})=>p===u?.denom)?.price??0,_=B(c).times(m).div(B(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:m,value:_}}))}function te(){const e=js();return e?j.InitiaAddress(e).bech32:""}function js(){const{address:e}=we.useAccount();return e?j.InitiaAddress(e).hex:""}function bt(){const e=zt(),s=te(),n=js();return e.metadata?.minitia?.type==="minievm"?n:s}function Dr(){const e=bt(),s=Tr();return $.useQuery({queryKey:Kt.username(s.restUrl,e).queryKey,queryFn:()=>s.getUsername(e),enabled:!!e,staleTime:z.MINUTE})}function xe(){const e=bt(),s=te(),n=js(),{data:r}=Dr(),o=vt(),{isDrawerOpen:a,openDrawer:i}=wt(),l=()=>{i("/")},c=()=>{i("/connect")},d=m=>{i("/bridge",m)},u=Sr();return{address:e,initiaAddress:s,hexAddress:n,username:r,offlineSigner:o,isOpen:a,openConnect:c,openWallet:l,openBridge:d,...u}}function ya(){const e=["initia-wallet-widget:last-connected-wallet","initia-wallet-widget:fee-denoms","initia-wallet-widget:chain-ids","initia-wallet-widget:opened-layers-assets","initia-wallet-widget:opened-layers-nft"],s={"initia-wallet-widget:ethereum-public-keys":{prefix:O.PUBLIC_KEY,getSuffix:n=>j.InitiaAddress(n).bech32}};for(const n of e)localStorage.removeItem(n);for(const[n,{prefix:r,getSuffix:o}]of Object.entries(s)){const a=localStorage.getItem(n);if(a)try{const i=JSON.parse(a);for(const[l,c]of Object.entries(i)){const d=`${r}:${o(l)}`;localStorage.setItem(d,c)}localStorage.removeItem(n)}catch{}}}const ja="_status_tn9m1_1",va="_error_tn9m1_9",Bn={status:ja,error:va},Y=({error:e,children:s})=>t.jsx("p",{className:D(Bn.status,{[Bn.error]:e}),children:s}),ye=({errorBoundaryProps:e={fallbackRender:({error:r})=>t.jsx(Y,{error:!0,children:r.message})},suspenseFallback:s=t.jsx(Y,{children:"Loading..."}),children:n})=>t.jsx(lr.ErrorBoundary,{...e,children:t.jsx(h.Suspense,{fallback:s,children:n})}),pe=$e.createQueryKeys("interwovenkit:skip",{chains:null,assets:e=>[e],asset:(e,s)=>[e,s],balances:(e,s)=>[e,s],route:(e,s)=>[e,s],routeErrorInfo:e=>[e],txTrack:(e,s)=>[e,s],txStatus:(e,s)=>[e,s]});function Ye(){const{routerApiUrl:e}=fe();return h.useMemo(()=>Z.create({prefixUrl:e}),[e])}function Pr(){const e=re();return s=>e.some(n=>n.chain_id===s)}function Ht(){const e=Pr();return s=>e(s.chain_id)?"initia":s.chain_type}function Ot(e){return Ht()(e)}function jn(){const e=Ye(),{data:s}=$.useSuspenseQuery({queryKey:pe.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:n})=>v.sortWith([v.descend(({chain_name:r})=>r==="initia"),v.ascend(({pretty_name:r})=>r)],n),staleTime:z.MINUTE});return s}function dt(){const e=jn();return s=>{const n=e.find(r=>r.chain_id===s);if(!n)throw new Error(`Chain not found: ${s}`);return n}}function ke(e){return dt()(e)}function yt(e){const s=Ye(),n=$.useQueryClient(),{data:r}=$.useSuspenseQuery({queryKey:pe.assets(e).queryKey,queryFn:()=>s.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:o})=>{const{assets:a}=o[e]??{assets:[]};for(const i of a)n.setQueryData(pe.asset(e,i.denom).queryKey,i);return a.toSorted(v.descend(i=>i.symbol==="INIT"))},staleTime:z.MINUTE});return r}function Rr(e){const s=yt(e);return n=>{const r=s.find(o=>o.denom===n);if(!r)throw new Error(`Asset not found: ${n}`);return r}}function Re(e,s){return Rr(s)(e)}const vn=h.createContext(null);function ct(){const{container:e}=h.useContext(vn);return e}function Br(e){const s=ct();return s?getComputedStyle(s).getPropertyValue(e):""}const wa=({children:e})=>{const[s,n]=h.useState(null);return t.jsx(vn.Provider,{value:{container:s,setContainer:n},children:e})},ba="_loader_4gdsk_1",Ca={loader:ba},Je=({size:e=24,color:s="currentColor",border:n=2})=>{const r={width:`${e}px`,height:`${e}px`,borderColor:`${s} ${s} transparent ${s}`,borderWidth:`${n}px`};return t.jsx("div",{className:Ca.loader,style:r})},Ia="_container_1zg8z_1",Na="_toast_1zg8z_10",Sa="_info_1zg8z_23",Aa="_success_1zg8z_27",ka="_error_1zg8z_31",$a="_icon_1zg8z_36",Ea="_content_1zg8z_43",Ta="_title_1zg8z_46",qa="_description_1zg8z_51",Da="_close_1zg8z_72",Le={container:Ia,toast:Na,info:Sa,success:Aa,error:ka,icon:$a,content:Ea,title:Ta,description:qa,close:Da},Pa=({notification:e,onClose:s,...n})=>{const r=oe.useTransition(e,{keys:a=>a?.id||"empty",from:{transform:"translateY(-52px)",opacity:0},enter:{transform:"translateY(0px)",opacity:1},leave:{transform:"translateY(-52px)",opacity:0},config:{tension:500,friction:30,clamp:!0}}),o=a=>{switch(a){case"loading":return t.jsx(Je,{size:16});case"info":case"success":return t.jsx(A.IconCheckCircleFilled,{size:16});case"error":return t.jsx(A.IconCloseCircleFilled,{size:16});default:return null}};return r((a,i)=>{if(!i)return null;const{type:l,title:c,description:d}=i,u=o(l);return t.jsx(oe.animated.div,{style:a,className:Le.container,children:t.jsxs("div",{className:D(Le.toast,l&&Le[l]),...n,children:[u&&t.jsx("div",{className:Le.icon,children:u}),t.jsxs("div",{className:Le.content,children:[t.jsx("p",{className:Le.title,children:c}),d&&t.jsx("div",{className:Le.description,children:d})]}),t.jsx("button",{className:Le.close,onClick:s,children:t.jsx(A.IconClose,{size:14})})]})})})},Fr=h.createContext(null),wn=()=>h.useContext(Fr),Ps=5e3,Ra=({children:e})=>{const s=ct(),[n,r]=h.useState(null),o=h.useRef(null),a=h.useRef(!1),i=()=>{o.current&&(clearTimeout(o.current),o.current=null)},l=h.useCallback(()=>{i(),r(null)},[]),c=h.useCallback(_=>{i(),r({..._,id:Dn.nanoid()}),_.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Ps))},[l]),d=h.useCallback(_=>{i(),r(p=>p?{...p,..._}:{..._,id:Dn.nanoid()}),_.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Ps))},[l]),u=()=>{i(),a.current=!0},m=()=>{i(),a.current=!1,n?.autoHide&&(o.current=setTimeout(()=>l(),Ps))};return h.useEffect(()=>()=>i(),[]),t.jsxs(Fr.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,s&&un.createPortal(t.jsx(Pa,{notification:n,onClose:l,onMouseEnter:u,onMouseLeave:m}),s)]})},Mr=h.createContext(!1),Ba="_overlay_1tsd9_1",Fa="_fullscreen_1tsd9_12",Ma="_content_1tsd9_16",Oa="_header_1tsd9_43",Ua="_title_1tsd9_52",La="_close_1tsd9_57",Xe={overlay:Ba,fullscreen:Fa,content:Ma,header:Oa,title:Ua,close:La},Or=({title:e,children:s,trigger:n,className:r,open:o,onOpenChange:a})=>{const i=ct(),l=h.useContext(Mr);h.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=oe.useTransition(o,{from:{opacity:0},enter:{opacity:1},leave:{opacity:0},config:{tension:500,friction:30,clamp:!0}}),d=oe.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?t.jsxs(t.Fragment,{children:[n&&t.jsx("button",{type:"button",className:r,onClick:()=>a(!0),children:n}),un.createPortal(t.jsxs(t.Fragment,{children:[c((u,m)=>m&&t.jsx(oe.animated.div,{style:u,className:D(Xe.overlay,{[Xe.fullscreen]:l}),onClick:()=>a(!1),onKeyDown:()=>a(!1),role:"button",tabIndex:0})),d((u,m)=>m&&t.jsxs(oe.animated.div,{style:u,className:D(Xe.content,{[Xe.fullscreen]:l}),children:[e&&t.jsxs("header",{className:Xe.header,children:[t.jsx("h2",{className:Xe.title,children:e}),t.jsx("button",{type:"button",className:Xe.close,onClick:()=>a(!1),children:t.jsx(A.IconClose,{size:20})})]}),s]}))]}),i)]}):null},za=10;function Ur(){const e=te();return s=>$.queryOptions({queryKey:Kt.txs(s.indexerUrl,e).queryKey,queryFn:async()=>{const n={"pagination.reverse":!0,"pagination.limit":za};return Z.create({prefixUrl:s.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:n}).json()},select:n=>n.txs,staleTime:z.SECOND})}function Ka(e){const s=Ur();return $.useSuspenseQuery(s(e))}function Ha(e,s){const n=e.flatMap((r,o)=>(s[o]??[]).map(i=>({...i,chain:r})));return v.sortWith([v.descend(r=>new Date(r.timestamp).getTime())])(n)}const Wa=()=>{const e=re(),s=Ur(),n=$.useQueries({queries:e.map(i=>s(i))}),r=n.map(v.prop("data")),o=Ha(e,r),a=n.some(i=>i.isLoading);return{activities:o,isLoading:a}};function Lr(e){const{data:s}=$.useSuspenseQuery({queryKey:fn.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:r}=await Z.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return r.toSorted(v.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const i=o==="uinit"?1:ur;return{amount:B(a).times(i).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:r})=>{if(v.isNil(r))throw new Error(`${n} has no price`);return{amount:String(r),denom:n}})},staleTime:z.SECOND});return s}function zr(e){const s=te(),{data:n}=Ka(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{return n.find(({tx:a})=>a.auth_info.signer_infos.some(i=>j.InitiaAddress.equals(s,it.computeAddress(`0x${H.toHex(Ys.Secp256k1.uncompressPubkey(H.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??r}catch{return r}}const Qa="_root_hypwm_1",Va="_item_hypwm_10",Ga="_chevron_hypwm_14",Ya="_trigger_hypwm_19",Ja="_content_hypwm_39",At={root:Qa,item:Va,chevron:Ga,trigger:Ya,content:Ja};function Za(e){const{list:s,getKey:n,renderHeader:r,renderContent:o,footer:a,...i}=e;return t.jsxs(U.Accordion.Root,{className:At.root,type:"multiple",...i,children:[s.map((l,c)=>t.jsxs(U.Accordion.Item,{className:At.item,value:n?.(l)??String(c),children:[t.jsx(U.Accordion.Header,{children:t.jsxs(U.Accordion.Trigger,{className:At.trigger,children:[r(l),t.jsx(A.IconChevronDown,{className:At.chevron,size:16})]})}),t.jsx(U.Accordion.Content,{className:At.content,children:o(l)})]},n?.(l)??c)),a]})}const Xa="_scrollable_abvhw_1",ei={scrollable:Xa},Me=({className:e,children:s,ref:n})=>t.jsx("div",{ref:n,className:D(ei.scrollable,e),children:s}),Xs=({children:e})=>{const s=h.useRef(null),[n,r]=h.useState(0),o=oe.useSpring({height:n,config:{tension:500,friction:30,clamp:!0}});return h.useEffect(()=>{if(s.current){const{height:a}=s.current.getBoundingClientRect();r(a)}},[e]),e?t.jsx(oe.animated.div,{style:{overflow:"hidden",...o},children:t.jsx("div",{ref:s,children:e})}):null},ti="_help_7m3jv_1",si="_icon_7m3jv_10",ni="_info_7m3jv_17",ri="_warning_7m3jv_21",oi="_error_7m3jv_25",ai="_success_7m3jv_31",Rs={help:ti,icon:si,info:ni,warning:ri,error:oi,success:ai},He=({level:e,className:s,mt:n=8,children:r})=>{if(!r)return null;const o=()=>{switch(e){case"loading":return t.jsx(Je,{size:12});case"info":return t.jsx(A.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(A.IconWarningFilled,{size:12});default:return t.jsx(A.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:D(Rs.help,e&&Rs[e],s),style:{marginTop:n},children:[t.jsx("div",{className:Rs.icon,children:o()}),t.jsx("p",{children:r})]})},ii="_stack_14kq8_1",ci="_help_14kq8_6",li="_info_14kq8_14",di="_warning_14kq8_19",ui="_error_14kq8_24",mi="_success_14kq8_29",en={stack:ii,help:ci,info:li,warning:di,error:ui,success:mi},hi=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(Xs,{children:t.jsx("div",{className:en.stack,children:e})}),ne=e=>t.jsx(He,{...e,className:D(en.help,en[e.level]),mt:0});ne.Stack=hi;const _i="_footer_xif7g_1",pi="_actions_xif7g_10",Fn={footer:_i,actions:pi},ae=({extra:e,className:s,children:n})=>t.jsxs("footer",{className:D(Fn.footer,s),children:[e,t.jsx("div",{className:Fn.actions,children:n})]}),fi="_button_1n7c4_1",gi="_outline_1n7c4_25",xi="_sm_1n7c4_43",yi="_full_1n7c4_49",ji="_small_1n7c4_53",vi="_unpadded_1n7c4_83",rt={button:fi,outline:gi,sm:xi,full:yi,small:ji,unpadded:vi},Kr=e=>{const{sm:s,fullWidth:n,loading:r,className:o,children:a,disabled:i,...l}=e;return t.jsx("button",{...l,className:D(rt.button,{[rt.sm]:s,[rt.full]:n},o),disabled:!!r||i,children:r?t.jsxs(t.Fragment,{children:[t.jsx(Je,{color:"currentColor",size:16}),typeof r=="string"&&t.jsx("span",{className:rt.loading,children:r})]}):a})},wi=({className:e,...s})=>t.jsx(Kr,{...s,className:D(rt.outline,e)}),bi=({className:e,unpadded:s,...n})=>t.jsx("button",{...n,className:D(rt.small,{[rt.unpadded]:s},e)}),V={White:Kr,Outline:wi,Small:bi},Ci="_item_1n572_1",Ii="_title_1n572_10",Ni="_content_1n572_14",Bs={item:Ci,title:Ii,content:Ni},Fs=({title:e,content:s})=>t.jsxs("div",{className:Bs.item,children:[t.jsx("div",{className:Bs.title,children:e}),t.jsx("div",{className:Bs.content,children:s})]});function Qe(e){if(e&&B(e).gt(0)&&B(e).lt(.01))return"<$0.01";const s=j.formatNumber(e,{dp:2});return s?`$${s}`:""}const Si="_placeholder_9cmx1_1",Ai="_logo_9cmx1_5",Mn={placeholder:Si,logo:Ai},K=({src:e,alt:s,placeholder:n,classNames:r,style:o,logo:a,...i})=>{const[l,c]=h.useState(!1),{width:d,height:u}=i,m=n??t.jsx("div",{className:D(Mn.placeholder,r?.placeholder),style:{width:d,height:u,...o}});return h.useEffect(()=>{c(!1)},[e]),!e||l?m:t.jsx("img",{...i,className:D(i.className,{[Mn.logo]:a}),style:{width:d,height:u,...o},src:e,alt:s,loading:"lazy",onError:()=>c(!0)})};function Hr(e,s){const n={};for(const r of e)if(r.attributes.some(a=>a.key==="msg_index")){if(r.type==="coin_spent"){const a=r.attributes.find(l=>l.key==="spender")?.value,i=r.attributes.find(l=>l.key==="amount")?.value;if(a===s&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=n[c]||BigInt(0);n[c]=d-BigInt(l)}}}if(r.type==="coin_received"){const a=r.attributes.find(l=>l.key==="receiver")?.value,i=r.attributes.find(l=>l.key==="amount")?.value;if(a===s&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=n[c]||BigInt(0);n[c]=d+BigInt(l)}}}}return Object.entries(n).filter(([,r])=>r!==BigInt(0)).map(([r,o])=>({amount:o.toString(),denom:r}))}function Wr(e,s){const n={};for(const r of e)if(r.attributes.some(a=>a.key==="msg_index")&&r.type==="move"){const a=r.attributes.find(c=>c.key==="type_tag")?.value,i=r.attributes.find(c=>c.key==="data")?.value;if(!a||!i)continue;let l;try{l=JSON.parse(i)}catch{continue}if(a==="0x1::fungible_asset::WithdrawEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&j.createUserDerivedObjectAddress(s,u)===c){const _=n[u]||BigInt(0);n[u]=_-BigInt(d)}}if(a==="0x1::fungible_asset::DepositEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&j.createUserDerivedObjectAddress(s,u)===c){const _=n[u]||BigInt(0);n[u]=_+BigInt(d)}}}return Object.entries(n).filter(([,r])=>r!==BigInt(0)).map(([r,o])=>({amount:o.toString(),metadata:r}))}const Qr=({metadata:e,chain:s,children:n})=>{const{restUrl:r}=s,{data:o}=$.useSuspenseQuery({queryKey:Ft.denom(r,e).queryKey,queryFn:()=>Z.create({prefixUrl:r}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:a})=>a,staleTime:z.INFINITY});return n(o)},ki="_root_jioyr_1",$i="_title_jioyr_7",Ei="_changes_jioyr_13",Ti="_change_jioyr_13",qi="_amount_jioyr_34",Di="_text_jioyr_40",Pi="_value_jioyr_47",ot={root:ki,title:$i,changes:Ei,change:Ti,amount:qi,text:Di,value:Pi},Vr=({amount:e,asset:s,price:n})=>{const{denom:r,symbol:o,decimals:a,logoUrl:i}=s,l=j.formatAmount(e,{decimals:a}),c=n&&B(j.fromBaseUnit(e,{decimals:a})).times(n).abs();return t.jsxs("div",{className:ot.change,children:[t.jsxs("div",{className:ot.amount,children:[t.jsx(K,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:ot.text,children:[l," ",o||r]})]}),c&&t.jsx("div",{className:ot.value,children:Qe(c)})]})},Ri=({changes:e,chain:s})=>{const n=Ge(s),{data:r}=fs(s);return e.map(({amount:o,denom:a},i)=>{const l=n(a),c=r?.find(({id:d})=>d===a)?.price;return t.jsx(Vr,{amount:o,asset:l,price:c},i)})},Bi=({changes:e,chain:s})=>{const n=Ge(s),{data:r}=fs(s);return e.map(({amount:o,metadata:a},i)=>t.jsx(Qr,{metadata:a,chain:s,children:l=>{const c=r?.find(({id:d})=>d===l)?.price;return t.jsx(Vr,{amount:o,asset:n(l),price:c})}},i))};function Fi(e,s){return typeof s=="bigint"?s.toString():s}const Mi=$e.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Fi)]}),Oi=({messages:e,memo:s,chainId:n})=>{const{initiaAddress:r,hexAddress:o}=xe(),a=Fe(n),{simulateTx:i}=Sr(),{data:l}=$.useSuspenseQuery({queryKey:Mi.simulate({messages:e,memo:s,chainId:n}).queryKey,queryFn:()=>i({messages:e,memo:s,chainId:n}),staleTime:z.SECOND}),c=_=>t.jsxs("div",{className:ot.root,children:[t.jsx("h2",{className:ot.title,children:"Estimated changes"}),t.jsx("div",{className:ot.changes,children:_})]});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 _=Wr(d,o),[p]=On(_);return p.length===0?null:c(t.jsx(Bi,{changes:p,chain:a}))}const u=Hr(d,r),[m]=On(u);return m.length===0?null:c(t.jsx(Ri,{changes:m,chain:a}))};function On(e){return v.partition(s=>new B(s.amount).isNegative(),e)}const Ui="_trigger_13rgr_1",Li="_icon_13rgr_5",zi="_content_13rgr_16",Ki="_item_13rgr_24",Jt={trigger:Ui,icon:Li,content:zi,item:Ki},Hi=({options:e,value:s,onChange:n})=>{const r=ct(),{txRequest:o}=Nr(),a=Fe(o.chainId),i=Ge(a),l=({amount:[{amount:c,denom:d}]})=>{if(B(c).isZero())return"0";const{symbol:u,decimals:m}=i(d);return`${j.formatAmount(c,{decimals:m})} ${u}`};return e.length===1?l(e[0]):t.jsxs(U.Select.Root,{value:s,onValueChange:n,children:[t.jsxs(U.Select.Trigger,{className:Jt.trigger,children:[t.jsx(U.Select.Value,{}),t.jsx(U.Select.Icon,{className:Jt.icon,children:t.jsx(A.IconChevronDown,{size:16})})]}),t.jsx(U.Select.Portal,{container:r,children:t.jsx(U.Select.Content,{className:Jt.content,position:"popper",sideOffset:6,align:"end",children:t.jsx(U.Select.Viewport,{children:e.map(c=>{const[{denom:d}]=c.amount;return t.jsx(U.Select.Item,{className:Jt.item,value:d,children:t.jsx(U.Select.ItemText,{children:l(c)})},d)})})})})]})};function ds(e){switch(typeof e){case"string":return e;case"number":case"bigint":return e.toString();case"boolean":return e?"true":"false";case"object":return e===null?"null":e instanceof Uint8Array?H.toBase64(e):Array.isArray(e)?`[${e.map(ds).join(",")}]`:JSON.stringify(e,(s,n)=>typeof n=="bigint"?n.toString():n);default:return"unknown"}}const Wi="_container_1xzyq_1",Qi="_toggle_1xzyq_5",Vi="_list_1xzyq_11",Gi="_arg_1xzyq_16",Yi="_type_1xzyq_21",kt={container:Wi,toggle:Qi,list:Vi,arg:Gi,type:Yi},Ji=$e.createQueryKeys("interwovenkit:move",{abi:(e,s,n,r)=>[e,s,n,r]}),Zi=({type:e,arg:s})=>ds(j.resolveBcsType(e).parse(s)),Xi=({msg:e,chainId:s,fallback:n})=>{const[r,o]=be.useToggle(!1),{restUrl:a}=Fe(s),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=$.useQuery({queryKey:Ji.abi(a,i,l,c).queryKey,queryFn:async()=>{const _=await Z.create({prefixUrl:a}).get(`initia/move/v1/accounts/${i}/modules/${l}`).json(),f=JSON.parse(_.module.abi).exposed_functions.find(({name:g})=>g===c);if(!f)throw new Error(`Function ${c} not found in module ${l}`);return f.params.filter(g=>!g.startsWith("&"))},staleTime:z.INFINITY});if(!u)return n;const m=(_,p)=>{const f=u[p];return t.jsxs("div",{className:kt.arg,children:[t.jsx("div",{className:kt.type,children:f}),t.jsx(lr.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(Zi,{type:f,arg:_})})]},p)};return t.jsxs("div",{className:kt.container,children:[t.jsx(V.Small,{className:kt.toggle,onClick:o,disabled:!u,children:r?"Encode":"Decode"}),r?t.jsx("div",{className:kt.list,children:d.map(m)}):n]})},ec="_list_r67rl_1",tc="_key_r67rl_8",sc="_value_r67rl_13",Ms={list:ec,key:tc,value:sc},nc=({message:e,chainId:s})=>{const{typeUrl:n,value:r}=e;return t.jsx("div",{className:Ms.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{children:[t.jsx("div",{className:Ms.key,children:o}),t.jsx("div",{className:Ms.value,children:n==="/initia.move.v1.MsgExecute"&&o==="args"?t.jsx(Xi,{msg:r,chainId:s,fallback:ds(a)}):ds(a)})]},o))})},rc="_title_kspdu_1",oc="_meta_kspdu_7",ac="_footer_kspdu_14",Os={title:rc,meta:oc,footer:ac},Gr=()=>{const{txRequest:e,resolve:s,reject:n}=Nr(),{messages:r,memo:o,chainId:a,gas:i,gasAdjustment:l,spendCoins:c}=e,d=te(),u=vt(),m=jr(),_=Fe(a),p=yn(_),f=Lr(_),g=zr(_),b=(e.gasPrices??f).map(({amount:x,denom:k})=>Ae.calculateFee(Math.ceil(i*l),Ae.GasPrice.fromString(x+k))),C=b.map(x=>x.amount[0]),w=x=>{const k=p.find(q=>q.denom===x)?.amount??0,R=C.find(q=>q.denom===x)?.amount??0,S=c.filter(q=>q.denom===x).reduce((q,F)=>B(q).plus(F.amount),B(0));if(S.gt(0)){const q=B(R).plus(S);return B(k).gte(q)}return B(k).gte(R)},P=()=>{if(g&&w(g))return g;for(const{denom:x}of C)if(w(x))return x;return C[0]?.denom},[E,y]=h.useState(P),{mutate:T,isPending:N}=$.useMutation({mutationKey:[Cr],mutationFn:async()=>{const x=b.find(R=>R.amount[0].denom===E);if(!x)throw new Error("Fee not found");if(!u)throw new Error("Signer not initialized");const k=await m(a,d,r,x,o);await s(k)},onError:async x=>{n(new Error(await Ve(x)))}}),I=!w(E);return t.jsxs(t.Fragment,{children:[t.jsxs(Me,{children:[t.jsx("h1",{className:Os.title,children:"Confirm tx"}),t.jsxs("div",{className:Os.meta,children:[t.jsx(Fs,{title:"Chain",content:a}),t.jsx(Fs,{title:"Tx fee",content:t.jsx(Hi,{options:b,value:E,onChange:y})}),o&&t.jsx(Fs,{title:"Memo",content:o}),I&&t.jsx(ne,{level:"error",children:"Insufficient balance for fee"})]}),t.jsx(Oi,{messages:r,memo:o,chainId:a}),t.jsx(Za,{list:r,renderHeader:({typeUrl:x})=>_s.sentenceCase(x.split(".").pop().replace(/^Msg/,"")),renderContent:x=>t.jsx(nc,{message:x,chainId:a})})]}),t.jsxs(ae,{className:Os.footer,children:[t.jsx(V.Outline,{onClick:()=>n(new Error("User rejected")),disabled:N,children:"Reject"}),t.jsx(V.White,{onClick:()=>T(),disabled:I,loading:N,children:"Approve"})]})]})},ic=({children:e})=>{const[{title:s,content:n,path:r},o]=h.useState({}),[a,i]=h.useState(!1),l=W.useAtomValue(ys),c=h.useCallback(m=>{o(m),i(!0)},[]),d=h.useCallback(()=>{o({}),i(!1)},[]),u=h.useCallback(m=>{m||(l?.reject(new Error("User rejected")),o({})),i(m)},[l]);return t.jsxs(fr.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(Or,{title:s,open:a,onOpenChange:u,children:t.jsx(ye,{children:r==="/tx"?t.jsx(Gr,{}):n})})]})};function vs(){return be.useMediaQuery("(max-width: 576px)")}const tn="interwoven-kit";function Yr(){const e=document.querySelector(tn)||document.body.appendChild(document.createElement(tn));return e.shadowRoot||e.attachShadow({mode:"open"})}function cc(){const{theme:e,container:s}=fe();return h.useEffect(()=>{document.querySelector(tn)?.setAttribute("data-theme",e)},[e]),s??Yr()}function lc(e){const s=Yr(),n=document.createElement("style");n.textContent=e,s.appendChild(n)}const bn=({value:e,children:s})=>{const[n,r]=h.useState(!1);return s({copy:async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1e3)}catch{}},copied:n})},dc="_tooltip_6zakp_1",uc="_arrow_6zakp_43",Un={tooltip:dc,arrow:uc},Ct=({label:e,children:s,small:n,...r})=>t.jsxs(U.Tooltip.Root,{...r,children:[t.jsx(U.Tooltip.Trigger,{asChild:!0,children:s}),t.jsx(U.Tooltip.Portal,{container:ct(),children:t.jsxs(U.Tooltip.Content,{className:D(Un.tooltip,{small:n}),collisionBoundary:ct(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(U.Tooltip.Arrow,{className:Un.arrow})]})})]}),mc="_root_1pbnr_1",hc="_address_1pbnr_9",_c="_copy_1pbnr_19",pc="_labelWrapper_1pbnr_33",fc="_labelCopy_1pbnr_43",gc="_labelCopied_1pbnr_47",xc="_copied_1pbnr_55",et={root:mc,address:hc,copy:_c,labelWrapper:pc,labelCopy:fc,labelCopied:gc,copied:xc},yc=()=>{const e=h.useRef(null),s=h.useRef(null),{initiaAddress:n,hexAddress:r}=xe(),o=Br("--gray-0");return h.useEffect(()=>{e.current&&(s.current?s.current.update({data:n}):(s.current=new Mo({type:"canvas",width:400,height:400,margin:0,data:n,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:o},cornersSquareOptions:{type:"extra-rounded",color:o},cornersDotOptions:{type:"dot",color:o},backgroundOptions:{color:"transparent"}}),s.current.append(e.current)))},[n,o]),t.jsxs("div",{className:et.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx(Ct,{label:`Derived from ${j.truncate(r)}`,children:t.jsx("span",{className:et.address,children:n})}),t.jsx(bn,{value:n,children:({copy:a,copied:i})=>t.jsxs("button",{className:D(et.copy,{[et.copied]:i}),onClick:a,children:[t.jsx(A.IconCopy,{size:12}),t.jsxs("div",{className:et.labelWrapper,children:[t.jsx("span",{className:et.labelCopy,children:"Copy address"}),t.jsx("span",{className:et.labelCopied,children:"Copied!"})]})]})})]})},jc="_header_1cvtq_1",vc="_account_1cvtq_16",wc="_name_1cvtq_27",bc="_address_1cvtq_31",Cc="_icon_1cvtq_35",Ic="_copied_1cvtq_42",Nc="_button_1cvtq_57",Sc="_qr_1cvtq_68",Ac="_disconnect_1cvtq_72",kc="_label_1cvtq_82",$c="_expanded_1cvtq_90",me={header:jc,account:vc,name:wc,address:bc,icon:Cc,copied:Ic,button:Nc,qr:Sc,disconnect:Ac,label:kc,expanded:$c},Ec=()=>{const e=de(),s=zt(),{connector:n}=we.useAccount(),{disconnect:r}=we.useDisconnect(),{address:o,username:a}=xe(),{closeDrawer:i}=wt(),{openModal:l}=Lt(),c=a??o,[d,u]=h.useState(!1),m=h.useRef(null),_=oe.useSpring({width:d?140:52,config:{tension:500,friction:30,clamp:!0}}),p=()=>{d?(e("/blank"),i(),r(),localStorage.removeItem(O.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(O.BRIDGE_SRC_DENOM),localStorage.removeItem(O.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(O.BRIDGE_DST_DENOM),localStorage.removeItem(O.BRIDGE_QUANTITY),localStorage.removeItem(O.BRIDGE_SLIPPAGE_PERCENT)):u(!0)},f=()=>{d&&(m.current=setTimeout(()=>{u(!1)},500))},g=()=>{m.current&&(clearTimeout(m.current),m.current=null)};return h.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),n?t.jsxs("header",{className:me.header,children:[t.jsx(bn,{value:o,children:({copy:b,copied:C})=>t.jsxs("button",{className:D(me.account,{[me.copied]:C}),onClick:b,children:[t.jsx(K,{src:n.icon,width:18,height:18}),t.jsx("div",{className:me.address,children:j.truncate(o)}),t.jsx("div",{className:me.name,children:j.truncate(c)}),t.jsx(A.IconCopy,{className:me.icon,size:12}),C?"Copied!":""]})}),s.metadata?.is_l1&&t.jsx("button",{className:D(me.button,me.qr),onClick:()=>l({title:"Initia address",content:t.jsx(yc,{})}),children:t.jsx(A.IconQrCode,{size:16})}),t.jsxs(oe.animated.button,{className:D(me.button,me.disconnect,{[me.expanded]:d}),style:_,onClick:p,onMouseLeave:f,onMouseEnter:g,children:[t.jsx(A.IconSignOut,{size:16}),t.jsx("span",{className:me.label,children:"Disconnect"})]})]}):null};function Tc(e){return/^[A-F0-9]{64}$/i.test(e)}function qc(e,s){const{txHash:n,accountAddress:r,pathSuffix:o}=s;if(n)return Tc(n)?v.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,n):void 0;if(r){if(!j.InitiaAddress.validate(r))return;const i=v.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,r);return i&&o?i+o:i}}function Dc(e){try{const s=new URL(e,window.location.href);if(!["http:","https:"].includes(s.protocol))throw new Error("Invalid protocol");return s.toString()}catch{return"#"}}const Pc="_link_guafb_1",Ln={link:Pc},ws=({chainId:e,txHash:s,accountAddress:n,pathSuffix:r,...o})=>{const{showIcon:a,className:i,children:l,onClick:c,...d}=o,u=Fe(e),m=qc(u,{txHash:s,accountAddress:n,pathSuffix:r}),_=s?j.truncate(s):n?j.truncate(n):"",p=l??_;return m?t.jsxs("a",{...d,href:Oo(Dc(m)),className:D(Ln.link,i),onClick:c,target:"_blank",children:[p,a&&t.jsx(A.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:D(Ln.link,i),children:p})},Rc=()=>{const[e,s]=W.useAtom(Ir),{showNotification:n,updateNotification:r,hideNotification:o}=wn();return h.useEffect(()=>{if(!e)return;const{status:a,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(ws,{txHash:l,chainId:i,onClick:o,showIcon:!0,children:"View on Initia Scan"}):null;switch(a){case"loading":n({type:"loading",title:"Transaction is pending..."});break;case"error":r({type:"error",title:"Transaction failed",description:d}),s(null);break;case"success":r({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),s(null);break}},[e,s,n,r,o]),null};function Bc(){return be.useScrollLock(),null}const Fc="_overlay_g3vaj_1",Mc="_content_g3vaj_49",Oc="_inner_g3vaj_67",Us={overlay:Fc,content:Mc,inner:Oc},Uc=({children:e})=>{const{isDrawerOpen:s,closeDrawer:n}=wt(),{setContainer:r}=h.useContext(vn),o=vs(),a=W.useAtomValue(ys),i=$.useIsMutating({mutationKey:[Cr]}),l=()=>{const p=i?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";n(),a?.reject(new Error(p))},c=_n(),d=de(),u=$.useQueryClient(),m={fallbackRender:({error:p,resetErrorBoundary:f})=>{const g=()=>{c==="/bridge"&&(localStorage.removeItem(O.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(O.BRIDGE_SRC_DENOM),localStorage.removeItem(O.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(O.BRIDGE_DST_DENOM)),d("/"),u.clear(),f()};return t.jsxs(Me,{children:[t.jsx(Y,{error:!0,children:p.message}),t.jsx(ae,{children:t.jsx(V.White,{onClick:g,children:"Retry"})})]})}},_=oe.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(t.jsxs(t.Fragment,{children:[_((p,f)=>f?t.jsx(oe.animated.button,{style:p,className:Us.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),_((p,f)=>f?t.jsx(oe.animated.div,{style:p,className:D(Us.content),children:t.jsxs("div",{className:D(Us.inner,"body"),ref:r,children:[o&&t.jsx(Bc,{}),t.jsx(Rc,{}),t.jsx(Ec,{}),t.jsx(ye,{errorBoundaryProps:m,children:e})]})}):null)]}),cc())},Lc="_page_1f6wh_1",zc="_title_1f6wh_10",Kc="_scrollable_1f6wh_17",Hc="_list_1f6wh_22",Wc="_item_1f6wh_32",Qc="_name_1f6wh_56",Vc="_dimmed_1f6wh_64",Gc="_recent_1f6wh_68",Yc="_installed_1f6wh_69",je={page:Lc,title:zc,scrollable:Kc,list:Hc,item:Wc,name:Qc,dimmed:Vc,recent:Gc,installed:Yc},Jc=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],zn=({onSuccess:e})=>{const{connectors:s,connectAsync:n}=we.useConnect(),r=be.useReadLocalStorage("wagmi.recentConnectorId"),[o,a]=h.useState(null),{mutate:i,isPending:l}=$.useMutation({mutationFn:async c=>{a(c.id);try{await n({connector:c})}catch(d){throw new Error(await Ve(d))}},onSettled:()=>{a(null)},onSuccess:()=>{e?.()}});return t.jsxs("div",{className:je.page,children:[t.jsx("h1",{className:je.title,children:"Connect wallet"}),t.jsx(Me,{className:je.scrollable,children:t.jsxs("div",{className:je.list,children:[s.toSorted(v.descend(c=>c.id===r)).map(c=>{const{name:d,icon:u,id:m}=c;return t.jsxs("button",{className:je.item,onClick:()=>i(c),disabled:l,children:[t.jsx(K,{src:u,width:24,height:24}),t.jsx("span",{className:je.name,children:d}),o===m?t.jsx(Je,{size:16}):r===m?t.jsx("span",{className:je.recent,children:"Recent"}):t.jsx("span",{className:je.installed,children:"Installed"})]},m)}),Jc.filter(({name:c})=>!s.some(d=>d.name.includes(c))).map(({name:c,url:d})=>{const u=`https://assets.initia.xyz/images/wallets/${c}.webp`;return t.jsxs("a",{href:d,className:je.item,target:"_blank",children:[t.jsx(K,{src:u,width:24,height:24}),t.jsx("span",{className:D(je.name,je.dimmed),children:c}),t.jsx(A.IconExternalLink,{size:10})]},c)})]})})]})};function Zc(e){return e.chains.reduce((s,{quantity:n})=>s.plus(n),B(0)).toString()}function Jr(e){return e.chains.reduce((s,{value:n})=>s+n,0)}function Xc(e){return v.sortWith([v.descend(({asset:s})=>s.symbol==="INIT"),v.descend(Jr),v.descend(({chains:s})=>s.length),v.ascend(({asset:s})=>s.symbol)])(e)}function el(e){return v.sortWith([v.descend(v.prop("value")),v.descend(({quantity:s})=>Number(s)),v.ascend(({chain:s})=>s.name)])(e)}function tl(e){return{asset:e.asset,chains:[e]}}function sl(e,s){return{...e,chains:[...e.chains,s]}}function Kn(e){const s=Object.values(e.reduce((n,r)=>{const o=r.asset.symbol,a=n[o];return{...n,[o]:a?sl(a,r):tl(r)}},{}));return Xc(s).map(n=>({...n,chains:el(n.chains)}))}function nl(e,s,n,r){const{denom:o,amount:a}=s,i=j.fromBaseUnit(a,{decimals:n.decimals}),l=Number(i)*r;return{denom:o,amount:a,quantity:i,price:r,value:l,chain:e,asset:n}}function rl(e,s){const{denom:n,amount:r}=s,o=j.fromBaseUnit(r,{decimals:0});return{denom:n,amount:r,quantity:o,price:0,value:0,chain:e,asset:{denom:n,symbol:n,decimals:0,logoUrl:gn}}}function ol(e,s,n,r){return s.filter(({amount:o})=>B(o).gt(0)).reduce((o,a)=>{const i=n.find(({denom:c})=>c===a.denom),l=i?nl(e,a,i,r[a.denom]??0):rl(e,a);return i?{...o,supported:[...o.supported,l]}:{...o,unsupported:[...o.unsupported,l]}},{supported:[],unsupported:[]})}function al(e,s){const n=e.reduce((r,{chain:o,value:a})=>{const i=r[o.chainId];return{...r,[o.chainId]:{chain:o,totalValue:(i?.totalValue??0)+a}}},{});return v.sortWith([v.descend(({chain:r})=>r.chainId===s),v.descend(({totalValue:r})=>r)])(Object.values(n))}function il(e,s,n,r,o){const{supported:a,unsupported:i}=r.reduce((l,c,d)=>{const u=e[d]??[],m=s[d]??[],_=n[d]??[],p=Object.fromEntries(_.map(({id:b,price:C})=>[b,C])),{supported:f,unsupported:g}=ol(c,u,m,p);return{supported:[...l.supported,...f],unsupported:[...l.unsupported,...g]}},{supported:[],unsupported:[]});return{assetGroups:Kn(a),unsupportedAssetGroups:Kn(i),chainPortfolios:al(a,o),totalValue:a.reduce((l,{value:c})=>l+c,0)}}const Zr=()=>{const{defaultChainId:e}=fe(),s=re(),n={balances:ga(),assets:pa(),prices:sa()},r={balances:n.balances.map(v.prop("data")),assets:n.assets.map(v.prop("data")),prices:n.prices.map(v.prop("data"))},o=Object.values(n).some(i=>i.some(({isLoading:l})=>l));return{...il(r.balances,r.assets,r.prices,s,e),isLoading:o}},cl="_root_xwz5z_1",ll="_header_xwz5z_6",dl="_title_xwz5z_12",ul="_warning_xwz5z_18",ml="_content_xwz5z_22",hl="_footer_xwz5z_26",_l="_secondary_xwz5z_36",tt={root:cl,header:ll,title:dl,warning:ul,content:ml,footer:hl,secondary:_l},Xr=e=>{const{type:s,icon:n,title:r,children:o,primaryButton:a,secondaryButton:i}=e;return t.jsxs(Me,{className:tt.root,children:[t.jsxs("header",{className:D(tt.header,s&&tt[s]),children:[n,t.jsx("h1",{className:tt.title,children:r})]}),t.jsx("div",{className:tt.content,children:o}),t.jsxs("footer",{className:tt.footer,children:[t.jsx(V.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),t.jsxs("button",{className:tt.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(A.IconChevronRight,{size:14})]})]})]})},pl="_list_tmcxc_1",fl="_row_tmcxc_8",gl="_dt_tmcxc_19",xl="_asset_tmcxc_25",Zt={list:pl,row:fl,dt:gl,asset:xl},yl=({list:e,onNavigate:s,onDismiss:n})=>{const r=ge(),o=Be(),a=Ge(r);return t.jsx(Xr,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:s},secondaryButton:{label:"Do not show again",onClick:n},children:t.jsx("div",{className:Zt.list,children:e.toSorted((i,l)=>i.chainId.localeCompare(l.chainId)).map(({txHash:i,chainId:l,amount:c,denom:d})=>{const u=o(l),{decimals:m,symbol:_}=a(d),p=j.formatAmount(c,{decimals:m});return t.jsxs("div",{className:Zt.row,children:[t.jsxs("div",{className:Zt.dt,children:[t.jsx(K,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:Zt.asset,children:[p," ",_]})]},i)})})})};function Ls(e,s){return e.chainId===s.chainId&&e.txHash===s.txHash}const Xt=({chainId:e,txHash:s})=>`${O.OP_REMINDER}:${e}:${s}`,jl=Uo.atomWithStorage(O.OP_REMINDER,[]);function It(){const e=te(),[s=[],n]=W.useAtom(jl),r=h.useMemo(()=>s.map(c=>{const d=localStorage.getItem(Xt(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:Ut.isPast(u)}),[e,s]),o=h.useCallback((c,d)=>{s.some(u=>Ls(u,c))||(n((u=[])=>[...u,c]),localStorage.setItem(Xt(c),JSON.stringify(d)))},[s,n]),a=h.useCallback(c=>{n((d=[])=>d.filter(u=>!Ls(u,c))),localStorage.removeItem(Xt(c))},[n]),i=h.useCallback(c=>{const d=c.filter(u=>!s.some(m=>Ls(m,u)));d.length!==0&&n((u=[])=>[...u,...d])},[s,n]),l=h.useCallback((c,d)=>{localStorage.setItem(Xt(c),JSON.stringify(d)),n((u=[])=>[...u])},[n]);return{reminders:r,addReminder:o,removeReminder:a,syncReminders:i,setReminder:l}}function eo(){const e=de(),{openModal:s,closeModal:n}=Lt(),{reminders:r,setReminder:o}=It();h.useEffect(()=>{const a=r.filter(c=>!c.dismissed);if(a.length===0)return;const i=()=>{const c=a.every(d=>d.chainId===a[0].chainId)?a[0].chainId:void 0;e("/op/withdrawals",{chainId:c}),l()},l=()=>{n();for(const c of a)o(c,{...c,dismissed:!0})};s({content:h.createElement(yl,{list:a,onNavigate:i,onDismiss:l})})},[r,n,e,s,o])}const to=h.createContext(null);function so(){return h.useContext(to)}const vl="_root_7yxgy_1",wl="_label_7yxgy_7",bl="_input_7yxgy_19",Cl="_hasValue_7yxgy_29",Il="_clear_7yxgy_33",$t={root:vl,label:wl,input:bl,hasValue:Cl,clear:Il},bs=e=>{const{rootClassName:s,padding:n=16,iconSize:r=16,onClear:o,ref:a,...i}=e;return t.jsxs("div",{className:D($t.root,s,{[$t.hasValue]:i.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${r}px`},children:[t.jsx("label",{htmlFor:"search",className:$t.label,children:t.jsx(A.IconSearch,{size:r})}),t.jsx("input",{className:$t.input,id:"search",type:"text",maxLength:100,ref:a,...i}),i.value&&t.jsx("button",{type:"button",className:$t.clear,"aria-label":"Clear search",onMouseDown:l=>l.preventDefault(),onClick:o,children:t.jsx(A.IconCloseCircleFilled,{size:r})})]})},Nl="_container_t1267_1",Sl="_controls_t1267_7",Al="_search_t1267_13",Cn={container:Nl,controls:Sl,search:Al},kl=({children:e})=>t.jsx("div",{className:Cn.container,children:e}),$l=({children:e})=>t.jsx("div",{className:Cn.controls,children:e}),El=e=>t.jsx(bs,{...e,rootClassName:Cn.search}),We={Root:kl,Controls:$l,SearchInput:El};function Wt(){const e=h.useRef(null),s=vs();return h.useEffect(()=>{s||e.current?.focus()},[s]),e}const Tl="_trigger_13nwp_1",ql="_icon_13nwp_21",Dl="_full_13nwp_25",Pl="_triggerContent_13nwp_30",Rl="_triggerText_13nwp_38",Bl="_popoverBackdrop_13nwp_49",Fl="_popoverPositioner_13nwp_71",Ml="_popoverPopup_13nwp_75",Ol="_search_13nwp_103",Ul="_viewport_13nwp_108",Ll="_item_13nwp_113",zl="_highlighted_13nwp_127",Kl="_itemContent_13nwp_132",ce={trigger:Tl,icon:ql,full:Dl,triggerContent:Pl,triggerText:Rl,popoverBackdrop:Bl,popoverPositioner:Fl,popoverPopup:Ml,search:Ol,viewport:Ul,item:Ll,highlighted:zl,itemContent:Kl},In=({value:e,onChange:s,chainIds:n,fullWidth:r})=>{const[o,a]=h.useState(""),[i,l]=h.useState(!1),[c,d]=h.useState(0),[u,m]=h.useState(),_=h.useRef([]),p=h.useRef(null),g=re().filter(x=>n.includes(x.chainId)),b=x=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:x,height:x,viewBox:"0 0 14 14",children:[t.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),t.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),C=h.useMemo(()=>({chainId:"",name:"All rollups",logoUrl:b}),[]),w=h.useMemo(()=>{const x=[C,...g];if(!o)return x;const k=o.toLowerCase();return x.filter(R=>R.name.toLowerCase().includes(k)||R.chainId.toLowerCase().includes(k))},[g,o,C]),P=g.find(x=>x.chainId===e)||C,E=parseInt(Br("--drawer-offset")),y=6,T=()=>{if(a(""),d(-1),p.current){const k=p.current.getBoundingClientRect().bottom+y,R=window.innerHeight-k-2*E;m(R)}l(!0)};h.useEffect(()=>{c>=0&&c<_.current.length&&_.current[c]?.scrollIntoView({block:"nearest",behavior:"auto"})},[c]);const N=h.useCallback(x=>{switch(x.key){case"ArrowDown":x.preventDefault(),d(k=>(k+1)%w.length);break;case"ArrowUp":x.preventDefault(),d(k=>(k-1+w.length)%w.length);break;case"Enter":x.preventDefault(),w[c]&&(s(w[c].chainId),l(!1));break;case"Escape":x.preventDefault(),l(!1);break}},[w,c,s,l]),I=x=>{s(x),l(!1)};return t.jsxs(_t.Popover.Root,{open:i,onOpenChange:T,children:[t.jsx(_t.Popover.Trigger,{render:t.jsxs("button",{className:D(ce.trigger,{[ce.full]:r}),"aria-expanded":i,role:"listbox",ref:p,children:[t.jsxs("div",{className:ce.triggerContent,children:[typeof P.logoUrl=="string"?t.jsx(K,{src:P.logoUrl,width:14,height:14,logo:!0}):P.logoUrl(14),t.jsx("span",{className:ce.triggerText,children:P.name})]}),t.jsx(A.IconChevronDown,{size:16,className:ce.icon})]})}),t.jsxs(_t.Popover.Portal,{container:ct(),children:[t.jsx(_t.Popover.Backdrop,{className:ce.popoverBackdrop,onClick:()=>l(!1)}),t.jsx(_t.Popover.Positioner,{className:ce.popoverPositioner,align:"end",side:"bottom",sideOffset:y,children:t.jsxs(_t.Popover.Popup,{className:D(ce.popoverPopup,{[ce.full]:r}),style:{maxHeight:u},children:[t.jsx(bs,{value:o,onChange:x=>{a(x.target.value),d(0)},onClear:()=>a(""),onKeyDown:N,placeholder:"Search rollups",rootClassName:ce.search,ref:Wt()}),t.jsx("div",{className:ce.viewport,role:"listbox",children:w.length===0?t.jsx(Y,{children:"No rollups found"}):w.map(({chainId:x,name:k,logoUrl:R},S)=>t.jsxs("div",{className:D(ce.item,{[ce.highlighted]:S===c}),onClick:()=>I(x),onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),I(x))},onMouseEnter:()=>d(S),role:"option","aria-selected":e===x,tabIndex:-1,ref:q=>{q&&(_.current[S]=q)},children:[t.jsxs("div",{className:ce.itemContent,children:[typeof R=="string"?t.jsx(K,{src:R,width:18,height:18,logo:!0}):R(18),t.jsx("span",{children:k})]}),e===x&&t.jsx(A.IconCheckCircleFilled,{size:14})]},x))})]})})]})]})},Hl="2.0.0-rc.6",Wl="_version_1sf5y_1",Ql={version:Wl},Vl=()=>t.jsxs("aside",{className:Ql.version,children:["v",Hl]}),Gl=W.atom(""),Yl=W.atom(""),Jl=W.atom(""),Zl=W.atom(""),Xl=W.atom(""),ed="_popup_dx6lq_1",td="_item_dx6lq_9",es={popup:ed,item:td},no=({denom:e,chain:s,children:n,isUnsupported:r})=>{const[o,a]=h.useState(!1),i=de(),l=so(),{showNotification:c}=wn(),{defaultChainId:d}=fe(),{evm_chain_id:u}=zt(),m=we.useChainId(),{address:_="",symbol:p,decimals:f,logoUrl:g}=xn(e,s),{switchChainAsync:b}=we.useSwitchChain(),{watchAssetAsync:C}=we.useWatchAsset(),{chainId:w}=s,P=()=>{a(!1),i("/send",{denom:e,chain:s})},E=()=>{a(!1),i("/bridge",{srcChainId:w,srcDenom:e,quantity:""})},y=$.useMutation({mutationFn:async()=>(await b({chainId:Number(u)}),C({type:"ERC20",options:{address:_,symbol:p,decimals:f,image:g}})),onSuccess:()=>{c({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:T=>{c({type:"error",title:"Asset addition failed",description:T.message})}});return t.jsxs(Ue.Menu.Root,{open:o,onOpenChange:a,modal:!1,children:[t.jsx(Ue.Menu.Trigger,{render:n}),t.jsx(Ue.Menu.Portal,{container:l.current,children:t.jsx(Ue.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(Ue.Menu.Popup,{className:es.popup,children:[t.jsxs(Ue.Menu.Item,{className:es.item,onClick:P,children:[t.jsx(A.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(Ue.Menu.Item,{className:es.item,onClick:E,disabled:r,children:[t.jsx(A.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),w===d&&u===m&&!!_&&t.jsxs(Ue.Menu.Item,{className:es.item,onClick:()=>y.mutate(),disabled:y.isPending||y.data,children:[y.data?t.jsx(A.IconCheck,{size:16}):t.jsx(A.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},sd="_images_cj4xz_1",zs={images:sd},Cs=({assetLogoUrl:e,assetLogoSize:s=36,chainLogoUrl:n,chainLogoSize:r=18,chainLogoOffset:o=6,className:a})=>t.jsxs("div",{className:D(zs.images,a),style:{position:"relative"},children:[t.jsx(K,{src:e,width:s,height:s,className:zs.asset,logo:!0}),t.jsx(K,{src:n,width:r,height:r,className:zs.chain,style:{position:"absolute",bottom:0,right:-1*o},logo:!0})]}),nd="_item_knoro_1",rd="_info_knoro_22",od="_images_knoro_28",ad="_name_knoro_32",id="_value_knoro_38",cd="_amount_knoro_46",ld="_usd_knoro_52",st={item:nd,info:rd,images:od,name:ad,value:id,amount:cd,usd:ld},dd=({chainBalance:e,isUnsupported:s})=>{const{chain:n,asset:r,denom:o,amount:a,value:i}=e,l=j.formatAmount(a,{decimals:r.decimals});return t.jsx(no,{denom:o,chain:n,isUnsupported:s,children:t.jsxs("button",{className:st.item,children:[t.jsxs("div",{className:st.info,children:[t.jsx(Cs,{assetLogoUrl:r.logoUrl,chainLogoUrl:n.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:st.images}),t.jsx("span",{className:st.name,children:n.name})]}),t.jsxs("div",{className:st.value,children:[t.jsx("span",{className:st.amount,children:l}),i>0&&t.jsx("span",{className:st.usd,children:Qe(i)})]})]})})},ud="_container_dh0ht_1",md="_assetItem_dh0ht_6",hd="_assetInfo_dh0ht_26",_d="_logo_dh0ht_32",pd="_symbol_dh0ht_36",fd="_chainName_dh0ht_46",gd="_chainInfos_dh0ht_52",xd="_chainLogos_dh0ht_58",yd="_chainLogo_dh0ht_58",jd="_moreChains_dh0ht_69",vd="_expandIcon_dh0ht_81",wd="_expanded_dh0ht_85",bd="_valueColumn_dh0ht_90",Cd="_amount_dh0ht_99",Id="_value_dh0ht_90",Nd="_collapsibleContent_dh0ht_112",Sd="_chainsList_dh0ht_142",J={container:ud,assetItem:md,assetInfo:hd,logo:_d,symbol:pd,chainName:fd,chainInfos:gd,chainLogos:xd,chainLogo:yd,moreChains:jd,expandIcon:vd,expanded:wd,valueColumn:bd,amount:Cd,value:Id,collapsibleContent:Nd,chainsList:Sd},Ad=W.atom([]),ro=({assetGroup:e,isUnsupported:s})=>{const[n,r]=W.useAtom(Ad),{asset:o,chains:a}=e,{symbol:i,logoUrl:l}=o,c=a.length===1,d=h.useMemo(()=>Zc(e),[e]),u=h.useMemo(()=>Jr(e),[e]),m=n.includes(i),_=()=>{r(f=>m?v.without([i],f):v.uniq([...f,i]))},p=()=>t.jsxs("button",{className:J.assetItem,children:[t.jsxs("div",{className:J.assetInfo,children:[l&&t.jsx(K,{src:l,width:32,height:32,className:J.logo,logo:!0}),t.jsxs("div",{className:J.details,children:[t.jsx("div",{className:J.symbol,children:i}),c?t.jsx("div",{className:J.chainName,children:a[0].chain.name}):t.jsxs("div",{className:J.chainInfos,children:[t.jsx("div",{className:J.chainLogos,children:a.slice(0,5).map(f=>t.jsx(K,{src:f.chain.logoUrl,width:16,height:16,className:J.chainLogo,logo:!0},f.chain.chainId))}),a.length>5&&t.jsxs("span",{className:J.moreChains,children:["+",a.length-5]}),t.jsx(A.IconChevronDown,{size:16,className:D(J.expandIcon,{[J.expanded]:m})})]})]})]}),t.jsxs("div",{className:J.valueColumn,children:[t.jsx("div",{className:J.amount,children:j.formatNumber(d,{dp:c?Math.min(o.decimals,6):6})}),u>0&&t.jsx("div",{className:J.value,children:Qe(u)})]})]});if(c){const[{denom:f,chain:g}]=a;return t.jsx("div",{className:J.container,children:t.jsx(no,{denom:f,chain:g,isUnsupported:s,children:p()})})}return t.jsx("div",{className:J.container,children:t.jsxs(U.Collapsible.Root,{open:m,onOpenChange:_,children:[t.jsx(U.Collapsible.Trigger,{asChild:!0,children:p()}),t.jsx(U.Collapsible.Content,{className:J.collapsibleContent,children:t.jsx("div",{className:J.chainsList,children:a.map(f=>t.jsx(dd,{chainBalance:f,isUnsupported:s},f.chain.chainId))})})]})})},kd="_collapsible_1spkj_1",$d="_trigger_1spkj_5",Ed="_divider_1spkj_20",Td="_label_1spkj_26",qd="_chevron_1spkj_31",Dd="_content_1spkj_39",Pd="_list_1spkj_43",ze={collapsible:kd,trigger:$d,divider:Ed,label:Td,chevron:qd,content:Dd,list:Pd},Rd=({unsupportedAssets:e})=>{const[s,n]=h.useState(!1),r=so(),o=h.useRef(null),[a,i]=h.useState(0);h.useEffect(()=>{if(o.current){const c=o.current.scrollHeight;i(c)}},[e]),h.useEffect(()=>{if(!s||!r?.current)return;const c=r.current;c.scrollTo({top:c.scrollHeight,behavior:"auto"});const d=window.setTimeout(()=>{c.scrollTo({top:c.scrollHeight,behavior:"smooth"})},150);return()=>window.clearTimeout(d)},[s,r]);const l=oe.useSpring({height:s?a:0,opacity:s?1:0,config:{tension:500,friction:30,clamp:!0}});return e.length===0?null:t.jsxs(U.Collapsible.Root,{open:s,onOpenChange:n,className:ze.collapsible,children:[t.jsxs(U.Collapsible.Trigger,{className:ze.trigger,children:[t.jsx("div",{className:ze.divider}),t.jsxs("span",{className:ze.label,children:["Unsupported assets (",e.length,")"]}),t.jsx(A.IconChevronDown,{className:ze.chevron,size:12,"data-state":s?"open":"closed"}),t.jsx("div",{className:ze.divider})]}),t.jsx(U.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(oe.animated.div,{className:ze.content,style:l,children:t.jsx("div",{className:ze.list,ref:o,children:e.map(c=>t.jsx(ro,{assetGroup:c,isUnsupported:!0},c.asset.denom))})})})]})},Bd="_list_szwvw_1",Fd={list:Bd},Md=()=>{const[e,s]=W.useAtom(Gl),[n,r]=W.useAtom(Yl),{assetGroups:o,unsupportedAssetGroups:a,chainPortfolios:i,isLoading:l}=Zr(),c=i.map(m=>m.chain.chainId),d=h.useMemo(()=>{const m=e?o.filter(p=>{const{denom:f,symbol:g,name:b="",address:C=""}=p.asset;return f.toLowerCase().includes(e.toLowerCase())||g.toLowerCase().includes(e.toLowerCase())||b.toLowerCase().includes(e.toLowerCase())||C.toLowerCase().includes(e.toLowerCase())}):o;return n?m.map(p=>({...p,chains:p.chains.filter(({chain:f})=>f.chainId===n)})).filter(p=>p.chains.length>0):m},[o,e,n]),u=h.useMemo(()=>{const m=e?a.filter(p=>{const{denom:f}=p.asset;return f.toLowerCase().includes(e.toLowerCase())}):a;return n?m.map(p=>({...p,chains:p.chains.filter(({chain:f})=>f.chainId===n)})).filter(p=>p.chains.length>0):m},[a,e,n]);return l&&o.length===0?t.jsx(Y,{children:"Loading assets..."}):!d.length&&!u.length&&!e&&!n&&!l?t.jsx(Y,{children:"No assets"}):t.jsxs(t.Fragment,{children:[t.jsxs(We.Root,{children:[t.jsxs(We.Controls,{children:[t.jsx(We.SearchInput,{value:e,onChange:m=>s(m.target.value),onClear:()=>s(""),placeholder:"Search assets"}),t.jsx(In,{value:n,onChange:r,chainIds:c})]}),t.jsx("div",{children:d.length===0&&u.length===0?t.jsx(Y,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Fd.list,children:d.map(m=>t.jsx(ro,{assetGroup:m},m.asset.symbol))}),t.jsx(Rd,{unsupportedAssets:u})]})})]}),t.jsx(Vl,{})]})},oo=$e.createQueryKeys("interwovenkit:nft",{nfts:(e,s)=>[e,s],metadata:e=>[e]});function Od(e,s){const{nft:n}=e,r=s.name??n.token_id;return{...e,...n,...s,name:r}}function Ud(e,s){return e.flatMap((n,r)=>(s[r]??[]).map(a=>({...a,chain:n})))}const Ld=()=>{const e=te(),s=re(),n=$.useQueries({queries:s.map(i=>({queryKey:oo.nfts(i.indexerUrl,e).queryKey,queryFn:()=>kr(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:i.indexerUrl},"tokens"),staleTime:z.SECOND}))}),r=n.map(v.prop("data")),o=Ud(s,r),a=n.some(i=>i.isLoading);return{nftInfos:o,isLoading:a}};function zd(e){const s=Hn(e);return $.useQuery({queryKey:oo.metadata(s).queryKey,queryFn:async()=>{try{if(!s)return{};const n=await Z.get(s).json();return{...n,image:Hn(n.image)}}catch{return{}}},staleTime:z.INFINITY})}function Hn(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const Kd="_thumbnail_1lblb_1",Hd="_placeholder_1lblb_16",Wd="_clickable_1lblb_22",Et={thumbnail:Kd,placeholder:Hd,clickable:Wd},Nn=({nftInfo:e,size:s,onClick:n})=>{const{collection_addr:r,object_addr:o,nft:a,chain:i}=e,l=new URL(`/v1/${i.chainId}/${r}/${o||a.token_id}`,"https://glyph.initia.xyz").toString();return n?t.jsx("button",{className:D(Et.thumbnail,Et.clickable),onClick:n,style:{width:s,height:s},children:t.jsx(K,{src:l,classNames:{placeholder:Et.placeholder}})}):t.jsx("div",{className:Et.thumbnail,style:{width:s,height:s},children:t.jsx(K,{src:l,classNames:{placeholder:Et.placeholder}})})},Qd="_nftItem_eopro_1",Vd="_collectionName_eopro_9",Gd="_nftName_eopro_19",Yd="_chainInfo_eopro_29",ts={nftItem:Qd,collectionName:Vd,nftName:Gd,chainInfo:Yd},Jd=({normalizedNft:e})=>{const{collection_name:s,name:n,chain:r}=e,o=de();return t.jsxs("div",{className:ts.nftItem,children:[t.jsx(Nn,{nftInfo:e,onClick:()=>o("/nft",e)}),t.jsxs("div",{children:[t.jsx("div",{className:ts.collectionName,children:s}),t.jsx("div",{className:ts.nftName,children:n}),t.jsxs("div",{className:ts.chainInfo,children:[t.jsx(K,{src:r.logoUrl,width:12,height:12}),t.jsx("span",{children:r.name})]})]})]})},Zd=({nftInfo:e,children:s})=>{const{data:n={}}=zd(e.nft.uri),r=Od(e,n);return s(r)},Xd="_grid_a1fhu_1",eu={grid:Xd},tu=()=>{const[e,s]=W.useAtom(Jl),[n,r]=W.useAtom(Zl),{nftInfos:o,isLoading:a}=Ld(),i=h.useMemo(()=>o.filter(({collection_addr:c,collection_name:d,nft:u,object_addr:m,chain:_})=>{if(n&&_.chainId!==n)return!1;if(e){const p=e.trim().toLowerCase();return c.toLowerCase().includes(p)||d.toLowerCase().includes(p)||u.token_id.toLowerCase().includes(p)||m.toLowerCase().includes(p)}return!0}),[o,n,e]),l=h.useMemo(()=>Array.from(new Set(o.map(({chain:c})=>c.chainId))),[o]);return a&&o.length===0?t.jsx(Y,{children:"Loading NFTs..."}):!o.length&&!e&&!a?t.jsx(Y,{children:"No NFTs"}):t.jsxs(We.Root,{children:[t.jsxs(We.Controls,{children:[t.jsx(We.SearchInput,{value:e,onChange:c=>s(c.target.value),onClear:()=>s(""),placeholder:"Search nfts"}),t.jsx(In,{value:n,onChange:r,chainIds:l})]}),i.length===0?t.jsx(Y,{children:"No NFTs found"}):t.jsx("div",{className:eu.grid,children:i.map(c=>t.jsx(Zd,{nftInfo:c,children:d=>t.jsx(Jd,{normalizedNft:d})},c.object_addr))})]})},su="_message_1g2hc_1",nu="_more_1g2hc_8",Wn={message:su,more:nu},ru=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((s,n)=>t.jsx("p",{className:Wn.message,children:_s.sentenceCase(s["@type"].split("Msg")[1])},n)),e.length>3&&t.jsx("footer",{className:Wn.more,children:`+${e.length-3} more`})]}),ou="_change_1x9v4_1",au="_positive_1x9v4_10",iu="_negative_1x9v4_14",Ks={change:ou,positive:au,negative:iu},ao=({amount:e,asset:s})=>{const{denom:n,symbol:r,decimals:o}=s,a=new B(e).isPositive(),i=new B(e).abs().toString();return t.jsxs("div",{className:D(Ks.change,a?Ks.positive:Ks.negative),children:[a?"+":"-",j.formatAmount(i,{decimals:o})," ",r||n]})},cu=({changes:e,chain:s})=>{const n=Ge(s);return e.map(({amount:r,denom:o},a)=>t.jsx(ao,{amount:r,asset:n(o)},a))},lu=({changes:e,chain:s})=>{const n=Ge(s);return e.map(({amount:r,metadata:o},a)=>t.jsx(Qr,{metadata:o,chain:s,children:i=>t.jsx(ao,{amount:r,asset:n(i)})},a))},du=({events:e,chain:s})=>{const{initiaAddress:n,hexAddress:r}=xe();return s.metadata?.is_l1||s.metadata?.minitia?.type==="minimove"?t.jsx(lu,{changes:Wr(e,r),chain:s}):t.jsx(cu,{changes:Hr(e,n),chain:s})},uu="_link_13w9m_1",mu="_inner_13w9m_15",hu="_header_13w9m_20",_u="_chainInfo_13w9m_26",pu="_error_13w9m_36",fu="_content_13w9m_46",gu="_messages_13w9m_53",xu="_changes_13w9m_58",Ke={link:uu,inner:mu,header:hu,chainInfo:_u,error:pu,content:fu,messages:gu,changes:xu},yu=({txItem:e,chain:s})=>t.jsx(ws,{txHash:e.txhash,chainId:s.chainId,className:Ke.link,children:t.jsxs("div",{className:Ke.inner,children:[t.jsxs("div",{className:Ke.header,children:[t.jsxs("div",{className:Ke.chainInfo,children:[t.jsx(K,{src:s.logoUrl,width:12,height:12}),t.jsx("span",{children:s.name})]}),e.code!==0&&t.jsxs("div",{className:Ke.error,children:[t.jsx(A.IconWarningFilled,{size:12}),t.jsx("span",{children:"Failed"})]})]}),t.jsxs("div",{className:Ke.content,children:[t.jsx("div",{className:Ke.messages,children:t.jsx(ru,{messages:e.tx.body.messages})}),t.jsx("div",{className:Ke.changes,children:t.jsx(ye,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(du,{...e,chain:s})})})]})]})}),ju="_list_1wa9p_1",vu="_dateGroup_1wa9p_7",wu="_dateHeader_1wa9p_12",bu="_more_1wa9p_18",ss={list:ju,dateGroup:vu,dateHeader:wu,more:bu},Cu=({list:e,chainId:s})=>{const n=te(),r=h.useMemo(()=>e.reduce((o,a)=>{const l=new Date(a.timestamp).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),c=o[l]||[];return{...o,[l]:[...c,a]}},{}),[e]);return e.length===0?t.jsx(Y,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ss.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{className:ss.dateGroup,children:[t.jsx("div",{className:ss.dateHeader,children:o}),a.map(i=>t.jsx(yu,{txItem:i,chain:i.chain},i.txhash))]},o))}),t.jsx(ws,{chainId:s,accountAddress:n,pathSuffix:"/txs",className:ss.more,showIcon:!0,children:"View more on Initia Scan"})]})},Iu=()=>{const{activities:e,isLoading:s}=Wa(),[n,r]=W.useAtom(Xl),o=ge(),a=h.useMemo(()=>Array.from(new Set(e.map(l=>l.chain.chainId))),[e]),i=h.useMemo(()=>n?e.filter(l=>l.chain.chainId===n):e,[e,n]);return s&&e.length===0?t.jsx(Y,{children:"Loading activities..."}):!e.length&&!s?t.jsx(Y,{children:"No activity yet"}):t.jsxs(We.Root,{children:[t.jsx(We.Controls,{children:t.jsx(In,{value:n,onChange:r,chainIds:a,fullWidth:!0})}),t.jsx(Cu,{list:i,chainId:n||o.chainId})]})},Nu="_totalValue_1udv1_1",Su="_totalLabel_1udv1_7",Au="_totalAmount_1udv1_13",ku="_loading_1udv1_18",$u="_nav_1udv1_23",Eu="_item_1udv1_28",Tu="_tabs_1udv1_51",qu="_tab_1udv1_51",ve={totalValue:Nu,totalLabel:Su,totalAmount:Au,loading:ku,nav:$u,item:Eu,tabs:Tu,tab:qu},Du=()=>{eo();const e=de(),s=_n(),{totalValue:n,isLoading:r}=Zr(),o=h.useRef(null);return t.jsx(to.Provider,{value:o,children:t.jsxs(Me,{ref:o,children:[t.jsxs("div",{className:ve.totalValue,children:[t.jsx("div",{className:ve.totalLabel,children:"Total value"}),t.jsx("div",{className:D(ve.totalAmount,{[ve.loading]:r}),children:Qe(n)})]}),t.jsxs("div",{className:ve.nav,children:[t.jsxs(pn,{to:"/send",className:ve.item,children:[t.jsx(A.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs("button",{className:ve.item,onClick:()=>e("/bridge"),children:[t.jsx(A.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]})]}),t.jsxs(Oe.Tabs.Root,{value:s,onValueChange:e,children:[t.jsxs(Oe.Tabs.List,{className:ve.tabs,children:[t.jsx(Oe.Tabs.Tab,{className:ve.tab,value:"/",children:"Assets"}),t.jsx(Oe.Tabs.Tab,{className:ve.tab,value:"/nfts",children:"NFTs"}),t.jsx(Oe.Tabs.Tab,{className:ve.tab,value:"/activity",children:"Activity"})]}),t.jsx(Oe.Tabs.Panel,{value:"/",children:t.jsx(Md,{})}),t.jsx(Oe.Tabs.Panel,{value:"/nfts",children:t.jsx(tu,{})}),t.jsx(Oe.Tabs.Panel,{value:"/activity",children:t.jsx(Iu,{})})]})]})})};function io({quantity:e,balance:s,decimals:n},r){if(B.BigNumber(e).isZero()){r.addIssue({code:G.z.ZodIssueCode.custom,message:"Enter amount",path:["quantity"]});return}if(!s||B.BigNumber(j.toBaseUnit(e,{decimals:n})).gt(s)){r.addIssue({code:G.z.ZodIssueCode.custom,message:"Insufficient balance",path:["quantity"]});return}}const co=G.z.string().nonempty("Recipient address is required").refine(e=>j.InitiaAddress.validate(e),"Invalid address"),Pu="_header_acels_1",Ru="_back_acels_11",Bu="_title_acels_23",Hs={header:Pu,back:Ru,title:Bu},ut=({title:e,returnTo:s,extra:n,children:r})=>t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Hs.header,children:[s!==!1&&t.jsx(pn,{to:s??-1,className:Hs.back,children:t.jsx(A.IconBack,{size:16})}),t.jsx("h1",{className:Hs.title,children:e}),n]}),t.jsx(Me,{children:r})]}),Fu="_fieldset_y241y_1",Mu="_upper_y241y_9",Ou="_select_y241y_14",Uu="_account_y241y_19",Lu="_lower_y241y_24",zu="_wrapper_y241y_25",Ku="_balance_y241y_32",Hu="_value_y241y_36",Wu="_error_y241y_49",De={fieldset:Fu,upper:Mu,select:Ou,account:Uu,lower:Lu,wrapper:zu,balance:Ku,value:Hu,error:Wu},sn=e=>{const{selectButton:s,accountButton:n,quantityInput:r,balanceButton:o,value:a,errorMessage:i}=e;return t.jsxs("div",{className:De.fieldset,children:[t.jsxs("div",{className:De.upper,children:[t.jsx("div",{className:De.select,children:s}),t.jsx("div",{className:De.account,children:n})]}),t.jsxs("div",{className:De.lower,children:[r,t.jsxs("div",{className:De.wrapper,children:[t.jsx("div",{className:De.balance,children:o}),a&&t.jsx("div",{className:De.value,children:a})]}),i&&t.jsxs("footer",{className:De.error,children:[t.jsx(A.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})},jt=({title:e,content:s,children:n,className:r})=>{const[o,a]=h.useState(!1),i=()=>a(!1);return t.jsx(Or,{title:e,trigger:n,className:r,open:o,onOpenChange:a,children:s(i)})},Qu="_root_1ipwv_1",Vu="_content_1ipwv_10",Gu="_details_1ipwv_18",Yu="_symbol_1ipwv_23",Ju="_chain_1ipwv_31",Zu="_chevron_1ipwv_40",nt={root:Qu,content:Vu,details:Gu,symbol:Yu,chain:Ju,chevron:Zu},lo=({asset:e,chain:s,readOnly:n})=>{const r=t.jsxs("div",{className:nt.content,children:[t.jsx(Cs,{assetLogoUrl:e.logoUrl,chainLogoUrl:s.logoUrl}),t.jsxs("div",{className:nt.details,children:[t.jsx("div",{className:nt.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:nt.chain,children:["on ",s.name]})]})]});return n?t.jsx("div",{className:nt.root,children:r}):t.jsxs("div",{className:nt.root,children:[r,t.jsx(A.IconChevronDown,{size:16,className:nt.chevron})]})},Xu="_wrapper_5ssm8_1",em="_balance_5ssm8_11",tm="_button_5ssm8_15",Ws={wrapper:Xu,balance:em,button:tm},uo=({onClick:e,children:s,disabled:n})=>t.jsxs("div",{className:Ws.wrapper,children:[t.jsx(A.IconWallet,{size:16}),t.jsx("span",{className:Ws.balance,children:s}),t.jsx("button",{type:"button",className:Ws.button,onClick:()=>e(),disabled:n,children:"MAX"})]}),sm="_input_h8073_1",nm={input:sm};function rm(e,s){const n=e.replace(/[^0-9.]/g,""),[r,...o]=n.split(".");return o.length===0?r:`${r}.${o.join("").slice(0,s)}`}function mo(e){const{name:s,control:n,dp:r=6,className:o,...a}=e,i=Wt();return t.jsx(le.Controller,{name:s,control:n,render:({field:l})=>t.jsx("input",{...l,className:D(nm.input,o),onChange:c=>l.onChange(rm(c.target.value,r)),placeholder:"0",inputMode:"decimal",autoComplete:"off",...a,ref:dr.mergeRefs([l.ref,i])})})}const om="_input_qpv94_1",am="_placeholder_qpv94_18",nn={input:om,placeholder:am},im=({children:e})=>t.jsx("p",{className:D(nn.input,{[nn.placeholder]:B(e).isZero()}),children:e}),us=()=>{const{control:e}=le.useFormContext();return t.jsx(mo,{name:"quantity",control:e,className:nn.input})};us.ReadOnly=im;const cm="_label_9417z_1",lm="_wrapper_9417z_7",dm="_input_9417z_10",um="_clear_9417z_18",ns={label:cm,wrapper:lm,input:dm,clear:um},Sn=({mode:e="onChange",myAddress:s,...n})=>{const{validate:r=j.InitiaAddress.validate,chainType:o="initia",onApply:a,ref:i}=n,l=Wt(),{getValues:c,setValue:d,formState:u}=le.useFormContext(),m=c("recipient"),[_,p]=h.useState(m),f=Tr(),{data:g,isLoading:b,error:C}=$.useQuery({queryKey:Kt.address(f.restUrl,_).queryKey,queryFn:()=>f.getAddress(_),staleTime:z.MINUTE,enabled:f.validateUsername(_)}),w=g??(r(_)?_:""),P=s&&j.InitiaAddress.equals(w,s),E=async()=>{try{const N=await navigator.clipboard.readText();p(N.trim())}catch{}};h.useEffect(()=>{e==="onChange"&&(!_&&!u.dirtyFields.recipient||d("recipient",g??_,{shouldValidate:!0,shouldDirty:!0}))},[u.dirtyFields.recipient,_,e,d,g]);const y=()=>{b||C||(d("recipient",w,{shouldValidate:!0,shouldDirty:!0}),a?.())},T=()=>{if(b)return t.jsx(He,{level:"loading",children:"Resolving username..."});if(C)return t.jsx(He,{level:"error",children:C.message});if(g)return t.jsx(He,{level:"success",className:"monospace",children:g});if(e==="onSubmit"&&_&&!w)return t.jsx(He,{level:"error",children:"Invalid address"});if(e==="onChange")return t.jsx(He,{level:"error",children:u.errors.recipient?.message})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:ns.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(V.Small,{type:"button",onClick:E,children:"Paste"})]}),t.jsxs("div",{className:ns.wrapper,children:[t.jsx("input",{id:"recipient",className:D(ns.input,"monospace"),value:_,onChange:N=>p(N.target.value.trim()),placeholder:o==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":_?"true":void 0,ref:e==="onSubmit"?dr.mergeRefs([i,l]):i}),!!_&&t.jsx("button",{type:"button",className:ns.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:t.jsx(A.IconCloseCircleFilled,{size:16})})]}),T(),P&&t.jsx(He,{children:"This is my address"}),e==="onSubmit"&&t.jsx(ae,{extra:(!s||!!w&&!P)&&t.jsx(ne,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:t.jsx(V.White,{type:"button",onClick:y,disabled:b||!!C||!w,children:"Apply"})})]})};function mm({balances:e,gasPrices:s,gas:n}){return s.map(({denom:r,amount:o})=>{const a=B(o).times(n).toFixed(0,B.ROUND_CEIL),i=e.find(l=>l.denom===r)?.amount??"0";return{amount:a,denom:r,balance:i}}).filter(({amount:r,balance:o})=>B(o).gte(r))}function hm({denom:e,balances:s,gasPrices:n,lastFeeDenom:r,gas:o}){const a=s.find(d=>d.denom===e)?.amount??"0",i=mm({balances:s,gasPrices:n,gas:o}),l=i.find(d=>d.denom===r);if(i.length===0)return a;if(e===r&&l){const d=B(a).minus(l.amount);return B.max(d,0).toString()}const c=i.find(d=>d.denom!==e)||i[0];if(!l&&e===c.denom){const d=B(a).minus(c.amount);return B.max(d,0).toString()}return B(a).toString()}const _m="_container_1a4ds_1",pm="_badge_1a4ds_5",Qn={container:_m,badge:pm},ho=e=>{const{offset:s=-4,disabled:n,children:r,className:o}=e;return t.jsxs("div",{className:D(Qn.container,o),children:[r,!n&&t.jsx("div",{className:Qn.badge,style:{right:s,top:s}})]})},fm="_stack_a3b9q_1",gm="_title_a3b9q_8",xm="_grid_a3b9q_15",ym="_item_a3b9q_21",jm="_button_a3b9q_25",vm="_active_a3b9q_43",ft={stack:fm,title:gm,grid:xm,item:ym,button:jm,active:vm},at=({label:e,chains:s,value:n,onSelect:r,getShowIndicator:o})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:ft.title,children:e}),t.jsx("div",{className:ft.grid,children:s.map(({chainId:a,name:i,logoUrl:l})=>t.jsx(ho,{offset:-2,disabled:!o?.(a),className:ft.item,children:t.jsx(Ct,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:D(ft.button,{[ft.active]:a===n}),onClick:()=>r(a),children:t.jsx(K,{src:l,width:28,height:28,logo:!0})})})},a))})]}),wm=({children:e})=>t.jsx("div",{className:ft.stack,children:e});at.Stack=wm;function bm(e,s,n){return n.filter(r=>{const o=e.map(a=>r[a]).map(a=>String(a??"").toLowerCase());return v.any(v.includes(s.toLowerCase()),o)})}const Cm="_container_whbo5_1",Im="_search_whbo5_6",Nm="_list_whbo5_10",Sm="_item_whbo5_16",Am="_logo_whbo5_35",km="_info_whbo5_39",$m="_symbol_whbo5_44",Em="_name_whbo5_51",Tm="_balance_whbo5_57",qm="_value_whbo5_65",_e={container:Cm,search:Im,list:Nm,item:Sm,logo:Am,info:km,symbol:$m,name:Em,balance:Tm,value:qm},Qt=e=>{const{assets:s,onSelect:n,renderAsset:r=(l,c)=>c(l)}=e,[o,a]=h.useState(""),i=bm(["symbol"],o,s);return t.jsxs("div",{className:_e.container,children:[t.jsx(bs,{value:o,onChange:l=>a(l.target.value),onClear:()=>a(""),placeholder:"Search by symbol",rootClassName:_e.search,padding:20,ref:Wt()}),i.length===0?t.jsx(Y,{children:"No assets"}):t.jsx("div",{className:_e.list,children:i.map(l=>t.jsx("button",{type:"button",className:_e.item,onClick:()=>n(l.denom),children:r(l,c=>{const{denom:d,logoUrl:u,symbol:m,name:_,balance:p,decimals:f,value:g=0}=c;return t.jsxs(t.Fragment,{children:[t.jsx(K,{src:u,width:32,height:32,className:_e.logo,logo:!0}),t.jsxs("div",{className:_e.info,children:[t.jsx("div",{className:_e.symbol,children:m||d}),t.jsx("div",{className:_e.name,children:_})]}),t.jsxs("div",{className:_e.balance,children:[p&&t.jsx("div",{children:j.formatAmount(p,{decimals:f})}),g>0&&t.jsx("div",{className:_e.value,children:Qe(g)})]})]})})},l.denom))})]})},Dm=()=>t.jsxs("div",{className:_e.container,children:[t.jsx(bs,{rootClassName:_e.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(Y,{children:"Loading..."})]});Qt.Placeholder=Dm;const Pm=({chain:e,onSelect:s})=>{const n=xa(e);return n.length===0?t.jsx(Y,{children:"No assets"}):t.jsx(Qt,{assets:n,onSelect:s})},Rm=({afterSelect:e})=>{const{watch:s,setValue:n}=le.useFormContext(),{chainId:r}=s(),[o,a]=h.useState(r),i=Fe(o),l=re(),c=d=>{n("chainId",o),n("denom",d),e()};return t.jsxs(t.Fragment,{children:[t.jsx(at.Stack,{children:t.jsx(at,{chains:l,value:o,onSelect:a})}),t.jsx(ye,{suspenseFallback:t.jsx(Qt.Placeholder,{}),children:t.jsx(Pm,{chain:i,onSelect:c})},o)]})},Bm="_fields_brpej_1",Fm="_divider_brpej_11",Vn={fields:Bm,divider:Fm},Mm=$e.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Om=()=>{const{address:e,initiaAddress:s,estimateGas:n,requestTxSync:r}=xe(),{register:o,watch:a,setValue:i,handleSubmit:l,formState:c,trigger:d}=le.useFormContext(),{chainId:u,denom:m,recipient:_,quantity:p,memo:f}=a(),g=Fe(u),b=yn(g),C=Lr(g),w=zr(g),P=xn(m,g),{data:E}=fs(g),{decimals:y}=P,T=b.find(F=>F.denom===m)?.amount??"0",N=E?.find(({id:F})=>F===m)?.price,{data:I=0,isLoading:x}=$.useQuery({queryKey:Mm.gas({chainId:u,denom:m,recipient:_,initiaAddress:s}).queryKey,queryFn:()=>{const F=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Pn.MsgSend.fromPartial({fromAddress:s,toAddress:j.InitiaAddress(_).bech32,amount:[{denom:m,amount:"1"}]})}];return n({messages:F,chainId:u})},staleTime:z.INFINITY}),k=Math.ceil(I*Bt),R=hm({denom:m,balances:b,gasPrices:C,lastFeeDenom:w,gas:k}),{mutate:S,isPending:q}=$.useMutation({mutationFn:({chainId:F,denom:Q,quantity:X,recipient:Ee,memo:Te})=>{const Ce=j.toBaseUnit(X,{decimals:y}),qe=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Pn.MsgSend.fromPartial({fromAddress:s,toAddress:j.InitiaAddress(Ee).bech32,amount:[{denom:Q,amount:Ce}]})}];return r({messages:qe,memo:Te,chainId:F,gas:I,gasAdjustment:Bt,gasPrices:C,spendCoins:[{denom:Q,amount:Ce}],internal:"/"})}});return t.jsx(ut,{title:"Send",children:t.jsxs("form",{onSubmit:l(F=>S(F)),children:[t.jsxs("div",{className:Vn.fields,children:[t.jsx(sn,{selectButton:t.jsx(jt,{title:"Select chain and asset",content:F=>t.jsx(Rm,{afterSelect:()=>{d("quantity"),F()}}),children:t.jsx(lo,{asset:P,chain:g})}),quantityInput:t.jsx(us,{}),balanceButton:t.jsx(uo,{onClick:()=>i("quantity",j.fromBaseUnit(R,{decimals:y}),{shouldValidate:!0}),disabled:C.some(({denom:F})=>F===m)&&x,children:j.formatAmount(T??"0",{decimals:y})}),value:p?N?Qe(B(p).times(N)):"$-":"$0",errorMessage:c.errors.quantity?.message}),t.jsx("div",{className:Vn.divider}),t.jsx(Sn,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...o("memo"),id:"memo",autoComplete:"off"}),t.jsx(He,{level:"error",children:c.errors.memo?.message})]}),t.jsx(ne.Stack,{children:!f&&t.jsx(ne,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(ae,{children:t.jsx(V.White,{type:"submit",loading:x||q,disabled:!c.isValid,children:"Confirm"})})]})})},Um=G.z.object({chainId:G.z.string().nonempty(),denom:G.z.string().nonempty(),quantity:G.z.string().nonempty("Amount is required"),recipient:co,memo:G.z.string().optional().refine(e=>!e||new Blob([e]).size<=256,"Memo is too long")}),Lm=()=>{const e=lt(),s=zt(),n=Mt(s),[r]=n,{chain:o=s,denom:a=r.denom}=e,i=Be(),l=te(),c=$.useQueryClient(),d=le.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:a,quantity:"",recipient:"",memo:""},resolver:mn.zodResolver(Um.superRefine(({chainId:u,denom:m,quantity:_},p)=>{const f=i(u),{decimals:g}=c.getQueryData(Ft.item(u,m).queryKey)??{decimals:0},C=(c.getQueryData(Kt.balances(f.restUrl,l).queryKey)??[]).find(w=>w.denom===m)?.amount;io({quantity:_,balance:C,decimals:g},p)}))});return t.jsx(le.FormProvider,{...d,children:t.jsx(Om,{})})},zm="_header_wr3q2_1",Km="_collectionName_wr3q2_6",Hm="_name_wr3q2_13",Wm="_chainInfo_wr3q2_19",Qm="_attributes_wr3q2_29",Vm="_title_wr3q2_32",Gm="_count_wr3q2_37",Ym="_item_wr3q2_41",Jm="_type_wr3q2_47",Zm="_value_wr3q2_53",Ne={header:zm,collectionName:Km,name:Hm,chainInfo:Wm,attributes:Qm,title:Vm,count:Gm,item:Ym,type:Jm,value:Zm},Xm=()=>{const e=de(),s=lt(),{collection_name:n,image:r,name:o,attributes:a,chain:i}=s;return t.jsxs(ut,{title:"NFT details",children:[t.jsxs("header",{className:Ne.header,children:[r&&t.jsx(Nn,{nftInfo:s}),t.jsxs("div",{children:[t.jsx("div",{className:Ne.collectionName,children:n}),t.jsx("h2",{className:Ne.name,children:o}),t.jsxs("div",{className:Ne.chainInfo,children:[t.jsx(K,{src:i.logoUrl,width:14,height:14}),t.jsx("span",{children:i.name})]})]})]}),t.jsx(ae,{children:t.jsx(V.White,{onClick:()=>e("/nft/send",s),sm:!0,children:"Send"})}),a&&t.jsxs("div",{className:Ne.attributes,children:[t.jsxs("header",{className:Ne.title,children:["Traits ",t.jsxs("span",{className:Ne.count,children:["(",a.length,")"]})]}),t.jsx("div",{children:a.map(({trait_type:l,value:c})=>t.jsxs("div",{className:Ne.item,children:[t.jsx("div",{className:Ne.type,children:l}),t.jsx("div",{className:Ne.value,children:c})]},l))})]})]})},eh="_scrollable_1p1lw_1",th="_list_1p1lw_5",sh="_item_1p1lw_9",nh="_name_1p1lw_13",rs={scrollable:eh,list:th,item:sh,name:nh};function _o({onSelect:e,list:s,...n}){const{getImage:r,getName:o,getKey:a,getIsLoading:i,getDisabled:l}=n;return t.jsx(Me,{className:rs.scrollable,children:t.jsx("div",{className:rs.list,children:s.map(c=>t.jsxs("button",{className:rs.item,onClick:()=>e(c),disabled:i?.(c)||l?.(c),children:[t.jsx(K,{src:r(c),width:28,height:28}),t.jsx("span",{className:rs.name,children:o(c)}),i?.(c)&&t.jsx(Je,{size:16})]},a(c)))})})}const rh="_header_5w36t_1",oh="_name_5w36t_8",ah="_collection_5w36t_15",ih="_nft_5w36t_20",ch="_fields_5w36t_24",lh="_chain_5w36t_29",pt={header:rh,name:oh,collection:ah,nft:ih,fields:ch,chain:lh},dh=$e.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),uh=()=>{const e=re(),s=lt(),{chain:n,collection_addr:r,collection_name:o,image:a,name:i}=s,{routerApiUrl:l}=fe(),c=xs(),d=ge(),{address:u,initiaAddress:m,requestTxSync:_}=xe(),{watch:p,setValue:f,handleSubmit:g,formState:b}=le.useFormContext(),C=p(),{recipient:w,dstChainId:P}=C,E=Fe(P),y=$.useQuery({queryKey:dh.simulation({collection_addr:r,nft:s,sender:m,recipient:w,srcChain:n,dstChain:E,layer1:d,routerApiUrl:l}).queryKey,queryFn:async()=>{const R={from_address:m,from_chain_id:n.chainId,to_address:j.InitiaAddress(w).bech32,to_chain_id:E.chainId,collection_address:r,token_ids:[s.token_id],object_addresses:[s.object_addr]},{msgs:S}=await Z.create({prefixUrl:l}).post("nft",{json:R}).json();return S.map(q=>c.fromAmino(q))},enabled:!!w}),{data:T,isLoading:N,error:I}=y,{mutate:x,isPending:k}=$.useMutation({mutationFn:async()=>{if(!T)throw new Error("Route not found");await _({messages:T,chainId:n.chainId,internal:"/nfts"})}});return t.jsxs("form",{onSubmit:g(()=>x()),children:[t.jsxs("header",{className:pt.header,children:[a&&t.jsx(Nn,{nftInfo:s,size:80}),t.jsxs("div",{className:pt.name,children:[t.jsx("div",{className:pt.collection,children:o}),t.jsx("div",{className:pt.nft,children:i})]})]}),t.jsxs("div",{className:pt.fields,children:[t.jsx(U.VisuallyHidden.Root,{children:t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination rollup"}),t.jsxs(jt,{title:"Destination rollup",content:R=>t.jsx(_o,{onSelect:({chainId:S})=>{f("dstChainId",S),R()},list:e,getImage:S=>S.logoUrl,getName:S=>S.name,getKey:S=>S.chainId}),className:D("input",pt.chain),children:[t.jsx(K,{src:E.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:E.name})]})]})}),t.jsx(Sn,{myAddress:u,ref:Wt()})]}),t.jsx(ae,{children:t.jsx(V.White,{loading:N||k,disabled:!b.isValid,children:I?"Route not found":"Confirm"})})]})},mh=G.z.object({dstChainId:G.z.string().nonempty(),recipient:co}),hh=()=>{const{chain:e}=lt(),s=le.useForm({defaultValues:{dstChainId:e.chainId},resolver:mn.zodResolver(mh)});return t.jsx(ut,{title:"Send NFT",children:t.jsx(le.FormProvider,{...s,children:t.jsx(uh,{})})})};function _h(){return ge().network_type==="testnet"}const po=G.z.object({srcChainId:G.z.string().nonempty(),srcDenom:G.z.string().nonempty(),dstChainId:G.z.string().nonempty(),dstDenom:G.z.string().nonempty(),quantity:G.z.string().nonempty("Amount is required"),sender:G.z.string().nonempty(),cosmosWalletName:G.z.string().optional(),recipient:G.z.string().nonempty("Recipient address is required"),slippagePercent:G.z.string().nonempty()});function Ze(){return le.useFormContext()}function ph(){const e=lt(),s=_h(),n={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},r={...n,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},o={...n,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},a=v.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(O.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(O.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(O.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(O.BRIDGE_DST_DENOM),quantity:localStorage.getItem(O.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(O.BRIDGE_SLIPPAGE_PERCENT)});return{...s?r:o,...a,...e}}function fo(){const{initiaAddress:e,hexAddress:s}=xe(),n=dt(),r=Ht();return o=>{const a=n(o);switch(r(a)){case"initia":return e;case"evm":return s;default:return""}}}function rn(){const e=dt(),s=Ht();return(n,r)=>{const o=e(r);switch(s(o)){case"initia":return j.InitiaAddress.validate(n);case"evm":return it.isAddress(n);case"cosmos":try{return H.fromBech32(n).prefix===o.bech32_prefix}catch{return!1}default:return!1}}}function fh(){const e=dt(),s=Ht();return({initialAddress:n,initialChainId:r,chainId:o,fallbackAddress:a})=>{const i=e(r),l=s(i),c=e(o),d=s(c);if(l==="evm"&&d==="initia")return j.InitiaAddress(n).bech32;if(l==="initia"&&d==="evm")return j.InitiaAddress(n).hex;if(l===d)return n;if(a){if(d==="initia")return j.InitiaAddress(a).bech32;if(d==="evm")return j.InitiaAddress(a).hex}return""}}const gh=[["d",1440*60],["h",3600],["m",60],["s",1]];function on(e){if(!e)return;const{formattedParts:s}=gh.reduce(({remainingSeconds:n,formattedParts:r},[o,a])=>{const i=Math.floor(n/a);return{remainingSeconds:n-i*a,formattedParts:i>0?[...r,`${i}${o}`]:r}},{remainingSeconds:e,formattedParts:[]});return s.join(" ")}function go(e){return e?.map(s=>{const{amount:n,origin_asset:r}=s;return`${j.formatAmount(n,{decimals:r.decimals??0})} ${r.symbol}`}).join(", ")}function Gn(e,s){const{watch:n}=Ze(),r=n(),o=Ye(),a={...r,quantity:e},i=$.useQueryClient();return $.useQuery({queryKey:pe.route(a,s?.isOpWithdraw).queryKey,queryFn:()=>{const{srcChainId:l,srcDenom:c,quantity:d,dstChainId:u,dstDenom:m}=a,{decimals:_}=i.getQueryData(pe.asset(l,c).queryKey)??{decimals:0},p={amount_in:j.toBaseUnit(d,{decimals:_}),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:p}).json()},enabled:!!Number(a.quantity)&&!s?.disabled,staleTime:z.MINUTE})}function xh(e){return $.useQuery({queryKey:pe.routeErrorInfo(e||new Error).queryKey,queryFn:async()=>{if(!e||!(e instanceof Z.HTTPError))return null;const{response:s}=e;return(s.headers.get("content-type")??"").includes("application/json")?(await s.json()).info??null:null}})}function yh(){const{watch:e}=Ze(),{srcChainId:s,srcDenom:n,dstChainId:r,dstDenom:o}=e(),a=ke(s),i=Ot(a),l=Re(n,s),c=Re(o,r),d=ge(),u=re();return i==="initia"&&r===d.chainId&&l.symbol===c.symbol&&u.find(m=>m.chainId===s)?.metadata?.op_denoms?.includes(c.denom)}var an=(e=>(e.FEE_BEHAVIOR_DEDUCTED="FEE_BEHAVIOR_DEDUCTED",e.FEE_BEHAVIOR_ADDITIONAL="FEE_BEHAVIOR_ADDITIONAL",e))(an||{});function An(e,s){const n=Ye();return $.useQuery({queryKey:pe.balances(s,e).queryKey,queryFn:()=>n.post("v2/info/balances",{json:{chains:{[s]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>e?r?r[s].denoms??{}:{}:{},enabled:!!e,staleTime:z.SECOND})}function jh(e,s,n){const{data:r={}}=An(e,s);return v.path([n],r)}const vh=({address:e,chain:s,onSelect:n})=>{const r=yt(s.chain_id),{data:o={}}=An(e,s.chain_id);return t.jsx(Qt,{assets:v.sortWith([v.descend(a=>a.symbol==="INIT"),v.descend(a=>a.value),({balance:a="0"},{balance:i="0"})=>B(i).comparedTo(a)??0,v.ascend(a=>a.symbol.toLowerCase())],r.filter(a=>!a.hidden).map(a=>{const{denom:i,symbol:l=j.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})},wh=({type:e,afterSelect:s})=>{const n=e==="src"?"srcChainId":"dstChainId",r=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"sender":"recipient",a=bt(),i=jn(),{watch:l,setValue:c,trigger:d}=Ze(),u=l("quantity"),m=l(o),_=l(n),[p,f]=h.useState(_),g=ke(p),b=fh(),C=Pr(),[w,P]=v.partition(y=>C(y.chain_id),i.filter(y=>!y.hidden)),E=y=>{c(n,p),c(r,y),Number(u)&&d(),s()};return t.jsxs(t.Fragment,{children:[t.jsxs(at.Stack,{children:[t.jsx(at,{label:"Interwoven Economy",chains:w.map(({chain_id:y,chain_name:T,pretty_name:N,logo_uri:I})=>({chainId:y,name:N||T,logoUrl:I??""})),value:p,onSelect:f}),t.jsx(at,{label:"Chains",chains:P.map(({chain_id:y,chain_name:T,pretty_name:N,logo_uri:I})=>({chainId:y,name:N||T,logoUrl:I??""})),value:p,onSelect:f})]}),t.jsx(ye,{suspenseFallback:t.jsx(Qt.Placeholder,{}),children:t.jsx(vh,{address:b({initialAddress:m,initialChainId:_,chainId:p,fallbackAddress:e==="src"?a:void 0}),chain:g,onSelect:E})},p)]})},Yn=({type:e})=>{const s=e==="src"?"srcChainId":"dstChainId",n=e==="src"?"srcDenom":"dstDenom",r=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:o}=Ze(),a=o(s),i=o(n),l=ke(a),c=Re(i,a);return t.jsx(jt,{title:r,content:d=>t.jsx(wh,{type:e,afterSelect:d}),children:t.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 Is(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:n=>e.find(r=>r.name===n)}}const bh="_account_iwrlj_8",Ch="_clear_iwrlj_27",Ih="_white_iwrlj_38",Tt={account:bh,clear:Ch,white:Ih},Jn=({type:e})=>{const{watch:s,setValue:n}=Ze(),{srcChainId:r,dstChainId:o,cosmosWalletName:a}=s(),l=s(e==="src"?"sender":"recipient"),c=Ot(ke(o)),{list:d,find:u}=Is(),m=u(a),_=fo(),p=rn(),f=_(o),g=j.InitiaAddress.equals(l,f),b=()=>t.jsx(jt,{title:"Connect wallet",content:P=>t.jsx(_o,{onSelect:async E=>{const y=E.getProvider();if(!y)return window.open(E.fallbackUrl,"_blank");const T=y.getOfflineSigner(r),[{address:N}]=await T.getAccounts();n("sender",N),n("cosmosWalletName",E.name),P()},list:d,getImage:E=>E.image,getName:E=>E.name,getKey:E=>E.name}),className:D(Tt.account,{[Tt.white]:!l}),children:l?t.jsxs(t.Fragment,{children:[m&&t.jsx(K,{src:m.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:j.truncate(l)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(A.IconChevronRight,{size:14})]})}),C=P=>t.jsx(jt,{title:"Recipient",content:E=>t.jsx(Me,{children:t.jsx(Sn,{mode:"onSubmit",myAddress:f,chainType:c,validate:y=>p(y,o),onApply:E})}),className:Tt.account,children:P}),w=()=>{switch(c){case"initia":case"evm":return g?C(t.jsx(A.IconWallet,{size:14})):t.jsxs("div",{className:Tt.account,children:[t.jsx("span",{className:"monospace",children:j.truncate(l)}),t.jsx("button",{type:"button",className:Tt.clear,onClick:()=>n("recipient",f,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(A.IconCloseCircleFilled,{size:14})})]});case"cosmos":return C(t.jsxs(t.Fragment,{children:[l?t.jsx("span",{className:"monospace",children:j.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx(A.IconEdit,{size:14})]}))}};switch(e){case"src":return b();case"dst":return w()}},Nh="_description_l5bcv_1",Sh="_presets_l5bcv_8",Ah="_preset_l5bcv_8",kh="_active_l5bcv_29",$h="_custom_l5bcv_40",Eh="_wrapper_l5bcv_46",Th="_percent_l5bcv_49",Se={description:Nh,presets:Sh,preset:Ah,active:kh,custom:$h,wrapper:Eh,percent:Th},Zn=["0.1","0.5","1.0"],qh=({afterConfirm:e})=>{const s=Ze(),n=s.getValues("slippagePercent"),[r,o]=h.useState(null),{control:a,watch:i,getValues:l,setValue:c}=le.useForm({defaultValues:{value:n}}),d=i("value");h.useEffect(()=>{const g=Zn.findIndex(b=>b===n);o(g>=0?g:null)},[n]);const u=(g,b)=>{c("value",g),o(b)},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]),p=_?.type==="error",f=({value:g})=>{s.setValue("slippagePercent",g),e()};return t.jsxs(Me,{children:[t.jsx("p",{className:Se.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:Se.presets,children:[Zn.map((g,b)=>t.jsxs("button",{type:"button",className:D(Se.preset,{[Se.active]:r===b}),onClick:()=>u(g,b),children:[g,"%"]},g)),r!==null?t.jsx("button",{type:"button",className:D(Se.preset,Se.custom),onClick:()=>o(null),children:"Custom"}):t.jsxs("div",{className:Se.wrapper,children:[t.jsx(mo,{name:"value",control:a,dp:2,onFocus:m,placeholder:"",className:D(Se.preset,Se.active)}),t.jsx("span",{className:Se.percent,children:"%"})]})]}),_&&t.jsx(ne,{level:_.type,children:_.text}),t.jsx(ae,{children:t.jsx(V.White,{type:"button",onClick:()=>f(l()),disabled:p,children:"Confirm"})})]})},Dh="_stack_hvmmo_1",Ph="_button_hvmmo_6",Rh="_checked_hvmmo_14",Bh="_checkmark_hvmmo_20",Fh="_inner_hvmmo_30",Mh="_info_hvmmo_42",Oh="_duration_hvmmo_51",Uh="_amount_hvmmo_61",Lh="_symbol_hvmmo_71",Pe={stack:Dh,button:Ph,checked:Rh,checkmark:Bh,inner:Fh,info:Mh,duration:Oh,amount:Uh,symbol:Lh},zh=({children:e})=>t.jsx("div",{className:Pe.stack,children:e}),is=({label:e,query:s,value:n,onSelect:r,checked:o})=>{const{data:a,isLoading:i}=s,{watch:l}=Ze(),{dstChainId:c,dstDenom:d}=l(),u=Re(d,c);return t.jsxs("button",{type:"button",className:D(Pe.button,{[Pe.checked]:o}),onClick:()=>r(n),children:[t.jsx("div",{className:Pe.checkmark,children:o&&t.jsx("span",{className:Pe.inner})}),t.jsxs("div",{className:Pe.info,children:[t.jsx("div",{children:e}),t.jsxs("div",{className:Pe.duration,children:[t.jsx(A.IconClockFilled,{size:12}),a?on(a.estimated_route_duration_seconds):"Not available"]})]}),t.jsx("div",{className:Pe.amount,children:i?t.jsx(Je,{size:14}):a?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:j.formatAmount(a.amount_out,{decimals:u.decimals})}),t.jsx("span",{className:Pe.symbol,children:u.symbol})]}):null})]})};is.Stack=zh;const Kh="_form_1coq4_1",Hh="_arrow_1coq4_5",Wh="_divider_1coq4_13",Qh="_flip_1coq4_21",Vh="_meta_1coq4_37",Gh="_row_1coq4_50",Yh="_title_1coq4_56",Jh="_description_1coq4_60",Zh="_icon_1coq4_67",Xh="_edit_1coq4_72",e_="_warning_1coq4_93",ee={form:Kh,arrow:Hh,divider:Wh,flip:Qh,meta:Vh,row:Gh,title:Yh,description:Jh,icon:Zh,edit:Xh,warning:e_},t_=()=>{const e=de(),s=vs(),[n,r]=be.useLocalStorage(O.BRIDGE_ROUTE_TYPE,"default"),{watch:o,setValue:a,handleSubmit:i,trigger:l,formState:c}=Ze(),d=o(),{srcChainId:u,srcDenom:m,dstChainId:_,dstDenom:p,quantity:f,sender:g,slippagePercent:b}=d,C=Be(),w=ke(u),P=Ot(w),E=ke(_),y=Ot(E),T=Re(m,u),N=Re(p,_),{data:I}=An(g,u),x=jh(g,u,m);h.useEffect(()=>{Number(f)&&l()},[x,f,l]);const[k]=be.useDebounceValue(f,300),R=P!=="initia"&&y!=="initia",S=yh(),q=Gn(k,{disabled:R}),F=Gn(k,{isOpWithdraw:!0,disabled:!S}),Q=S&&n==="op"?F:q,{data:X,isLoading:Ee,isFetching:Te,isFetched:Ce,error:qe}=Q,{data:ht}=xh(qe),[ue,ie]=h.useState(X);h.useEffect(()=>{X&&ie({...X,amount_out:"0",usd_amount_in:"0",usd_amount_out:"0"})},[X]),h.useEffect(()=>{ie(void 0)},[u,m,_,p]);const M=Ce?X:k&&!qe?ue:void 0,Vt=k&&(Ee||Te),As=()=>{a("srcChainId",_),a("srcDenom",p),a("dstChainId",u),a("dstDenom",m),Number(f)&&l()},{openModal:ko,closeModal:kn}=Lt(),$o=i(L=>{if(M?.warning){const{type:St="",message:Es}=M.warning??{};ko({content:t.jsx(Xr,{type:"warning",icon:t.jsx(A.IconWarningFilled,{size:40}),title:_s.sentenceCase(St),primaryButton:{label:"Cancel",onClick:kn},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:M,values:L}),kn()}},children:t.jsx("p",{className:ee.warning,children:Es})})});return}e("/bridge/preview",{route:M,values:L})}),Eo=h.useMemo(()=>M?.estimated_fees?.filter(({fee_behavior:L})=>L===an.FEE_BEHAVIOR_DEDUCTED)??[],[M]),ks=h.useMemo(()=>M?.estimated_fees?.filter(({fee_behavior:L})=>L===an.FEE_BEHAVIOR_ADDITIONAL)??[],[M]),$s=h.useMemo(()=>{for(const L of ks){const St=I?.[L.origin_asset.denom]?.amount??"0",Es=M?.source_asset_denom===L.origin_asset.denom?M.amount_in:"0";if(B(St).lt(B(Es).plus(L.amount??"0")))return`Insufficient ${L.origin_asset.symbol} for fees`}},[I,M,ks]),$n=h.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 L=po.safeParse(d);if(!L.success)return`Invalid ${L.error.issues[0].path}`;if(!M)return"Route not found";if($s)return $s},[k,$s,c,M,d]),To=M?j.formatAmount(M.amount_out,{decimals:N.decimals}):"0",qo=B(f).gt(0)&&B(f).isEqualTo(j.fromBaseUnit(x?.amount,{decimals:x?.decimals??0})),Do=(()=>{switch(P){case"initia":return C(u).fees.fee_tokens.some(({denom:L})=>L===m);case"cosmos":return w.fee_assets.some(({denom:L})=>L===m);case"evm":return!it.isAddress(m);default:return!1}})(),En=(L,St)=>L.length?t.jsxs("div",{className:ee.description,children:[go(L),!s&&t.jsx(Ct,{label:St,children:t.jsx("span",{className:ee.icon,children:t.jsx(A.IconInfoFilled,{size:12})})})]}):null;return t.jsxs("form",{className:ee.form,onSubmit:$o,children:[t.jsx(sn,{selectButton:t.jsx(Yn,{type:"src"}),accountButton:P==="cosmos"&&t.jsx(Jn,{type:"src"}),quantityInput:t.jsx(us,{}),balanceButton:t.jsx(uo,{onClick:()=>a("quantity",j.fromBaseUnit(x?.amount,{decimals:T?.decimals??0}),{shouldValidate:!0}),children:j.formatAmount(x?.amount??"0",{decimals:T.decimals})}),value:M?M.usd_amount_in?Qe(M.usd_amount_in):"$-":"$0"}),t.jsxs("div",{className:ee.arrow,children:[t.jsx("div",{className:ee.divider}),t.jsx("button",{type:"button",className:ee.flip,onClick:()=>As(),children:t.jsx(A.IconChevronDown,{size:16})})]}),t.jsx(sn,{selectButton:t.jsx(Yn,{type:"dst"}),accountButton:t.jsx(Jn,{type:"dst"}),quantityInput:t.jsx(us.ReadOnly,{children:To}),value:M?M.usd_amount_out?Qe(M.usd_amount_out):"$-":"$0"}),t.jsx(ae,{extra:t.jsxs(t.Fragment,{children:[t.jsx(Xs,{children:B(f).gt(0)&&S?t.jsxs(is.Stack,{children:[t.jsx(is,{label:"Minitswap",query:q,value:"default",onSelect:r,checked:n==="default"}),t.jsx(is,{label:"OP Bridge",query:F,value:"op",onSelect:r,checked:n==="op"})]}):null}),t.jsxs(ne.Stack,{children:[M?.extra_infos?.map(L=>t.jsx(ne,{level:"info",children:L},L)),ht&&t.jsx(ne,{level:"info",children:ht}),qo&&Do&&t.jsx(ne,{level:"warning",children:"Make sure to leave enough for transaction fee"}),M?.warning&&t.jsx(ne,{level:"warning",children:M.warning.message}),M?.extra_warnings?.map(L=>t.jsx(ne,{level:"warning",children:L},L))]}),t.jsx(Xs,{children:M&&t.jsxs("div",{className:ee.meta,children:[!!M.estimated_fees?.length&&t.jsxs("div",{className:ee.row,children:[t.jsx("span",{className:ee.title,children:"Fees"}),t.jsxs("div",{children:[En(Eo,"Fee deducted from the amount you receive"),En(ks,"Fee charged in addition to the amount you enter")]})]}),on(M.estimated_route_duration_seconds)&&t.jsxs("div",{className:ee.row,children:[t.jsx("span",{className:ee.title,children:"Estimated time"}),t.jsx("span",{className:ee.description,children:on(M.estimated_route_duration_seconds)})]}),M.does_swap&&t.jsxs("div",{className:ee.row,children:[t.jsx("span",{className:ee.title,children:"Slippage"}),t.jsxs("span",{className:ee.description,children:[t.jsxs("span",{children:[b,"%"]}),t.jsx(jt,{title:"Slippage tolerance",content:L=>t.jsx(qh,{afterConfirm:L}),className:ee.edit,children:t.jsx(A.IconSettingFilled,{size:12})})]})]})]})})]}),children:t.jsx(V.White,{loading:Vt&&"Simulating...",disabled:!!$n,children:$n??"Preview route"})})]})},s_=()=>{eo();const e=Vo(),s=de(),{closeDrawer:n}=wt(),r=bt(),o=ph(),a=rn(),i=$.useQueryClient(),l=le.useForm({mode:"onChange",defaultValues:o,resolver:mn.zodResolver(po.superRefine(({srcChainId:S,srcDenom:q,quantity:F,sender:Q},X)=>{const Ee=i.getQueryData(pe.balances(S,Q).queryKey),Te=v.pathOr("0",["chains",S,"denoms",q,"amount"],Ee),{decimals:Ce}=i.getQueryData(pe.asset(S,q).queryKey)??{decimals:0};io({quantity:F,balance:Te,decimals:Ce},X)}).superRefine(({dstChainId:S,recipient:q},F)=>{if(!a(q,S)){F.addIssue({code:G.z.ZodIssueCode.custom,message:"Invalid address",path:["recipient"]});return}}))}),{watch:c,setValue:d}=l,{srcChainId:u,dstChainId:m,srcDenom:_,dstDenom:p,quantity:f,slippagePercent:g,recipient:b}=c();c((S,{name:q})=>{(q==="srcChainId"||q==="srcDenom")&&d("quantity","")});const C=fo(),w=C(u),P=C(m),y=rn()(b,m);h.useEffect(()=>{d("cosmosWalletName",void 0),d("sender",w)},[u,w,d]),h.useEffect(()=>{y||d("recipient",P)},[P,y,d]);const T=yt(u),N=yt(m),I=h.useMemo(()=>{if(!T.find(S=>S.denom===_))return`${_} is not available for bridge/swap on ${u}`;if(!N.find(S=>S.denom===p))return`${p} is not available for bridge/swap on ${m}`},[N,m,p,T,u,_]);h.useEffect(()=>{I||(localStorage.setItem(O.BRIDGE_SRC_CHAIN_ID,u),localStorage.setItem(O.BRIDGE_SRC_DENOM,_),localStorage.setItem(O.BRIDGE_DST_CHAIN_ID,m),localStorage.setItem(O.BRIDGE_DST_DENOM,p),localStorage.setItem(O.BRIDGE_QUANTITY,f),localStorage.setItem(O.BRIDGE_SLIPPAGE_PERCENT,g))},[u,_,m,p,f,g,I]);const x=e[0].path==="/bridge",k=()=>t.jsxs(t.Fragment,{children:[t.jsx(Y,{error:!0,children:I}),t.jsx(ae,{children:x?t.jsx(V.White,{onClick:n,children:"Close"}):t.jsx(V.White,{onClick:()=>s(-1),children:"Go back"})})]}),{reminders:R}=It();return t.jsx(ut,{title:"Bridge/Swap",returnTo:x?!1:"/",extra:t.jsxs(t.Fragment,{children:[t.jsx(V.Small,{onClick:()=>s("/bridge/history"),unpadded:!0,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[t.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),t.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),t.jsx(ho,{offset:0,disabled:R.length===0,children:t.jsx(V.Small,{onClick:()=>s("/op/withdrawals"),disabled:!r,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:I?k():t.jsx(le.FormProvider,{...l,children:t.jsx(ye,{children:t.jsx(t_,{})})})})},n_="_button_1iys9_1",r_={button:n_},xo=({onClick:e,disabled:s})=>{const{ref:n,inView:r}=Lo.useInView();return h.useEffect(()=>{r&&e()},[r,e]),t.jsxs("button",{className:r_.button,onClick:e,disabled:s,ref:n,children:[t.jsx("span",{children:"Load more"}),t.jsx(A.IconChevronDown,{size:12})]})},mt=$e.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,s)=>[e,s],latestOutput:e=>[e],output:(e,s)=>[e,s],outputResponse:(e,s)=>[e,s],withdrawalClaimed:(e,s)=>[e,s]});function Ns(){const{restUrl:e}=ge();return h.useMemo(()=>Z.create({prefixUrl:e}),[e])}function o_(e){const s=Ns(),{data:n}=$.useSuspenseQuery({queryKey:mt.bridge(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:z.INFINITY});return n}const Xn=20;function a_(e){const s=te();return $.useSuspenseInfiniteQuery({queryKey:mt.withdrawals(e,s).queryKey,queryFn:async({pageParam:n})=>{if(!s)return[];const r={limit:Xn,offset:n,order:"desc"},{withdrawals:o}=await Z.create({prefixUrl:e}).get(`withdrawals/${s}`,{searchParams:r}).json();return o},getNextPageParam:n=>{const r=v.last(n)?.sequence;return n.length<Xn||!r||r<=1?null:r-1},initialPageParam:0,staleTime:z.SECOND})}function i_(e){const s=Ns(),{data:n}=$.useSuspenseQuery({queryKey:mt.latestOutput(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:r})=>{const[o]=r;return o||null},staleTime:z.SECOND});return n}function c_({bridge_id:e,output_index:s}){const n=Ns(),{data:r}=$.useSuspenseQuery({queryKey:mt.output(e,s).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${e}/outputs/${s}`).json()}catch{return null}},staleTime:z.SECOND});return r}function l_({bridge_id:e,sequence:s}){const r=re().find(({metadata:c})=>c?.op_bridge_id===e.toString())?.chain_id;if(!r)throw new Error(`Chain not found for bridge_id: ${e}`);const a=Be()(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:mt.outputResponse(i,s).queryKey,queryFn:()=>Z.create({prefixUrl:i}).get(`withdrawal/${s}`).json(),staleTime:z.SECOND});return l}function yo(e,s){const{bridge_id:n}=e,r=Ns(),{data:o}=$.useSuspenseQuery({queryKey:mt.withdrawalClaimed(n,s).queryKey,queryFn:()=>r.get(`opinit/ophost/v1/bridges/${n}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:s}}).json(),select:({claimed:a})=>a,staleTime:({state:{data:a}})=>a?.claimed?1/0:z.SECOND});return o}function qt(e){return zo.sha3_256.create().update(e).digest()}function Qs(e,s){const n=new ArrayBuffer(s);return new DataView(n).setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}function jo(e){const{bridge_id:s,sequence:n,amount:r,from:o,to:a}=e,i=Qs(s.toString(),8),l=Qs(n.toString(),8),c=Qs(r.amount,8),d=Gt.concatBytes(i,l,qt(Gt.toBytes(o)),qt(Gt.toBytes(a)),qt(Gt.toBytes(r.denom)),c);return qt(qt(d))}const vo=h.createContext(null);function Ss(){return h.useContext(vo)}const d_="_asset_6h8u2_1",u_="_info_6h8u2_7",m_="_symbol_6h8u2_11",Vs={asset:d_,info:u_,symbol:m_},h_=({amount:e,denom:s})=>{const n=ge(),r=xn(s,n),{symbol:o,logoUrl:a,decimals:i}=r;return t.jsxs("div",{className:Vs.asset,children:[t.jsx(K,{src:a,width:32,height:32,logo:!0}),t.jsxs("div",{className:Vs.info,children:[t.jsx("span",{className:"monospace",children:j.formatAmount(e,{decimals:i})}),t.jsx("span",{className:Vs.symbol,children:o})]})]})},__=({children:e})=>{const{withdrawalTx:s}=Ss(),n=i_(s.bridge_id),r=s.output_index>Number(n?.output_index);return e(r)},p_="_container_1oldz_1",f_="_icon_1oldz_7",er={container:p_,icon:f_},g_="Withdrawal will begin within an hour",tr=()=>{const e=vs();return t.jsxs("div",{className:er.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Ct,{label:g_,children:t.jsx("span",{className:er.icon,children:t.jsx(A.IconInfoFilled,{size:12})})})]})},wo=1e3,x_=60,y_=60,j_=24,cn=wo*x_,ln=cn*y_,sr=ln*j_,v_=({date:e})=>{const s=h.useCallback(()=>{const d=new Date().getTime(),m=e.getTime()-d;if(m<=0)return{days:0,hours:0,minutes:0,seconds:0};const _=Math.floor(m/sr),p=Math.floor(m%sr/ln),f=Math.floor(m%ln/cn),g=Math.floor(m%cn/wo);return{days:_,hours:p,minutes:f,seconds:g}},[e]),[n,r]=h.useState(s());h.useEffect(()=>{const d=window.setInterval(()=>{r(s())},1e3);return()=>window.clearInterval(d)},[s,e]);const o=d=>d.toString().padStart(2,"0"),{days:a,hours:i,minutes:l,seconds:c}=n;return t.jsx(Ct,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[a,"d ",o(i),"h ",o(l),"m ",o(c),"s"]})})},w_="_container_1lz3w_1",b_="_title_1lz3w_5",nr={container:w_,title:b_},C_=({date:e})=>t.jsxs("div",{className:nr.container,children:[t.jsx("div",{className:nr.title,children:"Claimable in"}),t.jsx(v_,{date:e})]}),I_=({children:e})=>{const{withdrawalTx:s}=Ss(),n=o_(s.bridge_id),r=c_(s),o=h.useMemo(()=>{if(!r)return null;const{bridge_config:a}=n,{output_proposal:i}=r;return Ut.addSeconds(new Date(i.l1_block_time),parseFloat(a.finalization_period))},[n,r]);return e(o)},N_=({date:e,children:s})=>{const{chainId:n,withdrawalTx:r}=Ss(),o=H.toBase64(jo(r)),a=yo(r,o),{setReminder:i,removeReminder:l}=It();return h.useEffect(()=>{const c={chainId:n,txHash:r.tx_hash};a?l(c):i(c,{...c,recipient:r.to,claimableAt:e.getTime(),amount:r.amount.amount,denom:r.amount.denom,dismissed:Ut.isPast(e.getTime())?!0:void 0})},[n,a,e,l,i,r]),s},S_="_button_1btdg_1",A_="_claimed_1btdg_23",rr={button:S_,claimed:A_},k_=()=>{const{withdrawalTx:e}=Ss(),{bridge_id:s,sequence:n,amount:r,output_index:o,withdrawal_proofs:a,storage_root:i,from:l,to:c,version:d}=e,u=ge(),m=te(),{requestTxSync:_,waitForTxConfirmation:p}=xe(),f=l_(e),g=H.toBase64(jo(e)),b=yo(e,g),C=$.useQueryClient(),{mutate:w,isPending:P}=$.useMutation({mutationFn:async()=>{if(!f)throw new Error("Output not found");const{last_block_hash:E}=f;return _({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:Ko.MsgFinalizeTokenWithdrawal.fromPartial({sender:m,bridgeId:BigInt(s),outputIndex:BigInt(o),withdrawalProofs:a.map(H.fromBase64),from:l,to:c,sequence:BigInt(n),amount:r,version:H.fromBase64(d),storageRoot:H.fromBase64(i),lastBlockHash:H.fromBase64(E)})}],internal:!0})},onSuccess:async E=>{await p({chainId:u.chain_id,txHash:E}),C.invalidateQueries({queryKey:mt.withdrawalClaimed(s,g).queryKey})}});return b?t.jsxs("div",{className:rr.claimed,children:[t.jsx(A.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:rr.button,onClick:()=>w(),disabled:P,children:"Claim"})},$_=()=>t.jsx(__,{children:e=>e?t.jsx(tr,{}):t.jsx(I_,{children:s=>s?t.jsx(N_,{date:s,children:Ut.isFuture(s)?t.jsx(C_,{date:s}):t.jsx(k_,{})}):t.jsx(tr,{})})}),E_="_item_km5w2_1",T_={item:E_},q_=({chain:e})=>{const s=e.metadata?.executor_uri;if(!s)throw new Error("Executor URL is not defined");const{data:n,fetchNextPage:r,hasNextPage:o,isFetching:a}=a_(s),i=h.useMemo(()=>n?.pages.flat()??[],[n]),{syncReminders:l}=It();return h.useEffect(()=>{const c=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));l(c)},[e.chainId,i,l]),i.length?t.jsxs(t.Fragment,{children:[i.map(c=>{const{amount:d}=c;return t.jsxs("div",{className:T_.item,children:[t.jsx(h_,{...d}),t.jsx(ye,{suspenseFallback:null,children:t.jsx(vo.Provider,{value:{chainId:e.chainId,withdrawalTx:c},children:t.jsx($_,{})})})]},c.sequence)}),o&&t.jsx(xo,{onClick:()=>r(),disabled:a})]}):t.jsx(Y,{children:"No withdrawals"})},D_="_content_dj1qm_1",P_="_title_dj1qm_5",or={content:D_,title:P_},R_=()=>{const{chainId:e}=lt(),s=re(),n=zt(),[r,o]=h.useState(e??(n.metadata?.is_l1?"":n.chainId)),a=Be(),{reminders:i}=It(),l=r?a(r):void 0;return t.jsxs(ut,{title:"OP Bridge withdrawals",children:[t.jsx(at,{chains:s.filter(({metadata:c})=>!c?.is_l1&&c?.op_denoms?.length),value:r,onSelect:o,getShowIndicator:c=>i.some(d=>d.chainId===c)}),t.jsx("div",{className:or.content,children:l?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:or.title,children:l.name}),t.jsx(ye,{children:t.jsx(q_,{chain:l})},r)]}):t.jsx(ne,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})};async function B_(e,s){const n=Z.create({prefixUrl:s}),r=`cosmos/auth/v1beta1/account_info/${e}`;for(let o=1;o<=24;o++)try{return await n.get(r).json()}catch{await new Promise(a=>setTimeout(a,5e3))}throw new Error(`Timeout: ${e} not found`)}const cs=({chainId:e,txHash:s})=>`${O.BRIDGE_HISTORY}:${e}:${s}`,ms=100,ar=10;function bo(){const[e,s]=be.useLocalStorage(O.BRIDGE_HISTORY,[]),n=h.useCallback((o,a)=>{localStorage.setItem(cs(o),JSON.stringify(a));for(const i of e.slice(ms-1))localStorage.removeItem(cs(i));s((i=[])=>[o,...i.slice(0,ms-1)])},[e,s]),r=h.useCallback(o=>{const a=localStorage.getItem(cs(o));return a?JSON.parse(a):null},[]);return{history:e,addHistoryItem:n,getHistoryDetails:r}}function Co(e){return be.useLocalStorage(cs(e),null)}async function Io(e,s){const{chain_type:n,chain_id:r,chain_name:o,evm_fee_asset:a,rpc:i}=s;if(n!=="evm")throw new Error(`Chain is not an EVM chain: ${o}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}catch(l){if(v.path(["error","code"],l)!==4902)throw l;if(!a)throw new Error(`Fee asset is not defined for chain: ${o}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(r).toString(16)}`,chainName:o,nativeCurrency:a,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}}function Nt(){return lt()}function F_(e){const s=de(),{showNotification:n,updateNotification:r,hideNotification:o}=wn(),{addHistoryItem:a}=bo(),{route:i,values:l}=Nt(),{srcChainId:c,sender:d,recipient:u,cosmosWalletName:m}=l,_=br(),{requestTxSync:p,waitForTxConfirmation:f}=xe(),{find:g}=Is(),b=gs(),C=xs(),w=ke(c),P=Ot(w),E=Rr(c),y=$.useQueryClient(),{registryUrl:T}=fe(),N=Be(),{addReminder:I}=It();return $.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const x=e.cosmos_tx.msgs.map(({msg_type_url:ue,msg:ie})=>{if(!(ue&&ie))throw new Error("Invalid transaction data");return C.fromAmino({type:Rt.aminoConverters[ue].aminoType,value:JSON.parse(ie)})});if(P==="initia"){const{srcDenom:ue,quantity:ie}=l,{decimals:M}=E(ue),Vt=await p({messages:x,chainId:c,internal:1,spendCoins:[{denom:ue,amount:j.toBaseUnit(ie,{decimals:M})}]}),As=f({txHash:Vt,chainId:c});return{txHash:Vt,wait:As}}const k=g(m)?.getProvider();if(!k)throw new Error("Wallet not connected");const R=k.getOfflineSignerOnlyAmino(c),S=await Ae.SigningStargateClient.connectWithSigner(w.rpc,R,{registry:b,aminoTypes:C}),q=await S.getAllBalances(d),F=w.fee_assets.find(ue=>q.some(ie=>ie.denom===ue.denom&&B(ie.amount).gt(0)));if(!F){const ie=["Insufficient balance for fees.",`Available fee assets: ${w.fee_assets.map(M=>E(M.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(ie)}const{denom:Q,gas_price:X}=F;if(!X)throw new Error(`Gas price not found for ${Q}`);const Ee=await S.simulate(d,x,""),Te=Ae.GasPrice.fromString(X.average+Q),Ce=Ae.calculateFee(Math.ceil(Ee*Bt),Te),qe=await S.signAndBroadcastSync(d,x,Ce),ht=Ar({txHash:qe,client:S});return{txHash:qe,wait:ht}}if("evm_tx"in e){const{chain_id:x,to:k,value:R,data:S}=e.evm_tx,q=await _(),F=await q.getSigner();await Io(q,w);const Q=await F.sendTransaction({chainId:x,to:k,value:R,data:`0x${S}`});return{txHash:Q.hash,wait:Q.wait()}}throw new Error("Unsupported chain type")}catch(x){throw new Error(await Ve(x))}},onSuccess:({txHash:x,wait:k})=>{localStorage.removeItem(O.BRIDGE_QUANTITY),s(-1),n({type:"loading",title:"Transaction is pending..."}),k.then(()=>{const R={chainId:c,txHash:x},S=No(i)==="OP Bridge withdrawal";a(R,{...R,timestamp:Date.now(),route:i,values:l,state:S?"success":void 0}),r({type:"info",title:"Transaction submitted",description:h.createElement(h.Fragment,null,"Check ",h.createElement(pn,{to:"/bridge/history",onClick:o},"the activity page")," for transaction status"),autoHide:!0}),S&&I(R,{...R,recipient:j.InitiaAddress(u).bech32,claimableAt:Date.now()+i.estimated_route_duration_seconds*1e3,amount:i.amount_out,denom:i.dest_asset_denom})}).catch(R=>{r({type:"error",title:"Transaction failed",description:R.message})}).finally(()=>{y.invalidateQueries({queryKey:pe.balances(c,d).queryKey})})},onError:async x=>{const k=P==="initia"?await Zs(x,N(c),T):x;n({type:"error",title:"Transaction failed",description:k.message})}})}function M_(){const e=Ye(),s=te(),n=jr(),{route:r,values:o}=Nt(),a=dt();return $.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:l}=await e.post("op-hook",{json:{source_address:s,source_asset_chain_id:r.source_asset_chain_id,source_asset_denom:r.source_asset_denom,dest_address:j.InitiaAddress(o.recipient).bech32,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom}}).json();await B_(s,a(r.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:m,msg:_})=>Rt.aminoTypes.fromAmino({type:Rt.aminoConverters[m].aminoType,value:JSON.parse(_)})),d=await n(i,s,c,{amount:[],gas:"1"},""),u=xt.Tx.fromPartial({body:xt.TxBody.decode(d.bodyBytes),authInfo:xt.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:s,hook:H.toBase64(xt.Tx.encode(u).finish())}}catch(i){throw new Error(await Ve(i))}}})}function O_(e){const{chainId:s,txHash:n,tracked:r}=e,o=Ye();return $.useQuery({queryKey:pe.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 Ve(a))}},select:({tx_hash:a})=>a,retry:6,retryDelay:5e3,staleTime:z.INFINITY,enabled:!r})}function U_(e){const{timestamp:s,chainId:n,txHash:r,tracked:o,state:a}=e,i=Ye();return $.useQuery({queryKey:pe.txStatus(n,r).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:r,chain_id:n}}).json(),enabled:!!r&&o&&!a,refetchInterval:({state:{data:l}})=>{if(!l)return!1;const{status:c}=l;if(c==="STATE_COMPLETED")return!1;const d=s+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),m=Math.floor((d-u)/1e3);return m<=0?1e3:m<=300?5e3:60*1e3},staleTime:z.INFINITY})}var ls=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(ls||{});function No(e){const{operations:s,dest_asset_denom:n}=e;return v.has("op_init_transfer",v.head(s))&&n==="uinit"?"OP Bridge withdrawal":"Skip"}const L_="_content_c0tee_1",z_="_info_c0tee_6",K_="_arrow_c0tee_11",H_="_divider_c0tee_19",W_="_type_c0tee_26",Q_="_asset_c0tee_44",V_="_amount_c0tee_52",G_="_lower_c0tee_57",Y_="_chain_c0tee_63",J_="_address_c0tee_69",he={content:L_,info:z_,arrow:K_,divider:H_,type:W_,asset:Q_,amount:V_,lower:G_,chain:Y_,address:J_},So=e=>{const{source:s,label:n,amount:r,denom:o,chainId:a,address:i,walletIcon:l}=e,{symbol:c=j.truncate(o),decimals:d=0,logo_uri:u=gn}=e,{chain_name:m,pretty_name:_,...p}=ke(a);return t.jsxs("div",{children:[!s&&t.jsxs("div",{className:he.arrow,children:[t.jsx("div",{className:he.divider}),n?t.jsx(Ct,{label:n,children:t.jsx("button",{className:he.type,children:t.jsx(A.IconArrowDown,{size:12})})}):t.jsx("span",{className:he.type,children:t.jsx(A.IconArrowDown,{size:12})}),t.jsx("div",{className:he.divider})]}),t.jsxs("div",{className:he.content,children:[t.jsx(Cs,{assetLogoUrl:u,chainLogoUrl:p.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:j.formatAmount(r,{decimals:d})}),t.jsx("span",{children:c})]}),t.jsxs("div",{className:he.lower,children:[t.jsxs("div",{className:he.chain,children:["on ",_||m]}),i&&t.jsx(bn,{value:i,children:({copy:f,copied:g})=>t.jsxs("button",{className:he.address,onClick:f,children:[l,g?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:j.truncate(i)})]})})]})]})]})]})},gt=e=>{const s=Re(e.denom,e.chainId);return t.jsx(So,{...e,...s})};gt.Placeholder=So;const Z_="_root_1l4he_1",X_="_flexEnd_1l4he_6",ep="_toggle_1l4he_11",tp="_route_1l4he_34",sp="_content_1l4he_41",Dt={root:Z_,flexEnd:X_,toggle:ep,route:tp,content:sp};function np(e){const s=({name:n})=>n==="initia-dex"?"Initia DEX":_s.capitalCase(v.head(n?.split("-")??[])??"");if("transfer"in e)return{label:"Bridge via IBC",...e,...e.transfer};if("bank_send"in e)return{label:"Send",...e,...e.bank_send};if("swap"in e){const n=e.swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...e,...e.swap}}if("axelar_transfer"in e)return{label:"Bridge via Axelar",...e,...e.axelar_transfer};if("cctp_transfer"in e)return{label:"Bridge via CCTP",...e,...e.cctp_transfer};if("hyperlane_transfer"in e)return{label:"Bridge via Hyperlane",...e,...e.hyperlane_transfer};if("evm_swap"in e){const n=e.evm_swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...e,...e.evm_swap}}if("op_init_transfer"in e)return{label:"Bridge via OP Bridge",...e,...e.op_init_transfer};if("go_fast_transfer"in e)return{label:"Bridge via Go Fast",...e,...e.go_fast_transfer};if("eureka_transfer"in e)return{label:"Bridge via Eureka",...e,...e.eureka_transfer};if("stargate_transfer"in e)return{label:"Bridge via Stargate",...e,...e.stargate_transfer};if("layer_zero_transfer"in e)return{label:"Bridge via LayerZero",...e,...e.layer_zero_transfer};throw new Error("Unknown operation type")}const rp=({addressList:e})=>{const{values:s,route:n}=Nt(),{source_asset_denom:r,source_asset_chain_id:o,amount_in:a,operations:i}=n,l=v.zipObj(n.required_chain_addresses,e),{find:c}=Is(),{connector:d,address:u=""}=we.useAccount(),[m,_]=be.useToggle(!1),p=i.length>1,f=t.jsx(K,{src:s.cosmosWalletName?c(s.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:a,denom:r,chainId:o,address:s.sender,walletIcon:f},b=y=>j.InitiaAddress.equals(y,u)?f:t.jsx(A.IconWallet,{size:11}),C=y=>{const{label:T,amount_out:N,denom:I,denom_out:x=I,chain_id:k,from_chain_id:R,to_chain_id:S=k??R}=y,q=l[S];return{label:p&&!m?void 0:T,amount:N,denom:x,chainId:S,address:q,walletIcon:b(q)}},w=i.map(np).map(C),P=w.slice(0,-1),E=w[w.length-1];return t.jsxs(U.Collapsible.Root,{className:Dt.root,open:m,onOpenChange:_,children:[p&&t.jsx("div",{className:Dt.flexEnd,children:t.jsx(U.Collapsible.Trigger,{className:Dt.toggle,children:m?t.jsxs(t.Fragment,{children:[t.jsx(A.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(A.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:Dt.route,children:[t.jsx(gt,{...g,source:!0}),t.jsx(U.Collapsible.Content,{className:Dt.content,children:P.map((y,T)=>t.jsx(ye,{suspenseFallback:t.jsx(gt.Placeholder,{...y}),errorBoundaryProps:{fallback:t.jsx(gt.Placeholder,{...y})},children:t.jsx(gt,{...y})},T))}),t.jsx(gt,{...E})]})]})},dn=({error:e})=>{const s=de();return t.jsx(ae,{extra:t.jsx(ne,{level:"error",children:e.message}),children:t.jsx(V.White,{onClick:()=>s("/bridge"),children:"Home"})})},op=({children:e})=>{const s=Nt(),{route:n,values:r}=s,{required_chain_addresses:o}=n,{srcChainId:a,dstChainId:i,sender:l,recipient:c}=r,{initiaAddress:d,hexAddress:u}=xe(),m=vt(),_=dt(),p=Ht(),f=_(a),g=p(f),b=o.slice(0,-1).some(N=>{const I=_(N);return p(I)==="cosmos"})&&g!=="cosmos",[C,w]=h.useState(void 0),[P,E]=h.useState(!1),[y,T]=h.useState(null);if(h.useEffect(()=>{(async()=>{try{if(!b)return;if(!m)throw new Error("Wallet not connected");E(!0),T(null);const[{pubkey:I}]=await m.getAccounts();w(I)}catch(I){T(new Error(await Ve(I)))}finally{E(!1)}})()},[b,m]),y)return t.jsx(dn,{error:y});if(P)return t.jsx(ae,{children:t.jsx(V.White,{loading:P&&"Generating intermediary addresses..."})});if(!b||C){const N=o.map((I,x)=>{if(x===o.length-1){const F=_(i);return p(F)==="initia"?j.InitiaAddress(c).bech32:c}const k=_(I),R=p(k),S=_(a),q=p(S);switch(R){case"initia":return d;case"evm":return u;case"cosmos":{if(q==="cosmos")return H.toBech32(k.bech32_prefix,H.fromBech32(l).data);if(!C)throw new Error("Pubkey not found");return Pt.pubkeyToAddress(Pt.encodeSecp256k1Pubkey(C),k.bech32_prefix)}default:throw new Error("Unsupported chain type")}});return e(N)}return null},ap=({addressList:e,signedOpHook:s,children:n})=>{const r=Ye(),{route:o,values:a}=Nt(),[i,l]=h.useState(void 0),[c,d]=h.useState(!1),[u,m]=h.useState(null);return h.useEffect(()=>{(async()=>{try{if(o.required_op_hook&&!s)throw new Error("Op hook is required");d(!0),m(null);const p={address_list:e,amount_in:o.amount_in,amount_out:o.amount_out,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom,slippage_tolerance_percent:a.slippagePercent,operations:o.operations,signed_op_hook:s},{txs:f}=await r.post("v2/fungible/msgs",{json:p}).json();if(!f||f.length===0)throw new Error("No transaction data found");const[g]=f;l(g)}catch(p){m(p)}finally{d(!1)}})()},[o,a,e,s,r]),u?t.jsx(dn,{error:u}):c?t.jsx(ae,{children:t.jsx(V.White,{loading:c&&"Fetching messages..."})}):i?n(i):t.jsx(dn,{error:new Error("Failed to fetch messages")})},ip=({children:e})=>{const{route:s}=Nt(),n=M_();return s.required_op_hook&&!n.data?t.jsx(ae,{extra:t.jsx(ne,{level:"error",children:n.error?.message}),children:t.jsx(V.White,{onClick:()=>n.mutate(),loading:n.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(n.data)},cp=({tx:e,children:s})=>{const n=br(),r=dt(),{mutate:o,data:a,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 n(),u=await d.getSigner();await Io(d,r(c));for(const m of e.evm_tx.required_erc20_approvals){const{token_contract:_,spender:p,amount:f}=m,g=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new it.ethers.Contract(_,g,u).approve(p,f)).wait()}return!0}catch(c){throw new Error(await Ve(c))}}});return"evm_tx"in e&&e.evm_tx.required_erc20_approvals&&e.evm_tx.required_erc20_approvals.length>0&&!a?t.jsx(ae,{extra:t.jsx(ne,{level:"error",children:l?.message}),children:t.jsx(V.White,{onClick:()=>o(),loading:i&&"Approving tokens...",children:"Approve tokens"})}):s},lp=({tx:e})=>{const{mutate:s,isPending:n}=F_(e);return t.jsx(ae,{children:t.jsx(V.White,{onClick:()=>s(),loading:n&&"Signing transaction...",children:"Confirm"})})},dp=()=>t.jsx(ut,{title:"Route preview",children:t.jsx(op,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(rp,{addressList:e}),t.jsx(ip,{children:s=>t.jsx(ap,{addressList:e,signedOpHook:s,children:n=>t.jsx(cp,{tx:n,children:t.jsx(lp,{tx:n})})})})]})})}),up="_button_14cv7_1",mp="_checkbox_14cv7_10",hp="_checked_14cv7_23",os={button:up,checkbox:mp,checked:hp},_p=({checked:e,onClick:s,label:n,className:r})=>t.jsxs("button",{type:"button",className:D(os.button,r),onClick:s,children:[t.jsx("div",{className:D(os.checkbox,{[os.checked]:e}),children:e&&t.jsx(A.IconCheck,{size:12})}),t.jsx("span",{className:os.label,children:n})]}),pp="_success_t4dfk_1",fp="_error_t4dfk_5",ir={success:pp,error:fp},gp=({tx:e})=>{const[s,n]=Co(e);if(!s)throw new Error("Bridge history details not found");const{data:r}=U_(s),o=s.state??xp(r);switch(h.useEffect(()=>{o!=="loading"&&n(a=>{if(!a)throw new Error("Bridge history details not found");return{...a,tracked:!0,state:o}})},[n,o]),o){case"error":return t.jsx("div",{className:ir.error,children:t.jsx(A.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:ir.success,children:t.jsx(A.IconCheckCircleFilled,{size:14})});default:return t.jsx(Je,{size:14})}};function xp(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 yp="_link_1uidr_1",jp="_header_1uidr_22",vp="_title_1uidr_30",wp="_date_1uidr_36",bp="_explorer_1uidr_40",Cp="_fees_1uidr_55",Ip="_label_1uidr_63",Np="_content_1uidr_67",Sp="_route_1uidr_73",Ap="_row_1uidr_78",kp="_asset_1uidr_84",$p="_amount_1uidr_92",Ep="_chain_1uidr_97",Tp="_account_1uidr_106",qp="_arrow_1uidr_113",se={link:yp,header:jp,title:vp,date:wp,explorer:bp,fees:Cp,label:Ip,content:Np,route:Sp,row:Ap,asset:kp,amount:$p,chain:Ep,account:Tp,arrow:qp},Dp=({tx:e})=>{const[s,n]=Co(e);if(!s)throw new Error("Bridge history details not found");const{chainId:r,txHash:o,route:a,values:i,timestamp:l,tracked:c}=s,{data:d}=O_(s),{address:u="",connector:m}=we.useAccount(),{find:_}=Is();h.useEffect(()=>{d&&n(Q=>{if(!Q)throw new Error("Bridge history details not found");return{...Q,tracked:!0}})},[n,d]);const{amount_in:p,amount_out:f,source_asset_chain_id:g,source_asset_denom:b,dest_asset_chain_id:C,dest_asset_denom:w,estimated_fees:P=[]}=a,E=ke(g),y=ke(C),T=Re(b,g),N=Re(w,C),I=(Q,X)=>X?t.jsx(K,{src:X,width:12,height:12}):j.InitiaAddress.equals(Q,u)?t.jsx(K,{src:m?.icon,width:12,height:12}):t.jsx(A.IconWallet,{size:12}),x=(Q,{symbol:X,decimals:Ee,logo_uri:Te},{chain_name:Ce,pretty_name:qe,...ht},ue,ie)=>t.jsxs("div",{className:se.row,children:[t.jsx(Cs,{assetLogoUrl:Te,chainLogoUrl:ht.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:se.asset,children:[t.jsx("span",{className:se.amount,children:j.formatAmount(Q,{decimals:Ee})}),t.jsx("span",{children:X})]}),t.jsxs("div",{className:se.chain,children:[t.jsxs("span",{children:["on ",qe||Ce]}),t.jsxs("div",{className:se.account,children:[ie,t.jsx("span",{className:"monospace",children:j.truncate(ue)})]})]})]})]}),k=No(a),R=h.useMemo(()=>{switch(k){case ls.SKIP:return"Skip Explorer";case ls.OP_WITHDRAW:return"Initia Scan"}},[k]),S=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:se.header,children:[t.jsxs("div",{className:se.title,children:[c?t.jsx(gp,{tx:e}):t.jsx(Je,{size:14}),t.jsx("div",{className:se.date,children:Ut.intlFormatDistance(new Date(l),new Date,{locale:"en-US"})})]}),t.jsxs("div",{className:se.explorer,children:[t.jsx("span",{children:R}),t.jsx(A.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:se.route,children:[x(p,T,E,i.sender,I(i.sender,_(i.cosmosWalletName)?.image)),t.jsx("div",{className:se.arrow,children:t.jsx(A.IconArrowDown,{size:12})}),x(f,N,y,i.recipient,I(i.recipient))]}),P.length>0&&t.jsxs("div",{className:se.fees,children:[t.jsx("span",{className:se.label,children:"Fees"}),t.jsx("span",{className:se.content,children:go(P)})]})]});if(k===ls.OP_WITHDRAW)return t.jsx(ws,{chainId:r,txHash:o,className:se.link,children:S});const q=new URLSearchParams({tx_hash:o,chain_id:r}),F=new URL(`?${q.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:F.toString(),className:se.link,target:"_blank",children:S})},Pp="_list_1q71m_1",Rp="_header_1q71m_5",Bp="_checkbox_1q71m_9",Fp="_item_1q71m_13",as={list:Pp,header:Rp,checkbox:Bp,item:Fp},Mp=()=>{const{initiaAddress:e,hexAddress:s}=xe(),{history:n,getHistoryDetails:r}=bo(),o=n.filter(_=>r(_)),a=o.filter(_=>{const p=r(_);if(!p)return!1;const{values:f}=p,{sender:g,recipient:b}=f;return[g,b].some(C=>[e,s].includes(C))}),[i,l]=h.useState(1),[c,d]=be.useToggle(!a.length),u=c?o:a,m=u.slice(0,i*ar);return t.jsx(ut,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:as.list,children:[o.length>0&&o.length!==a.length&&t.jsx("header",{className:as.header,children:t.jsx(_p,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:as.checkbox})}),u.length===0?t.jsx(Y,{children:"No bridge/swap activity"}):m.map((_,p)=>t.jsx("div",{className:as.item,children:t.jsx(ye,{children:t.jsx(Dp,{tx:_})})},p)),u.length>i*ar?t.jsx(xo,{onClick:()=>l(_=>_+1)}):n.length>=ms&&t.jsxs(Y,{children:["Only the latest ",ms," items are stored. Older entries will be removed automatically."]})]})})},Ao=()=>{const e=de(),s=_n(),n=bt(),{closeDrawer:r}=wt(),{closeModal:o}=Lt();if(h.useEffect(()=>{o(),s.startsWith("/bridge/")&&e("/bridge"),(s==="/collection"||s.startsWith("/nft"))&&e("/nfts")},[n]),s==="/connect")return n?null:t.jsx(zn,{onSuccess:r});if(s==="/blank")return null;if(!n)return t.jsx(zn,{});switch(s){case"/":case"/nfts":case"/activity":return t.jsx(Du,{});case"/send":return t.jsx(Lm,{},n);case"/nft":return t.jsx(Xm,{});case"/nft/send":return t.jsx(hh,{},n);case"/bridge":return t.jsx(s_,{},n);case"/bridge/preview":return t.jsx(dp,{});case"/bridge/history":return t.jsx(Mp,{});case"/op/withdrawals":return t.jsx(R_,{});case"/tx":return t.jsx(Gr,{})}},Op="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",Up=()=>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:Op}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),Lp=()=>{re();const e=ge();return jn(),yt(localStorage.getItem(O.BRIDGE_SRC_CHAIN_ID)??e.chainId),yt(localStorage.getItem(O.BRIDGE_DST_CHAIN_ID)??e.chainId),null},zp=({children:e,...s})=>(h.useEffect(()=>{ya()},[]),be.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(Up,{}),t.jsxs(gr.Provider,{value:{...mr,...s},children:[t.jsx(ye,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(Lp,{})}),t.jsx(pr,{children:t.jsx(wa,{children:t.jsx(U.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(Ra,{children:t.jsxs(ic,{children:[e,t.jsx(Uc,{children:t.jsx(Ao,{})})]})})})})})]})]}):null),Kp=({bridge:e})=>t.jsx(pr,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Mr.Provider,{value:!!e,children:t.jsx(ye,{children:t.jsx(Ao,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=Bt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=ur;exports.InterwovenKit=Kp;exports.InterwovenKitProvider=zp;exports.MAINNET=mr;exports.TESTNET=Ho;exports.initiaPrivyWallet=Qo;exports.initiaPrivyWalletConnector=Wo;exports.initiaPrivyWalletOptions=hn;exports.injectStyles=lc;exports.useAddress=bt;exports.useHexAddress=js;exports.useInitiaAddress=te;exports.useInterwovenKit=xe;exports.useUsernameQuery=Dr;
4
+ </svg>`,ha=encodeURIComponent(ma),pn=`data:image/svg+xml;utf8,${ha}`,ls=Te.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,s)=>[e,s],resource:(e,s)=>[e.chainId,s.denom],denom:(e,s)=>[e,s],metadata:(e,s)=>[e,s]});function fa(e){const{base:s,symbol:n,denom_units:r=[],display:o,logo_URIs:a,name:i,address:l,traces:c}=e,d=r.find(m=>m.denom===o)?.exponent??r.find(m=>m.denom===s)?.exponent??y.head(r)?.exponent??0,u=a?.png??"";return{denom:s,symbol:n,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function Pr(){const e=T.useQueryClient();return s=>{const n=s?.metadata?.assetlist;return T.queryOptions({queryKey:ls.list(n).queryKey,queryFn:async()=>n?J.get(n).json():{assets:[]},select:({assets:r})=>{if(!s)return[];const o=r.map(fa);for(const a of o)e.setQueryData(ls.item(s.chainId,a.denom).queryKey,a);return o},staleTime:K.MINUTE})}}function Ot(e){const s=Pr(),{data:n}=T.useSuspenseQuery(s(e));return n}function _a(){const e=se(),s=Pr();return T.useQueries({queries:e.map(n=>s(n))})}function Ve(e){const s=Ot(e),n=pe(),r=Ot(n),o=Rr(e);return a=>{const i=s.find(c=>c.denom===a);if(i)return i;const l=r.find(c=>c.denom===o(a));return l?{...l,denom:a}:{denom:a,symbol:"",decimals:0,logoUrl:pn}}}function Br(e,s){const n=Ve(s),o=T.useQueryClient().getQueryData(ls.item(s.chainId,e).queryKey);return o||n(e)}function Rr(e){const s=pe(),n=Ot(e);return r=>{if(e.metadata?.is_l1)return r;if(r.startsWith("l2/")||r.startsWith("ibc/")){const a=n.find(i=>i.denom===r)?.traces;if(a){for(const i of a)if(i.counterparty.chain_name===s.chain_name)return i.counterparty.base_denom}}const o=s.metadata?.ibc_channels?.find(({chain_id:a,version:i})=>a===e.chain_id&&i==="ics20-1")?.channel_id;return o?w.getIbcDenom(o,r):""}}const Bn="usernames";function pa({restUrl:e,moduleAddress:s}){const{viewFunction:n}=w.createMoveClient(e);async function r(i){if(!w.InitiaAddress.validate(i))return null;const l=await n({moduleAddress:s,moduleName:Bn,functionName:"get_name_from_address",typeArgs:[],args:[W.toBase64(w.InitiaAddress(i,32).bytes)]});return l?l+".init":null}function o(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function a(i){if(!o(i))return null;const l=await n({moduleAddress:s,moduleName:Bn,functionName:"get_address_from_name",typeArgs:[],args:[Ro.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return l?w.InitiaAddress(l).bech32:null}return{restUrl:e,getUsername:r,getAddress:a,validateUsername:o}}const bs=Te.createQueryKeys("interwovenkit:account",{username:(e,s)=>[e,s],address:(e,s)=>[e,s],balances:(e,s)=>[e,s],txs:(e,s)=>[e,s]});function Mr(){const{restUrl:e}=pe(),{usernamesModuleAddress:s}=de();return pa({restUrl:e,moduleAddress:s})}function Fr(){const e=ne();return s=>T.queryOptions({queryKey:bs.balances(s.restUrl,e).queryKey,queryFn:()=>Dr(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:s.restUrl},"balances"),staleTime:K.SECOND})}function gn(e){const s=Fr(),{data:n}=T.useSuspenseQuery(s(e));return n}function ga(){const e=se(),s=Fr();return T.useQueries({queries:e.map(n=>s(n))})}function xa(e){const s=gn(e),n=Ot(e),r=Ve(e),o=Rr(e),{data:a}=xs(e),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>n.some(d=>d.denom===c);return y.sortWith([y.descend(({denom:c})=>o(c)==="uinit"),y.descend(({denom:c})=>i(c)),y.descend(({value:c})=>c),y.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>R(d).comparedTo(c)??0,y.descend(({symbol:c})=>c.toLowerCase())],s.filter(({amount:c})=>!R(c).isZero()).map(({amount:c,denom:d})=>{const u=r(d),m=a?.find(({id:_})=>_===u?.denom)?.price??0,h=R(c).times(m).div(R(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:m,value:h}}))}const ya="INIT",ja="Initia";function xn(e){return e.assets.reduce((s,{value:n})=>s+(n??0),0)}function va(e){return e.assets.reduce((s,{quantity:n})=>s.plus(n),R(0)).toString()}function wa(e,s){return{symbol:s?.symbol??e,logoUrl:s?.logoUrl??pn}}function Rn(e){return y.pick(["chainId","name","logoUrl"],e)}function ba(e){return y.sortWith([y.descend(({symbol:s})=>s===ya),y.descend(xn),y.descend(({assets:s})=>s.length),y.ascend(({symbol:s})=>s)])(e)}function Ca(e){return y.sortWith([y.descend(({value:s})=>s??0),y.descend(({quantity:s})=>Number(s)),y.ascend(({chain:s})=>s.name)])(e)}function Ia(e){return y.sortWith([y.descend(({chain:s})=>s.name===ja),y.ascend(({chain:s})=>s.name),y.ascend(({denom:s})=>s)])(e)}function Na(e,s){return y.sortWith([y.descend(({chainId:n})=>n===s),y.descend(y.prop("value"))])(e)}function Sa(e,s,n,r,o){const a={};for(const u of e){const m=u.chainId,h=s[m]??[],_=n[m],p=r[m],g=[];for(const{amount:C,denom:$}of h){if(!R(C).gt(0))continue;const N=_?.find(b=>b.denom===$),q=p?.find(b=>b.id===$)?.price,v=N?.decimals??0,j=w.fromBaseUnit(C,{decimals:v}),k=q?R(j).times(q).toNumber():void 0;g.push({...wa($,N),amount:C,denom:$,decimals:v,quantity:j,price:q,value:k,address:N?.address,unlisted:!N,chain:Rn(u)})}a[m]=g}const i=new Map;for(const[u,m]of Object.entries(a)){const h=e.find(p=>p.chainId===u);if(!h)continue;const _=m.reduce((p,{value:g})=>p+(g??0),0);i.set(u,{...Rn(h),value:_})}const l=new Map;for(const u of Object.values(a))for(const m of u)if(!m.unlisted){const{symbol:h}=m,_=l.get(h)??[];l.set(h,[..._,m])}const c=[];for(const[u,m]of l){const h=y.head(m);if(!h)continue;const _=Ca(m);c.push({symbol:u,logoUrl:h.logoUrl,assets:_})}const d=[];for(const u of Object.values(a))for(const m of u)m.unlisted&&d.push(m);return{chainsByValue:Na(Array.from(i.values()),o),assetGroups:ba(c),unlistedAssets:Ia(d),totalValue:c.reduce((u,m)=>u+xn(m),0)}}function yn(){const{defaultChainId:e}=de(),s=se(),n=ga(),r=_a(),o=ea(),a=s.map(h=>h.chainId),i=y.zipObj(a,n.map(y.prop("data"))),l=y.zipObj(a,r.map(y.prop("data"))),c=y.zipObj(a,o.map(y.prop("data"))),d=Sa(s,i,l,c,e),u=[n,r,o].flat().some(({isLoading:h})=>h);return{...d,isLoading:u,refetch:()=>{n.forEach(({refetch:h})=>h()),r.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h())}}}function ne(){const e=Cs();return e?w.InitiaAddress(e).bech32:""}function Cs(){const{address:e}=_e.useAccount();return e?w.InitiaAddress(e).hex:""}function wt(){const e=Kt(),s=ne(),n=Cs();return e.metadata?.minitia?.type==="minievm"?n:s}function Or(){const e=wt(),s=Mr();return T.useQuery({queryKey:bs.username(s.restUrl,e).queryKey,queryFn:()=>s.getUsername(e),enabled:!!e,staleTime:K.MINUTE})}function ge(){const e=wt(),s=ne(),n=Cs(),{data:r}=Or(),o=jt(),a=kr(),{isDrawerOpen:i,openDrawer:l}=vt(),c=()=>{l("/")},d=()=>{l("/connect")},u=_=>{l("/bridge",_)},m=Er();return{address:e,initiaAddress:s,hexAddress:n,username:r,offlineSigner:o,isConnected:!!e,isOpen:i,openConnect:d,openWallet:c,openBridge:u,disconnect:a,...m}}function ka(){const e=["initia-wallet-widget:last-connected-wallet","initia-wallet-widget:fee-denoms","initia-wallet-widget:chain-ids","initia-wallet-widget:opened-layers-assets","initia-wallet-widget:opened-layers-nft"],s={"initia-wallet-widget:ethereum-public-keys":{prefix:F.PUBLIC_KEY,getSuffix:n=>w.InitiaAddress(n).bech32}};for(const n of e)localStorage.removeItem(n);for(const[n,{prefix:r,getSuffix:o}]of Object.entries(s)){const a=localStorage.getItem(n);if(a)try{const i=JSON.parse(a);for(const[l,c]of Object.entries(i)){const d=`${r}:${o(l)}`;localStorage.setItem(d,c)}localStorage.removeItem(n)}catch{}}}const Aa="_status_tn9m1_1",$a="_error_tn9m1_9",Mn={status:Aa,error:$a},Y=({error:e,children:s})=>t.jsx("p",{className:P(Mn.status,{[Mn.error]:e}),children:s}),xe=({errorBoundaryProps:e={fallbackRender:({error:r})=>t.jsx(Y,{error:!0,children:r.message})},suspenseFallback:s=t.jsx(Y,{children:"Loading..."}),children:n})=>t.jsx(ur.ErrorBoundary,{...e,children:t.jsx(f.Suspense,{fallback:s,children:n})}),Ae=Te.createQueryKeys("interwovenkit:skip",{chains:null,assets:e=>[e],asset:(e,s)=>[e,s],balances:(e,s)=>[e,s],route:(e,s)=>[e,s],routeErrorInfo:e=>[e],txTrack:(e,s)=>[e,s],txStatus:(e,s)=>[e,s]});function Re(){const{routerApiUrl:e}=de();return f.useMemo(()=>J.create({prefixUrl:e}),[e])}function Ur(){const e=se();return s=>e.some(n=>n.chain_id===s)}function Ht(){const e=Ur();return s=>e(s.chain_id)?"initia":s.chain_type}function Ut(e){return Ht()(e)}function jn(){const e=Re(),{data:s}=T.useSuspenseQuery({queryKey:Ae.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:n})=>y.sortWith([y.descend(({chain_name:r})=>r==="initia"),y.ascend(({pretty_name:r})=>r)],n),staleTime:K.MINUTE});return s}function lt(){const e=jn();return s=>{const n=e.find(r=>r.chain_id===s);if(!n)throw new Error(`Chain not found: ${s}`);return n}}function $e(e){return lt()(e)}function xt(e){const s=Re(),n=T.useQueryClient(),{data:r}=T.useSuspenseQuery({queryKey:Ae.assets(e).queryKey,queryFn:()=>s.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:o})=>{const{assets:a}=o[e]??{assets:[]};for(const i of a)n.setQueryData(Ae.asset(e,i.denom).queryKey,i);return a.toSorted(y.descend(i=>i.symbol==="INIT"))},staleTime:K.MINUTE});return r}function Lr(e){const s=xt(e);return n=>{const r=s.find(o=>o.denom===n);if(!r)throw new Error(`Asset not found: ${n}`);return r}}function De(e,s){return Lr(s)(e)}const vn=f.createContext(null);function it(){const{container:e}=f.useContext(vn);return e}function zr(e){const s=it();return s?getComputedStyle(s).getPropertyValue(e):""}const Ta=({children:e})=>{const[s,n]=f.useState(null);return t.jsx(vn.Provider,{value:{container:s,setContainer:n},children:e})},Ea="_loader_4gdsk_1",qa={loader:Ea},Ge=({size:e=24,color:s="currentColor",border:n=2})=>{const r={width:`${e}px`,height:`${e}px`,borderColor:`${s} ${s} transparent ${s}`,borderWidth:`${n}px`};return t.jsx("div",{className:qa.loader,style:r})},Da="_container_1zg8z_1",Pa="_toast_1zg8z_10",Ba="_info_1zg8z_23",Ra="_success_1zg8z_27",Ma="_error_1zg8z_31",Fa="_icon_1zg8z_36",Oa="_content_1zg8z_43",Ua="_title_1zg8z_46",La="_description_1zg8z_51",za="_close_1zg8z_72",Ue={container:Da,toast:Pa,info:Ba,success:Ra,error:Ma,icon:Fa,content:Oa,title:Ua,description:La,close:za},Ka=({notification:e,onClose:s,...n})=>{const r=re.useTransition(e,{keys:a=>a?.id||"empty",from:{transform:"translateY(-52px)",opacity:0},enter:{transform:"translateY(0px)",opacity:1},leave:{transform:"translateY(-52px)",opacity:0},config:{tension:500,friction:30,clamp:!0}}),o=a=>{switch(a){case"loading":return t.jsx(Ge,{size:16});case"info":case"success":return t.jsx(A.IconCheckCircleFilled,{size:16});case"error":return t.jsx(A.IconCloseCircleFilled,{size:16});default:return null}};return r((a,i)=>{if(!i)return null;const{type:l,title:c,description:d}=i,u=o(l);return t.jsx(re.animated.div,{style:a,className:Ue.container,children:t.jsxs("div",{className:P(Ue.toast,l&&Ue[l]),...n,children:[u&&t.jsx("div",{className:Ue.icon,children:u}),t.jsxs("div",{className:Ue.content,children:[t.jsx("p",{className:Ue.title,children:c}),d&&t.jsx("div",{className:Ue.description,children:d})]}),t.jsx("button",{className:Ue.close,onClick:s,children:t.jsx(A.IconClose,{size:14})})]})})})},Kr=f.createContext(null),wn=()=>f.useContext(Kr),Fs=5e3,Ha=({children:e})=>{const s=it(),[n,r]=f.useState(null),o=f.useRef(null),a=f.useRef(!1),i=()=>{o.current&&(clearTimeout(o.current),o.current=null)},l=f.useCallback(()=>{i(),r(null)},[]),c=f.useCallback(h=>{i(),r({...h,id:Dn.nanoid()}),h.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Fs))},[l]),d=f.useCallback(h=>{i(),r(_=>_?{..._,...h}:{...h,id:Dn.nanoid()}),h.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Fs))},[l]),u=()=>{i(),a.current=!0},m=()=>{i(),a.current=!1,n?.autoHide&&(o.current=setTimeout(()=>l(),Fs))};return f.useEffect(()=>()=>i(),[]),t.jsxs(Kr.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,s&&hn.createPortal(t.jsx(Ka,{notification:n,onClose:l,onMouseEnter:u,onMouseLeave:m}),s)]})},Hr=f.createContext(!1),Wa="_overlay_1tsd9_1",Qa="_fullscreen_1tsd9_12",Va="_content_1tsd9_16",Ga="_header_1tsd9_43",Ya="_title_1tsd9_52",Ja="_close_1tsd9_57",Ze={overlay:Wa,fullscreen:Qa,content:Va,header:Ga,title:Ya,close:Ja},Wr=({title:e,children:s,trigger:n,className:r,open:o,onOpenChange:a})=>{const i=it(),l=f.useContext(Hr);f.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=re.useTransition(o,{from:{opacity:0},enter:{opacity:1},leave:{opacity:0},config:{tension:500,friction:30,clamp:!0}}),d=re.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?t.jsxs(t.Fragment,{children:[n&&t.jsx("button",{type:"button",className:r,onClick:()=>a(!0),children:n}),hn.createPortal(t.jsxs(t.Fragment,{children:[c((u,m)=>m&&t.jsx(re.animated.div,{style:u,className:P(Ze.overlay,{[Ze.fullscreen]:l}),onClick:()=>a(!1),onKeyDown:()=>a(!1),role:"button",tabIndex:0})),d((u,m)=>m&&t.jsxs(re.animated.div,{style:u,className:P(Ze.content,{[Ze.fullscreen]:l}),children:[e&&t.jsxs("header",{className:Ze.header,children:[t.jsx("h2",{className:Ze.title,children:e}),t.jsx("button",{type:"button",className:Ze.close,onClick:()=>a(!1),children:t.jsx(A.IconClose,{size:20})})]}),s]}))]}),i)]}):null},Za=10;function Qr(){const e=ne();return s=>T.queryOptions({queryKey:bs.txs(s.indexerUrl,e).queryKey,queryFn:async()=>{const n={"pagination.reverse":!0,"pagination.limit":Za};return J.create({prefixUrl:s.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:n}).json()},select:n=>n.txs,staleTime:K.SECOND})}function Xa(e){const s=Qr();return T.useSuspenseQuery(s(e))}function ei(e,s){const n=e.flatMap((r,o)=>(s[o]??[]).map(i=>({...i,chain:r})));return y.sortWith([y.descend(r=>new Date(r.timestamp).getTime())])(n)}const ti=()=>{const e=se(),s=Qr(),n=T.useQueries({queries:e.map(i=>s(i))}),r=n.map(y.prop("data")),o=ei(e,r),a=n.some(i=>i.isLoading);return{activities:o,isLoading:a}};function Vr(e){const{data:s}=T.useSuspenseQuery({queryKey:_n.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:r}=await J.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return r.toSorted(y.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const i=o==="uinit"?1:fr;return{amount:R(a).times(i).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:r})=>{if(y.isNil(r))throw new Error(`${n} has no price`);return{amount:String(r),denom:n}})},staleTime:K.SECOND});return s}function Gr(e){const s=ne(),{data:n}=Xa(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{return n.find(({tx:a})=>a.auth_info.signer_infos.some(i=>w.InitiaAddress.equals(s,at.computeAddress(`0x${W.toHex(en.Secp256k1.uncompressPubkey(W.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??r}catch{return r}}const si="_root_hypwm_1",ni="_item_hypwm_10",ri="_chevron_hypwm_14",oi="_trigger_hypwm_19",ai="_content_hypwm_39",$t={root:si,item:ni,chevron:ri,trigger:oi,content:ai};function ii(e){const{list:s,getKey:n,renderHeader:r,renderContent:o,footer:a,...i}=e;return t.jsxs(U.Accordion.Root,{className:$t.root,type:"multiple",...i,children:[s.map((l,c)=>t.jsxs(U.Accordion.Item,{className:$t.item,value:n?.(l)??String(c),children:[t.jsx(U.Accordion.Header,{children:t.jsxs(U.Accordion.Trigger,{className:$t.trigger,children:[r(l),t.jsx(A.IconChevronDown,{className:$t.chevron,size:16})]})}),t.jsx(U.Accordion.Content,{className:$t.content,children:o(l)})]},n?.(l)??c)),a]})}const ci="_scrollable_abvhw_1",li={scrollable:ci},Me=({className:e,children:s,ref:n})=>t.jsx("div",{ref:n,className:P(li.scrollable,e),children:s}),nn=({children:e})=>{const s=f.useRef(null),[n,r]=f.useState(0),o=re.useSpring({height:n,config:{tension:500,friction:30,clamp:!0}});return f.useEffect(()=>{if(s.current){const{height:a}=s.current.getBoundingClientRect();r(a)}},[e]),e?t.jsx(re.animated.div,{style:{overflow:"hidden",...o},children:t.jsx("div",{ref:s,children:e})}):null},di="_help_7m3jv_1",ui="_icon_7m3jv_10",mi="_info_7m3jv_17",hi="_warning_7m3jv_21",fi="_error_7m3jv_25",_i="_success_7m3jv_31",Os={help:di,icon:ui,info:mi,warning:hi,error:fi,success:_i},Ke=({level:e,className:s,mt:n=8,children:r})=>{if(!r)return null;const o=()=>{switch(e){case"loading":return t.jsx(Ge,{size:12});case"info":return t.jsx(A.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(A.IconWarningFilled,{size:12});default:return t.jsx(A.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:P(Os.help,e&&Os[e],s),style:{marginTop:n},children:[t.jsx("div",{className:Os.icon,children:o()}),t.jsx("p",{children:r})]})},pi="_stack_14kq8_1",gi="_help_14kq8_6",xi="_info_14kq8_14",yi="_warning_14kq8_19",ji="_error_14kq8_24",vi="_success_14kq8_29",rn={stack:pi,help:gi,info:xi,warning:yi,error:ji,success:vi},wi=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(nn,{children:t.jsx("div",{className:rn.stack,children:e})}),te=e=>t.jsx(Ke,{...e,className:P(rn.help,rn[e.level]),mt:0});te.Stack=wi;const bi="_footer_xif7g_1",Ci="_actions_xif7g_10",Fn={footer:bi,actions:Ci},ae=({extra:e,className:s,children:n})=>t.jsxs("footer",{className:P(Fn.footer,s),children:[e,t.jsx("div",{className:Fn.actions,children:n})]}),Ii="_button_1n7c4_1",Ni="_outline_1n7c4_25",Si="_sm_1n7c4_43",ki="_full_1n7c4_49",Ai="_small_1n7c4_53",$i="_unpadded_1n7c4_83",nt={button:Ii,outline:Ni,sm:Si,full:ki,small:Ai,unpadded:$i},Yr=e=>{const{sm:s,fullWidth:n,loading:r,className:o,children:a,disabled:i,...l}=e;return t.jsx("button",{...l,className:P(nt.button,{[nt.sm]:s,[nt.full]:n},o),disabled:!!r||i,children:r?t.jsxs(t.Fragment,{children:[t.jsx(Ge,{color:"currentColor",size:16}),typeof r=="string"&&t.jsx("span",{className:nt.loading,children:r})]}):a})},Ti=({className:e,...s})=>t.jsx(Yr,{...s,className:P(nt.outline,e)}),Ei=({className:e,unpadded:s,...n})=>t.jsx("button",{...n,className:P(nt.small,{[nt.unpadded]:s},e)}),V={White:Yr,Outline:Ti,Small:Ei},qi="_item_1n572_1",Di="_title_1n572_10",Pi="_content_1n572_14",Us={item:qi,title:Di,content:Pi},Ls=({title:e,content:s})=>t.jsxs("div",{className:Us.item,children:[t.jsx("div",{className:Us.title,children:e}),t.jsx("div",{className:Us.content,children:s})]});function We(e){if(e&&R(e).gt(0)&&R(e).lt(.01))return"<$0.01";const s=w.formatNumber(e,{dp:2});return s?`$${s}`:""}const Bi="_placeholder_9cmx1_1",Ri="_logo_9cmx1_5",On={placeholder:Bi,logo:Ri},H=({src:e,alt:s,placeholder:n,classNames:r,style:o,logo:a,...i})=>{const[l,c]=f.useState(!1),{width:d,height:u}=i,m=n??t.jsx("div",{className:P(On.placeholder,r?.placeholder),style:{width:d,height:u,...o}});return f.useEffect(()=>{c(!1)},[e]),!e||l?m:t.jsx("img",{...i,className:P(i.className,{[On.logo]:a}),style:{width:d,height:u,...o},src:e,alt:s,loading:"lazy",onError:()=>c(!0)})};function Jr(e,s){const n={};for(const r of e)if(r.attributes.some(a=>a.key==="msg_index")){if(r.type==="coin_spent"){const a=r.attributes.find(l=>l.key==="spender")?.value,i=r.attributes.find(l=>l.key==="amount")?.value;if(a===s&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=n[c]||BigInt(0);n[c]=d-BigInt(l)}}}if(r.type==="coin_received"){const a=r.attributes.find(l=>l.key==="receiver")?.value,i=r.attributes.find(l=>l.key==="amount")?.value;if(a===s&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=n[c]||BigInt(0);n[c]=d+BigInt(l)}}}}return Object.entries(n).filter(([,r])=>r!==BigInt(0)).map(([r,o])=>({amount:o.toString(),denom:r}))}function Zr(e,s){const n={};for(const r of e)if(r.attributes.some(a=>a.key==="msg_index")&&r.type==="move"){const a=r.attributes.find(c=>c.key==="type_tag")?.value,i=r.attributes.find(c=>c.key==="data")?.value;if(!a||!i)continue;let l;try{l=JSON.parse(i)}catch{continue}if(a==="0x1::fungible_asset::WithdrawEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&w.createUserDerivedObjectAddress(s,u)===c){const h=n[u]||BigInt(0);n[u]=h-BigInt(d)}}if(a==="0x1::fungible_asset::DepositEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&w.createUserDerivedObjectAddress(s,u)===c){const h=n[u]||BigInt(0);n[u]=h+BigInt(d)}}}return Object.entries(n).filter(([,r])=>r!==BigInt(0)).map(([r,o])=>({amount:o.toString(),metadata:r}))}const Xr=({metadata:e,chain:s,children:n})=>{const{restUrl:r}=s,{data:o}=T.useSuspenseQuery({queryKey:ls.denom(r,e).queryKey,queryFn:()=>J.create({prefixUrl:r}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:a})=>a,staleTime:K.INFINITY});return n(o)},Mi="_root_jioyr_1",Fi="_title_jioyr_7",Oi="_changes_jioyr_13",Ui="_change_jioyr_13",Li="_amount_jioyr_34",zi="_text_jioyr_40",Ki="_value_jioyr_47",rt={root:Mi,title:Fi,changes:Oi,change:Ui,amount:Li,text:zi,value:Ki},eo=({amount:e,asset:s,price:n})=>{const{denom:r,symbol:o,decimals:a,logoUrl:i}=s,l=w.formatAmount(e,{decimals:a}),c=n&&R(w.fromBaseUnit(e,{decimals:a})).times(n).abs();return t.jsxs("div",{className:rt.change,children:[t.jsxs("div",{className:rt.amount,children:[t.jsx(H,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:rt.text,children:[l," ",o||r]})]}),c&&t.jsx("div",{className:rt.value,children:We(c)})]})},Hi=({changes:e,chain:s})=>{const n=Ve(s),{data:r}=xs(s);return e.map(({amount:o,denom:a},i)=>{const l=n(a),c=r?.find(({id:d})=>d===a)?.price;return t.jsx(eo,{amount:o,asset:l,price:c},i)})},Wi=({changes:e,chain:s})=>{const n=Ve(s),{data:r}=xs(s);return e.map(({amount:o,metadata:a},i)=>t.jsx(Xr,{metadata:a,chain:s,children:l=>{const c=r?.find(({id:d})=>d===l)?.price;return t.jsx(eo,{amount:o,asset:n(l),price:c})}},i))};function Qi(e,s){return typeof s=="bigint"?s.toString():s}const Vi=Te.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Qi)]}),Gi=({messages:e,memo:s,chainId:n})=>{const{initiaAddress:r,hexAddress:o}=ge(),a=Be(n),{simulateTx:i}=Er(),{data:l}=T.useSuspenseQuery({queryKey:Vi.simulate({messages:e,memo:s,chainId:n}).queryKey,queryFn:()=>i({messages:e,memo:s,chainId:n}),staleTime:K.SECOND}),c=h=>t.jsxs("div",{className:rt.root,children:[t.jsx("h2",{className:rt.title,children:"Estimated changes"}),t.jsx("div",{className:rt.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=Zr(d,o),[_]=Un(h);return _.length===0?null:c(t.jsx(Wi,{changes:_,chain:a}))}const u=Jr(d,r),[m]=Un(u);return m.length===0?null:c(t.jsx(Hi,{changes:m,chain:a}))};function Un(e){return y.partition(s=>new R(s.amount).isNegative(),e)}const Yi="_trigger_13rgr_1",Ji="_icon_13rgr_5",Zi="_content_13rgr_16",Xi="_item_13rgr_24",Yt={trigger:Yi,icon:Ji,content:Zi,item:Xi},ec=({options:e,value:s,onChange:n})=>{const r=it(),{txRequest:o}=Tr(),a=Be(o.chainId),i=Ve(a),l=({amount:[{amount:c,denom:d}]})=>{if(R(c).isZero())return"0";const{symbol:u,decimals:m}=i(d);return`${w.formatAmount(c,{decimals:m})} ${u}`};return e.length===1?l(e[0]):t.jsxs(U.Select.Root,{value:s,onValueChange:n,children:[t.jsxs(U.Select.Trigger,{className:Yt.trigger,children:[t.jsx(U.Select.Value,{}),t.jsx(U.Select.Icon,{className:Yt.icon,children:t.jsx(A.IconChevronDown,{size:16})})]}),t.jsx(U.Select.Portal,{container:r,children:t.jsx(U.Select.Content,{className:Yt.content,position:"popper",sideOffset:6,align:"end",children:t.jsx(U.Select.Viewport,{children:e.map(c=>{const[{denom:d}]=c.amount;return t.jsx(U.Select.Item,{className:Yt.item,value:d,children:t.jsx(U.Select.ItemText,{children:l(c)})},d)})})})})]})};function ds(e){switch(typeof e){case"string":return e;case"number":case"bigint":return e.toString();case"boolean":return e?"true":"false";case"object":return e===null?"null":e instanceof Uint8Array?W.toBase64(e):Array.isArray(e)?`[${e.map(ds).join(",")}]`:JSON.stringify(e,(s,n)=>typeof n=="bigint"?n.toString():n);default:return"unknown"}}const tc="_container_1xzyq_1",sc="_toggle_1xzyq_5",nc="_list_1xzyq_11",rc="_arg_1xzyq_16",oc="_type_1xzyq_21",Tt={container:tc,toggle:sc,list:nc,arg:rc,type:oc},ac=Te.createQueryKeys("interwovenkit:move",{abi:(e,s,n,r)=>[e,s,n,r]}),ic=({type:e,arg:s})=>ds(w.resolveBcsType(e).parse(s)),cc=({msg:e,chainId:s,fallback:n})=>{const[r,o]=be.useToggle(!1),{restUrl:a}=Be(s),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=T.useQuery({queryKey:ac.abi(a,i,l,c).queryKey,queryFn:async()=>{const h=await J.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:K.INFINITY});if(!u)return n;const m=(h,_)=>{const p=u[_];return t.jsxs("div",{className:Tt.arg,children:[t.jsx("div",{className:Tt.type,children:p}),t.jsx(ur.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(ic,{type:p,arg:h})})]},_)};return t.jsxs("div",{className:Tt.container,children:[t.jsx(V.Small,{className:Tt.toggle,onClick:o,disabled:!u,children:r?"Encode":"Decode"}),r?t.jsx("div",{className:Tt.list,children:d.map(m)}):n]})},lc="_list_r67rl_1",dc="_key_r67rl_8",uc="_value_r67rl_13",zs={list:lc,key:dc,value:uc},mc=({message:e,chainId:s})=>{const{typeUrl:n,value:r}=e;return t.jsx("div",{className:zs.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{children:[t.jsx("div",{className:zs.key,children:o}),t.jsx("div",{className:zs.value,children:n==="/initia.move.v1.MsgExecute"&&o==="args"?t.jsx(cc,{msg:r,chainId:s,fallback:ds(a)}):ds(a)})]},o))})},hc="_title_kspdu_1",fc="_meta_kspdu_7",_c="_footer_kspdu_14",Ks={title:hc,meta:fc,footer:_c},to=()=>{const{txRequest:e,resolve:s,reject:n}=Tr(),{messages:r,memo:o,chainId:a,gas:i,gasAdjustment:l,spendCoins:c}=e,d=ne(),u=jt(),m=Cr(),h=Be(a),_=gn(h),p=Vr(h),g=Gr(h),C=(e.gasPrices??p).map(({amount:x,denom:D})=>ke.calculateFee(Math.ceil(i*l),ke.GasPrice.fromString(x+D))),$=C.map(x=>x.amount[0]),N=x=>{const D=_.find(S=>S.denom===x)?.amount??0,E=$.find(S=>S.denom===x)?.amount??0,B=c.filter(S=>S.denom===x).reduce((S,O)=>R(S).plus(O.amount),R(0));if(B.gt(0)){const S=R(E).plus(B);return R(D).gte(S)}return R(D).gte(E)},q=()=>{if(g&&N(g))return g;for(const{denom:x}of $)if(N(x))return x;return $[0]?.denom},[v,j]=f.useState(q),{mutate:k,isPending:b}=T.useMutation({mutationKey:[Ar],mutationFn:async()=>{const x=C.find(E=>E.amount[0].denom===v);if(!x)throw new Error("Fee not found");if(!u)throw new Error("Signer not initialized");const D=await m(a,d,r,x,o);await s(D)},onError:async x=>{n(new Error(await Pe(x)))}}),I=!N(v);return t.jsxs(t.Fragment,{children:[t.jsxs(Me,{children:[t.jsx("h1",{className:Ks.title,children:"Confirm tx"}),t.jsxs("div",{className:Ks.meta,children:[t.jsx(Ls,{title:"Chain",content:a}),t.jsx(Ls,{title:"Tx fee",content:t.jsx(ec,{options:C,value:v,onChange:j})}),o&&t.jsx(Ls,{title:"Memo",content:o}),I&&t.jsx(te,{level:"error",children:"Insufficient balance for fee"})]}),t.jsx(Gi,{messages:r,memo:o,chainId:a}),t.jsx(ii,{list:r,renderHeader:({typeUrl:x})=>fs.sentenceCase(x.split(".").pop().replace(/^Msg/,"")),renderContent:x=>t.jsx(mc,{message:x,chainId:a})})]}),t.jsxs(ae,{className:Ks.footer,children:[t.jsx(V.Outline,{onClick:()=>n(new Error("User rejected")),disabled:b,children:"Reject"}),t.jsx(V.White,{onClick:()=>k(),disabled:I,loading:b,children:"Approve"})]})]})},pc=({children:e})=>{const[{title:s,content:n,path:r},o]=f.useState({}),[a,i]=f.useState(!1),l=Q.useAtomValue(ws),c=f.useCallback(m=>{o(m),i(!0)},[]),d=f.useCallback(()=>{o({}),i(!1)},[]),u=f.useCallback(m=>{m||(l?.reject(new Error("User rejected")),o({})),i(m)},[l]);return t.jsxs(jr.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(Wr,{title:s,open:a,onOpenChange:u,children:t.jsx(xe,{children:r==="/tx"?t.jsx(to,{}):n})})]})},gc=()=>(ca(),la(),null);function Is(){return be.useMediaQuery("(max-width: 576px)")}const on="interwoven-kit";function so(){const e=document.querySelector(on)||document.body.appendChild(document.createElement(on));return e.shadowRoot||e.attachShadow({mode:"open"})}function xc(){const{theme:e,container:s}=de();return f.useEffect(()=>{document.querySelector(on)?.setAttribute("data-theme",e)},[e]),s??so()}function yc(e){const s=so(),n=document.createElement("style");n.textContent=e,s.appendChild(n)}const bn=({value:e,children:s})=>{const[n,r]=f.useState(!1);return s({copy:async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1e3)}catch{}},copied:n})},jc="_tooltip_6zakp_1",vc="_arrow_6zakp_43",Ln={tooltip:jc,arrow:vc},bt=({label:e,children:s,small:n,...r})=>t.jsxs(U.Tooltip.Root,{...r,children:[t.jsx(U.Tooltip.Trigger,{asChild:!0,children:s}),t.jsx(U.Tooltip.Portal,{container:it(),children:t.jsxs(U.Tooltip.Content,{className:P(Ln.tooltip,{small:n}),collisionBoundary:it(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(U.Tooltip.Arrow,{className:Ln.arrow})]})})]}),wc="_root_1pbnr_1",bc="_address_1pbnr_9",Cc="_copy_1pbnr_19",Ic="_labelWrapper_1pbnr_33",Nc="_labelCopy_1pbnr_43",Sc="_labelCopied_1pbnr_47",kc="_copied_1pbnr_55",Xe={root:wc,address:bc,copy:Cc,labelWrapper:Ic,labelCopy:Nc,labelCopied:Sc,copied:kc},Ac=()=>{const e=f.useRef(null),s=f.useRef(null),{initiaAddress:n,hexAddress:r}=ge(),o=zr("--gray-0");return f.useEffect(()=>{e.current&&(s.current?s.current.update({data:n}):(s.current=new Mo({type:"canvas",width:400,height:400,margin:0,data:n,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:o},cornersSquareOptions:{type:"extra-rounded",color:o},cornersDotOptions:{type:"dot",color:o},backgroundOptions:{color:"transparent"}}),s.current.append(e.current)))},[n,o]),t.jsxs("div",{className:Xe.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx(bt,{label:`Derived from ${w.truncate(r)}`,children:t.jsx("span",{className:Xe.address,children:n})}),t.jsx(bn,{value:n,children:({copy:a,copied:i})=>t.jsxs("button",{className:P(Xe.copy,{[Xe.copied]:i}),onClick:a,children:[t.jsx(A.IconCopy,{size:12}),t.jsxs("div",{className:Xe.labelWrapper,children:[t.jsx("span",{className:Xe.labelCopy,children:"Copy address"}),t.jsx("span",{className:Xe.labelCopied,children:"Copied!"})]})]})})]})},$c="_header_1cvtq_1",Tc="_account_1cvtq_16",Ec="_name_1cvtq_27",qc="_address_1cvtq_31",Dc="_icon_1cvtq_35",Pc="_copied_1cvtq_42",Bc="_button_1cvtq_57",Rc="_qr_1cvtq_68",Mc="_disconnect_1cvtq_72",Fc="_label_1cvtq_82",Oc="_expanded_1cvtq_90",me={header:$c,account:Tc,name:Ec,address:qc,icon:Dc,copied:Pc,button:Bc,qr:Rc,disconnect:Mc,label:Fc,expanded:Oc},Uc=()=>{const e=Kt(),{connector:s}=_e.useAccount(),n=kr(),{address:r,username:o}=ge(),{openModal:a}=zt(),i=o??r,[l,c]=f.useState(!1),d=f.useRef(null),u=re.useSpring({width:l?140:52,config:{tension:500,friction:30,clamp:!0}}),m=()=>{l?n():c(!0)},h=()=>{l&&(d.current=setTimeout(()=>{c(!1)},500))},_=()=>{d.current&&(clearTimeout(d.current),d.current=null)};return f.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]),s?t.jsxs("header",{className:me.header,children:[t.jsx(bn,{value:r,children:({copy:p,copied:g})=>t.jsxs("button",{className:P(me.account,{[me.copied]:g}),onClick:p,children:[t.jsx(H,{src:s.icon,width:18,height:18}),t.jsx("div",{className:me.address,children:w.truncate(r)}),t.jsx("div",{className:me.name,children:w.truncate(i)}),t.jsx(A.IconCopy,{className:me.icon,size:12}),g?"Copied!":""]})}),e.metadata?.is_l1&&t.jsx("button",{className:P(me.button,me.qr),onClick:()=>a({title:"Initia address",content:t.jsx(Ac,{})}),children:t.jsx(A.IconQrCode,{size:16})}),t.jsxs(re.animated.button,{className:P(me.button,me.disconnect,{[me.expanded]:l}),style:u,onClick:m,onMouseLeave:h,onMouseEnter:_,children:[t.jsx(A.IconSignOut,{size:16}),t.jsx("span",{className:me.label,children:"Disconnect"})]})]}):null};function Lc(e){return/^[A-F0-9]{64}$/i.test(e)}function zc(e,s){const{txHash:n,accountAddress:r,pathSuffix:o}=s;if(n)return Lc(n)?y.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,n):void 0;if(r){if(!w.InitiaAddress.validate(r))return;const i=y.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,r);return i&&o?i+o:i}}function Kc(e){try{const s=new URL(e,window.location.href);if(!["http:","https:"].includes(s.protocol))throw new Error("Invalid protocol");return s.toString()}catch{return"#"}}const Hc="_link_guafb_1",zn={link:Hc},Ns=({chainId:e,txHash:s,accountAddress:n,pathSuffix:r,...o})=>{const{showIcon:a,className:i,children:l,onClick:c,...d}=o,u=Be(e),m=zc(u,{txHash:s,accountAddress:n,pathSuffix:r}),h=s?w.truncate(s):n?w.truncate(n):"",_=l??h;return m?t.jsxs("a",{...d,href:Fo(Kc(m)),className:P(zn.link,i),onClick:c,target:"_blank",children:[_,a&&t.jsx(A.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:P(zn.link,i),children:_})},Wc=()=>{const[e,s]=Q.useAtom($r),{showNotification:n,updateNotification:r,hideNotification:o}=wn();return f.useEffect(()=>{if(!e)return;const{status:a,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(Ns,{txHash:l,chainId:i,onClick:o,showIcon:!0,children:"View on Initia Scan"}):null;switch(a){case"loading":n({type:"loading",title:"Transaction is pending..."});break;case"error":r({type:"error",title:"Transaction failed",description:d}),s(null);break;case"success":r({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),s(null);break}},[e,s,n,r,o]),null};function Qc(){return be.useScrollLock(),null}const Vc="_overlay_g3vaj_1",Gc="_content_g3vaj_49",Yc="_inner_g3vaj_67",Hs={overlay:Vc,content:Gc,inner:Yc},Jc=({children:e})=>{const{isDrawerOpen:s,closeDrawer:n}=vt(),{setContainer:r}=f.useContext(vn),o=Is(),a=Q.useAtomValue(ws),i=T.useIsMutating({mutationKey:[Ar]}),l=()=>{const _=i?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";n(),a?.reject(new Error(_))},c=ps(),d=le(),u=T.useQueryClient(),m={fallbackRender:({error:_,resetErrorBoundary:p})=>{const g=()=>{c==="/bridge"&&(localStorage.removeItem(F.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(F.BRIDGE_SRC_DENOM),localStorage.removeItem(F.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(F.BRIDGE_DST_DENOM)),d("/"),u.clear(),p()};return t.jsxs(Me,{children:[t.jsx(Y,{error:!0,children:_.message}),t.jsx(ae,{children:t.jsx(V.White,{onClick:g,children:"Retry"})})]})}},h=re.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 hn.createPortal(t.jsxs(t.Fragment,{children:[h((_,p)=>p?t.jsx(re.animated.button,{style:_,className:Hs.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),h((_,p)=>p?t.jsx(re.animated.div,{style:_,className:P(Hs.content),children:t.jsxs("div",{className:P(Hs.inner,"body"),ref:r,children:[o&&t.jsx(Qc,{}),t.jsx(Wc,{}),t.jsx(Uc,{}),t.jsx(xe,{errorBoundaryProps:m,children:e})]})}):null)]}),xc())},Zc="_page_1f6wh_1",Xc="_title_1f6wh_10",el="_scrollable_1f6wh_17",tl="_list_1f6wh_22",sl="_item_1f6wh_32",nl="_name_1f6wh_56",rl="_dimmed_1f6wh_64",ol="_recent_1f6wh_68",al="_installed_1f6wh_69",ve={page:Zc,title:Xc,scrollable:el,list:tl,item:sl,name:nl,dimmed:rl,recent:ol,installed:al},il=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],Kn=({onSuccess:e})=>{const{connectors:s,connectAsync:n}=_e.useConnect(),r=be.useReadLocalStorage("wagmi.recentConnectorId"),[o,a]=f.useState(null),{mutate:i,isPending:l}=T.useMutation({mutationFn:async c=>{a(c.id);try{await n({connector:c})}catch(d){throw new Error(await Pe(d))}},onSettled:()=>{a(null)},onSuccess:()=>{e?.()}});return t.jsxs("div",{className:ve.page,children:[t.jsx("h1",{className:ve.title,children:"Connect wallet"}),t.jsx(Me,{className:ve.scrollable,children:t.jsxs("div",{className:ve.list,children:[s.toSorted(y.descend(c=>c.id===r)).map(c=>{const{name:d,icon:u,id:m}=c;return t.jsxs("button",{className:ve.item,onClick:()=>i(c),disabled:l,children:[t.jsx(H,{src:u,width:24,height:24}),t.jsx("span",{className:ve.name,children:d}),o===m?t.jsx(Ge,{size:16}):r===m?t.jsx("span",{className:ve.recent,children:"Recent"}):c.name==="Google"?null:t.jsx("span",{className:ve.installed,children:"Installed"})]},m)}),il.filter(({name:c})=>!s.some(d=>d.name.includes(c))).map(({name:c,url:d})=>{const u=`https://assets.initia.xyz/images/wallets/${c}.webp`;return t.jsxs("a",{href:d,className:ve.item,target:"_blank",children:[t.jsx(H,{src:u,width:24,height:24}),t.jsx("span",{className:P(ve.name,ve.dimmed),children:c}),t.jsx(A.IconExternalLink,{size:10})]},c)})]})})]})},cl="_root_xwz5z_1",ll="_header_xwz5z_6",dl="_title_xwz5z_12",ul="_warning_xwz5z_18",ml="_content_xwz5z_22",hl="_footer_xwz5z_26",fl="_secondary_xwz5z_36",et={root:cl,header:ll,title:dl,warning:ul,content:ml,footer:hl,secondary:fl},no=e=>{const{type:s,icon:n,title:r,children:o,primaryButton:a,secondaryButton:i}=e;return t.jsxs(Me,{className:et.root,children:[t.jsxs("header",{className:P(et.header,s&&et[s]),children:[n,t.jsx("h1",{className:et.title,children:r})]}),t.jsx("div",{className:et.content,children:o}),t.jsxs("footer",{className:et.footer,children:[t.jsx(V.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),t.jsxs("button",{className:et.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(A.IconChevronRight,{size:14})]})]})]})},_l="_list_tmcxc_1",pl="_row_tmcxc_8",gl="_dt_tmcxc_19",xl="_asset_tmcxc_25",Jt={list:_l,row:pl,dt:gl,asset:xl},yl=({list:e,onNavigate:s,onDismiss:n})=>{const r=pe(),o=Qe(),a=Ve(r);return t.jsx(no,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:s},secondaryButton:{label:"Do not show again",onClick:n},children:t.jsx("div",{className:Jt.list,children:e.toSorted((i,l)=>i.chainId.localeCompare(l.chainId)).map(({txHash:i,chainId:l,amount:c,denom:d})=>{const u=o(l),{decimals:m,symbol:h}=a(d),_=w.formatAmount(c,{decimals:m});return t.jsxs("div",{className:Jt.row,children:[t.jsxs("div",{className:Jt.dt,children:[t.jsx(H,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:Jt.asset,children:[_," ",h]})]},i)})})})};function Ws(e,s){return e.chainId===s.chainId&&e.txHash===s.txHash}const Zt=({chainId:e,txHash:s})=>`${F.OP_REMINDER}:${e}:${s}`,jl=Oo.atomWithStorage(F.OP_REMINDER,[]);function Ct(){const e=ne(),[s=[],n]=Q.useAtom(jl),r=f.useMemo(()=>s.map(c=>{const d=localStorage.getItem(Zt(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:Lt.isPast(u)}),[e,s]),o=f.useCallback((c,d)=>{s.some(u=>Ws(u,c))||(n((u=[])=>[...u,c]),localStorage.setItem(Zt(c),JSON.stringify(d)))},[s,n]),a=f.useCallback(c=>{n((d=[])=>d.filter(u=>!Ws(u,c))),localStorage.removeItem(Zt(c))},[n]),i=f.useCallback(c=>{const d=c.filter(u=>!s.some(m=>Ws(m,u)));d.length!==0&&n((u=[])=>[...u,...d])},[s,n]),l=f.useCallback((c,d)=>{localStorage.setItem(Zt(c),JSON.stringify(d)),n((u=[])=>[...u])},[n]);return{reminders:r,addReminder:o,removeReminder:a,syncReminders:i,setReminder:l}}function ro(){const e=le(),{openModal:s,closeModal:n}=zt(),{reminders:r,setReminder:o}=Ct();f.useEffect(()=>{const a=r.filter(c=>!c.dismissed);if(a.length===0)return;const i=()=>{const c=a.every(d=>d.chainId===a[0].chainId)?a[0].chainId:void 0;e("/op/withdrawals",{chainId:c}),l()},l=()=>{n();for(const c of a)o(c,{...c,dismissed:!0})};s({content:f.createElement(yl,{list:a,onNavigate:i,onDismiss:l})})},[r,n,e,s,o])}const oo=f.createContext(null);function ao(){return f.useContext(oo)}const vl="_root_7yxgy_1",wl="_label_7yxgy_7",bl="_input_7yxgy_19",Cl="_hasValue_7yxgy_29",Il="_clear_7yxgy_33",Et={root:vl,label:wl,input:bl,hasValue:Cl,clear:Il},Ss=e=>{const{rootClassName:s,padding:n=16,iconSize:r=16,onClear:o,ref:a,...i}=e;return t.jsxs("div",{className:P(Et.root,s,{[Et.hasValue]:i.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${r}px`},children:[t.jsx("label",{htmlFor:"search",className:Et.label,children:t.jsx(A.IconSearch,{size:r})}),t.jsx("input",{className:Et.input,id:"search",type:"text",maxLength:100,ref:a,...i}),i.value&&t.jsx("button",{type:"button",className:Et.clear,"aria-label":"Clear search",onMouseDown:l=>l.preventDefault(),onClick:o,children:t.jsx(A.IconCloseCircleFilled,{size:r})})]})},Nl="_container_t1267_1",Sl="_controls_t1267_7",kl="_search_t1267_13",Cn={container:Nl,controls:Sl,search:kl},Al=({children:e})=>t.jsx("div",{className:Cn.container,children:e}),$l=({children:e})=>t.jsx("div",{className:Cn.controls,children:e}),Tl=e=>t.jsx(Ss,{...e,rootClassName:Cn.search}),He={Root:Al,Controls:$l,SearchInput:Tl};function Wt(){const e=f.useRef(null),s=Is();return f.useEffect(()=>{s||e.current?.focus()},[s]),e}const El="_trigger_1pfd8_1",ql="_icon_1pfd8_21",Dl="_full_1pfd8_25",Pl="_triggerContent_1pfd8_30",Bl="_triggerText_1pfd8_38",Rl="_popoverBackdrop_1pfd8_49",Ml="_popoverPositioner_1pfd8_71",Fl="_popoverPopup_1pfd8_75",Ol="_search_1pfd8_103",Ul="_viewport_1pfd8_108",Ll="_item_1pfd8_113",zl="_highlighted_1pfd8_127",Kl="_itemContent_1pfd8_132",ce={trigger:El,icon:ql,full:Dl,triggerContent:Pl,triggerText:Bl,popoverBackdrop:Rl,popoverPositioner:Ml,popoverPopup:Fl,search:Ol,viewport:Ul,item:Ll,highlighted:zl,itemContent:Kl},In=({value:e,onChange:s,chainIds:n,fullWidth:r})=>{const[o,a]=f.useState(""),[i,l]=f.useState(!1),[c,d]=f.useState(0),[u,m]=f.useState(),h=f.useRef([]),_=f.useRef(null),p=se(),g=n.map(x=>p.find(D=>D.chainId===x)).filter(Boolean),C=x=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:x,height:x,viewBox:"0 0 14 14",children:[t.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),t.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),$=f.useMemo(()=>({chainId:"",name:"All rollups",logoUrl:C}),[]),N=f.useMemo(()=>{const x=[$,...g];if(!o)return x;const D=o.toLowerCase();return x.filter(E=>E.name.toLowerCase().includes(D)||E.chainId.toLowerCase().includes(D))},[g,o,$]),q=g.find(x=>x.chainId===e)||$,v=parseInt(zr("--drawer-offset")),j=6,k=()=>{if(a(""),d(-1),_.current){const D=_.current.getBoundingClientRect().bottom+j,E=window.innerHeight-D-2*v;m(E)}l(!0)};f.useEffect(()=>{c>=0&&c<h.current.length&&h.current[c]?.scrollIntoView({block:"nearest",behavior:"auto"})},[c]);const b=f.useCallback(x=>{switch(x.key){case"ArrowDown":x.preventDefault(),d(D=>(D+1)%N.length);break;case"ArrowUp":x.preventDefault(),d(D=>(D-1+N.length)%N.length);break;case"Enter":x.preventDefault(),N[c]&&(s(N[c].chainId),l(!1));break;case"Escape":x.preventDefault(),l(!1);break}},[N,c,s,l]),I=x=>{s(x),l(!1)};return t.jsxs(ht.Popover.Root,{open:i,onOpenChange:k,children:[t.jsx(ht.Popover.Trigger,{render:t.jsxs("button",{className:P(ce.trigger,{[ce.full]:r}),"aria-expanded":i,role:"listbox",ref:_,children:[t.jsxs("div",{className:ce.triggerContent,children:[typeof q.logoUrl=="string"?t.jsx(H,{src:q.logoUrl,width:14,height:14,logo:!0}):q.logoUrl(14),t.jsx("span",{className:ce.triggerText,children:q.name})]}),t.jsx(A.IconChevronDown,{size:16,className:ce.icon})]})}),t.jsxs(ht.Popover.Portal,{container:it(),children:[t.jsx(ht.Popover.Backdrop,{className:ce.popoverBackdrop,onClick:()=>l(!1)}),t.jsx(ht.Popover.Positioner,{className:ce.popoverPositioner,align:"end",side:"bottom",sideOffset:j,children:t.jsxs(ht.Popover.Popup,{className:P(ce.popoverPopup,{[ce.full]:r}),style:{maxHeight:u},children:[t.jsx(Ss,{value:o,onChange:x=>{a(x.target.value),d(0)},onClear:()=>a(""),onKeyDown:b,placeholder:"Search rollups",rootClassName:ce.search,ref:Wt()}),t.jsx("div",{className:ce.viewport,role:"listbox",children:N.length===0?t.jsx(Y,{children:"No rollups found"}):N.map(({chainId:x,name:D,logoUrl:E},B)=>t.jsxs("div",{className:P(ce.item,{[ce.highlighted]:B===c}),onClick:()=>I(x),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),I(x))},onMouseEnter:()=>d(B),role:"option","aria-selected":e===x,tabIndex:-1,ref:S=>{S&&(h.current[B]=S)},children:[t.jsxs("div",{className:ce.itemContent,children:[typeof E=="string"?t.jsx(H,{src:E,width:16,height:16,logo:!0}):E(16),t.jsx("span",{children:D})]}),e===x&&t.jsx(A.IconCheck,{size:16})]},x))})]})})]})]})},Hl="2.0.0-rc.7",Wl="_version_1sf5y_1",Ql={version:Wl},Vl=()=>t.jsxs("aside",{className:Ql.version,children:["v",Hl]}),Gl=Q.atom(""),Yl=Q.atom(""),Jl=Q.atom(""),Zl=Q.atom(""),Xl=Q.atom(""),ed="_popup_nbecp_1",td="_item_nbecp_19",Xt={popup:ed,item:td},io=({asset:e,children:s})=>{const{denom:n,decimals:r,symbol:o,logoUrl:a,unlisted:i,address:l,chain:c}=e,{chainId:d}=c,[u,m]=f.useState(!1),h=le(),_=ao(),{showNotification:p}=wn(),{defaultChainId:g}=de(),{evm_chain_id:C}=Kt(),$=_e.useChainId(),{switchChainAsync:N}=_e.useSwitchChain(),{watchAssetAsync:q}=_e.useWatchAsset(),v=()=>{m(!1),h("/send",{denom:n,chain:c})},j=()=>{m(!1),h("/bridge",{srcChainId:d,srcDenom:n,quantity:""})},k=T.useMutation({mutationFn:async()=>{if(!l)throw new Error("Address is required");const b=a;return await N({chainId:Number(C)}),q({type:"ERC20",options:{address:l,symbol:o,decimals:r,image:b}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:b=>{p({type:"error",title:"Asset addition failed",description:b.message})}});return t.jsxs(Oe.Menu.Root,{open:u,onOpenChange:m,modal:!1,children:[t.jsx(Oe.Menu.Trigger,{render:s}),t.jsx(Oe.Menu.Portal,{container:_.current,children:t.jsx(Oe.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(Oe.Menu.Popup,{className:Xt.popup,children:[t.jsxs(Oe.Menu.Item,{className:Xt.item,onClick:v,children:[t.jsx(A.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(Oe.Menu.Item,{className:Xt.item,onClick:j,disabled:i,children:[t.jsx(A.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===g&&C===$&&!!l&&t.jsxs(Oe.Menu.Item,{className:Xt.item,onClick:()=>k.mutate(),disabled:k.isPending||k.data,children:[k.data?t.jsx(A.IconCheck,{size:16}):t.jsx(A.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},sd="_images_cj4xz_1",Qs={images:sd},ks=({assetLogoUrl:e,assetLogoSize:s=36,chainLogoUrl:n,chainLogoSize:r=18,chainLogoOffset:o=6,className:a})=>t.jsxs("div",{className:P(Qs.images,a),style:{position:"relative"},children:[t.jsx(H,{src:e,width:s,height:s,className:Qs.asset,logo:!0}),t.jsx(H,{src:n,width:r,height:r,className:Qs.chain,style:{position:"absolute",bottom:0,right:-1*o},logo:!0})]}),nd="_item_knoro_1",rd="_info_knoro_22",od="_images_knoro_28",ad="_name_knoro_32",id="_value_knoro_38",cd="_amount_knoro_46",ld="_usd_knoro_52",tt={item:nd,info:rd,images:od,name:ad,value:id,amount:cd,usd:ld},dd=({asset:e})=>{const{amount:s,value:n,logoUrl:r,chain:o}=e,a=w.formatAmount(s,{decimals:e.decimals});return t.jsx(io,{asset:e,children:t.jsxs("button",{className:tt.item,children:[t.jsxs("div",{className:tt.info,children:[t.jsx(ks,{assetLogoUrl:r,chainLogoUrl:o.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:tt.images}),t.jsx("span",{className:tt.name,children:o.name})]}),t.jsxs("div",{className:tt.value,children:[t.jsx("span",{className:tt.amount,children:a}),Number(n)>0&&t.jsx("span",{className:tt.usd,children:We(n)})]})]})})},ud="_container_g5q73_1",md="_assetItem_g5q73_6",hd="_assetInfo_g5q73_26",fd="_logo_g5q73_32",_d="_symbol_g5q73_36",pd="_chainName_g5q73_46",gd="_chainInfos_g5q73_52",xd="_chainLogos_g5q73_58",yd="_chainLogo_g5q73_58",jd="_moreChains_g5q73_69",vd="_expandIcon_g5q73_81",wd="_expanded_g5q73_85",bd="_valueColumn_g5q73_90",Cd="_amount_g5q73_99",Id="_value_g5q73_90",Nd="_collapsibleContent_g5q73_112",Sd="_chainsList_g5q73_142",G={container:ud,assetItem:md,assetInfo:hd,logo:fd,symbol:_d,chainName:pd,chainInfos:gd,chainLogos:xd,chainLogo:yd,moreChains:jd,expandIcon:vd,expanded:wd,valueColumn:bd,amount:Cd,value:Id,collapsibleContent:Nd,chainsList:Sd},kd=Q.atom([]),co=({assetGroup:e})=>{const{symbol:s,logoUrl:n,assets:r}=e,o=r.length===1,[a,i]=Q.useAtom(kd),l=f.useMemo(()=>va(e),[e]),c=f.useMemo(()=>xn(e),[e]),d=a.includes(s),u=()=>{i(h=>d?y.without([s],h):y.uniq([...h,s]))},m=()=>t.jsxs("button",{className:G.assetItem,children:[t.jsxs("div",{className:G.assetInfo,children:[n&&t.jsx(H,{src:n,width:32,height:32,className:G.logo,logo:!0}),t.jsxs("div",{className:G.details,children:[t.jsx("div",{className:G.symbol,children:s}),o?t.jsx("div",{className:G.chainName,children:r[0].chain.name}):t.jsxs("div",{className:G.chainInfos,children:[t.jsx("div",{className:G.chainLogos,children:r.slice(0,5).map(({chain:h})=>t.jsx(H,{src:h.logoUrl,width:16,height:16,className:G.chainLogo,logo:!0},h.chainId))}),r.length>5&&t.jsxs("span",{className:G.moreChains,children:["+",r.length-5]}),t.jsx(A.IconChevronDown,{size:16,className:P(G.expandIcon,{[G.expanded]:d})})]})]})]}),t.jsxs("div",{className:G.valueColumn,children:[t.jsx("div",{className:G.amount,children:w.formatNumber(l,{dp:r[0].unlisted?0:6})}),c>0&&t.jsx("div",{className:G.value,children:We(c)})]})]});if(o){const[h]=r;return t.jsx("div",{className:G.container,children:t.jsx(io,{asset:h,children:m()})})}return t.jsx("div",{className:G.container,children:t.jsxs(U.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(U.Collapsible.Trigger,{asChild:!0,children:m()}),t.jsx(U.Collapsible.Content,{className:G.collapsibleContent,children:t.jsx("div",{className:G.chainsList,children:r.map(h=>t.jsx(dd,{asset:h},h.chain.chainId))})})]})})},Ad="_collapsible_1spkj_1",$d="_trigger_1spkj_5",Td="_divider_1spkj_20",Ed="_label_1spkj_26",qd="_chevron_1spkj_31",Dd="_content_1spkj_39",Pd="_list_1spkj_43",Le={collapsible:Ad,trigger:$d,divider:Td,label:Ed,chevron:qd,content:Dd,list:Pd},Bd=({unlistedAssets:e})=>{const[s,n]=f.useState(!0),r=ao(),o=f.useRef(null),[a,i]=f.useState(0);f.useEffect(()=>{if(o.current){const d=o.current.scrollHeight;i(d)}},[e]);const l=d=>{if(d&&!s&&r?.current){const u=r.current;u.scrollTo({top:u.scrollHeight,behavior:"auto"}),window.setTimeout(()=>{u.scrollTo({top:u.scrollHeight,behavior:"smooth"})},150)}n(d)},c=re.useSpring({height:s?a:0,opacity:s?1:0,config:{tension:500,friction:30,clamp:!0}});return e.length===0?null:t.jsxs(U.Collapsible.Root,{open:s,onOpenChange:l,className:Le.collapsible,children:[t.jsxs(U.Collapsible.Trigger,{className:Le.trigger,children:[t.jsx("div",{className:Le.divider}),t.jsxs("span",{className:Le.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(A.IconChevronDown,{className:Le.chevron,size:12,"data-state":s?"open":"closed"}),t.jsx("div",{className:Le.divider})]}),t.jsx(U.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(re.animated.div,{className:Le.content,style:c,children:t.jsx("div",{className:Le.list,ref:o,children:e.map(d=>t.jsx(co,{assetGroup:{...d,assets:[d]}},d.denom))})})})]})},Rd="_list_szwvw_1",Md={list:Rd},Fd=()=>{const[e,s]=Q.useAtom(Gl),[n,r]=Q.useAtom(Yl),{assetGroups:o,unlistedAssets:a,chainsByValue:i,isLoading:l}=yn(),c=i.filter(({value:m})=>m).map(({chainId:m})=>m),d=f.useMemo(()=>{const m=e?o.filter(_=>{const{symbol:p,assets:g}=_;return p.toLowerCase().includes(e.toLowerCase())||g.some(({denom:C,address:$})=>C.toLowerCase().includes(e.toLowerCase())||$?.toLowerCase().includes(e.toLowerCase()))}):o;return n?m.map(_=>({..._,assets:_.assets.filter(({chain:p})=>p.chainId===n)})).filter(_=>_.assets.length>0):m},[o,e,n]),u=f.useMemo(()=>{const m=e?a.filter(({denom:_,address:p})=>_.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):a;return n?m.filter(({chain:_})=>_.chainId===n):m},[a,e,n]);return l&&o.length===0?t.jsx(Y,{children:"Loading assets..."}):!d.length&&!u.length&&!e&&!n&&!l?t.jsx(Y,{children:"No assets"}):t.jsxs(t.Fragment,{children:[t.jsxs(He.Root,{children:[t.jsxs(He.Controls,{children:[t.jsx(He.SearchInput,{value:e,onChange:m=>s(m.target.value),onClear:()=>s(""),placeholder:"Search assets"}),t.jsx(In,{value:n,onChange:r,chainIds:c})]}),t.jsx("div",{children:d.length===0&&u.length===0?t.jsx(Y,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Md.list,children:d.map(m=>t.jsx(co,{assetGroup:m},m.symbol))}),t.jsx(Bd,{unlistedAssets:u})]})})]}),t.jsx(Vl,{})]})},lo=Te.createQueryKeys("interwovenkit:nft",{nfts:(e,s)=>[e,s],metadata:e=>[e]});function Od(e,s){const{nft:n}=e,r=s.name??n.token_id;return{...e,...n,...s,name:r}}function Ud(e,s){return e.flatMap((n,r)=>(s[r]??[]).map(a=>({...a,chain:n})))}const Ld=()=>{const e=ne(),s=se(),n=T.useQueries({queries:s.map(i=>({queryKey:lo.nfts(i.indexerUrl,e).queryKey,queryFn:()=>Dr(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:i.indexerUrl},"tokens"),staleTime:K.SECOND}))}),r=n.map(y.prop("data")),o=Ud(s,r),a=n.some(i=>i.isLoading);return{nftInfos:o,isLoading:a}};function zd(e){const s=Hn(e);return T.useQuery({queryKey:lo.metadata(s).queryKey,queryFn:async()=>{try{if(!s)return{};const n=await J.get(s).json();return{...n,image:Hn(n.image)}}catch{return{}}},staleTime:K.INFINITY})}function Hn(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const Kd="_thumbnail_1lblb_1",Hd="_placeholder_1lblb_16",Wd="_clickable_1lblb_22",qt={thumbnail:Kd,placeholder:Hd,clickable:Wd},Nn=({nftInfo:e,size:s,onClick:n})=>{const{collection_addr:r,object_addr:o,nft:a,chain:i}=e,l=new URL(`/v1/${i.chainId}/${r}/${o||a.token_id}`,"https://glyph.initia.xyz").toString();return n?t.jsx("button",{className:P(qt.thumbnail,qt.clickable),onClick:n,style:{width:s,height:s},children:t.jsx(H,{src:l,classNames:{placeholder:qt.placeholder}})}):t.jsx("div",{className:qt.thumbnail,style:{width:s,height:s},children:t.jsx(H,{src:l,classNames:{placeholder:qt.placeholder}})})},Qd="_nftItem_eopro_1",Vd="_collectionName_eopro_9",Gd="_nftName_eopro_19",Yd="_chainInfo_eopro_29",es={nftItem:Qd,collectionName:Vd,nftName:Gd,chainInfo:Yd},Jd=({normalizedNft:e})=>{const{collection_name:s,name:n,chain:r}=e,o=le();return t.jsxs("div",{className:es.nftItem,children:[t.jsx(Nn,{nftInfo:e,onClick:()=>o("/nft",e)}),t.jsxs("div",{children:[t.jsx("div",{className:es.collectionName,children:s}),t.jsx("div",{className:es.nftName,children:n}),t.jsxs("div",{className:es.chainInfo,children:[t.jsx(H,{src:r.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:r.name})]})]})]})},Zd=({nftInfo:e,children:s})=>{const{data:n={}}=zd(e.nft.uri),r=Od(e,n);return s(r)},Xd="_grid_a1fhu_1",eu={grid:Xd},tu=()=>{const[e,s]=Q.useAtom(Jl),[n,r]=Q.useAtom(Zl),{nftInfos:o,isLoading:a}=Ld(),i=f.useMemo(()=>o.filter(({collection_addr:c,collection_name:d,nft:u,object_addr:m,chain:h})=>{if(n&&h.chainId!==n)return!1;if(e){const _=e.trim().toLowerCase();return c.toLowerCase().includes(_)||d.toLowerCase().includes(_)||u.token_id.toLowerCase().includes(_)||m.toLowerCase().includes(_)}return!0}),[o,n,e]),l=f.useMemo(()=>Array.from(new Set(o.map(({chain:c})=>c.chainId))),[o]);return a&&o.length===0?t.jsx(Y,{children:"Loading NFTs..."}):!o.length&&!e&&!a?t.jsx(Y,{children:"No NFTs"}):t.jsxs(He.Root,{children:[t.jsxs(He.Controls,{children:[t.jsx(He.SearchInput,{value:e,onChange:c=>s(c.target.value),onClear:()=>s(""),placeholder:"Search nfts"}),t.jsx(In,{value:n,onChange:r,chainIds:l})]}),i.length===0?t.jsx(Y,{children:"No NFTs found"}):t.jsx("div",{className:eu.grid,children:i.map(c=>t.jsx(Zd,{nftInfo:c,children:d=>t.jsx(Jd,{normalizedNft:d})},c.object_addr))})]})},su="_message_1g2hc_1",nu="_more_1g2hc_8",Wn={message:su,more:nu},ru=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((s,n)=>t.jsx("p",{className:Wn.message,children:fs.sentenceCase(s["@type"].split("Msg")[1])},n)),e.length>3&&t.jsx("footer",{className:Wn.more,children:`+${e.length-3} more`})]}),ou="_change_1x9v4_1",au="_positive_1x9v4_10",iu="_negative_1x9v4_14",Vs={change:ou,positive:au,negative:iu},uo=({amount:e,asset:s})=>{const{denom:n,symbol:r,decimals:o}=s,a=new R(e).isPositive(),i=new R(e).abs().toString();return t.jsxs("div",{className:P(Vs.change,a?Vs.positive:Vs.negative),children:[a?"+":"-",w.formatAmount(i,{decimals:o})," ",r||n]})},cu=({changes:e,chain:s})=>{const n=Ve(s);return e.map(({amount:r,denom:o},a)=>t.jsx(uo,{amount:r,asset:n(o)},a))},lu=({changes:e,chain:s})=>{const n=Ve(s);return e.map(({amount:r,metadata:o},a)=>t.jsx(Xr,{metadata:o,chain:s,children:i=>t.jsx(uo,{amount:r,asset:n(i)})},a))},du=({events:e,chain:s})=>{const{initiaAddress:n,hexAddress:r}=ge();return s.metadata?.is_l1||s.metadata?.minitia?.type==="minimove"?t.jsx(lu,{changes:Zr(e,r),chain:s}):t.jsx(cu,{changes:Jr(e,n),chain:s})},uu="_link_13w9m_1",mu="_inner_13w9m_15",hu="_header_13w9m_20",fu="_chainInfo_13w9m_26",_u="_error_13w9m_36",pu="_content_13w9m_46",gu="_messages_13w9m_53",xu="_changes_13w9m_58",ze={link:uu,inner:mu,header:hu,chainInfo:fu,error:_u,content:pu,messages:gu,changes:xu},yu=({txItem:e,chain:s})=>t.jsx(Ns,{txHash:e.txhash,chainId:s.chainId,className:ze.link,children:t.jsxs("div",{className:ze.inner,children:[t.jsxs("div",{className:ze.header,children:[t.jsxs("div",{className:ze.chainInfo,children:[t.jsx(H,{src:s.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:s.name})]}),e.code!==0&&t.jsxs("div",{className:ze.error,children:[t.jsx(A.IconWarningFilled,{size:12}),t.jsx("span",{children:"Failed"})]})]}),t.jsxs("div",{className:ze.content,children:[t.jsx("div",{className:ze.messages,children:t.jsx(ru,{messages:e.tx.body.messages})}),t.jsx("div",{className:ze.changes,children:t.jsx(xe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(du,{...e,chain:s})})})]})]})}),ju="_list_1wa9p_1",vu="_dateGroup_1wa9p_7",wu="_dateHeader_1wa9p_12",bu="_more_1wa9p_18",ts={list:ju,dateGroup:vu,dateHeader:wu,more:bu},Cu=({list:e,chainId:s})=>{const n=ne(),r=f.useMemo(()=>e.reduce((o,a)=>{const l=new Date(a.timestamp).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),c=o[l]||[];return{...o,[l]:[...c,a]}},{}),[e]);return e.length===0?t.jsx(Y,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ts.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{className:ts.dateGroup,children:[t.jsx("div",{className:ts.dateHeader,children:o}),a.map(i=>t.jsx(yu,{txItem:i,chain:i.chain},i.txhash))]},o))}),t.jsx(Ns,{chainId:s,accountAddress:n,pathSuffix:"/txs",className:ts.more,showIcon:!0,children:"View more on Initia Scan"})]})},Iu=()=>{const{activities:e,isLoading:s}=ti(),[n,r]=Q.useAtom(Xl),o=pe(),a=f.useMemo(()=>Array.from(new Set(e.map(l=>l.chain.chainId))),[e]),i=f.useMemo(()=>n?e.filter(l=>l.chain.chainId===n):e,[e,n]);return s&&e.length===0?t.jsx(Y,{children:"Loading activities..."}):!e.length&&!s?t.jsx(Y,{children:"No activity yet"}):t.jsxs(He.Root,{children:[t.jsx(He.Controls,{children:t.jsx(In,{value:n,onChange:r,chainIds:a,fullWidth:!0})}),t.jsx(Cu,{list:i,chainId:n||o.chainId})]})},Nu="_totalValue_1udv1_1",Su="_totalLabel_1udv1_7",ku="_totalAmount_1udv1_13",Au="_loading_1udv1_18",$u="_nav_1udv1_23",Tu="_item_1udv1_28",Eu="_tabs_1udv1_51",qu="_tab_1udv1_51",we={totalValue:Nu,totalLabel:Su,totalAmount:ku,loading:Au,nav:$u,item:Tu,tabs:Eu,tab:qu},Du=()=>{ro();const e=le(),s=ps(),{totalValue:n,isLoading:r}=yn(),o=f.useRef(null);return t.jsx(oo.Provider,{value:o,children:t.jsxs(Me,{ref:o,children:[t.jsxs("div",{className:we.totalValue,children:[t.jsx("div",{className:we.totalLabel,children:"Total value"}),t.jsx("div",{className:P(we.totalAmount,{[we.loading]:r}),children:We(n)})]}),t.jsxs("div",{className:we.nav,children:[t.jsxs(gs,{to:"/send",className:we.item,children:[t.jsx(A.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs("button",{className:we.item,onClick:()=>e("/bridge"),children:[t.jsx(A.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]})]}),t.jsxs(Fe.Tabs.Root,{value:s,onValueChange:e,children:[t.jsxs(Fe.Tabs.List,{className:we.tabs,children:[t.jsx(Fe.Tabs.Tab,{className:we.tab,value:"/",children:"Assets"}),t.jsx(Fe.Tabs.Tab,{className:we.tab,value:"/nfts",children:"NFTs"}),t.jsx(Fe.Tabs.Tab,{className:we.tab,value:"/activity",children:"Activity"})]}),t.jsx(Fe.Tabs.Panel,{value:"/",children:t.jsx(Fd,{})}),t.jsx(Fe.Tabs.Panel,{value:"/nfts",children:t.jsx(tu,{})}),t.jsx(Fe.Tabs.Panel,{value:"/activity",children:t.jsx(Iu,{})})]})]})})},Pu="_header_acels_1",Bu="_back_acels_11",Ru="_title_acels_23",Gs={header:Pu,back:Bu,title:Ru},dt=({title:e,backButton:s,extra:n,children:r})=>t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Gs.header,children:[s??t.jsx(gs,{to:-1,className:Gs.back,children:t.jsx(A.IconBack,{size:16})}),t.jsx("h1",{className:Gs.title,children:e}),n]}),t.jsx(Me,{children:r})]}),Mu="_fieldset_y241y_1",Fu="_upper_y241y_9",Ou="_select_y241y_14",Uu="_account_y241y_19",Lu="_lower_y241y_24",zu="_wrapper_y241y_25",Ku="_balance_y241y_32",Hu="_value_y241y_36",Wu="_error_y241y_49",Ee={fieldset:Mu,upper:Fu,select:Ou,account:Uu,lower:Lu,wrapper:zu,balance:Ku,value:Hu,error:Wu},an=e=>{const{selectButton:s,accountButton:n,quantityInput:r,balanceButton:o,value:a,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:s}),t.jsx("div",{className:Ee.account,children:n})]}),t.jsxs("div",{className:Ee.lower,children:[r,t.jsxs("div",{className:Ee.wrapper,children:[t.jsx("div",{className:Ee.balance,children:o}),a&&t.jsx("div",{className:Ee.value,children:a})]}),i&&t.jsxs("footer",{className:Ee.error,children:[t.jsx(A.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})},yt=({title:e,content:s,children:n,className:r})=>{const[o,a]=f.useState(!1),i=()=>a(!1);return t.jsx(Wr,{title:e,trigger:n,className:r,open:o,onOpenChange:a,children:s(i)})},Qu="_root_1ipwv_1",Vu="_content_1ipwv_10",Gu="_details_1ipwv_18",Yu="_symbol_1ipwv_23",Ju="_chain_1ipwv_31",Zu="_chevron_1ipwv_40",st={root:Qu,content:Vu,details:Gu,symbol:Yu,chain:Ju,chevron:Zu},mo=({asset:e,chain:s,readOnly:n})=>{const r=t.jsxs("div",{className:st.content,children:[t.jsx(ks,{assetLogoUrl:e.logoUrl,chainLogoUrl:s.logoUrl}),t.jsxs("div",{className:st.details,children:[t.jsx("div",{className:st.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:st.chain,children:["on ",s.name]})]})]});return n?t.jsx("div",{className:st.root,children:r}):t.jsxs("div",{className:st.root,children:[r,t.jsx(A.IconChevronDown,{size:16,className:st.chevron})]})},Xu="_wrapper_5ssm8_1",em="_balance_5ssm8_11",tm="_button_5ssm8_15",Ys={wrapper:Xu,balance:em,button:tm},ho=({onClick:e,children:s,disabled:n})=>t.jsxs("div",{className:Ys.wrapper,children:[t.jsx(A.IconWallet,{size:16}),t.jsx("span",{className:Ys.balance,children:s}),t.jsx("button",{type:"button",className:Ys.button,onClick:()=>e(),disabled:n,children:"MAX"})]}),sm="_input_h8073_1",nm={input:sm};function rm(e,s){const n=e.replace(/[^0-9.]/g,""),[r,...o]=n.split(".");return o.length===0?r:`${r}.${o.join("").slice(0,s)}`}function fo(e){const{name:s,control:n,dp:r=6,className:o,rules:a,...i}=e,l=Wt();return t.jsx(oe.Controller,{name:s,control:n,rules:a,render:({field:c})=>t.jsx("input",{...c,className:P(nm.input,o),onChange:d=>c.onChange(rm(d.target.value,r)),placeholder:"0",inputMode:"decimal",autoComplete:"off",...i,ref:mr.mergeRefs([c.ref,l])})})}const om="_input_qpv94_1",am="_placeholder_qpv94_18",cn={input:om,placeholder:am},im=({children:e})=>t.jsx("p",{className:P(cn.input,{[cn.placeholder]:R(e).isZero()}),children:e}),us=({balance:e,decimals:s})=>{const{control:n}=oe.useFormContext(),r={required:"Enter amount",validate:o=>R(o).isZero()?"Enter amount":R(w.toBaseUnit(o,{decimals:s})).gt(e??0)?"Insufficient balance":!0};return t.jsx(fo,{name:"quantity",control:n,className:cn.input,rules:r})};us.ReadOnly=im;const cm="_label_9417z_1",lm="_wrapper_9417z_7",dm="_input_9417z_10",um="_clear_9417z_18",ss={label:cm,wrapper:lm,input:dm,clear:um},Sn=({mode:e="onChange",myAddress:s,...n})=>{const{validate:r=w.InitiaAddress.validate,chainType:o="initia",onApply:a,ref:i}=n,l=Wt(),{control:c,getValues:d,setValue:u,formState:m}=oe.useFormContext(),h=d("recipient"),[_,p]=f.useState(h),g=Mr(),{data:C,isLoading:$,error:N}=T.useQuery({queryKey:bs.address(g.restUrl,_).queryKey,queryFn:()=>g.getAddress(_),staleTime:K.MINUTE,enabled:g.validateUsername(_)}),q=C??(r(_)?_:""),v=s&&w.InitiaAddress.equals(q,s),j=async()=>{try{const I=await navigator.clipboard.readText();p(I.trim())}catch{}};f.useEffect(()=>{e==="onChange"&&(!_&&!m.dirtyFields.recipient||u("recipient",C??_,{shouldValidate:!0,shouldDirty:!0}))},[m.dirtyFields.recipient,_,e,u,C]);const k=()=>{$||N||(u("recipient",q,{shouldValidate:!0,shouldDirty:!0}),a?.())},b=()=>{if($)return t.jsx(Ke,{level:"loading",children:"Resolving username..."});if(N)return t.jsx(Ke,{level:"error",children:N.message});if(C)return t.jsx(Ke,{level:"success",className:"monospace",children:C});if(e==="onSubmit"&&_&&!q)return t.jsx(Ke,{level:"error",children:"Invalid address"});if(e==="onChange")return t.jsx(Ke,{level:"error",children:m.errors.recipient?.message})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:ss.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(V.Small,{type:"button",onClick:j,children:"Paste"})]}),t.jsxs("div",{className:ss.wrapper,children:[t.jsx(oe.Controller,{name:"recipient",control:c,rules:{required:"Recipient address is required",validate:I=>r(I)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:P(ss.input,"monospace"),value:_,onChange:I=>p(I.target.value.trim()),placeholder:o==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":_?"true":void 0,ref:e==="onSubmit"?mr.mergeRefs([i,l]):i})}),!!_&&t.jsx("button",{type:"button",className:ss.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:t.jsx(A.IconCloseCircleFilled,{size:16})})]}),b(),v&&t.jsx(Ke,{children:"This is my address"}),e==="onSubmit"&&t.jsx(ae,{extra:(!s||!!q&&!v)&&t.jsx(te,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:t.jsx(V.White,{type:"button",onClick:k,disabled:$||!!N||!q,children:"Apply"})})]})};function mm({balances:e,gasPrices:s,gas:n}){return s.map(({denom:r,amount:o})=>{const a=R(o).times(n).toFixed(0,R.ROUND_CEIL),i=e.find(l=>l.denom===r)?.amount??"0";return{amount:a,denom:r,balance:i}}).filter(({amount:r,balance:o})=>R(o).gte(r))}function hm({denom:e,balances:s,gasPrices:n,lastFeeDenom:r,gas:o}){const a=s.find(d=>d.denom===e)?.amount??"0",i=mm({balances:s,gasPrices:n,gas:o}),l=i.find(d=>d.denom===r);if(i.length===0)return a;if(e===r&&l){const d=R(a).minus(l.amount);return R.max(d,0).toString()}const c=i.find(d=>d.denom!==e)||i[0];if(!l&&e===c.denom){const d=R(a).minus(c.amount);return R.max(d,0).toString()}return R(a).toString()}const fm="_container_1a4ds_1",_m="_badge_1a4ds_5",Qn={container:fm,badge:_m},_o=e=>{const{offset:s=-4,disabled:n,children:r,className:o}=e;return t.jsxs("div",{className:P(Qn.container,o),children:[r,!n&&t.jsx("div",{className:Qn.badge,style:{right:s,top:s}})]})},pm="_stack_a3b9q_1",gm="_title_a3b9q_8",xm="_grid_a3b9q_15",ym="_item_a3b9q_21",jm="_button_a3b9q_25",vm="_active_a3b9q_43",_t={stack:pm,title:gm,grid:xm,item:ym,button:jm,active:vm},ot=({label:e,chains:s,value:n,onSelect:r,getShowIndicator:o})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:_t.title,children:e}),t.jsx("div",{className:_t.grid,children:s.map(({chainId:a,name:i,logoUrl:l})=>t.jsx(_o,{offset:-2,disabled:!o?.(a),className:_t.item,children:t.jsx(bt,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:P(_t.button,{[_t.active]:a===n}),onClick:()=>r(a),children:t.jsx(H,{src:l,width:28,height:28,logo:!0})})})},a))})]}),wm=({children:e})=>t.jsx("div",{className:_t.stack,children:e});ot.Stack=wm;function bm(e,s,n){return n.filter(r=>{const o=e.map(a=>r[a]).map(a=>String(a??"").toLowerCase());return y.any(y.includes(s.toLowerCase()),o)})}const Cm="_container_1voou_1",Im="_search_1voou_6",Nm="_list_1voou_10",Sm="_item_1voou_14",km="_logo_1voou_35",Am="_info_1voou_39",$m="_symbol_1voou_44",Tm="_name_1voou_52",Em="_balance_1voou_58",qm="_value_1voou_65",fe={container:Cm,search:Im,list:Nm,item:Sm,logo:km,info:Am,symbol:$m,name:Tm,balance:Em,value:qm},Qt=e=>{const{assets:s,onSelect:n,renderAsset:r=(l,c)=>c(l)}=e,[o,a]=f.useState(""),i=bm(["symbol"],o,s);return t.jsxs("div",{className:fe.container,children:[t.jsx(Ss,{value:o,onChange:l=>a(l.target.value),onClear:()=>a(""),placeholder:"Search by symbol",rootClassName:fe.search,padding:20,ref:Wt()}),i.length===0?t.jsx(Y,{children:"No assets"}):t.jsx("div",{className:fe.list,children:i.map(l=>t.jsx("button",{type:"button",className:fe.item,onClick:()=>n(l.denom),children:r(l,c=>{const{denom:d,logoUrl:u,symbol:m,name:h,balance:_,decimals:p,value:g=0}=c;return t.jsxs(t.Fragment,{children:[t.jsx(H,{src:u,width:32,height:32,className:fe.logo,logo:!0}),t.jsxs("div",{className:fe.info,children:[t.jsx("div",{className:fe.symbol,children:m||d}),t.jsx("div",{className:fe.name,children:h})]}),t.jsxs("div",{className:fe.balance,children:[_&&t.jsx("div",{children:w.formatAmount(_,{decimals:p})}),g>0&&t.jsx("div",{className:fe.value,children:We(g)})]})]})})},l.denom))})]})},Dm=()=>t.jsxs("div",{className:fe.container,children:[t.jsx(Ss,{rootClassName:fe.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(Y,{children:"Loading..."})]});Qt.Placeholder=Dm;const Pm=({chain:e,onSelect:s})=>{const n=xa(e);return t.jsx(Qt,{assets:n,onSelect:s})},Bm=({afterSelect:e})=>{const{watch:s,setValue:n}=oe.useFormContext(),{chainId:r,denom:o}=s(),{chainId:a}=s(),[i,l]=f.useState(a),c=Be(i),d=se(),u=m=>{if(r===i&&o===m){e();return}n("chainId",i),n("denom",m),n("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(ot.Stack,{children:t.jsx(ot,{chains:d,value:i,onSelect:l})}),t.jsx(xe,{suspenseFallback:t.jsx(Qt.Placeholder,{}),children:t.jsx(Pm,{chain:c,onSelect:u})},i)]})},Rm="_fields_brpej_1",Mm="_divider_brpej_11",Vn={fields:Rm,divider:Mm},Fm=Te.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Om=()=>{const{address:e,initiaAddress:s,estimateGas:n,requestTxSync:r}=ge(),{register:o,watch:a,setValue:i,handleSubmit:l,formState:c}=oe.useFormContext(),{chainId:d,denom:u,recipient:m,quantity:h,memo:_}=a(),p=Be(d),g=gn(p),C=Vr(p),$=Gr(p),N=Br(u,p),{data:q}=xs(p),{decimals:v}=N,j=g.find(S=>S.denom===u)?.amount??"0",k=q?.find(({id:S})=>S===u)?.price,{data:b=0,isLoading:I}=T.useQuery({queryKey:Fm.gas({chainId:d,denom:u,recipient:m,initiaAddress:s}).queryKey,queryFn:()=>{const S=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Pn.MsgSend.fromPartial({fromAddress:s,toAddress:w.InitiaAddress(m).bech32,amount:[{denom:u,amount:"1"}]})}];return n({messages:S,chainId:d})},enabled:w.InitiaAddress.validate(m),staleTime:K.INFINITY}),x=Math.ceil(b*Ft),D=hm({denom:u,balances:g,gasPrices:C,lastFeeDenom:$,gas:x}),{mutate:E,isPending:B}=T.useMutation({mutationFn:({chainId:S,denom:O,quantity:L,recipient:ie,memo:X})=>{const ye=w.toBaseUnit(L,{decimals:v}),ue=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Pn.MsgSend.fromPartial({fromAddress:s,toAddress:w.InitiaAddress(ie).bech32,amount:[{denom:O,amount:ye}]})}];return r({messages:ue,memo:X,chainId:S,gas:b,gasAdjustment:Ft,gasPrices:C,spendCoins:[{denom:O,amount:ye}],internal:"/"})}});return t.jsx(dt,{title:"Send",children:t.jsxs("form",{onSubmit:l(S=>E(S)),children:[t.jsxs("div",{className:Vn.fields,children:[t.jsx(an,{selectButton:t.jsx(yt,{title:"Select chain and asset",content:S=>t.jsx(Bm,{afterSelect:S}),children:t.jsx(mo,{asset:N,chain:p})}),quantityInput:t.jsx(us,{balance:j,decimals:v}),balanceButton:t.jsx(ho,{onClick:()=>i("quantity",w.fromBaseUnit(D,{decimals:v}),{shouldValidate:!0}),disabled:C.some(({denom:S})=>S===u)&&I,children:w.formatAmount(j??"0",{decimals:v})}),value:h?k?We(R(h).times(k)):"$-":"$0",errorMessage:c.errors.quantity?.message}),t.jsx("div",{className:Vn.divider}),t.jsx(Sn,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...o("memo",{validate:S=>!S||new Blob([S]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"}),t.jsx(Ke,{level:"error",children:c.errors.memo?.message})]}),t.jsx(te.Stack,{children:!_&&t.jsx(te,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(ae,{children:t.jsx(V.White,{type:"submit",loading:I||B,disabled:!c.isValid,children:"Confirm"})})]})})},Um=()=>{const e=ct(),s=Kt(),n=Ot(s),[r]=n,{chain:o=s,denom:a=r.denom}=e,i=oe.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:a,quantity:"",recipient:"",memo:""}});return t.jsx(oe.FormProvider,{...i,children:t.jsx(Om,{})})},Lm="_header_wr3q2_1",zm="_collectionName_wr3q2_6",Km="_name_wr3q2_13",Hm="_chainInfo_wr3q2_19",Wm="_attributes_wr3q2_29",Qm="_title_wr3q2_32",Vm="_count_wr3q2_37",Gm="_item_wr3q2_41",Ym="_type_wr3q2_47",Jm="_value_wr3q2_53",Ne={header:Lm,collectionName:zm,name:Km,chainInfo:Hm,attributes:Wm,title:Qm,count:Vm,item:Gm,type:Ym,value:Jm},Zm=()=>{const e=le(),s=ct(),{collection_name:n,image:r,name:o,attributes:a,chain:i}=s;return t.jsxs(dt,{title:"NFT details",children:[t.jsxs("header",{className:Ne.header,children:[r&&t.jsx(Nn,{nftInfo:s}),t.jsxs("div",{children:[t.jsx("div",{className:Ne.collectionName,children:n}),t.jsx("h2",{className:Ne.name,children:o}),t.jsxs("div",{className:Ne.chainInfo,children:[t.jsx(H,{src:i.logoUrl,width:14,height:14,logo:!0}),t.jsx("span",{children:i.name})]})]})]}),t.jsx(ae,{children:t.jsx(V.White,{onClick:()=>e("/nft/send",s),sm:!0,children:"Send"})}),a&&t.jsxs("div",{className:Ne.attributes,children:[t.jsxs("header",{className:Ne.title,children:["Traits ",t.jsxs("span",{className:Ne.count,children:["(",a.length,")"]})]}),t.jsx("div",{children:a.map(({trait_type:l,value:c})=>t.jsxs("div",{className:Ne.item,children:[t.jsx("div",{className:Ne.type,children:l}),t.jsx("div",{className:Ne.value,children:c})]},l))})]})]})},Xm="_scrollable_1p1lw_1",eh="_list_1p1lw_5",th="_item_1p1lw_9",sh="_name_1p1lw_13",ns={scrollable:Xm,list:eh,item:th,name:sh};function po({onSelect:e,list:s,...n}){const{getImage:r,getName:o,getKey:a,getIsLoading:i,getDisabled:l}=n;return t.jsx(Me,{className:ns.scrollable,children:t.jsx("div",{className:ns.list,children:s.map(c=>t.jsxs("button",{className:ns.item,onClick:()=>e(c),disabled:i?.(c)||l?.(c),children:[t.jsx(H,{src:r(c),width:28,height:28}),t.jsx("span",{className:ns.name,children:o(c)}),i?.(c)&&t.jsx(Ge,{size:16})]},a(c)))})})}const nh="_header_5w36t_1",rh="_name_5w36t_8",oh="_collection_5w36t_15",ah="_nft_5w36t_20",ih="_fields_5w36t_24",ch="_chain_5w36t_29",ft={header:nh,name:rh,collection:oh,nft:ah,fields:ih,chain:ch},lh=Te.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),dh=()=>{const e=se(),s=ct(),{chain:n,collection_addr:r,collection_name:o,image:a,name:i}=s,{routerApiUrl:l}=de(),c=js(),d=pe(),{address:u,initiaAddress:m,requestTxSync:h}=ge(),{watch:_,setValue:p,handleSubmit:g,formState:C}=oe.useFormContext(),$=_(),{recipient:N,dstChainId:q}=$,v=Be(q),j=T.useQuery({queryKey:lh.simulation({collection_addr:r,nft:s,sender:m,recipient:N,srcChain:n,dstChain:v,layer1:d,routerApiUrl:l}).queryKey,queryFn:async()=>{const E={from_address:m,from_chain_id:n.chainId,to_address:w.InitiaAddress(N).bech32,to_chain_id:v.chainId,collection_address:r,token_ids:[s.token_id],object_addresses:[s.object_addr]},{msgs:B}=await J.create({prefixUrl:l}).post("nft",{json:E}).json();return B.map(S=>c.fromAmino(S))},enabled:w.InitiaAddress.validate(N)}),{data:k,isLoading:b,error:I}=j,{mutate:x,isPending:D}=T.useMutation({mutationFn:async()=>{if(!k)throw new Error("Route not found");await h({messages:k,chainId:n.chainId,internal:"/nfts"})}});return t.jsxs("form",{onSubmit:g(()=>x()),children:[t.jsxs("header",{className:ft.header,children:[a&&t.jsx(Nn,{nftInfo:s,size:80}),t.jsxs("div",{className:ft.name,children:[t.jsx("div",{className:ft.collection,children:o}),t.jsx("div",{className:ft.nft,children:i})]})]}),t.jsxs("div",{className:ft.fields,children:[t.jsx(U.VisuallyHidden.Root,{children:t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination rollup"}),t.jsxs(yt,{title:"Destination rollup",content:E=>t.jsx(po,{onSelect:({chainId:B})=>{p("dstChainId",B),E()},list:e,getImage:B=>B.logoUrl,getName:B=>B.name,getKey:B=>B.chainId}),className:P("input",ft.chain),children:[t.jsx(H,{src:v.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:v.name})]})]})}),t.jsx(Sn,{myAddress:u,ref:Wt()})]}),t.jsx(ae,{children:t.jsx(V.White,{loading:b||D,disabled:!C.isValid||!!I,children:I?"Route not found":"Confirm"})})]})},uh=()=>{const{chain:e}=ct(),s=oe.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(dt,{title:"Send NFT",children:t.jsx(oe.FormProvider,{...s,children:t.jsx(dh,{})})})};function mh(){return pe().network_type==="testnet"}function Ye(){return oe.useFormContext()}function hh(){const e=ct(),s=mh(),n={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},r={...n,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},o={...n,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},a=y.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(F.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(F.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(F.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(F.BRIDGE_DST_DENOM),quantity:localStorage.getItem(F.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(F.BRIDGE_SLIPPAGE_PERCENT)});return{...s?r:o,...a,...e}}function go(){const{initiaAddress:e,hexAddress:s}=ge(),n=lt(),r=Ht();return o=>{const a=n(o);switch(r(a)){case"initia":return e;case"evm":return s;default:return""}}}function xo(){const e=lt(),s=Ht();return(n,r)=>{const o=e(r);switch(s(o)){case"initia":return w.InitiaAddress.validate(n);case"evm":return at.isAddress(n);case"cosmos":try{return W.fromBech32(n).prefix===o.bech32_prefix}catch{return!1}default:return!1}}}function fh(){const e=lt(),s=Ht();return({initialAddress:n,initialChainId:r,chainId:o,fallbackAddress:a})=>{const i=e(r),l=s(i),c=e(o),d=s(c);if(l==="evm"&&d==="initia")return w.InitiaAddress(n).bech32;if(l==="initia"&&d==="evm")return w.InitiaAddress(n).hex;if(l===d)return n;if(a){if(d==="initia")return w.InitiaAddress(a).bech32;if(d==="evm")return w.InitiaAddress(a).hex}return""}}const _h=[["d",1440*60],["h",3600],["m",60],["s",1]];function ln(e){if(!e)return;const{formattedParts:s}=_h.reduce(({remainingSeconds:n,formattedParts:r},[o,a])=>{const i=Math.floor(n/a);return{remainingSeconds:n-i*a,formattedParts:i>0?[...r,`${i}${o}`]:r}},{remainingSeconds:e,formattedParts:[]});return s.join(" ")}function yo(e){return e?.map(s=>{const{amount:n,origin_asset:r}=s;return`${w.formatAmount(n,{decimals:r.decimals??0})} ${r.symbol}`}).join(", ")}function Gn(e,s){const{watch:n}=Ye(),r=n(),o=Re(),a=vs(),i={...r,quantity:e},l=T.useQueryClient();return T.useQuery({queryKey:Ae.route(i,s?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:c,srcDenom:d,quantity:u,dstChainId:m,dstDenom:h}=i,{decimals:_}=l.getQueryData(Ae.asset(c,d).queryKey)??{decimals:0},p={amount_in:w.toBaseUnit(u,{decimals:_}),source_asset_chain_id:c,source_asset_denom:d,dest_asset_chain_id:m,dest_asset_denom:h,is_op_withdraw:s?.isOpWithdraw},g=await o.post("v2/fungible/route",{json:p}).json(),C={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return a("Bridge Simulation Success",C),g},enabled:!!Number(i.quantity)&&!s?.disabled,staleTime:K.MINUTE})}function ph(e){return T.useQuery({queryKey:Ae.routeErrorInfo(e||new Error).queryKey,queryFn:async()=>{if(!e||!(e instanceof J.HTTPError))return null;const{response:s}=e;return(s.headers.get("content-type")??"").includes("application/json")?(await s.json()).info??null:null}})}function gh(){const{watch:e}=Ye(),{srcChainId:s,srcDenom:n,dstChainId:r,dstDenom:o}=e(),a=$e(s),i=Ut(a),l=De(n,s),c=De(o,r),d=pe(),u=se();return i==="initia"&&r===d.chainId&&l.symbol===c.symbol&&u.find(m=>m.chainId===s)?.metadata?.op_denoms?.includes(c.denom)}function kn(e,s){const n=Re();return T.useQuery({queryKey:Ae.balances(s,e).queryKey,queryFn:()=>n.post("v2/info/balances",{json:{chains:{[s]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>e?r?r[s].denoms??{}:{}:{},enabled:!!e,staleTime:K.SECOND})}function xh(e,s,n){const{data:r={}}=kn(e,s);return y.path([n],r)}const yh=({address:e,chain:s,onSelect:n})=>{const r=xt(s.chain_id),{data:o={}}=kn(e,s.chain_id);return t.jsx(Qt,{assets:y.sortWith([y.descend(a=>a.symbol==="INIT"),y.descend(a=>a.value),({balance:a="0"},{balance:i="0"})=>R(i).comparedTo(a)??0,y.ascend(a=>a.symbol.toLowerCase())],r.filter(a=>!a.hidden).map(a=>{const{denom:i,symbol:l=w.truncate(i),logo_uri:c}=a,d=o[i]??{};return{...a,symbol:l,decimals:a.decimals??0,logoUrl:c??"",name:a.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:n})},jh=({type:e,afterSelect:s})=>{const n=e==="src"?"srcChainId":"dstChainId",r=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"sender":"recipient",a=wt(),i=jn(),{watch:l,setValue:c}=Ye(),d=l(o),u=l(n),m=l(r),[h,_]=f.useState(u),p=$e(h),g=fh(),C=Ur(),[$,N]=y.partition(v=>C(v.chain_id),i.filter(v=>!v.hidden)),q=v=>{if(u===h&&m===v){s();return}c(n,h),c(r,v),c("quantity","",{shouldTouch:!1,shouldDirty:!1}),s()};return t.jsxs(t.Fragment,{children:[t.jsxs(ot.Stack,{children:[t.jsx(ot,{label:"Interwoven Economy",chains:$.map(({chain_id:v,chain_name:j,pretty_name:k,logo_uri:b})=>({chainId:v,name:k||j,logoUrl:b??""})),value:h,onSelect:_}),t.jsx(ot,{label:"Chains",chains:N.map(({chain_id:v,chain_name:j,pretty_name:k,logo_uri:b})=>({chainId:v,name:k||j,logoUrl:b??""})),value:h,onSelect:_})]}),t.jsx(xe,{suspenseFallback:t.jsx(Qt.Placeholder,{}),children:t.jsx(yh,{address:g({initialAddress:d,initialChainId:u,chainId:h,fallbackAddress:e==="src"?a:void 0}),chain:p,onSelect:q})},h)]})},Yn=({type:e})=>{const s=e==="src"?"srcChainId":"dstChainId",n=e==="src"?"srcDenom":"dstDenom",r=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:o}=Ye(),a=o(s),i=o(n),l=$e(a),c=De(i,a);return t.jsx(yt,{title:r,content:d=>t.jsx(jh,{type:e,afterSelect:d}),children:t.jsx(mo,{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 As(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:n=>e.find(r=>r.name===n)}}const vh="_account_iwrlj_8",wh="_clear_iwrlj_27",bh="_white_iwrlj_38",Dt={account:vh,clear:wh,white:bh},Jn=({type:e})=>{const{watch:s,setValue:n}=Ye(),{srcChainId:r,dstChainId:o,cosmosWalletName:a}=s(),l=s(e==="src"?"sender":"recipient"),c=Ut($e(o)),{list:d,find:u}=As(),m=u(a),h=go(),_=xo(),p=h(o),g=w.InitiaAddress.equals(l,p),C=()=>t.jsx(yt,{title:"Connect wallet",content:q=>t.jsx(po,{onSelect:async v=>{const j=v.getProvider();if(!j)return window.open(v.fallbackUrl,"_blank");const k=j.getOfflineSigner(r),[{address:b}]=await k.getAccounts();n("sender",b),n("cosmosWalletName",v.name),q()},list:d,getImage:v=>v.image,getName:v=>v.name,getKey:v=>v.name}),className:P(Dt.account,{[Dt.white]:!l}),children:l?t.jsxs(t.Fragment,{children:[m&&t.jsx(H,{src:m.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:w.truncate(l)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(A.IconChevronRight,{size:14})]})}),$=q=>t.jsx(yt,{title:"Recipient",content:v=>t.jsx(Me,{children:t.jsx(Sn,{mode:"onSubmit",myAddress:p,chainType:c,validate:j=>_(j,o),onApply:v})}),className:Dt.account,children:q}),N=()=>{switch(c){case"initia":case"evm":return g?$(t.jsx(A.IconWallet,{size:14})):t.jsxs("div",{className:Dt.account,children:[t.jsx("span",{className:"monospace",children:w.truncate(l)}),t.jsx("button",{type:"button",className:Dt.clear,onClick:()=>n("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(A.IconCloseCircleFilled,{size:14})})]});case"cosmos":return $(t.jsxs(t.Fragment,{children:[l?t.jsx("span",{className:"monospace",children:w.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx(A.IconEdit,{size:14})]}))}};switch(e){case"src":return C();case"dst":return N()}},Ch="_description_l5bcv_1",Ih="_presets_l5bcv_8",Nh="_preset_l5bcv_8",Sh="_active_l5bcv_29",kh="_custom_l5bcv_40",Ah="_wrapper_l5bcv_46",$h="_percent_l5bcv_49",Se={description:Ch,presets:Ih,preset:Nh,active:Sh,custom:kh,wrapper:Ah,percent:$h},Zn=["0.1","0.5","1.0"],Th=({afterConfirm:e})=>{const s=Ye(),n=s.getValues("slippagePercent"),[r,o]=f.useState(null),{control:a,watch:i,getValues:l,setValue:c}=oe.useForm({defaultValues:{value:n}}),d=i("value");f.useEffect(()=>{const g=Zn.findIndex(C=>C===n);o(g>=0?g:null)},[n]);const u=(g,C)=>{c("value",g),o(C)},m=()=>{o(null)},h=f.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),_=h?.type==="error",p=({value:g})=>{s.setValue("slippagePercent",g),e()};return t.jsxs(Me,{children:[t.jsx("p",{className:Se.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:Se.presets,children:[Zn.map((g,C)=>t.jsxs("button",{type:"button",className:P(Se.preset,{[Se.active]:r===C}),onClick:()=>u(g,C),children:[g,"%"]},g)),r!==null?t.jsx("button",{type:"button",className:P(Se.preset,Se.custom),onClick:()=>o(null),children:"Custom"}):t.jsxs("div",{className:Se.wrapper,children:[t.jsx(fo,{name:"value",control:a,dp:2,onFocus:m,placeholder:"",className:P(Se.preset,Se.active)}),t.jsx("span",{className:Se.percent,children:"%"})]})]}),h&&t.jsx(te,{level:h.type,children:h.text}),t.jsx(ae,{children:t.jsx(V.White,{type:"button",onClick:()=>p(l()),disabled:_,children:"Confirm"})})]})},Eh="_stack_hvmmo_1",qh="_button_hvmmo_6",Dh="_checked_hvmmo_14",Ph="_checkmark_hvmmo_20",Bh="_inner_hvmmo_30",Rh="_info_hvmmo_42",Mh="_duration_hvmmo_51",Fh="_amount_hvmmo_61",Oh="_symbol_hvmmo_71",qe={stack:Eh,button:qh,checked:Dh,checkmark:Ph,inner:Bh,info:Rh,duration:Mh,amount:Fh,symbol:Oh},Uh=({children:e})=>t.jsx("div",{className:qe.stack,children:e}),as=({label:e,query:s,value:n,onSelect:r,checked:o})=>{const{data:a,isLoading:i}=s,{watch:l}=Ye(),{dstChainId:c,dstDenom:d}=l(),u=De(d,c);return t.jsxs("button",{type:"button",className:P(qe.button,{[qe.checked]:o}),onClick:()=>r(n),children:[t.jsx("div",{className:qe.checkmark,children:o&&t.jsx("span",{className:qe.inner})}),t.jsxs("div",{className:qe.info,children:[t.jsx("div",{children:e}),t.jsxs("div",{className:qe.duration,children:[t.jsx(A.IconClockFilled,{size:12}),a?ln(a.estimated_route_duration_seconds):"Not available"]})]}),t.jsx("div",{className:qe.amount,children:i?t.jsx(Ge,{size:14}):a?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:w.formatAmount(a.amount_out,{decimals:u.decimals})}),t.jsx("span",{className:qe.symbol,children:u.symbol})]}):null})]})};as.Stack=Uh;const Lh="_form_1coq4_1",zh="_arrow_1coq4_5",Kh="_divider_1coq4_13",Hh="_flip_1coq4_21",Wh="_meta_1coq4_37",Qh="_row_1coq4_50",Vh="_title_1coq4_56",Gh="_description_1coq4_60",Yh="_icon_1coq4_67",Jh="_edit_1coq4_72",Zh="_warning_1coq4_93",Z={form:Lh,arrow:zh,divider:Kh,flip:Hh,meta:Wh,row:Qh,title:Vh,description:Gh,icon:Yh,edit:Jh,warning:Zh},Xh=()=>{const e=le(),s=Is(),[n,r]=be.useLocalStorage(F.BRIDGE_ROUTE_TYPE,"default"),{watch:o,setValue:a,handleSubmit:i,formState:l}=Ye(),c=o(),{srcChainId:d,srcDenom:u,dstChainId:m,dstDenom:h,quantity:_,sender:p,slippagePercent:g}=c,C=Qe(),$=$e(d),N=Ut($),q=$e(m),v=Ut(q),j=De(u,d),k=De(h,m),{data:b}=kn(p,d),I=xh(p,d,u),[x]=be.useDebounceValue(_,300),D=N!=="initia"&&v!=="initia",E=gh(),B=Gn(x,{disabled:D}),S=Gn(x,{isOpWithdraw:!0,disabled:!E}),O=E&&n==="op"?S:B,{data:L,isLoading:ie,isFetching:X,isFetched:ye,error:ue}=O,{data:mt}=ph(ue),[Nt,Je]=f.useState(L);f.useEffect(()=>{L&&Je({...L,amount_out:"0",usd_amount_in:"0",usd_amount_out:"0"})},[L]),f.useEffect(()=>{Je(void 0)},[d,u,m,h]);const M=ye?L:x&&!ue?Nt:void 0,Ce=x&&(ie||X),je=()=>{a("srcChainId",m),a("srcDenom",h),a("dstChainId",d),a("dstDenom",u),a("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:St,closeModal:kt}=zt(),Es=i(z=>{if(M?.warning){const{type:At="",message:Ps}=M.warning??{};St({content:t.jsx(no,{type:"warning",icon:t.jsx(A.IconWarningFilled,{size:40}),title:fs.sentenceCase(At),primaryButton:{label:"Cancel",onClick:kt},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:M,values:z}),kt()}},children:t.jsx("p",{className:Z.warning,children:Ps})})});return}e("/bridge/preview",{route:M,values:z})}),$o=f.useMemo(()=>M?.estimated_fees?.filter(({fee_behavior:z})=>z==="FEE_BEHAVIOR_DEDUCTED")??[],[M]),qs=f.useMemo(()=>M?.estimated_fees?.filter(({fee_behavior:z})=>z==="FEE_BEHAVIOR_ADDITIONAL")??[],[M]),Ds=f.useMemo(()=>{for(const z of qs){const At=b?.[z.origin_asset.denom]?.amount??"0",Ps=M?.source_asset_denom===z.origin_asset.denom?M.amount_in:"0";if(R(At).lt(R(Ps).plus(z.amount??"0")))return`Insufficient ${z.origin_asset.symbol} for fees`}},[b,M,qs]),$n=f.useMemo(()=>{if(!c.sender)return"Connect wallet";if(!c.quantity||!x)return"Enter amount";if(!c.recipient)return"Enter recipient address";if(l.errors.quantity)return l.errors.quantity.message;if(!M)return"Route not found";if(Ds)return Ds},[x,Ds,l,M,c]),To=M?w.formatAmount(M.amount_out,{decimals:k.decimals}):"0",Eo=R(_).gt(0)&&R(_).isEqualTo(w.fromBaseUnit(I?.amount,{decimals:I?.decimals??0})),qo=(()=>{switch(N){case"initia":return C(d).fees.fee_tokens.some(({denom:z})=>z===u);case"cosmos":return $.fee_assets.some(({denom:z})=>z===u);case"evm":return!at.isAddress(u);default:return!1}})(),Tn=(z,At)=>z.length?t.jsxs("div",{className:Z.description,children:[yo(z),!s&&t.jsx(bt,{label:At,children:t.jsx("span",{className:Z.icon,children:t.jsx(A.IconInfoFilled,{size:12})})})]}):null;return t.jsxs("form",{className:Z.form,onSubmit:Es,children:[t.jsx(an,{selectButton:t.jsx(Yn,{type:"src"}),accountButton:N==="cosmos"&&t.jsx(Jn,{type:"src"}),quantityInput:t.jsx(us,{balance:I?.amount,decimals:j?.decimals}),balanceButton:t.jsx(ho,{onClick:()=>a("quantity",w.fromBaseUnit(I?.amount,{decimals:j?.decimals??0}),{shouldValidate:!0}),children:w.formatAmount(I?.amount??"0",{decimals:j.decimals})}),value:M?M.usd_amount_in?We(M.usd_amount_in):"$-":"$0"}),t.jsxs("div",{className:Z.arrow,children:[t.jsx("div",{className:Z.divider}),t.jsx("button",{type:"button",className:Z.flip,onClick:()=>je(),children:t.jsx(A.IconChevronDown,{size:16})})]}),t.jsx(an,{selectButton:t.jsx(Yn,{type:"dst"}),accountButton:t.jsx(Jn,{type:"dst"}),quantityInput:t.jsx(us.ReadOnly,{children:To}),value:M?M.usd_amount_out?We(M.usd_amount_out):"$-":"$0"}),t.jsx(ae,{extra:t.jsxs(t.Fragment,{children:[t.jsx(nn,{children:R(_).gt(0)&&E?t.jsxs(as.Stack,{children:[t.jsx(as,{label:"Minitswap",query:B,value:"default",onSelect:r,checked:n==="default"}),t.jsx(as,{label:"OP Bridge",query:S,value:"op",onSelect:r,checked:n==="op"})]}):null}),t.jsxs(te.Stack,{children:[M?.extra_infos?.map(z=>t.jsx(te,{level:"info",children:z},z)),mt&&t.jsx(te,{level:"info",children:mt}),Eo&&qo&&t.jsx(te,{level:"warning",children:"Make sure to leave enough for transaction fee"}),M?.warning&&t.jsx(te,{level:"warning",children:M.warning.message}),M?.extra_warnings?.map(z=>t.jsx(te,{level:"warning",children:z},z))]}),t.jsx(nn,{children:M&&t.jsxs("div",{className:Z.meta,children:[!!M.estimated_fees?.length&&t.jsxs("div",{className:Z.row,children:[t.jsx("span",{className:Z.title,children:"Fees"}),t.jsxs("div",{children:[Tn($o,"Fee deducted from the amount you receive"),Tn(qs,"Fee charged in addition to the amount you enter")]})]}),ln(M.estimated_route_duration_seconds)&&t.jsxs("div",{className:Z.row,children:[t.jsx("span",{className:Z.title,children:"Estimated time"}),t.jsx("span",{className:Z.description,children:ln(M.estimated_route_duration_seconds)})]}),M.does_swap&&t.jsxs("div",{className:Z.row,children:[t.jsx("span",{className:Z.title,children:"Slippage"}),t.jsxs("span",{className:Z.description,children:[t.jsxs("span",{children:[g,"%"]}),t.jsx(yt,{title:"Slippage tolerance",content:z=>t.jsx(Th,{afterConfirm:z}),className:Z.edit,children:t.jsx(A.IconSettingFilled,{size:12})})]})]})]})})]}),children:t.jsx(V.White,{loading:Ce&&"Simulating...",disabled:!!$n,children:$n??"Preview route"})})]})},ef="_backButton_oqpn7_1",tf={backButton:ef},sf=()=>{ro();const e=Qo(),s=le(),{closeDrawer:n}=vt(),r=wt(),o=hh(),a=oe.useForm({mode:"onChange",defaultValues:o}),{watch:i,setValue:l}=a,{srcChainId:c,dstChainId:d,srcDenom:u,dstDenom:m,quantity:h,slippagePercent:_,recipient:p}=i();i((D,{name:E})=>{(E==="srcChainId"||E==="srcDenom")&&l("quantity","")});const g=go(),C=g(c),$=g(d),q=xo()(p,d);f.useEffect(()=>{l("cosmosWalletName",void 0),l("sender",C)},[c,C,l]),f.useEffect(()=>{q||l("recipient",$)},[$,q,l]);const v=xt(c),j=xt(d),k=f.useMemo(()=>{if(!v.find(D=>D.denom===u))return`${u} is not available for bridge/swap on ${c}`;if(!j.find(D=>D.denom===m))return`${m} is not available for bridge/swap on ${d}`},[j,d,m,v,c,u]);f.useEffect(()=>{k||(localStorage.setItem(F.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(F.BRIDGE_SRC_DENOM,u),localStorage.setItem(F.BRIDGE_DST_CHAIN_ID,d),localStorage.setItem(F.BRIDGE_DST_DENOM,m),localStorage.setItem(F.BRIDGE_QUANTITY,h),localStorage.setItem(F.BRIDGE_SLIPPAGE_PERCENT,_))},[c,u,d,m,h,_,k]);const b=e[0].path==="/bridge",I=()=>t.jsxs(t.Fragment,{children:[t.jsx(Y,{error:!0,children:k}),t.jsx(ae,{children:b?t.jsx(V.White,{onClick:n,children:"Close"}):t.jsx(V.White,{onClick:()=>s(-1),children:"Go back"})})]}),{reminders:x}=Ct();return t.jsx(dt,{title:b?"":"Bridge/Swap",backButton:b?t.jsxs(gs,{to:"/",className:tf.backButton,shouldReset:!0,children:[t.jsx(A.IconBack,{size:12}),t.jsx("span",{children:"Wallet"})]}):void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(V.Small,{onClick:()=>s("/bridge/history"),unpadded:!0,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[t.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),t.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),t.jsx(_o,{offset:0,disabled:x.length===0,children:t.jsx(V.Small,{onClick:()=>s("/op/withdrawals"),disabled:!r,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:k?I():t.jsx(oe.FormProvider,{...a,children:t.jsx(xe,{children:t.jsx(Xh,{})})})})},nf="_button_1iys9_1",rf={button:nf},jo=({onClick:e,disabled:s})=>{const{ref:n,inView:r}=Uo.useInView();return f.useEffect(()=>{r&&e()},[r,e]),t.jsxs("button",{className:rf.button,onClick:e,disabled:s,ref:n,children:[t.jsx("span",{children:"Load more"}),t.jsx(A.IconChevronDown,{size:12})]})},ut=Te.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,s)=>[e,s],latestOutput:e=>[e],output:(e,s)=>[e,s],outputResponse:(e,s)=>[e,s],withdrawalClaimed:(e,s)=>[e,s]});function $s(){const{restUrl:e}=pe();return f.useMemo(()=>J.create({prefixUrl:e}),[e])}function of(e){const s=$s(),{data:n}=T.useSuspenseQuery({queryKey:ut.bridge(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:K.INFINITY});return n}const Xn=20;function af(e){const s=ne();return T.useSuspenseInfiniteQuery({queryKey:ut.withdrawals(e,s).queryKey,queryFn:async({pageParam:n})=>{if(!s)return[];const r={limit:Xn,offset:n,order:"desc"},{withdrawals:o}=await J.create({prefixUrl:e}).get(`withdrawals/${s}`,{searchParams:r}).json();return o},getNextPageParam:n=>{const r=y.last(n)?.sequence;return n.length<Xn||!r||r<=1?null:r-1},initialPageParam:0,staleTime:K.SECOND})}function cf(e){const s=$s(),{data:n}=T.useSuspenseQuery({queryKey:ut.latestOutput(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:r})=>{const[o]=r;return o||null},staleTime:K.SECOND});return n}function lf({bridge_id:e,output_index:s}){const n=$s(),{data:r}=T.useSuspenseQuery({queryKey:ut.output(e,s).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${e}/outputs/${s}`).json()}catch{return null}},staleTime:K.SECOND});return r}function df({bridge_id:e,sequence:s}){const r=se().find(({metadata:c})=>c?.op_bridge_id===e.toString())?.chain_id;if(!r)throw new Error(`Chain not found for bridge_id: ${e}`);const a=Qe()(r);if(!a)throw new Error(`Chain not found: ${r}`);const i=a.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${r}`);const{data:l}=T.useSuspenseQuery({queryKey:ut.outputResponse(i,s).queryKey,queryFn:()=>J.create({prefixUrl:i}).get(`withdrawal/${s}`).json(),staleTime:K.SECOND});return l}function vo(e,s){const{bridge_id:n}=e,r=$s(),{data:o}=T.useSuspenseQuery({queryKey:ut.withdrawalClaimed(n,s).queryKey,queryFn:()=>r.get(`opinit/ophost/v1/bridges/${n}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:s}}).json(),select:({claimed:a})=>a,staleTime:({state:{data:a}})=>a?.claimed?1/0:K.SECOND});return o}function Pt(e){return Lo.sha3_256.create().update(e).digest()}function Js(e,s){const n=new ArrayBuffer(s);return new DataView(n).setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}function wo(e){const{bridge_id:s,sequence:n,amount:r,from:o,to:a}=e,i=Js(s.toString(),8),l=Js(n.toString(),8),c=Js(r.amount,8),d=Vt.concatBytes(i,l,Pt(Vt.utf8ToBytes(o)),Pt(Vt.utf8ToBytes(a)),Pt(Vt.utf8ToBytes(r.denom)),c);return Pt(Pt(d))}const bo=f.createContext(null);function Ts(){return f.useContext(bo)}const uf="_asset_6h8u2_1",mf="_info_6h8u2_7",hf="_symbol_6h8u2_11",Zs={asset:uf,info:mf,symbol:hf},ff=({amount:e,denom:s})=>{const n=pe(),r=Br(s,n),{symbol:o,logoUrl:a,decimals:i}=r;return t.jsxs("div",{className:Zs.asset,children:[t.jsx(H,{src:a,width:32,height:32,logo:!0}),t.jsxs("div",{className:Zs.info,children:[t.jsx("span",{className:"monospace",children:w.formatAmount(e,{decimals:i})}),t.jsx("span",{className:Zs.symbol,children:o})]})]})},_f=({children:e})=>{const{withdrawalTx:s}=Ts(),n=cf(s.bridge_id),r=s.output_index>Number(n?.output_index);return e(r)},pf="_container_1oldz_1",gf="_icon_1oldz_7",er={container:pf,icon:gf},xf="Withdrawal will begin within an hour",tr=()=>{const e=Is();return t.jsxs("div",{className:er.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(bt,{label:xf,children:t.jsx("span",{className:er.icon,children:t.jsx(A.IconInfoFilled,{size:12})})})]})},Co=1e3,yf=60,jf=60,vf=24,dn=Co*yf,un=dn*jf,sr=un*vf,wf=({date:e})=>{const s=f.useCallback(()=>{const d=new Date().getTime(),m=e.getTime()-d;if(m<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(m/sr),_=Math.floor(m%sr/un),p=Math.floor(m%un/dn),g=Math.floor(m%dn/Co);return{days:h,hours:_,minutes:p,seconds:g}},[e]),[n,r]=f.useState(s());f.useEffect(()=>{const d=window.setInterval(()=>{r(s())},1e3);return()=>window.clearInterval(d)},[s,e]);const o=d=>d.toString().padStart(2,"0"),{days:a,hours:i,minutes:l,seconds:c}=n;return t.jsx(bt,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[a,"d ",o(i),"h ",o(l),"m ",o(c),"s"]})})},bf="_container_1lz3w_1",Cf="_title_1lz3w_5",nr={container:bf,title:Cf},If=({date:e})=>t.jsxs("div",{className:nr.container,children:[t.jsx("div",{className:nr.title,children:"Claimable in"}),t.jsx(wf,{date:e})]}),Nf=({children:e})=>{const{withdrawalTx:s}=Ts(),n=of(s.bridge_id),r=lf(s),o=f.useMemo(()=>{if(!r)return null;const{bridge_config:a}=n,{output_proposal:i}=r;return Lt.addSeconds(new Date(i.l1_block_time),parseFloat(a.finalization_period))},[n,r]);return e(o)},Sf=({date:e,children:s})=>{const{chainId:n,withdrawalTx:r}=Ts(),o=W.toBase64(wo(r)),a=vo(r,o),{setReminder:i,removeReminder:l}=Ct();return f.useEffect(()=>{const c={chainId:n,txHash:r.tx_hash};a?l(c):i(c,{...c,recipient:r.to,claimableAt:e.getTime(),amount:r.amount.amount,denom:r.amount.denom,dismissed:Lt.isPast(e.getTime())?!0:void 0})},[n,a,e,l,i,r]),s},kf="_button_1btdg_1",Af="_claimed_1btdg_23",rr={button:kf,claimed:Af},$f=()=>{const{withdrawalTx:e}=Ts(),{bridge_id:s,sequence:n,amount:r,output_index:o,withdrawal_proofs:a,storage_root:i,from:l,to:c,version:d}=e,u=pe(),m=ne(),{requestTxSync:h,waitForTxConfirmation:_}=ge(),p=df(e),g=W.toBase64(wo(e)),C=vo(e,g),$=T.useQueryClient(),{mutate:N,isPending:q}=T.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:v}=p;return h({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:m,bridgeId:BigInt(s),outputIndex:BigInt(o),withdrawalProofs:a.map(W.fromBase64),from:l,to:c,sequence:BigInt(n),amount:r,version:W.fromBase64(d),storageRoot:W.fromBase64(i),lastBlockHash:W.fromBase64(v)}}],internal:!0})},onSuccess:async v=>{await _({chainId:u.chain_id,txHash:v}),$.invalidateQueries({queryKey:ut.withdrawalClaimed(s,g).queryKey})}});return C?t.jsxs("div",{className:rr.claimed,children:[t.jsx(A.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:rr.button,onClick:()=>N(),disabled:q,children:"Claim"})},Tf=()=>t.jsx(_f,{children:e=>e?t.jsx(tr,{}):t.jsx(Nf,{children:s=>s?t.jsx(Sf,{date:s,children:Lt.isFuture(s)?t.jsx(If,{date:s}):t.jsx($f,{})}):t.jsx(tr,{})})}),Ef="_item_km5w2_1",qf={item:Ef},Df=({chain:e})=>{const s=e.metadata?.executor_uri;if(!s)throw new Error("Executor URL is not defined");const{data:n,fetchNextPage:r,hasNextPage:o,isFetching:a}=af(s),i=f.useMemo(()=>n?.pages.flat()??[],[n]),{syncReminders:l}=Ct();return f.useEffect(()=>{const c=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));l(c)},[e.chainId,i,l]),i.length?t.jsxs(t.Fragment,{children:[i.map(c=>{const{amount:d}=c;return t.jsxs("div",{className:qf.item,children:[t.jsx(ff,{...d}),t.jsx(xe,{suspenseFallback:null,children:t.jsx(bo.Provider,{value:{chainId:e.chainId,withdrawalTx:c},children:t.jsx(Tf,{})})})]},c.sequence)}),o&&t.jsx(jo,{onClick:()=>r(),disabled:a})]}):t.jsx(Y,{children:"No withdrawals"})},Pf="_content_dj1qm_1",Bf="_title_dj1qm_5",or={content:Pf,title:Bf},Rf=()=>{const{chainId:e}=ct(),s=se(),n=Kt(),[r,o]=f.useState(e??(n.metadata?.is_l1?"":n.chainId)),a=Qe(),{reminders:i}=Ct(),l=r?a(r):void 0;return t.jsxs(dt,{title:"OP Bridge withdrawals",children:[t.jsx(ot,{chains:s.filter(({metadata:c})=>!c?.is_l1&&c?.op_denoms?.length),value:r,onSelect:o,getShowIndicator:c=>i.some(d=>d.chainId===c)}),t.jsx("div",{className:or.content,children:l?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:or.title,children:l.name}),t.jsx(xe,{children:t.jsx(Df,{chain:l})},r)]}):t.jsx(te,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})};async function Mf(e,s){const n=J.create({prefixUrl:s}),r=`cosmos/auth/v1beta1/account_info/${e}`;for(let o=1;o<=24;o++)try{return await n.get(r).json()}catch{await new Promise(a=>setTimeout(a,5e3))}throw new Error(`Timeout: ${e} not found`)}const is=({chainId:e,txHash:s})=>`${F.BRIDGE_HISTORY}:${e}:${s}`,ms=100,ar=10;function Io(){const[e,s]=be.useLocalStorage(F.BRIDGE_HISTORY,[]),n=f.useCallback((o,a)=>{localStorage.setItem(is(o),JSON.stringify(a));for(const i of e.slice(ms-1))localStorage.removeItem(is(i));s((i=[])=>[o,...i.slice(0,ms-1)])},[e,s]),r=f.useCallback(o=>{const a=localStorage.getItem(is(o));return a?JSON.parse(a):null},[]);return{history:e,addHistoryItem:n,getHistoryDetails:r}}function No(e){return be.useLocalStorage(is(e),null)}async function So(e,s){const{chain_type:n,chain_id:r,chain_name:o,evm_fee_asset:a,rpc:i}=s;if(n!=="evm")throw new Error(`Chain is not an EVM chain: ${o}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}catch(l){if(y.path(["error","code"],l)!==4902)throw l;if(!a)throw new Error(`Fee asset is not defined for chain: ${o}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(r).toString(16)}`,chainName:o,nativeCurrency:a,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}}function It(){return ct()}function Ff(e){const s=le(),{showNotification:n,updateNotification:r,hideNotification:o}=wn(),{addHistoryItem:a}=Io(),i=vs(),{route:l,values:c}=It(),{srcChainId:d,sender:u,recipient:m,cosmosWalletName:h}=c,_=Sr(),{requestTxSync:p,waitForTxConfirmation:g}=ge(),{find:C}=As(),$=ys(),N=js(),q=$e(d),v=Ut(q),j=Lr(d),k=T.useQueryClient(),{registryUrl:b}=de(),I=Qe(),{addReminder:x}=Ct(),D=Re();return T.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const E=e.cosmos_tx.msgs.map(({msg_type_url:Ce,msg:je})=>{if(!(Ce&&je))throw new Error("Invalid transaction data");return N.fromAmino({type:Mt.aminoConverters[Ce].aminoType,value:JSON.parse(je)})});if(v==="initia"){const{srcDenom:Ce,quantity:je}=c,{decimals:St}=j(Ce),kt=await p({messages:E,chainId:d,internal:1,spendCoins:[{denom:Ce,amount:w.toBaseUnit(je,{decimals:St})}]}),Es=g({txHash:kt,chainId:d});return{txHash:kt,wait:Es}}const B=C(h)?.getProvider();if(!B)throw new Error("Wallet not connected");const S=B.getOfflineSignerOnlyAmino(d),O=await ke.SigningStargateClient.connectWithSigner(q.rpc,S,{registry:$,aminoTypes:N}),L=await O.getAllBalances(u),ie=q.fee_assets.find(Ce=>L.some(je=>je.denom===Ce.denom&&R(je.amount).gt(0)));if(!ie){const je=["Insufficient balance for fees.",`Available fee assets: ${q.fee_assets.map(St=>j(St.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(je)}const{denom:X,gas_price:ye}=ie;if(!ye)throw new Error(`Gas price not found for ${X}`);const ue=await O.simulate(u,E,""),mt=ke.GasPrice.fromString(ye.average+X),Nt=ke.calculateFee(Math.ceil(ue*Ft),mt),Je=await O.signAndBroadcastSync(u,E,Nt),M=qr({txHash:Je,client:O});return{txHash:Je,wait:M}}if("evm_tx"in e){const{chain_id:E,to:B,value:S,data:O}=e.evm_tx,L=await _(),ie=await L.getSigner();await So(L,q);const X=await ie.sendTransaction({chainId:E,to:B,value:S,data:`0x${O}`});return{txHash:X.hash,wait:X.wait()}}throw new Error("Unlisted chain type")}catch(E){throw new Error(await Pe(E))}},onSuccess:async({txHash:E,wait:B})=>{localStorage.removeItem(F.BRIDGE_QUANTITY),s(-1),n({type:"loading",title:"Transaction is pending..."});try{await B;const S=An(l)==="OP Bridge withdrawal",O=S?{success:!0,error:null}:await Kf(D,E,d);if(!O.success&&O.error){const ue=O.error instanceof Error?O.error.message:String(O.error);n({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${ue}. The transaction may still be processing.`,autoHide:!0})}const L=O.success,X=Lf({txHash:E,srcChainId:d,route:l,values:c,recipient:m},L);a(X.tx,X.details),r(Uf(o));const ye=ir(c,E);if(i("Bridge Transaction Success",ye),S){const ue=zf(X.tx,l,m);x(X.tx,ue)}}catch(S){const O=S instanceof Error?S.message:String(S);r({type:"error",title:"Transaction failed",description:O});const L={...ir(c,E),error:O};i("Bridge Transaction Failed",L)}finally{k.invalidateQueries({queryKey:Ae.balances(d,u).queryKey})}},onError:async E=>{const B=v==="initia"?await sn(E,I(d),b):E;n({type:"error",title:"Transaction failed",description:B.message})}})}function Of(){const e=Re(),s=ne(),n=Cr(),{route:r,values:o}=It(),a=lt();return T.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:l}=await e.post("op-hook",{json:{source_address:s,source_asset_chain_id:r.source_asset_chain_id,source_asset_denom:r.source_asset_denom,dest_address:w.InitiaAddress(o.recipient).bech32,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom}}).json();await Mf(s,a(r.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:m,msg:h})=>Mt.aminoTypes.fromAmino({type:Mt.aminoConverters[m].aminoType,value:JSON.parse(h)})),d=await n(i,s,c,{amount:[],gas:"1"},""),u=gt.Tx.fromPartial({body:gt.TxBody.decode(d.bodyBytes),authInfo:gt.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:s,hook:W.toBase64(gt.Tx.encode(u).finish())}}catch(i){throw new Error(await Pe(i))}}})}function Uf(e){return{type:"info",title:"Transaction submitted",description:f.createElement(f.Fragment,null,"Check ",f.createElement(gs,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function ir(e,s){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:s}}function Lf(e,s){const{txHash:n,srcChainId:r,route:o,values:a}=e,i={chainId:r,txHash:n},l=An(o)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:o,values:a,state:l?"success":void 0,tracked:s},isOpWithdraw:l}}function zf(e,s,n){return{...e,recipient:w.InitiaAddress(n).bech32,claimableAt:Date.now()+s.estimated_route_duration_seconds*1e3,amount:s.amount_out,denom:s.dest_asset_denom}}async function Kf(e,s,n){for(let a=0;a<=30;a++)try{return await e.post("v2/tx/track",{json:{tx_hash:s,chain_id:n}}).json(),{success:!0,error:null}}catch(i){if(a===30)return{success:!1,error:await Pe(i)};await new Promise(l=>setTimeout(l,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Hf(e){const{chainId:s,txHash:n,tracked:r}=e,o=Re();return T.useQuery({queryKey:Ae.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 Pe(a))}},select:({tx_hash:a})=>a,retry:6,retryDelay:5e3,staleTime:K.INFINITY,enabled:!r})}function Wf(e){const{timestamp:s,chainId:n,txHash:r,tracked:o,state:a}=e,i=Re();return T.useQuery({queryKey:Ae.txStatus(n,r).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:r,chain_id:n}}).json(),enabled:!!r&&o&&!a,refetchInterval:({state:{data:l}})=>{if(!l)return!1;const{status:c}=l;if(c==="STATE_COMPLETED")return!1;const d=s+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),m=Math.floor((d-u)/1e3);return m<=0?1e3:m<=300?5e3:60*1e3},staleTime:K.INFINITY})}var cs=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(cs||{});function An(e){const{operations:s,dest_asset_denom:n}=e;return y.has("op_init_transfer",y.head(s))&&n==="uinit"?"OP Bridge withdrawal":"Skip"}const Qf="_content_c0tee_1",Vf="_info_c0tee_6",Gf="_arrow_c0tee_11",Yf="_divider_c0tee_19",Jf="_type_c0tee_26",Zf="_asset_c0tee_44",Xf="_amount_c0tee_52",e_="_lower_c0tee_57",t_="_chain_c0tee_63",s_="_address_c0tee_69",he={content:Qf,info:Vf,arrow:Gf,divider:Yf,type:Jf,asset:Zf,amount:Xf,lower:e_,chain:t_,address:s_},ko=e=>{const{source:s,label:n,amount:r,denom:o,chainId:a,address:i,walletIcon:l}=e,{symbol:c=w.truncate(o),decimals:d=0,logo_uri:u=pn}=e,{chain_name:m,pretty_name:h,..._}=$e(a);return t.jsxs("div",{children:[!s&&t.jsxs("div",{className:he.arrow,children:[t.jsx("div",{className:he.divider}),n?t.jsx(bt,{label:n,children:t.jsx("button",{className:he.type,children:t.jsx(A.IconArrowDown,{size:12})})}):t.jsx("span",{className:he.type,children:t.jsx(A.IconArrowDown,{size:12})}),t.jsx("div",{className:he.divider})]}),t.jsxs("div",{className:he.content,children:[t.jsx(ks,{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:w.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(bn,{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:w.truncate(i)})]})})]})]})]})]})},pt=e=>{const s=De(e.denom,e.chainId);return t.jsx(ko,{...e,...s})};pt.Placeholder=ko;const n_="_root_1l4he_1",r_="_flexEnd_1l4he_6",o_="_toggle_1l4he_11",a_="_route_1l4he_34",i_="_content_1l4he_41",Bt={root:n_,flexEnd:r_,toggle:o_,route:a_,content:i_};function c_(e){const s=({name:n})=>n==="initia-dex"?"Initia DEX":fs.capitalCase(y.head(n?.split("-")??[])??"");if("transfer"in e)return{label:"Bridge via IBC",...e,...e.transfer};if("bank_send"in e)return{label:"Send",...e,...e.bank_send};if("swap"in e){const n=e.swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...e,...e.swap}}if("axelar_transfer"in e)return{label:"Bridge via Axelar",...e,...e.axelar_transfer};if("cctp_transfer"in e)return{label:"Bridge via CCTP",...e,...e.cctp_transfer};if("hyperlane_transfer"in e)return{label:"Bridge via Hyperlane",...e,...e.hyperlane_transfer};if("evm_swap"in e){const n=e.evm_swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...e,...e.evm_swap}}if("op_init_transfer"in e)return{label:"Bridge via OP Bridge",...e,...e.op_init_transfer};if("go_fast_transfer"in e)return{label:"Bridge via Go Fast",...e,...e.go_fast_transfer};if("eureka_transfer"in e)return{label:"Bridge via Eureka",...e,...e.eureka_transfer};if("stargate_transfer"in e)return{label:"Bridge via Stargate",...e,...e.stargate_transfer};if("layer_zero_transfer"in e)return{label:"Bridge via LayerZero",...e,...e.layer_zero_transfer};throw new Error("Unknown operation type")}const l_=({addressList:e})=>{const{values:s,route:n}=It(),{source_asset_denom:r,source_asset_chain_id:o,amount_in:a,operations:i}=n,l=y.zipObj(n.required_chain_addresses,e),{find:c}=As(),{connector:d,address:u=""}=_e.useAccount(),[m,h]=be.useToggle(!1),_=i.length>1,p=t.jsx(H,{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=j=>w.InitiaAddress.equals(j,u)?p:t.jsx(A.IconWallet,{size:11}),$=j=>{const{label:k,amount_out:b,denom:I,denom_out:x=I,chain_id:D,from_chain_id:E,to_chain_id:B=D??E}=j,S=l[B];return{label:_&&!m?void 0:k,amount:b,denom:x,chainId:B,address:S,walletIcon:C(S)}},N=i.map(c_).map($),q=N.slice(0,-1),v=N[N.length-1];return t.jsxs(U.Collapsible.Root,{className:Bt.root,open:m,onOpenChange:h,children:[_&&t.jsx("div",{className:Bt.flexEnd,children:t.jsx(U.Collapsible.Trigger,{className:Bt.toggle,children:m?t.jsxs(t.Fragment,{children:[t.jsx(A.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(A.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:Bt.route,children:[t.jsx(pt,{...g,source:!0}),t.jsx(U.Collapsible.Content,{className:Bt.content,children:q.map((j,k)=>t.jsx(xe,{suspenseFallback:t.jsx(pt.Placeholder,{...j}),errorBoundaryProps:{fallback:t.jsx(pt.Placeholder,{...j})},children:t.jsx(pt,{...j})},k))}),t.jsx(pt,{...v})]})]})},mn=({error:e})=>{const s=le();return t.jsx(ae,{extra:t.jsx(te,{level:"error",children:e.message}),children:t.jsx(V.White,{onClick:()=>s("/bridge"),children:"Home"})})},d_=({children:e})=>{const s=It(),{route:n,values:r}=s,{required_chain_addresses:o}=n,{srcChainId:a,dstChainId:i,sender:l,recipient:c}=r,{initiaAddress:d,hexAddress:u}=ge(),m=jt(),h=lt(),_=Ht(),p=h(a),g=_(p),C=o.slice(0,-1).some(b=>{const I=h(b);return _(I)==="cosmos"})&&g!=="cosmos",[$,N]=f.useState(void 0),[q,v]=f.useState(!1),[j,k]=f.useState(null);if(f.useEffect(()=>{(async()=>{try{if(!C)return;if(!m)throw new Error("Wallet not connected");v(!0),k(null);const[{pubkey:I}]=await m.getAccounts();N(I)}catch(I){k(new Error(await Pe(I)))}finally{v(!1)}})()},[C,m]),j)return t.jsx(mn,{error:j});if(q)return t.jsx(ae,{children:t.jsx(V.White,{loading:q&&"Generating intermediary addresses..."})});if(!C||$){const b=o.map((I,x)=>{if(x===o.length-1){const O=h(i);return _(O)==="initia"?w.InitiaAddress(c).bech32:c}const D=h(I),E=_(D),B=h(a),S=_(B);switch(E){case"initia":return d;case"evm":return u;case"cosmos":{if(S==="cosmos")return W.toBech32(D.bech32_prefix,W.fromBech32(l).data);if(!$)throw new Error("Pubkey not found");return Rt.pubkeyToAddress(Rt.encodeSecp256k1Pubkey($),D.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(b)}return null},u_=({addressList:e,signedOpHook:s,children:n})=>{const r=Re(),{route:o,values:a}=It(),[i,l]=f.useState(void 0),[c,d]=f.useState(!1),[u,m]=f.useState(null);return f.useEffect(()=>{(async()=>{try{if(o.required_op_hook&&!s)throw new Error("Op hook is required");d(!0),m(null);const _={address_list:e,amount_in:o.amount_in,amount_out:o.amount_out,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom,slippage_tolerance_percent:a.slippagePercent,operations:o.operations,signed_op_hook:s},{txs: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)}})()},[o,a,e,s,r]),u?t.jsx(mn,{error:u}):c?t.jsx(ae,{children:t.jsx(V.White,{loading:c&&"Fetching messages..."})}):i?n(i):t.jsx(mn,{error:new Error("Failed to fetch messages")})},m_=({children:e})=>{const{route:s}=It(),n=Of();return s.required_op_hook&&!n.data?t.jsx(ae,{extra:t.jsx(te,{level:"error",children:n.error?.message}),children:t.jsx(V.White,{onClick:()=>n.mutate(),loading:n.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(n.data)},h_=({tx:e,children:s})=>{const n=Sr(),r=lt(),{mutate:o,data:a,isPending:i,error:l}=T.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 n(),u=await d.getSigner();await So(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 at.ethers.Contract(h,g,u).approve(_,p)).wait()}return!0}catch(c){throw new Error(await Pe(c))}}});return"evm_tx"in e&&e.evm_tx.required_erc20_approvals&&e.evm_tx.required_erc20_approvals.length>0&&!a?t.jsx(ae,{extra:t.jsx(te,{level:"error",children:l?.message}),children:t.jsx(V.White,{onClick:()=>o(),loading:i&&"Approving tokens...",children:"Approve tokens"})}):s},f_=({tx:e})=>{const{mutate:s,isPending:n}=Ff(e);return t.jsx(ae,{children:t.jsx(V.White,{onClick:()=>s(),loading:n&&"Signing transaction...",children:"Confirm"})})},__=()=>t.jsx(dt,{title:"Route preview",children:t.jsx(d_,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(l_,{addressList:e}),t.jsx(m_,{children:s=>t.jsx(u_,{addressList:e,signedOpHook:s,children:n=>t.jsx(h_,{tx:n,children:t.jsx(f_,{tx:n})})})})]})})}),p_="_button_14cv7_1",g_="_checkbox_14cv7_10",x_="_checked_14cv7_23",rs={button:p_,checkbox:g_,checked:x_},y_=({checked:e,onClick:s,label:n,className:r})=>t.jsxs("button",{type:"button",className:P(rs.button,r),onClick:s,children:[t.jsx("div",{className:P(rs.checkbox,{[rs.checked]:e}),children:e&&t.jsx(A.IconCheck,{size:12})}),t.jsx("span",{className:rs.label,children:n})]}),j_="_success_t4dfk_1",v_="_error_t4dfk_5",cr={success:j_,error:v_},w_=({tx:e})=>{const[s,n]=No(e);if(!s)throw new Error("Bridge history details not found");const{data:r}=Wf(s),o=s.state??b_(r);switch(f.useEffect(()=>{o!=="loading"&&n(a=>{if(!a)throw new Error("Bridge history details not found");return{...a,tracked:!0,state:o}})},[n,o]),o){case"error":return t.jsx("div",{className:cr.error,children:t.jsx(A.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:cr.success,children:t.jsx(A.IconCheckCircleFilled,{size:14})});default:return t.jsx(Ge,{size:14})}};function b_(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 C_="_link_1uidr_1",I_="_header_1uidr_22",N_="_title_1uidr_30",S_="_date_1uidr_36",k_="_explorer_1uidr_40",A_="_fees_1uidr_55",$_="_label_1uidr_63",T_="_content_1uidr_67",E_="_route_1uidr_73",q_="_row_1uidr_78",D_="_asset_1uidr_84",P_="_amount_1uidr_92",B_="_chain_1uidr_97",R_="_account_1uidr_106",M_="_arrow_1uidr_113",ee={link:C_,header:I_,title:N_,date:S_,explorer:k_,fees:A_,label:$_,content:T_,route:E_,row:q_,asset:D_,amount:P_,chain:B_,account:R_,arrow:M_},F_=({tx:e})=>{const[s,n]=No(e);if(!s)throw new Error("Bridge history details not found");const{chainId:r,txHash:o,route:a,values:i,timestamp:l,tracked:c}=s,{data:d}=Hf(s),{address:u="",connector:m}=_e.useAccount(),{find:h}=As();f.useEffect(()=>{d&&n(L=>{if(!L)throw new Error("Bridge history details not found");return{...L,tracked:!0}})},[n,d]);const{amount_in:_,amount_out:p,source_asset_chain_id:g,source_asset_denom:C,dest_asset_chain_id:$,dest_asset_denom:N,estimated_fees:q=[]}=a,v=$e(g),j=$e($),k=De(C,g),b=De(N,$),I=(L,ie)=>ie?t.jsx(H,{src:ie,width:12,height:12}):w.InitiaAddress.equals(L,u)?t.jsx(H,{src:m?.icon,width:12,height:12}):t.jsx(A.IconWallet,{size:12}),x=(L,{symbol:ie,decimals:X,logo_uri:ye},{chain_name:ue,pretty_name:mt,...Nt},Je,M)=>t.jsxs("div",{className:ee.row,children:[t.jsx(ks,{assetLogoUrl:ye,chainLogoUrl:Nt.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:ee.asset,children:[t.jsx("span",{className:ee.amount,children:w.formatAmount(L,{decimals:X})}),t.jsx("span",{children:ie})]}),t.jsxs("div",{className:ee.chain,children:[t.jsxs("span",{children:["on ",mt||ue]}),t.jsxs("div",{className:ee.account,children:[M,t.jsx("span",{className:"monospace",children:w.truncate(Je)})]})]})]})]}),D=An(a),E=f.useMemo(()=>{switch(D){case cs.SKIP:return"Skip Explorer";case cs.OP_WITHDRAW:return"Initia Scan"}},[D]),B=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:ee.header,children:[t.jsxs("div",{className:ee.title,children:[c?t.jsx(w_,{tx:e}):t.jsx(Ge,{size:14}),t.jsx("div",{className:ee.date,children:Lt.intlFormatDistance(new Date(l),new Date,{locale:"en-US"})})]}),t.jsxs("div",{className:ee.explorer,children:[t.jsx("span",{children:E}),t.jsx(A.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:ee.route,children:[x(_,k,v,i.sender,I(i.sender,h(i.cosmosWalletName)?.image)),t.jsx("div",{className:ee.arrow,children:t.jsx(A.IconArrowDown,{size:12})}),x(p,b,j,i.recipient,I(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:yo(q)})]})]});if(D===cs.OP_WITHDRAW)return t.jsx(Ns,{chainId:r,txHash:o,className:ee.link,children:B});const S=new URLSearchParams({tx_hash:o,chain_id:r}),O=new URL(`?${S.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:O.toString(),className:ee.link,target:"_blank",children:B})},O_="_list_1q71m_1",U_="_header_1q71m_5",L_="_checkbox_1q71m_9",z_="_item_1q71m_13",os={list:O_,header:U_,checkbox:L_,item:z_},K_=()=>{const{initiaAddress:e,hexAddress:s}=ge(),{history:n,getHistoryDetails:r}=Io(),o=n.filter(h=>r(h)),a=o.filter(h=>{const _=r(h);if(!_)return!1;const{values:p}=_,{sender:g,recipient:C}=p;return[g,C].some($=>[e,s].includes($))}),[i,l]=f.useState(1),[c,d]=be.useToggle(!a.length),u=c?o:a,m=u.slice(0,i*ar);return t.jsx(dt,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:os.list,children:[o.length>0&&o.length!==a.length&&t.jsx("header",{className:os.header,children:t.jsx(y_,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:os.checkbox})}),u.length===0?t.jsx(Y,{children:"No bridge/swap activity"}):m.map((h,_)=>t.jsx("div",{className:os.item,children:t.jsx(xe,{children:t.jsx(F_,{tx:h})})},_)),u.length>i*ar?t.jsx(jo,{onClick:()=>l(h=>h+1)}):n.length>=ms&&t.jsxs(Y,{children:["Only the latest ",ms," items are stored. Older entries will be removed automatically."]})]})})},Ao=()=>{const e=le(),s=ps(),n=wt(),{closeDrawer:r}=vt(),{closeModal:o}=zt();f.useEffect(()=>{o(),s.startsWith("/bridge/")&&e("/bridge"),(s==="/collection"||s.startsWith("/nft"))&&e("/nfts")},[n]);const a=vs();if(f.useEffect(()=>{a("Page View")},[s,a]),s==="/connect")return n?null:t.jsx(Kn,{onSuccess:r});if(s==="/blank")return null;if(!n)return t.jsx(Kn,{});switch(s){case"/":case"/nfts":case"/activity":return t.jsx(Du,{});case"/send":return t.jsx(Um,{},n);case"/nft":return t.jsx(Zm,{});case"/nft/send":return t.jsx(uh,{},n);case"/bridge":return t.jsx(sf,{},n);case"/bridge/preview":return t.jsx(__,{});case"/bridge/history":return t.jsx(K_,{});case"/op/withdrawals":return t.jsx(Rf,{});case"/tx":return t.jsx(to,{})}},H_="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",W_=()=>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:H_}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),Q_=()=>{se();const e=pe();return jn(),xt(localStorage.getItem(F.BRIDGE_SRC_CHAIN_ID)??e.chainId),xt(localStorage.getItem(F.BRIDGE_DST_CHAIN_ID)??e.chainId),null},V_=new T.QueryClient({defaultOptions:{queries:{retry:0}}}),G_=({children:e,...s})=>(f.useEffect(()=>{ka()},[]),be.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(W_,{}),t.jsx(vr.Provider,{value:{..._r,...s},children:t.jsx(yr,{children:t.jsx(Ta,{children:t.jsx(U.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(Ha,{children:t.jsxs(pc,{children:[e,t.jsxs(T.QueryClientProvider,{client:V_,children:[t.jsx(gc,{}),t.jsx(xe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(Q_,{})}),t.jsx(Jc,{children:t.jsx(Ao,{})})]})]})})})})})})]}):null),Y_=({bridge:e})=>t.jsx(yr,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Hr.Provider,{value:!!e,children:t.jsx(xe,{children:t.jsx(Ao,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=Ft;exports.DEFAULT_GAS_PRICE_MULTIPLIER=fr;exports.InterwovenKit=Y_;exports.InterwovenKitProvider=G_;exports.MAINNET=_r;exports.TESTNET=Ko;exports.initiaPrivyWallet=Wo;exports.initiaPrivyWalletConnector=Ho;exports.initiaPrivyWalletOptions=fn;exports.injectStyles=yc;exports.useAddress=wt;exports.useHexAddress=Cs;exports.useInitiaAddress=ne;exports.useInterwovenKit=ge;exports.usePortfolio=yn;exports.useUsernameQuery=Or;