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