@glacislabs/stablegenie-zerodelta 4.19.0 → 4.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mount.cjs CHANGED
@@ -3420,6 +3420,7 @@ function resultForOption(result, option, mode, destinationChainId) {
3420
3420
  var DEFAULT_DEADLINE_SECONDS = 1800;
3421
3421
  var MAX_DEADLINE_SECONDS = 60 * 60;
3422
3422
  var ABSOLUTE_MAX_DEADLINE_SECONDS = 24 * 60 * 60;
3423
+ var DEADLINE_CLOCK_SKEW_SECONDS = 120;
3423
3424
  function recommendedDeadlineSeconds(quote) {
3424
3425
  const recommended = Number(quote?.recommendedDeadlineSeconds);
3425
3426
  if (!Number.isFinite(recommended) || recommended <= 0) return DEFAULT_DEADLINE_SECONDS;
@@ -3515,7 +3516,7 @@ function assertQuoteMatchesSelection({ quote, order, orders, option, destination
3515
3516
  throw new Error("ZeroDelta order guarantees less than the displayed receive amount.");
3516
3517
  }
3517
3518
  const maxDeadline = maxDeadlineSeconds(quote);
3518
- if (!Number.isFinite(deadline) || deadline <= now || deadline > now + maxDeadline) {
3519
+ if (!Number.isFinite(deadline) || deadline <= now || deadline > now + maxDeadline + DEADLINE_CLOCK_SKEW_SECONDS) {
3519
3520
  throw new Error("ZeroDelta quote deadline is invalid or too far in the future.");
3520
3521
  }
3521
3522
  for (let index = 1; index < list.length; index += 1) {
@@ -4271,10 +4272,55 @@ function buildZdHeavyRoute(ctx) {
4271
4272
  // src/core/quote-compare.ts
4272
4273
  var WAIT_MIN_SEC = 180;
4273
4274
  var WAIT_MAX_SEC = 7200;
4275
+ var WAIT_STEP_SEC = 60;
4274
4276
  function clampWait(sec) {
4275
4277
  if (!Number.isFinite(sec)) return WAIT_MIN_SEC;
4276
4278
  return Math.min(WAIT_MAX_SEC, Math.max(WAIT_MIN_SEC, sec));
4277
4279
  }
4280
+ var WAIT_POINTS = [
4281
+ [WAIT_MIN_SEC, 0],
4282
+ [1800, 0.295],
4283
+ [2700, 0.4725],
4284
+ [WAIT_MAX_SEC, 1]
4285
+ ];
4286
+ var FIGMA_TRAVEL_PX = 400;
4287
+ function waitScaleFor(travelPx) {
4288
+ if (!Number.isFinite(travelPx) || travelPx >= FIGMA_TRAVEL_PX || travelPx < 200) return WAIT_POINTS;
4289
+ return WAIT_POINTS.map(
4290
+ ([sec, fraction], i) => i === 0 || i === WAIT_POINTS.length - 1 ? [sec, fraction] : [sec, fraction * FIGMA_TRAVEL_PX / travelPx]
4291
+ );
4292
+ }
4293
+ var WAIT_POSITIONS = 1e3;
4294
+ function waitFraction(sec, points = WAIT_POINTS) {
4295
+ const s = clampWait(sec);
4296
+ for (let i = 1; i < points.length; i++) {
4297
+ const [s1, f1] = points[i];
4298
+ if (s <= s1) {
4299
+ const [s0, f0] = points[i - 1];
4300
+ return f0 + (s - s0) / (s1 - s0) * (f1 - f0);
4301
+ }
4302
+ }
4303
+ return 1;
4304
+ }
4305
+ function waitFromFraction(fraction, points = WAIT_POINTS) {
4306
+ const f = Number.isFinite(fraction) ? Math.min(1, Math.max(0, fraction)) : 0;
4307
+ for (let i = 1; i < points.length; i++) {
4308
+ const [s1, f1] = points[i];
4309
+ if (f <= f1) {
4310
+ const [s0, f0] = points[i - 1];
4311
+ return s0 + (f - f0) / (f1 - f0) * (s1 - s0);
4312
+ }
4313
+ }
4314
+ return WAIT_MAX_SEC;
4315
+ }
4316
+ function snapWait(sec) {
4317
+ return clampWait(Math.round(sec / WAIT_STEP_SEC) * WAIT_STEP_SEC);
4318
+ }
4319
+ function waitLabel(sec) {
4320
+ const min = Math.round(clampWait(sec) / 60);
4321
+ if (min >= 60 && min % 60 === 0) return `Up to ${min / 60} ${min === 60 ? "hour" : "hours"}`;
4322
+ return `Up to ${min} min`;
4323
+ }
4278
4324
  var hasTime = (o) => Number.isFinite(o.estimatedDuration) && o.estimatedDuration > 0;
4279
4325
  function selectableOptions(options) {
4280
4326
  return options.filter((o) => !o.unavailable);
@@ -4298,15 +4344,23 @@ function pickForWait(options, waitSec) {
4298
4344
  }
4299
4345
  var MAX_QUOTE_CARDS = 3;
4300
4346
  function visibleOptions(options, waitSec, selectedId) {
4301
- if (options.length <= MAX_QUOTE_CARDS) return [...options];
4347
+ if (options.length <= MAX_QUOTE_CARDS) return nettingFirst(options);
4302
4348
  const selectable = selectableOptions(options);
4303
- if (selectable.length === 0) return options.slice(0, MAX_QUOTE_CARDS);
4349
+ if (selectable.length === 0) return nettingFirst(options.slice(0, MAX_QUOTE_CARDS));
4304
4350
  const chosen = selectable.find((o) => o.id === selectedId) ?? pickForWait(options, waitSec);
4305
4351
  const gasless = bestOutputOption(selectable.filter((o) => o.gasSponsored));
4306
4352
  const netting = bestOutputOption(selectable.filter((o) => o.entersNetting));
4307
4353
  const ids = new Set([chosen?.id, fastestOption(options)?.id, gasless?.id, netting?.id].filter((id) => !!id));
4308
4354
  const keep = new Set([...ids].slice(0, MAX_QUOTE_CARDS));
4309
- return options.filter((o) => keep.has(o.id));
4355
+ return nettingFirst(options.filter((o) => keep.has(o.id)));
4356
+ }
4357
+ function nettingFirst(options) {
4358
+ return [...options.filter((o) => o.entersNetting), ...options.filter((o) => !o.entersNetting)];
4359
+ }
4360
+ function compareDuration(seconds) {
4361
+ if (!Number.isFinite(seconds) || seconds <= 0) return "--";
4362
+ if (seconds < 60) return `~${Math.round(seconds)} s`;
4363
+ return `~${Math.round(seconds / 60)} min`;
4310
4364
  }
4311
4365
  function parity(options, inputUsd, toUnitUsd) {
4312
4366
  const priced = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
@@ -4362,10 +4416,10 @@ function routeShapeLabel(option) {
4362
4416
  function cornerTags(options, option, parityState) {
4363
4417
  if (option.unavailable) return [];
4364
4418
  if (option.kind === "transfer") return [{ text: "Transfer", tone: "brand" }];
4419
+ if (option.entersNetting) return [{ text: "Best return", tone: "green" }];
4365
4420
  const tags = [];
4366
4421
  const labelledFastest = selectableOptions(options).some((o) => o.label?.toLowerCase() === "fastest");
4367
4422
  if (parityState.kind === "at" && parityState.option.id === option.id) tags.push({ text: "Target 1:1", tone: "brand" });
4368
- else if (option.entersNetting) tags.push({ text: "Potential best return", tone: "brand" });
4369
4423
  else if (option.label?.toLowerCase() === "fastest") tags.push({ text: "Fastest", tone: "brand" });
4370
4424
  else if (option.gasSponsored) tags.push({ text: "Gasless", tone: "purple" });
4371
4425
  else {
@@ -4373,9 +4427,24 @@ function cornerTags(options, option, parityState) {
4373
4427
  const text = badge === "Fastest" && labelledFastest ? void 0 : badge ?? routeShapeLabel(option) ?? void 0;
4374
4428
  if (text) tags.push({ text, tone: "brand" });
4375
4429
  }
4376
- if (option.entersNetting) tags.push({ text: "Netting", tone: "green" });
4377
4430
  return tags;
4378
4431
  }
4432
+ function humanAmount(n, maxFrac = 6) {
4433
+ if (!Number.isFinite(n)) return String(n);
4434
+ if (n === 0) return "0";
4435
+ const digits = Math.min(Math.max(0, Math.trunc(maxFrac)), 8);
4436
+ const fixed = n.toFixed(digits);
4437
+ const out = fixed.includes(".") ? fixed.replace(/\.?0+$/, "") : fixed;
4438
+ if (Number(out) === 0) return `<${digits > 0 ? `0.${"0".repeat(digits - 1)}1` : "1"}`;
4439
+ const match = out.match(/^([+-]?)(\d+)(\.\d+)?$/);
4440
+ return match ? `${match[1]}${match[2].replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${match[3] ?? ""}` : out;
4441
+ }
4442
+ function compareAmount(value) {
4443
+ const text = humanAmount(value, 6);
4444
+ if (text.startsWith("<")) return text;
4445
+ const [whole, fraction = ""] = text.split(".");
4446
+ return fraction.length >= 2 ? text : `${whole}.${fraction.padEnd(2, "0")}`;
4447
+ }
4379
4448
  function compareFeeUsd(option, fromUsd) {
4380
4449
  const centibips = option.feeCentibips;
4381
4450
  if (centibips === void 0 || option.feeNative) return null;
@@ -4894,7 +4963,7 @@ var CHANNEL_HEADER = "x-zd-channel";
4894
4963
  var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
4895
4964
  var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
4896
4965
  var WIDGET_CHANNEL = "widget";
4897
- var WIDGET_VERSION = "4.19.0" ;
4966
+ var WIDGET_VERSION = "4.20.1" ;
4898
4967
  var MAX_CHANNEL_VERSION_LEN = 32;
4899
4968
  function sanitizeVersion(raw2) {
4900
4969
  const v = String(raw2).trim();
@@ -4931,6 +5000,20 @@ function isReportableSubmission(report) {
4931
5000
  return typeof wallet === "string" && /^0x[0-9a-fA-F]{40}$/.test(wallet);
4932
5001
  }
4933
5002
 
5003
+ // src/core/quote-refusals.ts
5004
+ var GATE_REFUSALS = /* @__PURE__ */ new Set(["ROUTE_UNHEALTHY", "ROUTE_UNMEASURED", "GATE_UNAVAILABLE"]);
5005
+ function quoteRefusalCopy(code) {
5006
+ return code && GATE_REFUSALS.has(code) ? "This route is not available right now. Try again in a moment, or pick another token or network." : void 0;
5007
+ }
5008
+ var DETERMINISTIC_REFUSALS = /* @__PURE__ */ new Set(["ROUTE_UNHEALTHY", "ROUTE_UNMEASURED", "ROUTE_BLOCKED", "PAIR_HALTED", "PROTOCOL_DISABLED"]);
5009
+ var TRANSIENT_REFUSALS = /* @__PURE__ */ new Set(["GATE_UNAVAILABLE", "MARKET_HALTED"]);
5010
+ function gateRefusalRetryable(code) {
5011
+ if (!code) return void 0;
5012
+ if (DETERMINISTIC_REFUSALS.has(code)) return false;
5013
+ if (TRANSIENT_REFUSALS.has(code)) return true;
5014
+ return void 0;
5015
+ }
5016
+
4934
5017
  // src/core/api.ts
4935
5018
  function apiError(message, props = {}) {
4936
5019
  const err2 = new Error(message);
@@ -4994,6 +5077,8 @@ function nowFresh(entry) {
4994
5077
  return !!entry && Date.now() - entry.at < API_CACHE_TTL_MS;
4995
5078
  }
4996
5079
  function isTransientQuoteError(error) {
5080
+ const gate = gateRefusalRetryable(error?.code);
5081
+ if (gate !== void 0) return gate;
4997
5082
  if (error?.code === "BRIDGE_RATE_LIMITED" || Array.isArray(error?.fieldErrors) && error.fieldErrors.length > 0) return false;
4998
5083
  return error?.code === "gateway_timeout" || error?.status === 502 || error?.status === 503 || error?.status === 504 || /failed to get swap quote|timeout|temporar/i.test(error?.message || "");
4999
5084
  }
@@ -5064,9 +5149,10 @@ function createApiClient(cfg) {
5064
5149
  }
5065
5150
  }
5066
5151
  if (!response.ok) {
5067
- throw apiError(apiMessage(json, `ZeroDelta request failed (${response.status}).`), {
5152
+ const code = json?.error?.code || json?.code || (response.status >= 502 ? "gateway_timeout" : "api_error");
5153
+ throw apiError(quoteRefusalCopy(code) ?? apiMessage(json, `ZeroDelta request failed (${response.status}).`), {
5068
5154
  status: response.status,
5069
- code: json?.error?.code || json?.code || (response.status >= 502 ? "gateway_timeout" : "api_error"),
5155
+ code,
5070
5156
  fieldErrors: json?.error?.fieldErrors || json?.fieldErrors,
5071
5157
  limits: json?.error?.limits || json?.limits,
5072
5158
  reasons: json?.error?.reasons || json?.reasons
@@ -6674,6 +6760,11 @@ function useFlow(args) {
6674
6760
  };
6675
6761
  }
6676
6762
  var RETRY_DELAYS_MS = [800, 2400, 6e3];
6763
+ var CATALOGUE_REFRESH_MS = 6e4 + 250;
6764
+ function catalogueSignature(c) {
6765
+ const ids = (list) => list.map((t) => `${Number(t.chainId)}:${String(t.address).toLowerCase()}`).join(",");
6766
+ return [ids(c.tokens), ids(c.sources), [...c.source].sort().join(","), [...c.destination].sort().join(","), [...c.lanes ?? []].sort().join(","), [...c.brokenLanes?.keys() ?? []].sort().join(","), [...c.limitedLanes.keys()].sort().join(",")].join("|");
6767
+ }
6677
6768
  function useCatalogue(engine, options = {}) {
6678
6769
  const { allowedAssets, product, solanaSources } = options;
6679
6770
  const enabled = options.enabled !== false;
@@ -6690,7 +6781,10 @@ function useCatalogue(engine, options = {}) {
6690
6781
  engine.fetchCatalogue(allowedAssets, product, solanaSources ? { solanaSources: true } : void 0).then((next) => {
6691
6782
  if (!alive) return;
6692
6783
  setCatalogue(next);
6693
- if (next.ready) return;
6784
+ if (next.ready) {
6785
+ timer2 = setTimeout(refresh, CATALOGUE_REFRESH_MS);
6786
+ return;
6787
+ }
6694
6788
  if (attempt >= RETRY_DELAYS_MS.length) {
6695
6789
  setFailed(true);
6696
6790
  return;
@@ -6698,6 +6792,23 @@ function useCatalogue(engine, options = {}) {
6698
6792
  timer2 = setTimeout(read, RETRY_DELAYS_MS[attempt++]);
6699
6793
  });
6700
6794
  };
6795
+ const refresh = () => {
6796
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") {
6797
+ timer2 = setTimeout(refresh, CATALOGUE_REFRESH_MS);
6798
+ return;
6799
+ }
6800
+ if (isUserIdle()) {
6801
+ timer2 = setTimeout(refresh, CATALOGUE_REFRESH_MS);
6802
+ return;
6803
+ }
6804
+ engine.fetchCatalogue(allowedAssets, product, solanaSources ? { solanaSources: true } : void 0).then((next) => {
6805
+ if (!alive) return;
6806
+ if (next.ready) setCatalogue((prev) => prev?.ready && catalogueSignature(prev) === catalogueSignature(next) ? prev : next);
6807
+ }).catch(() => {
6808
+ }).finally(() => {
6809
+ if (alive) timer2 = setTimeout(refresh, CATALOGUE_REFRESH_MS);
6810
+ });
6811
+ };
6701
6812
  read();
6702
6813
  return () => {
6703
6814
  alive = false;
@@ -7685,6 +7796,217 @@ button.sg-rcp-row:focus-visible{outline:2px solid var(--sg-accent);outline-offse
7685
7796
  .sg-widget[data-sg-side]:has(>.sg-ws){display:flex;flex-direction:column}
7686
7797
  .sg-widget[data-sg-side]>.sg-ws{flex:1 1 auto}
7687
7798
  @media (prefers-reduced-motion:reduce){.sg-ws{animation:none}.sg-ws-spin{animation:none}}
7799
+ /* \u2500\u2500 Compliance details screen (ComplianceDetails) \u2014 Figma Widget Playground 3238:16033 / 16419 / 16879 / 17276 / 17894 \u2500\u2500 */
7800
+ .sg-cd{--sg-cd-r:min(var(--sg-radius-control),20px);--sg-t50:color-mix(in srgb,var(--sg-text) 50%,transparent);--sg-t25:color-mix(in srgb,var(--sg-text) 25%,transparent);display:flex;flex-direction:column;gap:12px;width:100%;box-sizing:border-box;animation:sg-cp-in var(--sg-motion-fast) var(--sg-ease-out-soft) both}
7801
+ .sg-cd:focus{outline:none}
7802
+ .sg-cd-back{position:relative;align-self:flex-start;display:inline-flex;align-items:center;gap:10px;margin:0 0 12px;padding:0;border:0;background:transparent;color:var(--sg-t50);font:inherit;font-size:14px;font-weight:500;line-height:1.2;cursor:pointer;transition:color 120ms ease}
7803
+ .sg-cd-back::after{content:"";position:absolute;inset:-12px -10px}
7804
+ .sg-cd-back:hover{color:var(--sg-text)}
7805
+ .sg-cd-back:focus-visible{outline:2px solid var(--sg-accent);outline-offset:4px;border-radius:6px}
7806
+ .sg-cd-title{margin:0;font-family:var(--sg-font-display);font-size:16px;font-weight:600;line-height:19.2px;letter-spacing:.32px;color:var(--sg-t90)}
7807
+ .sg-cd-tabs{display:flex;align-items:stretch;gap:0;padding:4px;border:1px solid var(--sg-border);border-radius:calc(var(--sg-cd-r) - 4px)}
7808
+ .sg-cd-tab{flex:1 0 0;display:inline-flex;align-items:center;justify-content:center;gap:8px;min-width:0;padding:13px 8px;border:0;border-radius:calc(var(--sg-cd-r) - 4px);background:transparent;color:var(--sg-t50);font:inherit;font-size:10px;font-weight:700;line-height:14px;text-transform:uppercase;letter-spacing:.2px;white-space:nowrap;cursor:pointer;transition:background 120ms ease,color 120ms ease}
7809
+ .sg-cd-tab:hover{color:var(--sg-text)}
7810
+ .sg-cd-tab[data-active="true"]{background:color-mix(in srgb,var(--sg-accent) 8%,transparent);color:var(--sg-accent)}
7811
+ .sg-cd-tab:focus-visible{outline:2px solid var(--sg-accent);outline-offset:-2px}
7812
+ .sg-cd-tab-count{font-weight:700;color:var(--sg-t25)}
7813
+ .sg-cd-tab[data-active="true"] .sg-cd-tab-count{color:color-mix(in srgb,var(--sg-accent) 50%,transparent)}
7814
+ .sg-cd-panel{display:flex;flex-direction:column;gap:6px;margin-top:-4px}
7815
+ .sg-cd-card{display:flex;flex-direction:column;gap:20px;padding:16px;border:1px solid var(--sg-border);border-radius:var(--sg-cd-r)}
7816
+ .sg-cd-card-head{display:flex;align-items:center;gap:8px}
7817
+ .sg-cd-card-glyph{display:flex;flex:0 0 auto;color:var(--sg-accent)}
7818
+ .sg-cd-card-title{margin:0;font-size:15px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
7819
+ .sg-cd-summary{display:flex;flex-direction:column;gap:4px}
7820
+ .sg-cd-summary-head{display:flex;align-items:center;gap:8px;color:var(--sg-ok-ink)}
7821
+ .sg-cd-summary-head[data-tone="neutral"]{color:var(--sg-t60)}
7822
+ .sg-cd-summary-head[data-tone="blocked"],.sg-cd-summary-head[data-tone="warn"]{color:var(--sg-danger)}
7823
+ .sg-cd-summary-title{font-size:14px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
7824
+ .sg-cd-summary-head[data-tone="blocked"] .sg-cd-summary-title,.sg-cd-summary-head[data-tone="warn"] .sg-cd-summary-title{color:var(--sg-danger)}
7825
+ .sg-cd-summary-sub{margin:0;padding-left:24px;font-size:13px;line-height:1.2;color:var(--sg-t50)}
7826
+ .sg-cd-checks{list-style:none;margin:2px 0 -1px;padding:0;display:flex;flex-direction:column;gap:12px}
7827
+ .sg-cd-card:has(.sg-cd-facts){gap:16px}
7828
+ .sg-cd-check-line{display:flex;align-items:center;gap:8px;min-width:0}
7829
+ .sg-cd-check-mark{display:flex;flex:0 0 auto;width:12px;justify-content:center;color:var(--sg-ok-ink)}
7830
+ .sg-cd-check-mark[data-ok="false"]{color:var(--sg-danger)}
7831
+ .sg-cd-check-label{font-size:14px;line-height:17px;color:var(--sg-t90)}
7832
+ .sg-cd-check[data-ok="false"] .sg-cd-check-label{color:var(--sg-danger)}
7833
+ .sg-cd-check-note,.sg-cd-check-reason{display:block;padding-left:26px;margin-top:3px;font-size:12px;line-height:1.4;color:var(--sg-t60);overflow-wrap:anywhere}
7834
+ .sg-cd-check-reason{color:var(--sg-danger)}
7835
+ .sg-cd-orphans{list-style:none;margin:0;padding:0 0 0 26px;display:flex;flex-direction:column;gap:3px;font-size:12px;line-height:1.4;color:var(--sg-danger)}
7836
+ .sg-cd-scope{margin:0;font-size:12px;line-height:1.45;color:var(--sg-t60)}
7837
+ .sg-cd-flags{margin:0;font-size:14px;color:var(--sg-t90)}
7838
+ .sg-cd-facts{margin:0;display:flex;flex-direction:column;gap:10px;padding-left:24px}
7839
+ .sg-cd-fact{display:grid;grid-template-columns:94px minmax(0,1fr);align-items:baseline;gap:0}
7840
+ .sg-cd-fact dt{font-size:13px;line-height:17px;color:var(--sg-t50)}
7841
+ .sg-cd-fact dd{margin:0;min-width:0;font-size:14px;line-height:17px;color:var(--sg-t90);overflow-wrap:anywhere}
7842
+ .sg-cd-policies{gap:6px}
7843
+ .sg-cd-policy{display:flex;flex-direction:column}
7844
+ .sg-cd-policy-head{position:relative;z-index:1;display:flex;align-items:center;gap:12px;width:100%;box-sizing:border-box;padding:21px 17px;border:1px solid var(--sg-border);border-radius:var(--sg-cd-r);background:var(--sg-bg);color:inherit;font:inherit;text-align:left}
7845
+ button.sg-cd-policy-head{cursor:pointer;transition:border-color 120ms ease}
7846
+ button.sg-cd-policy-head:hover{border-color:color-mix(in srgb,var(--sg-accent) 40%,var(--sg-border))}
7847
+ button.sg-cd-policy-head:focus-visible{outline:2px solid var(--sg-accent);outline-offset:2px}
7848
+ .sg-cd-policy-mark{display:flex;flex:0 0 auto;color:color-mix(in srgb,var(--sg-text) 45%,transparent)}
7849
+ .sg-cd-policy-text{display:flex;flex:1 1 auto;min-width:0;flex-direction:column;gap:6px}
7850
+ .sg-cd-policy-name{font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90);overflow-wrap:anywhere}
7851
+ .sg-cd-policy-sub{font-size:14px;line-height:18px;color:var(--sg-t60)}
7852
+ .sg-cd-policy-chev{display:flex;flex:0 0 auto;color:var(--sg-t90)}
7853
+ .sg-cd-policy-body{display:flex;flex-direction:column;gap:6px;margin-top:-24px;padding:40px 16px 16px;border-radius:var(--sg-cd-r);background:color-mix(in srgb,var(--sg-accent) 8%,transparent);animation:sg-cp-in var(--sg-motion-fast) var(--sg-ease-out-soft) both}
7854
+ .sg-cd-bucket{position:relative;display:flex;flex-direction:column;gap:12px;padding:12px 16px;border-radius:var(--sg-cd-r);background:var(--sg-bg)}
7855
+ .sg-cd-bucket-head{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:4px 8px}
7856
+ .sg-cd-bucket[data-outcome] .sg-cd-bucket-head:has(.sg-cd-hint){justify-content:flex-start;align-items:center;gap:8px}
7857
+ .sg-cd-bucket-title{font-size:14px;font-weight:500;line-height:16px;color:var(--sg-t90)}
7858
+ .sg-cd-bucket-detail{font-size:12px;line-height:14px;color:var(--sg-t50)}
7859
+ .sg-cd-cats{list-style:none;margin:0;padding:0 0 0 8px;display:flex;flex-direction:column;gap:4px}
7860
+ .sg-cd-cats li{display:flex;align-items:center;gap:12px;font-size:13px;line-height:18px;color:var(--sg-t90)}
7861
+ .sg-cd-dot{flex:0 0 auto;width:4px;height:4px;border-radius:999px;background:var(--sg-t90)}
7862
+ .sg-cd-bucket[data-outcome="flagged"] .sg-cd-dot{background:var(--sg-accent);opacity:.8}
7863
+ .sg-cd-cats li .sg-cd-hint{margin-left:-6px}
7864
+ .sg-cd-hint{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;width:20px;height:20px;padding:0;border:0;border-radius:999px;background:transparent;color:var(--sg-t60);cursor:pointer;transition:color 120ms ease}
7865
+ .sg-cd-hint{position:relative}
7866
+ .sg-cd-hint::after{content:"";position:absolute;inset:-12px}
7867
+ .sg-cd-hint:hover,.sg-cd-hint[aria-expanded="true"]{color:var(--sg-accent)}
7868
+ .sg-cd-hint:focus-visible{outline:2px solid var(--sg-accent);outline-offset:1px}
7869
+ .sg-cd-tip{position:absolute;z-index:3;left:0;right:0;top:100%;margin-top:2px;padding:10px 12px;border-radius:12px;background:var(--sg-text);color:var(--sg-bg);font-size:12px;font-weight:400;line-height:1.4;text-align:left;pointer-events:none;box-shadow:0 6px 20px rgba(0,0,0,.18)}
7870
+ .sg-cd-cats li,.sg-cd-bucket-head{position:relative}
7871
+ .sg-cd-policy-version{margin:0;padding:4px 4px 0;font-size:12px;line-height:14px;color:var(--sg-t60);overflow-wrap:anywhere}
7872
+ /* Wide's second panel (layout="side", 280px): the same screen on a denser scale \u2014 Figma 3238:16419 / 18187 / 18446 */
7873
+ .sg-cd[data-layout="side"] .sg-cd-back{font-size:12px;font-weight:400;line-height:16px;margin-bottom:4px}
7874
+ .sg-cd[data-layout="side"] .sg-cd-title{margin-bottom:4px;font-family:inherit;font-size:16px;font-weight:500;line-height:1.2;letter-spacing:0}
7875
+ .sg-cd[data-layout="side"] .sg-cd-panel{margin-top:-8px}
7876
+ .sg-cd[data-layout="side"] .sg-cd-card{padding:16px 12px;gap:16px}
7877
+ .sg-cd[data-layout="side"] .sg-cd-card:has(.sg-cd-facts){gap:16px}
7878
+ .sg-cd[data-layout="side"] .sg-cd-card-title{font-size:14px}
7879
+ .sg-cd[data-layout="side"] .sg-cd-summary-head,.sg-cd[data-layout="side"] .sg-cd-card-head{gap:8px}
7880
+ .sg-cd[data-layout="side"] .sg-cd-summary-sub{padding-left:0;font-size:13px;line-height:16px}
7881
+ .sg-cd[data-layout="side"] .sg-cd-checks{gap:12px}
7882
+ .sg-cd[data-layout="side"] .sg-cd-check-label,.sg-cd[data-layout="side"] .sg-cd-fact dt,.sg-cd[data-layout="side"] .sg-cd-fact dd{font-size:13px;line-height:16px}
7883
+ .sg-cd[data-layout="side"] .sg-cd-facts{padding-left:24px;gap:10px}
7884
+ .sg-cd[data-layout="side"] .sg-cd-policy-head{gap:6px;padding:21px 13px}
7885
+ .sg-cd[data-layout="side"] .sg-cd-policy-text{gap:2px}
7886
+ .sg-cd[data-layout="side"] .sg-cd-policy-name{font-size:14px;line-height:1.2}
7887
+ .sg-cd[data-layout="side"] .sg-cd-policy-sub{font-size:13px;line-height:1.4}
7888
+ .sg-cd[data-layout="side"] .sg-cd-policy-mark svg{width:16px;height:16px}
7889
+ .sg-cd[data-layout="side"] .sg-cd-policy-body{padding:32px 8px 16px}
7890
+ .sg-cd[data-layout="side"] .sg-cd-bucket{gap:8px;padding:12px 16px;border-radius:16px}
7891
+ @media (prefers-reduced-motion:reduce){.sg-cd,.sg-cd-policy-body{animation:none}}
7892
+ /* \u2500\u2500 Compare quotes \u2014 Figma Widget Playground 3237:13270 / 3237:13581 / 3237:13897 / 3237:14224 (2026-11-13) \u2500\u2500 */
7893
+ .sg-widget{--sg-a5:color-mix(in srgb,var(--sg-accent) 5%,transparent);--sg-a8:color-mix(in srgb,var(--sg-accent) 8%,transparent);--sg-a50:color-mix(in srgb,var(--sg-accent) 50%,transparent);--sg-purple:#4f24b4;--sg-green-12:color-mix(in srgb,var(--sg-ok-ink) 12%,transparent);--sg-cq-dot:#8fb8b4}
7894
+ .sg-widget[data-sg-mode="dark"]{--sg-purple:#b79cff;--sg-cq-dot:color-mix(in srgb,var(--sg-text) 50%,transparent)}
7895
+ .sg-ws-titlerow{display:flex;align-items:center;gap:12px}
7896
+ .sg-cq-refresh{display:flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:0;border-radius:4px;background:transparent;color:var(--sg-accent);cursor:pointer}
7897
+ .sg-cq-refresh:focus-visible,.sg-cq-main:focus-visible,.sg-cq-route-toggle:focus-visible,.sg-cq-info:focus-visible,.sg-cq-gap:focus-visible{outline:2px solid var(--sg-accent);outline-offset:2px}
7898
+ .sg-cq-spin{animation:sg-spin 900ms linear infinite}
7899
+ .sg-cq{display:flex;flex-direction:column;gap:16px}
7900
+ .sg-cq-wait{display:flex;flex-direction:column;gap:20px;padding:16px 12px 20px;border-radius:24px;background:var(--sg-a5)}
7901
+ .sg-cq-wait-top{display:flex;flex-direction:column;gap:8px}
7902
+ .sg-cq-wait-row{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;font-size:13px;line-height:1.4;color:var(--sg-t80)}
7903
+ .sg-cq-wait-scale{display:flex;flex-direction:column;gap:12px}
7904
+ .sg-cq-track{position:relative;width:100%;height:20px}
7905
+ .sg-cq-range{position:absolute;inset:0;z-index:1;width:100%;height:100%;margin:0;padding:0;border-radius:10px;opacity:0;cursor:pointer;appearance:none;-webkit-appearance:none}
7906
+ .sg-cq-rail{position:absolute;inset:0;overflow:hidden;border-radius:10px;border:1px solid color-mix(in srgb,var(--sg-bg) 80%,transparent);background:var(--sg-a8) repeating-linear-gradient(120deg,transparent 0 5.06px,color-mix(in srgb,var(--sg-bg) 30%,transparent) 5.06px 9.06px)}
7907
+ .sg-cq-range:focus-visible~.sg-cq-rail{outline:2px solid var(--sg-accent);outline-offset:2px}
7908
+ .sg-cq-thumb{position:absolute;left:2px;top:2px;bottom:2px;display:flex;align-items:center;justify-content:flex-end;border-radius:8px;border:1px solid var(--sg-bg);background:var(--sg-accent)}
7909
+ .sg-cq-thumb svg{flex:0 0 auto;margin-right:1px}
7910
+ .sg-cq-ends{position:relative;display:flex;align-items:center;justify-content:space-between;font-size:12px;font-weight:500;line-height:1.2;color:var(--sg-t50)}
7911
+ .sg-cq-parity{position:absolute;top:calc(50% + 2px);transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;padding:4px 8px;border-radius:8px;background:var(--sg-a8);font-size:11px;line-height:1.3;text-align:center;color:color-mix(in srgb,var(--sg-accent) 80%,var(--sg-text))}
7912
+ .sg-cq-parity-none{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);white-space:nowrap;font-size:11px;font-weight:400;color:var(--sg-t50)}
7913
+ .sg-cq-rule{height:1px;margin-top:-1px;background:var(--sg-a12)}
7914
+ .sg-cq-extra{display:flex;flex-wrap:nowrap;align-items:center;justify-content:space-between;gap:8px}
7915
+ .sg-cq-extra-icon{flex:0 0 auto;align-self:center;display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:999px;background:var(--sg-green-12);color:var(--sg-ok-ink)}
7916
+ .sg-cq-extra-icon svg{width:16px;height:16px}
7917
+ .sg-cq-extra-text{display:flex;flex:0 1 auto;min-width:0;flex-direction:column;justify-content:center;gap:0;margin-right:auto}
7918
+ .sg-cq-parity{white-space:nowrap}
7919
+ .sg-ws:has(.sg-cq) .sg-ws-top{gap:24px}
7920
+ .sg-cq-info,.sg-cq-gap{padding:0;border:0;background:transparent;font:inherit}
7921
+ .sg-cq-extra-label{display:flex;align-items:center;gap:6px;white-space:nowrap;font-size:12px;line-height:1.2;color:var(--sg-t50)}
7922
+ .sg-cq-extra-amt{white-space:nowrap;font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
7923
+ .sg-cq-extra-note{align-self:center;flex:0 0 auto;margin-left:auto;min-width:0;white-space:nowrap;text-align:right;font-size:9px;line-height:1.2;color:var(--sg-t50)}
7924
+ .sg-cq-info{display:inline-flex;border-radius:4px;color:var(--sg-t50);cursor:help}
7925
+ .sg-cq-list{display:flex;flex-direction:column;gap:8px}
7926
+ .sg-cq-empty{margin:0;padding:24px 0;text-align:center;font-size:13px;line-height:1.4;color:var(--sg-t50)}
7927
+ .sg-cq-card{position:relative;display:flex;flex-direction:column;gap:16px;overflow:clip;padding:16px 12px;border-radius:20px;border:1px solid var(--sg-a12);background:var(--sg-bg)}
7928
+ .sg-cq-card[data-selected]{border-color:color-mix(in srgb,var(--sg-accent) 80%,transparent)}
7929
+ .sg-cq-card[data-unavailable]{background:var(--sg-a4);opacity:.6;filter:grayscale(1)}
7930
+ .sg-cq-main{display:flex;flex-direction:column;align-items:flex-start;gap:20px;width:100%;padding:0;border:0;border-radius:20px;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
7931
+ .sg-cq-main:disabled{cursor:not-allowed}
7932
+ .sg-cq-head{display:flex;align-items:flex-start;gap:8px;width:100%;padding-right:min(150px,42%)}
7933
+ .sg-cq-radio{flex:0 0 auto;display:grid;place-items:center;width:16px;height:16px;margin-top:1.6px;border-radius:999px;border:1px solid var(--sg-a50)}
7934
+ .sg-cq-radio[data-on]{border-color:var(--sg-accent)}
7935
+ .sg-cq-radio[data-on]::after{content:"";width:8px;height:8px;border-radius:999px;background:var(--sg-accent)}
7936
+ .sg-cq-amount{min-width:0;font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
7937
+ .sg-cq-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
7938
+ .sg-cq-tag{position:absolute;top:-2px;right:-2px;display:flex;align-items:center;gap:8px;padding:10px 32px 12px;border-radius:0 0 0 40px;background:var(--sg-a8);font-size:12px;font-weight:500;line-height:1.4;letter-spacing:.12px}
7939
+ .sg-cq-tag[data-kind="netting"]{background:var(--sg-green-12)}
7940
+ .sg-cq-tag[data-kind="purple"]{background:color-mix(in srgb,var(--sg-purple) 8%,transparent)}
7941
+ .sg-cq-tag-item{display:flex;align-items:center;gap:8px;white-space:nowrap}
7942
+ .sg-cq-tag-dot{width:4px;height:4px;border-radius:999px;background:var(--sg-cq-dot)}
7943
+ .sg-overlay[data-sg-overlay="drawer"] .sg-cq[data-layout="card"] .sg-cq-tag{padding:10px 20px 12px;border-radius:0 0 0 32px;font-size:11px;letter-spacing:.11px;gap:6px}
7944
+ .sg-cq-tag [data-tone="brand"]{color:var(--sg-accent)}
7945
+ .sg-cq-tag [data-tone="green"]{color:var(--sg-ok-ink)}
7946
+ .sg-cq-tag [data-tone="purple"]{color:var(--sg-purple)}
7947
+ .sg-widget[data-sg-mode="dark"] .sg-cq-tag [data-tone="brand"]{color:var(--sg-info)}
7948
+ .sg-cq-stats{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:0 12px 0 24px}
7949
+ .sg-cq-cols{display:flex;align-items:center;gap:32px;white-space:nowrap}
7950
+ .sg-cq-col{display:flex;flex-direction:column;justify-content:center;gap:6px}
7951
+ .sg-cq-col-label{font-size:10px;font-weight:500;line-height:1.2;text-transform:uppercase;color:var(--sg-t50)}
7952
+ .sg-cq-col-value{font-size:14px;line-height:1.2;color:var(--sg-text)}
7953
+ .sg-cq-note{width:125px;text-align:right;font-size:12px;line-height:1.2;color:var(--sg-t50)}
7954
+ .sg-cq-why{padding-left:24px;font-size:13px;line-height:1.3;color:var(--sg-t50)}
7955
+ .sg-cq-route{display:flex;flex-direction:column;gap:10px;padding-left:24px}
7956
+ .sg-cq-route-toggle{display:flex;align-items:center;gap:4px;width:fit-content;padding:0;border:0;border-radius:4px;background:transparent;font:inherit;font-size:10px;font-weight:500;line-height:1.2;text-transform:uppercase;color:var(--sg-t50);cursor:pointer}
7957
+ .sg-cq-route-toggle svg{color:var(--sg-text)}
7958
+ .sg-cq-hops{display:flex;flex-wrap:wrap;align-items:flex-start;gap:4px}
7959
+ .sg-cq-hop{display:flex;align-items:flex-start;gap:4px}
7960
+ .sg-cq-arrow{flex:0 0 auto;color:var(--sg-accent)}
7961
+ .sg-cq-hop-body{display:flex;flex-direction:column;gap:4px}
7962
+ .sg-cq-hop-name{display:flex;align-items:center;gap:4px;font-size:14px;line-height:1.2;color:var(--sg-text)}
7963
+ .sg-cq-hop-chain{white-space:nowrap;font-size:12px;line-height:1.2;color:var(--sg-t50)}
7964
+ .sg-cq .sg-tok[data-size="xxs"] .sg-tok-badge{min-width:8px;width:8px;height:8px;right:-1px;bottom:-1px;border-width:1px;border-color:var(--sg-bg);font-size:4px;padding:0}
7965
+ .sg-cq .sg-tok[data-size="xs"] .sg-tok-badge{min-width:11px;width:11px;height:11px;right:-3px;bottom:-3px;border-width:1px;border-color:var(--sg-bg);font-size:4px;padding:0}
7966
+ /* Back-link and gap scoped to Compare quotes (Figma: 14px t50 compact, 12px t50 wide, 24px/16px to the title). */
7967
+ .sg-ws:has(.sg-cq) .sg-ws-back{font-size:14px;font-weight:500;color:var(--sg-t50)}
7968
+ .sg-dialog .sg-ws:has(.sg-cq):not([data-wide]) .sg-ws-top{gap:16px}
7969
+ /* Wide: compact cards, the tag a centred band across the card's top, the route as inline marks */
7970
+ .sg-cq[data-layout="side"] .sg-cq-card{gap:12px;padding:0 0 16px;border-radius:20px}
7971
+ .sg-cq[data-layout="side"] .sg-cq-tag{position:static;justify-content:center;width:100%;padding:2px 20px 4px;border-radius:0;font-size:11px;line-height:1.4;letter-spacing:.11px;gap:6px}
7972
+ .sg-ws[data-wide]:has(.sg-cq) .sg-ws-top{gap:16px}
7973
+ .sg-ws[data-wide]:has(.sg-cq) .sg-ws-title{font-size:16px}
7974
+ .sg-ws[data-wide]:has(.sg-cq) .sg-ws-back{font-size:12px;font-weight:400;color:var(--sg-t50)}
7975
+ .sg-cq[data-layout="side"]{gap:12px}
7976
+ .sg-cq[data-layout="side"] .sg-cq-wait{padding:16px 12px 20px;gap:20px}
7977
+ .sg-cq[data-layout="side"] .sg-cq-rule{margin-bottom:-8px}
7978
+ .sg-cq[data-layout="side"] .sg-cq-card:not(:has(.sg-cq-tag)){padding-top:12px}
7979
+ .sg-cq[data-layout="side"] .sg-cq-main{gap:20px;padding:0 12px;border-radius:0}
7980
+ .sg-cq[data-layout="side"] .sg-cq-head{padding-right:0!important}
7981
+ .sg-cq[data-layout="side"] .sg-cq-amount{font-size:15px}
7982
+ .sg-cq[data-layout="side"] .sg-cq-stats{padding:0}
7983
+ .sg-cq[data-layout="side"] .sg-cq-cols{gap:20px}
7984
+ .sg-cq[data-layout="side"] .sg-cq-col{gap:4px}
7985
+ .sg-cq[data-layout="side"] .sg-cq-col-label{font-size:9px}
7986
+ .sg-cq[data-layout="side"] .sg-cq-col-value{font-size:13px}
7987
+ .sg-cq[data-layout="side"] .sg-cq-card[data-selected]{border-color:color-mix(in srgb,var(--sg-accent) 50%,transparent)}
7988
+ .sg-cq[data-layout="side"] .sg-cq-extra-amt{font-size:15px}
7989
+ .sg-cq[data-layout="side"] .sg-cq-extra-label{gap:4px}
7990
+ .sg-cq[data-layout="side"] .sg-cq-info svg{width:12px;height:12px}
7991
+ .sg-cq[data-layout="side"] .sg-cq-card:not(:has(.sg-cq-tag)) .sg-cq-main{padding-top:0}
7992
+ .sg-cq-route-icons{display:flex;align-items:center;gap:2px}
7993
+ .sg-cq-route-icons .sg-cq-arrow{width:10px;height:10px}
7994
+ .sg-cq-hop-inline{display:flex;align-items:center;gap:2px}
7995
+ .sg-cq-hop-inline>span{display:flex}
7996
+ .sg-cq-gap{display:inline-flex;padding:0 2px;border-radius:4px;color:var(--sg-accent);text-decoration:underline;cursor:help}
7997
+ .sg-cq[data-layout="side"] .sg-cq-wait-scale .sg-cq-parity{flex-direction:row;gap:4px}
7998
+ /* Below Figma's widths the cards must shrink, not clip (narrow page; container = the sheet). */
7999
+ .sg-ws:has(.sg-cq){container-type:inline-size}
8000
+ @container (max-width:300px){
8001
+ .sg-cq-head{padding-right:0!important}
8002
+ .sg-cq-stats{flex-wrap:wrap;gap:8px;padding-left:0}
8003
+ .sg-cq-cols{flex-wrap:wrap;gap:12px;white-space:normal}
8004
+ .sg-cq-note{width:auto;max-width:100%;text-align:left}
8005
+ .sg-cq-route-icons{flex-wrap:wrap}
8006
+ .sg-cq-extra{flex-wrap:wrap}
8007
+ .sg-cq-extra-note{margin-left:0;text-align:left}
8008
+ }
8009
+ @media (prefers-reduced-motion:reduce){.sg-cq-spin{animation:none}}
7688
8010
  `;
7689
8011
  var injected = false;
7690
8012
  function injectStyles() {
@@ -8369,7 +8691,7 @@ function groupDecimal2(value) {
8369
8691
  if (!match) return value;
8370
8692
  return `${match[1]}${match[2].replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${match[3] ?? ""}`;
8371
8693
  }
8372
- function humanAmount(n, maxFrac = 6) {
8694
+ function humanAmount2(n, maxFrac = 6) {
8373
8695
  if (!Number.isFinite(n)) return String(n);
8374
8696
  if (n === 0) return "0";
8375
8697
  const digits = Math.min(Math.max(0, Math.trunc(maxFrac)), 8);
@@ -8505,7 +8827,7 @@ function BalanceColumn(props) {
8505
8827
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-bal", children: [
8506
8828
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-usd sg-mono", children: props.usd == null ? "\u2014" : formatBalanceUsd(props.usd) }),
8507
8829
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-bal-amt sg-mono", children: [
8508
- humanAmount(props.amount, 6),
8830
+ humanAmount2(props.amount, 6),
8509
8831
  " ",
8510
8832
  props.symbol
8511
8833
  ] })
@@ -9987,34 +10309,64 @@ function SheetFrame(props) {
9987
10309
  document.addEventListener("keydown", onKey, true);
9988
10310
  return () => document.removeEventListener("keydown", onKey, true);
9989
10311
  }, []);
9990
- return /* @__PURE__ */ jsxRuntime.jsxs(
9991
- "div",
9992
- {
9993
- className: "sg-ws",
9994
- "data-wide": props.wide || void 0,
9995
- role: "dialog",
9996
- "aria-modal": "true",
9997
- "aria-label": props.label,
9998
- ref: sheetRef,
9999
- tabIndex: -1,
10000
- style: props.minHeight ? { minHeight: props.minHeight } : void 0,
10001
- children: [
10002
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-top", children: [
10003
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-head", children: [
10004
- /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-ws-back", onClick: () => closeRef.current(), children: [
10005
- /* @__PURE__ */ jsxRuntime.jsx(ArrowLeft, {}),
10006
- props.backLabel ?? "Back to Exchange"
10312
+ return (
10313
+ // biome-ignore lint/a11y/noStaticElementInteractions: role is "region" or "dialog" — both carry semantics; the Tab trap only runs for the modal (dialog) case.
10314
+ // biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-modal is set only when role is "dialog" (asRegion is false); a region never receives it.
10315
+ /* @__PURE__ */ jsxRuntime.jsxs(
10316
+ "div",
10317
+ {
10318
+ className: "sg-ws",
10319
+ "data-wide": props.wide || void 0,
10320
+ role: props.asRegion ? "region" : "dialog",
10321
+ "aria-modal": props.asRegion ? void 0 : "true",
10322
+ "aria-label": props.label,
10323
+ ref: sheetRef,
10324
+ tabIndex: -1,
10325
+ onKeyDown: props.trapFocus ? (event) => {
10326
+ if (event.key !== "Tab") return;
10327
+ const root = sheetRef.current;
10328
+ if (!root) return;
10329
+ const focusable = Array.from(
10330
+ root.querySelectorAll('a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])')
10331
+ ).filter((el) => el.offsetParent !== null || el === document.activeElement);
10332
+ if (focusable.length === 0) {
10333
+ event.preventDefault();
10334
+ root.focus();
10335
+ return;
10336
+ }
10337
+ const first = focusable[0];
10338
+ const last = focusable[focusable.length - 1];
10339
+ const active = document.activeElement;
10340
+ if (event.shiftKey && (active === first || active === root)) {
10341
+ event.preventDefault();
10342
+ last.focus();
10343
+ } else if (!event.shiftKey && active === last) {
10344
+ event.preventDefault();
10345
+ first.focus();
10346
+ }
10347
+ } : void 0,
10348
+ style: props.minHeight ? { minHeight: props.minHeight } : void 0,
10349
+ children: [
10350
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-top", children: [
10351
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-head", children: [
10352
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-ws-back", onClick: () => closeRef.current(), children: [
10353
+ /* @__PURE__ */ jsxRuntime.jsx(ArrowLeft, {}),
10354
+ props.backLabel ?? "Back to Exchange"
10355
+ ] }),
10356
+ props.wide || props.hideClose ? null : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-ws-close", onClick: () => closeRef.current(), "aria-label": `Close ${props.label.toLowerCase()}`, children: /* @__PURE__ */ jsxRuntime.jsx(CloseX, {}) })
10007
10357
  ] }),
10008
- props.wide ? null : /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-ws-close", onClick: () => closeRef.current(), "aria-label": `Close ${props.label.toLowerCase()}`, children: /* @__PURE__ */ jsxRuntime.jsx(CloseX, {}) })
10358
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-main", children: [
10359
+ props.titleAddon ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-titlerow", children: [
10360
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-ws-title", id: titleId, children: props.title }),
10361
+ props.titleAddon
10362
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-ws-title", id: titleId, children: props.title }),
10363
+ props.children
10364
+ ] })
10009
10365
  ] }),
10010
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-main", children: [
10011
- /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-ws-title", id: titleId, children: props.title }),
10012
- props.children
10013
- ] })
10014
- ] }),
10015
- props.footer ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-ws-foot", children: props.footer }) : null
10016
- ]
10017
- }
10366
+ props.footer ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-ws-foot", children: props.footer }) : null
10367
+ ]
10368
+ }
10369
+ )
10018
10370
  );
10019
10371
  }
10020
10372
  function WalletChip(props) {
@@ -11316,6 +11668,7 @@ function PillLauncher(props) {
11316
11668
  const openAs = props.openAs === "drawer" ? "drawer" : "modal";
11317
11669
  const [open, setOpen] = react.useState(!!props.defaultOpen);
11318
11670
  const buttonRef = react.useRef(null);
11671
+ const dialogRef = react.useRef(null);
11319
11672
  const close = () => {
11320
11673
  setOpen(false);
11321
11674
  requestAnimationFrame(() => buttonRef.current?.focus());
@@ -11323,7 +11676,32 @@ function PillLauncher(props) {
11323
11676
  react.useEffect(() => {
11324
11677
  if (!open) return;
11325
11678
  const onKey = (e) => {
11326
- if (e.key === "Escape") close();
11679
+ if (e.key === "Escape") {
11680
+ close();
11681
+ return;
11682
+ }
11683
+ if (e.key !== "Tab") return;
11684
+ const root = dialogRef.current;
11685
+ if (!root) return;
11686
+ const list = Array.from(root.querySelectorAll("a[href],button,input,select,textarea,[tabindex]")).filter(
11687
+ (el) => el.tabIndex >= 0 && !el.hasAttribute("disabled") && el.getClientRects().length > 0
11688
+ );
11689
+ if (list.length === 0) {
11690
+ e.preventDefault();
11691
+ return;
11692
+ }
11693
+ const first = list[0];
11694
+ const last = list[list.length - 1];
11695
+ const idx = list.indexOf(document.activeElement);
11696
+ if (e.shiftKey) {
11697
+ if (idx <= 0) {
11698
+ e.preventDefault();
11699
+ last.focus();
11700
+ }
11701
+ } else if (idx === -1 || idx === list.length - 1) {
11702
+ e.preventDefault();
11703
+ first.focus();
11704
+ }
11327
11705
  };
11328
11706
  document.addEventListener("keydown", onKey);
11329
11707
  return () => document.removeEventListener("keydown", onKey);
@@ -11338,7 +11716,7 @@ function PillLauncher(props) {
11338
11716
  ] }),
11339
11717
  open ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-overlay", "data-sg-overlay": openAs, children: [
11340
11718
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-overlay-scrim", tabIndex: -1, "aria-label": "Close", onClick: close }),
11341
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-dialog", role: "dialog", "aria-modal": "true", "aria-label": props.verb, children: props.children(close, openAs) })
11719
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: dialogRef, className: "sg-dialog", role: "dialog", "aria-modal": "true", "aria-label": props.verb, children: props.children(close, openAs) })
11342
11720
  ] }) : null
11343
11721
  ] });
11344
11722
  }
@@ -12011,6 +12389,658 @@ function useSolanaSourceFlow(args) {
12011
12389
  }, []);
12012
12390
  return { status, preview, plan, error, balanceRaw, cost, progress, signature, lastTxEntry, sent, addressed, needsPreparation, insufficient, solShort, run, reset };
12013
12391
  }
12392
+ function BackArrow() {
12393
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 12H5m6-6-6 6 6 6", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) });
12394
+ }
12395
+ function ChevronDown2({ up = false }) {
12396
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", style: up ? { transform: "rotate(180deg)" } : void 0, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 9 6 6 6-6", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) });
12397
+ }
12398
+ function PolicyShield() {
12399
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
12400
+ /* @__PURE__ */ jsxRuntime.jsx(
12401
+ "path",
12402
+ {
12403
+ d: "M17.0089 5.8002V7.3252C17.0089 7.85853 16.7589 8.35853 16.3255 8.66686L7.15885 15.3835C6.56719 15.8169 5.75885 15.8169 5.17552 15.3752L3.97552 14.4752C3.43385 14.0669 2.99219 13.1835 2.99219 12.5085V5.8002C2.99219 4.86686 3.70885 3.83353 4.58385 3.50853L9.14219 1.8002C9.61719 1.6252 10.3839 1.6252 10.8589 1.8002L15.4172 3.50853C16.2922 3.83353 17.0089 4.86686 17.0089 5.8002Z",
12404
+ fill: "currentColor"
12405
+ }
12406
+ ),
12407
+ /* @__PURE__ */ jsxRuntime.jsx(
12408
+ "path",
12409
+ {
12410
+ d: "M15.682 10.2829C16.232 9.88287 17.007 10.2745 17.007 10.9579V12.5245C17.007 13.1995 16.5654 14.0745 16.0237 14.4829L11.4654 17.8912C11.0654 18.1829 10.532 18.3329 9.9987 18.3329C9.46537 18.3329 8.93204 18.1829 8.53204 17.8829L7.84037 17.3662C7.39037 17.0329 7.39037 16.3579 7.84871 16.0245L15.682 10.2829Z",
12411
+ fill: "currentColor"
12412
+ }
12413
+ )
12414
+ ] });
12415
+ }
12416
+ function InfoSquare() {
12417
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
12418
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "2", y: "2", width: "20", height: "20", rx: "6", fill: "currentColor" }),
12419
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 10.8v6", stroke: "var(--sg-bg)", strokeWidth: "2.1", strokeLinecap: "round" }),
12420
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "7.7", r: "1.25", fill: "var(--sg-bg)" })
12421
+ ] });
12422
+ }
12423
+ function InfoOutline() {
12424
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
12425
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "9.2", stroke: "currentColor", strokeWidth: "1.7" }),
12426
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 11v5.4", stroke: "currentColor", strokeWidth: "1.9", strokeLinecap: "round" }),
12427
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "7.8", r: "1.15", fill: "currentColor" })
12428
+ ] });
12429
+ }
12430
+ var FLAGGED_CATEGORY_HINTS = {
12431
+ "High-risk entity": "An entity associated with elevated financial-crime risk based on available screening data.",
12432
+ "Politically exposed person (PEP)": "A person who holds or has held a prominent public function, including close associates and family members.",
12433
+ "Unknown / unclassified": "The screening provider could not confidently assign the entity to a known risk category.",
12434
+ "Unclassified risk": "The screening provider could not confidently assign the entity to a known risk category."
12435
+ };
12436
+ var POLICY_DETAILS = {
12437
+ "always-blocked": "Cannot be changed or disabled",
12438
+ blocked: "Stops the order",
12439
+ flagged: "Does not automatically block"
12440
+ };
12441
+ function Hint({ id, label: label2, text, hint }) {
12442
+ const tipId = react.useId();
12443
+ const open = hint.open === id;
12444
+ const ptr = react.useRef("");
12445
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12446
+ /* @__PURE__ */ jsxRuntime.jsx(
12447
+ "button",
12448
+ {
12449
+ type: "button",
12450
+ className: "sg-cd-hint",
12451
+ "data-sg-hint": "",
12452
+ "aria-label": `About ${label2}`,
12453
+ "aria-expanded": open,
12454
+ "aria-describedby": open ? tipId : void 0,
12455
+ onPointerEnter: (e) => {
12456
+ ptr.current = e.pointerType;
12457
+ if (e.pointerType === "mouse") hint.setOpen(id);
12458
+ },
12459
+ onPointerLeave: (e) => {
12460
+ if (e.pointerType === "mouse") hint.setOpen(null);
12461
+ },
12462
+ onClick: () => {
12463
+ hint.setOpen(ptr.current === "mouse" ? id : open ? null : id);
12464
+ ptr.current = "";
12465
+ },
12466
+ onBlur: () => {
12467
+ ptr.current = "";
12468
+ },
12469
+ children: /* @__PURE__ */ jsxRuntime.jsx(InfoOutline, {})
12470
+ }
12471
+ ),
12472
+ open ? /* @__PURE__ */ jsxRuntime.jsx("span", { role: "tooltip", id: tipId, className: "sg-cd-tip", children: text }) : null
12473
+ ] });
12474
+ }
12475
+ function CheckRow2({ check: check2, hideNote }) {
12476
+ const label2 = check2.id === "risk" ? check2.ok ? "Risk screening passed" : "Risk screening failed" : check2.label;
12477
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "sg-cd-check", "data-ok": check2.ok, children: [
12478
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-check-line", children: [
12479
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-mark", "data-ok": check2.ok, children: check2.ok ? /* @__PURE__ */ jsxRuntime.jsx(Tick, { size: 12 }) : /* @__PURE__ */ jsxRuntime.jsx(Cross, { size: 12 }) }),
12480
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-label", children: label2 }),
12481
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sr-only", children: check2.ok ? " \u2014 passed" : " \u2014 failed" })
12482
+ ] }),
12483
+ check2.note && !hideNote ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-note", children: check2.note }) : null,
12484
+ check2.reasons.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-reason", children: humanizeComplianceReason(reason) }, reason))
12485
+ ] });
12486
+ }
12487
+ function Fact2({ label: label2, value, title, mono = false }) {
12488
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-fact", children: [
12489
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { children: label2 }),
12490
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { title, className: mono ? "sg-mono" : void 0, children: value })
12491
+ ] });
12492
+ }
12493
+ function QuoteChecks2(props) {
12494
+ const { compliance, cv, checks } = props;
12495
+ const allPassed = cv.tone === "ok" && checks.length > 0 && checks.every((c) => c.ok);
12496
+ const summary = allPassed ? "All checks passed" : cv.label;
12497
+ const orphans = unattributedComplianceReasons(compliance, cv);
12498
+ const wallets = distinctScreenedWallets(compliance);
12499
+ const jurisdiction = formatJurisdiction(compliance?.sourceJurisdiction, compliance?.sourceCountry);
12500
+ const hasDetails = Boolean(jurisdiction || wallets.length || compliance?.checkId);
12501
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-panel", children: [
12502
+ /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cd-card", children: [
12503
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-summary", children: [
12504
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-summary-head", "data-tone": cv.tone, children: [
12505
+ cv.tone === "blocked" || cv.tone === "warn" ? /* @__PURE__ */ jsxRuntime.jsx(CloseCircle, {}) : cv.tone === "neutral" ? /* @__PURE__ */ jsxRuntime.jsx(PendingCircle, {}) : /* @__PURE__ */ jsxRuntime.jsx(TickCircle, {}),
12506
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-summary-title", children: summary })
12507
+ ] }),
12508
+ checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "sg-cd-summary-sub", children: [
12509
+ checks.length,
12510
+ " check",
12511
+ checks.length === 1 ? " was" : "s were",
12512
+ " completed for this quote"
12513
+ ] }) : (
12514
+ // No decision was issued. Listing the controls here would be ticks for a verdict nobody gave,
12515
+ // and an unconfigured gate is not a set of passed checks.
12516
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-summary-sub", children: "The gateway returned no compliance decision for this quote, so there is nothing to show. It is not a failed check." })
12517
+ )
12518
+ ] }),
12519
+ checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cd-checks", children: checks.map((check2) => (
12520
+ // The Figma row carries no sub-line: with ONE screened wallet the note would repeat the
12521
+ // address Quote details names two cards down. Any other note (a count of wallets) stays.
12522
+ /* @__PURE__ */ jsxRuntime.jsx(CheckRow2, { check: check2, hideNote: check2.id === "screening" && wallets.length === 1 && hasDetails }, check2.id)
12523
+ )) }) : null,
12524
+ orphans.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cd-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
12525
+ props.direct && checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-scope", children: DIRECT_SCOPE_NOTE }) : null
12526
+ ] }),
12527
+ compliance?.flaggedCategories?.length ? /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cd-card", children: [
12528
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-cd-card-title", children: "Flagged, not blocking" }),
12529
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-flags", children: compliance.flaggedCategories.map(categoryLabel).join(" \xB7 ") }),
12530
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-scope", children: "The policy records these and still allows the payment. They do not stop settlement." })
12531
+ ] }) : null,
12532
+ hasDetails ? /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cd-card", children: [
12533
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-card-head", children: [
12534
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-card-glyph", children: /* @__PURE__ */ jsxRuntime.jsx(InfoSquare, {}) }),
12535
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-cd-card-title", children: "Quote details" })
12536
+ ] }),
12537
+ /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "sg-cd-facts", children: [
12538
+ jurisdiction ? /* @__PURE__ */ jsxRuntime.jsx(Fact2, { label: "Jurisdiction", value: jurisdiction }) : null,
12539
+ wallets.map((w, i) => /* @__PURE__ */ jsxRuntime.jsx(Fact2, { label: wallets.length > 1 ? i === 0 ? "Payer" : "Recipient" : "Wallet", value: shortAddr(w), title: w, mono: false }, w)),
12540
+ compliance?.checkId ? /* @__PURE__ */ jsxRuntime.jsx(Fact2, { label: "Check ID", value: compliance.checkId, mono: true }) : null
12541
+ ] })
12542
+ ] }) : null
12543
+ ] });
12544
+ }
12545
+ function riskRuleCount() {
12546
+ return SCREENING_BUCKETS.reduce((total, bucket) => total + bucket.categories.length, 0);
12547
+ }
12548
+ function appliedPolicies(compliance) {
12549
+ const names = compliance?.appliedPolicyNames ?? [];
12550
+ const legislation = compliance?.appliedLegislation ?? [];
12551
+ const applied = Boolean(compliance?.decision || compliance?.policyVersion?.trim()) || names.length > 0;
12552
+ if (!applied) return [];
12553
+ const ids = compliance?.appliedPolicyIds ?? [];
12554
+ const summary = `${riskRuleCount()} risk rules`;
12555
+ const statements = legislation.map((name, i) => ({ id: `legislation-${i}-${name}`, name, summary: null, buckets: null }));
12556
+ if (names.length === 0) return [{ id: "zd-screening-matrix", name: "Transaction screening", summary, buckets: SCREENING_BUCKETS }, ...statements];
12557
+ if (names.length === 1) return [{ id: ids[0] ?? names[0], name: names[0], summary, buckets: SCREENING_BUCKETS }, ...statements];
12558
+ return [
12559
+ ...names.map((name, i) => ({ id: ids[i] ?? `${name}-${i}`, name, summary: null, buckets: null })),
12560
+ ...statements,
12561
+ { id: "zd-screening-matrix", name: "Transaction screening", summary, buckets: SCREENING_BUCKETS }
12562
+ ];
12563
+ }
12564
+ function PolicyBuckets({ policyId, layout, hint }) {
12565
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: SCREENING_BUCKETS.map((bucket) => {
12566
+ const detail = POLICY_DETAILS[bucket.outcome];
12567
+ const bucketHint = `${policyId}:${bucket.outcome}`;
12568
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-bucket", "data-outcome": bucket.outcome, children: [
12569
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-bucket-head", children: [
12570
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-bucket-title", children: bucket.title }),
12571
+ layout === "side" ? /* @__PURE__ */ jsxRuntime.jsx(Hint, { id: bucketHint, label: bucket.title, text: detail, hint }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-bucket-detail", children: detail })
12572
+ ] }),
12573
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cd-cats", children: bucket.categories.map((category) => {
12574
+ const text = bucket.outcome === "flagged" ? FLAGGED_CATEGORY_HINTS[category] : void 0;
12575
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
12576
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-dot", "aria-hidden": "true" }),
12577
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: category }),
12578
+ text ? /* @__PURE__ */ jsxRuntime.jsx(Hint, { id: `${policyId}:${category}`, label: category, text, hint }) : null
12579
+ ] }, category);
12580
+ }) })
12581
+ ] }, bucket.outcome);
12582
+ }) });
12583
+ }
12584
+ function PolicyRow({
12585
+ policy,
12586
+ open,
12587
+ onToggle,
12588
+ layout,
12589
+ hint,
12590
+ policyVersion
12591
+ }) {
12592
+ const bodyId = react.useId();
12593
+ const head = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12594
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-policy-mark", children: /* @__PURE__ */ jsxRuntime.jsx(PolicyShield, {}) }),
12595
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-policy-text", children: [
12596
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-policy-name", children: policy.name }),
12597
+ policy.summary ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-policy-sub", children: policy.summary }) : null
12598
+ ] }),
12599
+ policy.buckets ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-policy-chev", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDown2, { up: open }) }) : null
12600
+ ] });
12601
+ if (!policy.buckets) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cd-policy", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cd-policy-head", "data-static": "", children: head }) });
12602
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-policy", "data-open": open, children: [
12603
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-cd-policy-head", "aria-expanded": open, "aria-controls": bodyId, onClick: onToggle, children: head }),
12604
+ open ? /* @__PURE__ */ jsxRuntime.jsxs("div", { id: bodyId, className: "sg-cd-policy-body", children: [
12605
+ /* @__PURE__ */ jsxRuntime.jsx(PolicyBuckets, { policyId: policy.id, layout, hint }),
12606
+ policyVersion ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "sg-cd-policy-version sg-mono", children: [
12607
+ "Policy version ",
12608
+ policyVersion
12609
+ ] }) : null
12610
+ ] }) : null
12611
+ ] });
12612
+ }
12613
+ function AppliedPolicies({ policies, layout, hint, policyVersion }) {
12614
+ const [openId, setOpenId] = react.useState(() => policies.find((p) => p.buckets)?.id ?? null);
12615
+ if (policies.length === 0) {
12616
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cd-panel", children: /* @__PURE__ */ jsxRuntime.jsx("section", { className: "sg-cd-card", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-summary", children: [
12617
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-summary-head", "data-tone": "neutral", children: [
12618
+ /* @__PURE__ */ jsxRuntime.jsx(PendingCircle, {}),
12619
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-summary-title", children: "No policy decision was returned" })
12620
+ ] }),
12621
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-summary-sub", children: "There is no applied policy to show for this quote. It is not a failed check." })
12622
+ ] }) }) });
12623
+ }
12624
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cd-panel sg-cd-policies", children: policies.map((policy) => /* @__PURE__ */ jsxRuntime.jsx(
12625
+ PolicyRow,
12626
+ {
12627
+ policy,
12628
+ open: openId === policy.id,
12629
+ onToggle: () => setOpenId(openId === policy.id ? null : policy.id),
12630
+ layout,
12631
+ hint,
12632
+ policyVersion: openId === policy.id ? policyVersion : void 0
12633
+ },
12634
+ policy.id
12635
+ )) });
12636
+ }
12637
+ function ComplianceDetails(props) {
12638
+ const [tab, setTab] = react.useState("checks");
12639
+ const [hintOpen, setHintOpen] = react.useState(null);
12640
+ const rootRef = react.useRef(null);
12641
+ const ids = react.useId();
12642
+ const compliance = props.compliance ?? null;
12643
+ const cv = complianceView(compliance, props.hasQuote ?? true);
12644
+ const allChecks = complianceChecks(compliance, cv);
12645
+ const checks = props.direct ? allChecks.filter((c) => DIRECT_CHECK_IDS.includes(c.id)) : allChecks;
12646
+ const policies = appliedPolicies(compliance);
12647
+ const policyVersion = compliance?.policyVersion?.trim() || void 0;
12648
+ const onBackRef = react.useRef(props.onBack);
12649
+ onBackRef.current = props.onBack;
12650
+ const hintRef = react.useRef(hintOpen);
12651
+ hintRef.current = hintOpen;
12652
+ react.useEffect(() => {
12653
+ rootRef.current?.focus({ preventScroll: true });
12654
+ const onKey = (e) => {
12655
+ if (e.key !== "Escape") return;
12656
+ e.stopPropagation();
12657
+ if (hintRef.current) setHintOpen(null);
12658
+ else onBackRef.current();
12659
+ };
12660
+ const onPointer = (e) => {
12661
+ if (hintRef.current && !e.target?.closest?.("[data-sg-hint]")) setHintOpen(null);
12662
+ };
12663
+ document.addEventListener("keydown", onKey, true);
12664
+ document.addEventListener("pointerdown", onPointer, true);
12665
+ return () => {
12666
+ document.removeEventListener("keydown", onKey, true);
12667
+ document.removeEventListener("pointerdown", onPointer, true);
12668
+ };
12669
+ }, []);
12670
+ const tabKeys = (e) => {
12671
+ const order = ["checks", "policy"];
12672
+ let next = null;
12673
+ if (e.key === "Home") next = order[0];
12674
+ else if (e.key === "End") next = order[order.length - 1];
12675
+ else if (e.key === "ArrowRight") next = order[(order.indexOf(tab) + 1) % order.length];
12676
+ else if (e.key === "ArrowLeft") next = order[(order.indexOf(tab) - 1 + order.length) % order.length];
12677
+ if (next === null) return;
12678
+ e.preventDefault();
12679
+ setTab(next);
12680
+ document.getElementById(`${ids}-tab-${next}`)?.focus();
12681
+ };
12682
+ const hint = { open: hintOpen, setOpen: setHintOpen };
12683
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cd", "data-layout": props.layout, "aria-label": "Compliance details", ref: rootRef, tabIndex: -1, children: [
12684
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-cd-back", onClick: props.onBack, children: [
12685
+ /* @__PURE__ */ jsxRuntime.jsx(BackArrow, {}),
12686
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Back to Exchange" })
12687
+ ] }),
12688
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "sg-cd-title", children: "Compliance details" }),
12689
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-tabs", role: "tablist", "aria-label": "Compliance details sections", children: [
12690
+ /* @__PURE__ */ jsxRuntime.jsx(
12691
+ "button",
12692
+ {
12693
+ type: "button",
12694
+ role: "tab",
12695
+ id: `${ids}-tab-checks`,
12696
+ "aria-selected": tab === "checks",
12697
+ "aria-controls": `${ids}-panel`,
12698
+ tabIndex: tab === "checks" ? 0 : -1,
12699
+ "data-active": tab === "checks",
12700
+ className: "sg-cd-tab",
12701
+ onClick: () => setTab("checks"),
12702
+ onKeyDown: tabKeys,
12703
+ children: "Quote checks"
12704
+ }
12705
+ ),
12706
+ /* @__PURE__ */ jsxRuntime.jsxs(
12707
+ "button",
12708
+ {
12709
+ type: "button",
12710
+ role: "tab",
12711
+ id: `${ids}-tab-policy`,
12712
+ "aria-selected": tab === "policy",
12713
+ "aria-controls": `${ids}-panel`,
12714
+ tabIndex: tab === "policy" ? 0 : -1,
12715
+ "data-active": tab === "policy",
12716
+ className: "sg-cd-tab",
12717
+ onClick: () => setTab("policy"),
12718
+ onKeyDown: tabKeys,
12719
+ children: [
12720
+ "Applied policies",
12721
+ policies.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-tab-count", children: policies.length }) : null
12722
+ ]
12723
+ }
12724
+ )
12725
+ ] }),
12726
+ /* @__PURE__ */ jsxRuntime.jsx("div", { id: `${ids}-panel`, role: "tabpanel", "aria-labelledby": `${ids}-tab-${tab}`, children: tab === "checks" ? /* @__PURE__ */ jsxRuntime.jsx(QuoteChecks2, { compliance, cv, checks, direct: !!props.direct }) : /* @__PURE__ */ jsxRuntime.jsx(AppliedPolicies, { policies, layout: props.layout, hint, policyVersion }) })
12727
+ ] });
12728
+ }
12729
+ function RefreshGlyph({ spinning }) {
12730
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: spinning ? "sg-cq-spin" : void 0, width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4.22639 4.22667C4.71306 3.74 5.28639 3.35333 5.91972 3.08667C6.57972 2.80667 7.27306 2.66667 7.99306 2.66667V1.33333C7.09306 1.33333 6.21972 1.50667 5.39972 1.86C4.60639 2.19333 3.89306 2.68 3.27972 3.28667C2.66639 3.9 2.18639 4.61333 1.85306 5.40667C1.50639 6.22667 1.32639 7.1 1.32639 8C1.32639 8.9 1.49972 9.77333 1.85306 10.5933C2.18639 11.3867 2.66639 12.1 3.27972 12.7133C3.39306 12.8267 3.51306 12.9267 3.62639 13.0333L1.99306 14.6667H5.99306V10.6667L4.57306 12.0867C4.45306 11.9867 4.33306 11.88 4.22639 11.7667C3.7398 11.2804 3.3506 10.7057 3.07972 10.0733C2.79972 9.41333 2.65972 8.72 2.65972 8C2.65972 7.28 2.79972 6.58 3.07972 5.92667C3.34639 5.29333 3.73306 4.72 4.22639 4.23333V4.22667ZM12.7131 3.28667C12.5997 3.17333 12.4797 3.07333 12.3664 2.96667L13.9997 1.33333H9.99972V5.33333L11.4197 3.91333C11.5397 4.01333 11.6597 4.12 11.7664 4.23333C12.2597 4.72667 12.6397 5.29333 12.9131 5.92667C13.1931 6.58667 13.3331 7.28 13.3331 8C13.3331 8.72 13.1931 9.42 12.9131 10.0733C12.6464 10.7067 12.2597 11.28 11.7664 11.7667C11.2797 12.2533 10.7064 12.64 10.0731 12.9067C9.41306 13.1867 8.71972 13.3267 7.99972 13.3267V14.66C8.89972 14.66 9.77306 14.4867 10.5931 14.1333C11.3864 13.8 12.0997 13.3133 12.7131 12.7067C13.3264 12.0933 13.8064 11.38 14.1397 10.5867C14.4864 9.76667 14.6664 8.89333 14.6664 7.99333C14.6664 7.09333 14.4931 6.22 14.1397 5.4C13.8068 4.60714 13.3222 3.88698 12.7131 3.28V3.28667Z" }) });
12731
+ }
12732
+ function SliderGrip() {
12733
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "28", height: "12", viewBox: "0 0 28 12", fill: "none", "aria-hidden": "true", children: [
12734
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "27", height: "11", rx: "5.5", fill: "rgba(255,255,255,0.3)" }),
12735
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11 3l3 3-3 3M15 3l3 3-3 3", stroke: "#fff", strokeWidth: "1.1", strokeLinecap: "round", strokeLinejoin: "round" })
12736
+ ] });
12737
+ }
12738
+ function WalletAddGlyph() {
12739
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: [
12740
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9.95 1.84167L7.94167 6.51667H5.93333C5.6 6.51667 5.275 6.54167 4.95833 6.60833L5.79167 4.60833L5.825 4.53333L5.875 4.4C5.9 4.34167 5.91667 4.29167 5.94167 4.25C6.90833 2.00833 7.99167 1.30833 9.95 1.84167Z" }),
12741
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15.6083 6.74167L15.5917 6.73333C15.0917 6.59167 14.5833 6.51667 14.0667 6.51667H8.85L10.725 2.15833L10.75 2.1C10.8667 2.14167 10.9917 2.2 11.1167 2.24167L12.9583 3.01667C13.9833 3.44167 14.7 3.88333 15.1417 4.41667C15.2167 4.51667 15.2833 4.60833 15.35 4.71667C15.425 4.83333 15.4833 4.95 15.5167 5.075C15.55 5.15 15.575 5.21667 15.5917 5.29167C15.7167 5.71667 15.725 6.2 15.6083 6.74167Z" }),
12742
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15.2417 7.93333C14.8667 7.825 14.475 7.76667 14.0667 7.76667H5.93333C5.36667 7.76667 4.83333 7.875 4.33333 8.09167C2.88333 8.71667 1.86667 10.1583 1.86667 11.8333V13.4583C1.86667 13.6583 1.88333 13.85 1.90833 14.05C2.09167 16.7 3.50833 18.1167 6.15833 18.2917C6.35 18.3167 6.54167 18.3333 6.75 18.3333H13.25C16.3333 18.3333 17.9583 16.8667 18.1167 13.95C18.125 13.7917 18.1333 13.625 18.1333 13.4583V11.8333C18.1333 9.99167 16.9083 8.44167 15.2417 7.93333ZM12.0833 13.4917H10.625V15C10.625 15.3417 10.3417 15.625 10 15.625C9.65833 15.625 9.375 15.3417 9.375 15V13.4917H7.91667C7.575 13.4917 7.29167 13.2167 7.29167 12.8667C7.29167 12.525 7.575 12.2417 7.91667 12.2417H9.375V10.8333C9.375 10.4917 9.65833 10.2083 10 10.2083C10.3417 10.2083 10.625 10.4917 10.625 10.8333V12.2417H12.0833C12.425 12.2417 12.7083 12.525 12.7083 12.8667C12.7083 13.2167 12.425 13.4917 12.0833 13.4917Z" })
12743
+ ] });
12744
+ }
12745
+ function ChevronGlyph2({ up }) {
12746
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true", style: up ? { transform: "scaleY(-1)" } : void 0, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2.5 4.5 6 8l3.5-3.5", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" }) });
12747
+ }
12748
+ function ArrowGlyph2() {
12749
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "sg-cq-arrow", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3.5 8h9M9 4.5 12.5 8 9 11.5", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" }) });
12750
+ }
12751
+ function InfoGlyph() {
12752
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: [
12753
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "5.6", stroke: "currentColor", strokeWidth: "1" }),
12754
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7 6.2v3.4", stroke: "currentColor", strokeWidth: "1.1", strokeLinecap: "round" }),
12755
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "4.5", r: ".7", fill: "currentColor" })
12756
+ ] });
12757
+ }
12758
+ function unavailableCopy(status) {
12759
+ return status === "unsigned-cross-chain-off" ? "Cross-chain orders are not enabled yet" : status === "router-unresolved" || status === "escrow-unresolved" ? "Not available on this network yet" : "Not available right now";
12760
+ }
12761
+ function compareFeeLabel(usd2) {
12762
+ if (usd2 === null) return "--";
12763
+ if (!Number.isFinite(usd2) || usd2 <= 0) return "$0.00";
12764
+ if (usd2 >= 0.01) return `$${usd2.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
12765
+ if (usd2 < 1e-6) return "<$0.000001";
12766
+ return `$${usd2.toLocaleString("en-US", { maximumSignificantDigits: 2 })}`;
12767
+ }
12768
+ function logoOf(tokens, hop) {
12769
+ const wanted = hop.address.toLowerCase();
12770
+ return tokens.find((t) => Number(t.chainId) === hop.chainId && String(t.address).toLowerCase() === wanted)?.logoUrl;
12771
+ }
12772
+ var WIDE_SCALE_TRAVEL_PX = 189 * 228 / 130;
12773
+ function thumbWidth(fraction) {
12774
+ return `max(32px, calc((100% - 4px) * ${fraction}))`;
12775
+ }
12776
+ function CompareQuotes(props) {
12777
+ const side = props.layout === "side";
12778
+ const sliderId = react.useId();
12779
+ const options = props.compare?.options ?? [];
12780
+ const selectedId = props.compare?.selectedId ?? null;
12781
+ const selected = options.find((o) => o.id === selectedId && !o.unavailable)?.id ?? options.find((o) => !o.unavailable)?.id ?? null;
12782
+ const picked = options.find((o) => o.id === selectedId && !o.unavailable);
12783
+ const [movedWait, setMovedWait] = react.useState(null);
12784
+ const wait2 = movedWait ?? (picked ? clampWait(picked.estimatedDuration) : proposedWait(options));
12785
+ const [openRoutes, setOpenRoutes] = react.useState(() => /* @__PURE__ */ new Set());
12786
+ const parityState = props.compare?.parity ?? { kind: "unknown" };
12787
+ const extra = props.compare ? extraVsFastest(options, selected) : null;
12788
+ const selectedOption = options.find((o) => o.id === selected);
12789
+ const anySelectable = options.some((o) => !o.unavailable);
12790
+ const moveWait = (sec) => {
12791
+ setMovedWait(sec);
12792
+ const pick = pickForWait(options, sec);
12793
+ if (pick && pick.id !== selected) props.onSelect(pick.id);
12794
+ };
12795
+ const pickCard = (option) => {
12796
+ if (props.onSelect(option.id)) setMovedWait(clampWait(option.estimatedDuration));
12797
+ };
12798
+ const toggleRoute = (id) => setOpenRoutes((prev) => {
12799
+ const next = new Set(prev);
12800
+ if (next.has(id)) next.delete(id);
12801
+ else next.add(id);
12802
+ return next;
12803
+ });
12804
+ const trackRef = react.useRef(null);
12805
+ const listRef = react.useRef(null);
12806
+ const [travel, setTravel] = react.useState(400);
12807
+ react.useLayoutEffect(() => {
12808
+ const el = trackRef.current;
12809
+ if (!el) return;
12810
+ const measure = () => setTravel(el.offsetWidth - 4);
12811
+ measure();
12812
+ if (typeof ResizeObserver === "undefined") return;
12813
+ const ro = new ResizeObserver(measure);
12814
+ ro.observe(el);
12815
+ return () => ro.disconnect();
12816
+ }, [anySelectable]);
12817
+ const scale = react.useMemo(() => waitScaleFor(side ? WIDE_SCALE_TRAVEL_PX : travel), [side, travel]);
12818
+ const pct = waitFraction(wait2, scale) * 100;
12819
+ const shown = react.useMemo(() => visibleOptions(options, wait2, selected), [options, wait2, selected]);
12820
+ const rovingId = shown.find((o) => o.id === selected && !o.unavailable)?.id ?? shown.find((o) => !o.unavailable)?.id ?? null;
12821
+ const refresh = props.onRefresh ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-cq-refresh", onClick: props.onRefresh, "aria-label": "Refresh quotes", "aria-busy": props.refreshing || void 0, children: /* @__PURE__ */ jsxRuntime.jsx(RefreshGlyph, { spinning: !!props.refreshing }) }) : void 0;
12822
+ return /* @__PURE__ */ jsxRuntime.jsx(SheetFrame, { label: "Compare quotes", title: "Compare quotes", titleAddon: refresh, hideClose: true, wide: side, asRegion: !props.modal, trapFocus: props.modal, onClose: props.onBack, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq", "data-layout": props.layout, children: [
12823
+ anySelectable ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-wait", "data-testid": "compare-wait", children: [
12824
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-wait-top", children: [
12825
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-wait-row", children: [
12826
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: sliderId, children: "I'm willing to wait" }),
12827
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "compare-wait-label", children: waitLabel(wait2) })
12828
+ ] }),
12829
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-wait-scale", children: [
12830
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: trackRef, className: "sg-cq-track", children: [
12831
+ /* @__PURE__ */ jsxRuntime.jsx(
12832
+ "input",
12833
+ {
12834
+ id: sliderId,
12835
+ className: "sg-cq-range",
12836
+ type: "range",
12837
+ min: 0,
12838
+ max: WAIT_POSITIONS,
12839
+ step: 1,
12840
+ value: Math.round(pct * WAIT_POSITIONS / 100),
12841
+ "aria-valuetext": waitLabel(wait2),
12842
+ onChange: (e) => moveWait(snapWait(waitFromFraction(Number(e.target.value) / WAIT_POSITIONS, scale))),
12843
+ onKeyDown: (e) => {
12844
+ const dir = e.key === "ArrowRight" || e.key === "ArrowUp" ? 1 : e.key === "ArrowLeft" || e.key === "ArrowDown" ? -1 : 0;
12845
+ if (dir === 0) return;
12846
+ e.preventDefault();
12847
+ moveWait(snapWait(wait2 + dir * WAIT_STEP_SEC));
12848
+ }
12849
+ }
12850
+ ),
12851
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cq-rail", "aria-hidden": "true" }),
12852
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cq-thumb", "aria-hidden": "true", style: { width: thumbWidth(pct / 100) }, children: /* @__PURE__ */ jsxRuntime.jsx(SliderGrip, {}) })
12853
+ ] }),
12854
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-ends", children: [
12855
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "3 min" }),
12856
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "2 h" }),
12857
+ parityState.kind === "at" ? /* @__PURE__ */ jsxRuntime.jsxs(
12858
+ "span",
12859
+ {
12860
+ className: "sg-cq-parity",
12861
+ "data-testid": "compare-parity",
12862
+ style: { left: `clamp(${side ? 60 : 44}px, calc(${thumbWidth(waitFraction(parityState.timeSec, scale))} - 13px), calc(100% - ${side ? 60 : 44}px))` },
12863
+ children: [
12864
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "1:1" }),
12865
+ " ",
12866
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: compareDuration(parityState.timeSec) })
12867
+ ]
12868
+ }
12869
+ ) : null,
12870
+ parityState.kind === "unavailable" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-parity-none", "data-testid": "compare-parity", children: "1:1 currently unavailable" }) : null
12871
+ ] })
12872
+ ] })
12873
+ ] }),
12874
+ extra !== null ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12875
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cq-rule", "aria-hidden": "true" }),
12876
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-extra", "data-testid": "compare-extra", children: [
12877
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-extra-icon", children: /* @__PURE__ */ jsxRuntime.jsx(WalletAddGlyph, {}) }),
12878
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-extra-text", children: [
12879
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-extra-label", children: [
12880
+ "Potential extra received",
12881
+ side ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-cq-info", "aria-label": `Compared with fastest${selectedOption?.entersNetting ? ". Depends on a matching order" : ""}`, title: `Compared with fastest${selectedOption?.entersNetting ? "\nDepends on a matching order" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(InfoGlyph, {}) }) : null
12882
+ ] }),
12883
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-extra-amt", children: [
12884
+ "+",
12885
+ compareAmount(extra),
12886
+ " ",
12887
+ props.toSymbol
12888
+ ] })
12889
+ ] }),
12890
+ side ? null : /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-extra-note", children: [
12891
+ "Compared with fastest",
12892
+ selectedOption?.entersNetting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12893
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
12894
+ "Depends on a matching order"
12895
+ ] }) : null
12896
+ ] })
12897
+ ] })
12898
+ ] }) : null
12899
+ ] }) : null,
12900
+ /* @__PURE__ */ jsxRuntime.jsxs(
12901
+ "div",
12902
+ {
12903
+ role: "radiogroup",
12904
+ "aria-label": "Quotes",
12905
+ className: "sg-cq-list",
12906
+ ref: listRef,
12907
+ onKeyDown: (e) => {
12908
+ const dir = e.key === "ArrowDown" || e.key === "ArrowRight" ? 1 : e.key === "ArrowUp" || e.key === "ArrowLeft" ? -1 : 0;
12909
+ if (dir === 0) return;
12910
+ const pickable = shown.filter((o) => !o.unavailable);
12911
+ if (pickable.length === 0) return;
12912
+ e.preventDefault();
12913
+ const cur = Math.max(0, pickable.findIndex((o) => o.id === rovingId));
12914
+ const next = pickable[(cur + dir + pickable.length) % pickable.length];
12915
+ pickCard(next);
12916
+ requestAnimationFrame(() => listRef.current?.querySelector(`[data-oid="${CSS.escape(next.id)}"]`)?.focus());
12917
+ },
12918
+ children: [
12919
+ shown.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
12920
+ QuoteCard,
12921
+ {
12922
+ option,
12923
+ isSelected: option.id === selected,
12924
+ tabIndex: option.id === rovingId ? 0 : -1,
12925
+ tags: cornerTags(options, option, parityState),
12926
+ toSymbol: props.toSymbol,
12927
+ side,
12928
+ routeOpen: openRoutes.has(option.id),
12929
+ tokens: props.tokens,
12930
+ chainName: props.chainName,
12931
+ onPick: () => pickCard(option),
12932
+ onToggleRoute: () => toggleRoute(option.id)
12933
+ },
12934
+ option.id
12935
+ )),
12936
+ options.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { role: "status", className: "sg-cq-empty", children: props.emptyMessage ?? "No quote yet \u2014 enter an amount to get one." }) : null
12937
+ ]
12938
+ }
12939
+ )
12940
+ ] }) });
12941
+ }
12942
+ function Column({ label: label2, value }) {
12943
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-col", children: [
12944
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-col-label", children: label2 }),
12945
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-col-value", children: value })
12946
+ ] });
12947
+ }
12948
+ function HopMark({ hop, tokens, size }) {
12949
+ return /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: hop.ticker, logoUrl: logoOf(tokens, hop), chainId: hop.chainId, size });
12950
+ }
12951
+ function QuoteCard(props) {
12952
+ const { option, tags, side } = props;
12953
+ const routeId = react.useId();
12954
+ const headRef = react.useRef(null);
12955
+ const tagRef = react.useRef(null);
12956
+ const [tagInset, setTagInset] = react.useState(null);
12957
+ react.useLayoutEffect(() => {
12958
+ const head = headRef.current;
12959
+ const tag = tagRef.current;
12960
+ if (side || !head || !tag) return setTagInset(null);
12961
+ const measure = () => setTagInset(Math.max(0, Math.ceil(head.getBoundingClientRect().right - tag.getBoundingClientRect().left) + 8));
12962
+ measure();
12963
+ if (typeof ResizeObserver === "undefined") return;
12964
+ const observer = new ResizeObserver(measure);
12965
+ observer.observe(tag);
12966
+ observer.observe(head);
12967
+ return () => observer.disconnect();
12968
+ }, [tags.length, side]);
12969
+ const netting = !!option.entersNetting;
12970
+ const gasless = !!option.gasSponsored;
12971
+ const note = netting ? "Matches your swap with an opposite order" : gasless ? "No native token needed for gas" : null;
12972
+ const nettingTag = tags.some((t) => t.tone === "green");
12973
+ const purple = tags[0]?.tone === "purple" && !nettingTag;
12974
+ const hops = option.hops;
12975
+ const collapsed = side && hops.length > 3;
12976
+ const inline = collapsed ? [hops[0], hops[1], "gap", hops[hops.length - 1]] : hops;
12977
+ const hidden3 = collapsed ? hops.slice(2, -1) : [];
12978
+ const routeIcons = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-route-icons", "data-testid": "compare-route-inline", children: inline.map((hop, i) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop-inline", children: [
12979
+ i > 0 ? /* @__PURE__ */ jsxRuntime.jsx(ArrowGlyph2, {}) : null,
12980
+ hop === "gap" ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-cq-gap", title: hidden3.map((h2) => `${h2.ticker} on ${props.chainName(h2.chainId)}`).join(" \u2192 "), "aria-label": `Also via ${hidden3.map((h2) => `${h2.ticker} on ${props.chainName(h2.chainId)}`).join(", ")}`, children: "\u2026" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { title: `${hop.ticker} on ${props.chainName(hop.chainId)}`, children: /* @__PURE__ */ jsxRuntime.jsx(HopMark, { hop, tokens: props.tokens, size: "xxs" }) })
12981
+ ] }, hop === "gap" ? "gap" : `${hop.chainId}-${hop.address}-${i}`)) });
12982
+ const fee = compareFeeLabel(option.feeUsd);
12983
+ const tagEl = tags.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { ref: tagRef, className: "sg-cq-tag", "data-kind": nettingTag ? "netting" : purple ? "purple" : "brand", children: tags.map((tag, i) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-tag-item", children: [
12984
+ i > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-tag-dot", "aria-hidden": "true" }) : null,
12985
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-tone": tag.tone, children: tag.text })
12986
+ ] }, tag.text)) }) : null;
12987
+ const body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12988
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { ref: headRef, className: "sg-cq-head", style: tagInset === null ? void 0 : { paddingRight: tagInset }, children: [
12989
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-radio", "data-on": props.isSelected || void 0, "aria-hidden": "true" }),
12990
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-amount", children: [
12991
+ tags.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-sr", children: [
12992
+ tags.map((t) => t.text).join(", "),
12993
+ " "
12994
+ ] }) : option.label ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-sr", children: [
12995
+ option.label.toLowerCase().replace(/^./, (c) => c.toUpperCase()),
12996
+ " "
12997
+ ] }) : null,
12998
+ netting ? "~" : "",
12999
+ compareAmount(option.amount),
13000
+ " ",
13001
+ props.toSymbol
13002
+ ] })
13003
+ ] }),
13004
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-stats", children: [
13005
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-cols", children: [
13006
+ /* @__PURE__ */ jsxRuntime.jsx(Column, { label: "Est. time", value: netting ? compareDuration(option.estimatedDuration).replace(/^~/, "") : compareDuration(option.estimatedDuration) }),
13007
+ gasless ? /* @__PURE__ */ jsxRuntime.jsx(Column, { label: "Gas fee", value: "Sponsored" }) : /* @__PURE__ */ jsxRuntime.jsx(Column, { label: netting ? "Est. fee" : "Fee", value: fee }),
13008
+ side && hops.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-col", children: [
13009
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-col-label", children: "Route" }),
13010
+ routeIcons
13011
+ ] }) : null
13012
+ ] }),
13013
+ !side && note ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-note", children: note }) : null
13014
+ ] }),
13015
+ option.unavailable ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-why", children: unavailableCopy(option.unavailable) }) : null
13016
+ ] });
13017
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-card", "data-testid": "compare-quote", "data-selected": props.isSelected || void 0, "data-unavailable": option.unavailable ? true : void 0, children: [
13018
+ tagEl,
13019
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", role: "radio", "aria-checked": props.isSelected, disabled: !!option.unavailable, tabIndex: props.tabIndex, "data-oid": option.id, onClick: props.onPick, className: "sg-cq-main", children: body }),
13020
+ !side && hops.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-route", children: [
13021
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-cq-route-toggle", onClick: props.onToggleRoute, "aria-expanded": props.routeOpen, "aria-controls": routeId, children: [
13022
+ "Route",
13023
+ /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph2, { up: props.routeOpen })
13024
+ ] }),
13025
+ props.routeOpen ? /* @__PURE__ */ jsxRuntime.jsx("div", { id: routeId, className: "sg-cq-hops", "data-testid": "compare-route", children: hops.map((hop, i) => (
13026
+ // biome-ignore lint/suspicious/noArrayIndexKey: a route is a fixed sequence, and a token can appear twice on it.
13027
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop", children: [
13028
+ i > 0 ? /* @__PURE__ */ jsxRuntime.jsx(ArrowGlyph2, {}) : null,
13029
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop-body", children: [
13030
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop-name", children: [
13031
+ /* @__PURE__ */ jsxRuntime.jsx(HopMark, { hop, tokens: props.tokens, size: "xxs" }),
13032
+ hop.ticker
13033
+ ] }),
13034
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop-chain", children: [
13035
+ "On ",
13036
+ props.chainName(hop.chainId)
13037
+ ] })
13038
+ ] })
13039
+ ] }, `${hop.chainId}-${hop.address}-${i}`)
13040
+ )) }) : null
13041
+ ] }) : null
13042
+ ] });
13043
+ }
12014
13044
  function QuoteSheet(props) {
12015
13045
  const sheetRef = react.useRef(null);
12016
13046
  const onCloseRef = react.useRef(props.onClose);
@@ -12301,6 +13331,14 @@ function ExchangeCard(props) {
12301
13331
  () => destinationStates ? toPickerTokens.filter((t) => !destinationStates[`${Number(t.chainId)}:${String(t.address || "").toLowerCase()}`]?.disabled) : toPickerTokens,
12302
13332
  [toPickerTokens, destinationStates]
12303
13333
  );
13334
+ const seenReadyCatalogue = react.useRef(null);
13335
+ react.useEffect(() => {
13336
+ if (!catalogue?.ready) return;
13337
+ const first = seenReadyCatalogue.current === null;
13338
+ seenReadyCatalogue.current = catalogue;
13339
+ if (first || !to) return;
13340
+ if (destinationStates?.[`${Number(to.chainId)}:${String(findToken(tokens, to.chainId, to.symbol)?.address || "").toLowerCase()}`]?.disabled || !findToken(tokens, to.chainId, to.symbol)) setTo(null);
13341
+ }, [catalogue]);
12304
13342
  const normalizedAmount = normalizeDecimalText(amount);
12305
13343
  const amountValid = /^\d+(\.\d+)?$/.test(normalizedAmount) && Number(normalizedAmount) > 0 && Number(normalizedAmount) <= 1e9;
12306
13344
  const rampMode = mode !== "exchange";
@@ -12478,6 +13516,7 @@ function ExchangeCard(props) {
12478
13516
  const recipientLocked = wide && recipientState.open && recipientPending;
12479
13517
  const ctaLabel = rampMode ? soonLabel : submitting ? "Exchanging\u2026" : connected2 && flow.quoteStale ? flow.quotePaused ? "Refresh quote" : "Refreshing quote\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall || "Exchange";
12480
13518
  const selected = addressed ? flow.selected : null;
13519
+ const compare = addressed && !solActive ? flow.compare : null;
12481
13520
  const hasQuote = Boolean(quotable && !quoting && !quoteError && receive);
12482
13521
  const nativeWei = (() => {
12483
13522
  try {
@@ -12534,10 +13573,14 @@ function ExchangeCard(props) {
12534
13573
  setView("main");
12535
13574
  requestAnimationFrame(() => (isFrom ? fromTileRef : toTileRef).current?.focus());
12536
13575
  };
13576
+ const openPicker = (v) => () => {
13577
+ setSheet(null);
13578
+ setView(v);
13579
+ };
12537
13580
  const closeSheet = () => {
12538
13581
  const was = sheet;
12539
13582
  setSheet(null);
12540
- requestAnimationFrame(() => (was === "quote" ? quoteBtnRef : complianceBtnRef).current?.focus());
13583
+ requestAnimationFrame(() => (was === "quote" || was === "compare" ? quoteBtnRef : complianceBtnRef).current?.focus());
12541
13584
  };
12542
13585
  const pctChips = mode !== "onramp" ? (
12543
13586
  // a11y note: <fieldset> carries UA styling that would have to be reset on every host page;
@@ -12567,7 +13610,7 @@ function ExchangeCard(props) {
12567
13610
  icon: /* @__PURE__ */ jsxRuntime.jsx(QuoteGlyph, {}),
12568
13611
  label: "Quote",
12569
13612
  badge: lg && hasQuote ? { text: "Best return", tone: "info" } : null,
12570
- onClick: () => setSheet("quote"),
13613
+ onClick: () => setSheet(compare ? "compare" : "quote"),
12571
13614
  disabled: !hasQuote
12572
13615
  }
12573
13616
  );
@@ -12584,7 +13627,27 @@ function ExchangeCard(props) {
12584
13627
  connect: !wallet.account ? { family: "evm", onClick: () => void wallet.connect(), busy: wallet.connecting } : !solanaWallet.address ? { family: "solana", onClick: (name) => void solanaWallet.connect(name), busy: solanaWallet.status === "connecting", choices: solanaWallet.wallets.map((w) => w.name) } : void 0,
12585
13628
  error: solanaWallet.error || wallet.error
12586
13629
  }
12587
- ) : recipientState.open ? /* @__PURE__ */ jsxRuntime.jsx(RecipientSheet, { state: recipientState, wide, onPending: wide ? setRecipientPending : void 0 }) : sheet === "compliance" ? /* @__PURE__ */ jsxRuntime.jsx(ComplianceSheet, { compliance, direct: selected?.state === "DIRECT", hasQuote: complianceHasQuote, onClose: closeSheet }) : sheet === "quote" && hasQuote ? /* @__PURE__ */ jsxRuntime.jsx(
13630
+ ) : recipientState.open ? /* @__PURE__ */ jsxRuntime.jsx(RecipientSheet, { state: recipientState, wide, onPending: wide ? setRecipientPending : void 0 }) : sheet === "compliance" ? /* @__PURE__ */ jsxRuntime.jsx(ComplianceDetails, { compliance, direct: selected?.state === "DIRECT", hasQuote: complianceHasQuote, onBack: closeSheet, layout: wide ? "side" : "card" }) : sheet === "compare" ? (
13631
+ // Stays mounted even when `compare` is momentarily null (a refresh that is loading or failed), mirroring the
13632
+ // dapp's CompareQuotesDialog: it shows the empty/error notice in place of the cards instead of popping the
13633
+ // screen and dropping focus (zd-dapp src/components/CompareQuotesDialog.tsx uses `emptyMessage` the same way).
13634
+ /* @__PURE__ */ jsxRuntime.jsx(
13635
+ CompareQuotes,
13636
+ {
13637
+ compare,
13638
+ toSymbol: toTicker,
13639
+ tokens,
13640
+ chainName: (id) => nameOf(id) ?? `Chain ${id}`,
13641
+ onSelect: flow.selectOption,
13642
+ onBack: closeSheet,
13643
+ onRefresh: flow.reload,
13644
+ refreshing: flow.status === "loading",
13645
+ emptyMessage: flow.status === "loading" ? "Fetching quote\u2026" : quoteError || void 0,
13646
+ modal: !!props.inDialog,
13647
+ layout: wide ? "side" : "card"
13648
+ }
13649
+ )
13650
+ ) : sheet === "quote" && hasQuote ? /* @__PURE__ */ jsxRuntime.jsx(
12588
13651
  QuoteSheet,
12589
13652
  {
12590
13653
  onClose: closeSheet,
@@ -12663,7 +13726,7 @@ function ExchangeCard(props) {
12663
13726
  }
12664
13727
  );
12665
13728
  } else if (sheetBody && !wide) {
12666
- takeover = walletsOpen && !walletDetails || recipientState.open;
13729
+ takeover = walletsOpen && !walletDetails || recipientState.open || !walletsOpen && (sheet === "compare" || sheet === "compliance");
12667
13730
  body = sheetBody;
12668
13731
  } else if (solActive && solFlow.status === "sent") {
12669
13732
  body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -12729,9 +13792,9 @@ function ExchangeCard(props) {
12729
13792
  body = wide ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12730
13793
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-stack", children: [
12731
13794
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ft", children: [
12732
- mode === "onramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatTile, { label: "From", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "From", pick: from, chainName: nameOf(from?.chainId), token: fromToken, disabled: submitting, btnRef: fromTileRef, onClick: () => setView("from") }),
13795
+ mode === "onramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatTile, { label: "From", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "From", pick: from, chainName: nameOf(from?.chainId), token: fromToken, disabled: submitting, btnRef: fromTileRef, onClick: openPicker("from") }),
12733
13796
  /* @__PURE__ */ jsxRuntime.jsx(FlipButton, { small: true, onClick: flip, disabled: !flippable }),
12734
- mode === "offramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatTile, { label: "To", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "To", pick: to, chainName: nameOf(to?.chainId), token: toToken2, disabled: submitting, btnRef: toTileRef, onClick: () => setView("to") })
13797
+ mode === "offramp" ? /* @__PURE__ */ jsxRuntime.jsx(FiatTile, { label: "To", currency: fiatCurrency, onCurrency: setFiatCurrency }) : /* @__PURE__ */ jsxRuntime.jsx(TokenTile, { label: "To", pick: to, chainName: nameOf(to?.chainId), token: toToken2, disabled: submitting, btnRef: toTileRef, onClick: openPicker("to") })
12735
13798
  ] }),
12736
13799
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane", "data-kind": "send", children: [
12737
13800
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane-top", children: [