@initia/interwovenkit-react 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4722 -4559
- package/dist/styles.css +1 -1
- package/dist/styles.js +1 -1
- package/package.json +34 -34
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _r=require("@privy-io/cross-app-connect/rainbow-kit"),xe=require("wagmi"),E=require("@tanstack/react-query"),N=require("@initia/utils"),Ve=require("cosmjs-types/cosmos/tx/v1beta1/tx"),Ut=require("@cosmjs/amino"),$e=require("@cosmjs/stargate"),Q=require("jotai"),t=require("react/jsx-runtime"),v=require("ramda"),f=require("react"),Z=require("ky"),qe=require("@lukemorales/query-key-factory"),Ye=require("ethers"),Bo=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),on=require("@cosmjs/amino/build/signdoc"),an=require("@cosmjs/crypto"),H=require("@cosmjs/encoding"),Bn=require("@cosmjs/math"),xs=require("@cosmjs/proto-signing"),Mn=require("@cosmjs/tendermint-rpc"),zt=require("@initia/amino-converter"),cn=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Mo=require("cosmjs-types/cosmos/auth/v1beta1/auth"),Fo=require("cosmjs-types/google/protobuf/any"),fr=require("@amplitude/analytics-browser"),M=require("bignumber.js"),Oo=require("@mysten/bcs"),G=require("radix-ui"),Ce=require("usehooks-ts"),pr=require("react-error-boundary"),R=require("clsx"),Fn=require("nanoid"),Lo=require("react-dom"),Je=require("@react-spring/web"),A=require("@initia/icons-react"),we=require("@base-ui-components/react/dialog"),ys=require("change-case"),De=require("@base-ui-components/react/select"),Uo=require("qr-code-styling"),zo=require("xss"),ze=require("@base-ui-components/react/tabs"),Nt=require("date-fns"),Ko=require("jotai/utils"),jt=require("@base-ui-components/react/popover"),Ke=require("@base-ui-components/react"),re=require("react-hook-form"),On=require("cosmjs-types/cosmos/bank/v1beta1/tx"),gr=require("react-merge-refs"),Ho=require("react-intersection-observer"),es=require("@noble/hashes/utils"),Wo=require("@noble/hashes/sha3");function Qo(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 yn=Qo(fr),Kt=1.4,xr=1.05,yr={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",theme:"dark"},Vo={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",theme:"dark",disableAnalytics:!0},js={id:"cmbq1ozyc006al70lx4uciz0q",name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Go=_r.toPrivyWalletConnector(js),Yo=_r.toPrivyWallet(js),jr=f.createContext(null);function vs(){return f.useContext(jr)}function vr(){const{location:e}=vs();return e}function bs(){const{path:e}=vr();return e}function ht(){const{state:e={}}=vr();return e}function Jo(){const{history:e}=vs();return e}function ie(){const{navigate:e}=vs();return e}function br(){const{reset:e}=vs();return e}const wr=({children:e,initialEntry:s})=>{const[n,r]=f.useState([s??{path:"/"}]),o=n[n.length-1],a=f.useCallback((l,c)=>{r(d=>{if(typeof l=="string")return[...d,{path:l,state:c}];const u=d.length+l;if(u<1)return d;const h=v.take(u,d);return c!==void 0?v.adjust(u-1,m=>({...m,state:c}),h):h})},[]),i=f.useCallback((l,c)=>{r([{path:l,state:c}])},[]);return t.jsx(jr.Provider,{value:{location:o,history:n,navigate:a,reset:i},children:e})},jn=({to:e,state:s,shouldReset:n,children:r,onClick:o,...a})=>{const i=ie(),l=br(),c=d=>{d.preventDefault(),o?.(d),n?l(e,s):i(e,s)};return t.jsx("button",{type:"button",...a,onClick:c,children:r})},Cr=f.createContext(null),ws=()=>f.useContext(Cr),Ir=f.createContext(null);function ce(){const e=f.useContext(Ir);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const U={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function Zo(e){if(e instanceof Z.HTTPError){const{response:s}=e,n=s.headers.get("content-type")??"";if(v.includes("application/json",n))try{const r=await s.json();if(r.message)return r.message}catch{return e.message}try{return await s.text()}catch{return e.message}}if(e instanceof Error){if(v.path(["code"],e)===4001||v.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const s=v.path(["error","message"],e),n=v.path(["cause","message"],e),r=v.path(["shortMessage"],e);return s||n||r||e.message}return String(e)}async function Re(e){return new Error(await Zo(e))}class Nr 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 Xo=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Os=new Map;function ea(e){const s=e.match(Xo);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 ta(e,s,n){const r=`${e}:${s}`;if(Os.has(r))return Os.get(r);try{const o=s==="0x1"?"0x1.json":`${e}/${s}.json`,a=`${n}/errors/${o}`,{errors:i={}}=await Z.get(a).json();return Os.set(r,i),i}catch{return null}}function sa(e,s,n,r,o,a,i){return new Nr(e,s,n,r,o,a,i)}async function bt(e,s,n){if(!s.metadata?.is_l1&&s.metadata?.minitia?.type!=="minimove")return await Re(e);const r=ea(e.message);if(!r)return await Re(e);const o=await ta(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 sa(c,e,r.moduleAddress,r.moduleName,r.errorCode,a,d)}const vn=qe.createQueryKeys("interwovenkit:chain",{list:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function ts(e){const s=v.path([0,"address"],e);if(!s)throw new Error("URL not found");return s}function na(e){const{chain_id:s,chain_name:n,pretty_name:r,logo_URIs:o,apis:a,metadata:i}=e,l=r||n,c=o?.png??"",{rpc:d,rest:u,["json-rpc"]:h,indexer:m}=a,_=ts(d),p=ts(u),g=ts(m),b=i?.minitia?.type==="minievm"?ts(h):void 0;return{...e,chainId:s,name:l,logoUrl:c,rpcUrl:_,restUrl:p,indexerUrl:g,jsonRpcUrl:b}}function se(){const{defaultChainId:e,registryUrl:s,customChain:n}=ce(),{data:r}=E.useSuspenseQuery({queryKey:vn.list(s).queryKey,queryFn:()=>Z.create({prefixUrl:s}).get("chains.json").json(),select:o=>(n?[n,...o.filter(i=>i.chain_id!==n.chain_id)]:o).map(na).toSorted(v.descend(i=>i.chainId===e)),staleTime:U.MINUTE});return r}function Ze(){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 Fe(e){return Ze()(e)}function Qt(){const{defaultChainId:e}=ce();return Fe(e)}function ye(){const s=se().find(n=>n.metadata?.is_l1);if(!s)throw new Error("Layer 1 not found");return s}function Sr(){return({chainId:e})=>E.queryOptions({queryKey:vn.prices(e).queryKey,queryFn:()=>Z.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:U.SECOND})}function Cs(e){const s=Sr();return E.useQuery(s(e))}function ra(){const e=se(),s=Sr();return E.useQueries({queries:e.map(n=>s(n))})}function oa(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:s}=cn.PubKey.decode(e.value);return Ut.encodeSecp256k1Pubkey(s)}return xs.decodeOptionalPubkey(e)}function aa({typeUrl:e,value:s}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:n,pubKey:r,accountNumber:o,sequence:a}=Mo.BaseAccount.decode(s),i=oa(r);return{address:n,pubkey:i,accountNumber:Number(o),sequence:Number(a)}}return $e.accountFromAny({typeUrl:e,value:s})}function ia(e){return e.type==="initia/PubKeyEthSecp256k1"}const ca={...Ut.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function la(e){if(ia(e)){const s=cn.PubKey.fromPartial({key:H.fromBase64(e.value)});return Fo.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(cn.PubKey.encode(s).finish())})}return xs.encodePubkey(e)}function kr(e){if(e.length!==33||e[0]!==2&&e[0]!==3)throw new Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03");return{type:ca.ethsecp256k1,value:H.toBase64(e)}}function da(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:kr(e),signature:H.toBase64(s)}}const Ne="interwovenkit",O={PUBLIC_KEY:`${Ne}:public-key`,BRIDGE_SRC_CHAIN_ID:`${Ne}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${Ne}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${Ne}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${Ne}:bridge:dst-denom`,BRIDGE_QUANTITY:`${Ne}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${Ne}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${Ne}:bridge:route-type`,BRIDGE_HISTORY:`${Ne}:bridge:history`,OP_REMINDER:`${Ne}:op:reminder`},Is=()=>{const e=ce();return new xs.Registry([...zt.protoRegistry,...e.protoTypes??[]])},Ns=()=>{const e=ce();return new $e.AminoTypes({...zt.aminoConverters,...e.aminoConverters})};class ua{constructor(s,n){this.address=s,this.signMessage=n}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const s=`${O.PUBLIC_KEY}:${this.address}`,n=localStorage.getItem(s);if(n)return this.cachedPublicKey=H.fromHex(n),H.fromHex(n);const r=await this.getPublicKey();return this.cachedPublicKey=r,localStorage.setItem(s,H.toHex(r)),r}async getPublicKey(){const s="Sign this message to identify your Initia account.",n=await this.signMessage(s),r=Ye.ethers.hashMessage(s),o=Ye.ethers.SigningKey.recoverPublicKey(r,n);return an.Secp256k1.compressPubkey(H.fromHex(o.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(s,n){if(this.address!==s)throw new Error("Signer address does not match the provided address");const r=on.escapeCharacters(on.sortedJsonStringify(n)),o=await this.signMessage(r),a=H.fromHex(o.replace("0x","")).subarray(0,-1),l=an.Secp256k1Signature.fromFixedLength(a).toFixedLength(),c=da(await this.getCachedPublicKey(),l);return{signed:n,signature:c}}}function bn(){const e=Is(),s=Ns(),n=St(),r=$r();return async function(o,a,i,l,c,d){if(!n)throw new Error("Signer not initialized");const u=await r(o),{accountNumber:h,...m}=await u.getSequence(a),_=m.sequence+(d?.incrementSequence??0),[p]=await n.getAccounts(),g=la(kr(p.pubkey)),b=Bo.SignMode.SIGN_MODE_EIP_191,k=i.map(y=>s.toAmino(y)),S=on.makeSignDoc(k,l,o,c,h,_),{signature:T,signed:j}=await n.signAmino(a,S),B={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:j.msgs.map(y=>s.fromAmino(y)),memo:c}},P=e.encode(B),I=Bn.Int53.fromString(j.fee.gas).toNumber(),x=Bn.Int53.fromString(j.sequence).toNumber(),w=xs.makeAuthInfoBytes([{pubkey:g,sequence:x}],j.fee.amount,I,j.fee.granter,j.fee.payer,b);return Ve.TxRaw.fromPartial({bodyBytes:P,authInfoBytes:w,signatures:[H.fromBase64(T.signature)]})}}function St(){const e=ne(),{signMessageAsync:s}=xe.useSignMessage();return f.useMemo(()=>new ua(e,n=>s({message:n})),[e,s])}const Ls=new Map,Us=new Map;function Ar(){const e=Ze();return async s=>{if(Ls.has(s))return Ls.get(s);const{rpcUrl:n}=e(s),r=await Mn.Comet38Client.create(new Mn.HttpClient(n));return Ls.set(s,r),r}}function $r(){const e=Is(),s=Ns(),n=St(),r=ne(),o=Ar();return async a=>{const i=`${r}:${a}`;if(Us.has(i))return Us.get(i);if(!n)throw new Error("Signer not initialized");const l=await o(a),c=await $e.SigningStargateClient.createWithSigner(l,n,{registry:e,aminoTypes:s,accountParser:aa,broadcastPollIntervalMs:500});return Us.set(i,c),c}}function Tr(){const{connector:e}=xe.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new Ye.BrowserProvider(await e.getProvider())}}const ha="c33b940c24c17e95f7d9d525d508ac61";function ma(){const{disableAnalytics:e}=ce();f.useEffect(()=>{e||yn.init(ha,{autocapture:!1})},[e])}function _a(){const{connector:e}=xe.useAccount(),{defaultChainId:s,disableAnalytics:n}=ce();f.useEffect(()=>{const r=new fr.Identify;e?.name&&r.set("connector",e.name),s&&r.set("defaultChainId",s),yn.identify(r)},[s,e?.name,n])}function Ss(){const e=bs();return f.useCallback((n,r)=>{yn.track(n,{path:e,...r})},[e])}const fa=Q.atom(!1);function kt(){const e=br(),[s,n]=Q.useAtom(fa),r=Ss();return{isDrawerOpen:s,openDrawer:(i,l)=>{i&&e(i,l),n(!0),r("Widget Opened")},closeDrawer:()=>{n(!1),r("Widget Closed")}}}function Er(){const e=ie(),{closeDrawer:s}=kt(),{disconnect:n}=xe.useDisconnect();return()=>{e("/blank"),s(),n(),localStorage.removeItem(O.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(O.BRIDGE_SRC_DENOM),localStorage.removeItem(O.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(O.BRIDGE_DST_DENOM),localStorage.removeItem(O.BRIDGE_QUANTITY),localStorage.removeItem(O.BRIDGE_SLIPPAGE_PERCENT)}}const qr="approve",ks=Q.atom(),Dr=Q.atom(null);function Pr(){const e=Q.useAtomValue(ks);if(!e)throw new Error("Tx request not found");return e}function Rr(){const e=ie(),s=ne(),{defaultChainId:n,registryUrl:r}=ce(),o=Ze(),{openDrawer:a,closeDrawer:i}=kt(),{openModal:l,closeModal:c}=ws(),d=Q.useSetAtom(ks),u=Q.useSetAtom(Dr),h=Ar(),m=$r(),_=St(),p=Is(),g=async({messages:I,memo:x,chainId:w=n})=>{try{return await(await m(w)).simulate(s,I,x)}catch(y){throw await bt(y,o(w),r)}},b=async({messages:I,memo:x,chainId:w=n})=>{const y=await h(w),q=$e.QueryClient.withExtensions(y,$e.setupTxExtension),C=I.map(le=>p.encodeAsAny(le)),[F]=await _.getAccounts(),$=Ut.encodeSecp256k1Pubkey(F.pubkey),V=await m(w),{sequence:K}=await V.getSequence(s);return q.tx.simulate(C,x,$,K)},k=async({txRequest:I,broadcaster:x})=>{const y={...{memo:"",chainId:n,gas:I.gas||await g(I),gasAdjustment:Kt,gasPrices:null,spendCoins:[],internal:!1},...I};return new Promise((q,C)=>{d({txRequest:y,resolve:async $=>{try{const V=await m(y.chainId),K=await x(V,Ve.TxRaw.encode($).finish());q(K),typeof y.internal=="string"&&e(y.internal)}catch(V){C(await bt(V,o(y.chainId),r))}finally{F()}},reject:$=>{C($),F()}}),y.internal?l({path:"/tx"}):a("/tx");const F=()=>{if(!y.internal){e("/blank"),i();return}c()}})},S=async I=>{const x=I.chainId??n;try{const w=await k({txRequest:I,broadcaster:async(y,q)=>await y.broadcastTxSync(q)});return I.internal&&typeof I.internal!="number"&&(u({txHash:w,chainId:x,status:"loading"}),P({txHash:w,chainId:I.chainId}).then(y=>{u({status:y.code===0?"success":"error",chainId:x,txHash:w})}).catch(()=>{u({status:"error",chainId:x,txHash:w})})),w}catch(w){throw I.internal&&typeof I.internal!="number"&&u({status:"error",chainId:x,error:w}),w}},T=(I,x=30*1e3,w=.5*1e3)=>k({txRequest:I,broadcaster:async(y,q)=>{const C=await y.broadcastTx(q,x,w);if(C.code!==0)throw new Error(C.rawLog);return C}}),j=bn(),D=async I=>{const x=I.chainId??n;try{const{messages:w,memo:y="",fee:q}=I,C=await m(x),F=await j(x,s,w,q,y);return await C.broadcastTxSync(Ve.TxRaw.encode(F).finish())}catch(w){throw await bt(w,o(x),r)}},B=async(I,x=30*1e3,w=.5*1e3)=>{const y=I.chainId??n;try{const{messages:q,memo:C="",fee:F}=I,$=await m(y),V=await j(y,s,q,F,C),K=await $.broadcastTx(Ve.TxRaw.encode(V).finish(),x,w);if(K.code!==0)throw new Error(K.rawLog);return K}catch(q){throw await bt(q,o(y),r)}},P=async({chainId:I=n,...x})=>{try{const w=await m(I);return await Br({...x,client:w})}catch(w){throw await bt(w,o(I),r)}};return{estimateGas:g,simulateTx:b,requestTxSync:S,requestTxBlock:T,submitTxSync:D,submitTxBlock:B,waitForTxConfirmation:P}}async function Br({txHash:e,client:s,timeoutMs:n=30*1e3,intervalMs:r=.5*1e3}){const o=Date.now();for(;;){const a=await s.getTx(e);if(a){if(a.code!==0)throw new Error(a.rawLog);return a}if(Date.now()-o>=n)throw new Error(`Transaction was submitted, but not found on the chain within ${n/1e3} seconds.`);await new Promise(i=>setTimeout(i,r))}}function pa(e){return e.pagination?.next_key??null}async function Mr(e,s,n){const r=Z.create(s),o=async(a,i)=>{const l=await r.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[n]??[],d=pa(l),u=[...a,...c];return d?o(u,d):u};return o([],null)}const ga=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const xr=require("@privy-io/cross-app-connect/rainbow-kit"),ve=require("wagmi"),A=require("@tanstack/react-query"),w=require("@initia/utils"),M=require("bignumber.js"),v=require("ramda"),ke=require("@lukemorales/query-key-factory"),Z=require("ky"),f=require("react"),W=require("@cosmjs/encoding"),Uo=require("@mysten/bcs"),ln=require("@cosmjs/amino/build/signdoc"),dn=require("@cosmjs/crypto"),Un=require("@cosmjs/math"),js=require("@cosmjs/proto-signing"),qe=require("@cosmjs/stargate"),Ln=require("@cosmjs/tendermint-rpc"),Lo=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),Ge=require("cosmjs-types/cosmos/tx/v1beta1/tx"),Ze=require("ethers"),Kt=require("@initia/amino-converter"),Ht=require("@cosmjs/amino"),zo=require("cosmjs-types/cosmos/auth/v1beta1/auth"),un=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Ko=require("cosmjs-types/google/protobuf/any"),G=require("jotai"),t=require("react/jsx-runtime"),yr=require("@amplitude/analytics-browser"),Y=require("radix-ui"),Ne=require("usehooks-ts"),jr=require("react-error-boundary"),B=require("clsx"),Ie=require("@base-ui-components/react/dialog"),Ho=require("xss"),k=require("@initia/icons-react"),Je=require("@react-spring/web"),Wo=require("qr-code-styling"),vs=require("change-case"),Re=require("@base-ui-components/react/select"),Ls=require("@base-ui-components/react/collapsible"),zn=require("nanoid"),Qo=require("react-dom"),ce=require("react-hook-form"),At=require("date-fns"),Vo=require("jotai/utils"),vr=require("react-merge-refs"),Go=require("react-intersection-observer"),Yo=require("@noble/hashes/sha3"),ss=require("@noble/hashes/utils"),He=require("@base-ui-components/react/tabs"),vt=require("@base-ui-components/react/popover"),We=require("@base-ui-components/react"),Kn=require("cosmjs-types/cosmos/bank/v1beta1/tx");function Zo(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(s,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return s.default=e,Object.freeze(s)}const bn=Zo(yr),Wt=1.4,br=1.05,wr={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",glyphUrl:"https://glyph.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",theme:"dark"},Jo={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",glyphUrl:"https://glyph.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",theme:"dark",disableAnalytics:!0},bs={id:"cmbq1ozyc006al70lx4uciz0q",name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Xo=xr.toPrivyWalletConnector(bs),ea=xr.toPrivyWallet(bs),Cr=f.createContext(null);function ee(){const e=f.useContext(Cr);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const K={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function ta(e){if(e instanceof Z.HTTPError){const{response:s}=e,n=s.headers.get("content-type")??"";if(v.includes("application/json",n))try{const r=await s.json();if(r.message)return r.message}catch{return e.message}try{return await s.text()}catch{return e.message}}if(e instanceof Error){if(v.path(["code"],e)===4001||v.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const s=v.path(["error","message"],e),n=v.path(["cause","message"],e),r=v.path(["shortMessage"],e);return s||n||r||e.message}return String(e)}async function Fe(e){return new Error(await ta(e))}const ws=ke.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function ns(e){const s=v.path([0,"address"],e);if(!s)throw new Error("URL not found");return s}function sa(e){const{chain_id:s,chain_name:n,pretty_name:r,logo_URIs:o,apis:a,metadata:i}=e,l=r||n,c=o?.png??"",{rpc:d,rest:u,["json-rpc"]:m,indexer:h}=a,_=ns(d),g=ns(u),p=ns(h),j=i?.minitia?.type==="minievm"?ns(m):void 0;return{...e,chainId:s,name:l,logoUrl:c,rpcUrl:_,restUrl:g,indexerUrl:p,jsonRpcUrl:j}}function oe(){const{defaultChainId:e,registryUrl:s,customChain:n}=ee(),{data:r}=A.useSuspenseQuery({queryKey:ws.list(s).queryKey,queryFn:()=>Z.create({prefixUrl:s}).get("chains.json").json(),select:o=>(n?[n,...o.filter(i=>i.chain_id!==n.chain_id)]:o).map(sa).toSorted(v.descend(i=>i.chainId===e)),staleTime:K.MINUTE});return r}function Ir(){const{registryUrl:e}=ee(),{data:s}=A.useSuspenseQuery({queryKey:ws.profiles(e).queryKey,queryFn:()=>Z.create({prefixUrl:e}).get("profiles.json").json(),staleTime:K.MINUTE});return s}function Xe(){const e=le(),s=oe(),n=Ir();return r=>{const o=s.find(i=>i.chain_id===r);if(o)return o;const a=n.find(i=>i.chain_id===r);if(!a)throw new Error(`Chain not found: ${r}`);return{chain_id:a.chain_id,chain_name:a.name,pretty_name:a.pretty_name,network_type:e.network_type,bech32_prefix:"init",fees:{fee_tokens:[]},apis:{rpc:[],rest:[],indexer:[]},chainId:r,name:a.pretty_name,logoUrl:a.logo,rpcUrl:"",restUrl:"",indexerUrl:"",jsonRpcUrl:""}}}function Oe(e){return Xe()(e)}function Gt(){const{defaultChainId:e}=ee();return Oe(e)}function le(){const s=oe().find(n=>n.metadata?.is_l1);if(!s)throw new Error("Layer 1 not found");return s}function Nr(){return({chainId:e})=>A.queryOptions({queryKey:ws.prices(e).queryKey,queryFn:()=>Z.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:K.SECOND})}function Cs(e){const s=Nr();return A.useQuery(s(e))}function na(){const e=oe(),s=Nr();return A.useQueries({queries:e.map(n=>s(n))})}const ra=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
|
|
2
2
|
<circle fill="#2F3337" cx="30" cy="30" r="30"/>
|
|
3
3
|
<path fill="#757C82" d="M26.328 34.288v-.48c0-2.048 1.024-2.816 4.128-4.16 3.104-1.28 3.712-1.952 3.712-3.488v-.128c0-1.664-1.344-2.464-4.224-2.464-2.816 0-4.416.736-4.768 3.296h-5.248c.416-5.536 4.416-7.584 9.888-7.584h.352c6.208 0 9.28 2.496 9.28 6.24v.352c0 3.392-1.28 4.96-5.376 6.592-1.504.64-2.048 1.024-2.208 1.824h-5.536ZM26.168 42v-5.152h5.792V42h-5.792Z"/>
|
|
4
|
-
</svg>`,xa=encodeURIComponent(ga),wn=`data:image/svg+xml;utf8,${xa}`,ms=qe.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,s)=>[e,s],resource:(e,s)=>[e.chainId,s.denom],denom:(e,s)=>[e,s],metadata:(e,s)=>[e,s]});function ya(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??v.head(r)?.exponent??0,u=a?.png??"";return{denom:s,symbol:n,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function Fr(){const e=E.useQueryClient();return s=>{const n=s?.metadata?.assetlist;return E.queryOptions({queryKey:ms.list(n).queryKey,queryFn:async()=>n?Z.get(n).json():{assets:[]},select:({assets:r})=>{if(!s)return[];const o=r.map(ya);for(const a of o)e.setQueryData(ms.item(s.chainId,a.denom).queryKey,a);return o},staleTime:U.MINUTE})}}function Ht(e){const s=Fr(),{data:n}=E.useSuspenseQuery(s(e));return n}function ja(){const e=se(),s=Fr();return E.useQueries({queries:e.map(n=>s(n))})}function Xe(e){const s=Ht(e),n=ye(),r=Ht(n),o=Lr(e);return a=>{const i=s.find(c=>c.denom===a);if(i)return i;const l=r.find(c=>c.denom===o(a));return l?{...l,denom:a}:{denom:a,symbol:"",decimals:0,logoUrl:wn}}}function Or(e,s){const n=Xe(s),o=E.useQueryClient().getQueryData(ms.item(s.chainId,e).queryKey);return o||n(e)}function Lr(e){const s=ye(),n=Ht(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?N.getIbcDenom(o,r):""}}const Ln="usernames";function va({restUrl:e,moduleAddress:s}){const{viewFunction:n}=N.createMoveClient(e);async function r(i){if(!N.InitiaAddress.validate(i))return null;const l=await n({moduleAddress:s,moduleName:Ln,functionName:"get_name_from_address",typeArgs:[],args:[H.toBase64(N.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:Ln,functionName:"get_address_from_name",typeArgs:[],args:[Oo.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return l?N.InitiaAddress(l).bech32:null}return{restUrl:e,getUsername:r,getAddress:a,validateUsername:o}}const As=qe.createQueryKeys("interwovenkit:account",{username:(e,s)=>[e,s],address:(e,s)=>[e,s],balances:(e,s)=>[e,s],txs:(e,s)=>[e,s]});function Ur(){const{restUrl:e}=ye(),{usernamesModuleAddress:s}=ce();return va({restUrl:e,moduleAddress:s})}function zr(){const e=ne();return s=>E.queryOptions({queryKey:As.balances(s.restUrl,e).queryKey,queryFn:()=>Mr(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:s.restUrl},"balances"),staleTime:U.SECOND})}function Cn(e){const s=zr(),{data:n}=E.useSuspenseQuery(s(e));return n}function ba(){const e=se(),s=zr();return E.useQueries({queries:e.map(n=>s(n))})}function wa(e){const s=Cn(e),n=Ht(e),r=Xe(e),o=Lr(e),{data:a}=Cs(e),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>n.some(d=>d.denom===c);return v.sortWith([v.descend(({denom:c})=>o(c)==="uinit"),v.descend(({denom:c})=>i(c)),v.descend(({value:c})=>c),v.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>M(d).comparedTo(c)??0,v.descend(({symbol:c})=>c.toLowerCase())],s.filter(({amount:c})=>!M(c).isZero()).map(({amount:c,denom:d})=>{const u=r(d),h=a?.find(({id:_})=>_===u?.denom)?.price??0,m=M(c).times(h).div(M(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:h,value:m}}))}const Ca="INIT",Ia="Initia";function In(e){return e.assets.reduce((s,{value:n})=>s+(n??0),0)}function Na(e){return e.assets.reduce((s,{quantity:n})=>s.plus(n),M(0)).toString()}function Sa(e,s){return{symbol:s?.symbol??e,logoUrl:s?.logoUrl??wn}}function Un(e){return v.pick(["chainId","name","logoUrl"],e)}function ka(e){return v.sortWith([v.descend(({symbol:s})=>s===Ca),v.descend(In),v.descend(({assets:s})=>s.length),v.ascend(({symbol:s})=>s)])(e)}function Aa(e){return v.sortWith([v.descend(({value:s})=>s??0),v.descend(({quantity:s})=>Number(s)),v.ascend(({chain:s})=>s.name)])(e)}function $a(e){return v.sortWith([v.descend(({chain:s})=>s.name===Ia),v.ascend(({chain:s})=>s.name),v.ascend(({denom:s})=>s)])(e)}function Ta(e,s){return v.sortWith([v.descend(({chainId:n})=>n===s),v.descend(v.prop("value"))])(e)}function Ea(e,s,n,r,o){const a={};for(const u of e){const h=u.chainId,m=s[h]??[],_=n[h],p=r[h],g=[];for(const{amount:b,denom:k}of m){if(!M(b).gt(0))continue;const S=_?.find(P=>P.denom===k),T=p?.find(P=>P.id===k)?.price,j=S?.decimals??0,D=N.fromBaseUnit(b,{decimals:j}),B=T?M(D).times(T).toNumber():void 0;g.push({...Sa(k,S),amount:b,denom:k,decimals:j,quantity:D,price:T,value:B,address:S?.address,unlisted:!S,chain:Un(u)})}a[h]=g}const i=new Map;for(const[u,h]of Object.entries(a)){const m=e.find(p=>p.chainId===u);if(!m)continue;const _=h.reduce((p,{value:g})=>p+(g??0),0);i.set(u,{...Un(m),value:_})}const l=new Map;for(const u of Object.values(a))for(const h of u)if(!h.unlisted){const{symbol:m}=h,_=l.get(m)??[];l.set(m,[..._,h])}const c=[];for(const[u,h]of l){const m=v.head(h);if(!m)continue;const _=Aa(h);c.push({symbol:u,logoUrl:m.logoUrl,assets:_})}const d=[];for(const u of Object.values(a))for(const h of u)h.unlisted&&d.push(h);return{chainsByValue:Ta(Array.from(i.values()),o),assetGroups:ka(c),unlistedAssets:$a(d),totalValue:c.reduce((u,h)=>u+In(h),0)}}function Nn(){const{defaultChainId:e}=ce(),s=se(),n=ba(),r=ja(),o=ra(),a=s.map(m=>m.chainId),i=v.zipObj(a,n.map(v.prop("data"))),l=v.zipObj(a,r.map(v.prop("data"))),c=v.zipObj(a,o.map(v.prop("data"))),d=Ea(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=$s();return e?N.InitiaAddress(e).bech32:""}function $s(){const{address:e}=xe.useAccount();return e?N.InitiaAddress(e).hex:""}function At(){const e=Qt(),s=ne(),n=$s();return e.metadata?.minitia?.type==="minievm"?n:s}function Kr(){const e=At(),s=Ur();return E.useQuery({queryKey:As.username(s.restUrl,e).queryKey,queryFn:()=>s.getUsername(e),enabled:!!e,staleTime:U.MINUTE})}function je(){const e=At(),s=ne(),n=$s(),{data:r}=Kr(),o=St(),a=Er(),{isDrawerOpen:i,openDrawer:l}=kt(),c=()=>{l("/")},d=()=>{l("/connect")},u=_=>{l("/bridge",_)},h=Rr();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 qa(){const e=["initia-wallet-widget:last-connected-wallet","initia-wallet-widget:fee-denoms","initia-wallet-widget:chain-ids","initia-wallet-widget:opened-layers-assets","initia-wallet-widget:opened-layers-nft"],s={"initia-wallet-widget:ethereum-public-keys":{prefix:O.PUBLIC_KEY,getSuffix:n=>N.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 Da="_status_tn9m1_1",Pa="_error_tn9m1_9",zn={status:Da,error:Pa},J=({error:e,children:s})=>t.jsx("p",{className:R(zn.status,{[zn.error]:e}),children:s}),ue=({errorBoundaryProps:e={fallbackRender:({error:r})=>t.jsx(J,{error:!0,children:r.message})},suspenseFallback:s=t.jsx(J,{children:"Loading..."}),children:n})=>t.jsx(pr.ErrorBoundary,{...e,children:t.jsx(f.Suspense,{fallback:s,children:n})}),Te=qe.createQueryKeys("interwovenkit:skip",{chains:null,assets:e=>[e],asset:(e,s)=>[e,s],balances:(e,s)=>[e,s],route:(e,s)=>[e,s],routeErrorInfo:e=>[e],txTrack:(e,s)=>[e,s],txStatus:(e,s)=>[e,s]});function Oe(){const{routerApiUrl:e}=ce();return f.useMemo(()=>Z.create({prefixUrl:e}),[e])}function Hr(){const e=se();return s=>e.some(n=>n.chain_id===s)}function Vt(){const e=Hr();return s=>e(s.chain_id)?"initia":s.chain_type}function Wt(e){return Vt()(e)}function Sn(){const e=Oe(),{data:s}=E.useSuspenseQuery({queryKey:Te.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:n})=>v.sortWith([v.descend(({chain_name:r})=>r==="initia"),v.ascend(({pretty_name:r})=>r)],n),staleTime:U.MINUTE});return s}function mt(){const e=Sn();return s=>{const n=e.find(r=>r.chain_id===s);if(!n)throw new Error(`Chain not found: ${s}`);return n}}function Ee(e){return mt()(e)}function It(e){const s=Oe(),n=E.useQueryClient(),{data:r}=E.useSuspenseQuery({queryKey:Te.assets(e).queryKey,queryFn:()=>s.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:o})=>{const{assets:a}=o[e]??{assets:[]};for(const i of a)n.setQueryData(Te.asset(e,i.denom).queryKey,i);return a.toSorted(v.descend(i=>i.symbol==="INIT"))},staleTime:U.MINUTE});return r}function Wr(e){const s=It(e);return n=>{const r=s.find(o=>o.denom===n);if(!r)throw new Error(`Asset not found: ${n}`);return r}}function Be(e,s){return Wr(s)(e)}const kn=f.createContext(null);function dt(){const{container:e}=f.useContext(kn);return e}function Qr(e){const s=dt();return s?getComputedStyle(s).getPropertyValue(e):""}const Ra=({children:e})=>{const[s,n]=f.useState(null);return t.jsx(kn.Provider,{value:{container:s,setContainer:n},children:e})},Ba="_loader_4gdsk_1",Ma={loader:Ba},_t=({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:Ma.loader,style:r})},Fa="_container_1zg8z_1",Oa="_toast_1zg8z_10",La="_info_1zg8z_23",Ua="_success_1zg8z_27",za="_error_1zg8z_31",Ka="_icon_1zg8z_36",Ha="_content_1zg8z_43",Wa="_title_1zg8z_46",Qa="_description_1zg8z_51",Va="_close_1zg8z_72",He={container:Fa,toast:Oa,info:La,success:Ua,error:za,icon:Ka,content:Ha,title:Wa,description:Qa,close:Va},Ga=({notification:e,onClose:s,...n})=>{const r=Je.useTransition(e,{keys:a=>a?.id||"empty",from:{transform:"translateY(-52px)",opacity:0},enter:{transform:"translateY(0px)",opacity:1},leave:{transform:"translateY(-52px)",opacity:0},config:{tension:500,friction:30,clamp:!0}}),o=a=>{switch(a){case"loading":return t.jsx(_t,{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(Je.animated.div,{style:a,className:He.container,children:t.jsxs("div",{className:R(He.toast,l&&He[l]),...n,children:[u&&t.jsx("div",{className:He.icon,children:u}),t.jsxs("div",{className:He.content,children:[t.jsx("p",{className:He.title,children:c}),d&&t.jsx("div",{className:He.description,children:d})]}),t.jsx("button",{className:He.close,onClick:s,children:t.jsx(A.IconClose,{size:14})})]})})})},Vr=f.createContext(null),An=()=>f.useContext(Vr),zs=5e3,Ya=({children:e})=>{const s=dt(),[n,r]=f.useState(null),o=f.useRef(null),a=f.useRef(!1),i=()=>{o.current&&(clearTimeout(o.current),o.current=null)},l=f.useCallback(()=>{i(),r(null)},[]),c=f.useCallback(m=>{i(),r({...m,id:Fn.nanoid()}),m.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),zs))},[l]),d=f.useCallback(m=>{i(),r(_=>_?{..._,...m}:{...m,id:Fn.nanoid()}),m.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),zs))},[l]),u=()=>{i(),a.current=!0},h=()=>{i(),a.current=!1,n?.autoHide&&(o.current=setTimeout(()=>l(),zs))};return f.useEffect(()=>()=>i(),[]),t.jsxs(Vr.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,s&&Lo.createPortal(t.jsx(Ga,{notification:n,onClose:l,onMouseEnter:u,onMouseLeave:h}),s)]})},Gr=f.createContext(!1),Ja="_overlay_2lgi8_1",Za="_fullscreen_2lgi8_15",Xa="_content_2lgi8_19",ei="_header_2lgi8_54",ti="_title_2lgi8_63",si="_close_2lgi8_68",st={overlay:Ja,fullscreen:Za,content:Xa,header:ei,title:ti,close:si},Yr=({title:e,children:s,trigger:n,className:r,open:o,onOpenChange:a})=>{const i=dt(),l=f.useContext(Gr);return i?t.jsxs(we.Dialog.Root,{open:o,onOpenChange:a,modal:"trap-focus",children:[n&&t.jsx(we.Dialog.Trigger,{className:r,children:n}),t.jsxs(we.Dialog.Portal,{container:i,children:[t.jsx(we.Dialog.Backdrop,{className:R(st.overlay,{[st.fullscreen]:l}),onClick:()=>a(!1),forceRender:!0}),t.jsxs(we.Dialog.Popup,{className:R(st.content,{[st.fullscreen]:l}),children:[e&&t.jsxs("header",{className:st.header,children:[t.jsx(we.Dialog.Title,{className:st.title,children:e}),t.jsx(we.Dialog.Close,{className:st.close,children:t.jsx(A.IconClose,{size:20})})]}),s]})]})]}):null},ni=10;function Jr(){const e=ne();return(s,n)=>E.queryOptions({queryKey:As.txs(s.indexerUrl,e).queryKey,queryFn:async()=>{if(!n.enabled)return[];const r={"pagination.reverse":!0,"pagination.limit":ni},{txs:o}=await Z.create({prefixUrl:s.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:r}).json();return o},staleTime:U.SECOND})}function ri(e,s){const n=Jr();return E.useSuspenseQuery(n(e,s))}function oi(e,s){const n=e.flatMap((r,o)=>(s[o]??[]).map(i=>({...i,chain:r})));return v.sortWith([v.descend(r=>new Date(r.timestamp).getTime())])(n)}const ai=()=>{const e=se(),s=Jr(),n=E.useQueries({queries:e.map(i=>s(i,{enabled:!0}))}),r=n.map(v.prop("data")),o=oi(e,r),a=n.some(i=>i.isLoading);return{activities:o,isLoading:a}};function Zr(e){const{data:s}=E.useSuspenseQuery({queryKey:vn.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:r}=await Z.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return r.toSorted(v.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const i=o==="uinit"?1:xr;return{amount:M(a).times(i).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:r})=>{if(v.isNil(r))throw new Error(`${n} has no price`);return{amount:String(r),denom:n}})},staleTime:U.SECOND});return s}function Xr(e){const s=ne(),{data:n}=ri(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const r=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return r;try{return n.find(({tx:a})=>a.auth_info.signer_infos.some(i=>N.InitiaAddress.equals(s,Ye.computeAddress(`0x${H.toHex(an.Secp256k1.uncompressPubkey(H.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??r}catch{return r}}const ii="_root_hypwm_1",ci="_item_hypwm_10",li="_chevron_hypwm_14",di="_trigger_hypwm_19",ui="_content_hypwm_39",Dt={root:ii,item:ci,chevron:li,trigger:di,content:ui};function hi(e){const{list:s,getKey:n,renderHeader:r,renderContent:o,footer:a,...i}=e;return t.jsxs(G.Accordion.Root,{className:Dt.root,type:"multiple",...i,children:[s.map((l,c)=>t.jsxs(G.Accordion.Item,{className:Dt.item,value:n?.(l)??String(c),children:[t.jsx(G.Accordion.Header,{children:t.jsxs(G.Accordion.Trigger,{className:Dt.trigger,children:[r(l),t.jsx(A.IconChevronDown,{className:Dt.chevron,size:16})]})}),t.jsx(G.Accordion.Content,{className:Dt.content,children:o(l)})]},n?.(l)??c)),a]})}const mi="_scrollable_abvhw_1",_i={scrollable:mi},Le=({className:e,children:s,ref:n})=>t.jsx("div",{ref:n,className:R(_i.scrollable,e),children:s}),ln=({children:e})=>{const s=f.useRef(null),[n,r]=f.useState(0),o=Je.useSpring({height:n,config:{tension:500,friction:30,clamp:!0}});return f.useEffect(()=>{if(s.current){const{height:a}=s.current.getBoundingClientRect();r(a)}},[e]),e?t.jsx(Je.animated.div,{style:{overflow:"hidden",...o},children:t.jsx("div",{ref:s,children:e})}):null},fi="_help_7m3jv_1",pi="_icon_7m3jv_10",gi="_info_7m3jv_17",xi="_warning_7m3jv_21",yi="_error_7m3jv_25",ji="_success_7m3jv_31",Ks={help:fi,icon:pi,info:gi,warning:xi,error:yi,success:ji},Qe=({level:e,className:s,mt:n=8,children:r})=>{if(!r)return null;const o=()=>{switch(e){case"loading":return t.jsx(_t,{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:R(Ks.help,e&&Ks[e],s),style:{marginTop:n},children:[t.jsx("div",{className:Ks.icon,children:o()}),t.jsx("p",{children:r})]})},vi="_stack_14kq8_1",bi="_help_14kq8_6",wi="_info_14kq8_14",Ci="_warning_14kq8_19",Ii="_error_14kq8_24",Ni="_success_14kq8_29",dn={stack:vi,help:bi,info:wi,warning:Ci,error:Ii,success:Ni},Si=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(ln,{children:t.jsx("div",{className:dn.stack,children:e})}),ee=e=>t.jsx(Qe,{...e,className:R(dn.help,dn[e.level]),mt:0});ee.Stack=Si;const ki="_footer_xif7g_1",Ai="_actions_xif7g_10",Kn={footer:ki,actions:Ai},te=({extra:e,className:s,children:n})=>t.jsxs("footer",{className:R(Kn.footer,s),children:[e,t.jsx("div",{className:Kn.actions,children:n})]}),$i="_button_1n7c4_1",Ti="_outline_1n7c4_25",Ei="_sm_1n7c4_43",qi="_full_1n7c4_49",Di="_small_1n7c4_53",Pi="_unpadded_1n7c4_83",it={button:$i,outline:Ti,sm:Ei,full:qi,small:Di,unpadded:Pi},eo=e=>{const{sm:s,fullWidth:n,loading:r,className:o,children:a,disabled:i,...l}=e;return t.jsx("button",{...l,className:R(it.button,{[it.sm]:s,[it.full]:n},o),disabled:!!r||i,children:r?t.jsxs(t.Fragment,{children:[t.jsx(_t,{color:"currentColor",size:16}),typeof r=="string"&&t.jsx("span",{className:it.loading,children:r})]}):a})},Ri=({className:e,...s})=>t.jsx(eo,{...s,className:R(it.outline,e)}),Bi=({className:e,unpadded:s,...n})=>t.jsx("button",{...n,className:R(it.small,{[it.unpadded]:s},e)}),W={White:eo,Outline:Ri,Small:Bi},Mi="_item_1n572_1",Fi="_title_1n572_10",Oi="_content_1n572_14",Hs={item:Mi,title:Fi,content:Oi},Ws=({title:e,content:s})=>t.jsxs("div",{className:Hs.item,children:[t.jsx("div",{className:Hs.title,children:e}),t.jsx("div",{className:Hs.content,children:s})]});function Me(e){if(e&&M(e).gt(0)&&M(e).lt(.01))return"<$0.01";const s=N.formatNumber(e,{dp:2});return s?`$${s}`:""}const Li="_placeholder_yluz4_1",Ui="_logo_yluz4_5",Hn={placeholder:Li,logo:Ui},z=({src:e,alt:s,placeholder:n,classNames:r,style:o,logo:a,...i})=>{const[l,c]=f.useState(!1),{width:d,height:u}=i,h=n??t.jsx("div",{className:R(Hn.placeholder,r?.placeholder),style:{width:d,height:u,...o}});return f.useEffect(()=>{c(!1)},[e]),!e||l?h:t.jsx("img",{...i,className:R(i.className,{[Hn.logo]:a}),style:{width:d,height:u,...o},src:e,alt:s,loading:"lazy",onError:()=>c(!0)})};function to(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 so(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&&N.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&&N.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 no=({metadata:e,chain:s,children:n})=>{const{restUrl:r}=s,{data:o}=E.useSuspenseQuery({queryKey:ms.denom(r,e).queryKey,queryFn:()=>Z.create({prefixUrl:r}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:a})=>a,staleTime:U.INFINITY});return n(o)},zi="_root_jioyr_1",Ki="_title_jioyr_7",Hi="_changes_jioyr_13",Wi="_change_jioyr_13",Qi="_amount_jioyr_34",Vi="_text_jioyr_40",Gi="_value_jioyr_47",ct={root:zi,title:Ki,changes:Hi,change:Wi,amount:Qi,text:Vi,value:Gi},ro=({amount:e,asset:s,price:n})=>{const{denom:r,symbol:o,decimals:a,logoUrl:i}=s,l=N.formatAmount(e,{decimals:a}),c=n&&M(N.fromBaseUnit(e,{decimals:a})).times(n).abs();return t.jsxs("div",{className:ct.change,children:[t.jsxs("div",{className:ct.amount,children:[t.jsx(z,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:ct.text,children:[l," ",o||r]})]}),c&&t.jsx("div",{className:ct.value,children:Me(c)})]})},Yi=({changes:e,chain:s})=>{const n=Xe(s),{data:r}=Cs(s);return e.map(({amount:o,denom:a},i)=>{const l=n(a),c=r?.find(({id:d})=>d===a)?.price;return t.jsx(ro,{amount:o,asset:l,price:c},i)})},Ji=({changes:e,chain:s})=>{const n=Xe(s),{data:r}=Cs(s);return e.map(({amount:o,metadata:a},i)=>t.jsx(no,{metadata:a,chain:s,children:l=>{const c=r?.find(({id:d})=>d===l)?.price;return t.jsx(ro,{amount:o,asset:n(l),price:c})}},i))};function Zi(e,s){return typeof s=="bigint"?s.toString():s}const Xi=qe.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Zi)]}),ec=({messages:e,memo:s,chainId:n})=>{const{initiaAddress:r,hexAddress:o}=je(),a=Fe(n),{simulateTx:i}=Rr(),{data:l}=E.useSuspenseQuery({queryKey:Xi.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:ct.root,children:[t.jsx("h2",{className:ct.title,children:"Estimated changes"}),t.jsx("div",{className:ct.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=so(d,o),[_]=Wn(m);return _.length===0?null:c(t.jsx(Ji,{changes:_,chain:a}))}const u=to(d,r),[h]=Wn(u);return h.length===0?null:c(t.jsx(Yi,{changes:h,chain:a}))};function Wn(e){return v.partition(s=>new M(s.amount).isNegative(),e)}const tc="_value_9u3br_1",sc="_trigger_9u3br_7",nc="_icon_9u3br_23",rc="_content_9u3br_32",oc="_item_9u3br_40",Pt={value:tc,trigger:sc,icon:nc,content:rc,item:oc},ac=({options:e,value:s,onChange:n})=>{const r=dt(),{txRequest:o}=Pr(),a=Fe(o.chainId),i=Xe(a),l=({amount:[{amount:_,denom:p}]})=>{if(M(_).isZero())return"0";const{symbol:g,decimals:b}=i(p);return`${N.formatAmount(_,{decimals:b})} ${g}`};if(e.length===1)return l(e[0]);const c=e.find(_=>_.amount[0].denom===s);if(!c)throw new Error("Fee option not found");const[{amount:d,denom:u}]=c.amount,{decimals:h,symbol:m}=i(u);return t.jsxs(De.Select.Root,{value:s,onValueChange:n,modal:!1,children:[t.jsxs("div",{className:Pt.value,children:[t.jsx("span",{className:"monospace",children:N.formatAmount(d,{decimals:h})}),t.jsxs(De.Select.Trigger,{className:Pt.trigger,children:[t.jsx(De.Select.Value,{children:m}),t.jsx(De.Select.Icon,{className:Pt.icon,children:t.jsx(A.IconChevronDown,{size:16})})]})]}),t.jsx(De.Select.Portal,{container:r,children:t.jsx(De.Select.Positioner,{className:Pt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(De.Select.Popup,{children:e.map(_=>{const[{denom:p}]=_.amount;return t.jsx(De.Select.Item,{className:Pt.item,value:p,children:t.jsx(De.Select.ItemText,{children:l(_)})},p)})})})})]})};function _s(e){switch(typeof e){case"string":return e;case"number":case"bigint":return e.toString();case"boolean":return e?"true":"false";case"object":return e===null?"null":e instanceof Uint8Array?H.toBase64(e):Array.isArray(e)?`[${e.map(_s).join(",")}]`:JSON.stringify(e,(s,n)=>typeof n=="bigint"?n.toString():n);default:return"unknown"}}const ic="_container_1xzyq_1",cc="_toggle_1xzyq_5",lc="_list_1xzyq_11",dc="_arg_1xzyq_16",uc="_type_1xzyq_21",Rt={container:ic,toggle:cc,list:lc,arg:dc,type:uc},hc=qe.createQueryKeys("interwovenkit:move",{abi:(e,s,n,r)=>[e,s,n,r]}),mc=({type:e,arg:s})=>_s(N.resolveBcsType(e).parse(s)),_c=({msg:e,chainId:s,fallback:n})=>{const[r,o]=Ce.useToggle(!1),{restUrl:a}=Fe(s),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=E.useQuery({queryKey:hc.abi(a,i,l,c).queryKey,queryFn:async()=>{const m=await Z.create({prefixUrl:a}).get(`initia/move/v1/accounts/${i}/modules/${l}`).json(),p=JSON.parse(m.module.abi).exposed_functions.find(({name:g})=>g===c);if(!p)throw new Error(`Function ${c} not found in module ${l}`);return p.params.filter(g=>!g.startsWith("&"))},staleTime:U.INFINITY});if(!u)return n;const h=(m,_)=>{const p=u[_];return t.jsxs("div",{className:Rt.arg,children:[t.jsx("div",{className:Rt.type,children:p}),t.jsx(pr.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(mc,{type:p,arg:m})})]},_)};return t.jsxs("div",{className:Rt.container,children:[t.jsx(W.Small,{className:Rt.toggle,onClick:o,disabled:!u,children:r?"Encode":"Decode"}),r?t.jsx("div",{className:Rt.list,children:d.map(h)}):n]})},fc="_list_r67rl_1",pc="_key_r67rl_8",gc="_value_r67rl_13",Qs={list:fc,key:pc,value:gc},xc=({message:e,chainId:s})=>{const{typeUrl:n,value:r}=e;return t.jsx("div",{className:Qs.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{children:[t.jsx("div",{className:Qs.key,children:o}),t.jsx("div",{className:Qs.value,children:n==="/initia.move.v1.MsgExecute"&&o==="args"?t.jsx(_c,{msg:r,chainId:s,fallback:_s(a)}):_s(a)})]},o))})},yc="_title_kspdu_1",jc="_meta_kspdu_7",vc="_footer_kspdu_14",Vs={title:yc,meta:jc,footer:vc},oo=()=>{const{txRequest:e,resolve:s,reject:n}=Pr(),{messages:r,memo:o,chainId:a,gas:i,gasAdjustment:l,spendCoins:c}=e,d=ne(),u=St(),h=bn(),m=Fe(a),_=Cn(m),p=Zr(m),g=Xr(m),b=(e.gasPrices??p).map(({amount:x,denom:w})=>$e.calculateFee(Math.ceil(i*l),$e.GasPrice.fromString(x+w))),k=b.map(x=>x.amount[0]),S=x=>{const w=_.find(C=>C.denom===x)?.amount??0,y=k.find(C=>C.denom===x)?.amount??0,q=c.filter(C=>C.denom===x).reduce((C,F)=>M(C).plus(F.amount),M(0));if(q.gt(0)){const C=M(y).plus(q);return M(w).gte(C)}return M(w).gte(y)},T=()=>{if(g&&S(g))return g;for(const{denom:x}of k)if(S(x))return x;return k[0]?.denom},[j,D]=f.useState(T),{mutate:B,isPending:P}=E.useMutation({mutationKey:[qr],mutationFn:async()=>{const x=b.find(y=>y.amount[0].denom===j);if(!x)throw new Error("Fee not found");if(!u)throw new Error("Signer not initialized");const w=await h(a,d,r,x,o);await s(w)},onError:async x=>{n(x)}}),I=!S(j);return t.jsxs(t.Fragment,{children:[t.jsxs(Le,{children:[t.jsx("h1",{className:Vs.title,children:"Confirm tx"}),t.jsxs("div",{className:Vs.meta,children:[t.jsx(Ws,{title:"Chain",content:a}),t.jsx(Ws,{title:"Tx fee",content:t.jsx(ac,{options:b,value:j,onChange:D})}),o&&t.jsx(Ws,{title:"Memo",content:o}),I&&t.jsx(ee,{level:"error",children:"Insufficient balance for fee"})]}),t.jsx(ec,{messages:r,memo:o,chainId:a}),t.jsx(hi,{list:r,renderHeader:({typeUrl:x})=>ys.sentenceCase(x.split(".").pop().replace(/^Msg/,"")),renderContent:x=>t.jsx(xc,{message:x,chainId:a})})]}),t.jsxs(te,{className:Vs.footer,children:[t.jsx(W.Outline,{onClick:()=>n(new Error("User rejected")),disabled:P,children:"Reject"}),t.jsx(W.White,{onClick:()=>B(),disabled:I,loading:P,children:"Approve"})]})]})},bc=({children:e})=>{const[{title:s,content:n,path:r},o]=f.useState({}),[a,i]=f.useState(!1),l=Q.useAtomValue(ks),c=f.useCallback(h=>{o(h),i(!0)},[]),d=f.useCallback(()=>{o({}),i(!1)},[]),u=f.useCallback(h=>{h||(l?.reject(new Error("User rejected")),o({})),i(h)},[l]);return t.jsxs(Cr.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(Yr,{title:s,open:a,onOpenChange:u,children:t.jsx(ue,{children:r==="/tx"?t.jsx(oo,{}):n})})]})},wc=()=>(ma(),_a(),null);function Ts(){return Ce.useMediaQuery("(max-width: 576px)")}const un="interwoven-kit";function ao(){const e=document.querySelector(un)||document.body.appendChild(document.createElement(un));return e.shadowRoot||e.attachShadow({mode:"open"})}function Cc(){const{theme:e,container:s}=ce();return f.useEffect(()=>{document.querySelector(un)?.setAttribute("data-theme",e)},[e]),s??ao()}function Ic(e){const s=ao(),n=document.createElement("style");n.textContent=e,s.appendChild(n)}const ut=({title:e,content:s,children:n,className:r})=>{const[o,a]=f.useState(!1),i=()=>a(!1);return t.jsx(Yr,{title:e,trigger:n,className:r,open:o,onOpenChange:a,children:s(i)})},fs=({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})},Nc="_root_19tvg_1",Sc="_address_19tvg_9",kc="_copy_19tvg_19",Ac="_labelWrapper_19tvg_33",$c="_labelCopy_19tvg_43",Tc="_labelCopied_19tvg_47",Ec="_copied_19tvg_55",qc="_derived_19tvg_65",Dc="_derivedLabel_19tvg_78",Pc="_derivedAddress_19tvg_82",Rc="_hexAddress_19tvg_88",Bc="_derivedCopy_19tvg_93",oe={root:Nc,address:Sc,copy:kc,labelWrapper:Ac,labelCopy:$c,labelCopied:Tc,copied:Ec,derived:qc,derivedLabel:Dc,derivedAddress:Pc,hexAddress:Rc,derivedCopy:Bc},Mc=()=>{const e=f.useRef(null),s=f.useRef(null),{initiaAddress:n,hexAddress:r}=je(),o=Qr("--gray-0");return f.useEffect(()=>{e.current&&(s.current?s.current.update({data:n}):(s.current=new Uo({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:oe.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:oe.address,children:n}),t.jsx(fs,{value:n,children:({copy:a,copied:i})=>t.jsxs("button",{className:R(oe.copy,{[oe.copied]:i}),onClick:a,children:[t.jsx(A.IconCopy,{size:12}),t.jsxs("div",{className:oe.labelWrapper,children:[t.jsx("span",{className:oe.labelCopy,children:"Copy address"}),t.jsx("span",{className:oe.labelCopied,children:"Copied!"})]})]})}),t.jsx(fs,{value:r,children:({copy:a,copied:i})=>t.jsxs("button",{className:R(oe.derived,{[oe.copied]:i}),onClick:a,children:[t.jsx("span",{className:oe.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:oe.derivedAddress,children:[t.jsx("span",{className:oe.hexAddress,children:N.truncate(r)}),t.jsx(A.IconCopy,{size:12,className:oe.derivedCopy}),i&&t.jsx("span",{className:oe.copiedText,children:"Copied!"})]})]})})]})},Fc="_header_1cvtq_1",Oc="_account_1cvtq_16",Lc="_name_1cvtq_27",Uc="_address_1cvtq_31",zc="_icon_1cvtq_35",Kc="_copied_1cvtq_42",Hc="_button_1cvtq_57",Wc="_qr_1cvtq_68",Qc="_disconnect_1cvtq_72",Vc="_label_1cvtq_82",Gc="_expanded_1cvtq_90",_e={header:Fc,account:Oc,name:Lc,address:Uc,icon:zc,copied:Kc,button:Hc,qr:Wc,disconnect:Qc,label:Vc,expanded:Gc},Yc=()=>{const e=Qt(),{connector:s}=xe.useAccount(),n=Er(),{address:r,username:o}=je(),a=o??r,[i,l]=f.useState(!1),c=f.useRef(null),d=Je.useSpring({width:i?140:52,config:{tension:500,friction:30,clamp:!0}}),u=()=>{i?n():l(!0)},h=()=>{i&&(c.current=setTimeout(()=>{l(!1)},500))},m=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return f.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),s?t.jsxs("header",{className:_e.header,children:[t.jsx(fs,{value:r,children:({copy:_,copied:p})=>t.jsxs("button",{className:R(_e.account,{[_e.copied]:p}),onClick:_,children:[t.jsx(z,{src:s.icon,width:18,height:18}),t.jsx("div",{className:_e.address,children:N.truncate(r)}),t.jsx("div",{className:_e.name,children:N.truncate(a)}),t.jsx(A.IconCopy,{className:_e.icon,size:12}),p?"Copied!":""]})}),e.metadata?.is_l1&&t.jsx(ut,{title:"Initia address",content:()=>t.jsx(Mc,{}),className:R(_e.button,_e.qr),children:t.jsx(A.IconQrCode,{size:16})}),t.jsxs(Je.animated.button,{className:R(_e.button,_e.disconnect,{[_e.expanded]:i}),style:d,onClick:u,onMouseLeave:h,onMouseEnter:m,children:[t.jsx(A.IconSignOut,{size:16}),t.jsx("span",{className:_e.label,children:"Disconnect"})]})]}):null};function Jc(e){return/^[A-F0-9]{64}$/i.test(e)}function Zc(e,s){const{txHash:n,accountAddress:r,pathSuffix:o}=s;if(n)return Jc(n)?v.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,n):void 0;if(r){if(!N.InitiaAddress.validate(r))return;const i=v.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,r);return i&&o?i+o:i}}function Xc(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 el="_link_guafb_1",Qn={link:el},Es=({chainId:e,txHash:s,accountAddress:n,pathSuffix:r,...o})=>{const{showIcon:a,className:i,children:l,onClick:c,...d}=o,u=Fe(e),h=Zc(u,{txHash:s,accountAddress:n,pathSuffix:r}),m=s?N.truncate(s):n?N.truncate(n):"",_=l??m;return h?t.jsxs("a",{...d,href:zo(Xc(h)),className:R(Qn.link,i),onClick:c,target:"_blank",children:[_,a&&t.jsx(A.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:R(Qn.link,i),children:_})},tl=()=>{const[e,s]=Q.useAtom(Dr),{showNotification:n,updateNotification:r,hideNotification:o}=An();return f.useEffect(()=>{if(!e)return;const{status:a,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(Es,{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 sl(){return Ce.useScrollLock(),null}const nl="_overlay_1dhd9_1",rl="_content_1dhd9_27",ol="_inner_1dhd9_58",Gs={overlay:nl,content:rl,inner:ol},al=({children:e})=>{const{isDrawerOpen:s,closeDrawer:n}=kt(),{setContainer:r}=f.useContext(kn),o=Ts(),a=Cc(),i=Q.useAtomValue(ks),l=E.useIsMutating({mutationKey:[qr]}),c=()=>{const _=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";n(),i?.reject(new Error(_))},d=bs(),u=ie(),h=E.useQueryClient(),m={fallbackRender:({error:_,resetErrorBoundary:p})=>{const g=()=>{d==="/bridge"&&(localStorage.removeItem(O.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(O.BRIDGE_SRC_DENOM),localStorage.removeItem(O.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(O.BRIDGE_DST_DENOM)),u("/"),h.clear(),p()};return t.jsxs(Le,{children:[t.jsx(J,{error:!0,children:_.message}),t.jsx(te,{children:t.jsx(W.White,{onClick:g,children:"Retry"})})]})}};return t.jsx(we.Dialog.Root,{open:s,onOpenChange:_=>!_&&c(),modal:!1,children:t.jsxs(we.Dialog.Portal,{container:a,children:[o&&t.jsx(we.Dialog.Backdrop,{className:Gs.overlay,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:Gs.content,children:t.jsxs("div",{className:R(Gs.inner,"body"),ref:r,children:[o&&t.jsx(sl,{}),t.jsx(tl,{}),t.jsx(Yc,{}),t.jsx(ue,{errorBoundaryProps:m,children:e})]})})]})})},il="_page_1f6wh_1",cl="_title_1f6wh_10",ll="_scrollable_1f6wh_17",dl="_list_1f6wh_22",ul="_item_1f6wh_32",hl="_name_1f6wh_56",ml="_dimmed_1f6wh_64",_l="_recent_1f6wh_68",fl="_installed_1f6wh_69",ve={page:il,title:cl,scrollable:ll,list:dl,item:ul,name:hl,dimmed:ml,recent:_l,installed:fl},pl=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],Vn=({onSuccess:e})=>{const{connectors:s,connectAsync:n}=xe.useConnect(),r=Ce.useReadLocalStorage("wagmi.recentConnectorId"),[o,a]=f.useState(null),{mutate:i,isPending:l}=E.useMutation({mutationFn:async c=>{a(c.id);try{await n({connector:c})}catch(d){throw await Re(d)}},onSettled:()=>{a(null)},onSuccess:()=>{e?.()}});return t.jsxs("div",{className:ve.page,children:[t.jsx("h1",{className:ve.title,children:"Connect wallet"}),t.jsx(Le,{className:ve.scrollable,children:t.jsxs("div",{className:ve.list,children:[s.toSorted(v.descend(c=>c.id===r)).map(c=>{const{name:d,icon:u,id:h}=c;return t.jsxs("button",{className:ve.item,onClick:()=>i(c),disabled:l,children:[t.jsx(z,{src:u,width:24,height:24}),t.jsx("span",{className:ve.name,children:d}),o===h?t.jsx(_t,{size:16}):r===h?t.jsx("span",{className:ve.recent,children:"Recent"}):c.id===js.id?null:t.jsx("span",{className:ve.installed,children:"Installed"})]},h)}),pl.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(z,{src:u,width:24,height:24}),t.jsx("span",{className:R(ve.name,ve.dimmed),children:c}),t.jsx(A.IconExternalLink,{size:10})]},c)})]})})]})},gl="_root_xwz5z_1",xl="_header_xwz5z_6",yl="_title_xwz5z_12",jl="_warning_xwz5z_18",vl="_content_xwz5z_22",bl="_footer_xwz5z_26",wl="_secondary_xwz5z_36",nt={root:gl,header:xl,title:yl,warning:jl,content:vl,footer:bl,secondary:wl},io=e=>{const{type:s,icon:n,title:r,children:o,primaryButton:a,secondaryButton:i}=e;return t.jsxs(Le,{className:nt.root,children:[t.jsxs("header",{className:R(nt.header,s&&nt[s]),children:[n,t.jsx("h1",{className:nt.title,children:r})]}),t.jsx("div",{className:nt.content,children:o}),t.jsxs("footer",{className:nt.footer,children:[t.jsx(W.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),t.jsxs("button",{className:nt.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(A.IconChevronRight,{size:14})]})]})]})},Cl="_list_tmcxc_1",Il="_row_tmcxc_8",Nl="_dt_tmcxc_19",Sl="_asset_tmcxc_25",ss={list:Cl,row:Il,dt:Nl,asset:Sl},kl=({list:e,onNavigate:s,onDismiss:n})=>{const r=ye(),o=Ze(),a=Xe(r);return t.jsx(io,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:s},secondaryButton:{label:"Do not show again",onClick:n},children:t.jsx("div",{className:ss.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),_=N.formatAmount(c,{decimals:h});return t.jsxs("div",{className:ss.row,children:[t.jsxs("div",{className:ss.dt,children:[t.jsx(z,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:ss.asset,children:[_," ",m]})]},i)})})})};function Ys(e,s){return e.chainId===s.chainId&&e.txHash===s.txHash}const ns=({chainId:e,txHash:s})=>`${O.OP_REMINDER}:${e}:${s}`,Al=Ko.atomWithStorage(O.OP_REMINDER,[]);function $t(){const e=ne(),[s=[],n]=Q.useAtom(Al),r=f.useMemo(()=>s.map(c=>{const d=localStorage.getItem(ns(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:Nt.isPast(u)}),[e,s]),o=f.useCallback((c,d)=>{s.some(u=>Ys(u,c))||(n((u=[])=>[...u,c]),localStorage.setItem(ns(c),JSON.stringify(d)))},[s,n]),a=f.useCallback(c=>{n((d=[])=>d.filter(u=>!Ys(u,c))),localStorage.removeItem(ns(c))},[n]),i=f.useCallback(c=>{const d=c.filter(u=>!s.some(h=>Ys(h,u)));d.length!==0&&n((u=[])=>[...u,...d])},[s,n]),l=f.useCallback((c,d)=>{localStorage.setItem(ns(c),JSON.stringify(d)),n((u=[])=>[...u])},[n]);return{reminders:r,addReminder:o,removeReminder:a,syncReminders:i,setReminder:l}}function co(){const e=ie(),{openModal:s,closeModal:n}=ws(),{reminders:r,setReminder:o}=$t();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(kl,{list:a,onNavigate:i,onDismiss:l})})},[r,n,e,s,o])}const lo=f.createContext(null);function uo(){return f.useContext(lo)}const $l="_root_7yxgy_1",Tl="_label_7yxgy_7",El="_input_7yxgy_19",ql="_hasValue_7yxgy_29",Dl="_clear_7yxgy_33",Bt={root:$l,label:Tl,input:El,hasValue:ql,clear:Dl},qs=e=>{const{rootClassName:s,padding:n=16,iconSize:r=16,onClear:o,ref:a,...i}=e;return t.jsxs("div",{className:R(Bt.root,s,{[Bt.hasValue]:i.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${r}px`},children:[t.jsx("label",{htmlFor:"search",className:Bt.label,children:t.jsx(A.IconSearch,{size:r})}),t.jsx("input",{className:Bt.input,id:"search",type:"text",maxLength:100,ref:a,...i}),i.value&&t.jsx("button",{type:"button",className:Bt.clear,"aria-label":"Clear search",onMouseDown:l=>l.preventDefault(),onClick:o,children:t.jsx(A.IconCloseCircleFilled,{size:r})})]})},Pl="_container_t1267_1",Rl="_controls_t1267_7",Bl="_search_t1267_13",$n={container:Pl,controls:Rl,search:Bl},Ml=({children:e})=>t.jsx("div",{className:$n.container,children:e}),Fl=({children:e})=>t.jsx("div",{className:$n.controls,children:e}),Ol=e=>t.jsx(qs,{...e,rootClassName:$n.search}),Ge={Root:Ml,Controls:Fl,SearchInput:Ol};function Gt(){const e=f.useRef(null),s=Ts();return f.useEffect(()=>{s||e.current?.focus()},[s]),e}const Ll="_trigger_386xl_1",Ul="_icon_386xl_21",zl="_full_386xl_25",Kl="_triggerContent_386xl_30",Hl="_triggerText_386xl_38",Wl="_popoverBackdrop_386xl_49",Ql="_popoverPositioner_386xl_84",Vl="_popoverPopup_386xl_88",Gl="_search_386xl_131",Yl="_viewport_386xl_136",Jl="_item_386xl_141",Zl="_highlighted_386xl_155",Xl="_itemContent_386xl_160",ae={trigger:Ll,icon:Ul,full:zl,triggerContent:Kl,triggerText:Hl,popoverBackdrop:Wl,popoverPositioner:Ql,popoverPopup:Vl,search:Gl,viewport:Yl,item:Jl,highlighted:Zl,itemContent:Xl},Tn=({value:e,onChange:s,chainIds:n,fullWidth:r})=>{const[o,a]=f.useState(""),[i,l]=f.useState(!1),[c,d]=f.useState(0),[u,h]=f.useState(),m=f.useRef([]),_=f.useRef(null),p=se(),g=n.map(x=>p.find(w=>w.chainId===x)).filter(Boolean),b=x=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:x,height:x,viewBox:"0 0 14 14",children:[t.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),t.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),k=f.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),S=f.useMemo(()=>{const x=[k,...g];if(!o)return x;const w=o.toLowerCase();return x.filter(y=>y.name.toLowerCase().includes(w)||y.chainId.toLowerCase().includes(w))},[g,o,k]),T=g.find(x=>x.chainId===e)||k,j=parseInt(Qr("--drawer-offset")),D=6,B=()=>{if(a(""),d(-1),_.current){const w=_.current.getBoundingClientRect().bottom+D,y=window.innerHeight-w-2*j;h(y)}l(!0)};f.useEffect(()=>{c>=0&&c<m.current.length&&m.current[c]?.scrollIntoView({block:"nearest",behavior:"auto"})},[c]);const P=f.useCallback(x=>{switch(x.key){case"ArrowDown":x.preventDefault(),d(w=>(w+1)%S.length);break;case"ArrowUp":x.preventDefault(),d(w=>(w-1+S.length)%S.length);break;case"Enter":x.preventDefault(),S[c]&&(s(S[c].chainId),l(!1));break;case"Escape":x.preventDefault(),l(!1);break}},[S,c,s,l]),I=x=>{s(x),l(!1)};return t.jsxs(jt.Popover.Root,{open:i,onOpenChange:B,modal:"trap-focus",children:[t.jsx(jt.Popover.Trigger,{render:t.jsxs("button",{className:R(ae.trigger,{[ae.full]:r}),"aria-expanded":i,role:"listbox",ref:_,children:[t.jsxs("div",{className:ae.triggerContent,children:[typeof T.logoUrl=="string"?t.jsx(z,{src:T.logoUrl,width:14,height:14,logo:!0}):T.logoUrl(14),t.jsx("span",{className:ae.triggerText,children:T.name})]}),t.jsx(A.IconChevronDown,{size:16,className:ae.icon})]})}),t.jsxs(jt.Popover.Portal,{container:dt(),children:[t.jsx(jt.Popover.Backdrop,{className:ae.popoverBackdrop,onClick:()=>l(!1)}),t.jsx(jt.Popover.Positioner,{className:ae.popoverPositioner,align:"end",side:"bottom",sideOffset:D,children:t.jsxs(jt.Popover.Popup,{className:R(ae.popoverPopup,{[ae.full]:r}),style:{maxHeight:u},children:[t.jsx(qs,{value:o,onChange:x=>{a(x.target.value),d(0)},onClear:()=>a(""),onKeyDown:P,placeholder:"Search appchains",rootClassName:ae.search,ref:Gt()}),t.jsx("div",{className:ae.viewport,role:"listbox",children:S.length===0?t.jsx(J,{children:"No appchains found"}):S.map(({chainId:x,name:w,logoUrl:y},q)=>t.jsxs("div",{className:R(ae.item,{[ae.highlighted]:q===c}),onClick:()=>I(x),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),I(x))},onMouseEnter:()=>d(q),role:"option","aria-selected":e===x,tabIndex:-1,ref:C=>{C&&(m.current[q]=C)},children:[t.jsxs("div",{className:ae.itemContent,children:[typeof y=="string"?t.jsx(z,{src:y,width:16,height:16,logo:!0}):y(16),t.jsx("span",{children:w})]}),e===x&&t.jsx(A.IconCheck,{size:16})]},x))})]})})]})]})},ed="2.0.4",td="_version_1sf5y_1",sd={version:td},nd=()=>t.jsxs("aside",{className:sd.version,children:["v",ed]}),rd=Q.atom(""),od=Q.atom(""),ad=Q.atom(""),id=Q.atom(""),cd=Q.atom(""),ld="_popup_nbecp_1",dd="_item_nbecp_19",rs={popup:ld,item:dd},ho=({asset:e,children:s})=>{const{denom:n,decimals:r,symbol:o,logoUrl:a,unlisted:i,address:l,chain:c}=e,{chainId:d}=c,[u,h]=f.useState(!1),m=ie(),_=uo(),{showNotification:p}=An(),{defaultChainId:g}=ce(),{evm_chain_id:b}=Qt(),k=xe.useChainId(),{switchChainAsync:S}=xe.useSwitchChain(),{watchAssetAsync:T}=xe.useWatchAsset(),j=()=>{h(!1),m("/send",{denom:n,chain:c})},D=()=>{h(!1),m("/bridge",{srcChainId:d,srcDenom:n,quantity:""})},B=E.useMutation({mutationFn:async()=>{if(!l)throw new Error("Address is required");const P=a;return await S({chainId:Number(b)}),T({type:"ERC20",options:{address:l,symbol:o,decimals:r,image:P}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:P=>{p({type:"error",title:"Asset addition failed",description:P.message})}});return t.jsxs(Ke.Menu.Root,{open:u,onOpenChange:h,modal:!1,children:[t.jsx(Ke.Menu.Trigger,{render:s}),t.jsx(Ke.Menu.Portal,{container:_.current,children:t.jsx(Ke.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(Ke.Menu.Popup,{className:rs.popup,children:[t.jsxs(Ke.Menu.Item,{className:rs.item,onClick:j,children:[t.jsx(A.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(Ke.Menu.Item,{className:rs.item,onClick:D,disabled:i,children:[t.jsx(A.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===g&&b===k&&!!l&&t.jsxs(Ke.Menu.Item,{className:rs.item,onClick:()=>B.mutate(),disabled:B.isPending||B.data,children:[B.data?t.jsx(A.IconCheck,{size:16}):t.jsx(A.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},ud="_images_cj4xz_1",Js={images:ud},Ds=({assetLogoUrl:e,assetLogoSize:s=36,chainLogoUrl:n,chainLogoSize:r=18,chainLogoOffset:o=6,className:a})=>t.jsxs("div",{className:R(Js.images,a),style:{position:"relative"},children:[t.jsx(z,{src:e,width:s,height:s,className:Js.asset,logo:!0}),t.jsx(z,{src:n,width:r,height:r,className:Js.chain,style:{position:"absolute",bottom:0,right:-1*o},logo:!0})]}),hd="_item_knoro_1",md="_info_knoro_22",_d="_images_knoro_28",fd="_name_knoro_32",pd="_value_knoro_38",gd="_amount_knoro_46",xd="_usd_knoro_52",rt={item:hd,info:md,images:_d,name:fd,value:pd,amount:gd,usd:xd},yd=({asset:e})=>{const{amount:s,value:n,logoUrl:r,chain:o}=e,a=N.formatAmount(s,{decimals:e.decimals});return t.jsx(ho,{asset:e,children:t.jsxs("button",{className:rt.item,children:[t.jsxs("div",{className:rt.info,children:[t.jsx(Ds,{assetLogoUrl:r,chainLogoUrl:o.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:rt.images}),t.jsx("span",{className:rt.name,children:o.name})]}),t.jsxs("div",{className:rt.value,children:[t.jsx("span",{className:rt.amount,children:a}),Number(n)>0&&t.jsx("span",{className:rt.usd,children:Me(n)})]})]})})},jd="_container_g5q73_1",vd="_assetItem_g5q73_6",bd="_assetInfo_g5q73_26",wd="_logo_g5q73_32",Cd="_symbol_g5q73_36",Id="_chainName_g5q73_46",Nd="_chainInfos_g5q73_52",Sd="_chainLogos_g5q73_58",kd="_chainLogo_g5q73_58",Ad="_moreChains_g5q73_69",$d="_expandIcon_g5q73_81",Td="_expanded_g5q73_85",Ed="_valueColumn_g5q73_90",qd="_amount_g5q73_99",Dd="_value_g5q73_90",Pd="_collapsibleContent_g5q73_112",Rd="_chainsList_g5q73_142",Y={container:jd,assetItem:vd,assetInfo:bd,logo:wd,symbol:Cd,chainName:Id,chainInfos:Nd,chainLogos:Sd,chainLogo:kd,moreChains:Ad,expandIcon:$d,expanded:Td,valueColumn:Ed,amount:qd,value:Dd,collapsibleContent:Pd,chainsList:Rd},Bd=Q.atom([]),mo=({assetGroup:e})=>{const{symbol:s,logoUrl:n,assets:r}=e,o=r.length===1,[a,i]=Q.useAtom(Bd),l=f.useMemo(()=>Na(e),[e]),c=f.useMemo(()=>In(e),[e]),d=a.includes(s),u=()=>{i(m=>d?v.without([s],m):v.uniq([...m,s]))},h=()=>t.jsxs("button",{className:Y.assetItem,children:[t.jsxs("div",{className:Y.assetInfo,children:[n&&t.jsx(z,{src:n,width:32,height:32,className:Y.logo,logo:!0}),t.jsxs("div",{className:Y.details,children:[t.jsx("div",{className:Y.symbol,children:s}),o?t.jsx("div",{className:Y.chainName,children:r[0].chain.name}):t.jsxs("div",{className:Y.chainInfos,children:[t.jsx("div",{className:Y.chainLogos,children:r.slice(0,5).map(({chain:m})=>t.jsx(z,{src:m.logoUrl,width:16,height:16,className:Y.chainLogo,logo:!0},m.chainId))}),r.length>5&&t.jsxs("span",{className:Y.moreChains,children:["+",r.length-5]}),t.jsx(A.IconChevronDown,{size:16,className:R(Y.expandIcon,{[Y.expanded]:d})})]})]})]}),t.jsxs("div",{className:Y.valueColumn,children:[t.jsx("div",{className:Y.amount,children:N.formatNumber(l,{dp:r[0].unlisted?0:6})}),c>0&&t.jsx("div",{className:Y.value,children:Me(c)})]})]});if(o){const[m]=r;return t.jsx("div",{className:Y.container,children:t.jsx(ho,{asset:m,children:h()})})}return t.jsx("div",{className:Y.container,children:t.jsxs(G.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(G.Collapsible.Trigger,{asChild:!0,children:h()}),t.jsx(G.Collapsible.Content,{className:Y.collapsibleContent,children:t.jsx("div",{className:Y.chainsList,children:r.map(m=>t.jsx(yd,{asset:m},m.chain.chainId))})})]})})},Md="_collapsible_1spkj_1",Fd="_trigger_1spkj_5",Od="_divider_1spkj_20",Ld="_label_1spkj_26",Ud="_chevron_1spkj_31",zd="_content_1spkj_39",Kd="_list_1spkj_43",We={collapsible:Md,trigger:Fd,divider:Od,label:Ld,chevron:Ud,content:zd,list:Kd},Hd=({unlistedAssets:e})=>{const[s,n]=f.useState(!0),r=uo(),o=f.useRef(null),[a,i]=f.useState(0);f.useEffect(()=>{if(o.current){const d=o.current.scrollHeight;i(d)}},[e]);const l=d=>{if(d&&!s&&r?.current){const u=r.current;u.scrollTo({top:u.scrollHeight,behavior:"auto"}),window.setTimeout(()=>{u.scrollTo({top:u.scrollHeight,behavior:"smooth"})},150)}n(d)},c=Je.useSpring({height:s?a:0,opacity:s?1:0,config:{tension:500,friction:30,clamp:!0}});return e.length===0?null:t.jsxs(G.Collapsible.Root,{open:s,onOpenChange:l,className:We.collapsible,children:[t.jsxs(G.Collapsible.Trigger,{className:We.trigger,children:[t.jsx("div",{className:We.divider}),t.jsxs("span",{className:We.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(A.IconChevronDown,{className:We.chevron,size:12,"data-state":s?"open":"closed"}),t.jsx("div",{className:We.divider})]}),t.jsx(G.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(Je.animated.div,{className:We.content,style:c,children:t.jsx("div",{className:We.list,ref:o,children:e.map(d=>t.jsx(mo,{assetGroup:{...d,assets:[d]}},d.denom))})})})]})},Wd="_list_szwvw_1",Qd={list:Wd},Vd=()=>{const[e,s]=Q.useAtom(rd),[n,r]=Q.useAtom(od),{assetGroups:o,unlistedAssets:a,chainsByValue:i,isLoading:l}=Nn(),c=i.filter(({value:h})=>h).map(({chainId:h})=>h),d=f.useMemo(()=>{const h=e?o.filter(_=>{const{symbol:p,assets:g}=_;return p.toLowerCase().includes(e.toLowerCase())||g.some(({denom:b,address:k})=>b.toLowerCase().includes(e.toLowerCase())||k?.toLowerCase().includes(e.toLowerCase()))}):o;return n?h.map(_=>({..._,assets:_.assets.filter(({chain:p})=>p.chainId===n)})).filter(_=>_.assets.length>0):h},[o,e,n]),u=f.useMemo(()=>{const h=e?a.filter(({denom:_,address:p})=>_.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):a;return n?h.filter(({chain:_})=>_.chainId===n):h},[a,e,n]);return l&&o.length===0?t.jsx(J,{children:"Loading assets..."}):!d.length&&!u.length&&!e&&!n&&!l?t.jsx(J,{children:"No assets"}):t.jsxs(t.Fragment,{children:[t.jsxs(Ge.Root,{children:[t.jsxs(Ge.Controls,{children:[t.jsx(Ge.SearchInput,{value:e,onChange:h=>s(h.target.value),onClear:()=>s(""),placeholder:"Search assets"}),t.jsx(Tn,{value:n,onChange:r,chainIds:c})]}),t.jsx("div",{children:d.length===0&&u.length===0?t.jsx(J,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Qd.list,children:d.map(h=>t.jsx(mo,{assetGroup:h},h.symbol))}),t.jsx(Hd,{unlistedAssets:u})]})})]}),t.jsx(nd,{})]})},_o=qe.createQueryKeys("interwovenkit:nft",{nfts:(e,s)=>[e,s],metadata:e=>[e]});function Gd(e,s){const{nft:n}=e,r=s.name??n.token_id;return{...e,...n,...s,name:r}}function Yd(e,s){return e.flatMap((n,r)=>(s[r]??[]).map(a=>({...a,chain:n})))}const Jd=()=>{const e=ne(),s=se(),n=E.useQueries({queries:s.map(i=>({queryKey:_o.nfts(i.indexerUrl,e).queryKey,queryFn:()=>Mr(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:i.indexerUrl},"tokens"),staleTime:U.SECOND}))}),r=n.map(v.prop("data")),o=Yd(s,r),a=n.some(i=>i.isLoading);return{nftInfos:o,isLoading:a}};function Zd(e){const s=Gn(e);return E.useQuery({queryKey:_o.metadata(s).queryKey,queryFn:async()=>{try{if(!s)return{};const n=await Z.get(s).json();return{...n,image:Gn(n.image)}}catch{return{}}},staleTime:U.INFINITY})}function Gn(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const Xd="_thumbnail_1lblb_1",eu="_placeholder_1lblb_16",tu="_clickable_1lblb_22",Mt={thumbnail:Xd,placeholder:eu,clickable:tu},En=({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(Mt.thumbnail,Mt.clickable),onClick:n,style:{width:s,height:s},children:t.jsx(z,{src:l,classNames:{placeholder:Mt.placeholder}})}):t.jsx("div",{className:Mt.thumbnail,style:{width:s,height:s},children:t.jsx(z,{src:l,classNames:{placeholder:Mt.placeholder}})})},su="_nftItem_eopro_1",nu="_collectionName_eopro_9",ru="_nftName_eopro_19",ou="_chainInfo_eopro_29",os={nftItem:su,collectionName:nu,nftName:ru,chainInfo:ou},au=({normalizedNft:e})=>{const{collection_name:s,name:n,chain:r}=e,o=ie();return t.jsxs("div",{className:os.nftItem,children:[t.jsx(En,{nftInfo:e,onClick:()=>o("/nft",e)}),t.jsxs("div",{children:[t.jsx("div",{className:os.collectionName,children:s}),t.jsx("div",{className:os.nftName,children:n}),t.jsxs("div",{className:os.chainInfo,children:[t.jsx(z,{src:r.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:r.name})]})]})]})},iu=({nftInfo:e,children:s})=>{const{data:n={}}=Zd(e.nft.uri),r=Gd(e,n);return s(r)},cu="_grid_a1fhu_1",lu={grid:cu},du=()=>{const[e,s]=Q.useAtom(ad),[n,r]=Q.useAtom(id),{nftInfos:o,isLoading:a}=Jd(),i=f.useMemo(()=>o.filter(({collection_addr:c,collection_name:d,nft:u,object_addr:h,chain:m})=>{if(n&&m.chainId!==n)return!1;if(e){const _=e.trim().toLowerCase();return c.toLowerCase().includes(_)||d.toLowerCase().includes(_)||u.token_id.toLowerCase().includes(_)||h.toLowerCase().includes(_)}return!0}),[o,n,e]),l=f.useMemo(()=>Array.from(new Set(o.map(({chain:c})=>c.chainId))),[o]);return a&&o.length===0?t.jsx(J,{children:"Loading NFTs..."}):!o.length&&!e&&!a?t.jsx(J,{children:"No NFTs"}):t.jsxs(Ge.Root,{children:[t.jsxs(Ge.Controls,{children:[t.jsx(Ge.SearchInput,{value:e,onChange:c=>s(c.target.value),onClear:()=>s(""),placeholder:"Search NFTs"}),t.jsx(Tn,{value:n,onChange:r,chainIds:l})]}),i.length===0?t.jsx(J,{children:"No NFTs found"}):t.jsx("div",{className:lu.grid,children:i.map(c=>{const{collection_addr:d,nft:u}=c;return t.jsx(iu,{nftInfo:c,children:h=>t.jsx(au,{normalizedNft:h})},d+u.token_id)})})]})};function fo(e,s){return e.reduce((n,r)=>{const o=s(r);if(!o)return n;const a=o.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=n[a]||[];return{...n,[a]:[...i,r]}},{})}const uu="_message_1g2hc_1",hu="_more_1g2hc_8",Yn={message:uu,more:hu},mu=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((s,n)=>t.jsx("p",{className:Yn.message,children:ys.sentenceCase(s["@type"].split("Msg")[1])},n)),e.length>3&&t.jsx("footer",{className:Yn.more,children:`+${e.length-3} more`})]}),_u="_change_1x9v4_1",fu="_positive_1x9v4_10",pu="_negative_1x9v4_14",Zs={change:_u,positive:fu,negative:pu},po=({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(Zs.change,a?Zs.positive:Zs.negative),children:[a?"+":"-",N.formatAmount(i,{decimals:o})," ",r||n]})},gu=({changes:e,chain:s})=>{const n=Xe(s);return e.map(({amount:r,denom:o},a)=>t.jsx(po,{amount:r,asset:n(o)},a))},xu=({changes:e,chain:s})=>{const n=Xe(s);return e.map(({amount:r,metadata:o},a)=>t.jsx(no,{metadata:o,chain:s,children:i=>t.jsx(po,{amount:r,asset:n(i)})},a))},yu=({events:e,chain:s})=>{const{initiaAddress:n,hexAddress:r}=je();return s.metadata?.is_l1||s.metadata?.minitia?.type==="minimove"?t.jsx(xu,{changes:so(e,r),chain:s}):t.jsx(gu,{changes:to(e,n),chain:s})},ju="_link_oq58b_1",vu="_inner_oq58b_15",bu="_header_oq58b_20",wu="_time_oq58b_29",Cu="_error_oq58b_35",Iu="_timestamp_oq58b_39",Nu="_chainInfo_oq58b_44",Su="_content_oq58b_52",ku="_messages_oq58b_59",Au="_changes_oq58b_64",Se={link:ju,inner:vu,header:bu,time:wu,error:Cu,timestamp:Iu,chainInfo:Nu,content:Su,messages:ku,changes:Au},$u=({txItem:e,chain:s})=>t.jsx(Es,{txHash:e.txhash,chainId:s.chainId,className:Se.link,children:t.jsxs("div",{className:Se.inner,children:[t.jsxs("div",{className:Se.header,children:[t.jsxs("div",{className:Se.time,children:[e.code!==0&&t.jsx(A.IconWarningFilled,{size:14,className:Se.error}),t.jsx("span",{className:Se.timestamp,children:Nt.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:Se.chainInfo,children:[t.jsx(z,{src:s.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:s.name})]})]}),t.jsxs("div",{className:Se.content,children:[t.jsx("div",{className:Se.messages,children:t.jsx(mu,{messages:e.tx.body.messages})}),t.jsx("div",{className:Se.changes,children:t.jsx(ue,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(yu,{...e,chain:s})})})]})]})}),Tu="_list_1wa9p_1",Eu="_dateGroup_1wa9p_7",qu="_dateHeader_1wa9p_12",Du="_more_1wa9p_18",as={list:Tu,dateGroup:Eu,dateHeader:qu,more:Du},Pu=({list:e,chainId:s})=>{const n=ne(),r=f.useMemo(()=>fo(e,o=>{if(o.timestamp)return new Date(o.timestamp)}),[e]);return e.length===0?t.jsx(J,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:as.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{className:as.dateGroup,children:[t.jsx("div",{className:as.dateHeader,children:o}),a.map(i=>t.jsx(ue,{errorBoundaryProps:{fallback:null},children:t.jsx($u,{txItem:i,chain:i.chain})},i.txhash))]},o))}),t.jsx(Es,{chainId:s,accountAddress:n,pathSuffix:"/txs",className:as.more,showIcon:!0,children:"View more on Initia Scan"})]})},Ru=()=>{const{activities:e,isLoading:s}=ai(),[n,r]=Q.useAtom(cd),o=ye(),a=f.useMemo(()=>Array.from(new Set(e.map(l=>l.chain.chainId))),[e]),i=f.useMemo(()=>n?e.filter(l=>l.chain.chainId===n):e,[e,n]);return s&&e.length===0?t.jsx(J,{children:"Loading activities..."}):!e.length&&!s?t.jsx(J,{children:"No activity yet"}):t.jsxs(Ge.Root,{children:[t.jsx(Ge.Controls,{children:t.jsx(Tn,{value:n,onChange:r,chainIds:a,fullWidth:!0})}),t.jsx(Pu,{list:i,chainId:n||o.chainId})]})},Bu="_totalValue_1udv1_1",Mu="_totalLabel_1udv1_7",Fu="_totalAmount_1udv1_13",Ou="_loading_1udv1_18",Lu="_nav_1udv1_23",Uu="_item_1udv1_28",zu="_tabs_1udv1_51",Ku="_tab_1udv1_51",be={totalValue:Bu,totalLabel:Mu,totalAmount:Fu,loading:Ou,nav:Lu,item:Uu,tabs:zu,tab:Ku},Hu=()=>{co();const e=ie(),s=bs(),{totalValue:n,isLoading:r}=Nn(),o=f.useRef(null);return t.jsx(lo.Provider,{value:o,children:t.jsxs(Le,{ref:o,children:[t.jsxs("div",{className:be.totalValue,children:[t.jsx("div",{className:be.totalLabel,children:"Total value"}),t.jsx("div",{className:R(be.totalAmount,{[be.loading]:r}),children:Me(n)})]}),t.jsxs("div",{className:be.nav,children:[t.jsxs(jn,{to:"/send",className:be.item,children:[t.jsx(A.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs("button",{className:be.item,onClick:()=>e("/bridge"),children:[t.jsx(A.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]})]}),t.jsxs(ze.Tabs.Root,{value:s,onValueChange:e,children:[t.jsxs(ze.Tabs.List,{className:be.tabs,children:[t.jsx(ze.Tabs.Tab,{className:be.tab,value:"/",children:"Assets"}),t.jsx(ze.Tabs.Tab,{className:be.tab,value:"/nfts",children:"NFTs"}),t.jsx(ze.Tabs.Tab,{className:be.tab,value:"/activity",children:"Activity"})]}),t.jsx(ze.Tabs.Panel,{value:"/",children:t.jsx(Vd,{})}),t.jsx(ze.Tabs.Panel,{value:"/nfts",children:t.jsx(du,{})}),t.jsx(ze.Tabs.Panel,{value:"/activity",children:t.jsx(Ru,{})})]})]})})},Wu="_header_acels_1",Qu="_back_acels_11",Vu="_title_acels_23",Xs={header:Wu,back:Qu,title:Vu},ft=({title:e,backButton:s,extra:n,children:r})=>t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Xs.header,children:[t.jsx(jn,{to:s??-1,className:Xs.back,shouldReset:!!s,children:t.jsx(A.IconBack,{size:16})}),t.jsx("h1",{className:Xs.title,children:e}),n]}),t.jsx(Le,{children:r})]}),Gu="_fieldset_y241y_1",Yu="_upper_y241y_9",Ju="_select_y241y_14",Zu="_account_y241y_19",Xu="_lower_y241y_24",eh="_wrapper_y241y_25",th="_balance_y241y_32",sh="_value_y241y_36",nh="_error_y241y_49",Pe={fieldset:Gu,upper:Yu,select:Ju,account:Zu,lower:Xu,wrapper:eh,balance:th,value:sh,error:nh},hn=e=>{const{selectButton:s,accountButton:n,quantityInput:r,balanceButton:o,value:a,errorMessage:i,hideNumbers:l}=e;return t.jsxs("div",{className:Pe.fieldset,children:[t.jsxs("div",{className:Pe.upper,children:[t.jsx("div",{className:Pe.select,children:s}),t.jsx("div",{className:Pe.account,children:n})]}),!l&&t.jsxs("div",{className:Pe.lower,children:[r,t.jsxs("div",{className:Pe.wrapper,children:[t.jsx("div",{className:Pe.balance,children:o}),a&&t.jsx("div",{className:Pe.value,children:a})]}),i&&t.jsxs("footer",{className:Pe.error,children:[t.jsx(A.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})},rh="_root_1ipwv_1",oh="_content_1ipwv_10",ah="_details_1ipwv_18",ih="_symbol_1ipwv_23",ch="_chain_1ipwv_31",lh="_chevron_1ipwv_40",ot={root:rh,content:oh,details:ah,symbol:ih,chain:ch,chevron:lh},go=({asset:e,chain:s,readOnly:n})=>{const r=t.jsxs("div",{className:ot.content,children:[t.jsx(Ds,{assetLogoUrl:e.logoUrl,chainLogoUrl:s.logoUrl}),t.jsxs("div",{className:ot.details,children:[t.jsx("div",{className:ot.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:ot.chain,children:["on ",s.name]})]})]});return n?t.jsx("div",{className:ot.root,children:r}):t.jsxs("div",{className:ot.root,children:[r,t.jsx(A.IconChevronDown,{size:16,className:ot.chevron})]})},dh="_wrapper_5ssm8_1",uh="_balance_5ssm8_11",hh="_button_5ssm8_15",en={wrapper:dh,balance:uh,button:hh},xo=({onClick:e,children:s,disabled:n})=>t.jsxs("div",{className:en.wrapper,children:[t.jsx(A.IconWallet,{size:16}),t.jsx("span",{className:en.balance,children:s}),t.jsx("button",{type:"button",tabIndex:-1,className:en.button,onClick:()=>e(),disabled:n,children:"MAX"})]}),mh="_input_h8073_1",_h={input:mh};function Jn(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 yo(e){const{name:s,control:n,dp:r=6,className:o,rules:a,...i}=e,l=Gt();return t.jsx(re.Controller,{name:s,control:n,rules:a,render:({field:c})=>t.jsx("input",{...c,className:R(_h.input,o),onChange:d=>c.onChange(Jn(d.target.value,r)),onPaste:d=>{d.preventDefault();const u=d.clipboardData.getData("text");if(!/^[0-9,]+(\.[0-9]+)?$/.test(u))return;const m=u.replace(/,/g,""),_=Jn(m,r);c.onChange(_)},placeholder:"0",inputMode:"decimal",autoComplete:"off",...i,ref:gr.mergeRefs([c.ref,l])})})}const fh="_input_qpv94_1",ph="_placeholder_qpv94_18",mn={input:fh,placeholder:ph},gh=({children:e})=>t.jsx("p",{className:R(mn.input,{[mn.placeholder]:M(e).isZero()}),children:e}),ps=({balance:e,decimals:s})=>{const{control:n}=re.useFormContext(),r={required:"Enter amount",validate:o=>M(o).isZero()?"Enter amount":M(N.toBaseUnit(o,{decimals:s})).gt(e??0)?"Insufficient balance":!0};return t.jsx(yo,{name:"quantity",control:n,className:mn.input,rules:r})};ps.ReadOnly=gh;const xh="_label_9417z_1",yh="_wrapper_9417z_7",jh="_input_9417z_10",vh="_clear_9417z_18",is={label:xh,wrapper:yh,input:jh,clear:vh},qn=({mode:e="onChange",myAddress:s,...n})=>{const{validate:r=N.InitiaAddress.validate,chainType:o="initia",onApply:a,ref:i}=n,l=Gt(),{control:c,getValues:d,setValue:u,formState:h}=re.useFormContext(),m=d("recipient"),[_,p]=f.useState(m),g=Ur(),{data:b,isLoading:k,error:S}=E.useQuery({queryKey:As.address(g.restUrl,_).queryKey,queryFn:()=>g.getAddress(_),staleTime:U.MINUTE,enabled:g.validateUsername(_)}),T=b??(r(_)?_:""),j=s&&N.InitiaAddress.equals(T,s),D=async()=>{try{const I=await navigator.clipboard.readText();p(I.trim())}catch{}};f.useEffect(()=>{e==="onChange"&&(!_&&!h.dirtyFields.recipient||u("recipient",b??_,{shouldValidate:!0,shouldDirty:!0}))},[h.dirtyFields.recipient,_,e,u,b]);const B=()=>{k||S||(u("recipient",T,{shouldValidate:!0,shouldDirty:!0}),a?.())},P=()=>{if(k)return t.jsx(Qe,{level:"loading",children:"Resolving username..."});if(S)return t.jsx(Qe,{level:"error",children:S.message});if(b)return t.jsx(Qe,{level:"success",className:"monospace",children:b});if(e==="onSubmit"&&_&&!T)return t.jsx(Qe,{level:"error",children:"Invalid address"});if(e==="onChange")return t.jsx(Qe,{level:"error",children:h.errors.recipient?.message})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:is.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(W.Small,{type:"button",tabIndex:-1,onClick:D,children:"Paste"})]}),t.jsxs("div",{className:is.wrapper,children:[t.jsx(re.Controller,{name:"recipient",control:c,rules:{required:"Recipient address is required",validate:I=>r(I)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:R(is.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"?gr.mergeRefs([i,l]):i})}),!!_&&t.jsx("button",{type:"button",className:is.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:t.jsx(A.IconCloseCircleFilled,{size:16})})]}),P(),j&&t.jsx(Qe,{children:"This is my address"}),e==="onSubmit"&&t.jsx(te,{extra:(!s||!!T&&!j)&&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:B,disabled:k||!!S||!T,children:"Apply"})})]})};function bh({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 wh({denom:e,balances:s,gasPrices:n,lastFeeDenom:r,gas:o}){const a=s.find(d=>d.denom===e)?.amount??"0",i=bh({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 Ch="_container_1a4ds_1",Ih="_badge_1a4ds_5",Zn={container:Ch,badge:Ih},jo=e=>{const{offset:s=-4,disabled:n,children:r,className:o}=e;return t.jsxs("div",{className:R(Zn.container,o),children:[r,!n&&t.jsx("div",{className:Zn.badge,style:{right:s,top:s}})]})},Nh="_tooltip_6zakp_1",Sh="_arrow_6zakp_43",Xn={tooltip:Nh,arrow:Sh},Yt=({label:e,children:s,small:n,...r})=>t.jsxs(G.Tooltip.Root,{...r,children:[t.jsx(G.Tooltip.Trigger,{asChild:!0,children:s}),t.jsx(G.Tooltip.Portal,{container:dt(),children:t.jsxs(G.Tooltip.Content,{className:R(Xn.tooltip,{small:n}),collisionBoundary:dt(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(G.Tooltip.Arrow,{className:Xn.arrow})]})})]}),kh="_stack_a3b9q_1",Ah="_title_a3b9q_8",$h="_grid_a3b9q_15",Th="_item_a3b9q_21",Eh="_button_a3b9q_25",qh="_active_a3b9q_43",wt={stack:kh,title:Ah,grid:$h,item:Th,button:Eh,active:qh},lt=({label:e,chains:s,value:n,onSelect:r,getShowIndicator:o})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:wt.title,children:e}),t.jsx("div",{className:wt.grid,children:s.map(({chainId:a,name:i,logoUrl:l})=>t.jsx(jo,{offset:-2,disabled:!o?.(a),className:wt.item,children:t.jsx(Yt,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:R(wt.button,{[wt.active]:a===n}),onClick:()=>r(a),children:t.jsx(z,{src:l,width:28,height:28,logo:!0})})})},a))})]}),Dh=({children:e})=>t.jsx("div",{className:wt.stack,children:e});lt.Stack=Dh;function Ph(e,s,n){return n.filter(r=>{const o=e.map(a=>r[a]).map(a=>String(a??"").toLowerCase());return v.any(v.includes(s.toLowerCase()),o)})}const Rh="_container_1voou_1",Bh="_search_1voou_6",Mh="_list_1voou_10",Fh="_item_1voou_14",Oh="_logo_1voou_35",Lh="_info_1voou_39",Uh="_symbol_1voou_44",zh="_name_1voou_52",Kh="_balance_1voou_58",Hh="_value_1voou_65",ge={container:Rh,search:Bh,list:Mh,item:Fh,logo:Oh,info:Lh,symbol:Uh,name:zh,balance:Kh,value:Hh},Jt=e=>{const{assets:s,onSelect:n,renderAsset:r=(l,c)=>c(l)}=e,[o,a]=f.useState(""),i=Ph(["symbol"],o,s);return t.jsxs("div",{className:ge.container,children:[t.jsx(qs,{value:o,onChange:l=>a(l.target.value),onClear:()=>a(""),placeholder:"Search by symbol",rootClassName:ge.search,padding:20,ref:Gt()}),i.length===0?t.jsx(J,{children:"No assets"}):t.jsx("div",{className:ge.list,children:i.map(l=>t.jsx("button",{type:"button",className:ge.item,onClick:()=>n(l.denom),children:r(l,c=>{const{denom:d,logoUrl:u,symbol:h,name:m,balance:_,decimals:p,value:g=0}=c;return t.jsxs(t.Fragment,{children:[t.jsx(z,{src:u,width:32,height:32,className:ge.logo,logo:!0}),t.jsxs("div",{className:ge.info,children:[t.jsx("div",{className:ge.symbol,children:h||d}),t.jsx("div",{className:ge.name,children:m})]}),t.jsxs("div",{className:ge.balance,children:[_&&t.jsx("div",{children:N.formatAmount(_,{decimals:p})}),g>0&&t.jsx("div",{className:ge.value,children:Me(g)})]})]})})},l.denom))})]})},Wh=()=>t.jsxs("div",{className:ge.container,children:[t.jsx(qs,{rootClassName:ge.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(J,{children:"Loading..."})]});Jt.Placeholder=Wh;const Qh=({chain:e,onSelect:s})=>{const n=wa(e);return t.jsx(Jt,{assets:n,onSelect:s})},Vh=({afterSelect:e})=>{const{watch:s,setValue:n}=re.useFormContext(),{chainId:r,denom:o}=s(),{chainId:a}=s(),[i,l]=f.useState(a),c=Fe(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(lt.Stack,{children:t.jsx(lt,{chains:d,value:i,onSelect:l})}),t.jsx(ue,{suspenseFallback:t.jsx(Jt.Placeholder,{}),children:t.jsx(Qh,{chain:c,onSelect:u})},i)]})},Gh="_fields_brpej_1",Yh="_divider_brpej_11",er={fields:Gh,divider:Yh},Jh=qe.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Zh=()=>{const{address:e,initiaAddress:s,estimateGas:n,requestTxSync:r}=je(),{register:o,watch:a,setValue:i,handleSubmit:l,formState:c}=re.useFormContext(),{chainId:d,denom:u,recipient:h,quantity:m,memo:_}=a(),p=Fe(d),g=Cn(p),b=Zr(p),k=Xr(p),S=Or(u,p),{data:T}=Cs(p),{decimals:j}=S,D=g.find(C=>C.denom===u)?.amount??"0",B=T?.find(({id:C})=>C===u)?.price,{data:P=0,isLoading:I}=E.useQuery({queryKey:Jh.gas({chainId:d,denom:u,recipient:h,initiaAddress:s}).queryKey,queryFn:()=>{const C=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:On.MsgSend.fromPartial({fromAddress:s,toAddress:N.InitiaAddress(h).bech32,amount:[{denom:u,amount:"1"}]})}];return n({messages:C,chainId:d})},enabled:N.InitiaAddress.validate(h),staleTime:U.INFINITY}),x=Math.ceil(P*Kt),w=wh({denom:u,balances:g,gasPrices:b,lastFeeDenom:k,gas:x}),{mutate:y,isPending:q}=E.useMutation({mutationFn:({chainId:C,denom:F,quantity:$,recipient:V,memo:K})=>{const le=N.toBaseUnit($,{decimals:j}),he=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:On.MsgSend.fromPartial({fromAddress:s,toAddress:N.InitiaAddress(V).bech32,amount:[{denom:F,amount:le}]})}];return r({messages:he,memo:K,chainId:C,gas:P,gasAdjustment:Kt,gasPrices:b,spendCoins:[{denom:F,amount:le}],internal:"/"})}});return t.jsx(ft,{title:"Send",children:t.jsxs("form",{onSubmit:l(C=>y(C)),children:[t.jsxs("div",{className:er.fields,children:[t.jsx(hn,{selectButton:t.jsx(ut,{title:"Select chain and asset",content:C=>t.jsx(Vh,{afterSelect:C}),children:t.jsx(go,{asset:S,chain:p})}),quantityInput:t.jsx(ps,{balance:D,decimals:j}),balanceButton:t.jsx(xo,{onClick:()=>i("quantity",N.fromBaseUnit(w,{decimals:j}),{shouldValidate:!0}),disabled:b.some(({denom:C})=>C===u)&&I,children:N.formatAmount(D??"0",{decimals:j})}),value:m?B?Me(M(m).times(B)):"$-":"$0",errorMessage:c.errors.quantity?.message}),t.jsx("div",{className:er.divider}),t.jsx(qn,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...o("memo",{validate:C=>!C||new Blob([C]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"}),t.jsx(Qe,{level:"error",children:c.errors.memo?.message})]}),t.jsx(ee.Stack,{children:!_&&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:I||q,disabled:!c.isValid,children:"Confirm"})})]})})},Xh=()=>{const e=ht(),s=Qt(),n=Ht(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(Zh,{})})},em="_header_4z0mk_1",tm="_collectionName_4z0mk_6",sm="_name_4z0mk_12",nm="_chainInfo_4z0mk_18",rm="_attributes_4z0mk_28",om="_title_4z0mk_31",am="_count_4z0mk_36",im="_item_4z0mk_40",cm="_type_4z0mk_46",lm="_value_4z0mk_52",ke={header:em,collectionName:tm,name:sm,chainInfo:nm,attributes:rm,title:om,count:am,item:im,type:cm,value:lm},dm=()=>{const e=ie(),s=ht(),{collection_name:n,image:r,name:o,attributes:a,chain:i}=s;return t.jsxs(ft,{title:"NFT details",children:[t.jsxs("header",{className:ke.header,children:[r&&t.jsx(En,{nftInfo:s}),t.jsxs("div",{children:[t.jsx("div",{className:ke.collectionName,children:n}),t.jsx("h2",{className:ke.name,children:o}),t.jsxs("div",{className:ke.chainInfo,children:[t.jsx(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:ke.attributes,children:[t.jsxs("header",{className:ke.title,children:["Traits ",t.jsxs("span",{className:ke.count,children:["(",a.length,")"]})]}),t.jsx("div",{children:a.map(({trait_type:l,value:c})=>t.jsxs("div",{className:ke.item,children:[t.jsx("div",{className:ke.type,children:l}),t.jsx("div",{className:ke.value,children:c})]},l))})]})]})},um="_scrollable_1p1lw_1",hm="_list_1p1lw_5",mm="_item_1p1lw_9",_m="_name_1p1lw_13",cs={scrollable:um,list:hm,item:mm,name:_m};function vo({onSelect:e,list:s,...n}){const{getImage:r,getName:o,getKey:a,getIsLoading:i,getDisabled:l}=n;return t.jsx(Le,{className:cs.scrollable,children:t.jsx("div",{className:cs.list,children:s.map(c=>t.jsxs("button",{className:cs.item,onClick:()=>e(c),disabled:i?.(c)||l?.(c),children:[t.jsx(z,{src:r(c),width:28,height:28}),t.jsx("span",{className:cs.name,children:o(c)}),i?.(c)&&t.jsx(_t,{size:16})]},a(c)))})})}const fm="_header_5w36t_1",pm="_name_5w36t_8",gm="_collection_5w36t_15",xm="_nft_5w36t_20",ym="_fields_5w36t_24",jm="_chain_5w36t_29",vt={header:fm,name:pm,collection:gm,nft:xm,fields:ym,chain:jm},vm=qe.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),bm=()=>{const e=se(),s=ht(),{chain:n,collection_addr:r,collection_name:o,image:a,name:i}=s,{routerApiUrl:l}=ce(),c=Ns(),d=ye(),{address:u,initiaAddress:h,requestTxSync:m}=je(),{watch:_,setValue:p,handleSubmit:g,formState:b}=re.useFormContext(),k=_(),{recipient:S,dstChainId:T}=k,j=Fe(T),D=E.useQuery({queryKey:vm.simulation({collection_addr:r,nft:s,sender:h,recipient:S,srcChain:n,dstChain:j,layer1:d,routerApiUrl:l}).queryKey,queryFn:async()=>{const y={from_address:h,from_chain_id:n.chainId,to_address:N.InitiaAddress(S).bech32,to_chain_id:j.chainId,collection_address:r,token_ids:[s.token_id],object_addresses:[s.object_addr]},{msgs:q}=await Z.create({prefixUrl:l}).post("nft",{json:y}).json();return q.map(C=>c.fromAmino(C))},enabled:N.InitiaAddress.validate(S)}),{data:B,isLoading:P,error:I}=D,{mutate:x,isPending:w}=E.useMutation({mutationFn:async()=>{if(!B)throw new Error("Route not found");await m({messages:B,chainId:n.chainId,internal:"/nfts"})}});return t.jsxs("form",{onSubmit:g(()=>x()),children:[t.jsxs("header",{className:vt.header,children:[a&&t.jsx(En,{nftInfo:s,size:80}),t.jsxs("div",{className:vt.name,children:[t.jsx("div",{className:vt.collection,children:o}),t.jsx("div",{className:vt.nft,children:i})]})]}),t.jsxs("div",{className:vt.fields,children:[t.jsx(G.VisuallyHidden.Root,{children:t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(ut,{title:"Destination appchain",content:y=>t.jsx(vo,{onSelect:({chainId:q})=>{p("dstChainId",q),y()},list:e,getImage:q=>q.logoUrl,getName:q=>q.name,getKey:q=>q.chainId}),className:R("input",vt.chain),children:[t.jsx(z,{src:j.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:j.name})]})]})}),t.jsx(qn,{myAddress:u,ref:Gt()})]}),t.jsx(te,{children:t.jsx(W.White,{loading:P||w,disabled:!b.isValid||!!I,children:I?"Route not found":"Confirm"})})]})},wm=()=>{const{chain:e}=ht(),s=re.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(ft,{title:"Send NFT",children:t.jsx(re.FormProvider,{...s,children:t.jsx(bm,{})})})};function Cm(){return ye().network_type==="testnet"}function et(){return re.useFormContext()}function Im(){const e=ht(),s=Cm(),n={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},r={...n,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},o={...n,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},a=v.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(O.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(O.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(O.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(O.BRIDGE_DST_DENOM),quantity:localStorage.getItem(O.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(O.BRIDGE_SLIPPAGE_PERCENT)});return{...s?r:o,...a,...e}}function bo(){const{initiaAddress:e,hexAddress:s}=je(),n=mt(),r=Vt();return o=>{const a=n(o);switch(r(a)){case"initia":return e;case"evm":return s;default:return""}}}function wo(){const e=mt(),s=Vt();return(n,r)=>{const o=e(r);switch(s(o)){case"initia":return N.InitiaAddress.validate(n);case"evm":return Ye.isAddress(n);case"cosmos":try{return H.fromBech32(n).prefix===o.bech32_prefix}catch{return!1}default:return!1}}}function Nm(){const e=mt(),s=Vt();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 N.InitiaAddress(n).bech32;if(l==="initia"&&d==="evm")return N.InitiaAddress(n).hex;if(l===d)return n;if(a){if(d==="initia")return N.InitiaAddress(a).bech32;if(d==="evm")return N.InitiaAddress(a).hex}return""}}const Sm=[["d",1440*60],["h",3600],["m",60],["s",1]];function _n(e){if(!e)return;const{formattedParts:s}=Sm.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 Co(e){return e?.map(s=>{const{amount:n,origin_asset:r}=s;return`${N.formatAmount(n,{decimals:r.decimals??0})} ${r.symbol}`}).join(", ")}function tr(e,s){const{watch:n}=et(),r=n(),o=Oe(),a=Ss(),i={...r,quantity:e},l=E.useQueryClient();return E.useQuery({queryKey:Te.route(i,s?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:c,srcDenom:d,quantity:u,dstChainId:h,dstDenom:m}=i,{decimals:_}=l.getQueryData(Te.asset(c,d).queryKey)??{decimals:0},p={amount_in:N.toBaseUnit(u,{decimals:_}),source_asset_chain_id:c,source_asset_denom:d,dest_asset_chain_id:h,dest_asset_denom:m,is_op_withdraw:s?.isOpWithdraw},g=await o.post("v2/fungible/route",{json:p}).json(),b={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return a("Bridge Simulation Success",b),g},enabled:!!Number(i.quantity)&&!s?.disabled,staleTime:U.MINUTE})}function km(e){return E.useQuery({queryKey:Te.routeErrorInfo(e||new Error).queryKey,queryFn:async()=>{if(!e||!(e instanceof Z.HTTPError))return null;const{response:s}=e;return(s.headers.get("content-type")??"").includes("application/json")?(await s.json()).info??null:null}})}function Am(){const{watch:e}=et(),{srcChainId:s,srcDenom:n,dstChainId:r,dstDenom:o}=e(),a=Ee(s),i=Wt(a),l=Be(n,s),c=Be(o,r),d=ye(),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 Dn(e,s){const n=Oe();return E.useQuery({queryKey:Te.balances(s,e).queryKey,queryFn:()=>n.post("v2/info/balances",{json:{chains:{[s]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>e?r?r[s].denoms??{}:{}:{},enabled:!!e,staleTime:U.SECOND})}function $m(e,s,n){const{data:r={}}=Dn(e,s);return v.path([n],r)}const Tm=({address:e,chain:s,onSelect:n})=>{const r=It(s.chain_id),{data:o={}}=Dn(e,s.chain_id);return t.jsx(Jt,{assets:v.sortWith([v.descend(a=>a.symbol==="INIT"),v.descend(a=>a.value),({balance:a="0"},{balance:i="0"})=>M(i).comparedTo(a)??0,v.ascend(a=>a.symbol.toLowerCase())],r.filter(a=>!a.hidden).map(a=>{const{denom:i,symbol:l=N.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})},Em=({type:e,afterSelect:s})=>{const n=e==="src"?"srcChainId":"dstChainId",r=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"sender":"recipient",a=At(),i=Sn(),{watch:l,setValue:c}=et(),d=l(o),u=l(n),h=l(r),[m,_]=f.useState(u),p=Ee(m),g=Nm(),b=Hr(),[k,S]=v.partition(j=>b(j.chain_id),i.filter(j=>!j.hidden)),T=j=>{if(u===m&&h===j){s();return}c(n,m),c(r,j),s()};return t.jsxs(t.Fragment,{children:[t.jsxs(lt.Stack,{children:[t.jsx(lt,{label:"Interwoven Economy",chains:k.map(({chain_id:j,chain_name:D,pretty_name:B,logo_uri:P})=>({chainId:j,name:B||D,logoUrl:P??""})),value:m,onSelect:_}),t.jsx(lt,{label:"Chains",chains:S.map(({chain_id:j,chain_name:D,pretty_name:B,logo_uri:P})=>({chainId:j,name:B||D,logoUrl:P??""})),value:m,onSelect:_})]}),t.jsx(ue,{suspenseFallback:t.jsx(Jt.Placeholder,{}),children:t.jsx(Tm,{address:g({initialAddress:d,initialChainId:u,chainId:m,fallbackAddress:e==="src"?a:void 0}),chain:p,onSelect:T})},m)]})},sr=({type:e})=>{const s=e==="src"?"srcChainId":"dstChainId",n=e==="src"?"srcDenom":"dstDenom",r=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:o}=et(),a=o(s),i=o(n),l=Ee(a),c=Be(i,a);return t.jsx(ut,{title:r,content:d=>t.jsx(Em,{type:e,afterSelect:d}),children:t.jsx(go,{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 Ps(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:n=>e.find(r=>r.name===n)}}const qm="_account_iwrlj_8",Dm="_clear_iwrlj_27",Pm="_white_iwrlj_38",Ft={account:qm,clear:Dm,white:Pm},nr=({type:e})=>{const{watch:s,setValue:n}=et(),{srcChainId:r,dstChainId:o,cosmosWalletName:a}=s(),l=s(e==="src"?"sender":"recipient"),c=Wt(Ee(o)),{list:d,find:u}=Ps(),h=u(a),m=bo(),_=wo(),p=m(o),g=N.InitiaAddress.equals(l,p),b=()=>t.jsx(ut,{title:"Connect wallet",content:T=>t.jsx(vo,{onSelect:async j=>{const D=j.getProvider();if(!D)return window.open(j.fallbackUrl,"_blank");const B=D.getOfflineSigner(r),[{address:P}]=await B.getAccounts();n("sender",P),n("cosmosWalletName",j.name),T()},list:d,getImage:j=>j.image,getName:j=>j.name,getKey:j=>j.name}),className:R(Ft.account,{[Ft.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:N.truncate(l)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(A.IconChevronRight,{size:14})]})}),k=T=>t.jsx(ut,{title:"Recipient",content:j=>t.jsx(Le,{children:t.jsx(qn,{mode:"onSubmit",myAddress:p,chainType:c,validate:D=>_(D,o),onApply:j})}),className:Ft.account,children:T}),S=()=>{switch(c){case"initia":case"evm":return g?k(t.jsx(A.IconWallet,{size:14})):t.jsxs("div",{className:Ft.account,children:[t.jsx("span",{className:"monospace",children:N.truncate(l)}),t.jsx("button",{type:"button",className:Ft.clear,onClick:()=>n("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(A.IconCloseCircleFilled,{size:14})})]});case"cosmos":return k(t.jsxs(t.Fragment,{children:[l?t.jsx("span",{className:"monospace",children:N.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx(A.IconEdit,{size:14})]}))}};switch(e){case"src":return b();case"dst":return S()}},Rm="_description_l5bcv_1",Bm="_presets_l5bcv_8",Mm="_preset_l5bcv_8",Fm="_active_l5bcv_29",Om="_custom_l5bcv_40",Lm="_wrapper_l5bcv_46",Um="_percent_l5bcv_49",Ae={description:Rm,presets:Bm,preset:Mm,active:Fm,custom:Om,wrapper:Lm,percent:Um},rr=["0.1","0.5","1.0"],zm=({afterConfirm:e})=>{const s=et(),n=s.getValues("slippagePercent"),[r,o]=f.useState(null),{control:a,watch:i,getValues:l,setValue:c}=re.useForm({defaultValues:{value:n}}),d=i("value");f.useEffect(()=>{const g=rr.findIndex(b=>b===n);o(g>=0?g:null)},[n]);const u=(g,b)=>{c("value",g),o(b)},h=()=>{o(null)},m=f.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),_=m?.type==="error",p=({value:g})=>{s.setValue("slippagePercent",g),e()};return t.jsxs(Le,{children:[t.jsx("p",{className:Ae.description,children:"Slippage is how much price movement you can tolerate between the time you send out a transaction and the time it's executed."}),t.jsxs("div",{className:Ae.presets,children:[rr.map((g,b)=>t.jsxs("button",{type:"button",className:R(Ae.preset,{[Ae.active]:r===b}),onClick:()=>u(g,b),children:[g,"%"]},g)),r!==null?t.jsx("button",{type:"button",className:R(Ae.preset,Ae.custom),onClick:()=>o(null),children:"Custom"}):t.jsxs("div",{className:Ae.wrapper,children:[t.jsx(yo,{name:"value",control:a,dp:2,onFocus:h,placeholder:"",className:R(Ae.preset,Ae.active)}),t.jsx("span",{className:Ae.percent,children:"%"})]})]}),m&&t.jsx(ee,{level:m.type,children:m.text}),t.jsx(te,{children:t.jsx(W.White,{type:"button",onClick:()=>p(l()),disabled:_,children:"Confirm"})})]})},Km="_skeleton_1l4jn_1",Hm={skeleton:Km},tn=({width:e="100%",height:s})=>t.jsx("div",{className:Hm.skeleton,style:{width:e,height:s}}),Wm="_stack_1ip8h_1",Qm="_button_1ip8h_6",Vm="_isLoading_1ip8h_19",Gm="_disabled_1ip8h_19",Ym="_checked_1ip8h_23",Jm="_header_1ip8h_37",Zm="_title_1ip8h_43",Xm="_duration_1ip8h_52",e_="_warning_1ip8h_62",t_="_amount_1ip8h_66",s_="_value_1ip8h_67",pe={stack:Wm,button:Qm,isLoading:Vm,disabled:Gm,checked:Ym,header:Jm,title:Zm,duration:Xm,warning:e_,amount:t_,value:s_},n_=({children:e})=>t.jsx("div",{className:pe.stack,children:e}),ds=({label:e,query:s,value:n,onSelect:r,...o})=>{const{data:a,isLoading:i}=s,{watch:l}=et(),{dstChainId:c,dstDenom:d}=l(),u=Be(d,c),h=!i&&o.checked,m=!i&&!a;return t.jsxs("button",{type:"button",className:R(pe.button,{[pe.isLoading]:i,[pe.disabled]:m,[pe.checked]:h}),onClick:()=>{i||m||r(n)},children:[t.jsxs("div",{className:pe.header,children:[t.jsxs("div",{className:pe.title,children:[t.jsx("span",{children:e}),h&&t.jsx(A.IconCheck,{size:14})]}),i?t.jsx(tn,{width:80,height:16}):a?t.jsxs("div",{className:R(pe.duration,{[pe.warning]:n==="op"}),children:[t.jsx(A.IconClockFilled,{size:12}),t.jsx("span",{children:_n(a.estimated_route_duration_seconds)})]}):t.jsx("div",{className:pe.duration,children:"Not available"})]}),(i||a)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:pe.amount,children:i?t.jsx(tn,{width:260,height:40}):a?N.formatAmount(a.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:pe.value,children:i?t.jsx(tn,{width:120,height:16}):a?a.usd_amount_out?Me(a.usd_amount_out):"$-":null})]})]})};ds.Stack=n_;const r_="_form_1coq4_1",o_="_arrow_1coq4_5",a_="_divider_1coq4_13",i_="_flip_1coq4_21",c_="_meta_1coq4_37",l_="_row_1coq4_50",d_="_title_1coq4_56",u_="_description_1coq4_60",h_="_icon_1coq4_67",m_="_edit_1coq4_72",__="_warning_1coq4_93",de={form:r_,arrow:o_,divider:a_,flip:i_,meta:c_,row:l_,title:d_,description:u_,icon:h_,edit:m_,warning:__},f_=()=>{const e=ie(),s=Ts(),[n,r]=Ce.useLocalStorage(O.BRIDGE_ROUTE_TYPE,"default"),{watch:o,setValue:a,handleSubmit:i,formState:l}=et(),c=o(),{srcChainId:d,srcDenom:u,dstChainId:h,dstDenom:m,quantity:_,sender:p,slippagePercent:g}=c,b=Ze(),k=Ee(d),S=Wt(k),T=Ee(h),j=Wt(T),D=Be(u,d),B=Be(m,h),{data:P}=Dn(p,d),I=$m(p,d,u),[x]=Ce.useDebounceValue(_,300),w=S!=="initia"&&j!=="initia",y=Am(),q=tr(x,{disabled:w}),C=tr(x,{isOpWithdraw:!0,disabled:!y}),F=y&&n==="op"?C:q,{data:$,isLoading:V,isFetching:K,error:le}=F,{data:he}=km(le),Et=x&&(V||K),qt=()=>{a("srcChainId",h),a("srcDenom",m),a("dstChainId",d),a("dstDenom",u),a("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:gt,closeModal:xt}=ws(),Ie=i(L=>{if($?.warning){const{type:tt="",message:Fs}=$.warning??{};gt({content:t.jsx(io,{type:"warning",icon:t.jsx(A.IconWarningFilled,{size:40}),title:ys.sentenceCase(tt),primaryButton:{label:"Cancel",onClick:xt},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:$,values:L}),xt()}},children:t.jsx("p",{className:de.warning,children:Fs})})});return}e("/bridge/preview",{route:$,values:L})}),me=f.useMemo(()=>$?.estimated_fees?.filter(({fee_behavior:L})=>L==="FEE_BEHAVIOR_DEDUCTED")??[],[$]),Ue=f.useMemo(()=>$?.estimated_fees?.filter(({fee_behavior:L})=>L==="FEE_BEHAVIOR_ADDITIONAL")??[],[$]),yt=f.useMemo(()=>{for(const L of Ue){const tt=P?.[L.origin_asset.denom]?.amount??"0",Fs=$?.source_asset_denom===L.origin_asset.denom?$.amount_in:"0";if(M(tt).lt(M(Fs).plus(L.amount??"0")))return`Insufficient ${L.origin_asset.symbol} for fees`}},[P,$,Ue]),Zt=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(!$)return"Route not found";if(yt)return yt},[x,yt,l,$,c]),Do=$?N.formatAmount($.amount_out,{decimals:B.decimals}):"0",Po=M(_).gt(0)&&M(_).isEqualTo(N.fromBaseUnit(I?.amount,{decimals:I?.decimals??0})),Ro=(()=>{switch(S){case"initia":return b(d).fees.fee_tokens.some(({denom:L})=>L===u);case"cosmos":return k.fee_assets.some(({denom:L})=>L===u);case"evm":return!Ye.isAddress(u);default:return!1}})(),Ms=f.useCallback((L,tt)=>L.length?t.jsxs("div",{className:de.description,children:[Co(L),!s&&t.jsx(Yt,{label:tt,children:t.jsx("span",{className:de.icon,children:t.jsx(A.IconInfoFilled,{size:12})})})]}):null,[s]),Xt=M(_).gt(0)&&y,Rn=f.useMemo(()=>$?[{condition:!!$.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Ms(me,"Fee deducted from the amount you receive"),Ms(Ue,"Fee charged in addition to the amount you enter")]})},{condition:!Xt&&!!_n($.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:de.description,children:_n($.estimated_route_duration_seconds)})},{condition:$.does_swap,title:"Slippage",content:t.jsxs("span",{className:de.description,children:[t.jsxs("span",{children:[g,"%"]}),t.jsx(ut,{title:"Slippage tolerance",content:L=>t.jsx(zm,{afterConfirm:L}),className:de.edit,children:t.jsx(A.IconSettingFilled,{size:12})})]})}].filter(L=>L.condition):[],[Ue,me,Ms,$,Xt,g]);return t.jsxs("form",{className:de.form,onSubmit:Ie,children:[t.jsx(hn,{selectButton:t.jsx(sr,{type:"src"}),accountButton:S==="cosmos"&&t.jsx(nr,{type:"src"}),quantityInput:t.jsx(ps,{balance:I?.amount,decimals:D?.decimals}),balanceButton:t.jsx(xo,{onClick:()=>a("quantity",N.fromBaseUnit(I?.amount,{decimals:D?.decimals??0}),{shouldValidate:!0}),children:N.formatAmount(I?.amount??"0",{decimals:D.decimals})}),value:$?$.usd_amount_in?Me($.usd_amount_in):"$-":"$0"}),t.jsxs("div",{className:de.arrow,children:[t.jsx("div",{className:de.divider}),t.jsx("button",{type:"button",className:de.flip,onClick:()=>qt(),children:t.jsx(A.IconChevronDown,{size:16})})]}),t.jsx(hn,{selectButton:t.jsx(sr,{type:"dst"}),accountButton:t.jsx(nr,{type:"dst"}),quantityInput:t.jsx(ps.ReadOnly,{children:Do}),value:$?$.usd_amount_out?Me($.usd_amount_out):"$-":"$0",hideNumbers:Xt}),t.jsx(ln,{children:Xt?t.jsxs(ds.Stack,{children:[t.jsx(ds,{label:"Fast",query:q,value:"default",onSelect:r,checked:n==="default"}),t.jsx(ds,{label:"Lossless",query:C,value:"op",onSelect:r,checked:n==="op"})]}):null}),t.jsx(te,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(ee.Stack,{children:[$?.extra_infos?.map(L=>t.jsx(ee,{level:"info",children:L},L)),he&&t.jsx(ee,{level:"info",children:he}),Po&&Ro&&t.jsx(ee,{level:"warning",children:"Make sure to leave enough for transaction fee"}),$?.warning&&t.jsx(ee,{level:"warning",children:$.warning.message}),$?.extra_warnings?.map(L=>t.jsx(ee,{level:"warning",children:L},L))]}),t.jsx(ln,{children:Rn.length>0&&t.jsx("div",{className:de.meta,children:Rn.map((L,tt)=>t.jsxs("div",{className:de.row,children:[t.jsx("span",{className:de.title,children:L.title}),L.content]},tt))})})]}),children:t.jsx(W.White,{loading:Et&&"Simulating...",disabled:!!Zt,children:Zt??"Preview route"})})]})},p_=()=>{co();const e=Jo(),s=ie(),{closeDrawer:n}=kt(),r=At(),o=Im(),a=re.useForm({mode:"onChange",defaultValues:o}),{watch:i,setValue:l}=a,{srcChainId:c,dstChainId:d,srcDenom:u,dstDenom:h,quantity:m,slippagePercent:_,recipient:p}=i();i((w,{name:y})=>{(y==="srcChainId"||y==="srcDenom")&&l("quantity","",{shouldTouch:!1,shouldDirty:!1})});const g=bo(),b=g(c),k=g(d),T=wo()(p,d);f.useEffect(()=>{l("cosmosWalletName",void 0),l("sender",b)},[c,b,l]),f.useEffect(()=>{T||l("recipient",k)},[k,T,l]);const j=It(c),D=It(d),B=f.useMemo(()=>{if(!j.find(w=>w.denom===u))return`${u} is not available for bridge/swap on ${c}`;if(!D.find(w=>w.denom===h))return`${h} is not available for bridge/swap on ${d}`},[D,d,h,j,c,u]);f.useEffect(()=>{B||(localStorage.setItem(O.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(O.BRIDGE_SRC_DENOM,u),localStorage.setItem(O.BRIDGE_DST_CHAIN_ID,d),localStorage.setItem(O.BRIDGE_DST_DENOM,h),localStorage.setItem(O.BRIDGE_QUANTITY,m),localStorage.setItem(O.BRIDGE_SLIPPAGE_PERCENT,_))},[c,u,d,h,m,_,B]);const P=e[0].path==="/bridge",I=()=>t.jsxs(t.Fragment,{children:[t.jsx(J,{error:!0,children:B}),t.jsx(te,{children:P?t.jsx(W.White,{onClick:n,children:"Close"}):t.jsx(W.White,{onClick:()=>s(-1),children:"Go back"})})]}),{reminders:x}=$t();return t.jsx(ft,{title:"Bridge/Swap",backButton:P?"/":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(jo,{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:B?I():t.jsx(re.FormProvider,{...a,children:t.jsx(ue,{children:t.jsx(f_,{})})})})},g_="_button_1iys9_1",x_={button:g_},Io=({onClick:e,disabled:s})=>{const{ref:n,inView:r}=Ho.useInView();return f.useEffect(()=>{r&&e()},[r,e]),t.jsxs("button",{className:x_.button,onClick:e,disabled:s,ref:n,children:[t.jsx("span",{children:"Load more"}),t.jsx(A.IconChevronDown,{size:12})]})},pt=qe.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,s)=>[e,s],latestOutput:e=>[e],output:(e,s)=>[e,s],outputResponse:(e,s)=>[e,s],withdrawalClaimed:(e,s)=>[e,s]});function Rs(){const{restUrl:e}=ye();return f.useMemo(()=>Z.create({prefixUrl:e}),[e])}function y_(e){const s=Rs(),{data:n}=E.useSuspenseQuery({queryKey:pt.bridge(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:U.INFINITY});return n}const or=20;function j_(e){const s=ne();return E.useSuspenseInfiniteQuery({queryKey:pt.withdrawals(e,s).queryKey,queryFn:async({pageParam:n})=>{if(!s)return[];const r={limit:or,offset:n,order:"desc"},{withdrawals:o}=await Z.create({prefixUrl:e}).get(`withdrawals/${s}`,{searchParams:r}).json();return o},getNextPageParam:n=>{const r=v.last(n)?.sequence;return n.length<or||!r||r<=1?null:r-1},initialPageParam:0,staleTime:U.SECOND})}function v_(e){const s=Rs(),{data:n}=E.useSuspenseQuery({queryKey:pt.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 b_({bridge_id:e,output_index:s}){const n=Rs(),{data:r}=E.useSuspenseQuery({queryKey:pt.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 w_({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=Ze()(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}=E.useSuspenseQuery({queryKey:pt.outputResponse(i,s).queryKey,queryFn:()=>Z.create({prefixUrl:i}).get(`withdrawal/${s}`).json(),staleTime:U.SECOND});return l}function No(e,s){const{bridge_id:n}=e,r=Rs(),{data:o}=E.useSuspenseQuery({queryKey:pt.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 Ot(e){return Wo.sha3_256.create().update(e).digest()}function sn(e,s){const n=new ArrayBuffer(s);return new DataView(n).setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}function So(e){const{bridge_id:s,sequence:n,amount:r,from:o,to:a}=e,i=sn(s.toString(),8),l=sn(n.toString(),8),c=sn(r.amount,8),d=es.concatBytes(i,l,Ot(es.utf8ToBytes(o)),Ot(es.utf8ToBytes(a)),Ot(es.utf8ToBytes(r.denom)),c);return Ot(Ot(d))}const ko=f.createContext(null);function Bs(){return f.useContext(ko)}const C_="_asset_6h8u2_1",I_="_info_6h8u2_7",N_="_symbol_6h8u2_11",nn={asset:C_,info:I_,symbol:N_},S_=({amount:e,denom:s})=>{const n=ye(),r=Or(s,n),{symbol:o,logoUrl:a,decimals:i}=r;return t.jsxs("div",{className:nn.asset,children:[t.jsx(z,{src:a,width:32,height:32,logo:!0}),t.jsxs("div",{className:nn.info,children:[t.jsx("span",{className:"monospace",children:N.formatAmount(e,{decimals:i})}),t.jsx("span",{className:nn.symbol,children:o})]})]})},k_=({children:e})=>{const{withdrawalTx:s}=Bs(),n=v_(s.bridge_id),r=s.output_index>Number(n?.output_index);return e(r)},A_="_container_1oldz_1",$_="_icon_1oldz_7",ar={container:A_,icon:$_},T_="Withdrawal will begin within an hour",ir=()=>{const e=Ts();return t.jsxs("div",{className:ar.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Yt,{label:T_,children:t.jsx("span",{className:ar.icon,children:t.jsx(A.IconInfoFilled,{size:12})})})]})},Ao=1e3,E_=60,q_=60,D_=24,fn=Ao*E_,pn=fn*q_,cr=pn*D_,P_=({date:e})=>{const s=f.useCallback(()=>{const d=new Date().getTime(),h=e.getTime()-d;if(h<=0)return{days:0,hours:0,minutes:0,seconds:0};const m=Math.floor(h/cr),_=Math.floor(h%cr/pn),p=Math.floor(h%pn/fn),g=Math.floor(h%fn/Ao);return{days:m,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(Yt,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[a,"d ",o(i),"h ",o(l),"m ",o(c),"s"]})})},R_="_container_1lz3w_1",B_="_title_1lz3w_5",lr={container:R_,title:B_},M_=({date:e})=>t.jsxs("div",{className:lr.container,children:[t.jsx("div",{className:lr.title,children:"Claimable in"}),t.jsx(P_,{date:e})]}),F_=({children:e})=>{const{withdrawalTx:s}=Bs(),n=y_(s.bridge_id),r=b_(s),o=f.useMemo(()=>{if(!r)return null;const{bridge_config:a}=n,{output_proposal:i}=r;return Nt.addSeconds(new Date(i.l1_block_time),parseFloat(a.finalization_period))},[n,r]);return e(o)},O_=({date:e,children:s})=>{const{chainId:n,withdrawalTx:r}=Bs(),o=H.toBase64(So(r)),a=No(r,o),{setReminder:i,removeReminder:l}=$t();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:Nt.isPast(e.getTime())?!0:void 0})},[n,a,e,l,i,r]),s},L_="_button_1btdg_1",U_="_claimed_1btdg_23",dr={button:L_,claimed:U_},z_=()=>{const{withdrawalTx:e}=Bs(),{bridge_id:s,sequence:n,amount:r,output_index:o,withdrawal_proofs:a,storage_root:i,from:l,to:c,version:d}=e,u=ye(),h=ne(),{requestTxSync:m,waitForTxConfirmation:_}=je(),p=w_(e),g=H.toBase64(So(e)),b=No(e,g),k=E.useQueryClient(),{mutate:S,isPending:T}=E.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:j}=p;return m({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:h,bridgeId:BigInt(s),outputIndex:BigInt(o),withdrawalProofs:a.map(H.fromBase64),from:l,to:c,sequence:BigInt(n),amount:r,version:H.fromBase64(d),storageRoot:H.fromBase64(i),lastBlockHash:H.fromBase64(j)}}],internal:!0})},onSuccess:async j=>{await _({chainId:u.chain_id,txHash:j}),k.invalidateQueries({queryKey:pt.withdrawalClaimed(s,g).queryKey})}});return b?t.jsxs("div",{className:dr.claimed,children:[t.jsx(A.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:dr.button,onClick:()=>S(),disabled:T,children:"Claim"})},K_=()=>t.jsx(k_,{children:e=>e?t.jsx(ir,{}):t.jsx(F_,{children:s=>s?t.jsx(O_,{date:s,children:Nt.isFuture(s)?t.jsx(M_,{date:s}):t.jsx(z_,{})}):t.jsx(ir,{})})}),H_="_item_km5w2_1",W_={item:H_},Q_=({chain:e})=>{const s=e.metadata?.executor_uri;if(!s)throw new Error("Executor URL is not defined");const{data:n,fetchNextPage:r,hasNextPage:o,isFetching:a}=j_(s),i=f.useMemo(()=>n?.pages.flat()??[],[n]),{syncReminders:l}=$t();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:W_.item,children:[t.jsx(S_,{...d}),t.jsx(ue,{suspenseFallback:null,children:t.jsx(ko.Provider,{value:{chainId:e.chainId,withdrawalTx:c},children:t.jsx(K_,{})})})]},c.sequence)}),o&&t.jsx(Io,{onClick:()=>r(),disabled:a})]}):t.jsx(J,{children:"No withdrawals"})},V_="_content_dj1qm_1",G_="_title_dj1qm_5",ur={content:V_,title:G_},Y_=()=>{const{chainId:e}=ht(),s=se(),n=Qt(),[r,o]=f.useState(e??(n.metadata?.is_l1?"":n.chainId)),a=Ze(),{reminders:i}=$t(),l=r?a(r):void 0;return t.jsxs(ft,{title:"OP Bridge withdrawals",children:[t.jsx(lt,{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:ur.content,children:l?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:ur.title,children:l.name}),t.jsx(ue,{children:t.jsx(Q_,{chain:l})},r)]}):t.jsx(ee,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})};async function J_(e,s){const n=Z.create({prefixUrl:s}),r=`cosmos/auth/v1beta1/account_info/${e}`;for(let o=1;o<=24;o++)try{return await n.get(r).json()}catch{await new Promise(a=>setTimeout(a,5e3))}throw new Error(`Timeout: ${e} not found`)}const us=({chainId:e,txHash:s})=>`${O.BRIDGE_HISTORY}:${e}:${s}`,gs=100,hr=10;function $o(){const[e,s]=Ce.useLocalStorage(O.BRIDGE_HISTORY,[]),n=f.useCallback((o,a)=>{localStorage.setItem(us(o),JSON.stringify(a));for(const i of e.slice(gs-1))localStorage.removeItem(us(i));s((i=[])=>[o,...i.slice(0,gs-1)])},[e,s]),r=f.useCallback(o=>{const a=localStorage.getItem(us(o));return a?JSON.parse(a):null},[]);return{history:e,addHistoryItem:n,getHistoryDetails:r}}function To(e){return Ce.useLocalStorage(us(e),null)}async function gn(e,s){const{chain_type:n,chain_id:r,chain_name:o,evm_fee_asset:a,rpc:i}=s;if(n!=="evm")throw new Error(`Chain is not an EVM chain: ${o}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}catch(l){if(v.path(["error","code"],l)!==4902)throw l;if(!a)throw new Error(`Fee asset is not defined for chain: ${o}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(r).toString(16)}`,chainName:o,nativeCurrency:a,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}}function Tt(){return ht()}function Z_(e){const s=ie(),{showNotification:n,updateNotification:r,hideNotification:o}=An(),{addHistoryItem:a}=$o(),i=Ss(),{route:l,values:c}=Tt(),{srcChainId:d,sender:u,recipient:h,cosmosWalletName:m}=c,_=Tr(),{requestTxSync:p,waitForTxConfirmation:g}=je(),{find:b}=Ps(),k=Is(),S=Ns(),T=Ee(d),j=Wt(T),D=Wr(d),B=E.useQueryClient(),{registryUrl:P}=ce(),I=Ze(),{addReminder:x}=$t(),w=Oe();return E.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const y=e.cosmos_tx.msgs.map(({msg_type_url:Ie,msg:me})=>{if(!(Ie&&me))throw new Error("Invalid transaction data");return S.fromAmino({type:zt.aminoConverters[Ie].aminoType,value:JSON.parse(me)})});if(j==="initia"){const{srcDenom:Ie,quantity:me}=c,{decimals:Ue}=D(Ie),yt=await p({messages:y,chainId:d,internal:1,spendCoins:[{denom:Ie,amount:N.toBaseUnit(me,{decimals:Ue})}]}),Zt=g({txHash:yt,chainId:d});return{txHash:yt,wait:Zt}}const q=b(m)?.getProvider();if(!q)throw new Error("Wallet not connected");const C=q.getOfflineSignerOnlyAmino(d),F=await $e.SigningStargateClient.connectWithSigner(T.rpc,C,{registry:k,aminoTypes:S}),$=await F.getAllBalances(u),V=T.fee_assets.find(Ie=>$.some(me=>me.denom===Ie.denom&&M(me.amount).gt(0)));if(!V){const me=["Insufficient balance for fees.",`Available fee assets: ${T.fee_assets.map(Ue=>D(Ue.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(me)}const{denom:K,gas_price:le}=V;if(!le)throw new Error(`Gas price not found for ${K}`);const he=await F.simulate(u,y,""),Et=$e.GasPrice.fromString(le.average+K),qt=$e.calculateFee(Math.ceil(he*Kt),Et),gt=await F.signAndBroadcastSync(u,y,qt),xt=Br({txHash:gt,client:F});return{txHash:gt,wait:xt}}if("evm_tx"in e){const{chain_id:y,to:q,value:C,data:F}=e.evm_tx,$=await _(),V=await $.getSigner();await gn($,T);const K=await V.sendTransaction({chainId:y,to:q,value:C,data:`0x${F}`});return{txHash:K.hash,wait:K.wait()}}throw new Error("Unlisted chain type")}catch(y){throw await Re(y)}},onSuccess:async({txHash:y,wait:q})=>{localStorage.removeItem(O.BRIDGE_QUANTITY),s(-1),n({type:"loading",title:"Transaction is pending..."});try{await q;const C=Pn(l)==="OP Bridge withdrawal",F=C?{success:!0,error:null}:await nf(w,y,d);if(!F.success&&F.error){const he=F.error instanceof Error?F.error.message:String(F.error);n({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${he}. The transaction may still be processing.`,autoHide:!0})}const $=F.success,K=tf({txHash:y,srcChainId:d,route:l,values:c,recipient:h},$);a(K.tx,K.details),r(ef(o));const le=rn(c,y);if(i("Bridge Transaction Success",le),C){const he=sf(K.tx,l,h);x(K.tx,he)}}catch(C){const F=C instanceof Error?C.message:String(C);r({type:"error",title:"Transaction not confirmed",description:F});const $={...rn(c,y),error:F};i("Bridge Confirmation Failed",$)}finally{B.invalidateQueries({queryKey:Te.balances(d,u).queryKey})}},onError:async y=>{const q=j==="initia"?await bt(y,I(d),P):y;n({type:"error",title:"Transaction failed",description:q.message});const C=rn(c);i("Bridge Transaction Failed",{...C,error:q.message})}})}function X_(){const e=Oe(),s=ne(),n=bn(),{route:r,values:o}=Tt(),a=mt();return E.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:N.InitiaAddress(o.recipient).bech32,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom}}).json();await J_(s,a(r.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:h,msg:m})=>zt.aminoTypes.fromAmino({type:zt.aminoConverters[h].aminoType,value:JSON.parse(m)})),d=await n(i,s,c,{amount:[],gas:"1"},"",{incrementSequence:i===o.srcChainId?2:0}),u=Ve.Tx.fromPartial({body:Ve.TxBody.decode(d.bodyBytes),authInfo:Ve.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:s,hook:H.toBase64(Ve.Tx.encode(u).finish())}}catch(i){throw await Re(i)}}})}function ef(e){return{type:"info",title:"Transaction submitted",description:f.createElement(f.Fragment,null,"Check ",f.createElement(jn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function rn(e,s){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:s}}function tf(e,s){const{txHash:n,srcChainId:r,route:o,values:a}=e,i={chainId:r,txHash:n},l=Pn(o)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:o,values:a,state:l?"success":void 0,tracked:s},isOpWithdraw:l}}function sf(e,s,n){return{...e,recipient:N.InitiaAddress(n).bech32,claimableAt:Date.now()+s.estimated_route_duration_seconds*1e3,amount:s.amount_out,denom:s.dest_asset_denom}}async function nf(e,s,n){for(let a=0;a<=30;a++)try{return await e.post("v2/tx/track",{json:{tx_hash:s,chain_id:n}}).json(),{success:!0,error:null}}catch(i){if(a===30)return{success:!1,error:await Re(i)};await new Promise(l=>setTimeout(l,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function rf(e){const{chainId:s,txHash:n,tracked:r}=e,o=Oe();return E.useQuery({queryKey:Te.txTrack(s,n).queryKey,queryFn:async()=>{try{return await o.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json()}catch(a){throw await Re(a)}},select:({tx_hash:a})=>a,retry:6,retryDelay:5e3,staleTime:U.INFINITY,enabled:!r})}function of(e){const{timestamp:s,chainId:n,txHash:r,tracked:o,state:a}=e,i=Oe();return E.useQuery({queryKey:Te.txStatus(n,r).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:r,chain_id:n}}).json(),enabled:!!r&&o&&!a,refetchInterval:({state:{data:l}})=>{if(!l)return!1;const{status:c}=l;if(c==="STATE_COMPLETED")return!1;const d=s+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),h=Math.floor((d-u)/1e3);return h<=0?1e3:h<=300?5e3:60*1e3},staleTime:U.INFINITY})}var hs=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(hs||{});function Pn(e){const{operations:s,dest_asset_denom:n}=e;return v.has("op_init_transfer",v.head(s))&&n==="uinit"?"OP Bridge withdrawal":"Skip"}const af="_content_c0tee_1",cf="_info_c0tee_6",lf="_arrow_c0tee_11",df="_divider_c0tee_19",uf="_type_c0tee_26",hf="_asset_c0tee_44",mf="_amount_c0tee_52",_f="_lower_c0tee_57",ff="_chain_c0tee_63",pf="_address_c0tee_69",fe={content:af,info:cf,arrow:lf,divider:df,type:uf,asset:hf,amount:mf,lower:_f,chain:ff,address:pf},Eo=e=>{const{source:s,label:n,amount:r,denom:o,chainId:a,address:i,walletIcon:l}=e,{symbol:c=N.truncate(o),decimals:d=0,logo_uri:u=wn}=e,{chain_name:h,pretty_name:m,..._}=Ee(a);return t.jsxs("div",{children:[!s&&t.jsxs("div",{className:fe.arrow,children:[t.jsx("div",{className:fe.divider}),n?t.jsx(Yt,{label:n,children:t.jsx("button",{className:fe.type,children:t.jsx(A.IconArrowDown,{size:12})})}):t.jsx("span",{className:fe.type,children:t.jsx(A.IconArrowDown,{size:12})}),t.jsx("div",{className:fe.divider})]}),t.jsxs("div",{className:fe.content,children:[t.jsx(Ds,{assetLogoUrl:u,chainLogoUrl:_.logo_uri??void 0}),t.jsxs("div",{className:fe.info,children:[t.jsxs("div",{className:fe.asset,children:[t.jsx("span",{className:fe.amount,children:N.formatAmount(r,{decimals:d})}),t.jsx("span",{children:c})]}),t.jsxs("div",{className:fe.lower,children:[t.jsxs("div",{className:fe.chain,children:["on ",m||h]}),i&&t.jsx(fs,{value:i,children:({copy:p,copied:g})=>t.jsxs("button",{className:fe.address,onClick:p,children:[l,g?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:N.truncate(i)})]})})]})]})]})]})},Ct=e=>{const s=Be(e.denom,e.chainId);return t.jsx(Eo,{...e,...s})};Ct.Placeholder=Eo;const gf="_root_1l4he_1",xf="_flexEnd_1l4he_6",yf="_toggle_1l4he_11",jf="_route_1l4he_34",vf="_content_1l4he_41",Lt={root:gf,flexEnd:xf,toggle:yf,route:jf,content:vf};function bf(e){const s=({name:n})=>n==="initia-dex"?"Initia DEX":ys.capitalCase(v.head(n?.split("-")??[])??"");if("transfer"in e)return{label:"Bridge via IBC",...e,...e.transfer};if("bank_send"in e)return{label:"Send",...e,...e.bank_send};if("swap"in e){const n=e.swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...e,...e.swap}}if("axelar_transfer"in e)return{label:"Bridge via Axelar",...e,...e.axelar_transfer};if("cctp_transfer"in e)return{label:"Bridge via CCTP",...e,...e.cctp_transfer};if("hyperlane_transfer"in e)return{label:"Bridge via Hyperlane",...e,...e.hyperlane_transfer};if("evm_swap"in e){const n=e.evm_swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...e,...e.evm_swap}}if("op_init_transfer"in e)return{label:"Bridge via OP Bridge",...e,...e.op_init_transfer};if("go_fast_transfer"in e)return{label:"Bridge via Go Fast",...e,...e.go_fast_transfer};if("eureka_transfer"in e)return{label:"Bridge via Eureka",...e,...e.eureka_transfer};if("stargate_transfer"in e)return{label:"Bridge via Stargate",...e,...e.stargate_transfer};if("layer_zero_transfer"in e)return{label:"Bridge via LayerZero",...e,...e.layer_zero_transfer};throw new Error("Unknown operation type")}const wf=({addressList:e})=>{const{values:s,route:n}=Tt(),{source_asset_denom:r,source_asset_chain_id:o,amount_in:a,operations:i}=n,l=v.zipObj(n.required_chain_addresses,e),{find:c}=Ps(),{connector:d,address:u=""}=xe.useAccount(),[h,m]=Ce.useToggle(!1),_=i.length>1,p=t.jsx(z,{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},b=D=>N.InitiaAddress.equals(D,u)?p:t.jsx(A.IconWallet,{size:11}),k=D=>{const{label:B,amount_out:P,denom:I,denom_out:x=I,chain_id:w,from_chain_id:y,to_chain_id:q=w??y}=D,C=l[q];return{label:_&&!h?void 0:B,amount:P,denom:x,chainId:q,address:C,walletIcon:b(C)}},S=i.map(bf).map(k),T=S.slice(0,-1),j=S[S.length-1];return t.jsxs(G.Collapsible.Root,{className:Lt.root,open:h,onOpenChange:m,children:[_&&t.jsx("div",{className:Lt.flexEnd,children:t.jsx(G.Collapsible.Trigger,{className:Lt.toggle,children:h?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:Lt.route,children:[t.jsx(Ct,{...g,source:!0}),t.jsx(G.Collapsible.Content,{className:Lt.content,children:T.map((D,B)=>t.jsx(ue,{suspenseFallback:t.jsx(Ct.Placeholder,{...D}),errorBoundaryProps:{fallback:t.jsx(Ct.Placeholder,{...D})},children:t.jsx(Ct,{...D})},B))}),t.jsx(Ct,{...j})]})]})},xn=({error:e})=>{const s=ie();return t.jsx(te,{extra:t.jsx(ee,{level:"error",children:e.message}),children:t.jsx(W.White,{onClick:()=>s("/bridge"),children:"Home"})})},Cf=({children:e})=>{const s=Tt(),{route:n,values:r}=s,{required_chain_addresses:o}=n,{srcChainId:a,dstChainId:i,sender:l,recipient:c}=r,{initiaAddress:d,hexAddress:u}=je(),h=St(),m=mt(),_=Vt(),p=m(a),g=_(p),b=o.slice(0,-1).some(P=>{const I=m(P);return _(I)==="cosmos"})&&g!=="cosmos",[k,S]=f.useState(void 0),[T,j]=f.useState(!1),[D,B]=f.useState(null);if(f.useEffect(()=>{(async()=>{try{if(!b)return;if(!h)throw new Error("Wallet not connected");j(!0),B(null);const[{pubkey:I}]=await h.getAccounts();S(I)}catch(I){B(await Re(I))}finally{j(!1)}})()},[b,h]),D)return t.jsx(xn,{error:D});if(T)return t.jsx(te,{children:t.jsx(W.White,{loading:T&&"Generating intermediary addresses..."})});if(!b||k){const P=o.map((I,x)=>{if(x===o.length-1){const F=m(i);return _(F)==="initia"?N.InitiaAddress(c).bech32:c}const w=m(I),y=_(w),q=m(a),C=_(q);switch(y){case"initia":return d;case"evm":return u;case"cosmos":{if(C==="cosmos")return H.toBech32(w.bech32_prefix,H.fromBech32(l).data);if(!k)throw new Error("Pubkey not found");return Ut.pubkeyToAddress(Ut.encodeSecp256k1Pubkey(k),w.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(P)}return null},If=({addressList:e,signedOpHook:s,children:n})=>{const r=Oe(),{route:o,values:a}=Tt(),[i,l]=f.useState(void 0),[c,d]=f.useState(!1),[u,h]=f.useState(null);return f.useEffect(()=>{(async()=>{try{if(o.required_op_hook&&!s)throw new Error("Op hook is required");d(!0),h(null);const _={address_list:e,amount_in:o.amount_in,amount_out:o.amount_out,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom,slippage_tolerance_percent:a.slippagePercent,operations:o.operations,signed_op_hook:s},{txs: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(_){h(_)}finally{d(!1)}})()},[o,a,e,s,r]),u?t.jsx(xn,{error:u}):c?t.jsx(te,{children:t.jsx(W.White,{loading:c&&"Fetching messages..."})}):i?n(i):t.jsx(xn,{error:new Error("Failed to fetch messages")})},Nf=({children:e})=>{const{route:s}=Tt(),n=X_();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)},Sf=({tx:e,children:s})=>{const n=Tr(),r=mt(),{data:o,isLoading:a}=E.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 gn(m,r(u));const _=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async g=>{const{token_contract:b,spender:k}=g,T=await new Ye.ethers.Contract(b,_,m).allowance(h,k);return{approval:g,currentAllowance:BigInt(T.toString())}}))).filter(({approval:g,currentAllowance:b})=>b<BigInt(g.amount)).map(({approval:g})=>g)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:l,isPending:c,error:d}=E.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 gn(h,r(u));for(const _ of o){const{token_contract:p,spender:g,amount:b}=_,k=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new Ye.ethers.Contract(p,k,m).approve(g,b)).wait()}return!0}catch(u){throw await Re(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},kf=({tx:e})=>{const{mutate:s,isPending:n}=Z_(e);return t.jsx(te,{children:t.jsx(W.White,{onClick:()=>s(),loading:n&&"Signing transaction...",children:"Confirm"})})},Af=()=>t.jsx(ft,{title:"Route preview",children:t.jsx(Cf,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(wf,{addressList:e}),t.jsx(Nf,{children:s=>t.jsx(If,{addressList:e,signedOpHook:s,children:n=>t.jsx(Sf,{tx:n,children:t.jsx(kf,{tx:n})})})})]})})}),$f="_button_14cv7_1",Tf="_checkbox_14cv7_10",Ef="_checked_14cv7_23",ls={button:$f,checkbox:Tf,checked:Ef},qf=({checked:e,onClick:s,label:n,className:r})=>t.jsxs("button",{type:"button",className:R(ls.button,r),onClick:s,children:[t.jsx("div",{className:R(ls.checkbox,{[ls.checked]:e}),children:e&&t.jsx(A.IconCheck,{size:12})}),t.jsx("span",{className:ls.label,children:n})]}),Df="_success_t4dfk_1",Pf="_error_t4dfk_5",mr={success:Df,error:Pf},Rf=({tx:e})=>{const[s,n]=To(e);if(!s)throw new Error("Bridge history details not found");const{data:r}=of(s),o=s.state??Bf(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:mr.error,children:t.jsx(A.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:mr.success,children:t.jsx(A.IconCheckCircleFilled,{size:14})});default:return t.jsx(_t,{size:14})}};function Bf(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 Mf="_link_12p3n_1",Ff="_header_12p3n_22",Of="_title_12p3n_30",Lf="_date_12p3n_36",Uf="_explorer_12p3n_40",zf="_fees_12p3n_55",Kf="_label_12p3n_63",Hf="_content_12p3n_67",Wf="_route_12p3n_73",Qf="_row_12p3n_78",Vf="_asset_12p3n_84",Gf="_amount_12p3n_92",Yf="_chain_12p3n_97",Jf="_account_12p3n_106",Zf="_arrow_12p3n_113",X={link:Mf,header:Ff,title:Of,date:Lf,explorer:Uf,fees:zf,label:Kf,content:Hf,route:Wf,row:Qf,asset:Vf,amount:Gf,chain:Yf,account:Jf,arrow:Zf},Xf=({tx:e})=>{const[s,n]=To(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}=rf(s),{address:u="",connector:h}=xe.useAccount(),{find:m}=Ps();f.useEffect(()=>{d&&n($=>{if(!$)throw new Error("Bridge history details not found");return{...$,tracked:!0}})},[n,d]);const{amount_in:_,amount_out:p,source_asset_chain_id:g,source_asset_denom:b,dest_asset_chain_id:k,dest_asset_denom:S,estimated_fees:T=[]}=a,j=Ee(g),D=Ee(k),B=Be(b,g),P=Be(S,k),I=($,V)=>V?t.jsx(z,{src:V,width:12,height:12}):N.InitiaAddress.equals($,u)?t.jsx(z,{src:h?.icon,width:12,height:12}):t.jsx(A.IconWallet,{size:12}),x=($,{symbol:V,decimals:K,logo_uri:le},{chain_name:he,pretty_name:Et,...qt},gt,xt)=>t.jsxs("div",{className:X.row,children:[t.jsx(Ds,{assetLogoUrl:le,chainLogoUrl:qt.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:X.asset,children:[t.jsx("span",{className:X.amount,children:N.formatAmount($,{decimals:K})}),t.jsx("span",{children:V})]}),t.jsxs("div",{className:X.chain,children:[t.jsxs("span",{children:["on ",Et||he]}),t.jsxs("div",{className:X.account,children:[xt,t.jsx("span",{className:"monospace",children:N.truncate(gt)})]})]})]})]}),w=Pn(a),y=f.useMemo(()=>{switch(w){case hs.SKIP:return"Skip Explorer";case hs.OP_WITHDRAW:return"Initia Scan"}},[w]),q=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:X.header,children:[t.jsxs("div",{className:X.title,children:[c?t.jsx(Rf,{tx:e}):t.jsx(_t,{size:14}),t.jsx("div",{className:X.date,children:Nt.format(new Date(l),"h:mm a")})]}),t.jsxs("div",{className:X.explorer,children:[t.jsx("span",{children:y}),t.jsx(A.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:X.route,children:[x(_,B,j,i.sender,I(i.sender,m(i.cosmosWalletName)?.image)),t.jsx("div",{className:X.arrow,children:t.jsx(A.IconArrowDown,{size:12})}),x(p,P,D,i.recipient,I(i.recipient))]}),T.length>0&&t.jsxs("div",{className:X.fees,children:[t.jsx("span",{className:X.label,children:"Fees"}),t.jsx("span",{className:X.content,children:Co(T)})]})]});if(w===hs.OP_WITHDRAW)return t.jsx(Es,{chainId:r,txHash:o,className:X.link,children:q});const C=new URLSearchParams({tx_hash:o,chain_id:r}),F=new URL(`?${C.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:F.toString(),className:X.link,target:"_blank",children:q})},ep="_history_13u9z_1",tp="_header_13u9z_5",sp="_checkbox_13u9z_9",np="_groups_13u9z_13",rp="_dateGroup_13u9z_21",op="_dateHeader_13u9z_26",ap="_list_13u9z_32",at={history:ep,header:tp,checkbox:sp,groups:np,dateGroup:rp,dateHeader:op,list:ap},ip=()=>{const{initiaAddress:e,hexAddress:s}=je(),{history:n,getHistoryDetails:r}=$o(),o=n.filter(_=>r(_)),a=o.filter(_=>{const p=r(_);if(!p)return!1;const{values:g}=p,{sender:b,recipient:k}=g;return[b,k].some(S=>[e,s].includes(S))}),[i,l]=f.useState(1),[c,d]=Ce.useToggle(!a.length),u=c?o:a,h=u.slice(0,i*hr),m=f.useMemo(()=>fo(h,_=>{const p=r(_);if(p)return new Date(p.timestamp)}),[h,r]);return t.jsx(ft,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:at.history,children:[o.length>0&&o.length!==a.length&&t.jsx("header",{className:at.header,children:t.jsx(qf,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:at.checkbox})}),u.length===0?t.jsx(J,{children:"No bridge/swap activity"}):t.jsx("div",{className:at.groups,children:Object.entries(m).map(([_,p])=>t.jsxs("div",{className:at.dateGroup,children:[t.jsx("div",{className:at.dateHeader,children:_}),t.jsx("div",{className:at.list,children:p.map(g=>t.jsx(ue,{children:t.jsx(Xf,{tx:g})},g.txHash))})]},_))}),u.length>i*hr?t.jsx(Io,{onClick:()=>l(_=>_+1)}):n.length>=gs&&t.jsxs(J,{children:["Only the latest ",gs," items are stored. Older entries will be removed automatically."]})]})})},qo=()=>{const e=ie(),s=bs(),n=At(),{closeDrawer:r}=kt(),{closeModal:o}=ws();f.useEffect(()=>{o(),s.startsWith("/bridge/")&&e("/bridge"),(s==="/collection"||s.startsWith("/nft"))&&e("/nfts")},[n]);const a=Ss();if(f.useEffect(()=>{a("Page View")},[s,a]),s==="/connect")return n?null:t.jsx(Vn,{onSuccess:r});if(s==="/blank")return null;if(!n)return t.jsx(Vn,{});switch(s){case"/":case"/nfts":case"/activity":return t.jsx(Hu,{});case"/send":return t.jsx(Xh,{},n);case"/nft":return t.jsx(dm,{});case"/nft/send":return t.jsx(wm,{},n);case"/bridge":return t.jsx(p_,{},n);case"/bridge/preview":return t.jsx(Af,{});case"/bridge/history":return t.jsx(ip,{});case"/op/withdrawals":return t.jsx(Y_,{});case"/tx":return t.jsx(oo,{})}},cp="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",lp=()=>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:cp}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),dp=()=>{se();const e=ye();return Sn(),It(localStorage.getItem(O.BRIDGE_SRC_CHAIN_ID)??e.chainId),It(localStorage.getItem(O.BRIDGE_DST_CHAIN_ID)??e.chainId),null},up=new E.QueryClient({defaultOptions:{queries:{retry:0}}}),hp=({children:e,...s})=>(f.useEffect(()=>{qa()},[]),Ce.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(lp,{}),t.jsx(Ir.Provider,{value:{...yr,...s},children:t.jsx(wr,{children:t.jsx(Ra,{children:t.jsx(G.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(Ya,{children:t.jsxs(bc,{children:[e,t.jsxs(E.QueryClientProvider,{client:up,children:[t.jsx(wc,{}),t.jsx(ue,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(dp,{})}),t.jsx(al,{children:t.jsx(qo,{})})]})]})})})})})})]}):null),mp=({bridge:e})=>t.jsx(wr,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Gr.Provider,{value:!!e,children:t.jsx(ue,{children:t.jsx(qo,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=Kt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=xr;exports.InterwovenKit=mp;exports.InterwovenKitProvider=hp;exports.MAINNET=yr;exports.MoveError=Nr;exports.TESTNET=Vo;exports.initiaPrivyWallet=Yo;exports.initiaPrivyWalletConnector=Go;exports.initiaPrivyWalletOptions=js;exports.injectStyles=Ic;exports.useAddress=At;exports.useHexAddress=$s;exports.useInitiaAddress=ne;exports.useInterwovenKit=je;exports.usePortfolio=Nn;exports.useUsernameQuery=Kr;
|
|
4
|
+
</svg>`,oa=encodeURIComponent(ra),wn=`data:image/svg+xml;utf8,${oa}`,fs=ke.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,s)=>[e,s],resource:(e,s)=>[e.chainId,s.denom],denom:(e,s)=>[e,s],metadata:(e,s)=>[e,s]});function aa(e){const{base:s,symbol:n,denom_units:r=[],display:o,logo_URIs:a,name:i,address:l,traces:c}=e,d=r.find(m=>m.denom===o)?.exponent??r.find(m=>m.denom===s)?.exponent??v.head(r)?.exponent??0,u=a?.png??"";return{denom:s,symbol:n,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function Sr(){const e=A.useQueryClient();return s=>{const n=s?.metadata?.assetlist;return A.queryOptions({queryKey:fs.list(n).queryKey,queryFn:async()=>n?Z.get(n).json():{assets:[]},select:({assets:r})=>{if(!s)return[];const o=r.map(aa);for(const a of o)e.setQueryData(fs.item(s.chainId,a.denom).queryKey,a);return o},staleTime:K.MINUTE})}}function Qt(e){const s=Sr(),{data:n}=A.useSuspenseQuery(s(e));return n}function ia(){const e=oe(),s=Sr();return A.useQueries({queries:e.map(n=>s(n))})}function Ue(e){const s=Qt(e),n=le(),r=Qt(n),o=Ar(e);return a=>{const i=s.find(c=>c.denom===a);if(i)return i;const l=r.find(c=>c.denom===o(a));return l?{...l,denom:a}:{denom:a,symbol:"",decimals:0,logoUrl:wn}}}function kr(e,s){const n=Ue(s),o=A.useQueryClient().getQueryData(fs.item(s.chainId,e).queryKey);return o||n(e)}function Ar(e){const s=le(),n=Qt(e);return r=>{if(e.metadata?.is_l1)return r;if(r.startsWith("l2/")||r.startsWith("ibc/")){const a=n.find(i=>i.denom===r)?.traces;if(a){for(const i of a)if(i.counterparty.chain_name===s.chain_name)return i.counterparty.base_denom}}const o=s.metadata?.ibc_channels?.find(({chain_id:a,version:i})=>a===e.chain_id&&i==="ics20-1")?.channel_id;return o?w.getIbcDenom(o,r):""}}function ca(e){return e.pagination?.next_key??null}async function $r(e,s,n){const r=Z.create(s),o=async(a,i)=>{const l=await r.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[n]??[],d=ca(l),u=[...a,...c];return d?o(u,d):u};return o([],null)}const Hn="usernames";function la({restUrl:e,moduleAddress:s}){const{viewFunction:n}=w.createMoveClient(e);async function r(i){if(!w.InitiaAddress.validate(i))return null;const l=await n({moduleAddress:s,moduleName:Hn,functionName:"get_name_from_address",typeArgs:[],args:[W.toBase64(w.InitiaAddress(i,32).bytes)]});return l?l+".init":null}function o(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function a(i){if(!o(i))return null;const l=await n({moduleAddress:s,moduleName:Hn,functionName:"get_address_from_name",typeArgs:[],args:[Uo.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return l?w.InitiaAddress(l).bech32:null}return{restUrl:e,getUsername:r,getAddress:a,validateUsername:o}}const Is=ke.createQueryKeys("interwovenkit:account",{username:(e,s)=>[e,s],address:(e,s)=>[e,s],balances:(e,s)=>[e,s],txs:(e,s)=>[e,s]});function Tr(){const{restUrl:e}=le(),{usernamesModuleAddress:s}=ee();return la({restUrl:e,moduleAddress:s})}function Er(){const e=ae();return s=>A.queryOptions({queryKey:Is.balances(s.restUrl,e).queryKey,queryFn:()=>$r(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:s.restUrl},"balances"),staleTime:K.SECOND})}function Cn(e){const s=Er(),{data:n}=A.useSuspenseQuery(s(e));return n}function da(){const e=oe(),s=Er();return A.useQueries({queries:e.map(n=>s(n))})}function ua(e){const s=Cn(e),n=Qt(e),r=Ue(e),o=Ar(e),{data:a}=Cs(e),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>n.some(d=>d.denom===c);return v.sortWith([v.descend(({denom:c})=>o(c)==="uinit"),v.descend(({denom:c})=>i(c)),v.descend(({value:c})=>c),v.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>M(d).comparedTo(c)??0,v.descend(({symbol:c})=>c.toLowerCase())],s.filter(({amount:c})=>!M(c).isZero()).map(({amount:c,denom:d})=>{const u=r(d),m=a?.find(({id:_})=>_===u?.denom)?.price??0,h=M(c).times(m).div(M(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:m,value:h}}))}function ha(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:s}=un.PubKey.decode(e.value);return Ht.encodeSecp256k1Pubkey(s)}return js.decodeOptionalPubkey(e)}function ma({typeUrl:e,value:s}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:n,pubKey:r,accountNumber:o,sequence:a}=zo.BaseAccount.decode(s),i=ha(r);return{address:n,pubkey:i,accountNumber:Number(o),sequence:Number(a)}}return qe.accountFromAny({typeUrl:e,value:s})}function _a(e){return e.type==="initia/PubKeyEthSecp256k1"}const fa={...Ht.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function pa(e){if(_a(e)){const s=un.PubKey.fromPartial({key:W.fromBase64(e.value)});return Ko.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(un.PubKey.encode(s).finish())})}return js.encodePubkey(e)}function qr(e){if(e.length!==33||e[0]!==2&&e[0]!==3)throw new Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03");return{type:fa.ethsecp256k1,value:W.toBase64(e)}}function ga(e,s){if(s.length!==64)throw new Error("Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s.");return{pub_key:qr(e),signature:W.toBase64(s)}}const Ae="interwovenkit",U={PUBLIC_KEY:`${Ae}:public-key`,BRIDGE_SRC_CHAIN_ID:`${Ae}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${Ae}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${Ae}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${Ae}:bridge:dst-denom`,BRIDGE_QUANTITY:`${Ae}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${Ae}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${Ae}:bridge:route-type`,BRIDGE_HISTORY:`${Ae}:bridge:history`,OP_REMINDER:`${Ae}:op:reminder`},Ns=()=>{const e=ee();return new js.Registry([...Kt.protoRegistry,...e.protoTypes??[]])},Yt=()=>{const e=ee();return new qe.AminoTypes({...Kt.aminoConverters,...e.aminoConverters})};class xa{constructor(s,n,r){this.address=s,this.signMessage=n,this.layer1RestUrl=r}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const s=`${U.PUBLIC_KEY}:${this.address}`,n=localStorage.getItem(s);if(n)return this.cachedPublicKey=W.fromHex(n),W.fromHex(n);const r=await this.getPublicKeyFromRestApi();if(r)return this.cachedPublicKey=r,localStorage.setItem(s,W.toHex(r)),r;const o=await this.getPublicKey();return this.cachedPublicKey=o,localStorage.setItem(s,W.toHex(o)),o}async getPublicKeyFromRestApi(){try{const n=(await Z.create({prefixUrl:this.layer1RestUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return n?W.fromBase64(n):null}catch{return null}}async getPublicKey(){const s="Sign this message to identify your Initia account.",n=await this.signMessage(s),r=Ze.ethers.hashMessage(s),o=Ze.ethers.SigningKey.recoverPublicKey(r,n);return dn.Secp256k1.compressPubkey(W.fromHex(o.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(s,n){if(this.address!==s)throw new Error("Signer address does not match the provided address");const r=ln.escapeCharacters(ln.sortedJsonStringify(n)),o=await this.signMessage(r),a=W.fromHex(o.replace("0x","")).subarray(0,-1),l=dn.Secp256k1Signature.fromFixedLength(a).toFixedLength(),c=ga(await this.getCachedPublicKey(),l);return{signed:n,signature:c}}}function In(){const e=Ns(),s=Yt(),n=$t(),r=Pr();return async function(o,a,i,l,c,d){if(!n)throw new Error("Signer not initialized");const u=await r(o),{accountNumber:m,...h}=await u.getSequence(a),_=h.sequence+(d?.incrementSequence??0),[g]=await n.getAccounts(),p=pa(qr(g.pubkey)),j=Lo.SignMode.SIGN_MODE_EIP_191,S=i.map(x=>s.toAmino(x)),N=ln.makeSignDoc(S,l,o,c,m,_),{signature:I,signed:b}=await n.signAmino(a,N),D={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:b.msgs.map(x=>s.fromAmino(x)),memo:c}},F=e.encode(D),C=Un.Int53.fromString(b.fee.gas).toNumber(),P=Un.Int53.fromString(b.sequence).toNumber(),y=js.makeAuthInfoBytes([{pubkey:p,sequence:P}],b.fee.amount,C,b.fee.granter,b.fee.payer,j);return Ge.TxRaw.fromPartial({bodyBytes:F,authInfoBytes:y,signatures:[W.fromBase64(I.signature)]})}}function $t(){const e=ae(),{signMessageAsync:s}=ve.useSignMessage(),n=le();return f.useMemo(()=>new xa(e,r=>s({message:r}),n.restUrl),[e,s,n.restUrl])}const zs=new Map,Ks=new Map;function Dr(){const e=Xe();return async s=>{if(zs.has(s))return zs.get(s);const{rpcUrl:n}=e(s),r=await Ln.Comet38Client.create(new Ln.HttpClient(n));return zs.set(s,r),r}}function Pr(){const e=Ns(),s=Yt(),n=$t(),r=ae(),o=Dr();return async a=>{const i=`${r}:${a}`;if(Ks.has(i))return Ks.get(i);if(!n)throw new Error("Signer not initialized");const l=await o(a),c=await qe.SigningStargateClient.createWithSigner(l,n,{registry:e,aminoTypes:s,accountParser:ma,broadcastPollIntervalMs:500});return Ks.set(i,c),c}}function Rr(){const{connector:e}=ve.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new Ze.BrowserProvider(await e.getProvider())}}const Br=f.createContext(null);function Ss(){return f.useContext(Br)}function Fr(){const{location:e}=Ss();return e}function ks(){const{path:e}=Fr();return e}function ft(){const{state:e={}}=Fr();return e}function ya(){const{history:e}=Ss();return e}function he(){const{navigate:e}=Ss();return e}function Mr(){const{reset:e}=Ss();return e}const Nn=({to:e,state:s,shouldReset:n,children:r,onClick:o,...a})=>{const i=he(),l=Mr(),c=d=>{d.preventDefault(),o?.(d),n?l(e,s):i(e,s)};return t.jsx("button",{type:"button",...a,onClick:c,children:r})},Or=({children:e,initialEntry:s})=>{const[n,r]=f.useState([s??{path:"/"}]),o=n[n.length-1],a=f.useCallback((l,c)=>{r(d=>{if(typeof l=="string")return[...d,{path:l,state:c}];const u=d.length+l;if(u<1)return d;const m=v.take(u,d);return c!==void 0?v.adjust(u-1,h=>({...h,state:c}),m):m})},[]),i=f.useCallback((l,c)=>{r([{path:l,state:c}])},[]);return t.jsx(Br.Provider,{value:{location:o,history:n,navigate:a,reset:i},children:e})},Ur=f.createContext(null),As=()=>f.useContext(Ur);class Lr extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(s,n,r,o,a,i,l){super(s),this.name="MoveError",this.originalError=n,this.moduleAddress=r,this.moduleName=o,this.errorCode=a,this.errorCodeHex=i,this.isFromRegistry=l}}const ja=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Hs=new Map;function va(e){const s=e.match(ja);if(!s)return null;const[,n,r,o]=s;return{moduleAddress:`0x${n.replace(/^0+/,"")||"0"}`,moduleName:r,errorCode:o.replace(/^0+/,"")||"0"}}async function ba(e,s,n){const r=`${e}:${s}`;if(Hs.has(r))return Hs.get(r);try{const o=s==="0x1"?"0x1.json":`${e}/${s}.json`,a=`${n}/errors/${o}`,{errors:i={}}=await Z.get(a).json();return Hs.set(r,i),i}catch{return null}}function wa(e,s,n,r,o,a,i){return new Lr(e,s,n,r,o,a,i)}async function Ct(e,s,n){if(!s.metadata?.is_l1&&s.metadata?.minitia?.type!=="minimove")return await Fe(e);const r=va(e.message);if(!r)return await Fe(e);const o=await ba(s.chain_name,r.moduleAddress,n),a=`0x${parseInt(r.errorCode,10).toString(16)}`,i=`Failed with code ${a} in module ${r.moduleName} at ${r.moduleAddress}`,l=o?.[r.moduleName]?.[r.errorCode],c=l||i,d=!!l;return wa(c,e,r.moduleAddress,r.moduleName,r.errorCode,a,d)}const Ca="c33b940c24c17e95f7d9d525d508ac61";function Ia(){const{disableAnalytics:e}=ee();f.useEffect(()=>{e||bn.init(Ca,{autocapture:!1})},[e])}function Na(){const{connector:e}=ve.useAccount(),{defaultChainId:s,disableAnalytics:n}=ee();f.useEffect(()=>{const r=new yr.Identify;e?.name&&r.set("connector",e.name),s&&r.set("defaultChainId",s),bn.identify(r)},[s,e?.name,n])}function $s(){const e=ks();return f.useCallback((n,r)=>{bn.track(n,{path:e,...r})},[e])}const Sa=G.atom(!1);function Tt(){const e=Mr(),[s,n]=G.useAtom(Sa),r=$s();return{isDrawerOpen:s,openDrawer:(i,l)=>{i&&e(i,l),n(!0),r("Widget Opened")},closeDrawer:()=>{n(!1),r("Widget Closed")}}}function zr(){const e=he(),{closeDrawer:s}=Tt(),{disconnect:n}=ve.useDisconnect();return()=>{e("/blank"),s(),n(),localStorage.removeItem(U.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(U.BRIDGE_SRC_DENOM),localStorage.removeItem(U.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(U.BRIDGE_DST_DENOM),localStorage.removeItem(U.BRIDGE_QUANTITY),localStorage.removeItem(U.BRIDGE_SLIPPAGE_PERCENT)}}const Kr="approve",Ts=G.atom(),Hr=G.atom(null);function Wr(){const e=G.useAtomValue(Ts);if(!e)throw new Error("Tx request not found");return e}function Sn(){const e=he(),s=ae(),{defaultChainId:n,registryUrl:r}=ee(),o=Xe(),{openDrawer:a,closeDrawer:i}=Tt(),{openModal:l,closeModal:c}=As(),d=G.useSetAtom(Ts),u=G.useSetAtom(Hr),m=Dr(),h=Pr(),_=$t(),g=Ns(),p=async({messages:C,memo:P,chainId:y=n})=>{try{return await(await h(y)).simulate(s,C,P)}catch(x){throw await Ct(x,o(y),r)}},j=async({messages:C,memo:P,chainId:y=n})=>{const x=await m(y),$=qe.QueryClient.withExtensions(x,qe.setupTxExtension),T=C.map(ie=>g.encodeAsAny(ie)),[R]=await _.getAccounts(),L=Ht.encodeSecp256k1Pubkey(R.pubkey),q=await h(y),{sequence:H}=await q.getSequence(s);return $.tx.simulate(T,P,L,H)},S=async({txRequest:C,broadcaster:P})=>{const x={...{memo:"",chainId:n,gas:C.gas||await p(C),gasAdjustment:Wt,gasPrices:null,spendCoins:[],internal:!1},...C};return new Promise(($,T)=>{d({txRequest:x,resolve:async L=>{try{const q=await h(x.chainId),H=await P(q,Ge.TxRaw.encode(L).finish());$(H),typeof x.internal=="string"&&e(x.internal)}catch(q){T(await Ct(q,o(x.chainId),r))}finally{R()}},reject:L=>{T(L),R()}}),x.internal?l({path:"/tx"}):a("/tx");const R=()=>{if(!x.internal){e("/blank"),i();return}c()}})},N=async C=>{const P=C.chainId??n;try{const y=await S({txRequest:C,broadcaster:async(x,$)=>await x.broadcastTxSync($)});return C.internal&&typeof C.internal!="number"&&(u({txHash:y,chainId:P,status:"loading"}),F({txHash:y,chainId:C.chainId}).then(x=>{u({status:x.code===0?"success":"error",chainId:P,txHash:y})}).catch(()=>{u({status:"error",chainId:P,txHash:y})})),y}catch(y){throw C.internal&&typeof C.internal!="number"&&u({status:"error",chainId:P,error:y}),y}},I=(C,P=30*1e3,y=.5*1e3)=>S({txRequest:C,broadcaster:async(x,$)=>{const T=await x.broadcastTx($,P,y);if(T.code!==0)throw new Error(T.rawLog);return T}}),b=In(),E=async C=>{const P=C.chainId??n;try{const{messages:y,memo:x="",fee:$}=C,T=await h(P),R=await b(P,s,y,$,x);return await T.broadcastTxSync(Ge.TxRaw.encode(R).finish())}catch(y){throw await Ct(y,o(P),r)}},D=async(C,P=30*1e3,y=.5*1e3)=>{const x=C.chainId??n;try{const{messages:$,memo:T="",fee:R}=C,L=await h(x),q=await b(x,s,$,R,T),H=await L.broadcastTx(Ge.TxRaw.encode(q).finish(),P,y);if(H.code!==0)throw new Error(H.rawLog);return H}catch($){throw await Ct($,o(x),r)}},F=async({chainId:C=n,...P})=>{try{const y=await h(C);return await Qr({...P,client:y})}catch(y){throw await Ct(y,o(C),r)}};return{estimateGas:p,simulateTx:j,requestTxSync:N,requestTxBlock:I,submitTxSync:E,submitTxBlock:D,waitForTxConfirmation:F}}async function Qr({txHash:e,client:s,timeoutMs:n=30*1e3,intervalMs:r=.5*1e3}){const o=Date.now();for(;;){const a=await s.getTx(e);if(a){if(a.code!==0)throw new Error(a.rawLog);return a}if(Date.now()-o>=n)throw new Error(`Transaction was submitted, but not found on the chain within ${n/1e3} seconds.`);await new Promise(i=>setTimeout(i,r))}}const ka="INIT",Aa="Initia";function kn(e){return e.assets.reduce((s,{value:n})=>s+(n??0),0)}function $a(e){return e.assets.reduce((s,{quantity:n})=>s.plus(n),M(0)).toString()}function Ta(e,s){return{symbol:s?.symbol??e,logoUrl:s?.logoUrl??wn}}function Wn(e){return v.pick(["chainId","name","logoUrl"],e)}function Ea(e){return v.sortWith([v.descend(({symbol:s})=>s===ka),v.descend(kn),v.descend(({assets:s})=>s.length),v.ascend(({symbol:s})=>s)])(e)}function qa(e){return v.sortWith([v.descend(({value:s})=>s??0),v.descend(({quantity:s})=>Number(s)),v.ascend(({chain:s})=>s.name)])(e)}function Da(e){return v.sortWith([v.descend(({chain:s})=>s.name===Aa),v.ascend(({chain:s})=>s.name),v.ascend(({denom:s})=>s)])(e)}function Pa(e,s){return v.sortWith([v.descend(({chainId:n})=>n===s),v.descend(v.prop("value"))])(e)}function Ra(e,s,n,r,o){const a={};for(const u of e){const m=u.chainId,h=s[m]??[],_=n[m],g=r[m],p=[];for(const{amount:j,denom:S}of h){if(!M(j).gt(0))continue;const N=_?.find(F=>F.denom===S),I=g?.find(F=>F.id===S)?.price,b=N?.decimals??0,E=w.fromBaseUnit(j,{decimals:b}),D=I?M(E).times(I).toNumber():void 0;p.push({...Ta(S,N),amount:j,denom:S,decimals:b,quantity:E,price:I,value:D,address:N?.address,unlisted:!N,chain:Wn(u)})}a[m]=p}const i=new Map;for(const[u,m]of Object.entries(a)){if(m.length===0)continue;const h=e.find(g=>g.chainId===u);if(!h)continue;const _=m.reduce((g,{value:p})=>g+(p??0),0);i.set(u,{...Wn(h),value:_})}const l=new Map;for(const u of Object.values(a))for(const m of u)if(!m.unlisted){const{symbol:h}=m,_=l.get(h)??[];l.set(h,[..._,m])}const c=[];for(const[u,m]of l){const h=v.head(m);if(!h)continue;const _=qa(m);c.push({symbol:u,logoUrl:h.logoUrl,assets:_})}const d=[];for(const u of Object.values(a))for(const m of u)m.unlisted&&d.push(m);return{chainsByValue:Pa(Array.from(i.values()),o),assetGroups:Ea(c),unlistedAssets:Da(d),totalValue:c.reduce((u,m)=>u+kn(m),0)}}function An(){const{defaultChainId:e}=ee(),s=oe(),n=da(),r=ia(),o=na(),a=s.map(h=>h.chainId),i=v.zipObj(a,n.map(v.prop("data"))),l=v.zipObj(a,r.map(v.prop("data"))),c=v.zipObj(a,o.map(v.prop("data"))),d=Ra(s,i,l,c,e),u=[n,r,o].flat().some(({isLoading:h})=>h);return{...d,isLoading:u,refetch:()=>{n.forEach(({refetch:h})=>h()),r.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h())}}}function ae(){const e=Es();return e?w.InitiaAddress(e).bech32:""}function Es(){const{address:e}=ve.useAccount();return e?w.InitiaAddress(e).hex:""}function Et(){const e=Gt(),s=ae(),n=Es();return e.metadata?.minitia?.type==="minievm"?n:s}function Vr(){const e=Et(),s=Tr();return A.useQuery({queryKey:Is.username(s.restUrl,e).queryKey,queryFn:()=>s.getUsername(e),enabled:!!e,staleTime:K.MINUTE})}function fe(){const e=Et(),s=ae(),n=Es(),{data:r}=Vr(),o=$t(),a=zr(),{isDrawerOpen:i,openDrawer:l}=Tt(),c=()=>{l("/")},d=()=>{l("/connect")},u=_=>{l("/bridge",_)},m=Sn();return{address:e,initiaAddress:s,hexAddress:n,username:r,offlineSigner:o,isConnected:!!e,isOpen:i,openConnect:d,openWallet:c,openBridge:u,disconnect:a,...m}}const Ba="_status_tn9m1_1",Fa="_error_tn9m1_9",Qn={status:Ba,error:Fa},X=({error:e,children:s})=>t.jsx("p",{className:B(Qn.status,{[Qn.error]:e}),children:s}),pe=({errorBoundaryProps:e={fallbackRender:({error:r})=>t.jsx(X,{error:!0,children:r.message})},suspenseFallback:s=t.jsx(X,{children:"Loading..."}),children:n})=>t.jsx(jr.ErrorBoundary,{...e,children:t.jsx(f.Suspense,{fallback:s,children:n})});function Ma(){const e=["initia-wallet-widget:last-connected-wallet","initia-wallet-widget:fee-denoms","initia-wallet-widget:chain-ids","initia-wallet-widget:opened-layers-assets","initia-wallet-widget:opened-layers-nft"],s={"initia-wallet-widget:ethereum-public-keys":{prefix:U.PUBLIC_KEY,getSuffix:n=>w.InitiaAddress(n).bech32}};for(const n of e)localStorage.removeItem(n);for(const[n,{prefix:r,getSuffix:o}]of Object.entries(s)){const a=localStorage.getItem(n);if(a)try{const i=JSON.parse(a);for(const[l,c]of Object.entries(i)){const d=`${r}:${o(l)}`;localStorage.setItem(d,c)}localStorage.removeItem(n)}catch{}}}const De=ke.createQueryKeys("interwovenkit:skip",{chains:null,assets:e=>[e],asset:(e,s)=>[e,s],balances:(e,s)=>[e,s],route:(e,s)=>[e,s],routeErrorInfo:e=>[e],txTrack:(e,s)=>[e,s],txStatus:(e,s)=>[e,s]});function Le(){const{routerApiUrl:e}=ee();return f.useMemo(()=>Z.create({prefixUrl:e}),[e])}function kt(e){const s=Le(),n=A.useQueryClient(),{data:r}=A.useSuspenseQuery({queryKey:De.assets(e).queryKey,queryFn:()=>s.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:o})=>{const{assets:a}=o[e]??{assets:[]};for(const i of a)n.setQueryData(De.asset(e,i.denom).queryKey,i);return a.toSorted(v.descend(i=>i.symbol==="INIT"))},staleTime:K.MINUTE});return r}function Gr(e){const s=kt(e);return n=>{const r=s.find(o=>o.denom===n);if(!r)throw new Error(`Asset not found: ${n}`);return r}}function Me(e,s){return Gr(s)(e)}function Yr(){const e=oe();return s=>e.some(n=>n.chain_id===s)}function Zt(){const e=Yr();return s=>e(s.chain_id)?"initia":s.chain_type}function Vt(e){return Zt()(e)}function $n(){const e=Le(),{data:s}=A.useSuspenseQuery({queryKey:De.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:n})=>v.sortWith([v.descend(({chain_name:r})=>r==="initia"),v.ascend(({pretty_name:r})=>r)],n),staleTime:K.MINUTE});return s}function pt(){const e=$n(),s=Ir();return n=>{const r=e.find(a=>a.chain_id===n);if(r)return r;const o=s.find(a=>a.chain_id===n);if(!o)throw new Error(`Chain not found: ${n}`);return{chain_id:o.chain_id,chain_name:o.name,pretty_name:o.pretty_name,logo_uri:o.logo,chain_type:"cosmos",rpc:"",rest:""}}}function Pe(e){return pt()(e)}const Oa=()=>(Ia(),Na(),null),Ua="_loader_4gdsk_1",La={loader:Ua},gt=({size:e=24,color:s="currentColor",border:n=2})=>{const r={width:`${e}px`,height:`${e}px`,borderColor:`${s} ${s} transparent ${s}`,borderWidth:`${n}px`};return t.jsx("div",{className:La.loader,style:r})},za="_button_1n7c4_1",Ka="_outline_1n7c4_25",Ha="_sm_1n7c4_43",Wa="_full_1n7c4_49",Qa="_small_1n7c4_53",Va="_unpadded_1n7c4_83",dt={button:za,outline:Ka,sm:Ha,full:Wa,small:Qa,unpadded:Va},Zr=e=>{const{sm:s,fullWidth:n,loading:r,className:o,children:a,disabled:i,...l}=e;return t.jsx("button",{...l,className:B(dt.button,{[dt.sm]:s,[dt.full]:n},o),disabled:!!r||i,children:r?t.jsxs(t.Fragment,{children:[t.jsx(gt,{color:"currentColor",size:16}),typeof r=="string"&&t.jsx("span",{className:dt.loading,children:r})]}):a})},Ga=({className:e,...s})=>t.jsx(Zr,{...s,className:B(dt.outline,e)}),Ya=({className:e,unpadded:s,...n})=>t.jsx("button",{...n,className:B(dt.small,{[dt.unpadded]:s},e)}),V={White:Zr,Outline:Ga,Small:Ya},Za="_footer_xif7g_1",Ja="_actions_xif7g_10",Vn={footer:Za,actions:Ja},re=({extra:e,className:s,children:n})=>t.jsxs("footer",{className:B(Vn.footer,s),children:[e,t.jsx("div",{className:Vn.actions,children:n})]}),Xa="_scrollable_abvhw_1",ei={scrollable:Xa},ze=({className:e,children:s,ref:n})=>t.jsx("div",{ref:n,className:B(ei.scrollable,e),children:s});function qs(){return Ne.useMediaQuery("(max-width: 576px)")}const hn="interwoven-kit";function Jr(){const e=document.querySelector(hn)||document.body.appendChild(document.createElement(hn));return e.shadowRoot||e.attachShadow({mode:"open"})}function ti(){const{theme:e,container:s}=ee();return f.useEffect(()=>{document.querySelector(hn)?.setAttribute("data-theme",e)},[e]),s??Jr()}function si(e){const s=Jr(),n=document.createElement("style");n.textContent=e,s.appendChild(n)}const Tn=f.createContext(null);function mt(){const{container:e}=f.useContext(Tn);return e}function Xr(e){const s=mt();return s?getComputedStyle(s).getPropertyValue(e):""}function ni(){return Ne.useScrollLock(),null}function ri(e){return/^[A-F0-9]{64}$/i.test(e)}function oi(e,s){const{txHash:n,accountAddress:r,pathSuffix:o}=s;if(n)return ri(n)?v.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,n):void 0;if(r){if(!w.InitiaAddress.validate(r))return;const i=v.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,r);return i&&o?i+o:i}}function ai(e){try{const s=new URL(e,window.location.href);if(!["http:","https:"].includes(s.protocol))throw new Error("Invalid protocol");return s.toString()}catch{return"#"}}const ii="_link_guafb_1",Gn={link:ii},Ds=({chainId:e,txHash:s,accountAddress:n,pathSuffix:r,...o})=>{const{showIcon:a,className:i,children:l,onClick:c,...d}=o,u=Oe(e),m=oi(u,{txHash:s,accountAddress:n,pathSuffix:r}),h=s?w.truncate(s):n?w.truncate(n):"",_=l??h;return m?t.jsxs("a",{...d,href:Ho(ai(m)),className:B(Gn.link,i),onClick:c,target:"_blank",children:[_,a&&t.jsx(k.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:B(Gn.link,i),children:_})},eo=f.createContext(null),En=()=>f.useContext(eo),ci=()=>{const[e,s]=G.useAtom(Hr),{showNotification:n,updateNotification:r,hideNotification:o}=En();return f.useEffect(()=>{if(!e)return;const{status:a,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(Ds,{txHash:l,chainId:i,onClick:o,showIcon:!0,children:"View on Initia Scan"}):null;switch(a){case"loading":n({type:"loading",title:"Transaction is pending..."});break;case"error":r({type:"error",title:"Transaction failed",description:d}),s(null);break;case"success":r({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),s(null);break}},[e,s,n,r,o]),null},ps=({value:e,children:s})=>{const[n,r]=f.useState(!1);return s({copy:async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1e3)}catch{}},copied:n})},li="_placeholder_10r3x_1",di="_logo_10r3x_5",Yn={placeholder:li,logo:di},Q=({src:e,alt:s,placeholder:n,classNames:r,style:o,logo:a,...i})=>{const[l,c]=f.useState(void 0),{width:d,height:u}=i,m=n??t.jsx("div",{className:B(Yn.placeholder,r?.placeholder),style:{width:d,height:u,...o}});return!e||l===e?m:t.jsx("img",{...i,className:B(i.className,{[Yn.logo]:a}),style:{width:d,height:u,...o},src:e,alt:s,loading:"lazy",onError:()=>c(e)})},to=f.createContext(!1),ui="_overlay_2lgi8_1",hi="_fullscreen_2lgi8_15",mi="_content_2lgi8_19",_i="_header_2lgi8_54",fi="_title_2lgi8_63",pi="_close_2lgi8_68",ot={overlay:ui,fullscreen:hi,content:mi,header:_i,title:fi,close:pi},so=({title:e,children:s,trigger:n,className:r,open:o,onOpenChange:a})=>{const i=mt(),l=f.useContext(to);return i?t.jsxs(Ie.Dialog.Root,{open:o,onOpenChange:a,modal:!1,children:[n&&t.jsx(Ie.Dialog.Trigger,{className:r,children:n}),t.jsxs(Ie.Dialog.Portal,{container:i,children:[t.jsx(Ie.Dialog.Backdrop,{className:B(ot.overlay,{[ot.fullscreen]:l}),onClick:()=>a(!1),forceRender:!0}),t.jsxs(Ie.Dialog.Popup,{className:B(ot.content,{[ot.fullscreen]:l}),children:[e&&t.jsxs("header",{className:ot.header,children:[t.jsx(Ie.Dialog.Title,{className:ot.title,children:e}),t.jsx(Ie.Dialog.Close,{className:ot.close,children:t.jsx(k.IconClose,{size:20})})]}),s]})]})]}):null},_t=({title:e,content:s,children:n,className:r})=>{const[o,a]=f.useState(!1),i=()=>a(!1);return t.jsx(so,{title:e,trigger:n,className:r,open:o,onOpenChange:a,children:s(i)})},gi="_root_19tvg_1",xi="_address_19tvg_9",yi="_copy_19tvg_19",ji="_labelWrapper_19tvg_33",vi="_labelCopy_19tvg_43",bi="_labelCopied_19tvg_47",wi="_copied_19tvg_55",Ci="_derived_19tvg_65",Ii="_derivedLabel_19tvg_78",Ni="_derivedAddress_19tvg_82",Si="_hexAddress_19tvg_88",ki="_derivedCopy_19tvg_93",ue={root:gi,address:xi,copy:yi,labelWrapper:ji,labelCopy:vi,labelCopied:bi,copied:wi,derived:Ci,derivedLabel:Ii,derivedAddress:Ni,hexAddress:Si,derivedCopy:ki},Ai=()=>{const e=f.useRef(null),s=f.useRef(null),{initiaAddress:n,hexAddress:r}=fe(),o=Xr("--gray-0");return f.useEffect(()=>{e.current&&(s.current?s.current.update({data:n}):(s.current=new Wo({type:"canvas",width:400,height:400,margin:0,data:n,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:o},cornersSquareOptions:{type:"extra-rounded",color:o},cornersDotOptions:{type:"dot",color:o},backgroundOptions:{color:"transparent"}}),s.current.append(e.current)))},[n,o]),t.jsxs("div",{className:ue.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:ue.address,children:n}),t.jsx(ps,{value:n,children:({copy:a,copied:i})=>t.jsxs("button",{className:B(ue.copy,{[ue.copied]:i}),onClick:a,children:[t.jsx(k.IconCopy,{size:12}),t.jsxs("div",{className:ue.labelWrapper,children:[t.jsx("span",{className:ue.labelCopy,children:"Copy address"}),t.jsx("span",{className:ue.labelCopied,children:"Copied!"})]})]})}),t.jsx(ps,{value:r,children:({copy:a,copied:i})=>t.jsxs("button",{className:B(ue.derived,{[ue.copied]:i}),onClick:a,children:[t.jsx("span",{className:ue.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:ue.derivedAddress,children:[t.jsx("span",{className:ue.hexAddress,children:w.truncate(r)}),t.jsx(k.IconCopy,{size:12,className:ue.derivedCopy}),i&&t.jsx("span",{className:ue.copiedText,children:"Copied!"})]})]})})]})},$i="_header_1cvtq_1",Ti="_account_1cvtq_16",Ei="_name_1cvtq_27",qi="_address_1cvtq_31",Di="_icon_1cvtq_35",Pi="_copied_1cvtq_42",Ri="_button_1cvtq_57",Bi="_qr_1cvtq_68",Fi="_disconnect_1cvtq_72",Mi="_label_1cvtq_82",Oi="_expanded_1cvtq_90",ge={header:$i,account:Ti,name:Ei,address:qi,icon:Di,copied:Pi,button:Ri,qr:Bi,disconnect:Fi,label:Mi,expanded:Oi},Ui=()=>{const e=Gt(),{connector:s}=ve.useAccount(),n=zr(),{address:r,username:o}=fe(),a=o??r,[i,l]=f.useState(!1),c=f.useRef(null),d=Je.useSpring({width:i?140:52,config:{tension:500,friction:30,clamp:!0}}),u=()=>{i?n():l(!0)},m=()=>{i&&(c.current=setTimeout(()=>{l(!1)},500))},h=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return f.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),s?t.jsxs("header",{className:ge.header,children:[t.jsx(ps,{value:r,children:({copy:_,copied:g})=>t.jsxs("button",{className:B(ge.account,{[ge.copied]:g}),onClick:_,children:[t.jsx(Q,{src:s.icon,width:18,height:18}),t.jsx("div",{className:ge.address,children:w.truncate(r)}),t.jsx("div",{className:ge.name,children:w.truncate(a)}),t.jsx(k.IconCopy,{className:ge.icon,size:12}),g?"Copied!":""]})}),e.metadata?.is_l1&&t.jsx(_t,{title:"Initia address",content:()=>t.jsx(Ai,{}),className:B(ge.button,ge.qr),children:t.jsx(k.IconQrCode,{size:16})}),t.jsxs(Je.animated.button,{className:B(ge.button,ge.disconnect,{[ge.expanded]:i}),style:d,onClick:u,onMouseLeave:m,onMouseEnter:h,children:[t.jsx(k.IconSignOut,{size:16}),t.jsx("span",{className:ge.label,children:"Disconnect"})]})]}):null},Li="_overlay_1dhd9_1",zi="_content_1dhd9_27",Ki="_inner_1dhd9_58",Ws={overlay:Li,content:zi,inner:Ki},Hi=({children:e})=>{const{isDrawerOpen:s,closeDrawer:n}=Tt(),{setContainer:r}=f.useContext(Tn),o=qs(),a=ti(),i=G.useAtomValue(Ts),l=A.useIsMutating({mutationKey:[Kr]}),c=()=>{const _=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";n(),i?.reject(new Error(_))},d=ks(),u=he(),m=A.useQueryClient(),h={fallbackRender:({error:_,resetErrorBoundary:g})=>{const p=()=>{d==="/bridge"&&(localStorage.removeItem(U.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(U.BRIDGE_SRC_DENOM),localStorage.removeItem(U.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(U.BRIDGE_DST_DENOM)),u("/"),m.clear(),g()};return t.jsxs(ze,{children:[t.jsx(X,{error:!0,children:_.message}),t.jsx(re,{children:t.jsx(V.White,{onClick:p,children:"Retry"})})]})}};return t.jsx(Ie.Dialog.Root,{open:s,onOpenChange:_=>!_&&c(),modal:!1,children:t.jsxs(Ie.Dialog.Portal,{container:a,children:[o&&t.jsx(Ie.Dialog.Backdrop,{className:Ws.overlay,onClick:c,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[t.jsx("path",{d:"M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z"}),t.jsx("path",{d:"M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z"})]})}),t.jsx(Ie.Dialog.Popup,{className:Ws.content,children:t.jsxs("div",{className:B(Ws.inner,"body"),ref:r,children:[o&&t.jsx(ni,{}),t.jsx(ci,{}),t.jsx(Ui,{}),t.jsx(pe,{errorBoundaryProps:h,children:e})]})})]})})},mn=({children:e})=>{const s=f.useRef(null),[n,r]=f.useState(0),o=Je.useSpring({height:n,config:{tension:500,friction:30,clamp:!0}});return f.useEffect(()=>{if(s.current){const{height:a}=s.current.getBoundingClientRect();r(a)}},[e]),e?t.jsx(Je.animated.div,{style:{overflow:"hidden",...o},children:t.jsx("div",{ref:s,children:e})}):null},Wi="_help_7m3jv_1",Qi="_icon_7m3jv_10",Vi="_info_7m3jv_17",Gi="_warning_7m3jv_21",Yi="_error_7m3jv_25",Zi="_success_7m3jv_31",Qs={help:Wi,icon:Qi,info:Vi,warning:Gi,error:Yi,success:Zi},It=({level:e,className:s,mt:n=8,children:r})=>{if(!r)return null;const o=()=>{switch(e){case"loading":return t.jsx(gt,{size:12});case"info":return t.jsx(k.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(k.IconWarningFilled,{size:12});default:return t.jsx(k.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:B(Qs.help,e&&Qs[e],s),style:{marginTop:n},children:[t.jsx("div",{className:Qs.icon,children:o()}),r]})},Ji="_stack_14kq8_1",Xi="_help_14kq8_6",ec="_info_14kq8_14",tc="_warning_14kq8_19",sc="_error_14kq8_24",nc="_success_14kq8_29",_n={stack:Ji,help:Xi,info:ec,warning:tc,error:sc,success:nc},rc=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(mn,{children:t.jsx("div",{className:_n.stack,children:e})}),ne=e=>t.jsx(It,{...e,className:B(_n.help,_n[e.level]),mt:0});ne.Stack=rc;const oc="_root_hypwm_1",ac="_item_hypwm_10",ic="_chevron_hypwm_14",cc="_trigger_hypwm_19",lc="_content_hypwm_39",Rt={root:oc,item:ac,chevron:ic,trigger:cc,content:lc};function dc(e){const{list:s,getKey:n,renderHeader:r,renderContent:o,footer:a,...i}=e;return t.jsxs(Y.Accordion.Root,{className:Rt.root,type:"multiple",...i,children:[s.map((l,c)=>t.jsxs(Y.Accordion.Item,{className:Rt.item,value:n?.(l)??String(c),children:[t.jsx(Y.Accordion.Header,{children:t.jsxs(Y.Accordion.Trigger,{className:Rt.trigger,children:[r(l),t.jsx(k.IconChevronDown,{className:Rt.chevron,size:16})]})}),t.jsx(Y.Accordion.Content,{className:Rt.content,children:o(l)})]},n?.(l)??c)),a]})}const uc=10;function no(){const e=ae();return(s,n)=>A.queryOptions({queryKey:Is.txs(s.indexerUrl,e).queryKey,queryFn:async()=>{if(!n.enabled)return[];const r={"pagination.reverse":!0,"pagination.limit":uc},{txs:o}=await Z.create({prefixUrl:s.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:r}).json();return o},staleTime:K.SECOND})}function hc(e,s){const n=no();return A.useSuspenseQuery(n(e,s))}function mc(e,s){const n=e.flatMap((r,o)=>(s[o]??[]).map(i=>({...i,chain:r})));return v.sortWith([v.descend(r=>new Date(r.timestamp).getTime())])(n)}const _c=()=>{const e=oe(),s=no(),n=A.useQueries({queries:e.map(i=>s(i,{enabled:!0}))}),r=n.map(v.prop("data")),o=mc(e,r),a=n.some(i=>i.isLoading);return{activities:o,isLoading:a}};function ro(e){const{data:s}=A.useSuspenseQuery({queryKey:ws.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:r}=await Z.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return r.toSorted(v.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const i=o==="uinit"?1:br;return{amount:M(a).times(i).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:r})=>{if(v.isNil(r))throw new Error(`${n} has no price`);return{amount:String(r),denom:n}})},staleTime:K.SECOND});return s}function oo(e){const s=ae(),{data:n}=hc(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const r=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return r;try{return n.find(({tx:a})=>a.auth_info.signer_infos.some(i=>w.InitiaAddress.equals(s,Ze.computeAddress(`0x${W.toHex(dn.Secp256k1.uncompressPubkey(W.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??r}catch{return r}}const fc="_value_9u3br_1",pc="_trigger_9u3br_7",gc="_icon_9u3br_23",xc="_content_9u3br_32",yc="_item_9u3br_40",Bt={value:fc,trigger:pc,icon:gc,content:xc,item:yc},jc=({options:e,value:s,onChange:n})=>{const r=mt(),{txRequest:o}=Wr(),a=Oe(o.chainId),i=Ue(a),l=(p,j)=>{if(w.formatAmount(p,{decimals:j})==="0.000000")return 8},c=({amount:[{amount:p,denom:j}]})=>{if(M(p).isZero())return"0";const{symbol:S,decimals:N}=i(j),I=l(p,N);return`${w.formatAmount(p,{decimals:N,dp:I})} ${S}`};if(e.length===1)return t.jsx("span",{className:"monospace",children:c(e[0])});const d=e.find(p=>p.amount[0].denom===s);if(!d)throw new Error("Fee option not found");const[{amount:u,denom:m}]=d.amount,{decimals:h,symbol:_}=i(m),g=l(u,h);return t.jsxs(Re.Select.Root,{value:s,onValueChange:n,modal:!1,children:[t.jsxs("div",{className:Bt.value,children:[t.jsx("span",{className:"monospace",children:w.formatAmount(u,{decimals:h,dp:g})}),t.jsxs(Re.Select.Trigger,{className:Bt.trigger,children:[t.jsx(Re.Select.Value,{children:_}),t.jsx(Re.Select.Icon,{className:Bt.icon,children:t.jsx(k.IconChevronDown,{size:16})})]})]}),t.jsx(Re.Select.Portal,{container:r,children:t.jsx(Re.Select.Positioner,{className:Bt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(Re.Select.Popup,{children:e.map(p=>{const[{denom:j}]=p.amount;return t.jsx(Re.Select.Item,{className:Bt.item,value:j,children:t.jsx(Re.Select.ItemText,{children:c(p)})},j)})})})})]})},vc="_root_7u427_1",bc="_trigger_7u427_5",wc="_chevron_7u427_13",Cc="_panel_7u427_27",Ic="_details_7u427_38",Nc="_row_7u427_47",bt={root:vc,trigger:bc,chevron:wc,panel:Cc,details:Ic,row:Nc},Sc=({spend:e,fee:s,total:n,balance:r,symbol:o,decimals:a})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:s},e&&{label:"Required (spend + fee)",value:n},{label:"Balance",value:r}].filter(Boolean),l=a===6?void 0:8;return t.jsxs(Ls.Collapsible.Root,{className:bt.root,children:[t.jsxs(Ls.Collapsible.Trigger,{className:bt.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(k.IconChevronDown,{className:bt.chevron,size:16})]}),t.jsx(Ls.Collapsible.Panel,{className:bt.panel,children:t.jsx("div",{className:bt.details,children:i.map(({label:c,value:d})=>t.jsxs("div",{className:bt.row,children:[t.jsx("span",{children:c}),t.jsxs("span",{children:[w.formatAmount(d,{decimals:a,dp:l})," ",o]})]},c))})})]})};function gs(e){switch(typeof e){case"string":return e;case"number":case"bigint":return e.toString();case"boolean":return e?"true":"false";case"object":return e===null?"null":e instanceof Uint8Array?W.toBase64(e):Array.isArray(e)?`[${e.map(gs).join(",")}]`:JSON.stringify(e,(s,n)=>typeof n=="bigint"?n.toString():n);default:return"unknown"}}const kc="_container_1xzyq_1",Ac="_toggle_1xzyq_5",$c="_list_1xzyq_11",Tc="_arg_1xzyq_16",Ec="_type_1xzyq_21",Ft={container:kc,toggle:Ac,list:$c,arg:Tc,type:Ec},qc=ke.createQueryKeys("interwovenkit:move",{abi:(e,s,n,r)=>[e,s,n,r]}),Dc=({type:e,arg:s})=>gs(w.resolveBcsType(e).parse(s)),Pc=({msg:e,chainId:s,fallback:n})=>{const[r,o]=Ne.useToggle(!1),{restUrl:a}=Oe(s),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=A.useQuery({queryKey:qc.abi(a,i,l,c).queryKey,queryFn:async()=>{const h=await Z.create({prefixUrl:a}).get(`initia/move/v1/accounts/${i}/modules/${l}`).json(),g=JSON.parse(h.module.abi).exposed_functions.find(({name:p})=>p===c);if(!g)throw new Error(`Function ${c} not found in module ${l}`);return g.params.filter(p=>!p.startsWith("&"))},staleTime:K.INFINITY});if(!u)return n;const m=(h,_)=>{const g=u[_];return t.jsxs("div",{className:Ft.arg,children:[t.jsx("div",{className:Ft.type,children:g}),t.jsx(jr.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(Dc,{type:g,arg:h})})]},_)};return t.jsxs("div",{className:Ft.container,children:[t.jsx(V.Small,{className:Ft.toggle,onClick:o,disabled:!u,children:r?"Encode":"Decode"}),r?t.jsx("div",{className:Ft.list,children:d.map(m)}):n]})},Rc="_list_r67rl_1",Bc="_key_r67rl_8",Fc="_value_r67rl_13",Vs={list:Rc,key:Bc,value:Fc},Mc=({message:e,chainId:s})=>{const{typeUrl:n,value:r}=e;return t.jsx("div",{className:Vs.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{children:[t.jsx("div",{className:Vs.key,children:o}),t.jsx("div",{className:Vs.value,children:n==="/initia.move.v1.MsgExecute"&&o==="args"?t.jsx(Pc,{msg:r,chainId:s,fallback:gs(a)}):gs(a)})]},o))})},Oc="_item_1n572_1",Uc="_title_1n572_10",Lc="_content_1n572_14",Gs={item:Oc,title:Uc,content:Lc},Ys=({title:e,content:s})=>t.jsxs("div",{className:Gs.item,children:[t.jsx("div",{className:Gs.title,children:e}),t.jsx("div",{className:Gs.content,children:s})]});function Se(e){if(e&&M(e).gt(0)&&M(e).lt(.01))return"<$0.01";const s=w.formatNumber(e,{dp:2});return s?`$${s}`:""}function ao(e,s){const n={};for(const r of e)if(r.attributes.some(a=>a.key==="msg_index")){if(r.type==="coin_spent"){const a=r.attributes.find(l=>l.key==="spender")?.value,i=r.attributes.find(l=>l.key==="amount")?.value;if(a===s&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=n[c]||BigInt(0);n[c]=d-BigInt(l)}}}if(r.type==="coin_received"){const a=r.attributes.find(l=>l.key==="receiver")?.value,i=r.attributes.find(l=>l.key==="amount")?.value;if(a===s&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=n[c]||BigInt(0);n[c]=d+BigInt(l)}}}}return Object.entries(n).filter(([,r])=>r!==BigInt(0)).map(([r,o])=>({amount:o.toString(),denom:r}))}function io(e,s){const n={};for(const r of e)if(r.attributes.some(a=>a.key==="msg_index")&&r.type==="move"){const a=r.attributes.find(c=>c.key==="type_tag")?.value,i=r.attributes.find(c=>c.key==="data")?.value;if(!a||!i)continue;let l;try{l=JSON.parse(i)}catch{continue}if(a==="0x1::fungible_asset::WithdrawEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&w.createUserDerivedObjectAddress(s,u)===c){const h=n[u]||BigInt(0);n[u]=h-BigInt(d)}}if(a==="0x1::fungible_asset::DepositEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&w.createUserDerivedObjectAddress(s,u)===c){const h=n[u]||BigInt(0);n[u]=h+BigInt(d)}}}return Object.entries(n).filter(([,r])=>r!==BigInt(0)).map(([r,o])=>({amount:o.toString(),metadata:r}))}const co=({metadata:e,chain:s,children:n})=>{const{restUrl:r}=s,{data:o}=A.useSuspenseQuery({queryKey:fs.denom(r,e).queryKey,queryFn:()=>Z.create({prefixUrl:r}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:a})=>a,staleTime:K.INFINITY});return n(o)},zc="_root_jioyr_1",Kc="_title_jioyr_7",Hc="_changes_jioyr_13",Wc="_change_jioyr_13",Qc="_amount_jioyr_34",Vc="_text_jioyr_40",Gc="_value_jioyr_47",ut={root:zc,title:Kc,changes:Hc,change:Wc,amount:Qc,text:Vc,value:Gc},lo=({amount:e,asset:s,price:n})=>{const{denom:r,symbol:o,decimals:a,logoUrl:i}=s,l=w.formatAmount(e,{decimals:a}),c=n&&M(w.fromBaseUnit(e,{decimals:a})).times(n).abs();return t.jsxs("div",{className:ut.change,children:[t.jsxs("div",{className:ut.amount,children:[t.jsx(Q,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:ut.text,children:[l," ",o||r]})]}),c&&t.jsx("div",{className:ut.value,children:Se(c)})]})},Yc=({changes:e,chain:s})=>{const n=Ue(s),{data:r}=Cs(s);return e.map(({amount:o,denom:a},i)=>{const l=n(a),c=r?.find(({id:d})=>d===a)?.price;return t.jsx(lo,{amount:o,asset:l,price:c},i)})},Zc=({changes:e,chain:s})=>{const n=Ue(s),{data:r}=Cs(s);return e.map(({amount:o,metadata:a},i)=>t.jsx(co,{metadata:a,chain:s,children:l=>{const c=r?.find(({id:d})=>d===l)?.price;return t.jsx(lo,{amount:o,asset:n(l),price:c})}},i))};function Jc(e,s){return typeof s=="bigint"?s.toString():s}const Xc=ke.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Jc)]}),el=({messages:e,memo:s,chainId:n})=>{const{initiaAddress:r,hexAddress:o}=fe(),a=Oe(n),{simulateTx:i}=Sn(),{data:l}=A.useSuspenseQuery({queryKey:Xc.simulate({messages:e,memo:s,chainId:n}).queryKey,queryFn:()=>i({messages:e,memo:s,chainId:n}),staleTime:K.SECOND}),c=h=>t.jsxs("div",{className:ut.root,children:[t.jsx("h2",{className:ut.title,children:"Estimated changes"}),t.jsx("div",{className:ut.changes,children:h})]});if(!l)return null;const d=l.result?.events??[];if(d.length===0)return null;if(a.metadata?.is_l1||a.metadata?.minitia?.type==="minimove"){const h=io(d,o),[_]=Zn(h);return _.length===0?null:c(t.jsx(Zc,{changes:_,chain:a}))}const u=ao(d,r),[m]=Zn(u);return m.length===0?null:c(t.jsx(Yc,{changes:m,chain:a}))};function Zn(e){return v.partition(s=>new M(s.amount).isNegative(),e)}const tl="_title_kspdu_1",sl="_meta_kspdu_7",nl="_footer_kspdu_14",Zs={title:tl,meta:sl,footer:nl},uo=()=>{const{txRequest:e,resolve:s,reject:n}=Wr(),{messages:r,memo:o,chainId:a,gas:i,gasAdjustment:l,spendCoins:c}=e,d=ae(),u=$t(),m=In(),h=Oe(a),_=Cn(h),g=ro(h),p=oo(h),j=Ue(h),S=(e.gasPrices??g).map(({amount:x,denom:$})=>qe.calculateFee(Math.ceil(i*l),qe.GasPrice.fromString(x+$))),N=S.map(x=>x.amount[0]),I=x=>{const $=_.find(O=>O.denom===x)?.amount??"0",T=N.find(O=>O.denom===x)?.amount??"0",R=c.filter(O=>O.denom===x).reduce((O,be)=>M(O).plus(be.amount),M("0")),L=M(T).plus(R),q=M($).gte(L),{symbol:H,decimals:ie}=j(x);return{symbol:H,decimals:ie,spend:R.gt(0)?R.toFixed():null,fee:T,total:L.toFixed(),balance:$,isSufficient:q}},b=()=>{if(p&&I(p).isSufficient)return p;for(const{denom:x}of N)if(I(x).isSufficient)return x;return N[0]?.denom},[E,D]=f.useState(b),{mutate:F,isPending:C}=A.useMutation({mutationKey:[Kr],mutationFn:async()=>{const x=S.find(T=>T.amount[0].denom===E);if(!x)throw new Error("Fee not found");if(!u)throw new Error("Signer not initialized");const $=await m(a,d,r,x,o);await s($)},onError:async x=>{n(x)}}),P=I(E),y=!P.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(ze,{children:[t.jsx("h1",{className:Zs.title,children:"Confirm tx"}),t.jsxs("div",{className:Zs.meta,children:[t.jsx(Ys,{title:"Chain",content:a}),t.jsx(Ys,{title:"Tx fee",content:t.jsx(jc,{options:S,value:E,onChange:D})}),o&&t.jsx(Ys,{title:"Memo",content:o}),y&&t.jsx(ne,{level:"error",children:t.jsx(Sc,{...P})})]}),t.jsx(el,{messages:r,memo:o,chainId:a}),t.jsx(dc,{list:r,renderHeader:({typeUrl:x})=>vs.sentenceCase(x.split(".").pop().replace(/^Msg/,"")),renderContent:x=>t.jsx(Mc,{message:x,chainId:a})})]}),t.jsxs(re,{className:Zs.footer,children:[t.jsx(V.Outline,{onClick:()=>n(new Error("User rejected")),disabled:C,children:"Reject"}),t.jsx(V.White,{onClick:()=>F(),disabled:y,loading:C,children:"Approve"})]})]})},rl=({children:e})=>{const[{title:s,content:n,path:r},o]=f.useState({}),[a,i]=f.useState(!1),l=G.useAtomValue(Ts),c=f.useCallback(m=>{o(m),i(!0)},[]),d=f.useCallback(()=>{o({}),i(!1)},[]),u=f.useCallback(m=>{m||(l?.reject(new Error("User rejected")),o({})),i(m)},[l]);return t.jsxs(Ur.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(so,{title:s,open:a,onOpenChange:u,children:t.jsx(pe,{children:r==="/tx"?t.jsx(uo,{}):n})})]})},ol="_container_1zg8z_1",al="_toast_1zg8z_10",il="_info_1zg8z_23",cl="_success_1zg8z_27",ll="_error_1zg8z_31",dl="_icon_1zg8z_36",ul="_content_1zg8z_43",hl="_title_1zg8z_46",ml="_description_1zg8z_51",_l="_close_1zg8z_72",Qe={container:ol,toast:al,info:il,success:cl,error:ll,icon:dl,content:ul,title:hl,description:ml,close:_l},fl=({notification:e,onClose:s,...n})=>{const r=Je.useTransition(e,{keys:a=>a?.id||"empty",from:{transform:"translateY(-52px)",opacity:0},enter:{transform:"translateY(0px)",opacity:1},leave:{transform:"translateY(-52px)",opacity:0},config:{tension:500,friction:30,clamp:!0}}),o=a=>{switch(a){case"loading":return t.jsx(gt,{size:16});case"info":case"success":return t.jsx(k.IconCheckCircleFilled,{size:16});case"error":return t.jsx(k.IconCloseCircleFilled,{size:16});default:return null}};return r((a,i)=>{if(!i)return null;const{type:l,title:c,description:d}=i,u=o(l);return t.jsx(Je.animated.div,{style:a,className:Qe.container,children:t.jsxs("div",{className:B(Qe.toast,l&&Qe[l]),...n,children:[u&&t.jsx("div",{className:Qe.icon,children:u}),t.jsxs("div",{className:Qe.content,children:[t.jsx("p",{className:Qe.title,children:c}),d&&t.jsx("div",{className:Qe.description,children:d})]}),t.jsx("button",{className:Qe.close,onClick:s,children:t.jsx(k.IconClose,{size:14})})]})})})},Js=5e3,pl=({children:e})=>{const s=mt(),[n,r]=f.useState(null),o=f.useRef(null),a=f.useRef(!1),i=()=>{o.current&&(clearTimeout(o.current),o.current=null)},l=f.useCallback(()=>{i(),r(null)},[]),c=f.useCallback(h=>{i(),r({...h,id:zn.nanoid()}),h.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Js))},[l]),d=f.useCallback(h=>{i(),r(_=>_?{..._,...h}:{...h,id:zn.nanoid()}),h.autoHide&&!a.current&&(o.current=setTimeout(()=>l(),Js))},[l]),u=()=>{i(),a.current=!0},m=()=>{i(),a.current=!1,n?.autoHide&&(o.current=setTimeout(()=>l(),Js))};return f.useEffect(()=>()=>i(),[]),t.jsxs(eo.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,s&&Qo.createPortal(t.jsx(fl,{notification:n,onClose:l,onMouseEnter:u,onMouseLeave:m}),s)]})},gl=({children:e})=>{const[s,n]=f.useState(null);return t.jsx(Tn.Provider,{value:{container:s,setContainer:n},children:e})},xl="_container_1a4ds_1",yl="_badge_1a4ds_5",Jn={container:xl,badge:yl},ho=e=>{const{offset:s=-4,disabled:n,children:r,className:o}=e;return t.jsxs("div",{className:B(Jn.container,o),children:[r,!n&&t.jsx("div",{className:Jn.badge,style:{right:s,top:s}})]})},jl="_header_acels_1",vl="_back_acels_11",bl="_title_acels_23",Xs={header:jl,back:vl,title:bl},xt=({title:e,backButton:s,extra:n,children:r})=>t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Xs.header,children:[t.jsx(Nn,{to:s??-1,className:Xs.back,shouldReset:!!s,children:t.jsx(k.IconBack,{size:16})}),t.jsx("h1",{className:Xs.title,children:e}),n]}),t.jsx(ze,{children:r})]});function mo(){const{initiaAddress:e,hexAddress:s}=fe(),n=pt(),r=Zt();return o=>{const a=n(o);switch(r(a)){case"initia":return e;case"evm":return s;default:return""}}}function _o(){const e=pt(),s=Zt();return(n,r)=>{const o=e(r);switch(s(o)){case"initia":return w.InitiaAddress.validate(n);case"evm":return Ze.isAddress(n);case"cosmos":try{return W.fromBech32(n).prefix===o.bech32_prefix}catch{return!1}default:return!1}}}function wl(){const e=pt(),s=Zt();return({initialAddress:n,initialChainId:r,chainId:o,fallbackAddress:a})=>{const i=e(r),l=s(i),c=e(o),d=s(c);if(l==="evm"&&d==="initia")return w.InitiaAddress(n).bech32;if(l==="initia"&&d==="evm")return w.InitiaAddress(n).hex;if(l===d)return n;if(a){if(d==="initia")return w.InitiaAddress(a).bech32;if(d==="evm")return w.InitiaAddress(a).hex}return""}}function Cl(){return le().network_type==="testnet"}function et(){return ce.useFormContext()}function Il(){const e=ft(),s=Cl(),n={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},r={...n,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},o={...n,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},a=v.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(U.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(U.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(U.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(U.BRIDGE_DST_DENOM),quantity:localStorage.getItem(U.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(U.BRIDGE_SLIPPAGE_PERCENT)});return{...s?r:o,...a,...e}}const Nl="_root_xwz5z_1",Sl="_header_xwz5z_6",kl="_title_xwz5z_12",Al="_warning_xwz5z_18",$l="_content_xwz5z_22",Tl="_footer_xwz5z_26",El="_secondary_xwz5z_36",at={root:Nl,header:Sl,title:kl,warning:Al,content:$l,footer:Tl,secondary:El},fo=e=>{const{type:s,icon:n,title:r,children:o,primaryButton:a,secondaryButton:i}=e;return t.jsxs(ze,{className:at.root,children:[t.jsxs("header",{className:B(at.header,s&&at[s]),children:[n,t.jsx("h1",{className:at.title,children:r})]}),t.jsx("div",{className:at.content,children:o}),t.jsxs("footer",{className:at.footer,children:[t.jsx(V.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),t.jsxs("button",{className:at.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(k.IconChevronRight,{size:14})]})]})]})},ql="_list_tmcxc_1",Dl="_row_tmcxc_8",Pl="_dt_tmcxc_19",Rl="_asset_tmcxc_25",rs={list:ql,row:Dl,dt:Pl,asset:Rl},Bl=({list:e,onNavigate:s,onDismiss:n})=>{const r=le(),o=Xe(),a=Ue(r);return t.jsx(fo,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:s},secondaryButton:{label:"Do not show again",onClick:n},children:t.jsx("div",{className:rs.list,children:e.toSorted((i,l)=>i.chainId.localeCompare(l.chainId)).map(({txHash:i,chainId:l,amount:c,denom:d})=>{const u=o(l),{decimals:m,symbol:h}=a(d),_=w.formatAmount(c,{decimals:m});return t.jsxs("div",{className:rs.row,children:[t.jsxs("div",{className:rs.dt,children:[t.jsx(Q,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:rs.asset,children:[_," ",h]})]},i)})})})};function en(e,s){return e.chainId===s.chainId&&e.txHash===s.txHash}const os=({chainId:e,txHash:s})=>`${U.OP_REMINDER}:${e}:${s}`,Fl=Vo.atomWithStorage(U.OP_REMINDER,[]);function qt(){const e=ae(),[s=[],n]=G.useAtom(Fl),r=f.useMemo(()=>s.map(c=>{const d=localStorage.getItem(os(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:At.isPast(u)}),[e,s]),o=f.useCallback((c,d)=>{s.some(u=>en(u,c))||(n((u=[])=>[...u,c]),localStorage.setItem(os(c),JSON.stringify(d)))},[s,n]),a=f.useCallback(c=>{n((d=[])=>d.filter(u=>!en(u,c))),localStorage.removeItem(os(c))},[n]),i=f.useCallback(c=>{const d=c.filter(u=>!s.some(m=>en(m,u)));d.length!==0&&n((u=[])=>[...u,...d])},[s,n]),l=f.useCallback((c,d)=>{localStorage.setItem(os(c),JSON.stringify(d)),n((u=[])=>[...u])},[n]);return{reminders:r,addReminder:o,removeReminder:a,syncReminders:i,setReminder:l}}function po(){const e=he(),{openModal:s,closeModal:n}=As(),{reminders:r,setReminder:o}=qt();f.useEffect(()=>{const a=r.filter(c=>!c.dismissed);if(a.length===0)return;const i=()=>{const c=a.every(d=>d.chainId===a[0].chainId)?a[0].chainId:void 0;e("/op/withdrawals",{chainId:c}),l()},l=()=>{n();for(const c of a)o(c,{...c,dismissed:!0})};s({content:f.createElement(Bl,{list:a,onNavigate:i,onDismiss:l})})},[r,n,e,s,o])}const Ml="_wrapper_5ssm8_1",Ol="_balance_5ssm8_11",Ul="_button_5ssm8_15",tn={wrapper:Ml,balance:Ol,button:Ul},go=({onClick:e,children:s,disabled:n})=>t.jsxs("div",{className:tn.wrapper,children:[t.jsx(k.IconWallet,{size:16}),t.jsx("span",{className:tn.balance,children:s}),t.jsx("button",{type:"button",tabIndex:-1,className:tn.button,onClick:()=>e(),disabled:n,children:"MAX"})]}),Ll="_fieldset_y241y_1",zl="_upper_y241y_9",Kl="_select_y241y_14",Hl="_account_y241y_19",Wl="_lower_y241y_24",Ql="_wrapper_y241y_25",Vl="_balance_y241y_32",Gl="_value_y241y_36",Yl="_error_y241y_49",Be={fieldset:Ll,upper:zl,select:Kl,account:Hl,lower:Wl,wrapper:Ql,balance:Vl,value:Gl,error:Yl},fn=e=>{const{selectButton:s,accountButton:n,quantityInput:r,balanceButton:o,value:a,errorMessage:i,hideNumbers:l}=e;return t.jsxs("div",{className:Be.fieldset,children:[t.jsxs("div",{className:Be.upper,children:[t.jsx("div",{className:Be.select,children:s}),t.jsx("div",{className:Be.account,children:n})]}),!l&&t.jsxs("div",{className:Be.lower,children:[r,t.jsxs("div",{className:Be.wrapper,children:[t.jsx("div",{className:Be.balance,children:o}),a&&t.jsx("div",{className:Be.value,children:a})]}),i&&t.jsxs("footer",{className:Be.error,children:[t.jsx(k.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function Jt(){const e=f.useRef(null),s=qs();return f.useEffect(()=>{s||e.current?.focus()},[s]),e}const Zl="_input_h8073_1",Jl={input:Zl};function Xn(e,s){const n=e.replace(/[^0-9.]/g,""),[r,...o]=n.split(".");return o.length===0?r:`${r}.${o.join("").slice(0,s)}`}function xo(e){const{name:s,control:n,dp:r=6,className:o,rules:a,...i}=e,l=Jt();return t.jsx(ce.Controller,{name:s,control:n,rules:a,render:({field:c})=>t.jsx("input",{...c,className:B(Jl.input,o),onChange:d=>c.onChange(Xn(d.target.value,r)),onPaste:d=>{d.preventDefault();const u=d.clipboardData.getData("text");if(!/^[0-9,]+(\.[0-9]+)?$/.test(u))return;const h=u.replace(/,/g,""),_=Xn(h,r);c.onChange(_)},placeholder:"0",inputMode:"decimal",autoComplete:"off",...i,ref:vr.mergeRefs([c.ref,l])})})}const Xl="_input_qpv94_1",ed="_placeholder_qpv94_18",pn={input:Xl,placeholder:ed},td=({children:e})=>t.jsx("p",{className:B(pn.input,{[pn.placeholder]:M(e).isZero()}),children:e}),xs=({balance:e,decimals:s})=>{const{control:n}=ce.useFormContext(),r={required:"Enter amount",validate:o=>M(o).isZero()?"Enter amount":M(w.toBaseUnit(o,{decimals:s})).gt(e??0)?"Insufficient balance":!0};return t.jsx(xo,{name:"quantity",control:n,className:pn.input,rules:r})};xs.ReadOnly=td;const sd="_tooltip_6zakp_1",nd="_arrow_6zakp_43",er={tooltip:sd,arrow:nd},Xt=({label:e,children:s,small:n,...r})=>t.jsxs(Y.Tooltip.Root,{...r,children:[t.jsx(Y.Tooltip.Trigger,{asChild:!0,children:s}),t.jsx(Y.Tooltip.Portal,{container:mt(),children:t.jsxs(Y.Tooltip.Content,{className:B(er.tooltip,{small:n}),collisionBoundary:mt(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(Y.Tooltip.Arrow,{className:er.arrow})]})})]});function qn(e,s){const n=Le();return A.useQuery({queryKey:De.balances(s,e).queryKey,queryFn:()=>n.post("v2/info/balances",{json:{chains:{[s]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>e?r?r[s].denoms??{}:{}:{},enabled:!!e,staleTime:K.SECOND})}function rd(e,s,n){const{data:r={}}=qn(e,s);return v.path([n],r)}const od=[["d",1440*60],["h",3600],["m",60],["s",1]];function gn(e){if(!e)return;const{formattedParts:s}=od.reduce(({remainingSeconds:n,formattedParts:r},[o,a])=>{const i=Math.floor(n/a);return{remainingSeconds:n-i*a,formattedParts:i>0?[...r,`${i}${o}`]:r}},{remainingSeconds:e,formattedParts:[]});return s.join(" ")}function yo(e){return e?.map(s=>{const{amount:n,origin_asset:r}=s;return`${w.formatAmount(n,{decimals:r.decimals??0})} ${r.symbol}`}).join(", ")}function tr(e,s){const{watch:n}=et(),r=n(),o=Le(),a=$s(),i={...r,quantity:e},l=A.useQueryClient();return A.useQuery({queryKey:De.route(i,s?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:c,srcDenom:d,quantity:u,dstChainId:m,dstDenom:h}=i,{decimals:_}=l.getQueryData(De.asset(c,d).queryKey)??{decimals:0},g={amount_in:w.toBaseUnit(u,{decimals:_}),source_asset_chain_id:c,source_asset_denom:d,dest_asset_chain_id:m,dest_asset_denom:h,is_op_withdraw:s?.isOpWithdraw},p=await o.post("v2/fungible/route",{json:g}).json(),j={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return a("Bridge Simulation Success",j),p},enabled:!!Number(i.quantity)&&!s?.disabled,staleTime:K.MINUTE})}function ad(e){return A.useQuery({queryKey:De.routeErrorInfo(e||new Error).queryKey,queryFn:async()=>{if(!e||!(e instanceof Z.HTTPError))return null;const{response:s}=e;return(s.headers.get("content-type")??"").includes("application/json")?(await s.json()).info??null:null}})}function id(){const{watch:e}=et(),{srcChainId:s,srcDenom:n,dstChainId:r,dstDenom:o}=e(),a=Pe(s),i=Vt(a),l=Me(n,s),c=Me(o,r),d=le(),u=oe();return i==="initia"&&r===d.chainId&&l.symbol===c.symbol&&u.find(m=>m.chainId===s)?.metadata?.op_denoms?.includes(c.denom)}const cd="_label_9417z_1",ld="_wrapper_9417z_7",dd="_input_9417z_10",ud="_clear_9417z_18",as={label:cd,wrapper:ld,input:dd,clear:ud},Dn=({mode:e="onChange",myAddress:s,...n})=>{const{validate:r=w.InitiaAddress.validate,chainType:o="initia",onApply:a,ref:i}=n,l=Jt(),{control:c,getValues:d,setValue:u,formState:m}=ce.useFormContext(),h=d("recipient"),[_,g]=f.useState(h),p=Tr(),{data:j,isLoading:S,error:N}=A.useQuery({queryKey:Is.address(p.restUrl,_).queryKey,queryFn:()=>p.getAddress(_),staleTime:K.MINUTE,enabled:p.validateUsername(_)}),I=j??(r(_)?_:""),b=s&&w.InitiaAddress.equals(I,s),E=async()=>{try{const C=await navigator.clipboard.readText();g(C.trim())}catch{}};f.useEffect(()=>{e==="onChange"&&(!_&&!m.dirtyFields.recipient||u("recipient",j??_,{shouldValidate:!0,shouldDirty:!0}))},[m.dirtyFields.recipient,_,e,u,j]);const D=()=>{S||N||(u("recipient",I,{shouldValidate:!0,shouldDirty:!0}),a?.())},F=()=>{if(S)return t.jsx(It,{level:"loading",children:"Resolving username..."});if(N)return t.jsx(It,{level:"error",children:N.message});if(j)return t.jsx(It,{level:"success",className:"monospace",children:j});if(e==="onSubmit"&&_&&!I)return t.jsx(It,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:as.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(V.Small,{type:"button",tabIndex:-1,onClick:E,children:"Paste"})]}),t.jsxs("div",{className:as.wrapper,children:[t.jsx(ce.Controller,{name:"recipient",control:c,rules:{required:"Recipient address is required",validate:C=>r(C)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:B(as.input,"monospace"),value:_,onChange:C=>g(C.target.value.trim()),placeholder:o==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":_?"true":void 0,ref:e==="onSubmit"?vr.mergeRefs([i,l]):i})}),!!_&&t.jsx("button",{type:"button",className:as.clear,onClick:()=>g(""),"aria-label":"Clear recipient",children:t.jsx(k.IconCloseCircleFilled,{size:16})})]}),F(),b&&t.jsx(It,{children:"This is my address"}),e==="onSubmit"&&t.jsx(re,{extra:(!s||!!I&&!b)&&t.jsx(ne,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:t.jsx(V.White,{type:"button",onClick:D,disabled:S||!!N||!I,children:"Apply"})})]})},hd="_scrollable_1p1lw_1",md="_list_1p1lw_5",_d="_item_1p1lw_9",fd="_name_1p1lw_13",is={scrollable:hd,list:md,item:_d,name:fd};function jo({onSelect:e,list:s,...n}){const{getImage:r,getName:o,getKey:a,getIsLoading:i,getDisabled:l}=n;return t.jsx(ze,{className:is.scrollable,children:t.jsx("div",{className:is.list,children:s.map(c=>t.jsxs("button",{className:is.item,onClick:()=>e(c),disabled:i?.(c)||l?.(c),children:[t.jsx(Q,{src:r(c),width:28,height:28}),t.jsx("span",{className:is.name,children:o(c)}),i?.(c)&&t.jsx(gt,{size:16})]},a(c)))})})}function Ps(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:n=>e.find(r=>r.name===n)}}const pd="_account_iwrlj_8",gd="_clear_iwrlj_27",xd="_white_iwrlj_38",Mt={account:pd,clear:gd,white:xd},sr=({type:e})=>{const{watch:s,setValue:n}=et(),{srcChainId:r,dstChainId:o,cosmosWalletName:a}=s(),l=s(e==="src"?"sender":"recipient"),c=Vt(Pe(o)),{list:d,find:u}=Ps(),m=u(a),h=mo(),_=_o(),g=h(o),p=w.InitiaAddress.equals(l,g),j=()=>t.jsx(_t,{title:"Connect wallet",content:I=>t.jsx(jo,{onSelect:async b=>{const E=b.getProvider();if(!E)return window.open(b.fallbackUrl,"_blank");const D=E.getOfflineSigner(r),[{address:F}]=await D.getAccounts();n("sender",F),n("cosmosWalletName",b.name),I()},list:d,getImage:b=>b.image,getName:b=>b.name,getKey:b=>b.name}),className:B(Mt.account,{[Mt.white]:!l}),children:l?t.jsxs(t.Fragment,{children:[m&&t.jsx(Q,{src:m.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:w.truncate(l)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(k.IconChevronRight,{size:14})]})}),S=I=>t.jsx(_t,{title:"Recipient",content:b=>t.jsx(ze,{children:t.jsx(Dn,{mode:"onSubmit",myAddress:g,chainType:c,validate:E=>_(E,o),onApply:b})}),className:Mt.account,children:I}),N=()=>{switch(c){case"initia":case"evm":return p?S(t.jsx(k.IconWallet,{size:14})):t.jsxs("div",{className:Mt.account,children:[t.jsx("span",{className:"monospace",children:w.truncate(l)}),t.jsx("button",{type:"button",className:Mt.clear,onClick:()=>n("recipient",g,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(k.IconCloseCircleFilled,{size:14})})]});case"cosmos":return S(t.jsxs(t.Fragment,{children:[l?t.jsx("span",{className:"monospace",children:w.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx(k.IconEdit,{size:14})]}))}};switch(e){case"src":return j();case"dst":return N()}},yd="_images_cj4xz_1",sn={images:yd},Rs=({assetLogoUrl:e,assetLogoSize:s=36,chainLogoUrl:n,chainLogoSize:r=18,chainLogoOffset:o=6,className:a})=>t.jsxs("div",{className:B(sn.images,a),style:{position:"relative"},children:[t.jsx(Q,{src:e,width:s,height:s,className:sn.asset,logo:!0}),t.jsx(Q,{src:n,width:r,height:r,className:sn.chain,style:{position:"absolute",bottom:0,right:-1*o},logo:!0})]}),jd="_root_1ipwv_1",vd="_content_1ipwv_10",bd="_details_1ipwv_18",wd="_symbol_1ipwv_23",Cd="_chain_1ipwv_31",Id="_chevron_1ipwv_40",it={root:jd,content:vd,details:bd,symbol:wd,chain:Cd,chevron:Id},vo=({asset:e,chain:s,readOnly:n})=>{const r=t.jsxs("div",{className:it.content,children:[t.jsx(Rs,{assetLogoUrl:e.logoUrl,chainLogoUrl:s.logoUrl}),t.jsxs("div",{className:it.details,children:[t.jsx("div",{className:it.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:it.chain,children:["on ",s.name]})]})]});return n?t.jsx("div",{className:it.root,children:r}):t.jsxs("div",{className:it.root,children:[r,t.jsx(k.IconChevronDown,{size:16,className:it.chevron})]})};function Nd(e,s,n){return n.filter(r=>{const o=e.map(a=>r[a]).map(a=>String(a??"").toLowerCase());return v.any(v.includes(s.toLowerCase()),o)})}const Sd="_root_7yxgy_1",kd="_label_7yxgy_7",Ad="_input_7yxgy_19",$d="_hasValue_7yxgy_29",Td="_clear_7yxgy_33",Ot={root:Sd,label:kd,input:Ad,hasValue:$d,clear:Td},Bs=e=>{const{rootClassName:s,padding:n=16,iconSize:r=16,onClear:o,ref:a,...i}=e;return t.jsxs("div",{className:B(Ot.root,s,{[Ot.hasValue]:i.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${r}px`},children:[t.jsx("label",{htmlFor:"search",className:Ot.label,children:t.jsx(k.IconSearch,{size:r})}),t.jsx("input",{className:Ot.input,id:"search",type:"text",maxLength:100,ref:a,...i}),i.value&&t.jsx("button",{type:"button",className:Ot.clear,"aria-label":"Clear search",onMouseDown:l=>l.preventDefault(),onClick:o,children:t.jsx(k.IconCloseCircleFilled,{size:r})})]})},Ed="_container_1voou_1",qd="_search_1voou_6",Dd="_list_1voou_10",Pd="_item_1voou_14",Rd="_logo_1voou_35",Bd="_info_1voou_39",Fd="_symbol_1voou_44",Md="_name_1voou_52",Od="_balance_1voou_58",Ud="_value_1voou_65",je={container:Ed,search:qd,list:Dd,item:Pd,logo:Rd,info:Bd,symbol:Fd,name:Md,balance:Od,value:Ud},es=e=>{const{assets:s,onSelect:n,renderAsset:r=(l,c)=>c(l)}=e,[o,a]=f.useState(""),i=Nd(["symbol"],o,s);return t.jsxs("div",{className:je.container,children:[t.jsx(Bs,{value:o,onChange:l=>a(l.target.value),onClear:()=>a(""),placeholder:"Search by symbol",rootClassName:je.search,padding:20,ref:Jt()}),i.length===0?t.jsx(X,{children:"No assets"}):t.jsx("div",{className:je.list,children:i.map(l=>t.jsx("button",{type:"button",className:je.item,onClick:()=>n(l.denom),children:r(l,c=>{const{denom:d,logoUrl:u,symbol:m,name:h,balance:_,decimals:g,value:p=0}=c;return t.jsxs(t.Fragment,{children:[t.jsx(Q,{src:u,width:32,height:32,className:je.logo,logo:!0}),t.jsxs("div",{className:je.info,children:[t.jsx("div",{className:je.symbol,children:m||d}),t.jsx("div",{className:je.name,children:h})]}),t.jsxs("div",{className:je.balance,children:[_&&t.jsx("div",{children:w.formatAmount(_,{decimals:g})}),p>0&&t.jsx("div",{className:je.value,children:Se(p)})]})]})})},l.denom))})]})},Ld=()=>t.jsxs("div",{className:je.container,children:[t.jsx(Bs,{rootClassName:je.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(X,{children:"Loading..."})]});es.Placeholder=Ld;const zd="_stack_a3b9q_1",Kd="_title_a3b9q_8",Hd="_grid_a3b9q_15",Wd="_item_a3b9q_21",Qd="_button_a3b9q_25",Vd="_active_a3b9q_43",Nt={stack:zd,title:Kd,grid:Hd,item:Wd,button:Qd,active:Vd},ht=({label:e,chains:s,value:n,onSelect:r,getShowIndicator:o})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:Nt.title,children:e}),t.jsx("div",{className:Nt.grid,children:s.map(({chainId:a,name:i,logoUrl:l})=>t.jsx(ho,{offset:-2,disabled:!o?.(a),className:Nt.item,children:t.jsx(Xt,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:B(Nt.button,{[Nt.active]:a===n}),onClick:()=>r(a),children:t.jsx(Q,{src:l,width:28,height:28,logo:!0})})})},a))})]}),Gd=({children:e})=>t.jsx("div",{className:Nt.stack,children:e});ht.Stack=Gd;const Yd=({address:e,chain:s,onSelect:n})=>{const r=kt(s.chain_id),{data:o={}}=qn(e,s.chain_id);return t.jsx(es,{assets:v.sortWith([v.descend(a=>a.symbol==="INIT"),v.descend(a=>a.value),({balance:a="0"},{balance:i="0"})=>M(i).comparedTo(a)??0,v.ascend(a=>a.symbol.toLowerCase())],r.filter(a=>!a.hidden).map(a=>{const{denom:i,symbol:l=w.truncate(i),logo_uri:c}=a,d=o[i]??{};return{...a,symbol:l,decimals:a.decimals??0,logoUrl:c??"",name:a.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:n})},Zd=({type:e,afterSelect:s})=>{const n=e==="src"?"srcChainId":"dstChainId",r=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"sender":"recipient",a=Et(),i=$n(),{watch:l,setValue:c}=et(),d=l(o),u=l(n),m=l(r),[h,_]=f.useState(u),g=Pe(h),p=wl(),j=Yr(),[S,N]=v.partition(b=>j(b.chain_id),i.filter(b=>!b.hidden)),I=b=>{if(u===h&&m===b){s();return}c(n,h),c(r,b),s()};return t.jsxs(t.Fragment,{children:[t.jsxs(ht.Stack,{children:[t.jsx(ht,{label:"Interwoven Economy",chains:S.map(({chain_id:b,chain_name:E,pretty_name:D,logo_uri:F})=>({chainId:b,name:D||E,logoUrl:F??""})),value:h,onSelect:_}),t.jsx(ht,{label:"Chains",chains:N.map(({chain_id:b,chain_name:E,pretty_name:D,logo_uri:F})=>({chainId:b,name:D||E,logoUrl:F??""})),value:h,onSelect:_})]}),t.jsx(pe,{suspenseFallback:t.jsx(es.Placeholder,{}),children:t.jsx(Yd,{address:p({initialAddress:d,initialChainId:u,chainId:h,fallbackAddress:e==="src"?a:void 0}),chain:g,onSelect:I})},h)]})},nr=({type:e})=>{const s=e==="src"?"srcChainId":"dstChainId",n=e==="src"?"srcDenom":"dstDenom",r=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:o}=et(),a=o(s),i=o(n),l=Pe(a),c=Me(i,a);return t.jsx(_t,{title:r,content:d=>t.jsx(Zd,{type:e,afterSelect:d}),children:t.jsx(vo,{asset:{denom:c.denom,decimals:c.decimals??0,symbol:c.symbol,logoUrl:c.logo_uri??""},chain:{chainId:l.chain_id,name:l.pretty_name||l.chain_name,logoUrl:l.logo_uri??""}})})},Jd="_skeleton_1l4jn_1",Xd={skeleton:Jd},nn=({width:e="100%",height:s})=>t.jsx("div",{className:Xd.skeleton,style:{width:e,height:s}}),eu="_stack_1ip8h_1",tu="_button_1ip8h_6",su="_isLoading_1ip8h_19",nu="_disabled_1ip8h_19",ru="_checked_1ip8h_23",ou="_header_1ip8h_37",au="_title_1ip8h_43",iu="_duration_1ip8h_52",cu="_warning_1ip8h_62",lu="_amount_1ip8h_66",du="_value_1ip8h_67",ye={stack:eu,button:tu,isLoading:su,disabled:nu,checked:ru,header:ou,title:au,duration:iu,warning:cu,amount:lu,value:du},uu=({children:e})=>t.jsx("div",{className:ye.stack,children:e}),hs=({label:e,query:s,value:n,onSelect:r,...o})=>{const{data:a,isLoading:i}=s,{watch:l}=et(),{dstChainId:c,dstDenom:d}=l(),u=Me(d,c),m=!i&&o.checked,h=!i&&!a;return t.jsxs("button",{type:"button",className:B(ye.button,{[ye.isLoading]:i,[ye.disabled]:h,[ye.checked]:m}),onClick:()=>{i||h||r(n)},children:[t.jsxs("div",{className:ye.header,children:[t.jsxs("div",{className:ye.title,children:[t.jsx("span",{children:e}),m&&t.jsx(k.IconCheck,{size:14})]}),i?t.jsx(nn,{width:80,height:16}):a?t.jsxs("div",{className:B(ye.duration,{[ye.warning]:n==="op"}),children:[t.jsx(k.IconClockFilled,{size:12}),t.jsx("span",{children:gn(a.estimated_route_duration_seconds)})]}):t.jsx("div",{className:ye.duration,children:"Not available"})]}),(i||a)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ye.amount,children:i?t.jsx(nn,{width:260,height:40}):a?w.formatAmount(a.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:ye.value,children:i?t.jsx(nn,{width:120,height:16}):a?a.usd_amount_out?Se(a.usd_amount_out):"$-":null})]})]})};hs.Stack=uu;const hu="_description_s1yto_1",mu="_presets_s1yto_8",_u="_preset_s1yto_8",fu="_active_s1yto_28",pu="_custom_s1yto_39",gu="_wrapper_s1yto_45",xu="_percent_s1yto_54",$e={description:hu,presets:mu,preset:_u,active:fu,custom:pu,wrapper:gu,percent:xu},rr=["0.1","0.5","1.0"],yu=({afterConfirm:e})=>{const s=et(),n=s.getValues("slippagePercent"),[r,o]=f.useState(null),{control:a,watch:i,getValues:l,setValue:c}=ce.useForm({defaultValues:{value:n}}),d=i("value");f.useEffect(()=>{const p=rr.findIndex(j=>j===n);o(p>=0?p:null)},[n]);const u=(p,j)=>{c("value",p),o(j)},m=()=>{o(null)},h=f.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),_=h?.type==="error",g=({value:p})=>{s.setValue("slippagePercent",p),e()};return t.jsxs(ze,{children:[t.jsx("p",{className:$e.description,children:"Slippage is how much price movement you can tolerate between the time you send out a transaction and the time it's executed."}),t.jsxs("div",{className:$e.presets,children:[rr.map((p,j)=>t.jsxs("button",{type:"button",className:B($e.preset,{[$e.active]:r===j}),onClick:()=>u(p,j),children:[p,"%"]},p)),r!==null?t.jsx("button",{type:"button",className:B($e.preset,$e.custom),onClick:()=>o(null),children:"Custom"}):t.jsxs("div",{className:$e.wrapper,children:[t.jsx(xo,{name:"value",control:a,dp:2,onFocus:m,placeholder:"",className:B($e.preset,$e.active)}),t.jsx("span",{className:$e.percent,children:"%"})]})]}),h&&t.jsx(ne,{level:h.type,children:h.text}),t.jsx(re,{children:t.jsx(V.White,{type:"button",onClick:()=>g(l()),disabled:_,children:"Confirm"})})]})},ju="_form_1coq4_1",vu="_arrow_1coq4_5",bu="_divider_1coq4_13",wu="_flip_1coq4_21",Cu="_meta_1coq4_37",Iu="_row_1coq4_50",Nu="_title_1coq4_56",Su="_description_1coq4_60",ku="_icon_1coq4_67",Au="_edit_1coq4_72",$u="_warning_1coq4_93",_e={form:ju,arrow:vu,divider:bu,flip:wu,meta:Cu,row:Iu,title:Nu,description:Su,icon:ku,edit:Au,warning:$u},Tu=()=>{const e=he(),s=qs(),[n,r]=Ne.useLocalStorage(U.BRIDGE_ROUTE_TYPE,"default"),{watch:o,setValue:a,handleSubmit:i,formState:l}=et(),c=o(),{srcChainId:d,srcDenom:u,dstChainId:m,dstDenom:h,quantity:_,sender:g,slippagePercent:p}=c,j=Xe(),S=Pe(d),N=Vt(S),I=Pe(m),b=Vt(I),E=Me(u,d),D=Me(h,m),{data:F}=qn(g,d),C=rd(g,d,u),P=!C?.amount||M(C.amount).isZero(),[y]=Ne.useDebounceValue(_,300),x=N!=="initia"&&b!=="initia",$=id(),T=tr(y,{disabled:x}),R=tr(y,{isOpWithdraw:!0,disabled:!$}),L=$&&n==="op"?R:T,{data:q,isLoading:H,isFetching:ie,error:O}=L,{data:be}=ad(O),tt=y&&(H||ie),Ke=()=>{a("srcChainId",m),a("srcDenom",h),a("dstChainId",d),a("dstDenom",u),a("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:st,closeModal:de}=As(),me=i(z=>{if(q?.warning){const{type:rt="",message:Us}=q.warning??{};st({content:t.jsx(fo,{type:"warning",icon:t.jsx(k.IconWarningFilled,{size:40}),title:vs.sentenceCase(rt),primaryButton:{label:"Cancel",onClick:de},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:q,values:z}),de()}},children:t.jsx("p",{className:_e.warning,children:Us})})});return}e("/bridge/preview",{route:q,values:z})}),jt=f.useMemo(()=>q?.estimated_fees?.filter(({fee_behavior:z})=>z==="FEE_BEHAVIOR_DEDUCTED")??[],[q]),nt=f.useMemo(()=>q?.estimated_fees?.filter(({fee_behavior:z})=>z==="FEE_BEHAVIOR_ADDITIONAL")??[],[q]),Pt=f.useMemo(()=>{for(const z of nt){const rt=F?.[z.origin_asset.denom]?.amount??"0",Us=q?.source_asset_denom===z.origin_asset.denom?q.amount_in:"0";if(M(rt).lt(M(Us).plus(z.amount??"0")))return`Insufficient ${z.origin_asset.symbol} for fees`}},[F,q,nt]),Mn=f.useMemo(()=>{if(!c.sender)return"Connect wallet";if(!c.quantity||!y)return"Enter amount";if(!c.recipient)return"Enter recipient address";if(l.errors.quantity)return l.errors.quantity.message;if(!q)return"Route not found";if(Pt)return Pt},[y,Pt,l,q,c]),Fo=q?w.formatAmount(q.amount_out,{decimals:D.decimals}):"0",Mo=M(_).gt(0)&&M(_).isEqualTo(w.fromBaseUnit(C?.amount,{decimals:C?.decimals??0})),Oo=(()=>{switch(N){case"initia":return j(d).fees.fee_tokens.some(({denom:z})=>z===u);case"cosmos":return S.fee_assets.some(({denom:z})=>z===u);case"evm":return!Ze.isAddress(u);default:return!1}})(),Os=f.useCallback((z,rt)=>z.length?t.jsxs("div",{className:_e.description,children:[yo(z),!s&&t.jsx(Xt,{label:rt,children:t.jsx("span",{className:_e.icon,children:t.jsx(k.IconInfoFilled,{size:12})})})]}):null,[s]),ts=M(_).gt(0)&&$,On=f.useMemo(()=>q?[{condition:!!q.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Os(jt,"Fee deducted from the amount you receive"),Os(nt,"Fee charged in addition to the amount you enter")]})},{condition:!ts&&!!gn(q.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:_e.description,children:gn(q.estimated_route_duration_seconds)})},{condition:q.does_swap,title:"Slippage",content:t.jsxs("span",{className:_e.description,children:[t.jsxs("span",{children:[p,"%"]}),t.jsx(_t,{title:"Slippage tolerance",content:z=>t.jsx(yu,{afterConfirm:z}),className:_e.edit,children:t.jsx(k.IconSettingFilled,{size:12})})]})}].filter(z=>z.condition):[],[nt,jt,Os,q,ts,p]);return t.jsxs("form",{className:_e.form,onSubmit:me,children:[t.jsx(fn,{selectButton:t.jsx(nr,{type:"src"}),accountButton:N==="cosmos"&&t.jsx(sr,{type:"src"}),quantityInput:t.jsx(xs,{balance:C?.amount,decimals:E?.decimals}),balanceButton:t.jsx(go,{onClick:()=>a("quantity",w.fromBaseUnit(C?.amount,{decimals:E?.decimals??0}),{shouldValidate:!0}),disabled:P,children:w.formatAmount(C?.amount??"0",{decimals:E.decimals})}),value:q?q.usd_amount_in?Se(q.usd_amount_in):"$-":"$0"}),t.jsxs("div",{className:_e.arrow,children:[t.jsx("div",{className:_e.divider}),t.jsx("button",{type:"button",className:_e.flip,onClick:()=>Ke(),children:t.jsx(k.IconChevronDown,{size:16})})]}),t.jsx(fn,{selectButton:t.jsx(nr,{type:"dst"}),accountButton:t.jsx(sr,{type:"dst"}),quantityInput:t.jsx(xs.ReadOnly,{children:Fo}),value:q?q.usd_amount_out?Se(q.usd_amount_out):"$-":"$0",hideNumbers:ts}),t.jsx(mn,{children:ts?t.jsxs(hs.Stack,{children:[t.jsx(hs,{label:"Fast",query:T,value:"default",onSelect:r,checked:n==="default"}),t.jsx(hs,{label:"Lossless",query:R,value:"op",onSelect:r,checked:n==="op"})]}):null}),t.jsx(re,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(ne.Stack,{children:[q?.extra_infos?.map(z=>t.jsx(ne,{level:"info",children:z},z)),be&&t.jsx(ne,{level:"info",children:be}),Mo&&Oo&&t.jsx(ne,{level:"warning",children:"Make sure to leave enough for transaction fee"}),q?.warning&&t.jsx(ne,{level:"warning",children:q.warning.message}),q?.extra_warnings?.map(z=>t.jsx(ne,{level:"warning",children:z},z))]}),t.jsx(mn,{children:On.length>0&&t.jsx("div",{className:_e.meta,children:On.map((z,rt)=>t.jsxs("div",{className:_e.row,children:[t.jsx("span",{className:_e.title,children:z.title}),z.content]},rt))})})]}),children:t.jsx(V.White,{loading:tt&&"Simulating...",disabled:!!Mn,children:Mn??"Preview route"})})]})},Eu=()=>{po();const e=ya(),s=he(),{closeDrawer:n}=Tt(),r=Et(),o=Il(),a=ce.useForm({mode:"onChange",defaultValues:o}),{watch:i,setValue:l}=a,{srcChainId:c,dstChainId:d,srcDenom:u,dstDenom:m,quantity:h,slippagePercent:_,recipient:g}=i();i((y,{name:x})=>{(x==="srcChainId"||x==="srcDenom")&&l("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=mo(),j=p(c),S=p(d),I=_o()(g,d);f.useEffect(()=>{l("cosmosWalletName",void 0),l("sender",j)},[c,j,l]),f.useEffect(()=>{I||l("recipient",S)},[S,I,l]);const b=kt(c),E=kt(d),D=f.useMemo(()=>{if(!b.find(y=>y.denom===u))return`${u} is not available for bridge/swap on ${c}`;if(!E.find(y=>y.denom===m))return`${m} is not available for bridge/swap on ${d}`},[E,d,m,b,c,u]);f.useEffect(()=>{D||(localStorage.setItem(U.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(U.BRIDGE_SRC_DENOM,u),localStorage.setItem(U.BRIDGE_DST_CHAIN_ID,d),localStorage.setItem(U.BRIDGE_DST_DENOM,m),localStorage.setItem(U.BRIDGE_QUANTITY,h),localStorage.setItem(U.BRIDGE_SLIPPAGE_PERCENT,_))},[c,u,d,m,h,_,D]);const F=e[0].path==="/bridge",C=()=>t.jsxs(t.Fragment,{children:[t.jsx(X,{error:!0,children:D}),t.jsx(re,{children:F?t.jsx(V.White,{onClick:n,children:"Close"}):t.jsx(V.White,{onClick:()=>s(-1),children:"Go back"})})]}),{reminders:P}=qt();return t.jsx(xt,{title:"Bridge/Swap",backButton:F?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(V.Small,{onClick:()=>s("/bridge/history"),unpadded:!0,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[t.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),t.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),t.jsx(ho,{offset:0,disabled:P.length===0,children:t.jsx(V.Small,{onClick:()=>s("/op/withdrawals"),disabled:!r,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:D?C():t.jsx(ce.FormProvider,{...a,children:t.jsx(pe,{children:t.jsx(Tu,{})})})})},qu="_button_14cv7_1",Du="_checkbox_14cv7_10",Pu="_checked_14cv7_23",cs={button:qu,checkbox:Du,checked:Pu},Ru=({checked:e,onClick:s,label:n,className:r})=>t.jsxs("button",{type:"button",className:B(cs.button,r),onClick:s,children:[t.jsx("div",{className:B(cs.checkbox,{[cs.checked]:e}),children:e&&t.jsx(k.IconCheck,{size:12})}),t.jsx("span",{className:cs.label,children:n})]}),Bu="_button_1iys9_1",Fu={button:Bu},bo=({onClick:e,disabled:s})=>{const{ref:n,inView:r}=Go.useInView();return f.useEffect(()=>{r&&e()},[r,e]),t.jsxs("button",{className:Fu.button,onClick:e,disabled:s,ref:n,children:[t.jsx("span",{children:"Load more"}),t.jsx(k.IconChevronDown,{size:12})]})};function wo(e,s){return e.reduce((n,r)=>{const o=s(r);if(!o)return n;const a=o.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=n[a]||[];return{...n,[a]:[...i,r]}},{})}const ms=({chainId:e,txHash:s})=>`${U.BRIDGE_HISTORY}:${e}:${s}`,ys=100,or=10;function Co(){const[e,s]=Ne.useLocalStorage(U.BRIDGE_HISTORY,[]),n=f.useCallback((o,a)=>{localStorage.setItem(ms(o),JSON.stringify(a));for(const i of e.slice(ys-1))localStorage.removeItem(ms(i));s((i=[])=>[o,...i.slice(0,ys-1)])},[e,s]),r=f.useCallback(o=>{const a=localStorage.getItem(ms(o));return a?JSON.parse(a):null},[]);return{history:e,addHistoryItem:n,getHistoryDetails:r}}function Io(e){return Ne.useLocalStorage(ms(e),null)}async function Mu(e,s){const n=Z.create({prefixUrl:s}),r=`cosmos/auth/v1beta1/account_info/${e}`;for(let o=1;o<=24;o++)try{return await n.get(r).json()}catch{await new Promise(a=>setTimeout(a,5e3))}throw new Error(`Timeout: ${e} not found`)}async function xn(e,s){const{chain_type:n,chain_id:r,chain_name:o,evm_fee_asset:a,rpc:i}=s;if(n!=="evm")throw new Error(`Chain is not an EVM chain: ${o}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}catch(l){if(v.path(["error","code"],l)!==4902)throw l;if(!a)throw new Error(`Fee asset is not defined for chain: ${o}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(r).toString(16)}`,chainName:o,nativeCurrency:a,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(r).toString(16)}`}])}}function Dt(){return ft()}function Ou(e){const s=he(),{showNotification:n,updateNotification:r,hideNotification:o}=En(),{addHistoryItem:a}=Co(),i=$s(),{route:l,values:c}=Dt(),{srcChainId:d,sender:u,recipient:m,cosmosWalletName:h}=c,_=Rr(),{requestTxSync:g,waitForTxConfirmation:p}=fe(),{find:j}=Ps(),S=Ns(),N=Yt(),I=Pe(d),b=Vt(I),E=Gr(d),D=A.useQueryClient(),{registryUrl:F}=ee(),C=Xe(),{addReminder:P}=qt(),y=Le();return A.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const x=e.cosmos_tx.msgs.map(({msg_type_url:de,msg:me})=>{if(!(de&&me))throw new Error("Invalid transaction data");return N.fromAmino({type:Kt.aminoConverters[de].aminoType,value:JSON.parse(me)})});if(b==="initia"){const{srcDenom:de,quantity:me}=c,{decimals:jt}=E(de),nt=await g({messages:x,chainId:d,internal:1,spendCoins:[{denom:de,amount:w.toBaseUnit(me,{decimals:jt})}]}),Pt=p({txHash:nt,chainId:d});return{txHash:nt,wait:Pt}}const $=j(h)?.getProvider();if(!$)throw new Error("Wallet not connected");const T=$.getOfflineSignerOnlyAmino(d),R=await qe.SigningStargateClient.connectWithSigner(I.rpc,T,{registry:S,aminoTypes:N}),L=await R.getAllBalances(u),q=I.fee_assets.find(de=>L.some(me=>me.denom===de.denom&&M(me.amount).gt(0)));if(!q){const me=["Insufficient balance for fees.",`Available fee assets: ${I.fee_assets.map(jt=>E(jt.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(me)}const{denom:H,gas_price:ie}=q;if(!ie)throw new Error(`Gas price not found for ${H}`);const O=await R.simulate(u,x,""),be=qe.GasPrice.fromString(ie.average+H),tt=qe.calculateFee(Math.ceil(O*Wt),be),Ke=await R.signAndBroadcastSync(u,x,tt),st=Qr({txHash:Ke,client:R});return{txHash:Ke,wait:st}}if("evm_tx"in e){const{chain_id:x,to:$,value:T,data:R}=e.evm_tx,L=await _(),q=await L.getSigner();await xn(L,I);const H=await q.sendTransaction({chainId:x,to:$,value:T,data:`0x${R}`});return{txHash:H.hash,wait:H.wait()}}throw new Error("Unlisted chain type")}catch(x){throw await Fe(x)}},onSuccess:async({txHash:x,wait:$})=>{localStorage.removeItem(U.BRIDGE_QUANTITY),s(-1),n({type:"loading",title:"Transaction is pending..."});try{await $;const T=Pn(l)==="OP Bridge withdrawal",R=T?{success:!0,error:null}:await Hu(y,x,d);if(!R.success&&R.error){const O=R.error instanceof Error?R.error.message:String(R.error);n({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${O}. The transaction may still be processing.`,autoHide:!0})}const L=R.success,H=zu({txHash:x,srcChainId:d,route:l,values:c,recipient:m},L);a(H.tx,H.details),r(Lu(o));const ie=rn(c,x);if(i("Bridge Transaction Success",ie),T){const O=Ku(H.tx,l,m);P(H.tx,O)}}catch(T){const R=T instanceof Error?T.message:String(T);r({type:"error",title:"Transaction not confirmed",description:R});const L={...rn(c,x),error:R};i("Bridge Confirmation Failed",L)}finally{D.invalidateQueries({queryKey:De.balances(d,u).queryKey})}},onError:async x=>{const $=b==="initia"?await Ct(x,C(d),F):x;n({type:"error",title:"Transaction failed",description:$.message});const T=rn(c);i("Bridge Transaction Failed",{...T,error:$.message})}})}function Uu(){const e=Le(),s=ae(),n=In(),{route:r,values:o}=Dt(),a=pt();return A.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:l}=await e.post("op-hook",{json:{source_address:s,source_asset_chain_id:r.source_asset_chain_id,source_asset_denom:r.source_asset_denom,dest_address:w.InitiaAddress(o.recipient).bech32,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom}}).json();await Mu(s,a(r.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:m,msg:h})=>Kt.aminoTypes.fromAmino({type:Kt.aminoConverters[m].aminoType,value:JSON.parse(h)})),d=await n(i,s,c,{amount:[],gas:"1"},"",{incrementSequence:i===o.srcChainId?2:0}),u=Ge.Tx.fromPartial({body:Ge.TxBody.decode(d.bodyBytes),authInfo:Ge.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:s,hook:W.toBase64(Ge.Tx.encode(u).finish())}}catch(i){throw await Fe(i)}}})}function Lu(e){return{type:"info",title:"Transaction submitted",description:f.createElement(f.Fragment,null,"Check ",f.createElement(Nn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function rn(e,s){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:s}}function zu(e,s){const{txHash:n,srcChainId:r,route:o,values:a}=e,i={chainId:r,txHash:n},l=Pn(o)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:o,values:a,state:l?"success":void 0,tracked:s},isOpWithdraw:l}}function Ku(e,s,n){return{...e,recipient:w.InitiaAddress(n).bech32,claimableAt:Date.now()+s.estimated_route_duration_seconds*1e3,amount:s.amount_out,denom:s.dest_asset_denom}}async function Hu(e,s,n){for(let a=0;a<=30;a++)try{return await e.post("v2/tx/track",{json:{tx_hash:s,chain_id:n}}).json(),{success:!0,error:null}}catch(i){if(a===30)return{success:!1,error:await Fe(i)};await new Promise(l=>setTimeout(l,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Wu(e){const{chainId:s,txHash:n,tracked:r}=e,o=Le();return A.useQuery({queryKey:De.txTrack(s,n).queryKey,queryFn:async()=>{try{return await o.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json()}catch(a){throw await Fe(a)}},select:({tx_hash:a})=>a,retry:6,retryDelay:5e3,staleTime:K.INFINITY,enabled:!r})}function Qu(e){const{timestamp:s,chainId:n,txHash:r,tracked:o,state:a}=e,i=Le();return A.useQuery({queryKey:De.txStatus(n,r).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:r,chain_id:n}}).json(),enabled:!!r&&o&&!a,refetchInterval:({state:{data:l}})=>{if(!l)return!1;const{status:c}=l;if(c==="STATE_COMPLETED")return!1;const d=s+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),m=Math.floor((d-u)/1e3);return m<=0?1e3:m<=300?5e3:60*1e3},staleTime:K.INFINITY})}var _s=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(_s||{});function Pn(e){const{operations:s,dest_asset_denom:n}=e;return v.has("op_init_transfer",v.head(s))&&n==="uinit"?"OP Bridge withdrawal":"Skip"}const Vu="_success_t4dfk_1",Gu="_error_t4dfk_5",ar={success:Vu,error:Gu},Yu=({tx:e})=>{const[s,n]=Io(e);if(!s)throw new Error("Bridge history details not found");const{data:r}=Qu(s),o=s.state??Zu(r);switch(f.useEffect(()=>{o!=="loading"&&n(a=>{if(!a)throw new Error("Bridge history details not found");return{...a,tracked:!0,state:o}})},[n,o]),o){case"error":return t.jsx("div",{className:ar.error,children:t.jsx(k.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:ar.success,children:t.jsx(k.IconCheckCircleFilled,{size:14})});default:return t.jsx(gt,{size:14})}};function Zu(e){if(!e)return"loading";switch(e.state){case"STATE_ABANDONED":case"STATE_COMPLETED_ERROR":case"STATE_PENDING_ERROR":return"error";case"STATE_COMPLETED_SUCCESS":return"success";default:return"loading"}}const Ju="_link_12p3n_1",Xu="_header_12p3n_22",eh="_title_12p3n_30",th="_date_12p3n_36",sh="_explorer_12p3n_40",nh="_fees_12p3n_55",rh="_label_12p3n_63",oh="_content_12p3n_67",ah="_route_12p3n_73",ih="_row_12p3n_78",ch="_asset_12p3n_84",lh="_amount_12p3n_92",dh="_chain_12p3n_97",uh="_account_12p3n_106",hh="_arrow_12p3n_113",te={link:Ju,header:Xu,title:eh,date:th,explorer:sh,fees:nh,label:rh,content:oh,route:ah,row:ih,asset:ch,amount:lh,chain:dh,account:uh,arrow:hh},mh=({tx:e})=>{const[s,n]=Io(e);if(!s)throw new Error("Bridge history details not found");const{chainId:r,txHash:o,route:a,values:i,timestamp:l,tracked:c}=s,{data:d}=Wu(s),{address:u="",connector:m}=ve.useAccount(),{find:h}=Ps();f.useEffect(()=>{d&&n(L=>{if(!L)throw new Error("Bridge history details not found");return{...L,tracked:!0}})},[n,d]);const{amount_in:_,amount_out:g,source_asset_chain_id:p,source_asset_denom:j,dest_asset_chain_id:S,dest_asset_denom:N,estimated_fees:I=[]}=a,b=Pe(p),E=Pe(S),D=Me(j,p),F=Me(N,S),C=(L,q)=>q?t.jsx(Q,{src:q,width:12,height:12}):w.InitiaAddress.equals(L,u)?t.jsx(Q,{src:m?.icon,width:12,height:12}):t.jsx(k.IconWallet,{size:12}),P=(L,{symbol:q,decimals:H,logo_uri:ie},{chain_name:O,pretty_name:be,...tt},Ke,st)=>t.jsxs("div",{className:te.row,children:[t.jsx(Rs,{assetLogoUrl:ie,chainLogoUrl:tt.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:te.asset,children:[t.jsx("span",{className:te.amount,children:w.formatAmount(L,{decimals:H})}),t.jsx("span",{children:q})]}),t.jsxs("div",{className:te.chain,children:[t.jsxs("span",{children:["on ",be||O]}),t.jsxs("div",{className:te.account,children:[st,t.jsx("span",{className:"monospace",children:w.truncate(Ke)})]})]})]})]}),y=Pn(a),x=f.useMemo(()=>{switch(y){case _s.SKIP:return"Skip Explorer";case _s.OP_WITHDRAW:return"Initia Scan"}},[y]),$=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:te.header,children:[t.jsxs("div",{className:te.title,children:[c?t.jsx(Yu,{tx:e}):t.jsx(gt,{size:14}),t.jsx("div",{className:te.date,children:At.format(new Date(l),"h:mm a")})]}),t.jsxs("div",{className:te.explorer,children:[t.jsx("span",{children:x}),t.jsx(k.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:te.route,children:[P(_,D,b,i.sender,C(i.sender,h(i.cosmosWalletName)?.image)),t.jsx("div",{className:te.arrow,children:t.jsx(k.IconArrowDown,{size:12})}),P(g,F,E,i.recipient,C(i.recipient))]}),I.length>0&&t.jsxs("div",{className:te.fees,children:[t.jsx("span",{className:te.label,children:"Fees"}),t.jsx("span",{className:te.content,children:yo(I)})]})]});if(y===_s.OP_WITHDRAW)return t.jsx(Ds,{chainId:r,txHash:o,className:te.link,children:$});const T=new URLSearchParams({tx_hash:o,chain_id:r}),R=new URL(`?${T.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:R.toString(),className:te.link,target:"_blank",children:$})},_h="_history_13u9z_1",fh="_header_13u9z_5",ph="_checkbox_13u9z_9",gh="_groups_13u9z_13",xh="_dateGroup_13u9z_21",yh="_dateHeader_13u9z_26",jh="_list_13u9z_32",ct={history:_h,header:fh,checkbox:ph,groups:gh,dateGroup:xh,dateHeader:yh,list:jh},vh=()=>{const{initiaAddress:e,hexAddress:s}=fe(),{history:n,getHistoryDetails:r}=Co(),o=n.filter(_=>r(_)),a=o.filter(_=>{const g=r(_);if(!g)return!1;const{values:p}=g,{sender:j,recipient:S}=p;return[j,S].some(N=>[e,s].includes(N))}),[i,l]=f.useState(1),[c,d]=Ne.useToggle(!a.length),u=c?o:a,m=u.slice(0,i*or),h=f.useMemo(()=>wo(m,_=>{const g=r(_);if(g)return new Date(g.timestamp)}),[m,r]);return t.jsx(xt,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:ct.history,children:[o.length>0&&o.length!==a.length&&t.jsx("header",{className:ct.header,children:t.jsx(Ru,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:ct.checkbox})}),u.length===0?t.jsx(X,{children:"No bridge/swap activity"}):t.jsx("div",{className:ct.groups,children:Object.entries(h).map(([_,g])=>t.jsxs("div",{className:ct.dateGroup,children:[t.jsx("div",{className:ct.dateHeader,children:_}),t.jsx("div",{className:ct.list,children:g.map(p=>t.jsx(pe,{children:t.jsx(mh,{tx:p})},p.txHash))})]},_))}),u.length>i*or?t.jsx(bo,{onClick:()=>l(_=>_+1)}):n.length>=ys&&t.jsxs(X,{children:["Only the latest ",ys," items are stored. Older entries will be removed automatically."]})]})})},bh=({tx:e})=>{const{mutate:s,isPending:n}=Ou(e);return t.jsx(re,{children:t.jsx(V.White,{onClick:()=>s(),loading:n&&"Signing transaction...",children:"Confirm"})})},wh="_content_c0tee_1",Ch="_info_c0tee_6",Ih="_arrow_c0tee_11",Nh="_divider_c0tee_19",Sh="_type_c0tee_26",kh="_asset_c0tee_44",Ah="_amount_c0tee_52",$h="_lower_c0tee_57",Th="_chain_c0tee_63",Eh="_address_c0tee_69",xe={content:wh,info:Ch,arrow:Ih,divider:Nh,type:Sh,asset:kh,amount:Ah,lower:$h,chain:Th,address:Eh},No=e=>{const{source:s,label:n,amount:r,denom:o,chainId:a,address:i,walletIcon:l}=e,{symbol:c=w.truncate(o),decimals:d=0,logo_uri:u=wn}=e,{chain_name:m,pretty_name:h,..._}=Pe(a);return t.jsxs("div",{children:[!s&&t.jsxs("div",{className:xe.arrow,children:[t.jsx("div",{className:xe.divider}),n?t.jsx(Xt,{label:n,children:t.jsx("button",{className:xe.type,children:t.jsx(k.IconArrowDown,{size:12})})}):t.jsx("span",{className:xe.type,children:t.jsx(k.IconArrowDown,{size:12})}),t.jsx("div",{className:xe.divider})]}),t.jsxs("div",{className:xe.content,children:[t.jsx(Rs,{assetLogoUrl:u,chainLogoUrl:_.logo_uri??void 0}),t.jsxs("div",{className:xe.info,children:[t.jsxs("div",{className:xe.asset,children:[t.jsx("span",{className:xe.amount,children:w.formatAmount(r,{decimals:d})}),t.jsx("span",{children:c})]}),t.jsxs("div",{className:xe.lower,children:[t.jsxs("div",{className:xe.chain,children:["on ",h||m]}),i&&t.jsx(ps,{value:i,children:({copy:g,copied:p})=>t.jsxs("button",{className:xe.address,onClick:g,children:[l,p?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:w.truncate(i)})]})})]})]})]})]})},St=e=>{const s=Me(e.denom,e.chainId);return t.jsx(No,{...e,...s})};St.Placeholder=No;const qh="_root_1l4he_1",Dh="_flexEnd_1l4he_6",Ph="_toggle_1l4he_11",Rh="_route_1l4he_34",Bh="_content_1l4he_41",Ut={root:qh,flexEnd:Dh,toggle:Ph,route:Rh,content:Bh};function Fh(e){const s=({name:n})=>n==="initia-dex"?"Initia DEX":vs.capitalCase(v.head(n?.split("-")??[])??"");if("transfer"in e)return{label:"Bridge via IBC",...e,...e.transfer};if("bank_send"in e)return{label:"Send",...e,...e.bank_send};if("swap"in e){const n=e.swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...e,...e.swap}}if("axelar_transfer"in e)return{label:"Bridge via Axelar",...e,...e.axelar_transfer};if("cctp_transfer"in e)return{label:"Bridge via CCTP",...e,...e.cctp_transfer};if("hyperlane_transfer"in e)return{label:"Bridge via Hyperlane",...e,...e.hyperlane_transfer};if("evm_swap"in e){const n=e.evm_swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...e,...e.evm_swap}}if("op_init_transfer"in e)return{label:"Bridge via OP Bridge",...e,...e.op_init_transfer};if("go_fast_transfer"in e)return{label:"Bridge via Go Fast",...e,...e.go_fast_transfer};if("eureka_transfer"in e)return{label:"Bridge via Eureka",...e,...e.eureka_transfer};if("stargate_transfer"in e)return{label:"Bridge via Stargate",...e,...e.stargate_transfer};if("layer_zero_transfer"in e)return{label:"Bridge via LayerZero",...e,...e.layer_zero_transfer};throw new Error("Unknown operation type")}const Mh=({addressList:e})=>{const{values:s,route:n}=Dt(),{source_asset_denom:r,source_asset_chain_id:o,amount_in:a,operations:i}=n,l=v.zipObj(n.required_chain_addresses,e),{find:c}=Ps(),{connector:d,address:u=""}=ve.useAccount(),[m,h]=Ne.useToggle(!1),_=i.length>1,g=t.jsx(Q,{src:s.cosmosWalletName?c(s.cosmosWalletName)?.image:d?.icon,width:12,height:12}),p={amount:a,denom:r,chainId:o,address:s.sender,walletIcon:g},j=E=>w.InitiaAddress.equals(E,u)?g:t.jsx(k.IconWallet,{size:11}),S=E=>{const{label:D,amount_out:F,denom:C,denom_out:P=C,chain_id:y,from_chain_id:x,to_chain_id:$=y??x}=E,T=l[$];return{label:_&&!m?void 0:D,amount:F,denom:P,chainId:$,address:T,walletIcon:j(T)}},N=i.map(Fh).map(S),I=N.slice(0,-1),b=N[N.length-1];return t.jsxs(Y.Collapsible.Root,{className:Ut.root,open:m,onOpenChange:h,children:[_&&t.jsx("div",{className:Ut.flexEnd,children:t.jsx(Y.Collapsible.Trigger,{className:Ut.toggle,children:m?t.jsxs(t.Fragment,{children:[t.jsx(k.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(k.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:Ut.route,children:[t.jsx(St,{...p,source:!0}),t.jsx(Y.Collapsible.Content,{className:Ut.content,children:I.map((E,D)=>t.jsx(pe,{suspenseFallback:t.jsx(St.Placeholder,{...E}),errorBoundaryProps:{fallback:t.jsx(St.Placeholder,{...E})},children:t.jsx(St,{...E})},D))}),t.jsx(St,{...b})]})]})},yn=({error:e})=>{const s=he();return t.jsx(re,{extra:t.jsx(ne,{level:"error",children:e.message}),children:t.jsx(V.White,{onClick:()=>s("/bridge"),children:"Home"})})},Oh=({children:e})=>{const s=Dt(),{route:n,values:r}=s,{required_chain_addresses:o}=n,{srcChainId:a,dstChainId:i,sender:l,recipient:c}=r,{initiaAddress:d,hexAddress:u}=fe(),m=$t(),h=pt(),_=Zt(),g=h(a),p=_(g),j=o.slice(0,-1).some(F=>{const C=h(F);return _(C)==="cosmos"})&&p!=="cosmos",[S,N]=f.useState(void 0),[I,b]=f.useState(!1),[E,D]=f.useState(null);if(f.useEffect(()=>{(async()=>{try{if(!j)return;if(!m)throw new Error("Wallet not connected");b(!0),D(null);const[{pubkey:C}]=await m.getAccounts();N(C)}catch(C){D(await Fe(C))}finally{b(!1)}})()},[j,m]),E)return t.jsx(yn,{error:E});if(I)return t.jsx(re,{children:t.jsx(V.White,{loading:I&&"Generating intermediary addresses..."})});if(!j||S){const F=o.map((C,P)=>{if(P===o.length-1){const R=h(i);return _(R)==="initia"?w.InitiaAddress(c).bech32:c}const y=h(C),x=_(y),$=h(a),T=_($);switch(x){case"initia":return d;case"evm":return u;case"cosmos":{if(T==="cosmos")return W.toBech32(y.bech32_prefix,W.fromBech32(l).data);if(!S)throw new Error("Pubkey not found");return Ht.pubkeyToAddress(Ht.encodeSecp256k1Pubkey(S),y.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(F)}return null},Uh=({tx:e,children:s})=>{const n=Rr(),r=pt(),{data:o,isLoading:a}=A.useQuery({queryKey:["erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:u,signer_address:m}=e.evm_tx,h=await n();await xn(h,r(u));const _=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async p=>{const{token_contract:j,spender:S}=p,I=await new Ze.ethers.Contract(j,_,h).allowance(m,S);return{approval:p,currentAllowance:BigInt(I.toString())}}))).filter(({approval:p,currentAllowance:j})=>j<BigInt(p.amount)).map(({approval:p})=>p)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:l,isPending:c,error:d}=A.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!o||o.length===0)throw new Error("No approvals needed");const{chain_id:u}=e.evm_tx,m=await n(),h=await m.getSigner();await xn(m,r(u));for(const _ of o){const{token_contract:g,spender:p,amount:j}=_,S=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new Ze.ethers.Contract(g,S,h).approve(p,j)).wait()}return!0}catch(u){throw await Fe(u)}}});return a?t.jsx(re,{children:t.jsx(V.White,{loading:"Checking approvals..."})}):o&&o.length>0&&!l?t.jsx(re,{extra:t.jsx(ne,{level:"error",children:d?.message}),children:t.jsx(V.White,{onClick:()=>i(),loading:c&&"Approving tokens...",children:"Approve tokens"})}):s},Lh=({addressList:e,signedOpHook:s,children:n})=>{const r=Le(),{route:o,values:a}=Dt(),[i,l]=f.useState(void 0),[c,d]=f.useState(!1),[u,m]=f.useState(null);return f.useEffect(()=>{(async()=>{try{if(o.required_op_hook&&!s)throw new Error("Op hook is required");d(!0),m(null);const _={address_list:e,amount_in:o.amount_in,amount_out:o.amount_out,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom,slippage_tolerance_percent:a.slippagePercent,operations:o.operations,signed_op_hook:s},{txs:g}=await r.post("v2/fungible/msgs",{json:_}).json();if(!g||g.length===0)throw new Error("No transaction data found");const[p]=g;l(p)}catch(_){m(_)}finally{d(!1)}})()},[o,a,e,s,r]),u?t.jsx(yn,{error:u}):c?t.jsx(re,{children:t.jsx(V.White,{loading:c&&"Fetching messages..."})}):i?n(i):t.jsx(yn,{error:new Error("Failed to fetch messages")})},zh=({children:e})=>{const{route:s}=Dt(),n=Uu();return s.required_op_hook&&!n.data?t.jsx(re,{extra:t.jsx(ne,{level:"error",children:n.error?.message}),children:t.jsx(V.White,{onClick:()=>n.mutate(),loading:n.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(n.data)},Kh=()=>t.jsx(xt,{title:"Route preview",children:t.jsx(Oh,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(Mh,{addressList:e}),t.jsx(zh,{children:s=>t.jsx(Lh,{addressList:e,signedOpHook:s,children:n=>t.jsx(Uh,{tx:n,children:t.jsx(bh,{tx:n})})})})]})})}),So=f.createContext(null);function Fs(){return f.useContext(So)}const yt=ke.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,s)=>[e,s],latestOutput:e=>[e],output:(e,s)=>[e,s],outputResponse:(e,s)=>[e,s],withdrawalClaimed:(e,s)=>[e,s]});function Ms(){const{restUrl:e}=le();return f.useMemo(()=>Z.create({prefixUrl:e}),[e])}function Hh(e){const s=Ms(),{data:n}=A.useSuspenseQuery({queryKey:yt.bridge(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:K.INFINITY});return n}const ir=20;function Wh(e){const s=ae();return A.useSuspenseInfiniteQuery({queryKey:yt.withdrawals(e,s).queryKey,queryFn:async({pageParam:n})=>{if(!s)return[];const r={limit:ir,offset:n,order:"desc"},{withdrawals:o}=await Z.create({prefixUrl:e}).get(`withdrawals/${s}`,{searchParams:r}).json();return o},getNextPageParam:n=>{const r=v.last(n)?.sequence;return n.length<ir||!r||r<=1?null:r-1},initialPageParam:0,staleTime:K.SECOND})}function Qh(e){const s=Ms(),{data:n}=A.useSuspenseQuery({queryKey:yt.latestOutput(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:r})=>{const[o]=r;return o||null},staleTime:K.SECOND});return n}function Vh({bridge_id:e,output_index:s}){const n=Ms(),{data:r}=A.useSuspenseQuery({queryKey:yt.output(e,s).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${e}/outputs/${s}`).json()}catch{return null}},staleTime:K.SECOND});return r}function Gh({bridge_id:e,sequence:s}){const r=oe().find(({metadata:c})=>c?.op_bridge_id===e.toString())?.chain_id;if(!r)throw new Error(`Chain not found for bridge_id: ${e}`);const a=Xe()(r);if(!a)throw new Error(`Chain not found: ${r}`);const i=a.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${r}`);const{data:l}=A.useSuspenseQuery({queryKey:yt.outputResponse(i,s).queryKey,queryFn:()=>Z.create({prefixUrl:i}).get(`withdrawal/${s}`).json(),staleTime:K.SECOND});return l}function ko(e,s){const{bridge_id:n}=e,r=Ms(),{data:o}=A.useSuspenseQuery({queryKey:yt.withdrawalClaimed(n,s).queryKey,queryFn:()=>r.get(`opinit/ophost/v1/bridges/${n}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:s}}).json(),select:({claimed:a})=>a,staleTime:({state:{data:a}})=>a?.claimed?1/0:K.SECOND});return o}function Lt(e){return Yo.sha3_256.create().update(e).digest()}function on(e,s){const n=new ArrayBuffer(s);return new DataView(n).setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}function Ao(e){const{bridge_id:s,sequence:n,amount:r,from:o,to:a}=e,i=on(s.toString(),8),l=on(n.toString(),8),c=on(r.amount,8),d=ss.concatBytes(i,l,Lt(ss.utf8ToBytes(o)),Lt(ss.utf8ToBytes(a)),Lt(ss.utf8ToBytes(r.denom)),c);return Lt(Lt(d))}const Yh="_button_1btdg_1",Zh="_claimed_1btdg_23",cr={button:Yh,claimed:Zh},Jh=()=>{const{withdrawalTx:e}=Fs(),{bridge_id:s,sequence:n,amount:r,output_index:o,withdrawal_proofs:a,storage_root:i,from:l,to:c,version:d}=e,u=le(),m=ae(),{requestTxSync:h,waitForTxConfirmation:_}=fe(),g=Gh(e),p=W.toBase64(Ao(e)),j=ko(e,p),S=A.useQueryClient(),{mutate:N,isPending:I}=A.useMutation({mutationFn:async()=>{if(!g)throw new Error("Output not found");const{last_block_hash:b}=g;return h({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:m,bridgeId:BigInt(s),outputIndex:BigInt(o),withdrawalProofs:a.map(W.fromBase64),from:l,to:c,sequence:BigInt(n),amount:r,version:W.fromBase64(d),storageRoot:W.fromBase64(i),lastBlockHash:W.fromBase64(b)}}],internal:!0})},onSuccess:async b=>{await _({chainId:u.chain_id,txHash:b}),S.invalidateQueries({queryKey:yt.withdrawalClaimed(s,p).queryKey})}});return j?t.jsxs("div",{className:cr.claimed,children:[t.jsx(k.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:cr.button,onClick:()=>N(),disabled:I,children:"Claim"})},Xh=({children:e})=>{const{withdrawalTx:s}=Fs(),n=Hh(s.bridge_id),r=Vh(s),o=f.useMemo(()=>{if(!r)return null;const{bridge_config:a}=n,{output_proposal:i}=r;return At.addSeconds(new Date(i.l1_block_time),parseFloat(a.finalization_period))},[n,r]);return e(o)},$o=1e3,em=60,tm=60,sm=24,jn=$o*em,vn=jn*tm,lr=vn*sm,nm=({date:e})=>{const s=f.useCallback(()=>{const d=new Date().getTime(),m=e.getTime()-d;if(m<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(m/lr),_=Math.floor(m%lr/vn),g=Math.floor(m%vn/jn),p=Math.floor(m%jn/$o);return{days:h,hours:_,minutes:g,seconds:p}},[e]),[n,r]=f.useState(s());f.useEffect(()=>{const d=window.setInterval(()=>{r(s())},1e3);return()=>window.clearInterval(d)},[s,e]);const o=d=>d.toString().padStart(2,"0"),{days:a,hours:i,minutes:l,seconds:c}=n;return t.jsx(Xt,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[a,"d ",o(i),"h ",o(l),"m ",o(c),"s"]})})},rm="_container_1lz3w_1",om="_title_1lz3w_5",dr={container:rm,title:om},am=({date:e})=>t.jsxs("div",{className:dr.container,children:[t.jsx("div",{className:dr.title,children:"Claimable in"}),t.jsx(nm,{date:e})]}),im="_container_1oldz_1",cm="_icon_1oldz_7",ur={container:im,icon:cm},lm="Withdrawal will begin within an hour",hr=()=>{const e=qs();return t.jsxs("div",{className:ur.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Xt,{label:lm,children:t.jsx("span",{className:ur.icon,children:t.jsx(k.IconInfoFilled,{size:12})})})]})},dm=({children:e})=>{const{withdrawalTx:s}=Fs(),n=Qh(s.bridge_id),r=s.output_index>Number(n?.output_index);return e(r)},um=({date:e,children:s})=>{const{chainId:n,withdrawalTx:r}=Fs(),o=W.toBase64(Ao(r)),a=ko(r,o),{setReminder:i,removeReminder:l}=qt();return f.useEffect(()=>{const c={chainId:n,txHash:r.tx_hash};a?l(c):i(c,{...c,recipient:r.to,claimableAt:e.getTime(),amount:r.amount.amount,denom:r.amount.denom,dismissed:At.isPast(e.getTime())?!0:void 0})},[n,a,e,l,i,r]),s},hm=()=>t.jsx(dm,{children:e=>e?t.jsx(hr,{}):t.jsx(Xh,{children:s=>s?t.jsx(um,{date:s,children:At.isFuture(s)?t.jsx(am,{date:s}):t.jsx(Jh,{})}):t.jsx(hr,{})})}),mm="_asset_6h8u2_1",_m="_info_6h8u2_7",fm="_symbol_6h8u2_11",an={asset:mm,info:_m,symbol:fm},pm=({amount:e,denom:s})=>{const n=le(),r=kr(s,n),{symbol:o,logoUrl:a,decimals:i}=r;return t.jsxs("div",{className:an.asset,children:[t.jsx(Q,{src:a,width:32,height:32,logo:!0}),t.jsxs("div",{className:an.info,children:[t.jsx("span",{className:"monospace",children:w.formatAmount(e,{decimals:i})}),t.jsx("span",{className:an.symbol,children:o})]})]})},gm="_item_km5w2_1",xm={item:gm},ym=({chain:e})=>{const s=e.metadata?.executor_uri;if(!s)throw new Error("Executor URL is not defined");const{data:n,fetchNextPage:r,hasNextPage:o,isFetching:a}=Wh(s),i=f.useMemo(()=>n?.pages.flat()??[],[n]),{syncReminders:l}=qt();return f.useEffect(()=>{const c=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));l(c)},[e.chainId,i,l]),i.length?t.jsxs(t.Fragment,{children:[i.map(c=>{const{amount:d}=c;return t.jsxs("div",{className:xm.item,children:[t.jsx(pm,{...d}),t.jsx(pe,{suspenseFallback:null,children:t.jsx(So.Provider,{value:{chainId:e.chainId,withdrawalTx:c},children:t.jsx(hm,{})})})]},c.sequence)}),o&&t.jsx(bo,{onClick:()=>r(),disabled:a})]}):t.jsx(X,{children:"No withdrawals"})},jm="_content_dj1qm_1",vm="_title_dj1qm_5",mr={content:jm,title:vm},bm=()=>{const{chainId:e}=ft(),s=oe(),n=Gt(),[r,o]=f.useState(e??(n.metadata?.is_l1?"":n.chainId)),a=Xe(),{reminders:i}=qt(),l=r?a(r):void 0;return t.jsxs(xt,{title:"OP Bridge withdrawals",children:[t.jsx(ht,{chains:s.filter(({metadata:c})=>!c?.is_l1&&c?.op_denoms?.length),value:r,onSelect:o,getShowIndicator:c=>i.some(d=>d.chainId===c)}),t.jsx("div",{className:mr.content,children:l?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:mr.title,children:l.name}),t.jsx(pe,{children:t.jsx(ym,{chain:l})},r)]}):t.jsx(ne,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},wm="_page_1f6wh_1",Cm="_title_1f6wh_10",Im="_scrollable_1f6wh_17",Nm="_list_1f6wh_22",Sm="_item_1f6wh_32",km="_name_1f6wh_56",Am="_dimmed_1f6wh_64",$m="_recent_1f6wh_68",Tm="_installed_1f6wh_69",we={page:wm,title:Cm,scrollable:Im,list:Nm,item:Sm,name:km,dimmed:Am,recent:$m,installed:Tm},Em=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],_r=({onSuccess:e})=>{const{connectors:s,connectAsync:n}=ve.useConnect(),r=Ne.useReadLocalStorage("wagmi.recentConnectorId"),[o,a]=f.useState(null),{mutate:i,isPending:l}=A.useMutation({mutationFn:async c=>{a(c.id);try{await n({connector:c})}catch(d){throw await Fe(d)}},onSettled:()=>{a(null)},onSuccess:()=>{e?.()}});return t.jsxs("div",{className:we.page,children:[t.jsx("h1",{className:we.title,children:"Connect wallet"}),t.jsx(ze,{className:we.scrollable,children:t.jsxs("div",{className:we.list,children:[s.toSorted(v.descend(c=>c.id===r)).map(c=>{const{name:d,icon:u,id:m}=c;return t.jsxs("button",{className:we.item,onClick:()=>i(c),disabled:l,children:[t.jsx(Q,{src:u,width:24,height:24}),t.jsx("span",{className:we.name,children:d}),o===m?t.jsx(gt,{size:16}):r===m?t.jsx("span",{className:we.recent,children:"Recent"}):c.id===bs.id?null:t.jsx("span",{className:we.installed,children:"Installed"})]},m)}),Em.filter(({name:c})=>!s.some(d=>d.name.includes(c))).map(({name:c,url:d})=>{const u=`https://assets.initia.xyz/images/wallets/${c}.webp`;return t.jsxs("a",{href:d,className:we.item,target:"_blank",children:[t.jsx(Q,{src:u,width:24,height:24}),t.jsx("span",{className:B(we.name,we.dimmed),children:c}),t.jsx(k.IconExternalLink,{size:10})]},c)})]})})]})},qm="_trigger_kivvl_1",Dm="_icon_kivvl_21",Pm="_full_kivvl_25",Rm="_triggerContent_kivvl_30",Bm="_triggerText_kivvl_38",Fm="_popoverBackdrop_kivvl_49",Mm="_popoverPositioner_kivvl_68",Om="_popoverPopup_kivvl_72",Um="_search_kivvl_96",Lm="_viewport_kivvl_101",zm="_item_kivvl_106",Km="_highlighted_kivvl_120",Hm="_active_kivvl_124",Wm="_name_kivvl_129",Qm="_extra_kivvl_133",se={trigger:qm,icon:Dm,full:Pm,triggerContent:Rm,triggerText:Bm,popoverBackdrop:Fm,popoverPositioner:Mm,popoverPopup:Om,search:Um,viewport:Lm,item:zm,highlighted:Km,active:Hm,name:Wm,extra:Qm},Rn=({value:e,onChange:s,chainIds:n,renderExtra:r,fullWidth:o})=>{const[a,i]=f.useState(""),[l,c]=f.useState(!1),[d,u]=f.useState(0),[m,h]=f.useState(),_=f.useRef([]),g=f.useRef(null),p=oe(),j=n.map(y=>p.find(x=>x.chainId===y)).filter(Boolean),S=y=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:y,height:y,viewBox:"0 0 14 14",children:[t.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),t.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),N=f.useMemo(()=>({chainId:"",name:"All",logoUrl:S}),[]),I=f.useMemo(()=>{const y=[N,...j];if(!a)return y;const x=a.toLowerCase();return y.filter($=>$.name.toLowerCase().includes(x)||$.chainId.toLowerCase().includes(x))},[j,a,N]),b=j.find(y=>y.chainId===e)||N,E=parseInt(Xr("--drawer-offset")),D=6,F=()=>{if(i(""),u(-1),g.current){const x=g.current.getBoundingClientRect().bottom+D,$=window.innerHeight-x-2*E;h($)}c(!0)};f.useEffect(()=>{d>=0&&d<_.current.length&&_.current[d]?.scrollIntoView({block:"nearest",behavior:"auto"})},[d]);const C=f.useCallback(y=>{switch(y.key){case"ArrowDown":y.preventDefault(),u(x=>(x+1)%I.length);break;case"ArrowUp":y.preventDefault(),u(x=>(x-1+I.length)%I.length);break;case"Enter":y.preventDefault(),I[d]&&(s(I[d].chainId),c(!1));break;case"Escape":y.preventDefault(),c(!1);break}},[I,d,s,c]),P=y=>{s(y),c(!1)};return t.jsxs(vt.Popover.Root,{open:l,onOpenChange:F,modal:"trap-focus",children:[t.jsx(vt.Popover.Trigger,{render:t.jsxs("button",{className:B(se.trigger,{[se.full]:o}),"aria-expanded":l,role:"listbox",ref:g,children:[t.jsxs("div",{className:se.triggerContent,children:[typeof b.logoUrl=="string"?t.jsx(Q,{src:b.logoUrl,width:14,height:14,logo:!0}):b.logoUrl(14),t.jsx("span",{className:se.triggerText,children:b.name})]}),t.jsx(k.IconChevronDown,{size:16,className:se.icon})]})}),t.jsxs(vt.Popover.Portal,{container:mt(),children:[t.jsx(vt.Popover.Backdrop,{className:se.popoverBackdrop,onClick:()=>c(!1)}),t.jsx(vt.Popover.Positioner,{className:se.popoverPositioner,align:"end",side:"bottom",sideOffset:D,collisionAvoidance:{side:"none"},children:t.jsxs(vt.Popover.Popup,{className:B(se.popoverPopup,{[se.full]:o}),style:{maxHeight:m},children:[t.jsx(Bs,{value:a,onChange:y=>{i(y.target.value),u(0)},onClear:()=>i(""),onKeyDown:C,placeholder:"Search appchains",rootClassName:se.search,ref:Jt()}),t.jsx("div",{className:se.viewport,role:"listbox",children:I.length===0?t.jsx(X,{children:"No appchains found"}):I.map(({chainId:y,name:x,logoUrl:$},T)=>t.jsxs("div",{className:B(se.item,{[se.highlighted]:T===d,[se.active]:e===y}),onClick:()=>P(y),onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),P(y))},onMouseEnter:()=>u(T),role:"option","aria-selected":e===y,tabIndex:-1,ref:R=>{R&&(_.current[T]=R)},children:[typeof $=="string"?t.jsx(Q,{src:$,width:16,height:16,logo:!0}):$(16),t.jsx("span",{className:se.name,children:x}),r&&t.jsx("span",{className:se.extra,children:r(y)})]},y))})]})})]})]})},Vm="_container_t1267_1",Gm="_controls_t1267_7",Ym="_search_t1267_13",Bn={container:Vm,controls:Gm,search:Ym},Zm=({children:e})=>t.jsx("div",{className:Bn.container,children:e}),Jm=({children:e})=>t.jsx("div",{className:Bn.controls,children:e}),Xm=e=>t.jsx(Bs,{...e,rootClassName:Bn.search}),Ye={Root:Zm,Controls:Jm,SearchInput:Xm},e_=G.atom(""),t_=G.atom(""),s_=G.atom(""),n_=G.atom(""),r_=G.atom(""),o_="_change_1x9v4_1",a_="_positive_1x9v4_10",i_="_negative_1x9v4_14",cn={change:o_,positive:a_,negative:i_},To=({amount:e,asset:s})=>{const{denom:n,symbol:r,decimals:o}=s,a=new M(e).isPositive(),i=new M(e).abs().toString();return t.jsxs("div",{className:B(cn.change,a?cn.positive:cn.negative),children:[a?"+":"-",w.formatAmount(i,{decimals:o})," ",r||n]})},c_=({changes:e,chain:s})=>{const n=Ue(s);return e.map(({amount:r,denom:o},a)=>t.jsx(To,{amount:r,asset:n(o)},a))},l_=({changes:e,chain:s})=>{const n=Ue(s);return e.map(({amount:r,metadata:o},a)=>t.jsx(co,{metadata:o,chain:s,children:i=>t.jsx(To,{amount:r,asset:n(i)})},a))},d_=({events:e,chain:s})=>{const{initiaAddress:n,hexAddress:r}=fe();return s.metadata?.is_l1||s.metadata?.minitia?.type==="minimove"?t.jsx(l_,{changes:io(e,r),chain:s}):t.jsx(c_,{changes:ao(e,n),chain:s})},u_="_message_1g2hc_1",h_="_more_1g2hc_8",fr={message:u_,more:h_},m_=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((s,n)=>t.jsx("p",{className:fr.message,children:vs.sentenceCase(s["@type"].split("Msg")[1])},n)),e.length>3&&t.jsx("footer",{className:fr.more,children:`+${e.length-3} more`})]}),__="_link_oq58b_1",f_="_inner_oq58b_15",p_="_header_oq58b_20",g_="_time_oq58b_29",x_="_error_oq58b_35",y_="_timestamp_oq58b_39",j_="_chainInfo_oq58b_44",v_="_content_oq58b_52",b_="_messages_oq58b_59",w_="_changes_oq58b_64",Te={link:__,inner:f_,header:p_,time:g_,error:x_,timestamp:y_,chainInfo:j_,content:v_,messages:b_,changes:w_},C_=({txItem:e,chain:s})=>t.jsx(Ds,{txHash:e.txhash,chainId:s.chainId,className:Te.link,children:t.jsxs("div",{className:Te.inner,children:[t.jsxs("div",{className:Te.header,children:[t.jsxs("div",{className:Te.time,children:[e.code!==0&&t.jsx(k.IconWarningFilled,{size:14,className:Te.error}),t.jsx("span",{className:Te.timestamp,children:At.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:Te.chainInfo,children:[t.jsx(Q,{src:s.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:s.name})]})]}),t.jsxs("div",{className:Te.content,children:[t.jsx("div",{className:Te.messages,children:t.jsx(m_,{messages:e.tx.body.messages})}),t.jsx("div",{className:Te.changes,children:t.jsx(pe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(d_,{...e,chain:s})})})]})]})}),I_="_list_1wa9p_1",N_="_dateGroup_1wa9p_7",S_="_dateHeader_1wa9p_12",k_="_more_1wa9p_18",ls={list:I_,dateGroup:N_,dateHeader:S_,more:k_},A_=({list:e,chainId:s})=>{const n=ae(),r=f.useMemo(()=>wo(e,o=>{if(o.timestamp)return new Date(o.timestamp)}),[e]);return e.length===0?t.jsx(X,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ls.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{className:ls.dateGroup,children:[t.jsx("div",{className:ls.dateHeader,children:o}),a.map(i=>t.jsx(pe,{errorBoundaryProps:{fallback:null},children:t.jsx(C_,{txItem:i,chain:i.chain})},i.txhash))]},o))}),t.jsx(Ds,{chainId:s,accountAddress:n,pathSuffix:"/txs",className:ls.more,showIcon:!0,children:"View more on Initia Scan"})]})},$_=()=>{const{activities:e,isLoading:s}=_c(),[n,r]=G.useAtom(r_),o=le(),a=f.useMemo(()=>Array.from(new Set(e.map(l=>l.chain.chainId))),[e]),i=f.useMemo(()=>n?e.filter(l=>l.chain.chainId===n):e,[e,n]);return s&&e.length===0?t.jsx(X,{children:"Loading activities..."}):!e.length&&!s?t.jsx(X,{children:"No activity yet"}):t.jsxs(Ye.Root,{children:[t.jsx(Ye.Controls,{children:t.jsx(Rn,{value:n,onChange:r,chainIds:a,fullWidth:!0})}),t.jsx(A_,{list:i,chainId:n||o.chainId})]})},T_="2.0.6",E_="_version_1sf5y_1",q_={version:E_},D_=()=>t.jsxs("aside",{className:q_.version,children:["v",T_]}),Eo=f.createContext(null);function qo(){return f.useContext(Eo)}const P_="_popup_nbecp_1",R_="_item_nbecp_19",ds={popup:P_,item:R_},Do=({asset:e,children:s})=>{const{denom:n,decimals:r,symbol:o,logoUrl:a,unlisted:i,address:l,chain:c}=e,{chainId:d}=c,[u,m]=f.useState(!1),h=he(),_=qo(),{showNotification:g}=En(),{defaultChainId:p}=ee(),{evm_chain_id:j}=Gt(),S=ve.useChainId(),{switchChainAsync:N}=ve.useSwitchChain(),{watchAssetAsync:I}=ve.useWatchAsset(),b=()=>{m(!1),h("/send",{denom:n,chain:c})},E=()=>{m(!1),h("/bridge",{srcChainId:d,srcDenom:n,quantity:""})},D=A.useMutation({mutationFn:async()=>{if(!l)throw new Error("Address is required");const F=a;return await N({chainId:Number(j)}),I({type:"ERC20",options:{address:l,symbol:o,decimals:r,image:F}})},onSuccess:()=>{g({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:F=>{g({type:"error",title:"Asset addition failed",description:F.message})}});return t.jsxs(We.Menu.Root,{open:u,onOpenChange:m,modal:!1,children:[t.jsx(We.Menu.Trigger,{render:s}),t.jsx(We.Menu.Portal,{container:_,children:t.jsx(We.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(We.Menu.Popup,{className:ds.popup,children:[t.jsxs(We.Menu.Item,{className:ds.item,onClick:b,children:[t.jsx(k.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(We.Menu.Item,{className:ds.item,onClick:E,disabled:i,children:[t.jsx(k.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===p&&j===S&&!!l&&t.jsxs(We.Menu.Item,{className:ds.item,onClick:()=>D.mutate(),disabled:D.isPending||D.data,children:[D.data?t.jsx(k.IconCheck,{size:16}):t.jsx(k.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},B_="_item_knoro_1",F_="_info_knoro_22",M_="_images_knoro_28",O_="_name_knoro_32",U_="_value_knoro_38",L_="_amount_knoro_46",z_="_usd_knoro_52",lt={item:B_,info:F_,images:M_,name:O_,value:U_,amount:L_,usd:z_},K_=({asset:e})=>{const{amount:s,value:n,logoUrl:r,chain:o}=e,a=w.formatAmount(s,{decimals:e.decimals});return t.jsx(Do,{asset:e,children:t.jsxs("button",{className:lt.item,children:[t.jsxs("div",{className:lt.info,children:[t.jsx(Rs,{assetLogoUrl:r,chainLogoUrl:o.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:lt.images}),t.jsx("span",{className:lt.name,children:o.name})]}),t.jsxs("div",{className:lt.value,children:[t.jsx("span",{className:lt.amount,children:a}),Number(n)>0&&t.jsx("span",{className:lt.usd,children:Se(n)})]})]})})},H_="_container_g5q73_1",W_="_assetItem_g5q73_6",Q_="_assetInfo_g5q73_26",V_="_logo_g5q73_32",G_="_symbol_g5q73_36",Y_="_chainName_g5q73_46",Z_="_chainInfos_g5q73_52",J_="_chainLogos_g5q73_58",X_="_chainLogo_g5q73_58",ef="_moreChains_g5q73_69",tf="_expandIcon_g5q73_81",sf="_expanded_g5q73_85",nf="_valueColumn_g5q73_90",rf="_amount_g5q73_99",of="_value_g5q73_90",af="_collapsibleContent_g5q73_112",cf="_chainsList_g5q73_142",J={container:H_,assetItem:W_,assetInfo:Q_,logo:V_,symbol:G_,chainName:Y_,chainInfos:Z_,chainLogos:J_,chainLogo:X_,moreChains:ef,expandIcon:tf,expanded:sf,valueColumn:nf,amount:rf,value:of,collapsibleContent:af,chainsList:cf},lf=G.atom([]),Po=({assetGroup:e})=>{const{symbol:s,logoUrl:n,assets:r}=e,o=r.length===1,[a,i]=G.useAtom(lf),l=f.useMemo(()=>$a(e),[e]),c=f.useMemo(()=>kn(e),[e]),d=a.includes(s),u=()=>{i(h=>d?v.without([s],h):v.uniq([...h,s]))},m=()=>t.jsxs("button",{className:J.assetItem,children:[t.jsxs("div",{className:J.assetInfo,children:[n&&t.jsx(Q,{src:n,width:32,height:32,className:J.logo,logo:!0}),t.jsxs("div",{className:J.details,children:[t.jsx("div",{className:J.symbol,children:s}),o?t.jsx("div",{className:J.chainName,children:r[0].chain.name}):t.jsxs("div",{className:J.chainInfos,children:[t.jsx("div",{className:J.chainLogos,children:r.slice(0,5).map(({chain:h})=>t.jsx(Q,{src:h.logoUrl,width:16,height:16,className:J.chainLogo,logo:!0},h.chainId))}),r.length>5&&t.jsxs("span",{className:J.moreChains,children:["+",r.length-5]}),t.jsx(k.IconChevronDown,{size:16,className:B(J.expandIcon,{[J.expanded]:d})})]})]})]}),t.jsxs("div",{className:J.valueColumn,children:[t.jsx("div",{className:J.amount,children:w.formatNumber(l,{dp:r[0].unlisted?0:6})}),c>0&&t.jsx("div",{className:J.value,children:Se(c)})]})]});if(o){const[h]=r;return t.jsx("div",{className:J.container,children:t.jsx(Do,{asset:h,children:m()})})}return t.jsx("div",{className:J.container,children:t.jsxs(Y.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(Y.Collapsible.Trigger,{asChild:!0,children:m()}),t.jsx(Y.Collapsible.Content,{className:J.collapsibleContent,children:t.jsx("div",{className:J.chainsList,children:r.map(h=>t.jsx(K_,{asset:h},h.chain.chainId))})})]})})},df="_collapsible_1spkj_1",uf="_trigger_1spkj_5",hf="_divider_1spkj_20",mf="_label_1spkj_26",_f="_chevron_1spkj_31",ff="_content_1spkj_39",pf="_list_1spkj_43",Ve={collapsible:df,trigger:uf,divider:hf,label:mf,chevron:_f,content:ff,list:pf},gf=({unlistedAssets:e})=>{const[s,n]=f.useState(!0),r=qo(),o=f.useRef(null),[a,i]=f.useState(0);f.useEffect(()=>{if(o.current){const d=o.current.scrollHeight;i(d)}},[e]);const l=d=>{if(d&&!s&&r?.current){const u=r.current;u.scrollTo({top:u.scrollHeight,behavior:"auto"}),window.setTimeout(()=>{u.scrollTo({top:u.scrollHeight,behavior:"smooth"})},150)}n(d)},c=Je.useSpring({height:s?a:0,opacity:s?1:0,config:{tension:500,friction:30,clamp:!0}});return e.length===0?null:t.jsxs(Y.Collapsible.Root,{open:s,onOpenChange:l,className:Ve.collapsible,children:[t.jsxs(Y.Collapsible.Trigger,{className:Ve.trigger,children:[t.jsx("div",{className:Ve.divider}),t.jsxs("span",{className:Ve.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(k.IconChevronDown,{className:Ve.chevron,size:12,"data-state":s?"open":"closed"}),t.jsx("div",{className:Ve.divider})]}),t.jsx(Y.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(Je.animated.div,{className:Ve.content,style:c,children:t.jsx("div",{className:Ve.list,ref:o,children:e.map(d=>t.jsx(Po,{assetGroup:{...d,assets:[d]}},d.denom))})})})]})},xf="_list_szwvw_1",yf={list:xf},jf=()=>{const[e,s]=G.useAtom(e_),[n,r]=G.useAtom(t_),{assetGroups:o,unlistedAssets:a,chainsByValue:i,totalValue:l,isLoading:c}=An(),d=i.map(({chainId:h})=>h),u=f.useMemo(()=>{const h=e?o.filter(g=>{const{symbol:p,assets:j}=g;return p.toLowerCase().includes(e.toLowerCase())||j.some(({denom:S,address:N})=>S.toLowerCase().includes(e.toLowerCase())||N?.toLowerCase().includes(e.toLowerCase()))}):o;return n?h.map(g=>({...g,assets:g.assets.filter(({chain:p})=>p.chainId===n)})).filter(g=>g.assets.length>0):h},[o,e,n]),m=f.useMemo(()=>{const h=e?a.filter(({denom:g,address:p})=>g.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):a;return n?h.filter(({chain:g})=>g.chainId===n):h},[a,e,n]);return c&&o.length===0?t.jsx(X,{children:"Loading assets..."}):!u.length&&!m.length&&!e&&!n&&!c?t.jsx(X,{children:"No assets"}):t.jsxs(t.Fragment,{children:[t.jsxs(Ye.Root,{children:[t.jsxs(Ye.Controls,{children:[t.jsx(Ye.SearchInput,{value:e,onChange:h=>s(h.target.value),onClear:()=>s(""),placeholder:"Search assets"}),t.jsx(Rn,{value:n,onChange:r,chainIds:d,renderExtra:h=>{if(!h)return Se(l);const _=i.find(g=>g.chainId===h);return _?Se(_.value):null}})]}),t.jsx("div",{children:u.length===0&&m.length===0?t.jsx(X,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:yf.list,children:u.map(h=>t.jsx(Po,{assetGroup:h},h.symbol))}),t.jsx(gf,{unlistedAssets:m})]})})]}),t.jsx(D_,{})]})},vf="_thumbnail_1lblb_1",bf="_placeholder_1lblb_16",wf="_clickable_1lblb_22",zt={thumbnail:vf,placeholder:bf,clickable:wf},Fn=({nftInfo:e,size:s,onClick:n})=>{const{collection_addr:r,object_addr:o,nft:a,chain:i}=e,{glyphUrl:l}=ee(),c=new URL(`/v1/${i.chainId}/${r}/${o||a.token_id}`,l).toString();return n?t.jsx("button",{className:B(zt.thumbnail,zt.clickable),onClick:n,style:{width:s,height:s},children:t.jsx(Q,{src:c,classNames:{placeholder:zt.placeholder}})}):t.jsx("div",{className:zt.thumbnail,style:{width:s,height:s},children:t.jsx(Q,{src:c,classNames:{placeholder:zt.placeholder}})})},Cf="_nftItem_eopro_1",If="_collectionName_eopro_9",Nf="_nftName_eopro_19",Sf="_chainInfo_eopro_29",us={nftItem:Cf,collectionName:If,nftName:Nf,chainInfo:Sf},kf=({normalizedNft:e})=>{const{collection_name:s,name:n,chain:r}=e,o=he();return t.jsxs("div",{className:us.nftItem,children:[t.jsx(Fn,{nftInfo:e,onClick:()=>o("/nft",e)}),t.jsxs("div",{children:[t.jsx("div",{className:us.collectionName,children:s}),t.jsx("div",{className:us.nftName,children:n}),t.jsxs("div",{className:us.chainInfo,children:[t.jsx(Q,{src:r.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:r.name})]})]})]})},Ro=ke.createQueryKeys("interwovenkit:nft",{nfts:(e,s)=>[e,s],metadata:e=>[e]});function Af(e,s){const{nft:n}=e,r=s.name??n.token_id;return{...e,...n,...s,name:r}}function $f(e,s){return e.flatMap((n,r)=>(s[r]??[]).map(a=>({...a,chain:n})))}const Tf=()=>{const e=ae(),s=oe(),n=A.useQueries({queries:s.map(c=>({queryKey:Ro.nfts(c.indexerUrl,e).queryKey,queryFn:()=>$r(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:c.indexerUrl},"tokens"),staleTime:K.SECOND}))}),r=n.map(v.prop("data")),o=$f(s,r),a=o.reduce((c,{chain:d})=>({...c,[d.chainId]:(c[d.chainId]||0)+1}),{}),i=Object.values(a).reduce((c,d)=>c+d,0),l=n.some(c=>c.isLoading);return{nftInfos:o,chainCounts:a,totalCount:i,isLoading:l}};function Ef(e){const s=pr(e);return A.useQuery({queryKey:Ro.metadata(s).queryKey,queryFn:async()=>{try{if(!s)return{};const n=await Z.get(s).json();return{...n,image:pr(n.image)}}catch{return{}}},staleTime:K.INFINITY})}function pr(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const qf=({nftInfo:e,children:s})=>{const{data:n={}}=Ef(e.nft.uri),r=Af(e,n);return s(r)},Df="_grid_a1fhu_1",Pf={grid:Df},Rf=()=>{const[e,s]=G.useAtom(s_),[n,r]=G.useAtom(n_),{nftInfos:o,chainCounts:a,totalCount:i,isLoading:l}=Tf(),c=f.useMemo(()=>o.filter(({collection_addr:u,collection_name:m,nft:h,object_addr:_,chain:g})=>{if(n&&g.chainId!==n)return!1;if(e){const p=e.trim().toLowerCase();return u.toLowerCase().includes(p)||m.toLowerCase().includes(p)||h.token_id.toLowerCase().includes(p)||_.toLowerCase().includes(p)}return!0}),[o,n,e]),d=f.useMemo(()=>Array.from(new Set(o.map(({chain:u})=>u.chainId))),[o]);return l&&o.length===0?t.jsx(X,{children:"Loading NFTs..."}):!o.length&&!e&&!l?t.jsx(X,{children:"No NFTs"}):t.jsxs(Ye.Root,{children:[t.jsxs(Ye.Controls,{children:[t.jsx(Ye.SearchInput,{value:e,onChange:u=>s(u.target.value),onClear:()=>s(""),placeholder:"Search NFTs"}),t.jsx(Rn,{value:n,onChange:r,chainIds:d,renderExtra:u=>u?a[u]||0:i})]}),c.length===0?t.jsx(X,{children:"No NFTs found"}):t.jsx("div",{className:Pf.grid,children:c.map(u=>{const{collection_addr:m,nft:h}=u;return t.jsx(qf,{nftInfo:u,children:_=>t.jsx(kf,{normalizedNft:_})},m+h.token_id)})})]})},Bf="_totalValue_1udv1_1",Ff="_totalLabel_1udv1_7",Mf="_totalAmount_1udv1_13",Of="_loading_1udv1_18",Uf="_nav_1udv1_23",Lf="_item_1udv1_28",zf="_tabs_1udv1_51",Kf="_tab_1udv1_51",Ce={totalValue:Bf,totalLabel:Ff,totalAmount:Mf,loading:Of,nav:Uf,item:Lf,tabs:zf,tab:Kf},Hf=()=>{po();const e=he(),s=ks(),{totalValue:n,isLoading:r}=An(),o=f.useRef(null);return t.jsx(Eo.Provider,{value:o,children:t.jsxs(ze,{ref:o,children:[t.jsxs("div",{className:Ce.totalValue,children:[t.jsx("div",{className:Ce.totalLabel,children:"Total value"}),t.jsx("div",{className:B(Ce.totalAmount,{[Ce.loading]:r}),children:Se(n)})]}),t.jsxs("div",{className:Ce.nav,children:[t.jsxs(Nn,{to:"/send",className:Ce.item,children:[t.jsx(k.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs("button",{className:Ce.item,onClick:()=>e("/bridge"),children:[t.jsx(k.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]})]}),t.jsxs(He.Tabs.Root,{value:s,onValueChange:e,children:[t.jsxs(He.Tabs.List,{className:Ce.tabs,children:[t.jsx(He.Tabs.Tab,{className:Ce.tab,value:"/",children:"Assets"}),t.jsx(He.Tabs.Tab,{className:Ce.tab,value:"/nfts",children:"NFTs"}),t.jsx(He.Tabs.Tab,{className:Ce.tab,value:"/activity",children:"Activity"})]}),t.jsx(He.Tabs.Panel,{value:"/",children:t.jsx(jf,{})}),t.jsx(He.Tabs.Panel,{value:"/nfts",children:t.jsx(Rf,{})}),t.jsx(He.Tabs.Panel,{value:"/activity",children:t.jsx($_,{})})]})]})})},Wf="_header_4z0mk_1",Qf="_collectionName_4z0mk_6",Vf="_name_4z0mk_12",Gf="_chainInfo_4z0mk_18",Yf="_attributes_4z0mk_28",Zf="_title_4z0mk_31",Jf="_count_4z0mk_36",Xf="_item_4z0mk_40",ep="_type_4z0mk_46",tp="_value_4z0mk_52",Ee={header:Wf,collectionName:Qf,name:Vf,chainInfo:Gf,attributes:Yf,title:Zf,count:Jf,item:Xf,type:ep,value:tp},sp=ke.createQueryKeys("interwovenkit:nft-details",{validation:e=>[e]}),np=()=>{const e=he(),s=ft(),{collection_name:n,name:r,attributes:o,chain:a,collection_addr:i,token_id:l,object_addr:c}=s,{routerApiUrl:d}=ee(),u=Yt(),m=le(),{initiaAddress:h}=fe(),{simulateTx:_}=Sn(),g=A.useQuery({queryKey:sp.validation({collection_addr:i,nft:s,token_id:l,object_addr:c,sender:h,recipient:h,srcChain:a,dstChain:a,layer1:m,routerApiUrl:d}).queryKey,queryFn:async()=>{const p={from_address:h,from_chain_id:a.chainId,to_address:h,to_chain_id:a.chainId,collection_address:i,token_ids:[l],object_addresses:[c]},{msgs:j}=await Z.create({prefixUrl:d}).post("nft",{json:p}).json(),S=j.map(N=>u.fromAmino(N));return await _({messages:S,chainId:a.chainId})},staleTime:K.INFINITY});return t.jsxs(xt,{title:"NFT details",children:[t.jsxs("header",{className:Ee.header,children:[t.jsx(Fn,{nftInfo:s}),t.jsxs("div",{children:[t.jsx("div",{className:Ee.collectionName,children:n}),t.jsx("h2",{className:Ee.name,children:r}),t.jsxs("div",{className:Ee.chainInfo,children:[t.jsx(Q,{src:a.logoUrl,width:14,height:14,logo:!0}),t.jsx("span",{children:a.name})]})]})]}),t.jsx(re,{children:t.jsx(V.White,{onClick:()=>e("/nft/send",s),disabled:!g.data,loading:g.isLoading?"Checking transferability...":void 0,sm:!0,children:g.error?"Non-transferable NFT":"Send"})}),o&&t.jsxs("div",{className:Ee.attributes,children:[t.jsxs("header",{className:Ee.title,children:["Traits ",t.jsxs("span",{className:Ee.count,children:["(",o.length,")"]})]}),t.jsx("div",{children:o.map(({trait_type:p,value:j})=>t.jsxs("div",{className:Ee.item,children:[t.jsx("div",{className:Ee.type,children:p}),t.jsx("div",{className:Ee.value,children:j})]},p))})]})]})};function rp({balances:e,gasPrices:s,gas:n}){return s.map(({denom:r,amount:o})=>{const a=M(o).times(n).toFixed(0,M.ROUND_CEIL),i=e.find(l=>l.denom===r)?.amount??"0";return{amount:a,denom:r,balance:i}}).filter(({amount:r,balance:o})=>M(o).gte(r))}function op({denom:e,balances:s,gasPrices:n,lastFeeDenom:r,gas:o}){const a=s.find(d=>d.denom===e)?.amount??"0",i=rp({balances:s,gasPrices:n,gas:o}),l=i.find(d=>d.denom===r);if(i.length===0)return a;if(e===r&&l){const d=M(a).minus(l.amount);return M.max(d,0).toString()}const c=i.find(d=>d.denom!==e)||i[0];if(!l&&e===c.denom){const d=M(a).minus(c.amount);return M.max(d,0).toString()}return M(a).toString()}const ap=({chain:e,onSelect:s})=>{const n=ua(e);return t.jsx(es,{assets:n,onSelect:s})},ip=({afterSelect:e})=>{const{watch:s,setValue:n}=ce.useFormContext(),{chainId:r,denom:o}=s(),{chainId:a}=s(),[i,l]=f.useState(a),c=Oe(i),d=oe(),u=m=>{if(r===i&&o===m){e();return}n("chainId",i),n("denom",m),n("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(ht.Stack,{children:t.jsx(ht,{chains:d,value:i,onSelect:l})}),t.jsx(pe,{suspenseFallback:t.jsx(es.Placeholder,{}),children:t.jsx(ap,{chain:c,onSelect:u})},i)]})},cp="_fields_brpej_1",lp="_divider_brpej_11",gr={fields:cp,divider:lp},dp=ke.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),up=()=>{const{address:e,initiaAddress:s,estimateGas:n,requestTxSync:r}=fe(),{register:o,watch:a,setValue:i,handleSubmit:l,formState:c}=ce.useFormContext(),{errors:d}=c,{chainId:u,denom:m,recipient:h,quantity:_,memo:g}=a(),p=Oe(u),j=Cn(p),S=ro(p),N=oo(p),I=kr(m,p),{data:b}=Cs(p),{decimals:E}=I,D=j.find(O=>O.denom===m)?.amount??"0",F=b?.find(({id:O})=>O===m)?.price,{data:C=0,isLoading:P}=A.useQuery({queryKey:dp.gas({chainId:u,denom:m,recipient:h,initiaAddress:s}).queryKey,queryFn:()=>{const O=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Kn.MsgSend.fromPartial({fromAddress:s,toAddress:w.InitiaAddress(h).bech32,amount:[{denom:m,amount:"1"}]})}];return n({messages:O,chainId:u})},enabled:w.InitiaAddress.validate(h),staleTime:K.INFINITY}),y=Math.ceil(C*Wt),x=op({denom:m,balances:j,gasPrices:S,lastFeeDenom:N,gas:y}),$=M(D).isZero(),R=S.some(({denom:O})=>O===m)&&P,L=$||R,{mutate:q,isPending:H}=A.useMutation({mutationFn:({chainId:O,denom:be,quantity:tt,recipient:Ke,memo:st})=>{const de=w.toBaseUnit(tt,{decimals:E}),me=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Kn.MsgSend.fromPartial({fromAddress:s,toAddress:w.InitiaAddress(Ke).bech32,amount:[{denom:be,amount:de}]})}];return r({messages:me,memo:st,chainId:O,gas:C,gasAdjustment:Wt,gasPrices:S,spendCoins:[{denom:be,amount:de}],internal:"/"})}}),ie=f.useMemo(()=>{if(!_)return"Enter amount";if(d.quantity)return d.quantity.message;if(!h)return"Enter recipient address";if(d.recipient)return d.recipient.message;if(d.memo)return d.memo.message},[_,h,d.quantity,d.recipient,d.memo]);return t.jsx(xt,{title:"Send",children:t.jsxs("form",{onSubmit:l(O=>q(O)),children:[t.jsxs("div",{className:gr.fields,children:[t.jsx(fn,{selectButton:t.jsx(_t,{title:"Select chain and asset",content:O=>t.jsx(ip,{afterSelect:O}),children:t.jsx(vo,{asset:I,chain:p})}),quantityInput:t.jsx(xs,{balance:D,decimals:E}),balanceButton:t.jsx(go,{onClick:()=>i("quantity",w.fromBaseUnit(x,{decimals:E}),{shouldValidate:!0}),disabled:L,children:w.formatAmount(D??"0",{decimals:E})}),value:_?F?Se(M(_).times(F)):"$-":"$0"}),t.jsx("div",{className:gr.divider}),t.jsx(Dn,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...o("memo",{validate:O=>!O||new Blob([O]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),t.jsx(ne.Stack,{children:!g&&t.jsx(ne,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(re,{children:t.jsx(V.White,{type:"submit",loading:(P?"Estimating gas...":!1)||H,disabled:!!ie,children:ie??"Confirm"})})]})})},hp=()=>{const e=ft(),s=Gt(),n=Qt(s),{chain:r=s}=e,o=v.head(n);if(!e.denom&&!o)throw new Error("Asset list not found. This occurs during local development when asset list is not configured. Use asset-specific send buttons instead of the default send button, or register chain in Initia Registry with at least one asset defined.");const a=e.denom??o?.denom,i=ce.useForm({mode:"onChange",defaultValues:{chainId:r.chainId,denom:a,quantity:"",recipient:"",memo:""}});return t.jsx(ce.FormProvider,{...i,children:t.jsx(up,{})})},mp="_header_5w36t_1",_p="_name_5w36t_8",fp="_collection_5w36t_15",pp="_nft_5w36t_20",gp="_fields_5w36t_24",xp="_chain_5w36t_29",wt={header:mp,name:_p,collection:fp,nft:pp,fields:gp,chain:xp},yp=ke.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),jp=()=>{const e=oe(),s=ft(),{chain:n,collection_addr:r,collection_name:o,name:a}=s,{routerApiUrl:i}=ee(),l=Yt(),c=le(),{address:d,initiaAddress:u,requestTxSync:m}=fe(),{watch:h,setValue:_,handleSubmit:g,formState:p}=ce.useFormContext(),{errors:j}=p,S=h(),{recipient:N,dstChainId:I}=S,b=Oe(I),E=A.useQuery({queryKey:yp.simulation({collection_addr:r,nft:s,sender:u,recipient:N,srcChain:n,dstChain:b,layer1:c,routerApiUrl:i}).queryKey,queryFn:async()=>{const $={from_address:u,from_chain_id:n.chainId,to_address:w.InitiaAddress(N).bech32,to_chain_id:b.chainId,collection_address:r,token_ids:[s.token_id],object_addresses:[s.object_addr]},{msgs:T}=await Z.create({prefixUrl:i}).post("nft",{json:$}).json();return T.map(R=>l.fromAmino(R))},enabled:w.InitiaAddress.validate(N)}),{data:D,isLoading:F,error:C}=E,{mutate:P,isPending:y}=A.useMutation({mutationFn:async()=>{if(!D)throw new Error("Route not found");await m({messages:D,chainId:n.chainId,internal:"/nfts"})}}),x=f.useMemo(()=>{if(!N)return"Enter recipient address";if(j.recipient)return j.recipient.message;if(C)return"Route not found"},[N,j.recipient,C]);return t.jsxs("form",{onSubmit:g(()=>P()),children:[t.jsxs("header",{className:wt.header,children:[t.jsx(Fn,{nftInfo:s,size:80}),t.jsxs("div",{className:wt.name,children:[t.jsx("div",{className:wt.collection,children:o}),t.jsx("div",{className:wt.nft,children:a})]})]}),t.jsxs("div",{className:wt.fields,children:[t.jsx(Y.VisuallyHidden.Root,{children:t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(_t,{title:"Destination appchain",content:$=>t.jsx(jo,{onSelect:({chainId:T})=>{_("dstChainId",T),$()},list:e,getImage:T=>T.logoUrl,getName:T=>T.name,getKey:T=>T.chainId}),className:B("input",wt.chain),children:[t.jsx(Q,{src:b.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:b.name})]})]})}),t.jsx(Dn,{myAddress:d,ref:Jt()})]}),t.jsx(re,{children:t.jsx(V.White,{loading:(F?"Finding route...":!1)||y,disabled:!!x,children:x??"Confirm"})})]})},vp=()=>{const{chain:e}=ft(),s=ce.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(xt,{title:"Send NFT",children:t.jsx(ce.FormProvider,{...s,children:t.jsx(jp,{})})})},Bo=()=>{const e=he(),s=ks(),n=Et(),{closeDrawer:r}=Tt(),{closeModal:o}=As();f.useEffect(()=>{o(),s.startsWith("/bridge/")&&e("/bridge"),(s==="/collection"||s.startsWith("/nft"))&&e("/nfts")},[n]);const a=$s();if(f.useEffect(()=>{a("Page View")},[s,a]),s==="/connect")return n?null:t.jsx(_r,{onSuccess:r});if(s==="/blank")return null;if(!n)return t.jsx(_r,{});switch(s){case"/":case"/nfts":case"/activity":return t.jsx(Hf,{});case"/send":return t.jsx(hp,{},n);case"/nft":return t.jsx(np,{});case"/nft/send":return t.jsx(vp,{},n);case"/bridge":return t.jsx(Eu,{},n);case"/bridge/preview":return t.jsx(Kh,{});case"/bridge/history":return t.jsx(vh,{});case"/op/withdrawals":return t.jsx(bm,{});case"/tx":return t.jsx(uo,{})}},bp="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",wp=()=>t.jsxs(t.Fragment,{children:[t.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),t.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),t.jsx("link",{rel:"stylesheet",href:bp}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),Cp=()=>{oe();const e=le();return $n(),kt(localStorage.getItem(U.BRIDGE_SRC_CHAIN_ID)??e.chainId),kt(localStorage.getItem(U.BRIDGE_DST_CHAIN_ID)??e.chainId),null},Ip=new A.QueryClient({defaultOptions:{queries:{retry:0}}}),Np=({children:e,...s})=>(f.useEffect(()=>{Ma()},[]),Ne.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(wp,{}),t.jsx(Cr.Provider,{value:{...wr,...s},children:t.jsx(Or,{children:t.jsx(gl,{children:t.jsx(Y.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(pl,{children:t.jsxs(rl,{children:[e,t.jsxs(A.QueryClientProvider,{client:Ip,children:[t.jsx(Oa,{}),t.jsx(pe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(Cp,{})}),t.jsx(Hi,{children:t.jsx(Bo,{})})]})]})})})})})})]}):null),Sp=({bridge:e})=>t.jsx(Or,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(to.Provider,{value:!!e,children:t.jsx(pe,{children:t.jsx(Bo,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=Wt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=br;exports.InterwovenKit=Sp;exports.InterwovenKitProvider=Np;exports.MAINNET=wr;exports.MoveError=Lr;exports.TESTNET=Jo;exports.initiaPrivyWallet=ea;exports.initiaPrivyWalletConnector=Xo;exports.initiaPrivyWalletOptions=bs;exports.injectStyles=si;exports.useAddress=Et;exports.useHexAddress=Es;exports.useInitiaAddress=ae;exports.useInterwovenKit=fe;exports.usePortfolio=An;exports.useUsernameQuery=Vr;
|