@deloraprotocol/widget 1.0.0 → 1.0.2

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 CHANGED
@@ -1,13 +1,13 @@
1
- var wt = Object.defineProperty;
2
- var He = (t) => {
3
- throw TypeError(t);
1
+ var kt = Object.defineProperty;
2
+ var Ye = (e) => {
3
+ throw TypeError(e);
4
4
  };
5
- var ut = (t, e, n) => e in t ? wt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
6
- var Se = (t, e, n) => ut(t, typeof e != "symbol" ? e + "" : e, n), Ce = (t, e, n) => e.has(t) || He("Cannot " + n);
7
- var b = (t, e, n) => (Ce(t, e, "read from private field"), n ? n.call(t) : e.get(t)), ge = (t, e, n) => e.has(t) ? He("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), ke = (t, e, n, r) => (Ce(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n), E = (t, e, n) => (Ce(t, e, "access private method"), n);
8
- import { jsxs as v, jsx as d, Fragment as ft } from "react/jsx-runtime";
9
- import { useState as U, useEffect as oe, useCallback as D, useRef as se, useLayoutEffect as ht, useMemo as ie } from "react";
10
- const pt = {
5
+ var bt = (e, t, n) => t in e ? kt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
+ var Fe = (e, t, n) => bt(e, typeof t != "symbol" ? t + "" : t, n), Re = (e, t, n) => t.has(e) || Ye("Cannot " + n);
7
+ var x = (e, t, n) => (Re(e, t, "read from private field"), n ? n.call(e) : t.get(e)), Ne = (e, t, n) => t.has(e) ? Ye("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), Te = (e, t, n, r) => (Re(e, t, "write to private field"), r ? r.call(e, n) : t.set(e, n), n), j = (e, t, n) => (Re(e, t, "access private method"), n);
8
+ import { jsxs as A, jsx as d, Fragment as xt } from "react/jsx-runtime";
9
+ import { useState as B, useRef as X, useMemo as ue, useEffect as re, useCallback as M, useLayoutEffect as yt } from "react";
10
+ const At = {
11
11
  bg: "#ffffff",
12
12
  fg: "#111216",
13
13
  accent: "#7ca7f5",
@@ -27,7 +27,7 @@ const pt = {
27
27
  fontSize: "13px",
28
28
  lineHeight: "1.2",
29
29
  letterSpacing: "-0.05em"
30
- }, mt = {
30
+ }, vt = {
31
31
  bg: "#090909",
32
32
  fg: "#ffffff",
33
33
  accent: "#7ca7f5",
@@ -47,14 +47,14 @@ const pt = {
47
47
  fontSize: "13px",
48
48
  lineHeight: "1.2",
49
49
  letterSpacing: "-0.05em"
50
- }, gt = {
51
- light: pt,
52
- dark: mt
50
+ }, Nt = {
51
+ light: At,
52
+ dark: vt
53
53
  };
54
- function et(t, e) {
55
- return { ...gt[t], ...e };
54
+ function dt(e, t) {
55
+ return { ...Nt[e], ...t };
56
56
  }
57
- const bt = {
57
+ const St = {
58
58
  bg: "--dw-bg",
59
59
  fg: "--dw-fg",
60
60
  accent: "--dw-accent",
@@ -75,32 +75,32 @@ const bt = {
75
75
  lineHeight: "--dw-line-height",
76
76
  letterSpacing: "--dw-letter-spacing"
77
77
  };
78
- function tt(t) {
79
- const e = {};
80
- for (const [n, r] of Object.entries(t)) {
81
- const s = bt[n];
82
- s && r != null && (e[s] = r);
78
+ function lt(e) {
79
+ const t = {};
80
+ for (const [n, r] of Object.entries(e)) {
81
+ const s = St[n];
82
+ s && r != null && (t[s] = r);
83
83
  }
84
- return e;
84
+ return t;
85
85
  }
86
- function hn(t) {
86
+ function An(e) {
87
87
  const {
88
- theme: e = "light",
88
+ theme: t = "light",
89
89
  vars: n,
90
90
  className: r,
91
91
  style: s,
92
- ...a
93
- } = t, i = et(e, n), h = {
94
- ...tt(i),
92
+ ...l
93
+ } = e, i = dt(t, n), p = {
94
+ ...lt(i),
95
95
  ...s
96
96
  };
97
- return /* @__PURE__ */ v(
97
+ return /* @__PURE__ */ A(
98
98
  "div",
99
99
  {
100
100
  "data-delora-widget-root": !0,
101
101
  className: `dw-flex dw-flex-col dw-gap-3 dw-rounded-[var(--dw-radius)] dw-border dw-border-[var(--dw-border)] dw-bg-[var(--dw-bg)] dw-p-4 dw-shadow-sm ${r ?? ""}`,
102
- style: h,
103
- ...a,
102
+ style: p,
103
+ ...l,
104
104
  children: [
105
105
  /* @__PURE__ */ d("h3", { className: "dw-text-base dw-font-semibold dw-text-[var(--dw-fg)]", children: "Delora" }),
106
106
  /* @__PURE__ */ d("p", { className: "dw-text-sm dw-text-[var(--dw-muted)]", children: "A simple widget with theme support." }),
@@ -116,513 +116,633 @@ function hn(t) {
116
116
  }
117
117
  );
118
118
  }
119
- function xt(t) {
119
+ const Be = "https://api.delora.build", at = "0x1111111111111111111111111111111111111111", it = "11111111111111111111111111111111", ct = "1111111111111111111111111111111111111111111111111111111111111111";
120
+ function wt(e) {
121
+ return (e || Be).replace(/\/$/, "");
122
+ }
123
+ function Ct(e, t, n) {
124
+ if (!e) return;
125
+ const r = e.replace(/\/+$/, "");
126
+ return r.includes("/token/") || r.includes("/coin/") ? `${r}/` : t === "MVM" || n === "sui" ? `${r}/coin/` : `${r}/token/`;
127
+ }
128
+ function It(e) {
129
+ var t, n, r;
130
+ return {
131
+ id: e.id,
132
+ name: e.name,
133
+ rpcUrls: e.rpcUrls ?? [],
134
+ logoURI: e.logoURI,
135
+ idHex: e.idHex,
136
+ chainType: e.chainType,
137
+ explorerUrl: Ct(
138
+ e.blockExplorerUrls,
139
+ e.chainType,
140
+ e.key
141
+ ),
142
+ key: e.key,
143
+ nativeCurrency: {
144
+ name: ((t = e.nativeToken) == null ? void 0 : t.name) ?? e.name,
145
+ symbol: ((n = e.nativeToken) == null ? void 0 : n.symbol) ?? "",
146
+ decimals: ((r = e.nativeToken) == null ? void 0 : r.decimals) ?? 18
147
+ }
148
+ };
149
+ }
150
+ function Tt(e) {
120
151
  return {
121
- symbol: t.symbol,
122
- name: t.name,
123
- contractAddress: t.address,
124
- chainId: t.chainId,
125
- imageUrl: t.logoURI,
126
- decimals: t.decimals,
127
- priceUSD: t.priceUSD
152
+ symbol: e.symbol,
153
+ name: e.name,
154
+ contractAddress: e.address,
155
+ chainId: e.chainId,
156
+ imageUrl: e.logoURI ?? "",
157
+ decimals: e.decimals,
158
+ priceUSD: e.priceUSD
128
159
  };
129
160
  }
130
- async function At(t) {
131
- const e = t || (typeof window < "u" ? window.location.origin : ""), n = await fetch(`${e}/data/networks.json`);
161
+ async function Bt(e) {
162
+ const t = wt(e), n = await fetch(`${t}/v1/chains`);
132
163
  if (!n.ok) throw new Error(`Failed to fetch networks: ${n.status}`);
133
- return n.json();
164
+ return ((await n.json()).chains ?? []).map(It);
134
165
  }
135
- async function vt(t) {
136
- const e = t || (typeof window < "u" ? window.location.origin : ""), n = await fetch(`${e}/data/tokens.json`);
166
+ async function Ut(e) {
167
+ const t = wt(e), n = await fetch(`${t}/v1/tokens`);
137
168
  if (!n.ok) throw new Error(`Failed to fetch tokens: ${n.status}`);
138
- return n.json();
169
+ return { byChainId: await n.json() };
139
170
  }
140
- async function kt(t) {
141
- const e = t || (typeof window < "u" ? window.location.origin : ""), n = await fetch(`${e}/data/tokens_search.json`);
142
- if (!n.ok) throw new Error(`Failed to fetch tokens_search: ${n.status}`);
143
- return n.json();
171
+ function ke(e, t) {
172
+ const n = String(t);
173
+ return (e.byChainId[n] ?? []).map(Tt);
144
174
  }
145
- function ae(t, e) {
146
- var w, h, p;
147
- const n = String(e), r = ((w = t.tokensEVM) == null ? void 0 : w[n]) ?? [], s = ((h = t.tokensSVM) == null ? void 0 : h[n]) ?? [], a = ((p = t.tokensMVM) == null ? void 0 : p[n]) ?? [];
148
- return (r.length ? r : s.length ? s : a.length ? a : []).map(xt);
175
+ function Ft(e, t) {
176
+ return ke(e, t);
149
177
  }
150
- function yt(t, e) {
151
- return ae(t, e);
178
+ function Rt(e) {
179
+ const t = "0x0000000000000000000000000000000000000000", n = "11111111111111111111111111111111", r = "1111111111111111111111111111111111111111111111111111111111111111";
180
+ return e.find(
181
+ (s) => s.contractAddress === t || s.contractAddress === n || s.contractAddress === r
182
+ ) ?? e[0];
152
183
  }
153
- function Nt(t) {
154
- const e = "0x0000000000000000000000000000000000000000", n = "11111111111111111111111111111111", r = "1111111111111111111111111111111111111111111111111111111111111111";
155
- return t.find(
156
- (s) => s.contractAddress === e || s.contractAddress === n || s.contractAddress === r
157
- ) ?? t[0];
184
+ function Je(e) {
185
+ return e.startsWith("0x");
158
186
  }
159
- function St(t) {
160
- const [e, n] = U([]), [r, s] = U(null), [a, i] = U(null), [w, h] = U(!0), [p, N] = U(null), [x, m] = U(), [u, k] = U(), [o, R] = U(), [M, V] = U();
161
- oe(() => {
162
- let c = !1;
163
- return h(!0), N(null), Promise.all([
164
- At(t.dataBaseUrl),
165
- vt(t.dataBaseUrl),
166
- kt(t.dataBaseUrl)
167
- ]).then(([f, C, A]) => {
168
- c || (n(f), s(C), i(A), f.length >= 2 ? (m(f[0]), k(f[1])) : f.length === 1 && (m(f[0]), k(f[0])));
169
- }).catch((f) => {
170
- c || N((f == null ? void 0 : f.message) ?? "Failed to load data");
187
+ function Et(e, t) {
188
+ return Je(e) || Je(t) ? e.toLowerCase() === t.toLowerCase() : e === t;
189
+ }
190
+ function Ge(e, t) {
191
+ if (t)
192
+ return e.find(
193
+ (n) => n.chainId === t.chainId && Et(n.contractAddress, t.address)
194
+ );
195
+ }
196
+ function Lt(e) {
197
+ const [t, n] = B([]), [r, s] = B(null), [l, i] = B(
198
+ null
199
+ ), [u, p] = B(!0), [g, C] = B(null), [I, k] = B(), [m, y] = B(), [v, $] = B(), [D, T] = B(), O = X(""), K = X(""), q = X(""), L = X(""), c = X(/* @__PURE__ */ new Set()), h = !!(e.lockSellNetwork || e.lockSellToken), b = !!(e.lockBuyNetwork || e.lockBuyToken), N = ue(
200
+ () => {
201
+ var w;
202
+ return e.initialSellNetworkId ?? ((w = e.initialSellToken) == null ? void 0 : w.chainId);
203
+ },
204
+ [e.initialSellNetworkId, e.initialSellToken]
205
+ ), o = ue(
206
+ () => {
207
+ var w;
208
+ return e.initialBuyNetworkId ?? ((w = e.initialBuyToken) == null ? void 0 : w.chainId);
209
+ },
210
+ [e.initialBuyNetworkId, e.initialBuyToken]
211
+ );
212
+ re(() => {
213
+ let w = !1;
214
+ return p(!0), C(null), Promise.all([Bt(e.apiBase), Ut(e.apiBase)]).then(([a, S]) => {
215
+ w || (n(a), s(S), i(S), a.length >= 2 ? (k(a[0]), y(a[1])) : a.length === 1 && (k(a[0]), y(a[0])));
216
+ }).catch((a) => {
217
+ var W;
218
+ if (w) return;
219
+ const S = (a == null ? void 0 : a.message) ?? "Failed to load data";
220
+ C(S), (W = e.onError) == null || W.call(e, {
221
+ source: "metadata",
222
+ message: S,
223
+ status: a == null ? void 0 : a.status,
224
+ statusCode: a == null ? void 0 : a.statusCode,
225
+ error: a
226
+ });
171
227
  }).finally(() => {
172
- c || h(!1);
228
+ w || p(!1);
173
229
  }), () => {
174
- c = !0;
230
+ w = !0;
175
231
  };
176
- }, [t.dataBaseUrl]), oe(() => {
177
- if (!x || !r) return;
178
- const c = ae(r, x.id);
179
- (c.length && !o || o && !c.some((f) => f.contractAddress === o.contractAddress && f.chainId === o.chainId)) && R(c[0]);
180
- }, [x, r, o]), oe(() => {
181
- if (!u || !r) return;
182
- const c = ae(r, u.id);
183
- if (c.length && !M) {
184
- const f = o ? c.find((C) => !(C.contractAddress === o.contractAddress && C.chainId === o.chainId)) : void 0;
185
- V(f ?? c[0]);
186
- } else if (M && !c.some((f) => f.contractAddress === M.contractAddress && f.chainId === M.chainId)) {
187
- const f = o ? c.find((C) => !(C.contractAddress === o.contractAddress && C.chainId === o.chainId)) : void 0;
188
- V(f ?? c[0]);
232
+ }, [e.apiBase, e.onError]), re(() => {
233
+ if (!t.length || !N) return;
234
+ const w = String(N);
235
+ if (O.current === w) return;
236
+ const a = t.find((S) => S.id === N);
237
+ a && (k(a), O.current = w);
238
+ }, [N, t]), re(() => {
239
+ if (!t.length || !o) return;
240
+ const w = String(o);
241
+ if (K.current === w) return;
242
+ const a = t.find((S) => S.id === o);
243
+ a && (y(a), K.current = w);
244
+ }, [o, t]), re(() => {
245
+ var W;
246
+ if (!I || !r) return;
247
+ const w = ke(r, I.id), a = e.initialSellToken ? `${e.initialSellToken.chainId}:${e.initialSellToken.address}` : "", S = Ge(w, e.initialSellToken);
248
+ if (S && q.current !== a) {
249
+ $(S), q.current = a;
250
+ return;
251
+ }
252
+ e.initialSellToken && !S && !c.current.has(`sell:${a}`) && (c.current.add(`sell:${a}`), (W = e.onError) == null || W.call(e, {
253
+ source: "selection",
254
+ message: `Initial sell token ${e.initialSellToken.address} was not found on chain ${e.initialSellToken.chainId}`
255
+ })), (w.length && !v || v && !w.some(
256
+ (Q) => Q.contractAddress === v.contractAddress && Q.chainId === v.chainId
257
+ )) && $(w[0]);
258
+ }, [e.initialSellToken, e.onError, I, v, r]), re(() => {
259
+ var W;
260
+ if (!m || !r) return;
261
+ const w = ke(r, m.id), a = e.initialBuyToken ? `${e.initialBuyToken.chainId}:${e.initialBuyToken.address}` : "", S = Ge(w, e.initialBuyToken);
262
+ if (S && L.current !== a) {
263
+ T(S), L.current = a;
264
+ return;
265
+ }
266
+ if (e.initialBuyToken && !S && !c.current.has(`buy:${a}`) && (c.current.add(`buy:${a}`), (W = e.onError) == null || W.call(e, {
267
+ source: "selection",
268
+ message: `Initial buy token ${e.initialBuyToken.address} was not found on chain ${e.initialBuyToken.chainId}`
269
+ })), w.length && !D) {
270
+ const Q = v ? w.find(
271
+ (z) => !(z.contractAddress === v.contractAddress && z.chainId === v.chainId)
272
+ ) : void 0;
273
+ T(Q ?? w[0]);
274
+ } else if (D && !w.some(
275
+ (Q) => Q.contractAddress === D.contractAddress && Q.chainId === D.chainId
276
+ )) {
277
+ const Q = v ? w.find(
278
+ (z) => !(z.contractAddress === v.contractAddress && z.chainId === v.chainId)
279
+ ) : void 0;
280
+ T(Q ?? w[0]);
189
281
  }
190
- }, [u, r, M, o]);
191
- const L = D(
192
- (c) => r ? ae(r, c) : [],
282
+ }, [D, e.initialBuyToken, e.onError, m, v, r]);
283
+ const E = M(
284
+ (w) => r ? ke(r, w) : [],
193
285
  [r]
194
- ), $ = D(
195
- (c) => a ? yt(a, c) : ae(r ?? { tokensEVM: {}, tokensSVM: {}, tokensMVM: {} }, c),
196
- [a, r]
197
- ), j = D(
198
- (c) => {
199
- const f = ae(r ?? { tokensEVM: {}, tokensSVM: {}, tokensMVM: {} }, c);
200
- return Nt(f);
286
+ ), V = M(
287
+ (w) => l ? Ft(l, w) : ke(r ?? { byChainId: {} }, w),
288
+ [l, r]
289
+ ), J = M(
290
+ (w) => {
291
+ const a = ke(r ?? { byChainId: {} }, w);
292
+ return Rt(a);
201
293
  },
202
294
  [r]
203
- ), l = D(
204
- (c) => e.find((f) => f.id === c),
205
- [e]
206
- ), S = D((c) => {
207
- const f = e.find((C) => C.id === c);
208
- f && m(f);
209
- }, [e]), g = D((c) => {
210
- const f = e.find((C) => C.id === c);
211
- f && k(f);
212
- }, [e]), y = D((c) => {
213
- k(c);
214
- }, []);
295
+ ), G = M(
296
+ (w) => t.find((a) => a.id === w),
297
+ [t]
298
+ ), ie = M(
299
+ (w) => {
300
+ if (h) return;
301
+ const a = t.find((S) => S.id === w);
302
+ a && k(a);
303
+ },
304
+ [t, h]
305
+ ), fe = M(
306
+ (w) => {
307
+ if (b) return;
308
+ const a = t.find((S) => S.id === w);
309
+ a && y(a);
310
+ },
311
+ [b, t]
312
+ ), ee = M(
313
+ (w) => {
314
+ h || k(w);
315
+ },
316
+ [h]
317
+ ), ce = M(
318
+ (w) => {
319
+ b || y(w);
320
+ },
321
+ [b]
322
+ ), de = M(
323
+ (w) => {
324
+ e.lockSellToken || $(w);
325
+ },
326
+ [e.lockSellToken]
327
+ ), oe = M(
328
+ (w) => {
329
+ e.lockBuyToken || T(w);
330
+ },
331
+ [e.lockBuyToken]
332
+ );
215
333
  return {
216
- networks: e,
217
- networkSell: x,
218
- networkBuy: u,
219
- sellToken: o,
220
- buyToken: M,
221
- setSellToken: R,
222
- setBuyToken: V,
223
- setNetworkSell: (c) => m(c),
224
- setNetworkBuy: y,
225
- updateNetworkSell: S,
226
- updateNetworkBuy: g,
227
- getTokensForNetworkId: L,
228
- getAllTokensForNetworkId: $,
229
- getNativeToken: j,
230
- getNetworkById: l,
231
- loading: w,
232
- error: p
334
+ networks: t,
335
+ networkSell: I,
336
+ networkBuy: m,
337
+ sellToken: v,
338
+ buyToken: D,
339
+ setSellToken: de,
340
+ setBuyToken: oe,
341
+ setNetworkSell: ee,
342
+ setNetworkBuy: ce,
343
+ updateNetworkSell: ie,
344
+ updateNetworkBuy: fe,
345
+ getTokensForNetworkId: E,
346
+ getAllTokensForNetworkId: V,
347
+ getNativeToken: J,
348
+ getNetworkById: G,
349
+ sellNetworkLocked: h,
350
+ buyNetworkLocked: b,
351
+ loading: u,
352
+ error: g
233
353
  };
234
354
  }
235
- const Ct = "6.16.0";
236
- function Re(t, e, n) {
237
- for (let r in e) {
238
- let s = e[r];
239
- Object.defineProperty(t, r, { enumerable: !0, value: s, writable: !1 });
355
+ const Mt = "6.16.0";
356
+ function Pe(e, t, n) {
357
+ for (let r in t) {
358
+ let s = t[r];
359
+ Object.defineProperty(e, r, { enumerable: !0, value: s, writable: !1 });
240
360
  }
241
361
  }
242
- function le(t, e) {
243
- if (t == null)
362
+ function be(e, t) {
363
+ if (e == null)
244
364
  return "null";
245
- if (e == null && (e = /* @__PURE__ */ new Set()), typeof t == "object") {
246
- if (e.has(t))
365
+ if (t == null && (t = /* @__PURE__ */ new Set()), typeof e == "object") {
366
+ if (t.has(e))
247
367
  return "[Circular]";
248
- e.add(t);
368
+ t.add(e);
249
369
  }
250
- if (Array.isArray(t))
251
- return "[ " + t.map((n) => le(n, e)).join(", ") + " ]";
252
- if (t instanceof Uint8Array) {
370
+ if (Array.isArray(e))
371
+ return "[ " + e.map((n) => be(n, t)).join(", ") + " ]";
372
+ if (e instanceof Uint8Array) {
253
373
  const n = "0123456789abcdef";
254
374
  let r = "0x";
255
- for (let s = 0; s < t.length; s++)
256
- r += n[t[s] >> 4], r += n[t[s] & 15];
375
+ for (let s = 0; s < e.length; s++)
376
+ r += n[e[s] >> 4], r += n[e[s] & 15];
257
377
  return r;
258
378
  }
259
- if (typeof t == "object" && typeof t.toJSON == "function")
260
- return le(t.toJSON(), e);
261
- switch (typeof t) {
379
+ if (typeof e == "object" && typeof e.toJSON == "function")
380
+ return be(e.toJSON(), t);
381
+ switch (typeof e) {
262
382
  case "boolean":
263
383
  case "number":
264
384
  case "symbol":
265
- return t.toString();
385
+ return e.toString();
266
386
  case "bigint":
267
- return BigInt(t).toString();
387
+ return BigInt(e).toString();
268
388
  case "string":
269
- return JSON.stringify(t);
389
+ return JSON.stringify(e);
270
390
  case "object": {
271
- const n = Object.keys(t);
272
- return n.sort(), "{ " + n.map((r) => `${le(r, e)}: ${le(t[r], e)}`).join(", ") + " }";
391
+ const n = Object.keys(e);
392
+ return n.sort(), "{ " + n.map((r) => `${be(r, t)}: ${be(e[r], t)}`).join(", ") + " }";
273
393
  }
274
394
  }
275
395
  return "[ COULD NOT SERIALIZE ]";
276
396
  }
277
- function It(t, e, n) {
278
- let r = t;
397
+ function $t(e, t, n) {
398
+ let r = e;
279
399
  {
280
- const a = [];
400
+ const l = [];
281
401
  if (n) {
282
402
  if ("message" in n || "code" in n || "name" in n)
283
- throw new Error(`value will overwrite populated values: ${le(n)}`);
403
+ throw new Error(`value will overwrite populated values: ${be(n)}`);
284
404
  for (const i in n) {
285
405
  if (i === "shortMessage")
286
406
  continue;
287
- const w = n[i];
288
- a.push(i + "=" + le(w));
407
+ const u = n[i];
408
+ l.push(i + "=" + be(u));
289
409
  }
290
410
  }
291
- a.push(`code=${e}`), a.push(`version=${Ct}`), a.length && (t += " (" + a.join(", ") + ")");
411
+ l.push(`code=${t}`), l.push(`version=${Mt}`), l.length && (e += " (" + l.join(", ") + ")");
292
412
  }
293
413
  let s;
294
- switch (e) {
414
+ switch (t) {
295
415
  case "INVALID_ARGUMENT":
296
- s = new TypeError(t);
416
+ s = new TypeError(e);
297
417
  break;
298
418
  case "NUMERIC_FAULT":
299
419
  case "BUFFER_OVERRUN":
300
- s = new RangeError(t);
420
+ s = new RangeError(e);
301
421
  break;
302
422
  default:
303
- s = new Error(t);
423
+ s = new Error(e);
304
424
  }
305
- return Re(s, { code: e }), n && Object.assign(s, n), s.shortMessage == null && Re(s, { shortMessage: r }), s;
425
+ return Pe(s, { code: t }), n && Object.assign(s, n), s.shortMessage == null && Pe(s, { shortMessage: r }), s;
306
426
  }
307
- function Y(t, e, n, r) {
308
- if (!t)
309
- throw It(e, n, r);
427
+ function Z(e, t, n, r) {
428
+ if (!e)
429
+ throw $t(t, n, r);
310
430
  }
311
- function P(t, e, n, r) {
312
- Y(t, e, "INVALID_ARGUMENT", { argument: n, value: r });
431
+ function H(e, t, n, r) {
432
+ Z(e, t, "INVALID_ARGUMENT", { argument: n, value: r });
313
433
  }
314
- ["NFD", "NFC", "NFKD", "NFKC"].reduce((t, e) => {
434
+ ["NFD", "NFC", "NFKD", "NFKC"].reduce((e, t) => {
315
435
  try {
316
- if ("test".normalize(e) !== "test")
436
+ if ("test".normalize(t) !== "test")
317
437
  throw new Error("bad");
318
- if (e === "NFD" && "é".normalize("NFD") !== "é")
438
+ if (t === "NFD" && "é".normalize("NFD") !== "é")
319
439
  throw new Error("broken");
320
- t.push(e);
440
+ e.push(t);
321
441
  } catch {
322
442
  }
323
- return t;
443
+ return e;
324
444
  }, []);
325
- function Bt(t, e, n) {
326
- if (t !== e) {
445
+ function Dt(e, t, n) {
446
+ if (e !== t) {
327
447
  let r = n, s = "new";
328
- r += ".", s += " " + n, Y(!1, `private constructor; use ${r}from* methods`, "UNSUPPORTED_OPERATION", {
448
+ r += ".", s += " " + n, Z(!1, `private constructor; use ${r}from* methods`, "UNSUPPORTED_OPERATION", {
329
449
  operation: s
330
450
  });
331
451
  }
332
452
  }
333
- function Tt(t, e, n) {
334
- if (t instanceof Uint8Array)
335
- return t;
336
- if (typeof t == "string" && t.length % 2 === 0 && t.match(/^0x[0-9a-f]*$/i)) {
337
- const r = new Uint8Array((t.length - 2) / 2);
453
+ function Ot(e, t, n) {
454
+ if (e instanceof Uint8Array)
455
+ return e;
456
+ if (typeof e == "string" && e.length % 2 === 0 && e.match(/^0x[0-9a-f]*$/i)) {
457
+ const r = new Uint8Array((e.length - 2) / 2);
338
458
  let s = 2;
339
- for (let a = 0; a < r.length; a++)
340
- r[a] = parseInt(t.substring(s, s + 2), 16), s += 2;
459
+ for (let l = 0; l < r.length; l++)
460
+ r[l] = parseInt(e.substring(s, s + 2), 16), s += 2;
341
461
  return r;
342
462
  }
343
- P(!1, "invalid BytesLike value", e, t);
463
+ H(!1, "invalid BytesLike value", t, e);
344
464
  }
345
- function Ut(t, e) {
346
- return Tt(t, e);
465
+ function Pt(e, t) {
466
+ return Ot(e, t);
347
467
  }
348
- const nt = BigInt(0), ce = BigInt(1), we = 9007199254740991;
349
- function Ee(t, e) {
350
- const n = rt(t, "value"), r = BigInt(Ae(e, "width"));
351
- if (Y(n >> r === nt, "overflow", "NUMERIC_FAULT", {
468
+ const ut = BigInt(0), xe = BigInt(1), ye = 9007199254740991;
469
+ function je(e, t) {
470
+ const n = ft(e, "value"), r = BigInt(Ie(t, "width"));
471
+ if (Z(n >> r === ut, "overflow", "NUMERIC_FAULT", {
352
472
  operation: "fromTwos",
353
473
  fault: "overflow",
354
- value: t
355
- }), n >> r - ce) {
356
- const s = (ce << r) - ce;
357
- return -((~n & s) + ce);
474
+ value: e
475
+ }), n >> r - xe) {
476
+ const s = (xe << r) - xe;
477
+ return -((~n & s) + xe);
358
478
  }
359
479
  return n;
360
480
  }
361
- function Ye(t, e) {
362
- const n = rt(t, "value"), r = BigInt(Ae(e, "bits"));
363
- return n & (ce << r) - ce;
481
+ function _e(e, t) {
482
+ const n = ft(e, "value"), r = BigInt(Ie(t, "bits"));
483
+ return n & (xe << r) - xe;
364
484
  }
365
- function Pe(t, e) {
366
- switch (typeof t) {
485
+ function Ke(e, t) {
486
+ switch (typeof e) {
367
487
  case "bigint":
368
- return t;
488
+ return e;
369
489
  case "number":
370
- return P(Number.isInteger(t), "underflow", e || "value", t), P(t >= -we && t <= we, "overflow", e || "value", t), BigInt(t);
490
+ return H(Number.isInteger(e), "underflow", t || "value", e), H(e >= -ye && e <= ye, "overflow", t || "value", e), BigInt(e);
371
491
  case "string":
372
492
  try {
373
- if (t === "")
493
+ if (e === "")
374
494
  throw new Error("empty string");
375
- return t[0] === "-" && t[1] !== "-" ? -BigInt(t.substring(1)) : BigInt(t);
495
+ return e[0] === "-" && e[1] !== "-" ? -BigInt(e.substring(1)) : BigInt(e);
376
496
  } catch (n) {
377
- P(!1, `invalid BigNumberish string: ${n.message}`, e || "value", t);
497
+ H(!1, `invalid BigNumberish string: ${n.message}`, t || "value", e);
378
498
  }
379
499
  }
380
- P(!1, "invalid BigNumberish value", e || "value", t);
500
+ H(!1, "invalid BigNumberish value", t || "value", e);
381
501
  }
382
- function rt(t, e) {
383
- const n = Pe(t, e);
384
- return Y(n >= nt, "unsigned value cannot be negative", "NUMERIC_FAULT", {
502
+ function ft(e, t) {
503
+ const n = Ke(e, t);
504
+ return Z(n >= ut, "unsigned value cannot be negative", "NUMERIC_FAULT", {
385
505
  fault: "overflow",
386
506
  operation: "getUint",
387
- value: t
507
+ value: e
388
508
  }), n;
389
509
  }
390
- const Ke = "0123456789abcdef";
391
- function Ft(t) {
392
- if (t instanceof Uint8Array) {
393
- let e = "0x0";
394
- for (const n of t)
395
- e += Ke[n >> 4], e += Ke[n & 15];
396
- return BigInt(e);
510
+ const Xe = "0123456789abcdef";
511
+ function jt(e) {
512
+ if (e instanceof Uint8Array) {
513
+ let t = "0x0";
514
+ for (const n of e)
515
+ t += Xe[n >> 4], t += Xe[n & 15];
516
+ return BigInt(t);
397
517
  }
398
- return Pe(t);
518
+ return Ke(e);
399
519
  }
400
- function Ae(t, e) {
401
- switch (typeof t) {
520
+ function Ie(e, t) {
521
+ switch (typeof e) {
402
522
  case "bigint":
403
- return P(t >= -we && t <= we, "overflow", e || "value", t), Number(t);
523
+ return H(e >= -ye && e <= ye, "overflow", t || "value", e), Number(e);
404
524
  case "number":
405
- return P(Number.isInteger(t), "underflow", e || "value", t), P(t >= -we && t <= we, "overflow", e || "value", t), t;
525
+ return H(Number.isInteger(e), "underflow", t || "value", e), H(e >= -ye && e <= ye, "overflow", t || "value", e), e;
406
526
  case "string":
407
527
  try {
408
- if (t === "")
528
+ if (e === "")
409
529
  throw new Error("empty string");
410
- return Ae(BigInt(t), e);
530
+ return Ie(BigInt(e), t);
411
531
  } catch (n) {
412
- P(!1, `invalid numeric string: ${n.message}`, e || "value", t);
532
+ H(!1, `invalid numeric string: ${n.message}`, t || "value", e);
413
533
  }
414
534
  }
415
- P(!1, "invalid numeric value", e || "value", t);
535
+ H(!1, "invalid numeric value", t || "value", e);
416
536
  }
417
- const Mt = BigInt(-1), z = BigInt(0), ue = BigInt(1), Rt = BigInt(5), de = {};
418
- let fe = "0000";
419
- for (; fe.length < 80; )
420
- fe += fe;
421
- function te(t) {
422
- let e = fe;
423
- for (; e.length < t; )
424
- e += e;
425
- return BigInt("1" + e.substring(0, t));
537
+ const Vt = BigInt(-1), te = BigInt(0), Ae = BigInt(1), Wt = BigInt(5), ge = {};
538
+ let ve = "0000";
539
+ for (; ve.length < 80; )
540
+ ve += ve;
541
+ function pe(e) {
542
+ let t = ve;
543
+ for (; t.length < e; )
544
+ t += t;
545
+ return BigInt("1" + t.substring(0, e));
426
546
  }
427
- function be(t, e, n) {
428
- const r = BigInt(e.width);
429
- if (e.signed) {
430
- const s = ue << r - ue;
431
- Y(n == null || t >= -s && t < s, "overflow", "NUMERIC_FAULT", {
547
+ function Se(e, t, n) {
548
+ const r = BigInt(t.width);
549
+ if (t.signed) {
550
+ const s = Ae << r - Ae;
551
+ Z(n == null || e >= -s && e < s, "overflow", "NUMERIC_FAULT", {
432
552
  operation: n,
433
553
  fault: "overflow",
434
- value: t
435
- }), t > z ? t = Ee(Ye(t, r), r) : t = -Ee(Ye(-t, r), r);
554
+ value: e
555
+ }), e > te ? e = je(_e(e, r), r) : e = -je(_e(-e, r), r);
436
556
  } else {
437
- const s = ue << r;
438
- Y(n == null || t >= 0 && t < s, "overflow", "NUMERIC_FAULT", {
557
+ const s = Ae << r;
558
+ Z(n == null || e >= 0 && e < s, "overflow", "NUMERIC_FAULT", {
439
559
  operation: n,
440
560
  fault: "overflow",
441
- value: t
442
- }), t = (t % s + s) % s & s - ue;
561
+ value: e
562
+ }), e = (e % s + s) % s & s - Ae;
443
563
  }
444
- return t;
564
+ return e;
445
565
  }
446
- function Ie(t) {
447
- typeof t == "number" && (t = `fixed128x${t}`);
448
- let e = !0, n = 128, r = 18;
449
- if (typeof t == "string") {
450
- if (t !== "fixed") if (t === "ufixed")
451
- e = !1;
566
+ function Ee(e) {
567
+ typeof e == "number" && (e = `fixed128x${e}`);
568
+ let t = !0, n = 128, r = 18;
569
+ if (typeof e == "string") {
570
+ if (e !== "fixed") if (e === "ufixed")
571
+ t = !1;
452
572
  else {
453
- const a = t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
454
- P(a, "invalid fixed format", "format", t), e = a[1] !== "u", n = parseInt(a[2]), r = parseInt(a[3]);
573
+ const l = e.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
574
+ H(l, "invalid fixed format", "format", e), t = l[1] !== "u", n = parseInt(l[2]), r = parseInt(l[3]);
455
575
  }
456
- } else if (t) {
457
- const a = t, i = (w, h, p) => a[w] == null ? p : (P(typeof a[w] === h, "invalid fixed format (" + w + " not " + h + ")", "format." + w, a[w]), a[w]);
458
- e = i("signed", "boolean", e), n = i("width", "number", n), r = i("decimals", "number", r);
576
+ } else if (e) {
577
+ const l = e, i = (u, p, g) => l[u] == null ? g : (H(typeof l[u] === p, "invalid fixed format (" + u + " not " + p + ")", "format." + u, l[u]), l[u]);
578
+ t = i("signed", "boolean", t), n = i("width", "number", n), r = i("decimals", "number", r);
459
579
  }
460
- P(n % 8 === 0, "invalid FixedNumber width (not byte aligned)", "format.width", n), P(r <= 80, "invalid FixedNumber decimals (too large)", "format.decimals", r);
461
- const s = (e ? "" : "u") + "fixed" + String(n) + "x" + String(r);
462
- return { signed: e, width: n, decimals: r, name: s };
580
+ H(n % 8 === 0, "invalid FixedNumber width (not byte aligned)", "format.width", n), H(r <= 80, "invalid FixedNumber decimals (too large)", "format.decimals", r);
581
+ const s = (t ? "" : "u") + "fixed" + String(n) + "x" + String(r);
582
+ return { signed: t, width: n, decimals: r, name: s };
463
583
  }
464
- function Et(t, e) {
584
+ function Qt(e, t) {
465
585
  let n = "";
466
- t < z && (n = "-", t *= Mt);
467
- let r = t.toString();
468
- if (e === 0)
586
+ e < te && (n = "-", e *= Vt);
587
+ let r = e.toString();
588
+ if (t === 0)
469
589
  return n + r;
470
- for (; r.length <= e; )
471
- r = fe + r;
472
- const s = r.length - e;
590
+ for (; r.length <= t; )
591
+ r = ve + r;
592
+ const s = r.length - t;
473
593
  for (r = r.substring(0, s) + "." + r.substring(s); r[0] === "0" && r[1] !== "."; )
474
594
  r = r.substring(1);
475
595
  for (; r[r.length - 1] === "0" && r[r.length - 2] !== "."; )
476
596
  r = r.substring(0, r.length - 1);
477
597
  return n + r;
478
598
  }
479
- var q, F, Q, B, ne, _, De, Ve, je, Oe;
480
- const Z = class Z {
599
+ var ne, R, Y, U, he, ae, We, Qe, qe, He;
600
+ const we = class we {
481
601
  // Use this when changing this file to get some typing info,
482
602
  // but then switch to any to mask the internal type
483
603
  //constructor(guard: any, value: bigint, format: _FixedFormat) {
484
604
  /**
485
605
  * @private
486
606
  */
487
- constructor(e, n, r) {
488
- ge(this, B);
607
+ constructor(t, n, r) {
608
+ Ne(this, U);
489
609
  /**
490
610
  * The specific fixed-point arithmetic field for this value.
491
611
  */
492
- Se(this, "format");
493
- ge(this, q);
612
+ Fe(this, "format");
613
+ Ne(this, ne);
494
614
  // The actual value (accounting for decimals)
495
- ge(this, F);
615
+ Ne(this, R);
496
616
  // A base-10 value to multiple values by to maintain the magnitude
497
- ge(this, Q);
617
+ Ne(this, Y);
498
618
  /**
499
619
  * This is a property so console.log shows a human-meaningful value.
500
620
  *
501
621
  * @private
502
622
  */
503
- Se(this, "_value");
504
- Bt(e, de, "FixedNumber"), ke(this, F, n), ke(this, q, r);
505
- const s = Et(n, r.decimals);
506
- Re(this, { format: r.name, _value: s }), ke(this, Q, te(r.decimals));
623
+ Fe(this, "_value");
624
+ Dt(t, ge, "FixedNumber"), Te(this, R, n), Te(this, ne, r);
625
+ const s = Qt(n, r.decimals);
626
+ Pe(this, { format: r.name, _value: s }), Te(this, Y, pe(r.decimals));
507
627
  }
508
628
  /**
509
629
  * If true, negative values are permitted, otherwise only
510
630
  * positive values and zero are allowed.
511
631
  */
512
632
  get signed() {
513
- return b(this, q).signed;
633
+ return x(this, ne).signed;
514
634
  }
515
635
  /**
516
636
  * The number of bits available to store the value.
517
637
  */
518
638
  get width() {
519
- return b(this, q).width;
639
+ return x(this, ne).width;
520
640
  }
521
641
  /**
522
642
  * The number of decimal places in the fixed-point arithment field.
523
643
  */
524
644
  get decimals() {
525
- return b(this, q).decimals;
645
+ return x(this, ne).decimals;
526
646
  }
527
647
  /**
528
648
  * The value as an integer, based on the smallest unit the
529
649
  * [[decimals]] allow.
530
650
  */
531
651
  get value() {
532
- return b(this, F);
652
+ return x(this, R);
533
653
  }
534
654
  /**
535
655
  * Returns a new [[FixedNumber]] with the result of %%this%% added
536
656
  * to %%other%%, ignoring overflow.
537
657
  */
538
- addUnsafe(e) {
539
- return E(this, B, De).call(this, e);
658
+ addUnsafe(t) {
659
+ return j(this, U, We).call(this, t);
540
660
  }
541
661
  /**
542
662
  * Returns a new [[FixedNumber]] with the result of %%this%% added
543
663
  * to %%other%%. A [[NumericFaultError]] is thrown if overflow
544
664
  * occurs.
545
665
  */
546
- add(e) {
547
- return E(this, B, De).call(this, e, "add");
666
+ add(t) {
667
+ return j(this, U, We).call(this, t, "add");
548
668
  }
549
669
  /**
550
670
  * Returns a new [[FixedNumber]] with the result of %%other%% subtracted
551
671
  * from %%this%%, ignoring overflow.
552
672
  */
553
- subUnsafe(e) {
554
- return E(this, B, Ve).call(this, e);
673
+ subUnsafe(t) {
674
+ return j(this, U, Qe).call(this, t);
555
675
  }
556
676
  /**
557
677
  * Returns a new [[FixedNumber]] with the result of %%other%% subtracted
558
678
  * from %%this%%. A [[NumericFaultError]] is thrown if overflow
559
679
  * occurs.
560
680
  */
561
- sub(e) {
562
- return E(this, B, Ve).call(this, e, "sub");
681
+ sub(t) {
682
+ return j(this, U, Qe).call(this, t, "sub");
563
683
  }
564
684
  /**
565
685
  * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
566
686
  * by %%other%%, ignoring overflow and underflow (precision loss).
567
687
  */
568
- mulUnsafe(e) {
569
- return E(this, B, je).call(this, e);
688
+ mulUnsafe(t) {
689
+ return j(this, U, qe).call(this, t);
570
690
  }
571
691
  /**
572
692
  * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
573
693
  * by %%other%%. A [[NumericFaultError]] is thrown if overflow
574
694
  * occurs.
575
695
  */
576
- mul(e) {
577
- return E(this, B, je).call(this, e, "mul");
696
+ mul(t) {
697
+ return j(this, U, qe).call(this, t, "mul");
578
698
  }
579
699
  /**
580
700
  * Returns a new [[FixedNumber]] with the result of %%this%% multiplied
581
701
  * by %%other%%. A [[NumericFaultError]] is thrown if overflow
582
702
  * occurs or if underflow (precision loss) occurs.
583
703
  */
584
- mulSignal(e) {
585
- E(this, B, ne).call(this, e);
586
- const n = b(this, F) * b(e, F);
587
- return Y(n % b(this, Q) === z, "precision lost during signalling mul", "NUMERIC_FAULT", {
704
+ mulSignal(t) {
705
+ j(this, U, he).call(this, t);
706
+ const n = x(this, R) * x(t, R);
707
+ return Z(n % x(this, Y) === te, "precision lost during signalling mul", "NUMERIC_FAULT", {
588
708
  operation: "mulSignal",
589
709
  fault: "underflow",
590
710
  value: this
591
- }), E(this, B, _).call(this, n / b(this, Q), "mulSignal");
711
+ }), j(this, U, ae).call(this, n / x(this, Y), "mulSignal");
592
712
  }
593
713
  /**
594
714
  * Returns a new [[FixedNumber]] with the result of %%this%% divided
595
715
  * by %%other%%, ignoring underflow (precision loss). A
596
716
  * [[NumericFaultError]] is thrown if overflow occurs.
597
717
  */
598
- divUnsafe(e) {
599
- return E(this, B, Oe).call(this, e);
718
+ divUnsafe(t) {
719
+ return j(this, U, He).call(this, t);
600
720
  }
601
721
  /**
602
722
  * Returns a new [[FixedNumber]] with the result of %%this%% divided
603
723
  * by %%other%%, ignoring underflow (precision loss). A
604
724
  * [[NumericFaultError]] is thrown if overflow occurs.
605
725
  */
606
- div(e) {
607
- return E(this, B, Oe).call(this, e, "div");
726
+ div(t) {
727
+ return j(this, U, He).call(this, t, "div");
608
728
  }
609
729
  /**
610
730
  * Returns a new [[FixedNumber]] with the result of %%this%% divided
611
731
  * by %%other%%. A [[NumericFaultError]] is thrown if underflow
612
732
  * (precision loss) occurs.
613
733
  */
614
- divSignal(e) {
615
- Y(b(e, F) !== z, "division by zero", "NUMERIC_FAULT", {
734
+ divSignal(t) {
735
+ Z(x(t, R) !== te, "division by zero", "NUMERIC_FAULT", {
616
736
  operation: "div",
617
737
  fault: "divide-by-zero",
618
738
  value: this
619
- }), E(this, B, ne).call(this, e);
620
- const n = b(this, F) * b(this, Q);
621
- return Y(n % b(e, F) === z, "precision lost during signalling div", "NUMERIC_FAULT", {
739
+ }), j(this, U, he).call(this, t);
740
+ const n = x(this, R) * x(this, Y);
741
+ return Z(n % x(t, R) === te, "precision lost during signalling div", "NUMERIC_FAULT", {
622
742
  operation: "divSignal",
623
743
  fault: "underflow",
624
744
  value: this
625
- }), E(this, B, _).call(this, n / b(e, F), "divSignal");
745
+ }), j(this, U, ae).call(this, n / x(t, R), "divSignal");
626
746
  }
627
747
  /**
628
748
  * Returns a comparison result between %%this%% and %%other%%.
@@ -631,40 +751,40 @@ const Z = class Z {
631
751
  * is smaller, ``1`` implies %%this%% is larger and ``0`` implies
632
752
  * both are equal.
633
753
  */
634
- cmp(e) {
635
- let n = this.value, r = e.value;
636
- const s = this.decimals - e.decimals;
637
- return s > 0 ? r *= te(s) : s < 0 && (n *= te(-s)), n < r ? -1 : n > r ? 1 : 0;
754
+ cmp(t) {
755
+ let n = this.value, r = t.value;
756
+ const s = this.decimals - t.decimals;
757
+ return s > 0 ? r *= pe(s) : s < 0 && (n *= pe(-s)), n < r ? -1 : n > r ? 1 : 0;
638
758
  }
639
759
  /**
640
760
  * Returns true if %%other%% is equal to %%this%%.
641
761
  */
642
- eq(e) {
643
- return this.cmp(e) === 0;
762
+ eq(t) {
763
+ return this.cmp(t) === 0;
644
764
  }
645
765
  /**
646
766
  * Returns true if %%other%% is less than to %%this%%.
647
767
  */
648
- lt(e) {
649
- return this.cmp(e) < 0;
768
+ lt(t) {
769
+ return this.cmp(t) < 0;
650
770
  }
651
771
  /**
652
772
  * Returns true if %%other%% is less than or equal to %%this%%.
653
773
  */
654
- lte(e) {
655
- return this.cmp(e) <= 0;
774
+ lte(t) {
775
+ return this.cmp(t) <= 0;
656
776
  }
657
777
  /**
658
778
  * Returns true if %%other%% is greater than to %%this%%.
659
779
  */
660
- gt(e) {
661
- return this.cmp(e) > 0;
780
+ gt(t) {
781
+ return this.cmp(t) > 0;
662
782
  }
663
783
  /**
664
784
  * Returns true if %%other%% is greater than or equal to %%this%%.
665
785
  */
666
- gte(e) {
667
- return this.cmp(e) >= 0;
786
+ gte(t) {
787
+ return this.cmp(t) >= 0;
668
788
  }
669
789
  /**
670
790
  * Returns a new [[FixedNumber]] which is the largest **integer**
@@ -673,8 +793,8 @@ const Z = class Z {
673
793
  * The decimal component of the result will always be ``0``.
674
794
  */
675
795
  floor() {
676
- let e = b(this, F);
677
- return b(this, F) < z && (e -= b(this, Q) - ue), e = b(this, F) / b(this, Q) * b(this, Q), E(this, B, _).call(this, e, "floor");
796
+ let t = x(this, R);
797
+ return x(this, R) < te && (t -= x(this, Y) - Ae), t = x(this, R) / x(this, Y) * x(this, Y), j(this, U, ae).call(this, t, "floor");
678
798
  }
679
799
  /**
680
800
  * Returns a new [[FixedNumber]] which is the smallest **integer**
@@ -683,32 +803,32 @@ const Z = class Z {
683
803
  * The decimal component of the result will always be ``0``.
684
804
  */
685
805
  ceiling() {
686
- let e = b(this, F);
687
- return b(this, F) > z && (e += b(this, Q) - ue), e = b(this, F) / b(this, Q) * b(this, Q), E(this, B, _).call(this, e, "ceiling");
806
+ let t = x(this, R);
807
+ return x(this, R) > te && (t += x(this, Y) - Ae), t = x(this, R) / x(this, Y) * x(this, Y), j(this, U, ae).call(this, t, "ceiling");
688
808
  }
689
809
  /**
690
810
  * Returns a new [[FixedNumber]] with the decimal component
691
811
  * rounded up on ties at %%decimals%% places.
692
812
  */
693
- round(e) {
694
- if (e == null && (e = 0), e >= this.decimals)
813
+ round(t) {
814
+ if (t == null && (t = 0), t >= this.decimals)
695
815
  return this;
696
- const n = this.decimals - e, r = Rt * te(n - 1);
816
+ const n = this.decimals - t, r = Wt * pe(n - 1);
697
817
  let s = this.value + r;
698
- const a = te(n);
699
- return s = s / a * a, be(s, b(this, q), "round"), new Z(de, s, b(this, q));
818
+ const l = pe(n);
819
+ return s = s / l * l, Se(s, x(this, ne), "round"), new we(ge, s, x(this, ne));
700
820
  }
701
821
  /**
702
822
  * Returns true if %%this%% is equal to ``0``.
703
823
  */
704
824
  isZero() {
705
- return b(this, F) === z;
825
+ return x(this, R) === te;
706
826
  }
707
827
  /**
708
828
  * Returns true if %%this%% is less than ``0``.
709
829
  */
710
830
  isNegative() {
711
- return b(this, F) < z;
831
+ return x(this, R) < te;
712
832
  }
713
833
  /**
714
834
  * Returns the string representation of %%this%%.
@@ -732,8 +852,8 @@ const Z = class Z {
732
852
  *
733
853
  * This will throw if the value cannot fit into %%format%%.
734
854
  */
735
- toFormat(e) {
736
- return Z.fromString(this.toString(), e);
855
+ toFormat(t) {
856
+ return we.fromString(this.toString(), t);
737
857
  }
738
858
  /**
739
859
  * Creates a new [[FixedNumber]] for %%value%% divided by
@@ -743,19 +863,19 @@ const Z = class Z {
743
863
  * for %%decimals%%) cannot fit in %%format%%, either due to overflow
744
864
  * or underflow (precision loss).
745
865
  */
746
- static fromValue(e, n, r) {
747
- const s = n == null ? 0 : Ae(n), a = Ie(r);
748
- let i = Pe(e, "value");
749
- const w = s - a.decimals;
750
- if (w > 0) {
751
- const h = te(w);
752
- Y(i % h === z, "value loses precision for format", "NUMERIC_FAULT", {
866
+ static fromValue(t, n, r) {
867
+ const s = n == null ? 0 : Ie(n), l = Ee(r);
868
+ let i = Ke(t, "value");
869
+ const u = s - l.decimals;
870
+ if (u > 0) {
871
+ const p = pe(u);
872
+ Z(i % p === te, "value loses precision for format", "NUMERIC_FAULT", {
753
873
  operation: "fromValue",
754
874
  fault: "underflow",
755
- value: e
756
- }), i /= h;
757
- } else w < 0 && (i *= te(-w));
758
- return be(i, a, "fromValue"), new Z(de, i, a);
875
+ value: t
876
+ }), i /= p;
877
+ } else u < 0 && (i *= pe(-u));
878
+ return Se(i, l, "fromValue"), new we(ge, i, l);
759
879
  }
760
880
  /**
761
881
  * Creates a new [[FixedNumber]] for %%value%% with %%format%%.
@@ -763,20 +883,20 @@ const Z = class Z {
763
883
  * This will throw a [[NumericFaultError]] if %%value%% cannot fit
764
884
  * in %%format%%, either due to overflow or underflow (precision loss).
765
885
  */
766
- static fromString(e, n) {
767
- const r = e.match(/^(-?)([0-9]*)\.?([0-9]*)$/);
768
- P(r && r[2].length + r[3].length > 0, "invalid FixedNumber string value", "value", e);
769
- const s = Ie(n);
770
- let a = r[2] || "0", i = r[3] || "";
886
+ static fromString(t, n) {
887
+ const r = t.match(/^(-?)([0-9]*)\.?([0-9]*)$/);
888
+ H(r && r[2].length + r[3].length > 0, "invalid FixedNumber string value", "value", t);
889
+ const s = Ee(n);
890
+ let l = r[2] || "0", i = r[3] || "";
771
891
  for (; i.length < s.decimals; )
772
- i += fe;
773
- Y(i.substring(s.decimals).match(/^0*$/), "too many decimals for format", "NUMERIC_FAULT", {
892
+ i += ve;
893
+ Z(i.substring(s.decimals).match(/^0*$/), "too many decimals for format", "NUMERIC_FAULT", {
774
894
  operation: "fromString",
775
895
  fault: "underflow",
776
- value: e
896
+ value: t
777
897
  }), i = i.substring(0, s.decimals);
778
- const w = BigInt(r[1] + a + i);
779
- return be(w, s, "fromString"), new Z(de, w, s);
898
+ const u = BigInt(r[1] + l + i);
899
+ return Se(u, s, "fromString"), new we(ge, u, s);
780
900
  }
781
901
  /**
782
902
  * Creates a new [[FixedNumber]] with the big-endian representation
@@ -785,31 +905,31 @@ const Z = class Z {
785
905
  * This will throw a [[NumericFaultError]] if %%value%% cannot fit
786
906
  * in %%format%% due to overflow.
787
907
  */
788
- static fromBytes(e, n) {
789
- let r = Ft(Ut(e, "value"));
790
- const s = Ie(n);
791
- return s.signed && (r = Ee(r, s.width)), be(r, s, "fromBytes"), new Z(de, r, s);
908
+ static fromBytes(t, n) {
909
+ let r = jt(Pt(t, "value"));
910
+ const s = Ee(n);
911
+ return s.signed && (r = je(r, s.width)), Se(r, s, "fromBytes"), new we(ge, r, s);
792
912
  }
793
913
  };
794
- q = new WeakMap(), F = new WeakMap(), Q = new WeakMap(), B = new WeakSet(), ne = function(e) {
795
- P(this.format === e.format, "incompatible format; use fixedNumber.toFormat", "other", e);
796
- }, _ = function(e, n) {
797
- return e = be(e, b(this, q), n), new Z(de, e, b(this, q));
798
- }, De = function(e, n) {
799
- return E(this, B, ne).call(this, e), E(this, B, _).call(this, b(this, F) + b(e, F), n);
800
- }, Ve = function(e, n) {
801
- return E(this, B, ne).call(this, e), E(this, B, _).call(this, b(this, F) - b(e, F), n);
802
- }, je = function(e, n) {
803
- return E(this, B, ne).call(this, e), E(this, B, _).call(this, b(this, F) * b(e, F) / b(this, Q), n);
804
- }, Oe = function(e, n) {
805
- return Y(b(e, F) !== z, "division by zero", "NUMERIC_FAULT", {
914
+ ne = new WeakMap(), R = new WeakMap(), Y = new WeakMap(), U = new WeakSet(), he = function(t) {
915
+ H(this.format === t.format, "incompatible format; use fixedNumber.toFormat", "other", t);
916
+ }, ae = function(t, n) {
917
+ return t = Se(t, x(this, ne), n), new we(ge, t, x(this, ne));
918
+ }, We = function(t, n) {
919
+ return j(this, U, he).call(this, t), j(this, U, ae).call(this, x(this, R) + x(t, R), n);
920
+ }, Qe = function(t, n) {
921
+ return j(this, U, he).call(this, t), j(this, U, ae).call(this, x(this, R) - x(t, R), n);
922
+ }, qe = function(t, n) {
923
+ return j(this, U, he).call(this, t), j(this, U, ae).call(this, x(this, R) * x(t, R) / x(this, Y), n);
924
+ }, He = function(t, n) {
925
+ return Z(x(t, R) !== te, "division by zero", "NUMERIC_FAULT", {
806
926
  operation: "div",
807
927
  fault: "divide-by-zero",
808
928
  value: this
809
- }), E(this, B, ne).call(this, e), E(this, B, _).call(this, b(this, F) * b(this, Q) / b(e, F), n);
929
+ }), j(this, U, he).call(this, t), j(this, U, ae).call(this, x(this, R) * x(this, Y) / x(t, R), n);
810
930
  };
811
- let Le = Z;
812
- const Lt = [
931
+ let Ve = we;
932
+ const qt = [
813
933
  "wei",
814
934
  "kwei",
815
935
  "mwei",
@@ -818,293 +938,314 @@ const Lt = [
818
938
  "finney",
819
939
  "ether"
820
940
  ];
821
- function Dt(t, e) {
822
- P(typeof t == "string", "value must be a string", "value", t);
941
+ function Ht(e, t) {
942
+ H(typeof e == "string", "value must be a string", "value", e);
823
943
  let n = 18;
824
- if (typeof e == "string") {
825
- const r = Lt.indexOf(e);
826
- P(r >= 0, "invalid unit", "unit", e), n = 3 * r;
827
- } else e != null && (n = Ae(e, "unit"));
828
- return Le.fromString(t, { decimals: n, width: 512 }).value;
944
+ if (typeof t == "string") {
945
+ const r = qt.indexOf(t);
946
+ H(r >= 0, "invalid unit", "unit", t), n = 3 * r;
947
+ } else t != null && (n = Ie(t, "unit"));
948
+ return Ve.fromString(e, { decimals: n, width: 512 }).value;
829
949
  }
830
- const Vt = "0x0000000000000000000000000000000000000000", $e = "https://api.delora.build", ot = "0x1111111111111111111111111111111111111111", st = "11111111111111111111111111111111", dt = "1111111111111111111111111111111111111111111111111111111111111111";
831
- function Be(t, e) {
832
- return (Number(t) / Math.pow(10, e)).toString();
950
+ const Kt = "0x0000000000000000000000000000000000000000";
951
+ function Le(e, t) {
952
+ return (Number(e) / Math.pow(10, t)).toString();
833
953
  }
834
- async function jt(t, e = $e) {
954
+ async function zt(e, t = Be) {
835
955
  const n = new URLSearchParams({
836
- senderAddress: t.senderAddress,
837
- receiverAddress: t.receiverAddress ?? t.senderAddress,
838
- originChainId: String(t.originChainId),
839
- destinationChainId: String(t.destinationChainId),
840
- amount: t.amount,
841
- originCurrency: t.originCurrency,
842
- destinationCurrency: t.destinationCurrency
956
+ senderAddress: e.senderAddress,
957
+ receiverAddress: e.receiverAddress ?? e.senderAddress,
958
+ originChainId: String(e.originChainId),
959
+ destinationChainId: String(e.destinationChainId),
960
+ amount: e.amount,
961
+ originCurrency: e.originCurrency,
962
+ destinationCurrency: e.destinationCurrency
843
963
  });
844
- t.slippage != null && n.set("slippage", String(t.slippage));
845
- const r = `${e}/v1/quotes?${n.toString()}`, s = await fetch(r);
964
+ e.slippage != null && n.set("slippage", String(e.slippage));
965
+ const r = `${t}/v1/quotes?${n.toString()}`, s = await fetch(r);
846
966
  if (!s.ok) {
847
- const a = await s.json().catch(() => ({})), i = new Error((a == null ? void 0 : a.message) ?? `HTTP ${s.status}`);
848
- throw i.status = s.status, i.statusCode = a == null ? void 0 : a.statusCode, i.error = a, i;
967
+ const l = await s.json().catch(() => ({})), i = new Error((l == null ? void 0 : l.message) ?? `HTTP ${s.status}`);
968
+ throw i.status = s.status, i.statusCode = l == null ? void 0 : l.statusCode, i.error = l, i;
849
969
  }
850
970
  return s.json();
851
971
  }
852
- function Ot(t, e) {
853
- if (e < 0 || !t.includes(".")) return t;
854
- const [n, r] = t.split(".");
855
- if (!r || r.length <= e) return t;
856
- const s = r.slice(0, e);
972
+ function Yt(e, t) {
973
+ if (t < 0 || !e.includes(".")) return e;
974
+ const [n, r] = e.split(".");
975
+ if (!r || r.length <= t) return e;
976
+ const s = r.slice(0, t);
857
977
  return s ? `${n}.${s}` : n || "0";
858
978
  }
859
- function Pt() {
860
- const [t, e] = U(null), [n, r] = U(""), [s, a] = U(""), [i, w] = U(0), [h, p] = U(null), [N, x] = U(), [m, u] = U(), [k, o] = U("swap"), R = se(null), M = se(0), V = D(() => {
861
- var j;
862
- (j = R.current) == null || j.abort(), R.current = null;
863
- }, []), L = D(() => {
864
- e(null), o("finding");
865
- }, []), $ = D(
866
- (j) => {
867
- V();
868
- const l = ++M.current, S = new AbortController();
869
- R.current = S;
979
+ function Jt(e = {}) {
980
+ const [t, n] = B(null), [r, s] = B(null), [l, i] = B(""), [u, p] = B(""), [g, C] = B(0), [I, k] = B(null), [m, y] = B(), [v, $] = B(), [D, T] = B("swap"), O = X(null), K = X(0), q = M(() => {
981
+ var h;
982
+ (h = O.current) == null || h.abort(), O.current = null;
983
+ }, []), L = M(() => {
984
+ n(null), s(null), T("finding");
985
+ }, []), c = M(
986
+ (h) => {
987
+ q();
988
+ const b = ++K.current, N = new AbortController();
989
+ O.current = N;
870
990
  const {
871
- sellNetworkId: g,
872
- buyNetworkId: y,
873
- sellToken: c,
874
- buyToken: f,
875
- sellAmountStr: C,
876
- slippage: A,
877
- fromAddress: T,
878
- toAddress: O,
879
- apiBase: J = $e
880
- } = j, G = Ot(
881
- C || "0",
882
- c.decimals
991
+ sellNetworkId: o,
992
+ buyNetworkId: E,
993
+ sellToken: V,
994
+ buyToken: J,
995
+ sellAmountStr: G,
996
+ slippage: ie,
997
+ fromAddress: fe,
998
+ toAddress: ee,
999
+ apiBase: ce = Be
1000
+ } = h, de = Yt(
1001
+ G || "0",
1002
+ V.decimals
883
1003
  );
884
- let H;
1004
+ let oe;
885
1005
  try {
886
- H = Dt(G, c.decimals);
1006
+ oe = Ht(de, V.decimals);
887
1007
  } catch {
888
- o("swap");
1008
+ T("swap");
889
1009
  return;
890
1010
  }
891
- if (H <= 0n) {
892
- o("swap");
1011
+ if (oe <= 0n) {
1012
+ T("swap");
893
1013
  return;
894
1014
  }
895
- o("finding"), e(null), x(void 0), u(void 0);
896
- const ve = O && O !== "" ? O : void 0;
897
- jt(
1015
+ T("finding"), n(null), s(null), y(void 0), $(void 0);
1016
+ const w = ee && ee !== "" ? ee : void 0;
1017
+ zt(
898
1018
  {
899
- originChainId: g,
900
- destinationChainId: y,
901
- originCurrency: c.contractAddress,
902
- destinationCurrency: f.contractAddress,
903
- amount: H.toString(),
904
- senderAddress: T,
905
- receiverAddress: ve,
906
- slippage: A ?? 5e-3
1019
+ originChainId: o,
1020
+ destinationChainId: E,
1021
+ originCurrency: V.contractAddress,
1022
+ destinationCurrency: J.contractAddress,
1023
+ amount: oe.toString(),
1024
+ senderAddress: fe,
1025
+ receiverAddress: w,
1026
+ slippage: ie ?? 5e-3
907
1027
  },
908
- J
909
- ).then((I) => {
910
- var ee, W, ye, X, he, pe;
911
- if (l !== M.current) return;
912
- const K = (W = (ee = I == null ? void 0 : I.fees) == null ? void 0 : ee.breakdown) == null ? void 0 : W.find(
913
- (me) => me.type === "gas"
1028
+ ce
1029
+ ).then((a) => {
1030
+ var W, Q, z, f, F, P;
1031
+ if (b !== K.current) return;
1032
+ n(a);
1033
+ const S = (Q = (W = a == null ? void 0 : a.fees) == null ? void 0 : W.breakdown) == null ? void 0 : Q.find(
1034
+ (_) => _.type === "gas"
914
1035
  );
915
- if (K && (u(String(K.amount)), K.gasPrice !== void 0 && x(String(K.gasPrice))), I != null && I.calldata) {
916
- const me = I.outputAmount ?? "0", We = (String(me).includes(".") ? Number(me) : Number(
917
- Be(
918
- String(me),
919
- f.decimals
1036
+ if (S && ($(String(S.amount)), S.gasPrice !== void 0 && y(String(S.gasPrice))), a != null && a.calldata) {
1037
+ const _ = a.outputAmount ?? "0", se = (String(_).includes(".") ? Number(_) : Number(
1038
+ Le(
1039
+ String(_),
1040
+ J.decimals
920
1041
  )
921
- )).toFixed(f.decimals).replace(/\.?0+$/, "");
922
- r(We), a(We);
923
- const at = Number(
924
- ((X = (ye = I.fees) == null ? void 0 : ye.total) == null ? void 0 : X.amount) || "0"
925
- ), it = Number(
926
- ((pe = (he = I.fees) == null ? void 0 : he.total) == null ? void 0 : pe.decimals) ?? 18
927
- ), Ne = at / Math.pow(10, it);
928
- p(
929
- Ne <= 0 ? null : Ne < 0.01 ? "$<0.01" : `$${Ne.toFixed(2)}`
1042
+ )).toFixed(J.decimals).replace(/\.?0+$/, "");
1043
+ i(se), p(se);
1044
+ const pt = Number(
1045
+ ((f = (z = a.fees) == null ? void 0 : z.total) == null ? void 0 : f.amount) || "0"
1046
+ ), ht = Number(
1047
+ ((P = (F = a.fees) == null ? void 0 : F.total) == null ? void 0 : P.decimals) ?? 18
1048
+ ), Ue = pt / Math.pow(10, ht);
1049
+ k(
1050
+ Ue <= 0 ? null : Ue < 0.01 ? "$<0.01" : `$${Ue.toFixed(2)}`
930
1051
  );
931
- const Qe = parseFloat(
932
- Be(
933
- I.inputAmount ?? "0",
934
- c.decimals
1052
+ const ze = parseFloat(
1053
+ Le(
1054
+ a.inputAmount ?? "0",
1055
+ V.decimals
935
1056
  )
936
- ), lt = parseFloat(
937
- Be(
938
- I.outputAmount ?? "0",
939
- f.decimals
1057
+ ), mt = parseFloat(
1058
+ Le(
1059
+ a.outputAmount ?? "0",
1060
+ J.decimals
940
1061
  )
941
1062
  );
942
- Qe > 0 && w(Number((lt / Qe).toFixed(3))), e(I.calldata ?? null);
943
- const ct = c.contractAddress === "0x0000000000000000000000000000000000000000";
944
- o(ct ? "swap" : "approve");
1063
+ ze > 0 && C(Number((mt / ze).toFixed(3))), s(a.calldata ?? null);
1064
+ const gt = V.contractAddress === "0x0000000000000000000000000000000000000000";
1065
+ T(gt ? "swap" : "approve");
945
1066
  }
946
- }).catch((I) => {
947
- var W;
948
- if (l !== M.current || (I == null ? void 0 : I.name) === "AbortError") return;
949
- const K = String(((W = I == null ? void 0 : I.error) == null ? void 0 : W.message) ?? (I == null ? void 0 : I.message) ?? ""), ee = (I == null ? void 0 : I.statusCode) ?? (I == null ? void 0 : I.status);
950
- K.includes("No available quotes") || ee === 422 ? o("no-available-quotes") : K.includes("Invalid toAddress") || K.includes("Invalid fromAddress") ? o("wrong-address") : ee === 429 || K.includes("Rate limit") ? o("rate-limit") : o("no-available-quotes");
1067
+ }).catch((a) => {
1068
+ var Q, z;
1069
+ if (b !== K.current || (a == null ? void 0 : a.name) === "AbortError") return;
1070
+ const S = String(((Q = a == null ? void 0 : a.error) == null ? void 0 : Q.message) ?? (a == null ? void 0 : a.message) ?? ""), W = (a == null ? void 0 : a.statusCode) ?? (a == null ? void 0 : a.status);
1071
+ S.includes("No available quotes") || W === 422 ? T("no-available-quotes") : S.includes("Invalid toAddress") || S.includes("Invalid fromAddress") ? T("wrong-address") : W === 429 || S.includes("Rate limit") ? T("rate-limit") : T("no-available-quotes"), (z = e.onError) == null || z.call(e, {
1072
+ source: "quote",
1073
+ message: S || "Failed to fetch quote",
1074
+ status: a == null ? void 0 : a.status,
1075
+ statusCode: W,
1076
+ error: a
1077
+ });
951
1078
  });
952
1079
  },
953
- [V]
1080
+ [q, e]
954
1081
  );
955
1082
  return {
956
- txData: t,
957
- buyAmount: n,
958
- buyAmountForInput: s,
959
- setBuyAmount: r,
960
- setBuyAmountForInput: a,
961
- price: i,
962
- gasCostUSD: h,
963
- gasPriceRaw: N,
964
- gasLimitRaw: m,
965
- buttonState: k,
966
- setButtonState: o,
967
- fetchQuote: $,
968
- cancelRequest: V,
1083
+ quote: t,
1084
+ txData: r,
1085
+ buyAmount: l,
1086
+ buyAmountForInput: u,
1087
+ setBuyAmount: i,
1088
+ setBuyAmountForInput: p,
1089
+ price: g,
1090
+ gasCostUSD: I,
1091
+ gasPriceRaw: m,
1092
+ gasLimitRaw: v,
1093
+ buttonState: D,
1094
+ setButtonState: T,
1095
+ fetchQuote: c,
1096
+ cancelRequest: q,
969
1097
  invalidateQuote: L
970
1098
  };
971
1099
  }
972
- const Te = "delora-slippage-selectedIndex", Ue = "delora-slippage-customValue", ze = "delora-slippage-value", qe = ["Auto", "0.1%", "0.5%"], Fe = 5e-3;
973
- function $t() {
974
- const [t, e] = U(0), [n, r] = U(""), [s, a] = U(Fe);
975
- oe(() => {
976
- const p = localStorage.getItem(Te), N = localStorage.getItem(Ue);
977
- p !== null && e(JSON.parse(p)), N && r(N);
1100
+ const Me = "delora-slippage-selectedIndex", $e = "delora-slippage-customValue", Ze = "delora-slippage-value", et = ["Auto", "0.1%", "0.5%"], De = 5e-3;
1101
+ function Gt() {
1102
+ const [e, t] = B(0), [n, r] = B(""), [s, l] = B(De);
1103
+ re(() => {
1104
+ const g = localStorage.getItem(Me), C = localStorage.getItem($e);
1105
+ g !== null && t(JSON.parse(g)), C && r(C);
978
1106
  }, []);
979
- const i = D((p) => {
980
- e(p), r(""), localStorage.setItem(Te, JSON.stringify(p)), localStorage.setItem(Ue, ""), a(p === 0 ? Fe : parseFloat(qe[p].replace("%", "")) / 100);
981
- }, []), w = D((p) => {
982
- e(null), r(p), localStorage.setItem(Te, "null"), localStorage.setItem(Ue, p);
983
- const N = parseFloat(p.replace("%", ""));
984
- !isNaN(N) && N <= 49.9 && a(N / 100);
985
- }, []), h = D(
986
- (p) => {
987
- if (p === "Auto") {
988
- const m = Fe;
989
- return a(m), localStorage.setItem(ze, p), m;
1107
+ const i = M((g) => {
1108
+ t(g), r(""), localStorage.setItem(Me, JSON.stringify(g)), localStorage.setItem($e, ""), l(g === 0 ? De : parseFloat(et[g].replace("%", "")) / 100);
1109
+ }, []), u = M((g) => {
1110
+ t(null), r(g), localStorage.setItem(Me, "null"), localStorage.setItem($e, g);
1111
+ const C = parseFloat(g.replace("%", ""));
1112
+ !isNaN(C) && C <= 49.9 && l(C / 100);
1113
+ }, []), p = M(
1114
+ (g) => {
1115
+ if (g === "Auto") {
1116
+ const k = De;
1117
+ return l(k), localStorage.setItem(Ze, g), k;
990
1118
  }
991
- const N = parseFloat(p.replace("%", ""));
992
- if (N > 49.9) throw new Error("Slippage is too high!");
993
- const x = N / 100;
994
- return a(x), localStorage.setItem(ze, p), x;
1119
+ const C = parseFloat(g.replace("%", ""));
1120
+ if (C > 49.9) throw new Error("Slippage is too high!");
1121
+ const I = C / 100;
1122
+ return l(I), localStorage.setItem(Ze, g), I;
995
1123
  },
996
1124
  []
997
1125
  );
998
1126
  return {
999
- options: qe,
1000
- selectedIndex: t,
1127
+ options: et,
1128
+ selectedIndex: e,
1001
1129
  customValue: n,
1002
1130
  slippage: s,
1003
1131
  selectOption: i,
1004
- setCustom: w,
1005
- save: h
1132
+ setCustom: u,
1133
+ save: p
1006
1134
  };
1007
1135
  }
1008
- const Wt = 1e3;
1009
- function xe(t, e) {
1010
- if (!t.includes(".")) return t;
1011
- const [n, r] = t.split(".");
1012
- return `${n}.${(r ?? "").slice(0, e)}`;
1136
+ const _t = 1e3;
1137
+ function Ce(e, t) {
1138
+ if (!e.includes(".")) return e;
1139
+ const [n, r] = e.split(".");
1140
+ return `${n}.${(r ?? "").slice(0, t)}`;
1013
1141
  }
1014
- function Je(t) {
1015
- return t === "EVM" ? ot : t === "SVM" ? st : dt;
1142
+ function tt(e) {
1143
+ return e === "EVM" ? at : e === "SVM" ? it : ct;
1016
1144
  }
1017
- function Qt(t) {
1018
- var $, j, l, S;
1019
- const e = St({ dataBaseUrl: t.dataBaseUrl }), n = Pt(), r = $t(), [s, a] = U(""), [i, w] = U(0), [h, p] = U(!1), N = se(null), x = 0, m = 0, u = !!e.sellToken && !!e.buyToken && i > 0, k = D(() => {
1020
- if (!e.networkSell || !e.networkBuy || !e.sellToken || !e.buyToken || i <= 0 || h)
1145
+ function Xt(e) {
1146
+ var q, L, c, h;
1147
+ const t = Lt({
1148
+ apiBase: e.apiBase,
1149
+ initialSellToken: e.initialSellToken,
1150
+ initialBuyToken: e.initialBuyToken,
1151
+ initialSellNetworkId: e.initialSellNetworkId,
1152
+ initialBuyNetworkId: e.initialBuyNetworkId,
1153
+ lockBuyToken: e.lockBuyToken,
1154
+ lockSellToken: e.lockSellToken,
1155
+ lockBuyNetwork: e.lockBuyNetwork,
1156
+ lockSellNetwork: e.lockSellNetwork,
1157
+ onError: e.onError
1158
+ }), n = Jt({ onError: e.onError }), r = Gt(), s = !!e.lockBuyToken || !!e.lockSellToken || !!e.lockBuyNetwork || !!e.lockSellNetwork, [l, i] = B(""), [u, p] = B(0), [g, C] = B(!1), I = X(null), k = 0, m = 0, y = !!t.sellToken && !!t.buyToken && u > 0, v = M(() => {
1159
+ if (!t.networkSell || !t.networkBuy || !t.sellToken || !t.buyToken || u <= 0 || g)
1021
1160
  return;
1022
- const g = Je(e.networkSell.chainType), y = Je(e.networkBuy.chainType);
1161
+ const b = tt(t.networkSell.chainType), N = tt(t.networkBuy.chainType);
1023
1162
  n.fetchQuote({
1024
- sellNetworkId: e.networkSell.id,
1025
- buyNetworkId: e.networkBuy.id,
1026
- sellToken: e.sellToken,
1027
- buyToken: e.buyToken,
1028
- sellAmountStr: s || "0",
1163
+ sellNetworkId: t.networkSell.id,
1164
+ buyNetworkId: t.networkBuy.id,
1165
+ sellToken: t.sellToken,
1166
+ buyToken: t.buyToken,
1167
+ sellAmountStr: l || "0",
1029
1168
  slippage: r.slippage,
1030
- fromAddress: g,
1031
- toAddress: y,
1032
- apiBase: t.apiBase ?? $e
1169
+ fromAddress: b,
1170
+ toAddress: N,
1171
+ apiBase: e.apiBase ?? Be
1033
1172
  });
1034
1173
  }, [
1035
- e.networkSell,
1036
- e.networkBuy,
1037
- e.sellToken,
1038
- e.buyToken,
1039
- i,
1040
- s,
1174
+ t.networkSell,
1175
+ t.networkBuy,
1176
+ t.sellToken,
1177
+ t.buyToken,
1178
+ u,
1179
+ l,
1041
1180
  r.slippage,
1042
- h,
1043
- t.apiBase,
1181
+ g,
1182
+ e.apiBase,
1044
1183
  n
1045
1184
  ]);
1046
- oe(() => {
1047
- if (!u) {
1185
+ re(() => {
1186
+ if (!y) {
1048
1187
  n.cancelRequest(), n.setBuyAmount(""), n.setBuyAmountForInput(""), n.setButtonState("swap");
1049
1188
  return;
1050
1189
  }
1051
- k();
1190
+ v();
1052
1191
  }, [
1192
+ y,
1193
+ (q = t.networkSell) == null ? void 0 : q.id,
1194
+ (L = t.networkBuy) == null ? void 0 : L.id,
1195
+ (c = t.sellToken) == null ? void 0 : c.contractAddress,
1196
+ (h = t.buyToken) == null ? void 0 : h.contractAddress,
1053
1197
  u,
1054
- ($ = e.networkSell) == null ? void 0 : $.id,
1055
- (j = e.networkBuy) == null ? void 0 : j.id,
1056
- (l = e.sellToken) == null ? void 0 : l.contractAddress,
1057
- (S = e.buyToken) == null ? void 0 : S.contractAddress,
1058
- i,
1059
- s,
1198
+ l,
1060
1199
  r.slippage,
1061
- h
1062
- ]), oe(() => {
1063
- i === 0 && (n.setBuyAmount(""), n.setBuyAmountForInput(""));
1064
- }, [i]);
1065
- const o = D((g) => {
1066
- const y = g.replace(/[^0-9.]/g, "").replace(/\.+/g, ".").replace(/^(\.)/g, ""), c = xe(y, 6), f = Number(c);
1067
- a(c), w(isNaN(f) ? 0 : f), p(!0), n.invalidateQuote(), N.current && clearTimeout(N.current), N.current = setTimeout(() => {
1068
- p(!1), N.current = null;
1069
- }, Wt);
1070
- }, [n]), R = D(() => {
1071
- a(String(x)), w(x), p(!1), u && k();
1072
- }, [x, u, k]), M = D(
1073
- (g) => {
1074
- const y = x * g / 100, c = xe(String(y), 6);
1075
- a(c), w(y), p(!1), u && k();
1200
+ g
1201
+ ]), re(() => {
1202
+ u === 0 && (n.setBuyAmount(""), n.setBuyAmountForInput(""));
1203
+ }, [u]);
1204
+ const $ = M((b) => {
1205
+ const N = b.replace(/[^0-9.]/g, "").replace(/\.+/g, ".").replace(/^(\.)/g, ""), o = Ce(N, 6), E = Number(o);
1206
+ i(o), p(isNaN(E) ? 0 : E), C(!0), n.invalidateQuote(), I.current && clearTimeout(I.current), I.current = setTimeout(() => {
1207
+ C(!1), I.current = null;
1208
+ }, _t);
1209
+ }, [n]), D = M(() => {
1210
+ i(String(k)), p(k), C(!1), y && v();
1211
+ }, [k, y, v]), T = M(
1212
+ (b) => {
1213
+ const N = k * b / 100, o = Ce(String(N), 6);
1214
+ i(o), p(N), C(!1), y && v();
1076
1215
  },
1077
- [x, u, k]
1078
- ), V = D(() => {
1079
- const g = e.sellToken, y = e.buyToken;
1080
- if (!g || !y) return;
1081
- const c = s || "0", f = n.buyAmountForInput || n.buyAmount || "0";
1082
- if (n.cancelRequest(), n.invalidateQuote(), e.updateNetworkSell(y.chainId), e.updateNetworkBuy(g.chainId), e.setSellToken(y), e.setBuyToken(g), f !== "0" && f !== "0.0") {
1083
- const C = xe(f, 6);
1084
- a(C), w(Number(C));
1216
+ [k, y, v]
1217
+ ), O = M(() => {
1218
+ if (s) return;
1219
+ const b = t.sellToken, N = t.buyToken;
1220
+ if (!b || !N) return;
1221
+ const o = l || "0", E = n.buyAmountForInput || n.buyAmount || "0";
1222
+ if (n.cancelRequest(), n.invalidateQuote(), t.updateNetworkSell(N.chainId), t.updateNetworkBuy(b.chainId), t.setSellToken(N), t.setBuyToken(b), E !== "0" && E !== "0.0") {
1223
+ const V = Ce(E, 6);
1224
+ i(V), p(Number(V));
1085
1225
  } else
1086
- a(""), w(0);
1087
- c !== "0" && c !== "0.0" ? (n.setBuyAmount(xe(c, 6)), n.setBuyAmountForInput(xe(c, 6))) : (n.setBuyAmount(""), n.setBuyAmountForInput(""));
1088
- }, [e, n, s]);
1226
+ i(""), p(0);
1227
+ o !== "0" && o !== "0.0" ? (n.setBuyAmount(Ce(o, 6)), n.setBuyAmountForInput(Ce(o, 6))) : (n.setBuyAmount(""), n.setBuyAmountForInput(""));
1228
+ }, [t, n, l, s]);
1089
1229
  return {
1090
- ...e,
1230
+ ...t,
1091
1231
  ...n,
1092
1232
  slippage: r,
1093
- sellAmountForInput: s,
1094
- setSellAmountForInput: a,
1095
- validatedSellAmount: i,
1096
- processSellInput: o,
1097
- setMaxSellAmount: R,
1098
- setSellAmountByPercent: M,
1099
- swapTokens: V,
1100
- balance: x,
1233
+ swapLocked: s,
1234
+ sellAmountForInput: l,
1235
+ setSellAmountForInput: i,
1236
+ validatedSellAmount: u,
1237
+ processSellInput: $,
1238
+ setMaxSellAmount: D,
1239
+ setSellAmountByPercent: T,
1240
+ swapTokens: O,
1241
+ balance: k,
1101
1242
  balanceBuy: m,
1102
- allFieldsReady: u,
1103
- isProcessingInput: h,
1104
- isSameToken: (g, y) => !!g && !!y && g.contractAddress === y.contractAddress && g.chainId === y.chainId
1243
+ allFieldsReady: y,
1244
+ isProcessingInput: g,
1245
+ isSameToken: (b, N) => !!b && !!N && b.contractAddress === N.contractAddress && b.chainId === N.chainId
1105
1246
  };
1106
1247
  }
1107
- const Ht = {
1248
+ const Zt = {
1108
1249
  trade: {
1109
1250
  possibleChars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+{}:"<>?|',
1110
1251
  glitchChars: '!@#$%^&*()_+{}:"<>?|\\',
@@ -1120,72 +1261,72 @@ const Ht = {
1120
1261
  animationSpeed: 25
1121
1262
  }
1122
1263
  };
1123
- function Yt({
1124
- ref: t,
1125
- text: e,
1264
+ function en({
1265
+ ref: e,
1266
+ text: t,
1126
1267
  enabled: n,
1127
1268
  preset: r = "trade",
1128
1269
  onAnimationStart: s,
1129
- onAnimationEnd: a
1270
+ onAnimationEnd: l
1130
1271
  }) {
1131
- const i = se(null);
1132
- ht(() => {
1133
- const w = t.current;
1134
- w && (!n || !e || e === "0" || e === "0.0") && (w.textContent = e);
1135
- }, [t, e, n]), oe(() => {
1136
- const w = t.current;
1137
- if (!w) return;
1138
- if (!n || !e || e === "0" || e === "0.0") {
1139
- w.textContent = e;
1272
+ const i = X(null);
1273
+ yt(() => {
1274
+ const u = e.current;
1275
+ u && (!n || !t || t === "0" || t === "0.0") && (u.textContent = t);
1276
+ }, [e, t, n]), re(() => {
1277
+ const u = e.current;
1278
+ if (!u) return;
1279
+ if (!n || !t || t === "0" || t === "0.0") {
1280
+ u.textContent = t;
1140
1281
  return;
1141
1282
  }
1142
- const { possibleChars: h, glitchChars: p, cyberChars: N, animationFrames: x, animationSpeed: m } = Ht[r], u = String(e);
1283
+ const { possibleChars: p, glitchChars: g, cyberChars: C, animationFrames: I, animationSpeed: k } = Zt[r], m = String(t);
1143
1284
  i.current && (clearTimeout(i.current), i.current = null);
1144
- let k = 0;
1145
- const o = Array(u.length).fill(!1), R = Array(u.length).fill(!1), M = () => {
1146
- if (!t.current) return;
1147
- if (k >= x) {
1148
- t.current.textContent = u, i.current = null, a == null || a();
1285
+ let y = 0;
1286
+ const v = Array(m.length).fill(!1), $ = Array(m.length).fill(!1), D = () => {
1287
+ if (!e.current) return;
1288
+ if (y >= I) {
1289
+ e.current.textContent = m, i.current = null, l == null || l();
1149
1290
  return;
1150
1291
  }
1151
- k === 0 && (s == null || s());
1152
- let L = "";
1153
- const $ = k / x, j = Math.pow($, 0.6), l = Math.floor(u.length * j);
1154
- for (let g = 0; g < l; g++)
1155
- R[g] || (R[g] = !0);
1156
- if (k % 2 === 0) {
1157
- const g = 0.05 + $ * 0.1;
1158
- for (let y = 0; y < u.length; y++)
1159
- Math.random() < g && (o[y] = !o[y]);
1292
+ y === 0 && (s == null || s());
1293
+ let O = "";
1294
+ const K = y / I, q = Math.pow(K, 0.6), L = Math.floor(m.length * q);
1295
+ for (let h = 0; h < L; h++)
1296
+ $[h] || ($[h] = !0);
1297
+ if (y % 2 === 0) {
1298
+ const h = 0.05 + K * 0.1;
1299
+ for (let b = 0; b < m.length; b++)
1300
+ Math.random() < h && (v[b] = !v[b]);
1160
1301
  }
1161
- for (let g = 0; g < u.length; g++)
1162
- if (R[g])
1163
- o[g] && k < x * 0.95 && u[g] !== " " ? Math.random() < 0.3 ? L += N[Math.floor(Math.random() * N.length)] : L += p[Math.floor(Math.random() * p.length)] : L += u[g];
1164
- else if (u[g] === " ")
1165
- L += " ";
1302
+ for (let h = 0; h < m.length; h++)
1303
+ if ($[h])
1304
+ v[h] && y < I * 0.95 && m[h] !== " " ? Math.random() < 0.3 ? O += C[Math.floor(Math.random() * C.length)] : O += g[Math.floor(Math.random() * g.length)] : O += m[h];
1305
+ else if (m[h] === " ")
1306
+ O += " ";
1166
1307
  else {
1167
- const y = Math.random();
1168
- y < 0.2 ? L += p[Math.floor(Math.random() * p.length)] : y < 0.4 ? L += N[Math.floor(Math.random() * N.length)] : L += h[Math.floor(Math.random() * h.length)];
1308
+ const b = Math.random();
1309
+ b < 0.2 ? O += g[Math.floor(Math.random() * g.length)] : b < 0.4 ? O += C[Math.floor(Math.random() * C.length)] : O += p[Math.floor(Math.random() * p.length)];
1169
1310
  }
1170
- t.current.textContent = L, k++;
1171
- let S = m;
1172
- $ < 0.3 ? S = m * 0.8 : $ > 0.7 ? S = m * 0.7 : S = m * 1.2, i.current = setTimeout(M, S);
1173
- }, V = setTimeout(() => {
1174
- t.current && M();
1311
+ e.current.textContent = O, y++;
1312
+ let c = k;
1313
+ K < 0.3 ? c = k * 0.8 : K > 0.7 ? c = k * 0.7 : c = k * 1.2, i.current = setTimeout(D, c);
1314
+ }, T = setTimeout(() => {
1315
+ e.current && D();
1175
1316
  }, 0);
1176
1317
  return () => {
1177
- clearTimeout(V), i.current && (clearTimeout(i.current), i.current = null), a == null || a();
1318
+ clearTimeout(T), i.current && (clearTimeout(i.current), i.current = null), l == null || l();
1178
1319
  };
1179
- }, [t, e, n, r]);
1320
+ }, [e, t, n, r]);
1180
1321
  }
1181
- function re(t, e) {
1182
- if (!t) return "";
1183
- if (t.startsWith("http://") || t.startsWith("https://") || t.startsWith("data:"))
1184
- return t;
1185
- const n = (e == null ? void 0 : e.replace(/\/$/, "")) ?? "";
1186
- return t.startsWith("/") ? `${n}${t}` : `${n}/${t}`;
1322
+ function me(e, t) {
1323
+ if (!e) return "";
1324
+ if (e.startsWith("http://") || e.startsWith("https://") || e.startsWith("data:"))
1325
+ return e;
1326
+ const n = (t == null ? void 0 : t.replace(/\/$/, "")) ?? "";
1327
+ return e.startsWith("/") ? `${n}${e}` : `${n}/${e}`;
1187
1328
  }
1188
- const Kt = "data:image/svg+xml,%3csvg%20width='27'%20height='27'%20viewBox='0%200%2027%2027'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.42142%203.29834C6.61961%203.29834%205.85064%203.61686%205.28367%204.18383C4.71671%204.75079%204.39819%205.51976%204.39819%206.32158V22.5371H4.12335C3.90467%2022.5371%203.69495%2022.624%203.54032%2022.7786C3.3857%2022.9332%203.29883%2023.143%203.29883%2023.3616C3.29883%2023.5803%203.3857%2023.79%203.54032%2023.9447C3.69495%2024.0993%203.90467%2024.1862%204.12335%2024.1862H18.9647C19.1834%2024.1862%2019.3931%2024.0993%2019.5477%2023.9447C19.7023%2023.79%2019.7892%2023.5803%2019.7892%2023.3616C19.7892%2023.143%2019.7023%2022.9332%2019.5477%2022.7786C19.3931%2022.624%2019.1834%2022.5371%2018.9647%2022.5371H18.6899V20.555C19.1499%2020.7915%2019.6631%2020.9058%2020.1801%2020.8868C20.697%2020.8679%2021.2005%2020.7163%2021.642%2020.4468C22.0835%2020.1772%2022.4484%2019.7987%2022.7015%2019.3475C22.9546%2018.8963%2023.0874%2018.3877%2023.0873%2017.8703V11.4523C23.0873%2010.7981%2022.8751%2010.1617%2022.4826%209.63834L21.2733%208.02558C21.1421%207.85064%2020.9468%207.73499%2020.7303%207.70406C20.5139%207.67314%2020.294%207.72947%2020.119%207.86068C19.9441%207.99189%2019.8284%208.18721%2019.7975%208.40369C19.7666%208.62017%2019.8229%208.84007%2019.9541%209.01501L21.1634%2010.6278C21.3415%2010.8652%2021.4383%2011.1555%2021.4383%2011.4523V17.8703C21.4383%2018.0501%2021.4028%2018.2281%2021.3341%2018.3941C21.2653%2018.5602%2021.1645%2018.7111%2021.0374%2018.8382C20.9103%2018.9653%2020.7594%2019.0661%2020.5933%2019.1349C20.4273%2019.2036%2020.2493%2019.239%2020.0695%2019.239C19.8898%2019.239%2019.7118%2019.2036%2019.5458%2019.1349C19.3797%2019.0661%2019.2288%2018.9653%2019.1017%2018.8382C18.9746%2018.7111%2018.8738%2018.5602%2018.805%2018.3941C18.7363%2018.2281%2018.7008%2018.0501%2018.7008%2017.8703V15.941C18.6999%2015.8964%2018.6962%2015.852%2018.6899%2015.8079V6.32158C18.6899%205.92456%2018.6117%205.53143%2018.4597%205.16463C18.3078%204.79784%2018.0851%204.46456%2017.8044%204.18383C17.5236%203.90309%2017.1904%203.6804%2016.8236%203.52847C16.4568%203.37654%2016.0636%203.29834%2015.6666%203.29834H7.42142ZM7.69626%207.42094C7.69626%207.20226%207.78313%206.99254%207.93776%206.83791C8.09239%206.68329%208.30211%206.59642%208.52078%206.59642H14.5673C14.7859%206.59642%2014.9957%206.68329%2015.1503%206.83791C15.3049%206.99254%2015.3918%207.20226%2015.3918%207.42094V11.2687C15.3918%2011.4874%2015.3049%2011.6971%2015.1503%2011.8517C14.9957%2012.0063%2014.7859%2012.0932%2014.5673%2012.0932H8.52078C8.30211%2012.0932%208.09239%2012.0063%207.93776%2011.8517C7.78313%2011.6971%207.69626%2011.4874%207.69626%2011.2687V7.42094Z'%20fill='white'/%3e%3c/svg%3e", zt = {
1329
+ const tn = "data:image/svg+xml,%3csvg%20width='27'%20height='27'%20viewBox='0%200%2027%2027'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7.42142%203.29834C6.61961%203.29834%205.85064%203.61686%205.28367%204.18383C4.71671%204.75079%204.39819%205.51976%204.39819%206.32158V22.5371H4.12335C3.90467%2022.5371%203.69495%2022.624%203.54032%2022.7786C3.3857%2022.9332%203.29883%2023.143%203.29883%2023.3616C3.29883%2023.5803%203.3857%2023.79%203.54032%2023.9447C3.69495%2024.0993%203.90467%2024.1862%204.12335%2024.1862H18.9647C19.1834%2024.1862%2019.3931%2024.0993%2019.5477%2023.9447C19.7023%2023.79%2019.7892%2023.5803%2019.7892%2023.3616C19.7892%2023.143%2019.7023%2022.9332%2019.5477%2022.7786C19.3931%2022.624%2019.1834%2022.5371%2018.9647%2022.5371H18.6899V20.555C19.1499%2020.7915%2019.6631%2020.9058%2020.1801%2020.8868C20.697%2020.8679%2021.2005%2020.7163%2021.642%2020.4468C22.0835%2020.1772%2022.4484%2019.7987%2022.7015%2019.3475C22.9546%2018.8963%2023.0874%2018.3877%2023.0873%2017.8703V11.4523C23.0873%2010.7981%2022.8751%2010.1617%2022.4826%209.63834L21.2733%208.02558C21.1421%207.85064%2020.9468%207.73499%2020.7303%207.70406C20.5139%207.67314%2020.294%207.72947%2020.119%207.86068C19.9441%207.99189%2019.8284%208.18721%2019.7975%208.40369C19.7666%208.62017%2019.8229%208.84007%2019.9541%209.01501L21.1634%2010.6278C21.3415%2010.8652%2021.4383%2011.1555%2021.4383%2011.4523V17.8703C21.4383%2018.0501%2021.4028%2018.2281%2021.3341%2018.3941C21.2653%2018.5602%2021.1645%2018.7111%2021.0374%2018.8382C20.9103%2018.9653%2020.7594%2019.0661%2020.5933%2019.1349C20.4273%2019.2036%2020.2493%2019.239%2020.0695%2019.239C19.8898%2019.239%2019.7118%2019.2036%2019.5458%2019.1349C19.3797%2019.0661%2019.2288%2018.9653%2019.1017%2018.8382C18.9746%2018.7111%2018.8738%2018.5602%2018.805%2018.3941C18.7363%2018.2281%2018.7008%2018.0501%2018.7008%2017.8703V15.941C18.6999%2015.8964%2018.6962%2015.852%2018.6899%2015.8079V6.32158C18.6899%205.92456%2018.6117%205.53143%2018.4597%205.16463C18.3078%204.79784%2018.0851%204.46456%2017.8044%204.18383C17.5236%203.90309%2017.1904%203.6804%2016.8236%203.52847C16.4568%203.37654%2016.0636%203.29834%2015.6666%203.29834H7.42142ZM7.69626%207.42094C7.69626%207.20226%207.78313%206.99254%207.93776%206.83791C8.09239%206.68329%208.30211%206.59642%208.52078%206.59642H14.5673C14.7859%206.59642%2014.9957%206.68329%2015.1503%206.83791C15.3049%206.99254%2015.3918%207.20226%2015.3918%207.42094V11.2687C15.3918%2011.4874%2015.3049%2011.6971%2015.1503%2011.8517C14.9957%2012.0063%2014.7859%2012.0932%2014.5673%2012.0932H8.52078C8.30211%2012.0932%208.09239%2012.0063%207.93776%2011.8517C7.78313%2011.6971%207.69626%2011.4874%207.69626%2011.2687V7.42094Z'%20fill='white'/%3e%3c/svg%3e", nn = {
1189
1330
  swap: "Swap",
1190
1331
  finding: "Finding Routes...",
1191
1332
  approve: "Approve",
@@ -1195,75 +1336,79 @@ const Kt = "data:image/svg+xml,%3csvg%20width='27'%20height='27'%20viewBox='0%20
1195
1336
  "wrong-address": "Wrong address",
1196
1337
  "rate-limit": "Try later"
1197
1338
  };
1198
- function qt(t) {
1339
+ function rn(e) {
1199
1340
  const {
1200
- sellToken: e,
1341
+ sellToken: t,
1201
1342
  buyToken: n,
1202
1343
  networkSellLogo: r,
1203
1344
  networkBuyLogo: s,
1204
- assetBaseUrl: a,
1345
+ assetBaseUrl: l,
1205
1346
  sellAmountForInput: i,
1206
- buyAmountForInput: w,
1207
- onSellAmountChange: h,
1208
- onSellInputProcess: p,
1209
- onOpenSellToken: N,
1210
- onOpenBuyToken: x,
1211
- onSwapTokens: m,
1212
- onRefresh: u,
1213
- onOpenSettings: k,
1214
- balance: o,
1215
- balanceBuy: R,
1216
- sellPriceUsd: M,
1217
- buyPriceUsd: V,
1218
- onMaxClick: L,
1219
- onSet50Percent: $,
1220
- onSet25Percent: j,
1221
- buttonState: l,
1222
- txData: S,
1223
- loading: g,
1224
- price: y,
1225
- gasCostUSD: c,
1226
- truncateTo6Decimals: f,
1227
- isWalletConnected: C = !1,
1228
- onConnectWallet: A
1229
- } = t, T = !!i && Number(i) > 0, O = l === "insufficient" || l === "no-available-quotes" || l === "wrong-address", J = !T || g || C && !S && l !== "finding" || l === "no-available-quotes" || l === "insufficient", G = se(null), H = se(null), ve = se(0), I = () => {
1230
- u(), ve.current += 1;
1231
- const W = H.current;
1232
- W && (W.style.transform = `rotate(${ve.current * -720}deg)`);
1347
+ buyAmountForInput: u,
1348
+ onSellAmountChange: p,
1349
+ onSellInputProcess: g,
1350
+ onOpenSellToken: C,
1351
+ onOpenBuyToken: I,
1352
+ onSwapTokens: k,
1353
+ onRefresh: m,
1354
+ onOpenSettings: y,
1355
+ balance: v,
1356
+ balanceBuy: $,
1357
+ sellPriceUsd: D,
1358
+ buyPriceUsd: T,
1359
+ onMaxClick: O,
1360
+ onSet50Percent: K,
1361
+ onSet25Percent: q,
1362
+ buttonState: L,
1363
+ txData: c,
1364
+ loading: h,
1365
+ price: b,
1366
+ gasCostUSD: N,
1367
+ truncateTo6Decimals: o,
1368
+ isWalletConnected: E = !1,
1369
+ onConnectWallet: V,
1370
+ onAction: J,
1371
+ swapDisabled: G = !1,
1372
+ sellTokenLocked: ie = !1,
1373
+ buyTokenLocked: fe = !1
1374
+ } = e, ee = !!i && Number(i) > 0, ce = L === "insufficient" || L === "no-available-quotes" || L === "wrong-address", de = !ee || h || E && !c && L !== "finding" || L === "no-available-quotes" || L === "insufficient", oe = E ? de : !1, w = X(null), a = X(null), S = X(0), W = () => {
1375
+ m(), S.current += 1;
1376
+ const f = a.current;
1377
+ f && (f.style.transform = `rotate(${S.current * -720}deg)`);
1233
1378
  };
1234
- Yt({
1235
- ref: G,
1236
- text: w || "0.0",
1237
- enabled: !!(n != null && n.symbol) && Number(i) > 0 && !!w && w !== "0" && w !== "0.0",
1379
+ en({
1380
+ ref: w,
1381
+ text: u || "0.0",
1382
+ enabled: !!(n != null && n.symbol) && Number(i) > 0 && !!u && u !== "0" && u !== "0.0",
1238
1383
  preset: "trade"
1239
1384
  });
1240
- const K = (W) => {
1241
- if ([",", ".", "/", "б", "ю"].includes(W.key)) {
1242
- W.preventDefault();
1243
- const X = W.target;
1244
- if (X.value.includes(".")) return;
1245
- const he = X.selectionStart ?? X.value.length, pe = X.value.slice(0, he) + "." + X.value.slice(he);
1246
- h(pe), p(pe);
1385
+ const Q = (f) => {
1386
+ if ([",", ".", "/", "б", "ю"].includes(f.key)) {
1387
+ f.preventDefault();
1388
+ const P = f.target;
1389
+ if (P.value.includes(".")) return;
1390
+ const _ = P.selectionStart ?? P.value.length, le = P.value.slice(0, _) + "." + P.value.slice(_);
1391
+ p(le), g(le);
1247
1392
  }
1248
- }, ee = C ? `dw-w-full dw-h-[38px] dw-rounded-[var(--dw-radius)] dw-border dw-text-[13px] dw-font-normal dw-transition-colors ${O ? "dw-bg-[var(--dw-danger)] dw-border-[var(--dw-danger)] dw-text-white" : J ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-border)] dw-text-[var(--dw-muted)]" : "dw-bg-[var(--dw-accent)] dw-border-[var(--dw-accent)] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] hover:dw-border-[var(--dw-accent-hover)]"}` : "dw-w-full dw-h-[38px] dw-rounded-[var(--dw-radius)] dw-border dw-border-[var(--dw-accent)] dw-text-[13px] dw-font-normal dw-transition-colors dw-bg-[var(--dw-accent)] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] hover:dw-border-[var(--dw-accent-hover)]";
1249
- return /* @__PURE__ */ v("div", { className: "dw-widget-shell dw-elevated-surface dw-flex dw-flex-col dw-gap-1.5 dw-font-mono", children: [
1250
- /* @__PURE__ */ v("div", { className: "dw-flex dw-items-center dw-justify-between dw-mb-0.5", children: [
1393
+ }, z = E ? `dw-w-full dw-h-[38px] dw-rounded-[var(--dw-radius)] dw-border dw-text-[13px] dw-font-normal dw-transition-colors ${ce ? "dw-bg-[var(--dw-danger)] dw-border-[var(--dw-danger)] dw-text-white" : de ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-border)] dw-text-[var(--dw-muted)]" : "dw-bg-[var(--dw-accent)] dw-border-[var(--dw-accent)] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] hover:dw-border-[var(--dw-accent-hover)]"}` : "dw-w-full dw-h-[38px] dw-rounded-[var(--dw-radius)] dw-border dw-border-[var(--dw-accent)] dw-text-[13px] dw-font-normal dw-transition-colors dw-bg-[var(--dw-accent)] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] hover:dw-border-[var(--dw-accent-hover)]";
1394
+ return /* @__PURE__ */ A("div", { className: "dw-widget-shell dw-elevated-surface dw-flex dw-flex-col dw-gap-1.5 dw-font-mono", children: [
1395
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between dw-mb-0.5", children: [
1251
1396
  /* @__PURE__ */ d("h3", { className: "dw-text-[14px] dw-font-normal dw-text-[var(--dw-fg)]", children: "Trade" }),
1252
- /* @__PURE__ */ v("div", { className: "dw-flex dw-items-center dw-gap-1", children: [
1397
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-1", children: [
1253
1398
  /* @__PURE__ */ d(
1254
1399
  "button",
1255
1400
  {
1256
1401
  type: "button",
1257
1402
  className: "dw-icon-button dw-w-4 dw-h-4 dw-flex dw-items-center dw-justify-center dw-rounded-[4px] dw-cursor-pointer dw-opacity-70",
1258
- onMouseDown: I,
1403
+ onMouseDown: W,
1259
1404
  "aria-label": "Refresh",
1260
1405
  children: /* @__PURE__ */ d(
1261
1406
  "span",
1262
1407
  {
1263
- ref: H,
1408
+ ref: a,
1264
1409
  className: "dw-w-full dw-h-full dw-flex dw-items-center dw-justify-center",
1265
1410
  style: { transition: "transform 1s ease-in-out" },
1266
- children: /* @__PURE__ */ d(_t, {})
1411
+ children: /* @__PURE__ */ d(dn, {})
1267
1412
  }
1268
1413
  )
1269
1414
  }
@@ -1273,62 +1418,65 @@ function qt(t) {
1273
1418
  {
1274
1419
  type: "button",
1275
1420
  className: "dw-icon-button dw-w-4 dw-h-4 dw-flex dw-items-center dw-justify-center dw-rounded-[4px] dw-cursor-pointer dw-opacity-70",
1276
- onClick: k,
1421
+ onClick: y,
1277
1422
  "aria-label": "Settings",
1278
- children: /* @__PURE__ */ d(Xt, {})
1423
+ children: /* @__PURE__ */ d(ln, {})
1279
1424
  }
1280
1425
  )
1281
1426
  ] })
1282
1427
  ] }),
1283
- /* @__PURE__ */ v("div", { className: "dw-relative dw-flex dw-flex-col dw-gap-1.5", children: [
1428
+ /* @__PURE__ */ A("div", { className: "dw-relative dw-flex dw-flex-col dw-gap-1.5", children: [
1284
1429
  /* @__PURE__ */ d(
1285
1430
  "button",
1286
1431
  {
1287
1432
  type: "button",
1288
- className: "dw-widget-section dw-group dw-w-[30px] dw-h-[30px] dw-absolute dw-left-1/2 dw-top-1/2 dw-z-10 dw--translate-x-1/2 dw--translate-y-1/2 dw-cursor-pointer dw-flex dw-justify-center dw-items-center",
1289
- onClick: m,
1433
+ className: `dw-widget-section dw-group dw-w-[30px] dw-h-[30px] dw-absolute dw-left-1/2 dw-top-1/2 dw-z-10 dw--translate-x-1/2 dw--translate-y-1/2 dw-flex dw-justify-center dw-items-center ${G ? "dw-cursor-not-allowed dw-opacity-40" : "dw-cursor-pointer"}`,
1434
+ onClick: k,
1290
1435
  "aria-label": "Swap tokens",
1291
- children: /* @__PURE__ */ d(Gt, {})
1436
+ disabled: G,
1437
+ children: /* @__PURE__ */ d(sn, {})
1292
1438
  }
1293
1439
  ),
1294
1440
  /* @__PURE__ */ d(
1295
- Ge,
1441
+ nt,
1296
1442
  {
1297
1443
  label: "From",
1298
1444
  labelTone: "danger",
1299
- token: e,
1445
+ token: t,
1300
1446
  networkLogo: r,
1301
- assetBaseUrl: a,
1447
+ assetBaseUrl: l,
1302
1448
  amount: i,
1303
1449
  amountPlaceholder: "0.0",
1304
- usdValue: M || "$0.000",
1305
- balance: f(o),
1306
- onOpenToken: N,
1307
- onInputChange: (W) => {
1308
- h(W), p(W);
1450
+ usdValue: D || "$0.000",
1451
+ balance: o(v),
1452
+ onOpenToken: C,
1453
+ tokenLocked: ie,
1454
+ onInputChange: (f) => {
1455
+ p(f), g(f);
1309
1456
  },
1310
- onKeyDown: K,
1311
- amountToneClassName: O ? "dw-text-[var(--dw-danger)]" : "dw-text-[var(--dw-fg)]",
1312
- quickActions: /* @__PURE__ */ v(ft, { children: [
1313
- /* @__PURE__ */ d(Me, { label: "MAX", onClick: L }),
1314
- /* @__PURE__ */ d(Me, { label: "50%", onClick: $ }),
1315
- /* @__PURE__ */ d(Me, { label: "25%", onClick: j })
1457
+ onKeyDown: Q,
1458
+ amountToneClassName: ce ? "dw-text-[var(--dw-danger)]" : "dw-text-[var(--dw-fg)]",
1459
+ quickActions: /* @__PURE__ */ A(xt, { children: [
1460
+ /* @__PURE__ */ d(Oe, { label: "MAX", onClick: O }),
1461
+ /* @__PURE__ */ d(Oe, { label: "50%", onClick: K }),
1462
+ /* @__PURE__ */ d(Oe, { label: "25%", onClick: q })
1316
1463
  ] })
1317
1464
  }
1318
1465
  ),
1319
1466
  /* @__PURE__ */ d(
1320
- Ge,
1467
+ nt,
1321
1468
  {
1322
1469
  label: "To",
1323
1470
  labelTone: "success",
1324
1471
  token: n,
1325
1472
  networkLogo: s,
1326
- assetBaseUrl: a,
1327
- amount: w || "0.0",
1328
- usdValue: V || "$0.000",
1329
- balance: f(R),
1330
- onOpenToken: x,
1331
- amountRef: G,
1473
+ assetBaseUrl: l,
1474
+ amount: u || "0.0",
1475
+ usdValue: T || "$0.000",
1476
+ balance: o($),
1477
+ onOpenToken: I,
1478
+ tokenLocked: fe,
1479
+ amountRef: w,
1332
1480
  readOnly: !0
1333
1481
  }
1334
1482
  ),
@@ -1336,124 +1484,125 @@ function qt(t) {
1336
1484
  "button",
1337
1485
  {
1338
1486
  type: "button",
1339
- className: ee,
1340
- disabled: C ? J : !1,
1341
- onClick: C ? () => {
1342
- } : A,
1343
- children: C ? zt[l] : "Connect Wallet"
1487
+ className: z,
1488
+ disabled: oe,
1489
+ onClick: E ? J : V,
1490
+ children: E ? nn[L] : "Connect Wallet"
1344
1491
  }
1345
1492
  ),
1346
- /* @__PURE__ */ v("div", { className: "dw-flex dw-items-center dw-justify-between dw-min-h-[12px] dw-px-0.5", children: [
1347
- /* @__PURE__ */ v("div", { className: "dw-flex dw-items-center dw-gap-1 dw-min-w-0", children: [
1348
- /* @__PURE__ */ d("img", { src: Kt, alt: "", className: "dw-w-[10px] dw-h-[10px]" }),
1349
- /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)]", children: S ? c ?? "—" : "$<0.01" })
1493
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between dw-min-h-[12px] dw-px-0.5", children: [
1494
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-1 dw-min-w-0", children: [
1495
+ /* @__PURE__ */ d("img", { src: tn, alt: "", className: "dw-w-[10px] dw-h-[10px]" }),
1496
+ /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)]", children: c ? N ?? "—" : "$<0.01" })
1350
1497
  ] }),
1351
- /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] dw-truncate dw-ml-3", children: S && (e != null && e.symbol) && (n != null && n.symbol) ? `1 ${e.symbol} = ${y} ${n.symbol}` : "" })
1498
+ /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] dw-truncate dw-ml-3", children: c && (t != null && t.symbol) && (n != null && n.symbol) ? `1 ${t.symbol} = ${b} ${n.symbol}` : "" })
1352
1499
  ] })
1353
1500
  ] })
1354
1501
  ] });
1355
1502
  }
1356
- function Ge(t) {
1503
+ function nt(e) {
1357
1504
  const {
1358
- label: e,
1505
+ label: t,
1359
1506
  labelTone: n,
1360
1507
  token: r,
1361
1508
  networkLogo: s,
1362
- assetBaseUrl: a,
1509
+ assetBaseUrl: l,
1363
1510
  amount: i,
1364
- amountPlaceholder: w = "0.0",
1365
- usdValue: h,
1366
- balance: p,
1367
- onOpenToken: N,
1368
- onInputChange: x,
1369
- onKeyDown: m,
1370
- amountToneClassName: u = "dw-text-[var(--dw-fg)]",
1371
- amountRef: k,
1372
- readOnly: o = !1,
1373
- quickActions: R
1374
- } = t;
1375
- return /* @__PURE__ */ v("div", { className: "dw-widget-section dw-relative dw-flex dw-flex-col dw-w-full dw-min-h-[91px] dw-px-4 dw-py-3", children: [
1376
- /* @__PURE__ */ v("div", { className: "dw-flex dw-items-start dw-justify-between", children: [
1377
- /* @__PURE__ */ v("div", { className: "dw-flex dw-flex-col dw-gap-2", children: [
1511
+ amountPlaceholder: u = "0.0",
1512
+ usdValue: p,
1513
+ balance: g,
1514
+ onOpenToken: C,
1515
+ onInputChange: I,
1516
+ onKeyDown: k,
1517
+ amountToneClassName: m = "dw-text-[var(--dw-fg)]",
1518
+ amountRef: y,
1519
+ readOnly: v = !1,
1520
+ quickActions: $,
1521
+ tokenLocked: D = !1
1522
+ } = e;
1523
+ return /* @__PURE__ */ A("div", { className: "dw-widget-section dw-relative dw-flex dw-flex-col dw-w-full dw-min-h-[91px] dw-px-4 dw-py-3", children: [
1524
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-items-start dw-justify-between", children: [
1525
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-flex-col dw-gap-2", children: [
1378
1526
  /* @__PURE__ */ d(
1379
1527
  "h6",
1380
1528
  {
1381
1529
  className: `dw-font-normal dw-text-[11px] ${n === "danger" ? "dw-text-[var(--dw-danger)]" : "dw-text-[var(--dw-success)]"}`,
1382
- children: e
1530
+ children: t
1383
1531
  }
1384
1532
  ),
1385
- /* @__PURE__ */ v(
1533
+ /* @__PURE__ */ A(
1386
1534
  "button",
1387
1535
  {
1388
1536
  type: "button",
1389
- className: "dw-flex dw-items-center dw-gap-2 dw-cursor-pointer",
1390
- onClick: N,
1537
+ className: `dw-flex dw-items-center dw-gap-2 ${D ? "dw-cursor-not-allowed dw-opacity-60" : "dw-cursor-pointer"}`,
1538
+ onClick: C,
1539
+ disabled: D,
1391
1540
  children: [
1392
1541
  /* @__PURE__ */ d(
1393
- Jt,
1542
+ on,
1394
1543
  {
1395
1544
  token: r,
1396
1545
  networkLogo: s,
1397
- assetBaseUrl: a,
1546
+ assetBaseUrl: l,
1398
1547
  sizeClassName: "dw-w-[28px] dw-h-[28px]",
1399
1548
  badgeClassName: "dw-w-[10px] dw-h-[10px]"
1400
1549
  }
1401
1550
  ),
1402
1551
  /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[13px] dw-text-[var(--dw-fg)]", children: (r == null ? void 0 : r.symbol) ?? "Select" }),
1403
- /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: "▼" })
1552
+ /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: D ? "LOCK" : "▼" })
1404
1553
  ]
1405
1554
  }
1406
1555
  )
1407
1556
  ] }),
1408
- /* @__PURE__ */ v("div", { className: "dw-flex dw-flex-col dw-items-end dw-min-w-0", children: [
1409
- o ? /* @__PURE__ */ d(
1557
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-flex-col dw-items-end dw-min-w-0", children: [
1558
+ v ? /* @__PURE__ */ d(
1410
1559
  "p",
1411
1560
  {
1412
- ref: k,
1413
- className: `dw-font-normal dw-text-[20px] dw-min-w-[70px] dw-max-w-[124px] dw-text-right dw-truncate ${u}`,
1414
- children: i || w
1561
+ ref: y,
1562
+ className: `dw-font-normal dw-text-[20px] dw-min-w-[70px] dw-max-w-[124px] dw-text-right dw-truncate ${m}`,
1563
+ children: i || u
1415
1564
  }
1416
1565
  ) : /* @__PURE__ */ d(
1417
1566
  "input",
1418
1567
  {
1419
1568
  type: "text",
1420
- placeholder: w,
1569
+ placeholder: u,
1421
1570
  value: i,
1422
- onChange: (M) => x == null ? void 0 : x(M.target.value),
1423
- onKeyDown: m,
1424
- className: `dw-h-[28px] dw-w-[124px] dw-font-normal dw-text-right dw-bg-transparent dw-outline-none dw-border-none dw-text-[20px] ${u}`
1571
+ onChange: (T) => I == null ? void 0 : I(T.target.value),
1572
+ onKeyDown: k,
1573
+ className: `dw-h-[28px] dw-w-[124px] dw-font-normal dw-text-right dw-bg-transparent dw-outline-none dw-border-none dw-text-[20px] ${m}`
1425
1574
  }
1426
1575
  ),
1427
- /* @__PURE__ */ d("p", { className: "dw-mt-1 dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: h })
1576
+ /* @__PURE__ */ d("p", { className: "dw-mt-1 dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: p })
1428
1577
  ] })
1429
1578
  ] }),
1430
- /* @__PURE__ */ d("div", { className: "dw-w-full dw-flex dw-items-center dw-justify-between dw-mt-2 dw-min-h-[12px]", children: /* @__PURE__ */ v("div", { className: "dw-flex dw-gap-2 dw-items-center dw-min-w-0", children: [
1431
- /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: p }),
1432
- R
1579
+ /* @__PURE__ */ d("div", { className: "dw-w-full dw-flex dw-items-center dw-justify-between dw-mt-2 dw-min-h-[12px]", children: /* @__PURE__ */ A("div", { className: "dw-flex dw-gap-2 dw-items-center dw-min-w-0", children: [
1580
+ /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: g }),
1581
+ $
1433
1582
  ] }) })
1434
1583
  ] });
1435
1584
  }
1436
- function Me(t) {
1585
+ function Oe(e) {
1437
1586
  return /* @__PURE__ */ d(
1438
1587
  "button",
1439
1588
  {
1440
1589
  type: "button",
1441
1590
  className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)] dw-cursor-pointer hover:dw-text-[var(--dw-text-subtle)]",
1442
- onClick: t.onClick,
1443
- children: t.label
1591
+ onClick: e.onClick,
1592
+ children: e.label
1444
1593
  }
1445
1594
  );
1446
1595
  }
1447
- function Jt(t) {
1448
- var h;
1596
+ function on(e) {
1597
+ var p;
1449
1598
  const {
1450
- token: e,
1599
+ token: t,
1451
1600
  networkLogo: n,
1452
1601
  assetBaseUrl: r,
1453
1602
  sizeClassName: s = "dw-w-[28px] dw-h-[28px]",
1454
- badgeClassName: a = "dw-w-[10px] dw-h-[10px]"
1455
- } = t;
1456
- if (!e)
1603
+ badgeClassName: l = "dw-w-[10px] dw-h-[10px]"
1604
+ } = e;
1605
+ if (!t)
1457
1606
  return /* @__PURE__ */ d(
1458
1607
  "div",
1459
1608
  {
@@ -1461,28 +1610,28 @@ function Jt(t) {
1461
1610
  children: /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-font-normal dw-text-[var(--dw-fg)]", children: "?" })
1462
1611
  }
1463
1612
  );
1464
- const i = re(e.imageUrl, r), w = re(n, r);
1465
- return /* @__PURE__ */ v("div", { className: "dw-relative", children: [
1613
+ const i = me(t.imageUrl, r), u = me(n, r);
1614
+ return /* @__PURE__ */ A("div", { className: "dw-relative", children: [
1466
1615
  /* @__PURE__ */ d(
1467
1616
  "div",
1468
1617
  {
1469
1618
  className: `${s} dw-rounded-full dw-bg-cover dw-flex dw-items-center dw-justify-center dw-border dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-hover)]`,
1470
1619
  style: { backgroundImage: i ? `url(${i})` : "none" },
1471
- children: !i && /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-font-normal dw-text-[var(--dw-fg)]", children: ((h = e.symbol[0]) == null ? void 0 : h.toUpperCase()) ?? "?" })
1620
+ children: !i && /* @__PURE__ */ d("span", { className: "dw-text-[10px] dw-font-normal dw-text-[var(--dw-fg)]", children: ((p = t.symbol[0]) == null ? void 0 : p.toUpperCase()) ?? "?" })
1472
1621
  }
1473
1622
  ),
1474
- w && /* @__PURE__ */ d(
1623
+ u && /* @__PURE__ */ d(
1475
1624
  "div",
1476
1625
  {
1477
- className: `dw-absolute dw--bottom-0.5 dw--left-0.5 ${a} dw-rounded-full dw-bg-cover dw-border dw-border-[var(--dw-surface)]`,
1478
- style: { backgroundImage: `url(${w})` }
1626
+ className: `dw-absolute dw--bottom-0.5 dw--left-0.5 ${l} dw-rounded-full dw-bg-cover dw-border dw-border-[var(--dw-surface)]`,
1627
+ style: { backgroundImage: `url(${u})` }
1479
1628
  }
1480
1629
  )
1481
1630
  ] });
1482
1631
  }
1483
- function Gt() {
1484
- return /* @__PURE__ */ v("div", { className: "dw-flex dw-flex-row dw-justify-center dw-items-center dw-w-[14px] dw-h-[14px] dw-gap-0", children: [
1485
- /* @__PURE__ */ v(
1632
+ function sn() {
1633
+ return /* @__PURE__ */ A("div", { className: "dw-flex dw-flex-row dw-justify-center dw-items-center dw-w-[14px] dw-h-[14px] dw-gap-0", children: [
1634
+ /* @__PURE__ */ A(
1486
1635
  "svg",
1487
1636
  {
1488
1637
  className: "dw-w-[7px] dw-h-[10px] dw-flex-shrink-0 dw-transition-[transform] dw-duration-200 group-hover:dw-translate-y-[-1px] dw-text-[var(--dw-fg)]",
@@ -1506,7 +1655,7 @@ function Gt() {
1506
1655
  ]
1507
1656
  }
1508
1657
  ),
1509
- /* @__PURE__ */ v(
1658
+ /* @__PURE__ */ A(
1510
1659
  "svg",
1511
1660
  {
1512
1661
  className: "dw-w-[7px] dw-h-[10px] dw-flex-shrink-0 dw-transition-[transform] dw-duration-200 group-hover:dw-translate-y-[1px] dw-text-[var(--dw-fg)]",
@@ -1540,7 +1689,7 @@ function Gt() {
1540
1689
  )
1541
1690
  ] });
1542
1691
  }
1543
- function _t() {
1692
+ function dn() {
1544
1693
  return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ d(
1545
1694
  "path",
1546
1695
  {
@@ -1552,7 +1701,7 @@ function _t() {
1552
1701
  }
1553
1702
  ) });
1554
1703
  }
1555
- function Xt() {
1704
+ function ln() {
1556
1705
  return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ d(
1557
1706
  "path",
1558
1707
  {
@@ -1564,213 +1713,216 @@ function Xt() {
1564
1713
  }
1565
1714
  ) });
1566
1715
  }
1567
- const Zt = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAHaSURBVHgB7Zj/dYIwEMcPX/+vGzRuYDewG3QD7QS1G3SDugF0go4AG+gG4ASywfUi4XnEBAkJ4h983ruXQMjlm19ADuDBicARRJxTMgdHoigqIDRSDNmWLCbL0Z+YTEAIyNE72QmHYd1VR2QR90nJzlKnVOaK0K7faNozcEVOgdbbnOybbInV+uuF8pszv/su9SKDo5iSjbosyF6pp6WtUXBDkP3BZZO5j6LWy5VWJkfhB8NsmHp24s4dVdNYc9LK1jjcppEYN86Tds3X2IGPHCWJoX4B/TC9SxNq59g65fTAhvUoZvdTbE7LCj02jPI5V35y5ju9VWnLHt4xRxwBAcHrt0aj4zPteV5Y79wlu5eF/mQpfxm7teLlM7iNYPkChuHI8q0jaEJYHIWktLTXSeA9sH46H0WglUmgL5NAXyaBvkwCfZkE+qIL5N9Erx/SUOgCDyy/Dv1z2oeGQHUeqEXKEZS/4C8wIqY1+MXyAi5nZMndp/1KoBrFD8vzzzAMguULXmDcxSQyoWRB9tviKCR8GRXgwtinuq5O0rHOxZ0irFjFaEyH6r6hOFuUdtH7WIvNqENoZMxnA75gtV5kDGWPYcixij0KW5vOQXRNcK+A+rnhIYLqY/APHpl3hlZpXEMAAAAASUVORK5CYII=", en = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAERSURBVHgB7dShDoMwEAbgK0EgJiYmEAgEAjGx93+KCR4AMTkxMYEgYXdJSbqOo4WVgrg/uRRo034pTQEkEolk3yiInGEYMmyuWNS2SqmH2Z9AxGjMDeuElWKV9phoIAOTGZ972APEYDqsuz128zM0h8Hz00FMEGLorIwH2InZFKQxtDOpL2Yz0FoMJeEm1P8+KoaiJiassCn0K11cLUTCUKZ2qDCeS1ykhEgYDvSy3p2oUBgO1GC9wRMVEkNRzCI0Od0fZ6vr60zhuBybKhSGBRkL1tjkMIHSmNrqo51t1mKcoBnUE+sCvxjamR7+iNfFyKCCY7xBDlQwzCIQgwqKWQzSqPEmp/uqCYmRSCSSI+QD+pyUWCGG+FwAAAAASUVORK5CYII=", tn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAwCAYAAAAhOEsMAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAABZSURBVHgB7c7RCQAgCEVRa5JGbONGKT8KgtQsCPp4FwQRDkh0WRhL5eigSC/jZxJPqVOnqLiggNIWSqjfdaghE1pIhTskQg9aoBdJMHvQAidsIoQQQgj9VgNcp//kKP+JUgAAAABJRU5ErkJggg==";
1568
- function _e(t) {
1716
+ const an = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAHaSURBVHgB7Zj/dYIwEMcPX/+vGzRuYDewG3QD7QS1G3SDugF0go4AG+gG4ASywfUi4XnEBAkJ4h983ruXQMjlm19ADuDBicARRJxTMgdHoigqIDRSDNmWLCbL0Z+YTEAIyNE72QmHYd1VR2QR90nJzlKnVOaK0K7faNozcEVOgdbbnOybbInV+uuF8pszv/su9SKDo5iSjbosyF6pp6WtUXBDkP3BZZO5j6LWy5VWJkfhB8NsmHp24s4dVdNYc9LK1jjcppEYN86Tds3X2IGPHCWJoX4B/TC9SxNq59g65fTAhvUoZvdTbE7LCj02jPI5V35y5ju9VWnLHt4xRxwBAcHrt0aj4zPteV5Y79wlu5eF/mQpfxm7teLlM7iNYPkChuHI8q0jaEJYHIWktLTXSeA9sH46H0WglUmgL5NAXyaBvkwCfZkE+qIL5N9Erx/SUOgCDyy/Dv1z2oeGQHUeqEXKEZS/4C8wIqY1+MXyAi5nZMndp/1KoBrFD8vzzzAMguULXmDcxSQyoWRB9tviKCR8GRXgwtinuq5O0rHOxZ0irFjFaEyH6r6hOFuUdtH7WIvNqENoZMxnA75gtV5kDGWPYcixij0KW5vOQXRNcK+A+rnhIYLqY/APHpl3hlZpXEMAAAAASUVORK5CYII=", cn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAERSURBVHgB7dShDoMwEAbgK0EgJiYmEAgEAjGx93+KCR4AMTkxMYEgYXdJSbqOo4WVgrg/uRRo034pTQEkEolk3yiInGEYMmyuWNS2SqmH2Z9AxGjMDeuElWKV9phoIAOTGZ972APEYDqsuz128zM0h8Hz00FMEGLorIwH2InZFKQxtDOpL2Yz0FoMJeEm1P8+KoaiJiassCn0K11cLUTCUKZ2qDCeS1ykhEgYDvSy3p2oUBgO1GC9wRMVEkNRzCI0Od0fZ6vr60zhuBybKhSGBRkL1tjkMIHSmNrqo51t1mKcoBnUE+sCvxjamR7+iNfFyKCCY7xBDlQwzCIQgwqKWQzSqPEmp/uqCYmRSCSSI+QD+pyUWCGG+FwAAAAASUVORK5CYII=", wn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAwCAYAAAAhOEsMAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAABZSURBVHgB7c7RCQAgCEVRa5JGbONGKT8KgtQsCPp4FwQRDkh0WRhL5eigSC/jZxJPqVOnqLiggNIWSqjfdaghE1pIhTskQg9aoBdJMHvQAidsIoQQQgj9VgNcp//kKP+JUgAAAABJRU5ErkJggg==";
1717
+ function rt(e) {
1569
1718
  const {
1570
- mode: e,
1719
+ mode: t,
1571
1720
  selectedNetworkId: n,
1572
1721
  selectedToken: r,
1573
1722
  excludeToken: s,
1574
- getAllTokensForNetwork: a,
1723
+ getAllTokensForNetwork: l,
1575
1724
  getNetworkById: i,
1576
- onSelectToken: w,
1577
- onSelectNetwork: h,
1578
- onOpenNetworkSelector: p,
1579
- onClose: N,
1580
- assetBaseUrl: x,
1581
- displayedNetworks: m,
1582
- additionalNetworksCount: u
1583
- } = t, [k, o] = U(""), [R, M] = U(
1725
+ onSelectToken: u,
1726
+ onSelectNetwork: p,
1727
+ onOpenNetworkSelector: g,
1728
+ onClose: C,
1729
+ assetBaseUrl: I,
1730
+ displayedNetworks: k,
1731
+ additionalNetworksCount: m,
1732
+ networkSelectionLocked: y = !1
1733
+ } = e, [v, $] = B(""), [D, T] = B(
1584
1734
  /* @__PURE__ */ new Set()
1585
- ), V = D(
1586
- (l) => {
1587
- const S = i(l.chainId);
1588
- return S ? S.chainType === "SVM" ? l.symbol === "SOL" : S.chainType === "MVM" ? l.symbol === "SUI" : l.contractAddress === Vt : !1;
1735
+ ), O = M(
1736
+ (c) => {
1737
+ const h = i(c.chainId);
1738
+ return h ? h.chainType === "SVM" ? c.symbol === "SOL" : h.chainType === "MVM" ? c.symbol === "SUI" : c.contractAddress === Kt : !1;
1589
1739
  },
1590
1740
  [i]
1591
- ), L = D(
1592
- (l, S) => {
1593
- S.stopPropagation(), navigator.clipboard.writeText(l).then(() => {
1594
- M((g) => new Set(g).add(l)), setTimeout(() => {
1595
- M((g) => {
1596
- const y = new Set(g);
1597
- return y.delete(l), y;
1741
+ ), K = M(
1742
+ (c, h) => {
1743
+ h.stopPropagation(), navigator.clipboard.writeText(c).then(() => {
1744
+ T((b) => new Set(b).add(c)), setTimeout(() => {
1745
+ T((b) => {
1746
+ const N = new Set(b);
1747
+ return N.delete(c), N;
1598
1748
  });
1599
1749
  }, 2e3);
1600
1750
  }).catch(() => console.error("Failed to copy to clipboard"));
1601
1751
  },
1602
1752
  []
1603
- ), j = ie(() => {
1604
- var y;
1605
- const l = n ?? ((y = m[0]) == null ? void 0 : y.id);
1606
- if (!l) return [];
1607
- const S = a(l);
1608
- if (!k.trim())
1609
- return S.filter(
1610
- (c) => !s || !(c.contractAddress === s.contractAddress && c.chainId === s.chainId)
1753
+ ), L = ue(() => {
1754
+ var N;
1755
+ const c = n ?? ((N = k[0]) == null ? void 0 : N.id);
1756
+ if (!c) return [];
1757
+ const h = l(c);
1758
+ if (!v.trim())
1759
+ return h.filter(
1760
+ (o) => !s || !(o.contractAddress === s.contractAddress && o.chainId === s.chainId)
1611
1761
  );
1612
- const g = k.toLowerCase();
1613
- return S.filter(
1614
- (c) => {
1615
- var f, C;
1616
- return (((f = c.symbol) == null ? void 0 : f.toLowerCase().includes(g)) || ((C = c.contractAddress) == null ? void 0 : C.toLowerCase().includes(g))) && (!s || !(c.contractAddress === s.contractAddress && c.chainId === s.chainId));
1762
+ const b = v.toLowerCase();
1763
+ return h.filter(
1764
+ (o) => {
1765
+ var E, V;
1766
+ return (((E = o.symbol) == null ? void 0 : E.toLowerCase().includes(b)) || ((V = o.contractAddress) == null ? void 0 : V.toLowerCase().includes(b))) && (!s || !(o.contractAddress === s.contractAddress && o.chainId === s.chainId));
1617
1767
  }
1618
1768
  );
1619
1769
  }, [
1620
1770
  n,
1621
- a,
1622
- k,
1771
+ l,
1772
+ v,
1623
1773
  s,
1624
- m
1774
+ k
1625
1775
  ]);
1626
- return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-top-0 dw-left-1/2 dw--translate-x-1/2 dw-max-h-[420px] dw-h-full dw-z-50 dw-flex dw-items-start dw-justify-center", children: /* @__PURE__ */ v(
1776
+ return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-top-0 dw-left-1/2 dw--translate-x-1/2 dw-max-h-[420px] dw-h-full dw-z-50 dw-flex dw-items-start dw-justify-center", children: /* @__PURE__ */ A(
1627
1777
  "div",
1628
1778
  {
1629
1779
  className: "dw-modal-surface dw-popup-content dw-w-[304px] dw-h-full dw-flex dw-flex-col dw-rounded-[var(--dw-radius)] dw-p-3 dw-overflow-hidden",
1630
- onClick: (l) => l.stopPropagation(),
1780
+ onClick: (c) => c.stopPropagation(),
1631
1781
  children: [
1632
- /* @__PURE__ */ v("div", { className: "dw-flex dw-items-center dw-justify-between", children: [
1633
- /* @__PURE__ */ d("h3", { className: "dw-text-[14px] dw-font-normal dw-text-[var(--dw-fg)]", children: e === "sell" ? "Exchange from" : "Exchange to" }),
1782
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between", children: [
1783
+ /* @__PURE__ */ d("h3", { className: "dw-text-[14px] dw-font-normal dw-text-[var(--dw-fg)]", children: t === "sell" ? "Exchange from" : "Exchange to" }),
1634
1784
  /* @__PURE__ */ d(
1635
1785
  "button",
1636
1786
  {
1637
1787
  type: "button",
1638
1788
  className: "dw-icon-button dw-w-4 dw-h-4 dw-rounded-[4px] dw-opacity-70 dw-cursor-pointer",
1639
- onClick: N,
1789
+ onClick: C,
1640
1790
  "aria-label": "Close",
1641
- children: /* @__PURE__ */ d(nn, {})
1791
+ children: /* @__PURE__ */ d(un, {})
1642
1792
  }
1643
1793
  )
1644
1794
  ] }),
1645
- /* @__PURE__ */ v("div", { className: "dw-flex dw-gap-1 dw-mt-3 dw-flex-wrap", children: [
1646
- m.map((l) => /* @__PURE__ */ d(
1795
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-gap-1 dw-mt-3 dw-flex-wrap", children: [
1796
+ k.map((c) => /* @__PURE__ */ d(
1647
1797
  "button",
1648
1798
  {
1649
1799
  type: "button",
1650
- className: `dw-w-[34px] dw-h-[34px] dw-flex dw-items-center dw-justify-center dw-border dw-rounded-[6px] dw-transition ${n === l.id ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)]" : "dw-bg-[var(--dw-surface-alt)] dw-border-[var(--dw-border)] hover:dw-bg-[var(--dw-surface-hover)]"}`,
1651
- onClick: () => h(l),
1652
- title: l.name,
1653
- children: l.logoURI && /* @__PURE__ */ d(
1800
+ className: `dw-w-[34px] dw-h-[34px] dw-flex dw-items-center dw-justify-center dw-border dw-rounded-[6px] dw-transition ${n === c.id ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)]" : "dw-bg-[var(--dw-surface-alt)] dw-border-[var(--dw-border)] hover:dw-bg-[var(--dw-surface-hover)]"} ${y ? "dw-cursor-not-allowed dw-opacity-50" : ""}`,
1801
+ onClick: () => p(c),
1802
+ title: c.name,
1803
+ disabled: y,
1804
+ children: c.logoURI && /* @__PURE__ */ d(
1654
1805
  "img",
1655
1806
  {
1656
- src: re(l.logoURI, x),
1807
+ src: me(c.logoURI, I),
1657
1808
  alt: "",
1658
1809
  className: "dw-w-5 dw-h-5 dw-object-cover"
1659
1810
  }
1660
1811
  )
1661
1812
  },
1662
- l.id
1813
+ c.id
1663
1814
  )),
1664
- u > 0 && /* @__PURE__ */ d(
1815
+ m > 0 && /* @__PURE__ */ d(
1665
1816
  "button",
1666
1817
  {
1667
1818
  type: "button",
1668
- className: "dw-min-w-[34px] dw-h-[34px] dw-px-2 dw-flex dw-items-center dw-justify-center dw-rounded-[6px] dw-border dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-alt)] hover:dw-bg-[var(--dw-surface-hover)] dw-transition dw-cursor-pointer",
1669
- onClick: p,
1819
+ className: `dw-min-w-[34px] dw-h-[34px] dw-px-2 dw-flex dw-items-center dw-justify-center dw-rounded-[6px] dw-border dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-alt)] hover:dw-bg-[var(--dw-surface-hover)] dw-transition ${y ? "dw-cursor-not-allowed dw-opacity-50" : "dw-cursor-pointer"}`,
1820
+ onClick: g,
1670
1821
  title: "More networks",
1671
- children: /* @__PURE__ */ v("p", { className: "dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)]", children: [
1672
- u,
1822
+ disabled: y,
1823
+ children: /* @__PURE__ */ A("p", { className: "dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)]", children: [
1824
+ m,
1673
1825
  "+"
1674
1826
  ] })
1675
1827
  }
1676
1828
  )
1677
1829
  ] }),
1678
- /* @__PURE__ */ v("div", { className: "dw-field-shell dw-flex dw-items-center dw-gap-2 dw-h-[34px] dw-mt-3 dw-rounded-[6px] dw-px-3", children: [
1830
+ /* @__PURE__ */ A("div", { className: "dw-field-shell dw-flex dw-items-center dw-gap-2 dw-h-[34px] dw-mt-3 dw-rounded-[6px] dw-px-3", children: [
1679
1831
  /* @__PURE__ */ d(
1680
1832
  "input",
1681
1833
  {
1682
1834
  type: "text",
1683
1835
  placeholder: "Search by name or contract address",
1684
- value: k,
1685
- onChange: (l) => o(l.target.value),
1836
+ value: v,
1837
+ onChange: (c) => $(c.target.value),
1686
1838
  className: "dw-flex-1 dw-h-5 dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)] dw-bg-transparent dw-outline-none dw-border-none"
1687
1839
  }
1688
1840
  ),
1689
- /* @__PURE__ */ d(rn, {})
1841
+ /* @__PURE__ */ d(fn, {})
1690
1842
  ] }),
1691
- /* @__PURE__ */ v("div", { className: "dw-flex dw-items-center dw-justify-between dw-mt-2.5 dw-px-0.5", children: [
1843
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between dw-mt-2.5 dw-px-0.5", children: [
1692
1844
  /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[11px] dw-text-[var(--dw-text-subtle)]", children: "Token list" }),
1693
1845
  /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[11px] dw-text-[var(--dw-text-subtle)]", children: "Contracts" })
1694
1846
  ] }),
1695
- /* @__PURE__ */ d("div", { className: "dw-widget-list dw-flex-1 dw-overflow-y-auto dw-mt-2 dw-pr-1 dw-flex dw-flex-col dw-gap-1", children: j.map((l) => {
1696
- var A;
1697
- const S = i(l.chainId), y = `${(S == null ? void 0 : S.explorerUrl) ?? "https://etherscan.io/token/"}${l.contractAddress}`, c = l.contractAddress.length > 10 ? `${l.contractAddress.slice(0, 4)}…${l.contractAddress.slice(-3)}` : l.contractAddress, f = R.has(l.contractAddress), C = !V(l);
1698
- return /* @__PURE__ */ v(
1847
+ /* @__PURE__ */ d("div", { className: "dw-widget-list dw-flex-1 dw-overflow-y-auto dw-mt-2 dw-pr-1 dw-flex dw-flex-col dw-gap-1", children: L.map((c) => {
1848
+ var J;
1849
+ const h = i(c.chainId), N = `${(h == null ? void 0 : h.explorerUrl) ?? "https://etherscan.io/token/"}${c.contractAddress}`, o = c.contractAddress.length > 10 ? `${c.contractAddress.slice(0, 4)}…${c.contractAddress.slice(-3)}` : c.contractAddress, E = D.has(c.contractAddress), V = !O(c);
1850
+ return /* @__PURE__ */ A(
1699
1851
  "button",
1700
1852
  {
1701
1853
  type: "button",
1702
- className: `dw-w-full dw-min-h-[48px] dw-flex dw-items-center dw-justify-between dw-rounded-[6px] dw-px-3 dw-py-2 dw-text-left dw-transition dw-cursor-pointer dw-border ${(r == null ? void 0 : r.contractAddress) === l.contractAddress && (r == null ? void 0 : r.chainId) === l.chainId ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)]" : "dw-bg-transparent dw-border-transparent hover:dw-bg-[var(--dw-surface-alt)] hover:dw-border-[var(--dw-border)]"}`,
1703
- onClick: () => w(l),
1854
+ className: `dw-w-full dw-min-h-[48px] dw-flex dw-items-center dw-justify-between dw-rounded-[6px] dw-px-3 dw-py-2 dw-text-left dw-transition dw-cursor-pointer dw-border ${(r == null ? void 0 : r.contractAddress) === c.contractAddress && (r == null ? void 0 : r.chainId) === c.chainId ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)]" : "dw-bg-transparent dw-border-transparent hover:dw-bg-[var(--dw-surface-alt)] hover:dw-border-[var(--dw-border)]"}`,
1855
+ onClick: () => u(c),
1704
1856
  children: [
1705
- /* @__PURE__ */ v("div", { className: "dw-flex dw-items-center dw-gap-2 dw-min-w-0", children: [
1857
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-2 dw-min-w-0", children: [
1706
1858
  /* @__PURE__ */ d(
1707
1859
  "div",
1708
1860
  {
1709
1861
  className: "dw-w-[28px] dw-h-[28px] dw-rounded-full dw-flex dw-items-center dw-justify-center dw-bg-cover dw-bg-[var(--dw-surface-hover)] dw-border dw-border-[var(--dw-border)] dw-flex-shrink-0",
1710
1862
  style: {
1711
- backgroundImage: re(
1712
- l.imageUrl,
1713
- x
1714
- ) ? `url(${re(l.imageUrl, x)})` : "none"
1863
+ backgroundImage: me(
1864
+ c.imageUrl,
1865
+ I
1866
+ ) ? `url(${me(c.imageUrl, I)})` : "none"
1715
1867
  },
1716
- children: !re(l.imageUrl, x) && /* @__PURE__ */ d("span", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)]", children: ((A = l.symbol[0]) == null ? void 0 : A.toUpperCase()) ?? "?" })
1868
+ children: !me(c.imageUrl, I) && /* @__PURE__ */ d("span", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-fg)]", children: ((J = c.symbol[0]) == null ? void 0 : J.toUpperCase()) ?? "?" })
1717
1869
  }
1718
1870
  ),
1719
- /* @__PURE__ */ v("div", { className: "dw-min-w-0", children: [
1720
- /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)] dw-truncate", children: l.symbol }),
1721
- l.name && /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] dw-truncate", children: l.name })
1871
+ /* @__PURE__ */ A("div", { className: "dw-min-w-0", children: [
1872
+ /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)] dw-truncate", children: c.symbol }),
1873
+ c.name && /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] dw-truncate", children: c.name })
1722
1874
  ] })
1723
1875
  ] }),
1724
- /* @__PURE__ */ v("div", { className: "dw-flex dw-flex-col dw-items-end dw-gap-1 dw-flex-shrink-0", children: [
1725
- C && /* @__PURE__ */ v("div", { className: "dw-flex dw-items-center dw-gap-2.5", children: [
1876
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-flex-col dw-items-end dw-gap-1 dw-flex-shrink-0", children: [
1877
+ V && /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-2.5", children: [
1726
1878
  /* @__PURE__ */ d(
1727
1879
  "button",
1728
1880
  {
1729
1881
  type: "button",
1730
- className: `dw-w-[12px] dw-h-[12px] dw-flex-shrink-0 dw-bg-cover dw-bg-no-repeat dw-cursor-pointer dw-transition-opacity hover:dw-opacity-100 ${f ? "dw-opacity-100" : "dw-opacity-50"}`,
1882
+ className: `dw-w-[12px] dw-h-[12px] dw-flex-shrink-0 dw-bg-cover dw-bg-no-repeat dw-cursor-pointer dw-transition-opacity hover:dw-opacity-100 ${E ? "dw-opacity-100" : "dw-opacity-50"}`,
1731
1883
  style: {
1732
- backgroundImage: `url(${f ? en : Zt})`
1884
+ backgroundImage: `url(${E ? cn : an})`
1733
1885
  },
1734
- onClick: (T) => L(l.contractAddress, T),
1886
+ onClick: (G) => K(c.contractAddress, G),
1735
1887
  "aria-label": "Copy address"
1736
1888
  }
1737
1889
  ),
1738
- /* @__PURE__ */ v(
1890
+ /* @__PURE__ */ A(
1739
1891
  "a",
1740
1892
  {
1741
- href: y,
1893
+ href: N,
1742
1894
  target: "_blank",
1743
1895
  rel: "noopener noreferrer",
1744
1896
  className: "dw-flex dw-items-center dw-gap-1 dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)] hover:dw-text-[var(--dw-fg)] dw-transition-colors",
1745
- onClick: (T) => T.stopPropagation(),
1897
+ onClick: (G) => G.stopPropagation(),
1746
1898
  children: [
1747
- /* @__PURE__ */ d("span", { children: c }),
1899
+ /* @__PURE__ */ d("span", { children: o }),
1748
1900
  /* @__PURE__ */ d(
1749
1901
  "span",
1750
1902
  {
1751
1903
  className: "dw-w-[6px] dw-h-[10px] dw-flex-shrink-0 dw-bg-cover dw-bg-no-repeat",
1752
- style: { backgroundImage: `url(${tn})` }
1904
+ style: { backgroundImage: `url(${wn})` }
1753
1905
  }
1754
1906
  )
1755
1907
  ]
1756
1908
  }
1757
1909
  )
1758
1910
  ] }),
1759
- !C && /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: "Native" })
1911
+ !V && /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[10px] dw-text-[var(--dw-text-subtle)]", children: "Native" })
1760
1912
  ] })
1761
1913
  ]
1762
1914
  },
1763
- `${l.chainId}-${l.contractAddress}`
1915
+ `${c.chainId}-${c.contractAddress}`
1764
1916
  );
1765
1917
  }) })
1766
1918
  ]
1767
1919
  }
1768
1920
  ) });
1769
1921
  }
1770
- function nn() {
1922
+ function un() {
1771
1923
  return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ d("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) });
1772
1924
  }
1773
- function rn() {
1925
+ function fn() {
1774
1926
  return /* @__PURE__ */ d("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ d(
1775
1927
  "path",
1776
1928
  {
@@ -1782,19 +1934,19 @@ function rn() {
1782
1934
  }
1783
1935
  ) });
1784
1936
  }
1785
- function Xe(t) {
1786
- const { networks: e, onSelectNetwork: n, onClose: r, assetBaseUrl: s } = t, [a, i] = U(""), w = ie(() => {
1787
- if (!a.trim()) return e;
1788
- const h = a.toLowerCase();
1789
- return e.filter((p) => p.name.toLowerCase().includes(h));
1790
- }, [e, a]);
1791
- return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-top-0 dw-left-1/2 dw--translate-x-1/2 dw-max-h-[420px] dw-h-full dw-z-[60] dw-flex dw-items-start dw-justify-center", children: /* @__PURE__ */ v(
1937
+ function ot(e) {
1938
+ const { networks: t, onSelectNetwork: n, onClose: r, assetBaseUrl: s } = e, [l, i] = B(""), u = ue(() => {
1939
+ if (!l.trim()) return t;
1940
+ const p = l.toLowerCase();
1941
+ return t.filter((g) => g.name.toLowerCase().includes(p));
1942
+ }, [t, l]);
1943
+ return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-top-0 dw-left-1/2 dw--translate-x-1/2 dw-max-h-[420px] dw-h-full dw-z-[60] dw-flex dw-items-start dw-justify-center", children: /* @__PURE__ */ A(
1792
1944
  "div",
1793
1945
  {
1794
1946
  className: "dw-modal-surface dw-popup-content dw-w-[304px] dw-h-full dw-flex dw-flex-col dw-rounded-[var(--dw-radius)] dw-p-3 dw-overflow-hidden",
1795
- onClick: (h) => h.stopPropagation(),
1947
+ onClick: (p) => p.stopPropagation(),
1796
1948
  children: [
1797
- /* @__PURE__ */ v("div", { className: "dw-flex dw-items-center dw-justify-between", children: [
1949
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between", children: [
1798
1950
  /* @__PURE__ */ d("h3", { className: "dw-text-[14px] dw-font-normal dw-text-[var(--dw-fg)]", children: "Select ecosystem" }),
1799
1951
  /* @__PURE__ */ d(
1800
1952
  "button",
@@ -1803,52 +1955,52 @@ function Xe(t) {
1803
1955
  className: "dw-icon-button dw-w-4 dw-h-4 dw-rounded-[4px] dw-opacity-70 dw-cursor-pointer",
1804
1956
  onClick: r,
1805
1957
  "aria-label": "Close",
1806
- children: /* @__PURE__ */ d(on, {})
1958
+ children: /* @__PURE__ */ d(pn, {})
1807
1959
  }
1808
1960
  )
1809
1961
  ] }),
1810
- /* @__PURE__ */ v("div", { className: "dw-field-shell dw-flex dw-items-center dw-gap-2 dw-h-[34px] dw-mt-3 dw-rounded-[6px] dw-px-3", children: [
1962
+ /* @__PURE__ */ A("div", { className: "dw-field-shell dw-flex dw-items-center dw-gap-2 dw-h-[34px] dw-mt-3 dw-rounded-[6px] dw-px-3", children: [
1811
1963
  /* @__PURE__ */ d(
1812
1964
  "input",
1813
1965
  {
1814
1966
  type: "text",
1815
1967
  placeholder: "Search by name",
1816
- value: a,
1817
- onChange: (h) => i(h.target.value),
1968
+ value: l,
1969
+ onChange: (p) => i(p.target.value),
1818
1970
  className: "dw-flex-1 dw-h-5 dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)] dw-bg-transparent dw-outline-none dw-border-none"
1819
1971
  }
1820
1972
  ),
1821
- /* @__PURE__ */ d(sn, {})
1973
+ /* @__PURE__ */ d(hn, {})
1822
1974
  ] }),
1823
- /* @__PURE__ */ d("div", { className: "dw-widget-list dw-flex-1 dw-overflow-y-auto dw-mt-3 dw-pr-1 dw-grid dw-grid-cols-2 dw-gap-1.5", children: w.map((h) => /* @__PURE__ */ v(
1975
+ /* @__PURE__ */ d("div", { className: "dw-widget-list dw-flex-1 dw-overflow-y-auto dw-mt-3 dw-pr-1 dw-grid dw-grid-cols-2 dw-gap-1.5", children: u.map((p) => /* @__PURE__ */ A(
1824
1976
  "button",
1825
1977
  {
1826
1978
  type: "button",
1827
1979
  className: "dw-w-full dw-min-h-[36px] dw-flex dw-items-center dw-gap-2 dw-rounded-[6px] dw-px-2.5 dw-py-2 dw-text-left dw-transition dw-cursor-pointer dw-bg-transparent dw-border dw-border-transparent hover:dw-bg-[var(--dw-surface-alt)] hover:dw-border-[var(--dw-border)]",
1828
- onClick: () => n(h),
1980
+ onClick: () => n(p),
1829
1981
  children: [
1830
1982
  /* @__PURE__ */ d(
1831
1983
  "div",
1832
1984
  {
1833
1985
  className: "dw-w-[18px] dw-h-[18px] dw-rounded-[4px] dw-flex-shrink-0 dw-bg-cover dw-bg-center",
1834
1986
  style: {
1835
- backgroundImage: h.logoURI ? `url(${re(h.logoURI, s)})` : "none"
1987
+ backgroundImage: p.logoURI ? `url(${me(p.logoURI, s)})` : "none"
1836
1988
  }
1837
1989
  }
1838
1990
  ),
1839
- /* @__PURE__ */ d("h6", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)] dw-truncate", children: h.name })
1991
+ /* @__PURE__ */ d("h6", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)] dw-truncate", children: p.name })
1840
1992
  ]
1841
1993
  },
1842
- h.id
1994
+ p.id
1843
1995
  )) })
1844
1996
  ]
1845
1997
  }
1846
1998
  ) });
1847
1999
  }
1848
- function on() {
2000
+ function pn() {
1849
2001
  return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ d("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) });
1850
2002
  }
1851
- function sn() {
2003
+ function hn() {
1852
2004
  return /* @__PURE__ */ d("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ d(
1853
2005
  "path",
1854
2006
  {
@@ -1860,94 +2012,94 @@ function sn() {
1860
2012
  }
1861
2013
  ) });
1862
2014
  }
1863
- const dn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIFSURBVHgB7Vf/VcMgEL5MYJxAnMBuIBvYDewIbtJukG5QnSB1AusEwQkaJzjvBF5ICg1Jaf/ie+979KUHHNwvDiAj47ooIDEQsaRhQXwhCvNbOCItURl+EvdFURzGFl0QBcxTSBIr4hGnoyGuQguvHcHKbFSOKCOIb8Qa02Bn1y6cTTCwP1+zvX4La56zihu0DsHMESFhMmvfvRKemk1ZEVcYcAv6XqK2CN9248z98gmzWbY4H7XZKOYWh3vL4dzCdxoaJHFJfAJtNh/YNGxmG1l7SIiodOExSUuKtJCRMY7kJcnC+KUEnbcezMh++Qtd4Bxu4qsm7Nc4rSzVeCbn8aKvqJNdxRtAJFAnyxRlqWEd7LpuSWqgXyoUdHlqWP1ZzuY4CenAaeh+qNgR4mpfLPbEb9CHUoP/+EDPcPokUqTYY0/S2LnBy1DjxLKE2i+3OPL0EUbBOl6Xf0ff4AS/jEEwXWD3EmWWhnegw12BDnmukQoyMsK4WkmyML7ai9IYv7xG+yZB5ygebeD4cDD8AB1EbWhBW1okTFcmRVmq0Fcv6ePOEWqskhhIltjlvArn9ZI+1Hb92JKkoN9+lRDfuvFct9YKM9fbS/jat0s6pN6pUd+2gDNAbf7lYN9NSHhuvbS9pIQZQO0WvRssAoL2OcPRJeC061agzfNDfIdbvUQzMhLiDyT6chuOT10RAAAAAElFTkSuQmCC";
1864
- function an(t) {
2015
+ const mn = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAYAAACoPemuAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIFSURBVHgB7Vf/VcMgEL5MYJxAnMBuIBvYDewIbtJukG5QnSB1AusEwQkaJzjvBF5ICg1Jaf/ie+979KUHHNwvDiAj47ooIDEQsaRhQXwhCvNbOCItURl+EvdFURzGFl0QBcxTSBIr4hGnoyGuQguvHcHKbFSOKCOIb8Qa02Bn1y6cTTCwP1+zvX4La56zihu0DsHMESFhMmvfvRKemk1ZEVcYcAv6XqK2CN9248z98gmzWbY4H7XZKOYWh3vL4dzCdxoaJHFJfAJtNh/YNGxmG1l7SIiodOExSUuKtJCRMY7kJcnC+KUEnbcezMh++Qtd4Bxu4qsm7Nc4rSzVeCbn8aKvqJNdxRtAJFAnyxRlqWEd7LpuSWqgXyoUdHlqWP1ZzuY4CenAaeh+qNgR4mpfLPbEb9CHUoP/+EDPcPokUqTYY0/S2LnBy1DjxLKE2i+3OPL0EUbBOl6Xf0ff4AS/jEEwXWD3EmWWhnegw12BDnmukQoyMsK4WkmyML7ai9IYv7xG+yZB5ygebeD4cDD8AB1EbWhBW1okTFcmRVmq0Fcv6ePOEWqskhhIltjlvArn9ZI+1Hb92JKkoN9+lRDfuvFct9YKM9fbS/jat0s6pN6pUd+2gDNAbf7lYN9NSHhuvbS9pIQZQO0WvRssAoL2OcPRJeC061agzfNDfIdbvUQzMhLiDyT6chuOT10RAAAAAElFTkSuQmCC";
2016
+ function gn(e) {
1865
2017
  const {
1866
- options: e,
2018
+ options: t,
1867
2019
  selectedIndex: n,
1868
2020
  customValue: r,
1869
2021
  onSelectOption: s,
1870
- onCustomChange: a,
2022
+ onCustomChange: l,
1871
2023
  onSave: i,
1872
- onClose: w
1873
- } = t, [h, p] = U(r), N = (m) => {
1874
- let u = m.target.value.replace(/,/g, ".");
1875
- u.startsWith(".") && (u = "0" + u), u = u.replace(/[^0-9.]/g, "");
1876
- const k = u.indexOf(".");
1877
- k >= 0 && (u = u.slice(0, k + 1) + u.slice(k + 1).replace(/\./g, "")), u = u.slice(0, 4), p(u), a(u);
1878
- }, x = () => {
1879
- let m;
2024
+ onClose: u
2025
+ } = e, [p, g] = B(r), C = (k) => {
2026
+ let m = k.target.value.replace(/,/g, ".");
2027
+ m.startsWith(".") && (m = "0" + m), m = m.replace(/[^0-9.]/g, "");
2028
+ const y = m.indexOf(".");
2029
+ y >= 0 && (m = m.slice(0, y + 1) + m.slice(y + 1).replace(/\./g, "")), m = m.slice(0, 4), g(m), l(m);
2030
+ }, I = () => {
2031
+ let k;
1880
2032
  if (n !== null)
1881
- m = e[n];
1882
- else if (h)
1883
- m = h + "%";
2033
+ k = t[n];
2034
+ else if (p)
2035
+ k = p + "%";
1884
2036
  else
1885
2037
  return;
1886
2038
  try {
1887
- i(m), w();
1888
- } catch (u) {
1889
- console.error(u);
2039
+ i(k), u();
2040
+ } catch (m) {
2041
+ console.error(m);
1890
2042
  }
1891
2043
  };
1892
- return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-inset-0 dw-z-50 dw-flex dw-items-center dw-justify-center", children: /* @__PURE__ */ v(
2044
+ return /* @__PURE__ */ d("div", { className: "dw-popup-backdrop dw-absolute dw-inset-0 dw-z-50 dw-flex dw-items-center dw-justify-center", children: /* @__PURE__ */ A(
1893
2045
  "div",
1894
2046
  {
1895
2047
  className: "dw-modal-surface dw-popup-content dw-w-[304px] dw-flex dw-flex-col dw-rounded-[var(--dw-radius)] dw-p-3",
1896
- onClick: (m) => m.stopPropagation(),
2048
+ onClick: (k) => k.stopPropagation(),
1897
2049
  children: [
1898
- /* @__PURE__ */ v("div", { className: "dw-flex dw-items-center dw-justify-between", children: [
2050
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-justify-between", children: [
1899
2051
  /* @__PURE__ */ d("h3", { className: "dw-font-normal dw-text-[14px] dw-text-[var(--dw-fg)]", children: "Settings" }),
1900
2052
  /* @__PURE__ */ d(
1901
2053
  "button",
1902
2054
  {
1903
2055
  type: "button",
1904
2056
  className: "dw-icon-button dw-w-4 dw-h-4 dw-rounded-[4px] dw-opacity-70 dw-cursor-pointer",
1905
- onClick: w,
2057
+ onClick: u,
1906
2058
  "aria-label": "Close",
1907
- children: /* @__PURE__ */ d(ln, {})
2059
+ children: /* @__PURE__ */ d(kn, {})
1908
2060
  }
1909
2061
  )
1910
2062
  ] }),
1911
- /* @__PURE__ */ v("div", { className: "dw-flex dw-items-center dw-gap-2 dw-mt-3", children: [
2063
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-2 dw-mt-3", children: [
1912
2064
  /* @__PURE__ */ d(
1913
2065
  "img",
1914
2066
  {
1915
- src: dn,
2067
+ src: mn,
1916
2068
  alt: "",
1917
2069
  className: "dw-w-[14px] dw-h-[14px] dw-object-cover"
1918
2070
  }
1919
2071
  ),
1920
2072
  /* @__PURE__ */ d("p", { className: "dw-font-normal dw-text-[12px] dw-text-[var(--dw-fg)]", children: "Slippage limit" })
1921
2073
  ] }),
1922
- /* @__PURE__ */ v("div", { className: "dw-flex dw-items-center dw-gap-1 dw-mt-3 dw-flex-wrap", children: [
1923
- e.map((m, u) => /* @__PURE__ */ d(
2074
+ /* @__PURE__ */ A("div", { className: "dw-flex dw-items-center dw-gap-1 dw-mt-3 dw-flex-wrap", children: [
2075
+ t.map((k, m) => /* @__PURE__ */ d(
1924
2076
  "button",
1925
2077
  {
1926
2078
  type: "button",
1927
- className: `dw-font-normal dw-text-[11px] dw-px-3 dw-py-1.5 dw-rounded-[6px] dw-border dw-transition ${n === u ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)] dw-text-[var(--dw-fg)]" : "dw-bg-transparent dw-border-[var(--dw-border)] dw-text-[var(--dw-text-subtle)] hover:dw-bg-[var(--dw-surface-alt)] hover:dw-text-[var(--dw-fg)]"}`,
1928
- onClick: () => s(u),
1929
- children: m
2079
+ className: `dw-font-normal dw-text-[11px] dw-px-3 dw-py-1.5 dw-rounded-[6px] dw-border dw-transition ${n === m ? "dw-bg-[var(--dw-surface-hover)] dw-border-[var(--dw-accent)] dw-text-[var(--dw-fg)]" : "dw-bg-transparent dw-border-[var(--dw-border)] dw-text-[var(--dw-text-subtle)] hover:dw-bg-[var(--dw-surface-alt)] hover:dw-text-[var(--dw-fg)]"}`,
2080
+ onClick: () => s(m),
2081
+ children: k
1930
2082
  },
1931
- m
2083
+ k
1932
2084
  )),
1933
- /* @__PURE__ */ v(
2085
+ /* @__PURE__ */ A(
1934
2086
  "div",
1935
2087
  {
1936
- className: `dw-relative dw-w-[72px] dw-h-[30px] dw-flex dw-items-center dw-justify-center dw-rounded-[6px] dw-border ${n === null && h ? "dw-border-[var(--dw-accent)] dw-bg-[var(--dw-surface-hover)]" : "dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-alt)]"}`,
2088
+ className: `dw-relative dw-w-[72px] dw-h-[30px] dw-flex dw-items-center dw-justify-center dw-rounded-[6px] dw-border ${n === null && p ? "dw-border-[var(--dw-accent)] dw-bg-[var(--dw-surface-hover)]" : "dw-border-[var(--dw-border)] dw-bg-[var(--dw-surface-alt)]"}`,
1937
2089
  children: [
1938
2090
  /* @__PURE__ */ d(
1939
2091
  "input",
1940
2092
  {
1941
2093
  type: "text",
1942
2094
  placeholder: "Custom",
1943
- value: h,
1944
- onChange: N,
1945
- onFocus: () => a(""),
2095
+ value: p,
2096
+ onChange: C,
2097
+ onFocus: () => l(""),
1946
2098
  maxLength: 4,
1947
2099
  className: "dw-w-10 dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)] dw-bg-transparent dw-border-none dw-outline-none dw-text-center"
1948
2100
  }
1949
2101
  ),
1950
- h && /* @__PURE__ */ d("span", { className: "dw-absolute dw-right-2 dw-pointer-events-none dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)]", children: "%" })
2102
+ p && /* @__PURE__ */ d("span", { className: "dw-absolute dw-right-2 dw-pointer-events-none dw-font-normal dw-text-[11px] dw-text-[var(--dw-fg)]", children: "%" })
1951
2103
  ]
1952
2104
  }
1953
2105
  )
@@ -1957,7 +2109,7 @@ function an(t) {
1957
2109
  {
1958
2110
  type: "button",
1959
2111
  className: "dw-w-full dw-h-[34px] dw-mt-4 dw-bg-[var(--dw-accent)] dw-border dw-border-transparent dw-rounded-[6px] dw-font-normal dw-text-[12px] dw-text-white hover:dw-bg-[var(--dw-accent-hover)] dw-cursor-pointer",
1960
- onClick: x,
2112
+ onClick: I,
1961
2113
  children: "Save"
1962
2114
  }
1963
2115
  )
@@ -1965,53 +2117,129 @@ function an(t) {
1965
2117
  }
1966
2118
  ) });
1967
2119
  }
1968
- function ln() {
2120
+ function kn() {
1969
2121
  return /* @__PURE__ */ d("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ d("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) });
1970
2122
  }
1971
- function Ze(t) {
1972
- return t === "EVM" ? ot : t === "SVM" ? st : dt;
2123
+ function st(e) {
2124
+ return e === "EVM" ? at : e === "SVM" ? it : ct;
1973
2125
  }
1974
- function pn(t) {
1975
- var j, l, S, g, y, c, f, C;
2126
+ function vn(e) {
2127
+ var de, oe, w, a, S, W, Q, z;
1976
2128
  const {
1977
- theme: e = "dark",
2129
+ theme: t = "dark",
1978
2130
  vars: n,
1979
2131
  className: r,
1980
2132
  style: s,
1981
- config: a,
1982
- ...i
1983
- } = t, w = et(e, n), p = {
1984
- ...tt(w),
2133
+ config: l,
2134
+ initialSellToken: i,
2135
+ initialBuyToken: u,
2136
+ initialSellNetworkId: p,
2137
+ initialBuyNetworkId: g,
2138
+ lockBuyToken: C = !1,
2139
+ lockSellToken: I = !1,
2140
+ lockBuyNetwork: k = !1,
2141
+ lockSellNetwork: m = !1,
2142
+ onApprove: y,
2143
+ onSwap: v,
2144
+ onQuote: $,
2145
+ onError: D,
2146
+ ...T
2147
+ } = e, O = dt(t, n), q = {
2148
+ ...lt(O),
1985
2149
  ...s
1986
- }, N = a.assetBaseUrl ?? a.dataBaseUrl ?? (typeof window < "u" ? window.location.origin : ""), [x, m] = U(null), [u, k] = U(null), o = Qt({
1987
- dataBaseUrl: a.dataBaseUrl,
1988
- apiBase: a.apiBase
1989
- }), R = ie(() => {
1990
- var G;
1991
- const A = o.networks, T = (G = o.networkSell) == null ? void 0 : G.id, O = A.slice(0, 6);
1992
- if (!T || O.some((H) => H.id === T)) return O;
1993
- const J = A.find((H) => H.id === T);
1994
- return J ? [...O.slice(0, 5), J] : O;
1995
- }, [o.networks, (j = o.networkSell) == null ? void 0 : j.id]), M = ie(() => {
1996
- const A = new Set(R.map((T) => T.id));
1997
- return o.networks.filter((T) => !A.has(T.id));
1998
- }, [o.networks, R]), V = ie(() => {
1999
- var G;
2000
- const A = o.networks, T = (G = o.networkBuy) == null ? void 0 : G.id, O = A.slice(0, 6);
2001
- if (!T || O.some((H) => H.id === T)) return O;
2002
- const J = A.find((H) => H.id === T);
2003
- return J ? [...O.slice(0, 5), J] : O;
2004
- }, [o.networks, (l = o.networkBuy) == null ? void 0 : l.id]), L = ie(() => {
2005
- const A = new Set(V.map((T) => T.id));
2006
- return o.networks.filter((T) => !A.has(T.id));
2007
- }, [o.networks, V]), $ = (A) => Math.trunc(A * 1e6) / 1e6;
2150
+ }, L = l.assetBaseUrl ?? l.dataBaseUrl ?? l.apiBase ?? (typeof window < "u" ? window.location.origin : ""), [c, h] = B(null), [b, N] = B(null), o = Xt({
2151
+ apiBase: l.apiBase,
2152
+ initialSellToken: i,
2153
+ initialBuyToken: u,
2154
+ initialSellNetworkId: p,
2155
+ initialBuyNetworkId: g,
2156
+ lockBuyToken: C,
2157
+ lockSellToken: I,
2158
+ lockBuyNetwork: k,
2159
+ lockSellNetwork: m,
2160
+ onError: D
2161
+ }), E = X(""), V = ue(() => {
2162
+ var le;
2163
+ const f = o.networks, F = (le = o.networkSell) == null ? void 0 : le.id, P = f.slice(0, 6);
2164
+ if (!F || P.some((se) => se.id === F)) return P;
2165
+ const _ = f.find((se) => se.id === F);
2166
+ return _ ? [...P.slice(0, 5), _] : P;
2167
+ }, [o.networks, (de = o.networkSell) == null ? void 0 : de.id]), J = ue(() => {
2168
+ const f = new Set(V.map((F) => F.id));
2169
+ return o.networks.filter((F) => !f.has(F.id));
2170
+ }, [o.networks, V]), G = ue(() => {
2171
+ var le;
2172
+ const f = o.networks, F = (le = o.networkBuy) == null ? void 0 : le.id, P = f.slice(0, 6);
2173
+ if (!F || P.some((se) => se.id === F)) return P;
2174
+ const _ = f.find((se) => se.id === F);
2175
+ return _ ? [...P.slice(0, 5), _] : P;
2176
+ }, [o.networks, (oe = o.networkBuy) == null ? void 0 : oe.id]), ie = ue(() => {
2177
+ const f = new Set(G.map((F) => F.id));
2178
+ return o.networks.filter((F) => !f.has(F.id));
2179
+ }, [o.networks, G]), fe = (f) => Math.trunc(f * 1e6) / 1e6, ee = M(
2180
+ (f) => !o.networkSell || !o.networkBuy || !o.sellToken || !o.buyToken ? null : {
2181
+ action: f,
2182
+ sellNetwork: o.networkSell,
2183
+ buyNetwork: o.networkBuy,
2184
+ sellToken: o.sellToken,
2185
+ buyToken: o.buyToken,
2186
+ sellAmount: o.sellAmountForInput,
2187
+ buyAmount: o.buyAmountForInput,
2188
+ slippage: o.slippage.slippage,
2189
+ quote: o.quote,
2190
+ txData: o.txData,
2191
+ price: o.price,
2192
+ gasCostUSD: o.gasCostUSD
2193
+ },
2194
+ [o]
2195
+ );
2196
+ re(() => {
2197
+ o.quote || (E.current = "");
2198
+ }, [o.quote]), re(() => {
2199
+ var F, P;
2200
+ if (!$ || !o.quote || !o.networkSell || !o.networkBuy || !o.sellToken || !o.buyToken)
2201
+ return;
2202
+ const f = [
2203
+ o.networkSell.id,
2204
+ o.networkBuy.id,
2205
+ o.sellToken.contractAddress,
2206
+ o.buyToken.contractAddress,
2207
+ o.sellAmountForInput,
2208
+ o.buyAmountForInput,
2209
+ o.quote.inputAmount ?? "",
2210
+ o.quote.outputAmount ?? "",
2211
+ ((F = o.txData) == null ? void 0 : F.to) ?? "",
2212
+ ((P = o.txData) == null ? void 0 : P.data) ?? ""
2213
+ ].join("|");
2214
+ E.current !== f && (E.current = f, $({
2215
+ sellNetwork: o.networkSell,
2216
+ buyNetwork: o.networkBuy,
2217
+ sellToken: o.sellToken,
2218
+ buyToken: o.buyToken,
2219
+ sellAmount: o.sellAmountForInput,
2220
+ buyAmount: o.buyAmountForInput,
2221
+ slippage: o.slippage.slippage,
2222
+ quote: o.quote
2223
+ }));
2224
+ }, [$, o]);
2225
+ const ce = M(() => {
2226
+ if (o.buttonState === "approve") {
2227
+ const f = ee("approve");
2228
+ f && (y == null || y(f));
2229
+ return;
2230
+ }
2231
+ if (o.buttonState === "swap") {
2232
+ const f = ee("swap");
2233
+ f && (v == null || v(f));
2234
+ }
2235
+ }, [ee, y, v, o.buttonState]);
2008
2236
  return o.loading ? /* @__PURE__ */ d(
2009
2237
  "div",
2010
2238
  {
2011
2239
  "data-delora-widget-root": !0,
2012
2240
  className: `dw-flex dw-items-center dw-justify-center dw-p-8 ${r ?? ""}`,
2013
- style: p,
2014
- ...i,
2241
+ style: q,
2242
+ ...T,
2015
2243
  children: /* @__PURE__ */ d("p", { className: "dw-text-[var(--dw-muted)]", children: "Loading..." })
2016
2244
  }
2017
2245
  ) : o.error ? /* @__PURE__ */ d(
@@ -2019,32 +2247,36 @@ function pn(t) {
2019
2247
  {
2020
2248
  "data-delora-widget-root": !0,
2021
2249
  className: `dw-flex dw-items-center dw-justify-center dw-p-8 ${r ?? ""}`,
2022
- style: p,
2023
- ...i,
2250
+ style: q,
2251
+ ...T,
2024
2252
  children: /* @__PURE__ */ d("p", { className: "dw-text-[#ff7e7e]", children: o.error })
2025
2253
  }
2026
- ) : /* @__PURE__ */ v(
2254
+ ) : /* @__PURE__ */ A(
2027
2255
  "div",
2028
2256
  {
2029
2257
  "data-delora-widget-root": !0,
2030
2258
  className: `dw-font-mono dw-relative dw-inline-block ${r ?? ""}`,
2031
- style: p,
2032
- ...i,
2259
+ style: q,
2260
+ ...T,
2033
2261
  children: [
2034
2262
  /* @__PURE__ */ d(
2035
- qt,
2263
+ rn,
2036
2264
  {
2037
- assetBaseUrl: N,
2265
+ assetBaseUrl: L,
2038
2266
  sellToken: o.sellToken,
2039
2267
  buyToken: o.buyToken,
2040
- networkSellLogo: (S = o.networkSell) == null ? void 0 : S.logoURI,
2041
- networkBuyLogo: (g = o.networkBuy) == null ? void 0 : g.logoURI,
2268
+ networkSellLogo: (w = o.networkSell) == null ? void 0 : w.logoURI,
2269
+ networkBuyLogo: (a = o.networkBuy) == null ? void 0 : a.logoURI,
2042
2270
  sellAmountForInput: o.sellAmountForInput,
2043
2271
  buyAmountForInput: o.buyAmountForInput,
2044
- onSellAmountChange: (A) => o.setSellAmountForInput(A),
2272
+ onSellAmountChange: (f) => o.setSellAmountForInput(f),
2045
2273
  onSellInputProcess: o.processSellInput,
2046
- onOpenSellToken: () => m("tokenSell"),
2047
- onOpenBuyToken: () => m("tokenBuy"),
2274
+ onOpenSellToken: () => {
2275
+ I || h("tokenSell");
2276
+ },
2277
+ onOpenBuyToken: () => {
2278
+ C || h("tokenBuy");
2279
+ },
2048
2280
  onSwapTokens: o.swapTokens,
2049
2281
  onRefresh: () => {
2050
2282
  o.networkSell && o.networkBuy && o.sellToken && o.buyToken && o.validatedSellAmount > 0 && o.fetchQuote({
@@ -2054,16 +2286,16 @@ function pn(t) {
2054
2286
  buyToken: o.buyToken,
2055
2287
  sellAmountStr: o.sellAmountForInput || "0",
2056
2288
  slippage: o.slippage.slippage,
2057
- fromAddress: Ze(o.networkSell.chainType),
2058
- toAddress: Ze(o.networkBuy.chainType),
2059
- apiBase: a.apiBase
2289
+ fromAddress: st(o.networkSell.chainType),
2290
+ toAddress: st(o.networkBuy.chainType),
2291
+ apiBase: l.apiBase
2060
2292
  });
2061
2293
  },
2062
- onOpenSettings: () => m("settings"),
2294
+ onOpenSettings: () => h("settings"),
2063
2295
  balance: o.balance,
2064
2296
  balanceBuy: o.balanceBuy,
2065
- sellPriceUsd: (y = o.sellToken) != null && y.priceUSD && o.sellAmountForInput && Number(o.sellAmountForInput) > 0 ? `$${(Number(o.sellAmountForInput) * Number(o.sellToken.priceUSD)).toFixed(3)}` : "",
2066
- buyPriceUsd: (c = o.buyToken) != null && c.priceUSD && o.buyAmountForInput && Number(o.buyAmountForInput) > 0 ? `$${(Number(o.buyAmountForInput) * Number(o.buyToken.priceUSD)).toFixed(3)}` : "",
2297
+ sellPriceUsd: (S = o.sellToken) != null && S.priceUSD && o.sellAmountForInput && Number(o.sellAmountForInput) > 0 ? `$${(Number(o.sellAmountForInput) * Number(o.sellToken.priceUSD)).toFixed(3)}` : "",
2298
+ buyPriceUsd: (W = o.buyToken) != null && W.priceUSD && o.buyAmountForInput && Number(o.buyAmountForInput) > 0 ? `$${(Number(o.buyAmountForInput) * Number(o.buyToken.priceUSD)).toFixed(3)}` : "",
2067
2299
  onMaxClick: o.setMaxSellAmount,
2068
2300
  onSet50Percent: () => o.setSellAmountByPercent(50),
2069
2301
  onSet25Percent: () => o.setSellAmountByPercent(25),
@@ -2072,93 +2304,103 @@ function pn(t) {
2072
2304
  loading: o.buttonState === "finding",
2073
2305
  price: o.price,
2074
2306
  gasCostUSD: o.gasCostUSD,
2075
- truncateTo6Decimals: $,
2076
- isWalletConnected: !!a.isWalletConnected,
2077
- onConnectWallet: a.onConnectWallet
2307
+ truncateTo6Decimals: fe,
2308
+ isWalletConnected: !!l.isWalletConnected,
2309
+ onConnectWallet: l.onConnectWallet,
2310
+ onAction: ce,
2311
+ swapDisabled: o.swapLocked,
2312
+ sellTokenLocked: I,
2313
+ buyTokenLocked: C
2078
2314
  }
2079
2315
  ),
2080
- x === "tokenSell" && /* @__PURE__ */ d(
2081
- _e,
2316
+ c === "tokenSell" && /* @__PURE__ */ d(
2317
+ rt,
2082
2318
  {
2083
2319
  mode: "sell",
2084
2320
  networks: o.networks,
2085
- selectedNetworkId: (f = o.networkSell) == null ? void 0 : f.id,
2321
+ selectedNetworkId: (Q = o.networkSell) == null ? void 0 : Q.id,
2086
2322
  selectedToken: o.sellToken,
2087
2323
  excludeToken: o.buyToken,
2088
2324
  getAllTokensForNetwork: o.getAllTokensForNetworkId,
2089
2325
  getNetworkById: o.getNetworkById,
2090
- displayedNetworks: R,
2091
- additionalNetworksCount: M.length,
2092
- onOpenNetworkSelector: () => k("sell"),
2093
- onSelectToken: (A) => {
2094
- o.setSellToken(A), o.cancelRequest(), m(null);
2326
+ displayedNetworks: V,
2327
+ additionalNetworksCount: J.length,
2328
+ onOpenNetworkSelector: () => {
2329
+ o.sellNetworkLocked || N("sell");
2330
+ },
2331
+ onSelectToken: (f) => {
2332
+ o.setSellToken(f), o.cancelRequest(), h(null);
2095
2333
  },
2096
- onSelectNetwork: (A) => {
2097
- var T;
2098
- o.updateNetworkSell(A.id), ((T = o.networkBuy) == null ? void 0 : T.id) !== A.id && o.setNetworkBuy(A);
2334
+ onSelectNetwork: (f) => {
2335
+ var F;
2336
+ o.updateNetworkSell(f.id), ((F = o.networkBuy) == null ? void 0 : F.id) !== f.id && o.setNetworkBuy(f);
2099
2337
  },
2100
- onClose: () => m(null),
2101
- assetBaseUrl: N
2338
+ onClose: () => h(null),
2339
+ assetBaseUrl: L,
2340
+ networkSelectionLocked: o.sellNetworkLocked
2102
2341
  }
2103
2342
  ),
2104
- x === "tokenBuy" && /* @__PURE__ */ d(
2105
- _e,
2343
+ c === "tokenBuy" && /* @__PURE__ */ d(
2344
+ rt,
2106
2345
  {
2107
2346
  mode: "buy",
2108
2347
  networks: o.networks,
2109
- selectedNetworkId: (C = o.networkBuy) == null ? void 0 : C.id,
2348
+ selectedNetworkId: (z = o.networkBuy) == null ? void 0 : z.id,
2110
2349
  selectedToken: o.buyToken,
2111
2350
  excludeToken: o.sellToken,
2112
2351
  getAllTokensForNetwork: o.getAllTokensForNetworkId,
2113
2352
  getNetworkById: o.getNetworkById,
2114
- displayedNetworks: V,
2115
- additionalNetworksCount: L.length,
2116
- onOpenNetworkSelector: () => k("buy"),
2117
- onSelectToken: (A) => {
2118
- o.setBuyToken(A), o.cancelRequest(), m(null);
2353
+ displayedNetworks: G,
2354
+ additionalNetworksCount: ie.length,
2355
+ onOpenNetworkSelector: () => {
2356
+ o.buyNetworkLocked || N("buy");
2357
+ },
2358
+ onSelectToken: (f) => {
2359
+ o.setBuyToken(f), o.cancelRequest(), h(null);
2119
2360
  },
2120
- onSelectNetwork: (A) => {
2121
- o.setNetworkBuy(A);
2361
+ onSelectNetwork: (f) => {
2362
+ o.setNetworkBuy(f);
2122
2363
  },
2123
- onClose: () => m(null),
2124
- assetBaseUrl: N
2364
+ onClose: () => h(null),
2365
+ assetBaseUrl: L,
2366
+ networkSelectionLocked: o.buyNetworkLocked
2125
2367
  }
2126
2368
  ),
2127
- u === "sell" && x === "tokenSell" && /* @__PURE__ */ d(
2128
- Xe,
2369
+ b === "sell" && c === "tokenSell" && /* @__PURE__ */ d(
2370
+ ot,
2129
2371
  {
2130
- networks: M,
2131
- assetBaseUrl: N,
2132
- onSelectNetwork: (A) => {
2133
- var T;
2134
- o.updateNetworkSell(A.id), ((T = o.networkBuy) == null ? void 0 : T.id) !== A.id && o.setNetworkBuy(A), k(null);
2372
+ networks: J,
2373
+ assetBaseUrl: L,
2374
+ onSelectNetwork: (f) => {
2375
+ var F;
2376
+ o.updateNetworkSell(f.id), ((F = o.networkBuy) == null ? void 0 : F.id) !== f.id && o.setNetworkBuy(f), N(null);
2135
2377
  },
2136
- onClose: () => k(null)
2378
+ onClose: () => N(null)
2137
2379
  }
2138
2380
  ),
2139
- u === "buy" && x === "tokenBuy" && /* @__PURE__ */ d(
2140
- Xe,
2381
+ b === "buy" && c === "tokenBuy" && /* @__PURE__ */ d(
2382
+ ot,
2141
2383
  {
2142
- networks: L,
2143
- assetBaseUrl: N,
2144
- onSelectNetwork: (A) => {
2145
- o.setNetworkBuy(A), k(null);
2384
+ networks: ie,
2385
+ assetBaseUrl: L,
2386
+ onSelectNetwork: (f) => {
2387
+ o.setNetworkBuy(f), N(null);
2146
2388
  },
2147
- onClose: () => k(null)
2389
+ onClose: () => N(null)
2148
2390
  }
2149
2391
  ),
2150
- x === "settings" && /* @__PURE__ */ d(
2151
- an,
2392
+ c === "settings" && /* @__PURE__ */ d(
2393
+ gn,
2152
2394
  {
2153
2395
  options: o.slippage.options,
2154
2396
  selectedIndex: o.slippage.selectedIndex,
2155
2397
  customValue: o.slippage.customValue,
2156
2398
  onSelectOption: o.slippage.selectOption,
2157
2399
  onCustomChange: o.slippage.setCustom,
2158
- onSave: (A) => {
2159
- o.slippage.save(A), m(null);
2400
+ onSave: (f) => {
2401
+ o.slippage.save(f), h(null);
2160
2402
  },
2161
- onClose: () => m(null)
2403
+ onClose: () => h(null)
2162
2404
  }
2163
2405
  )
2164
2406
  ]
@@ -2166,7 +2408,7 @@ function pn(t) {
2166
2408
  );
2167
2409
  }
2168
2410
  export {
2169
- hn as MyWidget,
2170
- pn as TradeWidget
2411
+ An as MyWidget,
2412
+ vn as TradeWidget
2171
2413
  };
2172
2414
  //# sourceMappingURL=index.js.map