@agg-market/ui 0.0.3 → 0.0.4

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 (140) hide show
  1. package/dist/badge.d.mts +2 -2
  2. package/dist/badge.d.ts +2 -2
  3. package/dist/badge.mjs +2 -2
  4. package/dist/button.d.mts +2 -2
  5. package/dist/button.d.ts +2 -2
  6. package/dist/button.js +1 -0
  7. package/dist/button.mjs +3 -3
  8. package/dist/card.mjs +2 -2
  9. package/dist/chart.mjs +3 -3
  10. package/dist/{chunk-YUIZZ6XE.mjs → chunk-3O4U3E5I.mjs} +1 -1
  11. package/dist/{chunk-JLLMIPIX.mjs → chunk-4VUDTWH7.mjs} +1 -1
  12. package/dist/{chunk-MG243DSX.mjs → chunk-AEMAY3MR.mjs} +1 -1
  13. package/dist/{chunk-FYV3MDIL.mjs → chunk-BJNHDIDW.mjs} +4 -4
  14. package/dist/{chunk-LY6474C4.mjs → chunk-BLSHXIAH.mjs} +36 -71
  15. package/dist/{chunk-DQ6XFBYJ.mjs → chunk-DYEWXEEY.mjs} +1 -1
  16. package/dist/{chunk-OUOIDPGX.mjs → chunk-EXF4SESB.mjs} +1 -1
  17. package/dist/chunk-F236MLT6.mjs +1337 -0
  18. package/dist/{chunk-PAQ542ER.mjs → chunk-GHB3GOCW.mjs} +4 -2
  19. package/dist/{chunk-GC3QIIH7.mjs → chunk-GJ4U5NCE.mjs} +23 -1
  20. package/dist/chunk-HM3CGN32.mjs +669 -0
  21. package/dist/chunk-I4YUYVJJ.mjs +472 -0
  22. package/dist/{chunk-NFYS557L.mjs → chunk-JH5VMNDL.mjs} +3 -3
  23. package/dist/{chunk-TTOR7JCT.mjs → chunk-JRS2M5GY.mjs} +1 -1
  24. package/dist/{chunk-QXFDXXDB.mjs → chunk-LWTQD345.mjs} +3 -3
  25. package/dist/{chunk-QE46DVJG.mjs → chunk-MNSHWA6M.mjs} +3 -3
  26. package/dist/{chunk-JQ4FUHXE.mjs → chunk-MXBPDNMC.mjs} +7 -7
  27. package/dist/{chunk-VYNVBJK6.mjs → chunk-NDG43KGL.mjs} +1 -1
  28. package/dist/chunk-O2XH4A3G.mjs +654 -0
  29. package/dist/{chunk-KDBYDMYV.mjs → chunk-OBCHURW5.mjs} +1 -1
  30. package/dist/{chunk-FZTAHWOS.mjs → chunk-OGI343OV.mjs} +2 -2
  31. package/dist/{chunk-XDAEEJYR.mjs → chunk-P23GR7NX.mjs} +2 -2
  32. package/dist/{chunk-J6L5BLKX.mjs → chunk-PGSPYQOW.mjs} +2 -2
  33. package/dist/{chunk-J7OETCZ7.mjs → chunk-QFQHD2V6.mjs} +19 -20
  34. package/dist/chunk-RGZQHSNJ.mjs +845 -0
  35. package/dist/{chunk-7XRKA6XF.mjs → chunk-RXACBTON.mjs} +5 -5
  36. package/dist/{chunk-A4QJAOZW.mjs → chunk-USLTNDJA.mjs} +7 -7
  37. package/dist/{chunk-FACIYUNK.mjs → chunk-VC7LTPQD.mjs} +2 -2
  38. package/dist/{chunk-CKTAVEW2.mjs → chunk-VIP7HSOU.mjs} +2 -2
  39. package/dist/{chunk-5MN6ZNFA.mjs → chunk-VUDJ3PYM.mjs} +9 -9
  40. package/dist/{chunk-2NCBX6XI.mjs → chunk-W2DMBW4E.mjs} +8 -8
  41. package/dist/{chunk-764YUN2J.mjs → chunk-XELWY7SO.mjs} +150 -49
  42. package/dist/chunk-ZDF7QP4G.mjs +160 -0
  43. package/dist/{chunk-4NK2FNAG.mjs → chunk-ZHKMDK5M.mjs} +244 -112
  44. package/dist/{chunk-C4OI72SM.mjs → chunk-ZVBVGWSP.mjs} +1 -0
  45. package/dist/chunk-ZYREURXK.mjs +470 -0
  46. package/dist/connect-button.js +767 -292
  47. package/dist/connect-button.mjs +8 -8
  48. package/dist/deposit-modal.d.mts +34 -0
  49. package/dist/deposit-modal.d.ts +34 -0
  50. package/dist/deposit-modal.js +2787 -0
  51. package/dist/deposit-modal.mjs +15 -0
  52. package/dist/event-list-item-details.js +271 -173
  53. package/dist/event-list-item-details.mjs +13 -13
  54. package/dist/event-list-item.js +903 -426
  55. package/dist/event-list-item.mjs +11 -11
  56. package/dist/event-list.js +1104 -517
  57. package/dist/event-list.mjs +14 -14
  58. package/dist/event-market-page.d.mts +1 -1
  59. package/dist/event-market-page.d.ts +1 -1
  60. package/dist/event-market-page.js +1505 -681
  61. package/dist/event-market-page.mjs +23 -23
  62. package/dist/hello-world.mjs +3 -3
  63. package/dist/home-page.d.mts +1 -1
  64. package/dist/home-page.d.ts +1 -1
  65. package/dist/home-page.js +1120 -533
  66. package/dist/home-page.mjs +15 -15
  67. package/dist/icon.d.mts +74 -4
  68. package/dist/icon.d.ts +74 -4
  69. package/dist/icon.js +668 -123
  70. package/dist/icon.mjs +32 -4
  71. package/dist/index.d.mts +15 -7
  72. package/dist/index.d.ts +15 -7
  73. package/dist/index.js +5301 -2147
  74. package/dist/index.mjs +80 -32
  75. package/dist/loading-icon.d.mts +1 -1
  76. package/dist/loading-icon.d.ts +1 -1
  77. package/dist/loading-icon.js +1 -0
  78. package/dist/loading-icon.mjs +3 -3
  79. package/dist/market-details.d.mts +2 -2
  80. package/dist/market-details.d.ts +2 -2
  81. package/dist/market-details.js +1097 -411
  82. package/dist/market-details.mjs +16 -16
  83. package/dist/modal.mjs +3 -3
  84. package/dist/number-value.mjs +2 -2
  85. package/dist/onboarding-modal.js +1249 -672
  86. package/dist/onboarding-modal.mjs +8 -8
  87. package/dist/place-order.d.mts +1 -1
  88. package/dist/place-order.d.ts +1 -1
  89. package/dist/place-order.js +1091 -506
  90. package/dist/place-order.mjs +12 -12
  91. package/dist/profile-modal.d.mts +66 -0
  92. package/dist/profile-modal.d.ts +66 -0
  93. package/dist/profile-modal.js +2429 -0
  94. package/dist/profile-modal.mjs +14 -0
  95. package/dist/{registry-CVn79H3I.d.mts → registry-DfSCFAdC.d.mts} +72 -0
  96. package/dist/{registry-CVn79H3I.d.ts → registry-DfSCFAdC.d.ts} +72 -0
  97. package/dist/search.d.mts +2 -2
  98. package/dist/search.d.ts +2 -2
  99. package/dist/search.js +740 -265
  100. package/dist/search.mjs +6 -6
  101. package/dist/select.d.mts +2 -0
  102. package/dist/select.d.ts +2 -0
  103. package/dist/select.js +814 -187
  104. package/dist/select.mjs +5 -5
  105. package/dist/settlement.d.mts +1 -1
  106. package/dist/settlement.d.ts +1 -1
  107. package/dist/settlement.js +891 -417
  108. package/dist/settlement.mjs +9 -9
  109. package/dist/skeleton.js +1 -1
  110. package/dist/skeleton.mjs +3 -3
  111. package/dist/styles.css +1 -1
  112. package/dist/switch-button.mjs +2 -2
  113. package/dist/tabs.js +854 -227
  114. package/dist/tabs.mjs +6 -6
  115. package/dist/tailwind.css +1 -1
  116. package/dist/types-Bed6Q0EK.d.mts +3 -0
  117. package/dist/types-Bed6Q0EK.d.ts +3 -0
  118. package/dist/typography.mjs +2 -2
  119. package/dist/user-profile-page.d.mts +133 -0
  120. package/dist/user-profile-page.d.ts +133 -0
  121. package/dist/user-profile-page.js +3335 -0
  122. package/dist/user-profile-page.mjs +15 -0
  123. package/dist/venue-logo.d.mts +2 -2
  124. package/dist/venue-logo.d.ts +2 -2
  125. package/dist/venue-logo.js +28 -70
  126. package/dist/venue-logo.mjs +2 -2
  127. package/dist/{venue-logo.types-Bg8eXtGp.d.ts → venue-logo.types-BSAuY84j.d.ts} +1 -1
  128. package/dist/{venue-logo.types-B1iPJgiD.d.mts → venue-logo.types-DACqcTvY.d.mts} +1 -1
  129. package/dist/withdraw-modal.d.mts +36 -0
  130. package/dist/withdraw-modal.d.ts +36 -0
  131. package/dist/withdraw-modal.js +2442 -0
  132. package/dist/withdraw-modal.mjs +14 -0
  133. package/package.json +43 -3
  134. package/dist/chunk-DA6KZWSK.mjs +0 -807
  135. package/dist/chunk-IY2AA3OL.mjs +0 -50
  136. package/dist/chunk-R3DRVI4J.mjs +0 -741
  137. package/dist/types-CayJ8tWA.d.mts +0 -3
  138. package/dist/types-CayJ8tWA.d.ts +0 -3
  139. package/dist/{types-C5JigCSX.d.mts → types-DkGlbmXq.d.mts} +2 -2
  140. package/dist/{types-C5JigCSX.d.ts → types-DkGlbmXq.d.ts} +2 -2
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  LoadingIcon
3
- } from "./chunk-FZTAHWOS.mjs";
3
+ } from "./chunk-OGI343OV.mjs";
4
4
  import {
5
5
  VenueLogo
6
- } from "./chunk-LY6474C4.mjs";
6
+ } from "./chunk-BLSHXIAH.mjs";
7
7
  import {
8
8
  Icon
9
- } from "./chunk-DA6KZWSK.mjs";
9
+ } from "./chunk-F236MLT6.mjs";
10
10
  import {
11
11
  Button
12
- } from "./chunk-J6L5BLKX.mjs";
12
+ } from "./chunk-PGSPYQOW.mjs";
13
13
  import {
14
14
  AGG_ROOT_CLASS_NAME,
15
15
  __spreadProps,
@@ -18,7 +18,7 @@ import {
18
18
  formatUsd,
19
19
  getMotionClassName,
20
20
  shortenAddress
21
- } from "./chunk-GC3QIIH7.mjs";
21
+ } from "./chunk-GJ4U5NCE.mjs";
22
22
 
