@agg-build/ui 2.4.2 → 2.4.3

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.js CHANGED
@@ -236,6 +236,7 @@ __export(src_exports, {
236
236
  getMotionClassName: () => getMotionClassName,
237
237
  getPendingCardSession: () => getPendingCardSession,
238
238
  getScrollBehavior: () => getScrollBehavior,
239
+ getSettlementDifferenceId: () => getSettlementDifferenceId,
239
240
  getTradingAveragePriceLabel: () => getTradingAveragePriceLabel,
240
241
  getTradingBalanceLabel: () => getTradingBalanceLabel,
241
242
  getTradingDateLabel: () => getTradingDateLabel,
@@ -251,8 +252,10 @@ __export(src_exports, {
251
252
  orderbookRowLimitDefault: () => orderbookRowLimitDefault,
252
253
  parseAmount: () => parseAmount,
253
254
  parseVenue: () => parseVenue,
255
+ prepareSettlementDifferences: () => prepareSettlementDifferences,
254
256
  requestAggDepositModalOpen: () => requestAggDepositModalOpen,
255
257
  requestAggWithdrawModalOpen: () => requestAggWithdrawModalOpen,
258
+ resolveDifferenceIconClassName: () => resolveDifferenceIconClassName,
256
259
  resolveEventDetailsSyncKey: () => resolveEventDetailsSyncKey,
257
260
  resolveOrderBookRows: () => resolveOrderBookRows,
258
261
  resolveResolvedOutcomeLabel: () => resolveResolvedOutcomeLabel,
@@ -6092,17 +6095,10 @@ var SettlementSkeletonView = ({
6092
6095
  children: [
6093
6096
  /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [
6094
6097
  /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(SkeletonBlock, { className: "h-4 w-[81px] rounded-agg-sm" }),
6095
- /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(SkeletonBlock, { className: "h-5 w-full max-w-[240px] rounded-agg-sm" })
6098
+ /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(SkeletonBlock, { className: "h-5 w-[240px] max-w-[60%] rounded-agg-sm" })
6096
6099
  ] }),
6097
- /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)("div", { className: "flex w-full flex-col gap-3", children: [
6098
- /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(SkeletonBlock, { className: "h-5 w-[200px] rounded-agg-sm" }),
6099
- /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)("div", { className: "flex flex-col gap-2", children: [
6100
- /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(SkeletonBlock, { className: "h-4 w-full max-w-[320px] rounded-agg-sm" }),
6101
- /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(SkeletonBlock, { className: "h-4 w-full max-w-[280px] rounded-agg-sm" })
6102
- ] })
6103
- ] }),
6104
- /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "h-px w-full bg-agg-separator" }),
6105
- /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)("div", { className: "flex w-full flex-col gap-3", children: [
6100
+ /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(SkeletonBlock, { className: "h-5 w-[200px] rounded-agg-sm" }),
6101
+ /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)("div", { className: "flex w-full flex-col gap-4", children: [
6106
6102
  /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)("div", { className: "flex items-center gap-2", children: [
6107
6103
  /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(SkeletonBlock, { className: "size-4 rounded-agg-sm" }),
6108
6104
  /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(SkeletonBlock, { className: "h-5 w-[100px] rounded-agg-sm" })
@@ -14069,6 +14065,137 @@ SettlementTextRenderer.displayName = "SettlementTextRenderer";
14069
14065
  // src/trading/settlement/index.tsx
14070
14066
  var import_jsx_runtime140 = require("react/jsx-runtime");
14071
14067
  var SETTLEMENT_SECTION_ID = "agg-settlement-section";
14068
+ var getSettlementDifferenceId = (sectionId, canonicalKey) => {
14069
+ return `${sectionId}-difference-${canonicalKey}`;
14070
+ };
14071
+ var dateOnlyRegex = /^(\d{4})-(\d{2})-(\d{2})$/;
14072
+ var isoTimestampWithTimezoneRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:?\d{2})$/i;
14073
+ var normalizeDifferenceText = (value) => {
14074
+ return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
14075
+ };
14076
+ var resolveCanonicalDifferenceKey = (difference) => {
14077
+ const normalizedType = normalizeDifferenceText(difference.type);
14078
+ const combined = normalizeDifferenceText(`${difference.type} ${difference.title}`);
14079
+ if (combined.includes("start_date") || combined.includes("open_date")) return "start_date";
14080
+ if (combined.includes("end_date") || combined.includes("close_date") || combined.includes("closing_date") || combined.includes("expiration_date") || combined.includes("expiry_date")) {
14081
+ return "end_date";
14082
+ }
14083
+ if (combined.includes("resolution_timing") || combined.includes("resolution_date") || combined.includes("resolution_deadline") || combined.includes("settlement_date") || combined.includes("settlement_deadline") || combined.includes("settlement_timing")) {
14084
+ return "resolution_timing";
14085
+ }
14086
+ return normalizedType || "other";
14087
+ };
14088
+ var parseSettlementDateMs = (value) => {
14089
+ const trimmed = value.trim();
14090
+ const dateOnlyMatch = dateOnlyRegex.exec(trimmed);
14091
+ if (dateOnlyMatch) {
14092
+ const [, year, month, day] = dateOnlyMatch;
14093
+ return Date.UTC(Number(year), Number(month) - 1, Number(day));
14094
+ }
14095
+ if (!isoTimestampWithTimezoneRegex.test(trimmed)) return null;
14096
+ const ms = Date.parse(trimmed);
14097
+ return Number.isNaN(ms) ? null : ms;
14098
+ };
14099
+ var isDateLikeDifference = (canonicalKey) => {
14100
+ return canonicalKey === "resolution_timing" || canonicalKey === "start_date" || canonicalKey === "end_date";
14101
+ };
14102
+ var hasEqualNormalizedDateValues = (difference, canonicalKey) => {
14103
+ if (!isDateLikeDifference(canonicalKey)) return false;
14104
+ const values = Object.values(difference.perVenue);
14105
+ if (values.length < 2) return false;
14106
+ const timestamps = values.map(parseSettlementDateMs);
14107
+ if (timestamps.some((timestamp) => timestamp === null)) return false;
14108
+ return new Set(timestamps).size === 1;
14109
+ };
14110
+ var resolveDifferenceSeverity = (difference, canonicalKey) => {
14111
+ var _a;
14112
+ const combined = normalizeDifferenceText(
14113
+ `${difference.type} ${difference.title} ${(_a = difference.summary) != null ? _a : ""}`
14114
+ );
14115
+ if (isDateLikeDifference(canonicalKey)) return "critical";
14116
+ if (canonicalKey === "scope" || canonicalKey === "threshold" || canonicalKey === "edge_cases") {
14117
+ return "critical";
14118
+ }
14119
+ if (combined.includes("conflict") || combined.includes("void") || combined.includes("cancel") || combined.includes("postpone") || combined.includes("recount") || combined.includes("overtime") || combined.includes("extra_time")) {
14120
+ return "critical";
14121
+ }
14122
+ return "informational";
14123
+ };
14124
+ var mergePerVenueValues = (current, next) => {
14125
+ return Object.entries(next).reduce(
14126
+ (merged, [venue, value]) => {
14127
+ if (merged[venue] === void 0) merged[venue] = value;
14128
+ return merged;
14129
+ },
14130
+ __spreadValues({}, current)
14131
+ );
14132
+ };
14133
+ var prepareSettlementDifferences = (differences) => {
14134
+ const byCanonicalKey = /* @__PURE__ */ new Map();
14135
+ for (const [originalIndex, difference] of (differences != null ? differences : []).entries()) {
14136
+ const canonicalKey = resolveCanonicalDifferenceKey(difference);
14137
+ if (hasEqualNormalizedDateValues(difference, canonicalKey)) continue;
14138
+ const existing = byCanonicalKey.get(canonicalKey);
14139
+ if (existing) {
14140
+ byCanonicalKey.set(canonicalKey, __spreadProps(__spreadValues({}, existing), {
14141
+ perVenue: mergePerVenueValues(existing.perVenue, difference.perVenue)
14142
+ }));
14143
+ continue;
14144
+ }
14145
+ byCanonicalKey.set(canonicalKey, __spreadProps(__spreadValues({}, difference), {
14146
+ canonicalKey,
14147
+ severity: resolveDifferenceSeverity(difference, canonicalKey),
14148
+ originalIndex
14149
+ }));
14150
+ }
14151
+ return Array.from(byCanonicalKey.values()).sort((left, right) => {
14152
+ const severityDelta = Number(right.severity === "critical") - Number(left.severity === "critical");
14153
+ if (severityDelta !== 0) return severityDelta;
14154
+ return left.originalIndex - right.originalIndex;
14155
+ });
14156
+ };
14157
+ var formatVenueFallbackLabel = (venue) => {
14158
+ return venue.split(/[-_\s]+/).filter(Boolean).map((part) => `${part.slice(0, 1).toUpperCase()}${part.slice(1)}`).join(" ");
14159
+ };
14160
+ var resolveSettlementVenueLabel = (venue, labels) => {
14161
+ var _a;
14162
+ return (_a = labels.venues[venue]) != null ? _a : formatVenueFallbackLabel(venue);
14163
+ };
14164
+ var resolveDifferenceVenueKeys = (difference, settlementVenues) => {
14165
+ const explicitVenues = Object.keys(difference.perVenue);
14166
+ if (!isDateLikeDifference(difference.canonicalKey)) return explicitVenues;
14167
+ const allVenues = [...settlementVenues != null ? settlementVenues : [], ...explicitVenues];
14168
+ return Array.from(new Set(allVenues.filter((venue) => venue.trim().length > 0)));
14169
+ };
14170
+ var resolveDifferenceIconClassName = (canonicalKey) => {
14171
+ if (canonicalKey.includes("source") || canonicalKey.includes("url")) return "fi-rr-world";
14172
+ if (canonicalKey === "resolution_timing" || canonicalKey.includes("timing")) {
14173
+ return "fi-rr-clock";
14174
+ }
14175
+ if (canonicalKey === "start_date" || canonicalKey.includes("start"))
14176
+ return "fi-rr-calendar-clock";
14177
+ if (canonicalKey === "end_date" || canonicalKey.includes("end")) return "fi-rr-calendar-clock";
14178
+ if (canonicalKey.includes("cancel") || canonicalKey.includes("void") || canonicalKey.includes("postpone")) {
14179
+ return "fi-rr-ban";
14180
+ }
14181
+ if (canonicalKey === "edge_cases" || canonicalKey.includes("edge")) {
14182
+ return "fi-rr-triangle-warning";
14183
+ }
14184
+ if (canonicalKey === "scope") return "fi-rr-layers";
14185
+ if (canonicalKey === "threshold") return "fi-rr-tachometer-alt-fastest";
14186
+ if (canonicalKey.includes("wording")) return "fi-rr-document";
14187
+ return "fi-rr-info";
14188
+ };
14189
+ var buildSettlementVenueRules = ({
14190
+ eventBlock,
14191
+ marketBlock,
14192
+ primaryRulesBlock,
14193
+ settlementVenueRules
14194
+ }) => {
14195
+ if (settlementVenueRules) return settlementVenueRules;
14196
+ const content = [marketBlock == null ? void 0 : marketBlock.content, primaryRulesBlock == null ? void 0 : primaryRulesBlock.content, eventBlock == null ? void 0 : eventBlock.content].filter((value) => typeof value === "string" && value.trim().length > 0).join("\n\n");
14197
+ return content ? [{ venue: "polymarket", content }] : [];
14198
+ };
14072
14199
  var getSettlementHeaderClassName = () => {
14073
14200
  return "flex items-center justify-between gap-4";
14074
14201
  };
@@ -14080,9 +14207,12 @@ var Settlement = ({
14080
14207
  eventDescription,
14081
14208
  marketDescription,
14082
14209
  primaryRules,
14210
+ settlementDiff,
14211
+ settlementVenues,
14212
+ settlementVenueRules,
14083
14213
  isLoading = false
14084
14214
  }) => {
14085
- var _a, _b, _c;
14215
+ var _a, _b, _c, _d, _e;
14086
14216
  const labels = (0, import_hooks46.useLabels)();
14087
14217
  const blocks = (0, import_react22.useMemo)(
14088
14218
  () => dedupeSettlementSources({
@@ -14092,9 +14222,34 @@ var Settlement = ({
14092
14222
  }),
14093
14223
  [eventDescription, marketDescription, primaryRules]
14094
14224
  );
14225
+ const settlementDifferences = (0, import_react22.useMemo)(
14226
+ () => prepareSettlementDifferences(settlementDiff == null ? void 0 : settlementDiff.differences),
14227
+ [settlementDiff == null ? void 0 : settlementDiff.differences]
14228
+ );
14095
14229
  const eventBlock = (_a = blocks.find((block) => block.key === "eventDescription")) != null ? _a : null;
14096
14230
  const marketBlock = (_b = blocks.find((block) => block.key === "marketDescription")) != null ? _b : null;
14097
14231
  const primaryRulesBlock = (_c = blocks.find((block) => block.key === "primaryRules")) != null ? _c : null;
14232
+ const venueRuleBlocks = (0, import_react22.useMemo)(
14233
+ () => buildSettlementVenueRules({
14234
+ eventBlock,
14235
+ marketBlock,
14236
+ primaryRulesBlock,
14237
+ settlementVenueRules
14238
+ }),
14239
+ [eventBlock, marketBlock, primaryRulesBlock, settlementVenueRules]
14240
+ );
14241
+ const defaultOpenDifferenceKey = (_e = (_d = settlementDifferences[0]) == null ? void 0 : _d.canonicalKey) != null ? _e : null;
14242
+ const [openDifferenceKeys, setOpenDifferenceKeys] = (0, import_react22.useState)(
14243
+ () => defaultOpenDifferenceKey ? [defaultOpenDifferenceKey] : []
14244
+ );
14245
+ (0, import_react22.useEffect)(() => {
14246
+ setOpenDifferenceKeys(defaultOpenDifferenceKey ? [defaultOpenDifferenceKey] : []);
14247
+ }, [defaultOpenDifferenceKey]);
14248
+ const handleToggleDifference = (canonicalKey) => {
14249
+ setOpenDifferenceKeys(
14250
+ (currentKeys) => currentKeys.includes(canonicalKey) ? currentKeys.filter((currentKey) => currentKey !== canonicalKey) : [...currentKeys, canonicalKey]
14251
+ );
14252
+ };
14098
14253
  if (isLoading) {
14099
14254
  return /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
14100
14255
  Skeleton,
@@ -14106,6 +14261,124 @@ var Settlement = ({
14106
14261
  );
14107
14262
  }
14108
14263
  const resolvedSectionLabel = sectionLabel === defaultSettlementSectionLabel ? labels.trading.settlementSection : sectionLabel;
14264
+ if (settlementDifferences.length > 0) {
14265
+ return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
14266
+ Card,
14267
+ {
14268
+ id,
14269
+ className: cn(
14270
+ "group/agg-settlement-card",
14271
+ "flex w-full flex-col items-start gap-4 rounded-agg-xl border border-agg-separator bg-agg-secondary p-5 shadow-none hover:shadow-none sm:gap-5",
14272
+ className
14273
+ ),
14274
+ children: [
14275
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { className: "agg-settlement-header flex w-full flex-col items-start gap-1 text-agg-muted-foreground sm:flex-row sm:items-center sm:justify-between sm:gap-4", children: [
14276
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("p", { className: "shrink-0 text-agg-xs font-agg-bold leading-agg-4 uppercase", children: resolvedSectionLabel }),
14277
+ question ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("p", { className: "agg-settlement-question min-w-0 text-agg-sm font-agg-normal leading-agg-5 sm:max-w-[314px] sm:truncate", children: question }) : null
14278
+ ] }),
14279
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { className: "agg-settlement-differences flex w-full flex-col items-start gap-5", children: [
14280
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { className: "flex items-center gap-2", children: [
14281
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: "Key differences" }),
14282
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("span", { className: "flex size-4 shrink-0 items-center justify-center rounded-agg-full bg-agg-primary text-[10px] font-agg-bold leading-[14px] text-agg-on-primary", children: settlementDifferences.length })
14283
+ ] }),
14284
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "flex w-full flex-col items-start gap-5", children: settlementDifferences.map((difference) => {
14285
+ const venueKeys = resolveDifferenceVenueKeys(difference, settlementVenues);
14286
+ const isExpanded = openDifferenceKeys.includes(difference.canonicalKey) && venueKeys.length > 0;
14287
+ return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
14288
+ "div",
14289
+ {
14290
+ id: getSettlementDifferenceId(id, difference.canonicalKey),
14291
+ className: "agg-settlement-difference flex w-full flex-col items-start gap-2 rounded-agg-lg",
14292
+ children: [
14293
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
14294
+ "button",
14295
+ {
14296
+ type: "button",
14297
+ className: "flex w-full cursor-pointer items-start gap-2 text-left",
14298
+ "aria-expanded": isExpanded,
14299
+ onClick: () => handleToggleDifference(difference.canonicalKey),
14300
+ children: [
14301
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
14302
+ "i",
14303
+ {
14304
+ className: cn(
14305
+ "fi",
14306
+ resolveDifferenceIconClassName(difference.canonicalKey),
14307
+ "inline-flex size-4! shrink-0 items-center justify-center text-[16px] leading-none text-agg-muted-foreground"
14308
+ ),
14309
+ "aria-hidden": "true"
14310
+ }
14311
+ ),
14312
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("p", { className: "min-w-0 text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground break-words [overflow-wrap:anywhere]", children: difference.title }),
14313
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
14314
+ Icon,
14315
+ {
14316
+ name: isExpanded ? "chevron-up" : "chevron-down",
14317
+ className: "size-4! mt-0.5 shrink-0 text-agg-foreground",
14318
+ "aria-hidden": "true"
14319
+ }
14320
+ )
14321
+ ]
14322
+ }
14323
+ ),
14324
+ isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("dl", { className: "flex w-full flex-col items-start gap-1 px-6", children: venueKeys.map((venue) => {
14325
+ var _a2;
14326
+ const venueValue = (_a2 = difference.perVenue[venue]) != null ? _a2 : labels.trading.settlementValueUnavailable;
14327
+ const venueLabel = resolveSettlementVenueLabel(venue, labels);
14328
+ return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { className: "flex w-full items-start gap-2", children: [
14329
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
14330
+ VenueLogo,
14331
+ {
14332
+ venue,
14333
+ size: "small",
14334
+ className: "mt-0.5 size-4",
14335
+ ariaLabel: venueLabel
14336
+ }
14337
+ ),
14338
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("dt", { className: "w-[88px] shrink-0 text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground", children: venueLabel }),
14339
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("dd", { className: "min-w-0 flex-1 text-agg-sm font-agg-normal leading-agg-5 text-agg-muted-foreground break-words [overflow-wrap:anywhere]", children: venueValue })
14340
+ ] }, venue);
14341
+ }) }) : null
14342
+ ]
14343
+ },
14344
+ difference.canonicalKey
14345
+ );
14346
+ }) }),
14347
+ venueRuleBlocks.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(import_jsx_runtime140.Fragment, { children: [
14348
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "h-px w-full bg-agg-separator" }),
14349
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("p", { className: "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: "Full rules by venue" }),
14350
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "flex w-full flex-col items-start gap-4", children: venueRuleBlocks.map((rule) => {
14351
+ const venueLabel = resolveSettlementVenueLabel(rule.venue, labels);
14352
+ return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("details", { className: "group/agg-settlement-rule w-full", children: [
14353
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("summary", { className: "flex cursor-pointer list-none items-center gap-2 text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground marker:hidden", children: [
14354
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
14355
+ VenueLogo,
14356
+ {
14357
+ venue: rule.venue,
14358
+ size: "small",
14359
+ className: "size-4",
14360
+ ariaLabel: venueLabel
14361
+ }
14362
+ ),
14363
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("span", { children: venueLabel }),
14364
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(
14365
+ Icon,
14366
+ {
14367
+ name: "chevron-down",
14368
+ className: "size-4! shrink-0 text-agg-foreground transition-transform group-open/agg-settlement-rule:rotate-180",
14369
+ "aria-hidden": "true"
14370
+ }
14371
+ )
14372
+ ] }),
14373
+ /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "mt-3 pl-6", children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(SettlementTextRenderer, { content: rule.content }) })
14374
+ ] }, rule.venue);
14375
+ }) })
14376
+ ] }) : null
14377
+ ] })
14378
+ ]
14379
+ }
14380
+ );
14381
+ }
14109
14382
  return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
