@agg-build/ui 2.4.3 → 2.4.5

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.
Files changed (38) hide show
  1. package/dist/{chunk-GLVLCXIM.mjs → chunk-CXSIXL7M.mjs} +29 -35
  2. package/dist/{chunk-PHAEFHBM.mjs → chunk-GWRFSQQK.mjs} +70 -17
  3. package/dist/{chunk-PHRYWSNV.mjs → chunk-I4X5UNCT.mjs} +307 -240
  4. package/dist/{chunk-3PSIO77N.mjs → chunk-JVRTJQPZ.mjs} +1 -1
  5. package/dist/{chunk-QDNG5UKJ.mjs → chunk-P5CVJQPW.mjs} +288 -291
  6. package/dist/{chunk-WZ55ERDO.mjs → chunk-PTNFXXOV.mjs} +50 -11
  7. package/dist/{chunk-STL4ZHLP.mjs → chunk-UH3DUTMG.mjs} +140 -115
  8. package/dist/events.js +440 -305
  9. package/dist/events.mjs +3 -3
  10. package/dist/index.js +840 -666
  11. package/dist/index.mjs +7 -7
  12. package/dist/modals.js +333 -297
  13. package/dist/modals.mjs +3 -3
  14. package/dist/pages.js +558 -381
  15. package/dist/pages.mjs +6 -6
  16. package/dist/primitives.js +50 -11
  17. package/dist/primitives.mjs +1 -1
  18. package/dist/styles.css +1 -1
  19. package/dist/tailwind.css +1 -1
  20. package/dist/trading.js +2597 -2384
  21. package/dist/trading.mjs +4 -4
  22. package/dist/types/events/item-details/event-list-item-details.constants.d.mts +1 -1
  23. package/dist/types/events/item-details/event-list-item-details.constants.d.ts +1 -1
  24. package/dist/types/events/item-details/settlement-summary.d.mts +1 -1
  25. package/dist/types/events/item-details/settlement-summary.d.ts +1 -1
  26. package/dist/types/onboarding/index.d.mts +1 -1
  27. package/dist/types/onboarding/index.d.ts +1 -1
  28. package/dist/types/onboarding/steps/connect-accounts.d.mts +1 -1
  29. package/dist/types/onboarding/steps/connect-accounts.d.ts +1 -1
  30. package/dist/types/primitives/icon/icon.constants.d.mts +1 -0
  31. package/dist/types/primitives/icon/icon.constants.d.ts +1 -0
  32. package/dist/types/shared/use-horizontal-scroll-state.d.mts +3 -0
  33. package/dist/types/shared/use-horizontal-scroll-state.d.ts +3 -0
  34. package/dist/types/trading/place-order/index.place-order.utils.d.mts +1 -0
  35. package/dist/types/trading/place-order/index.place-order.utils.d.ts +1 -0
  36. package/dist/types/trading/settlement/index.d.mts +1 -1
  37. package/dist/types/trading/settlement/index.d.ts +1 -1
  38. package/package.json +2 -2
@@ -10,7 +10,7 @@ import {
10
10
  isErrorWithStatus,
11
11
  useEventListTabs,
12
12
  useEventListTabsHeaderOverflow
13
- } from "./chunk-PHRYWSNV.mjs";
13
+ } from "./chunk-I4X5UNCT.mjs";
14
14
  import {
15
15
  DEPOSIT_MODAL_OPEN_EVENT,
16
16
  PlaceOrder,
@@ -18,10 +18,10 @@ import {
18
18
  WITHDRAW_MODAL_OPEN_EVENT,
19
19
  useClaimWinnings,
20
20
  useResolvedMarketClaim
21
- } from "./chunk-PHAEFHBM.mjs";
21
+ } from "./chunk-GWRFSQQK.mjs";
22
22
  import {
23
23
  getDisplayOutcomePrice
24
- } from "./chunk-STL4ZHLP.mjs";
24
+ } from "./chunk-UH3DUTMG.mjs";
25
25
  import {
26
26
  AggErrorBoundary,
27
27
  Button,
@@ -53,7 +53,7 @@ import {
53
53
  shortenAddress,
54
54
  skeletonViews,
55
55
  sortCategoriesForNavigation
56
- } from "./chunk-WZ55ERDO.mjs";
56
+ } from "./chunk-PTNFXXOV.mjs";
57
57
 