23
23
  // src/auth/connect-button/index.tsx
24
24
  import { useEffect, useMemo, useRef, useState } from "react";
@@ -1,26 +1,26 @@
1
1
  import {
2
2
  Settlement
3
- } from "./chunk-J7OETCZ7.mjs";
3
+ } from "./chunk-QFQHD2V6.mjs";
4
4
  import {
5
5
  PlaceOrder
6
- } from "./chunk-5MN6ZNFA.mjs";
6
+ } from "./chunk-VUDJ3PYM.mjs";
7
7
  import {
8
8
  EventListItemDetails
9
- } from "./chunk-4NK2FNAG.mjs";
9
+ } from "./chunk-ZHKMDK5M.mjs";
10
10
  import {
11
11
  MarketDetails
12
- } from "./chunk-764YUN2J.mjs";
12
+ } from "./chunk-XELWY7SO.mjs";
13
13
  import {
14
14
  Typography
15
- } from "./chunk-DQ6XFBYJ.mjs";
15
+ } from "./chunk-DYEWXEEY.mjs";
16
16
  import {
17
17
  Card
18
- } from "./chunk-YUIZZ6XE.mjs";
18
+ } from "./chunk-3O4U3E5I.mjs";
19
19
  import {
20
20
  __spreadProps,
21
21
  __spreadValues,
22
22
  cn
23
- } from "./chunk-GC3QIIH7.mjs";
23
+ } from "./chunk-GJ4U5NCE.mjs";
24
24
 