14110
14383
  Card,
14111
14384
  {
@@ -14120,7 +14393,7 @@ var Settlement = ({
14120
14393
  /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("p", { className: "text-agg-xs font-agg-bold leading-agg-4 uppercase text-agg-muted-foreground", children: resolvedSectionLabel }),
14121
14394
  question ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("p", { className: "agg-settlement-question text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: question }) : null
14122
14395
  ] }),
14123
- blocks.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("p", { className: "agg-settlement-empty text-agg-sm leading-agg-5 text-agg-muted-foreground", children: labels.trading.settlementEmpty }) : /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { className: "agg-settlement-sections flex flex-col gap-4", children: [
14396
+ blocks.length === 0 && settlementDifferences.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("p", { className: "agg-settlement-empty text-agg-sm leading-agg-5 text-agg-muted-foreground", children: labels.trading.settlementEmpty }) : /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { className: "agg-settlement-sections flex flex-col gap-4", children: [
14124
14397
  eventBlock || marketBlock ? /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)(
14125
14398
  "div",
14126
14399
  {
@@ -14155,12 +14428,17 @@ Settlement.displayName = "Settlement";
14155
14428
  var import_jsx_runtime141 = require("react/jsx-runtime");
14156
14429
  var SettlementSummary = ({
14157
14430
  content,
14431
+ settlementDiff,
14158
14432
  settlementSectionId = SETTLEMENT_SECTION_ID,
14159
14433
  className
14160
14434
  }) => {
14161
14435
  const labels = (0, import_hooks47.useLabels)();
14162
14436
  const firstParagraph = (0, import_react23.useMemo)(() => getFirstSettlementParagraph(content), [content]);
14163
- if (!firstParagraph) return null;
14437
+ const settlementDifferences = (0, import_react23.useMemo)(
14438
+ () => prepareSettlementDifferences(settlementDiff == null ? void 0 : settlementDiff.differences),
14439
+ [settlementDiff == null ? void 0 : settlementDiff.differences]
14440
+ );
14441
+ if (!firstParagraph && settlementDifferences.length === 0) return null;
14164
14442
  const handleReadFullDetails = (event) => {
14165
14443
  event.preventDefault();
14166
14444
  event.stopPropagation();
@@ -14169,43 +14447,118 @@ var SettlementSummary = ({
14169
14447
  if (!target) return;
14170
14448
  target.scrollIntoView({ behavior: "smooth", block: "start" });
14171
14449
  };
14172
- return /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { className: cn("agg-settlement-summary flex w-full flex-col gap-2", className), children: [
14173
- /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
14174
- Typography,
14450
+ const handleDifferencePillClick = (event, canonicalKey) => {
14451
+ event.preventDefault();
14452
+ event.stopPropagation();
14453
+ if (typeof document === "undefined") return;
14454
+ const target = document.getElementById(
14455
+ getSettlementDifferenceId(settlementSectionId, canonicalKey)
14456
+ );
14457
+ if (!target) return;
14458
+ const trigger = target.querySelector("button[aria-expanded]");
14459
+ if ((trigger == null ? void 0 : trigger.getAttribute("aria-expanded")) === "false") {
14460
+ trigger.click();
14461
+ }
14462
+ target.scrollIntoView({ behavior: "smooth", block: "start" });
14463
+ };
14464
+ const actionButton = /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(
14465
+ "button",
14466
+ {
14467
+ type: "button",
14468
+ className: cn(
14469
+ "agg-settlement-summary-toggle",
14470
+ "inline-flex shrink-0 cursor-pointer items-center gap-1 whitespace-nowrap text-agg-sm font-agg-bold leading-agg-5 text-agg-primary",
14471
+ "hover:opacity-80",
14472
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary"
14473
+ ),
14474
+ "aria-controls": settlementSectionId,
14475
+ onClick: handleReadFullDetails,
14476
+ children: [
14477
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("span", { children: labels.settlementSummary.readFullDetails }),
14478
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(Icon, { name: "chevron-down", className: "size-[14px]", "aria-hidden": "true" })
14479
+ ]
14480
+ }
14481
+ );
14482
+ if (settlementDifferences.length > 0) {
14483
+ const visibleDifferences = settlementDifferences.slice(0, 2);
14484
+ const hiddenDifferenceCount = settlementDifferences.length - visibleDifferences.length;
14485
+ return /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(
14486
+ "div",
14175
14487
  {
14176
- variant: "caption-caps",
14177
- className: "agg-settlement-summary-label text-agg-muted-foreground",
14178
- children: labels.settlementSummary.title
14488
+ className: cn(
14489
+ "agg-settlement-summary flex w-full flex-wrap items-start justify-between gap-x-4 gap-y-2",
14490
+ className
14491
+ ),
14492
+ children: [
14493
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { className: "flex min-w-[240px] flex-1 flex-wrap items-center gap-x-5 gap-y-3", children: [
14494
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { className: "agg-settlement-summary-heading flex shrink-0 items-center gap-2", children: [
14495
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("p", { className: "text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground", children: labels.settlementSummary.title }),
14496
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("span", { className: "flex size-4 shrink-0 items-center justify-center rounded-agg-full bg-agg-primary text-[10px] font-agg-bold leading-[14px] text-agg-on-primary", children: settlementDifferences.length })
14497
+ ] }),
14498
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { className: "agg-settlement-summary-pills flex min-w-[240px] flex-1 flex-wrap items-center gap-2", children: [
14499
+ visibleDifferences.map((difference) => /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(
14500
+ "button",
14501
+ {
14502
+ type: "button",
14503
+ className: cn(
14504
+ "flex h-6 max-w-full shrink-0 cursor-pointer items-center gap-2 rounded-agg-full bg-agg-secondary-hover px-3 py-1 text-agg-xs font-agg-normal leading-agg-4 text-agg-foreground sm:max-w-[220px]",
14505
+ "hover:opacity-80",
14506
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary"
14507
+ ),
14508
+ onClick: (event) => handleDifferencePillClick(event, difference.canonicalKey),
14509
+ children: [
14510
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
14511
+ "i",
14512
+ {
14513
+ className: cn(
14514
+ "fi",
14515
+ resolveDifferenceIconClassName(difference.canonicalKey),
14516
+ "inline-flex size-3 shrink-0 items-center justify-center text-[12px] leading-none text-agg-muted-foreground"
14517
+ ),
14518
+ "aria-hidden": "true"
14519
+ }
14520
+ ),
14521
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("span", { className: "min-w-0 truncate", children: difference.title })
14522
+ ]
14523
+ },
14524
+ difference.canonicalKey
14525
+ )),
14526
+ hiddenDifferenceCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("span", { className: "flex h-6 shrink-0 items-center rounded-agg-full bg-agg-secondary-hover px-3 py-1 text-agg-xs font-agg-normal leading-agg-4 text-agg-foreground", children: [
14527
+ "+",
14528
+ hiddenDifferenceCount
14529
+ ] }) : null
14530
+ ] })
14531
+ ] }),
14532
+ actionButton
14533
+ ]
14179
14534
  }
14180
- ),
14181
- /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { className: "agg-settlement-summary-row flex w-full items-center gap-3", children: [
14182
- /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
14183
- "p",
14184
- {
14185
- className: cn(
14186
- "agg-settlement-summary-text",
14187
- "min-w-0 flex-1 truncate text-agg-sm leading-agg-5 text-agg-foreground"
14188
- ),
14189
- children: firstParagraph
14190
- }
14535
+ );
14536
+ }
14537
+ return /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)(
14538
+ "div",
14539
+ {
14540
+ className: cn(
14541
+ "agg-settlement-summary flex w-full items-center justify-between gap-4",
14542
+ className
14191
14543
  ),
14192
- /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
14193
- "button",
14194
- {
14195
- type: "button",
14196
- className: cn(
14197
- "agg-settlement-summary-toggle",
14198
- "shrink-0 cursor-pointer whitespace-nowrap text-agg-sm font-agg-bold leading-agg-5 text-agg-primary",
14199
- "hover:opacity-80",
14200
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary"
14201
- ),
14202
- "aria-controls": settlementSectionId,
14203
- onClick: handleReadFullDetails,
14204
- children: labels.settlementSummary.readFullDetails
14205
- }
14206
- )
14207
- ] })
14208
- ] });
14544
+ children: [
14545
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { className: "agg-settlement-summary-row flex min-w-0 flex-1 items-center gap-5", children: [
14546
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("div", { className: "agg-settlement-summary-heading flex shrink-0 items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("p", { className: "text-agg-sm font-agg-normal leading-agg-5 text-agg-foreground", children: labels.settlementSummary.title }) }),
14547
+ /* @__PURE__ */ (0, import_jsx_runtime141.jsx)(
14548
+ "p",
14549
+ {
14550
+ className: cn(
14551
+ "agg-settlement-summary-text",
14552
+ "min-w-0 flex-1 truncate text-agg-sm leading-agg-5 text-agg-foreground"
14553
+ ),
14554
+ children: firstParagraph
14555
+ }
14556
+ )
14557
+ ] }),
14558
+ actionButton
14559
+ ]
14560
+ }
14561
+ );
14209
14562
  };
14210
14563
  SettlementSummary.displayName = "SettlementSummary";
14211
14564
 
@@ -14940,7 +15293,7 @@ var EventListItemDetailsContent = ({
14940
15293
  }
14941
15294
  )
14942
15295
  ] }),
