@initia/interwovenkit-react 2.0.0-rc.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.js ADDED
@@ -0,0 +1,4692 @@
1
+ var xi = Object.defineProperty;
2
+ var Ei = (e, t, s) => t in e ? xi(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var sr = (e, t, s) => Ei(e, typeof t != "symbol" ? t + "" : t, s);
4
+ import { isAddress as Ss, getAddress as Ti, ethers as ls, BrowserProvider as Ai, computeAddress as Di, Interface as qi } from "ethers";
5
+ import { fromBech32 as gn, toHex as mt, toBech32 as Br, fromHex as zt, toBase64 as qe, fromBase64 as at } from "@cosmjs/encoding";
6
+ import T, { BigNumber as it } from "bignumber.js";
7
+ import M, { HTTPError as Fr } from "ky";
8
+ import { bcs as Mr } from "@mysten/bcs";
9
+ import { createContext as ht, useContext as Ke, useEffect as H, useState as L, useCallback as ee, Suspense as Pi, useMemo as fe, useRef as $s, useLayoutEffect as Ri, createElement as Nt, Fragment as Oi } from "react";
10
+ import { useSignMessage as Bi, useAccount as St, useDisconnect as Fi, useConnect as Mi, useSwitchChain as Ui, useWatchAsset as ji } from "wagmi";
11
+ import { useSuspenseQuery as le, useQuery as ge, useQueryClient as Se, useMutation as Pe, useSuspenseInfiniteQuery as ks } from "@tanstack/react-query";
12
+ import { TxRaw as Ur, Tx as rr, AuthInfo as zi, TxBody as Ki } from "cosmjs-types/cosmos/tx/v1beta1/tx";
13
+ import { useAtom as In, atom as xs, useSetAtom as or, useAtomValue as Hi } from "jotai";
14
+ import { jsx as n, jsxs as u, Fragment as P } from "react/jsx-runtime";
15
+ import { take as Li, adjust as Wi, includes as jr, path as Ae, descend as _e, uniq as Vi, head as zr, sortWith as Es, ascend as Kr, last as Hr, pathOr as Lr, pipe as Gi, groupBy as Qi, prop as ir, values as Yi, map as ar, filter as Ji, any as Zi, pickBy as Xi, partition as ea, has as ta, zipObj as na } from "ramda";
16
+ import { SignMode as sa } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing";
17
+ import { makeSignDoc as ra, escapeCharacters as oa, sortedJsonStringify as ia } from "@cosmjs/amino/build/signdoc";
18
+ import { Secp256k1 as aa, Secp256k1Signature as ca } from "@cosmjs/crypto";
19
+ import { Int53 as cr } from "@cosmjs/math";
20
+ import { decodeOptionalPubkey as la, encodePubkey as da, makeAuthInfoBytes as ua, Registry as ma } from "@cosmjs/proto-signing";
21
+ import { accountFromAny as ha, SigningStargateClient as Wr, AminoTypes as _a, GasPrice as ds, calculateFee as Vr } from "@cosmjs/stargate";
22
+ import { Comet38Client as fa, HttpClient as pa } from "@cosmjs/tendermint-rpc";
23
+ import { protoRegistry as ga, aminoConverters as Ts, aminoTypes as ya } from "@initia/amino-converter";
24
+ import { PubKey as us } from "cosmjs-types/cosmos/crypto/secp256k1/keys";
25
+ import { BaseAccount as wa } from "cosmjs-types/cosmos/auth/v1beta1/auth";
26
+ import { encodeSecp256k1Pubkey as Gr, pubkeyType as ba, pubkeyToAddress as va } from "@cosmjs/amino";
27
+ import { Any as Na } from "cosmjs-types/google/protobuf/any";
28
+ import { atomWithStorage as Qr } from "jotai/utils";
29
+ import { createQueryKeys as He } from "@lukemorales/query-key-factory";
30
+ import { toBytes as Kt, utf8ToBytes as Ca, concatBytes as Ia } from "@noble/hashes/utils";
31
+ import { sha256 as Sa } from "@noble/hashes/sha2";
32
+ import { sha3_256 as As } from "@noble/hashes/sha3";
33
+ import { Dialog as pt, Accordion as Ce, Select as ke, Tabs as Be, Tooltip as wt, VisuallyHidden as $a, Collapsible as Vn } from "radix-ui";
34
+ import { ErrorBoundary as Yr } from "react-error-boundary";
35
+ import A from "clsx";
36
+ import { nanoid as lr } from "nanoid";
37
+ import { createPortal as Jr } from "react-dom";
38
+ import { useTransition as Zr, config as Xr, animated as yn, useSpring as ka } from "@react-spring/web";
39
+ import { IconClose as eo, IconCloseCircleFilled as Sn, IconCheckCircleFilled as $n, IconChevronDown as Le, IconWarningFilled as Qt, IconInfoFilled as kn, IconCopy as xa, IconSignOut as Ea, IconExternalLink as Ht, IconChevronRight as Ds, IconChevronUp as Ta, IconSettingFilled as to, IconPlus as no, IconCheck as so, IconArrowRight as Aa, IconSwap as Da, IconBack as qa, IconWallet as xn, IconSearch as Pa, IconMinus as ro, IconEdit as Ra, IconClockFilled as Oa, IconArrowDown as ms, IconList as Ba } from "@initia/icons-react";
40
+ import { sentenceCase as En } from "change-case";
41
+ import { useToggle as qs, useMedia as oo, useLocalStorage as Yt, useDebounce as Fa, useAsync as io } from "react-use";
42
+ import { Img as Ma } from "react-image";
43
+ import ao from "xss";
44
+ import { isPast as co, intlFormatDistance as lo, addSeconds as Ua, isFuture as ja } from "date-fns";
45
+ import { useInView as za } from "react-intersection-observer";
46
+ import { z as K } from "zod";
47
+ import { Controller as Ka, useFormContext as $t, useForm as Tn, FormProvider as Ps } from "react-hook-form";
48
+ import { zodResolver as Rs } from "@hookform/resolvers/zod";
49
+ import { MsgSend as Ha } from "cosmjs-types/cosmos/bank/v1beta1/tx";
50
+ import { mergeRefs as uo } from "react-merge-refs";
51
+ import { MsgFinalizeTokenWithdrawal as La } from "@initia/opinit.proto/opinit/ophost/v1/tx";
52
+ const Wa = console.error, Va = console.warn, Ga = "`DialogContent` requires a `DialogTitle`", Qa = "Missing `Description`";
53
+ console.error = (...e) => {
54
+ e.some(
55
+ (s) => typeof s == "string" && s.includes(Ga)
56
+ ) || Wa(...e);
57
+ };
58
+ console.warn = (...e) => {
59
+ e.some(
60
+ (s) => typeof s == "string" && s.includes(Qa)
61
+ ) || Va(...e);
62
+ };
63
+ const D = {
64
+ toBytes(e, t = 20) {
65
+ if (!e) throw new Error("address is required");
66
+ if (e.match(/^(0x)?[0-9a-fA-F]+$/)) {
67
+ const r = e.replace(/^0x/, "").padStart(t * 2, "0");
68
+ return zt(r);
69
+ }
70
+ const { data: s } = gn(e);
71
+ return s.length >= t ? s : new Uint8Array([...Array(t - s.length).fill(0), ...s]);
72
+ },
73
+ toBech32(e, t = "init") {
74
+ return e ? Br(t, D.toBytes(e)) : "";
75
+ },
76
+ toHex(e) {
77
+ return e ? mt(D.toBytes(e)) : "";
78
+ },
79
+ toPrefixedHex(e) {
80
+ if (!e) return "";
81
+ const t = Ti(D.toHex(e)), s = D.toBytes(e), r = s[s.length - 1];
82
+ return s.subarray(0, s.length - 1).every((i) => i === 0) && r < 16 ? t.replace(/^0x0+/, "0x") : t;
83
+ },
84
+ validate(e, t = "init") {
85
+ if (Ss(e))
86
+ return !0;
87
+ try {
88
+ return gn(e).prefix === t;
89
+ } catch {
90
+ return !1;
91
+ }
92
+ },
93
+ equals(e, t) {
94
+ return D.toBech32(e) === D.toBech32(t);
95
+ }
96
+ };
97
+ function ie(e = "", [t, s] = [6, 6]) {
98
+ const r = e.slice(0, t), o = e.slice(-1 * s, e.length);
99
+ return e.length > t + s ? [r, o].join("...") : e;
100
+ }
101
+ function Ct(e, t = {}) {
102
+ const s = T(e);
103
+ if (s.isZero() || s.isNaN()) return "0";
104
+ const { dp: r = 2 } = t;
105
+ return s.toFormat(r, T.ROUND_DOWN);
106
+ }
107
+ function ae(e, t = {}) {
108
+ if (!e) return "0";
109
+ const s = T(e);
110
+ if (s.isZero() || s.isNaN()) return "0";
111
+ const { decimals: r = 0, dp: o = r > 6 ? 6 : r } = t, i = s.div(new T(10).pow(r));
112
+ return Ct(i, { dp: o });
113
+ }
114
+ function Os(e, t = 6) {
115
+ return !e || T(e).isNaN() ? "0" : new T(e).times(new T(10).pow(t)).integerValue().toString(10);
116
+ }
117
+ function wn(e, t = 6) {
118
+ if (!e || T(e).isNaN()) return "0";
119
+ const s = Math.min(t, 6);
120
+ return new T(e).integerValue().div(new T(10).pow(t)).toFixed(s, T.ROUND_DOWN);
121
+ }
122
+ function qg(e, t) {
123
+ if (!e || T(e).isNaN()) return "0%";
124
+ const s = new T(e).times(100);
125
+ return typeof t == "number" ? s.toFixed(t) + "%" : (s.gte(100) ? s.toFixed(0) : s.toFixed(2)) + "%";
126
+ }
127
+ const dr = "usernames";
128
+ function Ya({ restUrl: e, moduleAddress: t }) {
129
+ const s = M.create({ prefixUrl: e });
130
+ async function r(d) {
131
+ const { moduleAddress: c, moduleName: l, functionName: m, typeArgs: h, args: _ } = d, f = `initia/move/v1/accounts/${c}/modules/${l}/view_functions/${m}`, g = { type_args: h, args: _ }, { data: p, message: w } = await s.post(f, { json: g }).json();
132
+ if (w) throw new Error(w);
133
+ return JSON.parse(p);
134
+ }
135
+ async function o(d) {
136
+ if (!D.validate(d)) return null;
137
+ const c = await r({
138
+ moduleAddress: t,
139
+ moduleName: dr,
140
+ functionName: "get_name_from_address",
141
+ typeArgs: [],
142
+ args: [qe(D.toBytes(d, 32))]
143
+ });
144
+ return c ? c + ".init" : null;
145
+ }
146
+ function i(d) {
147
+ return /^[A-Za-z0-9-]{3,64}\.init$/.test(d);
148
+ }
149
+ async function a(d) {
150
+ if (!i(d)) return null;
151
+ const c = await r({
152
+ moduleAddress: t,
153
+ moduleName: dr,
154
+ functionName: "get_address_from_name",
155
+ typeArgs: [],
156
+ args: [Mr.string().serialize(d.toLowerCase().replace(".init", "")).toBase64()]
157
+ });
158
+ return c ? D.toBech32(c) : null;
159
+ }
160
+ return { restUrl: e, getUsername: o, getAddress: a, validateUsername: i };
161
+ }
162
+ const mo = ht(null);
163
+ function te() {
164
+ return Ke(mo);
165
+ }
166
+ const hs = "interwoven-kit";
167
+ function ho() {
168
+ const e = document.querySelector(hs) || document.body.appendChild(document.createElement(hs));
169
+ return e.shadowRoot || e.attachShadow({ mode: "open" });
170
+ }
171
+ function Ja() {
172
+ const { theme: e } = te();
173
+ return H(() => {
174
+ const t = document.querySelector(hs);
175
+ t == null || t.setAttribute("data-theme", e);
176
+ }, [e]), ho();
177
+ }
178
+ function Pg(e) {
179
+ const t = ho(), s = document.createElement("style");
180
+ s.textContent = e, t.appendChild(s);
181
+ }
182
+ const _o = 1.4, Za = 1.03, Xa = {
183
+ defaultChainId: "interwoven-1",
184
+ registryUrl: "https://registry.initia.xyz",
185
+ routerApiUrl: "https://router-api.initia.xyz",
186
+ usernamesModuleAddress: "0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",
187
+ theme: "dark"
188
+ }, Rg = {
189
+ defaultChainId: "initiation-2",
190
+ registryUrl: "https://registry.testnet.initia.xyz",
191
+ routerApiUrl: "https://router-api.initiation-2.initia.xyz",
192
+ usernamesModuleAddress: "0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",
193
+ theme: "dark"
194
+ }, fo = ht(null);
195
+ function An() {
196
+ return Ke(fo);
197
+ }
198
+ function po() {
199
+ const { location: e } = An();
200
+ return e;
201
+ }
202
+ function go() {
203
+ const { path: e } = po();
204
+ return e;
205
+ }
206
+ function We() {
207
+ const { state: e = {} } = po();
208
+ return e;
209
+ }
210
+ function ec() {
211
+ const { history: e } = An();
212
+ return e;
213
+ }
214
+ function de() {
215
+ const { navigate: e } = An();
216
+ return e;
217
+ }
218
+ function tc() {
219
+ const { reset: e } = An();
220
+ return e;
221
+ }
222
+ const yo = ({ children: e, initialEntry: t }) => {
223
+ const [s, r] = L([t ?? { path: "/" }]), o = s[s.length - 1], i = ee((d, c) => {
224
+ r((l) => {
225
+ if (typeof d == "string")
226
+ return [...l, { path: d, state: c }];
227
+ const m = l.length + d;
228
+ if (m < 1) return l;
229
+ const h = Li(m, l);
230
+ return c !== void 0 ? Wi(m - 1, (_) => ({ ..._, state: c }), h) : h;
231
+ });
232
+ }, []), a = ee((d, c) => {
233
+ r([{ path: d, state: c }]);
234
+ }, []);
235
+ return /* @__PURE__ */ n(fo.Provider, { value: { location: o, history: s, navigate: i, reset: a }, children: e });
236
+ }, Jt = ({ to: e, state: t, children: s, onClick: r, ...o }) => {
237
+ const i = de();
238
+ return /* @__PURE__ */ n("button", { type: "button", ...o, onClick: (d) => {
239
+ d.preventDefault(), r == null || r(d), i(e, t);
240
+ }, children: s });
241
+ }, wo = ht(null), Dn = () => Ke(wo), F = {
242
+ SECOND: 1e3,
243
+ MINUTE: 1e3 * 60,
244
+ INFINITY: (
245
+ /* HOUR, just in case */
246
+ 1e3 * 60 * 60
247
+ )
248
+ };
249
+ async function Ve(e) {
250
+ if (e instanceof Fr) {
251
+ const { response: t } = e, s = t.headers.get("content-type") ?? "";
252
+ if (jr("application/json", s))
253
+ try {
254
+ const r = await t.json();
255
+ if (r.message) return r.message;
256
+ } catch {
257
+ return e.message;
258
+ }
259
+ try {
260
+ return await t.text();
261
+ } catch {
262
+ return e.message;
263
+ }
264
+ }
265
+ if (e instanceof Error) {
266
+ if (Ae(["code"], e) === 4001 || Ae(["code"], e) === "ACTION_REJECTED") return "User rejected";
267
+ const t = Ae(["error", "message"], e), s = Ae(["cause", "message"], e), r = Ae(["shortMessage"], e);
268
+ return t || s || r || e.message;
269
+ }
270
+ return String(e);
271
+ }
272
+ function nc(e) {
273
+ if ((e == null ? void 0 : e.typeUrl) === "/initia.crypto.v1beta1.ethsecp256k1.PubKey") {
274
+ const { key: t } = us.decode(e.value);
275
+ return Gr(t);
276
+ }
277
+ return la(e);
278
+ }
279
+ function sc({ typeUrl: e, value: t }) {
280
+ if (e === "/cosmos.auth.v1beta1.BaseAccount") {
281
+ const { address: s, pubKey: r, accountNumber: o, sequence: i } = wa.decode(t), a = nc(r);
282
+ return { address: s, pubkey: a, accountNumber: Number(o), sequence: Number(i) };
283
+ }
284
+ return ha({ typeUrl: e, value: t });
285
+ }
286
+ function rc(e) {
287
+ return e.type === "initia/PubKeyEthSecp256k1";
288
+ }
289
+ const oc = {
290
+ ...ba,
291
+ /** https://github.com/initia-labs/initia/blob/main/crypto/ethsecp256k1/ethsecp256k1.go#L40 */
292
+ ethsecp256k1: "initia/PubKeyEthSecp256k1"
293
+ };
294
+ function ic(e) {
295
+ if (rc(e)) {
296
+ const t = us.fromPartial({
297
+ key: at(e.value)
298
+ });
299
+ return Na.fromPartial({
300
+ typeUrl: "/initia.crypto.v1beta1.ethsecp256k1.PubKey",
301
+ value: Uint8Array.from(us.encode(t).finish())
302
+ });
303
+ }
304
+ return da(e);
305
+ }
306
+ function bo(e) {
307
+ if (e.length !== 33 || e[0] !== 2 && e[0] !== 3)
308
+ throw new Error(
309
+ "Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03"
310
+ );
311
+ return {
312
+ type: oc.ethsecp256k1,
313
+ value: qe(e)
314
+ };
315
+ }
316
+ function ac(e, t) {
317
+ if (t.length !== 64)
318
+ throw new Error(
319
+ "Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s."
320
+ );
321
+ return {
322
+ pub_key: bo(e),
323
+ signature: qe(t)
324
+ };
325
+ }
326
+ const X = "interwovenkit", U = {
327
+ // ui
328
+ ADDED_CHAIN_IDS: `${X}:chain-ids:added`,
329
+ OPENED_CHAIN_IDS: `${X}:chain-ids:opened`,
330
+ // wallet
331
+ PUBLIC_KEY: `${X}:public-key`,
332
+ LATEST_CONNECTOR_ID: `${X}:latest-connector-id`,
333
+ // tx fee
334
+ FEE_DENOM: `${X}:fee-denom`,
335
+ // bridge
336
+ BRIDGE_SRC_CHAIN_ID: `${X}:bridge:src-chain-id`,
337
+ BRIDGE_SRC_DENOM: `${X}:bridge:src-denom`,
338
+ BRIDGE_DST_CHAIN_ID: `${X}:bridge:dst-chain-id`,
339
+ BRIDGE_DST_DENOM: `${X}:bridge:dst-denom`,
340
+ BRIDGE_QUANTITY: `${X}:bridge:quantity`,
341
+ BRIDGE_SLIPPAGE_PERCENT: `${X}:bridge:slippage-percent`,
342
+ BRIDGE_ROUTE_TYPE: `${X}:bridge:route-type`,
343
+ BRIDGE_HISTORY: `${X}:bridge:history`,
344
+ // op
345
+ OP_REMINDER: `${X}:op:reminder`
346
+ }, Bs = He("interwovenkit:chain", {
347
+ list: (e) => [e],
348
+ prices: (e) => [e],
349
+ gasPrices: (e) => [e]
350
+ }), cc = Qr(U.ADDED_CHAIN_IDS, []);
351
+ function tn(e) {
352
+ const t = Ae([0, "address"], e);
353
+ if (!t) throw new Error("URL not found");
354
+ return t;
355
+ }
356
+ function lc(e) {
357
+ var v;
358
+ const { chain_id: t, chain_name: s, pretty_name: r, logo_URIs: o, apis: i, metadata: a } = e, d = r || s, c = (o == null ? void 0 : o.png) ?? "", { rpc: l, rest: m, api: h, ["json-rpc"]: _ } = i, f = tn(l), g = tn(m), p = a != null && a.is_l1 ? tn(h) : g, w = ((v = a == null ? void 0 : a.minitia) == null ? void 0 : v.type) === "minievm" ? tn(_) : void 0;
359
+ return { ...e, chainId: t, name: d, logoUrl: c, rpcUrl: f, restUrl: g, indexerUrl: p, jsonRpcUrl: w };
360
+ }
361
+ function Ge() {
362
+ const { defaultChainId: e, registryUrl: t, customChain: s } = te(), { data: r } = le({
363
+ queryKey: Bs.list(t).queryKey,
364
+ queryFn: () => M.create({ prefixUrl: t }).get("chains.json").json(),
365
+ select: (o) => (s ? [s, ...o.filter((a) => a.chain_id !== s.chain_id)] : o).map(lc).toSorted(_e((a) => a.chainId === e)),
366
+ staleTime: F.MINUTE
367
+ });
368
+ return r;
369
+ }
370
+ function _t() {
371
+ const e = Ge();
372
+ return (t) => {
373
+ const s = e.find((r) => r.chain_id === t);
374
+ if (!s) throw new Error(`Chain not found: ${t}`);
375
+ return s;
376
+ };
377
+ }
378
+ function $e(e) {
379
+ return _t()(e);
380
+ }
381
+ function qn() {
382
+ const { defaultChainId: e } = te();
383
+ return $e(e);
384
+ }
385
+ function we() {
386
+ const t = Ge().find((s) => {
387
+ var r;
388
+ return (r = s.metadata) == null ? void 0 : r.is_l1;
389
+ });
390
+ if (!t) throw new Error("Layer 1 not found");
391
+ return t;
392
+ }
393
+ function vo(e) {
394
+ return ge({
395
+ queryKey: Bs.prices(e).queryKey,
396
+ queryFn: () => M.create({ prefixUrl: "https://celatone-api-prod.alleslabs.dev" }).get(`v1/initia/${e}/assets`, { searchParams: { with_prices: !0 } }).json(),
397
+ staleTime: F.SECOND
398
+ });
399
+ }
400
+ function kt() {
401
+ const e = Ge(), { defaultChainId: t } = te(), [s, r] = In(cc), o = (l) => Vi([t, ...l]), i = o(s).map((l) => e.find((m) => m.chainId === l)).filter(Boolean), a = e.filter(
402
+ (l) => !o(s).includes(l.chainId)
403
+ );
404
+ return { chains: e, addedChains: i, notAddedChains: a, addChain: (l) => {
405
+ r((m) => o([...m, l]));
406
+ }, removeChain: (l) => {
407
+ r((m) => o(m.filter((h) => h !== l)));
408
+ } };
409
+ }
410
+ const Fs = () => {
411
+ const e = te();
412
+ return new ma([...ga, ...e.protoTypes ?? []]);
413
+ }, Pn = () => {
414
+ const e = te();
415
+ return new _a({ ...Ts, ...e.aminoConverters });
416
+ };
417
+ class dc {
418
+ constructor(t, s) {
419
+ // Cache the public key so we don't have to ask the wallet to sign the
420
+ // identification message every time a transaction is built.
421
+ sr(this, "cachedPublicKey", null);
422
+ this.address = t, this.signMessage = s;
423
+ }
424
+ async getCachedPublicKey() {
425
+ if (this.cachedPublicKey)
426
+ return this.cachedPublicKey;
427
+ const t = `${U.PUBLIC_KEY}:${this.address}`, s = localStorage.getItem(t);
428
+ if (s)
429
+ return this.cachedPublicKey = zt(s), zt(s);
430
+ const r = await this.getPublicKey();
431
+ return this.cachedPublicKey = r, localStorage.setItem(t, mt(r)), r;
432
+ }
433
+ async getPublicKey() {
434
+ const t = "Sign this message to identify your Initia account.", s = await this.signMessage(t), r = ls.hashMessage(t), o = ls.SigningKey.recoverPublicKey(r, s);
435
+ return aa.compressPubkey(zt(o.replace("0x", "")));
436
+ }
437
+ async getAccounts() {
438
+ return [
439
+ {
440
+ address: this.address,
441
+ algo: "ethsecp256k1",
442
+ pubkey: await this.getCachedPublicKey()
443
+ }
444
+ ];
445
+ }
446
+ async signAmino(t, s) {
447
+ if (this.address !== t)
448
+ throw new Error("Signer address does not match the provided address");
449
+ const r = oa(ia(s)), o = await this.signMessage(r), i = zt(o.replace("0x", "")).subarray(0, -1), d = ca.fromFixedLength(i).toFixedLength(), c = ac(await this.getCachedPublicKey(), d);
450
+ return { signed: s, signature: c };
451
+ }
452
+ }
453
+ function No() {
454
+ const e = Fs(), t = Pn(), s = Rn(), r = Co();
455
+ return async function(o, i, a, d, c) {
456
+ if (!s) throw new Error("Signer not initialized");
457
+ const l = await r(o), { accountNumber: m, sequence: h } = await l.getSequence(i), [_] = await s.getAccounts(), f = ic(bo(_.pubkey)), g = sa.SIGN_MODE_EIP_191, p = a.map((S) => t.toAmino(S)), w = ra(p, d, o, c, m, h), { signature: v, signed: b } = await s.signAmino(i, w), C = {
458
+ typeUrl: "/cosmos.tx.v1beta1.TxBody",
459
+ value: {
460
+ messages: b.msgs.map((S) => t.fromAmino(S)),
461
+ memo: c
462
+ }
463
+ }, I = e.encode(C), E = cr.fromString(b.fee.gas).toNumber(), N = cr.fromString(b.sequence).toNumber(), y = ua(
464
+ [{ pubkey: f, sequence: N }],
465
+ b.fee.amount,
466
+ E,
467
+ b.fee.granter,
468
+ b.fee.payer,
469
+ g
470
+ );
471
+ return Ur.fromPartial({
472
+ bodyBytes: I,
473
+ authInfoBytes: y,
474
+ signatures: [at(v.signature)]
475
+ });
476
+ };
477
+ }
478
+ function Rn() {
479
+ const e = Z(), { signMessageAsync: t } = Bi();
480
+ return new dc(e, (s) => t({ message: s }));
481
+ }
482
+ const Gn = /* @__PURE__ */ new Map();
483
+ function Co() {
484
+ const e = _t(), t = Fs(), s = Pn(), r = Rn(), o = Z();
485
+ return async (i) => {
486
+ const a = `${o}:${i}`;
487
+ if (Gn.has(a))
488
+ return Gn.get(a);
489
+ if (!r) throw new Error("Signer not initialized");
490
+ const { rpcUrl: d } = e(i), c = await fa.create(new pa(d)), l = await Wr.createWithSigner(c, r, {
491
+ registry: t,
492
+ aminoTypes: s,
493
+ accountParser: sc,
494
+ broadcastPollIntervalMs: 1e3
495
+ });
496
+ return Gn.set(a, l), l;
497
+ };
498
+ }
499
+ function Io() {
500
+ const { connector: e } = St();
501
+ return async () => {
502
+ if (!e) throw new Error("Wallet not connected");
503
+ return new Ai(await e.getProvider());
504
+ };
505
+ }
506
+ const uc = xs(!1);
507
+ function xt() {
508
+ const e = tc(), [t, s] = In(uc);
509
+ return { isDrawerOpen: t, openDrawer: (i, a) => {
510
+ i && e(i, a), s(!0);
511
+ }, closeDrawer: () => {
512
+ s(!1);
513
+ } };
514
+ }
515
+ const mc = "approve", So = xs(), $o = xs(null);
516
+ function ko() {
517
+ const e = Hi(So);
518
+ if (!e) throw new Error("Tx request not found");
519
+ return e;
520
+ }
521
+ function hc() {
522
+ const e = de(), t = Z(), { defaultChainId: s } = te(), { openDrawer: r, closeDrawer: o } = xt(), { openModal: i, closeModal: a } = Dn(), d = or(So), c = or($o), l = Co(), m = async ({ messages: p, memo: w, chainId: v = s }) => {
523
+ try {
524
+ return await (await l(v)).simulate(t, p, w);
525
+ } catch (b) {
526
+ throw new Error(await Ve(b));
527
+ }
528
+ }, h = async ({
529
+ txRequest: p,
530
+ broadcaster: w
531
+ }) => {
532
+ const b = { ...{
533
+ memo: "",
534
+ chainId: s,
535
+ gas: p.gas || await m(p),
536
+ gasAdjustment: _o,
537
+ fee: null,
538
+ internal: !1
539
+ }, ...p };
540
+ return new Promise((k, C) => {
541
+ d({
542
+ txRequest: b,
543
+ resolve: async (E) => {
544
+ try {
545
+ const N = await l(b.chainId), y = await w(N, Ur.encode(E).finish());
546
+ k(y), typeof b.internal == "string" && e(b.internal);
547
+ } catch (N) {
548
+ C(N);
549
+ } finally {
550
+ I();
551
+ }
552
+ },
553
+ reject: (E) => {
554
+ C(E), I();
555
+ }
556
+ }), b.internal ? i({ path: "/tx" }) : r("/tx");
557
+ const I = () => {
558
+ if (!b.internal) {
559
+ e("/blank"), o();
560
+ return;
561
+ }
562
+ a();
563
+ };
564
+ });
565
+ }, _ = async (p) => {
566
+ const w = p.chainId ?? s;
567
+ try {
568
+ const v = await h({
569
+ txRequest: p,
570
+ broadcaster: async (b, k) => await b.broadcastTxSync(k)
571
+ });
572
+ return p.internal && typeof p.internal != "number" && (c({ txHash: v, chainId: w, status: "loading" }), g({ txHash: v, chainId: p.chainId }).then((b) => {
573
+ c({ status: b.code === 0 ? "success" : "error", chainId: w, txHash: v });
574
+ }).catch(() => {
575
+ c({ status: "error", chainId: w, txHash: v });
576
+ })), v;
577
+ } catch (v) {
578
+ throw p.internal && typeof p.internal != "number" && c({ status: "error", chainId: w, error: v }), v;
579
+ }
580
+ }, f = (p) => h({
581
+ txRequest: p,
582
+ broadcaster: async (w, v) => {
583
+ const b = await w.broadcastTx(v);
584
+ if (b.code !== 0) throw new Error(b.rawLog);
585
+ return b;
586
+ }
587
+ }), g = async ({
588
+ chainId: p = s,
589
+ ...w
590
+ }) => {
591
+ const v = await l(p);
592
+ return xo({ ...w, client: v });
593
+ };
594
+ return { estimateGas: m, requestTxSync: _, requestTxBlock: f, waitForTxConfirmation: g };
595
+ }
596
+ async function xo({
597
+ txHash: e,
598
+ client: t,
599
+ timeoutSeconds: s = 30,
600
+ intervalSeconds: r = 1
601
+ }) {
602
+ const o = Date.now(), i = s * 1e3;
603
+ for (; ; ) {
604
+ const a = await t.getTx(e);
605
+ if (a) {
606
+ if (a.code !== 0) throw new Error(a.rawLog);
607
+ return a;
608
+ }
609
+ if (Date.now() - o >= i)
610
+ throw new Error(
611
+ `Transaction was submitted, but not found on the chain within ${s} seconds.`
612
+ );
613
+ await new Promise((d) => setTimeout(d, r * 1e3));
614
+ }
615
+ }
616
+ const _c = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
617
+ <circle fill="#2F3337" cx="30" cy="30" r="30"/>
618
+ <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"/>
619
+ </svg>`, fc = encodeURIComponent(_c), Eo = `data:image/svg+xml;utf8,${fc}`, dt = He("interwovenkit:asset", {
620
+ list: (e) => [e],
621
+ item: (e, t) => [e, t],
622
+ resource: (e, t) => [e.chainId, t.denom],
623
+ denom: (e, t) => [e, t],
624
+ metadata: (e, t) => [e, t]
625
+ });
626
+ function pc(e) {
627
+ var h, _, f;
628
+ const { base: t, symbol: s, denom_units: r = [], display: o, logo_URIs: i, name: a, address: d, traces: c } = e, l = ((h = r.find((g) => g.denom === o)) == null ? void 0 : h.exponent) ?? ((_ = r.find((g) => g.denom === t)) == null ? void 0 : _.exponent) ?? ((f = zr(r)) == null ? void 0 : f.exponent) ?? 0, m = (i == null ? void 0 : i.png) ?? "";
629
+ return { denom: t, symbol: s, decimals: l, logoUrl: m, name: a, address: d, traces: c };
630
+ }
631
+ function Lt(e) {
632
+ var o;
633
+ const t = (o = e == null ? void 0 : e.metadata) == null ? void 0 : o.assetlist, s = Se(), { data: r } = le({
634
+ queryKey: dt.list(t).queryKey,
635
+ queryFn: async () => t ? M.get(t).json() : { assets: [] },
636
+ select: ({ assets: i }) => {
637
+ if (!e) return [];
638
+ const a = i.map(pc);
639
+ for (const d of a)
640
+ s.setQueryData(dt.item(e.chainId, d.denom).queryKey, d);
641
+ return a;
642
+ },
643
+ staleTime: F.MINUTE
644
+ });
645
+ return r;
646
+ }
647
+ function Zt(e) {
648
+ const t = Lt(e), s = we(), r = Lt(s), o = To(e);
649
+ return (i) => {
650
+ const a = t.find((c) => c.denom === i);
651
+ if (a) return a;
652
+ const d = r.find((c) => c.denom === o(i));
653
+ return d ? { ...d, denom: i } : { denom: i, symbol: "", decimals: 0, logoUrl: Eo };
654
+ };
655
+ }
656
+ function Ms(e, t) {
657
+ const s = Zt(t), o = Se().getQueryData(
658
+ dt.item(t.chainId, e).queryKey
659
+ );
660
+ return o || s(e);
661
+ }
662
+ function To(e) {
663
+ const t = we(), s = Lt(e);
664
+ return (r) => {
665
+ var i, a, d, c, l;
666
+ if ((i = e.metadata) != null && i.is_l1)
667
+ return r;
668
+ if (r.startsWith("l2/") || r.startsWith("ibc/")) {
669
+ const m = (a = s.find((h) => h.denom === r)) == null ? void 0 : a.traces;
670
+ if (m) {
671
+ for (const h of m)
672
+ if (h.counterparty.chain_name === t.chain_name)
673
+ return h.counterparty.base_denom;
674
+ }
675
+ }
676
+ const o = (l = (c = (d = t.metadata) == null ? void 0 : d.ibc_channels) == null ? void 0 : c.find(
677
+ ({ chain_id: m, version: h }) => m === e.chain_id && h === "ics20-1"
678
+ )) == null ? void 0 : l.channel_id;
679
+ return o ? yc(o, r) : "";
680
+ };
681
+ }
682
+ function gc(e, t) {
683
+ const r = D.toBytes(e, 32), o = D.toBytes(t, 32), i = new Uint8Array([...r, ...o, 252]);
684
+ return mt(As.create().update(i).digest());
685
+ }
686
+ function Ao(e, t) {
687
+ const r = D.toBytes(e, 32), o = Kt(t), i = new Uint8Array([...r, ...o, 254]);
688
+ return mt(As.create().update(i).digest());
689
+ }
690
+ function Do(e) {
691
+ return e ? e.startsWith("move/") ? `0x${e.slice(5)}` : `0x${Ao("0x1", e)}` : "";
692
+ }
693
+ function yc(e, t) {
694
+ const s = `transfer/${e}/${t}`;
695
+ return `ibc/${mt(Sa(s)).toUpperCase()}`;
696
+ }
697
+ const Xt = He("interwovenkit:account", {
698
+ username: (e, t) => [e, t],
699
+ address: (e, t) => [e, t],
700
+ balances: (e, t) => [e, t],
701
+ txs: (e, t) => [e, t]
702
+ });
703
+ function qo() {
704
+ const { restUrl: e } = we(), { usernamesModuleAddress: t } = te();
705
+ return Ya({ restUrl: e, moduleAddress: t });
706
+ }
707
+ function Us(e) {
708
+ const t = Z(), { restUrl: s } = e, { data: r } = le({
709
+ queryKey: Xt.balances(s, t).queryKey,
710
+ queryFn: () => M.create({ prefixUrl: s }).get(`cosmos/bank/v1beta1/balances/${t}`).json(),
711
+ select: ({ balances: o }) => o,
712
+ staleTime: F.SECOND
713
+ });
714
+ return r;
715
+ }
716
+ function Po(e) {
717
+ const t = Us(e), s = Lt(e), r = Zt(e), o = To(e), { data: i } = vo(e.chainId), a = (c) => e.fees.fee_tokens.some((l) => l.denom === c), d = (c) => s.some((l) => l.denom === c);
718
+ return Es(
719
+ [
720
+ _e(({ denom: c }) => o(c) === "uinit"),
721
+ _e(({ denom: c }) => a(c)),
722
+ _e(({ value: c }) => c),
723
+ _e(({ denom: c }) => d(c)),
724
+ ({ balance: c }, { balance: l }) => T(l).comparedTo(c) ?? 0,
725
+ _e(({ symbol: c }) => c.toLowerCase())
726
+ ],
727
+ t.filter(({ amount: c }) => !T(c).isZero()).map(({ amount: c, denom: l }) => {
728
+ var f;
729
+ const m = r(l), h = ((f = i == null ? void 0 : i.find(({ id: g }) => g === (m == null ? void 0 : m.denom))) == null ? void 0 : f.price) ?? 0, _ = T(c).times(h).div(T(10).pow(m.decimals)).toNumber();
730
+ return { ...m, balance: c, price: h, value: _ };
731
+ })
732
+ );
733
+ }
734
+ function Z() {
735
+ const e = On();
736
+ return e ? D.toBech32(e) : "";
737
+ }
738
+ function On() {
739
+ const { address: e } = St();
740
+ return e ? D.toPrefixedHex(e) : "";
741
+ }
742
+ function en() {
743
+ var r, o;
744
+ const e = qn(), t = Z(), s = On();
745
+ return ((o = (r = e.metadata) == null ? void 0 : r.minitia) == null ? void 0 : o.type) === "minievm" ? s : t;
746
+ }
747
+ function wc() {
748
+ const e = en(), t = qo();
749
+ return ge({
750
+ queryKey: Xt.username(t.restUrl, e).queryKey,
751
+ queryFn: () => t.getUsername(e),
752
+ enabled: !!e,
753
+ staleTime: F.MINUTE
754
+ });
755
+ }
756
+ function Qe() {
757
+ const e = en(), t = Z(), s = On(), { data: r } = wc(), { openDrawer: o } = xt(), i = () => {
758
+ o("/");
759
+ }, a = () => {
760
+ o("/connect");
761
+ }, d = (l) => {
762
+ o("/bridge", l);
763
+ }, c = hc();
764
+ return {
765
+ address: e,
766
+ initiaAddress: t,
767
+ hexAddress: s,
768
+ username: r,
769
+ openConnect: a,
770
+ openWallet: i,
771
+ openBridge: d,
772
+ ...c
773
+ };
774
+ }
775
+ const bc = "_status_tn9m1_1", vc = "_error_tn9m1_9", ur = {
776
+ status: bc,
777
+ error: vc
778
+ }, ce = ({ error: e, children: t }) => /* @__PURE__ */ n("p", { className: A(ur.status, { [ur.error]: e }), children: t }), ne = ({
779
+ errorBoundaryProps: e = { fallbackRender: ({ error: r }) => /* @__PURE__ */ n(ce, { error: !0, children: r.message }) },
780
+ suspenseFallback: t = /* @__PURE__ */ n(ce, { children: "Loading..." }),
781
+ children: s
782
+ }) => /* @__PURE__ */ n(Yr, { ...e, children: /* @__PURE__ */ n(Pi, { fallback: t, children: s }) }), pe = He("interwovenkit:skip", {
783
+ chains: null,
784
+ assets: (e) => [e],
785
+ asset: (e, t) => [e, t],
786
+ balances: (e, t) => [e, t],
787
+ route: (e, t) => [e, t],
788
+ routeErrorInfo: (e) => [e],
789
+ txTrack: (e, t) => [e, t],
790
+ txStatus: (e, t) => [e, t]
791
+ });
792
+ function Ye() {
793
+ const { routerApiUrl: e } = te();
794
+ return fe(() => M.create({ prefixUrl: e }), [e]);
795
+ }
796
+ function Ro() {
797
+ const e = Ge();
798
+ return (t) => e.some((s) => s.chain_id === t);
799
+ }
800
+ function Et() {
801
+ const e = Ro();
802
+ return (t) => e(t.chain_id) ? "initia" : t.chain_type;
803
+ }
804
+ function Wt(e) {
805
+ return Et()(e);
806
+ }
807
+ function js() {
808
+ const e = Ye(), { data: t } = le({
809
+ queryKey: pe.chains.queryKey,
810
+ queryFn: () => e.get("v2/info/chains").json(),
811
+ select: ({ chains: s }) => Es(
812
+ [
813
+ _e(({ chain_name: r }) => r === "initia"),
814
+ Kr(({ pretty_name: r }) => r)
815
+ ],
816
+ s
817
+ ),
818
+ staleTime: F.MINUTE
819
+ });
820
+ return t;
821
+ }
822
+ function Je() {
823
+ const e = js();
824
+ return (t) => {
825
+ const s = e.find((r) => r.chain_id === t);
826
+ if (!s) throw new Error(`Chain not found: ${t}`);
827
+ return s;
828
+ };
829
+ }
830
+ function Ie(e) {
831
+ return Je()(e);
832
+ }
833
+ function It(e) {
834
+ const t = Ye(), s = Se(), { data: r } = le({
835
+ queryKey: pe.assets(e).queryKey,
836
+ queryFn: () => t.get("v2/fungible/assets", { searchParams: { chain_ids: e } }).json(),
837
+ select: ({ chain_to_assets_map: o }) => {
838
+ const { assets: i } = o[e] ?? { assets: [] };
839
+ for (const a of i)
840
+ s.setQueryData(pe.asset(e, a.denom).queryKey, a);
841
+ return i.toSorted(_e((a) => a.symbol === "INIT"));
842
+ },
843
+ staleTime: F.MINUTE
844
+ });
845
+ return r;
846
+ }
847
+ function Oo(e) {
848
+ const t = It(e);
849
+ return (s) => {
850
+ const r = t.find((o) => o.denom === s);
851
+ if (!r) throw new Error(`Asset not found: ${s}`);
852
+ return r;
853
+ };
854
+ }
855
+ function De(e, t) {
856
+ return Oo(t)(e);
857
+ }
858
+ const zs = ht(null);
859
+ function Vt() {
860
+ const { container: e } = Ke(zs);
861
+ return e;
862
+ }
863
+ const Nc = ({ children: e }) => {
864
+ const [t, s] = L(null);
865
+ return /* @__PURE__ */ n(zs.Provider, { value: { container: t, setContainer: s }, children: e });
866
+ }, Cc = "_loader_4gdsk_1", Ic = {
867
+ loader: Cc
868
+ }, Ze = ({ size: e = 24, color: t = "currentColor", border: s = 2 }) => {
869
+ const r = {
870
+ width: `${e}px`,
871
+ height: `${e}px`,
872
+ borderColor: `${t} ${t} transparent ${t}`,
873
+ borderWidth: `${s}px`
874
+ };
875
+ return /* @__PURE__ */ n("div", { className: Ic.loader, style: r });
876
+ }, Sc = "_container_4qmbg_1", $c = "_toast_4qmbg_10", kc = "_info_4qmbg_23", xc = "_success_4qmbg_27", Ec = "_error_4qmbg_31", Tc = "_icon_4qmbg_36", Ac = "_content_4qmbg_43", Dc = "_title_4qmbg_46", qc = "_description_4qmbg_51", Pc = "_close_4qmbg_72", Fe = {
877
+ container: Sc,
878
+ toast: $c,
879
+ info: kc,
880
+ success: xc,
881
+ error: Ec,
882
+ icon: Tc,
883
+ content: Ac,
884
+ title: Dc,
885
+ description: qc,
886
+ close: Pc
887
+ }, Rc = ({ notification: e, onClose: t }) => {
888
+ const s = Zr(e, {
889
+ keys: (o) => (o == null ? void 0 : o.id) || "empty",
890
+ from: { transform: "translateY(-52px)", opacity: 0 },
891
+ enter: { transform: "translateY(0px)", opacity: 1 },
892
+ leave: { transform: "translateY(-52px)", opacity: 0 },
893
+ config: { ...Xr.wobbly, clamp: !0 }
894
+ }), r = (o) => {
895
+ switch (o) {
896
+ case "loading":
897
+ return /* @__PURE__ */ n(Ze, { size: 16 });
898
+ case "info":
899
+ case "success":
900
+ return /* @__PURE__ */ n($n, { size: 16 });
901
+ case "error":
902
+ return /* @__PURE__ */ n(Sn, { size: 16 });
903
+ default:
904
+ return null;
905
+ }
906
+ };
907
+ return s((o, i) => {
908
+ if (!i) return null;
909
+ const { type: a, title: d, description: c } = i, l = r(a);
910
+ return /* @__PURE__ */ n(yn.div, { style: o, className: Fe.container, children: /* @__PURE__ */ u("div", { className: A(Fe.toast, a && Fe[a]), children: [
911
+ l && /* @__PURE__ */ n("div", { className: Fe.icon, children: l }),
912
+ /* @__PURE__ */ u("div", { className: Fe.content, children: [
913
+ /* @__PURE__ */ n("p", { className: Fe.title, children: d }),
914
+ c && /* @__PURE__ */ n("div", { className: Fe.description, children: c })
915
+ ] }),
916
+ /* @__PURE__ */ n("button", { className: Fe.close, onClick: t, children: /* @__PURE__ */ n(eo, { size: 14 }) })
917
+ ] }) });
918
+ });
919
+ }, Bo = ht(null), Fo = () => Ke(Bo), mr = 5e3, Oc = ({ children: e }) => {
920
+ const t = Vt(), [s, r] = L(null), o = $s(null), i = () => {
921
+ o.current && (clearTimeout(o.current), o.current = null);
922
+ }, a = ee(() => {
923
+ i(), r(null);
924
+ }, []), d = ee(
925
+ (l) => {
926
+ i(), r({ ...l, id: lr() }), l.autoHide && (o.current = setTimeout(() => a(), mr));
927
+ },
928
+ [a]
929
+ ), c = ee(
930
+ (l) => {
931
+ i(), r((m) => m ? { ...m, ...l } : { ...l, id: lr() }), l.autoHide && (o.current = setTimeout(() => a(), mr));
932
+ },
933
+ [a]
934
+ );
935
+ return H(() => () => i(), []), /* @__PURE__ */ u(
936
+ Bo.Provider,
937
+ {
938
+ value: { showNotification: d, updateNotification: c, hideNotification: a },
939
+ children: [
940
+ e,
941
+ t && Jr(/* @__PURE__ */ n(Rc, { notification: s, onClose: a }), t)
942
+ ]
943
+ }
944
+ );
945
+ }, Mo = ht(!1), Bc = "_overlay_1eoyl_1", Fc = "_fullscreen_1eoyl_12", Mc = "_content_1eoyl_16", Uc = "_header_1eoyl_73", jc = "_title_1eoyl_82", zc = "_close_1eoyl_87", et = {
946
+ overlay: Bc,
947
+ fullscreen: Fc,
948
+ content: Mc,
949
+ header: Uc,
950
+ title: jc,
951
+ close: zc
952
+ }, Uo = ({ title: e, children: t, trigger: s, open: r, onOpenChange: o }) => {
953
+ const i = Ke(Mo);
954
+ return /* @__PURE__ */ u(pt.Root, { open: r, onOpenChange: o, children: [
955
+ s && /* @__PURE__ */ n(pt.Trigger, { asChild: !0, children: s }),
956
+ /* @__PURE__ */ u(pt.Portal, { container: Vt(), children: [
957
+ /* @__PURE__ */ n("div", { className: A(et.overlay, { [et.fullscreen]: i }) }),
958
+ /* @__PURE__ */ u(pt.Content, { className: A(et.content, { [et.fullscreen]: i }), children: [
959
+ e && /* @__PURE__ */ u("header", { className: et.header, children: [
960
+ /* @__PURE__ */ n(pt.Title, { className: et.title, children: e }),
961
+ /* @__PURE__ */ n(pt.Close, { className: et.close, children: /* @__PURE__ */ n(eo, { size: 20 }) })
962
+ ] }),
963
+ t
964
+ ] })
965
+ ] })
966
+ ] });
967
+ }, Kc = "_root_1wwaf_1", Hc = "_item_1wwaf_10", Lc = "_chevron_1wwaf_14", Wc = "_trigger_1wwaf_19", Vc = "_content_1wwaf_39", Rt = {
968
+ root: Kc,
969
+ item: Hc,
970
+ chevron: Lc,
971
+ trigger: Wc,
972
+ content: Vc
973
+ };
974
+ function jo(e) {
975
+ const { list: t, getKey: s, renderHeader: r, renderContent: o, footer: i, ...a } = e;
976
+ return /* @__PURE__ */ u(Ce.Root, { className: Rt.root, type: "multiple", ...a, children: [
977
+ t.map((d, c) => /* @__PURE__ */ u(
978
+ Ce.Item,
979
+ {
980
+ className: Rt.item,
981
+ value: (s == null ? void 0 : s(d)) ?? String(c),
982
+ children: [
983
+ /* @__PURE__ */ n(Ce.Header, { children: /* @__PURE__ */ u(Ce.Trigger, { className: Rt.trigger, children: [
984
+ r(d),
985
+ /* @__PURE__ */ n(Le, { className: Rt.chevron, size: 16 })
986
+ ] }) }),
987
+ /* @__PURE__ */ n(Ce.Content, { className: Rt.content, children: o(d) })
988
+ ]
989
+ },
990
+ (s == null ? void 0 : s(d)) ?? c
991
+ )),
992
+ i
993
+ ] });
994
+ }
995
+ const Gc = "_scrollable_yv81n_1", Qc = {
996
+ scrollable: Gc
997
+ }, Re = ({ className: e, children: t }) => /* @__PURE__ */ n("div", { className: A(Qc.scrollable, e), children: t }), _s = ({ children: e }) => {
998
+ const t = $s(null), [s, r] = L(0), o = ka({
999
+ height: s,
1000
+ config: { ...Xr.stiff, clamp: !0 }
1001
+ });
1002
+ return H(() => {
1003
+ if (t.current) {
1004
+ const { height: i } = t.current.getBoundingClientRect();
1005
+ r(i);
1006
+ }
1007
+ }, [e]), e ? /* @__PURE__ */ n(yn.div, { style: { overflow: "hidden", ...o }, children: /* @__PURE__ */ n("div", { ref: t, children: e }) }) : null;
1008
+ }, Yc = "_help_7m3jv_1", Jc = "_icon_7m3jv_10", Zc = "_info_7m3jv_17", Xc = "_warning_7m3jv_21", el = "_error_7m3jv_25", tl = "_success_7m3jv_31", Qn = {
1009
+ help: Yc,
1010
+ icon: Jc,
1011
+ info: Zc,
1012
+ warning: Xc,
1013
+ error: el,
1014
+ success: tl
1015
+ }, ze = ({ level: e, className: t, mt: s = 8, children: r }) => {
1016
+ if (!r) return null;
1017
+ const o = () => {
1018
+ switch (e) {
1019
+ case "loading":
1020
+ return /* @__PURE__ */ n(Ze, { size: 12 });
1021
+ case "info":
1022
+ return /* @__PURE__ */ n(kn, { size: 12 });
1023
+ case "warning":
1024
+ case "error":
1025
+ return /* @__PURE__ */ n(Qt, { size: 12 });
1026
+ default:
1027
+ return /* @__PURE__ */ n($n, { size: 12 });
1028
+ }
1029
+ };
1030
+ return /* @__PURE__ */ u("div", { className: A(Qn.help, e && Qn[e], t), style: { marginTop: s }, children: [
1031
+ /* @__PURE__ */ n("div", { className: Qn.icon, children: o() }),
1032
+ /* @__PURE__ */ n("p", { children: r })
1033
+ ] });
1034
+ }, nl = "_stack_14kq8_1", sl = "_help_14kq8_6", rl = "_info_14kq8_14", ol = "_warning_14kq8_19", il = "_error_14kq8_24", al = "_success_14kq8_29", fs = {
1035
+ stack: nl,
1036
+ help: sl,
1037
+ info: rl,
1038
+ warning: ol,
1039
+ error: il,
1040
+ success: al
1041
+ }, cl = ({ children: e }) => !e || Array.isArray(e) && e.filter(Boolean).length === 0 ? null : /* @__PURE__ */ n(_s, { children: /* @__PURE__ */ n("div", { className: fs.stack, children: e }) }), Y = (e) => /* @__PURE__ */ n(ze, { ...e, className: A(fs.help, fs[e.level]), mt: 0 });
1042
+ Y.Stack = cl;
1043
+ const ll = "_footer_xif7g_1", dl = "_actions_xif7g_10", hr = {
1044
+ footer: ll,
1045
+ actions: dl
1046
+ }, J = ({ extra: e, className: t, children: s }) => /* @__PURE__ */ u("footer", { className: A(hr.footer, t), children: [
1047
+ e,
1048
+ /* @__PURE__ */ n("div", { className: hr.actions, children: s })
1049
+ ] }), ul = "_button_7llhj_1", ml = "_outline_7llhj_24", hl = "_sm_7llhj_42", _l = "_full_7llhj_48", fl = "_small_7llhj_52", pl = "_unpadded_7llhj_82", ct = {
1050
+ button: ul,
1051
+ outline: ml,
1052
+ sm: hl,
1053
+ full: _l,
1054
+ small: fl,
1055
+ unpadded: pl
1056
+ }, zo = (e) => {
1057
+ const { sm: t, fullWidth: s, loading: r, className: o, children: i, disabled: a, ...d } = e;
1058
+ return /* @__PURE__ */ n(
1059
+ "button",
1060
+ {
1061
+ ...d,
1062
+ className: A(ct.button, { [ct.sm]: t, [ct.full]: s }, o),
1063
+ disabled: !!r || a,
1064
+ children: r ? /* @__PURE__ */ u(P, { children: [
1065
+ /* @__PURE__ */ n(Ze, { color: "currentColor", size: 16 }),
1066
+ typeof r == "string" && /* @__PURE__ */ n("span", { className: ct.loading, children: r })
1067
+ ] }) : i
1068
+ }
1069
+ );
1070
+ }, gl = ({ className: e, ...t }) => /* @__PURE__ */ n(zo, { ...t, className: A(ct.outline, e) }), yl = ({ className: e, unpadded: t, ...s }) => /* @__PURE__ */ n("button", { ...s, className: A(ct.small, { [ct.unpadded]: t }, e) }), j = {
1071
+ White: zo,
1072
+ Outline: gl,
1073
+ Small: yl
1074
+ }, wl = "_item_1n572_1", bl = "_title_1n572_10", vl = "_content_1n572_14", Yn = {
1075
+ item: wl,
1076
+ title: bl,
1077
+ content: vl
1078
+ }, Jn = ({ title: e, content: t }) => /* @__PURE__ */ u("div", { className: Yn.item, children: [
1079
+ /* @__PURE__ */ n("div", { className: Yn.title, children: e }),
1080
+ /* @__PURE__ */ n("div", { className: Yn.content, children: t })
1081
+ ] }), Nl = "_trigger_13rgr_1", Cl = "_icon_13rgr_5", Il = "_content_13rgr_16", Sl = "_item_13rgr_24", nn = {
1082
+ trigger: Nl,
1083
+ icon: Cl,
1084
+ content: Il,
1085
+ item: Sl
1086
+ }, $l = ({ options: e, value: t, onChange: s }) => {
1087
+ const r = Vt(), { txRequest: o } = ko(), i = $e(o.chainId), a = Zt(i), d = ({ amount: [{ amount: c, denom: l }] }) => {
1088
+ if (T(c).isZero()) return "0";
1089
+ const { symbol: m, decimals: h } = a(l);
1090
+ return `${ae(c, { decimals: h })} ${m}`;
1091
+ };
1092
+ return e.length === 1 ? d(e[0]) : /* @__PURE__ */ u(ke.Root, { value: t, onValueChange: s, children: [
1093
+ /* @__PURE__ */ u(ke.Trigger, { className: nn.trigger, children: [
1094
+ /* @__PURE__ */ n(ke.Value, {}),
1095
+ /* @__PURE__ */ n(ke.Icon, { className: nn.icon, children: /* @__PURE__ */ n(Le, { size: 16 }) })
1096
+ ] }),
1097
+ /* @__PURE__ */ n(ke.Portal, { container: r, children: /* @__PURE__ */ n(ke.Content, { className: nn.content, position: "popper", sideOffset: 6, align: "end", children: /* @__PURE__ */ n(ke.Viewport, { children: e.map((c) => {
1098
+ const [{ denom: l }] = c.amount;
1099
+ return /* @__PURE__ */ n(ke.Item, { className: nn.item, value: l, children: /* @__PURE__ */ n(ke.ItemText, { children: d(c) }) }, l);
1100
+ }) }) }) })
1101
+ ] });
1102
+ };
1103
+ function bn(e) {
1104
+ switch (typeof e) {
1105
+ case "string":
1106
+ return e;
1107
+ case "number":
1108
+ case "bigint":
1109
+ return e.toString();
1110
+ case "boolean":
1111
+ return e ? "true" : "false";
1112
+ case "object":
1113
+ return e === null ? "null" : e instanceof Uint8Array ? qe(e) : Array.isArray(e) ? `[${e.map(bn).join(",")}]` : JSON.stringify(
1114
+ e,
1115
+ (t, s) => typeof s == "bigint" ? s.toString() : s
1116
+ );
1117
+ default:
1118
+ return "unknown";
1119
+ }
1120
+ }
1121
+ const Gt = {
1122
+ ...Mr,
1123
+ address: _r,
1124
+ object: _r,
1125
+ bigdecimal: kl
1126
+ };
1127
+ function Ko(e) {
1128
+ const t = e.trim().match(/^(\w+)<(.+)>$/);
1129
+ if (t) {
1130
+ const [, r, o] = t, i = Ko(o);
1131
+ return Gt[r](i);
1132
+ }
1133
+ const s = Hr(e.split("::")).toLowerCase();
1134
+ return Gt[s]();
1135
+ }
1136
+ function _r(e) {
1137
+ return Gt.bytes(32, e).transform({
1138
+ input: (t) => D.toBytes(t, 32),
1139
+ output: (t) => `0x${mt(t)}`
1140
+ });
1141
+ }
1142
+ function kl(e) {
1143
+ return Gt.vector(Gt.u8(e)).transform({
1144
+ input: (t) => {
1145
+ const s = it(t).times(it(10).pow(18)).toFixed(0, it.ROUND_DOWN);
1146
+ return xl(BigInt(s));
1147
+ },
1148
+ output: (t) => {
1149
+ const s = El(new Uint8Array(t));
1150
+ return it(s).div(it(10).pow(18)).toFixed();
1151
+ }
1152
+ });
1153
+ }
1154
+ function xl(e) {
1155
+ if (e < 0n)
1156
+ throw new Error("negative values are not supported");
1157
+ if (e === 0n)
1158
+ return new Uint8Array([0]);
1159
+ const t = [];
1160
+ let s = e;
1161
+ for (; s > 0n; )
1162
+ t.push(Number(s & 0xffn)), s >>= 8n;
1163
+ return new Uint8Array(t);
1164
+ }
1165
+ function El(e) {
1166
+ let t = 0n;
1167
+ for (let s = 0; s < e.length; s++)
1168
+ t += BigInt(e[s]) << BigInt(8 * s);
1169
+ return t;
1170
+ }
1171
+ const Tl = "_container_1xzyq_1", Al = "_toggle_1xzyq_5", Dl = "_list_1xzyq_11", ql = "_arg_1xzyq_16", Pl = "_type_1xzyq_21", Ot = {
1172
+ container: Tl,
1173
+ toggle: Al,
1174
+ list: Dl,
1175
+ arg: ql,
1176
+ type: Pl
1177
+ }, Rl = He("interwovenkit:move", {
1178
+ abi: (e, t, s, r) => [e, t, s, r]
1179
+ }), Ol = ({ type: e, arg: t }) => bn(Ko(e).parse(t)), Bl = ({ msg: e, chainId: t, fallback: s }) => {
1180
+ const [r, o] = qs(!1), { restUrl: i } = $e(t), { moduleAddress: a, moduleName: d, functionName: c, args: l } = e, { data: m } = ge({
1181
+ queryKey: Rl.abi(i, a, d, c).queryKey,
1182
+ queryFn: async () => {
1183
+ const _ = await M.create({ prefixUrl: i }).get(`initia/move/v1/accounts/${a}/modules/${d}`).json(), g = JSON.parse(_.module.abi).exposed_functions.find(({ name: p }) => p === c);
1184
+ if (!g)
1185
+ throw new Error(`Function ${c} not found in module ${d}`);
1186
+ return g.params.filter((p) => !p.startsWith("&"));
1187
+ },
1188
+ staleTime: F.INFINITY
1189
+ });
1190
+ if (!m) return s;
1191
+ const h = (_, f) => {
1192
+ const g = m[f];
1193
+ return /* @__PURE__ */ u("div", { className: Ot.arg, children: [
1194
+ /* @__PURE__ */ n("div", { className: Ot.type, children: g }),
1195
+ /* @__PURE__ */ n(Yr, { fallback: /* @__PURE__ */ n("div", { className: "error", children: "Error decoding argument" }), children: /* @__PURE__ */ n(Ol, { type: g, arg: _ }) })
1196
+ ] }, f);
1197
+ };
1198
+ return /* @__PURE__ */ u("div", { className: Ot.container, children: [
1199
+ /* @__PURE__ */ n(j.Small, { className: Ot.toggle, onClick: o, disabled: !m, children: r ? "Encode" : "Decode" }),
1200
+ r ? /* @__PURE__ */ n("div", { className: Ot.list, children: l.map(h) }) : s
1201
+ ] });
1202
+ }, Fl = "_list_r67rl_1", Ml = "_key_r67rl_8", Ul = "_value_r67rl_13", Zn = {
1203
+ list: Fl,
1204
+ key: Ml,
1205
+ value: Ul
1206
+ }, jl = ({ message: e, chainId: t }) => {
1207
+ const { typeUrl: s, value: r } = e;
1208
+ return /* @__PURE__ */ n("div", { className: Zn.list, children: Object.entries(r).map(([o, i]) => /* @__PURE__ */ u("div", { children: [
1209
+ /* @__PURE__ */ n("div", { className: Zn.key, children: o }),
1210
+ /* @__PURE__ */ n("div", { className: Zn.value, children: s === "/initia.move.v1.MsgExecute" && o === "args" ? /* @__PURE__ */ n(Bl, { msg: r, chainId: t, fallback: bn(i) }) : bn(i) })
1211
+ ] }, o)) });
1212
+ }, zl = "_title_kspdu_1", Kl = "_meta_kspdu_7", Hl = "_footer_kspdu_14", Xn = {
1213
+ title: zl,
1214
+ meta: Kl,
1215
+ footer: Hl
1216
+ }, Ho = () => {
1217
+ const { txRequest: e, resolve: t, reject: s } = ko(), { messages: r, memo: o, chainId: i, gas: a, gasAdjustment: d } = e, c = Z(), l = Rn(), m = No(), h = $e(i), _ = Us(h), { data: f } = le({
1218
+ queryKey: Bs.gasPrices(h).queryKey,
1219
+ queryFn: async () => {
1220
+ var y;
1221
+ if ((y = h.metadata) != null && y.is_l1) {
1222
+ const { restUrl: S } = h, { gas_prices: R } = await M.create({ prefixUrl: S }).get("initia/tx/v1/gas_prices").json();
1223
+ return R.toSorted(_e(({ denom: B }) => B === "uinit")).map(({ denom: B, amount: x }) => {
1224
+ const O = T(x).times(Za).toFixed(18);
1225
+ return ds.fromString(O + B);
1226
+ });
1227
+ }
1228
+ return h.fees.fee_tokens.map(
1229
+ ({ denom: S, fixed_min_gas_price: R }) => ds.fromString(R + S)
1230
+ );
1231
+ },
1232
+ staleTime: F.SECOND
1233
+ }), g = f.map(
1234
+ (y) => Vr(Math.ceil(a * d), y)
1235
+ ), p = g.map((y) => y.amount[0]), w = (y) => {
1236
+ var B, x;
1237
+ const S = ((B = _.find((O) => O.denom === y)) == null ? void 0 : B.amount) ?? 0, R = ((x = p.find((O) => O.denom === y)) == null ? void 0 : x.amount) ?? 0;
1238
+ return T(S).gte(R);
1239
+ }, v = `${U.FEE_DENOM}:${i}`, b = () => {
1240
+ const y = localStorage.getItem(v);
1241
+ if (y && w(y))
1242
+ return y;
1243
+ for (const { denom: S } of p)
1244
+ if (w(S))
1245
+ return S;
1246
+ return p[0].denom;
1247
+ }, [k, C] = L(b), { mutate: I, isPending: E } = Pe({
1248
+ mutationKey: [mc],
1249
+ mutationFn: async () => {
1250
+ const y = g.find((R) => R.amount[0].denom === k);
1251
+ if (!y) throw new Error("Fee not found");
1252
+ if (!l) throw new Error("Signer not initialized");
1253
+ const S = await m(i, c, r, y, o);
1254
+ await t(S);
1255
+ },
1256
+ onMutate: () => {
1257
+ localStorage.setItem(v, k);
1258
+ },
1259
+ onError: async (y) => {
1260
+ s(new Error(await Ve(y)));
1261
+ }
1262
+ });
1263
+ H(() => () => {
1264
+ s(new Error("User rejected"));
1265
+ }, [s]);
1266
+ const N = !w(k);
1267
+ return /* @__PURE__ */ u(P, { children: [
1268
+ /* @__PURE__ */ u(Re, { children: [
1269
+ /* @__PURE__ */ n("h1", { className: Xn.title, children: "Confirm tx" }),
1270
+ /* @__PURE__ */ u("div", { className: Xn.meta, children: [
1271
+ /* @__PURE__ */ n(Jn, { title: "Chain", content: i }),
1272
+ /* @__PURE__ */ n(
1273
+ Jn,
1274
+ {
1275
+ title: "Tx fee",
1276
+ content: /* @__PURE__ */ n($l, { options: g, value: k, onChange: C })
1277
+ }
1278
+ ),
1279
+ o && /* @__PURE__ */ n(Jn, { title: "Memo", content: o }),
1280
+ N && /* @__PURE__ */ n(Y, { level: "error", children: "Insufficient balance for fee" })
1281
+ ] }),
1282
+ /* @__PURE__ */ n(
1283
+ jo,
1284
+ {
1285
+ list: r,
1286
+ renderHeader: ({ typeUrl: y }) => En(y.split(".").pop().replace(/^Msg/, "")),
1287
+ renderContent: (y) => /* @__PURE__ */ n(jl, { message: y, chainId: i })
1288
+ }
1289
+ )
1290
+ ] }),
1291
+ /* @__PURE__ */ u(J, { className: Xn.footer, children: [
1292
+ /* @__PURE__ */ n(j.Outline, { onClick: () => s(new Error("User rejected")), disabled: E, children: "Reject" }),
1293
+ /* @__PURE__ */ n(j.White, { onClick: () => I(), disabled: N, loading: E, children: "Approve" })
1294
+ ] })
1295
+ ] });
1296
+ }, Ll = ({ children: e }) => {
1297
+ const [{ title: t, content: s, path: r }, o] = L({}), [i, a] = L(!1), d = ee((l) => {
1298
+ o(l), a(!0);
1299
+ }, []), c = ee(() => {
1300
+ o({}), a(!1);
1301
+ }, []);
1302
+ return /* @__PURE__ */ u(wo.Provider, { value: { openModal: d, closeModal: c }, children: [
1303
+ e,
1304
+ /* @__PURE__ */ n(Uo, { title: t, open: i, onOpenChange: a, children: r === "/tx" ? /* @__PURE__ */ n(Ho, {}) : s })
1305
+ ] });
1306
+ }, Lo = ({ value: e, children: t }) => {
1307
+ const [s, r] = L(!1);
1308
+ return t({ copy: async () => {
1309
+ try {
1310
+ await navigator.clipboard.writeText(e), r(!0), setTimeout(() => r(!1), 1e3);
1311
+ } catch {
1312
+ }
1313
+ }, copied: s });
1314
+ }, Wl = "_placeholder_80nya_1", Vl = "_circle_80nya_5", fr = {
1315
+ placeholder: Wl,
1316
+ circle: Vl
1317
+ }, z = ({ src: e, alt: t, placeholder: s, classNames: r, circle: o, ...i }) => {
1318
+ const { width: a, height: d } = i, c = s ?? /* @__PURE__ */ n("div", { className: A(fr.placeholder, r == null ? void 0 : r.placeholder), style: { width: a, height: d } });
1319
+ return e ? /* @__PURE__ */ n(
1320
+ Ma,
1321
+ {
1322
+ ...i,
1323
+ className: A(i.className, { [fr.circle]: o }),
1324
+ style: { width: a, height: d },
1325
+ src: e,
1326
+ alt: t,
1327
+ unloader: c,
1328
+ loading: "lazy"
1329
+ }
1330
+ ) : c;
1331
+ }, Gl = "_header_jomuw_1", Ql = "_logo_jomuw_10", Yl = "_copy_jomuw_18", Jl = "_name_jomuw_26", Zl = "_address_jomuw_30", Xl = "_icon_jomuw_34", ed = "_copied_jomuw_41", td = "_disconnect_jomuw_56", Me = {
1332
+ header: Gl,
1333
+ logo: Ql,
1334
+ copy: Yl,
1335
+ name: Jl,
1336
+ address: Zl,
1337
+ icon: Xl,
1338
+ copied: ed,
1339
+ disconnect: td
1340
+ }, nd = () => {
1341
+ const { connector: e } = St(), { disconnect: t } = Fi(), { address: s, username: r } = Qe(), { closeDrawer: o } = xt(), i = r ?? s;
1342
+ return e ? /* @__PURE__ */ u("header", { className: Me.header, children: [
1343
+ /* @__PURE__ */ n("div", { className: Me.logo, children: /* @__PURE__ */ n(z, { src: e.icon, width: 18, height: 18 }) }),
1344
+ /* @__PURE__ */ n(Lo, { value: s, children: ({ copy: a, copied: d }) => /* @__PURE__ */ u("button", { className: A(Me.copy, { [Me.copied]: d }), onClick: a, children: [
1345
+ /* @__PURE__ */ n("div", { className: Me.address, children: ie(s) }),
1346
+ /* @__PURE__ */ n("div", { className: Me.name, children: ie(i) }),
1347
+ /* @__PURE__ */ n(xa, { className: Me.icon, size: 12 }),
1348
+ d ? "Copied!" : ""
1349
+ ] }) }),
1350
+ /* @__PURE__ */ n(
1351
+ "button",
1352
+ {
1353
+ className: Me.disconnect,
1354
+ onClick: () => {
1355
+ o(), t();
1356
+ },
1357
+ children: /* @__PURE__ */ n(Ea, { size: 18 })
1358
+ }
1359
+ )
1360
+ ] }) : null;
1361
+ }, sd = "_link_guafb_1", rd = {
1362
+ link: sd
1363
+ }, Ks = (e) => {
1364
+ const { chainId: t, txHash: s, showIcon: r, className: o, children: i, onClick: a, ...d } = e, c = $e(t), l = Ae(["explorers", 0, "tx_page"], c), m = i ?? ie(s);
1365
+ return l ? /* @__PURE__ */ u(
1366
+ "a",
1367
+ {
1368
+ ...d,
1369
+ href: ao(od(l.replace(/\$\{txHash\}/g, s))),
1370
+ className: A(rd.link, o),
1371
+ onClick: a,
1372
+ target: "_blank",
1373
+ children: [
1374
+ m,
1375
+ r && /* @__PURE__ */ n(Ht, { size: 12 })
1376
+ ]
1377
+ }
1378
+ ) : /* @__PURE__ */ n("span", { ...d, children: m });
1379
+ };
1380
+ function od(e) {
1381
+ try {
1382
+ const t = new URL(e, window.location.href);
1383
+ if (!["http:", "https:"].includes(t.protocol))
1384
+ throw new Error("Invalid protocol");
1385
+ return t.toString();
1386
+ } catch {
1387
+ return "#";
1388
+ }
1389
+ }
1390
+ const id = () => {
1391
+ const [e, t] = In($o), { showNotification: s, updateNotification: r, hideNotification: o } = Fo();
1392
+ return H(() => {
1393
+ if (!e) return;
1394
+ const { status: i, chainId: a, txHash: d, error: c } = e, l = c ? c.message : d ? /* @__PURE__ */ n(Ks, { txHash: d, chainId: a, onClick: o, showIcon: !0, children: "View on Initia Scan" }) : null;
1395
+ switch (i) {
1396
+ case "loading":
1397
+ s({
1398
+ type: "loading",
1399
+ title: "Transaction is pending..."
1400
+ });
1401
+ break;
1402
+ case "error":
1403
+ r({
1404
+ type: "error",
1405
+ title: "Transaction failed",
1406
+ description: l
1407
+ }), t(null);
1408
+ break;
1409
+ case "success":
1410
+ r({
1411
+ type: "success",
1412
+ title: "Transaction is successful!",
1413
+ description: l
1414
+ }), t(null);
1415
+ break;
1416
+ }
1417
+ }, [e, t, s, r, o]), null;
1418
+ }, ad = "_overlay_1bu6o_1", cd = "_content_1bu6o_49", pr = {
1419
+ overlay: ad,
1420
+ content: cd
1421
+ }, ld = ({ children: e }) => {
1422
+ const { isDrawerOpen: t, closeDrawer: s } = xt(), { setContainer: r } = Ke(zs), o = oo("(max-width: 576px)");
1423
+ dd(t && o);
1424
+ const i = de(), a = Se(), d = {
1425
+ fallbackRender: ({ error: l, resetErrorBoundary: m }) => {
1426
+ const h = () => {
1427
+ i("/"), a.clear(), m();
1428
+ };
1429
+ return /* @__PURE__ */ u(Re, { children: [
1430
+ /* @__PURE__ */ n(ce, { error: !0, children: l.message }),
1431
+ /* @__PURE__ */ n(J, { children: /* @__PURE__ */ n(j.White, { onClick: h, children: "Retry" }) })
1432
+ ] });
1433
+ }
1434
+ }, c = Zr(t, {
1435
+ from: { transform: o ? "translateY(100%)" : "translateX(100%)" },
1436
+ enter: { transform: o ? "translateY(0%)" : "translateX(0%)" },
1437
+ leave: { transform: o ? "translateY(100%)" : "translateX(100%)" },
1438
+ config: { tension: 500, friction: 35, clamp: !0 }
1439
+ });
1440
+ return Jr(
1441
+ /* @__PURE__ */ u(P, { children: [
1442
+ c(
1443
+ (l, m) => m ? /* @__PURE__ */ n(yn.button, { style: l, className: pr.overlay, onClick: s, children: /* @__PURE__ */ u("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", width: "14", height: "14", children: [
1444
+ /* @__PURE__ */ n("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" }),
1445
+ /* @__PURE__ */ n("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" })
1446
+ ] }) }) : null
1447
+ ),
1448
+ c(
1449
+ (l, m) => m ? /* @__PURE__ */ u(yn.div, { style: l, className: A(pr.content, "body"), ref: r, children: [
1450
+ /* @__PURE__ */ n(id, {}),
1451
+ /* @__PURE__ */ n(nd, {}),
1452
+ /* @__PURE__ */ n(ne, { errorBoundaryProps: d, children: e })
1453
+ ] }) : null
1454
+ )
1455
+ ] }),
1456
+ Ja()
1457
+ );
1458
+ };
1459
+ function dd(e) {
1460
+ Ri(() => {
1461
+ const t = document.body.style.overflow;
1462
+ return e ? document.body.style.overflow = "hidden" : document.body.style.overflow = t, () => {
1463
+ document.body.style.overflow = t;
1464
+ };
1465
+ }, [e]);
1466
+ }
1467
+ const ud = "_page_rx25j_1", md = "_title_rx25j_10", hd = "_scrollable_rx25j_17", _d = "_list_rx25j_22", fd = "_item_rx25j_32", pd = "_name_rx25j_51", gd = "_dimmed_rx25j_59", yd = "_recent_rx25j_63", wd = "_installed_rx25j_64", bd = "_docs_rx25j_81", me = {
1468
+ page: ud,
1469
+ title: md,
1470
+ scrollable: hd,
1471
+ list: _d,
1472
+ item: fd,
1473
+ name: pd,
1474
+ dimmed: gd,
1475
+ recent: yd,
1476
+ installed: wd,
1477
+ docs: bd
1478
+ }, vd = [
1479
+ { name: "Rabby", url: "https://rabby.io" },
1480
+ { name: "Phantom", url: "https://phantom.com" },
1481
+ { name: "Keplr", url: "https://keplr.app" },
1482
+ { name: "Leap", url: "https://leapwallet.io" }
1483
+ ], Nd = () => {
1484
+ const { closeDrawer: e } = xt(), { connectors: t, connectAsync: s } = Mi(), [r, o] = Yt(
1485
+ U.LATEST_CONNECTOR_ID
1486
+ ), [i, a] = L(null), { mutate: d, isPending: c } = Pe({
1487
+ mutationFn: async (l) => {
1488
+ a(l.id);
1489
+ try {
1490
+ return await s({ connector: l }), l;
1491
+ } catch (m) {
1492
+ throw new Error(await Ve(m));
1493
+ }
1494
+ },
1495
+ onSettled: () => {
1496
+ a(null);
1497
+ },
1498
+ onSuccess: (l) => {
1499
+ o(l.id), e();
1500
+ }
1501
+ });
1502
+ return /* @__PURE__ */ u("div", { className: me.page, children: [
1503
+ /* @__PURE__ */ n("h1", { className: me.title, children: "Connect wallet" }),
1504
+ /* @__PURE__ */ n(Re, { className: me.scrollable, children: /* @__PURE__ */ u("div", { className: me.list, children: [
1505
+ t.toSorted(_e((l) => l.id === r)).map((l) => {
1506
+ const { name: m, icon: h, id: _ } = l;
1507
+ return /* @__PURE__ */ u(
1508
+ "button",
1509
+ {
1510
+ className: me.item,
1511
+ onClick: () => d(l),
1512
+ disabled: c,
1513
+ children: [
1514
+ /* @__PURE__ */ n(z, { src: h, width: 24, height: 24 }),
1515
+ /* @__PURE__ */ n("span", { className: me.name, children: m }),
1516
+ i === _ ? /* @__PURE__ */ n(Ze, { size: 16 }) : r === _ ? /* @__PURE__ */ n("span", { className: me.recent, children: "Recent" }) : /* @__PURE__ */ n("span", { className: me.installed, children: "Installed" })
1517
+ ]
1518
+ },
1519
+ _
1520
+ );
1521
+ }),
1522
+ vd.filter(({ name: l }) => !t.some((m) => m.name.includes(l))).map(({ name: l, url: m }) => {
1523
+ const h = `https://assets.initia.xyz/images/wallets/${l}.webp`;
1524
+ return /* @__PURE__ */ u("a", { href: m, className: me.item, target: "_blank", children: [
1525
+ /* @__PURE__ */ n(z, { src: h, width: 24, height: 24 }),
1526
+ /* @__PURE__ */ n("span", { className: A(me.name, me.dimmed), children: l }),
1527
+ /* @__PURE__ */ n(Ht, { size: 10 })
1528
+ ] }, l);
1529
+ })
1530
+ ] }) }),
1531
+ /* @__PURE__ */ n(J, { children: /* @__PURE__ */ u("a", { href: "https://docs.initia.xyz", target: "_blank", className: me.docs, children: [
1532
+ /* @__PURE__ */ n("span", { children: "Learn more" }),
1533
+ /* @__PURE__ */ n(Ht, { size: 14 })
1534
+ ] }) })
1535
+ ] });
1536
+ }, Cd = "_root_xwz5z_1", Id = "_header_xwz5z_6", Sd = "_title_xwz5z_12", $d = "_warning_xwz5z_18", kd = "_content_xwz5z_22", xd = "_footer_xwz5z_26", Ed = "_secondary_xwz5z_36", tt = {
1537
+ root: Cd,
1538
+ header: Id,
1539
+ title: Sd,
1540
+ warning: $d,
1541
+ content: kd,
1542
+ footer: xd,
1543
+ secondary: Ed
1544
+ }, Wo = (e) => {
1545
+ const { type: t, icon: s, title: r, children: o, primaryButton: i, secondaryButton: a } = e;
1546
+ return /* @__PURE__ */ u(Re, { className: tt.root, children: [
1547
+ /* @__PURE__ */ u("header", { className: A(tt.header, t && tt[t]), children: [
1548
+ s,
1549
+ /* @__PURE__ */ n("h1", { className: tt.title, children: r })
1550
+ ] }),
1551
+ /* @__PURE__ */ n("div", { className: tt.content, children: o }),
1552
+ /* @__PURE__ */ u("footer", { className: tt.footer, children: [
1553
+ /* @__PURE__ */ n(j.White, { onClick: i.onClick, sm: !0, fullWidth: !0, children: i.label }),
1554
+ /* @__PURE__ */ u("button", { className: tt.secondary, onClick: a.onClick, children: [
1555
+ /* @__PURE__ */ n("span", { children: a.label }),
1556
+ /* @__PURE__ */ n(Ds, { size: 14 })
1557
+ ] })
1558
+ ] })
1559
+ ] });
1560
+ }, Td = "_list_tmcxc_1", Ad = "_row_tmcxc_8", Dd = "_dt_tmcxc_19", qd = "_asset_tmcxc_25", sn = {
1561
+ list: Td,
1562
+ row: Ad,
1563
+ dt: Dd,
1564
+ asset: qd
1565
+ }, Pd = ({ list: e, onNavigate: t, onDismiss: s }) => {
1566
+ const r = we(), o = _t(), i = Zt(r);
1567
+ return /* @__PURE__ */ n(
1568
+ Wo,
1569
+ {
1570
+ title: "Ready to claim",
1571
+ primaryButton: { label: "View withdrawal status", onClick: t },
1572
+ secondaryButton: { label: "Do not show again", onClick: s },
1573
+ children: /* @__PURE__ */ n("div", { className: sn.list, children: e.toSorted((a, d) => a.chainId.localeCompare(d.chainId)).map(({ txHash: a, chainId: d, amount: c, denom: l }) => {
1574
+ const m = o(d), { decimals: h, symbol: _ } = i(l), f = ae(c, { decimals: h });
1575
+ return /* @__PURE__ */ u("div", { className: sn.row, children: [
1576
+ /* @__PURE__ */ u("div", { className: sn.dt, children: [
1577
+ /* @__PURE__ */ n(z, { src: m.logoUrl, width: 16, height: 16 }),
1578
+ /* @__PURE__ */ n("span", { children: m.name })
1579
+ ] }),
1580
+ /* @__PURE__ */ u("span", { className: sn.asset, children: [
1581
+ f,
1582
+ " ",
1583
+ _
1584
+ ] })
1585
+ ] }, a);
1586
+ }) })
1587
+ }
1588
+ );
1589
+ };
1590
+ function es(e, t) {
1591
+ return e.chainId === t.chainId && e.txHash === t.txHash;
1592
+ }
1593
+ const rn = ({ chainId: e, txHash: t }) => `${U.OP_REMINDER}:${e}:${t}`, Rd = Qr(U.OP_REMINDER, []);
1594
+ function Tt() {
1595
+ const e = Z(), [t = [], s] = In(Rd), r = fe(() => t.map((c) => {
1596
+ const l = localStorage.getItem(rn(c));
1597
+ return l ? JSON.parse(l) : null;
1598
+ }).filter((c) => {
1599
+ if (!c) return !1;
1600
+ const { recipient: l, claimableAt: m } = c;
1601
+ return l !== e ? !1 : co(m);
1602
+ }), [e, t]), o = ee(
1603
+ (c, l) => {
1604
+ t.some((m) => es(m, c)) || (s((m = []) => [...m, c]), localStorage.setItem(rn(c), JSON.stringify(l)));
1605
+ },
1606
+ [t, s]
1607
+ ), i = ee(
1608
+ (c) => {
1609
+ s((l = []) => l.filter((m) => !es(m, c))), localStorage.removeItem(rn(c));
1610
+ },
1611
+ [s]
1612
+ ), a = ee(
1613
+ (c) => {
1614
+ const l = c.filter((m) => !t.some((h) => es(h, m)));
1615
+ l.length !== 0 && s((m = []) => [...m, ...l]);
1616
+ },
1617
+ [t, s]
1618
+ ), d = ee(
1619
+ (c, l) => {
1620
+ localStorage.setItem(rn(c), JSON.stringify(l)), s((m = []) => [...m]);
1621
+ },
1622
+ [s]
1623
+ );
1624
+ return { reminders: r, addReminder: o, removeReminder: i, syncReminders: a, setReminder: d };
1625
+ }
1626
+ function Vo() {
1627
+ const e = de(), { openModal: t, closeModal: s } = Dn(), { reminders: r, setReminder: o } = Tt();
1628
+ H(() => {
1629
+ const i = r.filter((c) => !c.dismissed);
1630
+ if (i.length === 0)
1631
+ return;
1632
+ const a = () => {
1633
+ const c = i.every((l) => l.chainId === i[0].chainId) ? i[0].chainId : void 0;
1634
+ e("/op/withdrawals", { chainId: c }), d();
1635
+ }, d = () => {
1636
+ s();
1637
+ for (const c of i)
1638
+ o(c, { ...c, dismissed: !0 });
1639
+ };
1640
+ t({
1641
+ content: Nt(Pd, { list: i, onNavigate: a, onDismiss: d })
1642
+ });
1643
+ }, [r, s, e, t, o]);
1644
+ }
1645
+ const Od = "2.0.0-rc.1", Bd = "_flex_1v8wv_1", Fd = {
1646
+ flex: Bd
1647
+ }, ps = ({ mt: e, mb: t, children: s }) => /* @__PURE__ */ n("div", { className: Fd.flex, style: { marginTop: e, marginBottom: t }, children: s }), Md = "_toggle_grhff_1", Ud = "_name_grhff_7", jd = "_rollups_grhff_11", zd = "_version_grhff_29", on = {
1648
+ toggle: Md,
1649
+ name: Ud,
1650
+ rollups: jd,
1651
+ version: zd
1652
+ }, Go = ({ renderContent: e, storageKey: t }) => {
1653
+ const { defaultChainId: s } = te(), { addedChains: r } = kt(), [o = [], i] = Yt(
1654
+ `${U.OPENED_CHAIN_IDS}:${t}`,
1655
+ [s]
1656
+ ), a = o.length === 0, d = () => {
1657
+ i(a ? r.map((c) => c.chainId) : []);
1658
+ };
1659
+ return /* @__PURE__ */ u(P, { children: [
1660
+ /* @__PURE__ */ n(ps, { mb: 6, children: /* @__PURE__ */ u(j.Small, { className: on.toggle, onClick: d, children: [
1661
+ /* @__PURE__ */ n("span", { children: a ? "Expand all" : "Collapse all" }),
1662
+ a ? /* @__PURE__ */ n(Le, { size: 10 }) : /* @__PURE__ */ n(Ta, { size: 10 })
1663
+ ] }) }),
1664
+ /* @__PURE__ */ n(
1665
+ jo,
1666
+ {
1667
+ list: r,
1668
+ getKey: ({ chainId: c }) => c,
1669
+ renderHeader: ({ name: c, logoUrl: l }) => /* @__PURE__ */ u(P, { children: [
1670
+ /* @__PURE__ */ n(z, { src: l, width: 16, height: 16 }),
1671
+ /* @__PURE__ */ n("span", { className: on.name, children: c })
1672
+ ] }),
1673
+ renderContent: e,
1674
+ value: o,
1675
+ onValueChange: i,
1676
+ footer: /* @__PURE__ */ u(Jt, { className: on.rollups, to: "/rollups", children: [
1677
+ /* @__PURE__ */ n(to, { size: 12 }),
1678
+ /* @__PURE__ */ n("span", { children: "Manage rollup list" })
1679
+ ] })
1680
+ }
1681
+ ),
1682
+ /* @__PURE__ */ n(ps, { mt: 8, children: /* @__PURE__ */ u("span", { className: on.version, children: [
1683
+ "v",
1684
+ Od
1685
+ ] }) })
1686
+ ] });
1687
+ }, Hs = ({ chain: e, asset: t, children: s }) => {
1688
+ const r = Se(), { data: o } = ge({
1689
+ queryKey: dt.resource(e, t).queryKey,
1690
+ queryFn: async () => {
1691
+ var c, l, m;
1692
+ if (t.symbol || !((c = e.metadata) != null && c.is_l1 || ((m = (l = e.metadata) == null ? void 0 : l.minitia) == null ? void 0 : m.type) === "minimove")) return null;
1693
+ const i = Do(t.denom), { resource: a } = await M.create({ prefixUrl: e.restUrl }).get(`initia/move/v1/accounts/${i}/resources/by_struct_tag`, {
1694
+ searchParams: { struct_tag: "0x1::fungible_asset::Metadata" }
1695
+ }).json(), { data: d } = JSON.parse(a.move_resource);
1696
+ return r.setQueryData(dt.item(e.chainId, t.denom).queryKey, {
1697
+ ...t,
1698
+ ...d
1699
+ }), d;
1700
+ },
1701
+ staleTime: F.INFINITY
1702
+ });
1703
+ return s({ ...t, ...o });
1704
+ }, Kd = "_asset_1dxy8_1", Hd = "_token_1dxy8_23", Ld = "_symbol_1dxy8_28", Wd = "_name_1dxy8_29", Vd = "_balance_1dxy8_40", Gd = "_amount_1dxy8_45", Qd = "_value_1dxy8_49", nt = {
1705
+ asset: Kd,
1706
+ token: Hd,
1707
+ symbol: Ld,
1708
+ name: Wd,
1709
+ balance: Vd,
1710
+ amount: Gd,
1711
+ value: Qd
1712
+ }, Yd = (e) => {
1713
+ const { denom: t, symbol: s, name: r, logoUrl: o, decimals: i, balance: a = "0", value: d = 0 } = e;
1714
+ return /* @__PURE__ */ u("div", { className: nt.asset, children: [
1715
+ /* @__PURE__ */ n(z, { src: o, width: 24, height: 24 }),
1716
+ /* @__PURE__ */ u("div", { className: nt.token, children: [
1717
+ /* @__PURE__ */ n("div", { className: nt.symbol, children: s ?? ie(t) }),
1718
+ r && /* @__PURE__ */ n("div", { className: nt.name, children: r })
1719
+ ] }),
1720
+ T(a).gt(0) && /* @__PURE__ */ u("div", { className: nt.balance, children: [
1721
+ /* @__PURE__ */ n("div", { className: nt.amount, children: ae(a, { decimals: i }) }),
1722
+ d > 0 && /* @__PURE__ */ u("div", { className: nt.value, children: [
1723
+ "$",
1724
+ Ct(d)
1725
+ ] })
1726
+ ] })
1727
+ ] });
1728
+ }, Jd = "_actions_180l3_1", Zd = "_button_180l3_8", Xd = "_add_180l3_25", Bt = {
1729
+ actions: Jd,
1730
+ button: Zd,
1731
+ add: Xd
1732
+ }, eu = ({ denom: e, chain: t }) => {
1733
+ const s = de(), { defaultChainId: r } = te(), { evm_chain_id: o } = qn(), { address: i = "", symbol: a, decimals: d, logoUrl: c } = Ms(e, t), { connector: l } = St(), { switchChainAsync: m } = Ui(), { watchAssetAsync: h } = ji(), { chainId: _ } = t, f = () => {
1734
+ s("/send", { denom: e, chain: t });
1735
+ }, g = () => {
1736
+ s("/bridge", { srcChainId: _, srcDenom: e });
1737
+ }, p = Pe({
1738
+ mutationFn: async () => (await m({ chainId: Number(o) }), h({ type: "ERC20", options: { address: i, symbol: a, decimals: d, image: c } }))
1739
+ });
1740
+ return /* @__PURE__ */ u("nav", { className: Bt.actions, children: [
1741
+ /* @__PURE__ */ n("button", { className: Bt.button, onClick: f, children: "Send" }),
1742
+ /* @__PURE__ */ n("button", { className: Bt.button, onClick: g, children: "Bridge/Swap" }),
1743
+ _ === r && !!i && /* @__PURE__ */ u(
1744
+ "button",
1745
+ {
1746
+ className: A(Bt.button, Bt.add),
1747
+ onClick: () => p.mutate(),
1748
+ disabled: p.isPending || p.data,
1749
+ children: [
1750
+ p.data ? /* @__PURE__ */ n(so, { size: 10 }) : /* @__PURE__ */ n(no, { size: 10 }),
1751
+ /* @__PURE__ */ n(z, { src: l == null ? void 0 : l.icon, width: 16, height: 16 })
1752
+ ]
1753
+ }
1754
+ )
1755
+ ] });
1756
+ }, tu = "_list_wod0u_1", nu = "_item_wod0u_8", su = "_trigger_wod0u_19", ru = "_content_wod0u_24", an = {
1757
+ list: tu,
1758
+ item: nu,
1759
+ trigger: su,
1760
+ content: ru
1761
+ }, ou = (e) => {
1762
+ const t = Po(e);
1763
+ return t.length ? /* @__PURE__ */ n(Ce.Root, { type: "single", collapsible: !0, className: an.list, children: t.map((s) => /* @__PURE__ */ u(Ce.Item, { className: an.item, value: s.denom, children: [
1764
+ /* @__PURE__ */ n(Ce.Header, { children: /* @__PURE__ */ n(Ce.Trigger, { className: an.trigger, children: /* @__PURE__ */ n(Hs, { asset: s, chain: e, children: (r) => /* @__PURE__ */ n(Yd, { ...r }) }) }) }),
1765
+ /* @__PURE__ */ n(Ce.Content, { className: an.content, children: /* @__PURE__ */ n(eu, { denom: s.denom, chain: e }) })
1766
+ ] }, s.denom)) }) : /* @__PURE__ */ n(ce, { children: "No assets" });
1767
+ }, iu = () => /* @__PURE__ */ n(
1768
+ Go,
1769
+ {
1770
+ renderContent: (e) => /* @__PURE__ */ n(ne, { children: /* @__PURE__ */ n(ou, { ...e }) }),
1771
+ storageKey: "assets"
1772
+ }
1773
+ );
1774
+ function Ls(e, t) {
1775
+ var o;
1776
+ const s = ((o = t == null ? void 0 : t.pages) == null ? void 0 : o.map((i) => i[e] ?? []).flat()) ?? [], r = Lr(0, [0, "pagination", "total"], t == null ? void 0 : t.pages);
1777
+ return { list: s, count: r };
1778
+ }
1779
+ function Ws(e) {
1780
+ return e.pagination.next_key;
1781
+ }
1782
+ async function au(e, t, s) {
1783
+ const r = M.create(t), o = async (i, a) => {
1784
+ const d = await r.extend(a ? { searchParams: { "pagination.key": a } } : {}).get(e).json(), c = d[s] ?? [], l = Ws(d), m = [...i, ...c];
1785
+ return l ? o(m, l) : m;
1786
+ };
1787
+ return o([], null);
1788
+ }
1789
+ const Vs = He("interwovenkit:nft", {
1790
+ collections: (e, t) => [e, t],
1791
+ collection: (e, t, s) => [
1792
+ e,
1793
+ t,
1794
+ s
1795
+ ],
1796
+ metadata: (e) => [e]
1797
+ });
1798
+ function cu(e) {
1799
+ const { object_addr: t, collection: s } = e;
1800
+ return { object_addr: t, ...s };
1801
+ }
1802
+ function lu(e, t) {
1803
+ const { collection_addr: s, collection_name: r, nft: o, object_addr: i } = e, a = t.name ?? o.token_id;
1804
+ return { collection_addr: s, collection_name: r, ...o, object_addr: i, ...t, name: a };
1805
+ }
1806
+ function du(e) {
1807
+ const { indexerUrl: t } = e, s = Z(), { data: r } = le({
1808
+ queryKey: Vs.collections(t, s).queryKey,
1809
+ queryFn: () => au(
1810
+ `indexer/nft/v1/collections/by_account/${s}`,
1811
+ { prefixUrl: t },
1812
+ "collections"
1813
+ ),
1814
+ select: (o) => o.map(cu),
1815
+ staleTime: F.SECOND
1816
+ });
1817
+ return r;
1818
+ }
1819
+ function Qo({
1820
+ chain: e,
1821
+ collection: t
1822
+ }) {
1823
+ const s = Z(), { object_addr: r } = t, { indexerUrl: o } = e;
1824
+ return ks({
1825
+ queryKey: Vs.collection(o, s, r).queryKey,
1826
+ queryFn: ({ pageParam: i = "" }) => M.create({ prefixUrl: o }).get(`indexer/nft/v1/tokens/by_account/${s}`, {
1827
+ searchParams: {
1828
+ collection_addr: r,
1829
+ "pagination.key": i || "",
1830
+ "pagination.limit": 9
1831
+ }
1832
+ }).json(),
1833
+ initialPageParam: "",
1834
+ getNextPageParam: Ws,
1835
+ staleTime: F.SECOND
1836
+ });
1837
+ }
1838
+ function gr(e) {
1839
+ return e == null ? void 0 : e.replace("ipfs://", "https://ipfs.io/ipfs/");
1840
+ }
1841
+ function uu(e) {
1842
+ const t = gr(e);
1843
+ return ge({
1844
+ queryKey: Vs.metadata(t).queryKey,
1845
+ queryFn: async () => {
1846
+ try {
1847
+ if (!t) return {};
1848
+ const s = await M.get(t).json();
1849
+ return { ...s, image: gr(s.image) };
1850
+ } catch {
1851
+ return {};
1852
+ }
1853
+ },
1854
+ staleTime: F.INFINITY
1855
+ });
1856
+ }
1857
+ const Yo = ({ nftResponse: e, children: t }) => {
1858
+ const { data: s = {} } = uu(e.nft.uri), r = lu(e, s);
1859
+ return t(r);
1860
+ }, mu = "_thumbnail_1se9u_1", hu = "_placeholder_1se9u_15", _u = "_clickable_1se9u_21", Ft = {
1861
+ thumbnail: mu,
1862
+ placeholder: hu,
1863
+ clickable: _u
1864
+ }, Bn = ({ chain: e, collection: t, nft: s, size: r, onClick: o }) => {
1865
+ const i = new URL(
1866
+ `/v1/${e.chainId}/${t.object_addr}/${s.object_addr || s.token_id}`,
1867
+ "https://glyph.initia.xyz"
1868
+ ).toString();
1869
+ return o ? /* @__PURE__ */ n(
1870
+ "button",
1871
+ {
1872
+ className: A(Ft.thumbnail, Ft.clickable),
1873
+ onClick: o,
1874
+ style: { width: r, height: r },
1875
+ children: /* @__PURE__ */ n(z, { src: i, classNames: { placeholder: Ft.placeholder } })
1876
+ }
1877
+ ) : /* @__PURE__ */ n("div", { className: Ft.thumbnail, style: { width: r, height: r }, children: /* @__PURE__ */ n(z, { src: i, classNames: { placeholder: Ft.placeholder } }) });
1878
+ }, fu = "_item_1rdda_1", pu = "_content_1rdda_15", gu = "_name_1rdda_21", yu = "_count_1rdda_27", wu = "_chevron_1rdda_33", Mt = {
1879
+ item: fu,
1880
+ content: pu,
1881
+ name: gu,
1882
+ count: yu,
1883
+ chevron: wu
1884
+ }, bu = ({ chain: e, collection: t }) => {
1885
+ const { data: s } = Qo({ chain: e, collection: t }), { list: r, count: o } = Ls("tokens", s), [i] = r;
1886
+ return /* @__PURE__ */ u(Jt, { className: Mt.item, to: "/collection", state: { collection: t, chain: e }, children: [
1887
+ i && /* @__PURE__ */ n(Yo, { nftResponse: i, children: (a) => /* @__PURE__ */ n(Bn, { chain: e, collection: t, nft: a, size: 58 }) }),
1888
+ /* @__PURE__ */ u("div", { className: Mt.content, children: [
1889
+ /* @__PURE__ */ n("div", { className: Mt.name, children: t.name }),
1890
+ o > 0 && /* @__PURE__ */ n("div", { className: Mt.count, children: o })
1891
+ ] }),
1892
+ /* @__PURE__ */ n("div", { className: Mt.chevron, children: /* @__PURE__ */ n(Ds, {}) })
1893
+ ] });
1894
+ }, vu = "_list_1lv70_1", Nu = {
1895
+ list: vu
1896
+ }, Cu = ({ chain: e }) => {
1897
+ const t = du(e);
1898
+ return t.length ? /* @__PURE__ */ n("div", { className: Nu.list, children: t.map((s) => /* @__PURE__ */ n(bu, { collection: s, chain: e }, s.object_addr)) }) : /* @__PURE__ */ n(ce, { children: "No collections" });
1899
+ }, Iu = () => /* @__PURE__ */ n(
1900
+ Go,
1901
+ {
1902
+ renderContent: (e) => /* @__PURE__ */ n(ne, { children: /* @__PURE__ */ n(Cu, { chain: e }) }),
1903
+ storageKey: "nft"
1904
+ }
1905
+ ), ut = ({ title: e, content: t, children: s, className: r }) => {
1906
+ const [o, i] = L(!1);
1907
+ return /* @__PURE__ */ n(
1908
+ Uo,
1909
+ {
1910
+ title: e,
1911
+ trigger: /* @__PURE__ */ n("button", { className: r, children: s }),
1912
+ open: o,
1913
+ onOpenChange: i,
1914
+ children: t(() => i(!1))
1915
+ }
1916
+ );
1917
+ }, Su = "_scrollable_1p1lw_1", $u = "_list_1p1lw_5", ku = "_item_1p1lw_9", xu = "_name_1p1lw_13", cn = {
1918
+ scrollable: Su,
1919
+ list: $u,
1920
+ item: ku,
1921
+ name: xu
1922
+ };
1923
+ function Jo({ onSelect: e, list: t, ...s }) {
1924
+ const { getImage: r, getName: o, getKey: i, getIsLoading: a, getDisabled: d } = s;
1925
+ return /* @__PURE__ */ n(Re, { className: cn.scrollable, children: /* @__PURE__ */ n("div", { className: cn.list, children: t.map((c) => /* @__PURE__ */ u(
1926
+ "button",
1927
+ {
1928
+ className: cn.item,
1929
+ onClick: () => e(c),
1930
+ disabled: (a == null ? void 0 : a(c)) || (d == null ? void 0 : d(c)),
1931
+ children: [
1932
+ /* @__PURE__ */ n(z, { src: r(c), width: 28, height: 28 }),
1933
+ /* @__PURE__ */ n("span", { className: cn.name, children: o(c) }),
1934
+ (a == null ? void 0 : a(c)) && /* @__PURE__ */ n(Ze, { size: 16 })
1935
+ ]
1936
+ },
1937
+ i(c)
1938
+ )) }) });
1939
+ }
1940
+ const Zo = ({ onSelect: e }) => {
1941
+ const { addedChains: t } = kt();
1942
+ return /* @__PURE__ */ n(
1943
+ Jo,
1944
+ {
1945
+ onSelect: (s) => e(s.chainId),
1946
+ list: t,
1947
+ getImage: (s) => s.logoUrl,
1948
+ getName: (s) => s.name,
1949
+ getKey: (s) => s.chainId
1950
+ }
1951
+ );
1952
+ }, Eu = "_button_1uc4x_1", Tu = "_name_1uc4x_9", Au = "_icon_1uc4x_13", ts = {
1953
+ button: Eu,
1954
+ name: Tu,
1955
+ icon: Au
1956
+ }, Du = ({ value: e, onSelect: t }) => {
1957
+ const { logoUrl: s, name: r } = $e(e);
1958
+ return /* @__PURE__ */ u(
1959
+ ut,
1960
+ {
1961
+ title: "Select rollup",
1962
+ content: (o) => /* @__PURE__ */ n(
1963
+ Zo,
1964
+ {
1965
+ onSelect: (i) => {
1966
+ t(i), o();
1967
+ }
1968
+ }
1969
+ ),
1970
+ className: A("input", ts.button),
1971
+ children: [
1972
+ /* @__PURE__ */ n(z, { src: s, width: 16, height: 16 }),
1973
+ /* @__PURE__ */ n("span", { className: ts.name, children: r }),
1974
+ /* @__PURE__ */ n(Le, { size: 16, className: ts.icon })
1975
+ ]
1976
+ }
1977
+ );
1978
+ }, qu = "_button_1iys9_1", Pu = {
1979
+ button: qu
1980
+ }, Xo = ({ onClick: e, disabled: t }) => {
1981
+ const { ref: s, inView: r } = za();
1982
+ return H(() => {
1983
+ r && e();
1984
+ }, [r, e]), /* @__PURE__ */ u("button", { className: Pu.button, onClick: e, disabled: t, ref: s, children: [
1985
+ /* @__PURE__ */ n("span", { children: "Load more" }),
1986
+ /* @__PURE__ */ n(Le, { size: 12 })
1987
+ ] });
1988
+ };
1989
+ function Ru({ indexerUrl: e }) {
1990
+ const t = Z();
1991
+ return ks({
1992
+ queryKey: Xt.txs(e, t).queryKey,
1993
+ queryFn: async ({ pageParam: s = "" }) => {
1994
+ const r = { "pagination.key": s || "", "pagination.reverse": !0 };
1995
+ return M.create({ prefixUrl: e }).get(`indexer/tx/v1/txs/by_account/${t}`, { searchParams: r }).json();
1996
+ },
1997
+ initialPageParam: "",
1998
+ getNextPageParam: Ws,
1999
+ staleTime: F.SECOND
2000
+ });
2001
+ }
2002
+ const Ou = "_message_1g2hc_1", Bu = "_more_1g2hc_8", yr = {
2003
+ message: Ou,
2004
+ more: Bu
2005
+ }, Fu = ({ messages: e }) => /* @__PURE__ */ u(P, { children: [
2006
+ e.slice(0, 3).map((t, s) => /* @__PURE__ */ n("p", { className: yr.message, children: En(t["@type"].split("Msg")[1]) }, s)),
2007
+ e.length > 3 && /* @__PURE__ */ n("footer", { className: yr.more, children: `+${e.length - 3} more` })
2008
+ ] });
2009
+ function Mu(e) {
2010
+ return Object.fromEntries(e.map(({ key: t, value: s }) => [t, s]));
2011
+ }
2012
+ const wr = Gi(
2013
+ Qi(ir("metadata")),
2014
+ Yi,
2015
+ ar((e = []) => {
2016
+ const { metadata: t } = e[0];
2017
+ return { amount: T.sum(...ar(ir("amount"), e)).toString(), metadata: t };
2018
+ }),
2019
+ Ji(({ amount: e }) => !T(e).isZero())
2020
+ );
2021
+ function Uu(e, t, s) {
2022
+ try {
2023
+ const o = e.filter(({ type: i }) => i === "move").map(({ attributes: i }) => Mu(i)).reduce(
2024
+ (i, { type_tag: a, data: d }) => {
2025
+ try {
2026
+ const { amount: c, store_addr: l, metadata_addr: m } = JSON.parse(d);
2027
+ return `0x${gc(s, m)}` !== l ? i : a === "0x1::fungible_asset::DepositEvent" ? [...i, { amount: T(c).toString(), metadata: m }] : a === "0x1::fungible_asset::WithdrawEvent" ? [...i, { amount: T(c).negated().toString(), metadata: m }] : i;
2028
+ } catch {
2029
+ return i;
2030
+ }
2031
+ },
2032
+ [t]
2033
+ );
2034
+ return wr(o);
2035
+ } catch {
2036
+ return wr([]);
2037
+ }
2038
+ }
2039
+ const ju = ({ metadata: e, chain: t, children: s }) => {
2040
+ const { restUrl: r } = t, { data: o } = le({
2041
+ queryKey: dt.denom(r, e).queryKey,
2042
+ queryFn: () => M.create({ prefixUrl: r }).get("initia/move/v1/denom", { searchParams: { metadata: e } }).json(),
2043
+ select: ({ denom: i }) => i,
2044
+ staleTime: F.INFINITY
2045
+ });
2046
+ return s(o);
2047
+ }, zu = "_change_8jpfs_1", Ku = "_positive_8jpfs_9", Hu = "_negative_8jpfs_13", ns = {
2048
+ change: zu,
2049
+ positive: Ku,
2050
+ negative: Hu
2051
+ }, Lu = ({ tx: e, events: t, chain: s }) => {
2052
+ var _, f, g, p, w;
2053
+ const r = On(), o = Zt(s), i = Di(
2054
+ `0x${mt(at(e.auth_info.signer_infos[0].public_key.key))}`
2055
+ ), a = (_ = e.auth_info.fee) == null ? void 0 : _.payer, d = ((f = e.auth_info.fee) == null ? void 0 : f.amount[0]) ?? { amount: "0", denom: "" }, c = i === r && !a;
2056
+ if (!((g = s.metadata) != null && g.is_l1 || ((w = (p = s.metadata) == null ? void 0 : p.minitia) == null ? void 0 : w.type) === "minimove"))
2057
+ return null;
2058
+ const l = Do(d.denom), m = { amount: c ? d.amount : "0", metadata: l };
2059
+ return Uu(t, m, r).map(({ amount: v, metadata: b }, k) => {
2060
+ const C = new T(v).isPositive(), I = new T(v).abs().toString();
2061
+ return /* @__PURE__ */ n(ne, { suspenseFallback: null, errorBoundaryProps: { fallback: null }, children: /* @__PURE__ */ n(ju, { metadata: b, chain: s, children: (E) => /* @__PURE__ */ n(Hs, { asset: o(E), chain: s, children: ({ denom: N, symbol: y, decimals: S }) => /* @__PURE__ */ u(
2062
+ "div",
2063
+ {
2064
+ className: A(ns.change, C ? ns.positive : ns.negative),
2065
+ children: [
2066
+ C ? "+" : "-",
2067
+ ae(I, { decimals: S }),
2068
+ " ",
2069
+ y ?? ie(N)
2070
+ ]
2071
+ }
2072
+ ) }) }) }, k);
2073
+ });
2074
+ }, Wu = "_link_qkpto_1", Vu = "_inner_qkpto_14", Gu = "_timestamp_qkpto_23", Qu = "_content_qkpto_39", Yu = "_messages_qkpto_45", Ju = "_changes_qkpto_50", Zu = "_error_qkpto_57", st = {
2075
+ link: Wu,
2076
+ inner: Vu,
2077
+ timestamp: Gu,
2078
+ content: Qu,
2079
+ messages: Yu,
2080
+ changes: Ju,
2081
+ error: Zu
2082
+ }, Xu = ({ txItem: e, chain: t }) => /* @__PURE__ */ n(Ks, { txHash: e.txhash, chainId: t.chainId, className: st.link, children: /* @__PURE__ */ u("div", { className: st.inner, children: [
2083
+ /* @__PURE__ */ n("div", { className: st.timestamp, children: En(
2084
+ lo(new Date(e.timestamp), /* @__PURE__ */ new Date(), { locale: "en-US" })
2085
+ ) }),
2086
+ /* @__PURE__ */ u("div", { className: st.content, children: [
2087
+ /* @__PURE__ */ n("div", { className: st.messages, children: /* @__PURE__ */ n(Fu, { messages: e.tx.body.messages }) }),
2088
+ /* @__PURE__ */ n("div", { className: st.changes, children: /* @__PURE__ */ n(Lu, { ...e, chain: t }) })
2089
+ ] }),
2090
+ e.code !== 0 && /* @__PURE__ */ u("div", { className: st.error, children: [
2091
+ /* @__PURE__ */ n(Qt, { size: 12 }),
2092
+ /* @__PURE__ */ n("span", { children: "Failed" })
2093
+ ] })
2094
+ ] }) }), em = "_list_10hx5_1", tm = {
2095
+ list: em
2096
+ }, nm = ({ chain: e }) => {
2097
+ const { data: t, hasNextPage: s, isFetching: r, fetchNextPage: o } = Ru(e), { list: i } = Ls("txs", t);
2098
+ return i.length ? /* @__PURE__ */ u(P, { children: [
2099
+ /* @__PURE__ */ n("div", { className: tm.list, children: i.map((a) => /* @__PURE__ */ n(Xu, { txItem: a, chain: e }, a.txhash)) }),
2100
+ s && /* @__PURE__ */ n(Xo, { onClick: () => o(), disabled: r })
2101
+ ] }) : /* @__PURE__ */ n(ce, { children: "No activity yet" });
2102
+ }, sm = () => {
2103
+ const { defaultChainId: e } = te(), [t, s] = L(e), r = $e(t);
2104
+ return /* @__PURE__ */ u(P, { children: [
2105
+ /* @__PURE__ */ n(Du, { value: t, onSelect: s }),
2106
+ /* @__PURE__ */ n(ne, { children: /* @__PURE__ */ n(nm, { chain: r }) }, t)
2107
+ ] });
2108
+ }, rm = "_nav_1ldnv_1", om = "_item_1ldnv_6", im = "_tabs_1ldnv_28", am = "_tab_1ldnv_28", rt = {
2109
+ nav: rm,
2110
+ item: om,
2111
+ tabs: im,
2112
+ tab: am
2113
+ }, cm = () => {
2114
+ Vo();
2115
+ const e = de(), t = go();
2116
+ return /* @__PURE__ */ u(Re, { children: [
2117
+ /* @__PURE__ */ u("div", { className: rt.nav, children: [
2118
+ /* @__PURE__ */ u(Jt, { to: "/send", className: rt.item, children: [
2119
+ /* @__PURE__ */ n(Aa, { size: 16 }),
2120
+ /* @__PURE__ */ n("span", { children: "Send" })
2121
+ ] }),
2122
+ /* @__PURE__ */ u("button", { className: rt.item, onClick: () => e("/bridge"), children: [
2123
+ /* @__PURE__ */ n(Da, { size: 16 }),
2124
+ /* @__PURE__ */ n("span", { children: "Bridge/Swap" })
2125
+ ] })
2126
+ ] }),
2127
+ /* @__PURE__ */ u(Be.Root, { value: t, onValueChange: e, children: [
2128
+ /* @__PURE__ */ u(Be.List, { className: rt.tabs, children: [
2129
+ /* @__PURE__ */ n(Be.Trigger, { className: rt.tab, value: "/", children: "Assets" }),
2130
+ /* @__PURE__ */ n(Be.Trigger, { className: rt.tab, value: "/nfts", children: "NFTs" }),
2131
+ /* @__PURE__ */ n(Be.Trigger, { className: rt.tab, value: "/activity", children: "Activity" })
2132
+ ] }),
2133
+ /* @__PURE__ */ n(Be.Content, { value: "/", children: /* @__PURE__ */ n(iu, {}) }),
2134
+ /* @__PURE__ */ n(Be.Content, { value: "/nfts", children: /* @__PURE__ */ n(Iu, {}) }),
2135
+ /* @__PURE__ */ n(Be.Content, { value: "/activity", children: /* @__PURE__ */ n(sm, {}) })
2136
+ ] })
2137
+ ] });
2138
+ };
2139
+ function ei({
2140
+ quantity: e,
2141
+ balance: t,
2142
+ decimals: s
2143
+ }, r) {
2144
+ if (it(e).isZero()) {
2145
+ r.addIssue({
2146
+ code: K.ZodIssueCode.custom,
2147
+ message: "Enter amount",
2148
+ path: ["quantity"]
2149
+ });
2150
+ return;
2151
+ }
2152
+ if (!t || it(Os(e, s)).gt(t)) {
2153
+ r.addIssue({
2154
+ code: K.ZodIssueCode.custom,
2155
+ message: "Insufficient balance",
2156
+ path: ["quantity"]
2157
+ });
2158
+ return;
2159
+ }
2160
+ }
2161
+ const ti = K.string().nonempty("Recipient address is required").refine((e) => D.validate(e), "Invalid address"), lm = "_header_acels_1", dm = "_back_acels_11", um = "_title_acels_23", ss = {
2162
+ header: lm,
2163
+ back: dm,
2164
+ title: um
2165
+ }, Oe = ({ title: e, returnTo: t, extra: s, children: r }) => /* @__PURE__ */ u(P, { children: [
2166
+ /* @__PURE__ */ u("header", { className: ss.header, children: [
2167
+ t !== !1 && /* @__PURE__ */ n(Jt, { to: t ?? -1, className: ss.back, children: /* @__PURE__ */ n(qa, { size: 16 }) }),
2168
+ /* @__PURE__ */ n("h1", { className: ss.title, children: e }),
2169
+ s
2170
+ ] }),
2171
+ /* @__PURE__ */ n(Re, { children: r })
2172
+ ] }), mm = "_fieldset_y241y_1", hm = "_upper_y241y_9", _m = "_select_y241y_14", fm = "_account_y241y_19", pm = "_lower_y241y_24", gm = "_wrapper_y241y_25", ym = "_balance_y241y_32", wm = "_value_y241y_36", bm = "_error_y241y_49", xe = {
2173
+ fieldset: mm,
2174
+ upper: hm,
2175
+ select: _m,
2176
+ account: fm,
2177
+ lower: pm,
2178
+ wrapper: gm,
2179
+ balance: ym,
2180
+ value: wm,
2181
+ error: bm
2182
+ }, gs = (e) => {
2183
+ const { selectButton: t, accountButton: s, quantityInput: r, balanceButton: o, value: i, errorMessage: a } = e;
2184
+ return /* @__PURE__ */ u("div", { className: xe.fieldset, children: [
2185
+ /* @__PURE__ */ u("div", { className: xe.upper, children: [
2186
+ /* @__PURE__ */ n("div", { className: xe.select, children: t }),
2187
+ /* @__PURE__ */ n("div", { className: xe.account, children: s })
2188
+ ] }),
2189
+ /* @__PURE__ */ u("div", { className: xe.lower, children: [
2190
+ r,
2191
+ /* @__PURE__ */ u("div", { className: xe.wrapper, children: [
2192
+ /* @__PURE__ */ n("div", { className: xe.balance, children: o }),
2193
+ i && /* @__PURE__ */ u("div", { className: xe.value, children: [
2194
+ "$",
2195
+ i
2196
+ ] })
2197
+ ] }),
2198
+ a && /* @__PURE__ */ u("footer", { className: xe.error, children: [
2199
+ /* @__PURE__ */ n(Qt, { size: 12 }),
2200
+ /* @__PURE__ */ n("p", { children: a })
2201
+ ] })
2202
+ ] })
2203
+ ] });
2204
+ }, vm = "_images_1txea_1", Nm = "_chain_1txea_5", br = {
2205
+ images: vm,
2206
+ chain: Nm
2207
+ }, Gs = ({ assetLogoUrl: e, chainLogoUrl: t }) => /* @__PURE__ */ u("div", { className: br.images, children: [
2208
+ /* @__PURE__ */ n(z, { src: e, width: 36, height: 36 }),
2209
+ /* @__PURE__ */ n(z, { src: t, width: 18, height: 18, className: br.chain })
2210
+ ] }), Cm = "_root_1ipwv_1", Im = "_content_1ipwv_10", Sm = "_details_1ipwv_18", $m = "_symbol_1ipwv_23", km = "_chain_1ipwv_31", xm = "_chevron_1ipwv_40", ot = {
2211
+ root: Cm,
2212
+ content: Im,
2213
+ details: Sm,
2214
+ symbol: $m,
2215
+ chain: km,
2216
+ chevron: xm
2217
+ }, ni = ({ asset: e, chain: t, readOnly: s }) => {
2218
+ const r = /* @__PURE__ */ u("div", { className: ot.content, children: [
2219
+ /* @__PURE__ */ n(Gs, { assetLogoUrl: e.logoUrl, chainLogoUrl: t.logoUrl }),
2220
+ /* @__PURE__ */ u("div", { className: ot.details, children: [
2221
+ /* @__PURE__ */ n("div", { className: ot.symbol, children: e.symbol }),
2222
+ /* @__PURE__ */ u("div", { className: ot.chain, children: [
2223
+ "on ",
2224
+ t.name
2225
+ ] })
2226
+ ] })
2227
+ ] });
2228
+ return s ? /* @__PURE__ */ n("div", { className: ot.root, children: r }) : /* @__PURE__ */ u("div", { className: ot.root, children: [
2229
+ r,
2230
+ /* @__PURE__ */ n(Le, { size: 16, className: ot.chevron })
2231
+ ] });
2232
+ }, Em = "_wrapper_5vodt_1", Tm = "_balance_5vodt_11", Am = "_button_5vodt_15", rs = {
2233
+ wrapper: Em,
2234
+ balance: Tm,
2235
+ button: Am
2236
+ }, si = ({ onClick: e, children: t }) => /* @__PURE__ */ u("div", { className: rs.wrapper, children: [
2237
+ /* @__PURE__ */ n(xn, { size: 16 }),
2238
+ /* @__PURE__ */ n("span", { className: rs.balance, children: t }),
2239
+ /* @__PURE__ */ n("button", { type: "button", className: rs.button, onClick: () => e(), children: "MAX" })
2240
+ ] });
2241
+ function Fn() {
2242
+ const e = $s(null), t = oo("(max-width: 576px)");
2243
+ return H(() => {
2244
+ var s;
2245
+ t || (s = e.current) == null || s.focus();
2246
+ }, [t]), e;
2247
+ }
2248
+ const Dm = "_input_h8073_1", qm = {
2249
+ input: Dm
2250
+ };
2251
+ function Pm(e, t) {
2252
+ const s = e.replace(/[^0-9.]/g, ""), [r, ...o] = s.split(".");
2253
+ return o.length === 0 ? r : `${r}.${o.join("").slice(0, t)}`;
2254
+ }
2255
+ function ri(e) {
2256
+ const { name: t, control: s, dp: r = 6, className: o, ...i } = e, a = Fn();
2257
+ return /* @__PURE__ */ n(
2258
+ Ka,
2259
+ {
2260
+ name: t,
2261
+ control: s,
2262
+ render: ({ field: d }) => /* @__PURE__ */ n(
2263
+ "input",
2264
+ {
2265
+ ...d,
2266
+ className: A(qm.input, o),
2267
+ onChange: (c) => d.onChange(Pm(c.target.value, r)),
2268
+ placeholder: "0",
2269
+ inputMode: "decimal",
2270
+ autoComplete: "off",
2271
+ ...i,
2272
+ ref: uo([d.ref, a])
2273
+ }
2274
+ )
2275
+ }
2276
+ );
2277
+ }
2278
+ const Rm = "_input_qpv94_1", Om = "_placeholder_qpv94_18", ys = {
2279
+ input: Rm,
2280
+ placeholder: Om
2281
+ }, Bm = ({ children: e }) => /* @__PURE__ */ n("p", { className: A(ys.input, { [ys.placeholder]: T(e).isZero() }), children: e }), vn = () => {
2282
+ const { control: e } = $t();
2283
+ return /* @__PURE__ */ n(ri, { name: "quantity", control: e, className: ys.input });
2284
+ };
2285
+ vn.ReadOnly = Bm;
2286
+ const Fm = "_label_jg0i7_1", Mm = "_wrapper_jg0i7_7", Um = "_input_jg0i7_10", jm = "_clear_jg0i7_18", ln = {
2287
+ label: Fm,
2288
+ wrapper: Mm,
2289
+ input: Um,
2290
+ clear: jm
2291
+ }, Qs = ({ mode: e = "onChange", myAddress: t, ...s }) => {
2292
+ const { validate: r = D.validate, chainType: o = "initia", onApply: i, ref: a } = s, d = Fn(), { getValues: c, setValue: l, formState: m } = $t(), h = c("recipient"), [_, f] = L(h), g = qo(), {
2293
+ data: p,
2294
+ isLoading: w,
2295
+ error: v
2296
+ } = ge({
2297
+ queryKey: Xt.address(g.restUrl, _).queryKey,
2298
+ queryFn: () => g.getAddress(_),
2299
+ staleTime: F.MINUTE,
2300
+ enabled: g.validateUsername(_)
2301
+ }), b = p ?? (r(_) ? _ : ""), k = t && D.equals(b, t), C = async () => {
2302
+ try {
2303
+ const N = await navigator.clipboard.readText();
2304
+ f(N.trim());
2305
+ } catch {
2306
+ }
2307
+ };
2308
+ H(() => {
2309
+ e === "onChange" && _ && l("recipient", p ?? _, { shouldValidate: !0 });
2310
+ }, [_, e, l, p]);
2311
+ const I = () => {
2312
+ w || v || (l("recipient", b, { shouldValidate: !0 }), i == null || i());
2313
+ }, E = () => {
2314
+ var N;
2315
+ if (w)
2316
+ return /* @__PURE__ */ n(ze, { level: "loading", children: "Resolving username..." });
2317
+ if (v)
2318
+ return /* @__PURE__ */ n(ze, { level: "error", children: v.message });
2319
+ if (p)
2320
+ return /* @__PURE__ */ n(ze, { level: "success", className: "monospace", children: p });
2321
+ if (e === "onSubmit" && _ && !b)
2322
+ return /* @__PURE__ */ n(ze, { level: "error", children: "Invalid address" });
2323
+ if (e === "onChange")
2324
+ return /* @__PURE__ */ n(ze, { level: "error", children: (N = m.errors.recipient) == null ? void 0 : N.message });
2325
+ };
2326
+ return /* @__PURE__ */ u("div", { children: [
2327
+ /* @__PURE__ */ u("label", { htmlFor: "recipient", className: ln.label, children: [
2328
+ /* @__PURE__ */ n("span", { children: "Recipient" }),
2329
+ /* @__PURE__ */ n(j.Small, { type: "button", onClick: C, children: "Paste" })
2330
+ ] }),
2331
+ /* @__PURE__ */ u("div", { className: ln.wrapper, children: [
2332
+ /* @__PURE__ */ n(
2333
+ "input",
2334
+ {
2335
+ id: "recipient",
2336
+ className: A(ln.input, "monospace"),
2337
+ value: _,
2338
+ onChange: (N) => f(N.target.value.trim()),
2339
+ placeholder: o === "initia" ? "Address or username" : "Enter address",
2340
+ autoComplete: "off",
2341
+ ref: e === "onSubmit" ? uo([a, d]) : a
2342
+ }
2343
+ ),
2344
+ !!_ && /* @__PURE__ */ n(
2345
+ "button",
2346
+ {
2347
+ type: "button",
2348
+ className: ln.clear,
2349
+ onClick: () => f(""),
2350
+ "aria-label": "Clear recipient",
2351
+ children: /* @__PURE__ */ n(Sn, { size: 16 })
2352
+ }
2353
+ )
2354
+ ] }),
2355
+ E(),
2356
+ k && /* @__PURE__ */ n(ze, { children: "This is my address" }),
2357
+ e === "onSubmit" && /* @__PURE__ */ n(
2358
+ J,
2359
+ {
2360
+ extra: (!t || !!b && !k) && /* @__PURE__ */ n(Y, { level: "warning", children: "Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable." }),
2361
+ children: /* @__PURE__ */ n(
2362
+ j.White,
2363
+ {
2364
+ type: "button",
2365
+ onClick: I,
2366
+ disabled: w || !!v || !b,
2367
+ children: "Apply"
2368
+ }
2369
+ )
2370
+ }
2371
+ )
2372
+ ] });
2373
+ }, zm = "_container_1a4ds_1", Km = "_badge_1a4ds_5", vr = {
2374
+ container: zm,
2375
+ badge: Km
2376
+ }, oi = (e) => {
2377
+ const { offset: t = -4, disabled: s, children: r, className: o } = e;
2378
+ return /* @__PURE__ */ u("div", { className: A(vr.container, o), children: [
2379
+ r,
2380
+ !s && /* @__PURE__ */ n("div", { className: vr.badge, style: { right: t, top: t } })
2381
+ ] });
2382
+ }, Hm = "_tooltip_6zakp_1", Lm = "_arrow_6zakp_43", Nr = {
2383
+ tooltip: Hm,
2384
+ arrow: Lm
2385
+ }, At = ({ label: e, children: t, small: s, ...r }) => /* @__PURE__ */ u(wt.Root, { ...r, children: [
2386
+ /* @__PURE__ */ n(wt.Trigger, { asChild: !0, children: t }),
2387
+ /* @__PURE__ */ n(wt.Portal, { container: Vt(), children: /* @__PURE__ */ u(
2388
+ wt.Content,
2389
+ {
2390
+ className: A(Nr.tooltip, { small: s }),
2391
+ collisionBoundary: Vt(),
2392
+ collisionPadding: 8,
2393
+ sideOffset: 4,
2394
+ children: [
2395
+ e,
2396
+ /* @__PURE__ */ n(wt.Arrow, { className: Nr.arrow })
2397
+ ]
2398
+ }
2399
+ ) })
2400
+ ] }), Wm = "_stack_a3b9q_1", Vm = "_title_a3b9q_8", Gm = "_grid_a3b9q_15", Qm = "_item_a3b9q_21", Ym = "_button_a3b9q_25", Jm = "_active_a3b9q_43", bt = {
2401
+ stack: Wm,
2402
+ title: Vm,
2403
+ grid: Gm,
2404
+ item: Qm,
2405
+ button: Ym,
2406
+ active: Jm
2407
+ }, lt = ({ label: e, chains: t, value: s, onSelect: r, getShowIndicator: o }) => /* @__PURE__ */ u("div", { children: [
2408
+ e && /* @__PURE__ */ n("h2", { className: bt.title, children: e }),
2409
+ /* @__PURE__ */ n("div", { className: bt.grid, children: t.map(({ chainId: i, name: a, logoUrl: d }) => /* @__PURE__ */ n(
2410
+ oi,
2411
+ {
2412
+ offset: -2,
2413
+ disabled: !(o != null && o(i)),
2414
+ className: bt.item,
2415
+ children: /* @__PURE__ */ n(At, { label: a, disableHoverableContent: !0, children: /* @__PURE__ */ n(
2416
+ "button",
2417
+ {
2418
+ type: "button",
2419
+ className: A(bt.button, { [bt.active]: i === s }),
2420
+ onClick: () => r(i),
2421
+ children: /* @__PURE__ */ n(z, { src: d, width: 28, height: 28, circle: !0 })
2422
+ }
2423
+ ) })
2424
+ },
2425
+ i
2426
+ )) })
2427
+ ] }), Zm = ({ children: e }) => /* @__PURE__ */ n("div", { className: bt.stack, children: e });
2428
+ lt.Stack = Zm;
2429
+ function ii(e, t, s) {
2430
+ return s.filter((r) => {
2431
+ const o = e.map((i) => r[i]).map((i) => String(i ?? "").toLowerCase());
2432
+ return Zi(jr(t.toLowerCase()), o);
2433
+ });
2434
+ }
2435
+ const Xm = "_root_qd12v_1", eh = "_label_qd12v_8", th = "_input_qd12v_14", nh = "_clear_qd12v_20", dn = {
2436
+ root: Xm,
2437
+ label: eh,
2438
+ input: th,
2439
+ clear: nh
2440
+ }, ai = ({ value: e, onChange: t, placeholder: s = "Search", className: r }) => /* @__PURE__ */ u("div", { className: A(dn.root, r), children: [
2441
+ /* @__PURE__ */ n("label", { htmlFor: "search", className: dn.label, children: /* @__PURE__ */ n(Pa, { size: 16 }) }),
2442
+ /* @__PURE__ */ n(
2443
+ "input",
2444
+ {
2445
+ id: "search",
2446
+ type: "text",
2447
+ className: dn.input,
2448
+ value: e,
2449
+ onChange: (o) => t(o.target.value),
2450
+ placeholder: s,
2451
+ ref: Fn()
2452
+ }
2453
+ ),
2454
+ e && /* @__PURE__ */ n("button", { className: dn.clear, onClick: () => t(""), children: /* @__PURE__ */ n(Sn, { size: 20 }) })
2455
+ ] }), sh = "_container_17tpb_1", rh = "_list_17tpb_6", oh = "_item_17tpb_12", ih = "_logo_17tpb_31", ah = "_info_17tpb_35", ch = "_symbol_17tpb_40", lh = "_name_17tpb_44", dh = "_balance_17tpb_50", uh = "_value_17tpb_58", Ee = {
2456
+ container: sh,
2457
+ list: rh,
2458
+ item: oh,
2459
+ logo: ih,
2460
+ info: ah,
2461
+ symbol: ch,
2462
+ name: lh,
2463
+ balance: dh,
2464
+ value: uh
2465
+ }, ci = (e) => {
2466
+ const { assets: t, onSelect: s, renderAsset: r = (d, c) => c(d) } = e, [o, i] = L(""), a = ii(["symbol"], o, t);
2467
+ return /* @__PURE__ */ u("div", { className: Ee.container, children: [
2468
+ /* @__PURE__ */ n(ai, { value: o, onChange: i, placeholder: "Search by symbol" }),
2469
+ a.length === 0 ? /* @__PURE__ */ n(ce, { children: "No assets" }) : /* @__PURE__ */ n("div", { className: Ee.list, children: a.map((d) => /* @__PURE__ */ n(
2470
+ "button",
2471
+ {
2472
+ type: "button",
2473
+ className: Ee.item,
2474
+ onClick: () => s(d.denom),
2475
+ children: r(d, ({ logoUrl: c, symbol: l, name: m, balance: h, decimals: _, value: f = 0 }) => /* @__PURE__ */ u(P, { children: [
2476
+ /* @__PURE__ */ n(z, { src: c, width: 32, height: 32, className: Ee.logo }),
2477
+ /* @__PURE__ */ u("div", { className: Ee.info, children: [
2478
+ /* @__PURE__ */ n("div", { className: Ee.symbol, children: l }),
2479
+ /* @__PURE__ */ n("div", { className: Ee.name, children: m })
2480
+ ] }),
2481
+ /* @__PURE__ */ u("div", { className: Ee.balance, children: [
2482
+ h && /* @__PURE__ */ n("div", { children: ae(h, { decimals: _ }) }),
2483
+ f > 0 && /* @__PURE__ */ u("div", { className: Ee.value, children: [
2484
+ "$",
2485
+ Ct(f)
2486
+ ] })
2487
+ ] })
2488
+ ] }))
2489
+ },
2490
+ d.denom
2491
+ )) })
2492
+ ] });
2493
+ }, mh = ({ chain: e, onSelect: t }) => {
2494
+ const s = Po(e);
2495
+ return s.length === 0 ? /* @__PURE__ */ n(ce, { children: "No assets" }) : /* @__PURE__ */ n(
2496
+ ci,
2497
+ {
2498
+ assets: s,
2499
+ onSelect: t,
2500
+ renderAsset: (r, o) => /* @__PURE__ */ n(Hs, { asset: r, chain: e, children: (i) => o(i) })
2501
+ }
2502
+ );
2503
+ }, hh = ({ afterSelect: e }) => {
2504
+ const { watch: t, setValue: s } = $t(), { chainId: r } = t(), [o, i] = L(r), a = $e(o), { addedChains: d } = kt(), c = (l) => {
2505
+ s("chainId", o), s("denom", l), e();
2506
+ };
2507
+ return /* @__PURE__ */ u(P, { children: [
2508
+ d.length > 1 && /* @__PURE__ */ n(lt.Stack, { children: /* @__PURE__ */ n(lt, { chains: d, value: o, onSelect: i }) }),
2509
+ /* @__PURE__ */ n(ne, { children: /* @__PURE__ */ n(mh, { chain: a, onSelect: c }) }, o)
2510
+ ] });
2511
+ }, _h = "_fields_brpej_1", fh = "_divider_brpej_11", Cr = {
2512
+ fields: _h,
2513
+ divider: fh
2514
+ }, ph = () => {
2515
+ var y, S, R, B;
2516
+ const { address: e, initiaAddress: t, requestTxSync: s } = Qe(), { register: r, watch: o, setValue: i, handleSubmit: a, formState: d } = $t(), { chainId: c, denom: l, quantity: m, memo: h } = o(), { addedChains: _ } = kt(), f = $e(c), g = Us(f), p = Ms(l, f), { data: w } = vo(f.chainId), { decimals: v } = p, b = ((y = g.find((x) => x.denom === l)) == null ? void 0 : y.amount) ?? "0", k = (S = w == null ? void 0 : w.find(({ id: x }) => x === l)) == null ? void 0 : S.price, C = T(m).gt(0) && T(m).isEqualTo(wn(b, v)), I = f.fees.fee_tokens.some((x) => x.denom === l), { mutate: E, isPending: N } = Pe({
2517
+ mutationFn: ({ chainId: x, denom: O, quantity: W, recipient: be, memo: se }) => {
2518
+ const ve = Os(W, v), G = [
2519
+ {
2520
+ typeUrl: "/cosmos.bank.v1beta1.MsgSend",
2521
+ value: Ha.fromPartial({
2522
+ fromAddress: t,
2523
+ toAddress: D.toBech32(be),
2524
+ amount: [{ denom: O, amount: ve }]
2525
+ })
2526
+ }
2527
+ ];
2528
+ return s({ messages: G, memo: se, chainId: x, internal: "/" });
2529
+ }
2530
+ });
2531
+ return /* @__PURE__ */ n(Oe, { title: "Send", children: /* @__PURE__ */ u("form", { onSubmit: a((x) => E(x)), children: [
2532
+ /* @__PURE__ */ u("div", { className: Cr.fields, children: [
2533
+ /* @__PURE__ */ n(
2534
+ gs,
2535
+ {
2536
+ selectButton: /* @__PURE__ */ n(
2537
+ ut,
2538
+ {
2539
+ title: _.length > 1 ? "Select chain and asset" : "Select asset",
2540
+ content: (x) => /* @__PURE__ */ n(hh, { afterSelect: x }),
2541
+ children: /* @__PURE__ */ n(ni, { asset: p, chain: f })
2542
+ }
2543
+ ),
2544
+ quantityInput: /* @__PURE__ */ n(vn, {}),
2545
+ balanceButton: /* @__PURE__ */ n(
2546
+ si,
2547
+ {
2548
+ onClick: () => i("quantity", wn(b, v), { shouldValidate: !0 }),
2549
+ children: ae(b, { decimals: v })
2550
+ }
2551
+ ),
2552
+ value: m ? k ? Ct(T(m).times(k)) : "-" : "0",
2553
+ errorMessage: (R = d.errors.quantity) == null ? void 0 : R.message
2554
+ }
2555
+ ),
2556
+ /* @__PURE__ */ n("div", { className: Cr.divider }),
2557
+ /* @__PURE__ */ n(Qs, { myAddress: e }),
2558
+ /* @__PURE__ */ u("div", { children: [
2559
+ /* @__PURE__ */ n("label", { htmlFor: "memo", children: "Memo (optional)" }),
2560
+ /* @__PURE__ */ n("input", { ...r("memo"), id: "memo", autoComplete: "off" }),
2561
+ /* @__PURE__ */ n(ze, { level: "error", children: (B = d.errors.memo) == null ? void 0 : B.message })
2562
+ ] }),
2563
+ /* @__PURE__ */ u(Y.Stack, { children: [
2564
+ C && I && /* @__PURE__ */ n(Y, { level: "warning", children: "Make sure to leave enough for transaction fee" }),
2565
+ !h && /* @__PURE__ */ n(Y, { level: "warning", children: "Check if the above transaction requires a memo" })
2566
+ ] })
2567
+ ] }),
2568
+ /* @__PURE__ */ n(J, { children: /* @__PURE__ */ n(j.White, { type: "submit", loading: N, disabled: !d.isValid, children: "Confirm" }) })
2569
+ ] }) });
2570
+ }, gh = K.object({
2571
+ chainId: K.string().nonempty(),
2572
+ denom: K.string().nonempty(),
2573
+ quantity: K.string().nonempty("Amount is required"),
2574
+ recipient: ti,
2575
+ memo: K.string().optional().refine((e) => !e || new Blob([e]).size <= 256, "Memo is too long")
2576
+ }), yh = () => {
2577
+ const e = We(), t = qn(), s = Lt(t), [r] = s, { chain: o = t, denom: i = r.denom } = e, a = _t(), d = Z(), c = Se(), l = Tn({
2578
+ mode: "onChange",
2579
+ defaultValues: { chainId: o.chainId, denom: i, quantity: "", recipient: "", memo: "" },
2580
+ resolver: Rs(
2581
+ gh.superRefine(({ chainId: m, denom: h, quantity: _ }, f) => {
2582
+ var b;
2583
+ const g = a(m), { decimals: p } = c.getQueryData(
2584
+ dt.item(m, h).queryKey
2585
+ ) ?? { decimals: 0 }, { balances: w } = c.getQueryData(
2586
+ Xt.balances(g.restUrl, d).queryKey
2587
+ ) ?? { balances: [] }, v = (b = w.find((k) => k.denom === h)) == null ? void 0 : b.amount;
2588
+ ei({ quantity: _, balance: v, decimals: p }, f);
2589
+ })
2590
+ )
2591
+ });
2592
+ return /* @__PURE__ */ n(Ps, { ...l, children: /* @__PURE__ */ n(ph, {}) });
2593
+ }, wh = "_grid_4j669_1", bh = "_item_4j669_7", vh = "_name_4j669_15", os = {
2594
+ grid: wh,
2595
+ item: bh,
2596
+ name: vh
2597
+ }, Nh = () => {
2598
+ const e = de(), { collection: t, chain: s } = We(), { data: r, hasNextPage: o, isFetching: i, fetchNextPage: a } = Qo({ chain: s, collection: t }), { list: d } = Ls("tokens", r);
2599
+ return /* @__PURE__ */ u(Oe, { title: t.name, children: [
2600
+ /* @__PURE__ */ n("div", { className: os.grid, children: d.map((c) => /* @__PURE__ */ n(Yo, { nftResponse: c, children: (l) => /* @__PURE__ */ u("div", { className: os.item, children: [
2601
+ /* @__PURE__ */ n(
2602
+ Bn,
2603
+ {
2604
+ chain: s,
2605
+ collection: t,
2606
+ nft: l,
2607
+ onClick: () => e("/nft", { collection: t, nft: l, chain: s })
2608
+ }
2609
+ ),
2610
+ /* @__PURE__ */ n("div", { className: os.name, children: l.name })
2611
+ ] }) }, c.object_addr)) }),
2612
+ o && /* @__PURE__ */ n(Xo, { onClick: () => a(), disabled: i })
2613
+ ] });
2614
+ }, Ch = "_header_196nx_1", Ih = "_name_196nx_6", Sh = "_attributes_196nx_12", $h = "_title_196nx_15", kh = "_list_196nx_21", xh = "_item_196nx_25", Eh = "_type_196nx_34", Th = "_value_196nx_40", Ue = {
2615
+ header: Ch,
2616
+ name: Ih,
2617
+ attributes: Sh,
2618
+ title: $h,
2619
+ list: kh,
2620
+ item: xh,
2621
+ type: Eh,
2622
+ value: Th
2623
+ }, Ah = () => {
2624
+ const e = de(), t = We(), { collection: s, nft: r, chain: o } = t, { image: i, name: a, attributes: d } = r;
2625
+ return /* @__PURE__ */ u(Oe, { title: s.name, children: [
2626
+ /* @__PURE__ */ u("header", { className: Ue.header, children: [
2627
+ i && /* @__PURE__ */ n(Bn, { chain: o, collection: s, nft: r }),
2628
+ /* @__PURE__ */ n("h2", { className: Ue.name, children: a })
2629
+ ] }),
2630
+ /* @__PURE__ */ n(J, { children: /* @__PURE__ */ n(j.White, { onClick: () => e("/nft/send", t), children: "Send" }) }),
2631
+ d && /* @__PURE__ */ u("div", { className: Ue.attributes, children: [
2632
+ /* @__PURE__ */ u("header", { className: Ue.title, children: [
2633
+ "Traits (",
2634
+ d.length,
2635
+ ")"
2636
+ ] }),
2637
+ /* @__PURE__ */ n("div", { className: Ue.list, children: d.map(({ trait_type: c, value: l }) => /* @__PURE__ */ u("div", { className: Ue.item, children: [
2638
+ /* @__PURE__ */ n("div", { className: Ue.type, children: c }),
2639
+ /* @__PURE__ */ n("div", { className: Ue.value, children: l })
2640
+ ] }, c)) })
2641
+ ] })
2642
+ ] });
2643
+ };
2644
+ async function Dh({ object_addr: e }, { restUrl: t }) {
2645
+ const s = await qh(e, t);
2646
+ return s.startsWith("ibc/") ? Ao("0x1", s) === e.replace("0x", "").padStart(64, "0") ? {
2647
+ class_id: s,
2648
+ class_trace: await ws(s, t)
2649
+ } : {
2650
+ class_id: `move/${e.replace("0x", "").padStart(64, "0")}`,
2651
+ class_trace: await ws(s, t)
2652
+ } : {
2653
+ class_id: `move/${e.replace("0x", "").padStart(64, "0")}`,
2654
+ class_trace: null
2655
+ };
2656
+ }
2657
+ async function qh(e, t) {
2658
+ const { data: s } = await M.create({ prefixUrl: t }).post("initia/move/v1/view/json", {
2659
+ json: {
2660
+ address: "0x1",
2661
+ module_name: "collection",
2662
+ function_name: "name",
2663
+ type_args: ["0x1::collection::Collection"],
2664
+ args: [JSON.stringify(e)]
2665
+ }
2666
+ }).json();
2667
+ return JSON.parse(s);
2668
+ }
2669
+ async function Ph({ object_addr: e }, { restUrl: t }) {
2670
+ const s = await Rh(e, t);
2671
+ if (!s.startsWith("ibc/"))
2672
+ return {
2673
+ class_id: `evm/${D.toHex(e)}`,
2674
+ class_trace: null
2675
+ };
2676
+ const r = await ws(s, t);
2677
+ return r ? {
2678
+ class_id: s,
2679
+ class_trace: r
2680
+ } : {
2681
+ class_id: `evm/${D.toHex(e)}`,
2682
+ class_trace: null
2683
+ };
2684
+ }
2685
+ async function Rh(e, t) {
2686
+ const s = new qi([
2687
+ {
2688
+ inputs: [],
2689
+ name: "name",
2690
+ outputs: [{ internalType: "string", name: "", type: "string" }],
2691
+ stateMutability: "view",
2692
+ type: "function"
2693
+ }
2694
+ ]), { response: r } = await M.create({ prefixUrl: t }).post("minievm/evm/v1/call", {
2695
+ json: {
2696
+ sender: D.toBech32("0x1"),
2697
+ contract_addr: D.toPrefixedHex(e),
2698
+ input: s.encodeFunctionData("name")
2699
+ }
2700
+ }).json();
2701
+ return s.decodeFunctionResult("name", r)[0];
2702
+ }
2703
+ async function Oh({ creator_addr: e, object_addr: t }, s, r) {
2704
+ var g, p;
2705
+ const o = await Bh(t, s.restUrl), i = (p = (g = s.metadata) == null ? void 0 : g.ibc_channels) == null ? void 0 : p.find(
2706
+ ({ chain_id: w, version: v }) => w === r.chain_id && v.includes("ics721-1")
2707
+ );
2708
+ if (!i) throw new Error("Channel not found");
2709
+ const a = i.port_id, d = a.split(".")[1], c = qe(Kt(JSON.stringify({ class_id: { contract: t } }))), l = `cosmwasm/wasm/v1/contract/${d}/smart/${c}`, { data: m } = await M.create({ prefixUrl: s.restUrl }).get(l).json(), h = m ?? t;
2710
+ if (m && e !== a.replace("wasm.", "")) {
2711
+ const [w, v] = Ir(m);
2712
+ return {
2713
+ class_id: t,
2714
+ class_trace: { path: w, base_class_id: v }
2715
+ };
2716
+ }
2717
+ const [_, f] = Ir(o);
2718
+ return {
2719
+ class_id: h,
2720
+ class_trace: { path: _, base_class_id: f }
2721
+ };
2722
+ }
2723
+ async function Bh(e, t) {
2724
+ const s = qe(Ca(JSON.stringify({ contract_info: {} }))), { name: r } = await M.create({ prefixUrl: t }).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();
2725
+ return r;
2726
+ }
2727
+ const Fh = {
2728
+ minimove: Dh,
2729
+ minievm: Ph,
2730
+ miniwasm: Oh
2731
+ };
2732
+ async function Mh({
2733
+ collection: e,
2734
+ nft: t,
2735
+ srcChain: s,
2736
+ intermediaryChain: r
2737
+ }) {
2738
+ var a, d, c;
2739
+ const o = (a = s.metadata) != null && a.is_l1 ? "minimove" : (c = (d = s.metadata) == null ? void 0 : d.minitia) == null ? void 0 : c.type;
2740
+ if (!(o === "minimove" || o === "minievm" || o === "miniwasm"))
2741
+ throw new Error(`Unsupported minitia type: ${o}`);
2742
+ const i = await Fh[o](
2743
+ e,
2744
+ s,
2745
+ r
2746
+ );
2747
+ return Object.assign(
2748
+ i,
2749
+ o === "minievm" && {
2750
+ token_ids: await Uh(
2751
+ [t.token_id],
2752
+ i.class_id,
2753
+ s.restUrl
2754
+ )
2755
+ }
2756
+ );
2757
+ }
2758
+ async function ws(e, t) {
2759
+ const s = e.replace("ibc/", ""), { class_trace: r } = await M.create({ prefixUrl: t }).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();
2760
+ return r;
2761
+ }
2762
+ async function Uh(e, t, s) {
2763
+ const { token_infos: r } = await M.create({ prefixUrl: s }).get(`minievm/evm/v1/erc721/origin_token_infos/${t}`, {
2764
+ searchParams: { token_ids: e.join(",") }
2765
+ }).json();
2766
+ return r.map(({ token_origin_id: o }) => o);
2767
+ }
2768
+ function Ir(e) {
2769
+ const t = /^(.*channel-\d+)\/(.*)$/, s = e.match(t);
2770
+ if (!s) throw new Error("Pattern `channel-{number}/` not found.");
2771
+ const [, r, o] = s;
2772
+ return [r, o];
2773
+ }
2774
+ const jh = "_header_5w36t_1", zh = "_name_5w36t_8", Kh = "_collection_5w36t_15", Hh = "_nft_5w36t_20", Lh = "_fields_5w36t_24", Wh = "_chain_5w36t_29", gt = {
2775
+ header: jh,
2776
+ name: zh,
2777
+ collection: Kh,
2778
+ nft: Hh,
2779
+ fields: Lh,
2780
+ chain: Wh
2781
+ }, Vh = He("interwovenkit:send-nft", {
2782
+ simulation: (e) => [e]
2783
+ }), Gh = () => {
2784
+ const { chain: e, collection: t, nft: s } = We(), { routerApiUrl: r } = te(), o = Pn(), i = we(), { address: a, initiaAddress: d, requestTxSync: c } = Qe(), { watch: l, setValue: m, handleSubmit: h, formState: _ } = $t(), f = l(), { recipient: g, dstChainId: p } = f, w = $e(p), v = ge({
2785
+ queryKey: Vh.simulation({
2786
+ collection: t,
2787
+ nft: s,
2788
+ sender: d,
2789
+ recipient: g,
2790
+ srcChain: e,
2791
+ dstChainId: p,
2792
+ layer1: i,
2793
+ routerApiUrl: r
2794
+ }).queryKey,
2795
+ queryFn: async () => {
2796
+ const N = Object.assign(
2797
+ {
2798
+ from_address: d,
2799
+ from_chain_id: e.chainId,
2800
+ to_address: D.toBech32(g),
2801
+ to_chain_id: p,
2802
+ collection_address: t.object_addr,
2803
+ token_ids: [s.token_id],
2804
+ object_addresses: [s.object_addr]
2805
+ },
2806
+ e.chainId !== p && await Mh({
2807
+ collection: t,
2808
+ nft: s,
2809
+ srcChain: e,
2810
+ intermediaryChain: i
2811
+ })
2812
+ ), { msgs: y } = await M.create({ prefixUrl: r }).post("nft", { json: N }).json();
2813
+ return y.map((S) => o.fromAmino(S));
2814
+ },
2815
+ enabled: !!g
2816
+ }), { data: b, isLoading: k, error: C } = v, { mutate: I, isPending: E } = Pe({
2817
+ mutationFn: async () => {
2818
+ if (!b) throw new Error("Route not found");
2819
+ await c({ messages: b, chainId: e.chainId, internal: "/nfts" });
2820
+ }
2821
+ });
2822
+ return /* @__PURE__ */ u("form", { onSubmit: h(() => I()), children: [
2823
+ /* @__PURE__ */ u("header", { className: gt.header, children: [
2824
+ s.image && /* @__PURE__ */ n(Bn, { chain: e, collection: t, nft: s, size: 80 }),
2825
+ /* @__PURE__ */ u("div", { className: gt.name, children: [
2826
+ /* @__PURE__ */ n("div", { className: gt.collection, children: t.name }),
2827
+ /* @__PURE__ */ n("div", { className: gt.nft, children: s.name })
2828
+ ] })
2829
+ ] }),
2830
+ /* @__PURE__ */ u("div", { className: gt.fields, children: [
2831
+ /* @__PURE__ */ n($a.Root, { children: /* @__PURE__ */ u("div", { children: [
2832
+ /* @__PURE__ */ n("div", { className: "label", children: "Destination rollup" }),
2833
+ /* @__PURE__ */ u(
2834
+ ut,
2835
+ {
2836
+ title: "Destination rollup",
2837
+ content: (N) => /* @__PURE__ */ n(
2838
+ Zo,
2839
+ {
2840
+ onSelect: (y) => {
2841
+ m("dstChainId", y), N();
2842
+ }
2843
+ }
2844
+ ),
2845
+ className: A("input", gt.chain),
2846
+ children: [
2847
+ /* @__PURE__ */ n(z, { src: w.logoUrl, width: 20, height: 20 }),
2848
+ /* @__PURE__ */ n("span", { children: w.name })
2849
+ ]
2850
+ }
2851
+ )
2852
+ ] }) }),
2853
+ /* @__PURE__ */ n(Qs, { myAddress: a, ref: Fn() })
2854
+ ] }),
2855
+ /* @__PURE__ */ n(J, { children: /* @__PURE__ */ n(j.White, { loading: k || E, disabled: !_.isValid, children: C ? "Route not found" : "Confirm" }) })
2856
+ ] });
2857
+ }, Qh = K.object({
2858
+ dstChainId: K.string().nonempty(),
2859
+ recipient: ti
2860
+ }), Yh = () => {
2861
+ const { chain: e } = We(), t = Tn({
2862
+ defaultValues: { dstChainId: e.chainId },
2863
+ resolver: Rs(Qh)
2864
+ });
2865
+ return /* @__PURE__ */ n(Oe, { title: "Send NFT", children: /* @__PURE__ */ n(Ps, { ...t, children: /* @__PURE__ */ n(Gh, {}) }) });
2866
+ }, Jh = "_item_ny5a8_1", Zh = "_header_ny5a8_11", Xh = "_name_ny5a8_19", e_ = "_link_ny5a8_24", t_ = "_button_ny5a8_40", yt = {
2867
+ item: Jh,
2868
+ header: Zh,
2869
+ name: Xh,
2870
+ link: e_,
2871
+ button: t_
2872
+ }, is = (e) => {
2873
+ var _;
2874
+ const { chainId: t, name: s, logoUrl: r, website: o, metadata: i } = e, { defaultChainId: a } = te(), { addedChains: d, addChain: c, removeChain: l } = kt(), m = d.find((f) => f.chainId === t), h = () => t === a ? null : m ? /* @__PURE__ */ n("button", { className: yt.button, onClick: () => l(t), children: /* @__PURE__ */ n(ro, { size: 14 }) }) : /* @__PURE__ */ n("button", { className: yt.button, onClick: () => c(t), children: /* @__PURE__ */ n(no, { size: 14 }) });
2875
+ return /* @__PURE__ */ u("div", { className: yt.item, children: [
2876
+ /* @__PURE__ */ n(z, { src: r, width: 32, height: 32, title: (_ = i == null ? void 0 : i.minitia) == null ? void 0 : _.type }),
2877
+ /* @__PURE__ */ u("header", { className: yt.header, children: [
2878
+ /* @__PURE__ */ n("h3", { className: yt.name, children: s }),
2879
+ o && /* @__PURE__ */ n("a", { className: yt.link, href: ao(o), target: "_blank", children: /* @__PURE__ */ n(Ht, { size: 12 }) })
2880
+ ] }),
2881
+ h()
2882
+ ] });
2883
+ }, n_ = "_content_14twd_1", s_ = "_search_14twd_5", r_ = "_title_14twd_9", o_ = "_count_14twd_18", i_ = "_list_14twd_23", je = {
2884
+ content: n_,
2885
+ search: s_,
2886
+ title: r_,
2887
+ count: o_,
2888
+ list: i_
2889
+ }, a_ = () => {
2890
+ const [e, t] = L(""), { chains: s, addedChains: r, notAddedChains: o } = kt(), i = ii(["chainId", "name"], e, s);
2891
+ return /* @__PURE__ */ n(Oe, { title: "Manage rollup list", children: /* @__PURE__ */ u("div", { className: je.content, children: [
2892
+ /* @__PURE__ */ n(ai, { value: e, onChange: t, className: je.search }),
2893
+ e ? i.length === 0 ? /* @__PURE__ */ n(ce, { children: "No chains" }) : i.map((a) => /* @__PURE__ */ Nt(is, { ...a, key: a.chainId })) : /* @__PURE__ */ u(P, { children: [
2894
+ /* @__PURE__ */ u("div", { className: je.list, children: [
2895
+ /* @__PURE__ */ u("h2", { className: je.title, children: [
2896
+ /* @__PURE__ */ n("span", { children: "Shown" }),
2897
+ /* @__PURE__ */ u("span", { className: je.count, children: [
2898
+ "(",
2899
+ r.length,
2900
+ ")"
2901
+ ] })
2902
+ ] }),
2903
+ r.map((a) => /* @__PURE__ */ Nt(is, { ...a, key: a.chainId }))
2904
+ ] }),
2905
+ /* @__PURE__ */ u("div", { className: je.list, children: [
2906
+ /* @__PURE__ */ u("h2", { className: je.title, children: [
2907
+ /* @__PURE__ */ n("span", { children: "Hidden" }),
2908
+ /* @__PURE__ */ u("span", { className: je.count, children: [
2909
+ "(",
2910
+ o.length,
2911
+ ")"
2912
+ ] })
2913
+ ] }),
2914
+ o.map((a) => /* @__PURE__ */ Nt(is, { ...a, key: a.chainId }))
2915
+ ] })
2916
+ ] })
2917
+ ] }) });
2918
+ };
2919
+ function c_() {
2920
+ return we().network_type === "testnet";
2921
+ }
2922
+ const li = K.object({
2923
+ srcChainId: K.string().nonempty(),
2924
+ srcDenom: K.string().nonempty(),
2925
+ dstChainId: K.string().nonempty(),
2926
+ dstDenom: K.string().nonempty(),
2927
+ quantity: K.string().nonempty("Amount is required"),
2928
+ sender: K.string().nonempty(),
2929
+ cosmosWalletName: K.string().optional(),
2930
+ recipient: K.string().nonempty("Recipient address is required"),
2931
+ slippagePercent: K.string().nonempty()
2932
+ });
2933
+ function Xe() {
2934
+ return $t();
2935
+ }
2936
+ function l_() {
2937
+ const e = We(), t = c_(), s = {
2938
+ quantity: "",
2939
+ slippagePercent: "0.5",
2940
+ sender: "",
2941
+ cosmosWalletName: "",
2942
+ recipient: ""
2943
+ }, r = {
2944
+ ...s,
2945
+ srcChainId: "initiation-2",
2946
+ srcDenom: "uusdc",
2947
+ dstChainId: "initiation-2",
2948
+ dstDenom: "uinit"
2949
+ }, o = {
2950
+ ...s,
2951
+ srcChainId: "interwoven-1",
2952
+ srcDenom: "ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",
2953
+ dstChainId: "interwoven-1",
2954
+ dstDenom: "uinit"
2955
+ }, i = Xi((a) => a !== null, {
2956
+ srcChainId: localStorage.getItem(U.BRIDGE_SRC_CHAIN_ID),
2957
+ srcDenom: localStorage.getItem(U.BRIDGE_SRC_DENOM),
2958
+ dstChainId: localStorage.getItem(U.BRIDGE_DST_CHAIN_ID),
2959
+ dstDenom: localStorage.getItem(U.BRIDGE_DST_DENOM),
2960
+ quantity: localStorage.getItem(U.BRIDGE_QUANTITY),
2961
+ slippagePercent: localStorage.getItem(U.BRIDGE_SLIPPAGE_PERCENT)
2962
+ });
2963
+ return {
2964
+ ...t ? r : o,
2965
+ ...i,
2966
+ ...e
2967
+ };
2968
+ }
2969
+ function di() {
2970
+ const { initiaAddress: e, hexAddress: t } = Qe(), s = Je(), r = Et();
2971
+ return (o) => {
2972
+ const i = s(o);
2973
+ switch (r(i)) {
2974
+ case "initia":
2975
+ return e;
2976
+ case "evm":
2977
+ return t;
2978
+ default:
2979
+ return "";
2980
+ }
2981
+ };
2982
+ }
2983
+ function bs() {
2984
+ const e = Je(), t = Et();
2985
+ return (s, r) => {
2986
+ const o = e(r);
2987
+ switch (t(o)) {
2988
+ case "initia":
2989
+ return D.validate(s);
2990
+ case "evm":
2991
+ return Ss(s);
2992
+ case "cosmos":
2993
+ try {
2994
+ return gn(s).prefix === o.bech32_prefix;
2995
+ } catch {
2996
+ return !1;
2997
+ }
2998
+ default:
2999
+ return !1;
3000
+ }
3001
+ };
3002
+ }
3003
+ function d_() {
3004
+ const e = Je(), t = Et();
3005
+ return ({
3006
+ initialAddress: s,
3007
+ initialChainId: r,
3008
+ chainId: o,
3009
+ fallbackAddress: i
3010
+ }) => {
3011
+ const a = e(r), d = t(a), c = e(o), l = t(c);
3012
+ if (d === "evm" && l === "initia")
3013
+ return D.toBech32(s);
3014
+ if (d === "initia" && l === "evm")
3015
+ return D.toPrefixedHex(s);
3016
+ if (d === l)
3017
+ return s;
3018
+ if (i) {
3019
+ if (l === "initia") return D.toBech32(i);
3020
+ if (l === "evm") return D.toPrefixedHex(i);
3021
+ }
3022
+ return "";
3023
+ };
3024
+ }
3025
+ const u_ = [
3026
+ ["d", 24 * 60 * 60],
3027
+ // day
3028
+ ["h", 60 * 60],
3029
+ // hour
3030
+ ["m", 60],
3031
+ // minute
3032
+ ["s", 1]
3033
+ // second
3034
+ ];
3035
+ function vs(e) {
3036
+ if (!e) return;
3037
+ const { formattedParts: t } = u_.reduce(
3038
+ ({ remainingSeconds: s, formattedParts: r }, [o, i]) => {
3039
+ const a = Math.floor(s / i);
3040
+ return {
3041
+ remainingSeconds: s - a * i,
3042
+ formattedParts: a > 0 ? [...r, `${a}${o}`] : r
3043
+ };
3044
+ },
3045
+ { remainingSeconds: e, formattedParts: [] }
3046
+ );
3047
+ return t.join(" ");
3048
+ }
3049
+ function ui(e) {
3050
+ return e == null ? void 0 : e.map((t) => {
3051
+ const { amount: s, origin_asset: r } = t;
3052
+ return `${ae(s, { decimals: r.decimals ?? 0 })} ${r.symbol}`;
3053
+ }).join(", ");
3054
+ }
3055
+ function Sr(e, t) {
3056
+ const { watch: s } = Xe(), r = s(), o = Ye(), i = Je(), a = Et(), d = { ...r, quantity: e }, c = Se();
3057
+ return ge({
3058
+ queryKey: pe.route(d, t == null ? void 0 : t.isOpWithdraw).queryKey,
3059
+ queryFn: () => {
3060
+ const { srcChainId: l, srcDenom: m, quantity: h, dstChainId: _, dstDenom: f } = d, { symbol: g, decimals: p } = c.getQueryData(
3061
+ pe.asset(l, m).queryKey
3062
+ ) ?? { decimals: 0 }, w = {
3063
+ amount_in: Os(h, p),
3064
+ source_asset_chain_id: l,
3065
+ source_asset_denom: m,
3066
+ dest_asset_chain_id: _,
3067
+ dest_asset_denom: f,
3068
+ go_fast: g === "USDC" && a(i(l)) === "evm",
3069
+ is_op_withdraw: t == null ? void 0 : t.isOpWithdraw
3070
+ };
3071
+ return o.post("v2/fungible/route", { json: w }).json();
3072
+ },
3073
+ enabled: !!Number(d.quantity) && !(t != null && t.disabled),
3074
+ staleTime: F.MINUTE
3075
+ });
3076
+ }
3077
+ function m_(e) {
3078
+ return ge({
3079
+ queryKey: pe.routeErrorInfo(e || new Error()).queryKey,
3080
+ queryFn: async () => {
3081
+ if (!e || !(e instanceof Fr)) return null;
3082
+ const { response: t } = e;
3083
+ return (t.headers.get("content-type") ?? "").includes("application/json") ? (await t.json()).info ?? null : null;
3084
+ }
3085
+ });
3086
+ }
3087
+ function h_() {
3088
+ var h, _, f;
3089
+ const { watch: e } = Xe(), { srcChainId: t, srcDenom: s, dstChainId: r, dstDenom: o } = e(), i = Ie(t), a = Wt(i), d = De(s, t), c = De(o, r), l = we(), m = Ge();
3090
+ return a === "initia" && r === l.chainId && d.symbol === c.symbol && ((f = (_ = (h = m.find((g) => g.chainId === t)) == null ? void 0 : h.metadata) == null ? void 0 : _.op_denoms) == null ? void 0 : f.includes(c.denom));
3091
+ }
3092
+ var Ns = /* @__PURE__ */ ((e) => (e.FEE_BEHAVIOR_DEDUCTED = "FEE_BEHAVIOR_DEDUCTED", e.FEE_BEHAVIOR_ADDITIONAL = "FEE_BEHAVIOR_ADDITIONAL", e))(Ns || {});
3093
+ function Ys(e, t) {
3094
+ const s = Ye();
3095
+ return ge({
3096
+ queryKey: pe.balances(t, e).queryKey,
3097
+ queryFn: () => s.post("v2/info/balances", { json: { chains: { [t]: { address: e, denoms: [] } } } }).json(),
3098
+ select: ({ chains: r }) => e ? r ? r[t].denoms ?? {} : {} : {},
3099
+ enabled: !!e,
3100
+ staleTime: F.SECOND
3101
+ });
3102
+ }
3103
+ function __(e, t, s) {
3104
+ const { data: r = {} } = Ys(e, t);
3105
+ return Ae([s], r);
3106
+ }
3107
+ const f_ = ({ address: e, chain: t, onSelect: s }) => {
3108
+ const r = It(t.chain_id), { data: o = {} } = Ys(e, t.chain_id);
3109
+ return /* @__PURE__ */ n(
3110
+ ci,
3111
+ {
3112
+ assets: Es(
3113
+ [
3114
+ _e((i) => i.symbol === "INIT"),
3115
+ _e((i) => i.value),
3116
+ ({ balance: i = "0" }, { balance: a = "0" }) => T(a).comparedTo(i) ?? 0,
3117
+ Kr((i) => i.symbol.toLowerCase())
3118
+ ],
3119
+ r.filter((i) => !i.hidden).map((i) => {
3120
+ const { denom: a, symbol: d = ie(a), logo_uri: c } = i, l = o[a] ?? {};
3121
+ return {
3122
+ ...i,
3123
+ symbol: d,
3124
+ decimals: i.decimals ?? 0,
3125
+ logoUrl: c ?? "",
3126
+ name: i.name ?? "",
3127
+ balance: l.amount,
3128
+ value: Number(l.value_usd ?? 0)
3129
+ };
3130
+ })
3131
+ ),
3132
+ onSelect: s
3133
+ }
3134
+ );
3135
+ }, p_ = ({ type: e, afterSelect: t }) => {
3136
+ const s = e === "src" ? "srcChainId" : "dstChainId", r = e === "src" ? "srcDenom" : "dstDenom", o = e === "src" ? "sender" : "recipient", i = en(), a = js(), { watch: d, setValue: c, trigger: l } = Xe(), m = d("quantity"), h = d(o), _ = d(s), [f, g] = L(_), p = Ie(f), w = d_(), v = Ro(), [b, k] = ea(
3137
+ (I) => v(I.chain_id),
3138
+ a.filter((I) => !I.hidden)
3139
+ ), C = (I) => {
3140
+ c(s, f), c(r, I), Number(m) && l(), t();
3141
+ };
3142
+ return /* @__PURE__ */ u(P, { children: [
3143
+ /* @__PURE__ */ u(lt.Stack, { children: [
3144
+ /* @__PURE__ */ n(
3145
+ lt,
3146
+ {
3147
+ label: "Interwoven Economy",
3148
+ chains: b.map(({ chain_id: I, chain_name: E, pretty_name: N, logo_uri: y }) => ({ chainId: I, name: N || E, logoUrl: y ?? "" })),
3149
+ value: f,
3150
+ onSelect: g
3151
+ }
3152
+ ),
3153
+ /* @__PURE__ */ n(
3154
+ lt,
3155
+ {
3156
+ label: "Chains",
3157
+ chains: k.map(({ chain_id: I, chain_name: E, pretty_name: N, logo_uri: y }) => ({ chainId: I, name: N || E, logoUrl: y ?? "" })),
3158
+ value: f,
3159
+ onSelect: g
3160
+ }
3161
+ )
3162
+ ] }),
3163
+ /* @__PURE__ */ n(ne, { children: /* @__PURE__ */ n(
3164
+ f_,
3165
+ {
3166
+ address: w({
3167
+ initialAddress: h,
3168
+ initialChainId: _,
3169
+ chainId: f,
3170
+ fallbackAddress: e === "src" ? i : void 0
3171
+ }),
3172
+ chain: p,
3173
+ onSelect: C
3174
+ }
3175
+ ) }, f)
3176
+ ] });
3177
+ }, $r = ({ type: e }) => {
3178
+ const t = e === "src" ? "srcChainId" : "dstChainId", s = e === "src" ? "srcDenom" : "dstDenom", r = e === "src" ? "Select source chain and asset" : "Select destination chain and asset", { watch: o } = Xe(), i = o(t), a = o(s), d = Ie(i), c = De(a, i);
3179
+ return /* @__PURE__ */ n(
3180
+ ut,
3181
+ {
3182
+ title: r,
3183
+ content: (l) => /* @__PURE__ */ n(p_, { type: e, afterSelect: l }),
3184
+ children: /* @__PURE__ */ n(
3185
+ ni,
3186
+ {
3187
+ asset: {
3188
+ denom: c.denom,
3189
+ decimals: c.decimals ?? 0,
3190
+ symbol: c.symbol ?? ie(c.denom),
3191
+ logoUrl: c.logo_uri ?? ""
3192
+ },
3193
+ chain: {
3194
+ chainId: d.chain_id,
3195
+ name: d.pretty_name || d.chain_name,
3196
+ logoUrl: d.logo_uri ?? ""
3197
+ }
3198
+ }
3199
+ )
3200
+ }
3201
+ );
3202
+ };
3203
+ function Mn() {
3204
+ const e = [
3205
+ {
3206
+ name: "Keplr",
3207
+ image: "https://assets.initia.xyz/images/wallets/Keplr.webp",
3208
+ getProvider: () => window.keplr,
3209
+ fallbackUrl: "https://keplr.app/get"
3210
+ },
3211
+ {
3212
+ name: "Leap",
3213
+ image: "https://assets.initia.xyz/images/wallets/Leap.webp",
3214
+ getProvider: () => window.leap,
3215
+ fallbackUrl: "https://leapwallet.io/download"
3216
+ }
3217
+ ];
3218
+ return { list: e, find: (s) => e.find((r) => r.name === s) };
3219
+ }
3220
+ const g_ = "_account_iwrlj_8", y_ = "_clear_iwrlj_27", w_ = "_white_iwrlj_38", Ut = {
3221
+ account: g_,
3222
+ clear: y_,
3223
+ white: w_
3224
+ }, kr = ({ type: e }) => {
3225
+ const { watch: t, setValue: s } = Xe(), { srcChainId: r, dstChainId: o, cosmosWalletName: i } = t(), d = t(e === "src" ? "sender" : "recipient"), c = Wt(Ie(o)), { list: l, find: m } = Mn(), h = m(i), _ = di(), f = bs(), g = _(o), p = D.equals(d, g), w = () => /* @__PURE__ */ n(
3226
+ ut,
3227
+ {
3228
+ title: "Connect wallet",
3229
+ content: (k) => /* @__PURE__ */ n(
3230
+ Jo,
3231
+ {
3232
+ onSelect: async (C) => {
3233
+ const I = C.getProvider();
3234
+ if (!I) return window.open(C.fallbackUrl, "_blank");
3235
+ const E = I.getOfflineSigner(r), [{ address: N }] = await E.getAccounts();
3236
+ s("sender", N), s("cosmosWalletName", C.name), k();
3237
+ },
3238
+ list: l,
3239
+ getImage: (C) => C.image,
3240
+ getName: (C) => C.name,
3241
+ getKey: (C) => C.name
3242
+ }
3243
+ ),
3244
+ className: A(Ut.account, { [Ut.white]: !d }),
3245
+ children: d ? /* @__PURE__ */ u(P, { children: [
3246
+ h && /* @__PURE__ */ n(z, { src: h.image, width: 18, height: 18 }),
3247
+ /* @__PURE__ */ n("span", { className: "monospace", children: ie(d) })
3248
+ ] }) : /* @__PURE__ */ u(P, { children: [
3249
+ /* @__PURE__ */ n("span", { children: "Connect wallet" }),
3250
+ /* @__PURE__ */ n(Ds, { size: 14 })
3251
+ ] })
3252
+ }
3253
+ ), v = (k) => /* @__PURE__ */ n(
3254
+ ut,
3255
+ {
3256
+ title: "Recipient",
3257
+ content: (C) => /* @__PURE__ */ n(Re, { children: /* @__PURE__ */ n(
3258
+ Qs,
3259
+ {
3260
+ mode: "onSubmit",
3261
+ myAddress: g,
3262
+ chainType: c,
3263
+ validate: (I) => f(I, o),
3264
+ onApply: C
3265
+ }
3266
+ ) }),
3267
+ className: Ut.account,
3268
+ children: k
3269
+ }
3270
+ ), b = () => {
3271
+ switch (c) {
3272
+ case "initia":
3273
+ case "evm":
3274
+ return p ? v(/* @__PURE__ */ n(xn, { size: 14 })) : /* @__PURE__ */ u("div", { className: Ut.account, children: [
3275
+ /* @__PURE__ */ n("span", { className: "monospace", children: ie(d) }),
3276
+ /* @__PURE__ */ n(
3277
+ "button",
3278
+ {
3279
+ type: "button",
3280
+ className: Ut.clear,
3281
+ onClick: () => s("recipient", g, { shouldValidate: !0 }),
3282
+ "aria-label": "Reset to my address",
3283
+ children: /* @__PURE__ */ n(Sn, { size: 14 })
3284
+ }
3285
+ )
3286
+ ] });
3287
+ case "cosmos":
3288
+ return v(
3289
+ /* @__PURE__ */ u(P, { children: [
3290
+ d ? /* @__PURE__ */ n("span", { className: "monospace", children: ie(d) }) : /* @__PURE__ */ n("span", { children: "Recipient" }),
3291
+ /* @__PURE__ */ n(Ra, { size: 14 })
3292
+ ] })
3293
+ );
3294
+ }
3295
+ };
3296
+ switch (e) {
3297
+ case "src":
3298
+ return w();
3299
+ case "dst":
3300
+ return b();
3301
+ }
3302
+ }, b_ = "_description_l5bcv_1", v_ = "_presets_l5bcv_8", N_ = "_preset_l5bcv_8", C_ = "_active_l5bcv_29", I_ = "_custom_l5bcv_40", S_ = "_wrapper_l5bcv_46", $_ = "_percent_l5bcv_49", Ne = {
3303
+ description: b_,
3304
+ presets: v_,
3305
+ preset: N_,
3306
+ active: C_,
3307
+ custom: I_,
3308
+ wrapper: S_,
3309
+ percent: $_
3310
+ }, xr = ["0.1", "0.5", "1.0"], k_ = ({ afterConfirm: e }) => {
3311
+ const t = Xe(), s = t.getValues("slippagePercent"), [r, o] = L(null), { control: i, watch: a, getValues: d, setValue: c } = Tn({
3312
+ defaultValues: { value: s }
3313
+ }), l = a("value");
3314
+ H(() => {
3315
+ const p = xr.findIndex((w) => w === s);
3316
+ o(p >= 0 ? p : null);
3317
+ }, [s]);
3318
+ const m = (p, w) => {
3319
+ c("value", p), o(w);
3320
+ }, h = () => {
3321
+ o(null);
3322
+ }, _ = fe(() => Number(l) > 100 ? { type: "error", text: "Slippage must be less than 100%" } : Number(l) > 5 ? { type: "warning", text: "Your transaction may be frontrun" } : Number(l) < 0.5 ? { type: "warning", text: "Your transaction may fail" } : null, [l]), f = (_ == null ? void 0 : _.type) === "error", g = ({ value: p }) => {
3323
+ t.setValue("slippagePercent", p), e();
3324
+ };
3325
+ return /* @__PURE__ */ u(Re, { children: [
3326
+ /* @__PURE__ */ n("p", { className: Ne.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." }),
3327
+ /* @__PURE__ */ u("div", { className: Ne.presets, children: [
3328
+ xr.map((p, w) => /* @__PURE__ */ u(
3329
+ "button",
3330
+ {
3331
+ type: "button",
3332
+ className: A(Ne.preset, { [Ne.active]: r === w }),
3333
+ onClick: () => m(p, w),
3334
+ children: [
3335
+ p,
3336
+ "%"
3337
+ ]
3338
+ },
3339
+ p
3340
+ )),
3341
+ r !== null ? /* @__PURE__ */ n(
3342
+ "button",
3343
+ {
3344
+ type: "button",
3345
+ className: A(Ne.preset, Ne.custom),
3346
+ onClick: () => o(null),
3347
+ children: "Custom"
3348
+ }
3349
+ ) : /* @__PURE__ */ u("div", { className: Ne.wrapper, children: [
3350
+ /* @__PURE__ */ n(
3351
+ ri,
3352
+ {
3353
+ name: "value",
3354
+ control: i,
3355
+ dp: 2,
3356
+ onFocus: h,
3357
+ placeholder: "",
3358
+ className: A(Ne.preset, Ne.active)
3359
+ }
3360
+ ),
3361
+ /* @__PURE__ */ n("span", { className: Ne.percent, children: "%" })
3362
+ ] })
3363
+ ] }),
3364
+ _ && /* @__PURE__ */ n(Y, { level: _.type, children: _.text }),
3365
+ /* @__PURE__ */ n(J, { children: /* @__PURE__ */ n(j.White, { type: "button", onClick: () => g(d()), disabled: f, children: "Confirm" }) })
3366
+ ] });
3367
+ }, x_ = "_stack_hvmmo_1", E_ = "_button_hvmmo_6", T_ = "_checked_hvmmo_14", A_ = "_checkmark_hvmmo_20", D_ = "_inner_hvmmo_30", q_ = "_info_hvmmo_42", P_ = "_duration_hvmmo_51", R_ = "_amount_hvmmo_61", O_ = "_symbol_hvmmo_71", Te = {
3368
+ stack: x_,
3369
+ button: E_,
3370
+ checked: T_,
3371
+ checkmark: A_,
3372
+ inner: D_,
3373
+ info: q_,
3374
+ duration: P_,
3375
+ amount: R_,
3376
+ symbol: O_
3377
+ }, B_ = ({ children: e }) => /* @__PURE__ */ n("div", { className: Te.stack, children: e }), _n = ({ label: e, query: t, value: s, onSelect: r, checked: o }) => {
3378
+ const { data: i, isLoading: a } = t, { watch: d } = Xe(), { dstChainId: c, dstDenom: l } = d(), m = De(l, c);
3379
+ return /* @__PURE__ */ u(
3380
+ "button",
3381
+ {
3382
+ type: "button",
3383
+ className: A(Te.button, { [Te.checked]: o }),
3384
+ onClick: () => r(s),
3385
+ children: [
3386
+ /* @__PURE__ */ n("div", { className: Te.checkmark, children: o && /* @__PURE__ */ n("span", { className: Te.inner }) }),
3387
+ /* @__PURE__ */ u("div", { className: Te.info, children: [
3388
+ /* @__PURE__ */ n("div", { children: e }),
3389
+ /* @__PURE__ */ u("div", { className: Te.duration, children: [
3390
+ /* @__PURE__ */ n(Oa, { size: 12 }),
3391
+ i ? vs(i.estimated_route_duration_seconds) : "Not available"
3392
+ ] })
3393
+ ] }),
3394
+ /* @__PURE__ */ n("div", { className: Te.amount, children: a ? /* @__PURE__ */ n(Ze, { size: 14 }) : /* @__PURE__ */ u(P, { children: [
3395
+ /* @__PURE__ */ n("span", { children: ae(i == null ? void 0 : i.amount_out, { decimals: m.decimals }) }),
3396
+ /* @__PURE__ */ n("span", { className: Te.symbol, children: m.symbol })
3397
+ ] }) })
3398
+ ]
3399
+ }
3400
+ );
3401
+ };
3402
+ _n.Stack = B_;
3403
+ const F_ = "_form_lelld_1", M_ = "_arrow_lelld_5", U_ = "_divider_lelld_13", j_ = "_flip_lelld_21", z_ = "_meta_lelld_37", K_ = "_row_lelld_50", H_ = "_title_lelld_56", L_ = "_description_lelld_60", W_ = "_icon_lelld_67", V_ = "_edit_lelld_72", G_ = "_warning_lelld_93", Q = {
3404
+ form: F_,
3405
+ arrow: M_,
3406
+ divider: U_,
3407
+ flip: j_,
3408
+ meta: z_,
3409
+ row: K_,
3410
+ title: H_,
3411
+ description: L_,
3412
+ icon: W_,
3413
+ edit: V_,
3414
+ warning: G_
3415
+ }, Q_ = () => {
3416
+ var er, tr, nr;
3417
+ const e = de(), [t, s] = Yt(
3418
+ U.BRIDGE_ROUTE_TYPE,
3419
+ "default",
3420
+ { raw: !0 }
3421
+ ), { watch: r, setValue: o, handleSubmit: i, trigger: a, formState: d } = Xe(), c = r(), { srcChainId: l, srcDenom: m, dstChainId: h, dstDenom: _, quantity: f, sender: g, slippagePercent: p } = c, w = _t(), v = Ie(l), b = Wt(v), k = Ie(h), C = Wt(k), I = De(m, l), E = De(_, h), { data: N } = Ys(g, l), y = __(g, l, m);
3422
+ H(() => {
3423
+ Number(f) && a();
3424
+ }, [y, f, a]);
3425
+ const [S, R] = L(f);
3426
+ Fa(() => R(f), 300, [f]);
3427
+ const B = b !== "initia" && C !== "initia", x = h_(), O = Sr(S, {
3428
+ disabled: B
3429
+ }), W = Sr(S, {
3430
+ isOpWithdraw: !0,
3431
+ disabled: !x
3432
+ }), be = x && t === "op" ? W : O, { data: se, isLoading: ve, isFetching: G, isFetched: ye, error: qt } = be, { data: re } = m_(qt), [oe, Pt] = L(se);
3433
+ H(() => {
3434
+ se && Pt({ ...se, amount_out: "0", usd_amount_in: "0", usd_amount_out: "0" });
3435
+ }, [se]);
3436
+ const $ = ye ? se : S ? oe : void 0, zn = S && (ve || G), Kn = () => {
3437
+ o("srcChainId", h), o("srcDenom", _), o("dstChainId", l), o("dstDenom", m), Number(f) && a();
3438
+ }, { openModal: vi, closeModal: Js } = Dn(), Ni = i((q) => {
3439
+ if ($ != null && $.warning) {
3440
+ const { type: ue = "", message: Wn } = $.warning ?? {};
3441
+ vi({
3442
+ content: /* @__PURE__ */ n(
3443
+ Wo,
3444
+ {
3445
+ type: "warning",
3446
+ icon: /* @__PURE__ */ n(Qt, { size: 40 }),
3447
+ title: En(ue),
3448
+ primaryButton: { label: "Cancel", onClick: Js },
3449
+ secondaryButton: {
3450
+ label: "Proceed anyway",
3451
+ onClick: () => {
3452
+ e("/bridge/preview", { route: $, values: q }), Js();
3453
+ }
3454
+ },
3455
+ children: /* @__PURE__ */ n("p", { className: Q.warning, children: Wn })
3456
+ }
3457
+ )
3458
+ });
3459
+ return;
3460
+ }
3461
+ e("/bridge/preview", { route: $, values: q });
3462
+ }), Ci = fe(() => {
3463
+ var q;
3464
+ return ((q = $ == null ? void 0 : $.estimated_fees) == null ? void 0 : q.filter(
3465
+ ({ fee_behavior: ue }) => ue === Ns.FEE_BEHAVIOR_DEDUCTED
3466
+ )) ?? [];
3467
+ }, [$]), Hn = fe(() => {
3468
+ var q;
3469
+ return ((q = $ == null ? void 0 : $.estimated_fees) == null ? void 0 : q.filter(
3470
+ ({ fee_behavior: ue }) => ue === Ns.FEE_BEHAVIOR_ADDITIONAL
3471
+ )) ?? [];
3472
+ }, [$]), Ln = fe(() => {
3473
+ var q;
3474
+ for (const ue of Hn) {
3475
+ const Wn = ((q = N == null ? void 0 : N[ue.origin_asset.denom]) == null ? void 0 : q.amount) ?? "0", ki = ($ == null ? void 0 : $.source_asset_denom) === ue.origin_asset.denom ? $.amount_in : "0";
3476
+ if (T(Wn).lt(T(ki).plus(ue.amount ?? "0"))) return `Insufficient ${ue.origin_asset.symbol} for fees`;
3477
+ }
3478
+ }, [N, $, Hn]), Zs = fe(() => {
3479
+ if (!c.sender) return "Connect wallet";
3480
+ if (!c.quantity || !S) return "Enter amount";
3481
+ if (!c.recipient) return "Enter recipient address";
3482
+ if (d.errors.quantity) return d.errors.quantity.message;
3483
+ const q = li.safeParse(c);
3484
+ if (!q.success) return `Invalid ${q.error.issues[0].path}`;
3485
+ if (!$) return "Route not found";
3486
+ if (Ln) return Ln;
3487
+ }, [S, Ln, d, $, c]), Ii = $ ? ae($.amount_out, { decimals: E.decimals }) : "0", Si = T(f).gt(0) && T(f).isEqualTo(wn(y == null ? void 0 : y.amount, (y == null ? void 0 : y.decimals) ?? 0)), $i = (() => {
3488
+ switch (b) {
3489
+ case "initia":
3490
+ return w(l).fees.fee_tokens.some(({ denom: q }) => q === m);
3491
+ case "cosmos":
3492
+ return v.fee_assets.some(({ denom: q }) => q === m);
3493
+ case "evm":
3494
+ return !Ss(m);
3495
+ default:
3496
+ return !1;
3497
+ }
3498
+ })(), Xs = (q, ue) => q.length ? /* @__PURE__ */ u("div", { className: Q.description, children: [
3499
+ ui(q),
3500
+ /* @__PURE__ */ n(At, { label: ue, children: /* @__PURE__ */ n("span", { className: Q.icon, children: /* @__PURE__ */ n(kn, { size: 12 }) }) })
3501
+ ] }) : null;
3502
+ return /* @__PURE__ */ u("form", { className: Q.form, onSubmit: Ni, children: [
3503
+ /* @__PURE__ */ n(
3504
+ gs,
3505
+ {
3506
+ selectButton: /* @__PURE__ */ n($r, { type: "src" }),
3507
+ accountButton: b === "cosmos" && /* @__PURE__ */ n(kr, { type: "src" }),
3508
+ quantityInput: /* @__PURE__ */ n(vn, {}),
3509
+ balanceButton: /* @__PURE__ */ n(
3510
+ si,
3511
+ {
3512
+ onClick: () => o("quantity", wn(y == null ? void 0 : y.amount, I == null ? void 0 : I.decimals), {
3513
+ shouldValidate: !0
3514
+ }),
3515
+ children: ae(y == null ? void 0 : y.amount, { decimals: I.decimals })
3516
+ }
3517
+ ),
3518
+ value: $ ? $.usd_amount_in ? Ct($.usd_amount_in) : "-" : "0"
3519
+ }
3520
+ ),
3521
+ /* @__PURE__ */ u("div", { className: Q.arrow, children: [
3522
+ /* @__PURE__ */ n("div", { className: Q.divider }),
3523
+ /* @__PURE__ */ n("button", { type: "button", className: Q.flip, onClick: () => Kn(), children: /* @__PURE__ */ n(Le, { size: 16 }) })
3524
+ ] }),
3525
+ /* @__PURE__ */ n(
3526
+ gs,
3527
+ {
3528
+ selectButton: /* @__PURE__ */ n($r, { type: "dst" }),
3529
+ accountButton: /* @__PURE__ */ n(kr, { type: "dst" }),
3530
+ quantityInput: /* @__PURE__ */ n(vn.ReadOnly, { children: Ii }),
3531
+ value: $ ? $.usd_amount_out ? Ct($.usd_amount_out) : "-" : "0"
3532
+ }
3533
+ ),
3534
+ /* @__PURE__ */ n(
3535
+ J,
3536
+ {
3537
+ extra: /* @__PURE__ */ u(P, { children: [
3538
+ /* @__PURE__ */ n(_s, { children: T(f).gt(0) && x ? /* @__PURE__ */ u(_n.Stack, { children: [
3539
+ /* @__PURE__ */ n(
3540
+ _n,
3541
+ {
3542
+ label: "Minitswap",
3543
+ query: O,
3544
+ value: "default",
3545
+ onSelect: s,
3546
+ checked: t === "default"
3547
+ }
3548
+ ),
3549
+ /* @__PURE__ */ n(
3550
+ _n,
3551
+ {
3552
+ label: "Optimistic bridge",
3553
+ query: W,
3554
+ value: "op",
3555
+ onSelect: s,
3556
+ checked: t === "op"
3557
+ }
3558
+ )
3559
+ ] }) : null }),
3560
+ /* @__PURE__ */ u(Y.Stack, { children: [
3561
+ (er = $ == null ? void 0 : $.extra_infos) == null ? void 0 : er.map((q) => /* @__PURE__ */ n(Y, { level: "info", children: q }, q)),
3562
+ re && /* @__PURE__ */ n(Y, { level: "info", children: re }),
3563
+ Si && $i && /* @__PURE__ */ n(Y, { level: "warning", children: "Make sure to leave enough for transaction fee" }),
3564
+ ($ == null ? void 0 : $.warning) && /* @__PURE__ */ n(Y, { level: "warning", children: $.warning.message }),
3565
+ (tr = $ == null ? void 0 : $.extra_warnings) == null ? void 0 : tr.map((q) => /* @__PURE__ */ n(Y, { level: "warning", children: q }, q))
3566
+ ] }),
3567
+ /* @__PURE__ */ n(_s, { children: $ && /* @__PURE__ */ u("div", { className: Q.meta, children: [
3568
+ !!((nr = $.estimated_fees) != null && nr.length) && /* @__PURE__ */ u("div", { className: Q.row, children: [
3569
+ /* @__PURE__ */ n("span", { className: Q.title, children: "Fees" }),
3570
+ /* @__PURE__ */ u("div", { children: [
3571
+ Xs(Ci, "Fee deducted from the amount you receive"),
3572
+ Xs(
3573
+ Hn,
3574
+ "Fee charged in addition to the amount you enter"
3575
+ )
3576
+ ] })
3577
+ ] }),
3578
+ vs($.estimated_route_duration_seconds) && /* @__PURE__ */ u("div", { className: Q.row, children: [
3579
+ /* @__PURE__ */ n("span", { className: Q.title, children: "Estimated time" }),
3580
+ /* @__PURE__ */ n("span", { className: Q.description, children: vs($.estimated_route_duration_seconds) })
3581
+ ] }),
3582
+ $.does_swap && /* @__PURE__ */ u("div", { className: Q.row, children: [
3583
+ /* @__PURE__ */ n("span", { className: Q.title, children: "Slippage" }),
3584
+ /* @__PURE__ */ u("span", { className: Q.description, children: [
3585
+ /* @__PURE__ */ u("span", { children: [
3586
+ p,
3587
+ "%"
3588
+ ] }),
3589
+ /* @__PURE__ */ n(
3590
+ ut,
3591
+ {
3592
+ title: "Slippage tolerance",
3593
+ content: (q) => /* @__PURE__ */ n(k_, { afterConfirm: q }),
3594
+ className: Q.edit,
3595
+ children: /* @__PURE__ */ n(to, { size: 12 })
3596
+ }
3597
+ )
3598
+ ] })
3599
+ ] })
3600
+ ] }) })
3601
+ ] }),
3602
+ children: /* @__PURE__ */ n(j.White, { loading: zn && "Simulating...", disabled: !!Zs, children: Zs ?? "Preview route" })
3603
+ }
3604
+ )
3605
+ ] });
3606
+ }, Y_ = () => {
3607
+ Vo();
3608
+ const e = ec(), t = de(), { closeDrawer: s } = xt(), r = en(), o = l_(), i = bs(), a = Se(), d = Tn({
3609
+ mode: "onChange",
3610
+ defaultValues: o,
3611
+ resolver: Rs(
3612
+ li.superRefine(({ srcChainId: x, srcDenom: O, quantity: W, sender: be }, se) => {
3613
+ const ve = a.getQueryData(
3614
+ pe.balances(x, be).queryKey
3615
+ ), G = Lr("0", ["chains", x, "denoms", O, "amount"], ve), { decimals: ye } = a.getQueryData(
3616
+ pe.asset(x, O).queryKey
3617
+ ) ?? { decimals: 0 };
3618
+ ei({ quantity: W, balance: G, decimals: ye }, se);
3619
+ }).superRefine(({ dstChainId: x, recipient: O }, W) => {
3620
+ if (!i(O, x)) {
3621
+ W.addIssue({
3622
+ code: K.ZodIssueCode.custom,
3623
+ message: "Invalid address",
3624
+ path: ["recipient"]
3625
+ });
3626
+ return;
3627
+ }
3628
+ })
3629
+ )
3630
+ }), { watch: c, setValue: l } = d, { srcChainId: m, dstChainId: h, srcDenom: _, dstDenom: f, quantity: g, slippagePercent: p, recipient: w } = c();
3631
+ c((x, { name: O }) => {
3632
+ (O === "srcChainId" || O === "srcDenom") && l("quantity", "");
3633
+ });
3634
+ const v = di(), b = v(m), k = v(h), I = bs()(w, h);
3635
+ H(() => {
3636
+ l("cosmosWalletName", void 0), l("sender", b);
3637
+ }, [m, b, l]), H(() => {
3638
+ I || l("recipient", k);
3639
+ }, [k, I, l]);
3640
+ const E = It(m), N = It(h), y = fe(() => {
3641
+ if (!E.find((x) => x.denom === _))
3642
+ return `${_} is not available for bridge/swap on ${m}`;
3643
+ if (!N.find((x) => x.denom === f))
3644
+ return `${f} is not available for bridge/swap on ${h}`;
3645
+ }, [N, h, f, E, m, _]);
3646
+ H(() => {
3647
+ y || (localStorage.setItem(U.BRIDGE_SRC_CHAIN_ID, m), localStorage.setItem(U.BRIDGE_SRC_DENOM, _), localStorage.setItem(U.BRIDGE_DST_CHAIN_ID, h), localStorage.setItem(U.BRIDGE_DST_DENOM, f), localStorage.setItem(U.BRIDGE_QUANTITY, g), localStorage.setItem(U.BRIDGE_SLIPPAGE_PERCENT, p));
3648
+ }, [m, _, h, f, g, p, y]);
3649
+ const S = e[0].path === "/bridge", R = () => /* @__PURE__ */ u(P, { children: [
3650
+ /* @__PURE__ */ n(ce, { error: !0, children: y }),
3651
+ /* @__PURE__ */ n(J, { children: S ? /* @__PURE__ */ n(j.White, { onClick: s, children: "Close" }) : /* @__PURE__ */ n(j.White, { onClick: () => t(-1), children: "Go back" }) })
3652
+ ] }), { reminders: B } = Tt();
3653
+ return /* @__PURE__ */ n(
3654
+ Oe,
3655
+ {
3656
+ title: "Bridge/Swap",
3657
+ returnTo: S ? !1 : "/",
3658
+ extra: /* @__PURE__ */ u(P, { children: [
3659
+ /* @__PURE__ */ n(j.Small, { onClick: () => t("/bridge/history"), unpadded: !0, children: /* @__PURE__ */ u("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", width: "12", height: "12", children: [
3660
+ /* @__PURE__ */ n("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" }),
3661
+ /* @__PURE__ */ n("path", { d: "M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z" })
3662
+ ] }) }),
3663
+ /* @__PURE__ */ n(oi, { offset: 0, disabled: B.length === 0, children: /* @__PURE__ */ n(j.Small, { onClick: () => t("/op/withdrawals"), disabled: !r, children: /* @__PURE__ */ n("span", { children: "Withdrawal status" }) }) })
3664
+ ] }),
3665
+ children: y ? R() : /* @__PURE__ */ n(Ps, { ...d, children: /* @__PURE__ */ n(ne, { children: /* @__PURE__ */ n(Q_, {}) }) })
3666
+ }
3667
+ );
3668
+ }, ft = He("interwovenkit:op", {
3669
+ bridge: (e) => [e],
3670
+ withdrawals: (e, t) => [e, t],
3671
+ latestOutput: (e) => [e],
3672
+ output: (e, t) => [e, t],
3673
+ outputResponse: (e, t) => [e, t],
3674
+ withdrawalClaimed: (e, t) => [e, t]
3675
+ });
3676
+ function Un() {
3677
+ const { restUrl: e } = we();
3678
+ return fe(() => M.create({ prefixUrl: e }), [e]);
3679
+ }
3680
+ function J_(e) {
3681
+ const t = Un(), { data: s } = le({
3682
+ queryKey: ft.bridge(e).queryKey,
3683
+ queryFn: () => t.get(`opinit/ophost/v1/bridges/${e}`).json(),
3684
+ staleTime: F.INFINITY
3685
+ });
3686
+ return s;
3687
+ }
3688
+ const Er = 20;
3689
+ function Z_(e) {
3690
+ const t = Z();
3691
+ return ks({
3692
+ queryKey: ft.withdrawals(e, t).queryKey,
3693
+ queryFn: async ({ pageParam: s }) => {
3694
+ if (!t) return [];
3695
+ const r = { limit: Er, offset: s, order: "desc" }, { withdrawals: o } = await M.create({ prefixUrl: e }).get(`withdrawals/${t}`, { searchParams: r }).json();
3696
+ return o;
3697
+ },
3698
+ getNextPageParam: (s) => {
3699
+ var o;
3700
+ const r = (o = Hr(s)) == null ? void 0 : o.sequence;
3701
+ return s.length < Er || !r || r <= 1 ? null : r - 1;
3702
+ },
3703
+ initialPageParam: 0,
3704
+ staleTime: F.SECOND
3705
+ });
3706
+ }
3707
+ function X_(e) {
3708
+ const t = Un(), { data: s } = le({
3709
+ queryKey: ft.latestOutput(e).queryKey,
3710
+ queryFn: () => t.get(`opinit/ophost/v1/bridges/${e}/outputs`, {
3711
+ searchParams: { "pagination.reverse": !0, "pagination.limit": 1 }
3712
+ }).json(),
3713
+ select: ({ output_proposals: r }) => {
3714
+ const [o] = r;
3715
+ return o || null;
3716
+ },
3717
+ staleTime: F.SECOND
3718
+ });
3719
+ return s;
3720
+ }
3721
+ function ef({ bridge_id: e, output_index: t }) {
3722
+ const s = Un(), { data: r } = le({
3723
+ queryKey: ft.output(e, t).queryKey,
3724
+ queryFn: async () => {
3725
+ try {
3726
+ return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${t}`).json();
3727
+ } catch {
3728
+ return null;
3729
+ }
3730
+ },
3731
+ staleTime: F.SECOND
3732
+ });
3733
+ return r;
3734
+ }
3735
+ function tf({ bridge_id: e, sequence: t }) {
3736
+ var c, l;
3737
+ const r = (c = Ge().find(
3738
+ ({ metadata: m }) => (m == null ? void 0 : m.op_bridge_id) === e.toString()
3739
+ )) == null ? void 0 : c.chain_id;
3740
+ if (!r) throw new Error(`Chain not found for bridge_id: ${e}`);
3741
+ const i = _t()(r);
3742
+ if (!i) throw new Error(`Chain not found: ${r}`);
3743
+ const a = (l = i.metadata) == null ? void 0 : l.executor_uri;
3744
+ if (!a) throw new Error(`Executor URL not found: ${r}`);
3745
+ const { data: d } = le({
3746
+ queryKey: ft.outputResponse(a, t).queryKey,
3747
+ queryFn: () => M.create({ prefixUrl: a }).get(`withdrawal/${t}`).json(),
3748
+ staleTime: F.SECOND
3749
+ });
3750
+ return d;
3751
+ }
3752
+ function mi(e, t) {
3753
+ const { bridge_id: s } = e, r = Un(), { data: o } = le({
3754
+ queryKey: ft.withdrawalClaimed(s, t).queryKey,
3755
+ queryFn: () => r.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`, {
3756
+ searchParams: { withdrawal_hash: t }
3757
+ }).json(),
3758
+ select: ({ claimed: i }) => i,
3759
+ staleTime: ({ state: { data: i } }) => i != null && i.claimed ? 1 / 0 : F.SECOND
3760
+ });
3761
+ return o;
3762
+ }
3763
+ function jt(e) {
3764
+ return As.create().update(e).digest();
3765
+ }
3766
+ function as(e, t) {
3767
+ const s = new ArrayBuffer(t);
3768
+ return new DataView(s).setBigUint64(0, BigInt(e), !1), new Uint8Array(s);
3769
+ }
3770
+ function hi(e) {
3771
+ const { bridge_id: t, sequence: s, amount: r, from: o, to: i } = e, a = as(t.toString(), 8), d = as(s.toString(), 8), c = as(r.amount, 8), l = Ia(
3772
+ a,
3773
+ d,
3774
+ jt(Kt(o)),
3775
+ jt(Kt(i)),
3776
+ jt(Kt(r.denom)),
3777
+ c
3778
+ );
3779
+ return jt(jt(l));
3780
+ }
3781
+ const _i = ht(
3782
+ null
3783
+ );
3784
+ function jn() {
3785
+ return Ke(_i);
3786
+ }
3787
+ const nf = "_asset_6h8u2_1", sf = "_info_6h8u2_7", rf = "_symbol_6h8u2_11", cs = {
3788
+ asset: nf,
3789
+ info: sf,
3790
+ symbol: rf
3791
+ }, of = ({ amount: e, denom: t }) => {
3792
+ const s = we(), r = Ms(t, s), { symbol: o, logoUrl: i, decimals: a } = r;
3793
+ return /* @__PURE__ */ u("div", { className: cs.asset, children: [
3794
+ /* @__PURE__ */ n(z, { src: i, width: 32, height: 32 }),
3795
+ /* @__PURE__ */ u("div", { className: cs.info, children: [
3796
+ /* @__PURE__ */ n("span", { children: ae(e, { decimals: a }) }),
3797
+ /* @__PURE__ */ n("span", { className: cs.symbol, children: o })
3798
+ ] })
3799
+ ] });
3800
+ }, af = ({ children: e }) => {
3801
+ const { withdrawalTx: t } = jn(), s = X_(t.bridge_id), r = t.output_index > Number(s == null ? void 0 : s.output_index);
3802
+ return e(r);
3803
+ }, cf = "_container_1oldz_1", lf = "_icon_1oldz_7", Tr = {
3804
+ container: cf,
3805
+ icon: lf
3806
+ }, df = "Your withdrawal request is being processed, and time remaining will show up once it is in queue.", Ar = () => /* @__PURE__ */ u("div", { className: Tr.container, children: [
3807
+ /* @__PURE__ */ n("span", { children: "Withdrawal submitted" }),
3808
+ /* @__PURE__ */ n(At, { label: df, children: /* @__PURE__ */ n("span", { className: Tr.icon, children: /* @__PURE__ */ n(kn, { size: 12 }) }) })
3809
+ ] }), fi = 1e3, uf = 60, mf = 60, hf = 24, Cs = fi * uf, Is = Cs * mf, Dr = Is * hf, _f = ({ date: e }) => {
3810
+ const t = ee(() => {
3811
+ const l = (/* @__PURE__ */ new Date()).getTime(), h = e.getTime() - l;
3812
+ if (h <= 0)
3813
+ return { days: 0, hours: 0, minutes: 0, seconds: 0 };
3814
+ const _ = Math.floor(h / Dr), f = Math.floor(h % Dr / Is), g = Math.floor(h % Is / Cs), p = Math.floor(h % Cs / fi);
3815
+ return { days: _, hours: f, minutes: g, seconds: p };
3816
+ }, [e]), [s, r] = L(t());
3817
+ H(() => {
3818
+ const l = window.setInterval(() => {
3819
+ r(t());
3820
+ }, 1e3);
3821
+ return () => window.clearInterval(l);
3822
+ }, [t, e]);
3823
+ const o = (l) => l.toString().padStart(2, "0"), { days: i, hours: a, minutes: d, seconds: c } = s;
3824
+ return /* @__PURE__ */ n(At, { label: e.toLocaleString(), children: /* @__PURE__ */ u("span", { className: "monospace", children: [
3825
+ i,
3826
+ "d ",
3827
+ o(a),
3828
+ "h ",
3829
+ o(d),
3830
+ "m ",
3831
+ o(c),
3832
+ "s"
3833
+ ] }) });
3834
+ }, ff = "_container_1oldz_1", pf = "_icon_1oldz_7", qr = {
3835
+ container: ff,
3836
+ icon: pf
3837
+ }, gf = "Time remaining before you can claim", yf = ({ date: e }) => /* @__PURE__ */ u("div", { className: qr.container, children: [
3838
+ /* @__PURE__ */ n(_f, { date: e }),
3839
+ /* @__PURE__ */ n(At, { label: gf, children: /* @__PURE__ */ n("span", { className: qr.icon, children: /* @__PURE__ */ n(kn, { size: 12 }) }) })
3840
+ ] }), wf = ({ children: e }) => {
3841
+ const { withdrawalTx: t } = jn(), s = J_(t.bridge_id), r = ef(t), o = fe(() => {
3842
+ if (!r) return null;
3843
+ const { bridge_config: i } = s, { output_proposal: a } = r;
3844
+ return Ua(
3845
+ new Date(a.l1_block_time),
3846
+ parseFloat(i.finalization_period)
3847
+ );
3848
+ }, [s, r]);
3849
+ return e(o);
3850
+ }, bf = ({ date: e, children: t }) => {
3851
+ const { chainId: s, withdrawalTx: r } = jn(), o = qe(hi(r)), i = mi(r, o), { setReminder: a, removeReminder: d } = Tt();
3852
+ return H(() => {
3853
+ const c = { chainId: s, txHash: r.tx_hash };
3854
+ i ? d(c) : a(c, {
3855
+ ...c,
3856
+ recipient: r.to,
3857
+ claimableAt: e.getTime(),
3858
+ amount: r.amount.amount,
3859
+ denom: r.amount.denom,
3860
+ // Required to show the red dot even if the modal is not shown
3861
+ dismissed: co(e.getTime()) ? !0 : void 0
3862
+ });
3863
+ }, [s, i, e, d, a, r]), t;
3864
+ }, vf = "_button_wwvzw_1", Nf = "_claimed_wwvzw_16", Pr = {
3865
+ button: vf,
3866
+ claimed: Nf
3867
+ }, Cf = () => {
3868
+ const { withdrawalTx: e } = jn(), {
3869
+ bridge_id: t,
3870
+ sequence: s,
3871
+ amount: r,
3872
+ output_index: o,
3873
+ withdrawal_proofs: i,
3874
+ storage_root: a,
3875
+ from: d,
3876
+ to: c,
3877
+ version: l
3878
+ } = e, m = we(), h = Z(), { requestTxSync: _, waitForTxConfirmation: f } = Qe(), g = tf(e), p = qe(hi(e)), w = mi(e, p), v = Se(), { mutate: b, isPending: k } = Pe({
3879
+ mutationFn: async () => {
3880
+ if (!g) throw new Error("Output not found");
3881
+ const { last_block_hash: C } = g;
3882
+ return _({
3883
+ chainId: m.chain_id,
3884
+ messages: [
3885
+ {
3886
+ typeUrl: "/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",
3887
+ value: La.fromPartial({
3888
+ sender: h,
3889
+ bridgeId: BigInt(t),
3890
+ outputIndex: BigInt(o),
3891
+ withdrawalProofs: i.map(at),
3892
+ from: d,
3893
+ to: c,
3894
+ sequence: BigInt(s),
3895
+ amount: r,
3896
+ version: at(l),
3897
+ storageRoot: at(a),
3898
+ lastBlockHash: at(C)
3899
+ })
3900
+ }
3901
+ ],
3902
+ internal: !0
3903
+ });
3904
+ },
3905
+ onSuccess: async (C) => {
3906
+ await f({ chainId: m.chain_id, txHash: C }), v.invalidateQueries({
3907
+ queryKey: ft.withdrawalClaimed(t, p).queryKey
3908
+ });
3909
+ }
3910
+ });
3911
+ return w ? /* @__PURE__ */ u("div", { className: Pr.claimed, children: [
3912
+ /* @__PURE__ */ n($n, { size: 14 }),
3913
+ /* @__PURE__ */ n("span", { children: "Success" })
3914
+ ] }) : /* @__PURE__ */ n("button", { className: Pr.button, onClick: () => b(), disabled: k, children: "Claim" });
3915
+ }, If = () => /* @__PURE__ */ n(af, { children: (e) => e ? /* @__PURE__ */ n(Ar, {}) : /* @__PURE__ */ n(wf, { children: (t) => t ? /* @__PURE__ */ n(bf, { date: t, children: ja(t) ? /* @__PURE__ */ n(yf, { date: t }) : /* @__PURE__ */ n(Cf, {}) }) : /* @__PURE__ */ n(Ar, {}) }) }), Sf = "_item_km5w2_1", $f = "_more_km5w2_12", Rr = {
3916
+ item: Sf,
3917
+ more: $f
3918
+ }, kf = ({ chain: e }) => {
3919
+ var c;
3920
+ const t = (c = e.metadata) == null ? void 0 : c.executor_uri;
3921
+ if (!t) throw new Error("Executor URL is not defined");
3922
+ const { data: s, fetchNextPage: r, hasNextPage: o, isFetchingNextPage: i } = Z_(t), a = fe(() => (s == null ? void 0 : s.pages.flat()) ?? [], [s]), { syncReminders: d } = Tt();
3923
+ return H(() => {
3924
+ const l = a.map((m) => ({
3925
+ chainId: e.chainId,
3926
+ txHash: m.tx_hash
3927
+ }));
3928
+ d(l);
3929
+ }, [e.chainId, a, d]), a.length ? /* @__PURE__ */ u(P, { children: [
3930
+ a.map((l) => {
3931
+ const { amount: m } = l;
3932
+ return /* @__PURE__ */ u("div", { className: Rr.item, children: [
3933
+ /* @__PURE__ */ n(of, { ...m }),
3934
+ /* @__PURE__ */ n(ne, { suspenseFallback: null, children: /* @__PURE__ */ n(_i.Provider, { value: { chainId: e.chainId, withdrawalTx: l }, children: /* @__PURE__ */ n(If, {}) }) })
3935
+ ] }, l.sequence);
3936
+ }),
3937
+ o && /* @__PURE__ */ n(
3938
+ "button",
3939
+ {
3940
+ className: Rr.more,
3941
+ onClick: () => r(),
3942
+ disabled: i,
3943
+ children: i ? /* @__PURE__ */ n(Ze, { size: 14 }) : /* @__PURE__ */ u(P, { children: [
3944
+ /* @__PURE__ */ n("span", { children: "Load more" }),
3945
+ /* @__PURE__ */ n(Le, { size: 14 })
3946
+ ] })
3947
+ }
3948
+ )
3949
+ ] }) : /* @__PURE__ */ n(ce, { children: "No withdrawals" });
3950
+ }, xf = "_content_dj1qm_1", Ef = "_title_dj1qm_5", Or = {
3951
+ content: xf,
3952
+ title: Ef
3953
+ }, Tf = () => {
3954
+ var c;
3955
+ const { chainId: e } = We(), t = Ge(), s = qn(), [r, o] = L(
3956
+ e ?? ((c = s.metadata) != null && c.is_l1 ? "" : s.chainId)
3957
+ ), i = _t(), { reminders: a } = Tt(), d = r ? i(r) : void 0;
3958
+ return /* @__PURE__ */ u(Oe, { title: "Optimistic bridge withdrawals", children: [
3959
+ /* @__PURE__ */ n(
3960
+ lt,
3961
+ {
3962
+ chains: t.filter(({ metadata: l }) => {
3963
+ var m;
3964
+ return !(l != null && l.is_l1) && ((m = l == null ? void 0 : l.op_denoms) == null ? void 0 : m.length);
3965
+ }),
3966
+ value: r,
3967
+ onSelect: o,
3968
+ getShowIndicator: (l) => a.some((m) => m.chainId === l)
3969
+ }
3970
+ ),
3971
+ /* @__PURE__ */ n("div", { className: Or.content, children: d ? /* @__PURE__ */ u(P, { children: [
3972
+ /* @__PURE__ */ n("h2", { className: Or.title, children: d.name }),
3973
+ /* @__PURE__ */ n(ne, { children: /* @__PURE__ */ n(kf, { chain: d }) }, r)
3974
+ ] }) : /* @__PURE__ */ n(Y, { level: "info", children: "Select a chain to display your optimistic bridge withdrawals" }) })
3975
+ ] });
3976
+ };
3977
+ async function Af(e, t) {
3978
+ const s = M.create({ prefixUrl: t }), r = `cosmos/auth/v1beta1/account_info/${e}`;
3979
+ for (let o = 1; o <= 24; o++)
3980
+ try {
3981
+ return await s.get(r).json();
3982
+ } catch {
3983
+ await new Promise((i) => setTimeout(i, 5e3));
3984
+ }
3985
+ throw new Error(`Timeout: ${e} not found`);
3986
+ }
3987
+ const fn = ({ chainId: e, txHash: t }) => `${U.BRIDGE_HISTORY}:${e}:${t}`, Nn = 100;
3988
+ function pi() {
3989
+ const [e = [], t] = Yt(U.BRIDGE_HISTORY, []), s = ee(
3990
+ (o, i) => {
3991
+ localStorage.setItem(fn(o), JSON.stringify(i));
3992
+ for (const a of e.slice(Nn - 1))
3993
+ localStorage.removeItem(fn(a));
3994
+ t((a = []) => [o, ...a.slice(0, Nn - 1)]);
3995
+ },
3996
+ [e, t]
3997
+ ), r = ee((o) => {
3998
+ const i = localStorage.getItem(fn(o));
3999
+ return i ? JSON.parse(i) : null;
4000
+ }, []);
4001
+ return { history: e, addHistoryItem: s, getHistoryDetails: r };
4002
+ }
4003
+ function Df(e) {
4004
+ return Yt(fn(e));
4005
+ }
4006
+ async function gi(e, t) {
4007
+ const { chain_type: s, chain_id: r, chain_name: o, evm_fee_asset: i, rpc: a } = t;
4008
+ if (s !== "evm")
4009
+ throw new Error(`Chain is not an EVM chain: ${o}`);
4010
+ try {
4011
+ await e.send("wallet_switchEthereumChain", [
4012
+ { chainId: `0x${Number(r).toString(16)}` }
4013
+ ]);
4014
+ } catch (d) {
4015
+ if (Ae(["error", "code"], d) !== 4902)
4016
+ throw d;
4017
+ if (!i)
4018
+ throw new Error(`Fee asset is not defined for chain: ${o}`);
4019
+ await e.send("wallet_addEthereumChain", [
4020
+ {
4021
+ chainId: `0x${Number(r).toString(16)}`,
4022
+ chainName: o,
4023
+ nativeCurrency: i,
4024
+ rpcUrls: [a]
4025
+ }
4026
+ ]), await e.send("wallet_switchEthereumChain", [
4027
+ { chainId: `0x${Number(r).toString(16)}` }
4028
+ ]);
4029
+ }
4030
+ }
4031
+ function Dt() {
4032
+ return We();
4033
+ }
4034
+ function qf(e) {
4035
+ const t = de(), { showNotification: s, updateNotification: r, hideNotification: o } = Fo(), { addHistoryItem: i } = pi(), { route: a, values: d } = Dt(), { srcChainId: c, sender: l, recipient: m, cosmosWalletName: h } = d, _ = Io(), { requestTxSync: f, waitForTxConfirmation: g } = Qe(), { find: p } = Mn(), w = Fs(), v = Pn(), b = Ie(c), k = Wt(b), C = Oo(c), I = Se(), { addReminder: E } = Tt();
4036
+ return Pe({
4037
+ mutationFn: async () => {
4038
+ var N;
4039
+ try {
4040
+ if ("cosmos_tx" in e) {
4041
+ if (!e.cosmos_tx.msgs) throw new Error("Invalid transaction data");
4042
+ const y = e.cosmos_tx.msgs.map(({ msg_type_url: re, msg: oe }) => {
4043
+ if (!(re && oe)) throw new Error("Invalid transaction data");
4044
+ return v.fromAmino({
4045
+ type: Ts[re].aminoType,
4046
+ value: JSON.parse(oe)
4047
+ });
4048
+ });
4049
+ if (k === "initia") {
4050
+ const re = await f({ messages: y, chainId: c, internal: 1 }), oe = g({ txHash: re, chainId: c });
4051
+ return { txHash: re, wait: oe };
4052
+ }
4053
+ const S = (N = p(h)) == null ? void 0 : N.getProvider();
4054
+ if (!S) throw new Error("Wallet not connected");
4055
+ const R = S.getOfflineSignerOnlyAmino(c), B = await Wr.connectWithSigner(
4056
+ b.rpc,
4057
+ R,
4058
+ { registry: w, aminoTypes: v }
4059
+ ), x = await B.getAllBalances(l), O = b.fee_assets.find(
4060
+ (re) => x.some(
4061
+ (oe) => oe.denom === re.denom && T(oe.amount).gt(0)
4062
+ )
4063
+ );
4064
+ if (!O) {
4065
+ const oe = [
4066
+ "Insufficient balance for fees.",
4067
+ `Available fee assets: ${b.fee_assets.map((Pt) => C(Pt.denom).symbol).join(", ")}`,
4068
+ "(note: asset symbols may refer to different tokens across chains)"
4069
+ ].join(" ");
4070
+ throw new Error(oe);
4071
+ }
4072
+ const { denom: W, gas_price: be } = O;
4073
+ if (!be) throw new Error(`Gas price not found for ${W}`);
4074
+ const se = await B.simulate(l, y, ""), ve = ds.fromString(be.average + W), G = Vr(Math.ceil(se * _o), ve), ye = await B.signAndBroadcastSync(l, y, G), qt = xo({ txHash: ye, client: B });
4075
+ return { txHash: ye, wait: qt };
4076
+ }
4077
+ if ("evm_tx" in e) {
4078
+ const { chain_id: y, to: S, value: R, data: B } = e.evm_tx, x = await _(), O = await x.getSigner();
4079
+ await gi(x, b);
4080
+ const W = await O.sendTransaction({ chainId: y, to: S, value: R, data: `0x${B}` });
4081
+ return { txHash: W.hash, wait: W.wait() };
4082
+ }
4083
+ throw new Error("Unsupported chain type");
4084
+ } catch (y) {
4085
+ throw new Error(await Ve(y));
4086
+ }
4087
+ },
4088
+ onSuccess: ({ txHash: N, wait: y }) => {
4089
+ t(-1), s({
4090
+ type: "loading",
4091
+ title: "Transaction is pending..."
4092
+ }), y.then(() => {
4093
+ const S = { chainId: c, txHash: N }, R = yi(a) === "Optimistic bridge withdrawal";
4094
+ i(S, {
4095
+ ...S,
4096
+ timestamp: Date.now(),
4097
+ route: a,
4098
+ values: d,
4099
+ state: R ? "success" : void 0
4100
+ }), r({
4101
+ type: "info",
4102
+ title: "Transaction submitted",
4103
+ description: Nt(
4104
+ Oi,
4105
+ null,
4106
+ "Check ",
4107
+ Nt(
4108
+ Jt,
4109
+ { to: "/bridge/history", onClick: o },
4110
+ "the activity page"
4111
+ ),
4112
+ " for transaction status"
4113
+ )
4114
+ }), R && E(S, {
4115
+ ...S,
4116
+ recipient: D.toBech32(m),
4117
+ claimableAt: Date.now() + a.estimated_route_duration_seconds * 1e3,
4118
+ amount: a.amount_out,
4119
+ denom: a.dest_asset_denom
4120
+ });
4121
+ }).catch((S) => {
4122
+ r({
4123
+ type: "error",
4124
+ title: "Transaction failed",
4125
+ description: S.message
4126
+ });
4127
+ }).finally(() => {
4128
+ I.invalidateQueries({
4129
+ queryKey: pe.balances(c, l).queryKey
4130
+ });
4131
+ });
4132
+ },
4133
+ onError: (N) => {
4134
+ s({
4135
+ type: "error",
4136
+ title: "Transaction failed",
4137
+ description: N.message
4138
+ });
4139
+ }
4140
+ });
4141
+ }
4142
+ function Pf() {
4143
+ const e = Ye(), t = Z(), s = No(), { route: r, values: o } = Dt(), i = Je();
4144
+ return Pe({
4145
+ mutationFn: async () => {
4146
+ try {
4147
+ const { chain_id: a, hook: d } = await e.post("op-hook", {
4148
+ json: {
4149
+ source_address: t,
4150
+ source_asset_chain_id: r.source_asset_chain_id,
4151
+ source_asset_denom: r.source_asset_denom,
4152
+ dest_address: o.recipient,
4153
+ dest_asset_chain_id: r.dest_asset_chain_id,
4154
+ dest_asset_denom: r.dest_asset_denom
4155
+ }
4156
+ }).json();
4157
+ await Af(t, i(r.dest_asset_chain_id).rest);
4158
+ const c = d.map(({ msg_type_url: h, msg: _ }) => ya.fromAmino({
4159
+ type: Ts[h].aminoType,
4160
+ value: JSON.parse(_)
4161
+ })), l = await s(
4162
+ a,
4163
+ t,
4164
+ c,
4165
+ { amount: [], gas: "1" },
4166
+ ""
4167
+ ), m = rr.fromPartial({
4168
+ body: Ki.decode(l.bodyBytes),
4169
+ authInfo: zi.decode(l.authInfoBytes),
4170
+ signatures: l.signatures
4171
+ });
4172
+ return { signer: t, hook: qe(rr.encode(m).finish()) };
4173
+ } catch (a) {
4174
+ throw new Error(await Ve(a));
4175
+ }
4176
+ }
4177
+ });
4178
+ }
4179
+ function Rf(e) {
4180
+ const { chainId: t, txHash: s } = e, r = Ye();
4181
+ return ge({
4182
+ queryKey: pe.txTrack(t, s).queryKey,
4183
+ queryFn: async () => {
4184
+ try {
4185
+ return await r.post("v2/tx/track", { json: { tx_hash: s, chain_id: t } }).json();
4186
+ } catch (o) {
4187
+ throw new Error(await Ve(o));
4188
+ }
4189
+ },
4190
+ select: ({ tx_hash: o }) => o,
4191
+ retry: 30,
4192
+ retryDelay: 1e3,
4193
+ staleTime: F.INFINITY
4194
+ });
4195
+ }
4196
+ function Of(e) {
4197
+ const { timestamp: t, chainId: s, txHash: r, state: o } = e, i = Ye();
4198
+ return ge({
4199
+ queryKey: pe.txStatus(s, r).queryKey,
4200
+ queryFn: () => i.get("v2/tx/status", { searchParams: { tx_hash: r, chain_id: s } }).json(),
4201
+ enabled: !!r && !o,
4202
+ refetchInterval: ({ state: { data: a } }) => {
4203
+ if (!a) return !1;
4204
+ const { status: d } = a;
4205
+ if (d === "STATE_COMPLETED") return !1;
4206
+ const c = t + e.route.estimated_route_duration_seconds * 1e3, l = Date.now(), m = Math.floor((c - l) / 1e3);
4207
+ return m <= 0 ? 1e3 : m <= 5 * 60 ? 5e3 : 60 * 1e3;
4208
+ },
4209
+ staleTime: F.INFINITY
4210
+ });
4211
+ }
4212
+ var pn = /* @__PURE__ */ ((e) => (e.OP_WITHDRAW = "Optimistic bridge withdrawal", e.SKIP = "Skip", e))(pn || {});
4213
+ function yi(e) {
4214
+ const { operations: t, dest_asset_denom: s } = e;
4215
+ return ta("op_init_transfer", zr(t)) && s === "uinit" ? "Optimistic bridge withdrawal" : "Skip";
4216
+ }
4217
+ const Bf = "_content_c0tee_1", Ff = "_info_c0tee_6", Mf = "_arrow_c0tee_11", Uf = "_divider_c0tee_19", jf = "_type_c0tee_26", zf = "_asset_c0tee_44", Kf = "_amount_c0tee_52", Hf = "_lower_c0tee_57", Lf = "_chain_c0tee_63", Wf = "_address_c0tee_69", he = {
4218
+ content: Bf,
4219
+ info: Ff,
4220
+ arrow: Mf,
4221
+ divider: Uf,
4222
+ type: jf,
4223
+ asset: zf,
4224
+ amount: Kf,
4225
+ lower: Hf,
4226
+ chain: Lf,
4227
+ address: Wf
4228
+ }, wi = (e) => {
4229
+ const { source: t, label: s, amount: r, denom: o, chainId: i, address: a, walletIcon: d } = e, { symbol: c = ie(o), decimals: l = 0, logo_uri: m = Eo } = e, { chain_name: h, pretty_name: _, ...f } = Ie(i);
4230
+ return /* @__PURE__ */ u("div", { children: [
4231
+ !t && /* @__PURE__ */ u("div", { className: he.arrow, children: [
4232
+ /* @__PURE__ */ n("div", { className: he.divider }),
4233
+ s ? /* @__PURE__ */ n(At, { label: s, children: /* @__PURE__ */ n("button", { className: he.type, children: /* @__PURE__ */ n(ms, { size: 12 }) }) }) : /* @__PURE__ */ n("span", { className: he.type, children: /* @__PURE__ */ n(ms, { size: 12 }) }),
4234
+ /* @__PURE__ */ n("div", { className: he.divider })
4235
+ ] }),
4236
+ /* @__PURE__ */ u("div", { className: he.content, children: [
4237
+ /* @__PURE__ */ n(Gs, { assetLogoUrl: m, chainLogoUrl: f.logo_uri ?? void 0 }),
4238
+ /* @__PURE__ */ u("div", { className: he.info, children: [
4239
+ /* @__PURE__ */ u("div", { className: he.asset, children: [
4240
+ /* @__PURE__ */ n("span", { className: he.amount, children: ae(r, { decimals: l }) }),
4241
+ /* @__PURE__ */ n("span", { children: c })
4242
+ ] }),
4243
+ /* @__PURE__ */ u("div", { className: he.lower, children: [
4244
+ /* @__PURE__ */ u("div", { className: he.chain, children: [
4245
+ "on ",
4246
+ _ || h
4247
+ ] }),
4248
+ a && /* @__PURE__ */ n(Lo, { value: a, children: ({ copy: g, copied: p }) => /* @__PURE__ */ u("button", { className: he.address, onClick: g, children: [
4249
+ d,
4250
+ p ? /* @__PURE__ */ n("span", { children: "Copied!" }) : /* @__PURE__ */ n("span", { className: "monospace", children: ie(a) })
4251
+ ] }) })
4252
+ ] })
4253
+ ] })
4254
+ ] })
4255
+ ] });
4256
+ }, vt = (e) => {
4257
+ const t = De(e.denom, e.chainId);
4258
+ return /* @__PURE__ */ n(wi, { ...e, ...t });
4259
+ };
4260
+ vt.Placeholder = wi;
4261
+ const Vf = "_root_133os_1", Gf = "_toggle_133os_6", Qf = "_route_133os_29", Yf = "_content_133os_36", un = {
4262
+ root: Vf,
4263
+ toggle: Gf,
4264
+ route: Qf,
4265
+ content: Yf
4266
+ };
4267
+ function Jf(e) {
4268
+ if ("transfer" in e)
4269
+ return { label: "Bridge", ...e, ...e.transfer };
4270
+ if ("bank_send" in e)
4271
+ return { label: "Send", ...e, ...e.bank_send };
4272
+ if ("swap" in e)
4273
+ return { label: "Swap", ...e, ...e.swap };
4274
+ if ("axelar_transfer" in e)
4275
+ return { label: "Axelar", ...e, ...e.axelar_transfer };
4276
+ if ("cctp_transfer" in e)
4277
+ return { label: "CCTP", ...e, ...e.cctp_transfer };
4278
+ if ("hyperlane_transfer" in e)
4279
+ return { label: "Hyperlane", ...e, ...e.hyperlane_transfer };
4280
+ if ("evm_swap" in e)
4281
+ return { label: "Swap", ...e, ...e.evm_swap };
4282
+ if ("op_init_transfer" in e)
4283
+ return { label: "Op bridge", ...e, ...e.op_init_transfer };
4284
+ if ("go_fast_transfer" in e)
4285
+ return { label: "Go Fast", ...e, ...e.go_fast_transfer };
4286
+ if ("eureka_transfer" in e)
4287
+ return { label: "Eureka", ...e, ...e.eureka_transfer };
4288
+ if ("stargate_transfer" in e)
4289
+ return { label: "Stargate", ...e, ...e.stargate_transfer };
4290
+ if ("layer_zero_transfer" in e)
4291
+ return { label: "LayerZero", ...e, ...e.layer_zero_transfer };
4292
+ throw new Error("Unknown operation type");
4293
+ }
4294
+ const Zf = ({ addressList: e }) => {
4295
+ var I;
4296
+ const { values: t, route: s } = Dt(), { source_asset_denom: r, source_asset_chain_id: o, amount_in: i, operations: a } = s, d = na(s.required_chain_addresses, e), { find: c } = Mn(), { connector: l, address: m = "" } = St(), [h, _] = qs(!1), f = a.length > 1, g = /* @__PURE__ */ n(
4297
+ z,
4298
+ {
4299
+ src: t.cosmosWalletName ? (I = c(t.cosmosWalletName)) == null ? void 0 : I.image : l == null ? void 0 : l.icon,
4300
+ width: 12,
4301
+ height: 12
4302
+ }
4303
+ ), p = {
4304
+ amount: i,
4305
+ denom: r,
4306
+ chainId: o,
4307
+ address: t.sender,
4308
+ walletIcon: g
4309
+ }, w = (E) => D.equals(E, m) ? g : /* @__PURE__ */ n(xn, { size: 11 }), v = (E) => {
4310
+ const { label: N, amount_out: y, denom: S, denom_out: R = S, chain_id: B, from_chain_id: x, to_chain_id: O = B ?? x } = E, W = d[O];
4311
+ return {
4312
+ label: f && !h ? void 0 : N,
4313
+ amount: y,
4314
+ denom: R,
4315
+ chainId: O,
4316
+ address: W,
4317
+ walletIcon: w(W)
4318
+ };
4319
+ }, b = a.map(Jf).map(v), k = b.slice(0, -1), C = b[b.length - 1];
4320
+ return /* @__PURE__ */ u(Vn.Root, { className: un.root, open: h, onOpenChange: _, children: [
4321
+ f && /* @__PURE__ */ n(Vn.Trigger, { asChild: !0, children: /* @__PURE__ */ n(ps, { children: /* @__PURE__ */ n("button", { className: un.toggle, onClick: _, children: h ? /* @__PURE__ */ u(P, { children: [
4322
+ /* @__PURE__ */ n(ro, { size: 12 }),
4323
+ /* @__PURE__ */ n("span", { children: "Hide details" })
4324
+ ] }) : /* @__PURE__ */ u(P, { children: [
4325
+ /* @__PURE__ */ n(Ba, { size: 12 }),
4326
+ /* @__PURE__ */ n("span", { children: "Show details" })
4327
+ ] }) }) }) }),
4328
+ /* @__PURE__ */ u("div", { className: un.route, children: [
4329
+ /* @__PURE__ */ n(vt, { ...p, source: !0 }),
4330
+ /* @__PURE__ */ n(Vn.Content, { className: un.content, children: k.map((E, N) => /* @__PURE__ */ n(
4331
+ ne,
4332
+ {
4333
+ suspenseFallback: /* @__PURE__ */ n(vt.Placeholder, { ...E }),
4334
+ errorBoundaryProps: { fallback: /* @__PURE__ */ n(vt.Placeholder, { ...E }) },
4335
+ children: /* @__PURE__ */ n(vt, { ...E })
4336
+ },
4337
+ N
4338
+ )) }),
4339
+ /* @__PURE__ */ n(vt, { ...C })
4340
+ ] })
4341
+ ] });
4342
+ }, Cn = ({ error: e }) => {
4343
+ const t = de();
4344
+ return /* @__PURE__ */ n(J, { extra: /* @__PURE__ */ n(Y, { level: "error", children: e.message }), children: /* @__PURE__ */ n(j.White, { onClick: () => t("/bridge"), children: "Home" }) });
4345
+ }, Xf = ({ children: e }) => {
4346
+ const t = Dt(), { route: s, values: r } = t, { required_chain_addresses: o } = s, { srcChainId: i, dstChainId: a, sender: d, recipient: c } = r, { initiaAddress: l, hexAddress: m } = Qe(), h = Rn(), _ = Je(), f = Et(), g = _(i), p = f(g), w = o.slice(0, -1).some((C) => {
4347
+ const I = _(C);
4348
+ return f(I) === "cosmos";
4349
+ }) && p !== "cosmos", {
4350
+ value: v,
4351
+ loading: b,
4352
+ error: k
4353
+ } = io(async () => {
4354
+ try {
4355
+ if (!w) return;
4356
+ if (!h) throw new Error("Wallet not connected");
4357
+ const [{ pubkey: C }] = await h.getAccounts();
4358
+ return C;
4359
+ } catch (C) {
4360
+ throw new Error(await Ve(C));
4361
+ }
4362
+ });
4363
+ if (k)
4364
+ return /* @__PURE__ */ n(Cn, { error: k });
4365
+ if (b)
4366
+ return /* @__PURE__ */ n(J, { children: /* @__PURE__ */ n(j.White, { loading: b && "Generating intermediary addresses..." }) });
4367
+ if (!w || v) {
4368
+ const C = o.map((I, E) => {
4369
+ if (E === o.length - 1) {
4370
+ const B = _(a);
4371
+ return f(B) === "initia" ? D.toBech32(c) : c;
4372
+ }
4373
+ const N = _(I), y = f(N), S = _(i), R = f(S);
4374
+ switch (y) {
4375
+ case "initia":
4376
+ return l;
4377
+ case "evm":
4378
+ return m;
4379
+ case "cosmos": {
4380
+ if (R === "cosmos")
4381
+ return Br(N.bech32_prefix, gn(d).data);
4382
+ if (!v) throw new Error("Pubkey not found");
4383
+ return va(Gr(v), N.bech32_prefix);
4384
+ }
4385
+ default:
4386
+ throw new Error("Unsupported chain type");
4387
+ }
4388
+ });
4389
+ return e(C);
4390
+ }
4391
+ return /* @__PURE__ */ n(Cn, { error: new Error("Failed to generate intermediary addresses") });
4392
+ }, ep = ({ addressList: e, signedOpHook: t, children: s }) => {
4393
+ const r = Ye(), { route: o, values: i } = Dt(), { value: a, loading: d, error: c } = io(async () => {
4394
+ if (o.required_op_hook && !t)
4395
+ throw new Error("Op hook is required");
4396
+ const l = {
4397
+ address_list: e,
4398
+ amount_in: o.amount_in,
4399
+ amount_out: o.amount_out,
4400
+ source_asset_chain_id: o.source_asset_chain_id,
4401
+ source_asset_denom: o.source_asset_denom,
4402
+ dest_asset_chain_id: o.dest_asset_chain_id,
4403
+ dest_asset_denom: o.dest_asset_denom,
4404
+ slippage_tolerance_percent: i.slippagePercent,
4405
+ operations: o.operations,
4406
+ signed_op_hook: t
4407
+ }, { txs: m } = await r.post("v2/fungible/msgs", { json: l }).json();
4408
+ if (!m || m.length === 0) throw new Error("No transaction data found");
4409
+ const [h] = m;
4410
+ return h;
4411
+ });
4412
+ return c ? /* @__PURE__ */ n(Cn, { error: c }) : d ? /* @__PURE__ */ n(J, { children: /* @__PURE__ */ n(j.White, { loading: d && "Fetching messages..." }) }) : a ? s(a) : /* @__PURE__ */ n(Cn, { error: new Error("Failed to fetch messages") });
4413
+ }, tp = ({ children: e }) => {
4414
+ var r;
4415
+ const { route: t } = Dt(), s = Pf();
4416
+ return t.required_op_hook && !s.data ? /* @__PURE__ */ n(J, { extra: /* @__PURE__ */ n(Y, { level: "error", children: (r = s.error) == null ? void 0 : r.message }), children: /* @__PURE__ */ n(
4417
+ j.White,
4418
+ {
4419
+ onClick: () => s.mutate(),
4420
+ loading: s.isPending && "Awaiting signature...",
4421
+ children: "Authorize conversion"
4422
+ }
4423
+ ) }) : e(s.data);
4424
+ }, np = ({ tx: e, children: t }) => {
4425
+ const s = Io(), r = Je(), { mutate: o, data: i, isPending: a, error: d } = Pe({
4426
+ mutationFn: async () => {
4427
+ try {
4428
+ if (!("evm_tx" in e)) throw new Error("Transaction is not EVM");
4429
+ if (!e.evm_tx.required_erc20_approvals) throw new Error("No approvals required");
4430
+ const { chain_id: c } = e.evm_tx, l = await s(), m = await l.getSigner();
4431
+ await gi(l, r(c));
4432
+ for (const h of e.evm_tx.required_erc20_approvals) {
4433
+ const { token_contract: _, spender: f, amount: g } = h, p = [
4434
+ "function approve(address spender, uint256 amount) external returns (bool)"
4435
+ ];
4436
+ await (await new ls.Contract(_, p, m).approve(f, g)).wait();
4437
+ }
4438
+ return !0;
4439
+ } catch (c) {
4440
+ throw new Error(await Ve(c));
4441
+ }
4442
+ }
4443
+ });
4444
+ return "evm_tx" in e && e.evm_tx.required_erc20_approvals && e.evm_tx.required_erc20_approvals.length > 0 && !i ? /* @__PURE__ */ n(J, { extra: /* @__PURE__ */ n(Y, { level: "error", children: d == null ? void 0 : d.message }), children: /* @__PURE__ */ n(j.White, { onClick: () => o(), loading: a && "Approving tokens...", children: "Approve tokens" }) }) : t;
4445
+ }, sp = ({ tx: e }) => {
4446
+ const { mutate: t, isPending: s } = qf(e);
4447
+ return /* @__PURE__ */ n(J, { children: /* @__PURE__ */ n(j.White, { onClick: () => t(), loading: s && "Signing transaction...", children: "Confirm" }) });
4448
+ }, rp = () => /* @__PURE__ */ n(Oe, { title: "Route preview", children: /* @__PURE__ */ n(Xf, { children: (e) => /* @__PURE__ */ u(P, { children: [
4449
+ /* @__PURE__ */ n(Zf, { addressList: e }),
4450
+ /* @__PURE__ */ n(tp, { children: (t) => /* @__PURE__ */ n(ep, { addressList: e, signedOpHook: t, children: (s) => /* @__PURE__ */ n(np, { tx: s, children: /* @__PURE__ */ n(sp, { tx: s }) }) }) })
4451
+ ] }) }) }), op = "_button_14cv7_1", ip = "_checkbox_14cv7_10", ap = "_checked_14cv7_23", mn = {
4452
+ button: op,
4453
+ checkbox: ip,
4454
+ checked: ap
4455
+ }, cp = ({ checked: e, onClick: t, label: s, className: r }) => /* @__PURE__ */ u("button", { type: "button", className: A(mn.button, r), onClick: t, children: [
4456
+ /* @__PURE__ */ n("div", { className: A(mn.checkbox, { [mn.checked]: e }), children: e && /* @__PURE__ */ n(so, { size: 12 }) }),
4457
+ /* @__PURE__ */ n("span", { className: mn.label, children: s })
4458
+ ] }), lp = "_link_1j28k_1", dp = "_header_1j28k_22", up = "_title_1j28k_30", mp = "_success_1j28k_36", hp = "_error_1j28k_40", _p = "_date_1j28k_44", fp = "_explorer_1j28k_48", pp = "_fees_1j28k_63", gp = "_label_1j28k_71", yp = "_content_1j28k_75", wp = "_route_1j28k_81", bp = "_row_1j28k_86", vp = "_asset_1j28k_92", Np = "_amount_1j28k_100", Cp = "_chain_1j28k_105", Ip = "_account_1j28k_114", Sp = "_arrow_1j28k_121", V = {
4459
+ link: lp,
4460
+ header: dp,
4461
+ title: up,
4462
+ success: mp,
4463
+ error: hp,
4464
+ date: _p,
4465
+ explorer: fp,
4466
+ fees: pp,
4467
+ label: gp,
4468
+ content: yp,
4469
+ route: wp,
4470
+ row: bp,
4471
+ asset: vp,
4472
+ amount: Np,
4473
+ chain: Cp,
4474
+ account: Ip,
4475
+ arrow: Sp
4476
+ }, $p = ({ tx: e }) => {
4477
+ var ve;
4478
+ const [t, s] = Df(e);
4479
+ if (!t) throw new Error("Bridge history details not found");
4480
+ const { chainId: r, txHash: o, route: i, values: a, timestamp: d } = t, { data: c = "" } = Rf(t), { data: l } = Of({ ...t, txHash: c }), m = t.state ?? kp(l), { address: h = "", connector: _ } = St(), { find: f } = Mn();
4481
+ H(() => {
4482
+ c && s((G) => {
4483
+ if (!G) throw new Error("Bridge history details not found");
4484
+ return { ...G, tracked: !0 };
4485
+ });
4486
+ }, [s, c]), H(() => {
4487
+ m !== "loading" && s((G) => {
4488
+ if (!G) throw new Error("Bridge history details not found");
4489
+ return { ...G, tracked: !0, state: m };
4490
+ });
4491
+ }, [s, m, o]);
4492
+ const g = () => {
4493
+ switch (m) {
4494
+ case "error":
4495
+ return /* @__PURE__ */ n("div", { className: V.error, children: /* @__PURE__ */ n(Qt, { size: 14 }) });
4496
+ case "success":
4497
+ return /* @__PURE__ */ n("div", { className: V.success, children: /* @__PURE__ */ n($n, { size: 14 }) });
4498
+ default:
4499
+ return /* @__PURE__ */ n(Ze, { size: 14 });
4500
+ }
4501
+ }, {
4502
+ amount_in: p,
4503
+ amount_out: w,
4504
+ source_asset_chain_id: v,
4505
+ source_asset_denom: b,
4506
+ dest_asset_chain_id: k,
4507
+ dest_asset_denom: C,
4508
+ estimated_fees: I = []
4509
+ } = i, E = Ie(v), N = Ie(k), y = De(b, v), S = De(C, k), R = (G, ye) => ye ? /* @__PURE__ */ n(z, { src: ye, width: 12, height: 12 }) : D.equals(G, h) ? /* @__PURE__ */ n(z, { src: _ == null ? void 0 : _.icon, width: 12, height: 12 }) : /* @__PURE__ */ n(xn, { size: 12 }), B = (G, { symbol: ye, decimals: qt, logo_uri: re }, { chain_name: oe, pretty_name: Pt, ...$ }, zn, Kn) => /* @__PURE__ */ u("div", { className: V.row, children: [
4510
+ /* @__PURE__ */ n(Gs, { assetLogoUrl: re, chainLogoUrl: $.logo_uri ?? void 0 }),
4511
+ /* @__PURE__ */ u("div", { children: [
4512
+ /* @__PURE__ */ u("div", { className: V.asset, children: [
4513
+ /* @__PURE__ */ n("span", { className: V.amount, children: ae(G, { decimals: qt }) }),
4514
+ /* @__PURE__ */ n("span", { children: ye })
4515
+ ] }),
4516
+ /* @__PURE__ */ u("div", { className: V.chain, children: [
4517
+ /* @__PURE__ */ u("span", { children: [
4518
+ "on ",
4519
+ Pt || oe
4520
+ ] }),
4521
+ /* @__PURE__ */ u("div", { className: V.account, children: [
4522
+ Kn,
4523
+ /* @__PURE__ */ n("span", { className: "monospace", children: ie(zn) })
4524
+ ] })
4525
+ ] })
4526
+ ] })
4527
+ ] }), x = yi(i), O = fe(() => {
4528
+ switch (x) {
4529
+ case pn.SKIP:
4530
+ return "Skip Explorer";
4531
+ case pn.OP_WITHDRAW:
4532
+ return "Initia Scan";
4533
+ }
4534
+ }, [x]), W = /* @__PURE__ */ u(P, { children: [
4535
+ /* @__PURE__ */ u("header", { className: V.header, children: [
4536
+ /* @__PURE__ */ u("div", { className: V.title, children: [
4537
+ g(),
4538
+ /* @__PURE__ */ n("div", { className: V.date, children: lo(new Date(d), /* @__PURE__ */ new Date(), { locale: "en-US" }) })
4539
+ ] }),
4540
+ /* @__PURE__ */ u("div", { className: V.explorer, children: [
4541
+ /* @__PURE__ */ n("span", { children: O }),
4542
+ /* @__PURE__ */ n(Ht, { size: 12 })
4543
+ ] })
4544
+ ] }),
4545
+ /* @__PURE__ */ u("div", { className: V.route, children: [
4546
+ B(
4547
+ p,
4548
+ y,
4549
+ E,
4550
+ a.sender,
4551
+ R(a.sender, (ve = f(a.cosmosWalletName)) == null ? void 0 : ve.image)
4552
+ ),
4553
+ /* @__PURE__ */ n("div", { className: V.arrow, children: /* @__PURE__ */ n(ms, { size: 12 }) }),
4554
+ B(
4555
+ w,
4556
+ S,
4557
+ N,
4558
+ a.recipient,
4559
+ R(a.recipient)
4560
+ )
4561
+ ] }),
4562
+ I.length > 0 && /* @__PURE__ */ u("div", { className: V.fees, children: [
4563
+ /* @__PURE__ */ n("span", { className: V.label, children: "Fees" }),
4564
+ /* @__PURE__ */ n("span", { className: V.content, children: ui(I) })
4565
+ ] })
4566
+ ] });
4567
+ if (x === pn.OP_WITHDRAW)
4568
+ return /* @__PURE__ */ n(Ks, { chainId: r, txHash: o, className: V.link, children: W });
4569
+ const be = new URLSearchParams({ tx_hash: o, chain_id: r }), se = new URL(`?${be.toString()}`, "https://explorer.skip.build");
4570
+ return /* @__PURE__ */ n("a", { href: se.toString(), className: V.link, target: "_blank", children: W });
4571
+ };
4572
+ function kp(e) {
4573
+ if (!e) return "loading";
4574
+ switch (e.state) {
4575
+ case "STATE_ABANDONED":
4576
+ case "STATE_COMPLETED_ERROR":
4577
+ case "STATE_PENDING_ERROR":
4578
+ return "error";
4579
+ case "STATE_COMPLETED_SUCCESS":
4580
+ return "success";
4581
+ default:
4582
+ return "loading";
4583
+ }
4584
+ }
4585
+ const xp = "_list_1q71m_1", Ep = "_header_1q71m_5", Tp = "_checkbox_1q71m_9", Ap = "_item_1q71m_13", hn = {
4586
+ list: xp,
4587
+ header: Ep,
4588
+ checkbox: Tp,
4589
+ item: Ap
4590
+ }, Dp = () => {
4591
+ const { initiaAddress: e, hexAddress: t } = Qe(), { history: s, getHistoryDetails: r } = pi(), o = s.filter((l) => r(l)), i = o.filter((l) => {
4592
+ const m = r(l);
4593
+ if (!m) return !1;
4594
+ const { values: h } = m, { sender: _, recipient: f } = h;
4595
+ return [_, f].some((g) => [e, t].includes(g));
4596
+ }), [a, d] = qs(!i.length), c = a ? o : i;
4597
+ return /* @__PURE__ */ n(Oe, { title: "Bridge/Swap activity", children: /* @__PURE__ */ u("div", { className: hn.list, children: [
4598
+ o.length > 0 && o.length !== i.length && /* @__PURE__ */ n("header", { className: hn.header, children: /* @__PURE__ */ n(
4599
+ cp,
4600
+ {
4601
+ checked: a,
4602
+ onClick: d,
4603
+ label: "Show all transactions stored in this browser",
4604
+ className: hn.checkbox
4605
+ }
4606
+ ) }),
4607
+ c.length === 0 ? /* @__PURE__ */ n(ce, { children: "No bridge/swap activity" }) : c.map((l, m) => /* @__PURE__ */ n("div", { className: hn.item, children: /* @__PURE__ */ n(ne, { children: /* @__PURE__ */ n($p, { tx: l }) }) }, m)),
4608
+ s.length >= Nn && /* @__PURE__ */ u(ce, { children: [
4609
+ "Only the latest ",
4610
+ Nn,
4611
+ " items are stored. Older entries will be removed automatically."
4612
+ ] })
4613
+ ] }) });
4614
+ }, bi = () => {
4615
+ const e = de(), t = go(), s = en(), { closeModal: r } = Dn();
4616
+ if (H(() => {
4617
+ r(), t.startsWith("/bridge/") && e("/bridge"), (t === "/collection" || t.startsWith("/nft")) && e("/nfts");
4618
+ }, [s]), t === "/connect")
4619
+ return s ? null : /* @__PURE__ */ n(Nd, {});
4620
+ switch (t) {
4621
+ case "/bridge":
4622
+ return /* @__PURE__ */ n(Y_, {}, s);
4623
+ case "/bridge/history":
4624
+ return /* @__PURE__ */ n(Dp, {});
4625
+ }
4626
+ if (!s)
4627
+ return null;
4628
+ switch (t) {
4629
+ case "/":
4630
+ case "/nfts":
4631
+ case "/activity":
4632
+ return /* @__PURE__ */ n(cm, {});
4633
+ case "/send":
4634
+ return /* @__PURE__ */ n(yh, {}, s);
4635
+ case "/collection":
4636
+ return /* @__PURE__ */ n(Nh, {});
4637
+ case "/nft":
4638
+ return /* @__PURE__ */ n(Ah, {});
4639
+ case "/nft/send":
4640
+ return /* @__PURE__ */ n(Yh, {}, s);
4641
+ case "/rollups":
4642
+ return /* @__PURE__ */ n(a_, {});
4643
+ case "/bridge/preview":
4644
+ return /* @__PURE__ */ n(rp, {});
4645
+ case "/op/withdrawals":
4646
+ return /* @__PURE__ */ n(Tf, {});
4647
+ case "/tx":
4648
+ return /* @__PURE__ */ n(Ho, {});
4649
+ case "/blank":
4650
+ return null;
4651
+ }
4652
+ }, qp = "https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap", Pp = () => /* @__PURE__ */ u(P, { children: [
4653
+ /* @__PURE__ */ n("link", { rel: "preconnect", href: "https://fonts.googleapis.com" }),
4654
+ /* @__PURE__ */ n("link", { rel: "preconnect", href: "https://fonts.gstatic.com", crossOrigin: "" }),
4655
+ /* @__PURE__ */ n("link", { rel: "stylesheet", href: qp }),
4656
+ /* @__PURE__ */ n("link", { rel: "stylesheet", href: "https://assets.initia.xyz/fonts/PilatWide.css" })
4657
+ ] }), Rp = () => {
4658
+ Ge();
4659
+ const e = we();
4660
+ return js(), It(localStorage.getItem(U.BRIDGE_SRC_CHAIN_ID) ?? e.chainId), It(localStorage.getItem(U.BRIDGE_DST_CHAIN_ID) ?? e.chainId), null;
4661
+ }, Og = ({ children: e, ...t }) => typeof document > "u" || typeof window > "u" ? null : /* @__PURE__ */ u(P, { children: [
4662
+ /* @__PURE__ */ n(Pp, {}),
4663
+ /* @__PURE__ */ u(mo.Provider, { value: { ...Xa, ...t }, children: [
4664
+ /* @__PURE__ */ n(ne, { suspenseFallback: null, errorBoundaryProps: { fallback: null }, children: /* @__PURE__ */ n(Rp, {}) }),
4665
+ /* @__PURE__ */ n(yo, { children: /* @__PURE__ */ n(Nc, { children: /* @__PURE__ */ n(Oc, { children: /* @__PURE__ */ n(Ll, { children: /* @__PURE__ */ u(wt.Provider, { delayDuration: 0, skipDelayDuration: 0, children: [
4666
+ e,
4667
+ /* @__PURE__ */ n(ld, { children: /* @__PURE__ */ n(bi, {}) })
4668
+ ] }) }) }) }) })
4669
+ ] })
4670
+ ] }), Bg = ({ bridge: e }) => /* @__PURE__ */ n(yo, { initialEntry: { path: e ? "/bridge" : "/", state: e }, children: /* @__PURE__ */ n("div", { className: "body", children: /* @__PURE__ */ n(Mo.Provider, { value: !!e, children: /* @__PURE__ */ n(ne, { children: /* @__PURE__ */ n(bi, {}) }) }) }) });
4671
+ export {
4672
+ D as AddressUtils,
4673
+ _o as DEFAULT_GAS_ADJUSTMENT,
4674
+ Za as DEFAULT_GAS_PRICE_MULTIPLIER,
4675
+ Bg as InterwovenKit,
4676
+ Og as InterwovenKitProvider,
4677
+ Xa as MAINNET,
4678
+ Rg as TESTNET,
4679
+ Ya as createUsernameClient,
4680
+ ae as formatAmount,
4681
+ Ct as formatNumber,
4682
+ qg as formatPercent,
4683
+ Pg as injectStyles,
4684
+ Os as toAmount,
4685
+ wn as toQuantity,
4686
+ ie as truncate,
4687
+ en as useAddress,
4688
+ On as useHexAddress,
4689
+ Z as useInitiaAddress,
4690
+ Qe as useInterwovenKit,
4691
+ wc as useUsernameQuery
4692
+ };