@glacislabs/stablegenie-zerodelta 4.11.0 → 4.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mount.cjs CHANGED
@@ -1717,7 +1717,7 @@ var CHANNEL_HEADER = "x-zd-channel";
1717
1717
  var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
1718
1718
  var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
1719
1719
  var WIDGET_CHANNEL = "widget";
1720
- var WIDGET_VERSION = "4.11.0" ;
1720
+ var WIDGET_VERSION = "4.12.0" ;
1721
1721
  var MAX_CHANNEL_VERSION_LEN = 32;
1722
1722
  function sanitizeVersion(raw) {
1723
1723
  const v = String(raw).trim();
@@ -1988,6 +1988,7 @@ function createApiClient(cfg) {
1988
1988
  const missing = wanted.filter((s) => !nowFresh(priceCache.get(s) ?? null));
1989
1989
  if (missing.length) {
1990
1990
  let prices = {};
1991
+ let answered = true;
1991
1992
  try {
1992
1993
  const snapshot = await apiRequest(`/prices?symbols=${encodeURIComponent(missing.join(","))}`, {
1993
1994
  timeoutMs: 8e3
@@ -1995,9 +1996,10 @@ function createApiClient(cfg) {
1995
1996
  prices = snapshot && typeof snapshot === "object" && !snapshot.stale && snapshot.prices && typeof snapshot.prices === "object" ? snapshot.prices : {};
1996
1997
  } catch {
1997
1998
  prices = {};
1999
+ answered = false;
1998
2000
  }
1999
2001
  const at = Date.now();
2000
- for (const s of missing) {
2002
+ for (const s of answered ? missing : []) {
2001
2003
  const n = Number(prices[s]);
2002
2004
  priceCache.set(s, { at, value: Number.isFinite(n) && n > 0 ? n : null });
2003
2005
  }
@@ -3737,46 +3739,79 @@ img.sg-tok-badge{width:16px;padding:0;object-fit:cover;background:var(--sg-bg)}
3737
3739
  .sg-pct:hover:not(:disabled){color:var(--sg-accent)}
3738
3740
  .sg-pct:disabled{opacity:.55;cursor:not-allowed}
3739
3741
 
3740
- /* full-panel token selector (Exchange from / Exchange to) */
3742
+ /* full-panel takeover head (transaction history) */
3741
3743
  .sg-sel-head{display:flex;align-items:center;margin-bottom:14px}
3742
3744
  .sg-back{width:32px;height:32px;flex:0 0 auto;border:none;border-radius:999px;background:transparent;color:var(--sg-text);cursor:pointer;font:inherit;display:flex;align-items:center;justify-content:center;transition:background 120ms ease}
3743
3745
  .sg-back:hover{background:var(--sg-surface)}
3744
3746
  .sg-sel-title{flex:1 1 auto;min-width:0;text-align:center;font-size:15px;font-weight:600;margin-right:32px}
3745
3747
  /* Whose transactions these are \u2014 history is per wallet, and the takeover hides the header's pill. */
3746
3748
  .sg-sel-sub{display:block;font-size:11px;font-weight:600;color:var(--sg-text-muted);margin-top:1px}
3747
- /* Scrolls at ~2.5 rows. The catalogue's destination chains outnumber its source chains three to one
3748
- (9 escrow chains, ~37 total), so an ungated grid was eight rows tall and pushed the token list \u2014
3749
- the thing the panel exists for \u2014 below the fold. The fade is a scroll affordance, not decoration. */
3750
- .sg-chain-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:8px;margin-bottom:12px;max-height:124px;overflow-y:auto;scrollbar-width:thin;padding-bottom:2px;mask-image:linear-gradient(to bottom,#000 calc(100% - 14px),transparent);-webkit-mask-image:linear-gradient(to bottom,#000 calc(100% - 14px),transparent)}
3751
- /* No mask once everything fits \u2014 a fade under a grid with nothing below it reads as a rendering bug. */
3752
- .sg-chain-grid[data-scroll="false"]{mask-image:none;-webkit-mask-image:none;overflow-y:visible;max-height:none}
3753
- .sg-chain-chip{height:44px;border-radius:var(--sg-radius-control);border:1px solid var(--sg-border);background:var(--sg-surface);color:var(--sg-text);display:flex;align-items:center;justify-content:center;cursor:pointer;font:inherit;font-size:10px;font-weight:700;letter-spacing:.02em;transition:border-color 120ms ease,background 120ms ease;overflow:hidden}
3754
- .sg-chain-chip img{width:22px;height:22px;border-radius:999px;display:block}
3755
- .sg-chain-chip:hover{border-color:color-mix(in srgb,var(--sg-accent) 45%,var(--sg-border))}
3756
- .sg-chain-chip[data-selected="true"]{border-color:var(--sg-accent);background:color-mix(in srgb,var(--sg-accent) 10%,var(--sg-surface))}
3757
- .sg-search{position:relative;margin-bottom:10px}
3758
- .sg-search svg{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:var(--sg-text-muted);pointer-events:none}
3759
- .sg-search input{width:100%;padding:11px 12px 11px 38px;background:var(--sg-surface);color:var(--sg-text);border:1px solid var(--sg-border);border-radius:var(--sg-radius-control);font:inherit;font-size:14px;outline:none;transition:border-color 120ms ease}
3760
- .sg-search input:focus{border-color:var(--sg-accent)}
3761
3749
  .sg-toklist{display:flex;flex-direction:column;gap:2px;max-height:320px;overflow-y:auto;margin:0 -6px;padding:0 6px;scrollbar-width:thin}
3762
- .sg-tokrow{display:flex;align-items:center;gap:12px;padding:10px 8px;border:none;border-radius:var(--sg-radius-control);background:transparent;color:var(--sg-text);cursor:pointer;font:inherit;text-align:left;transition:background 120ms ease}
3763
- .sg-tokrow:hover{background:var(--sg-surface)}
3764
- .sg-tokrow-main{flex:1 1 auto;min-width:0}
3765
- .sg-tokrow-sym{display:block;font-size:15px;font-weight:700;line-height:1.2}
3766
- .sg-tokrow-name{display:block;font-size:12px;color:var(--sg-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
3767
- .sg-tokrow-end{flex:0 0 auto;text-align:right}
3768
- .sg-tokrow-bal{display:block;font-size:13px;font-weight:600;font-variant-numeric:tabular-nums}
3769
- .sg-tokrow-chain{display:block;font-size:11px;color:var(--sg-text-muted)}
3770
- /* funding rows the wallet can't cover (zero / insufficient): greyed, non-interactive, reason hint.
3771
- Mirrors RouteList's data-short dim + warn tone; no hover lift. Theme-aware via --sg-* vars. */
3772
- .sg-tokrow--off,.sg-tokrow[disabled]{opacity:.5;cursor:not-allowed}
3773
- .sg-tokrow--off:hover,.sg-tokrow[disabled]:hover{background:transparent}
3774
- .sg-tokrow--off .sg-tokrow-sym,.sg-tokrow--off .sg-tokrow-name,.sg-tokrow--off .sg-tokrow-bal{color:var(--sg-text-muted)}
3775
- .sg-tokrow-hint{display:block;font-size:11px;font-weight:600;color:var(--sg-danger)}
3776
- /* on a row that stays selectable (a limited lane): a caveat, not a refusal */
3777
- .sg-tokrow-hint[data-tone="note"]{color:var(--sg-text-muted)}
3778
3750
  .sg-sel-empty{padding:26px 10px;text-align:center;font-size:13px;color:var(--sg-text-muted)}
3779
3751
 
3752
+ /* Token picker, token first then network \u2014 the ZeroDelta dapp's TokenSelectModal (Figma 708:27430,
3753
+ 2517:52576), drawn in the widget's own theme: the dapp's brand tint is the accent, its green the
3754
+ success token. Geometry is the dapp's: 32px plates, 24px row plates, 16px chain marks, 20px gaps. The list keeps
3755
+ the previous picker's 320px cap so opening it does not grow the card. */
3756
+ .sg-pk{display:flex;flex-direction:column;gap:20px}
3757
+ .sg-pk-head{display:flex;align-items:center;justify-content:space-between;gap:8px}
3758
+ .sg-pk-title{font-family:var(--sg-font-display);font-size:16px;font-weight:600;line-height:1.2;letter-spacing:.32px;color:var(--sg-t90)}
3759
+ .sg-pk-close,.sg-pk-clear{display:grid;place-items:center;flex:0 0 auto;padding:6px;border:none;border-radius:8px;background:transparent;color:var(--sg-text-muted);cursor:pointer}
3760
+ .sg-pk-clear{padding:2px}
3761
+ .sg-pk-close:hover,.sg-pk-clear:hover{color:var(--sg-text)}
3762
+ .sg-pk-backlink{display:flex;align-items:center;gap:10px;padding:0;border:none;border-radius:8px;background:transparent;color:var(--sg-t60);font:inherit;font-size:16px;font-weight:500;line-height:1.2;cursor:pointer}
3763
+ .sg-pk-backlink:hover{color:var(--sg-text)}
3764
+ .sg-pk-intro{display:flex;flex-direction:column;gap:4px}
3765
+ .sg-pk-lead{margin:0;font-size:14px;line-height:1.3;color:var(--sg-text-muted)}
3766
+ .sg-pk-search{display:flex;align-items:center;gap:16px;width:100%;padding:16px;border:1px solid color-mix(in srgb,var(--sg-accent) 12%,transparent);border-radius:16px;background:var(--sg-surface);color:var(--sg-text-muted);cursor:text;transition:border-color 120ms ease}
3767
+ .sg-pk-search:focus-within{border-color:var(--sg-accent);color:var(--sg-accent)}
3768
+ .sg-pk-search input{flex:1 1 auto;min-width:0;padding:0;border:none;background:transparent;color:var(--sg-t90);font:inherit;font-size:15px;line-height:1.2;outline:none}
3769
+ .sg-pk-search input::placeholder{color:var(--sg-text-muted)}
3770
+ .sg-pk-body{display:flex;flex-direction:column;gap:8px}
3771
+ .sg-pk-selected{display:flex;flex-direction:column;gap:8px;margin-bottom:8px}
3772
+ .sg-pk-cap{margin:0;font-size:12px;line-height:1.2;color:var(--sg-text-muted)}
3773
+ .sg-pk-list{display:flex;flex-direction:column;gap:4px;max-height:320px;overflow-y:auto;margin:-1px;padding:1px;scrollbar-width:thin}
3774
+ .sg-pk-row{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:16px;border:none;border-radius:24px;background:color-mix(in srgb,var(--sg-accent) 4%,transparent);color:var(--sg-text);font:inherit;text-align:left;cursor:pointer;transition:background 120ms ease}
3775
+ .sg-pk-row:hover{background:color-mix(in srgb,var(--sg-accent) 8%,transparent)}
3776
+ .sg-pk-row--net{padding:20px 16px}
3777
+ .sg-pk-row[data-zero]{background:color-mix(in srgb,var(--sg-text) 4%,transparent)}
3778
+ .sg-pk-row[data-zero]:hover{background:color-mix(in srgb,var(--sg-accent) 4%,transparent)}
3779
+ .sg-pk-row[data-selected]{background:color-mix(in srgb,var(--sg-success) 6%,transparent)}
3780
+ .sg-pk-row[data-selected]:hover{background:color-mix(in srgb,var(--sg-success) 8%,transparent)}
3781
+ .sg-pk-row--off{opacity:.6;cursor:default}
3782
+ .sg-pk-row--off:hover{background:color-mix(in srgb,var(--sg-accent) 4%,transparent)}
3783
+ .sg-pk-row:focus-visible,.sg-pk-close:focus-visible,.sg-pk-backlink:focus-visible,.sg-pk-clear:focus-visible{outline:2px solid color-mix(in srgb,var(--sg-accent) 30%,transparent);outline-offset:2px}
3784
+ .sg-pk-left{display:flex;align-items:center;gap:12px;flex:1 1 auto;min-width:0}
3785
+ .sg-pk-text{display:flex;flex-direction:column;align-items:flex-start;gap:2px;flex:1 1 auto;min-width:0;overflow:hidden}
3786
+ .sg-pk-label{font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
3787
+ .sg-pk-alt{margin-left:8px;font-size:14px;font-weight:400;color:var(--sg-text-muted)}
3788
+ .sg-pk-line{display:flex;align-items:center;gap:4px;min-width:0;max-width:100%}
3789
+ .sg-pk-sub{flex:0 1 auto;font-size:14px;line-height:1.3;color:var(--sg-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
3790
+ .sg-pk-note{font-size:13px;line-height:1.3;color:var(--sg-text-muted)}
3791
+ .sg-pk-plate,.sg-pk-chainwrap{position:relative;display:grid;place-items:center;flex:0 0 auto;width:32px;height:32px}
3792
+ .sg-pk-plate-in{display:grid;place-items:center;width:32px;height:32px;overflow:hidden;border-radius:16px;background:var(--sg-surface)}
3793
+ .sg-pk-plate-in img{width:32px;height:32px;display:block;object-fit:cover}
3794
+ .sg-pk-plate-fb{font-size:10px;font-weight:700;color:var(--sg-accent)}
3795
+ .sg-pk-plate[data-muted] .sg-pk-plate-in{filter:grayscale(1)}
3796
+ .sg-pk-tick{position:absolute;right:-1px;bottom:-1px;display:grid;place-items:center;width:14px;height:14px;border-radius:999px;background:var(--sg-surface);color:var(--sg-success)}
3797
+ .sg-pk-chain{display:grid;place-items:center;width:32px;height:32px;overflow:hidden;border-radius:999px;background:var(--sg-surface);font-size:9px;font-weight:700;color:var(--sg-text-muted)}
3798
+ .sg-pk-chain img{width:32px;height:32px;display:block;object-fit:cover}
3799
+ .sg-pk-marks{display:flex;align-items:center;gap:4px;flex:0 0 auto}
3800
+ .sg-pk-stack{display:flex;align-items:center;height:18px}
3801
+ .sg-pk-markwrap{display:grid;flex:0 0 auto}
3802
+ .sg-pk-markwrap+.sg-pk-markwrap{margin-left:-2px}
3803
+ .sg-pk-mark{display:grid;place-items:center;width:16px;height:16px;overflow:hidden;border-radius:999px;background:var(--sg-surface);font-size:5px;font-weight:700;color:var(--sg-text-muted)}
3804
+ .sg-pk-mark img{width:16px;height:16px;display:block;object-fit:cover}
3805
+ .sg-pk-more{font-size:14px;line-height:1.3;color:var(--sg-text-muted)}
3806
+ .sg-pk-chev{display:grid;place-items:center;flex:0 0 auto;width:16px;height:16px;color:var(--sg-text-muted)}
3807
+ .sg-pk-chev svg{width:16px;height:16px}
3808
+ .sg-pk-chev--sm,.sg-pk-chev--sm svg{width:14px;height:14px}
3809
+ .sg-pk-bal{display:flex;flex-direction:column;align-items:flex-end;justify-content:center;gap:4px;min-height:36px;flex:0 0 auto;text-align:right}
3810
+ .sg-pk-bal-usd{font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
3811
+ .sg-pk-bal-amt{font-size:13px;line-height:1.4;color:var(--sg-text-muted)}
3812
+ .sg-pk-bal-zero{flex:0 0 auto;font-size:16px;font-weight:700;color:var(--sg-t35)}
3813
+ .sg-pk-empty{margin:0;padding:32px 0;text-align:center;font-size:14px;color:var(--sg-text-muted)}
3814
+
3780
3815
  /* wide (duo) layout: main card + receive/routes side card. The collapse is keyed to the WIDGET'S
3781
3816
  OWN available width (container query) \u2014 an embedded widget cannot infer the host layout from the
3782
3817
  viewport. The viewport media query stays as a fallback for engines without container queries. */
@@ -4723,6 +4758,200 @@ function chainLogoCandidates(chainId, logoUrl) {
4723
4758
  if (bundled) out.push(bundled);
4724
4759
  return out;
4725
4760
  }
4761
+
4762
+ // src/react/ui/tokenGroups.ts
4763
+ var rowKey = (t) => `${Number(t.chainId)}:${String(t.address || "").toLowerCase()}`;
4764
+ var CHAIN_TVL_ORDER = [
4765
+ 1,
4766
+ 1151111081099710,
4767
+ 8453,
4768
+ 56,
4769
+ 42161,
4770
+ 999,
4771
+ 143,
4772
+ 4663,
4773
+ 137,
4774
+ 9745,
4775
+ 43114,
4776
+ 10,
4777
+ 196,
4778
+ 57073,
4779
+ 14,
4780
+ 5e3,
4781
+ 2818,
4782
+ 30,
4783
+ 4217,
4784
+ 747474,
4785
+ 1672,
4786
+ 988,
4787
+ 480,
4788
+ 81457,
4789
+ 1329,
4790
+ 80094,
4791
+ 130,
4792
+ 4326,
4793
+ 59144,
4794
+ 2222,
4795
+ 252,
4796
+ 146,
4797
+ 324,
4798
+ 1776,
4799
+ 534352,
4800
+ 1030,
4801
+ 1868,
4802
+ 98866,
4803
+ 169,
4804
+ 1088,
4805
+ 50,
4806
+ 34443,
4807
+ 1135,
4808
+ 88,
4809
+ 48900,
4810
+ 151,
4811
+ 7777777,
4812
+ 1923,
4813
+ 3343,
4814
+ 81224,
4815
+ 21e6
4816
+ ];
4817
+ var TOKEN_MARKET_CAP_ORDER = ["USDT", "USDC", "USDS", "DAI", "USDE", "USD1", "USDG", "PYUSD", "XAUT", "RLUSD", "USDF", "GHO", "USD0", "USDTB", "AUSD", "WM"];
4818
+ var CHAIN_RANK = new Map(CHAIN_TVL_ORDER.map((chainId, index) => [chainId, index]));
4819
+ var TOKEN_RANK = new Map(TOKEN_MARKET_CAP_ORDER.map((symbol, index) => [symbol, index]));
4820
+ function chainTvlRank(chainId) {
4821
+ return CHAIN_RANK.get(Number(chainId)) ?? CHAIN_TVL_ORDER.length;
4822
+ }
4823
+ function tokenMarketCapRank(symbol) {
4824
+ return TOKEN_RANK.get(String(symbol).toUpperCase()) ?? TOKEN_MARKET_CAP_ORDER.length;
4825
+ }
4826
+ function dominantSymbol(tokens) {
4827
+ const counts = /* @__PURE__ */ new Map();
4828
+ for (const t of tokens) counts.set(t.symbol, (counts.get(t.symbol) ?? 0) + 1);
4829
+ let best = tokens[0].symbol;
4830
+ for (const [symbol, count] of counts) if (count > (counts.get(best) ?? 0)) best = symbol;
4831
+ return best;
4832
+ }
4833
+ function priceOf(prices, symbol) {
4834
+ const p = prices?.[String(symbol).toUpperCase()];
4835
+ return typeof p === "number" && Number.isFinite(p) ? p : void 0;
4836
+ }
4837
+ function buildGroup(key, members, prices) {
4838
+ const tokens = members.map((m) => m.token);
4839
+ let amount = null;
4840
+ let usd2 = null;
4841
+ for (const m of members) {
4842
+ if (m.balance == null) continue;
4843
+ amount = (amount ?? 0) + m.balance;
4844
+ const price = priceOf(prices, m.token.symbol);
4845
+ if (price !== void 0) usd2 = (usd2 ?? 0) + m.balance * price;
4846
+ }
4847
+ const first = members[0].token;
4848
+ return {
4849
+ key,
4850
+ symbol: dominantSymbol(tokens),
4851
+ name: String(first.name || first.symbol),
4852
+ logoUrl: first.logoUrl,
4853
+ deployments: members,
4854
+ unavailable: members.every((m) => m.disabled) ? { reason: members.find((m) => m.reason)?.reason } : null,
4855
+ amount,
4856
+ usd: usd2
4857
+ };
4858
+ }
4859
+ function byDeployment(a, b) {
4860
+ return Number(a.disabled) - Number(b.disabled) || (b.balance ?? 0) - (a.balance ?? 0) || chainTvlRank(a.token.chainId) - chainTvlRank(b.token.chainId);
4861
+ }
4862
+ function byPickability(a, b) {
4863
+ const zero = (g) => g.amount === 0 ? 1 : 0;
4864
+ return Number(!!a.unavailable) - Number(!!b.unavailable) || zero(a) - zero(b) || (b.usd ?? b.amount ?? 0) - (a.usd ?? a.amount ?? 0) || tokenMarketCapRank(a.symbol) - tokenMarketCapRank(b.symbol);
4865
+ }
4866
+ function groupDeployments(deployments, prices) {
4867
+ const order = [];
4868
+ const members = /* @__PURE__ */ new Map();
4869
+ for (const d of [...deployments].sort(byDeployment)) {
4870
+ const key = String(d.token.symbol).toUpperCase();
4871
+ const list = members.get(key);
4872
+ if (list) list.push(d);
4873
+ else {
4874
+ members.set(key, [d]);
4875
+ order.push(key);
4876
+ }
4877
+ }
4878
+ return order.map((key) => buildGroup(key, members.get(key), prices)).sort(byPickability);
4879
+ }
4880
+ var CHAIN_ALIASES = {
4881
+ 56: ["bsc", "binance"],
4882
+ 137: ["matic"],
4883
+ 43114: ["avax"]
4884
+ };
4885
+ function labelForms(label) {
4886
+ const lower2 = label.trim().toLowerCase();
4887
+ if (!lower2) return [];
4888
+ const compact = lower2.replace(/[^a-z0-9]/g, "");
4889
+ return compact && compact !== lower2 ? [lower2, compact] : [lower2];
4890
+ }
4891
+ function buildChainSearchTerms(chains) {
4892
+ const byId = /* @__PURE__ */ new Map();
4893
+ const ids = /* @__PURE__ */ new Set([...chains.map((c) => Number(c.chainId)), ...Object.keys(CHAIN_LABELS).map(Number)]);
4894
+ for (const id of ids) {
4895
+ const chain = chains.find((c) => Number(c.chainId) === id);
4896
+ const terms = /* @__PURE__ */ new Set();
4897
+ for (const label of [chain?.displayName, chain?.name, typeof chain?.slug === "string" ? chain.slug : void 0, CHAIN_LABELS[id]]) {
4898
+ if (label) for (const form of labelForms(label)) terms.add(form);
4899
+ }
4900
+ for (const alias of CHAIN_ALIASES[id] ?? []) terms.add(alias);
4901
+ byId.set(id, [...terms]);
4902
+ }
4903
+ return byId;
4904
+ }
4905
+ function splitSearchTerms(query) {
4906
+ return query.trim().toLowerCase().split(/\s+/).filter(Boolean);
4907
+ }
4908
+ function looksLikeAddress(term) {
4909
+ return /^(0x)?[0-9a-f]{4,}$/.test(term);
4910
+ }
4911
+ function chainMatches(term, token, chainTerms) {
4912
+ if (term === String(Number(token.chainId))) return true;
4913
+ return chainTerms.some((chainTerm) => chainTerm.includes(term));
4914
+ }
4915
+ function tokenMatches(term, token, asset) {
4916
+ return asset.symbol.toLowerCase().includes(term) || asset.name.toLowerCase().includes(term) || String(token.symbol || "").toLowerCase().includes(term) || // `₮` is not on a keyboard: both sides fold it to `T`, so "usdt0" finds USD₮0.
4917
+ foldTicker(tokenTicker(token)).includes(foldTicker(term)) || String(token.name || "").toLowerCase().includes(term) || looksLikeAddress(term) && String(token.address || "").toLowerCase().includes(term);
4918
+ }
4919
+ function matchingDeployments(terms, group, chainTerms) {
4920
+ if (terms.length === 0) return group.deployments;
4921
+ return group.deployments.filter((d) => {
4922
+ const ct = chainTerms.get(Number(d.token.chainId)) ?? [];
4923
+ return terms.every((term) => tokenMatches(term, d.token, group) || chainMatches(term, d.token, ct));
4924
+ });
4925
+ }
4926
+ function searchGroups(groups, query, chainTerms, prices) {
4927
+ const terms = splitSearchTerms(query);
4928
+ if (terms.length === 0) return groups;
4929
+ const rows = [];
4930
+ for (const g of groups) {
4931
+ const members = matchingDeployments(terms, g, chainTerms);
4932
+ if (members.length === 0) continue;
4933
+ rows.push(members.length === g.deployments.length ? g : buildGroup(g.key, members, prices));
4934
+ }
4935
+ return rows.sort(byPickability);
4936
+ }
4937
+ function groupDecimal2(value) {
4938
+ const match = value.match(/^([+-]?)(\d+)(\.\d+)?$/);
4939
+ if (!match) return value;
4940
+ return `${match[1]}${match[2].replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${match[3] ?? ""}`;
4941
+ }
4942
+ function humanAmount(n, maxFrac = 6) {
4943
+ if (!Number.isFinite(n)) return String(n);
4944
+ if (n === 0) return "0";
4945
+ const digits = Math.min(Math.max(0, Math.trunc(maxFrac)), 8);
4946
+ const fixed = n.toFixed(digits);
4947
+ const out = fixed.includes(".") ? fixed.replace(/\.?0+$/, "") : fixed;
4948
+ if (Number(out) === 0) return `<${digits > 0 ? `0.${"0".repeat(digits - 1)}1` : "1"}`;
4949
+ return groupDecimal2(out);
4950
+ }
4951
+ function formatBalanceUsd(value) {
4952
+ if (!Number.isFinite(value) || value <= 0) return "$0.00";
4953
+ return value < 0.01 ? "<$0.01" : `$${value.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
4954
+ }
4726
4955
  var CHAIN_SHORT = {
4727
4956
  1: "ETH",
4728
4957
  10: "OP",
@@ -4804,103 +5033,280 @@ function FundingTile(props) {
4804
5033
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tile-main", children: main })
4805
5034
  ] });
4806
5035
  }
4807
- function ChainChip(props) {
5036
+ function ChainMark(props) {
4808
5037
  const [failed, setFailed] = react.useState([]);
4809
- const src = chainLogoCandidates(props.chain?.chainId, props.chain?.logoUrl).find((u) => !failed.includes(u));
4810
- const name = props.name ?? props.label;
4811
- return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-chain-chip", "data-selected": props.selected, title: name, "aria-label": name, "aria-pressed": props.selected, onClick: props.onClick, children: src ? /* @__PURE__ */ jsxRuntime.jsx("img", { src, alt: "", loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : props.label });
5038
+ const src = chainLogoCandidates(props.chainId, props.chain?.logoUrl).find((u) => !failed.includes(u));
5039
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: props.size === "row" ? "sg-pk-chain" : "sg-pk-mark", "aria-hidden": "true", children: src ? /* @__PURE__ */ jsxRuntime.jsx("img", { src, alt: "", loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: chainBadge(props.chainId) }) });
5040
+ }
5041
+ var MARK_LIMIT = 3;
5042
+ function ChainMarks(props) {
5043
+ const ids = props.chainIds;
5044
+ if (!ids.length) return null;
5045
+ const shown = ids.slice(0, MARK_LIMIT);
5046
+ const overflow = ids.length - shown.length;
5047
+ const marks = shown.map((id) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-markwrap", children: /* @__PURE__ */ jsxRuntime.jsx(ChainMark, { chainId: id, chain: props.chainById.get(id), size: "mini" }) }, id));
5048
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-marks", children: [
5049
+ props.decorative ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-stack", "aria-hidden": "true", children: marks }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-stack", role: "img", "aria-label": `${ids.length} ${ids.length === 1 ? "network" : "networks"}`, children: marks }),
5050
+ overflow > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-more", "aria-hidden": "true", children: [
5051
+ "+",
5052
+ overflow
5053
+ ] }) : null
5054
+ ] });
5055
+ }
5056
+ function TokenPlate(props) {
5057
+ const [failed, setFailed] = react.useState([]);
5058
+ const src = tokenLogoCandidates(props.symbol, props.logoUrl).find((u) => !failed.includes(u));
5059
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-plate", "data-muted": props.muted || void 0, children: [
5060
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-plate-in", children: src ? /* @__PURE__ */ jsxRuntime.jsx("img", { src, alt: "", loading: "lazy", onError: () => setFailed((f) => [...f, src]) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-plate-fb", children: props.symbol.slice(0, 4) }) }),
5061
+ props.checked ? /* @__PURE__ */ jsxRuntime.jsx(TickBadge, {}) : null
5062
+ ] });
5063
+ }
5064
+ function TickBadge() {
5065
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-tick", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
5066
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "11", fill: "currentColor" }),
5067
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m7 12.5 3.2 3.2L17 9", stroke: "#fff", strokeWidth: "2.6", strokeLinecap: "round", strokeLinejoin: "round" })
5068
+ ] }) });
5069
+ }
5070
+ function BalanceColumn(props) {
5071
+ if (props.amount == null) return null;
5072
+ if (props.amount === 0) return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-zero", children: "0.00" });
5073
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-bal", children: [
5074
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-usd sg-mono", children: props.usd == null ? "\u2014" : formatBalanceUsd(props.usd) }),
5075
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-bal-amt sg-mono", children: [
5076
+ humanAmount(props.amount, 6),
5077
+ " ",
5078
+ props.symbol
5079
+ ] })
5080
+ ] });
5081
+ }
5082
+ var WALLET_STATE_REASONS = /* @__PURE__ */ new Set(["no-balance", "insufficient"]);
5083
+ function isPick(sel, t) {
5084
+ return !!sel && Number(sel.chainId) === Number(t.chainId) && String(sel.symbol).toUpperCase() === String(t.symbol).toUpperCase();
5085
+ }
5086
+ function usdOf(balance, prices, symbol) {
5087
+ const price = priceOf(prices, symbol);
5088
+ return balance == null || price === void 0 ? null : balance * price;
5089
+ }
5090
+ function UnavailableRow(props) {
5091
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-pk-row sg-pk-row--off", "data-testid": props.testId, "data-label": props.label, title: props.label, "aria-disabled": "true", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
5092
+ props.icon,
5093
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
5094
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-label", children: props.label }),
5095
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-sub", children: props.reason || "Not available right now" })
5096
+ ] })
5097
+ ] }) });
4812
5098
  }
4813
5099
  function SearchGlyph() {
4814
- return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", "aria-hidden": "true", children: [
5100
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", "aria-hidden": "true", children: [
4815
5101
  /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "11", cy: "11", r: "7" }),
4816
5102
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m20 20-3.5-3.5" })
4817
5103
  ] });
4818
5104
  }
4819
- function BackGlyph() {
4820
- return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "17", height: "17", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
5105
+ function CloseGlyph() {
5106
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", "aria-hidden": "true", children: [
5107
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6 6 18" }),
5108
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 6 12 12" })
5109
+ ] });
5110
+ }
5111
+ function ArrowLeftGlyph() {
5112
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
4821
5113
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 12H5" }),
4822
5114
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m12 19-7-7 7-7" })
4823
5115
  ] });
4824
5116
  }
4825
- var rowKey = (t) => `${Number(t.chainId)}:${String(t.address || "").toLowerCase()}`;
4826
5117
  function TokenSelect(props) {
4827
- const [chainFilter, setChainFilter] = react.useState(null);
5118
+ const side = props.side ?? "from";
4828
5119
  const [query, setQuery] = react.useState("");
4829
- const chains = react.useMemo(() => {
4830
- const listed = new Set(props.tokens.map((t) => Number(t.chainId)));
4831
- return props.chains.filter((c) => listed.has(Number(c.chainId)));
4832
- }, [props.chains, props.tokens]);
4833
- const activeFilter = chainFilter != null && chains.some((c) => Number(c.chainId) === chainFilter) ? chainFilter : null;
4834
- const rows = react.useMemo(() => {
4835
- const q = query.trim().toLowerCase();
4836
- const filtered = props.tokens.filter((t) => activeFilter == null ? true : Number(t.chainId) === activeFilter).filter((t) => {
4837
- if (!q) return true;
4838
- return String(t.symbol || "").toLowerCase().includes(q) || // The chain's own ticker too, with `₮` read as `T`: "usdt0" finds USD₮0.
4839
- foldTicker(tokenTicker(t)).includes(foldTicker(q)) || String(t.name || "").toLowerCase().includes(q) || String(t.address || "").toLowerCase().includes(q) || // Chain name too (2026-09-08): with ~37 destination chains most have no bundled mark and
4840
- // show a three-letter badge, so "Katana" or "Berachain" has to be findable by typing it.
4841
- String(CHAIN_LABELS[Number(t.chainId)] || "").toLowerCase().includes(q);
4842
- });
4843
- const off = (t) => props.optionStates?.[rowKey(t)]?.disabled ? 1 : 0;
4844
- const balNum = (t) => {
4845
- const n = Number(props.balances?.[rowKey(t)]?.formatted);
4846
- return Number.isFinite(n) ? n : 0;
5120
+ const [openKey, setOpenKey] = react.useState(null);
5121
+ const listRef = react.useRef(null);
5122
+ const savedScroll = react.useRef(0);
5123
+ const chainById2 = react.useMemo(() => new Map(props.chains.map((c) => [Number(c.chainId), c])), [props.chains]);
5124
+ const chainName3 = (chainId) => CHAIN_LABELS[chainId] || chainById2.get(chainId)?.displayName || chainById2.get(chainId)?.name || `Chain ${chainId}`;
5125
+ const showBalances = side === "from" && !!props.balances && Object.keys(props.balances).length > 0;
5126
+ const [prices, setPrices] = react.useState({});
5127
+ const symbolKey2 = react.useMemo(() => [...new Set(props.tokens.map((t) => String(t.symbol).toUpperCase()))].sort().join(","), [props.tokens]);
5128
+ const fetchPrices = props.fetchPrices;
5129
+ react.useEffect(() => {
5130
+ if (!showBalances || !fetchPrices || !symbolKey2) return;
5131
+ let alive = true;
5132
+ let timer2;
5133
+ const ask = (retriesLeft) => {
5134
+ fetchPrices(symbolKey2.split(",")).then((next) => {
5135
+ if (!alive) return;
5136
+ setPrices(next);
5137
+ if (!Object.keys(next).length && retriesLeft > 0) timer2 = setTimeout(() => ask(retriesLeft - 1), retriesLeft > 1 ? 5e3 : 2e4);
5138
+ }).catch(() => {
5139
+ });
4847
5140
  };
4848
- return [...filtered].sort((a, b) => off(a) - off(b) || balNum(b) - balNum(a));
4849
- }, [props.tokens, activeFilter, query, props.balances, props.optionStates]);
4850
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4851
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-sel-head", children: [
4852
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-back", onClick: props.onBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx(BackGlyph, {}) }),
4853
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-sel-title", children: props.title })
4854
- ] }),
4855
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-chain-grid", "data-scroll": chains.length > 14 ? void 0 : "false", role: "group", "aria-label": "Filter by chain", children: [
4856
- /* @__PURE__ */ jsxRuntime.jsx(ChainChip, { label: "All", selected: activeFilter == null, onClick: () => setChainFilter(null) }),
4857
- chains.map((c) => /* @__PURE__ */ jsxRuntime.jsx(
4858
- ChainChip,
4859
- {
4860
- chain: c,
4861
- label: chainBadge(Number(c.chainId)),
4862
- name: CHAIN_LABELS[Number(c.chainId)] || c.displayName || c.name || `Chain ${c.chainId}`,
4863
- selected: activeFilter === Number(c.chainId),
4864
- onClick: () => setChainFilter(Number(c.chainId))
4865
- },
4866
- c.chainId
4867
- ))
4868
- ] }),
4869
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-search", children: [
4870
- /* @__PURE__ */ jsxRuntime.jsx(SearchGlyph, {}),
4871
- /* @__PURE__ */ jsxRuntime.jsx("input", { autoFocus: true, placeholder: "Search by token, network or address", value: query, onChange: (e) => setQuery(e.target.value), spellCheck: false, "aria-label": "Search by token, network or address" })
4872
- ] }),
4873
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-toklist", role: "group", "aria-label": props.title, children: rows.length ? rows.map((t) => {
4874
- const chainId = Number(t.chainId);
4875
- const key = rowKey(t);
4876
- const bal = props.balances?.[key];
5141
+ ask(2);
5142
+ return () => {
5143
+ alive = false;
5144
+ if (timer2) clearTimeout(timer2);
5145
+ };
5146
+ }, [showBalances, fetchPrices, symbolKey2]);
5147
+ const groups = react.useMemo(() => {
5148
+ const deployments = [];
5149
+ for (const token of props.tokens) {
5150
+ const key = rowKey(token);
5151
+ const n = Number(props.balances?.[key]?.formatted);
4877
5152
  const st = props.optionStates?.[key];
4878
- const disabled = !!st?.disabled;
4879
- return /* @__PURE__ */ jsxRuntime.jsxs(
4880
- "button",
4881
- {
4882
- type: "button",
4883
- className: `sg-tokrow${disabled ? " sg-tokrow--off" : ""}`,
4884
- disabled,
4885
- "aria-disabled": disabled || void 0,
4886
- "data-disabled": disabled || void 0,
4887
- onClick: disabled ? void 0 : () => props.onPick({ chainId, symbol: t.symbol }),
4888
- children: [
4889
- /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: t.symbol, logoUrl: t.logoUrl, chainId }),
4890
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-tokrow-main", children: [
4891
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-sym", children: tokenTicker(t) }),
4892
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-name", children: t.name || t.symbol })
5153
+ if (st?.disabled && !WALLET_STATE_REASONS.has(String(st.reason))) continue;
5154
+ deployments.push({
5155
+ token,
5156
+ key,
5157
+ balance: showBalances && props.balances?.[key] && Number.isFinite(n) ? n : null,
5158
+ disabled: !!st?.disabled,
5159
+ // The line under a greyed row says why. Callers send either a sentence in `reason` (the
5160
+ // exchange's "cannot be delivered on this chain") or a machine code there with the words in
5161
+ // `hint` (the deposit card's "no-balance" / "No balance on this chain").
5162
+ reason: st?.disabled ? st.reason && /\s/.test(st.reason) ? st.reason : st.hint || st.reason : void 0,
5163
+ hint: st?.disabled ? void 0 : st?.hint
5164
+ });
5165
+ }
5166
+ return groupDeployments(deployments, prices);
5167
+ }, [props.tokens, props.balances, props.optionStates, showBalances, prices]);
5168
+ const chainTerms = react.useMemo(() => buildChainSearchTerms(props.chains), [props.chains]);
5169
+ const visible = react.useMemo(() => searchGroups(groups, query, chainTerms, prices), [groups, query, chainTerms, prices]);
5170
+ const openGroup = openKey ? visible.find((g) => g.key === openKey) ?? null : null;
5171
+ react.useEffect(() => {
5172
+ if (openKey && !openGroup) setOpenKey(null);
5173
+ }, [openKey, openGroup]);
5174
+ react.useLayoutEffect(() => {
5175
+ if (!openKey && listRef.current) listRef.current.scrollTop = savedScroll.current;
5176
+ }, [openKey]);
5177
+ const selected = props.selected;
5178
+ const isSelected = (t) => isPick(selected, t);
5179
+ const pick = (t) => props.onPick({ chainId: Number(t.chainId), symbol: t.symbol });
5180
+ const selectedRow = react.useMemo(() => {
5181
+ if (!selected) return null;
5182
+ for (const g of groups) for (const d of g.deployments) if (!d.disabled && isPick(selected, d.token)) return d;
5183
+ return null;
5184
+ }, [groups, selected]);
5185
+ const head = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk-head", children: [
5186
+ openGroup ? /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-pk-backlink", onClick: () => setOpenKey(null), children: [
5187
+ /* @__PURE__ */ jsxRuntime.jsx(ArrowLeftGlyph, {}),
5188
+ "Tokens"
5189
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-pk-title", children: props.title }),
5190
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-pk-close", onClick: props.onBack, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(CloseGlyph, {}) })
5191
+ ] });
5192
+ if (openGroup) {
5193
+ const sym = openGroup.symbol;
5194
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk", "data-step": "network", children: [
5195
+ head,
5196
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk-intro", children: [
5197
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk-title", children: [
5198
+ side === "from" ? "Pay with" : "Receive",
5199
+ " ",
5200
+ sym
5201
+ ] }),
5202
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-lead", children: side === "from" ? "Choose the network to pay from" : `Choose the network to receive ${sym} on` })
5203
+ ] }),
5204
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-pk-list", role: "group", "aria-label": "Select network", children: openGroup.deployments.map((d) => {
5205
+ const id = Number(d.token.chainId);
5206
+ const name = chainName3(id);
5207
+ if (d.disabled) {
5208
+ return /* @__PURE__ */ jsxRuntime.jsx(UnavailableRow, { icon: /* @__PURE__ */ jsxRuntime.jsx(ChainMark, { chainId: id, chain: chainById2.get(id), size: "row" }), label: name, reason: d.reason, testId: "network-row-unavailable" }, d.key);
5209
+ }
5210
+ const sel = isSelected(d.token);
5211
+ const ticker = tokenTicker(d.token);
5212
+ return /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-pk-row sg-pk-row--net", "data-testid": "network-row", "data-selected": sel || void 0, "aria-pressed": sel, title: name, onClick: () => pick(d.token), children: [
5213
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
5214
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-chainwrap", children: [
5215
+ /* @__PURE__ */ jsxRuntime.jsx(ChainMark, { chainId: id, chain: chainById2.get(id), size: "row" }),
5216
+ sel ? /* @__PURE__ */ jsxRuntime.jsx(TickBadge, {}) : null
4893
5217
  ] }),
4894
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-tokrow-end", children: [
4895
- bal ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-bal sg-mono", children: bal.formatted }) : null,
4896
- st?.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-hint", "data-tone": disabled ? void 0 : "note", children: st.hint }) : null,
4897
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-tokrow-chain", children: CHAIN_LABELS[chainId] || `Chain ${chainId}` })
5218
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
5219
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-label", children: [
5220
+ name,
5221
+ ticker !== sym ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-alt", children: ticker }) : null
5222
+ ] }),
5223
+ d.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: d.hint }) : null
4898
5224
  ] })
4899
- ]
4900
- },
4901
- `${chainId}:${t.address}`
4902
- );
4903
- }) : props.loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-sel-empty", children: "Loading the token list\u2026" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-sel-empty", children: "No tokens match \u2014 try another chain or search." }) })
5225
+ ] }),
5226
+ showBalances ? /* @__PURE__ */ jsxRuntime.jsx(BalanceColumn, { amount: d.balance, usd: usdOf(d.balance, prices, d.token.symbol), symbol: ticker }) : null
5227
+ ] }, d.key);
5228
+ }) })
5229
+ ] });
5230
+ }
5231
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk", "data-step": "token", children: [
5232
+ head,
5233
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "sg-pk-search", children: [
5234
+ /* @__PURE__ */ jsxRuntime.jsx(SearchGlyph, {}),
5235
+ /* @__PURE__ */ jsxRuntime.jsx("input", { autoFocus: true, placeholder: "Search by token or address", value: query, onChange: (e) => setQuery(e.target.value), spellCheck: false, "aria-label": "Search by token or address" }),
5236
+ query ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-pk-clear", onClick: () => setQuery(""), "aria-label": "Clear token search", children: /* @__PURE__ */ jsxRuntime.jsx(CloseGlyph, {}) }) : null
5237
+ ] }),
5238
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk-body", children: [
5239
+ selectedRow ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pk-selected", children: [
5240
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-cap", children: "Selected" }),
5241
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-pk-row", "data-testid": "selected-row", "data-selected": "true", "aria-pressed": "true", onClick: () => pick(selectedRow.token), children: [
5242
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
5243
+ /* @__PURE__ */ jsxRuntime.jsx(TokenPlate, { symbol: selectedRow.token.symbol, logoUrl: selectedRow.token.logoUrl, checked: true }),
5244
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
5245
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-label", children: tokenTicker(selectedRow.token) }),
5246
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-line", children: [
5247
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-sub", children: [
5248
+ "On ",
5249
+ chainName3(Number(selectedRow.token.chainId))
5250
+ ] }),
5251
+ /* @__PURE__ */ jsxRuntime.jsx(ChainMarks, { chainIds: [Number(selectedRow.token.chainId)], chainById: chainById2, decorative: true })
5252
+ ] })
5253
+ ] })
5254
+ ] }),
5255
+ showBalances ? /* @__PURE__ */ jsxRuntime.jsx(
5256
+ BalanceColumn,
5257
+ {
5258
+ amount: selectedRow.balance,
5259
+ usd: usdOf(selectedRow.balance, prices, selectedRow.token.symbol),
5260
+ symbol: tokenTicker(selectedRow.token)
5261
+ }
5262
+ ) : null
5263
+ ] })
5264
+ ] }) : null,
5265
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-cap", children: side === "from" ? "Your tokens \xB7 All networks" : "Popular tokens \xB7 All networks" }),
5266
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-pk-list", ref: listRef, role: "group", "aria-label": props.title, children: visible.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-pk-empty", children: props.loading ? "Loading the token list\u2026" : "No tokens found." }) : visible.map((g) => {
5267
+ const members = g.deployments;
5268
+ const multi = members.length > 1;
5269
+ const single = members[0];
5270
+ const label = multi ? g.symbol : tokenTicker(single.token);
5271
+ const blocked = !!g.unavailable;
5272
+ const opensNetworks = multi || blocked;
5273
+ const zero = showBalances && g.amount === 0 || blocked;
5274
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5275
+ "button",
5276
+ {
5277
+ type: "button",
5278
+ className: "sg-pk-row",
5279
+ "data-testid": "token-row",
5280
+ "data-symbol": g.symbol,
5281
+ "data-networks": members.length,
5282
+ "data-zero": zero || void 0,
5283
+ "data-unavailable": blocked || void 0,
5284
+ onClick: () => {
5285
+ if (opensNetworks) {
5286
+ savedScroll.current = listRef.current?.scrollTop ?? 0;
5287
+ setOpenKey(g.key);
5288
+ } else pick(single.token);
5289
+ },
5290
+ children: [
5291
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-left", children: [
5292
+ /* @__PURE__ */ jsxRuntime.jsx(TokenPlate, { symbol: g.symbol, logoUrl: g.logoUrl }),
5293
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-text", children: [
5294
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-label", children: label }),
5295
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-line", children: [
5296
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-sub", children: multi ? showBalances ? "Total across" : "Available on" : `On ${chainName3(Number(single.token.chainId))}` }),
5297
+ /* @__PURE__ */ jsxRuntime.jsx(ChainMarks, { chainIds: members.map((m) => Number(m.token.chainId)), chainById: chainById2, decorative: !multi }),
5298
+ opensNetworks && showBalances ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-chev sg-pk-chev--sm", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) }) : null
5299
+ ] }),
5300
+ !multi && single.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-note", "data-testid": "lane-limit", children: single.hint }) : null
5301
+ ] })
5302
+ ] }),
5303
+ showBalances ? /* @__PURE__ */ jsxRuntime.jsx(BalanceColumn, { amount: g.amount, usd: g.usd, symbol: label }) : opensNetworks ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-chev", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph, {}) }) : null
5304
+ ]
5305
+ },
5306
+ g.key
5307
+ );
5308
+ }) })
5309
+ ] })
4904
5310
  ] });
4905
5311
  }
4906
5312
  function ChevronRight({ size = 16 }) {
@@ -4918,7 +5324,7 @@ function ArrowDown({ size = 16 }) {
4918
5324
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12.667 8L8 12.667 3.333 8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
4919
5325
  ] });
4920
5326
  }
4921
- function CloseGlyph() {
5327
+ function CloseGlyph2() {
4922
5328
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
4923
5329
  }
4924
5330
  function ShieldTickGlyph({ size = 16 }) {
@@ -4958,7 +5364,7 @@ function AmountText({ value, suffix, exact }) {
4958
5364
  suffix ? ` ${suffix}` : null
4959
5365
  ] });
4960
5366
  }
4961
- function usdOf(amount, price) {
5367
+ function usdOf2(amount, price) {
4962
5368
  const n = typeof amount === "number" ? amount : Number(amount);
4963
5369
  if (!Number.isFinite(n) || n <= 0 || price === void 0 || !Number.isFinite(price) || price <= 0) return null;
4964
5370
  const usd2 = n * price;
@@ -5088,7 +5494,7 @@ function WidgetShell(props) {
5088
5494
  ] }),
5089
5495
  props.onClose ? (
5090
5496
  // type="button": a host page may wrap the widget in a <form>.
5091
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-close", onClick: props.onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(CloseGlyph, {}) })
5497
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-close", onClick: props.onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(CloseGlyph2, {}) })
5092
5498
  ) : null
5093
5499
  ] })
5094
5500
  ] }),
@@ -5384,7 +5790,7 @@ function useTxHistory(account) {
5384
5790
  }, [account]);
5385
5791
  return entries;
5386
5792
  }
5387
- function BackGlyph2() {
5793
+ function BackGlyph() {
5388
5794
  return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "17", height: "17", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
5389
5795
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 12H5" }),
5390
5796
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m12 19-7-7 7-7" })
@@ -5626,7 +6032,7 @@ function TxHistoryPanel(props) {
5626
6032
  };
5627
6033
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5628
6034
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-sel-head", children: [
5629
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", autoFocus: true, ref: backRef, className: "sg-back", onClick: selected ? () => setSelected(null) : props.onBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx(BackGlyph2, {}) }),
6035
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", autoFocus: true, ref: backRef, className: "sg-back", onClick: selected ? () => setSelected(null) : props.onBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx(BackGlyph, {}) }),
5630
6036
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-sel-title", children: [
5631
6037
  selected ? "Transaction" : "Transaction history",
5632
6038
  account ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sel-sub sg-mono", children: shortAddress2(account) }) : null
@@ -6382,6 +6788,9 @@ function PaymentIsland(props) {
6382
6788
  TokenSelect,
6383
6789
  {
6384
6790
  title: "Pay with",
6791
+ side: "from",
6792
+ selected: sel ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null,
6793
+ fetchPrices: engine.fetchPrices,
6385
6794
  chains: fundingChains,
6386
6795
  tokens: fundingTokens,
6387
6796
  balances: holdings.balances,
@@ -6397,6 +6806,9 @@ function PaymentIsland(props) {
6397
6806
  TokenSelect,
6398
6807
  {
6399
6808
  title: isFrom ? "Exchange from" : "Exchange to",
6809
+ side: isFrom ? "from" : "to",
6810
+ selected: isFrom ? exFrom : exTo,
6811
+ fetchPrices: engine.fetchPrices,
6400
6812
  chains,
6401
6813
  tokens: isFrom ? exFromPicker : exToPicker,
6402
6814
  balances: exBalances,
@@ -6941,6 +7353,9 @@ function PayCard(props) {
6941
7353
  TokenSelect,
6942
7354
  {
6943
7355
  title: "Pay with",
7356
+ side: "from",
7357
+ selected: sel ? { chainId: sel.source.chainId, symbol: sel.source.asset } : null,
7358
+ fetchPrices: engine.fetchPrices,
6944
7359
  chains: fundingChains,
6945
7360
  tokens: fundingTokens,
6946
7361
  balances: listBalances,
@@ -6988,7 +7403,7 @@ function PayCard(props) {
6988
7403
  }
6989
7404
  )
6990
7405
  ] }),
6991
- /* @__PURE__ */ jsxRuntime.jsx(PaneFoot, { usd: sel && selectedVisible ? usdOf(sel.source.payAmount, prices[selSymbol]) : null, balance: selBal ? shortBalance(selBal.formatted) : null })
7406
+ /* @__PURE__ */ jsxRuntime.jsx(PaneFoot, { usd: sel && selectedVisible ? usdOf2(sel.source.payAmount, prices[selSymbol]) : null, balance: selBal ? shortBalance(selBal.formatted) : null })
6992
7407
  ] }),
6993
7408
  loadingPlan ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pay-loading", "data-testid": "pay-loading", role: "status", children: [
6994
7409
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-skel sg-skel--row" }),
@@ -7500,8 +7915,8 @@ function ExchangeCard(props) {
7500
7915
  const routeShape = via === null ? "Direct" : via ? `Via ${via}` : "Two steps";
7501
7916
  const compliance = selected?.quote.compliance;
7502
7917
  const complianceHasQuote = Boolean(selected && flow.status !== "loading");
7503
- const fromUsd = usdOf(normalizedAmount, prices[from?.symbol ?? ""]);
7504
- const toUsd = usdOf(receive, prices[to?.symbol ?? ""]);
7918
+ const fromUsd = usdOf2(normalizedAmount, prices[from?.symbol ?? ""]);
7919
+ const toUsd = usdOf2(receive, prices[to?.symbol ?? ""]);
7505
7920
  const flippable = !rampMode && !submitting && Boolean(to && sourceTokens.some((t) => Number(t.chainId) === to.chainId && symbolKey(t.symbol) === to.symbol));
7506
7921
  const flip = () => {
7507
7922
  if (!flippable) return;
@@ -7584,6 +7999,9 @@ function ExchangeCard(props) {
7584
7999
  TokenSelect,
7585
8000
  {
7586
8001
  title: isFrom ? "Exchange from" : "Exchange to",
8002
+ side: isFrom ? "from" : "to",
8003
+ selected: isFrom ? from : to,
8004
+ fetchPrices: engine.fetchPrices,
7587
8005
  chains,
7588
8006
  tokens: isFrom ? fromPickerTokens : toPickerVisible,
7589
8007
  balances,