25
25
  // src/pages/event-market/index.tsx
26
26
  import { useEffect, useMemo, useState } from "react";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  SwitchButton
3
- } from "./chunk-TTOR7JCT.mjs";
3
+ } from "./chunk-JRS2M5GY.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues,
7
7
  cn
8
- } from "./chunk-GC3QIIH7.mjs";
8
+ } from "./chunk-GJ4U5NCE.mjs";
9
9
 
10
10
  // src/primitives/chart/index.tsx
11
11
  import dayjs from "dayjs";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  CloseIcon
3
- } from "./chunk-VYNVBJK6.mjs";
3
+ } from "./chunk-NDG43KGL.mjs";
4
4
  import {
5
5
  AGG_ROOT_CLASS_NAME,
6
6
  cn,
7
7
  getMotionClassName
8
- } from "./chunk-GC3QIIH7.mjs";
8
+ } from "./chunk-GJ4U5NCE.mjs";
9
9
 
10
10
  // src/primitives/modal/index.tsx
11
11
  import * as Dialog from "@radix-ui/react-dialog";
@@ -2,30 +2,30 @@ import {
2
2
  defaultTradingDisclaimer,
3
3
  getTradingDateLabel,
4
4
  getTradingVenueLabel
5
- } from "./chunk-KDBYDMYV.mjs";
5
+ } from "./chunk-OBCHURW5.mjs";
6
6
  import {
7
7
  Tabs
8
- } from "./chunk-QXFDXXDB.mjs";
8
+ } from "./chunk-LWTQD345.mjs";
9
9
  import {
10
10
  Skeleton,
11
11
  skeletonViews
12
- } from "./chunk-NFYS557L.mjs";
12
+ } from "./chunk-JH5VMNDL.mjs";
13
13
  import {
14
14
  VenueLogo
15
- } from "./chunk-LY6474C4.mjs";
15
+ } from "./chunk-BLSHXIAH.mjs";
16
16
  import {
17
17
  Icon
18
- } from "./chunk-DA6KZWSK.mjs";
18
+ } from "./chunk-F236MLT6.mjs";
19
19
  import {
20
20
  Button
21
- } from "./chunk-J6L5BLKX.mjs";
21
+ } from "./chunk-PGSPYQOW.mjs";
22
22
  import {
23
23
  Card
24
- } from "./chunk-YUIZZ6XE.mjs";
24
+ } from "./chunk-3O4U3E5I.mjs";
25
25
  import {
26
26
  cn,
27
27
  getMotionClassName
28
- } from "./chunk-GC3QIIH7.mjs";
28
+ } from "./chunk-GJ4U5NCE.mjs";
29
29
 
