@initia/interwovenkit-react 2.1.0 → 2.1.1
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.js +3032 -2981
- package/dist/styles.css +1 -1
- package/dist/styles.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ur=require("@privy-io/cross-app-connect/rainbow-kit"),de=require("wagmi"),$=require("@tanstack/react-query"),v=require("@initia/utils"),F=require("bignumber.js"),w=require("ramda"),Ne=require("@lukemorales/query-key-factory"),L=require("ky"),_=require("react"),V=require("@cosmjs/encoding"),va=require("@mysten/bcs"),H=require("jotai"),Lr=require("@amplitude/analytics-browser"),t=require("react/jsx-runtime"),yn=require("@cosmjs/amino/build/signdoc"),jn=require("@cosmjs/crypto"),sr=require("@cosmjs/math"),Is=require("@cosmjs/proto-signing"),Pe=require("@cosmjs/stargate"),nr=require("@cosmjs/tendermint-rpc"),wa=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),st=require("cosmjs-types/cosmos/tx/v1beta1/tx"),We=require("ethers"),Ht=require("@initia/amino-converter"),Qt=require("@cosmjs/amino"),ba=require("cosmjs-types/cosmos/auth/v1beta1/auth"),vn=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Ca=require("cosmjs-types/google/protobuf/any"),ke=require("date-fns"),qn=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),rr=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),or=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),zr=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),se=require("radix-ui"),Ie=require("usehooks-ts"),Kr=require("react-error-boundary"),D=require("clsx"),Ae=require("@base-ui-components/react/dialog"),Ia=require("xss"),A=require("@initia/icons-react"),rt=require("@react-spring/web"),Ns=require("change-case"),Le=require("@base-ui-components/react/select"),Js=require("@base-ui-components/react/collapsible"),ar=require("nanoid"),Na=require("react-dom"),ue=require("react-hook-form"),Sa=require("jotai/utils"),Wr=require("react-merge-refs"),Aa=require("react-intersection-observer"),ka=require("@noble/hashes/sha3"),_t=require("@noble/hashes/utils"),$a=require("qr-code-styling"),Ke=require("@base-ui-components/react"),Ze=require("@base-ui-components/react/tabs"),It=require("@base-ui-components/react/popover"),ir=require("cosmjs-types/cosmos/bank/v1beta1/tx");function Ta(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 Dn=Ta(Lr),Gt=1.4,Hr=1.05,Qr={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",glyphUrl:"https://glyph.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",theme:"dark"},Ea={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},Pn="cmbq1ozyc006al70lx4uciz0q",Ss={id:Pn,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},qa=Ur.toPrivyWalletConnector(Ss),Da=Ur.toPrivyWallet(Ss),Gr=_.createContext(null);function X(){const e=_.useContext(Gr);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const Q={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function Pa(e){if(e instanceof L.HTTPError){const{response:s}=e,n=s.headers.get("content-type")??"";if(w.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(w.path(["code"],e)===4001||w.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const s=w.path(["error","message"],e),n=w.path(["cause","message"],e),r=w.path(["shortMessage"],e);return s||n||r||e.message}return String(e)}async function He(e){return new Error(await Pa(e))}const As=Ne.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function is(e){const s=w.path([0,"address"],e);if(!s)throw new Error("URL not found");return s}function Ra(e){const{chain_id:s,chain_name:n,pretty_name:r,logo_URIs:o,apis:a,metadata:i}=e,c=r||n,l=o?.png??"",{rpc:d,rest:u,["json-rpc"]:h,indexer:m}=a,f=is(d),g=is(u),p=is(m),x=i?.minitia?.type==="minievm"?is(h):void 0;return{...e,chainId:s,name:c,logoUrl:l,rpcUrl:f,restUrl:g,indexerUrl:p,jsonRpcUrl:x}}function ae(){const{defaultChainId:e,registryUrl:s,customChain:n}=X(),{data:r}=$.useSuspenseQuery({queryKey:As.list(s).queryKey,queryFn:()=>L.create({prefixUrl:s}).get("chains.json").json(),select:o=>(n?[n,...o.filter(i=>i.chain_id!==n.chain_id)]:o).map(Ra).toSorted(w.descend(i=>i.chainId===e)),staleTime:Q.MINUTE});return r}function Vr(){const{registryUrl:e}=X(),{data:s}=$.useSuspenseQuery({queryKey:As.profiles(e).queryKey,queryFn:()=>L.create({prefixUrl:e}).get("profiles.json").json(),staleTime:Q.MINUTE});return s}function Te(){const e=_e(),s=ae(),n=Vr();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 Me(e){return Te()(e)}function Zt(){const{defaultChainId:e}=X();return Me(e)}function _e(){const s=ae().find(n=>n.metadata?.is_l1);if(!s)throw new Error("Layer 1 not found");return s}function Yr(){return({chainId:e})=>$.queryOptions({queryKey:As.prices(e).queryKey,queryFn:()=>L.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:Q.SECOND})}function ks(e){const s=Yr();return $.useQuery(s(e))}function Ba(){const e=ae(),s=Yr();return $.useQueries({queries:e.map(n=>s(n))})}const Ma=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
|
|
2
2
|
<circle fill="#2F3337" cx="30" cy="30" r="30"/>
|
|
3
3
|
<path fill="#757C82" d="M26.328 34.288v-.48c0-2.048 1.024-2.816 4.128-4.16 3.104-1.28 3.712-1.952 3.712-3.488v-.128c0-1.664-1.344-2.464-4.224-2.464-2.816 0-4.416.736-4.768 3.296h-5.248c.416-5.536 4.416-7.584 9.888-7.584h.352c6.208 0 9.28 2.496 9.28 6.24v.352c0 3.392-1.28 4.96-5.376 6.592-1.504.64-2.048 1.024-2.208 1.824h-5.536ZM26.168 42v-5.152h5.792V42h-5.792Z"/>
|
|
4
|
-
</svg>`,Ba=encodeURIComponent(Ra),Rn=`data:image/svg+xml;utf8,${Ba}`,ys=$e.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,s)=>[e,s],resource:(e,s)=>[e.chainId,s.denom],denom:(e,s)=>[e,s],metadata:(e,s)=>[e,s]});function Ma(e){const{base:s,symbol:n,denom_units:o=[],display:r,logo_URIs:a,name:i,address:c,traces:l}=e,d=o.find(m=>m.denom===r)?.exponent??o.find(m=>m.denom===s)?.exponent??b.head(o)?.exponent??0,u=a?.png??"";return{denom:s,symbol:n,decimals:d,logoUrl:u,name:i,address:c,traces:l}}function Zo(){const e=$.useQueryClient();return s=>{const n=s?.metadata?.assetlist;return $.queryOptions({queryKey:ys.list(n).queryKey,queryFn:async()=>n?z.get(n).json():{assets:[]},select:({assets:o})=>{if(!s)return[];const r=o.map(Ma);for(const a of r)e.setQueryData(ys.item(s.chainId,a.denom).queryKey,a);return r},staleTime:W.MINUTE})}}function Gt(e){const s=Zo(),{data:n}=$.useSuspenseQuery(s(e));return n}function Fa(){const e=re(),s=Zo();return $.useQueries({queries:e.map(n=>s(n))})}function Ve(e){const s=Gt(e),n=_e(),o=Gt(n),r=er(e);return a=>{const i=s.find(l=>l.denom===a);if(i)return i;const c=o.find(l=>l.denom===r(a));return c?{...c,denom:a}:{denom:a,symbol:"",decimals:0,logoUrl:Rn}}}function Xo(e,s){const n=Ve(s),r=$.useQueryClient().getQueryData(ys.item(s.chainId,e).queryKey);return r||n(e)}function er(e){const s=_e(),n=Gt(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const a=n.find(i=>i.denom===o)?.traces;if(a){for(const i of a)if(i.counterparty.chain_name===s.chain_name)return i.counterparty.base_denom}}const r=s.metadata?.ibc_channels?.find(({chain_id:a,version:i})=>a===e.chain_id&&i==="ics20-1")?.channel_id;return r?v.getIbcDenom(r,o):""}}function Oa(e){return e.pagination?.next_key??null}async function tr(e,s,n){const o=z.create(s),r=async(a,i)=>{const c=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),l=c[n]??[],d=Oa(c),u=[...a,...l];return d?r(u,d):u};return r([],null)}const co="usernames";function Ua({restUrl:e,moduleAddress:s}){const{viewFunction:n}=v.createMoveClient(e);async function o(i){if(!v.InitiaAddress.validate(i))return null;const c=await n({moduleAddress:s,moduleName:co,functionName:"get_name_from_address",typeArgs:[],args:[V.toBase64(v.InitiaAddress(i,32).bytes)]});return c?c+".init":null}function r(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function a(i){if(!r(i))return null;const c=await n({moduleAddress:s,moduleName:co,functionName:"get_address_from_name",typeArgs:[],args:[ya.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return c?v.InitiaAddress(c).bech32:null}return{restUrl:e,getUsername:o,getAddress:a,validateUsername:r}}const As=$e.createQueryKeys("interwovenkit:account",{username:(e,s)=>[e,s],address:(e,s)=>[e,s],balances:(e,s)=>[e,s],txs:(e,s)=>[e,s]});function sr(){const{restUrl:e}=_e(),{usernamesModuleAddress:s}=X();return Ua({restUrl:e,moduleAddress:s})}function nr(){const e=ne();return s=>$.queryOptions({queryKey:As.balances(s.restUrl,e).queryKey,queryFn:()=>tr(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:s.restUrl},"balances"),staleTime:W.SECOND})}function Bn(e){const s=nr(),{data:n}=$.useSuspenseQuery(s(e));return n}function La(){const e=re(),s=nr();return $.useQueries({queries:e.map(n=>s(n))})}function za(e){const s=Bn(e),n=Gt(e),o=Ve(e),r=er(e),{data:a}=ks(e),i=l=>e.fees.fee_tokens.some(d=>d.denom===l),c=l=>n.some(d=>d.denom===l);return b.sortWith([b.descend(({denom:l})=>r(l)==="uinit"),b.descend(({denom:l})=>i(l)),b.descend(({value:l})=>l),b.descend(({denom:l})=>c(l)),({balance:l},{balance:d})=>F(d).comparedTo(l)??0,b.descend(({symbol:l})=>l.toLowerCase())],s.filter(({amount:l})=>!F(l).isZero()).map(({amount:l,denom:d})=>{const u=o(d),m=a?.find(({id:f})=>f===u?.denom)?.price??0,h=F(l).times(m).div(F(10).pow(u.decimals)).toNumber();return{...u,balance:l,price:m,value:h}}))}const or=_.createContext(null);function $s(){return _.useContext(or)}function rr(){const{location:e}=$s();return e}function Ts(){const{path:e}=rr();return e}function jt(){const{state:e={}}=rr();return e}function Ka(){const{history:e}=$s();return e}function me(){const{navigate:e}=$s();return e}function ar(){const{reset:e}=$s();return e}const Et=({to:e,state:s,shouldReset:n,children:o,onClick:r,...a})=>{const i=me(),c=ar(),l=d=>{d.preventDefault(),r?.(d),n?c(e,s):i(e,s)};return t.jsx("button",{type:"button",...a,onClick:l,children:o})},ir=({children:e,initialEntry:s})=>{const[n,o]=_.useState([s??{path:"/"}]),r=n[n.length-1],a=_.useCallback((c,l)=>{o(d=>{if(typeof c=="string")return[...d,{path:c,state:l}];const u=d.length+c;if(u<1)return d;const m=b.take(u,d);return l!==void 0?b.adjust(u-1,h=>({...h,state:l}),m):m})},[]),i=_.useCallback((c,l)=>{o([{path:c,state:l}])},[]);return t.jsx(or.Provider,{value:{location:r,history:n,navigate:a,reset:i},children:e})},Wa="c33b940c24c17e95f7d9d525d508ac61";function Ha(){const{disableAnalytics:e}=X();_.useEffect(()=>{e||Dn.init(Wa,{autocapture:!1})},[e])}function Qa(){const{connector:e}=de.useAccount(),{defaultChainId:s,disableAnalytics:n}=X();_.useEffect(()=>{const o=new zo.Identify;e?.name&&o.set("connector",e.name),s&&o.set("defaultChainId",s),Dn.identify(o)},[s,e?.name,n])}function Es(){const e=Ts();return _.useCallback((n,o)=>{Dn.track(n,{path:e,...o})},[e])}const Ee="interwovenkit",Va=1e3,cr=60*Va,lr=60*cr,lo=24*lr,U={PUBLIC_KEY:`${Ee}:public-key`,BRIDGE_SRC_CHAIN_ID:`${Ee}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${Ee}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${Ee}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${Ee}:bridge:dst-denom`,BRIDGE_QUANTITY:`${Ee}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${Ee}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${Ee}:bridge:route-type`,BRIDGE_HISTORY:`${Ee}:bridge:history`,OP_REMINDER:`${Ee}:op:reminder`},Ga=G.atom(!1);function Ge(){const e=ar(),[s,n]=G.useAtom(Ga),o=Es();return{isDrawerOpen:s,openDrawer:(i,c)=>{i&&e(i,c),n(!0),o("Widget Opened")},closeDrawer:()=>{n(!1),o("Widget Closed")}}}function Mn(){const e=me(),{closeDrawer:s}=Ge(),{disconnect:n}=de.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)}}function Fn(){const{privyContext:e}=X(),{address:s}=de.useAccount();return e?s?!!e.privy.user?.linkedAccounts.map(o=>"address"in o&&o.address).filter(o=>!!o)?.some(o=>v.InitiaAddress.equals(o,s)):!1:!0}function Ya(){const{privyContext:e}=X(),s=Fn(),{address:n}=de.useAccount(),{signMessageAsync:o}=de.useSignMessage(),r=Mn(),a=!!e?.privy.ready,i=_.useRef(e);_.useEffect(()=>{i.current=e},[e]);const c=async l=>{try{if(!i.current)throw new Error("Privy context not found");i.current.privy.authenticated&&await i.current.privy.logout();const d=await i.current.siwe.generateSiweMessage({chainId:"eip155:1",address:l});if(!d)throw new Error("Failed to generate SIWE message");const u=await o({message:d});await i.current.siwe.loginWithSiwe({signature:u,message:d})}catch{r()}};_.useEffect(()=>{s||a&&n&&c(n)},[s,a,n])}function Ja(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:s}=vn.PubKey.decode(e.value);return Qt.encodeSecp256k1Pubkey(s)}return Cs.decodeOptionalPubkey(e)}function Za({typeUrl:e,value:s}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:n,pubKey:o,accountNumber:r,sequence:a}=va.BaseAccount.decode(s),i=Ja(o);return{address:n,pubkey:i,accountNumber:Number(r),sequence:Number(a)}}return Pe.accountFromAny({typeUrl:e,value:s})}function Xa(e){return e.type==="initia/PubKeyEthSecp256k1"}const ei={...Qt.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function ti(e){if(Xa(e)){const s=vn.PubKey.fromPartial({key:V.fromBase64(e.value)});return wa.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(vn.PubKey.encode(s).finish())})}return Cs.encodePubkey(e)}function dr(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:ei.ethsecp256k1,value:V.toBase64(e)}}function si(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:dr(e),signature:V.toBase64(s)}}const Xt=()=>{const e=X();return new Cs.Registry([...Ht.protoRegistry,...e.protoTypes??[]])},qs=()=>{const e=X();return new Pe.AminoTypes({...Ht.aminoConverters,...e.aminoConverters})};class ur{constructor(s,n,o){this.address=s,this.signMessage=n,this.restUrl=o}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=V.fromHex(n),V.fromHex(n);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(s,V.toHex(o)),o;const r=await this.getPublicKey();return this.cachedPublicKey=r,localStorage.setItem(s,V.toHex(r)),r}async getPublicKeyFromRestApi(){try{const n=(await z.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return n?V.fromBase64(n):null}catch{return null}}async getPublicKey(){const s="Sign this message to identify your Initia account.",n=await this.signMessage(s),o=We.ethers.hashMessage(s),r=We.ethers.SigningKey.recoverPublicKey(o,n);return jn.Secp256k1.compressPubkey(V.fromHex(r.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 o=yn.escapeCharacters(yn.sortedJsonStringify(n)),r=await this.signMessage(o),a=V.fromHex(r.replace("0x","")).subarray(0,-1),c=jn.Secp256k1Signature.fromFixedLength(a).toFixedLength(),l=si(await this.getCachedPublicKey(),c);return{signed:n,signature:l}}}function Ds(){const e=Xt(),s=qs(),n=es(),o=hr();return async function(r,a,i,c,l,d){const u=d?.customSigner??n;if(!u)throw new Error("Signer not initialized");const m=await o(r),{accountNumber:h,...f}=await m.getSequence(a),p=f.sequence+(d?.incrementSequence??0),[g]=await u.getAccounts(),y=ti(dr(g.pubkey)),I=ja.SignMode.SIGN_MODE_EIP_191,S=i.map(x=>s.toAmino(x)),k=yn.makeSignDoc(S,c,r,l,h,p),{signature:w,signed:T}=await u.signAmino(a,k),R={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:T.msgs.map(x=>s.fromAmino(x)),memo:l}},B=e.encode(R),K=so.Int53.fromString(T.fee.gas).toNumber(),j=so.Int53.fromString(T.sequence).toNumber(),C=Cs.makeAuthInfoBytes([{pubkey:y,sequence:j}],T.fee.amount,K,T.fee.granter,T.fee.payer,I);return st.TxRaw.fromPartial({bodyBytes:B,authInfoBytes:C,signatures:[V.fromBase64(w.signature)]})}}function es(){const e=ne(),{signMessageAsync:s}=de.useSignMessage(),n=_e();return _.useMemo(()=>new ur(e,o=>s({message:o}),n.restUrl),[e,s,n.restUrl])}const Zs=new Map,Xs=new Map;function mr(){const e=Te();return async s=>{if(Zs.has(s))return Zs.get(s);const{rpcUrl:n}=e(s),o=await no.Comet38Client.create(new no.HttpClient(n));return Zs.set(s,o),o}}function hr(){const e=Xt(),s=qs(),n=es(),o=ne(),r=mr();return async a=>{const i=`${o}:${a}`;if(Xs.has(i))return Xs.get(i);if(!n)throw new Error("Signer not initialized");const c=await r(a),l=await Pe.SigningStargateClient.createWithSigner(c,n,{registry:e,aminoTypes:s,accountParser:Za,broadcastPollIntervalMs:500});return Xs.set(i,l),l}}function fr(){const{connector:e}=de.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new We.BrowserProvider(await e.getProvider())}}function _r(){const{privyContext:e}=X(),s=Fn();if(!(!e||!s))return e.wallets.find(n=>n.connectorType==="embedded")}function Ps(){const e=_r();return e?.address?v.InitiaAddress(e.address).bech32:void 0}function pr(){const e=_r(),s=Ps(),n=Xt(),o=Te(),r=Ds();return async(a,i,c,l,d)=>{if(!e||!s)throw new Error("Embedded wallet not initialized");const u=[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:qn.MsgExec.fromPartial({grantee:s,msgs:c.map(f=>({typeUrl:f.typeUrl,value:n.encode(f)}))})}],m={...l,granter:i},h=new ur(s,e.sign,o(a).restUrl);return await r(a,s,u,m,d,{customSigner:h})}}const Yt=$e.createQueryKeys("interwovenkit:autosign",{expirations:(e,s)=>[e,s],grants:(e,s)=>[e,s]});function Rs(){const e=X(),s=Zt(),{enableAutoSign:n,defaultChainId:o}=e;if(!n)return{[o]:[]};if(typeof n!="boolean")return n;switch(s.metadata?.minitia?.type){case"minievm":return{[o]:["/minievm.evm.v1.MsgCall"]};case"miniwasm":return{[o]:["/cosmwasm.wasm.v1.MsgExecuteContract"]};default:return{[o]:["/initia.move.v1.MsgExecute"]}}}function gr(){const{data:e}=On(),s=Rs();return async(n,o)=>{const r=o.every(i=>{const c=s[n];return c?c.includes(i.typeUrl):!1}),a=e?.isEnabledByChain[n]??!1;return r&&a}}function On(){const e=ne(),s=Ps(),n=Te(),o=Rs();return $.useQuery({queryKey:Yt.expirations(e,s).queryKey,queryFn:async()=>{if(!e||!s)return{expiredAtByChain:{},isEnabledByChain:{}};const r={};for(const[i,c]of Object.entries(o))try{const l=n(i),d=z.create({prefixUrl:l.restUrl}),u=await d.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:s}}).json();if(!c.every(I=>u.grants.some(S=>S.authorization?.msg===I))){r[i]=null;continue}const h=await d.get(`cosmos/feegrant/v1beta1/allowance/${e}/${s}`).json(),f=u.grants.filter(I=>c.includes(I.authorization.msg)).map(I=>I.expiration),p=h.allowance.allowance.expiration,g=[...f,p],y=Un(g);r[i]=y?new Date(y):void 0}catch{r[i]=null}const a={};for(const[i,c]of Object.entries(r))switch(c){case null:a[i]=!1;break;case void 0:a[i]=!0;break;default:a[i]=ke.isFuture(c);break}return{expiredAtByChain:r,isEnabledByChain:a}},staleTime:W.INFINITY,retry:!1})}function ni(){const{data:e,refetch:s}=On();_.useEffect(()=>{if(!e)return;const n=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&ke.isFuture(c));if(o.length===0)return;const a=Un(o).getTime()-n.getTime();if(a<=0)return;const i=setTimeout(()=>{s()},a+100);return()=>clearTimeout(i)},[e,s])}function Un(e){return e.filter(s=>s!==void 0).toSorted((s,n)=>new Date(s).getTime()-new Date(n).getTime())[0]}const xr=_.createContext(null),Bs=()=>_.useContext(xr);class yr extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(s,n,o,r,a,i,c){super(s),this.name="MoveError",this.originalError=n,this.moduleAddress=o,this.moduleName=r,this.errorCode=a,this.errorCodeHex=i,this.isFromRegistry=c}}const oi=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,en=new Map;function ri(e){const s=e.match(oi);if(!s)return null;const[,n,o,r]=s;return{moduleAddress:`0x${n.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:r.replace(/^0+/,"")||"0"}}async function ai(e,s,n){const o=`${e}:${s}`;if(en.has(o))return en.get(o);try{const r=s==="0x1"?"0x1.json":`${e}/${s}.json`,a=`${n}/errors/${r}`,{errors:i={}}=await z.get(a).json();return en.set(o,i),i}catch{return null}}function ii(e,s,n,o,r,a,i){return new yr(e,s,n,o,r,a,i)}async function kt(e,s,n){if(!s.metadata?.is_l1&&s.metadata?.minitia?.type!=="minimove")return await He(e);const o=ri(e.message);if(!o)return await He(e);const r=await ai(s.chain_name,o.moduleAddress,n),a=`0x${parseInt(o.errorCode,10).toString(16)}`,i=`Failed with code ${a} in module ${o.moduleName} at ${o.moduleAddress}`,c=r?.[o.moduleName]?.[o.errorCode],l=c||i,d=!!c;return ii(l,e,o.moduleAddress,o.moduleName,o.errorCode,a,d)}const jr="approve",Ms=G.atom(),vr=G.atom(null);function wr(){const e=G.useAtomValue(Ms);if(!e)throw new Error("Tx request not found");return e}function Fs(){const e=me(),s=ne(),{defaultChainId:n,registryUrl:o}=X(),r=Te(),{openDrawer:a,closeDrawer:i}=Ge(),{openModal:c,closeModal:l}=Bs(),d=G.useSetAtom(Ms),u=G.useSetAtom(vr),m=mr(),h=hr(),f=es(),p=Xt(),g=gr(),y=pr(),I=Ds(),S=async({messages:j,memo:C,chainId:x=n})=>{try{return await(await h(x)).simulate(s,j,C)}catch(A){throw await kt(A,r(x),o)}},k=async({messages:j,memo:C,chainId:x=n})=>{const A=await m(x),q=Pe.QueryClient.withExtensions(A,Pe.setupTxExtension),M=j.map(Z=>p.encodeAsAny(Z)),[E]=await f.getAccounts(),H=Qt.encodeSecp256k1Pubkey(E.pubkey),ee=await h(x),{sequence:O}=await ee.getSequence(s);return q.tx.simulate(M,C,H,O)},w=async({txRequest:j,broadcaster:C})=>{const A={...{memo:"",chainId:n,gas:j.gas||await S(j),gasAdjustment:Vt,gasPrices:null,spendCoins:[],internal:!1},...j};return new Promise((q,M)=>{d({txRequest:A,resolve:async H=>{try{const ee=await h(A.chainId),O=await C(ee,st.TxRaw.encode(H).finish());q(O),typeof A.internal=="string"&&e(A.internal)}catch(ee){M(await kt(ee,r(A.chainId),o))}finally{E()}},reject:H=>{M(H),E()}}),A.internal?c({path:"/tx"}):a("/tx");const E=()=>{if(!A.internal){e("/blank"),i();return}l()}})},T=async j=>{const C=j.chainId??n;try{const x=await w({txRequest:j,broadcaster:async(A,q)=>await A.broadcastTxSync(q)});return j.internal&&typeof j.internal!="number"&&(u({txHash:x,chainId:C,status:"loading"}),K({txHash:x,chainId:j.chainId}).then(A=>{u({status:A.code===0?"success":"error",chainId:C,txHash:x})}).catch(()=>{u({status:"error",chainId:C,txHash:x})})),x}catch(x){throw j.internal&&typeof j.internal!="number"&&u({status:"error",chainId:C,error:x}),x}},P=(j,C=30*1e3,x=.5*1e3)=>w({txRequest:j,broadcaster:async(A,q)=>{const M=await A.broadcastTx(q,C,x);if(M.code!==0)throw new Error(M.rawLog);return M}}),R=async j=>{const C=j.chainId??n;try{const{messages:x,memo:A="",fee:q}=j,M=await h(C),H=await g(C,x)?await y(C,s,x,q,A):await I(C,s,x,q,A);return await M.broadcastTxSync(st.TxRaw.encode(H).finish())}catch(x){throw await kt(x,r(C),o)}},B=async(j,C=30*1e3,x=.5*1e3)=>{const A=j.chainId??n;try{const{messages:q,memo:M="",fee:E}=j,H=await h(A),O=await g(A,q)?await y(A,s,q,E,M):await I(A,s,q,E,M),Z=await H.broadcastTx(st.TxRaw.encode(O).finish(),C,x);if(Z.code!==0)throw new Error(Z.rawLog);return Z}catch(q){throw await kt(q,r(A),o)}},K=async({chainId:j=n,...C})=>{try{const x=await h(j);return await br({...C,client:x})}catch(x){throw await kt(x,r(j),o)}};return{estimateGas:S,simulateTx:k,requestTxSync:T,requestTxBlock:P,submitTxSync:R,submitTxBlock:B,waitForTxConfirmation:K}}async function br({txHash:e,client:s,timeoutMs:n=30*1e3,intervalMs:o=.5*1e3}){const r=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()-r>=n)throw new Error(`Transaction was submitted, but not found on the chain within ${n/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const Os=G.atom(null);function ci(){const{privyContext:e}=X(),s=ne(),n=Ps(),o=Rs(),{requestTxBlock:r}=Fs(),a=$.useQueryClient(),[i,c]=G.useAtom(Os),{closeDrawer:l}=Ge(),d=async()=>{if(n)return n;if(!e)throw new Error("Privy context not available");const u=await e.createWallet({createAdditional:!1});return v.InitiaAddress(u.address).bech32};return $.useMutation({mutationFn:async u=>{if(!i)throw new Error("No pending request");const{chainId:m}=i,h=await d();if(!s||!h)throw new Error("Wallets not initialized");const f=u===0?void 0:ke.addMilliseconds(new Date,u),p={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:Ko.MsgGrantAllowance.fromPartial({granter:s,grantee:h,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:ro.BasicAllowance.encode(ro.BasicAllowance.fromPartial({expiration:f})).finish()}})},g=o[m].map(I=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:qn.MsgGrant.fromPartial({granter:s,grantee:h,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:oo.GenericAuthorization.encode(oo.GenericAuthorization.fromPartial({msg:I})).finish()},expiration:f}})})),y=[p,...g];await r({messages:y,chainId:m,internal:!0})},onSuccess:async()=>{await a.invalidateQueries({queryKey:Yt.expirations._def}),i?.resolve()},onError:u=>{i?.reject(u)},onSettled:()=>{c(null),l()}})}function Cr(e){const s=X(),n=ne(),o=Ps(),r=e?.grantee||o,a=Rs(),i=e?.messageTypes||a,{requestTxBlock:c}=Fs(),l=$.useQueryClient();return $.useMutation({mutationFn:async(d=s.defaultChainId)=>{if(!n||!r)throw new Error("Wallets not initialized");const u={typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:Ko.MsgRevokeAllowance.fromPartial({granter:n,grantee:r})},m=i[d].map(f=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:qn.MsgRevoke.fromPartial({granter:n,grantee:r,msgTypeUrl:f})})),h=[u,...m];await c({messages:h,chainId:d,internal:e?.internal})},onSuccess:async()=>{const d=[Yt.expirations._def,Yt.grants._def];for(const u of d)await l.invalidateQueries({queryKey:u})}})}function li(){const{defaultChainId:e}=X(),{openDrawer:s}=Ge(),n=G.useSetAtom(Os),o=Cr(),{data:r={expiredAtByChain:{},isEnabledByChain:{}},isLoading:a}=On();return{...r,isLoading:a,enable:async(l=e)=>new Promise((d,u)=>{n({chainId:l,resolve:d,reject:u}),s("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}const di="INIT",ui="Initia";function Ln(e){return e.assets.reduce((s,{value:n})=>s+(n??0),0)}function mi(e){return e.assets.reduce((s,{quantity:n})=>s.plus(n),F(0)).toString()}function hi(e,s){return{symbol:s?.symbol??e,logoUrl:s?.logoUrl??Rn}}function uo(e){return b.pick(["chainId","name","logoUrl"],e)}function fi(e){return b.sortWith([b.descend(({symbol:s})=>s===di),b.descend(Ln),b.descend(({assets:s})=>s.length),b.ascend(({symbol:s})=>s)])(e)}function _i(e){return b.sortWith([b.descend(({value:s})=>s??0),b.descend(({quantity:s})=>Number(s)),b.ascend(({chain:s})=>s.name)])(e)}function pi(e){return b.sortWith([b.descend(({chain:s})=>s.name===ui),b.ascend(({chain:s})=>s.name),b.ascend(({denom:s})=>s)])(e)}function gi(e,s){return b.sortWith([b.descend(({chainId:n})=>n===s),b.descend(b.prop("value"))])(e)}function xi(e,s,n,o,r){const a={};for(const u of e){const m=u.chainId,h=s[m]??[],f=n[m],p=o[m],g=[];for(const{amount:y,denom:I}of h){if(!F(y).gt(0))continue;const S=f?.find(R=>R.denom===I),k=p?.find(R=>R.id===I)?.price,w=S?.decimals??0,T=v.fromBaseUnit(y,{decimals:w}),P=k?F(T).times(k).toNumber():void 0;g.push({...hi(I,S),amount:y,denom:I,decimals:w,quantity:T,price:k,value:P,address:S?.address,unlisted:!S,chain:uo(u)})}a[m]=g}const i=new Map;for(const[u,m]of Object.entries(a)){if(m.length===0)continue;const h=e.find(p=>p.chainId===u);if(!h)continue;const f=m.reduce((p,{value:g})=>p+(g??0),0);i.set(u,{...uo(h),value:f})}const c=new Map;for(const u of Object.values(a))for(const m of u)if(!m.unlisted){const{symbol:h}=m,f=c.get(h)??[];c.set(h,[...f,m])}const l=[];for(const[u,m]of c){const h=b.head(m);if(!h)continue;const f=_i(m);l.push({symbol:u,logoUrl:h.logoUrl,assets:f})}const d=[];for(const u of Object.values(a))for(const m of u)m.unlisted&&d.push(m);return{chainsByValue:gi(Array.from(i.values()),r),assetGroups:fi(l),unlistedAssets:pi(d),totalValue:l.reduce((u,m)=>u+Ln(m),0)}}function zn(){const{defaultChainId:e}=X(),s=re(),n=La(),o=Fa(),r=Pa(),a=s.map(h=>h.chainId),i=b.zipObj(a,n.map(b.prop("data"))),c=b.zipObj(a,o.map(b.prop("data"))),l=b.zipObj(a,r.map(b.prop("data"))),d=xi(s,i,c,l,e),u=[n,o,r].flat().some(({isLoading:h})=>h);return{...d,isLoading:u,refetch:()=>{n.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),r.forEach(({refetch:h})=>h())}}}function ne(){const e=Us();return e?v.InitiaAddress(e).bech32:""}function Us(){const{address:e}=de.useAccount(),s=Fn();return!e||!s?"":v.InitiaAddress(e).hex}function Pt(){const e=Zt(),s=ne(),n=Us();return e.metadata?.minitia?.type==="minievm"?n:s}function Ir(){const e=Pt(),s=sr();return $.useQuery({queryKey:As.username(s.restUrl,e).queryKey,queryFn:()=>s.getUsername(e),enabled:!!e,staleTime:W.MINUTE})}function xe(){const e=Pt(),s=ne(),n=Us(),{data:o}=Ir(),r=es(),a=Mn(),i=li(),{isDrawerOpen:c,openDrawer:l}=Ge(),d=()=>{l("/")},u=()=>{l("/connect")},m=p=>{l("/bridge",p)},h=Fs();return{address:e,initiaAddress:s,hexAddress:n,username:o,offlineSigner:r,isConnected:!!e,isOpen:c,openConnect:u,openWallet:d,openBridge:m,disconnect:a,autoSign:i,...h}}const yi="_status_tn9m1_1",ji="_error_tn9m1_9",mo={status:yi,error:ji},se=({error:e,children:s})=>t.jsx("p",{className:D(mo.status,{[mo.error]:e}),children:s}),ye=({errorBoundaryProps:e={fallbackRender:({error:o})=>t.jsx(se,{error:!0,children:o.message})},suspenseFallback:s=t.jsx(se,{children:"Loading..."}),children:n})=>t.jsx(Wo.ErrorBoundary,{...e,children:t.jsx(_.Suspense,{fallback:s,children:n})});function vi(){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=>v.InitiaAddress(n).bech32}};for(const n of e)localStorage.removeItem(n);for(const[n,{prefix:o,getSuffix:r}]of Object.entries(s)){const a=localStorage.getItem(n);if(a)try{const i=JSON.parse(a);for(const[c,l]of Object.entries(i)){const d=`${o}:${r(c)}`;localStorage.setItem(d,l)}localStorage.removeItem(n)}catch{}}}const Re=$e.createQueryKeys("interwovenkit:skip",{chains:null,assets:e=>[e],asset:(e,s)=>[e,s],balances:(e,s)=>[e,s],route:(e,s)=>[e,s],routeErrorInfo:e=>[e],txTrack:(e,s)=>[e,s],txStatus:(e,s)=>[e,s]});function Ye(){const{routerApiUrl:e}=X();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function qt(e){const s=Ye(),n=$.useQueryClient(),{data:o}=$.useSuspenseQuery({queryKey:Re.assets(e).queryKey,queryFn:()=>s.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:r})=>{const{assets:a}=r[e]??{assets:[]};for(const i of a)n.setQueryData(Re.asset(e,i.denom).queryKey,i);return a.toSorted(b.descend(i=>i.symbol==="INIT"))},staleTime:W.MINUTE});return o}function Nr(e){const s=qt(e);return n=>{const o=s.find(r=>r.denom===n);if(!o)throw new Error(`Asset not found: ${n}`);return o}}function Qe(e,s){return Nr(s)(e)}function Sr(){const e=re();return s=>e.some(n=>n.chain_id===s)}function ts(){const e=Sr();return s=>e(s.chain_id)?"initia":s.chain_type}function Jt(e){return ts()(e)}function Kn(){const e=Ye(),{data:s}=$.useSuspenseQuery({queryKey:Re.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:n})=>b.sortWith([b.descend(({chain_name:o})=>o==="initia"),b.ascend(({pretty_name:o})=>o)],n),staleTime:W.MINUTE});return s}function vt(){const e=Kn(),s=Yo();return n=>{const o=e.find(a=>a.chain_id===n);if(o)return o;const r=s.find(a=>a.chain_id===n);if(!r)throw new Error(`Chain not found: ${n}`);return{chain_id:r.chain_id,chain_name:r.name,pretty_name:r.pretty_name,logo_uri:r.logo,chain_type:"cosmos",rpc:"",rest:""}}}function Be(e){return vt()(e)}const wi=()=>(Ha(),Qa(),null),bi="_loader_4gdsk_1",Ci={loader:bi},wt=({size:e=24,color:s="currentColor",border:n=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${s} ${s} transparent ${s}`,borderWidth:`${n}px`};return t.jsx("div",{className:Ci.loader,style:o})},Ii="_button_1w43o_1",Ni="_outline_1w43o_27",Si="_sm_1w43o_45",ki="_full_1w43o_51",Ai="_small_1w43o_55",$i="_unpadded_1w43o_85",pt={button:Ii,outline:Ni,sm:Si,full:ki,small:Ai,unpadded:$i},kr=e=>{const{sm:s,fullWidth:n,loading:o,className:r,children:a,disabled:i,...c}=e;return t.jsx("button",{...c,className:D(pt.button,{[pt.sm]:s,[pt.full]:n},r),disabled:!!o||i,children:o?t.jsxs(t.Fragment,{children:[t.jsx(wt,{color:"currentColor",size:16}),typeof o=="string"&&t.jsx("span",{className:pt.loading,children:o})]}):a})},Ti=({className:e,...s})=>t.jsx(kr,{...s,className:D(pt.outline,e)}),Ei=({className:e,unpadded:s,...n})=>t.jsx("button",{...n,className:D(pt.small,{[pt.unpadded]:s},e)}),J={White:kr,Outline:Ti,Small:Ei},qi="_footer_1vp4h_1",Di="_actions_1vp4h_10",ho={footer:qi,actions:Di},ie=({extra:e,className:s,children:n})=>t.jsxs("footer",{className:D(ho.footer,s),children:[e,t.jsx("div",{className:ho.actions,children:n})]}),Pi="_scrollable_abvhw_1",Ri={scrollable:Pi},Fe=({className:e,children:s,ref:n})=>t.jsx("div",{ref:n,className:D(Ri.scrollable,e),children:s});function Ls(){return Ie.useMediaQuery("(max-width: 576px)")}const wn="interwoven-kit";function Ar(){const e=document.querySelector(wn)||document.body.appendChild(document.createElement(wn));return e.shadowRoot||e.attachShadow({mode:"open"})}function Bi(){const{theme:e,container:s}=X();return _.useEffect(()=>{document.querySelector(wn)?.setAttribute("data-theme",e)},[e]),s??Ar()}function Mi(e){const s=Ar(),n=document.createElement("style");n.textContent=e,s.appendChild(n)}const Wn=_.createContext(null);function yt(){const{container:e}=_.useContext(Wn);return e}function $r(e){const s=yt();return s?getComputedStyle(s).getPropertyValue(e):""}function Fi(){return Ie.useScrollLock(),null}function Oi(e){return/^[A-F0-9]{64}$/i.test(e)}function Ui(e,s){const{txHash:n,accountAddress:o,pathSuffix:r}=s;if(n)return Oi(n)?b.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,n):void 0;if(o){if(!v.InitiaAddress.validate(o))return;const i=b.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&r?i+r:i}}function Li(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 zi="_link_guafb_1",fo={link:zi},zs=({chainId:e,txHash:s,accountAddress:n,pathSuffix:o,...r})=>{const{showIcon:a,className:i,children:c,onClick:l,...d}=r,u=Me(e),m=Ui(u,{txHash:s,accountAddress:n,pathSuffix:o}),h=s?v.truncate(s):n?v.truncate(n):"",f=c??h;return m?t.jsxs("a",{...d,href:ba(Li(m)),className:D(fo.link,i),onClick:l,target:"_blank",children:[f,a&&t.jsx(N.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:D(fo.link,i),children:f})},Tr=_.createContext(null),Hn=()=>_.useContext(Tr),Ki=()=>{const[e,s]=G.useAtom(vr),{showNotification:n,updateNotification:o,hideNotification:r}=Hn();return _.useEffect(()=>{if(!e)return;const{status:a,chainId:i,txHash:c,error:l}=e,d=l?l.message:c?t.jsx(zs,{txHash:c,chainId:i,onClick:r,showIcon:!0,children:"View on Initia Scan"}):null;switch(a){case"loading":n({type:"loading",title:"Transaction is pending..."});break;case"error":o({type:"error",title:"Transaction failed",description:d}),s(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),s(null);break}},[e,s,n,o,r]),null},js=({value:e,children:s})=>{const[n,o]=_.useState(!1);return s({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:n})},Wi="_placeholder_10r3x_1",Hi="_logo_10r3x_5",_o={placeholder:Wi,logo:Hi},Y=({src:e,alt:s,placeholder:n,classNames:o,style:r,logo:a,...i})=>{const[c,l]=_.useState(void 0),{width:d,height:u}=i,m=n??t.jsx("div",{className:D(_o.placeholder,o?.placeholder),style:{width:d,height:u,...r}});return!e||c===e?m:t.jsx("img",{...i,className:D(i.className,{[_o.logo]:a}),style:{width:d,height:u,...r},src:e,alt:s,loading:"lazy",onError:()=>l(e)})},Qi="_header_1ajhc_1",Vi="_account_1ajhc_16",Gi="_name_1ajhc_27",Yi="_address_1ajhc_31",Ji="_icon_1ajhc_35",Zi="_copied_1ajhc_42",Xi="_button_1ajhc_57",ec="_settings_1ajhc_68",tc="_disconnect_1ajhc_72",sc="_label_1ajhc_82",nc="_expanded_1ajhc_90",je={header:Qi,account:Vi,name:Gi,address:Yi,icon:Ji,copied:Zi,button:Xi,settings:ec,disconnect:tc,label:sc,expanded:nc},oc=()=>{const{connector:e}=de.useAccount(),s=Mn(),{address:n,username:o}=xe(),r=o??n,[a,i]=_.useState(!1),c=_.useRef(null),l=ot.useSpring({width:a?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{a?s():i(!0)},u=()=>{a&&(c.current=setTimeout(()=>{i(!1)},500))},m=()=>{c.current&&(clearTimeout(c.current),c.current=null)};if(_.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),!e||!n)return null;const h=e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon;return t.jsxs("header",{className:je.header,children:[t.jsx(js,{value:n,children:({copy:f,copied:p})=>t.jsxs("button",{className:D(je.account,{[je.copied]:p}),onClick:f,children:[t.jsx(Y,{src:h,width:18,height:18}),t.jsx("div",{className:je.address,children:v.truncate(n)}),t.jsx("div",{className:je.name,children:v.truncate(r)}),t.jsx(N.IconCopy,{className:je.icon,size:12}),p?"Copied!":""]})}),t.jsx(Et,{to:"/settings",className:D(je.button,je.settings),"aria-label":"Open settings",children:t.jsx(N.IconSettingFilled,{size:16})}),t.jsxs(ot.animated.button,{className:D(je.button,je.disconnect,{[je.expanded]:a}),style:l,onClick:d,onMouseLeave:u,onMouseEnter:m,children:[t.jsx(N.IconSignOut,{size:16}),t.jsx("span",{className:je.label,children:"Disconnect"})]})]})},rc="_overlay_1dhd9_1",ac="_content_1dhd9_27",ic="_inner_1dhd9_58",tn={overlay:rc,content:ac,inner:ic},cc=({children:e})=>{const{isDrawerOpen:s,closeDrawer:n}=Ge(),{setContainer:o}=_.useContext(Wn),r=Ls(),a=Bi(),i=G.useAtomValue(Ms),c=G.useAtomValue(Os),l=$.useIsMutating({mutationKey:[jr]}),d=()=>{const p=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";n(),i?.reject(new Error(p)),c?.reject(new Error("User rejected"))},u=Ts(),m=me(),h=$.useQueryClient(),f={fallbackRender:({error:p,resetErrorBoundary:g})=>{const y=()=>{u==="/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)),m("/"),h.clear(),g()};return t.jsxs(Fe,{children:[t.jsx(se,{error:!0,children:p.message}),t.jsx(ie,{children:t.jsx(J.White,{onClick:y,children:"Retry"})})]})}};return t.jsx(Se.Dialog.Root,{open:s,onOpenChange:p=>!p&&d(),modal:!1,children:t.jsxs(Se.Dialog.Portal,{container:a,children:[r&&t.jsx(Se.Dialog.Backdrop,{className:tn.overlay,onClick:d,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(Se.Dialog.Popup,{className:tn.content,children:t.jsxs("div",{className:D(tn.inner,"body"),ref:o,children:[r&&t.jsx(Fi,{}),t.jsx(Ki,{}),t.jsx(oc,{}),t.jsx(ye,{errorBoundaryProps:f,children:e})]})})]})})},Er=_.createContext(!1),lc="_overlay_2lgi8_1",dc="_fullscreen_2lgi8_15",uc="_content_2lgi8_19",mc="_header_2lgi8_54",hc="_title_2lgi8_63",fc="_close_2lgi8_68",lt={overlay:lc,fullscreen:dc,content:uc,header:mc,title:hc,close:fc},qr=({title:e,children:s,trigger:n,className:o,open:r,onOpenChange:a})=>{const i=yt(),c=_.useContext(Er);return i?t.jsxs(Se.Dialog.Root,{open:r,onOpenChange:a,modal:!1,children:[n&&t.jsx(Se.Dialog.Trigger,{className:o,children:n}),t.jsxs(Se.Dialog.Portal,{container:i,children:[t.jsx(Se.Dialog.Backdrop,{className:D(lt.overlay,{[lt.fullscreen]:c}),onClick:()=>a(!1),forceRender:!0}),t.jsxs(Se.Dialog.Popup,{className:D(lt.content,{[lt.fullscreen]:c}),children:[e&&t.jsxs("header",{className:lt.header,children:[t.jsx(Se.Dialog.Title,{className:lt.title,children:e}),t.jsx(Se.Dialog.Close,{className:lt.close,children:t.jsx(N.IconClose,{size:20})})]}),s]})]})]}):null},bn=({children:e})=>{const s=_.useRef(null),[n,o]=_.useState(0),r=ot.useSpring({height:n,config:{tension:500,friction:30,clamp:!0}});return _.useEffect(()=>{if(s.current){const{height:a}=s.current.getBoundingClientRect();o(a)}},[e]),e?t.jsx(ot.animated.div,{style:{overflow:"hidden",...r},children:t.jsx("div",{ref:s,children:e})}):null},_c="_help_7m3jv_1",pc="_icon_7m3jv_10",gc="_info_7m3jv_17",xc="_warning_7m3jv_21",yc="_error_7m3jv_25",jc="_success_7m3jv_31",sn={help:_c,icon:pc,info:gc,warning:xc,error:yc,success:jc},At=({level:e,className:s,mt:n=8,children:o})=>{if(!o)return null;const r=()=>{switch(e){case"loading":return t.jsx(wt,{size:12});case"info":return t.jsx(N.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(N.IconWarningFilled,{size:12});default:return t.jsx(N.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:D(sn.help,e&&sn[e],s),style:{marginTop:n},children:[t.jsx("div",{className:sn.icon,children:r()}),o]})},vc="_stack_14kq8_1",wc="_help_14kq8_6",bc="_info_14kq8_14",Cc="_warning_14kq8_19",Ic="_error_14kq8_24",Nc="_success_14kq8_29",Cn={stack:vc,help:wc,info:bc,warning:Cc,error:Ic,success:Nc},Sc=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(bn,{children:t.jsx("div",{className:Cn.stack,children:e})}),ae=({mt:e=0,...s})=>t.jsx(At,{...s,className:D(Cn.help,Cn[s.level]),mt:e});ae.Stack=Sc;const kc="_root_hypwm_1",Ac="_item_hypwm_10",$c="_chevron_hypwm_14",Tc="_trigger_hypwm_19",Ec="_content_hypwm_39",Ft={root:kc,item:Ac,chevron:$c,trigger:Tc,content:Ec};function qc(e){const{list:s,getKey:n,renderHeader:o,renderContent:r,footer:a,...i}=e;return t.jsxs(te.Accordion.Root,{className:Ft.root,type:"multiple",...i,children:[s.map((c,l)=>t.jsxs(te.Accordion.Item,{className:Ft.item,value:n?.(c)??String(l),children:[t.jsx(te.Accordion.Header,{children:t.jsxs(te.Accordion.Trigger,{className:Ft.trigger,children:[o(c),t.jsx(N.IconChevronDown,{className:Ft.chevron,size:16})]})}),t.jsx(te.Accordion.Content,{className:Ft.content,children:r(c)})]},n?.(c)??l)),a]})}const Dc=10;function Dr(){const e=ne();return(s,n)=>$.queryOptions({queryKey:As.txs(s.indexerUrl,e).queryKey,queryFn:async()=>{if(!n.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Dc},{txs:r}=await z.create({prefixUrl:s.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return r},staleTime:W.SECOND})}function Pc(e,s){const n=Dr();return $.useSuspenseQuery(n(e,s))}function Rc(e,s){const n=e.flatMap((o,r)=>(s[r]??[]).map(i=>({...i,chain:o})));return b.sortWith([b.descend(o=>new Date(o.timestamp).getTime())])(n)}const Bc=()=>{const e=re(),s=Dr(),n=$.useQueries({queries:e.map(i=>s(i,{enabled:!0}))}),o=n.map(b.prop("data")),r=Rc(e,o),a=n.some(i=>i.isLoading);return{activities:r,isLoading:a}};function Pr(e){const{data:s}=$.useSuspenseQuery({queryKey:Ss.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:o}=await z.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return o.toSorted(b.descend(({denom:r})=>r==="uinit")).map(({denom:r,amount:a})=>{const i=r==="uinit"?1:Qo;return{amount:F(a).times(i).toFixed(18),denom:r}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:o})=>{if(b.isNil(o))throw new Error(`${n} has no price`);return{amount:String(o),denom:n}})},staleTime:W.SECOND});return s}function Rr(e){const s=ne(),{data:n}=Pc(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const o=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return o;try{return n.find(({tx:a})=>a.auth_info.signer_infos.some(i=>v.InitiaAddress.equals(s,We.computeAddress(`0x${V.toHex(jn.Secp256k1.uncompressPubkey(V.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const Mc="_trigger_1ti2t_1",Fc="_icon_1ti2t_18",Oc="_content_1ti2t_27",Uc="_item_1ti2t_35",Lc="_itemText_1ti2t_51",zc="_itemIndicator_1ti2t_56",Kc="_active_1ti2t_59",Xe={trigger:Mc,icon:Fc,content:Oc,item:Uc,itemText:Lc,itemIndicator:zc,active:Kc};function Br({options:e,value:s,onChange:n,classNames:o}){const r=yt(),a=e.find(c=>c.value===s);if(!a)throw new Error("Selected option not found");const i=c=>{const l=e.find(d=>String(d.value)===c);if(!l)throw new Error(`Option not found: ${c}`);n(l.value)};return t.jsxs(Le.Select.Root,{value:String(s),onValueChange:i,modal:!1,children:[t.jsxs(Le.Select.Trigger,{className:D(Xe.trigger,o?.trigger),children:[t.jsx(Le.Select.Value,{children:a.triggerLabel||a.label}),t.jsx(Le.Select.Icon,{className:Xe.icon,children:t.jsx(N.IconChevronDown,{size:12})})]}),t.jsx(Le.Select.Portal,{container:r,children:t.jsx(Le.Select.Positioner,{className:Xe.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(Le.Select.Popup,{className:Xe.popup,children:e.map(c=>t.jsxs(Le.Select.Item,{className:D(Xe.item,o?.item),value:String(c.value),children:[t.jsx(Le.Select.ItemText,{className:D(Xe.itemText,o?.itemText),children:c.label}),t.jsx(N.IconCheck,{size:12,className:D(Xe.itemIndicator,{[Xe.active]:c.value===s})})]},String(c.value)))})})})]})}const Wc="_root_epb1d_1",Hc="_trigger_epb1d_7",Qc="_item_epb1d_11",Vc="_itemText_epb1d_16",po={root:Wc,trigger:Hc,item:Qc,itemText:Vc},Gc=({options:e,value:s,onChange:n})=>{const{txRequest:o}=wr(),r=Me(o.chainId),a=Ve(r),i=(p,g)=>{if(v.formatAmount(p,{decimals:g})==="0.000000")return 8},c=({amount:[{amount:p,denom:g}]})=>{if(F(p).isZero())return"0";const{symbol:y,decimals:I}=a(g),S=i(p,I);return`${v.formatAmount(p,{decimals:I,dp:S})} ${y}`},l=e.map(p=>{const[{denom:g}]=p.amount,{symbol:y}=a(g);return{value:g,label:c(p),triggerLabel:y}});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}=a(m),f=i(u,h);return t.jsxs("div",{className:po.root,children:[t.jsx("span",{className:"monospace",children:v.formatAmount(u,{decimals:h,dp:f})}),t.jsx(Br,{options:l,value:s,onChange:n,classNames:po})]})},Yc="_root_7u427_1",Jc="_trigger_7u427_5",Zc="_chevron_7u427_13",Xc="_panel_7u427_27",el="_details_7u427_38",tl="_row_7u427_47",Nt={root:Yc,trigger:Jc,chevron:Zc,panel:Xc,details:el,row:tl},sl=({spend:e,fee:s,total:n,balance:o,symbol:r,decimals:a})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:s},e&&{label:"Required (spend + fee)",value:n},{label:"Balance",value:o}].filter(Boolean),c=a===6?void 0:8;return t.jsxs(Js.Collapsible.Root,{className:Nt.root,children:[t.jsxs(Js.Collapsible.Trigger,{className:Nt.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(N.IconChevronDown,{className:Nt.chevron,size:16})]}),t.jsx(Js.Collapsible.Panel,{className:Nt.panel,children:t.jsx("div",{className:Nt.details,children:i.map(({label:l,value:d})=>t.jsxs("div",{className:Nt.row,children:[t.jsx("span",{children:l}),t.jsxs("span",{children:[v.formatAmount(d,{decimals:a,dp:c})," ",r]})]},l))})})]})};function vs(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?V.toBase64(e):Array.isArray(e)?`[${e.map(vs).join(",")}]`:JSON.stringify(e,(s,n)=>typeof n=="bigint"?n.toString():n);default:return"unknown"}}const nl="_container_1xzyq_1",ol="_toggle_1xzyq_5",rl="_list_1xzyq_11",al="_arg_1xzyq_16",il="_type_1xzyq_21",Ot={container:nl,toggle:ol,list:rl,arg:al,type:il},cl=$e.createQueryKeys("interwovenkit:move",{abi:(e,s,n,o)=>[e,s,n,o]}),ll=({type:e,arg:s})=>vs(v.resolveBcsType(e).parse(s)),dl=({msg:e,chainId:s,fallback:n})=>{const[o,r]=Ie.useToggle(!1),{restUrl:a}=Me(s),{moduleAddress:i,moduleName:c,functionName:l,args:d}=e,{data:u}=$.useQuery({queryKey:cl.abi(a,i,c,l).queryKey,queryFn:async()=>{const h=await z.create({prefixUrl:a}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),p=JSON.parse(h.module.abi).exposed_functions.find(({name:g})=>g===l);if(!p)throw new Error(`Function ${l} not found in module ${c}`);return p.params.filter(g=>!g.startsWith("&"))},staleTime:W.INFINITY});if(!u)return n;const m=(h,f)=>{const p=u[f];return t.jsxs("div",{className:Ot.arg,children:[t.jsx("div",{className:Ot.type,children:p}),t.jsx(Wo.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(ll,{type:p,arg:h})})]},f)};return t.jsxs("div",{className:Ot.container,children:[t.jsx(J.Small,{className:Ot.toggle,onClick:r,disabled:!u,children:o?"Encode":"Decode"}),o?t.jsx("div",{className:Ot.list,children:d.map(m)}):n]})},ul="_list_r67rl_1",ml="_key_r67rl_8",hl="_value_r67rl_13",nn={list:ul,key:ml,value:hl},fl=({message:e,chainId:s})=>{const{typeUrl:n,value:o}=e;return t.jsx("div",{className:nn.list,children:Object.entries(o).map(([r,a])=>t.jsxs("div",{children:[t.jsx("div",{className:nn.key,children:r}),t.jsx("div",{className:nn.value,children:n==="/initia.move.v1.MsgExecute"&&r==="args"?t.jsx(dl,{msg:o,chainId:s,fallback:vs(a)}):vs(a)})]},r))})},_l="_item_1n572_1",pl="_title_1n572_10",gl="_content_1n572_14",on={item:_l,title:pl,content:gl},rn=({title:e,content:s})=>t.jsxs("div",{className:on.item,children:[t.jsx("div",{className:on.title,children:e}),t.jsx("div",{className:on.content,children:s})]});function Ae(e){if(e&&F(e).gt(0)&&F(e).lt(.01))return"<$0.01";const s=v.formatNumber(e,{dp:2});return s?`$${s}`:""}function Mr(e,s){const n={};for(const o of e)if(o.attributes.some(a=>a.key==="msg_index")){if(o.type==="coin_spent"){const a=o.attributes.find(c=>c.key==="spender")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(a===s&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=n[l]||BigInt(0);n[l]=d-BigInt(c)}}}if(o.type==="coin_received"){const a=o.attributes.find(c=>c.key==="receiver")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(a===s&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=n[l]||BigInt(0);n[l]=d+BigInt(c)}}}}return Object.entries(n).filter(([,o])=>o!==BigInt(0)).map(([o,r])=>({amount:r.toString(),denom:o}))}function Fr(e,s){const n={};for(const o of e)if(o.attributes.some(a=>a.key==="msg_index")&&o.type==="move"){const a=o.attributes.find(l=>l.key==="type_tag")?.value,i=o.attributes.find(l=>l.key==="data")?.value;if(!a||!i)continue;let c;try{c=JSON.parse(i)}catch{continue}if(a==="0x1::fungible_asset::WithdrawEvent"){const l=c.store_addr,d=c.amount,u=c.metadata_addr;if(l&&d&&u&&v.createUserDerivedObjectAddress(s,u)===l){const h=n[u]||BigInt(0);n[u]=h-BigInt(d)}}if(a==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,d=c.amount,u=c.metadata_addr;if(l&&d&&u&&v.createUserDerivedObjectAddress(s,u)===l){const h=n[u]||BigInt(0);n[u]=h+BigInt(d)}}}return Object.entries(n).filter(([,o])=>o!==BigInt(0)).map(([o,r])=>({amount:r.toString(),metadata:o}))}const Or=({metadata:e,chain:s,children:n})=>{const{restUrl:o}=s,{data:r}=$.useSuspenseQuery({queryKey:ys.denom(o,e).queryKey,queryFn:()=>z.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:a})=>a,staleTime:W.INFINITY});return n(r)},xl="_root_jioyr_1",yl="_title_jioyr_7",jl="_changes_jioyr_13",vl="_change_jioyr_13",wl="_amount_jioyr_34",bl="_text_jioyr_40",Cl="_value_jioyr_47",gt={root:xl,title:yl,changes:jl,change:vl,amount:wl,text:bl,value:Cl},Ur=({amount:e,asset:s,price:n})=>{const{denom:o,symbol:r,decimals:a,logoUrl:i}=s,c=v.formatAmount(e,{decimals:a}),l=n&&F(v.fromBaseUnit(e,{decimals:a})).times(n).abs();return t.jsxs("div",{className:gt.change,children:[t.jsxs("div",{className:gt.amount,children:[t.jsx(Y,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:gt.text,children:[c," ",r||o]})]}),l&&t.jsx("div",{className:gt.value,children:Ae(l)})]})},Il=({changes:e,chain:s})=>{const n=Ve(s),{data:o}=ks(s);return e.map(({amount:r,denom:a},i)=>{const c=n(a),l=o?.find(({id:d})=>d===a)?.price;return t.jsx(Ur,{amount:r,asset:c,price:l},i)})},Nl=({changes:e,chain:s})=>{const n=Ve(s),{data:o}=ks(s);return e.map(({amount:r,metadata:a},i)=>t.jsx(Or,{metadata:a,chain:s,children:c=>{const l=o?.find(({id:d})=>d===c)?.price;return t.jsx(Ur,{amount:r,asset:n(c),price:l})}},i))};function Sl(e,s){return typeof s=="bigint"?s.toString():s}const kl=$e.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Sl)]}),Al=({messages:e,memo:s,chainId:n})=>{const{initiaAddress:o,hexAddress:r}=xe(),a=Me(n),{simulateTx:i}=Fs(),{data:c}=$.useSuspenseQuery({queryKey:kl.simulate({messages:e,memo:s,chainId:n}).queryKey,queryFn:()=>i({messages:e,memo:s,chainId:n}),staleTime:W.SECOND}),l=h=>t.jsxs("div",{className:gt.root,children:[t.jsx("h2",{className:gt.title,children:"Estimated changes"}),t.jsx("div",{className:gt.changes,children:h})]});if(!c)return null;const d=c.result?.events??[];if(d.length===0)return null;if(a.metadata?.is_l1||a.metadata?.minitia?.type==="minimove"){const h=Fr(d,r),[f]=go(h);return f.length===0?null:l(t.jsx(Nl,{changes:f,chain:a}))}const u=Mr(d,o),[m]=go(u);return m.length===0?null:l(t.jsx(Il,{changes:m,chain:a}))};function go(e){return b.partition(s=>new F(s.amount).isNegative(),e)}const $l="_title_cxswl_1",Tl="_meta_cxswl_7",El="_footer_cxswl_14",ql="_rejectButton_cxswl_19",is={title:$l,meta:Tl,footer:El,rejectButton:ql},Lr=()=>{const{txRequest:e,resolve:s,reject:n}=wr(),{messages:o,memo:r,chainId:a,gas:i,gasAdjustment:c,spendCoins:l}=e,d=ne(),u=Ds(),m=Me(a),h=Bn(m),f=Pr(m),p=Rr(m),g=Ve(m),y=gr(),I=pr(),S=(e.gasPrices??f).map(({amount:x,denom:A})=>Pe.calculateFee(Math.ceil(i*c),Pe.GasPrice.fromString(x+A))),k=S.map(x=>x.amount[0]),w=x=>{const A=h.find(Z=>Z.denom===x)?.amount??"0",q=k.find(Z=>Z.denom===x)?.amount??"0",M=l.filter(Z=>Z.denom===x).reduce((Z,Ue)=>F(Z).plus(Ue.amount),F("0")),E=F(q).plus(M),H=F(A).gte(E),{symbol:ee,decimals:O}=g(x);return{symbol:ee,decimals:O,spend:M.gt(0)?M.toFixed():null,fee:q,total:E.toFixed(),balance:A,isSufficient:H}},T=()=>{if(p&&w(p).isSufficient)return p;for(const{denom:x}of k)if(w(x).isSufficient)return x;return k[0]?.denom},[P,R]=_.useState(T),{mutate:B,isPending:K}=$.useMutation({mutationKey:[jr],mutationFn:async()=>{const x=S.find(M=>M.amount[0].denom===P);if(!x)throw new Error("Fee not found");const q=!e.internal&&await y(a,o)?await I(a,d,o,x,r||""):await u(a,d,o,x,r);await s(q)},onError:async x=>{n(x)}}),j=w(P),C=!j.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(Fe,{children:[t.jsx("h1",{className:is.title,children:"Confirm tx"}),t.jsxs("div",{className:is.meta,children:[t.jsx(rn,{title:"Chain",content:a}),t.jsx(rn,{title:"Tx fee",content:t.jsx(Gc,{options:S,value:P,onChange:R})}),r&&t.jsx(rn,{title:"Memo",content:r}),C&&t.jsx(ae,{level:"error",children:t.jsx(sl,{...j})})]}),t.jsx(Al,{messages:o,memo:r,chainId:a}),t.jsx(qc,{list:o,renderHeader:({typeUrl:x})=>Is.sentenceCase(x.split(".").pop().replace(/^Msg/,"")),renderContent:x=>t.jsx(fl,{message:x,chainId:a})})]}),t.jsxs(ie,{className:is.footer,children:[t.jsx(J.Outline,{onClick:()=>n(new Error("User rejected")),disabled:K,className:is.rejectButton,children:t.jsx(N.IconClose,{size:16})}),t.jsx(J.White,{onClick:()=>B(),disabled:C,loading:K,children:"Approve"})]})]})},Dl=({children:e})=>{const[{title:s,content:n,path:o},r]=_.useState({}),[a,i]=_.useState(!1),c=G.useAtomValue(Ms),l=_.useCallback(m=>{r(m),i(!0)},[]),d=_.useCallback(()=>{r({}),i(!1)},[]),u=_.useCallback(m=>{m||(c?.reject(new Error("User rejected")),r({})),i(m)},[c]);return t.jsxs(xr.Provider,{value:{openModal:l,closeModal:d},children:[e,t.jsx(qr,{title:s,open:a,onOpenChange:u,children:t.jsx(ye,{children:o==="/tx"?t.jsx(Lr,{}):n})})]})},Pl="_container_1zg8z_1",Rl="_toast_1zg8z_10",Bl="_info_1zg8z_23",Ml="_success_1zg8z_27",Fl="_error_1zg8z_31",Ol="_icon_1zg8z_36",Ul="_content_1zg8z_43",Ll="_title_1zg8z_46",zl="_description_1zg8z_51",Kl="_close_1zg8z_72",et={container:Pl,toast:Rl,info:Bl,success:Ml,error:Fl,icon:Ol,content:Ul,title:Ll,description:zl,close:Kl},Wl=({notification:e,onClose:s,...n})=>{const o=ot.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}}),r=a=>{switch(a){case"loading":return t.jsx(wt,{size:16});case"info":case"success":return t.jsx(N.IconCheckCircleFilled,{size:16});case"error":return t.jsx(N.IconCloseCircleFilled,{size:16});default:return null}};return o((a,i)=>{if(!i)return null;const{type:c,title:l,description:d}=i,u=r(c);return t.jsx(ot.animated.div,{style:a,className:et.container,children:t.jsxs("div",{className:D(et.toast,c&&et[c]),...n,children:[u&&t.jsx("div",{className:et.icon,children:u}),t.jsxs("div",{className:et.content,children:[t.jsx("p",{className:et.title,children:l}),d&&t.jsx("div",{className:et.description,children:d})]}),t.jsx("button",{className:et.close,onClick:s,children:t.jsx(N.IconClose,{size:14})})]})})})},an=5e3,Hl=({children:e})=>{const s=yt(),[n,o]=_.useState(null),r=_.useRef(null),a=_.useRef(!1),i=()=>{r.current&&(clearTimeout(r.current),r.current=null)},c=_.useCallback(()=>{i(),o(null)},[]),l=_.useCallback(h=>{i(),o({...h,id:ao.nanoid()}),h.autoHide&&!a.current&&(r.current=setTimeout(()=>c(),an))},[c]),d=_.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:ao.nanoid()}),h.autoHide&&!a.current&&(r.current=setTimeout(()=>c(),an))},[c]),u=()=>{i(),a.current=!0},m=()=>{i(),a.current=!1,n?.autoHide&&(r.current=setTimeout(()=>c(),an))};return _.useEffect(()=>()=>i(),[]),t.jsxs(Tr.Provider,{value:{showNotification:l,updateNotification:d,hideNotification:c},children:[e,s&&Ca.createPortal(t.jsx(Wl,{notification:n,onClose:c,onMouseEnter:u,onMouseLeave:m}),s)]})},Ql=({children:e})=>{const[s,n]=_.useState(null);return t.jsx(Wn.Provider,{value:{container:s,setContainer:n},children:e})},zr=[{value:10*cr,label:"for 10 minutes"},{value:lr,label:"for 1 hour"},{value:lo,label:"for 1 day"},{value:7*lo,label:"for 7 days"},{value:0,label:"until revoked"}],Vl=zr[0].value,Gl="_container_t8r4b_1",Yl="_title_t8r4b_7",Jl="_description_t8r4b_14",Zl="_sectionTitle_t8r4b_20",Xl="_websiteInfo_t8r4b_27",ed="_favicon_t8r4b_37",td="_websiteTitle_t8r4b_42",sd="_websiteHost_t8r4b_48",nd="_warningContent_t8r4b_54",od="_ignoreButton_t8r4b_60",rd="_infoList_t8r4b_64",ad="_infoItem_t8r4b_74",id="_label_t8r4b_83",cd="_infoValue_t8r4b_92",ld="_durationTrigger_t8r4b_98",dd="_durationItem_t8r4b_99",ud="_featureList_t8r4b_103",md="_featureItem_t8r4b_111",hd="_checkIcon_t8r4b_121",fd="_learnMoreLink_t8r4b_125",_d="_footer_t8r4b_138",Q={container:Gl,title:Yl,description:Jl,sectionTitle:Zl,websiteInfo:Xl,favicon:ed,websiteTitle:td,websiteHost:sd,warningContent:nd,ignoreButton:od,infoList:rd,infoItem:ad,label:id,infoValue:cd,durationTrigger:ld,durationItem:dd,featureList:ud,featureItem:md,checkIcon:hd,learnMoreLink:fd,footer:_d};function pd(){const[e,s]=_.useState(Vl),[n,o]=G.useAtom(Os),[r,a]=_.useState(!1),i=Te(),c=re(),{address:l,username:d}=xe(),{mutate:u,isPending:m}=ci(),{closeDrawer:h}=Ge(),f={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},p=c.some(w=>{if(!w.website)return!1;const T=xo(new URL(w.website).hostname),P=xo(window.location.hostname);return T===P});if(!n)return null;const{logoUrl:g,name:y}=i(n.chainId),I=()=>{u(e)},S=()=>{n?.reject(new Error("User cancelled")),o(null),h()},k=!p&&!r;return t.jsxs(t.Fragment,{children:[t.jsxs(Fe,{className:Q.container,children:[t.jsxs("header",{children:[t.jsx("h1",{className:Q.title,children:"Enable auto-signing"}),t.jsx("p",{className:Q.description,children:"An application is requesting to enable auto-signing"})]}),t.jsxs("section",{children:[t.jsx("h2",{className:Q.sectionTitle,children:"Requested by"}),t.jsxs("div",{className:Q.websiteInfo,children:[t.jsx("img",{src:f.favicon,alt:"",className:Q.favicon}),t.jsxs("div",{children:[t.jsx("div",{className:Q.websiteTitle,children:f.title}),t.jsx("div",{className:Q.websiteHost,children:f.hostname})]})]}),!p&&!r&&t.jsx(ae,{level:"warning",mt:8,children:t.jsxs("div",{className:Q.warningContent,children:[t.jsx("span",{children:"You are on an unverified website"}),t.jsx("button",{onClick:()=>a(!0),className:Q.ignoreButton,children:"Ignore"})]})})]}),t.jsxs("section",{children:[t.jsx("h2",{className:Q.sectionTitle,children:"Applies to"}),t.jsxs("div",{className:Q.infoList,children:[t.jsxs("div",{className:Q.infoItem,children:[t.jsx("div",{className:Q.label,children:"Address"}),t.jsxs("div",{className:Q.infoValue,children:[t.jsx(N.IconWallet,{size:14}),t.jsx("span",{className:"monospace",children:v.truncate(d??l)})]})]}),t.jsxs("div",{className:Q.infoItem,children:[t.jsx("div",{className:Q.label,children:"Chain"}),t.jsxs("div",{className:Q.infoValue,children:[t.jsx(Y,{src:g,width:14,height:14,logo:!0}),t.jsx("span",{children:y})]})]}),t.jsxs("div",{className:Q.infoItem,children:[t.jsx("div",{className:Q.label,children:"Duration"}),t.jsx(Br,{options:zr,value:e,onChange:s,classNames:{trigger:Q.durationTrigger,item:Q.durationItem}})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:Q.sectionTitle,children:"About auto-signing"}),t.jsx("ul",{className:Q.featureList,children:["Send transactions without confirmation pop-ups","Protected by Privy embedded wallet","Revoke permissions any time in settings"].map(w=>t.jsxs("li",{className:Q.featureItem,children:[t.jsx(N.IconCheckCircle,{size:12,className:Q.checkIcon}),t.jsx("span",{children:w})]},w))}),t.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",className:Q.learnMoreLink,children:["Learn more ",t.jsx(N.IconExternalLink,{size:12})]})]})]}),t.jsxs(ie,{className:Q.footer,children:[t.jsx(J.Outline,{onClick:S,children:"Cancel"}),t.jsx(J.White,{onClick:I,disabled:k,loading:m,children:"Enable"})]})]})}function xo(e){const s=e.split(".");return s.length<2?e:s.slice(-2).join(".")}const gd="_container_1a4ds_1",xd="_badge_1a4ds_5",yo={container:gd,badge:xd},Kr=e=>{const{offset:s=-4,disabled:n,children:o,className:r}=e;return t.jsxs("div",{className:D(yo.container,r),children:[o,!n&&t.jsx("div",{className:yo.badge,style:{right:s,top:s}})]})},yd="_header_acels_1",jd="_back_acels_11",vd="_title_acels_23",cn={header:yd,back:jd,title:vd},Oe=({title:e,backButton:s,extra:n,children:o})=>t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:cn.header,children:[t.jsx(Et,{to:s??-1,className:cn.back,shouldReset:!!s,children:t.jsx(N.IconBack,{size:16})}),t.jsx("h1",{className:cn.title,children:e}),n]}),t.jsx(Fe,{children:o})]});function Wr(){const{initiaAddress:e,hexAddress:s}=xe(),n=vt(),o=ts();return r=>{const a=n(r);switch(o(a)){case"initia":return e;case"evm":return s;default:return""}}}function Hr(){const e=vt(),s=ts();return(n,o)=>{const r=e(o);switch(s(r)){case"initia":return v.InitiaAddress.validate(n);case"evm":return We.isAddress(n);case"cosmos":try{return V.fromBech32(n).prefix===r.bech32_prefix}catch{return!1}default:return!1}}}function wd(){const e=vt(),s=ts();return({initialAddress:n,initialChainId:o,chainId:r,fallbackAddress:a})=>{const i=e(o),c=s(i),l=e(r),d=s(l);if(c==="evm"&&d==="initia")return v.InitiaAddress(n).bech32;if(c==="initia"&&d==="evm")return v.InitiaAddress(n).hex;if(c===d)return n;if(a){if(d==="initia")return v.InitiaAddress(a).bech32;if(d==="evm")return v.InitiaAddress(a).hex}return""}}function bd(){return _e().network_type==="testnet"}function rt(){return ue.useFormContext()}function Cd(){const e=jt(),s=bd(),n={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},o={...n,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},r={...n,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},a=b.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?o:r,...a,...e}}const Id="_root_xwz5z_1",Nd="_header_xwz5z_6",Sd="_title_xwz5z_12",kd="_warning_xwz5z_18",Ad="_content_xwz5z_22",$d="_footer_xwz5z_26",Td="_secondary_xwz5z_36",dt={root:Id,header:Nd,title:Sd,warning:kd,content:Ad,footer:$d,secondary:Td},Qr=e=>{const{type:s,icon:n,title:o,children:r,primaryButton:a,secondaryButton:i}=e;return t.jsxs(Fe,{className:dt.root,children:[t.jsxs("header",{className:D(dt.header,s&&dt[s]),children:[n,t.jsx("h1",{className:dt.title,children:o})]}),t.jsx("div",{className:dt.content,children:r}),t.jsxs("footer",{className:dt.footer,children:[t.jsx(J.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),t.jsxs("button",{className:dt.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(N.IconChevronRight,{size:14})]})]})]})},Ed="_list_tmcxc_1",qd="_row_tmcxc_8",Dd="_dt_tmcxc_19",Pd="_asset_tmcxc_25",cs={list:Ed,row:qd,dt:Dd,asset:Pd},Rd=({list:e,onNavigate:s,onDismiss:n})=>{const o=_e(),r=Te(),a=Ve(o);return t.jsx(Qr,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:s},secondaryButton:{label:"Do not show again",onClick:n},children:t.jsx("div",{className:cs.list,children:e.toSorted((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:d})=>{const u=r(c),{decimals:m,symbol:h}=a(d),f=v.formatAmount(l,{decimals:m});return t.jsxs("div",{className:cs.row,children:[t.jsxs("div",{className:cs.dt,children:[t.jsx(Y,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:cs.asset,children:[f," ",h]})]},i)})})})};function ln(e,s){return e.chainId===s.chainId&&e.txHash===s.txHash}const ls=({chainId:e,txHash:s})=>`${U.OP_REMINDER}:${e}:${s}`,Bd=Ia.atomWithStorage(U.OP_REMINDER,[]);function Rt(){const e=ne(),[s=[],n]=G.useAtom(Bd),o=_.useMemo(()=>s.map(l=>{const d=localStorage.getItem(ls(l));return d?JSON.parse(d):null}).filter(l=>{if(!l)return!1;const{recipient:d,claimableAt:u}=l;return d!==e?!1:ke.isPast(u)}),[e,s]),r=_.useCallback((l,d)=>{s.some(u=>ln(u,l))||(n((u=[])=>[...u,l]),localStorage.setItem(ls(l),JSON.stringify(d)))},[s,n]),a=_.useCallback(l=>{n((d=[])=>d.filter(u=>!ln(u,l))),localStorage.removeItem(ls(l))},[n]),i=_.useCallback(l=>{const d=l.filter(u=>!s.some(m=>ln(m,u)));d.length!==0&&n((u=[])=>[...u,...d])},[s,n]),c=_.useCallback((l,d)=>{localStorage.setItem(ls(l),JSON.stringify(d)),n((u=[])=>[...u])},[n]);return{reminders:o,addReminder:r,removeReminder:a,syncReminders:i,setReminder:c}}function Vr(){const e=me(),{openModal:s,closeModal:n}=Bs(),{reminders:o,setReminder:r}=Rt();_.useEffect(()=>{const a=o.filter(l=>!l.dismissed);if(a.length===0)return;const i=()=>{const l=a.every(d=>d.chainId===a[0].chainId)?a[0].chainId:void 0;e("/op/withdrawals",{chainId:l}),c()},c=()=>{n();for(const l of a)r(l,{...l,dismissed:!0})};s({content:_.createElement(Rd,{list:a,onNavigate:i,onDismiss:c})})},[o,n,e,s,r])}const Md="_wrapper_5ssm8_1",Fd="_balance_5ssm8_11",Od="_button_5ssm8_15",dn={wrapper:Md,balance:Fd,button:Od},Gr=({onClick:e,children:s,disabled:n})=>t.jsxs("div",{className:dn.wrapper,children:[t.jsx(N.IconWallet,{size:16}),t.jsx("span",{className:dn.balance,children:s}),t.jsx("button",{type:"button",tabIndex:-1,className:dn.button,onClick:()=>e(),disabled:n,children:"MAX"})]}),Ud="_fieldset_y241y_1",Ld="_upper_y241y_9",zd="_select_y241y_14",Kd="_account_y241y_19",Wd="_lower_y241y_24",Hd="_wrapper_y241y_25",Qd="_balance_y241y_32",Vd="_value_y241y_36",Gd="_error_y241y_49",ze={fieldset:Ud,upper:Ld,select:zd,account:Kd,lower:Wd,wrapper:Hd,balance:Qd,value:Vd,error:Gd},In=e=>{const{selectButton:s,accountButton:n,quantityInput:o,balanceButton:r,value:a,errorMessage:i,hideNumbers:c}=e;return t.jsxs("div",{className:ze.fieldset,children:[t.jsxs("div",{className:ze.upper,children:[t.jsx("div",{className:ze.select,children:s}),t.jsx("div",{className:ze.account,children:n})]}),!c&&t.jsxs("div",{className:ze.lower,children:[o,t.jsxs("div",{className:ze.wrapper,children:[t.jsx("div",{className:ze.balance,children:r}),a&&t.jsx("div",{className:ze.value,children:a})]}),i&&t.jsxs("footer",{className:ze.error,children:[t.jsx(N.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function ss(){const e=_.useRef(null),s=Ls();return _.useEffect(()=>{s||e.current?.focus()},[s]),e}const Yd="_input_h8073_1",Jd={input:Yd};function jo(e,s){const n=e.replace(/[^0-9.]/g,""),[o,...r]=n.split(".");return r.length===0?o:`${o}.${r.join("").slice(0,s)}`}function Yr(e){const{name:s,control:n,dp:o=6,className:r,rules:a,...i}=e,c=ss();return t.jsx(ue.Controller,{name:s,control:n,rules:a,render:({field:l})=>t.jsx("input",{...l,className:D(Jd.input,r),onChange:d=>l.onChange(jo(d.target.value,o)),onPaste:d=>{d.preventDefault();const u=d.clipboardData.getData("text");if(!/^[0-9,]+(\.[0-9]+)?$/.test(u))return;const h=u.replace(/,/g,""),f=jo(h,o);l.onChange(f)},placeholder:"0",inputMode:"decimal",autoComplete:"off",...i,ref:Ho.mergeRefs([l.ref,c])})})}const Zd="_input_qpv94_1",Xd="_placeholder_qpv94_18",Nn={input:Zd,placeholder:Xd},eu=({children:e})=>t.jsx("p",{className:D(Nn.input,{[Nn.placeholder]:F(e).isZero()}),children:e}),ws=({balance:e,decimals:s})=>{const{control:n}=ue.useFormContext(),o={required:"Enter amount",validate:r=>F(r).isZero()?"Enter amount":F(v.toBaseUnit(r,{decimals:s})).gt(e??0)?"Insufficient balance":!0};return t.jsx(Yr,{name:"quantity",control:n,className:Nn.input,rules:o})};ws.ReadOnly=eu;const Dt=({title:e,content:s,children:n,className:o})=>{const[r,a]=_.useState(!1),i=()=>a(!1);return t.jsx(qr,{title:e,trigger:n,className:o,open:r,onOpenChange:a,children:s(i)})},tu="_tooltip_6zakp_1",su="_arrow_6zakp_43",vo={tooltip:tu,arrow:su},ns=({label:e,children:s,small:n,...o})=>t.jsxs(te.Tooltip.Root,{...o,children:[t.jsx(te.Tooltip.Trigger,{asChild:!0,children:s}),t.jsx(te.Tooltip.Portal,{container:yt(),children:t.jsxs(te.Tooltip.Content,{className:D(vo.tooltip,{small:n}),collisionBoundary:yt(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(te.Tooltip.Arrow,{className:vo.arrow})]})})]});function Qn(e,s){const n=Ye();return $.useQuery({queryKey:Re.balances(s,e).queryKey,queryFn:()=>n.post("v2/info/balances",{json:{chains:{[s]:{address:e,denoms:[]}}}}).json(),select:({chains:o})=>e?o?o[s].denoms??{}:{}:{},enabled:!!e,staleTime:W.SECOND})}function nu(e,s,n){const{data:o={}}=Qn(e,s);return b.path([n],o)}const ou=[["d",1440*60],["h",3600],["m",60],["s",1]];function Sn(e){if(!e)return;const{formattedParts:s}=ou.reduce(({remainingSeconds:n,formattedParts:o},[r,a])=>{const i=Math.floor(n/a);return{remainingSeconds:n-i*a,formattedParts:i>0?[...o,`${i}${r}`]:o}},{remainingSeconds:e,formattedParts:[]});return s.join(" ")}function Jr(e){return e?.map(s=>{const{amount:n,origin_asset:o}=s;return`${v.formatAmount(n,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function wo(e,s){const{watch:n}=rt(),o=n(),r=Ye(),a=Es(),i={...o,quantity:e},c=$.useQueryClient();return $.useQuery({queryKey:Re.route(i,s?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:l,srcDenom:d,quantity:u,dstChainId:m,dstDenom:h}=i,{decimals:f}=c.getQueryData(Re.asset(l,d).queryKey)??{decimals:0},p={amount_in:v.toBaseUnit(u,{decimals:f}),source_asset_chain_id:l,source_asset_denom:d,dest_asset_chain_id:m,dest_asset_denom:h,is_op_withdraw:s?.isOpWithdraw},g=await r.post("v2/fungible/route",{json:p}).json(),y={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return a("Bridge Simulation Success",y),g},enabled:!!Number(i.quantity)&&!s?.disabled,staleTime:W.MINUTE})}function ru(e){return $.useQuery({queryKey:Re.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 au(){const{watch:e}=rt(),{srcChainId:s,srcDenom:n,dstChainId:o,dstDenom:r}=e(),a=Be(s),i=Jt(a),c=Qe(n,s),l=Qe(r,o),d=_e(),u=re();return i==="initia"&&o===d.chainId&&c.symbol===l.symbol&&u.find(m=>m.chainId===s)?.metadata?.op_denoms?.includes(l.denom)}const iu="_label_9417z_1",cu="_wrapper_9417z_7",lu="_input_9417z_10",du="_clear_9417z_18",ds={label:iu,wrapper:cu,input:lu,clear:du},Vn=({mode:e="onChange",myAddress:s,...n})=>{const{validate:o=v.InitiaAddress.validate,chainType:r="initia",onApply:a,ref:i}=n,c=ss(),{control:l,getValues:d,setValue:u,formState:m}=ue.useFormContext(),h=d("recipient"),[f,p]=_.useState(h),g=sr(),{data:y,isLoading:I,error:S}=$.useQuery({queryKey:As.address(g.restUrl,f).queryKey,queryFn:()=>g.getAddress(f),staleTime:W.MINUTE,enabled:g.validateUsername(f)}),k=y??(o(f)?f:""),w=s&&v.InitiaAddress.equals(k,s),T=async()=>{try{const B=await navigator.clipboard.readText();p(B.trim())}catch{}};_.useEffect(()=>{e==="onChange"&&(!f&&!m.dirtyFields.recipient||u("recipient",y??f,{shouldValidate:!0,shouldDirty:!0}))},[m.dirtyFields.recipient,f,e,u,y]);const P=()=>{I||S||(u("recipient",k,{shouldValidate:!0,shouldDirty:!0}),a?.())},R=()=>{if(I)return t.jsx(At,{level:"loading",children:"Resolving username..."});if(S)return t.jsx(At,{level:"error",children:S.message});if(y)return t.jsx(At,{level:"success",className:"monospace",children:y});if(e==="onSubmit"&&f&&!k)return t.jsx(At,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:ds.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(J.Small,{type:"button",tabIndex:-1,onClick:T,children:"Paste"})]}),t.jsxs("div",{className:ds.wrapper,children:[t.jsx(ue.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:B=>o(B)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:D(ds.input,"monospace"),value:f,onChange:B=>p(B.target.value.trim()),placeholder:r==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?Ho.mergeRefs([i,c]):i})}),!!f&&t.jsx("button",{type:"button",className:ds.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:t.jsx(N.IconCloseCircleFilled,{size:16})})]}),R(),w&&t.jsx(At,{children:"This is my address"}),e==="onSubmit"&&t.jsx(ie,{extra:(!s||!!k&&!w)&&t.jsx(ae,{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(J.White,{type:"button",onClick:P,disabled:I||!!S||!k,children:"Apply"})})]})},uu="_scrollable_1p1lw_1",mu="_list_1p1lw_5",hu="_item_1p1lw_9",fu="_name_1p1lw_13",us={scrollable:uu,list:mu,item:hu,name:fu};function Zr({onSelect:e,list:s,...n}){const{getImage:o,getName:r,getKey:a,getIsLoading:i,getDisabled:c}=n;return t.jsx(Fe,{className:us.scrollable,children:t.jsx("div",{className:us.list,children:s.map(l=>t.jsxs("button",{className:us.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),children:[t.jsx(Y,{src:o(l),width:28,height:28}),t.jsx("span",{className:us.name,children:r(l)}),i?.(l)&&t.jsx(wt,{size:16})]},a(l)))})})}function Ks(){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(o=>o.name===n)}}const _u="_account_iwrlj_8",pu="_clear_iwrlj_27",gu="_white_iwrlj_38",Ut={account:_u,clear:pu,white:gu},bo=({type:e})=>{const{watch:s,setValue:n}=rt(),{srcChainId:o,dstChainId:r,cosmosWalletName:a}=s(),c=s(e==="src"?"sender":"recipient"),l=Jt(Be(r)),{list:d,find:u}=Ks(),m=u(a),h=Wr(),f=Hr(),p=h(r),g=v.InitiaAddress.equals(c,p),y=()=>t.jsx(Dt,{title:"Connect wallet",content:k=>t.jsx(Zr,{onSelect:async w=>{const T=w.getProvider();if(!T)return window.open(w.fallbackUrl,"_blank");const P=T.getOfflineSigner(o),[{address:R}]=await P.getAccounts();n("sender",R),n("cosmosWalletName",w.name),k()},list:d,getImage:w=>w.image,getName:w=>w.name,getKey:w=>w.name}),className:D(Ut.account,{[Ut.white]:!c}),children:c?t.jsxs(t.Fragment,{children:[m&&t.jsx(Y,{src:m.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:v.truncate(c)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(N.IconChevronRight,{size:14})]})}),I=k=>t.jsx(Dt,{title:"Recipient",content:w=>t.jsx(Fe,{children:t.jsx(Vn,{mode:"onSubmit",myAddress:p,chainType:l,validate:T=>f(T,r),onApply:w})}),className:Ut.account,children:k}),S=()=>{switch(l){case"initia":case"evm":return g?I(t.jsx(N.IconWallet,{size:14})):t.jsxs("div",{className:Ut.account,children:[t.jsx("span",{className:"monospace",children:v.truncate(c)}),t.jsx("button",{type:"button",className:Ut.clear,onClick:()=>n("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(N.IconCloseCircleFilled,{size:14})})]});case"cosmos":return I(t.jsxs(t.Fragment,{children:[c?t.jsx("span",{className:"monospace",children:v.truncate(c)}):t.jsx("span",{children:"Recipient"}),t.jsx(N.IconEdit,{size:14})]}))}};switch(e){case"src":return y();case"dst":return S()}},xu="_images_cj4xz_1",un={images:xu},Ws=({assetLogoUrl:e,assetLogoSize:s=36,chainLogoUrl:n,chainLogoSize:o=18,chainLogoOffset:r=6,className:a})=>t.jsxs("div",{className:D(un.images,a),style:{position:"relative"},children:[t.jsx(Y,{src:e,width:s,height:s,className:un.asset,logo:!0}),t.jsx(Y,{src:n,width:o,height:o,className:un.chain,style:{position:"absolute",bottom:0,right:-1*r},logo:!0})]}),yu="_root_1ipwv_1",ju="_content_1ipwv_10",vu="_details_1ipwv_18",wu="_symbol_1ipwv_23",bu="_chain_1ipwv_31",Cu="_chevron_1ipwv_40",ut={root:yu,content:ju,details:vu,symbol:wu,chain:bu,chevron:Cu},Xr=({asset:e,chain:s,readOnly:n})=>{const o=t.jsxs("div",{className:ut.content,children:[t.jsx(Ws,{assetLogoUrl:e.logoUrl,chainLogoUrl:s.logoUrl}),t.jsxs("div",{className:ut.details,children:[t.jsx("div",{className:ut.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:ut.chain,children:["on ",s.name]})]})]});return n?t.jsx("div",{className:ut.root,children:o}):t.jsxs("div",{className:ut.root,children:[o,t.jsx(N.IconChevronDown,{size:16,className:ut.chevron})]})};function Iu(e,s,n){return n.filter(o=>{const r=e.map(a=>o[a]).map(a=>String(a??"").toLowerCase());return b.any(b.includes(s.toLowerCase()),r)})}const Nu="_root_7yxgy_1",Su="_label_7yxgy_7",ku="_input_7yxgy_19",Au="_hasValue_7yxgy_29",$u="_clear_7yxgy_33",Lt={root:Nu,label:Su,input:ku,hasValue:Au,clear:$u},Hs=e=>{const{rootClassName:s,padding:n=16,iconSize:o=16,onClear:r,ref:a,...i}=e;return t.jsxs("div",{className:D(Lt.root,s,{[Lt.hasValue]:i.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${o}px`},children:[t.jsx("label",{htmlFor:"search",className:Lt.label,children:t.jsx(N.IconSearch,{size:o})}),t.jsx("input",{className:Lt.input,id:"search",type:"text",maxLength:100,ref:a,...i}),i.value&&t.jsx("button",{type:"button",className:Lt.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:r,children:t.jsx(N.IconCloseCircleFilled,{size:o})})]})},Tu="_container_1voou_1",Eu="_search_1voou_6",qu="_list_1voou_10",Du="_item_1voou_14",Pu="_logo_1voou_35",Ru="_info_1voou_39",Bu="_symbol_1voou_44",Mu="_name_1voou_52",Fu="_balance_1voou_58",Ou="_value_1voou_65",Ce={container:Tu,search:Eu,list:qu,item:Du,logo:Pu,info:Ru,symbol:Bu,name:Mu,balance:Fu,value:Ou},os=e=>{const{assets:s,onSelect:n,renderAsset:o=(c,l)=>l(c)}=e,[r,a]=_.useState(""),i=Iu(["symbol"],r,s);return t.jsxs("div",{className:Ce.container,children:[t.jsx(Hs,{value:r,onChange:c=>a(c.target.value),onClear:()=>a(""),placeholder:"Search by symbol",rootClassName:Ce.search,padding:20,ref:ss()}),i.length===0?t.jsx(se,{children:"No assets"}):t.jsx("div",{className:Ce.list,children:i.map(c=>t.jsx("button",{type:"button",className:Ce.item,onClick:()=>n(c.denom),children:o(c,l=>{const{denom:d,logoUrl:u,symbol:m,name:h,balance:f,decimals:p,value:g=0}=l;return t.jsxs(t.Fragment,{children:[t.jsx(Y,{src:u,width:32,height:32,className:Ce.logo,logo:!0}),t.jsxs("div",{className:Ce.info,children:[t.jsx("div",{className:Ce.symbol,children:m||d}),t.jsx("div",{className:Ce.name,children:h})]}),t.jsxs("div",{className:Ce.balance,children:[f&&t.jsx("div",{children:v.formatAmount(f,{decimals:p})}),g>0&&t.jsx("div",{className:Ce.value,children:Ae(g)})]})]})})},c.denom))})]})},Uu=()=>t.jsxs("div",{className:Ce.container,children:[t.jsx(Hs,{rootClassName:Ce.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(se,{children:"Loading..."})]});os.Placeholder=Uu;const Lu="_stack_a3b9q_1",zu="_title_a3b9q_8",Ku="_grid_a3b9q_15",Wu="_item_a3b9q_21",Hu="_button_a3b9q_25",Qu="_active_a3b9q_43",$t={stack:Lu,title:zu,grid:Ku,item:Wu,button:Hu,active:Qu},xt=({label:e,chains:s,value:n,onSelect:o,getShowIndicator:r})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:$t.title,children:e}),t.jsx("div",{className:$t.grid,children:s.map(({chainId:a,name:i,logoUrl:c})=>t.jsx(Kr,{offset:-2,disabled:!r?.(a),className:$t.item,children:t.jsx(ns,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:D($t.button,{[$t.active]:a===n}),onClick:()=>o(a),children:t.jsx(Y,{src:c,width:28,height:28,logo:!0})})})},a))})]}),Vu=({children:e})=>t.jsx("div",{className:$t.stack,children:e});xt.Stack=Vu;const Gu=({address:e,chain:s,onSelect:n})=>{const o=qt(s.chain_id),{data:r={}}=Qn(e,s.chain_id);return t.jsx(os,{assets:b.sortWith([b.descend(a=>a.symbol==="INIT"),b.descend(a=>a.value),({balance:a="0"},{balance:i="0"})=>F(i).comparedTo(a)??0,b.ascend(a=>a.symbol.toLowerCase())],o.filter(a=>!a.hidden).map(a=>{const{denom:i,symbol:c=v.truncate(i),logo_uri:l}=a,d=r[i]??{};return{...a,symbol:c,decimals:a.decimals??0,logoUrl:l??"",name:a.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:n})},Yu=({type:e,afterSelect:s})=>{const n=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",r=e==="src"?"sender":"recipient",a=Pt(),i=Kn(),{watch:c,setValue:l}=rt(),d=c(r),u=c(n),m=c(o),[h,f]=_.useState(u),p=Be(h),g=wd(),y=Sr(),[I,S]=b.partition(w=>y(w.chain_id),i.filter(w=>!w.hidden)),k=w=>{if(u===h&&m===w){s();return}l(n,h),l(o,w),s()};return t.jsxs(t.Fragment,{children:[t.jsxs(xt.Stack,{children:[t.jsx(xt,{label:"Interwoven Economy",chains:I.map(({chain_id:w,chain_name:T,pretty_name:P,logo_uri:R})=>({chainId:w,name:P||T,logoUrl:R??""})),value:h,onSelect:f}),t.jsx(xt,{label:"Chains",chains:S.map(({chain_id:w,chain_name:T,pretty_name:P,logo_uri:R})=>({chainId:w,name:P||T,logoUrl:R??""})),value:h,onSelect:f})]}),t.jsx(ye,{suspenseFallback:t.jsx(os.Placeholder,{}),children:t.jsx(Gu,{address:g({initialAddress:d,initialChainId:u,chainId:h,fallbackAddress:e==="src"?a:void 0}),chain:p,onSelect:k})},h)]})},Co=({type:e})=>{const s=e==="src"?"srcChainId":"dstChainId",n=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:r}=rt(),a=r(s),i=r(n),c=Be(a),l=Qe(i,a);return t.jsx(Dt,{title:o,content:d=>t.jsx(Yu,{type:e,afterSelect:d}),children:t.jsx(Xr,{asset:{denom:l.denom,decimals:l.decimals??0,symbol:l.symbol,logoUrl:l.logo_uri??""},chain:{chainId:c.chain_id,name:c.pretty_name||c.chain_name,logoUrl:c.logo_uri??""}})})},Ju="_skeleton_1l4jn_1",Zu={skeleton:Ju},mn=({width:e="100%",height:s})=>t.jsx("div",{className:Zu.skeleton,style:{width:e,height:s}}),Xu="_stack_1ip8h_1",em="_button_1ip8h_6",tm="_isLoading_1ip8h_19",sm="_disabled_1ip8h_19",nm="_checked_1ip8h_23",om="_header_1ip8h_37",rm="_title_1ip8h_43",am="_duration_1ip8h_52",im="_warning_1ip8h_62",cm="_amount_1ip8h_66",lm="_value_1ip8h_67",be={stack:Xu,button:em,isLoading:tm,disabled:sm,checked:nm,header:om,title:rm,duration:am,warning:im,amount:cm,value:lm},dm=({children:e})=>t.jsx("div",{className:be.stack,children:e}),ps=({label:e,query:s,value:n,onSelect:o,...r})=>{const{data:a,isLoading:i}=s,{watch:c}=rt(),{dstChainId:l,dstDenom:d}=c(),u=Qe(d,l),m=!i&&r.checked,h=!i&&!a;return t.jsxs("button",{type:"button",className:D(be.button,{[be.isLoading]:i,[be.disabled]:h,[be.checked]:m}),onClick:()=>{i||h||o(n)},children:[t.jsxs("div",{className:be.header,children:[t.jsxs("div",{className:be.title,children:[t.jsx("span",{children:e}),m&&t.jsx(N.IconCheck,{size:14})]}),i?t.jsx(mn,{width:80,height:16}):a?t.jsxs("div",{className:D(be.duration,{[be.warning]:n==="op"}),children:[t.jsx(N.IconClockFilled,{size:12}),t.jsx("span",{children:Sn(a.estimated_route_duration_seconds)})]}):t.jsx("div",{className:be.duration,children:"Not available"})]}),(i||a)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:be.amount,children:i?t.jsx(mn,{width:260,height:40}):a?v.formatAmount(a.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:be.value,children:i?t.jsx(mn,{width:120,height:16}):a?a.usd_amount_out?Ae(a.usd_amount_out):"$-":null})]})]})};ps.Stack=dm;const um="_description_s1yto_1",mm="_presets_s1yto_8",hm="_preset_s1yto_8",fm="_active_s1yto_28",_m="_custom_s1yto_39",pm="_wrapper_s1yto_45",gm="_percent_s1yto_54",qe={description:um,presets:mm,preset:hm,active:fm,custom:_m,wrapper:pm,percent:gm},Io=["0.1","0.5","1.0"],xm=({afterConfirm:e})=>{const s=rt(),n=s.getValues("slippagePercent"),[o,r]=_.useState(null),{control:a,watch:i,getValues:c,setValue:l}=ue.useForm({defaultValues:{value:n}}),d=i("value");_.useEffect(()=>{const g=Io.findIndex(y=>y===n);r(g>=0?g:null)},[n]);const u=(g,y)=>{l("value",g),r(y)},m=()=>{r(null)},h=_.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),f=h?.type==="error",p=({value:g})=>{s.setValue("slippagePercent",g),e()};return t.jsxs(Fe,{children:[t.jsx("p",{className:qe.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:qe.presets,children:[Io.map((g,y)=>t.jsxs("button",{type:"button",className:D(qe.preset,{[qe.active]:o===y}),onClick:()=>u(g,y),children:[g,"%"]},g)),o!==null?t.jsx("button",{type:"button",className:D(qe.preset,qe.custom),onClick:()=>r(null),children:"Custom"}):t.jsxs("div",{className:qe.wrapper,children:[t.jsx(Yr,{name:"value",control:a,dp:2,onFocus:m,placeholder:"",className:D(qe.preset,qe.active)}),t.jsx("span",{className:qe.percent,children:"%"})]})]}),h&&t.jsx(ae,{level:h.type,children:h.text}),t.jsx(ie,{children:t.jsx(J.White,{type:"button",onClick:()=>p(c()),disabled:f,children:"Confirm"})})]})},ym="_form_1coq4_1",jm="_arrow_1coq4_5",vm="_divider_1coq4_13",wm="_flip_1coq4_21",bm="_meta_1coq4_37",Cm="_row_1coq4_50",Im="_title_1coq4_56",Nm="_description_1coq4_60",Sm="_icon_1coq4_67",km="_edit_1coq4_72",Am="_warning_1coq4_93",ge={form:ym,arrow:jm,divider:vm,flip:wm,meta:bm,row:Cm,title:Im,description:Nm,icon:Sm,edit:km,warning:Am},$m=()=>{const e=me(),s=Ls(),[n,o]=Ie.useLocalStorage(U.BRIDGE_ROUTE_TYPE,"default"),{watch:r,setValue:a,handleSubmit:i,formState:c}=rt(),l=r(),{srcChainId:d,srcDenom:u,dstChainId:m,dstDenom:h,quantity:f,sender:p,slippagePercent:g}=l,y=Te(),I=Be(d),S=Jt(I),k=Be(m),w=Jt(k),T=Qe(u,d),P=Qe(h,m),{data:R}=Qn(p,d),B=nu(p,d,u),K=!B?.amount||F(B.amount).isZero(),[j]=Ie.useDebounceValue(f,300),C=S!=="initia"&&w!=="initia",x=au(),A=wo(j,{disabled:C}),q=wo(j,{isOpWithdraw:!0,disabled:!x}),M=x&&n==="op"?q:A,{data:E,isLoading:H,isFetching:ee,error:O}=M,{data:Z}=ru(O),Ue=j&&(H||ee),Je=()=>{a("srcChainId",m),a("srcDenom",h),a("dstChainId",d),a("dstDenom",u),a("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:at,closeModal:he}=Bs(),pe=i(L=>{if(E?.warning){const{type:ct="",message:Ys}=E.warning??{};at({content:t.jsx(Qr,{type:"warning",icon:t.jsx(N.IconWarningFilled,{size:40}),title:Is.sentenceCase(ct),primaryButton:{label:"Cancel",onClick:he},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:E,values:L}),he()}},children:t.jsx("p",{className:ge.warning,children:Ys})})});return}e("/bridge/preview",{route:E,values:L})}),Ct=_.useMemo(()=>E?.estimated_fees?.filter(({fee_behavior:L})=>L==="FEE_BEHAVIOR_DEDUCTED")??[],[E]),it=_.useMemo(()=>E?.estimated_fees?.filter(({fee_behavior:L})=>L==="FEE_BEHAVIOR_ADDITIONAL")??[],[E]),Mt=_.useMemo(()=>{for(const L of it){const ct=R?.[L.origin_asset.denom]?.amount??"0",Ys=E?.source_asset_denom===L.origin_asset.denom?E.amount_in:"0";if(F(ct).lt(F(Ys).plus(L.amount??"0")))return`Insufficient ${L.origin_asset.symbol} for fees`}},[R,E,it]),eo=_.useMemo(()=>{if(!l.sender)return"Connect wallet";if(!l.quantity||!j)return"Enter amount";if(!l.recipient)return"Enter recipient address";if(c.errors.quantity)return c.errors.quantity.message;if(!E)return"Route not found";if(Mt)return Mt},[j,Mt,c,E,l]),pa=E?v.formatAmount(E.amount_out,{decimals:P.decimals}):"0",ga=F(f).gt(0)&&F(f).isEqualTo(v.fromBaseUnit(B?.amount,{decimals:B?.decimals??0})),xa=(()=>{switch(S){case"initia":return y(d).fees.fee_tokens.some(({denom:L})=>L===u);case"cosmos":return I.fee_assets.some(({denom:L})=>L===u);case"evm":return!We.isAddress(u);default:return!1}})(),Gs=_.useCallback((L,ct)=>L.length?t.jsxs("div",{className:ge.description,children:[Jr(L),!s&&t.jsx(ns,{label:ct,children:t.jsx("span",{className:ge.icon,children:t.jsx(N.IconInfoFilled,{size:12})})})]}):null,[s]),rs=F(f).gt(0)&&x,to=_.useMemo(()=>E?[{condition:!!E.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Gs(Ct,"Fee deducted from the amount you receive"),Gs(it,"Fee charged in addition to the amount you enter")]})},{condition:!rs&&!!Sn(E.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:ge.description,children:Sn(E.estimated_route_duration_seconds)})},{condition:E.does_swap,title:"Slippage",content:t.jsxs("span",{className:ge.description,children:[t.jsxs("span",{children:[g,"%"]}),t.jsx(Dt,{title:"Slippage tolerance",content:L=>t.jsx(xm,{afterConfirm:L}),className:ge.edit,children:t.jsx(N.IconSettingFilled,{size:12})})]})}].filter(L=>L.condition):[],[it,Ct,Gs,E,rs,g]);return t.jsxs("form",{className:ge.form,onSubmit:pe,children:[t.jsx(In,{selectButton:t.jsx(Co,{type:"src"}),accountButton:S==="cosmos"&&t.jsx(bo,{type:"src"}),quantityInput:t.jsx(ws,{balance:B?.amount,decimals:T?.decimals}),balanceButton:t.jsx(Gr,{onClick:()=>a("quantity",v.fromBaseUnit(B?.amount,{decimals:T?.decimals??0}),{shouldValidate:!0}),disabled:K,children:v.formatAmount(B?.amount??"0",{decimals:T.decimals})}),value:E?E.usd_amount_in?Ae(E.usd_amount_in):"$-":"$0"}),t.jsxs("div",{className:ge.arrow,children:[t.jsx("div",{className:ge.divider}),t.jsx("button",{type:"button",className:ge.flip,onClick:()=>Je(),children:t.jsx(N.IconChevronDown,{size:16})})]}),t.jsx(In,{selectButton:t.jsx(Co,{type:"dst"}),accountButton:t.jsx(bo,{type:"dst"}),quantityInput:t.jsx(ws.ReadOnly,{children:pa}),value:E?E.usd_amount_out?Ae(E.usd_amount_out):"$-":"$0",hideNumbers:rs}),t.jsx(bn,{children:rs?t.jsxs(ps.Stack,{children:[t.jsx(ps,{label:"Fast",query:A,value:"default",onSelect:o,checked:n==="default"}),t.jsx(ps,{label:"Lossless",query:q,value:"op",onSelect:o,checked:n==="op"})]}):null}),t.jsx(ie,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(ae.Stack,{children:[E?.extra_infos?.map(L=>t.jsx(ae,{level:"info",children:L},L)),Z&&t.jsx(ae,{level:"info",children:Z}),ga&&xa&&t.jsx(ae,{level:"warning",children:"Make sure to leave enough for transaction fee"}),E?.warning&&t.jsx(ae,{level:"warning",children:E.warning.message}),E?.extra_warnings?.map(L=>t.jsx(ae,{level:"warning",children:L},L))]}),t.jsx(bn,{children:to.length>0&&t.jsx("div",{className:ge.meta,children:to.map((L,ct)=>t.jsxs("div",{className:ge.row,children:[t.jsx("span",{className:ge.title,children:L.title}),L.content]},ct))})})]}),children:t.jsx(J.White,{loading:Ue&&"Simulating...",disabled:!!eo,children:eo??"Preview route"})})]})},Tm=()=>{Vr();const e=Ka(),s=me(),{closeDrawer:n}=Ge(),o=Pt(),r=Cd(),a=ue.useForm({mode:"onChange",defaultValues:r}),{watch:i,setValue:c}=a,{srcChainId:l,dstChainId:d,srcDenom:u,dstDenom:m,quantity:h,slippagePercent:f,recipient:p}=i();i((j,{name:C})=>{(C==="srcChainId"||C==="srcDenom")&&c("quantity","",{shouldTouch:!1,shouldDirty:!1})});const g=Wr(),y=g(l),I=g(d),k=Hr()(p,d);_.useEffect(()=>{c("cosmosWalletName",void 0),c("sender",y)},[l,y,c]),_.useEffect(()=>{k||c("recipient",I)},[I,k,c]);const w=qt(l),T=qt(d),P=_.useMemo(()=>{if(!w.find(j=>j.denom===u))return`${u} is not available for bridge/swap on ${l}`;if(!T.find(j=>j.denom===m))return`${m} is not available for bridge/swap on ${d}`},[T,d,m,w,l,u]);_.useEffect(()=>{P||(localStorage.setItem(U.BRIDGE_SRC_CHAIN_ID,l),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,f))},[l,u,d,m,h,f,P]);const R=e[0].path==="/bridge",B=()=>t.jsxs(t.Fragment,{children:[t.jsx(se,{error:!0,children:P}),t.jsx(ie,{children:R?t.jsx(J.White,{onClick:n,children:"Close"}):t.jsx(J.White,{onClick:()=>s(-1),children:"Go back"})})]}),{reminders:K}=Rt();return t.jsx(Oe,{title:"Bridge/Swap",backButton:R?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(J.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(Kr,{offset:0,disabled:K.length===0,children:t.jsx(J.Small,{onClick:()=>s("/op/withdrawals"),disabled:!o,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:P?B():t.jsx(ue.FormProvider,{...a,children:t.jsx(ye,{children:t.jsx($m,{})})})})},Em="_button_14cv7_1",qm="_checkbox_14cv7_10",Dm="_checked_14cv7_23",ms={button:Em,checkbox:qm,checked:Dm},Pm=({checked:e,onClick:s,label:n,className:o})=>t.jsxs("button",{type:"button",className:D(ms.button,o),onClick:s,children:[t.jsx("div",{className:D(ms.checkbox,{[ms.checked]:e}),children:e&&t.jsx(N.IconCheck,{size:12})}),t.jsx("span",{className:ms.label,children:n})]}),Rm="_button_1iys9_1",Bm={button:Rm},ea=({onClick:e,disabled:s})=>{const{ref:n,inView:o}=Na.useInView();return _.useEffect(()=>{o&&e()},[o,e]),t.jsxs("button",{className:Bm.button,onClick:e,disabled:s,ref:n,children:[t.jsx("span",{children:"Load more"}),t.jsx(N.IconChevronDown,{size:12})]})};function ta(e,s){return e.reduce((n,o)=>{const r=s(o);if(!r)return n;const a=r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=n[a]||[];return{...n,[a]:[...i,o]}},{})}const gs=({chainId:e,txHash:s})=>`${U.BRIDGE_HISTORY}:${e}:${s}`,bs=100,No=10;function sa(){const[e,s]=Ie.useLocalStorage(U.BRIDGE_HISTORY,[]),n=_.useCallback((r,a)=>{localStorage.setItem(gs(r),JSON.stringify(a));for(const i of e.slice(bs-1))localStorage.removeItem(gs(i));s((i=[])=>[r,...i.slice(0,bs-1)])},[e,s]),o=_.useCallback(r=>{const a=localStorage.getItem(gs(r));return a?JSON.parse(a):null},[]);return{history:e,addHistoryItem:n,getHistoryDetails:o}}function na(e){return Ie.useLocalStorage(gs(e),null)}async function Mm(e,s){const n=z.create({prefixUrl:s}),o=`cosmos/auth/v1beta1/account_info/${e}`;for(let r=1;r<=24;r++)try{return await n.get(o).json()}catch{await new Promise(a=>setTimeout(a,5e3))}throw new Error(`Timeout: ${e} not found`)}async function kn(e,s){const{chain_type:n,chain_id:o,chain_name:r,evm_fee_asset:a,rpc:i}=s;if(n!=="evm")throw new Error(`Chain is not an EVM chain: ${r}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}catch(c){if(b.path(["error","code"],c)!==4902)throw c;if(!a)throw new Error(`Fee asset is not defined for chain: ${r}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(o).toString(16)}`,chainName:r,nativeCurrency:a,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}}function Bt(){return jt()}function Fm(e){const s=me(),{showNotification:n,updateNotification:o,hideNotification:r}=Hn(),{addHistoryItem:a}=sa(),i=Es(),{route:c,values:l}=Bt(),{srcChainId:d,sender:u,recipient:m,cosmosWalletName:h}=l,f=fr(),{requestTxSync:p,waitForTxConfirmation:g}=xe(),{find:y}=Ks(),I=Xt(),S=qs(),k=Be(d),w=Jt(k),T=Nr(d),P=$.useQueryClient(),{registryUrl:R}=X(),B=Te(),{addReminder:K}=Rt(),j=Ye();return $.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const C=e.cosmos_tx.msgs.map(({msg_type_url:he,msg:pe})=>{if(!(he&&pe))throw new Error("Invalid transaction data");return S.fromAmino({type:Ht.aminoConverters[he].aminoType,value:JSON.parse(pe)})});if(w==="initia"){const{srcDenom:he,quantity:pe}=l,{decimals:Ct}=T(he),it=await p({messages:C,chainId:d,internal:1,spendCoins:[{denom:he,amount:v.toBaseUnit(pe,{decimals:Ct})}]}),Mt=g({txHash:it,chainId:d});return{txHash:it,wait:Mt}}const x=y(h)?.getProvider();if(!x)throw new Error("Wallet not connected");const A=x.getOfflineSignerOnlyAmino(d),q=await Pe.SigningStargateClient.connectWithSigner(k.rpc,A,{registry:I,aminoTypes:S}),M=await q.getAllBalances(u),E=k.fee_assets.find(he=>M.some(pe=>pe.denom===he.denom&&F(pe.amount).gt(0)));if(!E){const pe=["Insufficient balance for fees.",`Available fee assets: ${k.fee_assets.map(Ct=>T(Ct.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(pe)}const{denom:H,gas_price:ee}=E;if(!ee)throw new Error(`Gas price not found for ${H}`);const O=await q.simulate(u,C,""),Z=Pe.GasPrice.fromString(ee.average+H),Ue=Pe.calculateFee(Math.ceil(O*Vt),Z),Je=await q.signAndBroadcastSync(u,C,Ue),at=br({txHash:Je,client:q});return{txHash:Je,wait:at}}if("evm_tx"in e){const{chain_id:C,to:x,value:A,data:q}=e.evm_tx,M=await f(),E=await M.getSigner();await kn(M,k);const H=await E.sendTransaction({chainId:C,to:x,value:A,data:`0x${q}`});return{txHash:H.hash,wait:H.wait()}}throw new Error("Unlisted chain type")}catch(C){throw await He(C)}},onSuccess:async({txHash:C,wait:x})=>{localStorage.removeItem(U.BRIDGE_QUANTITY),s(-1),n({type:"loading",title:"Transaction is pending..."});try{await x;const A=Gn(c)==="OP Bridge withdrawal",q=A?{success:!0,error:null}:await Km(j,C,d);if(!q.success&&q.error){const O=q.error instanceof Error?q.error.message:String(q.error);n({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${O}. The transaction may still be processing.`,autoHide:!0})}const M=q.success,H=Lm({txHash:C,srcChainId:d,route:c,values:l,recipient:m},M);a(H.tx,H.details),o(Um(r));const ee=hn(l,C);if(i("Bridge Transaction Success",ee),A){const O=zm(H.tx,c,m);K(H.tx,O)}}catch(A){const q=A instanceof Error?A.message:String(A);o({type:"error",title:"Transaction not confirmed",description:q});const M={...hn(l,C),error:q};i("Bridge Confirmation Failed",M)}finally{P.invalidateQueries({queryKey:Re.balances(d,u).queryKey})}},onError:async C=>{const x=w==="initia"?await kt(C,B(d),R):C;n({type:"error",title:"Transaction failed",description:x.message});const A=hn(l);i("Bridge Transaction Failed",{...A,error:x.message})}})}function Om(){const e=Ye(),s=ne(),n=Ds(),{route:o,values:r}=Bt(),a=vt();return $.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:c}=await e.post("op-hook",{json:{source_address:s,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:v.InitiaAddress(r.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await Mm(s,a(o.dest_asset_chain_id).rest);const l=c.map(({msg_type_url:m,msg:h})=>Ht.aminoTypes.fromAmino({type:Ht.aminoConverters[m].aminoType,value:JSON.parse(h)})),d=await n(i,s,l,{amount:[],gas:"1"},"",{incrementSequence:i===r.srcChainId?2:0}),u=st.Tx.fromPartial({body:st.TxBody.decode(d.bodyBytes),authInfo:st.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:s,hook:V.toBase64(st.Tx.encode(u).finish())}}catch(i){throw await He(i)}}})}function Um(e){return{type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(Et,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function hn(e,s){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:s}}function Lm(e,s){const{txHash:n,srcChainId:o,route:r,values:a}=e,i={chainId:o,txHash:n},c=Gn(r)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:r,values:a,state:c?"success":void 0,tracked:s},isOpWithdraw:c}}function zm(e,s,n){return{...e,recipient:v.InitiaAddress(n).bech32,claimableAt:Date.now()+s.estimated_route_duration_seconds*1e3,amount:s.amount_out,denom:s.dest_asset_denom}}async function Km(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 He(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Wm(e){const{chainId:s,txHash:n,tracked:o}=e,r=Ye();return $.useQuery({queryKey:Re.txTrack(s,n).queryKey,queryFn:async()=>{try{return await r.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json()}catch(a){throw await He(a)}},select:({tx_hash:a})=>a,retry:6,retryDelay:5e3,staleTime:W.INFINITY,enabled:!o})}function Hm(e){const{timestamp:s,chainId:n,txHash:o,tracked:r,state:a}=e,i=Ye();return $.useQuery({queryKey:Re.txStatus(n,o).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:o,chain_id:n}}).json(),enabled:!!o&&r&&!a,refetchInterval:({state:{data:c}})=>{if(!c)return!1;const{status:l}=c;if(l==="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:W.INFINITY})}var xs=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(xs||{});function Gn(e){const{operations:s,dest_asset_denom:n}=e;return b.has("op_init_transfer",b.head(s))&&n==="uinit"?"OP Bridge withdrawal":"Skip"}const Qm="_success_t4dfk_1",Vm="_error_t4dfk_5",So={success:Qm,error:Vm},Gm=({tx:e})=>{const[s,n]=na(e);if(!s)throw new Error("Bridge history details not found");const{data:o}=Hm(s),r=s.state??Ym(o);switch(_.useEffect(()=>{r!=="loading"&&n(a=>{if(!a)throw new Error("Bridge history details not found");return{...a,tracked:!0,state:r}})},[n,r]),r){case"error":return t.jsx("div",{className:So.error,children:t.jsx(N.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:So.success,children:t.jsx(N.IconCheckCircleFilled,{size:14})});default:return t.jsx(wt,{size:14})}};function Ym(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 Jm="_link_12p3n_1",Zm="_header_12p3n_22",Xm="_title_12p3n_30",eh="_date_12p3n_36",th="_explorer_12p3n_40",sh="_fees_12p3n_55",nh="_label_12p3n_63",oh="_content_12p3n_67",rh="_route_12p3n_73",ah="_row_12p3n_78",ih="_asset_12p3n_84",ch="_amount_12p3n_92",lh="_chain_12p3n_97",dh="_account_12p3n_106",uh="_arrow_12p3n_113",ce={link:Jm,header:Zm,title:Xm,date:eh,explorer:th,fees:sh,label:nh,content:oh,route:rh,row:ah,asset:ih,amount:ch,chain:lh,account:dh,arrow:uh},mh=({tx:e})=>{const[s,n]=na(e);if(!s)throw new Error("Bridge history details not found");const{chainId:o,txHash:r,route:a,values:i,timestamp:c,tracked:l}=s,{data:d}=Wm(s),{address:u="",connector:m}=de.useAccount(),{find:h}=Ks();_.useEffect(()=>{d&&n(M=>{if(!M)throw new Error("Bridge history details not found");return{...M,tracked:!0}})},[n,d]);const{amount_in:f,amount_out:p,source_asset_chain_id:g,source_asset_denom:y,dest_asset_chain_id:I,dest_asset_denom:S,estimated_fees:k=[]}=a,w=Be(g),T=Be(I),P=Qe(y,g),R=Qe(S,I),B=(M,E)=>E?t.jsx(Y,{src:E,width:12,height:12}):v.InitiaAddress.equals(M,u)?t.jsx(Y,{src:m?.icon,width:12,height:12}):t.jsx(N.IconWallet,{size:12}),K=(M,{symbol:E,decimals:H,logo_uri:ee},{chain_name:O,pretty_name:Z,...Ue},Je,at)=>t.jsxs("div",{className:ce.row,children:[t.jsx(Ws,{assetLogoUrl:ee,chainLogoUrl:Ue.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:ce.asset,children:[t.jsx("span",{className:ce.amount,children:v.formatAmount(M,{decimals:H})}),t.jsx("span",{children:E})]}),t.jsxs("div",{className:ce.chain,children:[t.jsxs("span",{children:["on ",Z||O]}),t.jsxs("div",{className:ce.account,children:[at,t.jsx("span",{className:"monospace",children:v.truncate(Je)})]})]})]})]}),j=Gn(a),C=_.useMemo(()=>{switch(j){case xs.SKIP:return"Skip Explorer";case xs.OP_WITHDRAW:return"Initia Scan"}},[j]),x=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:ce.header,children:[t.jsxs("div",{className:ce.title,children:[l?t.jsx(Gm,{tx:e}):t.jsx(wt,{size:14}),t.jsx("div",{className:ce.date,children:ke.format(new Date(c),"h:mm a")})]}),t.jsxs("div",{className:ce.explorer,children:[t.jsx("span",{children:C}),t.jsx(N.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:ce.route,children:[K(f,P,w,i.sender,B(i.sender,h(i.cosmosWalletName)?.image)),t.jsx("div",{className:ce.arrow,children:t.jsx(N.IconArrowDown,{size:12})}),K(p,R,T,i.recipient,B(i.recipient))]}),k.length>0&&t.jsxs("div",{className:ce.fees,children:[t.jsx("span",{className:ce.label,children:"Fees"}),t.jsx("span",{className:ce.content,children:Jr(k)})]})]});if(j===xs.OP_WITHDRAW)return t.jsx(zs,{chainId:o,txHash:r,className:ce.link,children:x});const A=new URLSearchParams({tx_hash:r,chain_id:o}),q=new URL(`?${A.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:q.toString(),className:ce.link,target:"_blank",children:x})},hh="_history_13u9z_1",fh="_header_13u9z_5",_h="_checkbox_13u9z_9",ph="_groups_13u9z_13",gh="_dateGroup_13u9z_21",xh="_dateHeader_13u9z_26",yh="_list_13u9z_32",mt={history:hh,header:fh,checkbox:_h,groups:ph,dateGroup:gh,dateHeader:xh,list:yh},jh=()=>{const{initiaAddress:e,hexAddress:s}=xe(),{history:n,getHistoryDetails:o}=sa(),r=n.filter(f=>o(f)),a=r.filter(f=>{const p=o(f);if(!p)return!1;const{values:g}=p,{sender:y,recipient:I}=g;return[y,I].some(S=>[e,s].includes(S))}),[i,c]=_.useState(1),[l,d]=Ie.useToggle(!a.length),u=l?r:a,m=u.slice(0,i*No),h=_.useMemo(()=>ta(m,f=>{const p=o(f);if(p)return new Date(p.timestamp)}),[m,o]);return t.jsx(Oe,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:mt.history,children:[r.length>0&&r.length!==a.length&&t.jsx("header",{className:mt.header,children:t.jsx(Pm,{checked:l,onClick:d,label:"Show all transactions stored in this browser",className:mt.checkbox})}),u.length===0?t.jsx(se,{children:"No bridge/swap activity"}):t.jsx("div",{className:mt.groups,children:Object.entries(h).map(([f,p])=>t.jsxs("div",{className:mt.dateGroup,children:[t.jsx("div",{className:mt.dateHeader,children:f}),t.jsx("div",{className:mt.list,children:p.map(g=>t.jsx(ye,{children:t.jsx(mh,{tx:g})},g.txHash))})]},f))}),u.length>i*No?t.jsx(ea,{onClick:()=>c(f=>f+1)}):n.length>=bs&&t.jsxs(se,{children:["Only the latest ",bs," items are stored. Older entries will be removed automatically."]})]})})},vh=({tx:e})=>{const{mutate:s,isPending:n}=Fm(e);return t.jsx(ie,{children:t.jsx(J.White,{onClick:()=>s(),loading:n&&"Signing transaction...",children:"Confirm"})})},wh="_content_c0tee_1",bh="_info_c0tee_6",Ch="_arrow_c0tee_11",Ih="_divider_c0tee_19",Nh="_type_c0tee_26",Sh="_asset_c0tee_44",kh="_amount_c0tee_52",Ah="_lower_c0tee_57",$h="_chain_c0tee_63",Th="_address_c0tee_69",ve={content:wh,info:bh,arrow:Ch,divider:Ih,type:Nh,asset:Sh,amount:kh,lower:Ah,chain:$h,address:Th},oa=e=>{const{source:s,label:n,amount:o,denom:r,chainId:a,address:i,walletIcon:c}=e,{symbol:l=v.truncate(r),decimals:d=0,logo_uri:u=Rn}=e,{chain_name:m,pretty_name:h,...f}=Be(a);return t.jsxs("div",{children:[!s&&t.jsxs("div",{className:ve.arrow,children:[t.jsx("div",{className:ve.divider}),n?t.jsx(ns,{label:n,children:t.jsx("button",{className:ve.type,children:t.jsx(N.IconArrowDown,{size:12})})}):t.jsx("span",{className:ve.type,children:t.jsx(N.IconArrowDown,{size:12})}),t.jsx("div",{className:ve.divider})]}),t.jsxs("div",{className:ve.content,children:[t.jsx(Ws,{assetLogoUrl:u,chainLogoUrl:f.logo_uri??void 0}),t.jsxs("div",{className:ve.info,children:[t.jsxs("div",{className:ve.asset,children:[t.jsx("span",{className:ve.amount,children:v.formatAmount(o,{decimals:d})}),t.jsx("span",{children:l})]}),t.jsxs("div",{className:ve.lower,children:[t.jsxs("div",{className:ve.chain,children:["on ",h||m]}),i&&t.jsx(js,{value:i,children:({copy:p,copied:g})=>t.jsxs("button",{className:ve.address,onClick:p,children:[c,g?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:v.truncate(i)})]})})]})]})]})]})},Tt=e=>{const s=Qe(e.denom,e.chainId);return t.jsx(oa,{...e,...s})};Tt.Placeholder=oa;const Eh="_root_1l4he_1",qh="_flexEnd_1l4he_6",Dh="_toggle_1l4he_11",Ph="_route_1l4he_34",Rh="_content_1l4he_41",zt={root:Eh,flexEnd:qh,toggle:Dh,route:Ph,content:Rh};function Bh(e){const s=({name:n})=>n==="initia-dex"?"Initia DEX":Is.capitalCase(b.head(n?.split("-")??[])??"");if("transfer"in e)return{label:"Bridge via IBC",...e,...e.transfer};if("bank_send"in e)return{label:"Send",...e,...e.bank_send};if("swap"in e){const n=e.swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...e,...e.swap}}if("axelar_transfer"in e)return{label:"Bridge via Axelar",...e,...e.axelar_transfer};if("cctp_transfer"in e)return{label:"Bridge via CCTP",...e,...e.cctp_transfer};if("hyperlane_transfer"in e)return{label:"Bridge via Hyperlane",...e,...e.hyperlane_transfer};if("evm_swap"in e){const n=e.evm_swap?.swap_venues?.map(s).join(", ");return{label:n?`Swap on ${n}`:"Swap",...e,...e.evm_swap}}if("op_init_transfer"in e)return{label:"Bridge via OP Bridge",...e,...e.op_init_transfer};if("go_fast_transfer"in e)return{label:"Bridge via Go Fast",...e,...e.go_fast_transfer};if("eureka_transfer"in e)return{label:"Bridge via Eureka",...e,...e.eureka_transfer};if("stargate_transfer"in e)return{label:"Bridge via Stargate",...e,...e.stargate_transfer};if("layer_zero_transfer"in e)return{label:"Bridge via LayerZero",...e,...e.layer_zero_transfer};throw new Error("Unknown operation type")}const Mh=({addressList:e})=>{const{values:s,route:n}=Bt(),{source_asset_denom:o,source_asset_chain_id:r,amount_in:a,operations:i}=n,c=b.zipObj(n.required_chain_addresses,e),{find:l}=Ks(),{connector:d,address:u=""}=de.useAccount(),[m,h]=Ie.useToggle(!1),f=i.length>1,p=t.jsx(Y,{src:s.cosmosWalletName?l(s.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:a,denom:o,chainId:r,address:s.sender,walletIcon:p},y=T=>v.InitiaAddress.equals(T,u)?p:t.jsx(N.IconWallet,{size:11}),I=T=>{const{label:P,amount_out:R,denom:B,denom_out:K=B,chain_id:j,from_chain_id:C,to_chain_id:x=j??C}=T,A=c[x];return{label:f&&!m?void 0:P,amount:R,denom:K,chainId:x,address:A,walletIcon:y(A)}},S=i.map(Bh).map(I),k=S.slice(0,-1),w=S[S.length-1];return t.jsxs(te.Collapsible.Root,{className:zt.root,open:m,onOpenChange:h,children:[f&&t.jsx("div",{className:zt.flexEnd,children:t.jsx(te.Collapsible.Trigger,{className:zt.toggle,children:m?t.jsxs(t.Fragment,{children:[t.jsx(N.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(N.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:zt.route,children:[t.jsx(Tt,{...g,source:!0}),t.jsx(te.Collapsible.Content,{className:zt.content,children:k.map((T,P)=>t.jsx(ye,{suspenseFallback:t.jsx(Tt.Placeholder,{...T}),errorBoundaryProps:{fallback:t.jsx(Tt.Placeholder,{...T})},children:t.jsx(Tt,{...T})},P))}),t.jsx(Tt,{...w})]})]})},An=({error:e})=>{const s=me();return t.jsx(ie,{extra:t.jsx(ae,{level:"error",children:e.message}),children:t.jsx(J.White,{onClick:()=>s("/bridge"),children:"Home"})})},Fh=({children:e})=>{const s=Bt(),{route:n,values:o}=s,{required_chain_addresses:r}=n,{srcChainId:a,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:d,hexAddress:u}=xe(),m=es(),h=vt(),f=ts(),p=h(a),g=f(p),y=r.slice(0,-1).some(R=>{const B=h(R);return f(B)==="cosmos"})&&g!=="cosmos",[I,S]=_.useState(void 0),[k,w]=_.useState(!1),[T,P]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!y)return;if(!m)throw new Error("Wallet not connected");w(!0),P(null);const[{pubkey:B}]=await m.getAccounts();S(B)}catch(B){P(await He(B))}finally{w(!1)}})()},[y,m]),T)return t.jsx(An,{error:T});if(k)return t.jsx(ie,{children:t.jsx(J.White,{loading:k&&"Generating intermediary addresses..."})});if(!y||I){const R=r.map((B,K)=>{if(K===r.length-1){const q=h(i);return f(q)==="initia"?v.InitiaAddress(l).bech32:l}const j=h(B),C=f(j),x=h(a),A=f(x);switch(C){case"initia":return d;case"evm":return u;case"cosmos":{if(A==="cosmos")return V.toBech32(j.bech32_prefix,V.fromBech32(c).data);if(!I)throw new Error("Pubkey not found");return Qt.pubkeyToAddress(Qt.encodeSecp256k1Pubkey(I),j.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(R)}return null},Oh=({tx:e,children:s})=>{const n=fr(),o=vt(),{data:r,isLoading: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 kn(h,o(u));const f=["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:y,spender:I}=g,k=await new We.ethers.Contract(y,f,h).allowance(m,I);return{approval:g,currentAllowance:BigInt(k.toString())}}))).filter(({approval:g,currentAllowance:y})=>y<BigInt(g.amount)).map(({approval:g})=>g)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:c,isPending:l,error:d}=$.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!r||r.length===0)throw new Error("No approvals needed");const{chain_id:u}=e.evm_tx,m=await n(),h=await m.getSigner();await kn(m,o(u));for(const f of r){const{token_contract:p,spender:g,amount:y}=f,I=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new We.ethers.Contract(p,I,h).approve(g,y)).wait()}return!0}catch(u){throw await He(u)}}});return a?t.jsx(ie,{children:t.jsx(J.White,{loading:"Checking approvals..."})}):r&&r.length>0&&!c?t.jsx(ie,{extra:t.jsx(ae,{level:"error",children:d?.message}),children:t.jsx(J.White,{onClick:()=>i(),loading:l&&"Approving tokens...",children:"Approve tokens"})}):s},Uh=({addressList:e,signedOpHook:s,children:n})=>{const o=Ye(),{route:r,values:a}=Bt(),[i,c]=_.useState(void 0),[l,d]=_.useState(!1),[u,m]=_.useState(null);return _.useEffect(()=>{(async()=>{try{if(r.required_op_hook&&!s)throw new Error("Op hook is required");d(!0),m(null);const f={address_list:e,amount_in:r.amount_in,amount_out:r.amount_out,source_asset_chain_id:r.source_asset_chain_id,source_asset_denom:r.source_asset_denom,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom,slippage_tolerance_percent:a.slippagePercent,operations:r.operations,signed_op_hook:s},{txs:p}=await o.post("v2/fungible/msgs",{json:f}).json();if(!p||p.length===0)throw new Error("No transaction data found");const[g]=p;c(g)}catch(f){m(f)}finally{d(!1)}})()},[r,a,e,s,o]),u?t.jsx(An,{error:u}):l?t.jsx(ie,{children:t.jsx(J.White,{loading:l&&"Fetching messages..."})}):i?n(i):t.jsx(An,{error:new Error("Failed to fetch messages")})},Lh=({children:e})=>{const{route:s}=Bt(),n=Om();return s.required_op_hook&&!n.data?t.jsx(ie,{extra:t.jsx(ae,{level:"error",children:n.error?.message}),children:t.jsx(J.White,{onClick:()=>n.mutate(),loading:n.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(n.data)},zh=()=>t.jsx(Oe,{title:"Route preview",children:t.jsx(Fh,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(Mh,{addressList:e}),t.jsx(Lh,{children:s=>t.jsx(Uh,{addressList:e,signedOpHook:s,children:n=>t.jsx(Oh,{tx:n,children:t.jsx(vh,{tx:n})})})})]})})}),ra=_.createContext(null);function Qs(){return _.useContext(ra)}const bt=$e.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,s)=>[e,s],latestOutput:e=>[e],output:(e,s)=>[e,s],outputResponse:(e,s)=>[e,s],withdrawalClaimed:(e,s)=>[e,s]});function Vs(){const{restUrl:e}=_e();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function Kh(e){const s=Vs(),{data:n}=$.useSuspenseQuery({queryKey:bt.bridge(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:W.INFINITY});return n}const ko=20;function Wh(e){const s=ne();return $.useSuspenseInfiniteQuery({queryKey:bt.withdrawals(e,s).queryKey,queryFn:async({pageParam:n})=>{if(!s)return[];const o={limit:ko,offset:n,order:"desc"},{withdrawals:r}=await z.create({prefixUrl:e}).get(`withdrawals/${s}`,{searchParams:o}).json();return r},getNextPageParam:n=>{const o=b.last(n)?.sequence;return n.length<ko||!o||o<=1?null:o-1},initialPageParam:0,staleTime:W.SECOND})}function Hh(e){const s=Vs(),{data:n}=$.useSuspenseQuery({queryKey:bt.latestOutput(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:o})=>{const[r]=o;return r||null},staleTime:W.SECOND});return n}function Qh({bridge_id:e,output_index:s}){const n=Vs(),{data:o}=$.useSuspenseQuery({queryKey:bt.output(e,s).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${e}/outputs/${s}`).json()}catch{return null}},staleTime:W.SECOND});return o}function Vh({bridge_id:e,sequence:s}){const o=re().find(({metadata:l})=>l?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const a=Te()(o);if(!a)throw new Error(`Chain not found: ${o}`);const i=a.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${o}`);const{data:c}=$.useSuspenseQuery({queryKey:bt.outputResponse(i,s).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${s}`).json(),staleTime:W.SECOND});return c}function aa(e,s){const{bridge_id:n}=e,o=Vs(),{data:r}=$.useSuspenseQuery({queryKey:bt.withdrawalClaimed(n,s).queryKey,queryFn:()=>o.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:W.SECOND});return r}function Kt(e){return Sa.sha3_256.create().update(e).digest()}function fn(e,s){const n=new ArrayBuffer(s);return new DataView(n).setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}function ia(e){const{bridge_id:s,sequence:n,amount:o,from:r,to:a}=e,i=fn(s.toString(),8),c=fn(n.toString(),8),l=fn(o.amount,8),d=_t.concatBytes(i,c,Kt(_t.utf8ToBytes(r)),Kt(_t.utf8ToBytes(a)),Kt(_t.utf8ToBytes(o.denom)),l);return Kt(Kt(d))}const Gh="_button_1btdg_1",Yh="_claimed_1btdg_23",Ao={button:Gh,claimed:Yh},Jh=()=>{const{withdrawalTx:e}=Qs(),{bridge_id:s,sequence:n,amount:o,output_index:r,withdrawal_proofs:a,storage_root:i,from:c,to:l,version:d}=e,u=_e(),m=ne(),{requestTxSync:h,waitForTxConfirmation:f}=xe(),p=Vh(e),g=V.toBase64(ia(e)),y=aa(e,g),I=$.useQueryClient(),{mutate:S,isPending:k}=$.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:w}=p;return h({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:m,bridgeId:BigInt(s),outputIndex:BigInt(r),withdrawalProofs:a.map(V.fromBase64),from:c,to:l,sequence:BigInt(n),amount:o,version:V.fromBase64(d),storageRoot:V.fromBase64(i),lastBlockHash:V.fromBase64(w)}}],internal:!0})},onSuccess:async w=>{await f({chainId:u.chain_id,txHash:w}),I.invalidateQueries({queryKey:bt.withdrawalClaimed(s,g).queryKey})}});return y?t.jsxs("div",{className:Ao.claimed,children:[t.jsx(N.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:Ao.button,onClick:()=>S(),disabled:k,children:"Claim"})},Zh=({children:e})=>{const{withdrawalTx:s}=Qs(),n=Kh(s.bridge_id),o=Qh(s),r=_.useMemo(()=>{if(!o)return null;const{bridge_config:a}=n,{output_proposal:i}=o;return ke.addSeconds(new Date(i.l1_block_time),parseFloat(a.finalization_period))},[n,o]);return e(r)},ca=1e3,Xh=60,ef=60,tf=24,$n=ca*Xh,Tn=$n*ef,$o=Tn*tf,sf=({date:e})=>{const s=_.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/$o),f=Math.floor(m%$o/Tn),p=Math.floor(m%Tn/$n),g=Math.floor(m%$n/ca);return{days:h,hours:f,minutes:p,seconds:g}},[e]),[n,o]=_.useState(s());_.useEffect(()=>{const d=window.setInterval(()=>{o(s())},1e3);return()=>window.clearInterval(d)},[s,e]);const r=d=>d.toString().padStart(2,"0"),{days:a,hours:i,minutes:c,seconds:l}=n;return t.jsx(ns,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[a,"d ",r(i),"h ",r(c),"m ",r(l),"s"]})})},nf="_container_1lz3w_1",of="_title_1lz3w_5",To={container:nf,title:of},rf=({date:e})=>t.jsxs("div",{className:To.container,children:[t.jsx("div",{className:To.title,children:"Claimable in"}),t.jsx(sf,{date:e})]}),af="_container_1oldz_1",cf="_icon_1oldz_7",Eo={container:af,icon:cf},lf="Withdrawal will begin within an hour",qo=()=>{const e=Ls();return t.jsxs("div",{className:Eo.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(ns,{label:lf,children:t.jsx("span",{className:Eo.icon,children:t.jsx(N.IconInfoFilled,{size:12})})})]})},df=({children:e})=>{const{withdrawalTx:s}=Qs(),n=Hh(s.bridge_id),o=s.output_index>Number(n?.output_index);return e(o)},uf=({date:e,children:s})=>{const{chainId:n,withdrawalTx:o}=Qs(),r=V.toBase64(ia(o)),a=aa(o,r),{setReminder:i,removeReminder:c}=Rt();return _.useEffect(()=>{const l={chainId:n,txHash:o.tx_hash};a?c(l):i(l,{...l,recipient:o.to,claimableAt:e.getTime(),amount:o.amount.amount,denom:o.amount.denom,dismissed:ke.isPast(e.getTime())?!0:void 0})},[n,a,e,c,i,o]),s},mf=()=>t.jsx(df,{children:e=>e?t.jsx(qo,{}):t.jsx(Zh,{children:s=>s?t.jsx(uf,{date:s,children:ke.isFuture(s)?t.jsx(rf,{date:s}):t.jsx(Jh,{})}):t.jsx(qo,{})})}),hf="_asset_6h8u2_1",ff="_info_6h8u2_7",_f="_symbol_6h8u2_11",_n={asset:hf,info:ff,symbol:_f},pf=({amount:e,denom:s})=>{const n=_e(),o=Xo(s,n),{symbol:r,logoUrl:a,decimals:i}=o;return t.jsxs("div",{className:_n.asset,children:[t.jsx(Y,{src:a,width:32,height:32,logo:!0}),t.jsxs("div",{className:_n.info,children:[t.jsx("span",{className:"monospace",children:v.formatAmount(e,{decimals:i})}),t.jsx("span",{className:_n.symbol,children:r})]})]})},gf="_item_km5w2_1",xf={item:gf},yf=({chain:e})=>{const s=e.metadata?.executor_uri;if(!s)throw new Error("Executor URL is not defined");const{data:n,fetchNextPage:o,hasNextPage:r,isFetching:a}=Wh(s),i=_.useMemo(()=>n?.pages.flat()??[],[n]),{syncReminders:c}=Rt();return _.useEffect(()=>{const l=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));c(l)},[e.chainId,i,c]),i.length?t.jsxs(t.Fragment,{children:[i.map(l=>{const{amount:d}=l;return t.jsxs("div",{className:xf.item,children:[t.jsx(pf,{...d}),t.jsx(ye,{suspenseFallback:null,children:t.jsx(ra.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:t.jsx(mf,{})})})]},l.sequence)}),r&&t.jsx(ea,{onClick:()=>o(),disabled:a})]}):t.jsx(se,{children:"No withdrawals"})},jf="_content_dj1qm_1",vf="_title_dj1qm_5",Do={content:jf,title:vf},wf=()=>{const{chainId:e}=jt(),s=re(),n=Zt(),[o,r]=_.useState(e??(n.metadata?.is_l1?"":n.chainId)),a=Te(),{reminders:i}=Rt(),c=o?a(o):void 0;return t.jsxs(Oe,{title:"OP Bridge withdrawals",children:[t.jsx(xt,{chains:s.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:o,onSelect:r,getShowIndicator:l=>i.some(d=>d.chainId===l)}),t.jsx("div",{className:Do.content,children:c?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:Do.title,children:c.name}),t.jsx(ye,{children:t.jsx(yf,{chain:c})},o)]}):t.jsx(ae,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},bf="_page_1f6wh_1",Cf="_title_1f6wh_10",If="_scrollable_1f6wh_17",Nf="_list_1f6wh_22",Sf="_item_1f6wh_32",kf="_name_1f6wh_56",Af="_dimmed_1f6wh_64",$f="_recent_1f6wh_68",Tf="_installed_1f6wh_69",Ne={page:bf,title:Cf,scrollable:If,list:Nf,item:Sf,name:kf,dimmed:Af,recent:$f,installed:Tf},Ef=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],Po=({onSuccess:e})=>{const{connectors:s,connectAsync:n}=de.useConnect(),o=Ie.useReadLocalStorage("wagmi.recentConnectorId"),[r,a]=_.useState(null),{mutate:i,isPending:c}=$.useMutation({mutationFn:async l=>{a(l.id);try{await n({connector:l})}catch(d){throw await He(d)}},onSettled:()=>{a(null)},onSuccess:()=>{e?.()}});return t.jsxs("div",{className:Ne.page,children:[t.jsx("h1",{className:Ne.title,children:"Connect wallet"}),t.jsx(Fe,{className:Ne.scrollable,children:t.jsxs("div",{className:Ne.list,children:[s.toSorted(b.descend(l=>l.id===o)).map(l=>{const{name:d,icon:u,id:m}=l;return t.jsxs("button",{className:Ne.item,onClick:()=>i(l),disabled:c,children:[t.jsx(Y,{src:u,width:24,height:24}),t.jsx("span",{className:Ne.name,children:d}),r===m?t.jsx(wt,{size:16}):o===m?t.jsx("span",{className:Ne.recent,children:"Recent"}):l.id===Ns.id?null:t.jsx("span",{className:Ne.installed,children:"Installed"})]},m)}),Ef.filter(({name:l})=>!s.some(d=>d.name.includes(l))).map(({name:l,url:d})=>{const u=`https://assets.initia.xyz/images/wallets/${l}.webp`;return t.jsxs("a",{href:d,className:Ne.item,target:"_blank",children:[t.jsx(Y,{src:u,width:24,height:24}),t.jsx("span",{className:D(Ne.name,Ne.dimmed),children:l}),t.jsx(N.IconExternalLink,{size:10})]},l)})]})})]})},qf="_root_19tvg_1",Df="_address_19tvg_9",Pf="_copy_19tvg_19",Rf="_labelWrapper_19tvg_33",Bf="_labelCopy_19tvg_43",Mf="_labelCopied_19tvg_47",Ff="_copied_19tvg_55",Of="_derived_19tvg_65",Uf="_derivedLabel_19tvg_78",Lf="_derivedAddress_19tvg_82",zf="_hexAddress_19tvg_88",Kf="_derivedCopy_19tvg_93",fe={root:qf,address:Df,copy:Pf,labelWrapper:Rf,labelCopy:Bf,labelCopied:Mf,copied:Ff,derived:Of,derivedLabel:Uf,derivedAddress:Lf,hexAddress:zf,derivedCopy:Kf},Wf=()=>{const e=_.useRef(null),s=_.useRef(null),{initiaAddress:n,hexAddress:o}=xe(),r=$r("--gray-0");return _.useEffect(()=>{e.current&&(s.current?s.current.update({data:n}):(s.current=new ka({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:r},cornersSquareOptions:{type:"extra-rounded",color:r},cornersDotOptions:{type:"dot",color:r},backgroundOptions:{color:"transparent"}}),s.current.append(e.current)))},[n,r]),t.jsx(Oe,{title:"Receive",children:t.jsxs("div",{className:fe.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:fe.address,children:n}),t.jsx(js,{value:n,children:({copy:a,copied:i})=>t.jsxs("button",{className:D(fe.copy,{[fe.copied]:i}),onClick:a,children:[t.jsx(N.IconCopy,{size:12}),t.jsxs("div",{className:fe.labelWrapper,children:[t.jsx("span",{className:fe.labelCopy,children:"Copy address"}),t.jsx("span",{className:fe.labelCopied,children:"Copied!"})]})]})}),t.jsx(js,{value:o,children:({copy:a,copied:i})=>t.jsxs("button",{className:D(fe.derived,{[fe.copied]:i}),onClick:a,children:[t.jsx("span",{className:fe.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:fe.derivedAddress,children:[t.jsx("span",{className:fe.hexAddress,children:v.truncate(o)}),t.jsx(N.IconCopy,{size:12,className:fe.derivedCopy}),i&&t.jsx("span",{className:fe.copiedText,children:"Copied!"})]})]})})]})})};function Hf(){const e=ne(),s=re();return $.useQueries({queries:s.map(n=>({queryKey:Yt.grants(n.chainId,e).queryKey,queryFn:async()=>{const{grants:o}=await z.create({prefixUrl:n.restUrl}).get(`cosmos/authz/v1beta1/grants/granter/${e}`).json();return{chainId:n.chainId,grants:o}},enabled:!!e,staleTime:W.SECOND,retry:!1}))})}const Qf="_countdown_vfms8_1",Vf={countdown:Qf},Gf=({expiration:e})=>{const s=()=>{const r=new Date,a=ke.differenceInSeconds(e,r),i=Math.floor(a/(1440*60)),c=Math.floor(a%(1440*60)/3600),l=Math.floor(a%3600/60),d=a%60,u=[];return i>0&&u.push(`${i}d`),(c>0||i>0)&&u.push(`${c}h`),(l>0||c>0||i>0)&&u.push(`${l}m`),u.push(`${d}s`),u.join(" ")},[n,o]=_.useState(s());return Ie.useInterval(()=>{o(s())},1e3),ke.isPast(e)?"Expired":t.jsxs(t.Fragment,{children:["Expires in ",t.jsx("span",{className:Vf.countdown,children:n})]})},Yf="_container_ksj5a_1",Jf="_info_ksj5a_11",Zf="_header_ksj5a_17",Xf="_chainName_ksj5a_23",e_="_expiration_ksj5a_29",t_="_revokeButton_ksj5a_35",St={container:Yf,info:Jf,header:Zf,chainName:Xf,expiration:e_,revokeButton:t_},s_=({chainId:e,grantee:s,messageTypes:n,expiration:o})=>{const r=Me(e),{mutate:a,isPending:i}=Cr({grantee:s,messageTypes:{[e]:n},internal:!0});return t.jsxs("div",{className:St.container,children:[t.jsxs("div",{className:St.info,children:[t.jsxs("div",{className:St.header,children:[t.jsx(Y,{src:r.logoUrl,width:16,height:16,logo:!0}),t.jsx("div",{className:St.chainName,children:r.name})]}),t.jsx("div",{className:St.expiration,children:o?t.jsx(Gf,{expiration:o}):"Until revoked"})]}),t.jsx("button",{className:St.revokeButton,onClick:()=>a(e),disabled:i,children:i?"Revoking...":"Revoke"})]})},n_=({chainId:e,grants:s})=>Object.values(s.reduce((o,r)=>{const a=o[r.grantee];return a?{...o,[r.grantee]:{...a,messageTypes:[...a.messageTypes,r.authorization.msg],expiration:Un([a.expiration,r.expiration?new Date(r.expiration):void 0])}}:{...o,[r.grantee]:{grantee:r.grantee,messageTypes:[r.authorization.msg],expiration:r.expiration?new Date(r.expiration):void 0}}},{})).map(o=>_.createElement(s_,{...o,chainId:e,key:o.grantee})),o_="_content_q36qs_1",r_={content:o_},a_=()=>{const e=Hf(),s=()=>{const n=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return n.length===0?t.jsx(se,{children:"No permissions found"}):t.jsx("div",{className:r_.content,children:n.map(({chainId:o,grants:r})=>t.jsx(n_,{chainId:o,grants:r},o))})};return t.jsx(Oe,{title:"Manage auto-signing",backButton:"/settings",children:s()})},i_="2.1.0",c_="_version_1sf5y_1",l_={version:c_},d_=()=>t.jsxs("aside",{className:l_.version,children:["v",i_]}),u_="_link_1vmyo_1",m_="_title_1vmyo_17",h_="_subtitle_1vmyo_23",f_="_icon_1vmyo_30",hs={link:u_,title:m_,subtitle:h_,icon:f_},la=({title:e,subtitle:s,rightSection:n,onClick:o})=>t.jsxs("button",{className:hs.link,onClick:o,children:[t.jsxs("div",{children:[t.jsx("p",{className:hs.title,children:e}),s&&t.jsx("p",{className:hs.subtitle,children:s})]}),t.jsx("div",{className:hs.icon,children:n??t.jsx(N.IconChevronRight,{size:16})})]}),__="https://export.initia.xyz/",p_=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return t.jsx(la,{title:"Export private key",rightSection:t.jsx(N.IconExternalLink,{size:16}),onClick:()=>window.open(__,"_blank",e)})},g_="_container_1rkl8_1",x_="_separator_1rkl8_7",Ro={container:g_,separator:x_},y_=()=>{const e=me(),{connector:s}=de.useAccount();return t.jsx(Oe,{title:"Settings",backButton:"/",children:t.jsxs("div",{className:Ro.container,children:[t.jsx(la,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),s?.id===Pn&&t.jsx(p_,{}),t.jsx(Ke.Separator,{className:Ro.separator}),t.jsx(d_,{})]})})},j_="_trigger_kivvl_1",v_="_icon_kivvl_21",w_="_full_kivvl_25",b_="_triggerContent_kivvl_30",C_="_triggerText_kivvl_38",I_="_popoverBackdrop_kivvl_49",N_="_popoverPositioner_kivvl_68",S_="_popoverPopup_kivvl_72",k_="_search_kivvl_96",A_="_viewport_kivvl_101",$_="_item_kivvl_106",T_="_highlighted_kivvl_120",E_="_active_kivvl_124",q_="_name_kivvl_129",D_="_extra_kivvl_133",le={trigger:j_,icon:v_,full:w_,triggerContent:b_,triggerText:C_,popoverBackdrop:I_,popoverPositioner:N_,popoverPopup:S_,search:k_,viewport:A_,item:$_,highlighted:T_,active:E_,name:q_,extra:D_},Yn=({value:e,onChange:s,chainIds:n,renderExtra:o,fullWidth:r})=>{const[a,i]=_.useState(""),[c,l]=_.useState(!1),[d,u]=_.useState(0),[m,h]=_.useState(),f=_.useRef([]),p=_.useRef(null),g=re(),y=n.map(j=>g.find(C=>C.chainId===j)).filter(Boolean),I=j=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:j,height:j,viewBox:"0 0 14 14",children:[t.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),t.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),S=_.useMemo(()=>({chainId:"",name:"All",logoUrl:I}),[]),k=_.useMemo(()=>{const j=[S,...y];if(!a)return j;const C=a.toLowerCase();return j.filter(x=>x.name.toLowerCase().includes(C)||x.chainId.toLowerCase().includes(C))},[y,a,S]),w=y.find(j=>j.chainId===e)||S,T=parseInt($r("--drawer-offset")),P=6,R=()=>{if(i(""),u(-1),p.current){const C=p.current.getBoundingClientRect().bottom+P,x=window.innerHeight-C-2*T;h(x)}l(!0)};_.useEffect(()=>{d>=0&&d<f.current.length&&f.current[d]?.scrollIntoView({block:"nearest",behavior:"auto"})},[d]);const B=_.useCallback(j=>{switch(j.key){case"ArrowDown":j.preventDefault(),u(C=>(C+1)%k.length);break;case"ArrowUp":j.preventDefault(),u(C=>(C-1+k.length)%k.length);break;case"Enter":j.preventDefault(),k[d]&&(s(k[d].chainId),l(!1));break;case"Escape":j.preventDefault(),l(!1);break}},[k,d,s,l]),K=j=>{s(j),l(!1)};return t.jsxs(It.Popover.Root,{open:c,onOpenChange:R,modal:"trap-focus",children:[t.jsx(It.Popover.Trigger,{render:t.jsxs("button",{className:D(le.trigger,{[le.full]:r}),"aria-expanded":c,role:"listbox",ref:p,children:[t.jsxs("div",{className:le.triggerContent,children:[typeof w.logoUrl=="string"?t.jsx(Y,{src:w.logoUrl,width:14,height:14,logo:!0}):w.logoUrl(14),t.jsx("span",{className:le.triggerText,children:w.name})]}),t.jsx(N.IconChevronDown,{size:16,className:le.icon})]})}),t.jsxs(It.Popover.Portal,{container:yt(),children:[t.jsx(It.Popover.Backdrop,{className:le.popoverBackdrop,onClick:()=>l(!1)}),t.jsx(It.Popover.Positioner,{className:le.popoverPositioner,align:"end",side:"bottom",sideOffset:P,collisionAvoidance:{side:"none"},children:t.jsxs(It.Popover.Popup,{className:D(le.popoverPopup,{[le.full]:r}),style:{maxHeight:m},children:[t.jsx(Hs,{value:a,onChange:j=>{i(j.target.value),u(0)},onClear:()=>i(""),onKeyDown:B,placeholder:"Search appchains",rootClassName:le.search,ref:ss()}),t.jsx("div",{className:le.viewport,role:"listbox",children:k.length===0?t.jsx(se,{children:"No appchains found"}):k.map(({chainId:j,name:C,logoUrl:x},A)=>t.jsxs("div",{className:D(le.item,{[le.highlighted]:A===d,[le.active]:e===j}),onClick:()=>K(j),onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),K(j))},onMouseEnter:()=>u(A),role:"option","aria-selected":e===j,tabIndex:-1,ref:q=>{q&&(f.current[A]=q)},children:[typeof x=="string"?t.jsx(Y,{src:x,width:16,height:16,logo:!0}):x(16),t.jsx("span",{className:le.name,children:C}),o&&t.jsx("span",{className:le.extra,children:o(j)})]},j))})]})})]})]})},P_="_container_t1267_1",R_="_controls_t1267_7",B_="_search_t1267_13",Jn={container:P_,controls:R_,search:B_},M_=({children:e})=>t.jsx("div",{className:Jn.container,children:e}),F_=({children:e})=>t.jsx("div",{className:Jn.controls,children:e}),O_=e=>t.jsx(Hs,{...e,rootClassName:Jn.search}),nt={Root:M_,Controls:F_,SearchInput:O_},U_=G.atom(""),L_=G.atom(""),z_=G.atom(""),K_=G.atom(""),W_=G.atom(""),H_="_change_1x9v4_1",Q_="_positive_1x9v4_10",V_="_negative_1x9v4_14",pn={change:H_,positive:Q_,negative:V_},da=({amount:e,asset:s})=>{const{denom:n,symbol:o,decimals:r}=s,a=new F(e).isPositive(),i=new F(e).abs().toString();return t.jsxs("div",{className:D(pn.change,a?pn.positive:pn.negative),children:[a?"+":"-",v.formatAmount(i,{decimals:r})," ",o||n]})},G_=({changes:e,chain:s})=>{const n=Ve(s);return e.map(({amount:o,denom:r},a)=>t.jsx(da,{amount:o,asset:n(r)},a))},Y_=({changes:e,chain:s})=>{const n=Ve(s);return e.map(({amount:o,metadata:r},a)=>t.jsx(Or,{metadata:r,chain:s,children:i=>t.jsx(da,{amount:o,asset:n(i)})},a))},J_=({events:e,chain:s})=>{const{initiaAddress:n,hexAddress:o}=xe();return s.metadata?.is_l1||s.metadata?.minitia?.type==="minimove"?t.jsx(Y_,{changes:Fr(e,o),chain:s}):t.jsx(G_,{changes:Mr(e,n),chain:s})},Z_="_message_1g2hc_1",X_="_more_1g2hc_8",Bo={message:Z_,more:X_},ep=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((s,n)=>t.jsx("p",{className:Bo.message,children:Is.sentenceCase(s["@type"].split("Msg")[1])},n)),e.length>3&&t.jsx("footer",{className:Bo.more,children:`+${e.length-3} more`})]}),tp="_link_oq58b_1",sp="_inner_oq58b_15",np="_header_oq58b_20",op="_time_oq58b_29",rp="_error_oq58b_35",ap="_timestamp_oq58b_39",ip="_chainInfo_oq58b_44",cp="_content_oq58b_52",lp="_messages_oq58b_59",dp="_changes_oq58b_64",De={link:tp,inner:sp,header:np,time:op,error:rp,timestamp:ap,chainInfo:ip,content:cp,messages:lp,changes:dp},up=({txItem:e,chain:s})=>t.jsx(zs,{txHash:e.txhash,chainId:s.chainId,className:De.link,children:t.jsxs("div",{className:De.inner,children:[t.jsxs("div",{className:De.header,children:[t.jsxs("div",{className:De.time,children:[e.code!==0&&t.jsx(N.IconWarningFilled,{size:14,className:De.error}),t.jsx("span",{className:De.timestamp,children:ke.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:De.chainInfo,children:[t.jsx(Y,{src:s.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:s.name})]})]}),t.jsxs("div",{className:De.content,children:[t.jsx("div",{className:De.messages,children:t.jsx(ep,{messages:e.tx.body.messages})}),t.jsx("div",{className:De.changes,children:t.jsx(ye,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(J_,{...e,chain:s})})})]})]})}),mp="_list_1wa9p_1",hp="_dateGroup_1wa9p_7",fp="_dateHeader_1wa9p_12",_p="_more_1wa9p_18",fs={list:mp,dateGroup:hp,dateHeader:fp,more:_p},pp=({list:e,chainId:s})=>{const n=ne(),o=_.useMemo(()=>ta(e,r=>{if(r.timestamp)return new Date(r.timestamp)}),[e]);return e.length===0?t.jsx(se,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:fs.list,children:Object.entries(o).map(([r,a])=>t.jsxs("div",{className:fs.dateGroup,children:[t.jsx("div",{className:fs.dateHeader,children:r}),a.map(i=>t.jsx(ye,{errorBoundaryProps:{fallback:null},children:t.jsx(up,{txItem:i,chain:i.chain})},i.txhash))]},r))}),t.jsx(zs,{chainId:s,accountAddress:n,pathSuffix:"/txs",className:fs.more,showIcon:!0,children:"View more on Initia Scan"})]})},gp=()=>{const{activities:e,isLoading:s}=Bc(),[n,o]=G.useAtom(W_),r=_e(),a=_.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=_.useMemo(()=>n?e.filter(c=>c.chain.chainId===n):e,[e,n]);return s&&e.length===0?t.jsx(se,{children:"Loading activities..."}):!e.length&&!s?t.jsx(se,{children:"No activity yet"}):t.jsxs(nt.Root,{children:[t.jsx(nt.Controls,{children:t.jsx(Yn,{value:n,onChange:o,chainIds:a,fullWidth:!0})}),t.jsx(pp,{list:i,chainId:n||r.chainId})]})},ua=_.createContext(null);function ma(){return _.useContext(ua)}const xp="_popup_nbecp_1",yp="_item_nbecp_19",_s={popup:xp,item:yp},ha=({asset:e,children:s})=>{const{denom:n,decimals:o,symbol:r,logoUrl:a,unlisted:i,address:c,chain:l}=e,{chainId:d}=l,[u,m]=_.useState(!1),h=me(),f=ma(),{showNotification:p}=Hn(),{defaultChainId:g}=X(),{evm_chain_id:y}=Zt(),I=de.useChainId(),{switchChainAsync:S}=de.useSwitchChain(),{watchAssetAsync:k}=de.useWatchAsset(),w=()=>{m(!1),h("/send",{denom:n,chain:l})},T=()=>{m(!1),h("/bridge",{srcChainId:d,srcDenom:n,quantity:""})},P=$.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const R=a;return await S({chainId:Number(y)}),k({type:"ERC20",options:{address:c,symbol:r,decimals:o,image:R}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:R=>{p({type:"error",title:"Asset addition failed",description:R.message})}});return t.jsxs(Ke.Menu.Root,{open:u,onOpenChange:m,modal:!1,children:[t.jsx(Ke.Menu.Trigger,{render:s}),t.jsx(Ke.Menu.Portal,{container:f,children:t.jsx(Ke.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(Ke.Menu.Popup,{className:_s.popup,children:[t.jsxs(Ke.Menu.Item,{className:_s.item,onClick:w,children:[t.jsx(N.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(Ke.Menu.Item,{className:_s.item,onClick:T,disabled:i,children:[t.jsx(N.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===g&&y===I&&!!c&&t.jsxs(Ke.Menu.Item,{className:_s.item,onClick:()=>P.mutate(),disabled:P.isPending||P.data,children:[P.data?t.jsx(N.IconCheck,{size:16}):t.jsx(N.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},jp="_item_knoro_1",vp="_info_knoro_22",wp="_images_knoro_28",bp="_name_knoro_32",Cp="_value_knoro_38",Ip="_amount_knoro_46",Np="_usd_knoro_52",ht={item:jp,info:vp,images:wp,name:bp,value:Cp,amount:Ip,usd:Np},Sp=({asset:e})=>{const{amount:s,value:n,logoUrl:o,chain:r}=e,a=v.formatAmount(s,{decimals:e.decimals});return t.jsx(ha,{asset:e,children:t.jsxs("button",{className:ht.item,children:[t.jsxs("div",{className:ht.info,children:[t.jsx(Ws,{assetLogoUrl:o,chainLogoUrl:r.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:ht.images}),t.jsx("span",{className:ht.name,children:r.name})]}),t.jsxs("div",{className:ht.value,children:[t.jsx("span",{className:ht.amount,children:a}),Number(n)>0&&t.jsx("span",{className:ht.usd,children:Ae(n)})]})]})})},kp="_container_g5q73_1",Ap="_assetItem_g5q73_6",$p="_assetInfo_g5q73_26",Tp="_logo_g5q73_32",Ep="_symbol_g5q73_36",qp="_chainName_g5q73_46",Dp="_chainInfos_g5q73_52",Pp="_chainLogos_g5q73_58",Rp="_chainLogo_g5q73_58",Bp="_moreChains_g5q73_69",Mp="_expandIcon_g5q73_81",Fp="_expanded_g5q73_85",Op="_valueColumn_g5q73_90",Up="_amount_g5q73_99",Lp="_value_g5q73_90",zp="_collapsibleContent_g5q73_112",Kp="_chainsList_g5q73_142",oe={container:kp,assetItem:Ap,assetInfo:$p,logo:Tp,symbol:Ep,chainName:qp,chainInfos:Dp,chainLogos:Pp,chainLogo:Rp,moreChains:Bp,expandIcon:Mp,expanded:Fp,valueColumn:Op,amount:Up,value:Lp,collapsibleContent:zp,chainsList:Kp},Wp=G.atom([]),fa=({assetGroup:e})=>{const{symbol:s,logoUrl:n,assets:o}=e,r=o.length===1,[a,i]=G.useAtom(Wp),c=_.useMemo(()=>mi(e),[e]),l=_.useMemo(()=>Ln(e),[e]),d=a.includes(s),u=()=>{i(h=>d?b.without([s],h):b.uniq([...h,s]))},m=()=>t.jsxs("button",{className:oe.assetItem,children:[t.jsxs("div",{className:oe.assetInfo,children:[n&&t.jsx(Y,{src:n,width:32,height:32,className:oe.logo,logo:!0}),t.jsxs("div",{className:oe.details,children:[t.jsx("div",{className:oe.symbol,children:s}),r?t.jsx("div",{className:oe.chainName,children:o[0].chain.name}):t.jsxs("div",{className:oe.chainInfos,children:[t.jsx("div",{className:oe.chainLogos,children:o.slice(0,5).map(({chain:h})=>t.jsx(Y,{src:h.logoUrl,width:16,height:16,className:oe.chainLogo,logo:!0},h.chainId))}),o.length>5&&t.jsxs("span",{className:oe.moreChains,children:["+",o.length-5]}),t.jsx(N.IconChevronDown,{size:16,className:D(oe.expandIcon,{[oe.expanded]:d})})]})]})]}),t.jsxs("div",{className:oe.valueColumn,children:[t.jsx("div",{className:oe.amount,children:v.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&t.jsx("div",{className:oe.value,children:Ae(l)})]})]});if(r){const[h]=o;return t.jsx("div",{className:oe.container,children:t.jsx(ha,{asset:h,children:m()})})}return t.jsx("div",{className:oe.container,children:t.jsxs(te.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(te.Collapsible.Trigger,{asChild:!0,children:m()}),t.jsx(te.Collapsible.Content,{className:oe.collapsibleContent,children:t.jsx("div",{className:oe.chainsList,children:o.map(h=>t.jsx(Sp,{asset:h},h.chain.chainId))})})]})})},Hp="_collapsible_1spkj_1",Qp="_trigger_1spkj_5",Vp="_divider_1spkj_20",Gp="_label_1spkj_26",Yp="_chevron_1spkj_31",Jp="_content_1spkj_39",Zp="_list_1spkj_43",tt={collapsible:Hp,trigger:Qp,divider:Vp,label:Gp,chevron:Yp,content:Jp,list:Zp},Xp=({unlistedAssets:e})=>{const[s,n]=_.useState(!0),o=ma(),r=_.useRef(null),[a,i]=_.useState(0);_.useEffect(()=>{if(r.current){const d=r.current.scrollHeight;i(d)}},[e]);const c=d=>{if(d&&!s&&o?.current){const u=o.current;u.scrollTo({top:u.scrollHeight,behavior:"auto"}),window.setTimeout(()=>{u.scrollTo({top:u.scrollHeight,behavior:"smooth"})},150)}n(d)},l=ot.useSpring({height:s?a:0,opacity:s?1:0,config:{tension:500,friction:30,clamp:!0}});return e.length===0?null:t.jsxs(te.Collapsible.Root,{open:s,onOpenChange:c,className:tt.collapsible,children:[t.jsxs(te.Collapsible.Trigger,{className:tt.trigger,children:[t.jsx("div",{className:tt.divider}),t.jsxs("span",{className:tt.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(N.IconChevronDown,{className:tt.chevron,size:12,"data-state":s?"open":"closed"}),t.jsx("div",{className:tt.divider})]}),t.jsx(te.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(ot.animated.div,{className:tt.content,style:l,children:t.jsx("div",{className:tt.list,ref:r,children:e.map(d=>t.jsx(fa,{assetGroup:{...d,assets:[d]}},d.denom))})})})]})},eg="_list_szwvw_1",tg={list:eg},sg=()=>{const[e,s]=G.useAtom(U_),[n,o]=G.useAtom(L_),{assetGroups:r,unlistedAssets:a,chainsByValue:i,totalValue:c,isLoading:l}=zn(),d=i.map(({chainId:h})=>h),u=_.useMemo(()=>{const h=e?r.filter(p=>{const{symbol:g,assets:y}=p;return g.toLowerCase().includes(e.toLowerCase())||y.some(({denom:I,address:S})=>I.toLowerCase().includes(e.toLowerCase())||S?.toLowerCase().includes(e.toLowerCase()))}):r;return n?h.map(p=>({...p,assets:p.assets.filter(({chain:g})=>g.chainId===n)})).filter(p=>p.assets.length>0):h},[r,e,n]),m=_.useMemo(()=>{const h=e?a.filter(({denom:p,address:g})=>p.toLowerCase().includes(e.toLowerCase())||g?.toLowerCase().includes(e.toLowerCase())):a;return n?h.filter(({chain:p})=>p.chainId===n):h},[a,e,n]);return l&&r.length===0?t.jsx(se,{children:"Loading assets..."}):!u.length&&!m.length&&!e&&!n&&!l?t.jsx(se,{children:"No assets"}):t.jsxs(nt.Root,{children:[t.jsxs(nt.Controls,{children:[t.jsx(nt.SearchInput,{value:e,onChange:h=>s(h.target.value),onClear:()=>s(""),placeholder:"Search assets"}),t.jsx(Yn,{value:n,onChange:o,chainIds:d,renderExtra:h=>{if(!h)return Ae(c);const f=i.find(p=>p.chainId===h);return f?Ae(f.value):null}})]}),t.jsx("div",{children:u.length===0&&m.length===0?t.jsx(se,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:tg.list,children:u.map(h=>t.jsx(fa,{assetGroup:h},h.symbol))}),t.jsx(Xp,{unlistedAssets:m})]})})]})},ng="_thumbnail_1tdri_1",og="_placeholder_1tdri_18",rg="_clickable_1tdri_24",Wt={thumbnail:ng,placeholder:og,clickable:rg},ag=({nftInfo:e,size:s,onClick:n})=>{const{collection_addr:o,object_addr:r,nft:a,chain:i}=e,{glyphUrl:c}=X(),l=new URL(`/v1/${i.chainId}/${o}/${r||a.token_id}`,c).toString();return n?t.jsx("button",{className:D(Wt.thumbnail,Wt.clickable),onClick:n,style:{width:s,height:s},children:t.jsx(Y,{src:l,classNames:{placeholder:Wt.placeholder}})}):t.jsx("div",{className:Wt.thumbnail,style:{width:s,height:s},children:t.jsx(Y,{src:l,classNames:{placeholder:Wt.placeholder}})})},ig="_collectionName_p9jco_1",cg="_nftName_p9jco_6",lg="_chainInfo_p9jco_10",gn={collectionName:ig,nftName:cg,chainInfo:lg},Zn=({normalizedNft:e,onThumbnailClick:s,thumbnailSize:n,chainIconSize:o=12,classNames:r})=>{const{collection_name:a,name:i,chain:c}=e;return t.jsxs("div",{className:r?.root,children:[t.jsx(ag,{nftInfo:e,onClick:s,size:n}),t.jsxs("div",{children:[t.jsx("div",{className:D(gn.collectionName,r?.collectionName),children:a}),t.jsx("div",{className:D(gn.nftName,r?.nftName),children:i}),t.jsxs("div",{className:D(gn.chainInfo,r?.chainInfo),children:[t.jsx(Y,{src:c.logoUrl,width:o,height:o,logo:!0}),t.jsx("span",{children:c.name})]})]})]})},Xn=$e.createQueryKeys("interwovenkit:nft",{nfts:(e,s)=>[e,s],metadata:e=>[e]});function dg(e,s){const{nft:n}=e,o=s.name??n.token_id;return{...e,...n,...s,name:o}}function ug(e,s){return e.flatMap((n,o)=>(s[o]??[]).map(a=>({...a,chain:n})))}const mg=()=>{const e=ne(),s=re(),n=$.useQueries({queries:s.map(l=>({queryKey:Xn.nfts(l.indexerUrl,e).queryKey,queryFn:()=>tr(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:W.SECOND}))}),o=n.map(b.prop("data")),r=ug(s,o),a=r.reduce((l,{chain:d})=>({...l,[d.chainId]:(l[d.chainId]||0)+1}),{}),i=Object.values(a).reduce((l,d)=>l+d,0),c=n.some(l=>l.isLoading);return{nftInfos:r,chainCounts:a,totalCount:i,isLoading:c}};function hg(e){const s=Mo(e);return $.useQuery({queryKey:Xn.metadata(s).queryKey,queryFn:async()=>{try{if(!s)return{};const n=await z.get(s).json();return{...n,image:Mo(n.image)}}catch{return{}}},staleTime:W.INFINITY})}function Mo(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const fg=({nftInfo:e,children:s})=>{const{data:n={}}=hg(e.nft.uri),o=dg(e,n);return s(o)},_g="_grid_1wwdn_1",pg="_root_1wwdn_7",gg="_collectionName_1wwdn_15",xg="_nftName_1wwdn_23",yg="_chainInfo_1wwdn_32",Fo={grid:_g,root:pg,collectionName:gg,nftName:xg,chainInfo:yg},jg=()=>{const[e,s]=G.useAtom(z_),[n,o]=G.useAtom(K_),{nftInfos:r,chainCounts:a,totalCount:i,isLoading:c}=mg(),l=me(),d=_.useMemo(()=>r.filter(({collection_addr:m,collection_name:h,nft:f,object_addr:p,chain:g})=>{if(n&&g.chainId!==n)return!1;if(e){const y=e.trim().toLowerCase();return m.toLowerCase().includes(y)||h.toLowerCase().includes(y)||f.token_id.toLowerCase().includes(y)||p.toLowerCase().includes(y)}return!0}),[r,n,e]),u=_.useMemo(()=>Array.from(new Set(r.map(({chain:m})=>m.chainId))),[r]);return c&&r.length===0?t.jsx(se,{children:"Loading NFTs..."}):!r.length&&!e&&!c?t.jsx(se,{children:"No NFTs"}):t.jsxs(nt.Root,{children:[t.jsxs(nt.Controls,{children:[t.jsx(nt.SearchInput,{value:e,onChange:m=>s(m.target.value),onClear:()=>s(""),placeholder:"Search NFTs"}),t.jsx(Yn,{value:n,onChange:o,chainIds:u,renderExtra:m=>m?a[m]||0:i})]}),d.length===0?t.jsx(se,{children:"No NFTs found"}):t.jsx("div",{className:Fo.grid,children:d.map(m=>{const{collection_addr:h,nft:f}=m;return t.jsx(fg,{nftInfo:m,children:p=>t.jsx(Zn,{normalizedNft:p,onThumbnailClick:()=>l("/nft",p),classNames:Fo})},h+f.token_id)})})]})},vg="_totalValue_19cj3_1",wg="_totalLabel_19cj3_7",bg="_totalAmount_19cj3_13",Cg="_loading_19cj3_18",Ig="_nav_19cj3_23",Ng="_item_19cj3_28",Sg="_tabs_19cj3_53",kg="_tab_19cj3_53",we={totalValue:vg,totalLabel:wg,totalAmount:bg,loading:Cg,nav:Ig,item:Ng,tabs:Sg,tab:kg},Ag=()=>{Vr();const e=me(),s=Ts(),{totalValue:n,isLoading:o}=zn(),r=_.useRef(null);return t.jsx(ua.Provider,{value:r,children:t.jsxs(Fe,{ref:r,children:[t.jsxs("div",{className:we.totalValue,children:[t.jsx("div",{className:we.totalLabel,children:"Total value"}),t.jsx("div",{className:D(we.totalAmount,{[we.loading]:o}),children:Ae(n)})]}),t.jsxs("div",{className:we.nav,children:[t.jsxs(Et,{to:"/send",className:we.item,children:[t.jsx(N.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(Et,{to:"/bridge",className:we.item,children:[t.jsx(N.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),t.jsxs(Et,{to:"/receive",className:we.item,children:[t.jsx(N.IconQrCode,{size:16}),t.jsx("span",{children:"Receive"})]})]}),t.jsxs(Ze.Tabs.Root,{value:s,onValueChange:e,children:[t.jsxs(Ze.Tabs.List,{className:we.tabs,children:[t.jsx(Ze.Tabs.Tab,{className:we.tab,value:"/",children:"Assets"}),t.jsx(Ze.Tabs.Tab,{className:we.tab,value:"/nfts",children:"NFTs"}),t.jsx(Ze.Tabs.Tab,{className:we.tab,value:"/activity",children:"Activity"})]}),t.jsx(Ze.Tabs.Panel,{value:"/",children:t.jsx(sg,{})}),t.jsx(Ze.Tabs.Panel,{value:"/nfts",children:t.jsx(jg,{})}),t.jsx(Ze.Tabs.Panel,{value:"/activity",children:t.jsx(gp,{})})]})]})})},$g="_root_9688k_1",Tg="_collectionName_9688k_8",Eg="_nftName_9688k_12",qg="_chainInfo_9688k_16",Dg="_attributes_9688k_20",Pg="_title_9688k_23",Rg="_count_9688k_28",Bg="_item_9688k_32",Mg="_type_9688k_38",Fg="_value_9688k_44",ft={root:$g,collectionName:Tg,nftName:Eg,chainInfo:qg,attributes:Dg,title:Pg,count:Rg,item:Bg,type:Mg,value:Fg},Og=()=>{const e=me(),s=jt(),{attributes:n}=s;return t.jsxs(Oe,{title:"NFT details",children:[t.jsx(Zn,{normalizedNft:s,chainIconSize:14,classNames:ft}),t.jsx(ie,{children:t.jsx(J.White,{onClick:()=>e("/nft/send",s),sm:!0,children:"Send"})}),n&&t.jsxs("div",{className:ft.attributes,children:[t.jsxs("header",{className:ft.title,children:["Traits ",t.jsxs("span",{className:ft.count,children:["(",n.length,")"]})]}),t.jsx("div",{children:n.map(({trait_type:o,value:r})=>t.jsxs("div",{className:ft.item,children:[t.jsx("div",{className:ft.type,children:o}),t.jsx("div",{className:ft.value,children:r})]},o))})]})]})};function Ug({balances:e,gasPrices:s,gas:n}){return s.map(({denom:o,amount:r})=>{const a=F(r).times(n).toFixed(0,F.ROUND_CEIL),i=e.find(c=>c.denom===o)?.amount??"0";return{amount:a,denom:o,balance:i}}).filter(({amount:o,balance:r})=>F(r).gte(o))}function Lg({denom:e,balances:s,gasPrices:n,lastFeeDenom:o,gas:r}){const a=s.find(d=>d.denom===e)?.amount??"0",i=Ug({balances:s,gasPrices:n,gas:r}),c=i.find(d=>d.denom===o);if(i.length===0)return a;if(e===o&&c){const d=F(a).minus(c.amount);return F.max(d,0).toString()}const l=i.find(d=>d.denom!==e)||i[0];if(!c&&e===l.denom){const d=F(a).minus(l.amount);return F.max(d,0).toString()}return F(a).toString()}const zg=({chain:e,onSelect:s})=>{const n=za(e);return t.jsx(os,{assets:n,onSelect:s})},Kg=({afterSelect:e})=>{const{watch:s,setValue:n}=ue.useFormContext(),{chainId:o,denom:r}=s(),{chainId:a}=s(),[i,c]=_.useState(a),l=Me(i),d=re(),u=m=>{if(o===i&&r===m){e();return}n("chainId",i),n("denom",m),n("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(xt.Stack,{children:t.jsx(xt,{chains:d,value:i,onSelect:c})}),t.jsx(ye,{suspenseFallback:t.jsx(os.Placeholder,{}),children:t.jsx(zg,{chain:l,onSelect:u})},i)]})},Wg="_fields_brpej_1",Hg="_divider_brpej_11",Oo={fields:Wg,divider:Hg},Qg=$e.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Vg=()=>{const{address:e,initiaAddress:s,estimateGas:n,requestTxSync:o}=xe(),{register:r,watch:a,setValue:i,handleSubmit:c,formState:l}=ue.useFormContext(),{errors:d}=l,{chainId:u,denom:m,recipient:h,quantity:f,memo:p}=a(),g=Me(u),y=Bn(g),I=Pr(g),S=Rr(g),k=Xo(m,g),{data:w}=ks(g),{decimals:T}=k,P=y.find(O=>O.denom===m)?.amount??"0",R=w?.find(({id:O})=>O===m)?.price,{data:B=0,isLoading:K}=$.useQuery({queryKey:Qg.gas({chainId:u,denom:m,recipient:h,initiaAddress:s}).queryKey,queryFn:()=>{const O=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:io.MsgSend.fromPartial({fromAddress:s,toAddress:v.InitiaAddress(h).bech32,amount:[{denom:m,amount:"1"}]})}];return n({messages:O,chainId:u})},enabled:v.InitiaAddress.validate(h),staleTime:W.INFINITY}),j=Math.ceil(B*Vt),C=Lg({denom:m,balances:y,gasPrices:I,lastFeeDenom:S,gas:j}),x=F(P).isZero(),q=I.some(({denom:O})=>O===m)&&K,M=x||q,{mutate:E,isPending:H}=$.useMutation({mutationFn:({chainId:O,denom:Z,quantity:Ue,recipient:Je,memo:at})=>{const he=v.toBaseUnit(Ue,{decimals:T}),pe=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:io.MsgSend.fromPartial({fromAddress:s,toAddress:v.InitiaAddress(Je).bech32,amount:[{denom:Z,amount:he}]})}];return o({messages:pe,memo:at,chainId:O,gas:B,gasAdjustment:Vt,gasPrices:I,spendCoins:[{denom:Z,amount:he}],internal:"/"})}}),ee=_.useMemo(()=>{if(!f)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},[f,h,d.quantity,d.recipient,d.memo]);return t.jsx(Oe,{title:"Send",children:t.jsxs("form",{onSubmit:c(O=>E(O)),children:[t.jsxs("div",{className:Oo.fields,children:[t.jsx(In,{selectButton:t.jsx(Dt,{title:"Select chain and asset",content:O=>t.jsx(Kg,{afterSelect:O}),children:t.jsx(Xr,{asset:k,chain:g})}),quantityInput:t.jsx(ws,{balance:P,decimals:T}),balanceButton:t.jsx(Gr,{onClick:()=>i("quantity",v.fromBaseUnit(C,{decimals:T}),{shouldValidate:!0}),disabled:M,children:v.formatAmount(P??"0",{decimals:T})}),value:f?R?Ae(F(f).times(R)):"$-":"$0"}),t.jsx("div",{className:Oo.divider}),t.jsx(Vn,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...r("memo",{validate:O=>!O||new Blob([O]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),t.jsx(ae.Stack,{children:!p&&t.jsx(ae,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(ie,{children:t.jsx(J.White,{type:"submit",loading:(K?"Estimating gas...":!1)||H,disabled:!!ee,children:ee??"Confirm"})})]})})},Gg=()=>{const e=jt(),s=Zt(),n=Gt(s),{chain:o=s}=e,r=b.head(n);if(!e.denom&&!r)throw new Error("Asset list not found. This occurs during local development when asset list is not configured. Use asset-specific send buttons instead of the default send button, or register chain in Initia Registry with at least one asset defined.");const a=e.denom??r?.denom,i=ue.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:a,quantity:"",recipient:"",memo:""}});return t.jsx(ue.FormProvider,{...i,children:t.jsx(Vg,{})})};async function En(e,s){const n=e.replace("ibc/",""),{class_trace:o}=await z.create({prefixUrl:s}).get(`ibc/apps/nft_transfer/v1/class_traces/${n}`).json();return o}async function Yg(e,s){const n=new We.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await z.create({prefixUrl:s}).post("minievm/evm/v1/call",{json:{sender:v.InitiaAddress("0x1").bech32,contract_addr:v.InitiaAddress(e).hex,input:n.encodeFunctionData("name")}}).json();return n.decodeFunctionResult("name",o)[0]}async function Jg(e,s,n){if(s.startsWith("evm/"))return e;const{token_infos:o}=await z.create({prefixUrl:n}).get(`minievm/evm/v1/erc721/origin_token_infos/${s}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:r})=>r)}async function Zg({collection_addr:e},{restUrl:s}){const n=await Yg(e,s);if(!n.startsWith("ibc/"))return{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await En(n,s);return o?{class_id:n,class_trace:o}:{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function Xg(e,s){const{data:n}=await z.create({prefixUrl:s}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(n)}async function ex({object_addr:e,collection_addr:s},{restUrl:n}){const o=await Xg(s,n);return o.startsWith("ibc/")?v.InitiaAddress.equals(v.createObjectAddress("0x1",o),s)?{class_id:o,class_trace:await En(o,n)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await En(o,n)}:{class_id:`move/${s.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function tx(e,s){const n=V.toBase64(_t.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await z.create({prefixUrl:s}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${n}`).json();return o.name}async function sx(e,s){const{collection:n}=await z.create({prefixUrl:s}).get(`indexer/nft/v1/collections/${e}`).json();return n.collection.creator}async function nx(e,s){const n=V.toBase64(_t.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:s}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${n}`).json();return o}function Uo(e){const s=/^(.*channel-\d+)\/(.*)$/,n=e.match(s);if(!n)throw new Error("Pattern `channel-{number}/` not found.");const[,o,r]=n;return[o,r]}async function ox({collection_addr:e},s,n){const o=v.InitiaAddress(e).bech32,r=await tx(o,s.restUrl),a=s.metadata?.ibc_channels?.find(({chain_id:g,version:y})=>g===n.chain_id&&y.includes("ics721-1"));if(!a)throw new Error("Channel not found");const i=a.port_id,c=i.split(".")[1],l=V.toBase64(_t.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await z.create({prefixUrl:s.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),u=d??o,m=await nx(c,s.restUrl),h=await sx(o,s.indexerUrl);if(u===o)return{class_id:u,class_trace:void 0,outgoing_proxy:m};if(d&&h!==i.replace("wasm.","")){const[g,y]=Uo(d);return{class_id:o,class_trace:{path:g,base_class_id:y},outgoing_proxy:m}}const[f,p]=Uo(r);return{class_id:o,class_trace:{path:f,base_class_id:p},outgoing_proxy:m}}const rx={minimove:ex,minievm:Zg,miniwasm:ox};async function ax({nft:e,srcChain:s,intermediaryChain:n}){const o=s.metadata?.is_l1?"minimove":s.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const r=await rx[o](e,s,n);return Object.assign(r,o==="minievm"&&{token_ids:await Jg([e.token_id],r.class_id,s.restUrl)})}const ix="_root_17hg0_1",cx="_collectionName_17hg0_9",lx="_nftName_17hg0_14",dx="_chainInfo_17hg0_18",ux="_fields_17hg0_23",mx="_chain_17hg0_18",xn={root:ix,collectionName:cx,nftName:lx,chainInfo:dx,fields:ux,chain:mx},hx=$e.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),fx=()=>{const e=re(),s=jt(),{chain:n,collection_addr:o}=s,{routerApiUrl:r}=X(),a=qs(),i=_e(),{address:c,initiaAddress:l,requestTxSync:d}=xe(),{watch:u,setValue:m,handleSubmit:h,formState:f}=ue.useFormContext(),{errors:p}=f,g=u(),{recipient:y,dstChainId:I}=g,S=Me(I),k=$.useQuery({queryKey:hx.simulation({collection_addr:o,nft:s,sender:l,recipient:y,srcChain:n,dstChain:S,layer1:i,routerApiUrl:r}).queryKey,queryFn:async()=>{const C=Object.assign({from_address:l,from_chain_id:n.chainId,to_address:v.InitiaAddress(y).bech32,to_chain_id:S.chainId,collection_address:o,token_ids:[s.token_id],object_addresses:[s.object_addr]},n.chainId!==S.chainId&&await ax({nft:s,srcChain:n,intermediaryChain:i})),{msgs:x}=await z.create({prefixUrl:r}).post("nft",{json:C}).json();return x.map(A=>a.fromAmino(A))},enabled:v.InitiaAddress.validate(y)}),{data:w,isLoading:T,error:P}=k,R=$.useQueryClient(),{mutate:B,isPending:K}=$.useMutation({mutationFn:async()=>{if(!w)throw new Error("Route not found");await d({messages:w,chainId:n.chainId,internal:"/nfts"})},onSuccess:()=>{R.invalidateQueries({queryKey:Xn.nfts._def})}}),j=_.useMemo(()=>{if(!y)return"Enter recipient address";if(p.recipient)return p.recipient.message;if(P)return"Route not found"},[y,p.recipient,P]);return t.jsxs("form",{onSubmit:h(()=>B()),children:[t.jsx(Zn,{normalizedNft:s,thumbnailSize:80,classNames:xn}),t.jsxs("div",{className:xn.fields,children:[t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(Dt,{title:"Destination appchain",content:C=>t.jsx(Zr,{onSelect:({chainId:x})=>{m("dstChainId",x),C()},list:e,getImage:x=>x.logoUrl,getName:x=>x.name,getKey:x=>x.chainId}),className:D("input",xn.chain),children:[t.jsx(Y,{src:S.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:S.name})]})]}),t.jsx(Vn,{myAddress:c,ref:ss()})]}),t.jsx(ie,{children:t.jsx(J.White,{loading:(T?"Finding route...":!1)||K,disabled:!!j,children:j??"Confirm"})})]})},_x=()=>{const{chain:e}=jt(),s=ue.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(Oe,{title:"Send NFT",children:t.jsx(ue.FormProvider,{...s,children:t.jsx(fx,{})})})},_a=()=>{const e=me(),s=Ts(),n=Pt(),{closeDrawer:o}=Ge(),{closeModal:r}=Bs();_.useEffect(()=>{r(),s.startsWith("/bridge/")&&e("/bridge"),(s==="/collection"||s.startsWith("/nft"))&&e("/nfts")},[n]);const a=Es();if(_.useEffect(()=>{a("Page View")},[s,a]),s==="/connect")return n?null:t.jsx(Po,{onSuccess:o});if(s==="/blank")return null;if(!n)return t.jsx(Po,{});switch(s){case"/":case"/nfts":case"/activity":return t.jsx(Ag,{});case"/send":return t.jsx(Gg,{},n);case"/receive":return t.jsx(Wf,{});case"/nft":return t.jsx(Og,{});case"/nft/send":return t.jsx(_x,{},n);case"/bridge":return t.jsx(Tm,{},n);case"/bridge/preview":return t.jsx(zh,{});case"/bridge/history":return t.jsx(jh,{});case"/op/withdrawals":return t.jsx(wf,{});case"/tx":return t.jsx(Lr,{});case"/autosign/enable":return t.jsx(pd,{});case"/settings":return t.jsx(y_,{});case"/settings/autosign":return t.jsx(a_,{})}},px="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",gx=()=>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:px}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),xx=()=>{Ya(),ni(),re();const e=_e();return Kn(),qt(localStorage.getItem(U.BRIDGE_SRC_CHAIN_ID)??e.chainId),qt(localStorage.getItem(U.BRIDGE_DST_CHAIN_ID)??e.chainId),null},yx=({children:e,...s})=>(_.useEffect(()=>{vi()},[]),Ie.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(gx,{}),t.jsx(Go.Provider,{value:{...Vo,...s},children:t.jsx(ir,{children:t.jsx(Ql,{children:t.jsx(te.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(Hl,{children:t.jsxs(Dl,{children:[e,t.jsx(wi,{}),t.jsx(ye,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(xx,{})}),t.jsx(cc,{children:t.jsx(_a,{})})]})})})})})})]}):null),jx=({bridge:e})=>t.jsx(ir,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Er.Provider,{value:!!e,children:t.jsx(ye,{children:t.jsx(_a,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=Vt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=Qo;exports.InterwovenKit=jx;exports.InterwovenKitProvider=yx;exports.MAINNET=Vo;exports.MoveError=yr;exports.PRIVY_APP_ID=Pn;exports.TESTNET=$a;exports.initiaPrivyWallet=Ea;exports.initiaPrivyWalletConnector=Ta;exports.initiaPrivyWalletOptions=Ns;exports.injectStyles=Mi;exports.useAddress=Pt;exports.useHexAddress=Us;exports.useInitiaAddress=ne;exports.useInterwovenKit=xe;exports.usePortfolio=zn;exports.useUsernameQuery=Ir;
|
|
4
|
+
</svg>`,Fa=encodeURIComponent(Ma),Rn=`data:image/svg+xml;utf8,${Fa}`,js=Ne.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 Oa(e){const{base:s,symbol:n,denom_units:r=[],display:o,logo_URIs:a,name:i,address:c,traces:l}=e,d=r.find(h=>h.denom===o)?.exponent??r.find(h=>h.denom===s)?.exponent??w.head(r)?.exponent??0,u=a?.png??"";return{denom:s,symbol:n,decimals:d,logoUrl:u,name:i,address:c,traces:l}}function Jr(){const e=$.useQueryClient();return s=>{const n=s?.metadata?.assetlist;return $.queryOptions({queryKey:js.list(n).queryKey,queryFn:async()=>n?L.get(n).json():{assets:[]},select:({assets:r})=>{if(!s)return[];const o=r.map(Oa);for(const a of o)e.setQueryData(js.item(s.chainId,a.denom).queryKey,a);return o},staleTime:Q.MINUTE})}}function Vt(e){const s=Jr(),{data:n}=$.useSuspenseQuery(s(e));return n}function Ua(){const e=ae(),s=Jr();return $.useQueries({queries:e.map(n=>s(n))})}function Ge(e){const s=Vt(e),n=_e(),r=Vt(n),o=Xr(e);return a=>{const i=s.find(l=>l.denom===a);if(i)return i;const c=r.find(l=>l.denom===o(a));return c?{...c,denom:a}:{denom:a,symbol:"",decimals:0,logoUrl:Rn}}}function Zr(e,s){const n=Ge(s),o=$.useQueryClient().getQueryData(js.item(s.chainId,e).queryKey);return o||n(e)}function Xr(e){const s=_e(),n=Vt(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?v.getIbcDenom(o,r):""}}function La(e){return e.pagination?.next_key??null}async function eo(e,s,n){const r=L.create(s),o=async(a,i)=>{const c=await r.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),l=c[n]??[],d=La(c),u=[...a,...l];return d?o(u,d):u};return o([],null)}const cr="usernames";function za({restUrl:e,moduleAddress:s}){const{viewFunction:n}=v.createMoveClient(e);async function r(i){if(!v.InitiaAddress.validate(i))return null;const c=await n({moduleAddress:s,moduleName:cr,functionName:"get_name_from_address",typeArgs:[],args:[V.toBase64(v.InitiaAddress(i,32).bytes)]});return c?c+".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 c=await n({moduleAddress:s,moduleName:cr,functionName:"get_address_from_name",typeArgs:[],args:[va.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return c?v.InitiaAddress(c).bech32:null}return{restUrl:e,getUsername:r,getAddress:a,validateUsername:o}}const $s=Ne.createQueryKeys("interwovenkit:account",{username:(e,s)=>[e,s],address:(e,s)=>[e,s],balances:(e,s)=>[e,s],txs:(e,s)=>[e,s]});function to(){const{restUrl:e}=_e(),{usernamesModuleAddress:s}=X();return za({restUrl:e,moduleAddress:s})}function so(){const e=ee();return s=>$.queryOptions({queryKey:$s.balances(s.restUrl,e).queryKey,queryFn:()=>eo(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:s.restUrl},"balances"),staleTime:Q.SECOND})}function Bn(e){const s=so(),{data:n}=$.useSuspenseQuery(s(e));return n}function Ka(){const e=ae(),s=so();return $.useQueries({queries:e.map(n=>s(n))})}function Wa(e){const s=Bn(e),n=Vt(e),r=Ge(e),o=Xr(e),{data:a}=ks(e),i=l=>e.fees.fee_tokens.some(d=>d.denom===l),c=l=>n.some(d=>d.denom===l);return w.sortWith([w.descend(({denom:l})=>o(l)==="uinit"),w.descend(({denom:l})=>i(l)),w.descend(({value:l})=>l),w.descend(({denom:l})=>c(l)),({balance:l},{balance:d})=>F(d).comparedTo(l)??0,w.descend(({symbol:l})=>l.toLowerCase())],s.filter(({amount:l})=>!F(l).isZero()).map(({amount:l,denom:d})=>{const u=r(d),h=a?.find(({id:f})=>f===u?.denom)?.price??0,m=F(l).times(h).div(F(10).pow(u.decimals)).toNumber();return{...u,balance:l,price:h,value:m}}))}const no=_.createContext(null);function Ts(){return _.useContext(no)}function ro(){const{location:e}=Ts();return e}function Es(){const{path:e}=ro();return e}function jt(){const{state:e={}}=ro();return e}function Ha(){const{history:e}=Ts();return e}function he(){const{navigate:e}=Ts();return e}function oo(){const{reset:e}=Ts();return e}const Et=({to:e,state:s,shouldReset:n,children:r,onClick:o,...a})=>{const i=he(),c=oo(),l=d=>{d.preventDefault(),o?.(d),n?c(e,s):i(e,s)};return t.jsx("button",{type:"button",...a,onClick:l,children:r})},ao=({children:e,initialEntry:s})=>{const[n,r]=_.useState([s??{path:"/"}]),o=n[n.length-1],a=_.useCallback((c,l)=>{r(d=>{if(typeof c=="string")return[...d,{path:c,state:l}];const u=d.length+c;if(u<1)return d;const h=w.take(u,d);return l!==void 0?w.adjust(u-1,m=>({...m,state:l}),h):h})},[]),i=_.useCallback((c,l)=>{r([{path:c,state:l}])},[]);return t.jsx(no.Provider,{value:{location:o,history:n,navigate:a,reset:i},children:e})},Qa="c33b940c24c17e95f7d9d525d508ac61";function Ga(){const{disableAnalytics:e}=X();_.useEffect(()=>{e||Dn.init(Qa,{autocapture:!1})},[e])}function Va(){const{connector:e}=de.useAccount(),{defaultChainId:s,disableAnalytics:n}=X();_.useEffect(()=>{const r=new Lr.Identify;e?.name&&r.set("connector",e.name),s&&r.set("defaultChainId",s),Dn.identify(r)},[s,e?.name,n])}function qs(){const e=Es();return _.useCallback((n,r)=>{Dn.track(n,{path:e,...r})},[e])}const Ee="interwovenkit",Ya=1e3,io=60*Ya,co=60*io,lr=24*co,U={PUBLIC_KEY:`${Ee}:public-key`,BRIDGE_SRC_CHAIN_ID:`${Ee}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${Ee}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${Ee}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${Ee}:bridge:dst-denom`,BRIDGE_QUANTITY:`${Ee}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${Ee}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${Ee}:bridge:route-type`,BRIDGE_HISTORY:`${Ee}:bridge:history`,OP_REMINDER:`${Ee}:op:reminder`},Ja=H.atom(!1);function Ve(){const e=oo(),[s,n]=H.useAtom(Ja),r=qs();return{isDrawerOpen:s,openDrawer:(i,c)=>{i&&e(i,c),n(!0),r("Widget Opened")},closeDrawer:()=>{n(!1),r("Widget Closed")}}}function Mn(){const e=he(),{closeDrawer:s}=Ve(),{disconnect:n}=de.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)}}function Fn(){const{privyContext:e}=X(),{address:s}=de.useAccount();return e?s?!!e.privy.user?.linkedAccounts.map(r=>"address"in r&&r.address).filter(r=>!!r)?.some(r=>v.InitiaAddress.equals(r,s)):!1:!0}function Za(){const{privyContext:e}=X(),s=Fn(),{address:n}=de.useAccount(),{signMessageAsync:r}=de.useSignMessage(),o=Mn(),a=!!e?.privy.ready,i=_.useRef(e);_.useEffect(()=>{i.current=e},[e]);const c=async l=>{try{if(!i.current)throw new Error("Privy context not found");i.current.privy.authenticated&&await i.current.privy.logout();const d=await i.current.siwe.generateSiweMessage({chainId:"eip155:1",address:l});if(!d)throw new Error("Failed to generate SIWE message");const u=await r({message:d});await i.current.siwe.loginWithSiwe({signature:u,message:d})}catch{o()}};_.useEffect(()=>{s||a&&n&&c(n)},[s,a,n])}function Xa(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:s}=vn.PubKey.decode(e.value);return Qt.encodeSecp256k1Pubkey(s)}return Is.decodeOptionalPubkey(e)}function ei({typeUrl:e,value:s}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:n,pubKey:r,accountNumber:o,sequence:a}=ba.BaseAccount.decode(s),i=Xa(r);return{address:n,pubkey:i,accountNumber:Number(o),sequence:Number(a)}}return Pe.accountFromAny({typeUrl:e,value:s})}function ti(e){return e.type==="initia/PubKeyEthSecp256k1"}const si={...Qt.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function ni(e){if(ti(e)){const s=vn.PubKey.fromPartial({key:V.fromBase64(e.value)});return Ca.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(vn.PubKey.encode(s).finish())})}return Is.encodePubkey(e)}function lo(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:si.ethsecp256k1,value:V.toBase64(e)}}function ri(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:lo(e),signature:V.toBase64(s)}}const Xt=()=>{const e=X();return new Is.Registry([...Ht.protoRegistry,...e.protoTypes??[]])},Ds=()=>{const e=X();return new Pe.AminoTypes({...Ht.aminoConverters,...e.aminoConverters})};class uo{constructor(s,n,r){this.address=s,this.signMessage=n,this.restUrl=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=V.fromHex(n),V.fromHex(n);const r=await this.getPublicKeyFromRestApi();if(r)return this.cachedPublicKey=r,localStorage.setItem(s,V.toHex(r)),r;const o=await this.getPublicKey();return this.cachedPublicKey=o,localStorage.setItem(s,V.toHex(o)),o}async getPublicKeyFromRestApi(){try{const n=(await L.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return n?V.fromBase64(n):null}catch{return null}}async getPublicKey(){const s="Sign this message to identify your Initia account.",n=await this.signMessage(s),r=We.ethers.hashMessage(s),o=We.ethers.SigningKey.recoverPublicKey(r,n);return jn.Secp256k1.compressPubkey(V.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=yn.escapeCharacters(yn.sortedJsonStringify(n)),o=await this.signMessage(r),a=V.fromHex(o.replace("0x","")).subarray(0,-1),c=jn.Secp256k1Signature.fromFixedLength(a).toFixedLength(),l=ri(await this.getCachedPublicKey(),c);return{signed:n,signature:l}}}function Ps(){const e=Xt(),s=Ds(),n=es(),r=mo();return async function(o,a,i,c,l,d){const u=d?.customSigner??n;if(!u)throw new Error("Signer not initialized");const h=await r(o),{accountNumber:m,...f}=await h.getSequence(a),g=f.sequence+(d?.incrementSequence??0),[p]=await u.getAccounts(),x=ni(lo(p.pubkey)),S=wa.SignMode.SIGN_MODE_EIP_191,I=i.map(y=>s.toAmino(y)),N=yn.makeSignDoc(I,c,o,l,m,g),{signature:C,signed:T}=await u.signAmino(a,N),R={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:T.msgs.map(y=>s.fromAmino(y)),memo:l}},B=e.encode(R),z=sr.Int53.fromString(T.fee.gas).toNumber(),j=sr.Int53.fromString(T.sequence).toNumber(),b=Is.makeAuthInfoBytes([{pubkey:x,sequence:j}],T.fee.amount,z,T.fee.granter,T.fee.payer,S);return st.TxRaw.fromPartial({bodyBytes:B,authInfoBytes:b,signatures:[V.fromBase64(C.signature)]})}}function es(){const e=ee(),{signMessageAsync:s}=de.useSignMessage(),n=_e();return _.useMemo(()=>new uo(e,r=>s({message:r}),n.restUrl),[e,s,n.restUrl])}const Zs=new Map,Xs=new Map;function ho(){const e=Te();return async s=>{if(Zs.has(s))return Zs.get(s);const{rpcUrl:n}=e(s),r=await nr.Comet38Client.create(new nr.HttpClient(n));return Zs.set(s,r),r}}function mo(){const e=Xt(),s=Ds(),n=es(),r=ee(),o=ho();return async a=>{const i=`${r}:${a}`;if(Xs.has(i))return Xs.get(i);if(!n)throw new Error("Signer not initialized");const c=await o(a),l=await Pe.SigningStargateClient.createWithSigner(c,n,{registry:e,aminoTypes:s,accountParser:ei,broadcastPollIntervalMs:500});return Xs.set(i,l),l}}function fo(){const{connector:e}=de.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new We.BrowserProvider(await e.getProvider())}}function _o(){const e=ee(),s=Te();return{fetchFeegrant:async(o,a)=>{if(!e)return null;const i=s(o),c=L.create({prefixUrl:i.restUrl});try{const{allowance:l}=await c.get(`cosmos/feegrant/v1beta1/allowance/${e}/${a}`).json();return l}catch{return null}},fetchGrants:async(o,a)=>{if(!e)return[];const i=s(o),c=L.create({prefixUrl:i.restUrl}),{grants:l}=await c.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:a}}).json();return l}}}function go(){const{privyContext:e}=X(),s=Fn();if(!(!e||!s))return e.wallets.find(n=>n.connectorType==="embedded")}function Rs(){const e=go();return e?.address?v.InitiaAddress(e.address).bech32:void 0}function po(){const e=go(),s=Rs(),n=Xt(),r=Te(),o=Ps();return async(a,i,c,l,d)=>{if(!e||!s)throw new Error("Embedded wallet not initialized");const u=[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:qn.MsgExec.fromPartial({grantee:s,msgs:c.map(f=>({typeUrl:f.typeUrl,value:n.encode(f)}))})}],h={...l,granter:i},m=new uo(s,e.sign,r(a).restUrl);return await o(a,s,u,h,d,{customSigner:m})}}const Yt=Ne.createQueryKeys("interwovenkit:autosign",{expirations:(e,s)=>[e,s],grants:(e,s)=>[e,s]});function Bs(){const e=X(),s=Zt(),{enableAutoSign:n,defaultChainId:r}=e;if(!n)return{[r]:[]};if(typeof n!="boolean")return n;switch(s.metadata?.minitia?.type){case"minievm":return{[r]:["/minievm.evm.v1.MsgCall"]};case"miniwasm":return{[r]:["/cosmwasm.wasm.v1.MsgExecuteContract"]};default:return{[r]:["/initia.move.v1.MsgExecute"]}}}function xo(){const{data:e}=On(),s=Bs();return async(n,r)=>{const o=r.every(i=>{const c=s[n];return c?c.includes(i.typeUrl):!1}),a=e?.isEnabledByChain[n]??!1;return o&&a}}function On(){const e=ee(),s=Rs(),n=Bs(),{fetchFeegrant:r,fetchGrants:o}=_o();return $.useQuery({queryKey:Yt.expirations(e,s).queryKey,queryFn:async()=>{if(!e||!s)return{expiredAtByChain:{},isEnabledByChain:{}};const a={};for(const[c,l]of Object.entries(n))try{const d=await o(c,s);if(!l.every(x=>d.some(S=>S.authorization?.msg===x))){a[c]=null;continue}const h=await r(c,s);if(!h){a[c]=null;continue}const m=d.filter(x=>l.includes(x.authorization.msg)).map(x=>x.expiration),f=h.allowance.expiration,g=[...m,f],p=Un(g);a[c]=p?new Date(p):void 0}catch{a[c]=null}const i={};for(const[c,l]of Object.entries(a))switch(l){case null:i[c]=!1;break;case void 0:i[c]=!0;break;default:i[c]=ke.isFuture(l);break}return{expiredAtByChain:a,isEnabledByChain:i}},staleTime:Q.INFINITY,retry:!1})}function oi(){const{data:e,refetch:s}=On();_.useEffect(()=>{if(!e)return;const n=new Date,r=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&ke.isFuture(c));if(r.length===0)return;const a=Un(r).getTime()-n.getTime();if(a<=0)return;const i=setTimeout(()=>{s()},a+100);return()=>clearTimeout(i)},[e,s])}function Un(e){return e.filter(s=>s!==void 0).toSorted((s,n)=>new Date(s).getTime()-new Date(n).getTime())[0]}const yo=_.createContext(null),Ms=()=>_.useContext(yo);class jo extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(s,n,r,o,a,i,c){super(s),this.name="MoveError",this.originalError=n,this.moduleAddress=r,this.moduleName=o,this.errorCode=a,this.errorCodeHex=i,this.isFromRegistry=c}}const ai=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,en=new Map;function ii(e){const s=e.match(ai);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 ci(e,s,n){const r=`${e}:${s}`;if(en.has(r))return en.get(r);try{const o=s==="0x1"?"0x1.json":`${e}/${s}.json`,a=`${n}/errors/${o}`,{errors:i={}}=await L.get(a).json();return en.set(r,i),i}catch{return null}}function li(e,s,n,r,o,a,i){return new jo(e,s,n,r,o,a,i)}async function At(e,s,n){if(!s.metadata?.is_l1&&s.metadata?.minitia?.type!=="minimove")return await He(e);const r=ii(e.message);if(!r)return await He(e);const o=await ci(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}`,c=o?.[r.moduleName]?.[r.errorCode],l=c||i,d=!!c;return li(l,e,r.moduleAddress,r.moduleName,r.errorCode,a,d)}const vo="approve",Fs=H.atom(),wo=H.atom(null);function bo(){const e=H.useAtomValue(Fs);if(!e)throw new Error("Tx request not found");return e}function Os(){const e=he(),s=ee(),{defaultChainId:n,registryUrl:r}=X(),o=Te(),{openDrawer:a,closeDrawer:i}=Ve(),{openModal:c,closeModal:l}=Ms(),d=H.useSetAtom(Fs),u=H.useSetAtom(wo),h=ho(),m=mo(),f=es(),g=Xt(),p=xo(),x=po(),S=Ps(),I=async({messages:j,memo:b,chainId:y=n})=>{try{return await(await m(y)).simulate(s,j,b)}catch(k){throw await At(k,o(y),r)}},N=async({messages:j,memo:b,chainId:y=n})=>{const k=await h(y),q=Pe.QueryClient.withExtensions(k,Pe.setupTxExtension),M=j.map(Z=>g.encodeAsAny(Z)),[E]=await f.getAccounts(),G=Qt.encodeSecp256k1Pubkey(E.pubkey),te=await m(y),{sequence:O}=await te.getSequence(s);return q.tx.simulate(M,b,G,O)},C=async({txRequest:j,broadcaster:b})=>{const k={...{memo:"",chainId:n,gas:j.gas||await I(j),gasAdjustment:Gt,gasPrices:null,spendCoins:[],internal:!1},...j};return new Promise((q,M)=>{d({txRequest:k,resolve:async G=>{try{const te=await m(k.chainId),O=await b(te,st.TxRaw.encode(G).finish());q(O),typeof k.internal=="string"&&e(k.internal)}catch(te){M(await At(te,o(k.chainId),r))}finally{E()}},reject:G=>{M(G),E()}}),k.internal?c({path:"/tx"}):a("/tx");const E=()=>{if(!k.internal){e("/blank"),i();return}l()}})},T=async j=>{const b=j.chainId??n;try{const y=await C({txRequest:j,broadcaster:async(k,q)=>await k.broadcastTxSync(q)});return j.internal&&typeof j.internal!="number"&&(u({txHash:y,chainId:b,status:"loading"}),z({txHash:y,chainId:j.chainId}).then(k=>{u({status:k.code===0?"success":"error",chainId:b,txHash:y})}).catch(()=>{u({status:"error",chainId:b,txHash:y})})),y}catch(y){throw j.internal&&typeof j.internal!="number"&&u({status:"error",chainId:b,error:y}),y}},P=(j,b=30*1e3,y=.5*1e3)=>C({txRequest:j,broadcaster:async(k,q)=>{const M=await k.broadcastTx(q,b,y);if(M.code!==0)throw new Error(M.rawLog);return M}}),R=async j=>{const b=j.chainId??n;try{const{messages:y,memo:k="",fee:q}=j,M=await m(b),G=await p(b,y)?await x(b,s,y,q,k):await S(b,s,y,q,k);return await M.broadcastTxSync(st.TxRaw.encode(G).finish())}catch(y){throw await At(y,o(b),r)}},B=async(j,b=30*1e3,y=.5*1e3)=>{const k=j.chainId??n;try{const{messages:q,memo:M="",fee:E}=j,G=await m(k),O=await p(k,q)?await x(k,s,q,E,M):await S(k,s,q,E,M),Z=await G.broadcastTx(st.TxRaw.encode(O).finish(),b,y);if(Z.code!==0)throw new Error(Z.rawLog);return Z}catch(q){throw await At(q,o(k),r)}},z=async({chainId:j=n,...b})=>{try{const y=await m(j);return await Co({...b,client:y})}catch(y){throw await At(y,o(j),r)}};return{estimateGas:I,simulateTx:N,requestTxSync:T,requestTxBlock:P,submitTxSync:R,submitTxBlock:B,waitForTxConfirmation:z}}async function Co({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 ts=H.atom(null);function Io(){const e=ee(),s=Bs(),{fetchFeegrant:n,fetchGrants:r}=_o();return async o=>{const{chainId:a,grantee:i}=o;if(!e)throw new Error("Granter wallet not initialized");const c=await n(a,i),l=await r(a,i),d=c?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:zr.MsgRevokeAllowance.fromPartial({granter:e,grantee:i})}]:[],u=s[a].filter(h=>l.some(m=>m?.authorization?.msg===h)).map(h=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:qn.MsgRevoke.fromPartial({granter:e,grantee:i,msgTypeUrl:h})}));return[...d,...u]}}function di(){const{privyContext:e}=X(),s=ee(),n=Rs(),r=Bs(),{requestTxBlock:o}=Os(),a=$.useQueryClient(),[i,c]=H.useAtom(ts),{closeDrawer:l}=Ve(),d=Io(),u=async()=>{if(n)return n;if(!e)throw new Error("Privy context not available");const h=await e.createWallet({createAdditional:!1});return v.InitiaAddress(h.address).bech32};return $.useMutation({mutationFn:async h=>{if(!i)throw new Error("No pending request");const{chainId:m}=i,f=await u();if(!s||!f)throw new Error("Wallets not initialized");const g=await d({chainId:m,grantee:f}),p=h===0?void 0:ke.addMilliseconds(new Date,h),x={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:zr.MsgGrantAllowance.fromPartial({granter:s,grantee:f,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:or.BasicAllowance.encode(or.BasicAllowance.fromPartial({expiration:p})).finish()}})},S=r[m].map(N=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:qn.MsgGrant.fromPartial({granter:s,grantee:f,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:rr.GenericAuthorization.encode(rr.GenericAuthorization.fromPartial({msg:N})).finish()},expiration:p}})})),I=[...g,x,...S];await o({messages:I,chainId:m,internal:!0})},onSuccess:async()=>{await a.invalidateQueries({queryKey:Yt.expirations._def}),i?.resolve()},onError:h=>{i?.reject(h)},onSettled:()=>{c(null),l()}})}function No(e){const s=X(),n=Rs(),r=e?.grantee||n,{requestTxBlock:o}=Os(),a=$.useQueryClient(),i=Io();return $.useMutation({mutationFn:async(c=s.defaultChainId)=>{if(!r)throw new Error("Wallets not initialized");const l=await i({chainId:c,grantee:r});await o({messages:l,chainId:c,internal:e?.internal})},onSuccess:async()=>{const c=[Yt.expirations._def,Yt.grants._def];for(const l of c)await a.invalidateQueries({queryKey:l})}})}function ui(){const{defaultChainId:e}=X(),{openDrawer:s}=Ve(),n=H.useSetAtom(ts),r=No(),{data:o={expiredAtByChain:{},isEnabledByChain:{}},isLoading:a}=On();return{...o,isLoading:a,enable:async(l=e)=>new Promise((d,u)=>{n({chainId:l,resolve:d,reject:u}),s("/autosign/enable")}),disable:async(l=e)=>{await r.mutateAsync(l)}}}const hi="INIT",mi="Initia";function Ln(e){return e.assets.reduce((s,{value:n})=>s+(n??0),0)}function fi(e){return e.assets.reduce((s,{quantity:n})=>s.plus(n),F(0)).toString()}function _i(e,s){return{symbol:s?.symbol??e,logoUrl:s?.logoUrl??Rn}}function dr(e){return w.pick(["chainId","name","logoUrl"],e)}function gi(e){return w.sortWith([w.descend(({symbol:s})=>s===hi),w.descend(Ln),w.descend(({assets:s})=>s.length),w.ascend(({symbol:s})=>s)])(e)}function pi(e){return w.sortWith([w.descend(({value:s})=>s??0),w.descend(({quantity:s})=>Number(s)),w.ascend(({chain:s})=>s.name)])(e)}function xi(e){return w.sortWith([w.descend(({chain:s})=>s.name===mi),w.ascend(({chain:s})=>s.name),w.ascend(({denom:s})=>s)])(e)}function yi(e,s){return w.sortWith([w.descend(({chainId:n})=>n===s),w.descend(w.prop("value"))])(e)}function ji(e,s,n,r,o){const a={};for(const u of e){const h=u.chainId,m=s[h]??[],f=n[h],g=r[h],p=[];for(const{amount:x,denom:S}of m){if(!F(x).gt(0))continue;const I=f?.find(R=>R.denom===S),N=g?.find(R=>R.id===S)?.price,C=I?.decimals??0,T=v.fromBaseUnit(x,{decimals:C}),P=N?F(T).times(N).toNumber():void 0;p.push({..._i(S,I),amount:x,denom:S,decimals:C,quantity:T,price:N,value:P,address:I?.address,unlisted:!I,chain:dr(u)})}a[h]=p}const i=new Map;for(const[u,h]of Object.entries(a)){if(h.length===0)continue;const m=e.find(g=>g.chainId===u);if(!m)continue;const f=h.reduce((g,{value:p})=>g+(p??0),0);i.set(u,{...dr(m),value:f})}const c=new Map;for(const u of Object.values(a))for(const h of u)if(!h.unlisted){const{symbol:m}=h,f=c.get(m)??[];c.set(m,[...f,h])}const l=[];for(const[u,h]of c){const m=w.head(h);if(!m)continue;const f=pi(h);l.push({symbol:u,logoUrl:m.logoUrl,assets:f})}const d=[];for(const u of Object.values(a))for(const h of u)h.unlisted&&d.push(h);return{chainsByValue:yi(Array.from(i.values()),o),assetGroups:gi(l),unlistedAssets:xi(d),totalValue:l.reduce((u,h)=>u+Ln(h),0)}}function zn(){const{defaultChainId:e}=X(),s=ae(),n=Ka(),r=Ua(),o=Ba(),a=s.map(m=>m.chainId),i=w.zipObj(a,n.map(w.prop("data"))),c=w.zipObj(a,r.map(w.prop("data"))),l=w.zipObj(a,o.map(w.prop("data"))),d=ji(s,i,c,l,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 ee(){const e=Us();return e?v.InitiaAddress(e).bech32:""}function Us(){const{address:e}=de.useAccount(),s=Fn();return!e||!s?"":v.InitiaAddress(e).hex}function Pt(){const e=Zt(),s=ee(),n=Us();return e.metadata?.minitia?.type==="minievm"?n:s}function So(){const e=Pt(),s=to();return $.useQuery({queryKey:$s.username(s.restUrl,e).queryKey,queryFn:()=>s.getUsername(e),enabled:!!e,staleTime:Q.MINUTE})}function xe(){const e=Pt(),s=ee(),n=Us(),{data:r}=So(),o=es(),a=Mn(),i=ui(),{isDrawerOpen:c,openDrawer:l}=Ve(),d=()=>{l("/")},u=()=>{l("/connect")},h=g=>{l("/bridge",g)},m=Os();return{address:e,initiaAddress:s,hexAddress:n,username:r,offlineSigner:o,isConnected:!!e,isOpen:c,openConnect:u,openWallet:d,openBridge:h,disconnect:a,autoSign:i,...m}}const vi="_status_tn9m1_1",wi="_error_tn9m1_9",ur={status:vi,error:wi},ne=({error:e,children:s})=>t.jsx("p",{className:D(ur.status,{[ur.error]:e}),children:s}),ye=({errorBoundaryProps:e={fallbackRender:({error:r})=>t.jsx(ne,{error:!0,children:r.message})},suspenseFallback:s=t.jsx(ne,{children:"Loading..."}),children:n})=>t.jsx(Kr.ErrorBoundary,{...e,children:t.jsx(_.Suspense,{fallback:s,children:n})});function bi(){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=>v.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[c,l]of Object.entries(i)){const d=`${r}:${o(c)}`;localStorage.setItem(d,l)}localStorage.removeItem(n)}catch{}}}const Re=Ne.createQueryKeys("interwovenkit:skip",{chains:null,assets:e=>[e],asset:(e,s)=>[e,s],balances:(e,s)=>[e,s],route:(e,s)=>[e,s],routeErrorInfo:e=>[e],txTrack:(e,s)=>[e,s],txStatus:(e,s)=>[e,s]});function Ye(){const{routerApiUrl:e}=X();return _.useMemo(()=>L.create({prefixUrl:e}),[e])}function qt(e){const s=Ye(),n=$.useQueryClient(),{data:r}=$.useSuspenseQuery({queryKey:Re.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(Re.asset(e,i.denom).queryKey,i);return a.toSorted(w.descend(i=>i.symbol==="INIT"))},staleTime:Q.MINUTE});return r}function Ao(e){const s=qt(e);return n=>{const r=s.find(o=>o.denom===n);if(!r)throw new Error(`Asset not found: ${n}`);return r}}function Qe(e,s){return Ao(s)(e)}function ko(){const e=ae();return s=>e.some(n=>n.chain_id===s)}function ss(){const e=ko();return s=>e(s.chain_id)?"initia":s.chain_type}function Jt(e){return ss()(e)}function Kn(){const e=Ye(),{data:s}=$.useSuspenseQuery({queryKey:Re.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:n})=>w.sortWith([w.descend(({chain_name:r})=>r==="initia"),w.ascend(({pretty_name:r})=>r)],n),staleTime:Q.MINUTE});return s}function vt(){const e=Kn(),s=Vr();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 Be(e){return vt()(e)}const Ci=()=>(Ga(),Va(),null),Ii="_loader_1vxch_1",Ni={loader:Ii},wt=({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:Ni.loader,style:r})},Si="_button_1q027_1",Ai="_outline_1q027_28",ki="_sm_1q027_46",$i="_full_1q027_53",Ti="_small_1q027_57",Ei="_unpadded_1q027_88",gt={button:Si,outline:Ai,sm:ki,full:$i,small:Ti,unpadded:Ei},$o=e=>{const{sm:s,fullWidth:n,loading:r,className:o,children:a,disabled:i,...c}=e;return t.jsx("button",{...c,className:D(gt.button,{[gt.sm]:s,[gt.full]:n},o),disabled:!!r||i,children:r?t.jsxs(t.Fragment,{children:[t.jsx(wt,{color:"currentColor",size:16}),typeof r=="string"&&t.jsx("span",{className:gt.loading,children:r})]}):a})},qi=({className:e,...s})=>t.jsx($o,{...s,className:D(gt.outline,e)}),Di=({className:e,unpadded:s,...n})=>t.jsx("button",{...n,className:D(gt.small,{[gt.unpadded]:s},e)}),J={White:$o,Outline:qi,Small:Di},Pi="_footer_1vp4h_1",Ri="_actions_1vp4h_10",hr={footer:Pi,actions:Ri},ie=({extra:e,className:s,children:n})=>t.jsxs("footer",{className:D(hr.footer,s),children:[e,t.jsx("div",{className:hr.actions,children:n})]}),Bi="_scrollable_13su7_1",Mi={scrollable:Bi},Fe=({className:e,children:s,ref:n})=>t.jsx("div",{ref:n,className:D(Mi.scrollable,e),children:s});function Ls(){return Ie.useMediaQuery("(max-width: 576px)")}const wn="interwoven-kit";function To(){const e=document.querySelector(wn)||document.body.appendChild(document.createElement(wn));return e.shadowRoot||e.attachShadow({mode:"open"})}function Fi(){const{theme:e,container:s}=X();return _.useEffect(()=>{document.querySelector(wn)?.setAttribute("data-theme",e)},[e]),s??To()}function Oi(e){const s=To(),n=document.createElement("style");n.textContent=e,s.appendChild(n)}const Wn=_.createContext(null);function yt(){const{container:e}=_.useContext(Wn);return e}function Eo(e){const s=yt();return s?getComputedStyle(s).getPropertyValue(e):""}function Ui(){return Ie.useScrollLock(),null}function Li(e){return/^[A-F0-9]{64}$/i.test(e)}function zi(e,s){const{txHash:n,accountAddress:r,pathSuffix:o}=s;if(n)return Li(n)?w.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,n):void 0;if(r){if(!v.InitiaAddress.validate(r))return;const i=w.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,r);return i&&o?i+o:i}}function Ki(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 Wi="_link_j1lkz_1",mr={link:Wi},zs=({chainId:e,txHash:s,accountAddress:n,pathSuffix:r,...o})=>{const{showIcon:a,className:i,children:c,onClick:l,...d}=o,u=Me(e),h=zi(u,{txHash:s,accountAddress:n,pathSuffix:r}),m=s?v.truncate(s):n?v.truncate(n):"",f=c??m;return h?t.jsxs("a",{...d,href:Ia(Ki(h)),className:D(mr.link,i),onClick:l,target:"_blank",children:[f,a&&t.jsx(A.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:D(mr.link,i),children:f})},qo=_.createContext(null),Hn=()=>_.useContext(qo),Hi=()=>{const[e,s]=H.useAtom(wo),{showNotification:n,updateNotification:r,hideNotification:o}=Hn();return _.useEffect(()=>{if(!e)return;const{status:a,chainId:i,txHash:c,error:l}=e,d=l?l.message:c?t.jsx(zs,{txHash:c,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},vs=({value:e,children:s})=>{const[n,r]=_.useState(!1);return s({copy:async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1e3)}catch{}},copied:n})},Qi="_placeholder_10r3x_1",Gi="_logo_10r3x_5",fr={placeholder:Qi,logo:Gi},Y=({src:e,alt:s,placeholder:n,classNames:r,style:o,logo:a,...i})=>{const[c,l]=_.useState(void 0),{width:d,height:u}=i,h=n??t.jsx("div",{className:D(fr.placeholder,r?.placeholder),style:{width:d,height:u,...o}});return!e||c===e?h:t.jsx("img",{...i,className:D(i.className,{[fr.logo]:a}),style:{width:d,height:u,...o},src:e,alt:s,loading:"lazy",onError:()=>l(e)})},Vi="_header_1q8ju_1",Yi="_account_1q8ju_17",Ji="_name_1q8ju_28",Zi="_address_1q8ju_32",Xi="_icon_1q8ju_36",ec="_copied_1q8ju_43",tc="_button_1q8ju_58",sc="_settings_1q8ju_69",nc="_disconnect_1q8ju_73",rc="_label_1q8ju_83",oc="_expanded_1q8ju_91",je={header:Vi,account:Yi,name:Ji,address:Zi,icon:Xi,copied:ec,button:tc,settings:sc,disconnect:nc,label:rc,expanded:oc},ac=()=>{const{connector:e}=de.useAccount(),s=Mn(),{address:n,username:r}=xe(),o=r??n,[a,i]=_.useState(!1),c=_.useRef(null),l=rt.useSpring({width:a?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{a?s():i(!0)},u=()=>{a&&(c.current=setTimeout(()=>{i(!1)},500))},h=()=>{c.current&&(clearTimeout(c.current),c.current=null)};if(_.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),!e||!n)return null;const m=e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon;return t.jsxs("header",{className:je.header,children:[t.jsx(vs,{value:n,children:({copy:f,copied:g})=>t.jsxs("button",{className:D(je.account,{[je.copied]:g}),onClick:f,children:[t.jsx(Y,{src:m,width:18,height:18}),t.jsx("div",{className:je.address,children:v.truncate(n)}),t.jsx("div",{className:je.name,children:v.truncate(o)}),t.jsx(A.IconCopy,{className:je.icon,size:12}),g?"Copied!":""]})}),t.jsx(Et,{to:"/settings",className:D(je.button,je.settings),"aria-label":"Open settings",children:t.jsx(A.IconSettingFilled,{size:16})}),t.jsxs(rt.animated.button,{className:D(je.button,je.disconnect,{[je.expanded]:a}),style:l,onClick:d,onMouseLeave:u,onMouseEnter:h,children:[t.jsx(A.IconSignOut,{size:16}),t.jsx("span",{className:je.label,children:"Disconnect"})]})]})},ic="_overlay_jij9g_1",cc="_content_jij9g_28",lc="_inner_jij9g_60",tn={overlay:ic,content:cc,inner:lc},dc=({children:e})=>{const{isDrawerOpen:s,closeDrawer:n}=Ve(),{setContainer:r}=_.useContext(Wn),o=Ls(),a=Fi(),i=H.useAtomValue(Fs),c=H.useAtomValue(ts),l=$.useIsMutating({mutationKey:[vo]}),d=()=>{const g=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";n(),i?.reject(new Error(g)),c?.reject(new Error("User rejected"))},u=Es(),h=he(),m=$.useQueryClient(),f={fallbackRender:({error:g,resetErrorBoundary:p})=>{const x=()=>{u==="/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)),h("/"),m.clear(),p()};return t.jsxs(Fe,{children:[t.jsx(ne,{error:!0,children:g.message}),t.jsx(ie,{children:t.jsx(J.White,{onClick:x,children:"Retry"})})]})}};return t.jsx(Ae.Dialog.Root,{open:s,onOpenChange:g=>!g&&d(),modal:!1,children:t.jsxs(Ae.Dialog.Portal,{container:a,children:[o&&t.jsx(Ae.Dialog.Backdrop,{className:tn.overlay,onClick:d,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(Ae.Dialog.Popup,{className:tn.content,children:t.jsxs("div",{className:D(tn.inner,"body"),ref:r,children:[o&&t.jsx(Ui,{}),t.jsx(Hi,{}),t.jsx(ac,{}),t.jsx(ye,{errorBoundaryProps:f,children:e})]})})]})})},Do=_.createContext(!1),uc="_overlay_1iyfl_1",hc="_fullscreen_1iyfl_15",mc="_content_1iyfl_19",fc="_header_1iyfl_56",_c="_title_1iyfl_65",gc="_close_1iyfl_70",lt={overlay:uc,fullscreen:hc,content:mc,header:fc,title:_c,close:gc},Po=({title:e,children:s,trigger:n,className:r,open:o,onOpenChange:a})=>{const i=yt(),c=_.useContext(Do);return i?t.jsxs(Ae.Dialog.Root,{open:o,onOpenChange:a,modal:!1,children:[n&&t.jsx(Ae.Dialog.Trigger,{className:r,children:n}),t.jsxs(Ae.Dialog.Portal,{container:i,children:[t.jsx(Ae.Dialog.Backdrop,{className:D(lt.overlay,{[lt.fullscreen]:c}),onClick:()=>a(!1),forceRender:!0}),t.jsxs(Ae.Dialog.Popup,{className:D(lt.content,{[lt.fullscreen]:c}),children:[e&&t.jsxs("header",{className:lt.header,children:[t.jsx(Ae.Dialog.Title,{className:lt.title,children:e}),t.jsx(Ae.Dialog.Close,{className:lt.close,children:t.jsx(A.IconClose,{size:20})})]}),s]})]})]}):null},bn=({children:e})=>{const s=_.useRef(null),[n,r]=_.useState(0),o=rt.useSpring({height:n,config:{tension:500,friction:30,clamp:!0}});return _.useEffect(()=>{if(s.current){const{height:a}=s.current.getBoundingClientRect();r(a)}},[e]),e?t.jsx(rt.animated.div,{style:{overflow:"hidden",...o},children:t.jsx("div",{ref:s,children:e})}):null},pc="_help_qcmtq_1",xc="_icon_qcmtq_10",yc="_info_qcmtq_19",jc="_warning_qcmtq_23",vc="_error_qcmtq_27",wc="_success_qcmtq_33",sn={help:pc,icon:xc,info:yc,warning:jc,error:vc,success:wc},kt=({level:e,className:s,mt:n=8,children:r})=>{if(!r)return null;const o=()=>{switch(e){case"loading":return t.jsx(wt,{size:12});case"info":return t.jsx(A.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(A.IconWarningFilled,{size:12});default:return t.jsx(A.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:D(sn.help,e&&sn[e],s),style:{marginTop:n},children:[t.jsx("div",{className:sn.icon,children:o()}),r]})},bc="_stack_a6m7u_1",Cc="_help_a6m7u_6",Ic="_info_a6m7u_14",Nc="_warning_a6m7u_19",Sc="_error_a6m7u_24",Ac="_success_a6m7u_29",Cn={stack:bc,help:Cc,info:Ic,warning:Nc,error:Sc,success:Ac},kc=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(bn,{children:t.jsx("div",{className:Cn.stack,children:e})}),oe=({mt:e=0,...s})=>t.jsx(kt,{...s,className:D(Cn.help,Cn[s.level]),mt:e});oe.Stack=kc;const $c="_root_16p5j_1",Tc="_item_16p5j_10",Ec="_chevron_16p5j_14",qc="_trigger_16p5j_19",Dc="_content_16p5j_39",Ft={root:$c,item:Tc,chevron:Ec,trigger:qc,content:Dc};function Pc(e){const{list:s,getKey:n,renderHeader:r,renderContent:o,footer:a,...i}=e;return t.jsxs(se.Accordion.Root,{className:Ft.root,type:"multiple",...i,children:[s.map((c,l)=>t.jsxs(se.Accordion.Item,{className:Ft.item,value:n?.(c)??String(l),children:[t.jsx(se.Accordion.Header,{children:t.jsxs(se.Accordion.Trigger,{className:Ft.trigger,children:[r(c),t.jsx(A.IconChevronDown,{className:Ft.chevron,size:16})]})}),t.jsx(se.Accordion.Content,{className:Ft.content,children:o(c)})]},n?.(c)??l)),a]})}const Rc=10;function Ro(){const e=ee();return(s,n)=>$.queryOptions({queryKey:$s.txs(s.indexerUrl,e).queryKey,queryFn:async()=>{if(!n.enabled)return[];const r={"pagination.reverse":!0,"pagination.limit":Rc},{txs:o}=await L.create({prefixUrl:s.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:r}).json();return o},staleTime:Q.SECOND})}function Bc(e,s){const n=Ro();return $.useSuspenseQuery(n(e,s))}function Mc(e,s){const n=e.flatMap((r,o)=>(s[o]??[]).map(i=>({...i,chain:r})));return w.sortWith([w.descend(r=>new Date(r.timestamp).getTime())])(n)}const Fc=()=>{const e=ae(),s=Ro(),n=$.useQueries({queries:e.map(i=>s(i,{enabled:!0}))}),r=n.map(w.prop("data")),o=Mc(e,r),a=n.some(i=>i.isLoading);return{activities:o,isLoading:a}};function Bo(e){const{data:s}=$.useSuspenseQuery({queryKey:As.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:r}=await L.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return r.toSorted(w.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const i=o==="uinit"?1:Hr;return{amount:F(a).times(i).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:r})=>{if(w.isNil(r))throw new Error(`${n} has no price`);return{amount:String(r),denom:n}})},staleTime:Q.SECOND});return s}function Mo(e){const s=ee(),{data:n}=Bc(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=>v.InitiaAddress.equals(s,We.computeAddress(`0x${V.toHex(jn.Secp256k1.uncompressPubkey(V.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??r}catch{return r}}const Oc="_trigger_u613p_1",Uc="_icon_u613p_18",Lc="_content_u613p_27",zc="_item_u613p_36",Kc="_itemText_u613p_52",Wc="_itemIndicator_u613p_57",Hc="_active_u613p_60",Xe={trigger:Oc,icon:Uc,content:Lc,item:zc,itemText:Kc,itemIndicator:Wc,active:Hc};function Fo({options:e,value:s,onChange:n,classNames:r}){const o=yt(),a=e.find(c=>c.value===s);if(!a)throw new Error("Selected option not found");const i=c=>{const l=e.find(d=>String(d.value)===c);if(!l)throw new Error(`Option not found: ${c}`);n(l.value)};return t.jsxs(Le.Select.Root,{value:String(s),onValueChange:i,modal:!1,children:[t.jsxs(Le.Select.Trigger,{className:D(Xe.trigger,r?.trigger),children:[t.jsx(Le.Select.Value,{children:a.triggerLabel||a.label}),t.jsx(Le.Select.Icon,{className:Xe.icon,children:t.jsx(A.IconChevronDown,{size:12})})]}),t.jsx(Le.Select.Portal,{container:o,children:t.jsx(Le.Select.Positioner,{className:Xe.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(Le.Select.Popup,{className:Xe.popup,children:e.map(c=>t.jsxs(Le.Select.Item,{className:D(Xe.item,r?.item),value:String(c.value),children:[t.jsx(Le.Select.ItemText,{className:D(Xe.itemText,r?.itemText),children:c.label}),t.jsx(A.IconCheck,{size:12,className:D(Xe.itemIndicator,{[Xe.active]:c.value===s})})]},String(c.value)))})})})]})}const Qc="_root_1t37n_1",Gc="_trigger_1t37n_7",Vc="_item_1t37n_11",Yc="_itemText_1t37n_17",_r={root:Qc,trigger:Gc,item:Vc,itemText:Yc},Jc=({options:e,value:s,onChange:n})=>{const{txRequest:r}=bo(),o=Me(r.chainId),a=Ge(o),i=(g,p)=>{if(v.formatAmount(g,{decimals:p})==="0.000000")return 8},c=({amount:[{amount:g,denom:p}]})=>{if(F(g).isZero())return"0";const{symbol:x,decimals:S}=a(p),I=i(g,S);return`${v.formatAmount(g,{decimals:S,dp:I})} ${x}`},l=e.map(g=>{const[{denom:p}]=g.amount,{symbol:x}=a(p);return{value:p,label:c(g),triggerLabel:x}});if(e.length===1)return t.jsx("span",{className:"monospace",children:c(e[0])});const d=e.find(g=>g.amount[0].denom===s);if(!d)throw new Error("Fee option not found");const[{amount:u,denom:h}]=d.amount,{decimals:m}=a(h),f=i(u,m);return t.jsxs("div",{className:_r.root,children:[t.jsx("span",{className:"monospace",children:v.formatAmount(u,{decimals:m,dp:f})}),t.jsx(Fo,{options:l,value:s,onChange:n,classNames:_r})]})},Zc="_root_16nr2_1",Xc="_trigger_16nr2_5",el="_chevron_16nr2_13",tl="_panel_16nr2_27",sl="_details_16nr2_39",nl="_row_16nr2_48",Nt={root:Zc,trigger:Xc,chevron:el,panel:tl,details:sl,row:nl},rl=({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),c=a===6?void 0:8;return t.jsxs(Js.Collapsible.Root,{className:Nt.root,children:[t.jsxs(Js.Collapsible.Trigger,{className:Nt.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(A.IconChevronDown,{className:Nt.chevron,size:16})]}),t.jsx(Js.Collapsible.Panel,{className:Nt.panel,children:t.jsx("div",{className:Nt.details,children:i.map(({label:l,value:d})=>t.jsxs("div",{className:Nt.row,children:[t.jsx("span",{children:l}),t.jsxs("span",{children:[v.formatAmount(d,{decimals:a,dp:c})," ",o]})]},l))})})]})};function ws(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?V.toBase64(e):Array.isArray(e)?`[${e.map(ws).join(",")}]`:JSON.stringify(e,(s,n)=>typeof n=="bigint"?n.toString():n);default:return"unknown"}}const ol="_container_1xzyq_1",al="_toggle_1xzyq_5",il="_list_1xzyq_11",cl="_arg_1xzyq_16",ll="_type_1xzyq_21",Ot={container:ol,toggle:al,list:il,arg:cl,type:ll},dl=Ne.createQueryKeys("interwovenkit:move",{abi:(e,s,n,r)=>[e,s,n,r]}),ul=({type:e,arg:s})=>ws(v.resolveBcsType(e).parse(s)),hl=({msg:e,chainId:s,fallback:n})=>{const[r,o]=Ie.useToggle(!1),{restUrl:a}=Me(s),{moduleAddress:i,moduleName:c,functionName:l,args:d}=e,{data:u}=$.useQuery({queryKey:dl.abi(a,i,c,l).queryKey,queryFn:async()=>{const m=await L.create({prefixUrl:a}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),g=JSON.parse(m.module.abi).exposed_functions.find(({name:p})=>p===l);if(!g)throw new Error(`Function ${l} not found in module ${c}`);return g.params.filter(p=>!p.startsWith("&"))},staleTime:Q.INFINITY});if(!u)return n;const h=(m,f)=>{const g=u[f];return t.jsxs("div",{className:Ot.arg,children:[t.jsx("div",{className:Ot.type,children:g}),t.jsx(Kr.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(ul,{type:g,arg:m})})]},f)};return t.jsxs("div",{className:Ot.container,children:[t.jsx(J.Small,{className:Ot.toggle,onClick:o,disabled:!u,children:r?"Encode":"Decode"}),r?t.jsx("div",{className:Ot.list,children:d.map(h)}):n]})},ml="_list_oip9m_1",fl="_key_oip9m_9",_l="_value_oip9m_14",nn={list:ml,key:fl,value:_l},gl=({message:e,chainId:s})=>{const{typeUrl:n,value:r}=e;return t.jsx("div",{className:nn.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{children:[t.jsx("div",{className:nn.key,children:o}),t.jsx("div",{className:nn.value,children:n==="/initia.move.v1.MsgExecute"&&o==="args"?t.jsx(hl,{msg:r,chainId:s,fallback:ws(a)}):ws(a)})]},o))})},pl="_item_1n572_1",xl="_title_1n572_10",yl="_content_1n572_14",rn={item:pl,title:xl,content:yl},on=({title:e,content:s})=>t.jsxs("div",{className:rn.item,children:[t.jsx("div",{className:rn.title,children:e}),t.jsx("div",{className:rn.content,children:s})]});function $e(e){if(e&&F(e).gt(0)&&F(e).lt(.01))return"<$0.01";const s=v.formatNumber(e,{dp:2});return s?`$${s}`:""}function Oo(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(c=>c.key==="spender")?.value,i=r.attributes.find(c=>c.key==="amount")?.value;if(a===s&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=n[l]||BigInt(0);n[l]=d-BigInt(c)}}}if(r.type==="coin_received"){const a=r.attributes.find(c=>c.key==="receiver")?.value,i=r.attributes.find(c=>c.key==="amount")?.value;if(a===s&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=n[l]||BigInt(0);n[l]=d+BigInt(c)}}}}return Object.entries(n).filter(([,r])=>r!==BigInt(0)).map(([r,o])=>({amount:o.toString(),denom:r}))}function Uo(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(l=>l.key==="type_tag")?.value,i=r.attributes.find(l=>l.key==="data")?.value;if(!a||!i)continue;let c;try{c=JSON.parse(i)}catch{continue}if(a==="0x1::fungible_asset::WithdrawEvent"){const l=c.store_addr,d=c.amount,u=c.metadata_addr;if(l&&d&&u&&v.createUserDerivedObjectAddress(s,u)===l){const m=n[u]||BigInt(0);n[u]=m-BigInt(d)}}if(a==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,d=c.amount,u=c.metadata_addr;if(l&&d&&u&&v.createUserDerivedObjectAddress(s,u)===l){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 Lo=({metadata:e,chain:s,children:n})=>{const{restUrl:r}=s,{data:o}=$.useSuspenseQuery({queryKey:js.denom(r,e).queryKey,queryFn:()=>L.create({prefixUrl:r}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:a})=>a,staleTime:Q.INFINITY});return n(o)},jl="_root_1p8a4_1",vl="_title_1p8a4_8",wl="_changes_1p8a4_14",bl="_change_1p8a4_14",Cl="_amount_1p8a4_35",Il="_text_1p8a4_42",Nl="_value_1p8a4_49",pt={root:jl,title:vl,changes:wl,change:bl,amount:Cl,text:Il,value:Nl},zo=({amount:e,asset:s,price:n})=>{const{denom:r,symbol:o,decimals:a,logoUrl:i}=s,c=v.formatAmount(e,{decimals:a}),l=n&&F(v.fromBaseUnit(e,{decimals:a})).times(n).abs();return t.jsxs("div",{className:pt.change,children:[t.jsxs("div",{className:pt.amount,children:[t.jsx(Y,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:pt.text,children:[c," ",o||r]})]}),l&&t.jsx("div",{className:pt.value,children:$e(l)})]})},Sl=({changes:e,chain:s})=>{const n=Ge(s),{data:r}=ks(s);return e.map(({amount:o,denom:a},i)=>{const c=n(a),l=r?.find(({id:d})=>d===a)?.price;return t.jsx(zo,{amount:o,asset:c,price:l},i)})},Al=({changes:e,chain:s})=>{const n=Ge(s),{data:r}=ks(s);return e.map(({amount:o,metadata:a},i)=>t.jsx(Lo,{metadata:a,chain:s,children:c=>{const l=r?.find(({id:d})=>d===c)?.price;return t.jsx(zo,{amount:o,asset:n(c),price:l})}},i))};function kl(e,s){return typeof s=="bigint"?s.toString():s}const $l=Ne.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,kl)]}),Tl=({messages:e,memo:s,chainId:n})=>{const{initiaAddress:r,hexAddress:o}=xe(),a=Me(n),{simulateTx:i}=Os(),{data:c}=$.useSuspenseQuery({queryKey:$l.simulate({messages:e,memo:s,chainId:n}).queryKey,queryFn:()=>i({messages:e,memo:s,chainId:n}),staleTime:Q.SECOND}),l=m=>t.jsxs("div",{className:pt.root,children:[t.jsx("h2",{className:pt.title,children:"Estimated changes"}),t.jsx("div",{className:pt.changes,children:m})]});if(!c)return null;const d=c.result?.events??[];if(d.length===0)return null;if(a.metadata?.is_l1||a.metadata?.minitia?.type==="minimove"){const m=Uo(d,o),[f]=gr(m);return f.length===0?null:l(t.jsx(Al,{changes:f,chain:a}))}const u=Oo(d,r),[h]=gr(u);return h.length===0?null:l(t.jsx(Sl,{changes:h,chain:a}))};function gr(e){return w.partition(s=>new F(s.amount).isNegative(),e)}const El="_title_1d032_1",ql="_meta_1d032_7",Dl="_footer_1d032_14",Pl="_rejectButton_1d032_19",cs={title:El,meta:ql,footer:Dl,rejectButton:Pl},Ko=()=>{const{txRequest:e,resolve:s,reject:n}=bo(),{messages:r,memo:o,chainId:a,gas:i,gasAdjustment:c,spendCoins:l}=e,d=ee(),u=Ps(),h=Me(a),m=Bn(h),f=Bo(h),g=Mo(h),p=Ge(h),x=xo(),S=po(),I=(e.gasPrices??f).map(({amount:y,denom:k})=>Pe.calculateFee(Math.ceil(i*c),Pe.GasPrice.fromString(y+k))),N=I.map(y=>y.amount[0]),C=y=>{const k=m.find(Z=>Z.denom===y)?.amount??"0",q=N.find(Z=>Z.denom===y)?.amount??"0",M=l.filter(Z=>Z.denom===y).reduce((Z,Ue)=>F(Z).plus(Ue.amount),F("0")),E=F(q).plus(M),G=F(k).gte(E),{symbol:te,decimals:O}=p(y);return{symbol:te,decimals:O,spend:M.gt(0)?M.toFixed():null,fee:q,total:E.toFixed(),balance:k,isSufficient:G}},T=()=>{if(g&&C(g).isSufficient)return g;for(const{denom:y}of N)if(C(y).isSufficient)return y;return N[0]?.denom},[P,R]=_.useState(T),{mutate:B,isPending:z}=$.useMutation({mutationKey:[vo],mutationFn:async()=>{const y=I.find(M=>M.amount[0].denom===P);if(!y)throw new Error("Fee not found");const q=!e.internal&&await x(a,r)?await S(a,d,r,y,o||""):await u(a,d,r,y,o);await s(q)},onError:async y=>{n(y)}}),j=C(P),b=!j.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(Fe,{children:[t.jsx("h1",{className:cs.title,children:"Confirm tx"}),t.jsxs("div",{className:cs.meta,children:[t.jsx(on,{title:"Chain",content:a}),t.jsx(on,{title:"Tx fee",content:t.jsx(Jc,{options:I,value:P,onChange:R})}),o&&t.jsx(on,{title:"Memo",content:o}),b&&t.jsx(oe,{level:"error",children:t.jsx(rl,{...j})})]}),t.jsx(Tl,{messages:r,memo:o,chainId:a}),t.jsx(Pc,{list:r,renderHeader:({typeUrl:y})=>Ns.sentenceCase(y.split(".").pop().replace(/^Msg/,"")),renderContent:y=>t.jsx(gl,{message:y,chainId:a})})]}),t.jsxs(ie,{className:cs.footer,children:[t.jsx(J.Outline,{onClick:()=>n(new Error("User rejected")),disabled:z,className:cs.rejectButton,children:t.jsx(A.IconClose,{size:16})}),t.jsx(J.White,{onClick:()=>B(),disabled:b,loading:z,children:"Approve"})]})]})},Rl=({children:e})=>{const[{title:s,content:n,path:r},o]=_.useState({}),[a,i]=_.useState(!1),c=H.useAtomValue(Fs),l=_.useCallback(h=>{o(h),i(!0)},[]),d=_.useCallback(()=>{o({}),i(!1)},[]),u=_.useCallback(h=>{h||(c?.reject(new Error("User rejected")),o({})),i(h)},[c]);return t.jsxs(yo.Provider,{value:{openModal:l,closeModal:d},children:[e,t.jsx(Po,{title:s,open:a,onOpenChange:u,children:t.jsx(ye,{children:r==="/tx"?t.jsx(Ko,{}):n})})]})},Bl="_container_1w1hx_1",Ml="_toast_1w1hx_11",Fl="_info_1w1hx_24",Ol="_success_1w1hx_28",Ul="_error_1w1hx_32",Ll="_icon_1w1hx_37",zl="_content_1w1hx_45",Kl="_title_1w1hx_48",Wl="_description_1w1hx_53",Hl="_close_1w1hx_75",et={container:Bl,toast:Ml,info:Fl,success:Ol,error:Ul,icon:Ll,content:zl,title:Kl,description:Wl,close:Hl},Ql=({notification:e,onClose:s,...n})=>{const r=rt.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(wt,{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:c,title:l,description:d}=i,u=o(c);return t.jsx(rt.animated.div,{style:a,className:et.container,children:t.jsxs("div",{className:D(et.toast,c&&et[c]),...n,children:[u&&t.jsx("div",{className:et.icon,children:u}),t.jsxs("div",{className:et.content,children:[t.jsx("p",{className:et.title,children:l}),d&&t.jsx("div",{className:et.description,children:d})]}),t.jsx("button",{className:et.close,onClick:s,children:t.jsx(A.IconClose,{size:14})})]})})})},an=5e3,Gl=({children:e})=>{const s=yt(),[n,r]=_.useState(null),o=_.useRef(null),a=_.useRef(!1),i=()=>{o.current&&(clearTimeout(o.current),o.current=null)},c=_.useCallback(()=>{i(),r(null)},[]),l=_.useCallback(m=>{i(),r({...m,id:ar.nanoid()}),m.autoHide&&!a.current&&(o.current=setTimeout(()=>c(),an))},[c]),d=_.useCallback(m=>{i(),r(f=>f?{...f,...m}:{...m,id:ar.nanoid()}),m.autoHide&&!a.current&&(o.current=setTimeout(()=>c(),an))},[c]),u=()=>{i(),a.current=!0},h=()=>{i(),a.current=!1,n?.autoHide&&(o.current=setTimeout(()=>c(),an))};return _.useEffect(()=>()=>i(),[]),t.jsxs(qo.Provider,{value:{showNotification:l,updateNotification:d,hideNotification:c},children:[e,s&&Na.createPortal(t.jsx(Ql,{notification:n,onClose:c,onMouseEnter:u,onMouseLeave:h}),s)]})},Vl=({children:e})=>{const[s,n]=_.useState(null);return t.jsx(Wn.Provider,{value:{container:s,setContainer:n},children:e})},Wo=[{value:10*io,label:"for 10 minutes"},{value:co,label:"for 1 hour"},{value:lr,label:"for 1 day"},{value:7*lr,label:"for 7 days"},{value:0,label:"until revoked"}],Yl=Wo[0].value,Jl="_container_1422v_1",Zl="_title_1422v_7",Xl="_description_1422v_14",ed="_sectionTitle_1422v_20",td="_websiteInfo_1422v_27",sd="_favicon_1422v_37",nd="_websiteTitle_1422v_42",rd="_websiteHost_1422v_48",od="_warningContent_1422v_54",ad="_ignoreButton_1422v_61",id="_infoList_1422v_65",cd="_infoItem_1422v_75",ld="_label_1422v_84",dd="_infoValue_1422v_94",ud="_durationTrigger_1422v_100",hd="_durationItem_1422v_101",md="_featureList_1422v_105",fd="_featureItem_1422v_113",_d="_checkIcon_1422v_123",gd="_learnMoreLink_1422v_127",pd="_feedbackContainer_1422v_140",xd="_footer_1422v_146",W={container:Jl,title:Zl,description:Xl,sectionTitle:ed,websiteInfo:td,favicon:sd,websiteTitle:nd,websiteHost:rd,warningContent:od,ignoreButton:ad,infoList:id,infoItem:cd,label:ld,infoValue:dd,durationTrigger:ud,durationItem:hd,featureList:md,featureItem:fd,checkIcon:_d,learnMoreLink:gd,feedbackContainer:pd,footer:xd},yd=Ne.createQueryKeys("interwovenkit:account",{info:(e,s)=>({queryKey:[e,s],queryFn:async()=>{const n=L.create({prefixUrl:e}),r=`cosmos/auth/v1beta1/account_info/${s}`;return n.get(r).json()}})}),jd=()=>{const[e,s]=_.useState(Yl),[n,r]=H.useAtom(ts),[o,a]=_.useState(!1),i=Te(),c=ae(),{address:l,username:d}=xe(),{mutate:u,isPending:h}=di(),{closeDrawer:m}=Ve();if(!n)throw new Error("Pending request not found");const{logoUrl:f,name:g,restUrl:p}=i(n.chainId),{data:x,isLoading:S}=$.useQuery(yd.info(p,l)),I={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},N=c.some(R=>{if(!R.website)return!1;const B=pr(new URL(R.website).hostname),z=pr(window.location.hostname);return B===z}),C=()=>{u(e)},T=()=>{n?.reject(new Error("User cancelled")),r(null),m()},P=!N&&!o;return t.jsxs(t.Fragment,{children:[t.jsxs(Fe,{className:W.container,children:[t.jsxs("header",{children:[t.jsx("h1",{className:W.title,children:"Enable auto-signing"}),t.jsx("p",{className:W.description,children:"An application is requesting to enable auto-signing"})]}),t.jsxs("section",{children:[t.jsx("h2",{className:W.sectionTitle,children:"Requested by"}),t.jsxs("div",{className:W.websiteInfo,children:[t.jsx("img",{src:I.favicon,alt:"",className:W.favicon}),t.jsxs("div",{children:[t.jsx("div",{className:W.websiteTitle,children:I.title}),t.jsx("div",{className:W.websiteHost,children:I.hostname})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:W.sectionTitle,children:"Applies to"}),t.jsxs("div",{className:W.infoList,children:[t.jsxs("div",{className:W.infoItem,children:[t.jsx("div",{className:W.label,children:"Address"}),t.jsxs("div",{className:W.infoValue,children:[t.jsx(A.IconWallet,{size:14}),t.jsx("span",{className:"monospace",children:v.truncate(d??l)})]})]}),t.jsxs("div",{className:W.infoItem,children:[t.jsx("div",{className:W.label,children:"Chain"}),t.jsxs("div",{className:W.infoValue,children:[t.jsx(Y,{src:f,width:14,height:14,logo:!0}),t.jsx("span",{children:g})]})]}),t.jsxs("div",{className:W.infoItem,children:[t.jsx("div",{className:W.label,children:"Duration"}),t.jsx(Fo,{options:Wo,value:e,onChange:s,classNames:{trigger:W.durationTrigger,item:W.durationItem}})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:W.sectionTitle,children:"About auto-signing"}),t.jsx("ul",{className:W.featureList,children:["Send transactions without confirmation pop-ups","Protected by Privy embedded wallet","Revoke permissions any time in settings"].map(R=>t.jsxs("li",{className:W.featureItem,children:[t.jsx(A.IconCheckCircle,{size:12,className:W.checkIcon}),t.jsx("span",{children:R})]},R))}),t.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",className:W.learnMoreLink,children:["Learn more ",t.jsx(A.IconExternalLink,{size:12})]})]})]}),t.jsxs(ie,{className:W.footer,extra:t.jsxs("div",{className:W.feedbackContainer,children:[!S&&!x&&t.jsx(oe,{level:"error",children:"Insufficient balance for fee"}),!N&&!o&&t.jsx(oe,{level:"warning",children:t.jsxs("div",{className:W.warningContent,children:[t.jsx("span",{children:"You are on an unverified website"}),t.jsx("button",{onClick:()=>a(!0),className:W.ignoreButton,children:"Ignore"})]})})]}),children:[t.jsx(J.Outline,{onClick:T,children:"Cancel"}),t.jsx(J.White,{onClick:C,disabled:P||!x||S,loading:h,children:"Enable"})]})]})},vd=()=>H.useAtomValue(ts)?t.jsx(jd,{}):null;function pr(e){const s=e.split(".");return s.length<2?e:s.slice(-2).join(".")}const wd="_container_mqvhs_1",bd="_badge_mqvhs_5",xr={container:wd,badge:bd},Ho=e=>{const{offset:s=-4,disabled:n,children:r,className:o}=e;return t.jsxs("div",{className:D(xr.container,o),children:[r,!n&&t.jsx("div",{className:xr.badge,style:{right:s,top:s}})]})},Cd="_header_s7mee_1",Id="_back_s7mee_12",Nd="_title_s7mee_24",cn={header:Cd,back:Id,title:Nd},Oe=({title:e,backButton:s,extra:n,children:r})=>t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:cn.header,children:[t.jsx(Et,{to:s??-1,className:cn.back,shouldReset:!!s,children:t.jsx(A.IconBack,{size:16})}),t.jsx("h1",{className:cn.title,children:e}),n]}),t.jsx(Fe,{children:r})]});function Qo(){const{initiaAddress:e,hexAddress:s}=xe(),n=vt(),r=ss();return o=>{const a=n(o);switch(r(a)){case"initia":return e;case"evm":return s;default:return""}}}function Go(){const e=vt(),s=ss();return(n,r)=>{const o=e(r);switch(s(o)){case"initia":return v.InitiaAddress.validate(n);case"evm":return We.isAddress(n);case"cosmos":try{return V.fromBech32(n).prefix===o.bech32_prefix}catch{return!1}default:return!1}}}function Sd(){const e=vt(),s=ss();return({initialAddress:n,initialChainId:r,chainId:o,fallbackAddress:a})=>{const i=e(r),c=s(i),l=e(o),d=s(l);if(c==="evm"&&d==="initia")return v.InitiaAddress(n).bech32;if(c==="initia"&&d==="evm")return v.InitiaAddress(n).hex;if(c===d)return n;if(a){if(d==="initia")return v.InitiaAddress(a).bech32;if(d==="evm")return v.InitiaAddress(a).hex}return""}}function Ad(){return _e().network_type==="testnet"}function ot(){return ue.useFormContext()}function kd(){const e=jt(),s=Ad(),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=w.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 $d="_root_ekn9t_1",Td="_header_ekn9t_6",Ed="_title_ekn9t_12",qd="_warning_ekn9t_18",Dd="_content_ekn9t_22",Pd="_footer_ekn9t_26",Rd="_secondary_ekn9t_36",dt={root:$d,header:Td,title:Ed,warning:qd,content:Dd,footer:Pd,secondary:Rd},Vo=e=>{const{type:s,icon:n,title:r,children:o,primaryButton:a,secondaryButton:i}=e;return t.jsxs(Fe,{className:dt.root,children:[t.jsxs("header",{className:D(dt.header,s&&dt[s]),children:[n,t.jsx("h1",{className:dt.title,children:r})]}),t.jsx("div",{className:dt.content,children:o}),t.jsxs("footer",{className:dt.footer,children:[t.jsx(J.White,{onClick:a.onClick,sm:!0,fullWidth:!0,children:a.label}),t.jsxs("button",{className:dt.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(A.IconChevronRight,{size:14})]})]})]})},Bd="_list_k4n3k_1",Md="_row_k4n3k_9",Fd="_dt_k4n3k_20",Od="_asset_k4n3k_26",ls={list:Bd,row:Md,dt:Fd,asset:Od},Ud=({list:e,onNavigate:s,onDismiss:n})=>{const r=_e(),o=Te(),a=Ge(r);return t.jsx(Vo,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:s},secondaryButton:{label:"Do not show again",onClick:n},children:t.jsx("div",{className:ls.list,children:e.toSorted((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:d})=>{const u=o(c),{decimals:h,symbol:m}=a(d),f=v.formatAmount(l,{decimals:h});return t.jsxs("div",{className:ls.row,children:[t.jsxs("div",{className:ls.dt,children:[t.jsx(Y,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:ls.asset,children:[f," ",m]})]},i)})})})};function ln(e,s){return e.chainId===s.chainId&&e.txHash===s.txHash}const ds=({chainId:e,txHash:s})=>`${U.OP_REMINDER}:${e}:${s}`,Ld=Sa.atomWithStorage(U.OP_REMINDER,[]);function Rt(){const e=ee(),[s=[],n]=H.useAtom(Ld),r=_.useMemo(()=>s.map(l=>{const d=localStorage.getItem(ds(l));return d?JSON.parse(d):null}).filter(l=>{if(!l)return!1;const{recipient:d,claimableAt:u}=l;return d!==e?!1:ke.isPast(u)}),[e,s]),o=_.useCallback((l,d)=>{s.some(u=>ln(u,l))||(n((u=[])=>[...u,l]),localStorage.setItem(ds(l),JSON.stringify(d)))},[s,n]),a=_.useCallback(l=>{n((d=[])=>d.filter(u=>!ln(u,l))),localStorage.removeItem(ds(l))},[n]),i=_.useCallback(l=>{const d=l.filter(u=>!s.some(h=>ln(h,u)));d.length!==0&&n((u=[])=>[...u,...d])},[s,n]),c=_.useCallback((l,d)=>{localStorage.setItem(ds(l),JSON.stringify(d)),n((u=[])=>[...u])},[n]);return{reminders:r,addReminder:o,removeReminder:a,syncReminders:i,setReminder:c}}function Yo(){const e=he(),{openModal:s,closeModal:n}=Ms(),{reminders:r,setReminder:o}=Rt();_.useEffect(()=>{const a=r.filter(l=>!l.dismissed);if(a.length===0)return;const i=()=>{const l=a.every(d=>d.chainId===a[0].chainId)?a[0].chainId:void 0;e("/op/withdrawals",{chainId:l}),c()},c=()=>{n();for(const l of a)o(l,{...l,dismissed:!0})};s({content:_.createElement(Ud,{list:a,onNavigate:i,onDismiss:c})})},[r,n,e,s,o])}const zd="_wrapper_5ssm8_1",Kd="_balance_5ssm8_11",Wd="_button_5ssm8_15",dn={wrapper:zd,balance:Kd,button:Wd},Jo=({onClick:e,children:s,disabled:n})=>t.jsxs("div",{className:dn.wrapper,children:[t.jsx(A.IconWallet,{size:16}),t.jsx("span",{className:dn.balance,children:s}),t.jsx("button",{type:"button",tabIndex:-1,className:dn.button,onClick:()=>e(),disabled:n,children:"MAX"})]}),Hd="_fieldset_up6fh_1",Qd="_upper_up6fh_9",Gd="_select_up6fh_14",Vd="_account_up6fh_20",Yd="_lower_up6fh_25",Jd="_wrapper_up6fh_26",Zd="_balance_up6fh_33",Xd="_value_up6fh_37",eu="_error_up6fh_50",ze={fieldset:Hd,upper:Qd,select:Gd,account:Vd,lower:Yd,wrapper:Jd,balance:Zd,value:Xd,error:eu},In=e=>{const{selectButton:s,accountButton:n,quantityInput:r,balanceButton:o,value:a,errorMessage:i,hideNumbers:c}=e;return t.jsxs("div",{className:ze.fieldset,children:[t.jsxs("div",{className:ze.upper,children:[t.jsx("div",{className:ze.select,children:s}),t.jsx("div",{className:ze.account,children:n})]}),!c&&t.jsxs("div",{className:ze.lower,children:[r,t.jsxs("div",{className:ze.wrapper,children:[t.jsx("div",{className:ze.balance,children:o}),a&&t.jsx("div",{className:ze.value,children:a})]}),i&&t.jsxs("footer",{className:ze.error,children:[t.jsx(A.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function ns(){const e=_.useRef(null),s=Ls();return _.useEffect(()=>{s||e.current?.focus()},[s]),e}const tu="_input_h8073_1",su={input:tu};function yr(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 Zo(e){const{name:s,control:n,dp:r=6,className:o,rules:a,...i}=e,c=ns();return t.jsx(ue.Controller,{name:s,control:n,rules:a,render:({field:l})=>t.jsx("input",{...l,className:D(su.input,o),onChange:d=>l.onChange(yr(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,""),f=yr(m,r);l.onChange(f)},placeholder:"0",inputMode:"decimal",autoComplete:"off",...i,ref:Wr.mergeRefs([l.ref,c])})})}const nu="_input_19r9r_1",ru="_placeholder_19r9r_18",Nn={input:nu,placeholder:ru},ou=({children:e})=>t.jsx("p",{className:D(Nn.input,{[Nn.placeholder]:F(e).isZero()}),children:e}),bs=({balance:e,decimals:s})=>{const{control:n}=ue.useFormContext(),r={required:"Enter amount",validate:o=>F(o).isZero()?"Enter amount":F(v.toBaseUnit(o,{decimals:s})).gt(e??0)?"Insufficient balance":!0};return t.jsx(Zo,{name:"quantity",control:n,className:Nn.input,rules:r})};bs.ReadOnly=ou;const Dt=({title:e,content:s,children:n,className:r})=>{const[o,a]=_.useState(!1),i=()=>a(!1);return t.jsx(Po,{title:e,trigger:n,className:r,open:o,onOpenChange:a,children:s(i)})},au="_tooltip_19kvs_1",iu="_arrow_19kvs_44",jr={tooltip:au,arrow:iu},rs=({label:e,children:s,small:n,...r})=>t.jsxs(se.Tooltip.Root,{...r,children:[t.jsx(se.Tooltip.Trigger,{asChild:!0,children:s}),t.jsx(se.Tooltip.Portal,{container:yt(),children:t.jsxs(se.Tooltip.Content,{className:D(jr.tooltip,{small:n}),collisionBoundary:yt(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(se.Tooltip.Arrow,{className:jr.arrow})]})})]});function Qn(e,s){const n=Ye();return $.useQuery({queryKey:Re.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:Q.SECOND})}function cu(e,s,n){const{data:r={}}=Qn(e,s);return w.path([n],r)}const lu=[["d",1440*60],["h",3600],["m",60],["s",1]];function Sn(e){if(!e)return;const{formattedParts:s}=lu.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 Xo(e){return e?.map(s=>{const{amount:n,origin_asset:r}=s;return`${v.formatAmount(n,{decimals:r.decimals??0})} ${r.symbol}`}).join(", ")}function vr(e,s){const{watch:n}=ot(),r=n(),o=Ye(),a=qs(),i={...r,quantity:e},c=$.useQueryClient();return $.useQuery({queryKey:Re.route(i,s?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:l,srcDenom:d,quantity:u,dstChainId:h,dstDenom:m}=i,{decimals:f}=c.getQueryData(Re.asset(l,d).queryKey)??{decimals:0},g={amount_in:v.toBaseUnit(u,{decimals:f}),source_asset_chain_id:l,source_asset_denom:d,dest_asset_chain_id:h,dest_asset_denom:m,is_op_withdraw:s?.isOpWithdraw},p=await o.post("v2/fungible/route",{json:g}).json(),x={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return a("Bridge Simulation Success",x),p},enabled:!!Number(i.quantity)&&!s?.disabled,staleTime:Q.MINUTE})}function du(e){return $.useQuery({queryKey:Re.routeErrorInfo(e||new Error).queryKey,queryFn:async()=>{if(!e||!(e instanceof L.HTTPError))return null;const{response:s}=e;return(s.headers.get("content-type")??"").includes("application/json")?(await s.json()).info??null:null}})}function uu(){const{watch:e}=ot(),{srcChainId:s,srcDenom:n,dstChainId:r,dstDenom:o}=e(),a=Be(s),i=Jt(a),c=Qe(n,s),l=Qe(o,r),d=_e(),u=ae();return i==="initia"&&r===d.chainId&&c.symbol===l.symbol&&u.find(h=>h.chainId===s)?.metadata?.op_denoms?.includes(l.denom)}const hu="_label_t93ix_1",mu="_wrapper_t93ix_7",fu="_input_t93ix_10",_u="_clear_t93ix_18",us={label:hu,wrapper:mu,input:fu,clear:_u},Gn=({mode:e="onChange",myAddress:s,...n})=>{const{validate:r=v.InitiaAddress.validate,chainType:o="initia",onApply:a,ref:i}=n,c=ns(),{control:l,getValues:d,setValue:u,formState:h}=ue.useFormContext(),m=d("recipient"),[f,g]=_.useState(m),p=to(),{data:x,isLoading:S,error:I}=$.useQuery({queryKey:$s.address(p.restUrl,f).queryKey,queryFn:()=>p.getAddress(f),staleTime:Q.MINUTE,enabled:p.validateUsername(f)}),N=x??(r(f)?f:""),C=s&&v.InitiaAddress.equals(N,s),T=async()=>{try{const B=await navigator.clipboard.readText();g(B.trim())}catch{}};_.useEffect(()=>{e==="onChange"&&(!f&&!h.dirtyFields.recipient||u("recipient",x??f,{shouldValidate:!0,shouldDirty:!0}))},[h.dirtyFields.recipient,f,e,u,x]);const P=()=>{S||I||(u("recipient",N,{shouldValidate:!0,shouldDirty:!0}),a?.())},R=()=>{if(S)return t.jsx(kt,{level:"loading",children:"Resolving username..."});if(I)return t.jsx(kt,{level:"error",children:I.message});if(x)return t.jsx(kt,{level:"success",className:"monospace",children:x});if(e==="onSubmit"&&f&&!N)return t.jsx(kt,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:us.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(J.Small,{type:"button",tabIndex:-1,onClick:T,children:"Paste"})]}),t.jsxs("div",{className:us.wrapper,children:[t.jsx(ue.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:B=>r(B)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:D(us.input,"monospace"),value:f,onChange:B=>g(B.target.value.trim()),placeholder:o==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?Wr.mergeRefs([i,c]):i})}),!!f&&t.jsx("button",{type:"button",className:us.clear,onClick:()=>g(""),"aria-label":"Clear recipient",children:t.jsx(A.IconCloseCircleFilled,{size:16})})]}),R(),C&&t.jsx(kt,{children:"This is my address"}),e==="onSubmit"&&t.jsx(ie,{extra:(!s||!!N&&!C)&&t.jsx(oe,{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(J.White,{type:"button",onClick:P,disabled:S||!!I||!N,children:"Apply"})})]})},gu="_scrollable_vgj3r_1",pu="_list_vgj3r_5",xu="_item_vgj3r_9",yu="_name_vgj3r_22",hs={scrollable:gu,list:pu,item:xu,name:yu};function ea({onSelect:e,list:s,...n}){const{getImage:r,getName:o,getKey:a,getIsLoading:i,getDisabled:c}=n;return t.jsx(Fe,{className:hs.scrollable,children:t.jsx("div",{className:hs.list,children:s.map(l=>t.jsxs("button",{className:hs.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),children:[t.jsx(Y,{src:r(l),width:28,height:28}),t.jsx("span",{className:hs.name,children:o(l)}),i?.(l)&&t.jsx(wt,{size:16})]},a(l)))})})}function Ks(){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 ju="_account_h04x1_8",vu="_clear_h04x1_28",wu="_white_h04x1_39",Ut={account:ju,clear:vu,white:wu},wr=({type:e})=>{const{watch:s,setValue:n}=ot(),{srcChainId:r,dstChainId:o,cosmosWalletName:a}=s(),c=s(e==="src"?"sender":"recipient"),l=Jt(Be(o)),{list:d,find:u}=Ks(),h=u(a),m=Qo(),f=Go(),g=m(o),p=v.InitiaAddress.equals(c,g),x=()=>t.jsx(Dt,{title:"Connect wallet",content:N=>t.jsx(ea,{onSelect:async C=>{const T=C.getProvider();if(!T)return window.open(C.fallbackUrl,"_blank");const P=T.getOfflineSigner(r),[{address:R}]=await P.getAccounts();n("sender",R),n("cosmosWalletName",C.name),N()},list:d,getImage:C=>C.image,getName:C=>C.name,getKey:C=>C.name}),className:D(Ut.account,{[Ut.white]:!c}),children:c?t.jsxs(t.Fragment,{children:[h&&t.jsx(Y,{src:h.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:v.truncate(c)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(A.IconChevronRight,{size:14})]})}),S=N=>t.jsx(Dt,{title:"Recipient",content:C=>t.jsx(Fe,{children:t.jsx(Gn,{mode:"onSubmit",myAddress:g,chainType:l,validate:T=>f(T,o),onApply:C})}),className:Ut.account,children:N}),I=()=>{switch(l){case"initia":case"evm":return p?S(t.jsx(A.IconWallet,{size:14})):t.jsxs("div",{className:Ut.account,children:[t.jsx("span",{className:"monospace",children:v.truncate(c)}),t.jsx("button",{type:"button",className:Ut.clear,onClick:()=>n("recipient",g,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(A.IconCloseCircleFilled,{size:14})})]});case"cosmos":return S(t.jsxs(t.Fragment,{children:[c?t.jsx("span",{className:"monospace",children:v.truncate(c)}):t.jsx("span",{children:"Recipient"}),t.jsx(A.IconEdit,{size:14})]}))}};switch(e){case"src":return x();case"dst":return I()}},bu="_images_cj4xz_1",un={images:bu},Ws=({assetLogoUrl:e,assetLogoSize:s=36,chainLogoUrl:n,chainLogoSize:r=18,chainLogoOffset:o=6,className:a})=>t.jsxs("div",{className:D(un.images,a),style:{position:"relative"},children:[t.jsx(Y,{src:e,width:s,height:s,className:un.asset,logo:!0}),t.jsx(Y,{src:n,width:r,height:r,className:un.chain,style:{position:"absolute",bottom:0,right:-1*o},logo:!0})]}),Cu="_root_6187w_1",Iu="_content_6187w_10",Nu="_details_6187w_20",Su="_symbol_6187w_26",Au="_chain_6187w_34",ku="_chevron_6187w_43",ut={root:Cu,content:Iu,details:Nu,symbol:Su,chain:Au,chevron:ku},ta=({asset:e,chain:s,readOnly:n})=>{const r=t.jsxs("div",{className:ut.content,children:[t.jsx(Ws,{assetLogoUrl:e.logoUrl,chainLogoUrl:s.logoUrl}),t.jsxs("div",{className:ut.details,children:[t.jsx("div",{className:ut.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:ut.chain,children:["on ",s.name]})]})]});return n?t.jsx("div",{className:ut.root,children:r}):t.jsxs("div",{className:ut.root,children:[r,t.jsx(A.IconChevronDown,{size:16,className:ut.chevron})]})};function $u(e,s,n){return n.filter(r=>{const o=e.map(a=>r[a]).map(a=>String(a??"").toLowerCase());return w.any(w.includes(s.toLowerCase()),o)})}const Tu="_root_1sh27_1",Eu="_label_1sh27_8",qu="_input_1sh27_21",Du="_hasValue_1sh27_31",Pu="_clear_1sh27_35",Lt={root:Tu,label:Eu,input:qu,hasValue:Du,clear:Pu},Hs=e=>{const{rootClassName:s,padding:n=16,iconSize:r=16,onClear:o,ref:a,...i}=e;return t.jsxs("div",{className:D(Lt.root,s,{[Lt.hasValue]:i.value}),style:{"--search-input-padding":`${n}px`,"--search-input-icon-size":`${r}px`},children:[t.jsx("label",{htmlFor:"search",className:Lt.label,children:t.jsx(A.IconSearch,{size:r})}),t.jsx("input",{className:Lt.input,id:"search",type:"text",maxLength:100,ref:a,...i}),i.value&&t.jsx("button",{type:"button",className:Lt.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:o,children:t.jsx(A.IconCloseCircleFilled,{size:r})})]})},Ru="_container_1mzcj_1",Bu="_search_1mzcj_7",Mu="_list_1mzcj_11",Fu="_item_1mzcj_15",Ou="_logo_1mzcj_37",Uu="_info_1mzcj_41",Lu="_symbol_1mzcj_47",zu="_name_1mzcj_56",Ku="_balance_1mzcj_62",Wu="_value_1mzcj_69",Ce={container:Ru,search:Bu,list:Mu,item:Fu,logo:Ou,info:Uu,symbol:Lu,name:zu,balance:Ku,value:Wu},os=e=>{const{assets:s,onSelect:n,renderAsset:r=(c,l)=>l(c)}=e,[o,a]=_.useState(""),i=$u(["symbol"],o,s);return t.jsxs("div",{className:Ce.container,children:[t.jsx(Hs,{value:o,onChange:c=>a(c.target.value),onClear:()=>a(""),placeholder:"Search by symbol",rootClassName:Ce.search,padding:20,ref:ns()}),i.length===0?t.jsx(ne,{children:"No assets"}):t.jsx("div",{className:Ce.list,children:i.map(c=>t.jsx("button",{type:"button",className:Ce.item,onClick:()=>n(c.denom),children:r(c,l=>{const{denom:d,logoUrl:u,symbol:h,name:m,balance:f,decimals:g,value:p=0}=l;return t.jsxs(t.Fragment,{children:[t.jsx(Y,{src:u,width:32,height:32,className:Ce.logo,logo:!0}),t.jsxs("div",{className:Ce.info,children:[t.jsx("div",{className:Ce.symbol,children:h||d}),t.jsx("div",{className:Ce.name,children:m})]}),t.jsxs("div",{className:Ce.balance,children:[f&&t.jsx("div",{children:v.formatAmount(f,{decimals:g})}),p>0&&t.jsx("div",{className:Ce.value,children:$e(p)})]})]})})},c.denom))})]})},Hu=()=>t.jsxs("div",{className:Ce.container,children:[t.jsx(Hs,{rootClassName:Ce.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(ne,{children:"Loading..."})]});os.Placeholder=Hu;const Qu="_stack_16oqn_1",Gu="_title_16oqn_9",Vu="_grid_16oqn_16",Yu="_item_16oqn_22",Ju="_button_16oqn_26",Zu="_active_16oqn_44",$t={stack:Qu,title:Gu,grid:Vu,item:Yu,button:Ju,active:Zu},xt=({label:e,chains:s,value:n,onSelect:r,getShowIndicator:o})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:$t.title,children:e}),t.jsx("div",{className:$t.grid,children:s.map(({chainId:a,name:i,logoUrl:c})=>t.jsx(Ho,{offset:-2,disabled:!o?.(a),className:$t.item,children:t.jsx(rs,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:D($t.button,{[$t.active]:a===n}),onClick:()=>r(a),children:t.jsx(Y,{src:c,width:28,height:28,logo:!0})})})},a))})]}),Xu=({children:e})=>t.jsx("div",{className:$t.stack,children:e});xt.Stack=Xu;const eh=({address:e,chain:s,onSelect:n})=>{const r=qt(s.chain_id),{data:o={}}=Qn(e,s.chain_id);return t.jsx(os,{assets:w.sortWith([w.descend(a=>a.symbol==="INIT"),w.descend(a=>a.value),({balance:a="0"},{balance:i="0"})=>F(i).comparedTo(a)??0,w.ascend(a=>a.symbol.toLowerCase())],r.filter(a=>!a.hidden).map(a=>{const{denom:i,symbol:c=v.truncate(i),logo_uri:l}=a,d=o[i]??{};return{...a,symbol:c,decimals:a.decimals??0,logoUrl:l??"",name:a.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:n})},th=({type:e,afterSelect:s})=>{const n=e==="src"?"srcChainId":"dstChainId",r=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"sender":"recipient",a=Pt(),i=Kn(),{watch:c,setValue:l}=ot(),d=c(o),u=c(n),h=c(r),[m,f]=_.useState(u),g=Be(m),p=Sd(),x=ko(),[S,I]=w.partition(C=>x(C.chain_id),i.filter(C=>!C.hidden)),N=C=>{if(u===m&&h===C){s();return}l(n,m),l(r,C),s()};return t.jsxs(t.Fragment,{children:[t.jsxs(xt.Stack,{children:[t.jsx(xt,{label:"Interwoven Economy",chains:S.map(({chain_id:C,chain_name:T,pretty_name:P,logo_uri:R})=>({chainId:C,name:P||T,logoUrl:R??""})),value:m,onSelect:f}),t.jsx(xt,{label:"Chains",chains:I.map(({chain_id:C,chain_name:T,pretty_name:P,logo_uri:R})=>({chainId:C,name:P||T,logoUrl:R??""})),value:m,onSelect:f})]}),t.jsx(ye,{suspenseFallback:t.jsx(os.Placeholder,{}),children:t.jsx(eh,{address:p({initialAddress:d,initialChainId:u,chainId:m,fallbackAddress:e==="src"?a:void 0}),chain:g,onSelect:N})},m)]})},br=({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}=ot(),a=o(s),i=o(n),c=Be(a),l=Qe(i,a);return t.jsx(Dt,{title:r,content:d=>t.jsx(th,{type:e,afterSelect:d}),children:t.jsx(ta,{asset:{denom:l.denom,decimals:l.decimals??0,symbol:l.symbol,logoUrl:l.logo_uri??""},chain:{chainId:c.chain_id,name:c.pretty_name||c.chain_name,logoUrl:c.logo_uri??""}})})},sh="_skeleton_1l4jn_1",nh={skeleton:sh},hn=({width:e="100%",height:s})=>t.jsx("div",{className:nh.skeleton,style:{width:e,height:s}}),rh="_stack_oq1ir_1",oh="_button_oq1ir_6",ah="_isLoading_oq1ir_19",ih="_disabled_oq1ir_19",ch="_checked_oq1ir_23",lh="_header_oq1ir_37",dh="_title_oq1ir_43",uh="_duration_oq1ir_52",hh="_warning_oq1ir_62",mh="_amount_oq1ir_66",fh="_value_oq1ir_67",be={stack:rh,button:oh,isLoading:ah,disabled:ih,checked:ch,header:lh,title:dh,duration:uh,warning:hh,amount:mh,value:fh},_h=({children:e})=>t.jsx("div",{className:be.stack,children:e}),ps=({label:e,query:s,value:n,onSelect:r,...o})=>{const{data:a,isLoading:i}=s,{watch:c}=ot(),{dstChainId:l,dstDenom:d}=c(),u=Qe(d,l),h=!i&&o.checked,m=!i&&!a;return t.jsxs("button",{type:"button",className:D(be.button,{[be.isLoading]:i,[be.disabled]:m,[be.checked]:h}),onClick:()=>{i||m||r(n)},children:[t.jsxs("div",{className:be.header,children:[t.jsxs("div",{className:be.title,children:[t.jsx("span",{children:e}),h&&t.jsx(A.IconCheck,{size:14})]}),i?t.jsx(hn,{width:80,height:16}):a?t.jsxs("div",{className:D(be.duration,{[be.warning]:n==="op"}),children:[t.jsx(A.IconClockFilled,{size:12}),t.jsx("span",{children:Sn(a.estimated_route_duration_seconds)})]}):t.jsx("div",{className:be.duration,children:"Not available"})]}),(i||a)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:be.amount,children:i?t.jsx(hn,{width:260,height:40}):a?v.formatAmount(a.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:be.value,children:i?t.jsx(hn,{width:120,height:16}):a?a.usd_amount_out?$e(a.usd_amount_out):"$-":null})]})]})};ps.Stack=_h;const gh="_description_nuyvt_1",ph="_presets_nuyvt_8",xh="_preset_nuyvt_8",yh="_active_nuyvt_29",jh="_custom_nuyvt_40",vh="_wrapper_nuyvt_47",wh="_percent_nuyvt_58",qe={description:gh,presets:ph,preset:xh,active:yh,custom:jh,wrapper:vh,percent:wh},Cr=["0.1","0.5","1.0"],bh=({afterConfirm:e})=>{const s=ot(),n=s.getValues("slippagePercent"),[r,o]=_.useState(null),{control:a,watch:i,getValues:c,setValue:l}=ue.useForm({defaultValues:{value:n}}),d=i("value");_.useEffect(()=>{const p=Cr.findIndex(x=>x===n);o(p>=0?p:null)},[n]);const u=(p,x)=>{l("value",p),o(x)},h=()=>{o(null)},m=_.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),f=m?.type==="error",g=({value:p})=>{s.setValue("slippagePercent",p),e()};return t.jsxs(Fe,{children:[t.jsx("p",{className:qe.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:qe.presets,children:[Cr.map((p,x)=>t.jsxs("button",{type:"button",className:D(qe.preset,{[qe.active]:r===x}),onClick:()=>u(p,x),children:[p,"%"]},p)),r!==null?t.jsx("button",{type:"button",className:D(qe.preset,qe.custom),onClick:()=>o(null),children:"Custom"}):t.jsxs("div",{className:qe.wrapper,children:[t.jsx(Zo,{name:"value",control:a,dp:2,onFocus:h,placeholder:"",className:D(qe.preset,qe.active)}),t.jsx("span",{className:qe.percent,children:"%"})]})]}),m&&t.jsx(oe,{level:m.type,children:m.text}),t.jsx(ie,{children:t.jsx(J.White,{type:"button",onClick:()=>g(c()),disabled:f,children:"Confirm"})})]})},Ch="_form_1owk5_1",Ih="_arrow_1owk5_5",Nh="_divider_1owk5_14",Sh="_flip_1owk5_23",Ah="_meta_1owk5_41",kh="_row_1owk5_54",$h="_title_1owk5_60",Th="_description_1owk5_64",Eh="_icon_1owk5_71",qh="_edit_1owk5_76",Dh="_warning_1owk5_99",pe={form:Ch,arrow:Ih,divider:Nh,flip:Sh,meta:Ah,row:kh,title:$h,description:Th,icon:Eh,edit:qh,warning:Dh},Ph=()=>{const e=he(),s=Ls(),[n,r]=Ie.useLocalStorage(U.BRIDGE_ROUTE_TYPE,"default"),{watch:o,setValue:a,handleSubmit:i,formState:c}=ot(),l=o(),{srcChainId:d,srcDenom:u,dstChainId:h,dstDenom:m,quantity:f,sender:g,slippagePercent:p}=l,x=Te(),S=Be(d),I=Jt(S),N=Be(h),C=Jt(N),T=Qe(u,d),P=Qe(m,h),{data:R}=Qn(g,d),B=cu(g,d,u),z=!B?.amount||F(B.amount).isZero(),[j]=Ie.useDebounceValue(f,300),b=I!=="initia"&&C!=="initia",y=uu(),k=vr(j,{disabled:b}),q=vr(j,{isOpWithdraw:!0,disabled:!y}),M=y&&n==="op"?q:k,{data:E,isLoading:G,isFetching:te,error:O}=M,{data:Z}=du(O),Ue=j&&(G||te),Je=()=>{a("srcChainId",h),a("srcDenom",m),a("dstChainId",d),a("dstDenom",u),a("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:at,closeModal:me}=Ms(),ge=i(K=>{if(E?.warning){const{type:ct="",message:Ys}=E.warning??{};at({content:t.jsx(Vo,{type:"warning",icon:t.jsx(A.IconWarningFilled,{size:40}),title:Ns.sentenceCase(ct),primaryButton:{label:"Cancel",onClick:me},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:E,values:K}),me()}},children:t.jsx("p",{className:pe.warning,children:Ys})})});return}e("/bridge/preview",{route:E,values:K})}),Ct=_.useMemo(()=>E?.estimated_fees?.filter(({fee_behavior:K})=>K==="FEE_BEHAVIOR_DEDUCTED")??[],[E]),it=_.useMemo(()=>E?.estimated_fees?.filter(({fee_behavior:K})=>K==="FEE_BEHAVIOR_ADDITIONAL")??[],[E]),Mt=_.useMemo(()=>{for(const K of it){const ct=R?.[K.origin_asset.denom]?.amount??"0",Ys=E?.source_asset_denom===K.origin_asset.denom?E.amount_in:"0";if(F(ct).lt(F(Ys).plus(K.amount??"0")))return`Insufficient ${K.origin_asset.symbol} for fees`}},[R,E,it]),er=_.useMemo(()=>{if(!l.sender)return"Connect wallet";if(!l.quantity||!j)return"Enter amount";if(!l.recipient)return"Enter recipient address";if(c.errors.quantity)return c.errors.quantity.message;if(!E)return"Route not found";if(Mt)return Mt},[j,Mt,c,E,l]),xa=E?v.formatAmount(E.amount_out,{decimals:P.decimals}):"0",ya=F(f).gt(0)&&F(f).isEqualTo(v.fromBaseUnit(B?.amount,{decimals:B?.decimals??0})),ja=(()=>{switch(I){case"initia":return x(d).fees.fee_tokens.some(({denom:K})=>K===u);case"cosmos":return S.fee_assets.some(({denom:K})=>K===u);case"evm":return!We.isAddress(u);default:return!1}})(),Vs=_.useCallback((K,ct)=>K.length?t.jsxs("div",{className:pe.description,children:[Xo(K),!s&&t.jsx(rs,{label:ct,children:t.jsx("span",{className:pe.icon,children:t.jsx(A.IconInfoFilled,{size:12})})})]}):null,[s]),as=F(f).gt(0)&&y,tr=_.useMemo(()=>E?[{condition:!!E.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Vs(Ct,"Fee deducted from the amount you receive"),Vs(it,"Fee charged in addition to the amount you enter")]})},{condition:!as&&!!Sn(E.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:pe.description,children:Sn(E.estimated_route_duration_seconds)})},{condition:E.does_swap,title:"Slippage",content:t.jsxs("span",{className:pe.description,children:[t.jsxs("span",{children:[p,"%"]}),t.jsx(Dt,{title:"Slippage tolerance",content:K=>t.jsx(bh,{afterConfirm:K}),className:pe.edit,children:t.jsx(A.IconSettingFilled,{size:12})})]})}].filter(K=>K.condition):[],[it,Ct,Vs,E,as,p]);return t.jsxs("form",{className:pe.form,onSubmit:ge,children:[t.jsx(In,{selectButton:t.jsx(br,{type:"src"}),accountButton:I==="cosmos"&&t.jsx(wr,{type:"src"}),quantityInput:t.jsx(bs,{balance:B?.amount,decimals:T?.decimals}),balanceButton:t.jsx(Jo,{onClick:()=>a("quantity",v.fromBaseUnit(B?.amount,{decimals:T?.decimals??0}),{shouldValidate:!0}),disabled:z,children:v.formatAmount(B?.amount??"0",{decimals:T.decimals})}),value:E?E.usd_amount_in?$e(E.usd_amount_in):"$-":"$0"}),t.jsxs("div",{className:pe.arrow,children:[t.jsx("div",{className:pe.divider}),t.jsx("button",{type:"button",className:pe.flip,onClick:()=>Je(),children:t.jsx(A.IconChevronDown,{size:16})})]}),t.jsx(In,{selectButton:t.jsx(br,{type:"dst"}),accountButton:t.jsx(wr,{type:"dst"}),quantityInput:t.jsx(bs.ReadOnly,{children:xa}),value:E?E.usd_amount_out?$e(E.usd_amount_out):"$-":"$0",hideNumbers:as}),t.jsx(bn,{children:as?t.jsxs(ps.Stack,{children:[t.jsx(ps,{label:"Fast",query:k,value:"default",onSelect:r,checked:n==="default"}),t.jsx(ps,{label:"Lossless",query:q,value:"op",onSelect:r,checked:n==="op"})]}):null}),t.jsx(ie,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(oe.Stack,{children:[E?.extra_infos?.map(K=>t.jsx(oe,{level:"info",children:K},K)),Z&&t.jsx(oe,{level:"info",children:Z}),ya&&ja&&t.jsx(oe,{level:"warning",children:"Make sure to leave enough for transaction fee"}),E?.warning&&t.jsx(oe,{level:"warning",children:E.warning.message}),E?.extra_warnings?.map(K=>t.jsx(oe,{level:"warning",children:K},K))]}),t.jsx(bn,{children:tr.length>0&&t.jsx("div",{className:pe.meta,children:tr.map((K,ct)=>t.jsxs("div",{className:pe.row,children:[t.jsx("span",{className:pe.title,children:K.title}),K.content]},ct))})})]}),children:t.jsx(J.White,{loading:Ue&&"Simulating...",disabled:!!er,children:er??"Preview route"})})]})},Rh=()=>{Yo();const e=Ha(),s=he(),{closeDrawer:n}=Ve(),r=Pt(),o=kd(),a=ue.useForm({mode:"onChange",defaultValues:o}),{watch:i,setValue:c}=a,{srcChainId:l,dstChainId:d,srcDenom:u,dstDenom:h,quantity:m,slippagePercent:f,recipient:g}=i();i((j,{name:b})=>{(b==="srcChainId"||b==="srcDenom")&&c("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=Qo(),x=p(l),S=p(d),N=Go()(g,d);_.useEffect(()=>{c("cosmosWalletName",void 0),c("sender",x)},[l,x,c]),_.useEffect(()=>{N||c("recipient",S)},[S,N,c]);const C=qt(l),T=qt(d),P=_.useMemo(()=>{if(!C.find(j=>j.denom===u))return`${u} is not available for bridge/swap on ${l}`;if(!T.find(j=>j.denom===h))return`${h} is not available for bridge/swap on ${d}`},[T,d,h,C,l,u]);_.useEffect(()=>{P||(localStorage.setItem(U.BRIDGE_SRC_CHAIN_ID,l),localStorage.setItem(U.BRIDGE_SRC_DENOM,u),localStorage.setItem(U.BRIDGE_DST_CHAIN_ID,d),localStorage.setItem(U.BRIDGE_DST_DENOM,h),localStorage.setItem(U.BRIDGE_QUANTITY,m),localStorage.setItem(U.BRIDGE_SLIPPAGE_PERCENT,f))},[l,u,d,h,m,f,P]);const R=e[0].path==="/bridge",B=()=>t.jsxs(t.Fragment,{children:[t.jsx(ne,{error:!0,children:P}),t.jsx(ie,{children:R?t.jsx(J.White,{onClick:n,children:"Close"}):t.jsx(J.White,{onClick:()=>s(-1),children:"Go back"})})]}),{reminders:z}=Rt();return t.jsx(Oe,{title:"Bridge/Swap",backButton:R?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(J.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:z.length===0,children:t.jsx(J.Small,{onClick:()=>s("/op/withdrawals"),disabled:!r,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:P?B():t.jsx(ue.FormProvider,{...a,children:t.jsx(ye,{children:t.jsx(Ph,{})})})})},Bh="_button_1crvp_1",Mh="_checkbox_1crvp_11",Fh="_checked_1crvp_25",ms={button:Bh,checkbox:Mh,checked:Fh},Oh=({checked:e,onClick:s,label:n,className:r})=>t.jsxs("button",{type:"button",className:D(ms.button,r),onClick:s,children:[t.jsx("div",{className:D(ms.checkbox,{[ms.checked]:e}),children:e&&t.jsx(A.IconCheck,{size:12})}),t.jsx("span",{className:ms.label,children:n})]}),Uh="_button_aoxv2_1",Lh={button:Uh},sa=({onClick:e,disabled:s})=>{const{ref:n,inView:r}=Aa.useInView();return _.useEffect(()=>{r&&e()},[r,e]),t.jsxs("button",{className:Lh.button,onClick:e,disabled:s,ref:n,children:[t.jsx("span",{children:"Load more"}),t.jsx(A.IconChevronDown,{size:12})]})};function na(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 xs=({chainId:e,txHash:s})=>`${U.BRIDGE_HISTORY}:${e}:${s}`,Cs=100,Ir=10;function ra(){const[e,s]=Ie.useLocalStorage(U.BRIDGE_HISTORY,[]),n=_.useCallback((o,a)=>{localStorage.setItem(xs(o),JSON.stringify(a));for(const i of e.slice(Cs-1))localStorage.removeItem(xs(i));s((i=[])=>[o,...i.slice(0,Cs-1)])},[e,s]),r=_.useCallback(o=>{const a=localStorage.getItem(xs(o));return a?JSON.parse(a):null},[]);return{history:e,addHistoryItem:n,getHistoryDetails:r}}function oa(e){return Ie.useLocalStorage(xs(e),null)}async function zh(e,s){const n=L.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 An(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(c){if(w.path(["error","code"],c)!==4902)throw c;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 Bt(){return jt()}function Kh(e){const s=he(),{showNotification:n,updateNotification:r,hideNotification:o}=Hn(),{addHistoryItem:a}=ra(),i=qs(),{route:c,values:l}=Bt(),{srcChainId:d,sender:u,recipient:h,cosmosWalletName:m}=l,f=fo(),{requestTxSync:g,waitForTxConfirmation:p}=xe(),{find:x}=Ks(),S=Xt(),I=Ds(),N=Be(d),C=Jt(N),T=Ao(d),P=$.useQueryClient(),{registryUrl:R}=X(),B=Te(),{addReminder:z}=Rt(),j=Ye();return $.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const b=e.cosmos_tx.msgs.map(({msg_type_url:me,msg:ge})=>{if(!(me&&ge))throw new Error("Invalid transaction data");return I.fromAmino({type:Ht.aminoConverters[me].aminoType,value:JSON.parse(ge)})});if(C==="initia"){const{srcDenom:me,quantity:ge}=l,{decimals:Ct}=T(me),it=await g({messages:b,chainId:d,internal:1,spendCoins:[{denom:me,amount:v.toBaseUnit(ge,{decimals:Ct})}]}),Mt=p({txHash:it,chainId:d});return{txHash:it,wait:Mt}}const y=x(m)?.getProvider();if(!y)throw new Error("Wallet not connected");const k=y.getOfflineSignerOnlyAmino(d),q=await Pe.SigningStargateClient.connectWithSigner(N.rpc,k,{registry:S,aminoTypes:I}),M=await q.getAllBalances(u),E=N.fee_assets.find(me=>M.some(ge=>ge.denom===me.denom&&F(ge.amount).gt(0)));if(!E){const ge=["Insufficient balance for fees.",`Available fee assets: ${N.fee_assets.map(Ct=>T(Ct.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(ge)}const{denom:G,gas_price:te}=E;if(!te)throw new Error(`Gas price not found for ${G}`);const O=await q.simulate(u,b,""),Z=Pe.GasPrice.fromString(te.average+G),Ue=Pe.calculateFee(Math.ceil(O*Gt),Z),Je=await q.signAndBroadcastSync(u,b,Ue),at=Co({txHash:Je,client:q});return{txHash:Je,wait:at}}if("evm_tx"in e){const{chain_id:b,to:y,value:k,data:q}=e.evm_tx,M=await f(),E=await M.getSigner();await An(M,N);const G=await E.sendTransaction({chainId:b,to:y,value:k,data:`0x${q}`});return{txHash:G.hash,wait:G.wait()}}throw new Error("Unlisted chain type")}catch(b){throw await He(b)}},onSuccess:async({txHash:b,wait:y})=>{localStorage.removeItem(U.BRIDGE_QUANTITY),s(-1),n({type:"loading",title:"Transaction is pending..."});try{await y;const k=Vn(c)==="OP Bridge withdrawal",q=k?{success:!0,error:null}:await Vh(j,b,d);if(!q.success&&q.error){const O=q.error instanceof Error?q.error.message:String(q.error);n({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${O}. The transaction may still be processing.`,autoHide:!0})}const M=q.success,G=Qh({txHash:b,srcChainId:d,route:c,values:l,recipient:h},M);a(G.tx,G.details),r(Hh(o));const te=mn(l,b);if(i("Bridge Transaction Success",te),k){const O=Gh(G.tx,c,h);z(G.tx,O)}}catch(k){const q=k instanceof Error?k.message:String(k);r({type:"error",title:"Transaction not confirmed",description:q});const M={...mn(l,b),error:q};i("Bridge Confirmation Failed",M)}finally{P.invalidateQueries({queryKey:Re.balances(d,u).queryKey})}},onError:async b=>{const y=C==="initia"?await At(b,B(d),R):b;n({type:"error",title:"Transaction failed",description:y.message});const k=mn(l);i("Bridge Transaction Failed",{...k,error:y.message})}})}function Wh(){const e=Ye(),s=ee(),n=Ps(),{route:r,values:o}=Bt(),a=vt();return $.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:c}=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:v.InitiaAddress(o.recipient).bech32,dest_asset_chain_id:r.dest_asset_chain_id,dest_asset_denom:r.dest_asset_denom}}).json();await zh(s,a(r.dest_asset_chain_id).rest);const l=c.map(({msg_type_url:h,msg:m})=>Ht.aminoTypes.fromAmino({type:Ht.aminoConverters[h].aminoType,value:JSON.parse(m)})),d=await n(i,s,l,{amount:[],gas:"1"},"",{incrementSequence:i===o.srcChainId?2:0}),u=st.Tx.fromPartial({body:st.TxBody.decode(d.bodyBytes),authInfo:st.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:s,hook:V.toBase64(st.Tx.encode(u).finish())}}catch(i){throw await He(i)}}})}function Hh(e){return{type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(Et,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function mn(e,s){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:s}}function Qh(e,s){const{txHash:n,srcChainId:r,route:o,values:a}=e,i={chainId:r,txHash:n},c=Vn(o)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:o,values:a,state:c?"success":void 0,tracked:s},isOpWithdraw:c}}function Gh(e,s,n){return{...e,recipient:v.InitiaAddress(n).bech32,claimableAt:Date.now()+s.estimated_route_duration_seconds*1e3,amount:s.amount_out,denom:s.dest_asset_denom}}async function Vh(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 He(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Yh(e){const{chainId:s,txHash:n,tracked:r}=e,o=Ye();return $.useQuery({queryKey:Re.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 He(a)}},select:({tx_hash:a})=>a,retry:6,retryDelay:5e3,staleTime:Q.INFINITY,enabled:!r})}function Jh(e){const{timestamp:s,chainId:n,txHash:r,tracked:o,state:a}=e,i=Ye();return $.useQuery({queryKey:Re.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:c}})=>{if(!c)return!1;const{status:l}=c;if(l==="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:Q.INFINITY})}var ys=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(ys||{});function Vn(e){const{operations:s,dest_asset_denom:n}=e;return w.has("op_init_transfer",w.head(s))&&n==="uinit"?"OP Bridge withdrawal":"Skip"}const Zh="_success_t4dfk_1",Xh="_error_t4dfk_5",Nr={success:Zh,error:Xh},em=({tx:e})=>{const[s,n]=oa(e);if(!s)throw new Error("Bridge history details not found");const{data:r}=Jh(s),o=s.state??tm(r);switch(_.useEffect(()=>{o!=="loading"&&n(a=>{if(!a)throw new Error("Bridge history details not found");return{...a,tracked:!0,state:o}})},[n,o]),o){case"error":return t.jsx("div",{className:Nr.error,children:t.jsx(A.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:Nr.success,children:t.jsx(A.IconCheckCircleFilled,{size:14})});default:return t.jsx(wt,{size:14})}};function tm(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 sm="_link_104m3_1",nm="_header_104m3_23",rm="_title_104m3_31",om="_date_104m3_37",am="_explorer_104m3_41",im="_fees_104m3_57",cm="_label_104m3_65",lm="_content_104m3_69",dm="_route_104m3_75",um="_row_104m3_80",hm="_asset_104m3_86",mm="_amount_104m3_94",fm="_chain_104m3_99",_m="_account_104m3_108",gm="_arrow_104m3_115",ce={link:sm,header:nm,title:rm,date:om,explorer:am,fees:im,label:cm,content:lm,route:dm,row:um,asset:hm,amount:mm,chain:fm,account:_m,arrow:gm},pm=({tx:e})=>{const[s,n]=oa(e);if(!s)throw new Error("Bridge history details not found");const{chainId:r,txHash:o,route:a,values:i,timestamp:c,tracked:l}=s,{data:d}=Yh(s),{address:u="",connector:h}=de.useAccount(),{find:m}=Ks();_.useEffect(()=>{d&&n(M=>{if(!M)throw new Error("Bridge history details not found");return{...M,tracked:!0}})},[n,d]);const{amount_in:f,amount_out:g,source_asset_chain_id:p,source_asset_denom:x,dest_asset_chain_id:S,dest_asset_denom:I,estimated_fees:N=[]}=a,C=Be(p),T=Be(S),P=Qe(x,p),R=Qe(I,S),B=(M,E)=>E?t.jsx(Y,{src:E,width:12,height:12}):v.InitiaAddress.equals(M,u)?t.jsx(Y,{src:h?.icon,width:12,height:12}):t.jsx(A.IconWallet,{size:12}),z=(M,{symbol:E,decimals:G,logo_uri:te},{chain_name:O,pretty_name:Z,...Ue},Je,at)=>t.jsxs("div",{className:ce.row,children:[t.jsx(Ws,{assetLogoUrl:te,chainLogoUrl:Ue.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:ce.asset,children:[t.jsx("span",{className:ce.amount,children:v.formatAmount(M,{decimals:G})}),t.jsx("span",{children:E})]}),t.jsxs("div",{className:ce.chain,children:[t.jsxs("span",{children:["on ",Z||O]}),t.jsxs("div",{className:ce.account,children:[at,t.jsx("span",{className:"monospace",children:v.truncate(Je)})]})]})]})]}),j=Vn(a),b=_.useMemo(()=>{switch(j){case ys.SKIP:return"Skip Explorer";case ys.OP_WITHDRAW:return"Initia Scan"}},[j]),y=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:ce.header,children:[t.jsxs("div",{className:ce.title,children:[l?t.jsx(em,{tx:e}):t.jsx(wt,{size:14}),t.jsx("div",{className:ce.date,children:ke.format(new Date(c),"h:mm a")})]}),t.jsxs("div",{className:ce.explorer,children:[t.jsx("span",{children:b}),t.jsx(A.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:ce.route,children:[z(f,P,C,i.sender,B(i.sender,m(i.cosmosWalletName)?.image)),t.jsx("div",{className:ce.arrow,children:t.jsx(A.IconArrowDown,{size:12})}),z(g,R,T,i.recipient,B(i.recipient))]}),N.length>0&&t.jsxs("div",{className:ce.fees,children:[t.jsx("span",{className:ce.label,children:"Fees"}),t.jsx("span",{className:ce.content,children:Xo(N)})]})]});if(j===ys.OP_WITHDRAW)return t.jsx(zs,{chainId:r,txHash:o,className:ce.link,children:y});const k=new URLSearchParams({tx_hash:o,chain_id:r}),q=new URL(`?${k.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:q.toString(),className:ce.link,target:"_blank",children:y})},xm="_history_13u9z_1",ym="_header_13u9z_5",jm="_checkbox_13u9z_9",vm="_groups_13u9z_13",wm="_dateGroup_13u9z_21",bm="_dateHeader_13u9z_26",Cm="_list_13u9z_32",ht={history:xm,header:ym,checkbox:jm,groups:vm,dateGroup:wm,dateHeader:bm,list:Cm},Im=()=>{const{initiaAddress:e,hexAddress:s}=xe(),{history:n,getHistoryDetails:r}=ra(),o=n.filter(f=>r(f)),a=o.filter(f=>{const g=r(f);if(!g)return!1;const{values:p}=g,{sender:x,recipient:S}=p;return[x,S].some(I=>[e,s].includes(I))}),[i,c]=_.useState(1),[l,d]=Ie.useToggle(!a.length),u=l?o:a,h=u.slice(0,i*Ir),m=_.useMemo(()=>na(h,f=>{const g=r(f);if(g)return new Date(g.timestamp)}),[h,r]);return t.jsx(Oe,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:ht.history,children:[o.length>0&&o.length!==a.length&&t.jsx("header",{className:ht.header,children:t.jsx(Oh,{checked:l,onClick:d,label:"Show all transactions stored in this browser",className:ht.checkbox})}),u.length===0?t.jsx(ne,{children:"No bridge/swap activity"}):t.jsx("div",{className:ht.groups,children:Object.entries(m).map(([f,g])=>t.jsxs("div",{className:ht.dateGroup,children:[t.jsx("div",{className:ht.dateHeader,children:f}),t.jsx("div",{className:ht.list,children:g.map(p=>t.jsx(ye,{children:t.jsx(pm,{tx:p})},p.txHash))})]},f))}),u.length>i*Ir?t.jsx(sa,{onClick:()=>c(f=>f+1)}):n.length>=Cs&&t.jsxs(ne,{children:["Only the latest ",Cs," items are stored. Older entries will be removed automatically."]})]})})},Nm=({tx:e})=>{const{mutate:s,isPending:n}=Kh(e);return t.jsx(ie,{children:t.jsx(J.White,{onClick:()=>s(),loading:n&&"Signing transaction...",children:"Confirm"})})},Sm="_content_1hzj2_1",Am="_info_1hzj2_6",km="_arrow_1hzj2_11",$m="_divider_1hzj2_19",Tm="_type_1hzj2_27",Em="_asset_1hzj2_47",qm="_amount_1hzj2_55",Dm="_lower_1hzj2_60",Pm="_chain_1hzj2_66",Rm="_address_1hzj2_72",ve={content:Sm,info:Am,arrow:km,divider:$m,type:Tm,asset:Em,amount:qm,lower:Dm,chain:Pm,address:Rm},aa=e=>{const{source:s,label:n,amount:r,denom:o,chainId:a,address:i,walletIcon:c}=e,{symbol:l=v.truncate(o),decimals:d=0,logo_uri:u=Rn}=e,{chain_name:h,pretty_name:m,...f}=Be(a);return t.jsxs("div",{children:[!s&&t.jsxs("div",{className:ve.arrow,children:[t.jsx("div",{className:ve.divider}),n?t.jsx(rs,{label:n,children:t.jsx("button",{className:ve.type,children:t.jsx(A.IconArrowDown,{size:12})})}):t.jsx("span",{className:ve.type,children:t.jsx(A.IconArrowDown,{size:12})}),t.jsx("div",{className:ve.divider})]}),t.jsxs("div",{className:ve.content,children:[t.jsx(Ws,{assetLogoUrl:u,chainLogoUrl:f.logo_uri??void 0}),t.jsxs("div",{className:ve.info,children:[t.jsxs("div",{className:ve.asset,children:[t.jsx("span",{className:ve.amount,children:v.formatAmount(r,{decimals:d})}),t.jsx("span",{children:l})]}),t.jsxs("div",{className:ve.lower,children:[t.jsxs("div",{className:ve.chain,children:["on ",m||h]}),i&&t.jsx(vs,{value:i,children:({copy:g,copied:p})=>t.jsxs("button",{className:ve.address,onClick:g,children:[c,p?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:v.truncate(i)})]})})]})]})]})]})},Tt=e=>{const s=Qe(e.denom,e.chainId);return t.jsx(aa,{...e,...s})};Tt.Placeholder=aa;const Bm="_root_1hbar_1",Mm="_flexEnd_1hbar_6",Fm="_toggle_1hbar_11",Om="_route_1hbar_36",Um="_content_1hbar_43",zt={root:Bm,flexEnd:Mm,toggle:Fm,route:Om,content:Um};function Lm(e){const s=({name:n})=>n==="initia-dex"?"Initia DEX":Ns.capitalCase(w.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 zm=({addressList:e})=>{const{values:s,route:n}=Bt(),{source_asset_denom:r,source_asset_chain_id:o,amount_in:a,operations:i}=n,c=w.zipObj(n.required_chain_addresses,e),{find:l}=Ks(),{connector:d,address:u=""}=de.useAccount(),[h,m]=Ie.useToggle(!1),f=i.length>1,g=t.jsx(Y,{src:s.cosmosWalletName?l(s.cosmosWalletName)?.image:d?.icon,width:12,height:12}),p={amount:a,denom:r,chainId:o,address:s.sender,walletIcon:g},x=T=>v.InitiaAddress.equals(T,u)?g:t.jsx(A.IconWallet,{size:11}),S=T=>{const{label:P,amount_out:R,denom:B,denom_out:z=B,chain_id:j,from_chain_id:b,to_chain_id:y=j??b}=T,k=c[y];return{label:f&&!h?void 0:P,amount:R,denom:z,chainId:y,address:k,walletIcon:x(k)}},I=i.map(Lm).map(S),N=I.slice(0,-1),C=I[I.length-1];return t.jsxs(se.Collapsible.Root,{className:zt.root,open:h,onOpenChange:m,children:[f&&t.jsx("div",{className:zt.flexEnd,children:t.jsx(se.Collapsible.Trigger,{className:zt.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:zt.route,children:[t.jsx(Tt,{...p,source:!0}),t.jsx(se.Collapsible.Content,{className:zt.content,children:N.map((T,P)=>t.jsx(ye,{suspenseFallback:t.jsx(Tt.Placeholder,{...T}),errorBoundaryProps:{fallback:t.jsx(Tt.Placeholder,{...T})},children:t.jsx(Tt,{...T})},P))}),t.jsx(Tt,{...C})]})]})},kn=({error:e})=>{const s=he();return t.jsx(ie,{extra:t.jsx(oe,{level:"error",children:e.message}),children:t.jsx(J.White,{onClick:()=>s("/bridge"),children:"Home"})})},Km=({children:e})=>{const s=Bt(),{route:n,values:r}=s,{required_chain_addresses:o}=n,{srcChainId:a,dstChainId:i,sender:c,recipient:l}=r,{initiaAddress:d,hexAddress:u}=xe(),h=es(),m=vt(),f=ss(),g=m(a),p=f(g),x=o.slice(0,-1).some(R=>{const B=m(R);return f(B)==="cosmos"})&&p!=="cosmos",[S,I]=_.useState(void 0),[N,C]=_.useState(!1),[T,P]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!x)return;if(!h)throw new Error("Wallet not connected");C(!0),P(null);const[{pubkey:B}]=await h.getAccounts();I(B)}catch(B){P(await He(B))}finally{C(!1)}})()},[x,h]),T)return t.jsx(kn,{error:T});if(N)return t.jsx(ie,{children:t.jsx(J.White,{loading:N&&"Generating intermediary addresses..."})});if(!x||S){const R=o.map((B,z)=>{if(z===o.length-1){const q=m(i);return f(q)==="initia"?v.InitiaAddress(l).bech32:l}const j=m(B),b=f(j),y=m(a),k=f(y);switch(b){case"initia":return d;case"evm":return u;case"cosmos":{if(k==="cosmos")return V.toBech32(j.bech32_prefix,V.fromBech32(c).data);if(!S)throw new Error("Pubkey not found");return Qt.pubkeyToAddress(Qt.encodeSecp256k1Pubkey(S),j.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(R)}return null},Wm=({tx:e,children:s})=>{const n=fo(),r=vt(),{data:o,isLoading: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:h}=e.evm_tx,m=await n();await An(m,r(u));const f=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async p=>{const{token_contract:x,spender:S}=p,N=await new We.ethers.Contract(x,f,m).allowance(h,S);return{approval:p,currentAllowance:BigInt(N.toString())}}))).filter(({approval:p,currentAllowance:x})=>x<BigInt(p.amount)).map(({approval:p})=>p)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:c,isPending:l,error:d}=$.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 An(h,r(u));for(const f of o){const{token_contract:g,spender:p,amount:x}=f,S=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new We.ethers.Contract(g,S,m).approve(p,x)).wait()}return!0}catch(u){throw await He(u)}}});return a?t.jsx(ie,{children:t.jsx(J.White,{loading:"Checking approvals..."})}):o&&o.length>0&&!c?t.jsx(ie,{extra:t.jsx(oe,{level:"error",children:d?.message}),children:t.jsx(J.White,{onClick:()=>i(),loading:l&&"Approving tokens...",children:"Approve tokens"})}):s},Hm=({addressList:e,signedOpHook:s,children:n})=>{const r=Ye(),{route:o,values:a}=Bt(),[i,c]=_.useState(void 0),[l,d]=_.useState(!1),[u,h]=_.useState(null);return _.useEffect(()=>{(async()=>{try{if(o.required_op_hook&&!s)throw new Error("Op hook is required");d(!0),h(null);const f={address_list:e,amount_in:o.amount_in,amount_out:o.amount_out,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom,slippage_tolerance_percent:a.slippagePercent,operations:o.operations,signed_op_hook:s},{txs:g}=await r.post("v2/fungible/msgs",{json:f}).json();if(!g||g.length===0)throw new Error("No transaction data found");const[p]=g;c(p)}catch(f){h(f)}finally{d(!1)}})()},[o,a,e,s,r]),u?t.jsx(kn,{error:u}):l?t.jsx(ie,{children:t.jsx(J.White,{loading:l&&"Fetching messages..."})}):i?n(i):t.jsx(kn,{error:new Error("Failed to fetch messages")})},Qm=({children:e})=>{const{route:s}=Bt(),n=Wh();return s.required_op_hook&&!n.data?t.jsx(ie,{extra:t.jsx(oe,{level:"error",children:n.error?.message}),children:t.jsx(J.White,{onClick:()=>n.mutate(),loading:n.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(n.data)},Gm=()=>t.jsx(Oe,{title:"Route preview",children:t.jsx(Km,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(zm,{addressList:e}),t.jsx(Qm,{children:s=>t.jsx(Hm,{addressList:e,signedOpHook:s,children:n=>t.jsx(Wm,{tx:n,children:t.jsx(Nm,{tx:n})})})})]})})}),ia=_.createContext(null);function Qs(){return _.useContext(ia)}const bt=Ne.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 Gs(){const{restUrl:e}=_e();return _.useMemo(()=>L.create({prefixUrl:e}),[e])}function Vm(e){const s=Gs(),{data:n}=$.useSuspenseQuery({queryKey:bt.bridge(e).queryKey,queryFn:()=>s.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:Q.INFINITY});return n}const Sr=20;function Ym(e){const s=ee();return $.useSuspenseInfiniteQuery({queryKey:bt.withdrawals(e,s).queryKey,queryFn:async({pageParam:n})=>{if(!s)return[];const r={limit:Sr,offset:n,order:"desc"},{withdrawals:o}=await L.create({prefixUrl:e}).get(`withdrawals/${s}`,{searchParams:r}).json();return o},getNextPageParam:n=>{const r=w.last(n)?.sequence;return n.length<Sr||!r||r<=1?null:r-1},initialPageParam:0,staleTime:Q.SECOND})}function Jm(e){const s=Gs(),{data:n}=$.useSuspenseQuery({queryKey:bt.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:Q.SECOND});return n}function Zm({bridge_id:e,output_index:s}){const n=Gs(),{data:r}=$.useSuspenseQuery({queryKey:bt.output(e,s).queryKey,queryFn:async()=>{try{return await n.get(`opinit/ophost/v1/bridges/${e}/outputs/${s}`).json()}catch{return null}},staleTime:Q.SECOND});return r}function Xm({bridge_id:e,sequence:s}){const r=ae().find(({metadata:l})=>l?.op_bridge_id===e.toString())?.chain_id;if(!r)throw new Error(`Chain not found for bridge_id: ${e}`);const a=Te()(r);if(!a)throw new Error(`Chain not found: ${r}`);const i=a.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${r}`);const{data:c}=$.useSuspenseQuery({queryKey:bt.outputResponse(i,s).queryKey,queryFn:()=>L.create({prefixUrl:i}).get(`withdrawal/${s}`).json(),staleTime:Q.SECOND});return c}function ca(e,s){const{bridge_id:n}=e,r=Gs(),{data:o}=$.useSuspenseQuery({queryKey:bt.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:Q.SECOND});return o}function Kt(e){return ka.sha3_256.create().update(e).digest()}function fn(e,s){const n=new ArrayBuffer(s);return new DataView(n).setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}function la(e){const{bridge_id:s,sequence:n,amount:r,from:o,to:a}=e,i=fn(s.toString(),8),c=fn(n.toString(),8),l=fn(r.amount,8),d=_t.concatBytes(i,c,Kt(_t.utf8ToBytes(o)),Kt(_t.utf8ToBytes(a)),Kt(_t.utf8ToBytes(r.denom)),l);return Kt(Kt(d))}const ef="_button_17r1o_1",tf="_claimed_17r1o_24",Ar={button:ef,claimed:tf},sf=()=>{const{withdrawalTx:e}=Qs(),{bridge_id:s,sequence:n,amount:r,output_index:o,withdrawal_proofs:a,storage_root:i,from:c,to:l,version:d}=e,u=_e(),h=ee(),{requestTxSync:m,waitForTxConfirmation:f}=xe(),g=Xm(e),p=V.toBase64(la(e)),x=ca(e,p),S=$.useQueryClient(),{mutate:I,isPending:N}=$.useMutation({mutationFn:async()=>{if(!g)throw new Error("Output not found");const{last_block_hash:C}=g;return m({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:h,bridgeId:BigInt(s),outputIndex:BigInt(o),withdrawalProofs:a.map(V.fromBase64),from:c,to:l,sequence:BigInt(n),amount:r,version:V.fromBase64(d),storageRoot:V.fromBase64(i),lastBlockHash:V.fromBase64(C)}}],internal:!0})},onSuccess:async C=>{await f({chainId:u.chain_id,txHash:C}),S.invalidateQueries({queryKey:bt.withdrawalClaimed(s,p).queryKey})}});return x?t.jsxs("div",{className:Ar.claimed,children:[t.jsx(A.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:Ar.button,onClick:()=>I(),disabled:N,children:"Claim"})},nf=({children:e})=>{const{withdrawalTx:s}=Qs(),n=Vm(s.bridge_id),r=Zm(s),o=_.useMemo(()=>{if(!r)return null;const{bridge_config:a}=n,{output_proposal:i}=r;return ke.addSeconds(new Date(i.l1_block_time),parseFloat(a.finalization_period))},[n,r]);return e(o)},da=1e3,rf=60,of=60,af=24,$n=da*rf,Tn=$n*of,kr=Tn*af,cf=({date:e})=>{const s=_.useCallback(()=>{const d=new Date().getTime(),h=e.getTime()-d;if(h<=0)return{days:0,hours:0,minutes:0,seconds:0};const m=Math.floor(h/kr),f=Math.floor(h%kr/Tn),g=Math.floor(h%Tn/$n),p=Math.floor(h%$n/da);return{days:m,hours:f,minutes:g,seconds:p}},[e]),[n,r]=_.useState(s());_.useEffect(()=>{const d=window.setInterval(()=>{r(s())},1e3);return()=>window.clearInterval(d)},[s,e]);const o=d=>d.toString().padStart(2,"0"),{days:a,hours:i,minutes:c,seconds:l}=n;return t.jsx(rs,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[a,"d ",o(i),"h ",o(c),"m ",o(l),"s"]})})},lf="_container_1lz3w_1",df="_title_1lz3w_5",$r={container:lf,title:df},uf=({date:e})=>t.jsxs("div",{className:$r.container,children:[t.jsx("div",{className:$r.title,children:"Claimable in"}),t.jsx(cf,{date:e})]}),hf="_container_1oldz_1",mf="_icon_1oldz_7",Tr={container:hf,icon:mf},ff="Withdrawal will begin within an hour",Er=()=>{const e=Ls();return t.jsxs("div",{className:Tr.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(rs,{label:ff,children:t.jsx("span",{className:Tr.icon,children:t.jsx(A.IconInfoFilled,{size:12})})})]})},_f=({children:e})=>{const{withdrawalTx:s}=Qs(),n=Jm(s.bridge_id),r=s.output_index>Number(n?.output_index);return e(r)},gf=({date:e,children:s})=>{const{chainId:n,withdrawalTx:r}=Qs(),o=V.toBase64(la(r)),a=ca(r,o),{setReminder:i,removeReminder:c}=Rt();return _.useEffect(()=>{const l={chainId:n,txHash:r.tx_hash};a?c(l):i(l,{...l,recipient:r.to,claimableAt:e.getTime(),amount:r.amount.amount,denom:r.amount.denom,dismissed:ke.isPast(e.getTime())?!0:void 0})},[n,a,e,c,i,r]),s},pf=()=>t.jsx(_f,{children:e=>e?t.jsx(Er,{}):t.jsx(nf,{children:s=>s?t.jsx(gf,{date:s,children:ke.isFuture(s)?t.jsx(uf,{date:s}):t.jsx(sf,{})}):t.jsx(Er,{})})}),xf="_asset_6h8u2_1",yf="_info_6h8u2_7",jf="_symbol_6h8u2_11",_n={asset:xf,info:yf,symbol:jf},vf=({amount:e,denom:s})=>{const n=_e(),r=Zr(s,n),{symbol:o,logoUrl:a,decimals:i}=r;return t.jsxs("div",{className:_n.asset,children:[t.jsx(Y,{src:a,width:32,height:32,logo:!0}),t.jsxs("div",{className:_n.info,children:[t.jsx("span",{className:"monospace",children:v.formatAmount(e,{decimals:i})}),t.jsx("span",{className:_n.symbol,children:o})]})]})},wf="_item_km5w2_1",bf={item:wf},Cf=({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}=Ym(s),i=_.useMemo(()=>n?.pages.flat()??[],[n]),{syncReminders:c}=Rt();return _.useEffect(()=>{const l=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));c(l)},[e.chainId,i,c]),i.length?t.jsxs(t.Fragment,{children:[i.map(l=>{const{amount:d}=l;return t.jsxs("div",{className:bf.item,children:[t.jsx(vf,{...d}),t.jsx(ye,{suspenseFallback:null,children:t.jsx(ia.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:t.jsx(pf,{})})})]},l.sequence)}),o&&t.jsx(sa,{onClick:()=>r(),disabled:a})]}):t.jsx(ne,{children:"No withdrawals"})},If="_content_dj1qm_1",Nf="_title_dj1qm_5",qr={content:If,title:Nf},Sf=()=>{const{chainId:e}=jt(),s=ae(),n=Zt(),[r,o]=_.useState(e??(n.metadata?.is_l1?"":n.chainId)),a=Te(),{reminders:i}=Rt(),c=r?a(r):void 0;return t.jsxs(Oe,{title:"OP Bridge withdrawals",children:[t.jsx(xt,{chains:s.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:r,onSelect:o,getShowIndicator:l=>i.some(d=>d.chainId===l)}),t.jsx("div",{className:qr.content,children:c?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:qr.title,children:c.name}),t.jsx(ye,{children:t.jsx(Cf,{chain:c})},r)]}):t.jsx(oe,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},Af="_page_1g5uz_1",kf="_title_1g5uz_11",$f="_scrollable_1g5uz_18",Tf="_list_1g5uz_24",Ef="_item_1g5uz_35",qf="_name_1g5uz_59",Df="_dimmed_1g5uz_67",Pf="_recent_1g5uz_71",Rf="_installed_1g5uz_72",Se={page:Af,title:kf,scrollable:$f,list:Tf,item:Ef,name:qf,dimmed:Df,recent:Pf,installed:Rf},Bf=[{name:"Rabby",url:"https://rabby.io"},{name:"Phantom",url:"https://phantom.com"},{name:"Keplr",url:"https://keplr.app"},{name:"Leap",url:"https://leapwallet.io"}],Dr=({onSuccess:e})=>{const{connectors:s,connectAsync:n}=de.useConnect(),r=Ie.useReadLocalStorage("wagmi.recentConnectorId"),[o,a]=_.useState(null),{mutate:i,isPending:c}=$.useMutation({mutationFn:async l=>{a(l.id);try{await n({connector:l})}catch(d){throw await He(d)}},onSettled:()=>{a(null)},onSuccess:()=>{e?.()}});return t.jsxs("div",{className:Se.page,children:[t.jsx("h1",{className:Se.title,children:"Connect wallet"}),t.jsx(Fe,{className:Se.scrollable,children:t.jsxs("div",{className:Se.list,children:[s.toSorted(w.descend(l=>l.id===r)).map(l=>{const{name:d,icon:u,id:h}=l;return t.jsxs("button",{className:Se.item,onClick:()=>i(l),disabled:c,children:[t.jsx(Y,{src:u,width:24,height:24}),t.jsx("span",{className:Se.name,children:d}),o===h?t.jsx(wt,{size:16}):r===h?t.jsx("span",{className:Se.recent,children:"Recent"}):l.id===Ss.id?null:t.jsx("span",{className:Se.installed,children:"Installed"})]},h)}),Bf.filter(({name:l})=>!s.some(d=>d.name.includes(l))).map(({name:l,url:d})=>{const u=`https://assets.initia.xyz/images/wallets/${l}.webp`;return t.jsxs("a",{href:d,className:Se.item,target:"_blank",children:[t.jsx(Y,{src:u,width:24,height:24}),t.jsx("span",{className:D(Se.name,Se.dimmed),children:l}),t.jsx(A.IconExternalLink,{size:10})]},l)})]})})]})},Mf="_root_1lo0i_1",Ff="_address_1lo0i_9",Of="_copy_1lo0i_19",Uf="_labelWrapper_1lo0i_33",Lf="_labelCopy_1lo0i_43",zf="_labelCopied_1lo0i_47",Kf="_copied_1lo0i_55",Wf="_derived_1lo0i_65",Hf="_derivedLabel_1lo0i_79",Qf="_derivedAddress_1lo0i_83",Gf="_hexAddress_1lo0i_89",Vf="_derivedCopy_1lo0i_94",fe={root:Mf,address:Ff,copy:Of,labelWrapper:Uf,labelCopy:Lf,labelCopied:zf,copied:Kf,derived:Wf,derivedLabel:Hf,derivedAddress:Qf,hexAddress:Gf,derivedCopy:Vf},Yf=()=>{const e=_.useRef(null),s=_.useRef(null),{initiaAddress:n,hexAddress:r}=xe(),o=Eo("--gray-0");return _.useEffect(()=>{e.current&&(s.current?s.current.update({data:n}):(s.current=new $a({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.jsx(Oe,{title:"Receive",children:t.jsxs("div",{className:fe.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:fe.address,children:n}),t.jsx(vs,{value:n,children:({copy:a,copied:i})=>t.jsxs("button",{className:D(fe.copy,{[fe.copied]:i}),onClick:a,children:[t.jsx(A.IconCopy,{size:12}),t.jsxs("div",{className:fe.labelWrapper,children:[t.jsx("span",{className:fe.labelCopy,children:"Copy address"}),t.jsx("span",{className:fe.labelCopied,children:"Copied!"})]})]})}),t.jsx(vs,{value:r,children:({copy:a,copied:i})=>t.jsxs("button",{className:D(fe.derived,{[fe.copied]:i}),onClick:a,children:[t.jsx("span",{className:fe.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:fe.derivedAddress,children:[t.jsx("span",{className:fe.hexAddress,children:v.truncate(r)}),t.jsx(A.IconCopy,{size:12,className:fe.derivedCopy}),i&&t.jsx("span",{className:fe.copiedText,children:"Copied!"})]})]})})]})})};function Jf(){const e=ee(),s=ae();return $.useQueries({queries:s.map(n=>({queryKey:Yt.grants(n.chainId,e).queryKey,queryFn:async()=>{const{grants:r}=await L.create({prefixUrl:n.restUrl}).get(`cosmos/authz/v1beta1/grants/granter/${e}`).json();return{chainId:n.chainId,grants:r}},enabled:!!e,staleTime:Q.SECOND,retry:!1}))})}const Zf="_countdown_vfms8_1",Xf={countdown:Zf},e_=({expiration:e})=>{const s=()=>{const o=new Date,a=ke.differenceInSeconds(e,o),i=Math.floor(a/(1440*60)),c=Math.floor(a%(1440*60)/3600),l=Math.floor(a%3600/60),d=a%60,u=[];return i>0&&u.push(`${i}d`),(c>0||i>0)&&u.push(`${c}h`),(l>0||c>0||i>0)&&u.push(`${l}m`),u.push(`${d}s`),u.join(" ")},[n,r]=_.useState(s());return Ie.useInterval(()=>{r(s())},1e3),ke.isPast(e)?"Expired":t.jsxs(t.Fragment,{children:["Expires in ",t.jsx("span",{className:Xf.countdown,children:n})]})},t_="_container_1l528_1",s_="_info_1l528_11",n_="_header_1l528_17",r_="_chainName_1l528_23",o_="_expiration_1l528_29",a_="_revokeButton_1l528_35",St={container:t_,info:s_,header:n_,chainName:r_,expiration:o_,revokeButton:a_},i_=({chainId:e,grantee:s,messageTypes:n,expiration:r})=>{const o=Me(e),{mutate:a,isPending:i}=No({grantee:s,internal:!0});return t.jsxs("div",{className:St.container,children:[t.jsxs("div",{className:St.info,children:[t.jsxs("div",{className:St.header,children:[t.jsx(Y,{src:o.logoUrl,width:16,height:16,logo:!0}),t.jsx("div",{className:St.chainName,children:o.name})]}),t.jsx("div",{className:St.expiration,children:r?t.jsx(e_,{expiration:r}):"Until revoked"})]}),t.jsx("button",{className:St.revokeButton,onClick:()=>a(e),disabled:i,children:i?"Revoking...":"Revoke"})]})},c_=({chainId:e,grants:s})=>Object.values(s.reduce((r,o)=>{const a=r[o.grantee];return a?{...r,[o.grantee]:{...a,messageTypes:[...a.messageTypes,o.authorization.msg],expiration:Un([a.expiration,o.expiration?new Date(o.expiration):void 0])}}:{...r,[o.grantee]:{grantee:o.grantee,messageTypes:[o.authorization.msg],expiration:o.expiration?new Date(o.expiration):void 0}}},{})).map(r=>_.createElement(i_,{...r,chainId:e,key:r.grantee})),l_="_content_q36qs_1",d_={content:l_},u_=()=>{const e=Jf(),s=()=>{const n=e.filter(r=>r.data&&r.data.grants.length>0).map(r=>r.data);return n.length===0?t.jsx(ne,{children:"No permissions found"}):t.jsx("div",{className:d_.content,children:n.map(({chainId:r,grants:o})=>t.jsx(c_,{chainId:r,grants:o},r))})};return t.jsx(Oe,{title:"Manage auto-signing",backButton:"/settings",children:s()})},h_="2.1.1",m_="_version_1sf5y_1",f_={version:m_},__=()=>t.jsxs("aside",{className:f_.version,children:["v",h_]}),g_="_link_se23z_1",p_="_title_se23z_17",x_="_subtitle_se23z_23",y_="_icon_se23z_30",fs={link:g_,title:p_,subtitle:x_,icon:y_},ua=({title:e,subtitle:s,rightSection:n,onClick:r})=>t.jsxs("button",{className:fs.link,onClick:r,children:[t.jsxs("div",{children:[t.jsx("p",{className:fs.title,children:e}),s&&t.jsx("p",{className:fs.subtitle,children:s})]}),t.jsx("div",{className:fs.icon,children:n??t.jsx(A.IconChevronRight,{size:16})})]}),j_="https://export.initia.xyz/",v_=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return t.jsx(ua,{title:"Export private key",rightSection:t.jsx(A.IconExternalLink,{size:16}),onClick:()=>window.open(j_,"_blank",e)})},w_="_container_1vxr7_1",b_="_separator_1vxr7_7",Pr={container:w_,separator:b_},C_=()=>{const e=he(),{connector:s}=de.useAccount();return t.jsx(Oe,{title:"Settings",backButton:"/",children:t.jsxs("div",{className:Pr.container,children:[t.jsx(ua,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),s?.id===Pn&&t.jsx(v_,{}),t.jsx(Ke.Separator,{className:Pr.separator}),t.jsx(__,{})]})})},I_="_trigger_1hs5b_1",N_="_icon_1hs5b_23",S_="_full_1hs5b_27",A_="_triggerContent_1hs5b_32",k_="_triggerText_1hs5b_40",$_="_popoverBackdrop_1hs5b_51",T_="_popoverPositioner_1hs5b_70",E_="_popoverPopup_1hs5b_74",q_="_search_1hs5b_99",D_="_viewport_1hs5b_105",P_="_item_1hs5b_111",R_="_highlighted_1hs5b_126",B_="_active_1hs5b_130",M_="_name_1hs5b_135",F_="_extra_1hs5b_139",le={trigger:I_,icon:N_,full:S_,triggerContent:A_,triggerText:k_,popoverBackdrop:$_,popoverPositioner:T_,popoverPopup:E_,search:q_,viewport:D_,item:P_,highlighted:R_,active:B_,name:M_,extra:F_},Yn=({value:e,onChange:s,chainIds:n,renderExtra:r,fullWidth:o})=>{const[a,i]=_.useState(""),[c,l]=_.useState(!1),[d,u]=_.useState(0),[h,m]=_.useState(),f=_.useRef([]),g=_.useRef(null),p=ae(),x=n.map(j=>p.find(b=>b.chainId===j)).filter(Boolean),S=j=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:j,height:j,viewBox:"0 0 14 14",children:[t.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),t.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),I=_.useMemo(()=>({chainId:"",name:"All",logoUrl:S}),[]),N=_.useMemo(()=>{const j=[I,...x];if(!a)return j;const b=a.toLowerCase();return j.filter(y=>y.name.toLowerCase().includes(b)||y.chainId.toLowerCase().includes(b))},[x,a,I]),C=x.find(j=>j.chainId===e)||I,T=parseInt(Eo("--drawer-offset")),P=6,R=()=>{if(i(""),u(-1),g.current){const b=g.current.getBoundingClientRect().bottom+P,y=window.innerHeight-b-2*T;m(y)}l(!0)};_.useEffect(()=>{d>=0&&d<f.current.length&&f.current[d]?.scrollIntoView({block:"nearest",behavior:"auto"})},[d]);const B=_.useCallback(j=>{switch(j.key){case"ArrowDown":j.preventDefault(),u(b=>(b+1)%N.length);break;case"ArrowUp":j.preventDefault(),u(b=>(b-1+N.length)%N.length);break;case"Enter":j.preventDefault(),N[d]&&(s(N[d].chainId),l(!1));break;case"Escape":j.preventDefault(),l(!1);break}},[N,d,s,l]),z=j=>{s(j),l(!1)};return t.jsxs(It.Popover.Root,{open:c,onOpenChange:R,modal:"trap-focus",children:[t.jsx(It.Popover.Trigger,{render:t.jsxs("button",{className:D(le.trigger,{[le.full]:o}),"aria-expanded":c,role:"listbox",ref:g,children:[t.jsxs("div",{className:le.triggerContent,children:[typeof C.logoUrl=="string"?t.jsx(Y,{src:C.logoUrl,width:14,height:14,logo:!0}):C.logoUrl(14),t.jsx("span",{className:le.triggerText,children:C.name})]}),t.jsx(A.IconChevronDown,{size:16,className:le.icon})]})}),t.jsxs(It.Popover.Portal,{container:yt(),children:[t.jsx(It.Popover.Backdrop,{className:le.popoverBackdrop,onClick:()=>l(!1)}),t.jsx(It.Popover.Positioner,{className:le.popoverPositioner,align:"end",side:"bottom",sideOffset:P,collisionAvoidance:{side:"none"},children:t.jsxs(It.Popover.Popup,{className:D(le.popoverPopup,{[le.full]:o}),style:{maxHeight:h},children:[t.jsx(Hs,{value:a,onChange:j=>{i(j.target.value),u(0)},onClear:()=>i(""),onKeyDown:B,placeholder:"Search appchains",rootClassName:le.search,ref:ns()}),t.jsx("div",{className:le.viewport,role:"listbox",children:N.length===0?t.jsx(ne,{children:"No appchains found"}):N.map(({chainId:j,name:b,logoUrl:y},k)=>t.jsxs("div",{className:D(le.item,{[le.highlighted]:k===d,[le.active]:e===j}),onClick:()=>z(j),onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),z(j))},onMouseEnter:()=>u(k),role:"option","aria-selected":e===j,tabIndex:-1,ref:q=>{q&&(f.current[k]=q)},children:[typeof y=="string"?t.jsx(Y,{src:y,width:16,height:16,logo:!0}):y(16),t.jsx("span",{className:le.name,children:b}),r&&t.jsx("span",{className:le.extra,children:r(j)})]},j))})]})})]})]})},O_="_container_1nap1_1",U_="_controls_1nap1_7",L_="_search_1nap1_13",Jn={container:O_,controls:U_,search:L_},z_=({children:e})=>t.jsx("div",{className:Jn.container,children:e}),K_=({children:e})=>t.jsx("div",{className:Jn.controls,children:e}),W_=e=>t.jsx(Hs,{...e,rootClassName:Jn.search}),nt={Root:z_,Controls:K_,SearchInput:W_},H_=H.atom(""),Q_=H.atom(""),G_=H.atom(""),V_=H.atom(""),Y_=H.atom(""),J_="_change_1x9v4_1",Z_="_positive_1x9v4_10",X_="_negative_1x9v4_14",gn={change:J_,positive:Z_,negative:X_},ha=({amount:e,asset:s})=>{const{denom:n,symbol:r,decimals:o}=s,a=new F(e).isPositive(),i=new F(e).abs().toString();return t.jsxs("div",{className:D(gn.change,a?gn.positive:gn.negative),children:[a?"+":"-",v.formatAmount(i,{decimals:o})," ",r||n]})},eg=({changes:e,chain:s})=>{const n=Ge(s);return e.map(({amount:r,denom:o},a)=>t.jsx(ha,{amount:r,asset:n(o)},a))},tg=({changes:e,chain:s})=>{const n=Ge(s);return e.map(({amount:r,metadata:o},a)=>t.jsx(Lo,{metadata:o,chain:s,children:i=>t.jsx(ha,{amount:r,asset:n(i)})},a))},sg=({events:e,chain:s})=>{const{initiaAddress:n,hexAddress:r}=xe();return s.metadata?.is_l1||s.metadata?.minitia?.type==="minimove"?t.jsx(tg,{changes:Uo(e,r),chain:s}):t.jsx(eg,{changes:Oo(e,n),chain:s})},ng="_message_1g2hc_1",rg="_more_1g2hc_8",Rr={message:ng,more:rg},og=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((s,n)=>t.jsx("p",{className:Rr.message,children:Ns.sentenceCase(s["@type"].split("Msg")[1])},n)),e.length>3&&t.jsx("footer",{className:Rr.more,children:`+${e.length-3} more`})]}),ag="_link_fuhbt_1",ig="_inner_fuhbt_16",cg="_header_fuhbt_21",lg="_time_fuhbt_30",dg="_error_fuhbt_36",ug="_timestamp_fuhbt_40",hg="_chainInfo_fuhbt_45",mg="_content_fuhbt_53",fg="_messages_fuhbt_61",_g="_changes_fuhbt_67",De={link:ag,inner:ig,header:cg,time:lg,error:dg,timestamp:ug,chainInfo:hg,content:mg,messages:fg,changes:_g},gg=({txItem:e,chain:s})=>t.jsx(zs,{txHash:e.txhash,chainId:s.chainId,className:De.link,children:t.jsxs("div",{className:De.inner,children:[t.jsxs("div",{className:De.header,children:[t.jsxs("div",{className:De.time,children:[e.code!==0&&t.jsx(A.IconWarningFilled,{size:14,className:De.error}),t.jsx("span",{className:De.timestamp,children:ke.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:De.chainInfo,children:[t.jsx(Y,{src:s.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:s.name})]})]}),t.jsxs("div",{className:De.content,children:[t.jsx("div",{className:De.messages,children:t.jsx(og,{messages:e.tx.body.messages})}),t.jsx("div",{className:De.changes,children:t.jsx(ye,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(sg,{...e,chain:s})})})]})]})}),pg="_list_1mv55_1",xg="_dateGroup_1mv55_7",yg="_dateHeader_1mv55_12",jg="_more_1mv55_18",_s={list:pg,dateGroup:xg,dateHeader:yg,more:jg},vg=({list:e,chainId:s})=>{const n=ee(),r=_.useMemo(()=>na(e,o=>{if(o.timestamp)return new Date(o.timestamp)}),[e]);return e.length===0?t.jsx(ne,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:_s.list,children:Object.entries(r).map(([o,a])=>t.jsxs("div",{className:_s.dateGroup,children:[t.jsx("div",{className:_s.dateHeader,children:o}),a.map(i=>t.jsx(ye,{errorBoundaryProps:{fallback:null},children:t.jsx(gg,{txItem:i,chain:i.chain})},i.txhash))]},o))}),t.jsx(zs,{chainId:s,accountAddress:n,pathSuffix:"/txs",className:_s.more,showIcon:!0,children:"View more on Initia Scan"})]})},wg=()=>{const{activities:e,isLoading:s}=Fc(),[n,r]=H.useAtom(Y_),o=_e(),a=_.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=_.useMemo(()=>n?e.filter(c=>c.chain.chainId===n):e,[e,n]);return s&&e.length===0?t.jsx(ne,{children:"Loading activities..."}):!e.length&&!s?t.jsx(ne,{children:"No activity yet"}):t.jsxs(nt.Root,{children:[t.jsx(nt.Controls,{children:t.jsx(Yn,{value:n,onChange:r,chainIds:a,fullWidth:!0})}),t.jsx(vg,{list:i,chainId:n||o.chainId})]})},ma=_.createContext(null);function fa(){return _.useContext(ma)}const bg="_popup_nbecp_1",Cg="_item_nbecp_19",gs={popup:bg,item:Cg},_a=({asset:e,children:s})=>{const{denom:n,decimals:r,symbol:o,logoUrl:a,unlisted:i,address:c,chain:l}=e,{chainId:d}=l,[u,h]=_.useState(!1),m=he(),f=fa(),{showNotification:g}=Hn(),{defaultChainId:p}=X(),{evm_chain_id:x}=Zt(),S=de.useChainId(),{switchChainAsync:I}=de.useSwitchChain(),{watchAssetAsync:N}=de.useWatchAsset(),C=()=>{h(!1),m("/send",{denom:n,chain:l})},T=()=>{h(!1),m("/bridge",{srcChainId:d,srcDenom:n,quantity:""})},P=$.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const R=a;return await I({chainId:Number(x)}),N({type:"ERC20",options:{address:c,symbol:o,decimals:r,image:R}})},onSuccess:()=>{g({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:R=>{g({type:"error",title:"Asset addition failed",description:R.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:f,children:t.jsx(Ke.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(Ke.Menu.Popup,{className:gs.popup,children:[t.jsxs(Ke.Menu.Item,{className:gs.item,onClick:C,children:[t.jsx(A.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(Ke.Menu.Item,{className:gs.item,onClick:T,disabled:i,children:[t.jsx(A.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===p&&x===S&&!!c&&t.jsxs(Ke.Menu.Item,{className:gs.item,onClick:()=>P.mutate(),disabled:P.isPending||P.data,children:[P.data?t.jsx(A.IconCheck,{size:16}):t.jsx(A.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},Ig="_item_38qhm_1",Ng="_info_38qhm_23",Sg="_images_38qhm_29",Ag="_name_38qhm_33",kg="_value_38qhm_39",$g="_amount_38qhm_47",Tg="_usd_38qhm_53",mt={item:Ig,info:Ng,images:Sg,name:Ag,value:kg,amount:$g,usd:Tg},Eg=({asset:e})=>{const{amount:s,value:n,logoUrl:r,chain:o}=e,a=v.formatAmount(s,{decimals:e.decimals});return t.jsx(_a,{asset:e,children:t.jsxs("button",{className:mt.item,children:[t.jsxs("div",{className:mt.info,children:[t.jsx(Ws,{assetLogoUrl:r,chainLogoUrl:o.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:mt.images}),t.jsx("span",{className:mt.name,children:o.name})]}),t.jsxs("div",{className:mt.value,children:[t.jsx("span",{className:mt.amount,children:a}),Number(n)>0&&t.jsx("span",{className:mt.usd,children:$e(n)})]})]})})},qg="_container_10heg_1",Dg="_assetItem_10heg_6",Pg="_assetInfo_10heg_27",Rg="_logo_10heg_33",Bg="_symbol_10heg_37",Mg="_chainName_10heg_48",Fg="_chainInfos_10heg_54",Og="_chainLogos_10heg_60",Ug="_chainLogo_10heg_60",Lg="_moreChains_10heg_71",zg="_expandIcon_10heg_84",Kg="_expanded_10heg_88",Wg="_valueColumn_10heg_93",Hg="_amount_10heg_103",Qg="_value_10heg_93",Gg="_collapsibleContent_10heg_116",Vg="_chainsList_10heg_146",re={container:qg,assetItem:Dg,assetInfo:Pg,logo:Rg,symbol:Bg,chainName:Mg,chainInfos:Fg,chainLogos:Og,chainLogo:Ug,moreChains:Lg,expandIcon:zg,expanded:Kg,valueColumn:Wg,amount:Hg,value:Qg,collapsibleContent:Gg,chainsList:Vg},Yg=H.atom([]),ga=({assetGroup:e})=>{const{symbol:s,logoUrl:n,assets:r}=e,o=r.length===1,[a,i]=H.useAtom(Yg),c=_.useMemo(()=>fi(e),[e]),l=_.useMemo(()=>Ln(e),[e]),d=a.includes(s),u=()=>{i(m=>d?w.without([s],m):w.uniq([...m,s]))},h=()=>t.jsxs("button",{className:re.assetItem,children:[t.jsxs("div",{className:re.assetInfo,children:[n&&t.jsx(Y,{src:n,width:32,height:32,className:re.logo,logo:!0}),t.jsxs("div",{className:re.details,children:[t.jsx("div",{className:re.symbol,children:s}),o?t.jsx("div",{className:re.chainName,children:r[0].chain.name}):t.jsxs("div",{className:re.chainInfos,children:[t.jsx("div",{className:re.chainLogos,children:r.slice(0,5).map(({chain:m})=>t.jsx(Y,{src:m.logoUrl,width:16,height:16,className:re.chainLogo,logo:!0},m.chainId))}),r.length>5&&t.jsxs("span",{className:re.moreChains,children:["+",r.length-5]}),t.jsx(A.IconChevronDown,{size:16,className:D(re.expandIcon,{[re.expanded]:d})})]})]})]}),t.jsxs("div",{className:re.valueColumn,children:[t.jsx("div",{className:re.amount,children:v.formatNumber(c,{dp:r[0].unlisted?0:6})}),l>0&&t.jsx("div",{className:re.value,children:$e(l)})]})]});if(o){const[m]=r;return t.jsx("div",{className:re.container,children:t.jsx(_a,{asset:m,children:h()})})}return t.jsx("div",{className:re.container,children:t.jsxs(se.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(se.Collapsible.Trigger,{asChild:!0,children:h()}),t.jsx(se.Collapsible.Content,{className:re.collapsibleContent,children:t.jsx("div",{className:re.chainsList,children:r.map(m=>t.jsx(Eg,{asset:m},m.chain.chainId))})})]})})},Jg="_collapsible_1g7rh_1",Zg="_trigger_1g7rh_5",Xg="_divider_1g7rh_20",ep="_label_1g7rh_28",tp="_chevron_1g7rh_33",sp="_content_1g7rh_41",np="_list_1g7rh_45",tt={collapsible:Jg,trigger:Zg,divider:Xg,label:ep,chevron:tp,content:sp,list:np},rp=({unlistedAssets:e})=>{const[s,n]=_.useState(!0),r=fa(),o=_.useRef(null),[a,i]=_.useState(0);_.useEffect(()=>{if(o.current){const d=o.current.scrollHeight;i(d)}},[e]);const c=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)},l=rt.useSpring({height:s?a:0,opacity:s?1:0,config:{tension:500,friction:30,clamp:!0}});return e.length===0?null:t.jsxs(se.Collapsible.Root,{open:s,onOpenChange:c,className:tt.collapsible,children:[t.jsxs(se.Collapsible.Trigger,{className:tt.trigger,children:[t.jsx("div",{className:tt.divider}),t.jsxs("span",{className:tt.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(A.IconChevronDown,{className:tt.chevron,size:12,"data-state":s?"open":"closed"}),t.jsx("div",{className:tt.divider})]}),t.jsx(se.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(rt.animated.div,{className:tt.content,style:l,children:t.jsx("div",{className:tt.list,ref:o,children:e.map(d=>t.jsx(ga,{assetGroup:{...d,assets:[d]}},d.denom))})})})]})},op="_list_szwvw_1",ap={list:op},ip=()=>{const[e,s]=H.useAtom(H_),[n,r]=H.useAtom(Q_),{assetGroups:o,unlistedAssets:a,chainsByValue:i,totalValue:c,isLoading:l}=zn(),d=i.map(({chainId:m})=>m),u=_.useMemo(()=>{const m=e?o.filter(g=>{const{symbol:p,assets:x}=g;return p.toLowerCase().includes(e.toLowerCase())||x.some(({denom:S,address:I})=>S.toLowerCase().includes(e.toLowerCase())||I?.toLowerCase().includes(e.toLowerCase()))}):o;return n?m.map(g=>({...g,assets:g.assets.filter(({chain:p})=>p.chainId===n)})).filter(g=>g.assets.length>0):m},[o,e,n]),h=_.useMemo(()=>{const m=e?a.filter(({denom:g,address:p})=>g.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):a;return n?m.filter(({chain:g})=>g.chainId===n):m},[a,e,n]);return l&&o.length===0?t.jsx(ne,{children:"Loading assets..."}):!u.length&&!h.length&&!e&&!n&&!l?t.jsx(ne,{children:"No assets"}):t.jsxs(nt.Root,{children:[t.jsxs(nt.Controls,{children:[t.jsx(nt.SearchInput,{value:e,onChange:m=>s(m.target.value),onClear:()=>s(""),placeholder:"Search assets"}),t.jsx(Yn,{value:n,onChange:r,chainIds:d,renderExtra:m=>{if(!m)return $e(c);const f=i.find(g=>g.chainId===m);return f?$e(f.value):null}})]}),t.jsx("div",{children:u.length===0&&h.length===0?t.jsx(ne,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ap.list,children:u.map(m=>t.jsx(ga,{assetGroup:m},m.symbol))}),t.jsx(rp,{unlistedAssets:h})]})})]})},cp="_thumbnail_1xyqw_1",lp="_placeholder_1xyqw_18",dp="_clickable_1xyqw_24",Wt={thumbnail:cp,placeholder:lp,clickable:dp},up=({nftInfo:e,size:s,onClick:n})=>{const{collection_addr:r,object_addr:o,nft:a,chain:i}=e,{glyphUrl:c}=X(),l=new URL(`/v1/${i.chainId}/${r}/${o||a.token_id}`,c).toString();return n?t.jsx("button",{className:D(Wt.thumbnail,Wt.clickable),onClick:n,style:{width:s,height:s},children:t.jsx(Y,{src:l,classNames:{placeholder:Wt.placeholder}})}):t.jsx("div",{className:Wt.thumbnail,style:{width:s,height:s},children:t.jsx(Y,{src:l,classNames:{placeholder:Wt.placeholder}})})},hp="_collectionName_qs5tw_1",mp="_nftName_qs5tw_6",fp="_chainInfo_qs5tw_10",pn={collectionName:hp,nftName:mp,chainInfo:fp},Zn=({normalizedNft:e,onThumbnailClick:s,thumbnailSize:n,chainIconSize:r=12,classNames:o})=>{const{collection_name:a,name:i,chain:c}=e;return t.jsxs("div",{className:o?.root,children:[t.jsx(up,{nftInfo:e,onClick:s,size:n}),t.jsxs("div",{children:[t.jsx("div",{className:D(pn.collectionName,o?.collectionName),children:a}),t.jsx("div",{className:D(pn.nftName,o?.nftName),children:i}),t.jsxs("div",{className:D(pn.chainInfo,o?.chainInfo),children:[t.jsx(Y,{src:c.logoUrl,width:r,height:r,logo:!0}),t.jsx("span",{children:c.name})]})]})]})},Xn=Ne.createQueryKeys("interwovenkit:nft",{nfts:(e,s)=>[e,s],metadata:e=>[e]});function _p(e,s){const{nft:n}=e,r=s.name??n.token_id;return{...e,...n,...s,name:r}}function gp(e,s){return e.flatMap((n,r)=>(s[r]??[]).map(a=>({...a,chain:n})))}const pp=()=>{const e=ee(),s=ae(),n=$.useQueries({queries:s.map(l=>({queryKey:Xn.nfts(l.indexerUrl,e).queryKey,queryFn:()=>eo(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:Q.SECOND}))}),r=n.map(w.prop("data")),o=gp(s,r),a=o.reduce((l,{chain:d})=>({...l,[d.chainId]:(l[d.chainId]||0)+1}),{}),i=Object.values(a).reduce((l,d)=>l+d,0),c=n.some(l=>l.isLoading);return{nftInfos:o,chainCounts:a,totalCount:i,isLoading:c}};function xp(e){const s=Br(e);return $.useQuery({queryKey:Xn.metadata(s).queryKey,queryFn:async()=>{try{if(!s)return{};const n=await L.get(s).json();return{...n,image:Br(n.image)}}catch{return{}}},staleTime:Q.INFINITY})}function Br(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const yp=({nftInfo:e,children:s})=>{const{data:n={}}=xp(e.nft.uri),r=_p(e,n);return s(r)},jp="_grid_1wwdn_1",vp="_root_1wwdn_7",wp="_collectionName_1wwdn_15",bp="_nftName_1wwdn_23",Cp="_chainInfo_1wwdn_32",Mr={grid:jp,root:vp,collectionName:wp,nftName:bp,chainInfo:Cp},Ip=()=>{const[e,s]=H.useAtom(G_),[n,r]=H.useAtom(V_),{nftInfos:o,chainCounts:a,totalCount:i,isLoading:c}=pp(),l=he(),d=_.useMemo(()=>o.filter(({collection_addr:h,collection_name:m,nft:f,object_addr:g,chain:p})=>{if(n&&p.chainId!==n)return!1;if(e){const x=e.trim().toLowerCase();return h.toLowerCase().includes(x)||m.toLowerCase().includes(x)||f.token_id.toLowerCase().includes(x)||g.toLowerCase().includes(x)}return!0}),[o,n,e]),u=_.useMemo(()=>Array.from(new Set(o.map(({chain:h})=>h.chainId))),[o]);return c&&o.length===0?t.jsx(ne,{children:"Loading NFTs..."}):!o.length&&!e&&!c?t.jsx(ne,{children:"No NFTs"}):t.jsxs(nt.Root,{children:[t.jsxs(nt.Controls,{children:[t.jsx(nt.SearchInput,{value:e,onChange:h=>s(h.target.value),onClear:()=>s(""),placeholder:"Search NFTs"}),t.jsx(Yn,{value:n,onChange:r,chainIds:u,renderExtra:h=>h?a[h]||0:i})]}),d.length===0?t.jsx(ne,{children:"No NFTs found"}):t.jsx("div",{className:Mr.grid,children:d.map(h=>{const{collection_addr:m,nft:f}=h;return t.jsx(yp,{nftInfo:h,children:g=>t.jsx(Zn,{normalizedNft:g,onThumbnailClick:()=>l("/nft",g),classNames:Mr})},m+f.token_id)})})]})},Np="_totalValue_znvjc_1",Sp="_totalLabel_znvjc_7",Ap="_totalAmount_znvjc_13",kp="_loading_znvjc_18",$p="_nav_znvjc_23",Tp="_item_znvjc_29",Ep="_tabs_znvjc_54",qp="_tab_znvjc_54",we={totalValue:Np,totalLabel:Sp,totalAmount:Ap,loading:kp,nav:$p,item:Tp,tabs:Ep,tab:qp},Dp=()=>{Yo();const e=he(),s=Es(),{totalValue:n,isLoading:r}=zn(),o=_.useRef(null);return t.jsx(ma.Provider,{value:o,children:t.jsxs(Fe,{ref:o,children:[t.jsxs("div",{className:we.totalValue,children:[t.jsx("div",{className:we.totalLabel,children:"Total value"}),t.jsx("div",{className:D(we.totalAmount,{[we.loading]:r}),children:$e(n)})]}),t.jsxs("div",{className:we.nav,children:[t.jsxs(Et,{to:"/send",className:we.item,children:[t.jsx(A.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(Et,{to:"/bridge",className:we.item,children:[t.jsx(A.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),t.jsxs(Et,{to:"/receive",className:we.item,children:[t.jsx(A.IconQrCode,{size:16}),t.jsx("span",{children:"Receive"})]})]}),t.jsxs(Ze.Tabs.Root,{value:s,onValueChange:e,children:[t.jsxs(Ze.Tabs.List,{className:we.tabs,children:[t.jsx(Ze.Tabs.Tab,{className:we.tab,value:"/",children:"Assets"}),t.jsx(Ze.Tabs.Tab,{className:we.tab,value:"/nfts",children:"NFTs"}),t.jsx(Ze.Tabs.Tab,{className:we.tab,value:"/activity",children:"Activity"})]}),t.jsx(Ze.Tabs.Panel,{value:"/",children:t.jsx(ip,{})}),t.jsx(Ze.Tabs.Panel,{value:"/nfts",children:t.jsx(Ip,{})}),t.jsx(Ze.Tabs.Panel,{value:"/activity",children:t.jsx(wg,{})})]})]})})},Pp="_root_th990_1",Rp="_collectionName_th990_9",Bp="_nftName_th990_13",Mp="_chainInfo_th990_17",Fp="_attributes_th990_21",Op="_title_th990_24",Up="_count_th990_29",Lp="_item_th990_33",zp="_type_th990_39",Kp="_value_th990_45",ft={root:Pp,collectionName:Rp,nftName:Bp,chainInfo:Mp,attributes:Fp,title:Op,count:Up,item:Lp,type:zp,value:Kp},Wp=()=>{const e=he(),s=jt(),{attributes:n}=s;return t.jsxs(Oe,{title:"NFT details",children:[t.jsx(Zn,{normalizedNft:s,chainIconSize:14,classNames:ft}),t.jsx(ie,{children:t.jsx(J.White,{onClick:()=>e("/nft/send",s),sm:!0,children:"Send"})}),n&&t.jsxs("div",{className:ft.attributes,children:[t.jsxs("header",{className:ft.title,children:["Traits ",t.jsxs("span",{className:ft.count,children:["(",n.length,")"]})]}),t.jsx("div",{children:n.map(({trait_type:r,value:o})=>t.jsxs("div",{className:ft.item,children:[t.jsx("div",{className:ft.type,children:r}),t.jsx("div",{className:ft.value,children:o})]},r))})]})]})};function Hp({balances:e,gasPrices:s,gas:n}){return s.map(({denom:r,amount:o})=>{const a=F(o).times(n).toFixed(0,F.ROUND_CEIL),i=e.find(c=>c.denom===r)?.amount??"0";return{amount:a,denom:r,balance:i}}).filter(({amount:r,balance:o})=>F(o).gte(r))}function Qp({denom:e,balances:s,gasPrices:n,lastFeeDenom:r,gas:o}){const a=s.find(d=>d.denom===e)?.amount??"0",i=Hp({balances:s,gasPrices:n,gas:o}),c=i.find(d=>d.denom===r);if(i.length===0)return a;if(e===r&&c){const d=F(a).minus(c.amount);return F.max(d,0).toString()}const l=i.find(d=>d.denom!==e)||i[0];if(!c&&e===l.denom){const d=F(a).minus(l.amount);return F.max(d,0).toString()}return F(a).toString()}const Gp=({chain:e,onSelect:s})=>{const n=Wa(e);return t.jsx(os,{assets:n,onSelect:s})},Vp=({afterSelect:e})=>{const{watch:s,setValue:n}=ue.useFormContext(),{chainId:r,denom:o}=s(),{chainId:a}=s(),[i,c]=_.useState(a),l=Me(i),d=ae(),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(xt.Stack,{children:t.jsx(xt,{chains:d,value:i,onSelect:c})}),t.jsx(ye,{suspenseFallback:t.jsx(os.Placeholder,{}),children:t.jsx(Gp,{chain:l,onSelect:u})},i)]})},Yp="_fields_brpej_1",Jp="_divider_brpej_11",Fr={fields:Yp,divider:Jp},Zp=Ne.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Xp=()=>{const{address:e,initiaAddress:s,estimateGas:n,requestTxSync:r}=xe(),{register:o,watch:a,setValue:i,handleSubmit:c,formState:l}=ue.useFormContext(),{errors:d}=l,{chainId:u,denom:h,recipient:m,quantity:f,memo:g}=a(),p=Me(u),x=Bn(p),S=Bo(p),I=Mo(p),N=Zr(h,p),{data:C}=ks(p),{decimals:T}=N,P=x.find(O=>O.denom===h)?.amount??"0",R=C?.find(({id:O})=>O===h)?.price,{data:B=0,isLoading:z}=$.useQuery({queryKey:Zp.gas({chainId:u,denom:h,recipient:m,initiaAddress:s}).queryKey,queryFn:()=>{const O=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ir.MsgSend.fromPartial({fromAddress:s,toAddress:v.InitiaAddress(m).bech32,amount:[{denom:h,amount:"1"}]})}];return n({messages:O,chainId:u})},enabled:v.InitiaAddress.validate(m),staleTime:Q.INFINITY}),j=Math.ceil(B*Gt),b=Qp({denom:h,balances:x,gasPrices:S,lastFeeDenom:I,gas:j}),y=F(P).isZero(),q=S.some(({denom:O})=>O===h)&&z,M=y||q,{mutate:E,isPending:G}=$.useMutation({mutationFn:({chainId:O,denom:Z,quantity:Ue,recipient:Je,memo:at})=>{const me=v.toBaseUnit(Ue,{decimals:T}),ge=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ir.MsgSend.fromPartial({fromAddress:s,toAddress:v.InitiaAddress(Je).bech32,amount:[{denom:Z,amount:me}]})}];return r({messages:ge,memo:at,chainId:O,gas:B,gasAdjustment:Gt,gasPrices:S,spendCoins:[{denom:Z,amount:me}],internal:"/"})}}),te=_.useMemo(()=>{if(!f)return"Enter amount";if(d.quantity)return d.quantity.message;if(!m)return"Enter recipient address";if(d.recipient)return d.recipient.message;if(d.memo)return d.memo.message},[f,m,d.quantity,d.recipient,d.memo]);return t.jsx(Oe,{title:"Send",children:t.jsxs("form",{onSubmit:c(O=>E(O)),children:[t.jsxs("div",{className:Fr.fields,children:[t.jsx(In,{selectButton:t.jsx(Dt,{title:"Select chain and asset",content:O=>t.jsx(Vp,{afterSelect:O}),children:t.jsx(ta,{asset:N,chain:p})}),quantityInput:t.jsx(bs,{balance:P,decimals:T}),balanceButton:t.jsx(Jo,{onClick:()=>i("quantity",v.fromBaseUnit(b,{decimals:T}),{shouldValidate:!0}),disabled:M,children:v.formatAmount(P??"0",{decimals:T})}),value:f?R?$e(F(f).times(R)):"$-":"$0"}),t.jsx("div",{className:Fr.divider}),t.jsx(Gn,{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(oe.Stack,{children:!g&&t.jsx(oe,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(ie,{children:t.jsx(J.White,{type:"submit",loading:(z?"Estimating gas...":!1)||G,disabled:!!te,children:te??"Confirm"})})]})})},ex=()=>{const e=jt(),s=Zt(),n=Vt(s),{chain:r=s}=e,o=w.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=ue.useForm({mode:"onChange",defaultValues:{chainId:r.chainId,denom:a,quantity:"",recipient:"",memo:""}});return t.jsx(ue.FormProvider,{...i,children:t.jsx(Xp,{})})};async function En(e,s){const n=e.replace("ibc/",""),{class_trace:r}=await L.create({prefixUrl:s}).get(`ibc/apps/nft_transfer/v1/class_traces/${n}`).json();return r}async function tx(e,s){const n=new We.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:r}=await L.create({prefixUrl:s}).post("minievm/evm/v1/call",{json:{sender:v.InitiaAddress("0x1").bech32,contract_addr:v.InitiaAddress(e).hex,input:n.encodeFunctionData("name")}}).json();return n.decodeFunctionResult("name",r)[0]}async function sx(e,s,n){if(s.startsWith("evm/"))return e;const{token_infos:r}=await L.create({prefixUrl:n}).get(`minievm/evm/v1/erc721/origin_token_infos/${s}`,{searchParams:{token_ids:e.join(",")}}).json();return r.map(({token_origin_id:o})=>o)}async function nx({collection_addr:e},{restUrl:s}){const n=await tx(e,s);if(!n.startsWith("ibc/"))return{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0};const r=await En(n,s);return r?{class_id:n,class_trace:r}:{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function rx(e,s){const{data:n}=await L.create({prefixUrl:s}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(n)}async function ox({object_addr:e,collection_addr:s},{restUrl:n}){const r=await rx(s,n);return r.startsWith("ibc/")?v.InitiaAddress.equals(v.createObjectAddress("0x1",r),s)?{class_id:r,class_trace:await En(r,n)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await En(r,n)}:{class_id:`move/${s.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function ax(e,s){const n=V.toBase64(_t.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:r}=await L.create({prefixUrl:s}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${n}`).json();return r.name}async function ix(e,s){const{collection:n}=await L.create({prefixUrl:s}).get(`indexer/nft/v1/collections/${e}`).json();return n.collection.creator}async function cx(e,s){const n=V.toBase64(_t.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:r}=await L.create({prefixUrl:s}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${n}`).json();return r}function Or(e){const s=/^(.*channel-\d+)\/(.*)$/,n=e.match(s);if(!n)throw new Error("Pattern `channel-{number}/` not found.");const[,r,o]=n;return[r,o]}async function lx({collection_addr:e},s,n){const r=v.InitiaAddress(e).bech32,o=await ax(r,s.restUrl),a=s.metadata?.ibc_channels?.find(({chain_id:p,version:x})=>p===n.chain_id&&x.includes("ics721-1"));if(!a)throw new Error("Channel not found");const i=a.port_id,c=i.split(".")[1],l=V.toBase64(_t.toBytes(JSON.stringify({class_id:{contract:r}}))),{data:d}=await L.create({prefixUrl:s.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),u=d??r,h=await cx(c,s.restUrl),m=await ix(r,s.indexerUrl);if(u===r)return{class_id:u,class_trace:void 0,outgoing_proxy:h};if(d&&m!==i.replace("wasm.","")){const[p,x]=Or(d);return{class_id:r,class_trace:{path:p,base_class_id:x},outgoing_proxy:h}}const[f,g]=Or(o);return{class_id:r,class_trace:{path:f,base_class_id:g},outgoing_proxy:h}}const dx={minimove:ox,minievm:nx,miniwasm:lx};async function ux({nft:e,srcChain:s,intermediaryChain:n}){const r=s.metadata?.is_l1?"minimove":s.metadata?.minitia?.type;if(!(r==="minimove"||r==="minievm"||r==="miniwasm"))throw new Error(`Unsupported minitia type: ${r}`);const o=await dx[r](e,s,n);return Object.assign(o,r==="minievm"&&{token_ids:await sx([e.token_id],o.class_id,s.restUrl)})}const hx="_root_1tyvn_1",mx="_collectionName_1tyvn_10",fx="_nftName_1tyvn_15",_x="_chainInfo_1tyvn_19",gx="_fields_1tyvn_24",px="_chain_1tyvn_19",xn={root:hx,collectionName:mx,nftName:fx,chainInfo:_x,fields:gx,chain:px},xx=Ne.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),yx=()=>{const e=ae(),s=jt(),{chain:n,collection_addr:r}=s,{routerApiUrl:o}=X(),a=Ds(),i=_e(),{address:c,initiaAddress:l,requestTxSync:d}=xe(),{watch:u,setValue:h,handleSubmit:m,formState:f}=ue.useFormContext(),{errors:g}=f,p=u(),{recipient:x,dstChainId:S}=p,I=Me(S),N=$.useQuery({queryKey:xx.simulation({collection_addr:r,nft:s,sender:l,recipient:x,srcChain:n,dstChain:I,layer1:i,routerApiUrl:o}).queryKey,queryFn:async()=>{const b=Object.assign({from_address:l,from_chain_id:n.chainId,to_address:v.InitiaAddress(x).bech32,to_chain_id:I.chainId,collection_address:r,token_ids:[s.token_id],object_addresses:[s.object_addr]},n.chainId!==I.chainId&&await ux({nft:s,srcChain:n,intermediaryChain:i})),{msgs:y}=await L.create({prefixUrl:o}).post("nft",{json:b}).json();return y.map(k=>a.fromAmino(k))},enabled:v.InitiaAddress.validate(x)}),{data:C,isLoading:T,error:P}=N,R=$.useQueryClient(),{mutate:B,isPending:z}=$.useMutation({mutationFn:async()=>{if(!C)throw new Error("Route not found");await d({messages:C,chainId:n.chainId,internal:"/nfts"})},onSuccess:()=>{R.invalidateQueries({queryKey:Xn.nfts._def})}}),j=_.useMemo(()=>{if(!x)return"Enter recipient address";if(g.recipient)return g.recipient.message;if(P)return"Route not found"},[x,g.recipient,P]);return t.jsxs("form",{onSubmit:m(()=>B()),children:[t.jsx(Zn,{normalizedNft:s,thumbnailSize:80,classNames:xn}),t.jsxs("div",{className:xn.fields,children:[t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(Dt,{title:"Destination appchain",content:b=>t.jsx(ea,{onSelect:({chainId:y})=>{h("dstChainId",y),b()},list:e,getImage:y=>y.logoUrl,getName:y=>y.name,getKey:y=>y.chainId}),className:D("input",xn.chain),children:[t.jsx(Y,{src:I.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:I.name})]})]}),t.jsx(Gn,{myAddress:c,ref:ns()})]}),t.jsx(ie,{children:t.jsx(J.White,{loading:(T?"Finding route...":!1)||z,disabled:!!j,children:j??"Confirm"})})]})},jx=()=>{const{chain:e}=jt(),s=ue.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(Oe,{title:"Send NFT",children:t.jsx(ue.FormProvider,{...s,children:t.jsx(yx,{})})})},pa=()=>{const e=he(),s=Es(),n=Pt(),{closeDrawer:r}=Ve(),{closeModal:o}=Ms();_.useEffect(()=>{o(),s.startsWith("/bridge/")&&e("/bridge"),(s==="/collection"||s.startsWith("/nft"))&&e("/nfts")},[n]);const a=qs();if(_.useEffect(()=>{a("Page View")},[s,a]),s==="/connect")return n?null:t.jsx(Dr,{onSuccess:r});if(s==="/blank")return null;if(!n)return t.jsx(Dr,{});switch(s){case"/":case"/nfts":case"/activity":return t.jsx(Dp,{});case"/send":return t.jsx(ex,{},n);case"/receive":return t.jsx(Yf,{});case"/nft":return t.jsx(Wp,{});case"/nft/send":return t.jsx(jx,{},n);case"/bridge":return t.jsx(Rh,{},n);case"/bridge/preview":return t.jsx(Gm,{});case"/bridge/history":return t.jsx(Im,{});case"/op/withdrawals":return t.jsx(Sf,{});case"/tx":return t.jsx(Ko,{});case"/autosign/enable":return t.jsx(vd,{});case"/settings":return t.jsx(C_,{});case"/settings/autosign":return t.jsx(u_,{})}},vx="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",wx=()=>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:vx}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),bx=()=>{Za(),oi(),ae();const e=_e();return Kn(),qt(localStorage.getItem(U.BRIDGE_SRC_CHAIN_ID)??e.chainId),qt(localStorage.getItem(U.BRIDGE_DST_CHAIN_ID)??e.chainId),null},Cx=({children:e,...s})=>(_.useEffect(()=>{bi()},[]),Ie.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(wx,{}),t.jsx(Gr.Provider,{value:{...Qr,...s},children:t.jsx(ao,{children:t.jsx(Vl,{children:t.jsx(se.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(Gl,{children:t.jsxs(Rl,{children:[e,t.jsx(Ci,{}),t.jsx(ye,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(bx,{})}),t.jsx(dc,{children:t.jsx(pa,{})})]})})})})})})]}):null),Ix=({bridge:e})=>t.jsx(ao,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Do.Provider,{value:!!e,children:t.jsx(ye,{children:t.jsx(pa,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=Gt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=Hr;exports.InterwovenKit=Ix;exports.InterwovenKitProvider=Cx;exports.MAINNET=Qr;exports.MoveError=jo;exports.PRIVY_APP_ID=Pn;exports.TESTNET=Ea;exports.initiaPrivyWallet=Da;exports.initiaPrivyWalletConnector=qa;exports.initiaPrivyWalletOptions=Ss;exports.injectStyles=Oi;exports.useAddress=Pt;exports.useHexAddress=Us;exports.useInitiaAddress=ee;exports.useInterwovenKit=xe;exports.usePortfolio=zn;exports.useUsernameQuery=So;
|