58
58
  // src/pages/home/index.tsx
59
59
  import {
@@ -4137,10 +4137,6 @@ EmptyState.displayName = "EmptyState";
4137
4137
  // src/pages/user-profile/components/position-row.tsx
4138
4138
  import { optimizedImageUrl, useLabels as useLabels7 } from "@agg-build/hooks";
4139
4139
  import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
4140
- var floorToTwoDecimals = (value) => {
4141
- if (!Number.isFinite(value) || value <= 0) return 0;
4142
- return Math.trunc(value * 100) / 100;
4143
- };
4144
4140
  var shouldUseNativeLinkNavigation2 = (event) => {
4145
4141
  return event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button === 1;
4146
4142
  };
@@ -4153,32 +4149,21 @@ var OutcomePill = ({ label }) => /* @__PURE__ */ jsx12("span", { className: "agg
4153
4149
  var ResolutionPill = ({ label }) => /* @__PURE__ */ jsx12("span", { className: "agg-position-resolution-pill inline-flex w-full items-center justify-center overflow-hidden rounded-full bg-agg-secondary-hover px-4 py-[6px] md:w-auto", children: /* @__PURE__ */ jsx12("span", { className: "truncate whitespace-nowrap font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground", children: label }) });
4154
4150
  var VenueShares = ({
4155
4151
  model,
4156
- totalSharesLabel,
4157
4152
  className,
4158
4153
  keyPrefix
4159
4154
  }) => {
4160
- if (!totalSharesLabel && model.venueShareBreakdown.length === 0) return null;
4161
- return /* @__PURE__ */ jsxs11("div", { className: cn(className, "gap-2"), children: [
4162
- model.venueShareBreakdown.length > 0 ? /* @__PURE__ */ jsx12("div", { className: "flex items-center gap-1", children: model.venueShareBreakdown.map((row, index) => /* @__PURE__ */ jsx12(
4163
- Tooltip,
4164
- {
4165
- content: /* @__PURE__ */ jsx12("span", { children: row.sharesLabel }),
4166
- "aria-label": `${row.venue} shares`,
4167
- side: "top",
4168
- children: /* @__PURE__ */ jsx12(
4169
- "span",
4170
- {
4171
- tabIndex: 0,
4172
- className: "cursor-help rounded-agg-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
4173
- "aria-label": `${row.venue} shares`,
4174
- children: /* @__PURE__ */ jsx12(VenueLogo, { venue: row.venue, size: "small", className: "size-4 shrink-0" })
4175
- }
4176
- )
4177
- },
4178
- `${keyPrefix}-${row.venue}-${String(index)}`
4179
- )) }) : null,
4180
- totalSharesLabel ? /* @__PURE__ */ jsx12("span", { className: "whitespace-nowrap font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground", children: totalSharesLabel }) : null
4181
- ] });
4155
+ if (model.venueShareBreakdown.length === 0) return null;
4156
+ return /* @__PURE__ */ jsx12("div", { className: cn(className, "gap-x-3 gap-y-2"), children: model.venueShareBreakdown.map((row, index) => /* @__PURE__ */ jsxs11(
4157
+ "div",
4158
+ {
4159
+ className: "flex min-w-0 max-w-full items-center gap-1",
4160
+ children: [
4161
+ /* @__PURE__ */ jsx12(VenueLogo, { venue: row.venue, size: "small", className: "size-4 shrink-0" }),
4162
+ /* @__PURE__ */ jsx12("span", { className: "truncate whitespace-nowrap font-agg-sans text-agg-sm leading-agg-5 font-agg-normal text-agg-foreground", children: row.sharesLabel })
4163
+ ]
4164
+ },
4165
+ `${keyPrefix}-${row.venue}-${row.sharesLabel}-${String(index)}`
4166
+ )) });
4182
4167
  };
4183
4168
  var StatusBadge = ({
4184
4169
  status,
@@ -4295,7 +4280,6 @@ var PositionRow = ({
4295
4280
  finalPrefix: labels.finalPrefix
4296
4281
  });
4297
4282
  const isClosed = (variant != null ? variant : model.bucket) === "closed";
4298
- const totalSharesLabel = typeof position.totalShares === "number" && Number.isFinite(position.totalShares) ? `${String(floorToTwoDecimals(position.totalShares))} shares` : null;
4299
4283
  const handleClaim = (event) => {
4300
4284
  event.preventDefault();
4301
4285
  event.stopPropagation();
@@ -4356,7 +4340,6 @@ var PositionRow = ({
4356
4340
  VenueShares,
4357
4341
  {
4358
4342
  model,
4359
- totalSharesLabel,
4360
4343
  keyPrefix: "desktop",
4361
4344
  className: "agg-position-venues flex flex-1 flex-wrap content-center items-center gap-x-3 gap-y-2"
4362
4345
  }
@@ -4371,7 +4354,6 @@ var PositionRow = ({
4371
4354
  VenueShares,
4372
4355
  {
4373
4356
  model,
4374
- totalSharesLabel,
4375
4357
  keyPrefix: "mobile",
4376
4358
  className: "agg-position-venues flex min-w-0 flex-1 flex-wrap content-center items-center gap-x-3 gap-y-2 md:hidden"
4377
4359
  }
@@ -5583,7 +5565,19 @@ function buildVenueShareBreakdown(outcome) {
5583
5565
  if (breakdown.length === 0) {
5584
5566
  return [];
5585
5567
  }
5586
- const sorted = [...breakdown].sort(
5568
+ const aggregatedByVenue = breakdown.reduce(
5569
+ (acc, row) => {
5570
+ const existing = acc.get(row.venue);
5571
+ if (existing) {
5572
+ existing.size += row.size;
5573
+ return acc;
5574
+ }
5575
+ acc.set(row.venue, { venue: row.venue, size: row.size });
5576
+ return acc;
5577
+ },
5578
+ /* @__PURE__ */ new Map()
5579
+ );
5580
+ const sorted = [...aggregatedByVenue.values()].sort(
5587
5581
  (a, b) => venueBreakdownSortKey(a.venue) - venueBreakdownSortKey(b.venue)
5588
5582
  );
5589
5583
  return sorted.map((row) => ({
@@ -7,12 +7,13 @@ import {
7
7
  getTradingPriceLabel,
8
8
  getTradingValueLabel,
9
9
  getTradingVenueLabel,
10
+ prepareSettlementDifferences,
10
11
  resolveOrderEligibilityMessage
11
- } from "./chunk-STL4ZHLP.mjs";
12
+ } from "./chunk-UH3DUTMG.mjs";
12
13
  import {
13
14
  GeoBlockBanner,
14
15
  subscribeAggDepositNotification
15
- } from "./chunk-3PSIO77N.mjs";
16
+ } from "./chunk-JVRTJQPZ.mjs";
16
17
  import {
17
18
  AGG_TERMS_OF_SERVICE_URL,
18
19
  Button,
@@ -41,10 +42,11 @@ import {
41
42
  formatSportsEventTimeEt,
42
43
  formatUsd,
43
44
  getMotionClassName,
45
+ normalizeVenueMarketCluster,
44
46
  resolveResolvedOutcomeLabel,
45
47
  skeletonViews,
46
48
  useOptionalToast
47
- } from "./chunk-WZ55ERDO.mjs";
49
+ } from "./chunk-PTNFXXOV.mjs";
48
50
 
49
51
  // src/trading/types.ts
50
52
  import { Venue, enumGuard, isFiniteNonNeg, safeParse } from "@agg-build/sdk";
@@ -53,38 +55,65 @@ var parseVenue = (v) => safeParse(v, isVenue);
53
55
  var parseAmount = (v) => safeParse(v, isFiniteNonNeg);
54
56
 
55
57
  // src/trading/settlement/settlement-details.tsx
56
- import { useEventTradingContext } from "@agg-build/hooks";
58
+ import {
59
+ resolveDefaultTradingMarket,
60
+ useEventTradingContext
61
+ } from "@agg-build/hooks";
57
62
  import { jsx } from "react/jsx-runtime";
58
63
  var hasContent = (value) => {
59
64
  return typeof value === "string" && value.trim().length > 0;
60
65
  };
66
+ var buildVenueSettlementRules = (venueMarkets) => {
67
+ var _a;
68
+ const contentByVenue = /* @__PURE__ */ new Map();
69
+ for (const venueMarket of venueMarkets) {
70
+ const content = [venueMarket.description, venueMarket.rulesPrimary, venueMarket.rulesSecondary].filter(hasContent).map((value) => value.trim());
71
+ if (content.length === 0) continue;
72
+ const venueContent = (_a = contentByVenue.get(venueMarket.venue)) != null ? _a : [];
73
+ for (const value of content) {
74
+ if (!venueContent.includes(value)) venueContent.push(value);
75
+ }
76
+ contentByVenue.set(venueMarket.venue, venueContent);
77
+ }
78
+ return Array.from(contentByVenue, ([venue, content]) => ({
79
+ venue,
80
+ content: content.join("\n\n")
81
+ }));
82
+ };
61
83
  var SettlementDetails = ({ className }) => {
62
- var _a, _b, _c, _d, _e, _f, _g, _h;
84
+ var _a, _b, _c, _d, _e, _f;
63
85
  const tradingContext = useEventTradingContext();
64
86
  const selectedEvent = (_a = tradingContext == null ? void 0 : tradingContext.selectedEvent) != null ? _a : null;
65
87
  const selectedMarket = (_b = tradingContext == null ? void 0 : tradingContext.selectedMarket) != null ? _b : null;
66
88
  if (!selectedEvent) return null;
67
- if (!selectedMarket) return null;
89
+ const activeMarket = selectedMarket != null ? selectedMarket : resolveDefaultTradingMarket(selectedEvent);
90
+ if (!activeMarket) return null;
91
+ const allVenueMarkets = normalizeVenueMarketCluster(selectedEvent.venueMarkets);
92
+ const activeMarketCluster = normalizeVenueMarketCluster(
93
+ selectedEvent.venueMarkets,
94
+ activeMarket.id
95
+ );
96
+ const activeMarketIds = new Set(activeMarketCluster.map((market) => market.id));
97
+ const orderedActiveMarketCluster = allVenueMarkets.filter(
98
+ (market) => activeMarketIds.has(market.id)
99
+ );
68
100
  const eventDescription = (_c = selectedEvent.description) != null ? _c : null;
69
- const marketDescription = (_d = selectedMarket.description) != null ? _d : null;
70
- const primaryRules = (_e = selectedMarket.rulesPrimary) != null ? _e : null;
101
+ const marketDescription = (_d = activeMarket.description) != null ? _d : null;
102
+ const primaryRules = (_e = activeMarket.rulesPrimary) != null ? _e : null;
71
103
  const settlementDiff = (_f = selectedEvent.settlementDiff) != null ? _f : null;
72
104
  const settlementVenues = Array.from(
73
- new Set(selectedEvent.venueMarkets.map((market) => market.venue))
105
+ new Set(orderedActiveMarketCluster.map((market) => market.venue))
74
106
  );
75
- const selectedMarketRuleContent = [
76
- selectedMarket.description,
77
- selectedMarket.rulesPrimary,
78
- selectedMarket.rulesSecondary
79
- ].filter(hasContent).join("\n\n");
80
- const settlementVenueRules = selectedMarketRuleContent ? [{ venue: selectedMarket.venue, content: selectedMarketRuleContent }] : [];
81
- if (!hasContent(eventDescription) && !hasContent(marketDescription) && !hasContent(primaryRules) && ((_g = settlementDiff == null ? void 0 : settlementDiff.differences.length) != null ? _g : 0) === 0) {
107
+ const settlementVenueRules = buildVenueSettlementRules(orderedActiveMarketCluster);
108
+ const hasSettlementDifferences = prepareSettlementDifferences(settlementDiff == null ? void 0 : settlementDiff.differences).length > 0;
109
+ const hasVenueSettlementRules = settlementVenueRules.length > 0;
110
+ if (!hasContent(eventDescription) && !hasVenueSettlementRules && !hasSettlementDifferences) {
82
111
  return null;
83
112
  }
84
113
  return /* @__PURE__ */ jsx("div", { className: "agg-settlement-list flex flex-col gap-6", children: /* @__PURE__ */ jsx("div", { className: "agg-settlement-list-item", children: /* @__PURE__ */ jsx(
85
114
  Settlement,
86
115
  {
87
- question: (_h = selectedMarket.question) != null ? _h : selectedEvent.title,
116
+ question: selectedEvent.title,
88
117
  eventDescription,
89
118
  marketDescription,
90
119
  primaryRules,
@@ -1093,6 +1122,10 @@ var extractGeoBlockedVenues = (warnings) => {
1093
1122
  warnings.filter((w) => w.venue && isGeoBlockWarningReason(w.reason)).map((w) => w.venue)
1094
1123
  );
1095
1124
  };
1125
+ var hasLowLiquidityWarning = (warnings) => {
1126
+ if (!(warnings == null ? void 0 : warnings.length)) return false;
1127
+ return warnings.some((warning) => (warning == null ? void 0 : warning.reason) === "low_liquidity");
1128
+ };
1096
1129
  var getPlaceOrderContainerClassName = () => {
1097
1130
  return PLACE_ORDER_CONTAINER_CLASS_NAME;
1098
1131
  };
@@ -4059,6 +4092,7 @@ var PlaceOrder = ({
4059
4092
  return fills.length > 0 && fills.every((f) => geoBlockedVenuesFromWarnings.has(f.venue));
4060
4093
  }, [selectedRouteCard, geoBlockedVenuesFromWarnings]);
4061
4094
  const shouldShowGeoBlockBanner = isTradingBlocked || selectedRouteGeoBlocked || isPrimaryVenueGeoBlocked;
4095
+ const shouldShowLowLiquidityWarning = !isQuoteInputEditing && !isQuoteLoading && (activeQuoteData == null ? void 0 : activeQuoteData.venueMarketOutcomeId) === scopedSelectedOutcomeId && hasLowLiquidityWarning(activeQuoteData.warnings);
4062
4096
  const actionLabel = `${internalTab === "buy" ? tradingLabels.buy : tradingLabels.sell} ${selectedOutcomeLabel}`.trim();
4063
4097
  const isActionDisabled = isPrimaryActionDisabled || !orderEligibility.canPlaceOrder || isActionLoading || !hasEnteredAmount || !scopedSelectedMarket || isInsufficientBalance || isQuoteInsufficientBalance || isBelowMinimum || isQuoteLoading || !selectedRouteCard || !selectedRouteCard.quoteData.quoteId || selectedRouteGeoBlocked || !isAuthenticated || quoteStatus !== void 0;
4064
4098
  const shouldShowSmartRouting = orderEligibility.canPlaceOrder && hasEnteredAmount && !isBelowMinimum && (orderedRouteCards.length > 0 || smartRoute.isFetching || smartRoute.isLoading);
@@ -4865,6 +4899,25 @@ var PlaceOrder = ({
4865
4899
  children: actionLabel
4866
4900
  }
4867
4901
  ),
4902
+ shouldShowLowLiquidityWarning ? /* @__PURE__ */ jsxs4(
4903
+ "div",
4904
+ {
4905
+ className: "agg-order-low-liquidity-warning flex w-full items-center gap-2 rounded-agg-lg bg-agg-warning/10 px-3 py-2",
4906
+ role: "status",
4907
+ children: [
4908
+ /* @__PURE__ */ jsx5(
4909
+ Icon,
4910
+ {
4911
+ name: "warning-filled",
4912
+ size: "small",
4913
+ className: "h-4! w-4! shrink-0 text-agg-warning",
4914
+ "aria-hidden": "true"
4915
+ }
4916
+ ),
4917
+ /* @__PURE__ */ jsx5("p", { className: "min-w-0 flex-1 wrap-break-word text-agg-sm leading-agg-5 text-agg-foreground", children: tradingLabels.lowLiquidityWarning })
4918
+ ]
4919
+ }
4920
+ ) : null,
4868
4921
  !shouldShowGeoBlockBanner && internalTab === "buy" && showFeesBreakdown ? /* @__PURE__ */ jsxs4("div", { className: "agg-order-platform-fee mt-1 flex items-center justify-center gap-1.5 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: [
4869
4922
  /* @__PURE__ */ jsx5(
4870
4923
  Icon,