30
30
  // src/trading/place-order/index.tsx
31
31
  import { useEffect, useMemo, useState } from "react";
@@ -277,7 +277,7 @@ var PlaceOrder = ({
277
277
  "div",
278
278
  {
279
279
  className: cn(
280
- "pointer-events-none absolute inset-x-0 bottom-0 h-11 bg-gradient-to-b from-transparent to-agg-trade-highlight-glow",
280
+ "pointer-events-none absolute inset-x-0 bottom-0 h-11 bg-linear-to-b from-transparent to-agg-trade-highlight-glow",
281
281
  hasHighlightedRouting ? "opacity-100" : "opacity-0"
282
282
  )
283
283
  }
@@ -9,31 +9,31 @@ import {
9
9
  resolveVenueLabel,
10
10
  resolveVisibleOutcomes,
11
11
  selectPrimaryVenueMarket
12
- } from "./chunk-PAQ542ER.mjs";
12
+ } from "./chunk-GHB3GOCW.mjs";
13
13
  import {
14
14
  Badge
15
- } from "./chunk-MG243DSX.mjs";
15
+ } from "./chunk-AEMAY3MR.mjs";
16
16
  import {
17
17
  Skeleton,
18
18
  baseCardClassName
19
- } from "./chunk-NFYS557L.mjs";
19
+ } from "./chunk-JH5VMNDL.mjs";
20
20
  import {
21
21
  VenueLogo
22
- } from "./chunk-LY6474C4.mjs";
22
+ } from "./chunk-BLSHXIAH.mjs";
23
23
  import {
24
24
  Icon
25
- } from "./chunk-DA6KZWSK.mjs";
25
+ } from "./chunk-F236MLT6.mjs";
26
26
  import {
27
27
  Typography
28
- } from "./chunk-DQ6XFBYJ.mjs";
28
+ } from "./chunk-DYEWXEEY.mjs";
29
29
  import {
30
30
  Card
31
- } from "./chunk-YUIZZ6XE.mjs";
31
+ } from "./chunk-3O4U3E5I.mjs";
32
32
  import {
33
33
  __objRest,
34
34
  __spreadValues,
35
35
  cn
36
- } from "./chunk-GC3QIIH7.mjs";
36
+ } from "./chunk-GJ4U5NCE.mjs";
37
37
 
38
38
  // src/events/item/index.tsx
39
39
  import dayjs from "dayjs";
@@ -4,17 +4,17 @@ import {
4
4
  resolveOutcomeLabels,
5
5
  resolveOutcomesByVenue,
6
6
  resolveSeriesColor
7
- } from "./chunk-XDAEEJYR.mjs";
7
+ } from "./chunk-P23GR7NX.mjs";
8
8
  import {
9
9
  Tabs
10
- } from "./chunk-QXFDXXDB.mjs";
10
+ } from "./chunk-LWTQD345.mjs";
11
11
  import {
12
12
  getVenueSummary,
13
13
  normalizeProbability,
14
14
  resolveTileImage,
15
15
  resolveTileTitle,
16
16
  selectPrimaryVenueMarket
17
- } from "./chunk-PAQ542ER.mjs";
17
+ } from "./chunk-GHB3GOCW.mjs";
18
18
  import {
19
19
  Skeleton,
20
20
  eventListItemDetailsTimeRanges,
@@ -22,31 +22,31 @@ import {
22
22
  marketDetailsBaseCardClassName,
23
23
  marketDetailsDefaultIsOpened,
24
24
  orderBookRowLimitDefault
25
- } from "./chunk-NFYS557L.mjs";
25
+ } from "./chunk-JH5VMNDL.mjs";
26
26
  import {
27
27
  LoadingIcon
28
- } from "./chunk-FZTAHWOS.mjs";
28
+ } from "./chunk-OGI343OV.mjs";
29
29
  import {
30
30
  VenueLogo
31
- } from "./chunk-LY6474C4.mjs";
31
+ } from "./chunk-BLSHXIAH.mjs";
32
32
  import {
33
33
  Typography
34
- } from "./chunk-DQ6XFBYJ.mjs";
34
+ } from "./chunk-DYEWXEEY.mjs";
35
35
  import {
36
36
  Card
37
- } from "./chunk-YUIZZ6XE.mjs";
37
+ } from "./chunk-3O4U3E5I.mjs";
38
38
  import {
39
39
  LineChart
40
- } from "./chunk-FACIYUNK.mjs";
40
+ } from "./chunk-VC7LTPQD.mjs";
41
41
  import {
42
42
  SwitchButton
43
- } from "./chunk-TTOR7JCT.mjs";
43
+ } from "./chunk-JRS2M5GY.mjs";
44
44
  import {
45
45
  __spreadProps,
46
46
  __spreadValues,
47
47
  cn,
48
48
  getMotionClassName
49
- } from "./chunk-GC3QIIH7.mjs";
49
+ } from "./chunk-GJ4U5NCE.mjs";
50
50
 