14943
- event.description ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(SettlementSummary, { content: event.description }) : null
15296
+ event.description || event.settlementDiff ? /* @__PURE__ */ (0, import_jsx_runtime142.jsx)(SettlementSummary, { content: event.description, settlementDiff: event.settlementDiff }) : null
14944
15297
  ]
14945
15298
  }
14946
15299
  );
@@ -18102,7 +18455,7 @@ var hasContent = (value) => {
18102
18455
  return typeof value === "string" && value.trim().length > 0;
18103
18456
  };
18104
18457
  var SettlementDetails = ({ className }) => {
18105
- var _a, _b, _c, _d, _e, _f;
18458
+ var _a, _b, _c, _d, _e, _f, _g, _h;
18106
18459
  const tradingContext = (0, import_hooks54.useEventTradingContext)();
18107
18460
  const selectedEvent = (_a = tradingContext == null ? void 0 : tradingContext.selectedEvent) != null ? _a : null;
18108
18461
  const selectedMarket = (_b = tradingContext == null ? void 0 : tradingContext.selectedMarket) != null ? _b : null;
@@ -18111,16 +18464,29 @@ var SettlementDetails = ({ className }) => {
18111
18464
  const eventDescription = (_c = selectedEvent.description) != null ? _c : null;
18112
18465
  const marketDescription = (_d = selectedMarket.description) != null ? _d : null;
18113
18466
  const primaryRules = (_e = selectedMarket.rulesPrimary) != null ? _e : null;
18114
- if (!hasContent(eventDescription) && !hasContent(marketDescription) && !hasContent(primaryRules)) {
18467
+ const settlementDiff = (_f = selectedEvent.settlementDiff) != null ? _f : null;
18468
+ const settlementVenues = Array.from(
18469
+ new Set(selectedEvent.venueMarkets.map((market) => market.venue))
18470
+ );
18471
+ const selectedMarketRuleContent = [
18472
+ selectedMarket.description,
18473
+ selectedMarket.rulesPrimary,
18474
+ selectedMarket.rulesSecondary
18475
+ ].filter(hasContent).join("\n\n");
18476
+ const settlementVenueRules = selectedMarketRuleContent ? [{ venue: selectedMarket.venue, content: selectedMarketRuleContent }] : [];
18477
+ if (!hasContent(eventDescription) && !hasContent(marketDescription) && !hasContent(primaryRules) && ((_g = settlementDiff == null ? void 0 : settlementDiff.differences.length) != null ? _g : 0) === 0) {
18115
18478
  return null;
18116
18479
  }
18117
18480
  return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", { className: "agg-settlement-list flex flex-col gap-6", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", { className: "agg-settlement-list-item", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
18118
18481
  Settlement,
18119
18482
  {
18120
- question: (_f = selectedMarket.question) != null ? _f : selectedEvent.title,
18483
+ question: (_h = selectedMarket.question) != null ? _h : selectedEvent.title,
18121
18484
  eventDescription,
18122
18485
  marketDescription,
18123
18486
  primaryRules,
18487
+ settlementDiff,
18488
+ settlementVenues,
18489
+ settlementVenueRules,
18124
18490
  className
18125
18491
  }
18126
18492
  ) }) });
