@glacislabs/stablegenie-zerodelta 4.19.0 → 4.20.0

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