@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/index.cjs CHANGED
@@ -3439,6 +3439,7 @@ function resultForOption(result, option, mode, destinationChainId) {
3439
3439
  var DEFAULT_DEADLINE_SECONDS = 1800;
3440
3440
  var MAX_DEADLINE_SECONDS = 60 * 60;
3441
3441
  var ABSOLUTE_MAX_DEADLINE_SECONDS = 24 * 60 * 60;
3442
+ var DEADLINE_CLOCK_SKEW_SECONDS = 120;
3442
3443
  function recommendedDeadlineSeconds(quote) {
3443
3444
  const recommended = Number(quote?.recommendedDeadlineSeconds);
3444
3445
  if (!Number.isFinite(recommended) || recommended <= 0) return DEFAULT_DEADLINE_SECONDS;
@@ -3534,7 +3535,7 @@ function assertQuoteMatchesSelection({ quote, order, orders, option, destination
3534
3535
  throw new Error("ZeroDelta order guarantees less than the displayed receive amount.");
3535
3536
  }
3536
3537
  const maxDeadline = maxDeadlineSeconds(quote);
3537
- if (!Number.isFinite(deadline) || deadline <= now || deadline > now + maxDeadline) {
3538
+ if (!Number.isFinite(deadline) || deadline <= now || deadline > now + maxDeadline + DEADLINE_CLOCK_SKEW_SECONDS) {
3538
3539
  throw new Error("ZeroDelta quote deadline is invalid or too far in the future.");
3539
3540
  }
3540
3541
  for (let index = 1; index < list.length; index += 1) {
@@ -4290,10 +4291,55 @@ function buildZdHeavyRoute(ctx) {
4290
4291
  // src/core/quote-compare.ts
4291
4292
  var WAIT_MIN_SEC = 180;
4292
4293
  var WAIT_MAX_SEC = 7200;
4294
+ var WAIT_STEP_SEC = 60;
4293
4295
  function clampWait(sec) {
4294
4296
  if (!Number.isFinite(sec)) return WAIT_MIN_SEC;
4295
4297
  return Math.min(WAIT_MAX_SEC, Math.max(WAIT_MIN_SEC, sec));
4296
4298
  }
4299
+ var WAIT_POINTS = [
4300
+ [WAIT_MIN_SEC, 0],
4301
+ [1800, 0.295],
4302
+ [2700, 0.4725],
4303
+ [WAIT_MAX_SEC, 1]
4304
+ ];
4305
+ var FIGMA_TRAVEL_PX = 400;
4306
+ function waitScaleFor(travelPx) {
4307
+ if (!Number.isFinite(travelPx) || travelPx >= FIGMA_TRAVEL_PX || travelPx < 200) return WAIT_POINTS;
4308
+ return WAIT_POINTS.map(
4309
+ ([sec, fraction], i) => i === 0 || i === WAIT_POINTS.length - 1 ? [sec, fraction] : [sec, fraction * FIGMA_TRAVEL_PX / travelPx]
4310
+ );
4311
+ }
4312
+ var WAIT_POSITIONS = 1e3;
4313
+ function waitFraction(sec, points = WAIT_POINTS) {
4314
+ const s = clampWait(sec);
4315
+ for (let i = 1; i < points.length; i++) {
4316
+ const [s1, f1] = points[i];
4317
+ if (s <= s1) {
4318
+ const [s0, f0] = points[i - 1];
4319
+ return f0 + (s - s0) / (s1 - s0) * (f1 - f0);
4320
+ }
4321
+ }
4322
+ return 1;
4323
+ }
4324
+ function waitFromFraction(fraction, points = WAIT_POINTS) {
4325
+ const f = Number.isFinite(fraction) ? Math.min(1, Math.max(0, fraction)) : 0;
4326
+ for (let i = 1; i < points.length; i++) {
4327
+ const [s1, f1] = points[i];
4328
+ if (f <= f1) {
4329
+ const [s0, f0] = points[i - 1];
4330
+ return s0 + (f - f0) / (f1 - f0) * (s1 - s0);
4331
+ }
4332
+ }
4333
+ return WAIT_MAX_SEC;
4334
+ }
4335
+ function snapWait(sec) {
4336
+ return clampWait(Math.round(sec / WAIT_STEP_SEC) * WAIT_STEP_SEC);
4337
+ }
4338
+ function waitLabel(sec) {
4339
+ const min = Math.round(clampWait(sec) / 60);
4340
+ if (min >= 60 && min % 60 === 0) return `Up to ${min / 60} ${min === 60 ? "hour" : "hours"}`;
4341
+ return `Up to ${min} min`;
4342
+ }
4297
4343
  var hasTime = (o) => Number.isFinite(o.estimatedDuration) && o.estimatedDuration > 0;
4298
4344
  function selectableOptions(options) {
4299
4345
  return options.filter((o) => !o.unavailable);
@@ -4317,15 +4363,23 @@ function pickForWait(options, waitSec) {
4317
4363
  }
4318
4364
  var MAX_QUOTE_CARDS = 3;
4319
4365
  function visibleOptions(options, waitSec, selectedId) {
4320
- if (options.length <= MAX_QUOTE_CARDS) return [...options];
4366
+ if (options.length <= MAX_QUOTE_CARDS) return nettingFirst(options);
4321
4367
  const selectable = selectableOptions(options);
4322
- if (selectable.length === 0) return options.slice(0, MAX_QUOTE_CARDS);
4368
+ if (selectable.length === 0) return nettingFirst(options.slice(0, MAX_QUOTE_CARDS));
4323
4369
  const chosen = selectable.find((o) => o.id === selectedId) ?? pickForWait(options, waitSec);
4324
4370
  const gasless = bestOutputOption(selectable.filter((o) => o.gasSponsored));
4325
4371
  const netting = bestOutputOption(selectable.filter((o) => o.entersNetting));
4326
4372
  const ids = new Set([chosen?.id, fastestOption(options)?.id, gasless?.id, netting?.id].filter((id) => !!id));
4327
4373
  const keep = new Set([...ids].slice(0, MAX_QUOTE_CARDS));
4328
- return options.filter((o) => keep.has(o.id));
4374
+ return nettingFirst(options.filter((o) => keep.has(o.id)));
4375
+ }
4376
+ function nettingFirst(options) {
4377
+ return [...options.filter((o) => o.entersNetting), ...options.filter((o) => !o.entersNetting)];
4378
+ }
4379
+ function compareDuration(seconds) {
4380
+ if (!Number.isFinite(seconds) || seconds <= 0) return "--";
4381
+ if (seconds < 60) return `~${Math.round(seconds)} s`;
4382
+ return `~${Math.round(seconds / 60)} min`;
4329
4383
  }
4330
4384
  function parity(options, inputUsd, toUnitUsd) {
4331
4385
  const priced = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
@@ -4381,10 +4435,10 @@ function routeShapeLabel(option) {
4381
4435
  function cornerTags(options, option, parityState) {
4382
4436
  if (option.unavailable) return [];
4383
4437
  if (option.kind === "transfer") return [{ text: "Transfer", tone: "brand" }];
4438
+ if (option.entersNetting) return [{ text: "Best return", tone: "green" }];
4384
4439
  const tags = [];
4385
4440
  const labelledFastest = selectableOptions(options).some((o) => o.label?.toLowerCase() === "fastest");
4386
4441
  if (parityState.kind === "at" && parityState.option.id === option.id) tags.push({ text: "Target 1:1", tone: "brand" });
4387
- else if (option.entersNetting) tags.push({ text: "Potential best return", tone: "brand" });
4388
4442
  else if (option.label?.toLowerCase() === "fastest") tags.push({ text: "Fastest", tone: "brand" });
4389
4443
  else if (option.gasSponsored) tags.push({ text: "Gasless", tone: "purple" });
4390
4444
  else {
@@ -4392,9 +4446,24 @@ function cornerTags(options, option, parityState) {
4392
4446
  const text = badge === "Fastest" && labelledFastest ? void 0 : badge ?? routeShapeLabel(option) ?? void 0;
4393
4447
  if (text) tags.push({ text, tone: "brand" });
4394
4448
  }
4395
- if (option.entersNetting) tags.push({ text: "Netting", tone: "green" });
4396
4449
  return tags;
4397
4450
  }
4451
+ function humanAmount(n, maxFrac = 6) {
4452
+ if (!Number.isFinite(n)) return String(n);
4453
+ if (n === 0) return "0";
4454
+ const digits = Math.min(Math.max(0, Math.trunc(maxFrac)), 8);
4455
+ const fixed = n.toFixed(digits);
4456
+ const out = fixed.includes(".") ? fixed.replace(/\.?0+$/, "") : fixed;
4457
+ if (Number(out) === 0) return `<${digits > 0 ? `0.${"0".repeat(digits - 1)}1` : "1"}`;
4458
+ const match = out.match(/^([+-]?)(\d+)(\.\d+)?$/);
4459
+ return match ? `${match[1]}${match[2].replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${match[3] ?? ""}` : out;
4460
+ }
4461
+ function compareAmount(value) {
4462
+ const text = humanAmount(value, 6);
4463
+ if (text.startsWith("<")) return text;
4464
+ const [whole, fraction = ""] = text.split(".");
4465
+ return fraction.length >= 2 ? text : `${whole}.${fraction.padEnd(2, "0")}`;
4466
+ }
4398
4467
  function compareFeeUsd(option, fromUsd) {
4399
4468
  const centibips = option.feeCentibips;
4400
4469
  if (centibips === void 0 || option.feeNative) return null;
@@ -4913,7 +4982,7 @@ var CHANNEL_HEADER = "x-zd-channel";
4913
4982
  var CHANNEL_VERSION_HEADER = "x-zd-channel-version";
4914
4983
  var CHANNEL_ORIGIN_HEADER = "x-zd-channel-origin";
4915
4984
  var WIDGET_CHANNEL = "widget";
4916
- var WIDGET_VERSION = "4.19.0" ;
4985
+ var WIDGET_VERSION = "4.20.1" ;
4917
4986
  var MAX_CHANNEL_VERSION_LEN = 32;
4918
4987
  function sanitizeVersion(raw2) {
4919
4988
  const v = String(raw2).trim();
@@ -4950,6 +5019,20 @@ function isReportableSubmission(report) {
4950
5019
  return typeof wallet === "string" && /^0x[0-9a-fA-F]{40}$/.test(wallet);
4951
5020
  }
4952
5021
 
5022
+ // src/core/quote-refusals.ts
5023
+ var GATE_REFUSALS = /* @__PURE__ */ new Set(["ROUTE_UNHEALTHY", "ROUTE_UNMEASURED", "GATE_UNAVAILABLE"]);
5024
+ function quoteRefusalCopy(code) {
5025
+ 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;
5026
+ }
5027
+ var DETERMINISTIC_REFUSALS = /* @__PURE__ */ new Set(["ROUTE_UNHEALTHY", "ROUTE_UNMEASURED", "ROUTE_BLOCKED", "PAIR_HALTED", "PROTOCOL_DISABLED"]);
5028
+ var TRANSIENT_REFUSALS = /* @__PURE__ */ new Set(["GATE_UNAVAILABLE", "MARKET_HALTED"]);
5029
+ function gateRefusalRetryable(code) {
5030
+ if (!code) return void 0;
5031
+ if (DETERMINISTIC_REFUSALS.has(code)) return false;
5032
+ if (TRANSIENT_REFUSALS.has(code)) return true;
5033
+ return void 0;
5034
+ }
5035
+
4953
5036
  // src/core/api.ts
4954
5037
  function apiError(message, props = {}) {
4955
5038
  const err2 = new Error(message);
@@ -5013,6 +5096,8 @@ function nowFresh(entry) {
5013
5096
  return !!entry && Date.now() - entry.at < API_CACHE_TTL_MS;
5014
5097
  }
5015
5098
  function isTransientQuoteError(error) {
5099
+ const gate = gateRefusalRetryable(error?.code);
5100
+ if (gate !== void 0) return gate;
5016
5101
  if (error?.code === "BRIDGE_RATE_LIMITED" || Array.isArray(error?.fieldErrors) && error.fieldErrors.length > 0) return false;
5017
5102
  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 || "");
5018
5103
  }
@@ -5083,9 +5168,10 @@ function createApiClient(cfg) {
5083
5168
  }
5084
5169
  }
5085
5170
  if (!response.ok) {
5086
- throw apiError(apiMessage(json, `ZeroDelta request failed (${response.status}).`), {
5171
+ const code = json?.error?.code || json?.code || (response.status >= 502 ? "gateway_timeout" : "api_error");
5172
+ throw apiError(quoteRefusalCopy(code) ?? apiMessage(json, `ZeroDelta request failed (${response.status}).`), {
5087
5173
  status: response.status,
5088
- code: json?.error?.code || json?.code || (response.status >= 502 ? "gateway_timeout" : "api_error"),
5174
+ code,
5089
5175
  fieldErrors: json?.error?.fieldErrors || json?.fieldErrors,
5090
5176
  limits: json?.error?.limits || json?.limits,
5091
5177
  reasons: json?.error?.reasons || json?.reasons
@@ -6693,6 +6779,11 @@ function useFlow(args) {
6693
6779
  };
6694
6780
  }
6695
6781
  var RETRY_DELAYS_MS = [800, 2400, 6e3];
6782
+ var CATALOGUE_REFRESH_MS = 6e4 + 250;
6783
+ function catalogueSignature(c) {
6784
+ const ids = (list) => list.map((t) => `${Number(t.chainId)}:${String(t.address).toLowerCase()}`).join(",");
6785
+ 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("|");
6786
+ }
6696
6787
  function useCatalogue(engine, options = {}) {
6697
6788
  const { allowedAssets, product, solanaSources } = options;
6698
6789
  const enabled = options.enabled !== false;
@@ -6709,7 +6800,10 @@ function useCatalogue(engine, options = {}) {
6709
6800
  engine.fetchCatalogue(allowedAssets, product, solanaSources ? { solanaSources: true } : void 0).then((next) => {
6710
6801
  if (!alive) return;
6711
6802
  setCatalogue(next);
6712
- if (next.ready) return;
6803
+ if (next.ready) {
6804
+ timer2 = setTimeout(refresh, CATALOGUE_REFRESH_MS);
6805
+ return;
6806
+ }
6713
6807
  if (attempt >= RETRY_DELAYS_MS.length) {
6714
6808
  setFailed(true);
6715
6809
  return;
@@ -6717,6 +6811,23 @@ function useCatalogue(engine, options = {}) {
6717
6811
  timer2 = setTimeout(read, RETRY_DELAYS_MS[attempt++]);
6718
6812
  });
6719
6813
  };
6814
+ const refresh = () => {
6815
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") {
6816
+ timer2 = setTimeout(refresh, CATALOGUE_REFRESH_MS);
6817
+ return;
6818
+ }
6819
+ if (isUserIdle()) {
6820
+ timer2 = setTimeout(refresh, CATALOGUE_REFRESH_MS);
6821
+ return;
6822
+ }
6823
+ engine.fetchCatalogue(allowedAssets, product, solanaSources ? { solanaSources: true } : void 0).then((next) => {
6824
+ if (!alive) return;
6825
+ if (next.ready) setCatalogue((prev) => prev?.ready && catalogueSignature(prev) === catalogueSignature(next) ? prev : next);
6826
+ }).catch(() => {
6827
+ }).finally(() => {
6828
+ if (alive) timer2 = setTimeout(refresh, CATALOGUE_REFRESH_MS);
6829
+ });
6830
+ };
6720
6831
  read();
6721
6832
  return () => {
6722
6833
  alive = false;
@@ -7704,6 +7815,217 @@ button.sg-rcp-row:focus-visible{outline:2px solid var(--sg-accent);outline-offse
7704
7815
  .sg-widget[data-sg-side]:has(>.sg-ws){display:flex;flex-direction:column}
7705
7816
  .sg-widget[data-sg-side]>.sg-ws{flex:1 1 auto}
7706
7817
  @media (prefers-reduced-motion:reduce){.sg-ws{animation:none}.sg-ws-spin{animation:none}}
7818
+ /* \u2500\u2500 Compliance details screen (ComplianceDetails) \u2014 Figma Widget Playground 3238:16033 / 16419 / 16879 / 17276 / 17894 \u2500\u2500 */
7819
+ .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}
7820
+ .sg-cd:focus{outline:none}
7821
+ .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}
7822
+ .sg-cd-back::after{content:"";position:absolute;inset:-12px -10px}
7823
+ .sg-cd-back:hover{color:var(--sg-text)}
7824
+ .sg-cd-back:focus-visible{outline:2px solid var(--sg-accent);outline-offset:4px;border-radius:6px}
7825
+ .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)}
7826
+ .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)}
7827
+ .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}
7828
+ .sg-cd-tab:hover{color:var(--sg-text)}
7829
+ .sg-cd-tab[data-active="true"]{background:color-mix(in srgb,var(--sg-accent) 8%,transparent);color:var(--sg-accent)}
7830
+ .sg-cd-tab:focus-visible{outline:2px solid var(--sg-accent);outline-offset:-2px}
7831
+ .sg-cd-tab-count{font-weight:700;color:var(--sg-t25)}
7832
+ .sg-cd-tab[data-active="true"] .sg-cd-tab-count{color:color-mix(in srgb,var(--sg-accent) 50%,transparent)}
7833
+ .sg-cd-panel{display:flex;flex-direction:column;gap:6px;margin-top:-4px}
7834
+ .sg-cd-card{display:flex;flex-direction:column;gap:20px;padding:16px;border:1px solid var(--sg-border);border-radius:var(--sg-cd-r)}
7835
+ .sg-cd-card-head{display:flex;align-items:center;gap:8px}
7836
+ .sg-cd-card-glyph{display:flex;flex:0 0 auto;color:var(--sg-accent)}
7837
+ .sg-cd-card-title{margin:0;font-size:15px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
7838
+ .sg-cd-summary{display:flex;flex-direction:column;gap:4px}
7839
+ .sg-cd-summary-head{display:flex;align-items:center;gap:8px;color:var(--sg-ok-ink)}
7840
+ .sg-cd-summary-head[data-tone="neutral"]{color:var(--sg-t60)}
7841
+ .sg-cd-summary-head[data-tone="blocked"],.sg-cd-summary-head[data-tone="warn"]{color:var(--sg-danger)}
7842
+ .sg-cd-summary-title{font-size:14px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
7843
+ .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)}
7844
+ .sg-cd-summary-sub{margin:0;padding-left:24px;font-size:13px;line-height:1.2;color:var(--sg-t50)}
7845
+ .sg-cd-checks{list-style:none;margin:2px 0 -1px;padding:0;display:flex;flex-direction:column;gap:12px}
7846
+ .sg-cd-card:has(.sg-cd-facts){gap:16px}
7847
+ .sg-cd-check-line{display:flex;align-items:center;gap:8px;min-width:0}
7848
+ .sg-cd-check-mark{display:flex;flex:0 0 auto;width:12px;justify-content:center;color:var(--sg-ok-ink)}
7849
+ .sg-cd-check-mark[data-ok="false"]{color:var(--sg-danger)}
7850
+ .sg-cd-check-label{font-size:14px;line-height:17px;color:var(--sg-t90)}
7851
+ .sg-cd-check[data-ok="false"] .sg-cd-check-label{color:var(--sg-danger)}
7852
+ .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}
7853
+ .sg-cd-check-reason{color:var(--sg-danger)}
7854
+ .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)}
7855
+ .sg-cd-scope{margin:0;font-size:12px;line-height:1.45;color:var(--sg-t60)}
7856
+ .sg-cd-flags{margin:0;font-size:14px;color:var(--sg-t90)}
7857
+ .sg-cd-facts{margin:0;display:flex;flex-direction:column;gap:10px;padding-left:24px}
7858
+ .sg-cd-fact{display:grid;grid-template-columns:94px minmax(0,1fr);align-items:baseline;gap:0}
7859
+ .sg-cd-fact dt{font-size:13px;line-height:17px;color:var(--sg-t50)}
7860
+ .sg-cd-fact dd{margin:0;min-width:0;font-size:14px;line-height:17px;color:var(--sg-t90);overflow-wrap:anywhere}
7861
+ .sg-cd-policies{gap:6px}
7862
+ .sg-cd-policy{display:flex;flex-direction:column}
7863
+ .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}
7864
+ button.sg-cd-policy-head{cursor:pointer;transition:border-color 120ms ease}
7865
+ button.sg-cd-policy-head:hover{border-color:color-mix(in srgb,var(--sg-accent) 40%,var(--sg-border))}
7866
+ button.sg-cd-policy-head:focus-visible{outline:2px solid var(--sg-accent);outline-offset:2px}
7867
+ .sg-cd-policy-mark{display:flex;flex:0 0 auto;color:color-mix(in srgb,var(--sg-text) 45%,transparent)}
7868
+ .sg-cd-policy-text{display:flex;flex:1 1 auto;min-width:0;flex-direction:column;gap:6px}
7869
+ .sg-cd-policy-name{font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90);overflow-wrap:anywhere}
7870
+ .sg-cd-policy-sub{font-size:14px;line-height:18px;color:var(--sg-t60)}
7871
+ .sg-cd-policy-chev{display:flex;flex:0 0 auto;color:var(--sg-t90)}
7872
+ .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}
7873
+ .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)}
7874
+ .sg-cd-bucket-head{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:4px 8px}
7875
+ .sg-cd-bucket[data-outcome] .sg-cd-bucket-head:has(.sg-cd-hint){justify-content:flex-start;align-items:center;gap:8px}
7876
+ .sg-cd-bucket-title{font-size:14px;font-weight:500;line-height:16px;color:var(--sg-t90)}
7877
+ .sg-cd-bucket-detail{font-size:12px;line-height:14px;color:var(--sg-t50)}
7878
+ .sg-cd-cats{list-style:none;margin:0;padding:0 0 0 8px;display:flex;flex-direction:column;gap:4px}
7879
+ .sg-cd-cats li{display:flex;align-items:center;gap:12px;font-size:13px;line-height:18px;color:var(--sg-t90)}
7880
+ .sg-cd-dot{flex:0 0 auto;width:4px;height:4px;border-radius:999px;background:var(--sg-t90)}
7881
+ .sg-cd-bucket[data-outcome="flagged"] .sg-cd-dot{background:var(--sg-accent);opacity:.8}
7882
+ .sg-cd-cats li .sg-cd-hint{margin-left:-6px}
7883
+ .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}
7884
+ .sg-cd-hint{position:relative}
7885
+ .sg-cd-hint::after{content:"";position:absolute;inset:-12px}
7886
+ .sg-cd-hint:hover,.sg-cd-hint[aria-expanded="true"]{color:var(--sg-accent)}
7887
+ .sg-cd-hint:focus-visible{outline:2px solid var(--sg-accent);outline-offset:1px}
7888
+ .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)}
7889
+ .sg-cd-cats li,.sg-cd-bucket-head{position:relative}
7890
+ .sg-cd-policy-version{margin:0;padding:4px 4px 0;font-size:12px;line-height:14px;color:var(--sg-t60);overflow-wrap:anywhere}
7891
+ /* Wide's second panel (layout="side", 280px): the same screen on a denser scale \u2014 Figma 3238:16419 / 18187 / 18446 */
7892
+ .sg-cd[data-layout="side"] .sg-cd-back{font-size:12px;font-weight:400;line-height:16px;margin-bottom:4px}
7893
+ .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}
7894
+ .sg-cd[data-layout="side"] .sg-cd-panel{margin-top:-8px}
7895
+ .sg-cd[data-layout="side"] .sg-cd-card{padding:16px 12px;gap:16px}
7896
+ .sg-cd[data-layout="side"] .sg-cd-card:has(.sg-cd-facts){gap:16px}
7897
+ .sg-cd[data-layout="side"] .sg-cd-card-title{font-size:14px}
7898
+ .sg-cd[data-layout="side"] .sg-cd-summary-head,.sg-cd[data-layout="side"] .sg-cd-card-head{gap:8px}
7899
+ .sg-cd[data-layout="side"] .sg-cd-summary-sub{padding-left:0;font-size:13px;line-height:16px}
7900
+ .sg-cd[data-layout="side"] .sg-cd-checks{gap:12px}
7901
+ .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}
7902
+ .sg-cd[data-layout="side"] .sg-cd-facts{padding-left:24px;gap:10px}
7903
+ .sg-cd[data-layout="side"] .sg-cd-policy-head{gap:6px;padding:21px 13px}
7904
+ .sg-cd[data-layout="side"] .sg-cd-policy-text{gap:2px}
7905
+ .sg-cd[data-layout="side"] .sg-cd-policy-name{font-size:14px;line-height:1.2}
7906
+ .sg-cd[data-layout="side"] .sg-cd-policy-sub{font-size:13px;line-height:1.4}
7907
+ .sg-cd[data-layout="side"] .sg-cd-policy-mark svg{width:16px;height:16px}
7908
+ .sg-cd[data-layout="side"] .sg-cd-policy-body{padding:32px 8px 16px}
7909
+ .sg-cd[data-layout="side"] .sg-cd-bucket{gap:8px;padding:12px 16px;border-radius:16px}
7910
+ @media (prefers-reduced-motion:reduce){.sg-cd,.sg-cd-policy-body{animation:none}}
7911
+ /* \u2500\u2500 Compare quotes \u2014 Figma Widget Playground 3237:13270 / 3237:13581 / 3237:13897 / 3237:14224 (2026-11-13) \u2500\u2500 */
7912
+ .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}
7913
+ .sg-widget[data-sg-mode="dark"]{--sg-purple:#b79cff;--sg-cq-dot:color-mix(in srgb,var(--sg-text) 50%,transparent)}
7914
+ .sg-ws-titlerow{display:flex;align-items:center;gap:12px}
7915
+ .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}
7916
+ .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}
7917
+ .sg-cq-spin{animation:sg-spin 900ms linear infinite}
7918
+ .sg-cq{display:flex;flex-direction:column;gap:16px}
7919
+ .sg-cq-wait{display:flex;flex-direction:column;gap:20px;padding:16px 12px 20px;border-radius:24px;background:var(--sg-a5)}
7920
+ .sg-cq-wait-top{display:flex;flex-direction:column;gap:8px}
7921
+ .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)}
7922
+ .sg-cq-wait-scale{display:flex;flex-direction:column;gap:12px}
7923
+ .sg-cq-track{position:relative;width:100%;height:20px}
7924
+ .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}
7925
+ .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)}
7926
+ .sg-cq-range:focus-visible~.sg-cq-rail{outline:2px solid var(--sg-accent);outline-offset:2px}
7927
+ .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)}
7928
+ .sg-cq-thumb svg{flex:0 0 auto;margin-right:1px}
7929
+ .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)}
7930
+ .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))}
7931
+ .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)}
7932
+ .sg-cq-rule{height:1px;margin-top:-1px;background:var(--sg-a12)}
7933
+ .sg-cq-extra{display:flex;flex-wrap:nowrap;align-items:center;justify-content:space-between;gap:8px}
7934
+ .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)}
7935
+ .sg-cq-extra-icon svg{width:16px;height:16px}
7936
+ .sg-cq-extra-text{display:flex;flex:0 1 auto;min-width:0;flex-direction:column;justify-content:center;gap:0;margin-right:auto}
7937
+ .sg-cq-parity{white-space:nowrap}
7938
+ .sg-ws:has(.sg-cq) .sg-ws-top{gap:24px}
7939
+ .sg-cq-info,.sg-cq-gap{padding:0;border:0;background:transparent;font:inherit}
7940
+ .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)}
7941
+ .sg-cq-extra-amt{white-space:nowrap;font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
7942
+ .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)}
7943
+ .sg-cq-info{display:inline-flex;border-radius:4px;color:var(--sg-t50);cursor:help}
7944
+ .sg-cq-list{display:flex;flex-direction:column;gap:8px}
7945
+ .sg-cq-empty{margin:0;padding:24px 0;text-align:center;font-size:13px;line-height:1.4;color:var(--sg-t50)}
7946
+ .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)}
7947
+ .sg-cq-card[data-selected]{border-color:color-mix(in srgb,var(--sg-accent) 80%,transparent)}
7948
+ .sg-cq-card[data-unavailable]{background:var(--sg-a4);opacity:.6;filter:grayscale(1)}
7949
+ .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}
7950
+ .sg-cq-main:disabled{cursor:not-allowed}
7951
+ .sg-cq-head{display:flex;align-items:flex-start;gap:8px;width:100%;padding-right:min(150px,42%)}
7952
+ .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)}
7953
+ .sg-cq-radio[data-on]{border-color:var(--sg-accent)}
7954
+ .sg-cq-radio[data-on]::after{content:"";width:8px;height:8px;border-radius:999px;background:var(--sg-accent)}
7955
+ .sg-cq-amount{min-width:0;font-size:16px;font-weight:500;line-height:1.2;color:var(--sg-t90)}
7956
+ .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}
7957
+ .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}
7958
+ .sg-cq-tag[data-kind="netting"]{background:var(--sg-green-12)}
7959
+ .sg-cq-tag[data-kind="purple"]{background:color-mix(in srgb,var(--sg-purple) 8%,transparent)}
7960
+ .sg-cq-tag-item{display:flex;align-items:center;gap:8px;white-space:nowrap}
7961
+ .sg-cq-tag-dot{width:4px;height:4px;border-radius:999px;background:var(--sg-cq-dot)}
7962
+ .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}
7963
+ .sg-cq-tag [data-tone="brand"]{color:var(--sg-accent)}
7964
+ .sg-cq-tag [data-tone="green"]{color:var(--sg-ok-ink)}
7965
+ .sg-cq-tag [data-tone="purple"]{color:var(--sg-purple)}
7966
+ .sg-widget[data-sg-mode="dark"] .sg-cq-tag [data-tone="brand"]{color:var(--sg-info)}
7967
+ .sg-cq-stats{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:0 12px 0 24px}
7968
+ .sg-cq-cols{display:flex;align-items:center;gap:32px;white-space:nowrap}
7969
+ .sg-cq-col{display:flex;flex-direction:column;justify-content:center;gap:6px}
7970
+ .sg-cq-col-label{font-size:10px;font-weight:500;line-height:1.2;text-transform:uppercase;color:var(--sg-t50)}
7971
+ .sg-cq-col-value{font-size:14px;line-height:1.2;color:var(--sg-text)}
7972
+ .sg-cq-note{width:125px;text-align:right;font-size:12px;line-height:1.2;color:var(--sg-t50)}
7973
+ .sg-cq-why{padding-left:24px;font-size:13px;line-height:1.3;color:var(--sg-t50)}
7974
+ .sg-cq-route{display:flex;flex-direction:column;gap:10px;padding-left:24px}
7975
+ .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}
7976
+ .sg-cq-route-toggle svg{color:var(--sg-text)}
7977
+ .sg-cq-hops{display:flex;flex-wrap:wrap;align-items:flex-start;gap:4px}
7978
+ .sg-cq-hop{display:flex;align-items:flex-start;gap:4px}
7979
+ .sg-cq-arrow{flex:0 0 auto;color:var(--sg-accent)}
7980
+ .sg-cq-hop-body{display:flex;flex-direction:column;gap:4px}
7981
+ .sg-cq-hop-name{display:flex;align-items:center;gap:4px;font-size:14px;line-height:1.2;color:var(--sg-text)}
7982
+ .sg-cq-hop-chain{white-space:nowrap;font-size:12px;line-height:1.2;color:var(--sg-t50)}
7983
+ .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}
7984
+ .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}
7985
+ /* Back-link and gap scoped to Compare quotes (Figma: 14px t50 compact, 12px t50 wide, 24px/16px to the title). */
7986
+ .sg-ws:has(.sg-cq) .sg-ws-back{font-size:14px;font-weight:500;color:var(--sg-t50)}
7987
+ .sg-dialog .sg-ws:has(.sg-cq):not([data-wide]) .sg-ws-top{gap:16px}
7988
+ /* Wide: compact cards, the tag a centred band across the card's top, the route as inline marks */
7989
+ .sg-cq[data-layout="side"] .sg-cq-card{gap:12px;padding:0 0 16px;border-radius:20px}
7990
+ .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}
7991
+ .sg-ws[data-wide]:has(.sg-cq) .sg-ws-top{gap:16px}
7992
+ .sg-ws[data-wide]:has(.sg-cq) .sg-ws-title{font-size:16px}
7993
+ .sg-ws[data-wide]:has(.sg-cq) .sg-ws-back{font-size:12px;font-weight:400;color:var(--sg-t50)}
7994
+ .sg-cq[data-layout="side"]{gap:12px}
7995
+ .sg-cq[data-layout="side"] .sg-cq-wait{padding:16px 12px 20px;gap:20px}
7996
+ .sg-cq[data-layout="side"] .sg-cq-rule{margin-bottom:-8px}
7997
+ .sg-cq[data-layout="side"] .sg-cq-card:not(:has(.sg-cq-tag)){padding-top:12px}
7998
+ .sg-cq[data-layout="side"] .sg-cq-main{gap:20px;padding:0 12px;border-radius:0}
7999
+ .sg-cq[data-layout="side"] .sg-cq-head{padding-right:0!important}
8000
+ .sg-cq[data-layout="side"] .sg-cq-amount{font-size:15px}
8001
+ .sg-cq[data-layout="side"] .sg-cq-stats{padding:0}
8002
+ .sg-cq[data-layout="side"] .sg-cq-cols{gap:20px}
8003
+ .sg-cq[data-layout="side"] .sg-cq-col{gap:4px}
8004
+ .sg-cq[data-layout="side"] .sg-cq-col-label{font-size:9px}
8005
+ .sg-cq[data-layout="side"] .sg-cq-col-value{font-size:13px}
8006
+ .sg-cq[data-layout="side"] .sg-cq-card[data-selected]{border-color:color-mix(in srgb,var(--sg-accent) 50%,transparent)}
8007
+ .sg-cq[data-layout="side"] .sg-cq-extra-amt{font-size:15px}
8008
+ .sg-cq[data-layout="side"] .sg-cq-extra-label{gap:4px}
8009
+ .sg-cq[data-layout="side"] .sg-cq-info svg{width:12px;height:12px}
8010
+ .sg-cq[data-layout="side"] .sg-cq-card:not(:has(.sg-cq-tag)) .sg-cq-main{padding-top:0}
8011
+ .sg-cq-route-icons{display:flex;align-items:center;gap:2px}
8012
+ .sg-cq-route-icons .sg-cq-arrow{width:10px;height:10px}
8013
+ .sg-cq-hop-inline{display:flex;align-items:center;gap:2px}
8014
+ .sg-cq-hop-inline>span{display:flex}
8015
+ .sg-cq-gap{display:inline-flex;padding:0 2px;border-radius:4px;color:var(--sg-accent);text-decoration:underline;cursor:help}
8016
+ .sg-cq[data-layout="side"] .sg-cq-wait-scale .sg-cq-parity{flex-direction:row;gap:4px}
8017
+ /* Below Figma's widths the cards must shrink, not clip (narrow page; container = the sheet). */
8018
+ .sg-ws:has(.sg-cq){container-type:inline-size}
8019
+ @container (max-width:300px){
8020
+ .sg-cq-head{padding-right:0!important}
8021
+ .sg-cq-stats{flex-wrap:wrap;gap:8px;padding-left:0}
8022
+ .sg-cq-cols{flex-wrap:wrap;gap:12px;white-space:normal}
8023
+ .sg-cq-note{width:auto;max-width:100%;text-align:left}
8024
+ .sg-cq-route-icons{flex-wrap:wrap}
8025
+ .sg-cq-extra{flex-wrap:wrap}
8026
+ .sg-cq-extra-note{margin-left:0;text-align:left}
8027
+ }
8028
+ @media (prefers-reduced-motion:reduce){.sg-cq-spin{animation:none}}
7707
8029
  `;
7708
8030
  var injected = false;
7709
8031
  function injectStyles() {
@@ -8388,7 +8710,7 @@ function groupDecimal2(value) {
8388
8710
  if (!match) return value;
8389
8711
  return `${match[1]}${match[2].replace(/\B(?=(\d{3})+(?!\d))/g, ",")}${match[3] ?? ""}`;
8390
8712
  }
8391
- function humanAmount(n, maxFrac = 6) {
8713
+ function humanAmount2(n, maxFrac = 6) {
8392
8714
  if (!Number.isFinite(n)) return String(n);
8393
8715
  if (n === 0) return "0";
8394
8716
  const digits = Math.min(Math.max(0, Math.trunc(maxFrac)), 8);
@@ -8524,7 +8846,7 @@ function BalanceColumn(props) {
8524
8846
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-bal", children: [
8525
8847
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-pk-bal-usd sg-mono", children: props.usd == null ? "\u2014" : formatBalanceUsd(props.usd) }),
8526
8848
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-pk-bal-amt sg-mono", children: [
8527
- humanAmount(props.amount, 6),
8849
+ humanAmount2(props.amount, 6),
8528
8850
  " ",
8529
8851
  props.symbol
8530
8852
  ] })
@@ -10006,34 +10328,64 @@ function SheetFrame(props) {
10006
10328
  document.addEventListener("keydown", onKey, true);
10007
10329
  return () => document.removeEventListener("keydown", onKey, true);
10008
10330
  }, []);
10009
- return /* @__PURE__ */ jsxRuntime.jsxs(
10010
- "div",
10011
- {
10012
- className: "sg-ws",
10013
- "data-wide": props.wide || void 0,
10014
- role: "dialog",
10015
- "aria-modal": "true",
10016
- "aria-label": props.label,
10017
- ref: sheetRef,
10018
- tabIndex: -1,
10019
- style: props.minHeight ? { minHeight: props.minHeight } : void 0,
10020
- children: [
10021
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-top", children: [
10022
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-head", children: [
10023
- /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-ws-back", onClick: () => closeRef.current(), children: [
10024
- /* @__PURE__ */ jsxRuntime.jsx(ArrowLeft, {}),
10025
- props.backLabel ?? "Back to Exchange"
10331
+ return (
10332
+ // biome-ignore lint/a11y/noStaticElementInteractions: role is "region" or "dialog" — both carry semantics; the Tab trap only runs for the modal (dialog) case.
10333
+ // biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-modal is set only when role is "dialog" (asRegion is false); a region never receives it.
10334
+ /* @__PURE__ */ jsxRuntime.jsxs(
10335
+ "div",
10336
+ {
10337
+ className: "sg-ws",
10338
+ "data-wide": props.wide || void 0,
10339
+ role: props.asRegion ? "region" : "dialog",
10340
+ "aria-modal": props.asRegion ? void 0 : "true",
10341
+ "aria-label": props.label,
10342
+ ref: sheetRef,
10343
+ tabIndex: -1,
10344
+ onKeyDown: props.trapFocus ? (event) => {
10345
+ if (event.key !== "Tab") return;
10346
+ const root = sheetRef.current;
10347
+ if (!root) return;
10348
+ const focusable = Array.from(
10349
+ root.querySelectorAll('a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])')
10350
+ ).filter((el) => el.offsetParent !== null || el === document.activeElement);
10351
+ if (focusable.length === 0) {
10352
+ event.preventDefault();
10353
+ root.focus();
10354
+ return;
10355
+ }
10356
+ const first = focusable[0];
10357
+ const last = focusable[focusable.length - 1];
10358
+ const active = document.activeElement;
10359
+ if (event.shiftKey && (active === first || active === root)) {
10360
+ event.preventDefault();
10361
+ last.focus();
10362
+ } else if (!event.shiftKey && active === last) {
10363
+ event.preventDefault();
10364
+ first.focus();
10365
+ }
10366
+ } : void 0,
10367
+ style: props.minHeight ? { minHeight: props.minHeight } : void 0,
10368
+ children: [
10369
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-top", children: [
10370
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-head", children: [
10371
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-ws-back", onClick: () => closeRef.current(), children: [
10372
+ /* @__PURE__ */ jsxRuntime.jsx(ArrowLeft, {}),
10373
+ props.backLabel ?? "Back to Exchange"
10374
+ ] }),
10375
+ 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, {}) })
10026
10376
  ] }),
10027
- 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, {}) })
10377
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-main", children: [
10378
+ props.titleAddon ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-titlerow", children: [
10379
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-ws-title", id: titleId, children: props.title }),
10380
+ props.titleAddon
10381
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-ws-title", id: titleId, children: props.title }),
10382
+ props.children
10383
+ ] })
10028
10384
  ] }),
10029
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ws-main", children: [
10030
- /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-ws-title", id: titleId, children: props.title }),
10031
- props.children
10032
- ] })
10033
- ] }),
10034
- props.footer ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-ws-foot", children: props.footer }) : null
10035
- ]
10036
- }
10385
+ props.footer ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-ws-foot", children: props.footer }) : null
10386
+ ]
10387
+ }
10388
+ )
10037
10389
  );
10038
10390
  }
10039
10391
  function WalletChip(props) {
@@ -11335,6 +11687,7 @@ function PillLauncher(props) {
11335
11687
  const openAs = props.openAs === "drawer" ? "drawer" : "modal";
11336
11688
  const [open, setOpen] = react.useState(!!props.defaultOpen);
11337
11689
  const buttonRef = react.useRef(null);
11690
+ const dialogRef = react.useRef(null);
11338
11691
  const close = () => {
11339
11692
  setOpen(false);
11340
11693
  requestAnimationFrame(() => buttonRef.current?.focus());
@@ -11342,7 +11695,32 @@ function PillLauncher(props) {
11342
11695
  react.useEffect(() => {
11343
11696
  if (!open) return;
11344
11697
  const onKey = (e) => {
11345
- if (e.key === "Escape") close();
11698
+ if (e.key === "Escape") {
11699
+ close();
11700
+ return;
11701
+ }
11702
+ if (e.key !== "Tab") return;
11703
+ const root = dialogRef.current;
11704
+ if (!root) return;
11705
+ const list = Array.from(root.querySelectorAll("a[href],button,input,select,textarea,[tabindex]")).filter(
11706
+ (el) => el.tabIndex >= 0 && !el.hasAttribute("disabled") && el.getClientRects().length > 0
11707
+ );
11708
+ if (list.length === 0) {
11709
+ e.preventDefault();
11710
+ return;
11711
+ }
11712
+ const first = list[0];
11713
+ const last = list[list.length - 1];
11714
+ const idx = list.indexOf(document.activeElement);
11715
+ if (e.shiftKey) {
11716
+ if (idx <= 0) {
11717
+ e.preventDefault();
11718
+ last.focus();
11719
+ }
11720
+ } else if (idx === -1 || idx === list.length - 1) {
11721
+ e.preventDefault();
11722
+ first.focus();
11723
+ }
11346
11724
  };
11347
11725
  document.addEventListener("keydown", onKey);
11348
11726
  return () => document.removeEventListener("keydown", onKey);
@@ -11357,7 +11735,7 @@ function PillLauncher(props) {
11357
11735
  ] }),
11358
11736
  open ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-overlay", "data-sg-overlay": openAs, children: [
11359
11737
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-overlay-scrim", tabIndex: -1, "aria-label": "Close", onClick: close }),
11360
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-dialog", role: "dialog", "aria-modal": "true", "aria-label": props.verb, children: props.children(close, openAs) })
11738
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: dialogRef, className: "sg-dialog", role: "dialog", "aria-modal": "true", "aria-label": props.verb, children: props.children(close, openAs) })
11361
11739
  ] }) : null
11362
11740
  ] });
11363
11741
  }
@@ -12030,6 +12408,658 @@ function useSolanaSourceFlow(args) {
12030
12408
  }, []);
12031
12409
  return { status, preview, plan, error, balanceRaw, cost, progress, signature, lastTxEntry, sent, addressed, needsPreparation, insufficient, solShort, run, reset };
12032
12410
  }
12411
+ function BackArrow() {
12412
+ 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" }) });
12413
+ }
12414
+ function ChevronDown2({ up = false }) {
12415
+ 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" }) });
12416
+ }
12417
+ function PolicyShield() {
12418
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
12419
+ /* @__PURE__ */ jsxRuntime.jsx(
12420
+ "path",
12421
+ {
12422
+ 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",
12423
+ fill: "currentColor"
12424
+ }
12425
+ ),
12426
+ /* @__PURE__ */ jsxRuntime.jsx(
12427
+ "path",
12428
+ {
12429
+ 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",
12430
+ fill: "currentColor"
12431
+ }
12432
+ )
12433
+ ] });
12434
+ }
12435
+ function InfoSquare() {
12436
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
12437
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "2", y: "2", width: "20", height: "20", rx: "6", fill: "currentColor" }),
12438
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 10.8v6", stroke: "var(--sg-bg)", strokeWidth: "2.1", strokeLinecap: "round" }),
12439
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "7.7", r: "1.25", fill: "var(--sg-bg)" })
12440
+ ] });
12441
+ }
12442
+ function InfoOutline() {
12443
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
12444
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "9.2", stroke: "currentColor", strokeWidth: "1.7" }),
12445
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 11v5.4", stroke: "currentColor", strokeWidth: "1.9", strokeLinecap: "round" }),
12446
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "7.8", r: "1.15", fill: "currentColor" })
12447
+ ] });
12448
+ }
12449
+ var FLAGGED_CATEGORY_HINTS = {
12450
+ "High-risk entity": "An entity associated with elevated financial-crime risk based on available screening data.",
12451
+ "Politically exposed person (PEP)": "A person who holds or has held a prominent public function, including close associates and family members.",
12452
+ "Unknown / unclassified": "The screening provider could not confidently assign the entity to a known risk category.",
12453
+ "Unclassified risk": "The screening provider could not confidently assign the entity to a known risk category."
12454
+ };
12455
+ var POLICY_DETAILS = {
12456
+ "always-blocked": "Cannot be changed or disabled",
12457
+ blocked: "Stops the order",
12458
+ flagged: "Does not automatically block"
12459
+ };
12460
+ function Hint({ id, label: label2, text, hint }) {
12461
+ const tipId = react.useId();
12462
+ const open = hint.open === id;
12463
+ const ptr = react.useRef("");
12464
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12465
+ /* @__PURE__ */ jsxRuntime.jsx(
12466
+ "button",
12467
+ {
12468
+ type: "button",
12469
+ className: "sg-cd-hint",
12470
+ "data-sg-hint": "",
12471
+ "aria-label": `About ${label2}`,
12472
+ "aria-expanded": open,
12473
+ "aria-describedby": open ? tipId : void 0,
12474
+ onPointerEnter: (e) => {
12475
+ ptr.current = e.pointerType;
12476
+ if (e.pointerType === "mouse") hint.setOpen(id);
12477
+ },
12478
+ onPointerLeave: (e) => {
12479
+ if (e.pointerType === "mouse") hint.setOpen(null);
12480
+ },
12481
+ onClick: () => {
12482
+ hint.setOpen(ptr.current === "mouse" ? id : open ? null : id);
12483
+ ptr.current = "";
12484
+ },
12485
+ onBlur: () => {
12486
+ ptr.current = "";
12487
+ },
12488
+ children: /* @__PURE__ */ jsxRuntime.jsx(InfoOutline, {})
12489
+ }
12490
+ ),
12491
+ open ? /* @__PURE__ */ jsxRuntime.jsx("span", { role: "tooltip", id: tipId, className: "sg-cd-tip", children: text }) : null
12492
+ ] });
12493
+ }
12494
+ function CheckRow2({ check: check2, hideNote }) {
12495
+ const label2 = check2.id === "risk" ? check2.ok ? "Risk screening passed" : "Risk screening failed" : check2.label;
12496
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "sg-cd-check", "data-ok": check2.ok, children: [
12497
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-check-line", children: [
12498
+ /* @__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 }) }),
12499
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-label", children: label2 }),
12500
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-sr-only", children: check2.ok ? " \u2014 passed" : " \u2014 failed" })
12501
+ ] }),
12502
+ check2.note && !hideNote ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-note", children: check2.note }) : null,
12503
+ check2.reasons.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-check-reason", children: humanizeComplianceReason(reason) }, reason))
12504
+ ] });
12505
+ }
12506
+ function Fact2({ label: label2, value, title, mono = false }) {
12507
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-fact", children: [
12508
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { children: label2 }),
12509
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { title, className: mono ? "sg-mono" : void 0, children: value })
12510
+ ] });
12511
+ }
12512
+ function QuoteChecks2(props) {
12513
+ const { compliance, cv, checks } = props;
12514
+ const allPassed = cv.tone === "ok" && checks.length > 0 && checks.every((c) => c.ok);
12515
+ const summary = allPassed ? "All checks passed" : cv.label;
12516
+ const orphans = unattributedComplianceReasons(compliance, cv);
12517
+ const wallets = distinctScreenedWallets(compliance);
12518
+ const jurisdiction = formatJurisdiction(compliance?.sourceJurisdiction, compliance?.sourceCountry);
12519
+ const hasDetails = Boolean(jurisdiction || wallets.length || compliance?.checkId);
12520
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-panel", children: [
12521
+ /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cd-card", children: [
12522
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-summary", children: [
12523
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-summary-head", "data-tone": cv.tone, children: [
12524
+ cv.tone === "blocked" || cv.tone === "warn" ? /* @__PURE__ */ jsxRuntime.jsx(CloseCircle, {}) : cv.tone === "neutral" ? /* @__PURE__ */ jsxRuntime.jsx(PendingCircle, {}) : /* @__PURE__ */ jsxRuntime.jsx(TickCircle, {}),
12525
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-summary-title", children: summary })
12526
+ ] }),
12527
+ checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "sg-cd-summary-sub", children: [
12528
+ checks.length,
12529
+ " check",
12530
+ checks.length === 1 ? " was" : "s were",
12531
+ " completed for this quote"
12532
+ ] }) : (
12533
+ // No decision was issued. Listing the controls here would be ticks for a verdict nobody gave,
12534
+ // and an unconfigured gate is not a set of passed checks.
12535
+ /* @__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." })
12536
+ )
12537
+ ] }),
12538
+ checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cd-checks", children: checks.map((check2) => (
12539
+ // The Figma row carries no sub-line: with ONE screened wallet the note would repeat the
12540
+ // address Quote details names two cards down. Any other note (a count of wallets) stays.
12541
+ /* @__PURE__ */ jsxRuntime.jsx(CheckRow2, { check: check2, hideNote: check2.id === "screening" && wallets.length === 1 && hasDetails }, check2.id)
12542
+ )) }) : null,
12543
+ orphans.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cd-orphans", children: orphans.map((reason) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: humanizeComplianceReason(reason) }, reason)) }) : null,
12544
+ props.direct && checks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-scope", children: DIRECT_SCOPE_NOTE }) : null
12545
+ ] }),
12546
+ compliance?.flaggedCategories?.length ? /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cd-card", children: [
12547
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-cd-card-title", children: "Flagged, not blocking" }),
12548
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-flags", children: compliance.flaggedCategories.map(categoryLabel).join(" \xB7 ") }),
12549
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "sg-cd-scope", children: "The policy records these and still allows the payment. They do not stop settlement." })
12550
+ ] }) : null,
12551
+ hasDetails ? /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cd-card", children: [
12552
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-card-head", children: [
12553
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-card-glyph", children: /* @__PURE__ */ jsxRuntime.jsx(InfoSquare, {}) }),
12554
+ /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "sg-cd-card-title", children: "Quote details" })
12555
+ ] }),
12556
+ /* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "sg-cd-facts", children: [
12557
+ jurisdiction ? /* @__PURE__ */ jsxRuntime.jsx(Fact2, { label: "Jurisdiction", value: jurisdiction }) : null,
12558
+ 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)),
12559
+ compliance?.checkId ? /* @__PURE__ */ jsxRuntime.jsx(Fact2, { label: "Check ID", value: compliance.checkId, mono: true }) : null
12560
+ ] })
12561
+ ] }) : null
12562
+ ] });
12563
+ }
12564
+ function riskRuleCount() {
12565
+ return SCREENING_BUCKETS.reduce((total, bucket) => total + bucket.categories.length, 0);
12566
+ }
12567
+ function appliedPolicies(compliance) {
12568
+ const names = compliance?.appliedPolicyNames ?? [];
12569
+ const legislation = compliance?.appliedLegislation ?? [];
12570
+ const applied = Boolean(compliance?.decision || compliance?.policyVersion?.trim()) || names.length > 0;
12571
+ if (!applied) return [];
12572
+ const ids = compliance?.appliedPolicyIds ?? [];
12573
+ const summary = `${riskRuleCount()} risk rules`;
12574
+ const statements = legislation.map((name, i) => ({ id: `legislation-${i}-${name}`, name, summary: null, buckets: null }));
12575
+ if (names.length === 0) return [{ id: "zd-screening-matrix", name: "Transaction screening", summary, buckets: SCREENING_BUCKETS }, ...statements];
12576
+ if (names.length === 1) return [{ id: ids[0] ?? names[0], name: names[0], summary, buckets: SCREENING_BUCKETS }, ...statements];
12577
+ return [
12578
+ ...names.map((name, i) => ({ id: ids[i] ?? `${name}-${i}`, name, summary: null, buckets: null })),
12579
+ ...statements,
12580
+ { id: "zd-screening-matrix", name: "Transaction screening", summary, buckets: SCREENING_BUCKETS }
12581
+ ];
12582
+ }
12583
+ function PolicyBuckets({ policyId, layout, hint }) {
12584
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: SCREENING_BUCKETS.map((bucket) => {
12585
+ const detail = POLICY_DETAILS[bucket.outcome];
12586
+ const bucketHint = `${policyId}:${bucket.outcome}`;
12587
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-bucket", "data-outcome": bucket.outcome, children: [
12588
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-bucket-head", children: [
12589
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-bucket-title", children: bucket.title }),
12590
+ 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 })
12591
+ ] }),
12592
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "sg-cd-cats", children: bucket.categories.map((category) => {
12593
+ const text = bucket.outcome === "flagged" ? FLAGGED_CATEGORY_HINTS[category] : void 0;
12594
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
12595
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-dot", "aria-hidden": "true" }),
12596
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: category }),
12597
+ text ? /* @__PURE__ */ jsxRuntime.jsx(Hint, { id: `${policyId}:${category}`, label: category, text, hint }) : null
12598
+ ] }, category);
12599
+ }) })
12600
+ ] }, bucket.outcome);
12601
+ }) });
12602
+ }
12603
+ function PolicyRow({
12604
+ policy,
12605
+ open,
12606
+ onToggle,
12607
+ layout,
12608
+ hint,
12609
+ policyVersion
12610
+ }) {
12611
+ const bodyId = react.useId();
12612
+ const head = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12613
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-policy-mark", children: /* @__PURE__ */ jsxRuntime.jsx(PolicyShield, {}) }),
12614
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-policy-text", children: [
12615
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-policy-name", children: policy.name }),
12616
+ policy.summary ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-policy-sub", children: policy.summary }) : null
12617
+ ] }),
12618
+ policy.buckets ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-policy-chev", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDown2, { up: open }) }) : null
12619
+ ] });
12620
+ 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 }) });
12621
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-policy", "data-open": open, children: [
12622
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "sg-cd-policy-head", "aria-expanded": open, "aria-controls": bodyId, onClick: onToggle, children: head }),
12623
+ open ? /* @__PURE__ */ jsxRuntime.jsxs("div", { id: bodyId, className: "sg-cd-policy-body", children: [
12624
+ /* @__PURE__ */ jsxRuntime.jsx(PolicyBuckets, { policyId: policy.id, layout, hint }),
12625
+ policyVersion ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "sg-cd-policy-version sg-mono", children: [
12626
+ "Policy version ",
12627
+ policyVersion
12628
+ ] }) : null
12629
+ ] }) : null
12630
+ ] });
12631
+ }
12632
+ function AppliedPolicies({ policies, layout, hint, policyVersion }) {
12633
+ const [openId, setOpenId] = react.useState(() => policies.find((p) => p.buckets)?.id ?? null);
12634
+ if (policies.length === 0) {
12635
+ 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: [
12636
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cd-summary-head", "data-tone": "neutral", children: [
12637
+ /* @__PURE__ */ jsxRuntime.jsx(PendingCircle, {}),
12638
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-summary-title", children: "No policy decision was returned" })
12639
+ ] }),
12640
+ /* @__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." })
12641
+ ] }) }) });
12642
+ }
12643
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cd-panel sg-cd-policies", children: policies.map((policy) => /* @__PURE__ */ jsxRuntime.jsx(
12644
+ PolicyRow,
12645
+ {
12646
+ policy,
12647
+ open: openId === policy.id,
12648
+ onToggle: () => setOpenId(openId === policy.id ? null : policy.id),
12649
+ layout,
12650
+ hint,
12651
+ policyVersion: openId === policy.id ? policyVersion : void 0
12652
+ },
12653
+ policy.id
12654
+ )) });
12655
+ }
12656
+ function ComplianceDetails(props) {
12657
+ const [tab, setTab] = react.useState("checks");
12658
+ const [hintOpen, setHintOpen] = react.useState(null);
12659
+ const rootRef = react.useRef(null);
12660
+ const ids = react.useId();
12661
+ const compliance = props.compliance ?? null;
12662
+ const cv = complianceView(compliance, props.hasQuote ?? true);
12663
+ const allChecks = complianceChecks(compliance, cv);
12664
+ const checks = props.direct ? allChecks.filter((c) => DIRECT_CHECK_IDS.includes(c.id)) : allChecks;
12665
+ const policies = appliedPolicies(compliance);
12666
+ const policyVersion = compliance?.policyVersion?.trim() || void 0;
12667
+ const onBackRef = react.useRef(props.onBack);
12668
+ onBackRef.current = props.onBack;
12669
+ const hintRef = react.useRef(hintOpen);
12670
+ hintRef.current = hintOpen;
12671
+ react.useEffect(() => {
12672
+ rootRef.current?.focus({ preventScroll: true });
12673
+ const onKey = (e) => {
12674
+ if (e.key !== "Escape") return;
12675
+ e.stopPropagation();
12676
+ if (hintRef.current) setHintOpen(null);
12677
+ else onBackRef.current();
12678
+ };
12679
+ const onPointer = (e) => {
12680
+ if (hintRef.current && !e.target?.closest?.("[data-sg-hint]")) setHintOpen(null);
12681
+ };
12682
+ document.addEventListener("keydown", onKey, true);
12683
+ document.addEventListener("pointerdown", onPointer, true);
12684
+ return () => {
12685
+ document.removeEventListener("keydown", onKey, true);
12686
+ document.removeEventListener("pointerdown", onPointer, true);
12687
+ };
12688
+ }, []);
12689
+ const tabKeys = (e) => {
12690
+ const order = ["checks", "policy"];
12691
+ let next = null;
12692
+ if (e.key === "Home") next = order[0];
12693
+ else if (e.key === "End") next = order[order.length - 1];
12694
+ else if (e.key === "ArrowRight") next = order[(order.indexOf(tab) + 1) % order.length];
12695
+ else if (e.key === "ArrowLeft") next = order[(order.indexOf(tab) - 1 + order.length) % order.length];
12696
+ if (next === null) return;
12697
+ e.preventDefault();
12698
+ setTab(next);
12699
+ document.getElementById(`${ids}-tab-${next}`)?.focus();
12700
+ };
12701
+ const hint = { open: hintOpen, setOpen: setHintOpen };
12702
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "sg-cd", "data-layout": props.layout, "aria-label": "Compliance details", ref: rootRef, tabIndex: -1, children: [
12703
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-cd-back", onClick: props.onBack, children: [
12704
+ /* @__PURE__ */ jsxRuntime.jsx(BackArrow, {}),
12705
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Back to Exchange" })
12706
+ ] }),
12707
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "sg-cd-title", children: "Compliance details" }),
12708
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cd-tabs", role: "tablist", "aria-label": "Compliance details sections", children: [
12709
+ /* @__PURE__ */ jsxRuntime.jsx(
12710
+ "button",
12711
+ {
12712
+ type: "button",
12713
+ role: "tab",
12714
+ id: `${ids}-tab-checks`,
12715
+ "aria-selected": tab === "checks",
12716
+ "aria-controls": `${ids}-panel`,
12717
+ tabIndex: tab === "checks" ? 0 : -1,
12718
+ "data-active": tab === "checks",
12719
+ className: "sg-cd-tab",
12720
+ onClick: () => setTab("checks"),
12721
+ onKeyDown: tabKeys,
12722
+ children: "Quote checks"
12723
+ }
12724
+ ),
12725
+ /* @__PURE__ */ jsxRuntime.jsxs(
12726
+ "button",
12727
+ {
12728
+ type: "button",
12729
+ role: "tab",
12730
+ id: `${ids}-tab-policy`,
12731
+ "aria-selected": tab === "policy",
12732
+ "aria-controls": `${ids}-panel`,
12733
+ tabIndex: tab === "policy" ? 0 : -1,
12734
+ "data-active": tab === "policy",
12735
+ className: "sg-cd-tab",
12736
+ onClick: () => setTab("policy"),
12737
+ onKeyDown: tabKeys,
12738
+ children: [
12739
+ "Applied policies",
12740
+ policies.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cd-tab-count", children: policies.length }) : null
12741
+ ]
12742
+ }
12743
+ )
12744
+ ] }),
12745
+ /* @__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 }) })
12746
+ ] });
12747
+ }
12748
+ function RefreshGlyph({ spinning }) {
12749
+ 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" }) });
12750
+ }
12751
+ function SliderGrip() {
12752
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "28", height: "12", viewBox: "0 0 28 12", fill: "none", "aria-hidden": "true", children: [
12753
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "0.5", y: "0.5", width: "27", height: "11", rx: "5.5", fill: "rgba(255,255,255,0.3)" }),
12754
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11 3l3 3-3 3M15 3l3 3-3 3", stroke: "#fff", strokeWidth: "1.1", strokeLinecap: "round", strokeLinejoin: "round" })
12755
+ ] });
12756
+ }
12757
+ function WalletAddGlyph() {
12758
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", children: [
12759
+ /* @__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" }),
12760
+ /* @__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" }),
12761
+ /* @__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" })
12762
+ ] });
12763
+ }
12764
+ function ChevronGlyph2({ up }) {
12765
+ 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" }) });
12766
+ }
12767
+ function ArrowGlyph2() {
12768
+ 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" }) });
12769
+ }
12770
+ function InfoGlyph() {
12771
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: [
12772
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "5.6", stroke: "currentColor", strokeWidth: "1" }),
12773
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7 6.2v3.4", stroke: "currentColor", strokeWidth: "1.1", strokeLinecap: "round" }),
12774
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "4.5", r: ".7", fill: "currentColor" })
12775
+ ] });
12776
+ }
12777
+ function unavailableCopy(status) {
12778
+ 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";
12779
+ }
12780
+ function compareFeeLabel(usd2) {
12781
+ if (usd2 === null) return "--";
12782
+ if (!Number.isFinite(usd2) || usd2 <= 0) return "$0.00";
12783
+ if (usd2 >= 0.01) return `$${usd2.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
12784
+ if (usd2 < 1e-6) return "<$0.000001";
12785
+ return `$${usd2.toLocaleString("en-US", { maximumSignificantDigits: 2 })}`;
12786
+ }
12787
+ function logoOf(tokens, hop) {
12788
+ const wanted = hop.address.toLowerCase();
12789
+ return tokens.find((t) => Number(t.chainId) === hop.chainId && String(t.address).toLowerCase() === wanted)?.logoUrl;
12790
+ }
12791
+ var WIDE_SCALE_TRAVEL_PX = 189 * 228 / 130;
12792
+ function thumbWidth(fraction) {
12793
+ return `max(32px, calc((100% - 4px) * ${fraction}))`;
12794
+ }
12795
+ function CompareQuotes(props) {
12796
+ const side = props.layout === "side";
12797
+ const sliderId = react.useId();
12798
+ const options = props.compare?.options ?? [];
12799
+ const selectedId = props.compare?.selectedId ?? null;
12800
+ const selected = options.find((o) => o.id === selectedId && !o.unavailable)?.id ?? options.find((o) => !o.unavailable)?.id ?? null;
12801
+ const picked = options.find((o) => o.id === selectedId && !o.unavailable);
12802
+ const [movedWait, setMovedWait] = react.useState(null);
12803
+ const wait2 = movedWait ?? (picked ? clampWait(picked.estimatedDuration) : proposedWait(options));
12804
+ const [openRoutes, setOpenRoutes] = react.useState(() => /* @__PURE__ */ new Set());
12805
+ const parityState = props.compare?.parity ?? { kind: "unknown" };
12806
+ const extra = props.compare ? extraVsFastest(options, selected) : null;
12807
+ const selectedOption = options.find((o) => o.id === selected);
12808
+ const anySelectable = options.some((o) => !o.unavailable);
12809
+ const moveWait = (sec) => {
12810
+ setMovedWait(sec);
12811
+ const pick = pickForWait(options, sec);
12812
+ if (pick && pick.id !== selected) props.onSelect(pick.id);
12813
+ };
12814
+ const pickCard = (option) => {
12815
+ if (props.onSelect(option.id)) setMovedWait(clampWait(option.estimatedDuration));
12816
+ };
12817
+ const toggleRoute = (id) => setOpenRoutes((prev) => {
12818
+ const next = new Set(prev);
12819
+ if (next.has(id)) next.delete(id);
12820
+ else next.add(id);
12821
+ return next;
12822
+ });
12823
+ const trackRef = react.useRef(null);
12824
+ const listRef = react.useRef(null);
12825
+ const [travel, setTravel] = react.useState(400);
12826
+ react.useLayoutEffect(() => {
12827
+ const el = trackRef.current;
12828
+ if (!el) return;
12829
+ const measure = () => setTravel(el.offsetWidth - 4);
12830
+ measure();
12831
+ if (typeof ResizeObserver === "undefined") return;
12832
+ const ro = new ResizeObserver(measure);
12833
+ ro.observe(el);
12834
+ return () => ro.disconnect();
12835
+ }, [anySelectable]);
12836
+ const scale = react.useMemo(() => waitScaleFor(side ? WIDE_SCALE_TRAVEL_PX : travel), [side, travel]);
12837
+ const pct = waitFraction(wait2, scale) * 100;
12838
+ const shown = react.useMemo(() => visibleOptions(options, wait2, selected), [options, wait2, selected]);
12839
+ const rovingId = shown.find((o) => o.id === selected && !o.unavailable)?.id ?? shown.find((o) => !o.unavailable)?.id ?? null;
12840
+ 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;
12841
+ 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: [
12842
+ anySelectable ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-wait", "data-testid": "compare-wait", children: [
12843
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-wait-top", children: [
12844
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-wait-row", children: [
12845
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: sliderId, children: "I'm willing to wait" }),
12846
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-testid": "compare-wait-label", children: waitLabel(wait2) })
12847
+ ] }),
12848
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-wait-scale", children: [
12849
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: trackRef, className: "sg-cq-track", children: [
12850
+ /* @__PURE__ */ jsxRuntime.jsx(
12851
+ "input",
12852
+ {
12853
+ id: sliderId,
12854
+ className: "sg-cq-range",
12855
+ type: "range",
12856
+ min: 0,
12857
+ max: WAIT_POSITIONS,
12858
+ step: 1,
12859
+ value: Math.round(pct * WAIT_POSITIONS / 100),
12860
+ "aria-valuetext": waitLabel(wait2),
12861
+ onChange: (e) => moveWait(snapWait(waitFromFraction(Number(e.target.value) / WAIT_POSITIONS, scale))),
12862
+ onKeyDown: (e) => {
12863
+ const dir = e.key === "ArrowRight" || e.key === "ArrowUp" ? 1 : e.key === "ArrowLeft" || e.key === "ArrowDown" ? -1 : 0;
12864
+ if (dir === 0) return;
12865
+ e.preventDefault();
12866
+ moveWait(snapWait(wait2 + dir * WAIT_STEP_SEC));
12867
+ }
12868
+ }
12869
+ ),
12870
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cq-rail", "aria-hidden": "true" }),
12871
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cq-thumb", "aria-hidden": "true", style: { width: thumbWidth(pct / 100) }, children: /* @__PURE__ */ jsxRuntime.jsx(SliderGrip, {}) })
12872
+ ] }),
12873
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-ends", children: [
12874
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "3 min" }),
12875
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "2 h" }),
12876
+ parityState.kind === "at" ? /* @__PURE__ */ jsxRuntime.jsxs(
12877
+ "span",
12878
+ {
12879
+ className: "sg-cq-parity",
12880
+ "data-testid": "compare-parity",
12881
+ style: { left: `clamp(${side ? 60 : 44}px, calc(${thumbWidth(waitFraction(parityState.timeSec, scale))} - 13px), calc(100% - ${side ? 60 : 44}px))` },
12882
+ children: [
12883
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "1:1" }),
12884
+ " ",
12885
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: compareDuration(parityState.timeSec) })
12886
+ ]
12887
+ }
12888
+ ) : null,
12889
+ parityState.kind === "unavailable" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-parity-none", "data-testid": "compare-parity", children: "1:1 currently unavailable" }) : null
12890
+ ] })
12891
+ ] })
12892
+ ] }),
12893
+ extra !== null ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12894
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sg-cq-rule", "aria-hidden": "true" }),
12895
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-extra", "data-testid": "compare-extra", children: [
12896
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-extra-icon", children: /* @__PURE__ */ jsxRuntime.jsx(WalletAddGlyph, {}) }),
12897
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-extra-text", children: [
12898
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-extra-label", children: [
12899
+ "Potential extra received",
12900
+ 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
12901
+ ] }),
12902
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-extra-amt", children: [
12903
+ "+",
12904
+ compareAmount(extra),
12905
+ " ",
12906
+ props.toSymbol
12907
+ ] })
12908
+ ] }),
12909
+ side ? null : /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-extra-note", children: [
12910
+ "Compared with fastest",
12911
+ selectedOption?.entersNetting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12912
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
12913
+ "Depends on a matching order"
12914
+ ] }) : null
12915
+ ] })
12916
+ ] })
12917
+ ] }) : null
12918
+ ] }) : null,
12919
+ /* @__PURE__ */ jsxRuntime.jsxs(
12920
+ "div",
12921
+ {
12922
+ role: "radiogroup",
12923
+ "aria-label": "Quotes",
12924
+ className: "sg-cq-list",
12925
+ ref: listRef,
12926
+ onKeyDown: (e) => {
12927
+ const dir = e.key === "ArrowDown" || e.key === "ArrowRight" ? 1 : e.key === "ArrowUp" || e.key === "ArrowLeft" ? -1 : 0;
12928
+ if (dir === 0) return;
12929
+ const pickable = shown.filter((o) => !o.unavailable);
12930
+ if (pickable.length === 0) return;
12931
+ e.preventDefault();
12932
+ const cur = Math.max(0, pickable.findIndex((o) => o.id === rovingId));
12933
+ const next = pickable[(cur + dir + pickable.length) % pickable.length];
12934
+ pickCard(next);
12935
+ requestAnimationFrame(() => listRef.current?.querySelector(`[data-oid="${CSS.escape(next.id)}"]`)?.focus());
12936
+ },
12937
+ children: [
12938
+ shown.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
12939
+ QuoteCard,
12940
+ {
12941
+ option,
12942
+ isSelected: option.id === selected,
12943
+ tabIndex: option.id === rovingId ? 0 : -1,
12944
+ tags: cornerTags(options, option, parityState),
12945
+ toSymbol: props.toSymbol,
12946
+ side,
12947
+ routeOpen: openRoutes.has(option.id),
12948
+ tokens: props.tokens,
12949
+ chainName: props.chainName,
12950
+ onPick: () => pickCard(option),
12951
+ onToggleRoute: () => toggleRoute(option.id)
12952
+ },
12953
+ option.id
12954
+ )),
12955
+ 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
12956
+ ]
12957
+ }
12958
+ )
12959
+ ] }) });
12960
+ }
12961
+ function Column({ label: label2, value }) {
12962
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-col", children: [
12963
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-col-label", children: label2 }),
12964
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-col-value", children: value })
12965
+ ] });
12966
+ }
12967
+ function HopMark({ hop, tokens, size }) {
12968
+ return /* @__PURE__ */ jsxRuntime.jsx(TokenGlyph, { symbol: hop.ticker, logoUrl: logoOf(tokens, hop), chainId: hop.chainId, size });
12969
+ }
12970
+ function QuoteCard(props) {
12971
+ const { option, tags, side } = props;
12972
+ const routeId = react.useId();
12973
+ const headRef = react.useRef(null);
12974
+ const tagRef = react.useRef(null);
12975
+ const [tagInset, setTagInset] = react.useState(null);
12976
+ react.useLayoutEffect(() => {
12977
+ const head = headRef.current;
12978
+ const tag = tagRef.current;
12979
+ if (side || !head || !tag) return setTagInset(null);
12980
+ const measure = () => setTagInset(Math.max(0, Math.ceil(head.getBoundingClientRect().right - tag.getBoundingClientRect().left) + 8));
12981
+ measure();
12982
+ if (typeof ResizeObserver === "undefined") return;
12983
+ const observer = new ResizeObserver(measure);
12984
+ observer.observe(tag);
12985
+ observer.observe(head);
12986
+ return () => observer.disconnect();
12987
+ }, [tags.length, side]);
12988
+ const netting = !!option.entersNetting;
12989
+ const gasless = !!option.gasSponsored;
12990
+ const note = netting ? "Matches your swap with an opposite order" : gasless ? "No native token needed for gas" : null;
12991
+ const nettingTag = tags.some((t) => t.tone === "green");
12992
+ const purple = tags[0]?.tone === "purple" && !nettingTag;
12993
+ const hops = option.hops;
12994
+ const collapsed = side && hops.length > 3;
12995
+ const inline = collapsed ? [hops[0], hops[1], "gap", hops[hops.length - 1]] : hops;
12996
+ const hidden3 = collapsed ? hops.slice(2, -1) : [];
12997
+ 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: [
12998
+ i > 0 ? /* @__PURE__ */ jsxRuntime.jsx(ArrowGlyph2, {}) : null,
12999
+ 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" }) })
13000
+ ] }, hop === "gap" ? "gap" : `${hop.chainId}-${hop.address}-${i}`)) });
13001
+ const fee = compareFeeLabel(option.feeUsd);
13002
+ 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: [
13003
+ i > 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-tag-dot", "aria-hidden": "true" }) : null,
13004
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-tone": tag.tone, children: tag.text })
13005
+ ] }, tag.text)) }) : null;
13006
+ const body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13007
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { ref: headRef, className: "sg-cq-head", style: tagInset === null ? void 0 : { paddingRight: tagInset }, children: [
13008
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-radio", "data-on": props.isSelected || void 0, "aria-hidden": "true" }),
13009
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-amount", children: [
13010
+ tags.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-sr", children: [
13011
+ tags.map((t) => t.text).join(", "),
13012
+ " "
13013
+ ] }) : option.label ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-sr", children: [
13014
+ option.label.toLowerCase().replace(/^./, (c) => c.toUpperCase()),
13015
+ " "
13016
+ ] }) : null,
13017
+ netting ? "~" : "",
13018
+ compareAmount(option.amount),
13019
+ " ",
13020
+ props.toSymbol
13021
+ ] })
13022
+ ] }),
13023
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-stats", children: [
13024
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-cols", children: [
13025
+ /* @__PURE__ */ jsxRuntime.jsx(Column, { label: "Est. time", value: netting ? compareDuration(option.estimatedDuration).replace(/^~/, "") : compareDuration(option.estimatedDuration) }),
13026
+ gasless ? /* @__PURE__ */ jsxRuntime.jsx(Column, { label: "Gas fee", value: "Sponsored" }) : /* @__PURE__ */ jsxRuntime.jsx(Column, { label: netting ? "Est. fee" : "Fee", value: fee }),
13027
+ side && hops.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-col", children: [
13028
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-col-label", children: "Route" }),
13029
+ routeIcons
13030
+ ] }) : null
13031
+ ] }),
13032
+ !side && note ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-note", children: note }) : null
13033
+ ] }),
13034
+ option.unavailable ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sg-cq-why", children: unavailableCopy(option.unavailable) }) : null
13035
+ ] });
13036
+ 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: [
13037
+ tagEl,
13038
+ /* @__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 }),
13039
+ !side && hops.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-cq-route", children: [
13040
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "sg-cq-route-toggle", onClick: props.onToggleRoute, "aria-expanded": props.routeOpen, "aria-controls": routeId, children: [
13041
+ "Route",
13042
+ /* @__PURE__ */ jsxRuntime.jsx(ChevronGlyph2, { up: props.routeOpen })
13043
+ ] }),
13044
+ props.routeOpen ? /* @__PURE__ */ jsxRuntime.jsx("div", { id: routeId, className: "sg-cq-hops", "data-testid": "compare-route", children: hops.map((hop, i) => (
13045
+ // biome-ignore lint/suspicious/noArrayIndexKey: a route is a fixed sequence, and a token can appear twice on it.
13046
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop", children: [
13047
+ i > 0 ? /* @__PURE__ */ jsxRuntime.jsx(ArrowGlyph2, {}) : null,
13048
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop-body", children: [
13049
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop-name", children: [
13050
+ /* @__PURE__ */ jsxRuntime.jsx(HopMark, { hop, tokens: props.tokens, size: "xxs" }),
13051
+ hop.ticker
13052
+ ] }),
13053
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sg-cq-hop-chain", children: [
13054
+ "On ",
13055
+ props.chainName(hop.chainId)
13056
+ ] })
13057
+ ] })
13058
+ ] }, `${hop.chainId}-${hop.address}-${i}`)
13059
+ )) }) : null
13060
+ ] }) : null
13061
+ ] });
13062
+ }
12033
13063
  function QuoteSheet(props) {
12034
13064
  const sheetRef = react.useRef(null);
12035
13065
  const onCloseRef = react.useRef(props.onClose);
@@ -12320,6 +13350,14 @@ function ExchangeCard(props) {
12320
13350
  () => destinationStates ? toPickerTokens.filter((t) => !destinationStates[`${Number(t.chainId)}:${String(t.address || "").toLowerCase()}`]?.disabled) : toPickerTokens,
12321
13351
  [toPickerTokens, destinationStates]
12322
13352
  );
13353
+ const seenReadyCatalogue = react.useRef(null);
13354
+ react.useEffect(() => {
13355
+ if (!catalogue?.ready) return;
13356
+ const first = seenReadyCatalogue.current === null;
13357
+ seenReadyCatalogue.current = catalogue;
13358
+ if (first || !to) return;
13359
+ if (destinationStates?.[`${Number(to.chainId)}:${String(findToken(tokens, to.chainId, to.symbol)?.address || "").toLowerCase()}`]?.disabled || !findToken(tokens, to.chainId, to.symbol)) setTo(null);
13360
+ }, [catalogue]);
12323
13361
  const normalizedAmount = normalizeDecimalText(amount);
12324
13362
  const amountValid = /^\d+(\.\d+)?$/.test(normalizedAmount) && Number(normalizedAmount) > 0 && Number(normalizedAmount) <= 1e9;
12325
13363
  const rampMode = mode !== "exchange";
@@ -12497,6 +13535,7 @@ function ExchangeCard(props) {
12497
13535
  const recipientLocked = wide && recipientState.open && recipientPending;
12498
13536
  const ctaLabel = rampMode ? soonLabel : submitting ? "Exchanging\u2026" : connected2 && flow.quoteStale ? flow.quotePaused ? "Refresh quote" : "Refreshing quote\u2026" : flow.insufficient ? "Insufficient balance" : flow.nativeShortfall || "Exchange";
12499
13537
  const selected = addressed ? flow.selected : null;
13538
+ const compare = addressed && !solActive ? flow.compare : null;
12500
13539
  const hasQuote = Boolean(quotable && !quoting && !quoteError && receive);
12501
13540
  const nativeWei = (() => {
12502
13541
  try {
@@ -12553,10 +13592,14 @@ function ExchangeCard(props) {
12553
13592
  setView("main");
12554
13593
  requestAnimationFrame(() => (isFrom ? fromTileRef : toTileRef).current?.focus());
12555
13594
  };
13595
+ const openPicker = (v) => () => {
13596
+ setSheet(null);
13597
+ setView(v);
13598
+ };
12556
13599
  const closeSheet = () => {
12557
13600
  const was = sheet;
12558
13601
  setSheet(null);
12559
- requestAnimationFrame(() => (was === "quote" ? quoteBtnRef : complianceBtnRef).current?.focus());
13602
+ requestAnimationFrame(() => (was === "quote" || was === "compare" ? quoteBtnRef : complianceBtnRef).current?.focus());
12560
13603
  };
12561
13604
  const pctChips = mode !== "onramp" ? (
12562
13605
  // a11y note: <fieldset> carries UA styling that would have to be reset on every host page;
@@ -12586,7 +13629,7 @@ function ExchangeCard(props) {
12586
13629
  icon: /* @__PURE__ */ jsxRuntime.jsx(QuoteGlyph, {}),
12587
13630
  label: "Quote",
12588
13631
  badge: lg && hasQuote ? { text: "Best return", tone: "info" } : null,
12589
- onClick: () => setSheet("quote"),
13632
+ onClick: () => setSheet(compare ? "compare" : "quote"),
12590
13633
  disabled: !hasQuote
12591
13634
  }
12592
13635
  );
@@ -12603,7 +13646,27 @@ function ExchangeCard(props) {
12603
13646
  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,
12604
13647
  error: solanaWallet.error || wallet.error
12605
13648
  }
12606
- ) : 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(
13649
+ ) : 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" ? (
13650
+ // Stays mounted even when `compare` is momentarily null (a refresh that is loading or failed), mirroring the
13651
+ // dapp's CompareQuotesDialog: it shows the empty/error notice in place of the cards instead of popping the
13652
+ // screen and dropping focus (zd-dapp src/components/CompareQuotesDialog.tsx uses `emptyMessage` the same way).
13653
+ /* @__PURE__ */ jsxRuntime.jsx(
13654
+ CompareQuotes,
13655
+ {
13656
+ compare,
13657
+ toSymbol: toTicker,
13658
+ tokens,
13659
+ chainName: (id) => nameOf(id) ?? `Chain ${id}`,
13660
+ onSelect: flow.selectOption,
13661
+ onBack: closeSheet,
13662
+ onRefresh: flow.reload,
13663
+ refreshing: flow.status === "loading",
13664
+ emptyMessage: flow.status === "loading" ? "Fetching quote\u2026" : quoteError || void 0,
13665
+ modal: !!props.inDialog,
13666
+ layout: wide ? "side" : "card"
13667
+ }
13668
+ )
13669
+ ) : sheet === "quote" && hasQuote ? /* @__PURE__ */ jsxRuntime.jsx(
12607
13670
  QuoteSheet,
12608
13671
  {
12609
13672
  onClose: closeSheet,
@@ -12682,7 +13745,7 @@ function ExchangeCard(props) {
12682
13745
  }
12683
13746
  );
12684
13747
  } else if (sheetBody && !wide) {
12685
- takeover = walletsOpen && !walletDetails || recipientState.open;
13748
+ takeover = walletsOpen && !walletDetails || recipientState.open || !walletsOpen && (sheet === "compare" || sheet === "compliance");
12686
13749
  body = sheetBody;
12687
13750
  } else if (solActive && solFlow.status === "sent") {
12688
13751
  body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -12748,9 +13811,9 @@ function ExchangeCard(props) {
12748
13811
  body = wide ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12749
13812
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-stack", children: [
12750
13813
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-ft", children: [
12751
- 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") }),
13814
+ 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") }),
12752
13815
  /* @__PURE__ */ jsxRuntime.jsx(FlipButton, { small: true, onClick: flip, disabled: !flippable }),
12753
- 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") })
13816
+ 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") })
12754
13817
  ] }),
12755
13818
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane", "data-kind": "send", children: [
12756
13819
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sg-pane-top", children: [