@@ -23161,7 +23527,14 @@ var EventMarketPageLoadingState = ({
23161
23527
  /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(MarketDetails, { isLoading: true, isOpened: true, classNames: { root: "w-full" } }),
23162
23528
  /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(MarketDetails, { isLoading: true, isOpened: false, classNames: { root: "w-full" } }),
23163
23529
  /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(MarketDetails, { isLoading: true, isOpened: false, classNames: { root: "w-full" } })
23164
- ] })
23530
+ ] }),
23531
+ /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
23532
+ Skeleton,
23533
+ {
23534
+ view: skeletonViews.settlement,
23535
+ className: cn("agg-settlement-list-item", classNames == null ? void 0 : classNames.settlement)
23536
+ }
23537
+ )
23165
23538
  ]
23166
23539
  }
23167
23540
  ),
@@ -33311,6 +33684,7 @@ GeoBlockModal.displayName = "GeoBlockModal";
33311
33684
  getMotionClassName,
33312
33685
  getPendingCardSession,
33313
33686
  getScrollBehavior,
33687
+ getSettlementDifferenceId,
33314
33688
  getTradingAveragePriceLabel,
33315
33689
  getTradingBalanceLabel,
33316
33690
  getTradingDateLabel,
@@ -33326,8 +33700,10 @@ GeoBlockModal.displayName = "GeoBlockModal";
33326
33700
  orderbookRowLimitDefault,
33327
33701
  parseAmount,
33328
33702
  parseVenue,
33703
+ prepareSettlementDifferences,
33329
33704
  requestAggDepositModalOpen,
33330
33705
  requestAggWithdrawModalOpen,
33706
+ resolveDifferenceIconClassName,
33331
33707
  resolveEventDetailsSyncKey,
33332
33708
  resolveOrderBookRows,
33333
33709
  resolveResolvedOutcomeLabel,