51
51
  // src/events/market-details/index.tsx
52
52
  import { useEffect, useId, useMemo, useState } from "react";
@@ -190,22 +190,24 @@ var resolveOrderBookRows = ({
190
190
  const tone = side === "asks" ? "negative" : "positive";
191
191
  const rows = data.flatMap((result) => {
192
192
  var _a;
193
- return ((_a = result.orderbook[side]) != null ? _a : []).flatMap((level, index) => {
194
- const parsedLevel = OrderBookLevelSchema.safeParse(level);
195
- if (!parsedLevel.success)
196
- return [];
197
- const parsedRow = OrderBookRowSchema.safeParse({
198
- id: `${result.market.id}-${side}-${index}-${parsedLevel.data.price}`,
199
- venue: result.market.venue,
200
- price: parsedLevel.data.price,
201
- size: parsedLevel.data.size,
202
- total: parsedLevel.data.price * parsedLevel.data.size,
203
- tone
204
- });
205
- if (!parsedRow.success)
206
- return [];
207
- return [parsedRow.data];
208
- });
193
+ return ((_a = result.orderbook[side]) != null ? _a : []).flatMap(
194
+ (level, index) => {
195
+ const parsedLevel = OrderBookLevelSchema.safeParse(level);
196
+ if (!parsedLevel.success)
197
+ return [];
198
+ const parsedRow = OrderBookRowSchema.safeParse({
199
+ id: `${result.market.id}-${side}-${index}-${parsedLevel.data.price}`,
200
+ venue: result.market.venue,
201
+ price: parsedLevel.data.price,
202
+ size: parsedLevel.data.size,
203
+ total: parsedLevel.data.price * parsedLevel.data.size,
204
+ tone
205
+ });
206
+ if (!parsedRow.success)
207
+ return [];
208
+ return [parsedRow.data];
209
+ }
210
+ );
209
211
  });
210
212
  const sortedRows = [...rows].sort((left, right) => {
211
213
  if (side === "asks")
@@ -427,6 +429,7 @@ var MarketDetailsContent = ({
427
429
  return resolveInitialOutcomeLabel((_a = model == null ? void 0 : model.outcomeLabels) != null ? _a : [], defaultOutcomeLabel);
428
430
  }
429
431
  );
432
+ const [selectedGraphVenue, setSelectedGraphVenue] = useState(null);
430
433
  useEffect(() => {
431
434
  var _a;
432
435
  setSelectedOutcomeLabel(
@@ -443,17 +446,43 @@ var MarketDetailsContent = ({
443
446
  return void 0;
444
447
  return model.probabilityByLabel.get(selectedOutcomeLabel);
445
448
  }, [model, selectedOutcomeLabel]);
449
+ const outcomesByLabel = useMemo(() => {
450
+ const outcomesByLabelMap = /* @__PURE__ */ new Map();
451
+ if (!model) {
452
+ return outcomesByLabelMap;
453
+ }
454
+ headerOutcomeItems.forEach((headerOutcomeItem) => {
455
+ outcomesByLabelMap.set(
456
+ headerOutcomeItem.label,
457
+ resolveOutcomesByVenue(model.market.venueMarkets, headerOutcomeItem.label)
458
+ );
459
+ });
460
+ return outcomesByLabelMap;
461
+ }, [headerOutcomeItems, model]);
446
462
  const selectedOutcomesByVenue = useMemo(() => {
447
- if (!model || !selectedOutcomeLabel)
463
+ var _a;
464
+ if (!selectedOutcomeLabel)
448
465
  return [];
449
- return resolveOutcomesByVenue(model.market.venueMarkets, selectedOutcomeLabel);
450
- }, [model, selectedOutcomeLabel]);
466
+ return (_a = outcomesByLabel.get(selectedOutcomeLabel)) != null ? _a : [];
467
+ }, [outcomesByLabel, selectedOutcomeLabel]);
451
468
  const timeWindow = useMemo(() => {
452
469
  return getTimeWindowByRange(selectedTimeRange);
453
470
  }, [selectedTimeRange]);
471
+ const graphOutcomes = useMemo(() => {
472
+ const uniqueOutcomesByVenueAndId = /* @__PURE__ */ new Map();
473
+ outcomesByLabel.forEach((outcomes) => {
474
+ outcomes.forEach((outcomeByVenue) => {
475
+ uniqueOutcomesByVenueAndId.set(
476
+ `${outcomeByVenue.venue}:${outcomeByVenue.outcome.id}`,
477
+ outcomeByVenue
478
+ );
479
+ });
480
+ });
481
+ return [...uniqueOutcomesByVenueAndId.values()];
482
+ }, [outcomesByLabel]);
454
483
  const priceHistoryGroups = useMemo(() => {
455
- return buildPriceHistoryGroups(selectedOutcomesByVenue);
456
- }, [selectedOutcomesByVenue]);
484
+ return buildPriceHistoryGroups(graphOutcomes);
485
+ }, [graphOutcomes]);
457
486
  const { data: priceHistoryData, isLoading: isPriceHistoryLoading } = usePriceHistory(__spreadProps(__spreadValues({
458
487
  groups: priceHistoryGroups
459
488
  }, timeWindow), {
@@ -484,24 +513,71 @@ var MarketDetailsContent = ({
484
513
  depth: orderBookDepth
485
514
  });
486
515
  }, [orderBookData, orderBookDepth]);
487
- const graphSeries = useMemo(() => {
488
- if (!(priceHistoryData == null ? void 0 : priceHistoryData.length))
489
- return [];
490
- return priceHistoryData.map((history, index) => {
516
+ const priceHistoryByVenue = useMemo(() => {
517
+ const historyByVenue = /* @__PURE__ */ new Map();
518
+ if (!(priceHistoryData == null ? void 0 : priceHistoryData.length)) {
519
+ return historyByVenue;
520
+ }
521
+ priceHistoryData.forEach((historyItem) => {
522
+ const venue = historyItem.venue;
523
+ const venueHistory = historyByVenue.get(venue);
524
+ if (venueHistory) {
525
+ venueHistory.push(historyItem);
526
+ return;
527
+ }
528
+ historyByVenue.set(venue, [historyItem]);
529
+ });
530
+ return historyByVenue;
531
+ }, [priceHistoryData]);
532
+ const graphSeriesByOutcomeLabel = useMemo(() => {
533
+ const seriesByOutcomeLabel = /* @__PURE__ */ new Map();
534
+ const resolveOutcomeCandidateIds = (outcomeByVenue) => {
491
535
  var _a;
492
- const matchingOutcome = selectedOutcomesByVenue.find((item) => {
493
- return item.outcome.id === history.marketId || item.outcome.externalIdentifier === history.marketId || item.market.externalIdentifier === history.marketId;
494
- });
495
- return {
496
- id: `${history.venue}-${history.marketId}-${index}`,
497
- color: resolveSeriesColor((_a = matchingOutcome == null ? void 0 : matchingOutcome.venue) != null ? _a : history.venue, index),
498
- points: history.points.map((point) => ({
536
+ return [
537
+ outcomeByVenue.outcome.id,
538
+ (_a = outcomeByVenue.outcome.externalIdentifier) != null ? _a : void 0,
539
+ outcomeByVenue.market.externalIdentifier
540
+ ].filter((value) => typeof value === "string" && value.trim().length > 0);
541
+ };
542
+ headerOutcomeItems.forEach((headerOutcomeItem) => {
543
+ var _a;
544
+ const outcomes = (_a = outcomesByLabel.get(headerOutcomeItem.label)) != null ? _a : [];
545
+ const graphSeries2 = [];
546
+ outcomes.forEach((outcomeByVenue, index) => {
547
+ var _a2;
548
+ const venueHistory = priceHistoryByVenue.get(outcomeByVenue.venue);
549
+ if (!(venueHistory == null ? void 0 : venueHistory.length))
550
+ return;
551
+ const candidateIds = resolveOutcomeCandidateIds(outcomeByVenue);
552
+ const matchingHistory = (_a2 = venueHistory.find((historyItem) => candidateIds.includes(historyItem.marketId))) != null ? _a2 : venueHistory.length === 1 ? venueHistory[0] : void 0;
553
+ if (!matchingHistory)
554
+ return;
555
+ const points = matchingHistory.points.map((point) => ({
499
556
  time: point.timestamp,
500
557
  value: point.price * 100
501
- }))
502
- };
503
- }).filter((seriesItem) => seriesItem.points.length > 0);
504
- }, [priceHistoryData, selectedOutcomesByVenue]);
558
+ })).filter((point) => Number.isFinite(point.time) && Number.isFinite(point.value));
559
+ if (points.length === 0)
560
+ return;
561
+ graphSeries2.push({
562
+ id: `${headerOutcomeItem.label}-${outcomeByVenue.venue}-${matchingHistory.marketId}`,
563
+ venue: outcomeByVenue.venue,
564
+ color: resolveSeriesColor(outcomeByVenue.venue, index),
565
+ points
566
+ });
567
+ });
568
+ seriesByOutcomeLabel.set(headerOutcomeItem.label, graphSeries2);
569
+ });
570
+ return seriesByOutcomeLabel;
571
+ }, [headerOutcomeItems, outcomesByLabel, priceHistoryByVenue]);
572
+ const graphSeries = useMemo(() => {
573
+ var _a;
574
+ if (!selectedOutcomeLabel)
575
+ return [];
576
+ const seriesForOutcomeLabel = (_a = graphSeriesByOutcomeLabel.get(selectedOutcomeLabel)) != null ? _a : [];
577
+ if (!selectedGraphVenue)
578
+ return seriesForOutcomeLabel;
579
+ return seriesForOutcomeLabel.filter((seriesItem) => seriesItem.venue === selectedGraphVenue);
580
+ }, [graphSeriesByOutcomeLabel, selectedGraphVenue, selectedOutcomeLabel]);
505
581
  const otherRows = useMemo(() => {
506
582
  if (!model)
507
583
  return [];
@@ -525,6 +601,22 @@ var MarketDetailsContent = ({
525
601
  setIsOpened((prev) => !prev);
526
602
  onOpenChange == null ? void 0 : onOpenChange(!isOpened);
527
603
  };
604
+ const handleGraphVenueToggle = (venue) => {
605
+ setSelectedGraphVenue((currentVenue) => {
606
+ if (currentVenue === venue)
607
+ return null;
608
+ return venue;
609
+ });
610
+ };
611
+ useEffect(() => {
612
+ if (!selectedGraphVenue) {
613
+ return;
614
+ }
615
+ if (selectedOutcomesByVenue.some((item) => item.venue === selectedGraphVenue)) {
616
+ return;
617
+ }
618
+ setSelectedGraphVenue(null);
619
+ }, [selectedGraphVenue, selectedOutcomesByVenue]);
528
620
  if (!model) {
529
621
  return /* @__PURE__ */ jsx(MarketDetailsUnavailableState, { ariaLabel, classNames });
530
622
  }
@@ -700,10 +792,19 @@ var MarketDetailsContent = ({
700
792
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 md:flex-row md:items-center md:justify-between", children: [
701
793
  /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: selectedOutcomesByVenue.map((item) => {
702
794
  const probability = formatProbabilityPercent(item.outcome.price);
795
+ const isActiveVenue = selectedGraphVenue === item.venue;
703
796
  return /* @__PURE__ */ jsxs(
704
- "div",
797
+ "button",
705
798
  {
706
- className: "inline-flex items-center gap-2 rounded-agg-full bg-agg-secondary-hover px-4 py-2",
799
+ type: "button",
800
+ "aria-label": `${item.venue} ${probability}`,
801
+ "aria-pressed": isActiveVenue,
802
+ className: cn(
803
+ "inline-flex items-center gap-2 rounded-agg-full border-2 px-4 py-2",
804
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-2 focus-visible:ring-offset-agg-secondary-hover",
805
+ isActiveVenue ? "border-agg-primary bg-agg-secondary" : "border-transparent bg-agg-secondary-hover"
806
+ ),
807
+ onClick: () => handleGraphVenueToggle(item.venue),
707
808
  children: [
708
809
  /* @__PURE__ */ jsx(VenueLogo, { venue: item.venue, size: "xs" }),
709
810
  /* @__PURE__ */ jsx("span", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: probability })
@@ -0,0 +1,160 @@
1
+ import {
2
+ Icon
3
+ } from "./chunk-F236MLT6.mjs";
4
+ import {
5
+ cn,
6
+ getMotionClassName
7
+ } from "./chunk-GJ4U5NCE.mjs";
8
+
9
+ // src/primitives/select/index.tsx
10
+ import { useCallback, useEffect, useRef, useState } from "react";
11
+ import { useLabels, useSdkUiConfig } from "@agg-market/hooks";
12
+ import { jsx, jsxs } from "react/jsx-runtime";
13
+ var Select = ({
14
+ items,
15
+ value,
16
+ onChange,
17
+ ariaLabel,
18
+ className,
19
+ disabled = false
20
+ }) => {
21
+ var _a;
22
+ const labels = useLabels();
23
+ const { enableAnimations } = useSdkUiConfig();
24
+ const hasEnabledItems = items.some((item) => !item.disabled);
25
+ const hasAnyIcon = items.some((item) => item.iconUrl);
26
+ const [isOpen, setIsOpen] = useState(false);
27
+ const containerRef = useRef(null);
28
+ const close = useCallback(() => setIsOpen(false), []);
29
+ useEffect(() => {
30
+ if (!isOpen)
31
+ return;
32
+ const handlePointerDown = (e) => {
33
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
34
+ close();
35
+ }
36
+ };
37
+ document.addEventListener("mousedown", handlePointerDown);
38
+ return () => document.removeEventListener("mousedown", handlePointerDown);
39
+ }, [isOpen, close]);
40
+ useEffect(() => {
41
+ if (!isOpen)
42
+ return;
43
+ const handleKey = (e) => {
44
+ if (e.key === "Escape")
45
+ close();
46
+ };
47
+ document.addEventListener("keydown", handleKey);
48
+ return () => document.removeEventListener("keydown", handleKey);
49
+ }, [isOpen, close]);
50
+ const isDisabled = disabled || !hasEnabledItems;
51
+ const selectedItem = items.find((item) => item.value === value);
52
+ if (!hasAnyIcon) {
53
+ return /* @__PURE__ */ jsxs("label", { className: cn("relative inline-flex w-full", className), children: [
54
+ /* @__PURE__ */ jsx(
55
+ "select",
56
+ {
57
+ "aria-label": ariaLabel != null ? ariaLabel : labels.common.selectAria,
58
+ className: cn(
59
+ "w-full appearance-none rounded-agg-md border border-agg-separator bg-agg-secondary px-4 py-2 pr-10 font-agg-sans text-agg-sm leading-agg-5 text-agg-foreground outline-none",
60
+ getMotionClassName(
61
+ enableAnimations,
62
+ "transition-[border-color,box-shadow] duration-200 ease-out"
63
+ ),
64
+ "focus:border-agg-primary focus:ring-2 focus:ring-agg-primary/15",
65
+ "disabled:cursor-not-allowed disabled:opacity-60"
66
+ ),
67
+ disabled: isDisabled,
68
+ value,
69
+ onChange: (event) => onChange(event.target.value),
70
+ children: items.map((item) => /* @__PURE__ */ jsx("option", { value: item.value, disabled: item.disabled, children: item.label }, item.value))
71
+ }
72
+ ),
73
+ /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute inset-y-0 right-3 inline-flex items-center justify-center text-agg-muted-foreground", children: /* @__PURE__ */ jsx(Icon, { name: "chevron-down", size: "s", color: "currentColor" }) })
74
+ ] });
75
+ }
76
+ return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: cn("relative inline-flex w-full", className), children: [
77
+ /* @__PURE__ */ jsxs(
78
+ "button",
79
+ {
80
+ type: "button",
81
+ "aria-label": ariaLabel != null ? ariaLabel : labels.common.selectAria,
82
+ "aria-expanded": isOpen,
83
+ "aria-haspopup": "listbox",
84
+ disabled: isDisabled,
85
+ className: cn(
86
+ "w-full rounded-agg-md border border-agg-separator bg-agg-secondary px-4 py-2 pr-10 font-agg-sans text-agg-sm leading-agg-5 text-agg-foreground outline-none",
87
+ "flex items-center gap-2 text-left",
88
+ getMotionClassName(
89
+ enableAnimations,
90
+ "transition-[border-color,box-shadow] duration-200 ease-out"
91
+ ),
92
+ "focus:border-agg-primary focus:ring-2 focus:ring-agg-primary/15",
93
+ "disabled:cursor-not-allowed disabled:opacity-60"
94
+ ),
95
+ onClick: () => setIsOpen((prev) => !prev),
96
+ children: [
97
+ (selectedItem == null ? void 0 : selectedItem.iconUrl) ? /* @__PURE__ */ jsx(
98
+ "img",
99
+ {
100
+ src: selectedItem.iconUrl,
101
+ alt: "",
102
+ className: "h-4 w-4 shrink-0 rounded-sm object-contain"
103
+ }
104
+ ) : null,
105
+ /* @__PURE__ */ jsx("span", { className: "flex-1 truncate", children: (_a = selectedItem == null ? void 0 : selectedItem.label) != null ? _a : "" })
106
+ ]
107
+ }
108
+ ),
109
+ /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute inset-y-0 right-3 inline-flex items-center justify-center text-agg-muted-foreground", children: /* @__PURE__ */ jsx(Icon, { name: "chevron-down", size: "s", color: "currentColor" }) }),
110
+ isOpen ? /* @__PURE__ */ jsx(
111
+ "div",
112
+ {
113
+ role: "listbox",
114
+ "aria-label": ariaLabel != null ? ariaLabel : labels.common.selectAria,
115
+ className: "absolute top-full left-0 z-50 mt-1 w-full overflow-hidden rounded-agg-md border border-agg-separator bg-agg-secondary shadow-lg",
116
+ children: items.map((item) => {
117
+ const isSelected = item.value === value;
118
+ return /* @__PURE__ */ jsxs(
119
+ "button",
120
+ {
121
+ type: "button",
122
+ role: "option",
123
+ "aria-selected": isSelected,
124
+ disabled: item.disabled,
125
+ className: cn(
126
+ "flex w-full items-center gap-2 px-4 py-2 text-left text-agg-sm leading-agg-5 outline-none",
127
+ "hover:bg-agg-secondary-hover focus-visible:bg-agg-secondary-hover",
128
+ isSelected ? "font-agg-bold text-agg-primary" : "font-agg-normal text-agg-foreground",
129
+ item.disabled && "cursor-not-allowed opacity-60"
130
+ ),
131
+ onClick: () => {
132
+ if (!item.disabled) {
133
+ onChange(item.value);
134
+ close();
135
+ }
136
+ },
137
+ children: [
138
+ item.iconUrl ? /* @__PURE__ */ jsx(
139
+ "img",
140
+ {
141
+ src: item.iconUrl,
142
+ alt: "",
143
+ className: "h-4 w-4 shrink-0 rounded-sm object-contain"
144
+ }
145
+ ) : null,
146
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: item.label })
147
+ ]
148
+ },
149
+ item.value
150
+ );
151
+ })
152
+ }
153
+ ) : null
154
+ ] });
155
+ };
156
+ Select.displayName = "Select";
157
+
158
+ export {
159
+ Select
160
+ };