aegis-swap-widget 0.3.0 → 0.3.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.
@@ -1,67 +1,19 @@
1
- import { jsxs as m, jsx as r } from "react/jsx-runtime";
2
- import { formatUnits as Tt, parseUnits as Fa, createWalletClient as ka, custom as Ua, WaitForTransactionReceiptTimeoutError as an, erc20Abi as Tn } from "viem";
3
- import { memo as nt, useState as N, useEffect as k, useRef as $, useLayoutEffect as Wa, useSyncExternalStore as _t, useCallback as B, useMemo as X, useId as De } from "react";
4
- import { a3 as $a, T as Fe, a9 as qa, R as Nn, w as za, W as Ha, s as Va, D as Ga, S as Cn, Z as Ka, v as ja, u as Xa, O as ke, a7 as Ya, a0 as Mn, H as Rn, a1 as Qa, G as Ae, $ as vt, J as It, r as Za, _ as On, aa as Se, a5 as Ja, a4 as rn, ab as mt, I as ei, L as gt, a6 as ti, Y as ni, a2 as ai, N as ii, b as sn, z as ri, a as si, B as oi, k as li, f as on, F as ci, X as ui, n as ln, a8 as di } from "./polling-BI4pZg8Z.js";
5
- import { A as ss, c as os, d as ls, e as cs, g as us, h as ds, i as ps, j as fs, l as hs, m as ms, o as gs, M as ws, p as ys, q as bs, P as _s, U as vs, t as Is, x as Ss, y as As, C as Es, E as xs, K as Ps, Q as Ts, V as Ns } from "./polling-BI4pZg8Z.js";
6
- import { createPortal as pi } from "react-dom";
7
- function Be(t) {
8
- const a = ((t.match(/,/g) ?? []).length === 1 && !t.includes(".") ? t.replace(",", ".") : t).replace(/[^\d.]/g, ""), [i = "", ...o] = a.split("."), s = o.length > 0 ? `${i}.${o.join("")}` : i;
9
- return s === "." ? "0." : s;
10
- }
11
- function cn(t) {
12
- const e = Be(t);
13
- if (!e) return "";
14
- const n = Number(e);
15
- return Number.isFinite(n) && n > 20 ? "20" : e;
16
- }
17
- function fi(t, e) {
18
- const n = t.trim();
19
- if (!n || n === ".") return null;
20
- try {
21
- return Fa(n, e);
22
- } catch {
23
- return null;
24
- }
25
- }
26
- function un(t) {
27
- const e = t.trim();
28
- if (!e) return null;
29
- const n = Number(e);
30
- return !Number.isFinite(n) || n < 0 || n > 20 ? null : Math.round(n * 100);
31
- }
32
- function Dn(t, e, n = "half-up") {
33
- if (t === 0n || e <= 0) return t;
34
- const a = t < 0n ? -1n : 1n, i = t < 0n ? -t : t, s = i.toString().length - e;
35
- if (s <= 0) return t;
36
- const l = 10n ** BigInt(s);
37
- return (n === "floor" ? i / l * l : (i + l / 2n) / l * l) * a;
38
- }
39
- function Nt(t) {
40
- return t.includes(".") ? t.replace(/\.?0+$/, "") : t;
41
- }
42
- function Ee(t, e, n = 4) {
43
- return t == null ? "--" : Nt(Tt(Dn(t, n), e));
44
- }
45
- function hi(t, e, n = 4) {
46
- return t == null ? "--" : Nt(
47
- Tt(Dn(t, n, "floor"), e)
48
- );
49
- }
50
- function dn(t, e) {
51
- return t == null ? "" : Ee(t, e);
52
- }
53
- function mi(t, e) {
54
- return t == null ? "" : Nt(Tt(t, e));
55
- }
56
- const gi = {
1
+ import { jsxs as p, jsx as i, Fragment as yn } from "react/jsx-runtime";
2
+ import { memo as ft, useState as T, useSyncExternalStore as ut, useRef as $, useEffect as F, useLayoutEffect as ai, useCallback as D, useMemo as J, useId as Ve } from "react";
3
+ import { Box as ii, Flame as ri, Gauge as si, Coins as oi } from "lucide-react";
4
+ import { a3 as li, T as ze, a9 as ci, R as qn, w as ui, W as di, s as pi, D as fi, S as Gn, Z as hi, v as gi, u as mi, O as Ke, a7 as wi, a0 as zn, H as Kn, a1 as bi, G as Re, $ as Tt, J as jn, r as yi, _ as Xn, aa as Me, a5 as vi, a4 as vn, ab as At, I as _i, L as Et, a6 as Ii, Y as Si, a2 as Ai, N as Ei, b as _n, z as xi, a as Ni, B as Pi, k as Ti, f as In, F as Ci, X as Mi, n as Sn, a8 as Ri } from "./polling-BI4pZg8Z.js";
5
+ import { A as $s, c as Ws, d as Hs, e as Vs, g as qs, h as Gs, i as zs, j as Ks, l as js, m as Xs, o as Ys, M as Qs, p as Zs, q as Js, P as eo, U as to, t as no, x as ao, y as io, C as ro, E as so, K as oo, Q as lo, V as co } from "./polling-BI4pZg8Z.js";
6
+ import { createPortal as Di } from "react-dom";
7
+ import { parseUnits as Oi, formatUnits as kt, formatEther as Bi, formatGwei as ki, createWalletClient as Li, custom as Fi, WaitForTransactionReceiptTimeoutError as An, erc20Abi as Yn } from "viem";
8
+ const Ui = {
57
9
  USDC: { primary: "#d7ecff", secondary: "#2775ca", text: "#06111f" },
58
10
  WATER: { primary: "#87dcff", secondary: "#0f5d96", text: "#051621" },
59
11
  WOOD: { primary: "#c79a62", secondary: "#45633d", text: "#171008" },
60
12
  GRASS: { primary: "#76e28a", secondary: "#244f32", text: "#061508" },
61
13
  STONE: { primary: "#d7d1c3", secondary: "#5a6366", text: "#111416" }
62
14
  };
63
- function wi(t) {
64
- const e = gi[t] ?? {
15
+ function $i(t) {
16
+ const e = Ui[t] ?? {
65
17
  primary: "#eef3f0",
66
18
  secondary: "#75827c",
67
19
  text: "#111815"
@@ -72,38 +24,38 @@ function wi(t) {
72
24
  "--aegis-token-text": e.text
73
25
  };
74
26
  }
75
- const St = nt(function({
27
+ const Ct = ft(function({
76
28
  token: e,
77
29
  metadataByAddress: n,
78
30
  className: a
79
31
  }) {
80
- const i = $a(e, n), [o, s] = N(null), l = i && o !== i ? i : null;
81
- return /* @__PURE__ */ r("span", { className: a, style: wi(e.symbol), "aria-hidden": "true", children: l ? /* @__PURE__ */ r(
32
+ const r = li(e, n), [s, o] = T(null), l = r && s !== r ? r : null;
33
+ return /* @__PURE__ */ i("span", { className: a, style: $i(e.symbol), "aria-hidden": "true", children: l ? /* @__PURE__ */ i(
82
34
  "img",
83
35
  {
84
36
  src: l,
85
37
  alt: "",
86
38
  loading: "lazy",
87
39
  decoding: "async",
88
- onError: () => s(l)
40
+ onError: () => o(l)
89
41
  }
90
42
  ) : e.symbol.slice(0, 1) });
91
- }), Bn = nt(function({
43
+ }), Qn = ft(function({
92
44
  market: e,
93
45
  metadataByAddress: n,
94
46
  className: a
95
47
  }) {
96
- return /* @__PURE__ */ m("span", { className: a, "aria-hidden": "true", children: [
97
- /* @__PURE__ */ r(
98
- St,
48
+ return /* @__PURE__ */ p("span", { className: a, "aria-hidden": "true", children: [
49
+ /* @__PURE__ */ i(
50
+ Ct,
99
51
  {
100
52
  token: e.counterToken,
101
53
  metadataByAddress: n,
102
54
  className: "aegis-swap-widget__pair-icon"
103
55
  }
104
56
  ),
105
- /* @__PURE__ */ r(
106
- St,
57
+ /* @__PURE__ */ i(
58
+ Ct,
107
59
  {
108
60
  token: e.token,
109
61
  metadataByAddress: n,
@@ -112,9 +64,9 @@ const St = nt(function({
112
64
  )
113
65
  ] });
114
66
  });
115
- function yi() {
116
- return /* @__PURE__ */ m("svg", { viewBox: "0 0 150 151", "aria-hidden": "true", focusable: "false", children: [
117
- /* @__PURE__ */ r(
67
+ function Wi() {
68
+ return /* @__PURE__ */ p("svg", { viewBox: "0 0 150 151", "aria-hidden": "true", focusable: "false", children: [
69
+ /* @__PURE__ */ i(
118
70
  "path",
119
71
  {
120
72
  d: "M64.7727 0.691736C28.1896 5.67985 0 37.048 0 75.0003C0 112.952 28.1896 144.321 64.7727 149.309C68.264 148.833 71.6788 148.116 75 147.177C106.48 138.274 129.545 109.141 129.545 74.8109C129.545 51.4969 113.281 31.9817 91.4795 26.993C87.8685 26.1667 84.1035 26.1664 80.4924 26.9925C78.6184 27.4212 76.7854 27.9573 75 28.5939C93.9861 35.3633 107.576 53.5001 107.576 74.8109C107.576 96.1216 93.9861 114.258 75 121.028C73.2146 121.664 71.3816 122.2 69.5076 122.629C65.8965 123.455 62.1318 123.454 58.5199 122.632C36.7188 117.667 20.4545 98.314 20.4545 75.0003C20.4545 40.67 43.5204 11.727 75 2.82341C78.3212 1.88407 81.736 1.16777 85.2273 0.691735C81.8833 0.235781 78.4691 0.000244141 75 0.000244141C71.5309 0.000244141 68.1167 0.235782 64.7727 0.691736Z",
@@ -122,7 +74,7 @@ function yi() {
122
74
  opacity: "0.92"
123
75
  }
124
76
  ),
125
- /* @__PURE__ */ r(
77
+ /* @__PURE__ */ i(
126
78
  "path",
127
79
  {
128
80
  d: "M85.2273 149.374C121.81 144.386 150 113.018 150 75.0659C150 37.1137 121.81 5.74551 85.2273 0.757401C81.736 1.23343 78.3212 1.94972 75 2.88907C43.5204 11.7926 20.4545 40.925 20.4545 75.2553C20.4545 98.5693 36.7191 118.084 58.5205 123.073C62.1315 123.899 65.8965 123.9 69.5076 123.074C71.3816 122.645 73.2146 122.109 75 121.472C56.0139 114.703 42.4242 96.5661 42.4242 75.2553C42.4242 53.9445 56.0139 35.8078 75 29.0383C76.7854 28.4017 78.6184 27.8657 80.4924 27.437C84.1035 26.6108 87.8682 26.612 91.4801 27.4345C113.281 32.3988 129.545 51.7522 129.545 75.0659C129.545 109.396 106.48 138.339 75 147.243C71.6788 148.182 68.264 148.898 64.7727 149.374C68.1167 149.83 71.5309 150.066 75 150.066C78.4691 150.066 81.8833 149.83 85.2273 149.374Z",
@@ -132,8 +84,8 @@ function yi() {
132
84
  )
133
85
  ] });
134
86
  }
135
- function bi({ className: t }) {
136
- return /* @__PURE__ */ m(
87
+ function Hi({ className: t }) {
88
+ return /* @__PURE__ */ p(
137
89
  "svg",
138
90
  {
139
91
  className: t,
@@ -142,17 +94,17 @@ function bi({ className: t }) {
142
94
  focusable: "false",
143
95
  fill: "currentColor",
144
96
  children: [
145
- /* @__PURE__ */ r("path", { d: "m959.8 730.9-539.8 245.4 539.8 319.1 539.9-319.1z", opacity: "0.6" }),
146
- /* @__PURE__ */ r("path", { d: "m420.2 976.3 539.8 319.1v-564.5-650.3z", opacity: "0.45" }),
147
- /* @__PURE__ */ r("path", { d: "m960 80.6v650.3 564.5l539.8-319.1z", opacity: "0.8" }),
148
- /* @__PURE__ */ r("path", { d: "m420 1078.7 539.8 760.7v-441.8z", opacity: "0.45" }),
149
- /* @__PURE__ */ r("path", { d: "m959.8 1397.6v441.8l540.2-760.7z", opacity: "0.8" })
97
+ /* @__PURE__ */ i("path", { d: "m959.8 730.9-539.8 245.4 539.8 319.1 539.9-319.1z", opacity: "0.6" }),
98
+ /* @__PURE__ */ i("path", { d: "m420.2 976.3 539.8 319.1v-564.5-650.3z", opacity: "0.45" }),
99
+ /* @__PURE__ */ i("path", { d: "m960 80.6v650.3 564.5l539.8-319.1z", opacity: "0.8" }),
100
+ /* @__PURE__ */ i("path", { d: "m420 1078.7 539.8 760.7v-441.8z", opacity: "0.45" }),
101
+ /* @__PURE__ */ i("path", { d: "m959.8 1397.6v441.8l540.2-760.7z", opacity: "0.8" })
150
102
  ]
151
103
  }
152
104
  );
153
105
  }
154
- function _i({ className: t }) {
155
- return /* @__PURE__ */ m(
106
+ function Vi({ className: t }) {
107
+ return /* @__PURE__ */ p(
156
108
  "svg",
157
109
  {
158
110
  className: t,
@@ -160,8 +112,8 @@ function _i({ className: t }) {
160
112
  "aria-hidden": "true",
161
113
  focusable: "false",
162
114
  children: [
163
- /* @__PURE__ */ r("circle", { cx: "16", cy: "16", r: "16", fill: "#0052ff" }),
164
- /* @__PURE__ */ r(
115
+ /* @__PURE__ */ i("circle", { cx: "16", cy: "16", r: "16", fill: "#0052ff" }),
116
+ /* @__PURE__ */ i(
165
117
  "path",
166
118
  {
167
119
  d: "M16.16 26.4c5.52 0 10.08-4.48 10.08-10S21.68 6.4 16.16 6.4c-5.04 0-9.2 3.68-9.92 8.48h13.32v2.56H6.24c.72 4.8 4.88 8.96 9.92 8.96Z",
@@ -172,71 +124,83 @@ function _i({ className: t }) {
172
124
  }
173
125
  );
174
126
  }
175
- function vi() {
176
- return /* @__PURE__ */ m("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
177
- /* @__PURE__ */ r("path", { d: "m3 16 4 4 4-4" }),
178
- /* @__PURE__ */ r("path", { d: "M7 20V4" }),
179
- /* @__PURE__ */ r("path", { d: "m21 8-4-4-4 4" }),
180
- /* @__PURE__ */ r("path", { d: "M17 4v16" })
127
+ function qi() {
128
+ return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
129
+ /* @__PURE__ */ i("path", { d: "m3 16 4 4 4-4" }),
130
+ /* @__PURE__ */ i("path", { d: "M7 20V4" }),
131
+ /* @__PURE__ */ i("path", { d: "m21 8-4-4-4 4" }),
132
+ /* @__PURE__ */ i("path", { d: "M17 4v16" })
181
133
  ] });
182
134
  }
183
- function Ln() {
184
- return /* @__PURE__ */ m("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
185
- /* @__PURE__ */ r("path", { d: "M14 5h5v5" }),
186
- /* @__PURE__ */ r("path", { d: "m13 11 6-6" }),
187
- /* @__PURE__ */ r("path", { d: "M19 14v4.5A1.5 1.5 0 0 1 17.5 20h-12A1.5 1.5 0 0 1 4 18.5v-12A1.5 1.5 0 0 1 5.5 5H10" })
135
+ function Mt() {
136
+ return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
137
+ /* @__PURE__ */ i("path", { d: "M14 5h5v5" }),
138
+ /* @__PURE__ */ i("path", { d: "m13 11 6-6" }),
139
+ /* @__PURE__ */ i("path", { d: "M19 14v4.5A1.5 1.5 0 0 1 17.5 20h-12A1.5 1.5 0 0 1 4 18.5v-12A1.5 1.5 0 0 1 5.5 5H10" })
188
140
  ] });
189
141
  }
190
- function Ii() {
191
- return /* @__PURE__ */ m("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
192
- /* @__PURE__ */ r("rect", { x: "8", y: "8", width: "12", height: "12", rx: "2" }),
193
- /* @__PURE__ */ r("path", { d: "M4 14V6a2 2 0 0 1 2-2h8" })
142
+ function Gi() {
143
+ return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
144
+ /* @__PURE__ */ i("rect", { x: "8", y: "8", width: "12", height: "12", rx: "2" }),
145
+ /* @__PURE__ */ i("path", { d: "M4 14V6a2 2 0 0 1 2-2h8" })
194
146
  ] });
195
147
  }
196
- function at() {
197
- return /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ r("path", { d: "M20 6 9 17l-5-5" }) });
148
+ function dt() {
149
+ return /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ i("path", { d: "M20 6 9 17l-5-5" }) });
198
150
  }
199
- function Fn() {
200
- return /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ r("path", { d: "m6 9 6 6 6-6" }) });
151
+ function Zn() {
152
+ return /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ i("path", { d: "m6 9 6 6 6-6" }) });
201
153
  }
202
- function Si() {
203
- return /* @__PURE__ */ m("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
204
- /* @__PURE__ */ r("path", { d: "M5 7h5" }),
205
- /* @__PURE__ */ r("path", { d: "M14 7h5" }),
206
- /* @__PURE__ */ r("path", { d: "M5 17h9" }),
207
- /* @__PURE__ */ r("path", { d: "M18 17h1" }),
208
- /* @__PURE__ */ r("circle", { cx: "12", cy: "7", r: "2" }),
209
- /* @__PURE__ */ r("circle", { cx: "16", cy: "17", r: "2" })
154
+ function zi() {
155
+ return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
156
+ /* @__PURE__ */ i("path", { d: "M5 7h5" }),
157
+ /* @__PURE__ */ i("path", { d: "M14 7h5" }),
158
+ /* @__PURE__ */ i("path", { d: "M5 17h9" }),
159
+ /* @__PURE__ */ i("path", { d: "M18 17h1" }),
160
+ /* @__PURE__ */ i("circle", { cx: "12", cy: "7", r: "2" }),
161
+ /* @__PURE__ */ i("circle", { cx: "16", cy: "17", r: "2" })
210
162
  ] });
211
163
  }
212
- function Ai() {
213
- return /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "9" }) });
164
+ function Ki() {
165
+ return /* @__PURE__ */ i(oi, { "aria-hidden": "true", focusable: "false" });
214
166
  }
215
- function Ei() {
216
- return /* @__PURE__ */ m("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
217
- /* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "9" }),
218
- /* @__PURE__ */ r("path", { d: "M12 8v4" }),
219
- /* @__PURE__ */ r("path", { d: "M12 16h.01" })
167
+ function ji() {
168
+ return /* @__PURE__ */ i(si, { "aria-hidden": "true", focusable: "false" });
169
+ }
170
+ function Xi() {
171
+ return /* @__PURE__ */ i(ri, { "aria-hidden": "true", focusable: "false" });
172
+ }
173
+ function Yi() {
174
+ return /* @__PURE__ */ i(ii, { "aria-hidden": "true", focusable: "false" });
175
+ }
176
+ function Qi() {
177
+ return /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ i("circle", { cx: "12", cy: "12", r: "9" }) });
178
+ }
179
+ function Zi() {
180
+ return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
181
+ /* @__PURE__ */ i("circle", { cx: "12", cy: "12", r: "9" }),
182
+ /* @__PURE__ */ i("path", { d: "M12 8v4" }),
183
+ /* @__PURE__ */ i("path", { d: "M12 16h.01" })
220
184
  ] });
221
185
  }
222
- function xi() {
223
- return /* @__PURE__ */ m("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
224
- /* @__PURE__ */ r("circle", { cx: "12", cy: "12", r: "9" }),
225
- /* @__PURE__ */ r("path", { d: "M12 11v5" }),
226
- /* @__PURE__ */ r("path", { d: "M12 8h.01" })
186
+ function Jn() {
187
+ return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
188
+ /* @__PURE__ */ i("circle", { cx: "12", cy: "12", r: "9" }),
189
+ /* @__PURE__ */ i("path", { d: "M12 11v5" }),
190
+ /* @__PURE__ */ i("path", { d: "M12 8h.01" })
227
191
  ] });
228
192
  }
229
- function Pi() {
230
- return /* @__PURE__ */ m("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
231
- /* @__PURE__ */ r("path", { d: "M18 6 6 18" }),
232
- /* @__PURE__ */ r("path", { d: "m6 6 12 12" })
193
+ function Ji() {
194
+ return /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [
195
+ /* @__PURE__ */ i("path", { d: "M18 6 6 18" }),
196
+ /* @__PURE__ */ i("path", { d: "m6 6 12 12" })
233
197
  ] });
234
198
  }
235
- const pn = "#06120c", fn = "#f4f8f5";
236
- function xe(t) {
199
+ const En = "#06120c", xn = "#f4f8f5";
200
+ function De(t) {
237
201
  return Math.min(255, Math.max(0, Math.round(t)));
238
202
  }
239
- function hn(t) {
203
+ function Nn(t) {
240
204
  const e = t.replace(/^#/, "");
241
205
  if (!/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$/.test(e)) return null;
242
206
  const n = e.length === 3 ? e.split("").map((a) => a + a).join("") : e;
@@ -246,30 +210,30 @@ function hn(t) {
246
210
  b: Number.parseInt(n.slice(4, 6), 16)
247
211
  };
248
212
  }
249
- function Ti(t) {
213
+ function er(t) {
250
214
  return t.endsWith("%") ? Number.parseFloat(t) * 255 / 100 : Number.parseFloat(t);
251
215
  }
252
- function mn(t) {
216
+ function Pn(t) {
253
217
  const e = t.match(/^rgba?\(\s*([\d.]+%?)\s*[,\s]\s*([\d.]+%?)\s*[,\s]\s*([\d.]+%?)/i);
254
218
  if (!e) return null;
255
- const [n, a, i] = [e[1], e[2], e[3]].map(Ti);
256
- return [n, a, i].some((o) => Number.isNaN(o)) ? null : { r: xe(n), g: xe(a), b: xe(i) };
219
+ const [n, a, r] = [e[1], e[2], e[3]].map(er);
220
+ return [n, a, r].some((s) => Number.isNaN(s)) ? null : { r: De(n), g: De(a), b: De(r) };
257
221
  }
258
- function Ni(t, e, n) {
259
- const a = e / 100, i = n / 100, o = (1 - Math.abs(2 * i - 1)) * a, s = (t % 360 + 360) % 360 / 60, l = o * (1 - Math.abs(s % 2 - 1)), u = i - o / 2, [c, p, g] = s < 1 ? [o, l, 0] : s < 2 ? [l, o, 0] : s < 3 ? [0, o, l] : s < 4 ? [0, l, o] : s < 5 ? [l, 0, o] : [o, 0, l];
222
+ function tr(t, e, n) {
223
+ const a = e / 100, r = n / 100, s = (1 - Math.abs(2 * r - 1)) * a, o = (t % 360 + 360) % 360 / 60, l = s * (1 - Math.abs(o % 2 - 1)), u = r - s / 2, [c, f, m] = o < 1 ? [s, l, 0] : o < 2 ? [l, s, 0] : o < 3 ? [0, s, l] : o < 4 ? [0, l, s] : o < 5 ? [l, 0, s] : [s, 0, l];
260
224
  return {
261
- r: xe((c + u) * 255),
262
- g: xe((p + u) * 255),
263
- b: xe((g + u) * 255)
225
+ r: De((c + u) * 255),
226
+ g: De((f + u) * 255),
227
+ b: De((m + u) * 255)
264
228
  };
265
229
  }
266
- function Ci(t) {
230
+ function nr(t) {
267
231
  const e = t.match(/^hsla?\(\s*([\d.]+)(?:deg)?\s*[,\s]\s*([\d.]+)%\s*[,\s]\s*([\d.]+)%/i);
268
232
  if (!e) return null;
269
- const [n, a, i] = [e[1], e[2], e[3]].map(Number.parseFloat);
270
- return [n, a, i].some((o) => Number.isNaN(o)) ? null : Ni(n, a, i);
233
+ const [n, a, r] = [e[1], e[2], e[3]].map(Number.parseFloat);
234
+ return [n, a, r].some((s) => Number.isNaN(s)) ? null : tr(n, a, r);
271
235
  }
272
- function Mi(t) {
236
+ function ar(t) {
273
237
  if (typeof document > "u") return null;
274
238
  const e = document.createElement("canvas").getContext("2d");
275
239
  if (!e) return null;
@@ -279,89 +243,102 @@ function Mi(t) {
279
243
  const a = e.fillStyle;
280
244
  return n === a ? n : null;
281
245
  }
282
- function Ri(t) {
283
- const e = t.trim(), n = hn(e) ?? mn(e) ?? Ci(e);
246
+ function ir(t) {
247
+ const e = t.trim(), n = Nn(e) ?? Pn(e) ?? nr(e);
284
248
  if (n) return n;
285
- const a = Mi(e);
286
- return a ? hn(a) ?? mn(a) : null;
249
+ const a = ar(e);
250
+ return a ? Nn(a) ?? Pn(a) : null;
287
251
  }
288
- function wt(t) {
252
+ function xt(t) {
289
253
  const e = t / 255;
290
254
  return e <= 0.03928 ? e / 12.92 : ((e + 0.055) / 1.055) ** 2.4;
291
255
  }
292
- function yt(t) {
293
- const e = Ri(t);
294
- return e ? 0.2126 * wt(e.r) + 0.7152 * wt(e.g) + 0.0722 * wt(e.b) : null;
256
+ function Nt(t) {
257
+ const e = ir(t);
258
+ return e ? 0.2126 * xt(e.r) + 0.7152 * xt(e.g) + 0.0722 * xt(e.b) : null;
295
259
  }
296
- function gn(t, e) {
260
+ function Tn(t, e) {
297
261
  return (Math.max(t, e) + 0.05) / (Math.min(t, e) + 0.05);
298
262
  }
299
- function kn(t) {
300
- const e = yt(t);
263
+ function ea(t) {
264
+ const e = Nt(t);
301
265
  if (e === null) return null;
302
- const n = yt(pn) ?? 0, a = yt(fn) ?? 1;
303
- return gn(e, n) >= gn(e, a) ? pn : fn;
266
+ const n = Nt(En) ?? 0, a = Nt(xn) ?? 1;
267
+ return Tn(e, n) >= Tn(e, a) ? En : xn;
304
268
  }
305
- const Un = "(prefers-color-scheme: light)";
306
- function Oi() {
307
- return typeof window > "u" || !window.matchMedia ? "dark" : window.matchMedia(Un).matches ? "light" : "dark";
269
+ const ta = "(prefers-color-scheme: light)";
270
+ function rr() {
271
+ return typeof window > "u" || !window.matchMedia ? "dark" : window.matchMedia(ta).matches ? "light" : "dark";
308
272
  }
309
- function Wn(t) {
310
- const e = t === "auto", [n, a] = N(Oi);
311
- return k(() => {
312
- if (!e || typeof window > "u" || !window.matchMedia) return;
313
- const i = window.matchMedia(Un), o = () => a(i.matches ? "light" : "dark");
314
- return o(), i.addEventListener("change", o), () => i.removeEventListener("change", o);
315
- }, [e]), t === "light" ? "light" : t === "dark" ? "dark" : e ? n : "dark";
316
- }
317
- function Di(t, e, n, a) {
318
- const i = /* @__PURE__ */ new Map();
319
- let o = 0, s = 0;
273
+ function sr() {
274
+ return "dark";
275
+ }
276
+ function or(t) {
277
+ if (typeof window > "u" || !window.matchMedia) return () => {
278
+ };
279
+ const e = window.matchMedia(ta);
280
+ return e.addEventListener("change", t), () => e.removeEventListener("change", t);
281
+ }
282
+ function lr() {
283
+ return () => {
284
+ };
285
+ }
286
+ function na(t) {
287
+ const e = t === "auto", n = ut(
288
+ e ? or : lr,
289
+ rr,
290
+ sr
291
+ );
292
+ return t === "light" ? "light" : t === "dark" ? "dark" : e ? n : "dark";
293
+ }
294
+ function cr(t, e, n, a) {
295
+ const r = /* @__PURE__ */ new Map();
296
+ let s = 0, o = 0;
320
297
  return t.forEach((l, u) => {
321
- i.set(l.id, {
298
+ r.set(l.id, {
322
299
  index: u,
323
300
  zIndex: t.length - u,
324
- offset: o,
301
+ offset: s,
325
302
  front: u === 0,
326
- hidden: s >= a
327
- }), l.dismissed || (o += (e[l.id] ?? 0) + n, s += 1);
328
- }), i;
303
+ hidden: o >= a
304
+ }), l.dismissed || (s += (e[l.id] ?? 0) + n, o += 1);
305
+ }), r;
329
306
  }
330
- function Bi(t) {
307
+ function ur(t) {
331
308
  const e = t.style.height, n = t.style.transition;
332
309
  t.style.transition = "none", t.style.height = "auto";
333
310
  const a = t.getBoundingClientRect().height;
334
311
  return t.style.height = e, t.getBoundingClientRect(), t.style.transition = n, a;
335
312
  }
336
- const it = Object.freeze([]), Li = 32;
337
- let J = it;
338
- const At = /* @__PURE__ */ new Set();
339
- let Re = 0, wn = 0;
340
- function Ue(t) {
341
- J = t.length === 0 ? it : t;
342
- for (const e of At) e();
313
+ const ht = Object.freeze([]), dr = 32;
314
+ let re = ht;
315
+ const Rt = /* @__PURE__ */ new Set();
316
+ let We = 0, Cn = 0;
317
+ function je(t) {
318
+ re = t.length === 0 ? ht : t;
319
+ for (const e of Rt) e();
343
320
  }
344
- function Fi() {
345
- return J;
321
+ function pr() {
322
+ return re;
346
323
  }
347
- function ki(t) {
348
- return At.add(t), () => {
349
- At.delete(t);
324
+ function fr(t) {
325
+ return Rt.add(t), () => {
326
+ Rt.delete(t);
350
327
  };
351
328
  }
352
- function Ui() {
353
- return wn += 1, `aegis-toast-${wn}`;
329
+ function hr() {
330
+ return Cn += 1, `aegis-toast-${Cn}`;
354
331
  }
355
- function Wi(t, e) {
332
+ function gr(t, e) {
356
333
  return !t || !e ? t === e : t.label === e.label && t.href === e.href && t.onClick === e.onClick;
357
334
  }
358
- function Le(t) {
359
- const e = t.id ?? Ui(), n = J.find((s) => s.id === e), a = t.dismissible ?? !0;
335
+ function qe(t) {
336
+ const e = t.id ?? hr(), n = re.find((o) => o.id === e), a = t.dismissible ?? !0;
360
337
  if (n) {
361
- if (n.type === t.type && n.title === t.title && n.description === t.description && Wi(n.action, t.action) && n.duration === t.duration && n.dismissible === a && !n.dismissed)
338
+ if (n.type === t.type && n.title === t.title && n.description === t.description && gr(n.action, t.action) && n.duration === t.duration && n.dismissible === a && !n.dismissed)
362
339
  return e;
363
- Re += 1;
364
- const s = {
340
+ We += 1;
341
+ const o = {
365
342
  id: e,
366
343
  type: t.type,
367
344
  title: t.title,
@@ -370,13 +347,13 @@ function Le(t) {
370
347
  duration: t.duration,
371
348
  dismissible: a,
372
349
  createdAt: n.createdAt,
373
- updatedAt: Re,
350
+ updatedAt: We,
374
351
  dismissed: !1
375
352
  };
376
- return Ue(J.map((l) => l.id === e ? s : l)), e;
353
+ return je(re.map((l) => l.id === e ? o : l)), e;
377
354
  }
378
- Re += 1;
379
- const i = {
355
+ We += 1;
356
+ const r = {
380
357
  id: e,
381
358
  type: t.type,
382
359
  title: t.title,
@@ -384,227 +361,227 @@ function Le(t) {
384
361
  action: t.action,
385
362
  duration: t.duration,
386
363
  dismissible: a,
387
- createdAt: Re,
388
- updatedAt: Re,
364
+ createdAt: We,
365
+ updatedAt: We,
389
366
  dismissed: !1
390
- }, o = J.length >= Li ? J.slice(1) : J;
391
- return Ue([...o, i]), e;
367
+ }, s = re.length >= dr ? re.slice(1) : re;
368
+ return je([...s, r]), e;
392
369
  }
393
- function me(t) {
394
- if (tt.size === 0) {
395
- const i = t === void 0 ? it : J.filter((o) => o.id !== t);
396
- i.length !== J.length && Ue(i);
370
+ function ve(t) {
371
+ if (pt.size === 0) {
372
+ const r = t === void 0 ? ht : re.filter((s) => s.id !== t);
373
+ r.length !== re.length && je(r);
397
374
  return;
398
375
  }
399
376
  let n = !1;
400
- const a = J.map((i) => i.dismissed || t !== void 0 && i.id !== t ? i : (n = !0, { ...i, dismissed: !0 }));
401
- n && Ue(a);
402
- }
403
- function $i(t) {
404
- const e = J.filter((n) => n.id !== t);
405
- e.length !== J.length && Ue(e);
406
- }
407
- const tt = /* @__PURE__ */ new Map(), Et = /* @__PURE__ */ new WeakMap();
408
- let qi = 0;
409
- const xt = /* @__PURE__ */ new Set();
410
- function yn() {
411
- for (const t of xt) t();
412
- }
413
- function zi(t, e) {
414
- return Et.has(t) || Et.set(t, qi++), tt.set(t, e), yn(), () => {
415
- tt.delete(t), yn();
377
+ const a = re.map((r) => r.dismissed || t !== void 0 && r.id !== t ? r : (n = !0, { ...r, dismissed: !0 }));
378
+ n && je(a);
379
+ }
380
+ function mr(t) {
381
+ const e = re.filter((n) => n.id !== t);
382
+ e.length !== re.length && je(e);
383
+ }
384
+ const pt = /* @__PURE__ */ new Map(), Dt = /* @__PURE__ */ new WeakMap();
385
+ let wr = 0;
386
+ const Ot = /* @__PURE__ */ new Set();
387
+ function Mn() {
388
+ for (const t of Ot) t();
389
+ }
390
+ function br(t, e) {
391
+ return Dt.has(t) || Dt.set(t, wr++), pt.set(t, e), Mn(), () => {
392
+ pt.delete(t), Mn();
416
393
  };
417
394
  }
418
- function Hi(t) {
419
- return xt.add(t), () => {
420
- xt.delete(t);
395
+ function yr(t) {
396
+ return Ot.add(t), () => {
397
+ Ot.delete(t);
421
398
  };
422
399
  }
423
- function Vi(t) {
400
+ function vr(t) {
424
401
  let e = null, n = null, a = 1 / 0;
425
- for (const [i, o] of tt) {
426
- const s = Et.get(i) ?? 1 / 0;
427
- (e === null || o === "host" && n !== "host" || o === n && s < a) && (e = i, n = o, a = s);
402
+ for (const [r, s] of pt) {
403
+ const o = Dt.get(r) ?? 1 / 0;
404
+ (e === null || s === "host" && n !== "host" || s === n && o < a) && (e = r, n = s, a = o);
428
405
  }
429
406
  return e === t;
430
407
  }
431
- const Gi = 45, Ki = 0.11;
432
- function ji(t) {
408
+ const _r = 45, Ir = 0.11;
409
+ function Sr(t) {
433
410
  return t === "bottom" ? 1 : -1;
434
411
  }
435
- function Xi(t, e) {
412
+ function Ar(t, e) {
436
413
  const n = Math.abs(t);
437
- return n >= Gi ? !0 : e > 0 && n / e > Ki;
414
+ return n >= _r ? !0 : e > 0 && n / e > Ir;
438
415
  }
439
- function Yi(t, e) {
416
+ function Er(t, e) {
440
417
  return t * e >= 0 ? t : t / (1.5 + Math.abs(t) / 20);
441
418
  }
442
- function Qi(t, e, n) {
419
+ function xr(t, e, n) {
443
420
  const a = n === "touch" ? 10 : 2;
444
421
  return Math.max(Math.abs(t), Math.abs(e)) < a ? "pending" : Math.abs(e) >= Math.abs(t) ? "swipe" : "abort";
445
422
  }
446
- function Zi(t, e, n = {}) {
447
- const a = n.now ?? (() => Date.now()), i = n.set ?? ((p, g) => setTimeout(p, g)), o = n.clear ?? ((p) => clearTimeout(p));
448
- let s = e, l = 0, u = null, c = !1;
423
+ function Nr(t, e, n = {}) {
424
+ const a = n.now ?? (() => Date.now()), r = n.set ?? ((f, m) => setTimeout(f, m)), s = n.clear ?? ((f) => clearTimeout(f));
425
+ let o = e, l = 0, u = null, c = !1;
449
426
  return {
450
427
  start() {
451
- c || u !== null || (l = a(), u = i(
428
+ c || u !== null || (l = a(), u = r(
452
429
  () => {
453
430
  u = null, c = !0, t();
454
431
  },
455
- Math.max(0, s)
432
+ Math.max(0, o)
456
433
  ));
457
434
  },
458
435
  pause() {
459
- c || u === null || (o(u), u = null, s -= a() - l);
436
+ c || u === null || (s(u), u = null, o -= a() - l);
460
437
  },
461
438
  cancel() {
462
- u !== null && o(u), u = null, c = !0;
439
+ u !== null && s(u), u = null, c = !0;
463
440
  }
464
441
  };
465
442
  }
466
- function Ji({
443
+ function Pr({
467
444
  durationMs: t,
468
445
  epoch: e,
469
446
  paused: n,
470
447
  onExpire: a
471
448
  }) {
472
- const i = $(a);
473
- i.current = a;
474
- const o = $(null);
475
- k(() => {
449
+ const r = $(a);
450
+ r.current = a;
451
+ const s = $(null);
452
+ F(() => {
476
453
  if (t === null || !Number.isFinite(t)) return;
477
- const s = Zi(() => i.current(), t);
478
- return o.current = s, () => {
479
- o.current = null, s.cancel();
454
+ const o = Nr(() => r.current(), t);
455
+ return s.current = o, () => {
456
+ s.current = null, o.cancel();
480
457
  };
481
- }, [t, e]), k(() => {
482
- const s = o.current;
483
- s && (n ? s.pause() : s.start());
458
+ }, [t, e]), F(() => {
459
+ const o = s.current;
460
+ o && (n ? o.pause() : o.start());
484
461
  }, [t, e, n]);
485
462
  }
486
- const er = 260, $n = 8e3, tr = {
487
- loading: Ai,
488
- success: at,
489
- error: Ei,
490
- info: xi
463
+ const Tr = 260, aa = 8e3, Cr = {
464
+ loading: Qi,
465
+ success: dt,
466
+ error: Zi,
467
+ info: Jn
491
468
  };
492
- function nr(t, e) {
493
- return t.duration !== void 0 ? Number.isFinite(t.duration) ? t.duration : null : t.type === "loading" ? null : t.type === "error" ? $n : e;
469
+ function Mr(t, e) {
470
+ return t.duration !== void 0 ? Number.isFinite(t.duration) ? t.duration : null : t.type === "loading" ? null : t.type === "error" ? aa : e;
494
471
  }
495
- const ar = nt(function({
472
+ const Rr = ft(function({
496
473
  toast: e,
497
474
  index: n,
498
475
  zIndex: a,
499
- offset: i,
500
- front: o,
501
- hidden: s,
476
+ offset: r,
477
+ front: s,
478
+ hidden: o,
502
479
  regionPaused: l,
503
480
  yPosition: u,
504
481
  defaultDurationMs: c,
505
- closeButton: p,
506
- height: g,
507
- registerHeight: y,
508
- unregisterHeight: I,
509
- swipeStateRef: b
482
+ closeButton: f,
483
+ height: m,
484
+ registerHeight: I,
485
+ unregisterHeight: E,
486
+ swipeStateRef: v
510
487
  }) {
511
- var V;
512
- const w = $(null), S = $(null), [A, M] = N(!1), [L, D] = N(!1), [_, f] = N(!1);
513
- k(() => {
488
+ var K;
489
+ const w = $(null), b = $(null), [x, R] = T(!1), [O, B] = T(!1), [S, h] = T(!1);
490
+ F(() => {
514
491
  let d = 0;
515
- const v = requestAnimationFrame(() => {
516
- d = requestAnimationFrame(() => M(!0));
492
+ const _ = requestAnimationFrame(() => {
493
+ d = requestAnimationFrame(() => R(!0));
517
494
  });
518
495
  return () => {
519
- cancelAnimationFrame(v), cancelAnimationFrame(d);
496
+ cancelAnimationFrame(_), cancelAnimationFrame(d);
520
497
  };
521
- }, []), Wa(() => {
498
+ }, []), ai(() => {
522
499
  if (e.dismissed) return;
523
500
  const d = w.current;
524
- d && y(e.id, Bi(d));
501
+ d && I(e.id, ur(d));
525
502
  }, [
526
- y,
527
- (V = e.action) == null ? void 0 : V.label,
503
+ I,
504
+ (K = e.action) == null ? void 0 : K.label,
528
505
  e.description,
529
506
  e.dismissed,
530
507
  e.id,
531
508
  e.title
532
509
  ]);
533
- const C = $(i);
534
- e.dismissed || (C.current = i);
535
- const x = e.dismissed ? C.current : i;
536
- k(() => {
510
+ const A = $(r);
511
+ e.dismissed || (A.current = r);
512
+ const y = e.dismissed ? A.current : r;
513
+ F(() => {
537
514
  if (!e.dismissed) {
538
- f(!1);
515
+ h(!1);
539
516
  return;
540
517
  }
541
- I(e.id);
542
- const d = window.setTimeout(() => $i(e.id), er);
518
+ E(e.id);
519
+ const d = window.setTimeout(() => mr(e.id), Tr);
543
520
  return () => window.clearTimeout(d);
544
- }, [e.dismissed, e.id, I]), k(() => () => I(e.id), [e.id, I]), Ji({
545
- durationMs: nr(e, c),
521
+ }, [e.dismissed, e.id, E]), F(() => () => E(e.id), [e.id, E]), Pr({
522
+ durationMs: Mr(e, c),
546
523
  epoch: e.updatedAt,
547
- paused: l || L || s || e.dismissed,
548
- onExpire: () => me(e.id)
524
+ paused: l || O || o || e.dismissed,
525
+ onExpire: () => ve(e.id)
549
526
  });
550
- const W = (d, v) => {
551
- const U = S.current;
552
- if (!U || d.pointerId !== U.pointerId || (S.current = null, U.intent !== "swipe")) return;
553
- D(!1), b.current = !1;
554
- const F = w.current, ee = F && Number.parseFloat(F.style.getPropertyValue("--swipe-y")) || 0;
555
- !v && Xi(ee, Date.now() - U.startedAt) ? (f(!0), me(e.id)) : F == null || F.style.setProperty("--swipe-y", "0px");
556
- }, q = (d) => {
557
- !e.dismissible || e.dismissed || d.target.closest("button, a") || (S.current = {
527
+ const M = (d, _) => {
528
+ const V = b.current;
529
+ if (!V || d.pointerId !== V.pointerId || (b.current = null, V.intent !== "swipe")) return;
530
+ B(!1), v.current = !1;
531
+ const L = w.current, X = L && Number.parseFloat(L.style.getPropertyValue("--swipe-y")) || 0;
532
+ !_ && Ar(X, Date.now() - V.startedAt) ? (h(!0), ve(e.id)) : L == null || L.style.setProperty("--swipe-y", "0px");
533
+ }, H = (d) => {
534
+ !e.dismissible || e.dismissed || d.target.closest("button, a") || (b.current = {
558
535
  pointerId: d.pointerId,
559
536
  startX: d.clientX,
560
537
  startY: d.clientY,
561
538
  startedAt: Date.now(),
562
539
  intent: "pending"
563
540
  }, d.currentTarget.setPointerCapture(d.pointerId));
564
- }, H = (d) => {
565
- var P;
566
- const v = S.current;
567
- if (!v || d.pointerId !== v.pointerId) return;
568
- const U = d.clientX - v.startX, F = d.clientY - v.startY;
569
- if (v.intent === "pending" && (v.intent = Qi(U, F, d.pointerType || "mouse"), v.intent === "swipe" && (D(!0), b.current = !0)), v.intent !== "swipe") return;
570
- const ee = Yi(F, ji(u));
571
- (P = w.current) == null || P.style.setProperty("--swipe-y", `${ee}px`);
572
- }, E = tr[e.type], Y = {
541
+ }, z = (d) => {
542
+ var ne;
543
+ const _ = b.current;
544
+ if (!_ || d.pointerId !== _.pointerId) return;
545
+ const V = d.clientX - _.startX, L = d.clientY - _.startY;
546
+ if (_.intent === "pending" && (_.intent = xr(V, L, d.pointerType || "mouse"), _.intent === "swipe" && (B(!0), v.current = !0)), _.intent !== "swipe") return;
547
+ const X = Er(L, Sr(u));
548
+ (ne = w.current) == null || ne.style.setProperty("--swipe-y", `${X}px`);
549
+ }, N = Cr[e.type], te = {
573
550
  "--index": n,
574
551
  "--z": a,
575
- "--offset": `${x}px`,
576
- ...g !== void 0 ? { "--initial-height": `${g}px` } : {}
552
+ "--offset": `${y}px`,
553
+ ...m !== void 0 ? { "--initial-height": `${m}px` } : {}
577
554
  };
578
- return /* @__PURE__ */ m(
555
+ return /* @__PURE__ */ p(
579
556
  "li",
580
557
  {
581
558
  ref: w,
582
559
  className: "aegis-swap-toast",
583
560
  "data-type": e.type,
584
- "data-mounted": A ? "" : void 0,
585
- "data-front": o ? "" : void 0,
586
- "data-removing": e.dismissed && !_ ? "" : void 0,
587
- "data-swipe-out": _ ? "" : void 0,
588
- "data-swiping": L ? "" : void 0,
589
- "data-hidden": s ? "" : void 0,
561
+ "data-mounted": x ? "" : void 0,
562
+ "data-front": s ? "" : void 0,
563
+ "data-removing": e.dismissed && !S ? "" : void 0,
564
+ "data-swipe-out": S ? "" : void 0,
565
+ "data-swiping": O ? "" : void 0,
566
+ "data-hidden": o ? "" : void 0,
590
567
  "data-dismissible": e.dismissible ? "" : void 0,
591
568
  role: e.type === "error" ? "alert" : "status",
592
569
  "aria-live": e.type === "error" ? "assertive" : "polite",
593
570
  "aria-atomic": "true",
594
- "aria-hidden": s ? !0 : void 0,
595
- style: Y,
596
- onPointerDown: q,
597
- onPointerMove: H,
598
- onPointerUp: (d) => W(d, !1),
599
- onPointerCancel: (d) => W(d, !0),
571
+ "aria-hidden": o ? !0 : void 0,
572
+ style: te,
573
+ onPointerDown: H,
574
+ onPointerMove: z,
575
+ onPointerUp: (d) => M(d, !1),
576
+ onPointerCancel: (d) => M(d, !0),
600
577
  onKeyDown: (d) => {
601
- d.key === "Escape" && e.dismissible && !e.dismissed && (d.stopPropagation(), me(e.id));
578
+ d.key === "Escape" && e.dismissible && !e.dismissed && (d.stopPropagation(), ve(e.id));
602
579
  },
603
580
  children: [
604
- /* @__PURE__ */ r("span", { className: "aegis-swap-toast__icon", "aria-hidden": "true", children: /* @__PURE__ */ r(E, {}) }, e.type),
605
- /* @__PURE__ */ m("div", { className: "aegis-swap-toast__content", children: [
606
- /* @__PURE__ */ r("p", { className: "aegis-swap-toast__title", children: e.title }, `t:${e.title}`),
607
- e.description ? /* @__PURE__ */ r(
581
+ /* @__PURE__ */ i("span", { className: "aegis-swap-toast__icon", "aria-hidden": "true", children: /* @__PURE__ */ i(N, {}) }, e.type),
582
+ /* @__PURE__ */ p("div", { className: "aegis-swap-toast__content", children: [
583
+ /* @__PURE__ */ i("p", { className: "aegis-swap-toast__title", children: e.title }, `t:${e.title}`),
584
+ e.description ? /* @__PURE__ */ i(
608
585
  "p",
609
586
  {
610
587
  className: "aegis-swap-toast__description",
@@ -613,144 +590,144 @@ const ar = nt(function({
613
590
  `d:${e.description}`
614
591
  ) : null
615
592
  ] }),
616
- e.action ? e.action.href ? /* @__PURE__ */ r(
593
+ e.action ? e.action.href ? /* @__PURE__ */ i(
617
594
  "a",
618
595
  {
619
596
  className: "aegis-swap-toast__action",
620
597
  href: e.action.href,
621
598
  target: "_blank",
622
599
  rel: "noopener noreferrer",
623
- onClick: () => me(e.id),
600
+ onClick: () => ve(e.id),
624
601
  children: e.action.label
625
602
  }
626
- ) : /* @__PURE__ */ r(
603
+ ) : /* @__PURE__ */ i(
627
604
  "button",
628
605
  {
629
606
  type: "button",
630
607
  className: "aegis-swap-toast__action",
631
608
  onClick: () => {
632
- var d, v;
633
- (v = (d = e.action) == null ? void 0 : d.onClick) == null || v.call(d), me(e.id);
609
+ var d, _;
610
+ (_ = (d = e.action) == null ? void 0 : d.onClick) == null || _.call(d), ve(e.id);
634
611
  },
635
612
  children: e.action.label
636
613
  }
637
614
  ) : null,
638
- p && e.dismissible ? /* @__PURE__ */ r(
615
+ f && e.dismissible ? /* @__PURE__ */ i(
639
616
  "button",
640
617
  {
641
618
  type: "button",
642
619
  className: "aegis-swap-toast__close",
643
620
  "aria-label": "Dismiss notification",
644
- onClick: () => me(e.id),
645
- children: /* @__PURE__ */ r(Pi, {})
621
+ onClick: () => ve(e.id),
622
+ children: /* @__PURE__ */ i(Ji, {})
646
623
  }
647
624
  ) : null
648
625
  ]
649
626
  }
650
627
  );
651
628
  });
652
- function ir(t) {
629
+ function Dr(t) {
653
630
  return document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t);
654
631
  }
655
- const rr = () => !0;
656
- function sr() {
657
- return _t(ir, Fe, rr);
632
+ const Or = () => !0;
633
+ function Br() {
634
+ return ut(Dr, ze, Or);
658
635
  }
659
- const or = 12, lr = 5e3, cr = 3, ur = () => it, dr = () => !1;
660
- function qn({
636
+ const kr = 12, Lr = 5e3, Fr = 3, Ur = () => ht, $r = () => !1;
637
+ function ia({
661
638
  kind: t,
662
639
  position: e = "bottom-right",
663
640
  theme: n,
664
641
  accentColor: a,
665
- accentTextColor: i,
666
- duration: o = lr,
667
- visibleToasts: s = cr,
642
+ accentTextColor: r,
643
+ duration: s = Lr,
644
+ visibleToasts: o = Fr,
668
645
  closeButton: l = !1,
669
646
  expand: u = !1,
670
647
  offset: c,
671
- className: p,
672
- style: g
648
+ className: f,
649
+ style: m
673
650
  }) {
674
- const y = _t(ki, Fi, ur), I = $({}).current;
675
- k(() => zi(I, t), [t, I]);
676
- const b = _t(
677
- Hi,
678
- () => Vi(I),
679
- dr
680
- ), [w, S] = N(!1);
681
- k(() => S(!0), []);
682
- const A = Wn(n), M = sr(), [L, D] = N(!1), [_, f] = N(!1), [C, x] = N({}), W = $(!1), q = B((h, T) => {
683
- x((R) => R[h] === T ? R : { ...R, [h]: T });
684
- }, []), H = B((h) => {
685
- x((T) => {
686
- if (!(h in T)) return T;
687
- const R = { ...T };
688
- return delete R[h], R;
651
+ const I = ut(fr, pr, Ur), E = $({}).current;
652
+ F(() => br(E, t), [t, E]);
653
+ const v = ut(
654
+ yr,
655
+ () => vr(E),
656
+ $r
657
+ ), [w, b] = T(!1);
658
+ F(() => b(!0), []);
659
+ const x = na(n), R = Br(), [O, B] = T(!1), [S, h] = T(!1), [A, y] = T({}), M = $(!1), H = D((k, g) => {
660
+ y((C) => C[k] === g ? C : { ...C, [k]: g });
661
+ }, []), z = D((k) => {
662
+ y((g) => {
663
+ if (!(k in g)) return g;
664
+ const C = { ...g };
665
+ return delete C[k], C;
689
666
  });
690
- }, []), E = X(() => [...y].reverse(), [y]), Y = X(
691
- () => Di(E, C, or, s),
692
- [C, E, s]
693
- ), V = E.find((h) => !h.dismissed) ?? E[0], d = V ? C[V.id] ?? 0 : 0;
694
- k(() => {
695
- E.length > 0 || (D(!1), f(!1));
696
- }, [E.length]);
697
- const [v, U] = e.split("-"), F = u || L || _, ee = L || _ || !M, P = X(() => {
698
- const h = { ...g };
667
+ }, []), N = J(() => [...I].reverse(), [I]), te = J(
668
+ () => cr(N, A, kr, o),
669
+ [A, N, o]
670
+ ), K = N.find((k) => !k.dismissed) ?? N[0], d = K ? A[K.id] ?? 0 : 0;
671
+ F(() => {
672
+ N.length > 0 || (B(!1), h(!1));
673
+ }, [N.length]);
674
+ const [_, V] = e.split("-"), L = u || O || S, X = O || S || !R, ne = J(() => {
675
+ const k = { ...m };
699
676
  if (a) {
700
- h["--aegis-swap-accent"] = a;
701
- const T = i ?? kn(a);
702
- T && (h["--aegis-swap-accent-text"] = T);
703
- } else i && (h["--aegis-swap-accent-text"] = i);
677
+ k["--aegis-swap-accent"] = a;
678
+ const g = r ?? ea(a);
679
+ g && (k["--aegis-swap-accent-text"] = g);
680
+ } else r && (k["--aegis-swap-accent-text"] = r);
704
681
  if (c !== void 0) {
705
- const T = typeof c == "number" ? `${c}px` : c;
706
- h["--aegis-swap-toast-offset-x"] = T, h["--aegis-swap-toast-offset-y"] = T;
682
+ const g = typeof c == "number" ? `${c}px` : c;
683
+ k["--aegis-swap-toast-offset-x"] = g, k["--aegis-swap-toast-offset-y"] = g;
707
684
  }
708
- return h["--aegis-swap-toast-front-height"] = `${d}px`, h;
709
- }, [a, i, d, c, g]);
710
- return !w || !b || E.length === 0 ? null : pi(
711
- /* @__PURE__ */ r(
685
+ return k["--aegis-swap-toast-front-height"] = `${d}px`, k;
686
+ }, [a, r, d, c, m]);
687
+ return !w || !v || N.length === 0 ? null : Di(
688
+ /* @__PURE__ */ i(
712
689
  "ol",
713
690
  {
714
691
  className: [
715
692
  "aegis-swap-toaster",
716
- A === "light" ? "aegis-swap-toaster--light" : "",
717
- p ?? ""
693
+ x === "light" ? "aegis-swap-toaster--light" : "",
694
+ f ?? ""
718
695
  ].join(" ").trim(),
719
- "data-y-position": v,
720
- "data-x-position": U,
721
- "data-expanded": F ? "" : void 0,
696
+ "data-y-position": _,
697
+ "data-x-position": V,
698
+ "data-expanded": L ? "" : void 0,
722
699
  "aria-label": "Notifications",
723
- style: P,
724
- onMouseEnter: () => D(!0),
725
- onMouseMove: () => D(!0),
700
+ style: ne,
701
+ onMouseEnter: () => B(!0),
702
+ onMouseMove: () => B(!0),
726
703
  onMouseLeave: () => {
727
- W.current || D(!1);
704
+ M.current || B(!1);
728
705
  },
729
- onFocus: () => f(!0),
730
- onBlur: (h) => {
731
- h.currentTarget.contains(h.relatedTarget) || f(!1);
706
+ onFocus: () => h(!0),
707
+ onBlur: (k) => {
708
+ k.currentTarget.contains(k.relatedTarget) || h(!1);
732
709
  },
733
- children: E.map((h) => {
734
- const T = Y.get(h.id);
735
- return T ? /* @__PURE__ */ r(
736
- ar,
710
+ children: N.map((k) => {
711
+ const g = te.get(k.id);
712
+ return g ? /* @__PURE__ */ i(
713
+ Rr,
737
714
  {
738
- toast: h,
739
- index: T.index,
740
- zIndex: T.zIndex,
741
- offset: T.offset,
742
- front: T.front,
743
- hidden: T.hidden,
744
- regionPaused: ee,
745
- yPosition: v,
746
- defaultDurationMs: o,
715
+ toast: k,
716
+ index: g.index,
717
+ zIndex: g.zIndex,
718
+ offset: g.offset,
719
+ front: g.front,
720
+ hidden: g.hidden,
721
+ regionPaused: X,
722
+ yPosition: _,
723
+ defaultDurationMs: s,
747
724
  closeButton: l,
748
- height: C[h.id],
749
- registerHeight: q,
750
- unregisterHeight: H,
751
- swipeStateRef: W
725
+ height: A[k.id],
726
+ registerHeight: H,
727
+ unregisterHeight: z,
728
+ swipeStateRef: M
752
729
  },
753
- h.id
730
+ k.id
754
731
  ) : null;
755
732
  })
756
733
  }
@@ -758,137 +735,192 @@ function qn({
758
735
  document.body
759
736
  );
760
737
  }
761
- function ns(t) {
762
- return /* @__PURE__ */ r(qn, { kind: "host", ...t });
738
+ function ks(t) {
739
+ return /* @__PURE__ */ i(ia, { kind: "host", ...t });
763
740
  }
764
- function pr(t) {
765
- return /* @__PURE__ */ r(qn, { kind: "internal", ...t });
741
+ function Wr(t) {
742
+ return /* @__PURE__ */ i(ia, { kind: "internal", ...t });
766
743
  }
767
- function Oe(t) {
768
- return (e, n) => Le({ ...n, type: t, title: e });
744
+ function Ge(t) {
745
+ const a = ((t.match(/,/g) ?? []).length === 1 && !t.includes(".") ? t.replace(",", ".") : t).replace(/[^\d.]/g, ""), [r = "", ...s] = a.split("."), o = s.length > 0 ? `${r}.${s.join("")}` : r;
746
+ return o === "." ? "0." : o;
747
+ }
748
+ function Rn(t) {
749
+ const e = Ge(t);
750
+ if (!e) return "";
751
+ const n = Number(e);
752
+ return Number.isFinite(n) && n > 20 ? "20" : e;
753
+ }
754
+ function Hr(t, e) {
755
+ const n = t.trim();
756
+ if (!n || n === ".") return null;
757
+ try {
758
+ return Oi(n, e);
759
+ } catch {
760
+ return null;
761
+ }
769
762
  }
770
- function bt(t, e) {
763
+ function Dn(t) {
764
+ const e = t.trim();
765
+ if (!e) return null;
766
+ const n = Number(e);
767
+ return !Number.isFinite(n) || n < 0 || n > 20 ? null : Math.round(n * 100);
768
+ }
769
+ function gt(t, e, n = "half-up") {
770
+ if (t === 0n || e <= 0) return t;
771
+ const a = t < 0n ? -1n : 1n, r = t < 0n ? -t : t, o = r.toString().length - e;
772
+ if (o <= 0) return t;
773
+ const l = 10n ** BigInt(o);
774
+ return (n === "floor" ? r / l * l : (r + l / 2n) / l * l) * a;
775
+ }
776
+ function Xe(t) {
777
+ return t.includes(".") ? t.replace(/\.?0+$/, "") : t;
778
+ }
779
+ function _e(t, e, n = 4) {
780
+ return t == null ? "--" : Xe(kt(gt(t, n), e));
781
+ }
782
+ function Vr(t, e, n = 4) {
783
+ return t == null ? "--" : Xe(
784
+ kt(gt(t, n, "floor"), e)
785
+ );
786
+ }
787
+ function On(t, e) {
788
+ return t == null ? "" : _e(t, e);
789
+ }
790
+ function qr(t, e) {
791
+ return t == null ? "" : Xe(kt(t, e));
792
+ }
793
+ function Gr(t, e = 4) {
794
+ return t == null ? "--" : Xe(Bi(gt(t, e)));
795
+ }
796
+ function zr(t, e = 4) {
797
+ return t == null ? "--" : Xe(ki(gt(t, e)));
798
+ }
799
+ function He(t) {
800
+ return (e, n) => qe({ ...n, type: t, title: e });
801
+ }
802
+ function Pt(t, e) {
771
803
  const n = typeof t == "function" ? t(e) : t;
772
804
  return typeof n == "string" ? { title: n } : n;
773
805
  }
774
- const he = Object.assign(Oe("info"), {
775
- info: Oe("info"),
776
- success: Oe("success"),
777
- error: Oe("error"),
778
- loading: Oe("loading"),
806
+ const ye = Object.assign(He("info"), {
807
+ info: He("info"),
808
+ success: He("success"),
809
+ error: He("error"),
810
+ loading: He("loading"),
779
811
  dismiss(t) {
780
- me(t);
812
+ ve(t);
781
813
  },
782
814
  promise(t, e) {
783
- const n = typeof e.loading == "string" ? { title: e.loading } : e.loading, a = Le({ ...n, id: e.id, type: "loading" });
784
- let i;
815
+ const n = typeof e.loading == "string" ? { title: e.loading } : e.loading, a = qe({ ...n, id: e.id, type: "loading" });
816
+ let r;
785
817
  try {
786
- i = typeof t == "function" ? t() : t;
787
- } catch (o) {
788
- throw Le({ ...bt(e.error, o), id: a, type: "error" }), o;
818
+ r = typeof t == "function" ? t() : t;
819
+ } catch (s) {
820
+ throw qe({ ...Pt(e.error, s), id: a, type: "error" }), s;
789
821
  }
790
- return i.then(
791
- (o) => {
792
- Le({ ...bt(e.success, o), id: a, type: "success" });
822
+ return r.then(
823
+ (s) => {
824
+ qe({ ...Pt(e.success, s), id: a, type: "success" });
793
825
  },
794
- (o) => {
795
- Le({ ...bt(e.error, o), id: a, type: "error" });
826
+ (s) => {
827
+ qe({ ...Pt(e.error, s), id: a, type: "error" });
796
828
  }
797
829
  ), a;
798
830
  }
799
- }), fr = 4e3;
800
- function hr({
831
+ }), Kr = 4e3;
832
+ function jr({
801
833
  enabled: t,
802
834
  status: e,
803
835
  progress: n,
804
836
  txHash: a,
805
- explorerUrl: i,
806
- successDescription: o
837
+ explorerUrl: r,
838
+ successDescription: s
807
839
  }) {
808
- const s = $({ currentId: null, terminal: !1, lastId: null }), l = (n == null ? void 0 : n.state) ?? null, u = (n == null ? void 0 : n.label) ?? null;
809
- k(() => {
810
- const c = s.current;
840
+ const o = $({ currentId: null, terminal: !1, lastId: null }), l = (n == null ? void 0 : n.state) ?? null, u = (n == null ? void 0 : n.label) ?? null;
841
+ F(() => {
842
+ const c = o.current;
811
843
  if (!t) {
812
- c.currentId && !c.terminal && he.dismiss(c.currentId), c.currentId = null, c.terminal = !1;
844
+ c.currentId && !c.terminal && ye.dismiss(c.currentId), c.currentId = null, c.terminal = !1;
813
845
  return;
814
846
  }
815
- const p = a && i ? { label: "View transaction", href: i } : void 0;
847
+ const f = a && r ? { label: "View transaction", href: r } : void 0;
816
848
  if (l === "error" && u) {
817
- c.currentId = he.error(u, {
849
+ c.currentId = ye.error(u, {
818
850
  id: c.currentId ?? void 0,
819
- action: p,
820
- duration: u === qa ? fr : $n
851
+ action: f,
852
+ duration: u === ci ? Kr : aa
821
853
  }), c.terminal = !0, c.lastId = c.currentId;
822
854
  return;
823
855
  }
824
856
  if (e === "success") {
825
- c.currentId = he.success("Swap confirmed", {
857
+ c.currentId = ye.success("Swap confirmed", {
826
858
  id: c.currentId ?? void 0,
827
- description: o ?? void 0,
828
- action: p
859
+ description: s ?? void 0,
860
+ action: f
829
861
  }), c.terminal = !0, c.lastId = c.currentId;
830
862
  return;
831
863
  }
832
- if ((l === "pending" || l === "mining") && Nn(e) && u) {
833
- (!c.currentId || c.terminal) && (c.lastId && he.dismiss(c.lastId), c.currentId = null, c.terminal = !1), c.currentId = he.loading(u, {
864
+ if ((l === "pending" || l === "mining") && qn(e) && u) {
865
+ (!c.currentId || c.terminal) && (c.lastId && ye.dismiss(c.lastId), c.currentId = null, c.terminal = !1), c.currentId = ye.loading(u, {
834
866
  id: c.currentId ?? void 0
835
867
  }), c.lastId = c.currentId;
836
868
  return;
837
869
  }
838
- c.currentId && !c.terminal && (he.dismiss(c.currentId), c.currentId = null);
839
- }, [t, i, u, l, e, o, a]), k(
870
+ c.currentId && !c.terminal && (ye.dismiss(c.currentId), c.currentId = null);
871
+ }, [t, r, u, l, e, s, a]), F(
840
872
  () => () => {
841
- const c = s.current;
842
- c.currentId && !c.terminal && he.dismiss(c.currentId);
873
+ const c = o.current;
874
+ c.currentId && !c.terminal && ye.dismiss(c.currentId);
843
875
  },
844
876
  []
845
877
  );
846
878
  }
847
- function zn(t, e, { initial: n, label: a, equals: i = Object.is }) {
848
- const o = $(t);
849
- o.current = t;
850
- const s = $(n);
851
- k(() => {
879
+ function ra(t, e, { initial: n, label: a, equals: r = Object.is }) {
880
+ const s = $(t);
881
+ s.current = t;
882
+ const o = $(n);
883
+ F(() => {
852
884
  var l;
853
- if (!i(s.current, e)) {
854
- s.current = e;
885
+ if (!r(o.current, e)) {
886
+ o.current = e;
855
887
  try {
856
- (l = o.current) == null || l.call(o, e);
888
+ (l = s.current) == null || l.call(s, e);
857
889
  } catch (u) {
858
890
  console.warn(`[AegisSwapWidget] ${a} callback failed`, u);
859
891
  }
860
892
  }
861
893
  });
862
894
  }
863
- function mr(t, e) {
864
- zn(t ? (a) => {
895
+ function Xr(t, e) {
896
+ ra(t ? (a) => {
865
897
  a !== void 0 && t(a);
866
898
  } : void 0, e, { initial: e, label: "onPoolChange" });
867
899
  }
868
- function Hn(t, e) {
869
- return Pt(t, e, /* @__PURE__ */ new WeakSet());
900
+ function sa(t, e) {
901
+ return Bt(t, e, /* @__PURE__ */ new WeakSet());
870
902
  }
871
- function Pt(t, e, n) {
903
+ function Bt(t, e, n) {
872
904
  if (t === e) return !0;
873
905
  if (typeof t != typeof e || typeof t != "object" || t === null || e === null || n.has(t)) return !1;
874
906
  n.add(t);
875
907
  try {
876
908
  if (Array.isArray(t))
877
- return !Array.isArray(e) || t.length !== e.length ? !1 : t.every((s, l) => Pt(s, e[l], n));
909
+ return !Array.isArray(e) || t.length !== e.length ? !1 : t.every((o, l) => Bt(o, e[l], n));
878
910
  if (Array.isArray(e)) return !1;
879
- const a = t, i = e, o = Object.keys(a);
880
- return o.length !== Object.keys(i).length ? !1 : o.every(
881
- (s) => Object.prototype.hasOwnProperty.call(i, s) && Pt(a[s], i[s], n)
911
+ const a = t, r = e, s = Object.keys(a);
912
+ return s.length !== Object.keys(r).length ? !1 : s.every(
913
+ (o) => Object.prototype.hasOwnProperty.call(r, o) && Bt(a[o], r[o], n)
882
914
  );
883
915
  } finally {
884
916
  n.delete(t);
885
917
  }
886
918
  }
887
- function Ie(t) {
919
+ function Ce(t) {
888
920
  const e = $(t);
889
- return Hn(e.current, t) || (e.current = t), e.current;
921
+ return sa(e.current, t) || (e.current = t), e.current;
890
922
  }
891
- const gr = {
923
+ const Yr = {
892
924
  status: "idle",
893
925
  progress: null,
894
926
  label: null,
@@ -898,768 +930,776 @@ const gr = {
898
930
  txHash: null,
899
931
  error: null
900
932
  };
901
- function wr(t, e) {
902
- zn(t, e, {
903
- initial: gr,
933
+ function Qr(t, e) {
934
+ ra(t, e, {
935
+ initial: Yr,
904
936
  label: "onStatusChange",
905
- equals: Hn
937
+ equals: sa
906
938
  });
907
939
  }
908
- async function yr({
940
+ async function Zr({
909
941
  wallet: t,
910
942
  publicClient: e,
911
943
  activeChain: n,
912
944
  permit2: a,
913
- router: i,
914
- token: o,
915
- amount: s,
945
+ router: r,
946
+ token: s,
947
+ amount: o,
916
948
  approvalMode: l,
917
949
  allowanceRead: u,
918
950
  setStatus: c
919
951
  }) {
920
952
  try {
921
- return await za({
953
+ return await ui({
922
954
  provider: t.provider,
923
955
  publicClient: e,
924
956
  account: t.account,
925
957
  chainId: n.chainId,
926
958
  chain: n.chain,
927
959
  permit2: a,
928
- router: i,
929
- token: o,
930
- amount: s,
960
+ router: r,
961
+ token: s,
962
+ amount: o,
931
963
  sizing: l,
932
964
  allowanceRead: u
933
965
  });
934
- } catch (p) {
935
- if (Ha(p)) throw p;
936
- return c("approving"), await Va({
966
+ } catch (f) {
967
+ if (di(f)) throw f;
968
+ return c("approving"), await pi({
937
969
  provider: t.provider,
938
970
  publicClient: e,
939
971
  account: t.account,
940
972
  chain: n.chain,
941
- token: o,
973
+ token: s,
942
974
  permit2: a,
943
- router: i,
975
+ router: r,
944
976
  // undefined -> MAX_UINT160, mirroring the 'max' permit sizing above.
945
- amount: l === "max" ? void 0 : s,
946
- expiration: Math.floor(Date.now() / 1e3) + Ga
977
+ amount: l === "max" ? void 0 : o,
978
+ expiration: Math.floor(Date.now() / 1e3) + fi
947
979
  }), null;
948
980
  }
949
981
  }
950
- async function br({
982
+ async function Jr({
951
983
  wallet: t,
952
984
  publicClient: e,
953
985
  activeChain: n,
954
986
  market: a,
955
- inputToken: i,
956
- outputToken: o,
957
- swapQuote: s,
987
+ inputToken: r,
988
+ outputToken: s,
989
+ swapQuote: o,
958
990
  permit: l,
959
991
  setStatus: u,
960
992
  setTxHash: c,
961
- onSubmitted: p
993
+ onSubmitted: f
962
994
  }) {
963
- const g = BigInt(Math.floor(Date.now() / 1e3) + Cn), y = Ka(s), I = s.mode === "exactOut" ? ja({
964
- poolKey: s.poolKey,
965
- zeroForOne: s.zeroForOne,
966
- amountOut: s.grossAmountOut,
967
- amountInMaximum: s.amountInMaximum,
995
+ const m = BigInt(Math.floor(Date.now() / 1e3) + Gn), I = hi(o), E = o.mode === "exactOut" ? gi({
996
+ poolKey: o.poolKey,
997
+ zeroForOne: o.zeroForOne,
998
+ amountOut: o.grossAmountOut,
999
+ amountInMaximum: o.amountInMaximum,
968
1000
  recipient: t.account,
969
- deadline: g,
1001
+ deadline: m,
970
1002
  permit: l,
971
- fee: y
972
- }) : Xa({
973
- poolKey: s.poolKey,
974
- zeroForOne: s.zeroForOne,
975
- amountIn: s.amountIn,
976
- amountOutMinimum: s.amountOutMinimum,
1003
+ fee: I
1004
+ }) : mi({
1005
+ poolKey: o.poolKey,
1006
+ zeroForOne: o.zeroForOne,
1007
+ amountIn: o.amountIn,
1008
+ amountOutMinimum: o.amountOutMinimum,
977
1009
  recipient: t.account,
978
- deadline: g,
1010
+ deadline: m,
979
1011
  permit: l,
980
- fee: y
1012
+ fee: I
981
1013
  });
982
1014
  u("submitting");
983
- const b = ka({
1015
+ const v = Li({
984
1016
  account: t.account,
985
1017
  chain: n.chain,
986
- transport: Ua(t.provider)
1018
+ transport: Fi(t.provider)
987
1019
  }), w = await e.estimateGas({
988
1020
  account: t.account,
989
1021
  to: a.router,
990
- data: I.calldata,
991
- value: I.value
992
- }), S = await b.sendTransaction({
1022
+ data: E.calldata,
1023
+ value: E.value
1024
+ }), b = await v.sendTransaction({
993
1025
  to: a.router,
994
- data: I.calldata,
995
- value: I.value,
1026
+ data: E.calldata,
1027
+ value: E.value,
996
1028
  gas: w * 12n / 10n
997
- }), A = {
998
- mode: s.mode,
999
- inputSymbol: i.symbol,
1000
- outputSymbol: o.symbol,
1001
- amountIn: s.amountIn,
1002
- amountOut: s.amountOut,
1003
- feeAmount: s.feeAmount,
1004
- feeBps: s.feeBps
1029
+ }), x = {
1030
+ mode: o.mode,
1031
+ inputSymbol: r.symbol,
1032
+ outputSymbol: s.symbol,
1033
+ amountIn: o.amountIn,
1034
+ amountOut: o.amountOut,
1035
+ feeAmount: o.feeAmount,
1036
+ feeBps: o.feeBps
1005
1037
  };
1006
- c(S);
1038
+ c(b);
1007
1039
  try {
1008
- p == null || p(S, A);
1009
- } catch (D) {
1010
- console.warn("[AegisSwapWidget] onSubmitted callback failed", D);
1040
+ f == null || f(b, x);
1041
+ } catch (A) {
1042
+ console.warn("[AegisSwapWidget] onSubmitted callback failed", A);
1011
1043
  }
1012
- let M = null;
1013
- const L = await e.waitForTransactionReceipt({
1014
- hash: S,
1015
- onReplaced: (D) => {
1016
- M = D.reason, c(D.transaction.hash);
1044
+ let R = null;
1045
+ const O = await e.waitForTransactionReceipt({
1046
+ hash: b,
1047
+ onReplaced: (A) => {
1048
+ R = A.reason, c(A.transaction.hash);
1017
1049
  }
1018
1050
  });
1019
- if (M === "cancelled") throw new Error("Swap was cancelled in the wallet.");
1020
- if (L.status === "reverted") throw new Error("Swap reverted on-chain.");
1021
- return { receipt: L, swapDetails: A };
1051
+ if (R === "cancelled") throw new Error("Swap was cancelled in the wallet.");
1052
+ if (O.status === "reverted") throw new Error("Swap reverted on-chain.");
1053
+ const B = O.gasUsed ?? 0n, S = O.effectiveGasPrice ?? 0n, h = {
1054
+ transactionHash: O.transactionHash,
1055
+ blockNumber: O.blockNumber ?? 0n,
1056
+ gasUsed: B,
1057
+ effectiveGasPrice: S,
1058
+ feeWei: B * S
1059
+ };
1060
+ return { receipt: O, summary: h, swapDetails: x };
1022
1061
  }
1023
- async function _r(t, e) {
1024
- return await On(
1025
- () => ke(t),
1062
+ async function es(t, e) {
1063
+ return await Xn(
1064
+ () => Ke(t),
1026
1065
  (a) => a === e,
1027
1066
  12,
1028
1067
  250
1029
1068
  ) === e;
1030
1069
  }
1031
- function vr(t, e) {
1032
- return On(t, (n) => n >= e, 5, 300);
1070
+ function ts(t, e) {
1071
+ return Xn(t, (n) => n >= e, 5, 300);
1033
1072
  }
1034
- function Ir({
1073
+ function ns({
1035
1074
  publicClient: t,
1036
1075
  activeChain: e,
1037
1076
  market: n,
1038
1077
  inputToken: a,
1039
- outputToken: i,
1040
- quoteMode: o,
1041
- activeAmount: s,
1078
+ outputToken: r,
1079
+ quoteMode: s,
1080
+ activeAmount: o,
1042
1081
  slippageBps: l,
1043
1082
  feeConfig: u,
1044
1083
  quote: c,
1045
- setQuote: p,
1046
- owner: g,
1047
- getActiveProvider: y,
1048
- connectWallet: I,
1049
- setWalletChainId: b,
1084
+ setQuote: f,
1085
+ owner: m,
1086
+ getActiveProvider: I,
1087
+ connectWallet: E,
1088
+ setWalletChainId: v,
1050
1089
  readAllowance: w,
1051
- commitAllowance: S,
1052
- approvalMode: A,
1053
- refreshBalances: M,
1054
- refreshAllowances: L,
1055
- onSubmitted: D,
1056
- onSuccess: _,
1057
- onError: f
1090
+ commitAllowance: b,
1091
+ approvalMode: x,
1092
+ refreshBalances: R,
1093
+ refreshAllowances: O,
1094
+ onSubmitted: B,
1095
+ onSuccess: S,
1096
+ onError: h
1058
1097
  }) {
1059
- const [C, x] = N("idle"), [W, q] = N(null), [H, E] = N(null), [Y, V] = N({
1098
+ const [A, y] = T("idle"), [M, H] = T(null), [z, N] = T(null), [te, K] = T({
1060
1099
  required: !1,
1061
1100
  done: !1
1062
- }), d = B(() => {
1063
- x("idle"), q(null), E(null), V({ required: !1, done: !1 });
1064
- }, []), v = B(async () => {
1065
- let P = await y(), h = g;
1066
- if (!P || !h) {
1067
- const R = await I();
1068
- P = (R == null ? void 0 : R.provider) ?? P, h = h ?? (R == null ? void 0 : R.account) ?? null;
1101
+ }), [d, _] = T(null), V = D(() => {
1102
+ y("idle"), H(null), N(null), K({ required: !1, done: !1 }), _(null);
1103
+ }, []), L = D(async () => {
1104
+ let g = await I(), C = m;
1105
+ if (!g || !C) {
1106
+ const U = await E();
1107
+ g = (U == null ? void 0 : U.provider) ?? g, C = C ?? (U == null ? void 0 : U.account) ?? null;
1069
1108
  }
1070
- if (!P)
1071
- return E("No wallet provider found."), null;
1072
- if (!h)
1073
- return E("Wallet connection was not completed."), null;
1074
- const T = await ke(P);
1075
- if (b(T), T !== e.chainId) {
1076
- await Ya(P, e);
1077
- const R = await _r(P, e.chainId);
1078
- if (b(R ? e.chainId : await ke(P)), !R)
1079
- return E("Network switch did not complete. Switch to the correct network and try again."), null;
1109
+ if (!g)
1110
+ return N("No wallet provider found."), null;
1111
+ if (!C)
1112
+ return N("Wallet connection was not completed."), null;
1113
+ const W = await Ke(g);
1114
+ if (v(W), W !== e.chainId) {
1115
+ await wi(g, e);
1116
+ const U = await es(g, e.chainId);
1117
+ if (v(U ? e.chainId : await Ke(g)), !U)
1118
+ return N("Network switch did not complete. Switch to the correct network and try again."), null;
1080
1119
  }
1081
- return { provider: P, account: h };
1082
- }, [e, I, y, g, b]), U = B(
1083
- async (P, h) => {
1084
- if (!n || l === null || !s || s <= 0n) {
1085
- E("Enter a valid amount and slippage, then try again."), x("idle");
1120
+ return { provider: g, account: C };
1121
+ }, [e, E, I, m, v]), X = D(
1122
+ async (g, C) => {
1123
+ if (!n || l === null || !o || o <= 0n) {
1124
+ N("Enter a valid amount and slippage, then try again."), y("idle");
1086
1125
  return;
1087
1126
  }
1088
- const T = h !== void 0 ? Promise.resolve(h) : w(P.account, n).catch(() => null), R = Mn({
1127
+ const W = C !== void 0 ? Promise.resolve(C) : w(g.account, n).catch(() => null), U = zn({
1089
1128
  publicClient: t,
1090
1129
  permit2: n.permit2,
1091
- account: P.account,
1130
+ account: g.account,
1092
1131
  token: a.address,
1093
1132
  router: n.router
1094
1133
  });
1095
- R.catch(() => {
1134
+ U.catch(() => {
1096
1135
  });
1097
- let te;
1136
+ let Ie;
1098
1137
  try {
1099
- const ce = await Rn({
1138
+ const pe = await Kn({
1100
1139
  publicClient: t,
1101
- account: P.account,
1140
+ account: g.account,
1102
1141
  market: n,
1103
1142
  tokenIn: a,
1104
- tokenOut: i,
1105
- mode: o,
1106
- amount: s,
1143
+ tokenOut: r,
1144
+ mode: s,
1145
+ amount: o,
1107
1146
  slippageBps: l,
1108
1147
  fee: u
1109
- }), qe = Qa(c, ce);
1110
- if (qe.priceMovedBeyondTolerance) {
1111
- p(ce), E(
1148
+ }), Ee = bi(c, pe);
1149
+ if (Ee.priceMovedBeyondTolerance) {
1150
+ f(pe), N(
1112
1151
  "Price moved beyond your slippage tolerance. Review the updated quote and try again."
1113
- ), x("idle");
1152
+ ), y("idle");
1114
1153
  return;
1115
1154
  }
1116
- te = qe.quote;
1117
- } catch (ce) {
1118
- E(Ae(ce, "Quote unavailable. Try again.")), x("idle");
1155
+ Ie = Ee.quote;
1156
+ } catch (pe) {
1157
+ N(Re(pe, "Quote unavailable. Try again.")), y("idle");
1119
1158
  return;
1120
1159
  }
1121
- p(te);
1122
- const ge = vt(te);
1123
- if (ge <= 0n) {
1124
- E("Quote returned an empty amount. Try again."), x("idle");
1160
+ f(Ie);
1161
+ const Se = Tt(Ie);
1162
+ if (Se <= 0n) {
1163
+ N("Quote returned an empty amount. Try again."), y("idle");
1125
1164
  return;
1126
1165
  }
1127
- const We = await T ?? await w(P.account, n);
1128
- if (S(P.account, n, We), We < ge) {
1129
- V({ required: !0, done: !1 }), E(`Approve ${a.symbol} before swapping.`), x("idle");
1166
+ const ae = await W ?? await w(g.account, n);
1167
+ if (b(g.account, n, ae), ae < Se) {
1168
+ K({ required: !0, done: !1 }), N(`Approve ${a.symbol} before swapping.`), y("idle");
1130
1169
  return;
1131
1170
  }
1132
- x("signing");
1133
- const rt = await yr({
1134
- wallet: P,
1171
+ y("signing");
1172
+ const Ae = await Zr({
1173
+ wallet: g,
1135
1174
  publicClient: t,
1136
1175
  activeChain: e,
1137
1176
  permit2: n.permit2,
1138
1177
  router: n.router,
1139
1178
  token: a.address,
1140
- amount: ge,
1141
- approvalMode: A,
1142
- allowanceRead: R,
1143
- setStatus: x
1144
- }), { receipt: le, swapDetails: $e } = await br({
1145
- wallet: P,
1179
+ amount: Se,
1180
+ approvalMode: x,
1181
+ allowanceRead: U,
1182
+ setStatus: y
1183
+ }), { receipt: ue, summary: Ye, swapDetails: mt } = await Jr({
1184
+ wallet: g,
1146
1185
  publicClient: t,
1147
1186
  activeChain: e,
1148
1187
  market: n,
1149
1188
  inputToken: a,
1150
- outputToken: i,
1151
- swapQuote: te,
1152
- permit: rt,
1153
- setStatus: x,
1154
- setTxHash: q,
1155
- onSubmitted: D
1189
+ outputToken: r,
1190
+ swapQuote: Ie,
1191
+ permit: Ae,
1192
+ setStatus: y,
1193
+ setTxHash: H,
1194
+ onSubmitted: B
1156
1195
  });
1157
- x("success");
1196
+ _(Ye), y("success");
1158
1197
  try {
1159
- _ == null || _({
1160
- hash: le.transactionHash,
1161
- explorerUrl: It(le.transactionHash, e),
1162
- swap: $e
1198
+ S == null || S({
1199
+ hash: ue.transactionHash,
1200
+ explorerUrl: jn(ue.transactionHash, e),
1201
+ swap: mt
1163
1202
  }), await Promise.all([
1164
- M(P.account),
1165
- L(P.account, n)
1203
+ R(g.account),
1204
+ O(g.account, n)
1166
1205
  ]);
1167
- } catch (ce) {
1168
- console.warn("[AegisSwapWidget] Post-success refresh failed", ce);
1206
+ } catch (pe) {
1207
+ console.warn("[AegisSwapWidget] Post-success refresh failed", pe);
1169
1208
  }
1170
1209
  },
1171
1210
  [
1172
- s,
1211
+ o,
1173
1212
  e,
1174
- A,
1175
- S,
1213
+ x,
1214
+ b,
1176
1215
  u,
1177
1216
  a,
1178
1217
  n,
1179
- D,
1180
- _,
1181
- i,
1218
+ B,
1219
+ S,
1220
+ r,
1182
1221
  t,
1183
1222
  c,
1184
- o,
1223
+ s,
1185
1224
  w,
1186
- L,
1187
- M,
1188
- p,
1225
+ O,
1226
+ R,
1227
+ f,
1189
1228
  l
1190
1229
  ]
1191
- ), F = B(async () => {
1192
- E(null), q(null);
1230
+ ), ne = D(async () => {
1231
+ N(null), H(null), _(null);
1193
1232
  try {
1194
- const P = await v();
1195
- if (!P) return;
1196
- await U(P);
1197
- } catch (P) {
1198
- if (P instanceof an) {
1199
- E("Transaction is still pending. Check its status via the transaction link."), x("idle");
1233
+ const g = await L();
1234
+ if (!g) return;
1235
+ await X(g);
1236
+ } catch (g) {
1237
+ if (g instanceof An) {
1238
+ N("Transaction is still pending. Check its status via the transaction link."), y("idle");
1200
1239
  return;
1201
1240
  }
1202
- const h = Ae(P, "Swap failed."), T = P instanceof Error ? P : new Error(h);
1203
- E(h), x("idle"), f == null || f(T);
1241
+ const C = Re(g, "Swap failed."), W = g instanceof Error ? g : new Error(C);
1242
+ N(C), y("idle"), h == null || h(W);
1204
1243
  }
1205
- }, [v, f, U]), ee = B(async () => {
1206
- E(null), q(null), V({ required: !0, done: !1 });
1207
- let P = !1;
1244
+ }, [L, h, X]), k = D(async () => {
1245
+ N(null), H(null), _(null), K({ required: !0, done: !1 });
1246
+ let g = !1;
1208
1247
  try {
1209
- const h = await v();
1210
- if (!h) return;
1211
- if (!n || !c || s === null || s <= 0n) {
1212
- E("Enter a valid amount before approving.");
1248
+ const C = await L();
1249
+ if (!C) return;
1250
+ if (!n || !c || o === null || o <= 0n) {
1251
+ N("Enter a valid amount before approving.");
1213
1252
  return;
1214
1253
  }
1215
- const T = vt(c);
1216
- if (T <= 0n) {
1217
- E("Enter a valid amount before approving.");
1254
+ const W = Tt(c);
1255
+ if (W <= 0n) {
1256
+ N("Enter a valid amount before approving.");
1218
1257
  return;
1219
1258
  }
1220
- let R = await w(h.account, n);
1221
- if (S(h.account, n, R), R < T && (x("approving"), await Za({
1222
- provider: h.provider,
1259
+ let U = await w(C.account, n);
1260
+ if (b(C.account, n, U), U < W && (y("approving"), await yi({
1261
+ provider: C.provider,
1223
1262
  publicClient: t,
1224
- account: h.account,
1263
+ account: C.account,
1225
1264
  chain: e.chain,
1226
1265
  token: a.address,
1227
1266
  permit2: n.permit2,
1228
- amount: A === "exact" ? T : void 0
1229
- }), R = await vr(
1230
- () => w(h.account, n),
1231
- T
1232
- ), S(h.account, n, R), R < T)) {
1233
- E("Approval confirmed, but allowance is still below this quote. Try again."), x("idle");
1267
+ amount: x === "exact" ? W : void 0
1268
+ }), U = await ts(
1269
+ () => w(C.account, n),
1270
+ W
1271
+ ), b(C.account, n, U), U < W)) {
1272
+ N("Approval confirmed, but allowance is still below this quote. Try again."), y("idle");
1234
1273
  return;
1235
1274
  }
1236
- V({ required: !0, done: !0 }), P = !0, await U(h, R);
1237
- } catch (h) {
1238
- if (h instanceof an) {
1239
- E(
1240
- P ? "Transaction is still pending. Check its status via the transaction link." : "Approval is still pending. Wait for it to confirm, then try again."
1241
- ), x("idle");
1275
+ K({ required: !0, done: !0 }), g = !0, await X(C, U);
1276
+ } catch (C) {
1277
+ if (C instanceof An) {
1278
+ N(
1279
+ g ? "Transaction is still pending. Check its status via the transaction link." : "Approval is still pending. Wait for it to confirm, then try again."
1280
+ ), y("idle");
1242
1281
  return;
1243
1282
  }
1244
- const T = Ae(h, P ? "Swap failed." : "Approval failed."), R = h instanceof Error ? h : new Error(T);
1245
- E(T), x("idle"), f == null || f(R);
1283
+ const W = Re(C, g ? "Swap failed." : "Approval failed."), U = C instanceof Error ? C : new Error(W);
1284
+ N(W), y("idle"), h == null || h(U);
1246
1285
  }
1247
1286
  }, [
1248
- s,
1287
+ o,
1249
1288
  e.chain,
1250
- A,
1251
- S,
1252
- v,
1289
+ x,
1290
+ b,
1291
+ L,
1253
1292
  a.address,
1254
1293
  n,
1255
- f,
1256
- U,
1294
+ h,
1295
+ X,
1257
1296
  t,
1258
1297
  c,
1259
1298
  w
1260
1299
  ]);
1261
1300
  return {
1262
- submit: F,
1263
- approveInputToken: ee,
1264
- reset: d,
1265
- status: C,
1266
- busy: Nn(C),
1267
- txHash: W,
1268
- actionError: H,
1269
- approvalProgress: Y
1301
+ submit: ne,
1302
+ approveInputToken: k,
1303
+ reset: V,
1304
+ status: A,
1305
+ busy: qn(A),
1306
+ txHash: M,
1307
+ actionError: z,
1308
+ approvalProgress: te,
1309
+ receiptSummary: d
1270
1310
  };
1271
1311
  }
1272
- const Sr = 250, Ar = 5e3;
1273
- function Er({
1312
+ const as = 250, is = 5e3;
1313
+ function rs({
1274
1314
  owner: t,
1275
1315
  market: e,
1276
1316
  inputToken: n,
1277
1317
  outputToken: a,
1278
- quoteMode: i,
1279
- activeAmount: o,
1280
- slippageBps: s,
1318
+ quoteMode: r,
1319
+ activeAmount: s,
1320
+ slippageBps: o,
1281
1321
  feeConfig: l
1282
1322
  }) {
1283
1323
  return [
1284
- Se(t),
1324
+ Me(t),
1285
1325
  (e == null ? void 0 : e.chainId) ?? "",
1286
1326
  (e == null ? void 0 : e.poolId.toLowerCase()) ?? "",
1287
- Se(n.address),
1288
- Se(a.address),
1289
- i,
1290
- (o == null ? void 0 : o.toString()) ?? "",
1291
- s ?? "",
1327
+ Me(n.address),
1328
+ Me(a.address),
1329
+ r,
1330
+ (s == null ? void 0 : s.toString()) ?? "",
1331
+ o ?? "",
1292
1332
  (l == null ? void 0 : l.bps) ?? "",
1293
- Se(l == null ? void 0 : l.recipient)
1333
+ Me(l == null ? void 0 : l.recipient)
1294
1334
  ].join("|");
1295
1335
  }
1296
- function xr({
1336
+ function ss({
1297
1337
  publicClient: t,
1298
1338
  owner: e,
1299
1339
  market: n,
1300
1340
  inputToken: a,
1301
- outputToken: i,
1302
- quoteMode: o,
1303
- activeAmount: s,
1341
+ outputToken: r,
1342
+ quoteMode: s,
1343
+ activeAmount: o,
1304
1344
  slippageBps: l,
1305
1345
  feeConfig: u,
1306
1346
  onQuote: c,
1307
- pausedRef: p
1347
+ pausedRef: f
1308
1348
  }) {
1309
- const [g, y] = N(null), [I, b] = N(!1), [w, S] = N(null), A = X(
1310
- () => Er({
1349
+ const [m, I] = T(null), [E, v] = T(!1), [w, b] = T(null), x = J(
1350
+ () => rs({
1311
1351
  owner: e,
1312
1352
  market: n,
1313
1353
  inputToken: a,
1314
- outputToken: i,
1315
- quoteMode: o,
1316
- activeAmount: s,
1354
+ outputToken: r,
1355
+ quoteMode: s,
1356
+ activeAmount: o,
1317
1357
  slippageBps: l,
1318
1358
  feeConfig: u
1319
1359
  }),
1320
- [s, u, a, n, i, e, o, l]
1321
- ), M = (g == null ? void 0 : g.key) === A ? g.quote : null, L = B(
1322
- (f) => {
1323
- y(f ? { key: A, quote: f } : null);
1360
+ [o, u, a, n, r, e, s, l]
1361
+ ), R = (m == null ? void 0 : m.key) === x ? m.quote : null, O = D(
1362
+ (h) => {
1363
+ I(h ? { key: x, quote: h } : null);
1324
1364
  },
1325
- [A]
1326
- ), D = $(c);
1327
- D.current = c;
1328
- const _ = B(() => {
1329
- y(null), S(null);
1365
+ [x]
1366
+ ), B = $(c);
1367
+ B.current = c;
1368
+ const S = D(() => {
1369
+ I(null), b(null);
1330
1370
  }, []);
1331
- return k(() => {
1332
- const f = new AbortController();
1333
- let C = !1, x = !1, W;
1334
- y(null), S(null);
1335
- const q = e, H = n, E = s, Y = l;
1336
- if (!q || !H || !E || E <= 0n || Y === null)
1337
- return b(!1), () => f.abort();
1338
- const V = q, d = H, v = E, U = Y;
1339
- async function F(h) {
1340
- var T;
1341
- if (!(x || f.signal.aborted)) {
1342
- x = !0, h && b(!0);
1371
+ return F(() => {
1372
+ const h = new AbortController();
1373
+ let A = !1, y = !1, M;
1374
+ I(null), b(null);
1375
+ const H = e, z = n, N = o, te = l;
1376
+ if (!H || !z || !N || N <= 0n || te === null)
1377
+ return v(!1), () => h.abort();
1378
+ const K = H, d = z, _ = N, V = te;
1379
+ async function L(k) {
1380
+ var g;
1381
+ if (!(y || h.signal.aborted)) {
1382
+ y = !0, k && v(!0);
1343
1383
  try {
1344
- const R = await Rn({
1384
+ const C = await Kn({
1345
1385
  publicClient: t,
1346
- account: V,
1386
+ account: K,
1347
1387
  market: d,
1348
1388
  tokenIn: a,
1349
- tokenOut: i,
1350
- mode: o,
1351
- amount: v,
1352
- slippageBps: U,
1389
+ tokenOut: r,
1390
+ mode: s,
1391
+ amount: _,
1392
+ slippageBps: V,
1353
1393
  fee: u,
1354
- signal: f.signal
1394
+ signal: h.signal
1355
1395
  });
1356
- if (C || f.signal.aborted) return;
1357
- y(
1358
- (te) => te && te.key === A && Ja(te.quote, R) ? te : { key: A, quote: R }
1359
- ), S(null), (T = D.current) == null || T.call(D, R);
1360
- } catch (R) {
1361
- if (C || f.signal.aborted) return;
1362
- S(Ae(R, "Quote unavailable."));
1396
+ if (A || h.signal.aborted) return;
1397
+ I(
1398
+ (W) => W && W.key === x && vi(W.quote, C) ? W : { key: x, quote: C }
1399
+ ), b(null), (g = B.current) == null || g.call(B, C);
1400
+ } catch (C) {
1401
+ if (A || h.signal.aborted) return;
1402
+ b(Re(C, "Quote unavailable."));
1363
1403
  } finally {
1364
- x = !1, !C && !f.signal.aborted && b(!1);
1404
+ y = !1, !A && !h.signal.aborted && v(!1);
1365
1405
  }
1366
1406
  }
1367
1407
  }
1368
- const ee = window.setTimeout(() => {
1369
- F(!0), W = window.setInterval(() => {
1370
- !(p != null && p.current) && Fe() && F(!1);
1371
- }, Ar);
1372
- }, Sr), P = () => {
1373
- !(p != null && p.current) && Fe() && F(!1);
1408
+ const X = window.setTimeout(() => {
1409
+ L(!0), M = window.setInterval(() => {
1410
+ !(f != null && f.current) && ze() && L(!1);
1411
+ }, is);
1412
+ }, as), ne = () => {
1413
+ !(f != null && f.current) && ze() && L(!1);
1374
1414
  };
1375
- return document.addEventListener("visibilitychange", P), () => {
1376
- C = !0, window.clearTimeout(ee), W !== void 0 && window.clearInterval(W), document.removeEventListener("visibilitychange", P), f.abort();
1415
+ return document.addEventListener("visibilitychange", ne), () => {
1416
+ A = !0, window.clearTimeout(X), M !== void 0 && window.clearInterval(M), document.removeEventListener("visibilitychange", ne), h.abort();
1377
1417
  };
1378
1418
  }, [
1379
- s,
1419
+ o,
1380
1420
  u,
1381
1421
  a,
1382
1422
  n,
1383
- i,
1423
+ r,
1384
1424
  e,
1385
1425
  t,
1386
- o,
1387
- A,
1426
+ s,
1427
+ x,
1388
1428
  l
1389
- ]), { quote: M, quoteLoading: I, quoteError: w, setQuote: L, clearQuote: _ };
1429
+ ]), { quote: R, quoteLoading: E, quoteError: w, setQuote: O, clearQuote: S };
1390
1430
  }
1391
- function bn(t, e, n, a) {
1392
- return !t || !e || !mt(t.owner, e) || !mt(t.token, n) || !mt(t.spender, a) ? null : t;
1431
+ function Bn(t, e, n, a) {
1432
+ return !t || !e || !At(t.owner, e) || !At(t.token, n) || !At(t.spender, a) ? null : t;
1393
1433
  }
1394
- function _n(t, e) {
1434
+ function kn(t, e) {
1395
1435
  if (!t || e === void 0 || e <= 0n) return !1;
1396
1436
  const n = Math.floor(Date.now() / 1e3);
1397
- return t.amount >= e && t.expiration > n + Cn;
1437
+ return t.amount >= e && t.expiration > n + Gn;
1398
1438
  }
1399
- function Pr({
1439
+ function os({
1400
1440
  publicClient: t,
1401
1441
  owner: e,
1402
1442
  market: n,
1403
1443
  inputToken: a,
1404
- spendAmount: i
1444
+ spendAmount: r
1405
1445
  }) {
1406
- var V;
1407
- const [o, s] = N(null), [l, u] = N(null), [c, p] = N(!1), [g, y] = N(!1), [I, b] = N(null), [w, S] = N(null), A = B(
1408
- async (d, v) => t.readContract({
1446
+ var K;
1447
+ const [s, o] = T(null), [l, u] = T(null), [c, f] = T(!1), [m, I] = T(!1), [E, v] = T(null), [w, b] = T(null), x = D(
1448
+ async (d, _) => t.readContract({
1409
1449
  address: a.address,
1410
- abi: Tn,
1450
+ abi: Yn,
1411
1451
  functionName: "allowance",
1412
- args: [d, v.permit2]
1452
+ args: [d, _.permit2]
1413
1453
  }),
1414
1454
  [a.address, t]
1415
- ), M = B(
1416
- (d, v, U) => {
1417
- s({
1455
+ ), R = D(
1456
+ (d, _, V) => {
1457
+ o({
1418
1458
  owner: d,
1419
1459
  token: a.address,
1420
- spender: v.permit2,
1421
- amount: U
1422
- }), b(null);
1460
+ spender: _.permit2,
1461
+ amount: V
1462
+ }), v(null);
1423
1463
  },
1424
1464
  [a.address]
1425
- ), L = B(
1426
- async (d, v) => {
1427
- const [U, F] = await Mn({
1465
+ ), O = D(
1466
+ async (d, _) => {
1467
+ const [V, L] = await zn({
1428
1468
  publicClient: t,
1429
- permit2: v.permit2,
1469
+ permit2: _.permit2,
1430
1470
  account: d,
1431
1471
  token: a.address,
1432
- router: v.router
1472
+ router: _.router
1433
1473
  });
1434
1474
  return {
1435
1475
  owner: d,
1436
1476
  token: a.address,
1437
- spender: v.router,
1438
- amount: U,
1439
- expiration: Number(F)
1477
+ spender: _.router,
1478
+ amount: V,
1479
+ expiration: Number(L)
1440
1480
  };
1441
1481
  },
1442
1482
  [a.address, t]
1443
- ), D = B(
1444
- async (d, v) => {
1445
- const [U, F] = await Promise.allSettled([
1446
- A(d, v),
1447
- L(d, v)
1483
+ ), B = D(
1484
+ async (d, _) => {
1485
+ const [V, L] = await Promise.allSettled([
1486
+ x(d, _),
1487
+ O(d, _)
1448
1488
  ]);
1449
- d !== e || v.id !== (n == null ? void 0 : n.id) || (U.status === "fulfilled" && M(d, v, U.value), F.status === "fulfilled" && (u(F.value), S(null)));
1489
+ d !== e || _.id !== (n == null ? void 0 : n.id) || (V.status === "fulfilled" && R(d, _, V.value), L.status === "fulfilled" && (u(L.value), b(null)));
1450
1490
  },
1451
- [M, A, L, e, n]
1452
- ), _ = i !== void 0 && i > 0n ? i : null, f = _ !== null;
1453
- k(() => {
1491
+ [R, x, O, e, n]
1492
+ ), S = r !== void 0 && r > 0n ? r : null, h = S !== null;
1493
+ F(() => {
1454
1494
  let d = !1;
1455
- return b(null), !e || !n || !f ? (s(null), p(!1), () => {
1495
+ return v(null), !e || !n || !h ? (o(null), f(!1), () => {
1456
1496
  d = !0;
1457
- }) : (p(!0), rn(() => A(e, n), 3, 300, () => d).then((v) => {
1458
- d || M(e, n, v);
1459
- }).catch((v) => {
1460
- d || (s(null), b(Ae(v, "Approval check unavailable.")));
1497
+ }) : (f(!0), vn(() => x(e, n), 3, 300, () => d).then((_) => {
1498
+ d || R(e, n, _);
1499
+ }).catch((_) => {
1500
+ d || (o(null), v(Re(_, "Approval check unavailable.")));
1461
1501
  }).finally(() => {
1462
- d || p(!1);
1502
+ d || f(!1);
1463
1503
  }), () => {
1464
1504
  d = !0;
1465
1505
  });
1466
- }, [M, f, n, e, A]), k(() => {
1506
+ }, [R, h, n, e, x]), F(() => {
1467
1507
  let d = !1;
1468
- return S(null), !e || !n || !f ? (u(null), y(!1), () => {
1508
+ return b(null), !e || !n || !h ? (u(null), I(!1), () => {
1469
1509
  d = !0;
1470
- }) : (y(!0), rn(() => L(e, n), 3, 300, () => d).then((v) => {
1471
- d || u(v);
1472
- }).catch((v) => {
1473
- d || (u(null), S(
1474
- Ae(v, "Authorization check unavailable.")
1510
+ }) : (I(!0), vn(() => O(e, n), 3, 300, () => d).then((_) => {
1511
+ d || u(_);
1512
+ }).catch((_) => {
1513
+ d || (u(null), b(
1514
+ Re(_, "Authorization check unavailable.")
1475
1515
  ));
1476
1516
  }).finally(() => {
1477
- d || y(!1);
1517
+ d || I(!1);
1478
1518
  }), () => {
1479
1519
  d = !0;
1480
1520
  });
1481
- }, [f, n, e, L]);
1482
- const C = n ? ((V = bn(o, e, a.address, n.permit2)) == null ? void 0 : V.amount) ?? null : null, x = n ? bn(l, e, a.address, n.router) : null, W = !!(e && n && f && !I && (c || C === null)), q = !!(e && n && _ !== null && C !== null && C < _), H = !!(e && n && f && !q && !w && (g || x === null)), E = !!(e && n && f && !q && (w || x !== null && !_n(x, i))), Y = !!(e && n && f && !_n(x, i));
1521
+ }, [h, n, e, O]);
1522
+ const A = n ? ((K = Bn(s, e, a.address, n.permit2)) == null ? void 0 : K.amount) ?? null : null, y = n ? Bn(l, e, a.address, n.router) : null, M = !!(e && n && h && !E && (c || A === null)), H = !!(e && n && S !== null && A !== null && A < S), z = !!(e && n && h && !H && !w && (m || y === null)), N = !!(e && n && h && !H && (w || y !== null && !kn(y, r))), te = !!(e && n && h && !kn(y, r));
1483
1523
  return {
1484
- allowanceAmount: C,
1485
- allowanceError: I,
1486
- approvalCheckPending: W,
1487
- approvalRequired: q,
1488
- authorizationCheckPending: H,
1489
- authorizationRequired: E,
1490
- authorizationPromptExpected: Y,
1491
- readAllowance: A,
1492
- commitAllowance: M,
1493
- refreshAllowances: D
1524
+ allowanceAmount: A,
1525
+ allowanceError: E,
1526
+ approvalCheckPending: M,
1527
+ approvalRequired: H,
1528
+ authorizationCheckPending: z,
1529
+ authorizationRequired: N,
1530
+ authorizationPromptExpected: te,
1531
+ readAllowance: x,
1532
+ commitAllowance: R,
1533
+ refreshAllowances: B
1494
1534
  };
1495
1535
  }
1496
- const Tr = 5e3, Nr = { input: null, output: null };
1497
- function et(t, e, n) {
1498
- return [t ?? "", Se(e), Se(n.address)].join("|");
1536
+ const ls = 5e3, cs = { input: null, output: null };
1537
+ function ct(t, e, n) {
1538
+ return [t ?? "", Me(e), Me(n.address)].join("|");
1499
1539
  }
1500
- function Cr(t, e, n, a, i) {
1501
- return t[e] === n && t[a] === i ? t : { ...t, [e]: n, [a]: i };
1540
+ function us(t, e, n, a, r) {
1541
+ return t[e] === n && t[a] === r ? t : { ...t, [e]: n, [a]: r };
1502
1542
  }
1503
- function vn(t, e, n) {
1543
+ function Ln(t, e, n) {
1504
1544
  return t.readContract({
1505
1545
  address: e.address,
1506
- abi: Tn,
1546
+ abi: Yn,
1507
1547
  functionName: "balanceOf",
1508
1548
  args: [n]
1509
1549
  });
1510
1550
  }
1511
- function Mr({
1551
+ function ds({
1512
1552
  publicClient: t,
1513
1553
  owner: e,
1514
1554
  inputToken: n,
1515
1555
  outputToken: a
1516
1556
  }) {
1517
- var g;
1518
- const [i, o] = N({}), s = $(0), l = (g = t.chain) == null ? void 0 : g.id, u = X(
1557
+ var m;
1558
+ const [r, s] = T({}), o = $(0), l = (m = t.chain) == null ? void 0 : m.id, u = J(
1519
1559
  () => e ? {
1520
- input: i[et(l, e, n)] ?? null,
1521
- output: i[et(l, e, a)] ?? null
1522
- } : Nr,
1523
- [i, l, n, a, e]
1524
- ), c = B(
1525
- async (y, I) => {
1526
- const b = ++s.current, w = et(l, y, n), S = et(l, y, a);
1560
+ input: r[ct(l, e, n)] ?? null,
1561
+ output: r[ct(l, e, a)] ?? null
1562
+ } : cs,
1563
+ [r, l, n, a, e]
1564
+ ), c = D(
1565
+ async (I, E) => {
1566
+ const v = ++o.current, w = ct(l, I, n), b = ct(l, I, a);
1527
1567
  try {
1528
- const [A, M] = await Promise.all([
1529
- vn(t, n, y),
1530
- vn(t, a, y)
1568
+ const [x, R] = await Promise.all([
1569
+ Ln(t, n, I),
1570
+ Ln(t, a, I)
1531
1571
  ]);
1532
- b === s.current && !(I != null && I()) && o((L) => Cr(L, w, A, S, M));
1572
+ v === o.current && !(E != null && E()) && s((O) => us(O, w, x, b, R));
1533
1573
  } catch {
1534
1574
  }
1535
1575
  },
1536
1576
  [l, n, a, t]
1537
- ), p = B(
1538
- (y) => c(y),
1577
+ ), f = D(
1578
+ (I) => c(I),
1539
1579
  [c]
1540
1580
  );
1541
- return k(() => {
1542
- let y = !1;
1581
+ return F(() => {
1582
+ let I = !1;
1543
1583
  if (!e)
1544
- return s.current += 1, o({}), () => {
1545
- y = !0;
1584
+ return o.current += 1, s({}), () => {
1585
+ I = !0;
1546
1586
  };
1547
- const I = e;
1548
- let b = !1;
1587
+ const E = e;
1588
+ let v = !1;
1549
1589
  async function w() {
1550
- if (!b) {
1551
- b = !0;
1590
+ if (!v) {
1591
+ v = !0;
1552
1592
  try {
1553
- await c(I, () => y);
1593
+ await c(E, () => I);
1554
1594
  } finally {
1555
- b = !1;
1595
+ v = !1;
1556
1596
  }
1557
1597
  }
1558
1598
  }
1559
1599
  w();
1560
- const S = window.setInterval(() => {
1561
- Fe() && w();
1562
- }, Tr), A = () => {
1563
- Fe() && w();
1600
+ const b = window.setInterval(() => {
1601
+ ze() && w();
1602
+ }, ls), x = () => {
1603
+ ze() && w();
1564
1604
  };
1565
- return document.addEventListener("visibilitychange", A), () => {
1566
- y = !0, window.clearInterval(S), document.removeEventListener("visibilitychange", A);
1605
+ return document.addEventListener("visibilitychange", x), () => {
1606
+ I = !0, window.clearInterval(b), document.removeEventListener("visibilitychange", x);
1567
1607
  };
1568
- }, [c, e]), { balances: u, refreshBalances: p };
1608
+ }, [c, e]), { balances: u, refreshBalances: f };
1569
1609
  }
1570
- function Rr({
1610
+ function ps({
1571
1611
  endpoint: t,
1572
1612
  chainId: e,
1573
1613
  addresses: n
1574
1614
  }) {
1575
- const [a, i] = N({});
1576
- return k(() => {
1615
+ const [a, r] = T({});
1616
+ return F(() => {
1577
1617
  if (!t || !n.length) return;
1578
- const o = new AbortController();
1579
- return ei({
1618
+ const s = new AbortController();
1619
+ return _i({
1580
1620
  endpoint: t,
1581
1621
  chainId: e,
1582
1622
  addresses: n,
1583
- signal: o.signal
1584
- }).then((s) => {
1585
- o.signal.aborted || s.size === 0 || i((l) => {
1623
+ signal: s.signal
1624
+ }).then((o) => {
1625
+ s.signal.aborted || o.size === 0 || r((l) => {
1586
1626
  let u = !1;
1587
1627
  const c = { ...l };
1588
- return s.forEach((p, g) => {
1589
- var y;
1590
- ((y = c[g]) == null ? void 0 : y.iconURL) !== p.iconURL && (c[g] = p, u = !0);
1628
+ return o.forEach((f, m) => {
1629
+ var I;
1630
+ ((I = c[m]) == null ? void 0 : I.iconURL) !== f.iconURL && (c[m] = f, u = !0);
1591
1631
  }), u ? c : l;
1592
1632
  });
1593
- }).catch((s) => {
1594
- o.signal.aborted || console.warn("[AegisSwapWidget] Token metadata icons unavailable", s);
1595
- }), () => o.abort();
1633
+ }).catch((o) => {
1634
+ s.signal.aborted || console.warn("[AegisSwapWidget] Token metadata icons unavailable", o);
1635
+ }), () => s.abort();
1596
1636
  }, [n, e, t]), a;
1597
1637
  }
1598
- function Or({
1638
+ function fs({
1599
1639
  provider: t,
1600
1640
  controlledAccount: e,
1601
1641
  getProvider: n,
1602
1642
  onConnectWallet: a
1603
1643
  }) {
1604
- const [i, o] = N(null), [s, l] = N(null), [u, c] = N(null), p = B(async () => {
1644
+ const [r, s] = T(null), [o, l] = T(null), [u, c] = T(null), f = D(async () => {
1605
1645
  if (t) return t;
1606
1646
  if (n) {
1607
- const b = await n();
1608
- if (b) return b;
1647
+ const v = await n();
1648
+ if (v) return v;
1609
1649
  }
1610
- return gt();
1611
- }, [n, t]), g = t ?? u ?? gt(), y = e ?? i;
1612
- k(() => {
1613
- let b = !1;
1614
- return p().then((w) => {
1615
- b || c(w);
1650
+ return Et();
1651
+ }, [n, t]), m = t ?? u ?? Et(), I = e ?? r;
1652
+ F(() => {
1653
+ let v = !1;
1654
+ return f().then((w) => {
1655
+ v || c(w);
1616
1656
  }).catch((w) => {
1617
- b || (console.warn("[AegisSwapWidget] Provider resolver unavailable", w), c(gt()));
1657
+ v || (console.warn("[AegisSwapWidget] Provider resolver unavailable", w), c(Et()));
1618
1658
  }), () => {
1619
- b = !0;
1659
+ v = !0;
1620
1660
  };
1621
- }, [p]), k(() => {
1622
- if (!g) return;
1623
- let b = !1;
1661
+ }, [f]), F(() => {
1662
+ if (!m) return;
1663
+ let v = !1;
1624
1664
  const w = async () => {
1625
1665
  try {
1626
- const [A, M] = await Promise.all([
1627
- e ? Promise.resolve(e) : ii(g),
1628
- ke(g)
1666
+ const [x, R] = await Promise.all([
1667
+ e ? Promise.resolve(e) : Ei(m),
1668
+ Ke(m)
1629
1669
  ]);
1630
- if (b) return;
1631
- o(A), l(M);
1670
+ if (v) return;
1671
+ s(x), l(R);
1632
1672
  } catch {
1633
- b || (e || o(null), l(null));
1673
+ v || (e || s(null), l(null));
1634
1674
  }
1635
1675
  };
1636
1676
  w();
1637
- const S = ti(g, {
1677
+ const b = Ii(m, {
1638
1678
  onAccountsChanged: w,
1639
1679
  onChainChanged: w
1640
1680
  });
1641
1681
  return () => {
1642
- b = !0, S();
1682
+ v = !0, b();
1643
1683
  };
1644
- }, [e, g]);
1645
- const I = B(async () => {
1646
- const b = ni(
1684
+ }, [e, m]);
1685
+ const E = D(async () => {
1686
+ const v = Si(
1647
1687
  a ? await a() : void 0
1648
- ), w = b.provider ?? await p();
1688
+ ), w = v.provider ?? await f();
1649
1689
  if (!w) return null;
1650
1690
  c(w);
1651
- const S = b.account ?? await ai(w), A = await ke(w);
1652
- return o(S), l(A), { provider: w, account: S };
1653
- }, [p, a]);
1654
- return { owner: y, walletChainId: s, setWalletChainId: l, getActiveProvider: p, connectWallet: I };
1691
+ const b = v.account ?? await Ai(w), x = await Ke(w);
1692
+ return s(b), l(x), { provider: w, account: b };
1693
+ }, [f, a]);
1694
+ return { owner: I, walletChainId: o, setWalletChainId: l, getActiveProvider: f, connectWallet: E };
1655
1695
  }
1656
- function Dr(t) {
1696
+ function hs(t) {
1657
1697
  return t === "sell" ? "sell" : "buy";
1658
1698
  }
1659
- function Br(t) {
1699
+ function gs(t) {
1660
1700
  return `${t.slice(0, 6)}...${t.slice(-4)}`;
1661
1701
  }
1662
- function Vn(t, e, n) {
1702
+ function oa(t, e, n) {
1663
1703
  switch (t) {
1664
1704
  case "ArrowRight":
1665
1705
  case "ArrowDown":
@@ -1675,590 +1715,641 @@ function Vn(t, e, n) {
1675
1715
  return null;
1676
1716
  }
1677
1717
  }
1678
- function Lr({
1718
+ function ms({
1679
1719
  busy: t,
1680
1720
  status: e,
1681
1721
  hasMarket: n,
1682
1722
  hasAvailablePools: a,
1683
- ownerConnected: i,
1684
- wrongChain: o,
1685
- activeChainName: s,
1723
+ ownerConnected: r,
1724
+ wrongChain: s,
1725
+ activeChainName: o,
1686
1726
  activeInput: l,
1687
1727
  amountInvalid: u,
1688
1728
  slippageValid: c,
1689
- insufficientBalance: p,
1690
- hasQuote: g,
1691
- quoteLoading: y,
1692
- quoteUnavailable: I,
1693
- allowanceError: b,
1729
+ insufficientBalance: f,
1730
+ hasQuote: m,
1731
+ quoteLoading: I,
1732
+ quoteUnavailable: E,
1733
+ allowanceError: v,
1694
1734
  approvalCheckPending: w,
1695
- approvalRequired: S,
1696
- authorizationCheckPending: A,
1697
- authorizationRequired: M,
1698
- inputSymbol: L,
1699
- targetSymbol: D,
1700
- counterSymbol: _,
1701
- direction: f
1735
+ approvalRequired: b,
1736
+ authorizationCheckPending: x,
1737
+ authorizationRequired: R,
1738
+ inputSymbol: O,
1739
+ targetSymbol: B,
1740
+ counterSymbol: S,
1741
+ direction: h
1702
1742
  }) {
1703
- const C = !i, x = i && o, W = !!(i && !o && l.trim() && !u && c && !p && g && !b), q = !!(W && S), H = !!(W && !w && !S && !A && M), E = !!(W && !w && !S && !A && !M), Y = !!(!t && n && (C || x || q || H || E)), V = e === "approving" ? `Approving ${L}` : e === "signing" ? "Signing permit" : e === "submitting" ? "Swapping" : e === "success" ? "Swapped" : n ? C ? "Connect wallet" : x ? `Switch to ${s}` : l.trim() ? u ? "Invalid amount" : c ? p ? `Insufficient ${L}` : y ? "Fetching quote" : I ? "Quote unavailable" : b ? "Approval unavailable" : w ? "Checking approval" : S ? `Approve ${L} & swap` : A ? "Checking authorization" : M ? f === "buy" ? `Approve & swap to ${D}` : `Approve & swap to ${_}` : f === "buy" ? `Swap to ${D}` : `Swap to ${_}` : "Invalid slippage" : "Enter amount" : a ? "Pool unavailable" : "No pools available";
1743
+ const A = !r, y = r && s, M = !!(r && !s && l.trim() && !u && c && !f && m && !v), H = !!(M && b), z = !!(M && !w && !b && !x && R), N = !!(M && !w && !b && !x && !R), te = !!(!t && n && (A || y || H || z || N)), K = e === "approving" ? `Approving ${O}` : e === "signing" ? "Signing permit" : e === "submitting" ? "Swapping" : e === "success" ? "Swapped" : n ? A ? "Connect wallet" : y ? `Switch to ${o}` : l.trim() ? u ? "Invalid amount" : c ? f ? `Insufficient ${O}` : I ? "Fetching quote" : E ? "Quote unavailable" : v ? "Approval unavailable" : w ? "Checking approval" : b ? `Approve ${O} & swap` : x ? "Checking authorization" : R ? h === "buy" ? `Approve & swap to ${B}` : `Approve & swap to ${S}` : h === "buy" ? `Swap to ${B}` : `Swap to ${S}` : "Invalid slippage" : "Enter amount" : a ? "Pool unavailable" : "No pools available";
1704
1744
  return {
1705
- canConnectWallet: C,
1706
- canSwitchChain: x,
1707
- validEntry: W,
1708
- canApprove: q,
1709
- canAuthorize: H,
1710
- canSwap: E,
1711
- canSubmit: Y,
1712
- primaryAction: S ? "approve" : "swap",
1713
- ctaLabel: V
1745
+ canConnectWallet: A,
1746
+ canSwitchChain: y,
1747
+ validEntry: M,
1748
+ canApprove: H,
1749
+ canAuthorize: z,
1750
+ canSwap: N,
1751
+ canSubmit: te,
1752
+ primaryAction: b ? "approve" : "swap",
1753
+ ctaLabel: K
1714
1754
  };
1715
1755
  }
1716
- function Fr({
1756
+ function ws({
1717
1757
  quote: t,
1718
1758
  inputSymbol: e,
1719
1759
  inputDecimals: n,
1720
1760
  outputSymbol: a,
1721
- outputDecimals: i
1761
+ outputDecimals: r
1722
1762
  }) {
1723
1763
  if (!t) return [];
1724
- const o = [], s = t.amountIn > 0n ? t.amountOut * 10n ** BigInt(n) / t.amountIn : null;
1725
- return s !== null && o.push({
1764
+ const s = [], o = t.amountIn > 0n ? t.amountOut * 10n ** BigInt(n) / t.amountIn : null;
1765
+ return o !== null && s.push({
1726
1766
  label: "Rate",
1727
- value: `1 ${e} = ${Ee(s, i)} ${a}`
1728
- }), t.mode === "exactOut" ? o.push({
1767
+ value: `1 ${e} = ${_e(o, r)} ${a}`
1768
+ }), t.mode === "exactOut" ? s.push({
1729
1769
  label: "Max sold",
1730
- value: `${Ee(t.amountInMaximum, n)} ${e}`
1731
- }) : o.push({
1770
+ value: `${_e(t.amountInMaximum, n)} ${e}`
1771
+ }) : s.push({
1732
1772
  label: "Min received",
1733
- value: `${Ee(t.userAmountOutMinimum, i)} ${a}`
1734
- }), o;
1773
+ value: `${_e(t.userAmountOutMinimum, r)} ${a}`
1774
+ }), s;
1735
1775
  }
1736
- const In = 3e3, Sn = 420, An = 30;
1737
- function En(t) {
1776
+ const Fn = 3e3, Un = 420, $n = 30;
1777
+ function Wn(t) {
1738
1778
  const e = t.trim().match(/^(\d*\.?\d+)(ms|s)$/);
1739
1779
  if (!e) return null;
1740
1780
  const n = Number(e[1]);
1741
1781
  return Number.isFinite(n) ? e[2] === "s" ? n * 1e3 : n : null;
1742
1782
  }
1743
- function kr(t) {
1744
- const e = In + Sn + An, n = t == null ? void 0 : t.ownerDocument.defaultView;
1783
+ function bs(t) {
1784
+ const e = Fn + Un + $n, n = t == null ? void 0 : t.ownerDocument.defaultView;
1745
1785
  if (!t || !n) return e;
1746
- const a = n.getComputedStyle(t), i = En(a.getPropertyValue("--aegis-rail-hold")) ?? In, o = En(a.getPropertyValue("--aegis-rail-fade")) ?? Sn;
1747
- return i + o + An;
1786
+ const a = n.getComputedStyle(t), r = Wn(a.getPropertyValue("--aegis-rail-hold")) ?? Fn, s = Wn(a.getPropertyValue("--aegis-rail-fade")) ?? Un;
1787
+ return r + s + $n;
1748
1788
  }
1749
- function Ur(t) {
1750
- var en;
1789
+ function ys(t) {
1790
+ var gn, mn;
1751
1791
  const {
1752
1792
  provider: e,
1753
1793
  account: n,
1754
1794
  getProvider: a,
1755
- onConnectWallet: i,
1756
- onSubmitted: o,
1757
- onSuccess: s,
1795
+ onConnectWallet: r,
1796
+ onSubmitted: s,
1797
+ onSuccess: o,
1758
1798
  onError: l,
1759
1799
  onQuote: u,
1760
1800
  onStatusChange: c,
1761
- onPoolChange: p,
1762
- chainId: g = sn,
1763
- chains: y,
1764
- networkOptions: I,
1765
- pools: b,
1801
+ onPoolChange: f,
1802
+ chainId: m = _n,
1803
+ chains: I,
1804
+ networkOptions: E,
1805
+ pools: v,
1766
1806
  defaultPoolId: w,
1767
- poolIds: S,
1768
- defaultDirection: A,
1769
- defaultSlippagePercent: M = 1,
1770
- rpcUrls: L,
1771
- metadataEndpoint: D,
1772
- className: _,
1773
- style: f,
1774
- title: C = "",
1775
- subtitle: x = "",
1776
- ariaLabel: W = "Aegis direct pool swap",
1777
- theme: q,
1778
- accentColor: H,
1779
- accentTextColor: E,
1780
- showPoolLink: Y = !0,
1781
- defaultApprovalMode: V = "exact",
1807
+ poolIds: b,
1808
+ defaultDirection: x,
1809
+ defaultSlippagePercent: R = 1,
1810
+ rpcUrls: O,
1811
+ metadataEndpoint: B,
1812
+ className: S,
1813
+ style: h,
1814
+ title: A = "",
1815
+ subtitle: y = "",
1816
+ ariaLabel: M = "Aegis direct pool swap",
1817
+ theme: H,
1818
+ accentColor: z,
1819
+ accentTextColor: N,
1820
+ showPoolLink: te = !0,
1821
+ defaultApprovalMode: K = "exact",
1782
1822
  showApprovalMode: d = !0,
1783
- showExecutionDetails: v = !0,
1784
- defaultExecutionDetailsOpen: U = !1,
1785
- statusSurface: F = "rail",
1786
- toastPosition: ee = "bottom-right"
1787
- } = t, P = Wn(q), h = De(), T = De(), R = De(), te = De(), ge = Ie(y), We = Ie(b), rt = Ie(S), le = Ie(L), $e = Ie(f), ce = Ie(I), qe = X(() => {
1788
- const O = { ...$e };
1789
- if (H) {
1790
- O["--aegis-swap-accent"] = H;
1791
- const j = E ?? kn(H);
1792
- j && (O["--aegis-swap-accent-text"] = j);
1793
- } else E && (O["--aegis-swap-accent-text"] = E);
1794
- return O;
1795
- }, [H, E, $e]), st = X(() => ri(ge), [ge]), G = st[g] ?? si[sn], Ct = G.fee ?? null, ne = We, Mt = X(
1796
- () => oi(ne, st),
1797
- [st, ne]
1798
- ), we = X(
1823
+ showExecutionDetails: _ = !0,
1824
+ defaultExecutionDetailsOpen: V = !1,
1825
+ executionDetailsOpen: L,
1826
+ onExecutionDetailsOpenChange: X,
1827
+ statusSurface: ne = "rail",
1828
+ toastPosition: k = "bottom-right"
1829
+ } = t, g = na(H), C = Ve(), W = Ve(), U = Ve(), Ie = Ve(), Se = Ce(I), ae = Ce(v), Ae = Ce(b), ue = Ce(O), Ye = Ce(h), mt = Ce(E), pe = J(() => {
1830
+ const P = { ...Ye };
1831
+ if (z) {
1832
+ P["--aegis-swap-accent"] = z;
1833
+ const q = N ?? ea(z);
1834
+ q && (P["--aegis-swap-accent-text"] = q);
1835
+ } else N && (P["--aegis-swap-accent-text"] = N);
1836
+ return P;
1837
+ }, [z, N, Ye]), Ee = J(() => xi(Se), [Se]), j = Ee[m] ?? Ni[_n], Lt = j.fee ?? null, Ft = J(
1838
+ () => Pi(ae, Ee),
1839
+ [Ee, ae]
1840
+ ), xe = J(
1799
1841
  () => ({
1800
- ...ne != null && ne.length ? {} : li,
1801
- ...Mt
1842
+ ...ae != null && ae.length ? {} : Ti,
1843
+ ...Ft
1802
1844
  }),
1803
- [Mt, ne]
1804
- ), ze = rt, ae = X(() => (ze && ze.length > 0 ? ze : ne != null && ne.length ? ne.map((j) => j.id) : on).filter((j) => {
1805
- var pe;
1806
- return ((pe = we[j]) == null ? void 0 : pe.chainId) === G.chainId;
1807
- }), [G.chainId, ne, we, ze]), Rt = X(() => Array.isArray(le) ? le : (le == null ? void 0 : le[G.chainId]) ?? G.rpcUrls, [G, le]), Gn = D === void 0 ? G.metadataEndpoint : D, Kn = Rt.join(","), He = X(
1808
- () => ci(G.chain, Rt),
1809
- [G.chainId, Kn]
1845
+ [Ft, ae]
1846
+ ), se = J(() => (Ae && Ae.length > 0 ? Ae : ae != null && ae.length ? ae.map((q) => q.id) : In).filter((q) => {
1847
+ var ge;
1848
+ return ((ge = xe[q]) == null ? void 0 : ge.chainId) === j.chainId;
1849
+ }), [j.chainId, ae, xe, Ae]), Ut = J(() => Array.isArray(ue) ? ue : (ue == null ? void 0 : ue[j.chainId]) ?? j.rpcUrls, [j, ue]), la = B === void 0 ? j.metadataEndpoint : B, ca = Ut.join(","), Qe = J(
1850
+ () => Ci(j.chain, Ut),
1851
+ [j.chainId, ca]
1810
1852
  // not activeChain.chain/resolvedRpcUrls identity
1811
- ), jn = ui(n), [Ot, Xn] = N(
1812
- w ?? on[0]
1813
- ), [Ve, Yn] = N(
1814
- () => Dr(A)
1815
- ), [ie, Pe] = N("exactIn"), [Dt, Te] = N(""), [Bt, Ne] = N(""), ot = cn(String(M)) || "1", [ye, Lt] = N(ot), [Qn, lt] = N(null), [Ft, Zn] = N(V), [Jn, ea] = N(U), kt = $(null), Ut = $(/* @__PURE__ */ new Map()), ct = $(void 0);
1816
- k(() => () => window.clearTimeout(ct.current), []);
1817
- const { owner: Ce, walletChainId: Wt, setWalletChainId: ta, getActiveProvider: na, connectWallet: aa } = Or({ provider: e, controlledAccount: jn, getProvider: a, onConnectWallet: i }), fe = ae.includes(Ot) ? Ot : ae[0];
1818
- mr(p, fe);
1819
- const z = fe ? we[fe] ?? null : null, Ge = (z == null ? void 0 : z.token) ?? ln.WATER, Ke = (z == null ? void 0 : z.counterToken) ?? ln.USDC, Q = Ve === "buy" ? Ke : Ge, re = Ve === "buy" ? Ge : Ke, je = ie === "exactOut" ? Bt : Dt, $t = ie === "exactOut" ? re : Q, ut = X(
1820
- () => fi(je, $t.decimals),
1821
- [je, $t.decimals]
1822
- ), Xe = X(() => un(ye), [ye]), { balances: ue, refreshBalances: ia } = Mr({
1823
- publicClient: He,
1824
- owner: Ce,
1853
+ ), ua = Mi(n), [$t, da] = T(
1854
+ w ?? In[0]
1855
+ ), [Ze, pa] = T(
1856
+ () => hs(x)
1857
+ ), [le, Oe] = T("exactIn"), [Wt, Be] = T(""), [Ht, ke] = T(""), wt = Rn(String(R)) || "1", [Ne, Vt] = T(wt), [fa, bt] = T(null), [qt, ha] = T(K), [ga, ma] = T(V), [wa, Gt] = T("trade"), [Le, ba] = T(null), zt = $(null), Kt = $(/* @__PURE__ */ new Map()), yt = $(void 0);
1858
+ F(() => () => window.clearTimeout(yt.current), []);
1859
+ const { owner: Fe, walletChainId: jt, setWalletChainId: ya, getActiveProvider: va, connectWallet: _a } = fs({ provider: e, controlledAccount: ua, getProvider: a, onConnectWallet: r }), me = se.includes($t) ? $t : se[0];
1860
+ Xr(f, me);
1861
+ const G = me ? xe[me] ?? null : null, Je = (G == null ? void 0 : G.token) ?? Sn.WATER, et = (G == null ? void 0 : G.counterToken) ?? Sn.USDC, Q = Ze === "buy" ? et : Je, ie = Ze === "buy" ? Je : et, tt = le === "exactOut" ? Ht : Wt, Xt = le === "exactOut" ? ie : Q, vt = J(
1862
+ () => Hr(tt, Xt.decimals),
1863
+ [tt, Xt.decimals]
1864
+ ), nt = J(() => Dn(Ne), [Ne]), { balances: fe, refreshBalances: Ia } = ds({
1865
+ publicClient: Qe,
1866
+ owner: Fe,
1825
1867
  inputToken: Q,
1826
- outputToken: re
1827
- }), qt = $(!1), { quote: Z, quoteLoading: ra, quoteError: zt, setQuote: sa, clearQuote: Ye } = xr({
1828
- publicClient: He,
1829
- owner: Ce,
1830
- market: z,
1868
+ outputToken: ie
1869
+ }), Yt = $(!1), { quote: Z, quoteLoading: Qt, quoteError: Zt, setQuote: Sa, clearQuote: at } = ss({
1870
+ publicClient: Qe,
1871
+ owner: Fe,
1872
+ market: G,
1831
1873
  inputToken: Q,
1832
- outputToken: re,
1833
- quoteMode: ie,
1834
- activeAmount: ut,
1835
- slippageBps: Xe,
1836
- feeConfig: Ct,
1874
+ outputToken: ie,
1875
+ quoteMode: le,
1876
+ activeAmount: vt,
1877
+ slippageBps: nt,
1878
+ feeConfig: Lt,
1837
1879
  onQuote: u,
1838
- pausedRef: qt
1839
- }), be = Z ? vt(Z) : void 0, {
1840
- allowanceAmount: Ht,
1841
- allowanceError: Vt,
1842
- approvalCheckPending: oa,
1843
- approvalRequired: la,
1844
- authorizationCheckPending: ca,
1845
- authorizationRequired: ua,
1846
- authorizationPromptExpected: Qe,
1847
- readAllowance: da,
1848
- commitAllowance: pa,
1849
- refreshAllowances: fa
1850
- } = Pr({ publicClient: He, owner: Ce, market: z, inputToken: Q, spendAmount: be }), {
1851
- submit: Gt,
1852
- approveInputToken: Kt,
1853
- reset: se,
1854
- status: oe,
1855
- busy: _e,
1856
- txHash: de,
1857
- actionError: ve,
1858
- approvalProgress: jt
1859
- } = Ir({
1860
- publicClient: He,
1861
- activeChain: G,
1862
- market: z,
1880
+ pausedRef: Yt
1881
+ }), de = Z ? Tt(Z) : void 0, {
1882
+ allowanceAmount: Jt,
1883
+ allowanceError: en,
1884
+ approvalCheckPending: Aa,
1885
+ approvalRequired: Ea,
1886
+ authorizationCheckPending: xa,
1887
+ authorizationRequired: tn,
1888
+ authorizationPromptExpected: it,
1889
+ readAllowance: Na,
1890
+ commitAllowance: Pa,
1891
+ refreshAllowances: Ta
1892
+ } = os({ publicClient: Qe, owner: Fe, market: G, inputToken: Q, spendAmount: de }), {
1893
+ submit: nn,
1894
+ approveInputToken: an,
1895
+ reset: ce,
1896
+ status: ee,
1897
+ busy: we,
1898
+ txHash: he,
1899
+ actionError: be,
1900
+ approvalProgress: rn,
1901
+ receiptSummary: oe
1902
+ } = ns({
1903
+ publicClient: Qe,
1904
+ activeChain: j,
1905
+ market: G,
1863
1906
  inputToken: Q,
1864
- outputToken: re,
1865
- quoteMode: ie,
1866
- activeAmount: ut,
1867
- slippageBps: Xe,
1868
- feeConfig: Ct,
1907
+ outputToken: ie,
1908
+ quoteMode: le,
1909
+ activeAmount: vt,
1910
+ slippageBps: nt,
1911
+ feeConfig: Lt,
1869
1912
  quote: Z,
1870
- setQuote: sa,
1871
- owner: Ce,
1872
- getActiveProvider: na,
1873
- connectWallet: aa,
1874
- setWalletChainId: ta,
1875
- readAllowance: da,
1876
- commitAllowance: pa,
1877
- refreshAllowances: fa,
1878
- approvalMode: Ft,
1879
- refreshBalances: ia,
1880
- onSubmitted: o,
1881
- onSuccess: s,
1913
+ setQuote: Sa,
1914
+ owner: Fe,
1915
+ getActiveProvider: va,
1916
+ connectWallet: _a,
1917
+ setWalletChainId: ya,
1918
+ readAllowance: Na,
1919
+ commitAllowance: Pa,
1920
+ refreshAllowances: Ta,
1921
+ approvalMode: qt,
1922
+ refreshBalances: Ia,
1923
+ onSubmitted: s,
1924
+ onSuccess: o,
1882
1925
  onError: l
1883
1926
  });
1884
- k(() => {
1885
- qt.current = _e;
1886
- }, [_e]), k(() => {
1887
- if (oe !== "success") return;
1888
- const O = window.setTimeout(() => se(), kr(kt.current));
1889
- return () => window.clearTimeout(O);
1890
- }, [oe, se]);
1891
- const ha = X(() => {
1892
- const O = /* @__PURE__ */ new Set();
1893
- for (const j of ae) {
1894
- const pe = we[j];
1895
- O.add(pe.token.address), O.add(pe.counterToken.address);
1927
+ F(() => {
1928
+ Yt.current = we;
1929
+ }, [we]), F(() => {
1930
+ if (ee !== "success") return;
1931
+ const P = window.setTimeout(() => ce(), bs(zt.current));
1932
+ return () => window.clearTimeout(P);
1933
+ }, [ee, ce]);
1934
+ const Ca = J(() => {
1935
+ const P = /* @__PURE__ */ new Set();
1936
+ for (const q of se) {
1937
+ const ge = xe[q];
1938
+ P.add(ge.token.address), P.add(ge.counterToken.address);
1896
1939
  }
1897
- return [...O];
1898
- }, [we, ae]), ma = Rr({
1899
- endpoint: Gn,
1900
- chainId: G.chainId,
1901
- addresses: ha
1902
- }), ga = Wt !== null && Wt !== G.chainId, dt = je.trim().length > 0 && ut === null, Xt = ae.length > 0, wa = be !== void 0 && ue.input !== null && be > ue.input, ya = z ? ((en = G.poolExplorerUrl) == null ? void 0 : en.call(G, z.poolId, z)) ?? null : null, ba = !!(z && Qn === z.poolId), Me = ie === "exactOut" && Z ? dn(Z.amountIn, Q.decimals) : Dt, pt = ie === "exactIn" && Z ? dn(Z.amountOut, re.decimals) : Bt, _a = B(async () => {
1903
- var O;
1904
- if (!(!z || !((O = navigator.clipboard) != null && O.writeText)))
1940
+ return [...P];
1941
+ }, [xe, se]), Ma = ps({
1942
+ endpoint: la,
1943
+ chainId: j.chainId,
1944
+ addresses: Ca
1945
+ }), Ra = jt !== null && jt !== j.chainId, _t = tt.trim().length > 0 && vt === null, sn = se.length > 0, Da = de !== void 0 && fe.input !== null && de > fe.input, Oa = G ? ((gn = j.poolExplorerUrl) == null ? void 0 : gn.call(j, G.poolId, G)) ?? null : null, Ba = !!(G && fa === G.poolId), Ue = le === "exactOut" && Z ? On(Z.amountIn, Q.decimals) : Wt, It = le === "exactIn" && Z ? On(Z.amountOut, ie.decimals) : Ht, ka = D(async () => {
1946
+ var P;
1947
+ if (!(!G || !((P = navigator.clipboard) != null && P.writeText)))
1905
1948
  try {
1906
- await navigator.clipboard.writeText(z.poolId), lt(z.poolId), window.clearTimeout(ct.current), ct.current = window.setTimeout(() => lt(null), 1e3);
1949
+ await navigator.clipboard.writeText(G.poolId), bt(G.poolId), window.clearTimeout(yt.current), yt.current = window.setTimeout(() => bt(null), 1e3);
1907
1950
  } catch {
1908
- lt(null);
1951
+ bt(null);
1909
1952
  }
1910
- }, [z]), Ze = B(
1911
- (O) => {
1912
- O !== null && (Pe("exactIn"), Te(mi(O, Q.decimals)), Ne(""), se());
1953
+ }, [G]), rt = D(
1954
+ (P) => {
1955
+ P !== null && (Oe("exactIn"), Be(qr(P, Q.decimals)), ke(""), ce());
1913
1956
  },
1914
- [Q.decimals, se]
1915
- ), va = B(
1916
- () => Ze(ue.input === null ? null : ue.input / 2n),
1917
- [ue.input, Ze]
1918
- ), Ia = B(() => Ze(ue.input), [ue.input, Ze]), Sa = B(() => {
1919
- const O = Be(pt || Me);
1920
- Yn((j) => j === "buy" ? "sell" : "buy"), Pe("exactIn"), Te(O), Ne(""), Ye(), se();
1921
- }, [pt, Ye, se, Me]), ft = B(
1922
- (O) => {
1923
- const j = Be(Me);
1924
- Xn(O), Pe("exactIn"), Te(j), Ne(""), Ye(), se();
1957
+ [Q.decimals, ce]
1958
+ ), La = D(
1959
+ () => rt(fe.input === null ? null : fe.input / 2n),
1960
+ [fe.input, rt]
1961
+ ), Fa = D(() => rt(fe.input), [fe.input, rt]), Ua = D(() => {
1962
+ const P = Ge(It || Ue);
1963
+ pa((q) => q === "buy" ? "sell" : "buy"), Oe("exactIn"), Be(P), ke(""), at(), ce();
1964
+ }, [It, at, ce, Ue]), St = D(
1965
+ (P) => {
1966
+ const q = Ge(Ue);
1967
+ da(P), Oe("exactIn"), Be(q), ke(""), at(), ce();
1925
1968
  },
1926
- [Ye, se, Me]
1927
- ), Aa = B(
1928
- (O) => {
1929
- var nn;
1930
- if (ae.length === 0 || !fe) return;
1931
- const j = Math.max(ae.indexOf(fe), 0), pe = Vn(O.key, j, ae.length);
1932
- if (pe === null) return;
1933
- O.preventDefault();
1934
- const tn = ae[pe];
1935
- ft(tn), (nn = Ut.current.get(tn)) == null || nn.focus();
1969
+ [at, ce, Ue]
1970
+ ), $a = D(
1971
+ (P) => {
1972
+ var bn;
1973
+ if (se.length === 0 || !me) return;
1974
+ const q = Math.max(se.indexOf(me), 0), ge = oa(P.key, q, se.length);
1975
+ if (ge === null) return;
1976
+ P.preventDefault();
1977
+ const wn = se[ge];
1978
+ St(wn), (bn = Kt.current.get(wn)) == null || bn.focus();
1936
1979
  },
1937
- [fe, ae, ft]
1938
- ), Je = B(
1939
- (O, j) => {
1940
- O === "exactIn" ? (Pe("exactIn"), Te(Be(j)), Ne("")) : (Pe("exactOut"), Ne(Be(j)), Te("")), se();
1980
+ [me, se, St]
1981
+ ), st = D(
1982
+ (P, q) => {
1983
+ P === "exactIn" ? (Oe("exactIn"), Be(Ge(q)), ke("")) : (Oe("exactOut"), ke(Ge(q)), Be("")), ce();
1941
1984
  },
1942
- [se]
1943
- ), Ea = B(
1944
- (O) => Je("exactIn", O),
1945
- [Je]
1946
- ), xa = B(
1947
- (O) => Je("exactOut", O),
1948
- [Je]
1949
- ), { canSubmit: Pa, primaryAction: ht, ctaLabel: Ta } = Lr({
1950
- busy: _e,
1951
- status: oe,
1952
- hasMarket: !!z,
1953
- hasAvailablePools: Xt,
1954
- ownerConnected: !!Ce,
1955
- wrongChain: ga,
1956
- activeChainName: G.name,
1957
- activeInput: je,
1958
- amountInvalid: dt,
1959
- slippageValid: Xe !== null,
1960
- insufficientBalance: wa,
1985
+ [ce]
1986
+ ), Wa = D(
1987
+ (P) => st("exactIn", P),
1988
+ [st]
1989
+ ), Ha = D(
1990
+ (P) => st("exactOut", P),
1991
+ [st]
1992
+ ), { canSubmit: on, primaryAction: ot, ctaLabel: Va } = ms({
1993
+ busy: we,
1994
+ status: ee,
1995
+ hasMarket: !!G,
1996
+ hasAvailablePools: sn,
1997
+ ownerConnected: !!Fe,
1998
+ wrongChain: Ra,
1999
+ activeChainName: j.name,
2000
+ activeInput: tt,
2001
+ amountInvalid: _t,
2002
+ slippageValid: nt !== null,
2003
+ insufficientBalance: Da,
1961
2004
  hasQuote: !!Z,
1962
- quoteLoading: ra,
1963
- quoteUnavailable: !!(zt && !Z),
1964
- allowanceError: !!Vt,
1965
- approvalCheckPending: oa,
1966
- approvalRequired: la,
1967
- authorizationCheckPending: ca,
1968
- authorizationRequired: ua,
2005
+ quoteLoading: Qt,
2006
+ quoteUnavailable: !!(Zt && !Z),
2007
+ allowanceError: !!en,
2008
+ approvalCheckPending: Aa,
2009
+ approvalRequired: Ea,
2010
+ authorizationCheckPending: xa,
2011
+ authorizationRequired: tn,
1969
2012
  inputSymbol: Q.symbol,
1970
- targetSymbol: Ge.symbol,
1971
- counterSymbol: Ke.symbol,
1972
- direction: Ve
1973
- }), Na = !!(jt.done && be !== void 0 && be > 0n && Ht !== null && Ht >= be), Yt = $(Qe);
1974
- k(() => {
1975
- oe === "idle" && !ve && (Yt.current = Qe);
1976
- }, [ve, Qe, oe]);
1977
- const Ca = oe === "idle" && !ve ? Qe : Yt.current, K = di({
1978
- status: oe,
2013
+ targetSymbol: Je.symbol,
2014
+ counterSymbol: et.symbol,
2015
+ direction: Ze
2016
+ }), qa = !!(rn.done && de !== void 0 && de > 0n && Jt !== null && Jt >= de), ln = $(it);
2017
+ F(() => {
2018
+ ee === "idle" && !be && (ln.current = it);
2019
+ }, [be, it, ee]);
2020
+ const Ga = ee === "idle" && !be ? it : ln.current, Y = Ri({
2021
+ status: ee,
1979
2022
  inputSymbol: Q.symbol,
1980
- txHash: de,
1981
- actionError: ve,
1982
- approvalRequired: jt.required,
1983
- approvalDone: Na,
1984
- authorizationRequired: Ca
1985
- }), Qt = (K == null ? void 0 : K.state) ?? null;
1986
- wr(c, {
1987
- status: oe,
1988
- progress: Qt,
1989
- label: (K == null ? void 0 : K.label) ?? null,
1990
- walletPrompts: (K == null ? void 0 : K.walletPrompts) ?? { total: 0, completed: 0, active: null },
1991
- completePct: (K == null ? void 0 : K.completePct) ?? null,
1992
- activeWidthPct: (K == null ? void 0 : K.activeWidthPct) ?? null,
1993
- txHash: de,
1994
- error: ve
2023
+ txHash: he,
2024
+ actionError: be,
2025
+ approvalRequired: rn.required,
2026
+ approvalDone: qa,
2027
+ authorizationRequired: Ga
2028
+ }), cn = (Y == null ? void 0 : Y.state) ?? null;
2029
+ Qr(c, {
2030
+ status: ee,
2031
+ progress: cn,
2032
+ label: (Y == null ? void 0 : Y.label) ?? null,
2033
+ walletPrompts: (Y == null ? void 0 : Y.walletPrompts) ?? { total: 0, completed: 0, active: null },
2034
+ completePct: (Y == null ? void 0 : Y.completePct) ?? null,
2035
+ activeWidthPct: (Y == null ? void 0 : Y.activeWidthPct) ?? null,
2036
+ txHash: he,
2037
+ error: be
1995
2038
  });
1996
- const Ma = F === "rail" || F === "both", Zt = F === "toast" || F === "both", Jt = de ? It(de, G) : null;
1997
- hr({
1998
- enabled: Zt,
1999
- status: oe,
2000
- progress: K,
2001
- txHash: de,
2002
- explorerUrl: Jt === "#" ? null : Jt,
2003
- successDescription: Z ? `Received ~${Ee(Z.amountOut, re.decimals)} ${re.symbol}` : null
2039
+ const za = ne === "rail" || ne === "both", un = ne === "toast" || ne === "both", dn = he ? jn(he, j) : null, Pe = dn === "#" ? null : dn;
2040
+ jr({
2041
+ enabled: un,
2042
+ status: ee,
2043
+ progress: Y,
2044
+ txHash: he,
2045
+ explorerUrl: Pe,
2046
+ successDescription: Z ? `Received ~${_e(Z.amountOut, ie.decimals)} ${ie.symbol}` : null
2004
2047
  });
2005
- const Ra = B(() => {
2006
- ht === "approve" ? Kt() : Gt();
2007
- }, [Kt, ht, Gt]), Oa = B(() => ea((O) => !O), []), Da = B(
2008
- (O) => Lt(cn(O)),
2048
+ const Ka = D(() => {
2049
+ ot === "approve" ? an() : nn();
2050
+ }, [an, ot, nn]), lt = L ?? ga, pn = L !== void 0, Te = D(
2051
+ (P) => {
2052
+ const q = typeof P == "function" ? P(lt) : P;
2053
+ q !== lt && (pn || ma(q), X == null || X(q));
2054
+ },
2055
+ [lt, pn, X]
2056
+ ), ja = D(
2057
+ () => Te((P) => !P),
2058
+ [Te]
2059
+ ), Xa = D(
2060
+ (P) => Vt(Rn(P)),
2009
2061
  []
2010
- ), Ba = B(() => {
2011
- un(ye) === null && Lt(ot);
2012
- }, [ot, ye]), La = Fr({
2062
+ ), Ya = D(() => {
2063
+ Dn(Ne) === null && Vt(wt);
2064
+ }, [wt, Ne]), Qa = ws({
2013
2065
  quote: Z,
2014
2066
  inputSymbol: Q.symbol,
2015
2067
  inputDecimals: Q.decimals,
2016
- outputSymbol: re.symbol,
2017
- outputDecimals: re.decimals
2018
- });
2068
+ outputSymbol: ie.symbol,
2069
+ outputDecimals: ie.decimals
2070
+ }), fn = de !== void 0 && de > 0n ? _e(de, Q.decimals) : null, Za = be || ee === "success" || !fn || !on && !we ? null : ot === "approve" ? `To swap, approve ${fn} ${Q.symbol} in your wallet` : tn ? `To swap, sign the ${Q.symbol} permit in your wallet — no gas` : null, hn = ((mn = j.chain.nativeCurrency) == null ? void 0 : mn.symbol) ?? "ETH", $e = J(() => oe ? {
2071
+ transactionHash: oe.transactionHash,
2072
+ received: Z && ee === "success" ? `${_e(Z.amountOut, ie.decimals)} ${ie.symbol}` : null,
2073
+ txExplorerHref: Pe,
2074
+ rows: [
2075
+ oe.feeWei > 0n ? {
2076
+ kind: "network-fee",
2077
+ label: "Network fee",
2078
+ value: `${Gr(oe.feeWei)} ${hn}`
2079
+ } : null,
2080
+ oe.effectiveGasPrice > 0n ? {
2081
+ kind: "gas-price",
2082
+ label: "Gas price",
2083
+ value: `${zr(oe.effectiveGasPrice)} gwei`
2084
+ } : null,
2085
+ oe.gasUsed > 0n ? { kind: "gas-used", label: "Gas used", value: oe.gasUsed.toString() } : null,
2086
+ oe.blockNumber > 0n ? { kind: "block", label: "Block", value: `#${oe.blockNumber.toString()}` } : null
2087
+ ].filter((P) => P !== null)
2088
+ } : null, [
2089
+ Pe,
2090
+ hn,
2091
+ ie.decimals,
2092
+ ie.symbol,
2093
+ Z,
2094
+ oe,
2095
+ ee
2096
+ ]);
2097
+ F(() => {
2098
+ ee !== "success" || !$e || (ba($e), Gt("transaction"), Te(!0));
2099
+ }, [Te, ee, $e]);
2100
+ const Ja = !!(A || y), ei = Le ? wa : "trade", ti = D((P) => {
2101
+ Gt(P), Te(!0);
2102
+ }, [Te]), ni = he && Pe && !$e && (Le == null ? void 0 : Le.transactionHash) !== he ? Pe : null;
2019
2103
  return {
2020
2104
  // identity / layout
2021
- rootRef: kt,
2022
- resolvedThemeMode: P,
2023
- widgetStyle: qe,
2024
- className: _,
2025
- ariaLabel: W,
2026
- title: C,
2027
- subtitle: x,
2028
- hasBrandText: !!(C || x),
2105
+ rootRef: zt,
2106
+ resolvedThemeMode: g,
2107
+ widgetStyle: pe,
2108
+ className: S,
2109
+ ariaLabel: M,
2110
+ title: A,
2111
+ subtitle: y,
2112
+ hasBrandText: Ja,
2029
2113
  // toaster + surfaces
2030
- theme: q,
2031
- accentColor: H,
2032
- accentTextColor: E,
2033
- toastPosition: ee,
2034
- showRail: Ma,
2035
- showToast: Zt,
2036
- showExecutionDetails: v,
2037
- showPoolLink: Y,
2114
+ theme: H,
2115
+ accentColor: z,
2116
+ accentTextColor: N,
2117
+ toastPosition: k,
2118
+ showRail: za,
2119
+ showToast: un,
2120
+ showExecutionDetails: _,
2121
+ showPoolLink: te,
2038
2122
  showApprovalMode: d,
2039
2123
  // progress
2040
- progress: K,
2041
- progressState: Qt,
2124
+ progress: Y,
2125
+ progressState: cn,
2042
2126
  // pools / network
2043
- poolIds: ae,
2044
- activePoolId: fe,
2045
- marketMap: we,
2046
- metadataByAddress: ma,
2047
- poolButtonRefs: Ut,
2048
- onSelectPool: ft,
2049
- onPoolKeyDown: Aa,
2050
- activeChain: G,
2051
- networkOptions: ce,
2052
- hasAvailablePools: Xt,
2127
+ poolIds: se,
2128
+ activePoolId: me,
2129
+ marketMap: xe,
2130
+ metadataByAddress: Ma,
2131
+ poolButtonRefs: Kt,
2132
+ onSelectPool: St,
2133
+ onPoolKeyDown: $a,
2134
+ activeChain: j,
2135
+ networkOptions: mt,
2136
+ hasAvailablePools: sn,
2053
2137
  // form: sell side
2054
- balances: ue,
2055
- sellInputId: h,
2138
+ balances: fe,
2139
+ sellInputId: C,
2056
2140
  inputToken: Q,
2057
- sellFieldValue: Me,
2058
- sellInvalid: ie === "exactIn" && dt,
2059
- sellRefreshEnabled: ie === "exactOut" && !_e,
2060
- onSellChange: Ea,
2061
- onHalf: va,
2062
- onMax: Ia,
2141
+ sellFieldValue: Ue,
2142
+ sellInvalid: le === "exactIn" && _t,
2143
+ sellRefreshEnabled: le === "exactOut" && !we,
2144
+ onSellChange: Wa,
2145
+ onHalf: La,
2146
+ onMax: Fa,
2063
2147
  // form: flip
2064
- direction: Ve,
2065
- market: z,
2066
- onFlipDirection: Sa,
2148
+ direction: Ze,
2149
+ market: G,
2150
+ onFlipDirection: Ua,
2067
2151
  // form: buy side
2068
- buyInputId: T,
2069
- outputToken: re,
2070
- buyFieldValue: pt,
2071
- buyInvalid: ie === "exactOut" && dt,
2072
- buyRefreshEnabled: ie === "exactIn" && !_e,
2073
- onBuyChange: xa,
2152
+ buyInputId: W,
2153
+ outputToken: ie,
2154
+ buyFieldValue: It,
2155
+ buyInvalid: le === "exactOut" && _t,
2156
+ buyRefreshEnabled: le === "exactIn" && !we,
2157
+ onBuyChange: Ha,
2074
2158
  // submit
2075
- busy: _e,
2076
- canSubmit: Pa,
2077
- primaryAction: ht,
2078
- ctaLabel: Ta,
2079
- onPrimaryAction: Ra,
2159
+ busy: we,
2160
+ canSubmit: on,
2161
+ primaryAction: ot,
2162
+ ctaLabel: Va,
2163
+ onPrimaryAction: Ka,
2080
2164
  // execution details
2081
- executionDetailsOpen: Jn,
2082
- executionDetailsId: te,
2083
- onToggleExecutionDetails: Oa,
2084
- tradeDetailRows: La,
2085
- slippageInputId: R,
2086
- slippageInput: ye,
2087
- slippageInvalid: !!(ye.trim() && Xe === null),
2088
- onSlippageChange: Da,
2089
- onSlippageBlur: Ba,
2090
- approvalMode: Ft,
2091
- onApprovalModeChange: Zn,
2092
- counterToken: Ke,
2093
- targetToken: Ge,
2094
- poolUrl: ya,
2095
- onCopyPoolId: _a,
2096
- routePoolCopied: ba,
2165
+ executionDetailsOpen: lt,
2166
+ executionDetailsView: ei,
2167
+ executionDetailsId: Ie,
2168
+ onToggleExecutionDetails: ja,
2169
+ onExecutionDetailsViewChange: ti,
2170
+ latestTxSummary: Le,
2171
+ tradeDetailRows: Qa,
2172
+ slippageInputId: U,
2173
+ slippageInput: Ne,
2174
+ slippageInvalid: !!(Ne.trim() && nt === null),
2175
+ onSlippageChange: Xa,
2176
+ onSlippageBlur: Ya,
2177
+ approvalMode: qt,
2178
+ onApprovalModeChange: ha,
2179
+ counterToken: et,
2180
+ targetToken: Je,
2181
+ poolUrl: Oa,
2182
+ onCopyPoolId: ka,
2183
+ routePoolCopied: Ba,
2097
2184
  // status / result
2098
- status: oe,
2099
- txHash: de,
2185
+ status: ee,
2186
+ txHash: he,
2100
2187
  quote: Z,
2101
- quoteError: zt,
2102
- actionError: ve,
2103
- allowanceError: Vt,
2104
- txExplorerHref: de ? It(de, G) : null
2188
+ quoteError: Zt,
2189
+ quoteLoading: Qt,
2190
+ actionError: be,
2191
+ allowanceError: en,
2192
+ inlineTxExplorerHref: ni,
2193
+ txExplorerHref: Pe,
2194
+ approvalHint: Za,
2195
+ txSummary: $e
2105
2196
  };
2106
2197
  }
2107
- const Wr = 150;
2108
- function xn({ icon: t = "ethereum" }) {
2109
- return t === "base" ? /* @__PURE__ */ r(_i, { className: "aegis-swap-widget__chain-logo" }) : /* @__PURE__ */ r(bi, { className: "aegis-swap-widget__chain-logo" });
2198
+ const vs = 150;
2199
+ function Hn({ icon: t = "ethereum" }) {
2200
+ return t === "base" ? /* @__PURE__ */ i(Vi, { className: "aegis-swap-widget__chain-logo" }) : /* @__PURE__ */ i(Hi, { className: "aegis-swap-widget__chain-logo" });
2110
2201
  }
2111
- const $r = {
2202
+ const _s = {
2112
2203
  1: "ethereum",
2113
2204
  8453: "base"
2114
- }, qr = nt(function({
2205
+ }, Is = ft(function({
2115
2206
  activeChainName: e,
2116
2207
  activeChainId: n,
2117
2208
  options: a
2118
2209
  }) {
2119
- const [i, o] = N(!1), [s, l] = N(!1), u = $(null), c = $(null), p = $(null), g = $(), y = De(), I = a != null && a.length ? a : [], b = I.find((_) => _.id === n) ?? I.find((_) => _.name === e), w = {
2210
+ const [r, s] = T(!1), [o, l] = T(!1), u = $(null), c = $(null), f = $(null), m = $(), I = Ve(), E = a != null && a.length ? a : [], v = E.find((S) => S.id === n) ?? E.find((S) => S.name === e), w = {
2120
2211
  id: n,
2121
2212
  name: e,
2122
- icon: $r[n]
2123
- }, S = b ? I : [w, ...I], A = b ?? w, M = B((_ = !1) => {
2124
- var f;
2125
- o(!1), l(!0), window.clearTimeout(g.current), g.current = window.setTimeout(() => l(!1), Wr), _ && ((f = c.current) == null || f.focus());
2126
- }, []), L = B(() => {
2127
- window.clearTimeout(g.current), l(!1), o(!0);
2213
+ icon: _s[n]
2214
+ }, b = v ? E : [w, ...E], x = v ?? w, R = D((S = !1) => {
2215
+ var h;
2216
+ s(!1), l(!0), window.clearTimeout(m.current), m.current = window.setTimeout(() => l(!1), vs), S && ((h = c.current) == null || h.focus());
2217
+ }, []), O = D(() => {
2218
+ window.clearTimeout(m.current), l(!1), s(!0);
2128
2219
  }, []);
2129
- k(() => () => window.clearTimeout(g.current), []);
2130
- const D = (_) => {
2131
- var W;
2132
- const f = Array.from(
2133
- ((W = p.current) == null ? void 0 : W.querySelectorAll('[role="option"]:not(:disabled)')) ?? []
2220
+ F(() => () => window.clearTimeout(m.current), []);
2221
+ const B = (S) => {
2222
+ var M;
2223
+ const h = Array.from(
2224
+ ((M = f.current) == null ? void 0 : M.querySelectorAll('[role="option"]:not(:disabled)')) ?? []
2134
2225
  );
2135
- if (f.length === 0) return;
2136
- const C = f.indexOf(document.activeElement), x = Vn(_.key, C, f.length);
2137
- x !== null && (_.preventDefault(), f[x].focus());
2226
+ if (h.length === 0) return;
2227
+ const A = h.indexOf(document.activeElement), y = oa(S.key, A, h.length);
2228
+ y !== null && (S.preventDefault(), h[y].focus());
2138
2229
  };
2139
- return k(() => {
2140
- if (!i) return;
2141
- const _ = (C) => {
2142
- var x;
2143
- (x = u.current) != null && x.contains(C.target) || M();
2144
- }, f = (C) => {
2145
- C.key === "Escape" && (C.stopPropagation(), M(!0));
2230
+ return F(() => {
2231
+ if (!r) return;
2232
+ const S = (A) => {
2233
+ var y;
2234
+ (y = u.current) != null && y.contains(A.target) || R();
2235
+ }, h = (A) => {
2236
+ A.key === "Escape" && (A.stopPropagation(), R(!0));
2146
2237
  };
2147
- return document.addEventListener("pointerdown", _), document.addEventListener("keydown", f), () => {
2148
- document.removeEventListener("pointerdown", _), document.removeEventListener("keydown", f);
2238
+ return document.addEventListener("pointerdown", S), document.addEventListener("keydown", h), () => {
2239
+ document.removeEventListener("pointerdown", S), document.removeEventListener("keydown", h);
2149
2240
  };
2150
- }, [i, M]), /* @__PURE__ */ m("div", { className: "aegis-swap-widget__network", ref: u, children: [
2151
- /* @__PURE__ */ m(
2241
+ }, [r, R]), /* @__PURE__ */ p("div", { className: "aegis-swap-widget__network", ref: u, children: [
2242
+ /* @__PURE__ */ p(
2152
2243
  "button",
2153
2244
  {
2154
2245
  type: "button",
2155
2246
  ref: c,
2156
2247
  className: "aegis-swap-widget__chain",
2157
2248
  "aria-haspopup": "listbox",
2158
- "aria-expanded": i,
2159
- "aria-controls": y,
2160
- "aria-label": `Network: ${A.name}. Change network`,
2161
- "data-open": i || void 0,
2162
- onClick: () => i ? M() : L(),
2249
+ "aria-expanded": r,
2250
+ "aria-controls": I,
2251
+ "aria-label": `Network: ${x.name}. Change network`,
2252
+ "data-open": r || void 0,
2253
+ onClick: () => r ? R() : O(),
2163
2254
  children: [
2164
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__chain-mark", "aria-hidden": "true", children: /* @__PURE__ */ r(xn, { icon: A.icon }) }),
2165
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__chain-caret", "aria-hidden": "true", children: /* @__PURE__ */ r(Fn, {}) })
2255
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__chain-mark", "aria-hidden": "true", children: /* @__PURE__ */ i(Hn, { icon: x.icon }) }),
2256
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__chain-caret", "aria-hidden": "true", children: /* @__PURE__ */ i(Zn, {}) })
2166
2257
  ]
2167
2258
  }
2168
2259
  ),
2169
- /* @__PURE__ */ m(
2260
+ /* @__PURE__ */ p(
2170
2261
  "div",
2171
2262
  {
2172
- className: `aegis-swap-widget__network-menu${i ? " is-open" : ""}${s ? " is-closing" : ""}`,
2173
- "aria-hidden": !i,
2263
+ className: `aegis-swap-widget__network-menu${r ? " is-open" : ""}${o ? " is-closing" : ""}`,
2264
+ "aria-hidden": !r,
2174
2265
  children: [
2175
- /* @__PURE__ */ r(
2266
+ /* @__PURE__ */ i(
2176
2267
  "div",
2177
2268
  {
2178
2269
  role: "listbox",
2179
- id: y,
2270
+ id: I,
2180
2271
  "aria-label": "Network",
2181
2272
  className: "aegis-swap-widget__network-list",
2182
- ref: p,
2183
- onKeyDown: D,
2184
- children: S.map((_) => {
2185
- const f = _ === A, C = f ? !1 : _.disabled ?? !0;
2186
- return /* @__PURE__ */ m(
2273
+ ref: f,
2274
+ onKeyDown: B,
2275
+ children: b.map((S) => {
2276
+ const h = S === x, A = h ? !1 : S.disabled ?? !0;
2277
+ return /* @__PURE__ */ p(
2187
2278
  "button",
2188
2279
  {
2189
2280
  type: "button",
2190
2281
  role: "option",
2191
- "aria-selected": C ? void 0 : f,
2192
- tabIndex: i && !C ? 0 : -1,
2193
- disabled: C,
2282
+ "aria-selected": A ? void 0 : h,
2283
+ tabIndex: r && !A ? 0 : -1,
2284
+ disabled: A,
2194
2285
  className: "aegis-swap-widget__network-option",
2195
- onClick: () => M(!0),
2286
+ onClick: () => R(!0),
2196
2287
  children: [
2197
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__network-mark", "aria-hidden": "true", children: /* @__PURE__ */ r(xn, { icon: _.icon }) }),
2198
- /* @__PURE__ */ m("span", { className: "aegis-swap-widget__network-label", children: [
2199
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__network-name", children: _.name }),
2200
- _.status ? /* @__PURE__ */ r("span", { className: "aegis-swap-widget__network-status", children: _.status }) : null
2288
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__network-mark", "aria-hidden": "true", children: /* @__PURE__ */ i(Hn, { icon: S.icon }) }),
2289
+ /* @__PURE__ */ p("span", { className: "aegis-swap-widget__network-label", children: [
2290
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__network-name", children: S.name }),
2291
+ S.status ? /* @__PURE__ */ i("span", { className: "aegis-swap-widget__network-status", children: S.status }) : null
2201
2292
  ] }),
2202
- f ? /* @__PURE__ */ r("span", { className: "aegis-swap-widget__network-check", "aria-hidden": "true", children: /* @__PURE__ */ r(at, {}) }) : null
2293
+ h ? /* @__PURE__ */ i("span", { className: "aegis-swap-widget__network-check", "aria-hidden": "true", children: /* @__PURE__ */ i(dt, {}) }) : null
2203
2294
  ]
2204
2295
  },
2205
- _.id
2296
+ S.id
2206
2297
  );
2207
2298
  })
2208
2299
  }
2209
2300
  ),
2210
- I.length === 0 ? /* @__PURE__ */ r("p", { className: "aegis-swap-widget__network-soon", children: "More networks coming soon" }) : null
2301
+ E.length === 0 ? /* @__PURE__ */ i("p", { className: "aegis-swap-widget__network-soon", children: "More networks coming soon" }) : null
2211
2302
  ]
2212
2303
  }
2213
2304
  )
2214
2305
  ] });
2215
2306
  });
2216
- function zr({
2307
+ function Ss({
2217
2308
  poolIds: t,
2218
2309
  activePoolId: e,
2219
2310
  marketMap: n,
2220
2311
  metadataByAddress: a,
2221
- busy: i,
2222
- onSelectPool: o,
2223
- onKeyDown: s,
2312
+ busy: r,
2313
+ onSelectPool: s,
2314
+ onKeyDown: o,
2224
2315
  buttonRefs: l
2225
2316
  }) {
2226
- return /* @__PURE__ */ r(
2317
+ return /* @__PURE__ */ i(
2227
2318
  "div",
2228
2319
  {
2229
2320
  className: "aegis-swap-widget__targets",
2230
2321
  role: "radiogroup",
2231
2322
  "aria-label": "Swap pool",
2232
- onKeyDown: s,
2323
+ onKeyDown: o,
2233
2324
  style: {
2234
2325
  "--aegis-seg-index": Math.max(t.indexOf(e ?? ""), 0),
2235
2326
  "--aegis-seg-count": t.length
2236
2327
  },
2237
2328
  children: t.map((u) => {
2238
- const c = n[u], p = u === e;
2239
- return /* @__PURE__ */ m(
2329
+ const c = n[u], f = u === e;
2330
+ return /* @__PURE__ */ p(
2240
2331
  "button",
2241
2332
  {
2242
2333
  type: "button",
2243
2334
  role: "radio",
2244
- ref: (g) => {
2245
- l.current.set(u, g);
2335
+ ref: (m) => {
2336
+ l.current.set(u, m);
2246
2337
  },
2247
2338
  className: "aegis-swap-widget__target",
2248
- "aria-checked": p,
2249
- tabIndex: p ? 0 : -1,
2250
- disabled: i,
2251
- onClick: () => o(u),
2339
+ "aria-checked": f,
2340
+ tabIndex: f ? 0 : -1,
2341
+ disabled: r,
2342
+ onClick: () => s(u),
2252
2343
  children: [
2253
- /* @__PURE__ */ r(
2254
- Bn,
2344
+ /* @__PURE__ */ i(
2345
+ Qn,
2255
2346
  {
2256
2347
  market: c,
2257
2348
  metadataByAddress: a,
2258
2349
  className: "aegis-swap-widget__target-pair"
2259
2350
  }
2260
2351
  ),
2261
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__target-symbol", children: c.symbol ?? u })
2352
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__target-symbol", children: c.symbol ?? u })
2262
2353
  ]
2263
2354
  },
2264
2355
  u
@@ -2267,185 +2358,277 @@ function zr({
2267
2358
  }
2268
2359
  );
2269
2360
  }
2270
- function Hr(t, e) {
2271
- const [n, a] = N(!1), i = $(t);
2272
- return k(() => {
2273
- const o = i.current !== t;
2274
- if (i.current = t, !e || !o || t === "") return;
2361
+ function As(t, e) {
2362
+ const [n, a] = T(!1), r = $(t);
2363
+ return F(() => {
2364
+ const s = r.current !== t;
2365
+ if (r.current = t, !e || !s || t === "") return;
2275
2366
  a(!0);
2276
- const s = window.setTimeout(() => a(!1), 700);
2367
+ const o = window.setTimeout(() => a(!1), 700);
2277
2368
  return () => {
2278
- window.clearTimeout(s), a(!1);
2369
+ window.clearTimeout(o), a(!1);
2279
2370
  };
2280
2371
  }, [e, t]), n;
2281
2372
  }
2282
- function Pn({
2373
+ function Vn({
2283
2374
  inputId: t,
2284
2375
  label: e,
2285
2376
  token: n,
2286
2377
  value: a,
2287
- balance: i,
2288
- invalid: o,
2289
- busy: s,
2378
+ balance: r,
2379
+ invalid: s,
2380
+ busy: o,
2290
2381
  refreshEnabled: l,
2291
- metadataByAddress: u,
2292
- onChange: c,
2293
- quickActions: p
2382
+ refreshing: u,
2383
+ metadataByAddress: c,
2384
+ onChange: f,
2385
+ quickActions: m
2294
2386
  }) {
2295
- const g = Hr(a, l ?? !1);
2296
- return /* @__PURE__ */ m("div", { className: "aegis-swap-widget__amount-box", "data-refreshed": g || void 0, children: [
2297
- /* @__PURE__ */ m("span", { className: "aegis-swap-widget__field-label", children: [
2298
- /* @__PURE__ */ r("label", { htmlFor: t, children: e }),
2299
- p ? /* @__PURE__ */ m("span", { className: "aegis-swap-widget__quick", children: [
2300
- /* @__PURE__ */ r(
2301
- "button",
2302
- {
2303
- type: "button",
2304
- className: "aegis-swap-widget__half",
2305
- "aria-label": `Use half ${n.symbol} balance`,
2306
- disabled: i === null || s,
2307
- onClick: p.onHalf,
2308
- children: "50%"
2309
- }
2310
- ),
2311
- /* @__PURE__ */ r(
2312
- "button",
2313
- {
2314
- type: "button",
2315
- className: "aegis-swap-widget__max",
2316
- "aria-label": `Use max ${n.symbol} balance`,
2317
- disabled: i === null || s,
2318
- onClick: p.onMax,
2319
- children: "Max"
2320
- }
2321
- )
2322
- ] }) : null
2323
- ] }),
2324
- /* @__PURE__ */ m("span", { className: "aegis-swap-widget__amount-row", children: [
2325
- /* @__PURE__ */ r(
2326
- "input",
2327
- {
2328
- id: t,
2329
- inputMode: "decimal",
2330
- autoComplete: "off",
2331
- value: a,
2332
- "aria-invalid": o ? !0 : void 0,
2333
- onChange: (y) => c(y.target.value),
2334
- placeholder: "0",
2335
- disabled: s
2336
- }
2337
- ),
2338
- /* @__PURE__ */ m("span", { className: "aegis-swap-widget__token", children: [
2339
- /* @__PURE__ */ r(
2340
- St,
2341
- {
2342
- token: n,
2343
- metadataByAddress: u,
2344
- className: "aegis-swap-widget__token-mark"
2345
- }
2346
- ),
2347
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__token-symbol", children: n.symbol })
2348
- ] }, n.address)
2349
- ] }),
2350
- /* @__PURE__ */ m("span", { className: "aegis-swap-widget__meta", children: [
2351
- "Balance ",
2352
- hi(i, n.decimals),
2353
- " ",
2354
- n.symbol
2355
- ] })
2356
- ] });
2387
+ const I = As(a, l ?? !1);
2388
+ return /* @__PURE__ */ p(
2389
+ "div",
2390
+ {
2391
+ className: "aegis-swap-widget__amount-box",
2392
+ "data-refreshed": I || void 0,
2393
+ "data-refreshing": l && u || void 0,
2394
+ children: [
2395
+ /* @__PURE__ */ p("span", { className: "aegis-swap-widget__field-label", children: [
2396
+ /* @__PURE__ */ i("label", { htmlFor: t, children: e }),
2397
+ m ? /* @__PURE__ */ p("span", { className: "aegis-swap-widget__quick", children: [
2398
+ /* @__PURE__ */ i(
2399
+ "button",
2400
+ {
2401
+ type: "button",
2402
+ className: "aegis-swap-widget__half",
2403
+ "aria-label": `Use half ${n.symbol} balance`,
2404
+ disabled: r === null || o,
2405
+ onClick: m.onHalf,
2406
+ children: "50%"
2407
+ }
2408
+ ),
2409
+ /* @__PURE__ */ i(
2410
+ "button",
2411
+ {
2412
+ type: "button",
2413
+ className: "aegis-swap-widget__max",
2414
+ "aria-label": `Use max ${n.symbol} balance`,
2415
+ disabled: r === null || o,
2416
+ onClick: m.onMax,
2417
+ children: "Max"
2418
+ }
2419
+ )
2420
+ ] }) : null
2421
+ ] }),
2422
+ /* @__PURE__ */ p("span", { className: "aegis-swap-widget__amount-row", children: [
2423
+ /* @__PURE__ */ i(
2424
+ "input",
2425
+ {
2426
+ id: t,
2427
+ inputMode: "decimal",
2428
+ autoComplete: "off",
2429
+ value: a,
2430
+ "aria-invalid": s ? !0 : void 0,
2431
+ onChange: (E) => f(E.target.value),
2432
+ placeholder: "0",
2433
+ disabled: o
2434
+ }
2435
+ ),
2436
+ /* @__PURE__ */ p("span", { className: "aegis-swap-widget__token", children: [
2437
+ /* @__PURE__ */ i(
2438
+ Ct,
2439
+ {
2440
+ token: n,
2441
+ metadataByAddress: c,
2442
+ className: "aegis-swap-widget__token-mark"
2443
+ }
2444
+ ),
2445
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__token-symbol", children: n.symbol })
2446
+ ] }, n.address)
2447
+ ] }),
2448
+ /* @__PURE__ */ p("span", { className: "aegis-swap-widget__meta", children: [
2449
+ "Balance ",
2450
+ Vr(r, n.decimals),
2451
+ " ",
2452
+ n.symbol
2453
+ ] })
2454
+ ]
2455
+ }
2456
+ );
2357
2457
  }
2358
- function Vr({
2458
+ function Es({ kind: t }) {
2459
+ switch (t) {
2460
+ case "network-fee":
2461
+ return /* @__PURE__ */ i(Ki, {});
2462
+ case "gas-price":
2463
+ return /* @__PURE__ */ i(ji, {});
2464
+ case "gas-used":
2465
+ return /* @__PURE__ */ i(Xi, {});
2466
+ case "block":
2467
+ return /* @__PURE__ */ i(Yi, {});
2468
+ }
2469
+ }
2470
+ function xs({
2359
2471
  open: t,
2360
2472
  panelId: e,
2361
2473
  onToggle: n,
2362
- rows: a,
2363
- slippageInputId: i,
2364
- slippageValue: o,
2365
- slippageInvalid: s,
2366
- onSlippageChange: l,
2367
- onSlippageBlur: u,
2368
- showApprovalControl: c,
2369
- approvalMode: p,
2370
- onApprovalModeChange: g,
2371
- busy: y,
2372
- market: I,
2373
- metadataByAddress: b,
2374
- counterToken: w,
2375
- targetToken: S,
2376
- showPoolLink: A,
2377
- poolUrl: M,
2378
- onCopyPoolId: L,
2379
- poolCopied: D
2474
+ activeView: a,
2475
+ onViewChange: r,
2476
+ latestTxSummary: s,
2477
+ rows: o,
2478
+ slippageInputId: l,
2479
+ slippageValue: u,
2480
+ slippageInvalid: c,
2481
+ onSlippageChange: f,
2482
+ onSlippageBlur: m,
2483
+ showApprovalControl: I,
2484
+ approvalMode: E,
2485
+ onApprovalModeChange: v,
2486
+ busy: w,
2487
+ market: b,
2488
+ metadataByAddress: x,
2489
+ counterToken: R,
2490
+ targetToken: O,
2491
+ showPoolLink: B,
2492
+ poolUrl: S,
2493
+ onCopyPoolId: h,
2494
+ poolCopied: A
2380
2495
  }) {
2381
- return /* @__PURE__ */ m("div", { className: "aegis-swap-widget__execution", "data-open": t ? !0 : void 0, children: [
2382
- /* @__PURE__ */ m(
2383
- "button",
2384
- {
2385
- type: "button",
2386
- className: "aegis-swap-widget__execution-toggle",
2387
- "aria-expanded": t,
2388
- "aria-controls": e,
2389
- "aria-label": t ? "Collapse trade details" : "Expand trade details",
2390
- onClick: n,
2391
- children: [
2392
- /* @__PURE__ */ m("span", { className: "aegis-swap-widget__execution-toggle-label", children: [
2393
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__execution-toggle-icon", children: /* @__PURE__ */ r(Si, {}) }),
2394
- /* @__PURE__ */ r("span", { children: "Trade details" })
2395
- ] }),
2396
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__execution-chevron", children: /* @__PURE__ */ r(Fn, {}) })
2397
- ]
2398
- }
2399
- ),
2400
- /* @__PURE__ */ r("div", { id: e, className: "aegis-swap-widget__execution-panel", children: /* @__PURE__ */ m("div", { className: "aegis-swap-widget__execution-panel-inner", children: [
2401
- a.length > 0 ? /* @__PURE__ */ r("div", { className: "aegis-swap-widget__quote-summary", children: a.map((_) => /* @__PURE__ */ m("div", { className: "aegis-swap-widget__detail-row", children: [
2402
- /* @__PURE__ */ r("span", { children: _.label }),
2403
- /* @__PURE__ */ r("strong", { children: _.value }, _.value)
2404
- ] }, _.label)) }) : null,
2405
- /* @__PURE__ */ r("div", { className: "aegis-swap-widget__settings", children: /* @__PURE__ */ m("label", { htmlFor: i, children: [
2406
- /* @__PURE__ */ r("span", { children: "Slippage" }),
2407
- /* @__PURE__ */ m("span", { className: "aegis-swap-widget__slippage-input", children: [
2408
- /* @__PURE__ */ r(
2496
+ const y = s && a === "transaction" ? "transaction" : "trade";
2497
+ return /* @__PURE__ */ p("div", { className: "aegis-swap-widget__execution", "data-open": t ? !0 : void 0, children: [
2498
+ /* @__PURE__ */ p("div", { className: "aegis-swap-widget__execution-header", children: [
2499
+ /* @__PURE__ */ p(
2500
+ "button",
2501
+ {
2502
+ type: "button",
2503
+ className: "aegis-swap-widget__execution-toggle",
2504
+ "aria-expanded": t,
2505
+ "aria-controls": e,
2506
+ "aria-label": t ? "Collapse trade details" : "Expand trade details",
2507
+ onClick: n,
2508
+ children: [
2509
+ /* @__PURE__ */ p("span", { className: "aegis-swap-widget__execution-toggle-label", children: [
2510
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__execution-toggle-icon", children: /* @__PURE__ */ i(zi, {}) }),
2511
+ /* @__PURE__ */ i("span", { children: "Trade details" })
2512
+ ] }),
2513
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__execution-chevron", children: /* @__PURE__ */ i(Zn, {}) })
2514
+ ]
2515
+ }
2516
+ ),
2517
+ s ? /* @__PURE__ */ p(
2518
+ "span",
2519
+ {
2520
+ className: "aegis-swap-widget__execution-view-toggle",
2521
+ role: "group",
2522
+ "aria-label": "Details view",
2523
+ style: { "--aegis-seg-index": y === "trade" ? 0 : 1 },
2524
+ children: [
2525
+ /* @__PURE__ */ i(
2526
+ "button",
2527
+ {
2528
+ type: "button",
2529
+ "data-active": y === "trade" ? !0 : void 0,
2530
+ "aria-pressed": y === "trade",
2531
+ onClick: () => r("trade"),
2532
+ children: "Trade"
2533
+ }
2534
+ ),
2535
+ /* @__PURE__ */ i(
2536
+ "button",
2537
+ {
2538
+ type: "button",
2539
+ "data-active": y === "transaction" ? !0 : void 0,
2540
+ "aria-pressed": y === "transaction",
2541
+ onClick: () => r("transaction"),
2542
+ children: "Latest tx"
2543
+ }
2544
+ )
2545
+ ]
2546
+ }
2547
+ ) : null
2548
+ ] }),
2549
+ /* @__PURE__ */ i("div", { id: e, className: "aegis-swap-widget__execution-panel", children: /* @__PURE__ */ i("div", { className: "aegis-swap-widget__execution-panel-inner", children: y === "transaction" && s ? /* @__PURE__ */ p("div", { className: "aegis-swap-widget__receipt", role: "status", children: [
2550
+ /* @__PURE__ */ p("div", { className: "aegis-swap-widget__receipt-head", children: [
2551
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__success-check", "aria-hidden": "true", children: /* @__PURE__ */ i(dt, {}) }),
2552
+ /* @__PURE__ */ p("span", { children: [
2553
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__receipt-title", children: "Latest transaction" }),
2554
+ /* @__PURE__ */ p("span", { className: "aegis-swap-widget__receipt-subtitle", children: [
2555
+ "Swap complete",
2556
+ s.received ? /* @__PURE__ */ p(yn, { children: [
2557
+ " · received ",
2558
+ /* @__PURE__ */ i("strong", { children: s.received })
2559
+ ] }) : null
2560
+ ] })
2561
+ ] })
2562
+ ] }),
2563
+ s.rows.length > 0 ? /* @__PURE__ */ i("dl", { className: "aegis-swap-widget__receipt-list", children: s.rows.map((M) => /* @__PURE__ */ p("div", { className: "aegis-swap-widget__receipt-row", "data-kind": M.kind, children: [
2564
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__receipt-metric-icon", "aria-hidden": "true", children: /* @__PURE__ */ i(Es, { kind: M.kind }) }),
2565
+ /* @__PURE__ */ p("div", { className: "aegis-swap-widget__receipt-row-copy", children: [
2566
+ /* @__PURE__ */ i("dt", { children: M.label }),
2567
+ /* @__PURE__ */ i("dd", { children: M.value })
2568
+ ] })
2569
+ ] }, M.label)) }) : null,
2570
+ s.txExplorerHref ? /* @__PURE__ */ p(
2571
+ "a",
2572
+ {
2573
+ className: "aegis-swap-widget__receipt-link",
2574
+ href: s.txExplorerHref,
2575
+ target: "_blank",
2576
+ rel: "noreferrer",
2577
+ children: [
2578
+ "View transaction",
2579
+ /* @__PURE__ */ i(Mt, {})
2580
+ ]
2581
+ }
2582
+ ) : null
2583
+ ] }) : /* @__PURE__ */ p(yn, { children: [
2584
+ o.length > 0 ? /* @__PURE__ */ i("div", { className: "aegis-swap-widget__quote-summary", children: o.map((M) => /* @__PURE__ */ p("div", { className: "aegis-swap-widget__detail-row", children: [
2585
+ /* @__PURE__ */ i("span", { children: M.label }),
2586
+ /* @__PURE__ */ i("strong", { children: M.value }, M.value)
2587
+ ] }, M.label)) }) : null,
2588
+ /* @__PURE__ */ i("div", { className: "aegis-swap-widget__settings", children: /* @__PURE__ */ p("label", { htmlFor: l, children: [
2589
+ /* @__PURE__ */ i("span", { children: "Slippage" }),
2590
+ /* @__PURE__ */ p("span", { className: "aegis-swap-widget__slippage-input", children: [
2591
+ /* @__PURE__ */ i(
2409
2592
  "input",
2410
2593
  {
2411
- id: i,
2412
- value: o,
2594
+ id: l,
2595
+ value: u,
2413
2596
  inputMode: "decimal",
2414
- "aria-invalid": s ? !0 : void 0,
2415
- onChange: (_) => l(_.target.value),
2416
- onBlur: u
2597
+ "aria-invalid": c ? !0 : void 0,
2598
+ onChange: (M) => f(M.target.value),
2599
+ onBlur: m
2417
2600
  }
2418
2601
  ),
2419
- /* @__PURE__ */ r("span", { children: "%" })
2602
+ /* @__PURE__ */ i("span", { children: "%" })
2420
2603
  ] })
2421
2604
  ] }) }),
2422
- c ? /* @__PURE__ */ m("div", { className: "aegis-swap-widget__approval-mode", children: [
2423
- /* @__PURE__ */ r("span", { children: "Approval" }),
2424
- /* @__PURE__ */ m(
2605
+ I ? /* @__PURE__ */ p("div", { className: "aegis-swap-widget__approval-mode", children: [
2606
+ /* @__PURE__ */ i("span", { children: "Approval" }),
2607
+ /* @__PURE__ */ p(
2425
2608
  "span",
2426
2609
  {
2427
2610
  className: "aegis-swap-widget__approval-options",
2428
2611
  role: "group",
2429
2612
  "aria-label": "Approval amount",
2430
- style: { "--aegis-seg-index": p === "exact" ? 0 : 1 },
2613
+ style: { "--aegis-seg-index": E === "exact" ? 0 : 1 },
2431
2614
  children: [
2432
- /* @__PURE__ */ r(
2615
+ /* @__PURE__ */ i(
2433
2616
  "button",
2434
2617
  {
2435
2618
  type: "button",
2436
- "data-active": p === "exact" ? !0 : void 0,
2437
- disabled: y,
2438
- onClick: () => g("exact"),
2619
+ "data-active": E === "exact" ? !0 : void 0,
2620
+ disabled: w,
2621
+ onClick: () => v("exact"),
2439
2622
  children: "Exact"
2440
2623
  }
2441
2624
  ),
2442
- /* @__PURE__ */ r(
2625
+ /* @__PURE__ */ i(
2443
2626
  "button",
2444
2627
  {
2445
2628
  type: "button",
2446
- "data-active": p === "max" ? !0 : void 0,
2447
- disabled: y,
2448
- onClick: () => g("max"),
2629
+ "data-active": E === "max" ? !0 : void 0,
2630
+ disabled: w,
2631
+ onClick: () => v("max"),
2449
2632
  children: "Max"
2450
2633
  }
2451
2634
  )
@@ -2453,53 +2636,53 @@ function Vr({
2453
2636
  }
2454
2637
  )
2455
2638
  ] }) : null,
2456
- I ? /* @__PURE__ */ r("div", { className: "aegis-swap-widget__details", children: /* @__PURE__ */ m("div", { className: "aegis-swap-widget__pool", children: [
2457
- /* @__PURE__ */ m("span", { className: "aegis-swap-widget__pool-label", children: [
2458
- /* @__PURE__ */ r(
2459
- Bn,
2639
+ b ? /* @__PURE__ */ i("div", { className: "aegis-swap-widget__details", children: /* @__PURE__ */ p("div", { className: "aegis-swap-widget__pool", children: [
2640
+ /* @__PURE__ */ p("span", { className: "aegis-swap-widget__pool-label", children: [
2641
+ /* @__PURE__ */ i(
2642
+ Qn,
2460
2643
  {
2461
- market: I,
2462
- metadataByAddress: b,
2644
+ market: b,
2645
+ metadataByAddress: x,
2463
2646
  className: "aegis-swap-widget__pool-pair"
2464
2647
  }
2465
2648
  ),
2466
2649
  "Route"
2467
2650
  ] }),
2468
- /* @__PURE__ */ m(
2651
+ /* @__PURE__ */ p(
2469
2652
  "span",
2470
2653
  {
2471
2654
  className: "aegis-swap-widget__route-chip",
2472
- "aria-label": `Uniswap v4 pool ${I.poolId}`,
2473
- title: `${I.label ?? `${w.symbol} / ${S.symbol}`}: ${I.poolId}`,
2655
+ "aria-label": `Uniswap v4 pool ${b.poolId}`,
2656
+ title: `${b.label ?? `${R.symbol} / ${O.symbol}`}: ${b.poolId}`,
2474
2657
  children: [
2475
- /* @__PURE__ */ m("span", { className: "aegis-swap-widget__route-protocol", children: [
2476
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__route-version", children: "v4" }),
2477
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__route-kind", children: "Pool" })
2658
+ /* @__PURE__ */ p("span", { className: "aegis-swap-widget__route-protocol", children: [
2659
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__route-version", children: "v4" }),
2660
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__route-kind", children: "Pool" })
2478
2661
  ] }),
2479
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__route-id", children: Br(I.poolId) }),
2480
- /* @__PURE__ */ m("span", { className: "aegis-swap-widget__route-actions", children: [
2481
- A && M ? /* @__PURE__ */ r(
2662
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__route-id", children: gs(b.poolId) }),
2663
+ /* @__PURE__ */ p("span", { className: "aegis-swap-widget__route-actions", children: [
2664
+ B && S ? /* @__PURE__ */ i(
2482
2665
  "a",
2483
2666
  {
2484
2667
  className: "aegis-swap-widget__route-action",
2485
- href: M,
2668
+ href: S,
2486
2669
  target: "_blank",
2487
2670
  rel: "noreferrer",
2488
2671
  "aria-label": "Open pool",
2489
- children: /* @__PURE__ */ r(Ln, {})
2672
+ children: /* @__PURE__ */ i(Mt, {})
2490
2673
  }
2491
2674
  ) : null,
2492
- /* @__PURE__ */ m(
2675
+ /* @__PURE__ */ p(
2493
2676
  "button",
2494
2677
  {
2495
2678
  type: "button",
2496
2679
  className: "aegis-swap-widget__route-action",
2497
- "data-copied": D || void 0,
2498
- onClick: L,
2499
- "aria-label": D ? "Pool id copied" : "Copy pool id",
2680
+ "data-copied": A || void 0,
2681
+ onClick: h,
2682
+ "aria-label": A ? "Pool id copied" : "Copy pool id",
2500
2683
  children: [
2501
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__copy-icon", "data-icon": "copy", "aria-hidden": "true", children: /* @__PURE__ */ r(Ii, {}) }),
2502
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__copy-icon", "data-icon": "check", "aria-hidden": "true", children: /* @__PURE__ */ r(at, {}) })
2684
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__copy-icon", "data-icon": "copy", "aria-hidden": "true", children: /* @__PURE__ */ i(Gi, {}) }),
2685
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__copy-icon", "data-icon": "check", "aria-hidden": "true", children: /* @__PURE__ */ i(dt, {}) })
2503
2686
  ]
2504
2687
  }
2505
2688
  )
@@ -2508,48 +2691,48 @@ function Vr({
2508
2691
  }
2509
2692
  )
2510
2693
  ] }) }) : null
2511
- ] }) })
2694
+ ] }) }) })
2512
2695
  ] });
2513
2696
  }
2514
- const Gr = {
2697
+ const Ns = {
2515
2698
  pending: { completePct: 0, activeWidthPct: 100 },
2516
2699
  mining: { completePct: 0, activeWidthPct: 100 },
2517
2700
  success: { completePct: 100, activeWidthPct: 0 },
2518
2701
  error: { completePct: 100, activeWidthPct: 0 }
2519
2702
  };
2520
- function Kr({
2703
+ function Ps({
2521
2704
  state: t,
2522
2705
  label: e,
2523
2706
  completePct: n,
2524
2707
  activeWidthPct: a,
2525
- className: i
2708
+ className: r
2526
2709
  }) {
2527
2710
  if (!t) return null;
2528
- const o = Gr[t];
2529
- if (!o) return null;
2530
- const s = n ?? o.completePct, l = a ?? o.activeWidthPct;
2531
- return /* @__PURE__ */ m(
2711
+ const s = Ns[t];
2712
+ if (!s) return null;
2713
+ const o = n ?? s.completePct, l = a ?? s.activeWidthPct;
2714
+ return /* @__PURE__ */ p(
2532
2715
  "span",
2533
2716
  {
2534
- className: `aegis-swap-widget__progress-rail${i ? ` ${i}` : ""}`,
2717
+ className: `aegis-swap-widget__progress-rail${r ? ` ${r}` : ""}`,
2535
2718
  "data-state": t,
2536
2719
  title: e ? `${e} · ${t}` : t,
2537
2720
  style: {
2538
- "--aegis-swap-progress-complete": `${s}%`,
2721
+ "--aegis-swap-progress-complete": `${o}%`,
2539
2722
  "--aegis-swap-progress-active-width": `${l}%`
2540
2723
  },
2541
2724
  "aria-hidden": "true",
2542
2725
  children: [
2543
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__progress-complete" }),
2544
- l > 0 ? /* @__PURE__ */ r("span", { className: "aegis-swap-widget__progress-active" }) : null
2726
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__progress-complete" }),
2727
+ l > 0 ? /* @__PURE__ */ i("span", { className: "aegis-swap-widget__progress-active" }) : null
2545
2728
  ]
2546
2729
  }
2547
2730
  );
2548
2731
  }
2549
- function jr(t) {
2550
- var i, o, s;
2551
- const e = Ur(t), n = /* @__PURE__ */ r(
2552
- zr,
2732
+ function Ts(t) {
2733
+ var r, s, o;
2734
+ const e = ys(t), n = /* @__PURE__ */ i(
2735
+ Ss,
2553
2736
  {
2554
2737
  poolIds: e.poolIds,
2555
2738
  activePoolId: e.activePoolId,
@@ -2560,15 +2743,15 @@ function jr(t) {
2560
2743
  onKeyDown: e.onPoolKeyDown,
2561
2744
  buttonRefs: e.poolButtonRefs
2562
2745
  }
2563
- ), a = /* @__PURE__ */ r(
2564
- qr,
2746
+ ), a = /* @__PURE__ */ i(
2747
+ Is,
2565
2748
  {
2566
2749
  activeChainName: e.activeChain.name,
2567
2750
  activeChainId: e.activeChain.chainId,
2568
2751
  options: e.networkOptions
2569
2752
  }
2570
2753
  );
2571
- return /* @__PURE__ */ m(
2754
+ return /* @__PURE__ */ p(
2572
2755
  "section",
2573
2756
  {
2574
2757
  ref: e.rootRef,
@@ -2579,21 +2762,21 @@ function jr(t) {
2579
2762
  style: e.widgetStyle,
2580
2763
  "aria-label": e.ariaLabel,
2581
2764
  children: [
2582
- e.showRail ? /* @__PURE__ */ r(
2583
- Kr,
2765
+ e.showRail ? /* @__PURE__ */ i(
2766
+ Ps,
2584
2767
  {
2585
2768
  state: e.progressState,
2586
- label: (i = e.progress) == null ? void 0 : i.label,
2587
- completePct: (o = e.progress) == null ? void 0 : o.completePct,
2588
- activeWidthPct: (s = e.progress) == null ? void 0 : s.activeWidthPct
2769
+ label: (r = e.progress) == null ? void 0 : r.label,
2770
+ completePct: (s = e.progress) == null ? void 0 : s.completePct,
2771
+ activeWidthPct: (o = e.progress) == null ? void 0 : o.activeWidthPct
2589
2772
  }
2590
2773
  ) : null,
2591
2774
  e.showToast ? (
2592
2775
  // Portals to document.body (the widget root's entrance transform
2593
2776
  // would trap position: fixed) and yields to any host-mounted
2594
2777
  // AegisSwapToaster via the toaster election.
2595
- /* @__PURE__ */ r(
2596
- pr,
2778
+ /* @__PURE__ */ i(
2779
+ Wr,
2597
2780
  {
2598
2781
  position: e.toastPosition,
2599
2782
  theme: e.theme,
@@ -2602,32 +2785,32 @@ function jr(t) {
2602
2785
  }
2603
2786
  )
2604
2787
  ) : null,
2605
- e.hasBrandText ? /* @__PURE__ */ m("div", { className: "aegis-swap-widget__header", children: [
2606
- /* @__PURE__ */ m("div", { className: "aegis-swap-widget__brand", children: [
2607
- e.subtitle ? /* @__PURE__ */ r("span", { className: "aegis-swap-widget__eyebrow", children: e.subtitle }) : null,
2608
- e.title ? /* @__PURE__ */ r("h2", { children: e.title }) : null
2788
+ e.hasBrandText ? /* @__PURE__ */ p("div", { className: "aegis-swap-widget__header", children: [
2789
+ /* @__PURE__ */ p("div", { className: "aegis-swap-widget__brand", children: [
2790
+ e.subtitle ? /* @__PURE__ */ i("span", { className: "aegis-swap-widget__eyebrow", children: e.subtitle }) : null,
2791
+ e.title ? /* @__PURE__ */ i("h2", { children: e.title }) : null
2609
2792
  ] }),
2610
2793
  a
2611
2794
  ] }) : null,
2612
- e.hasBrandText ? n : /* @__PURE__ */ m("div", { className: "aegis-swap-widget__topbar", children: [
2795
+ e.hasBrandText ? n : /* @__PURE__ */ p("div", { className: "aegis-swap-widget__topbar", children: [
2613
2796
  n,
2614
2797
  a
2615
2798
  ] }),
2616
- e.hasAvailablePools ? null : /* @__PURE__ */ m("p", { className: "aegis-swap-widget__empty", role: "status", children: [
2799
+ e.hasAvailablePools ? null : /* @__PURE__ */ p("p", { className: "aegis-swap-widget__empty", role: "status", children: [
2617
2800
  "No pools are configured for ",
2618
2801
  e.activeChain.name,
2619
2802
  "."
2620
2803
  ] }),
2621
- /* @__PURE__ */ m(
2804
+ /* @__PURE__ */ p(
2622
2805
  "form",
2623
2806
  {
2624
2807
  onSubmit: (l) => {
2625
2808
  l.preventDefault(), e.canSubmit && e.onPrimaryAction();
2626
2809
  },
2627
2810
  children: [
2628
- /* @__PURE__ */ m("div", { className: "aegis-swap-widget__panel", children: [
2629
- /* @__PURE__ */ r(
2630
- Pn,
2811
+ /* @__PURE__ */ p("div", { className: "aegis-swap-widget__panel", children: [
2812
+ /* @__PURE__ */ i(
2813
+ Vn,
2631
2814
  {
2632
2815
  inputId: e.sellInputId,
2633
2816
  label: "Sell",
@@ -2637,12 +2820,13 @@ function jr(t) {
2637
2820
  invalid: e.sellInvalid,
2638
2821
  busy: e.busy,
2639
2822
  refreshEnabled: e.sellRefreshEnabled,
2823
+ refreshing: e.quoteLoading,
2640
2824
  metadataByAddress: e.metadataByAddress,
2641
2825
  onChange: e.onSellChange,
2642
2826
  quickActions: { onHalf: e.onHalf, onMax: e.onMax }
2643
2827
  }
2644
2828
  ),
2645
- /* @__PURE__ */ r(
2829
+ /* @__PURE__ */ i(
2646
2830
  "button",
2647
2831
  {
2648
2832
  type: "button",
@@ -2651,11 +2835,11 @@ function jr(t) {
2651
2835
  onClick: e.onFlipDirection,
2652
2836
  disabled: !e.market || e.busy,
2653
2837
  "aria-label": "Switch swap direction",
2654
- children: /* @__PURE__ */ r(vi, {})
2838
+ children: /* @__PURE__ */ i(qi, {})
2655
2839
  }
2656
2840
  ),
2657
- /* @__PURE__ */ r(
2658
- Pn,
2841
+ /* @__PURE__ */ i(
2842
+ Vn,
2659
2843
  {
2660
2844
  inputId: e.buyInputId,
2661
2845
  label: "Buy",
@@ -2665,17 +2849,21 @@ function jr(t) {
2665
2849
  invalid: e.buyInvalid,
2666
2850
  busy: e.busy,
2667
2851
  refreshEnabled: e.buyRefreshEnabled,
2852
+ refreshing: e.quoteLoading,
2668
2853
  metadataByAddress: e.metadataByAddress,
2669
2854
  onChange: e.onBuyChange
2670
2855
  }
2671
2856
  )
2672
2857
  ] }),
2673
- e.showExecutionDetails ? /* @__PURE__ */ r(
2674
- Vr,
2858
+ e.showExecutionDetails ? /* @__PURE__ */ i(
2859
+ xs,
2675
2860
  {
2676
2861
  open: e.executionDetailsOpen,
2677
2862
  panelId: e.executionDetailsId,
2678
2863
  onToggle: e.onToggleExecutionDetails,
2864
+ activeView: e.executionDetailsView,
2865
+ onViewChange: e.onExecutionDetailsViewChange,
2866
+ latestTxSummary: e.latestTxSummary,
2679
2867
  rows: e.tradeDetailRows,
2680
2868
  slippageInputId: e.slippageInputId,
2681
2869
  slippageValue: e.slippageInput,
@@ -2699,7 +2887,7 @@ function jr(t) {
2699
2887
  e.quoteError || e.actionError || e.allowanceError ? (
2700
2888
  // Keyed on the message so a different error remounts and replays
2701
2889
  // the shake; the same error staying up does not re-shake.
2702
- /* @__PURE__ */ r(
2890
+ /* @__PURE__ */ i(
2703
2891
  "p",
2704
2892
  {
2705
2893
  className: "aegis-swap-widget__error",
@@ -2708,8 +2896,15 @@ function jr(t) {
2708
2896
  },
2709
2897
  e.quoteError ?? e.actionError ?? e.allowanceError
2710
2898
  )
2899
+ ) : e.approvalHint ? (
2900
+ // Aave-style caption to the CTA: names the exact wallet step the
2901
+ // user is about to take. Keyed so a phase change replays the enter.
2902
+ /* @__PURE__ */ p("p", { className: "aegis-swap-widget__hint", role: "note", children: [
2903
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__hint-icon", "aria-hidden": "true", children: /* @__PURE__ */ i(Jn, {}) }),
2904
+ e.approvalHint
2905
+ ] }, e.approvalHint)
2711
2906
  ) : null,
2712
- /* @__PURE__ */ r(
2907
+ /* @__PURE__ */ i(
2713
2908
  "button",
2714
2909
  {
2715
2910
  type: "submit",
@@ -2717,35 +2912,28 @@ function jr(t) {
2717
2912
  disabled: !e.canSubmit,
2718
2913
  "data-action": e.primaryAction,
2719
2914
  "data-busy": e.busy || void 0,
2720
- children: /* @__PURE__ */ r("span", { className: "aegis-swap-widget__submit-label", children: e.ctaLabel }, e.ctaLabel)
2915
+ children: /* @__PURE__ */ i("span", { className: "aegis-swap-widget__submit-label", children: e.ctaLabel }, e.ctaLabel)
2721
2916
  }
2722
2917
  )
2723
2918
  ]
2724
2919
  }
2725
2920
  ),
2726
- e.status === "success" && e.txHash && e.quote ? /* @__PURE__ */ m("p", { className: "aegis-swap-widget__success", role: "status", children: [
2727
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__success-check", "aria-hidden": "true", children: /* @__PURE__ */ r(at, {}) }),
2728
- "Swap complete · received ~",
2729
- Ee(e.quote.amountOut, e.outputToken.decimals),
2730
- " ",
2731
- e.outputToken.symbol
2732
- ] }) : null,
2733
- e.txHash && e.txExplorerHref ? /* @__PURE__ */ m(
2921
+ e.inlineTxExplorerHref ? /* @__PURE__ */ p(
2734
2922
  "a",
2735
2923
  {
2736
2924
  className: "aegis-swap-widget__tx",
2737
- href: e.txExplorerHref,
2925
+ href: e.inlineTxExplorerHref,
2738
2926
  target: "_blank",
2739
2927
  rel: "noreferrer",
2740
2928
  children: [
2741
2929
  "View transaction",
2742
- /* @__PURE__ */ r(Ln, {})
2930
+ /* @__PURE__ */ i(Mt, {})
2743
2931
  ]
2744
2932
  }
2745
2933
  ) : null,
2746
- /* @__PURE__ */ m("p", { className: "aegis-swap-widget__powered", children: [
2747
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__powered-prefix", children: "Powered by" }),
2748
- /* @__PURE__ */ m(
2934
+ /* @__PURE__ */ p("p", { className: "aegis-swap-widget__powered", children: [
2935
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__powered-prefix", children: "Powered by" }),
2936
+ /* @__PURE__ */ p(
2749
2937
  "a",
2750
2938
  {
2751
2939
  className: "aegis-swap-widget__powered-link",
@@ -2753,8 +2941,8 @@ function jr(t) {
2753
2941
  target: "_blank",
2754
2942
  rel: "noreferrer",
2755
2943
  children: [
2756
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__powered-mark", children: /* @__PURE__ */ r(yi, {}) }),
2757
- /* @__PURE__ */ r("span", { className: "aegis-swap-widget__powered-brand", children: "AEGIS" })
2944
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__powered-mark", children: /* @__PURE__ */ i(Wi, {}) }),
2945
+ /* @__PURE__ */ i("span", { className: "aegis-swap-widget__powered-brand", children: "AEGIS" })
2758
2946
  ]
2759
2947
  }
2760
2948
  )
@@ -2763,75 +2951,75 @@ function jr(t) {
2763
2951
  }
2764
2952
  );
2765
2953
  }
2766
- const as = jr;
2954
+ const Ls = Ts;
2767
2955
  export {
2768
- ss as AEGIS_DYNAMIC_FEE_FLAG,
2769
- si as AEGIS_SWAP_CHAINS,
2770
- sn as AEGIS_SWAP_CHAIN_ID,
2771
- os as AEGIS_SWAP_DEFAULT_FEE_BPS,
2772
- ls as AEGIS_SWAP_DEFAULT_FEE_RECIPIENT,
2773
- cs as AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT,
2774
- on as AEGIS_SWAP_DEFAULT_POOL_IDS,
2775
- us as AEGIS_SWAP_DEFAULT_RPC_URLS,
2776
- ds as AEGIS_SWAP_HOOK,
2777
- ps as AEGIS_SWAP_MAINNET_CHAIN,
2778
- fs as AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS,
2779
- li as AEGIS_SWAP_MARKETS,
2780
- hs as AEGIS_SWAP_PERMIT2,
2781
- ms as AEGIS_SWAP_ROUTER,
2782
- ln as AEGIS_SWAP_TOKENS,
2783
- gs as AEGIS_SWAP_V4_QUOTER,
2784
- jr as AegisDirectSwapWidget,
2785
- Kr as AegisSwapProgressRail,
2786
- ns as AegisSwapToaster,
2787
- as as AegisSwapWidget,
2788
- Ga as DEFAULT_PERMIT_EXPIRATION_SECONDS,
2789
- ws as MAX_UINT128,
2790
- ys as MAX_UINT160,
2791
- bs as MAX_UINT256,
2792
- _s as PERMIT2_FAR_FUTURE_EXPIRATION,
2793
- Cn as SWAP_TX_DEADLINE_SECONDS,
2794
- vs as UNISWAP_V4_CONTRACTS_BY_CHAIN,
2795
- he as aegisToast,
2796
- Za as approveErc20ToPermit2,
2797
- Va as approvePermit2ToRouter,
2798
- Is as assertUint128,
2799
- Xa as buildExactInSwapTransaction,
2800
- ja as buildExactOutSwapTransaction,
2801
- za as buildSignedPermitBatch,
2802
- Ss as computePoolId,
2803
- As as createAegisSwapChainConfig,
2804
- ri as createAegisSwapChains,
2805
- oi as createAegisSwapMarketsFromPools,
2806
- Es as createAegisSwapPoolMarket,
2807
- xs as createAegisSwapUniswapV4Contracts,
2808
- ci as createSwapPublicClient,
2809
- jr as default,
2810
- Ae as errorMessage,
2811
- Rn as fetchDirectSwapQuote,
2812
- ei as fetchGlobalTokenMetadata,
2813
- It as getExplorerUrl,
2814
- Ps as getIchiIconGuess,
2815
- gt as getInjectedProvider,
2816
- ii as getProviderAccount,
2817
- ke as getProviderChainId,
2818
- Ts as getZeroForOne,
2819
- Nn as isBusy,
2820
- Fe as isDocumentVisible,
2821
- Ns as isEip1193Provider,
2822
- Ha as isUserRejectedError,
2823
- ui as normalizeAccount,
2824
- ni as normalizeWalletConnection,
2825
- Ka as outputFeeForQuote,
2826
- On as pollUntil,
2827
- vt as quoteSpendAmount,
2828
- Mn as readPermit2RouterAllowance,
2829
- Qa as reconcileSubmitQuote,
2830
- ai as requestProviderAccount,
2831
- $a as resolveTokenIconUrl,
2832
- rn as retryOnError,
2833
- Ja as sameQuote,
2834
- ti as subscribeProvider,
2835
- Ya as switchProviderChain,
2836
- di as transactionProgressView
2956
+ $s as AEGIS_DYNAMIC_FEE_FLAG,
2957
+ Ni as AEGIS_SWAP_CHAINS,
2958
+ _n as AEGIS_SWAP_CHAIN_ID,
2959
+ Ws as AEGIS_SWAP_DEFAULT_FEE_BPS,
2960
+ Hs as AEGIS_SWAP_DEFAULT_FEE_RECIPIENT,
2961
+ Vs as AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT,
2962
+ In as AEGIS_SWAP_DEFAULT_POOL_IDS,
2963
+ qs as AEGIS_SWAP_DEFAULT_RPC_URLS,
2964
+ Gs as AEGIS_SWAP_HOOK,
2965
+ zs as AEGIS_SWAP_MAINNET_CHAIN,
2966
+ Ks as AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS,
2967
+ Ti as AEGIS_SWAP_MARKETS,
2968
+ js as AEGIS_SWAP_PERMIT2,
2969
+ Xs as AEGIS_SWAP_ROUTER,
2970
+ Sn as AEGIS_SWAP_TOKENS,
2971
+ Ys as AEGIS_SWAP_V4_QUOTER,
2972
+ Ts as AegisDirectSwapWidget,
2973
+ Ps as AegisSwapProgressRail,
2974
+ ks as AegisSwapToaster,
2975
+ Ls as AegisSwapWidget,
2976
+ fi as DEFAULT_PERMIT_EXPIRATION_SECONDS,
2977
+ Qs as MAX_UINT128,
2978
+ Zs as MAX_UINT160,
2979
+ Js as MAX_UINT256,
2980
+ eo as PERMIT2_FAR_FUTURE_EXPIRATION,
2981
+ Gn as SWAP_TX_DEADLINE_SECONDS,
2982
+ to as UNISWAP_V4_CONTRACTS_BY_CHAIN,
2983
+ ye as aegisToast,
2984
+ yi as approveErc20ToPermit2,
2985
+ pi as approvePermit2ToRouter,
2986
+ no as assertUint128,
2987
+ mi as buildExactInSwapTransaction,
2988
+ gi as buildExactOutSwapTransaction,
2989
+ ui as buildSignedPermitBatch,
2990
+ ao as computePoolId,
2991
+ io as createAegisSwapChainConfig,
2992
+ xi as createAegisSwapChains,
2993
+ Pi as createAegisSwapMarketsFromPools,
2994
+ ro as createAegisSwapPoolMarket,
2995
+ so as createAegisSwapUniswapV4Contracts,
2996
+ Ci as createSwapPublicClient,
2997
+ Ts as default,
2998
+ Re as errorMessage,
2999
+ Kn as fetchDirectSwapQuote,
3000
+ _i as fetchGlobalTokenMetadata,
3001
+ jn as getExplorerUrl,
3002
+ oo as getIchiIconGuess,
3003
+ Et as getInjectedProvider,
3004
+ Ei as getProviderAccount,
3005
+ Ke as getProviderChainId,
3006
+ lo as getZeroForOne,
3007
+ qn as isBusy,
3008
+ ze as isDocumentVisible,
3009
+ co as isEip1193Provider,
3010
+ di as isUserRejectedError,
3011
+ Mi as normalizeAccount,
3012
+ Si as normalizeWalletConnection,
3013
+ hi as outputFeeForQuote,
3014
+ Xn as pollUntil,
3015
+ Tt as quoteSpendAmount,
3016
+ zn as readPermit2RouterAllowance,
3017
+ bi as reconcileSubmitQuote,
3018
+ Ai as requestProviderAccount,
3019
+ li as resolveTokenIconUrl,
3020
+ vn as retryOnError,
3021
+ vi as sameQuote,
3022
+ Ii as subscribeProvider,
3023
+ wi as switchProviderChain,
3024
+ Ri as transactionProgressView
2837
3025
  };