@agg-market/ui 10.0.0 → 11.0.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.
Files changed (50) hide show
  1. package/dist/{chunk-GYOCLZGH.mjs → chunk-2KGE5AJQ.mjs} +167 -276
  2. package/dist/{chunk-55YYUTBK.mjs → chunk-5FSWOXEG.mjs} +1 -1
  3. package/dist/{chunk-RYQSVETG.mjs → chunk-HMUMJUIL.mjs} +429 -331
  4. package/dist/{chunk-XP7DREIX.mjs → chunk-IUJXJEDQ.mjs} +1300 -656
  5. package/dist/{chunk-5G4T5R2H.mjs → chunk-UONHGMFI.mjs} +7 -3
  6. package/dist/events.js +756 -670
  7. package/dist/events.mjs +2 -2
  8. package/dist/index.js +2976 -2367
  9. package/dist/index.mjs +13 -6
  10. package/dist/modals.js +26 -9
  11. package/dist/modals.mjs +2 -2
  12. package/dist/pages.js +2653 -1790
  13. package/dist/pages.mjs +4 -4
  14. package/dist/primitives.js +1277 -649
  15. package/dist/primitives.mjs +5 -1
  16. package/dist/styles.css +1 -1
  17. package/dist/tailwind.css +1 -1
  18. package/dist/trading.js +257 -189
  19. package/dist/trading.mjs +2 -2
  20. package/dist/types/events/list/event-list.types.d.mts +1 -1
  21. package/dist/types/events/list/event-list.types.d.ts +1 -1
  22. package/dist/types/events/market-details/index.d.mts +2 -2
  23. package/dist/types/events/market-details/index.d.ts +2 -2
  24. package/dist/types/events/market-details/market-details.types.d.mts +1 -5
  25. package/dist/types/events/market-details/market-details.types.d.ts +1 -5
  26. package/dist/types/primitives/agg-logo/index.d.mts +6 -0
  27. package/dist/types/primitives/agg-logo/index.d.ts +6 -0
  28. package/dist/types/primitives/header/agg-logo.d.mts +2 -0
  29. package/dist/types/primitives/header/agg-logo.d.ts +2 -0
  30. package/dist/types/primitives/header/header.constants.d.mts +3 -0
  31. package/dist/types/primitives/header/header.constants.d.ts +3 -0
  32. package/dist/types/primitives/header/header.types.d.mts +28 -0
  33. package/dist/types/primitives/header/header.types.d.ts +28 -0
  34. package/dist/types/primitives/header/index.d.mts +7 -0
  35. package/dist/types/primitives/header/index.d.ts +7 -0
  36. package/dist/types/primitives/index.d.mts +2 -0
  37. package/dist/types/primitives/index.d.ts +2 -0
  38. package/dist/types/primitives/search/index.d.mts +1 -1
  39. package/dist/types/primitives/search/index.d.ts +1 -1
  40. package/dist/types/primitives/search/search.types.d.mts +9 -59
  41. package/dist/types/primitives/search/search.types.d.ts +9 -59
  42. package/dist/types/primitives/search/search.utils.d.mts +4 -0
  43. package/dist/types/primitives/search/search.utils.d.ts +4 -0
  44. package/dist/types/primitives/skeleton/skeleton.types.d.mts +1 -0
  45. package/dist/types/primitives/skeleton/skeleton.types.d.ts +1 -0
  46. package/dist/types/primitives/skeleton/views/search-skeleton-view.d.mts +5 -0
  47. package/dist/types/primitives/skeleton/views/search-skeleton-view.d.ts +5 -0
  48. package/dist/types/trading/types.d.mts +2 -2
  49. package/dist/types/trading/types.d.ts +2 -2
  50. package/package.json +3 -3
@@ -1,19 +1,25 @@
1
1
  import {
2
2
  EventList,
3
+ EventListItem,
3
4
  EventListItemDetails,
4
5
  MarketDetails,
5
- isErrorWithStatus
6
- } from "./chunk-GYOCLZGH.mjs";
6
+ MarketDetailsList,
7
+ getDefaultEventListTabs,
8
+ isErrorWithStatus,
9
+ resolveTabVenus
10
+ } from "./chunk-2KGE5AJQ.mjs";
7
11
  import {
8
12
  PlaceOrder,
9
13
  Settlement
10
- } from "./chunk-5G4T5R2H.mjs";
14
+ } from "./chunk-UONHGMFI.mjs";
11
15
  import {
12
16
  Button,
13
17
  Card,
18
+ Header,
14
19
  Icon,
15
20
  Modal,
16
21
  RemoteImage,
22
+ Skeleton,
17
23
  StateMessage,
18
24
  Tabs,
19
25
  Typography,
@@ -21,224 +27,17 @@ import {
21
27
  __spreadProps,
22
28
  __spreadValues,
23
29
  cn
24
- } from "./chunk-XP7DREIX.mjs";
30
+ } from "./chunk-IUJXJEDQ.mjs";
25
31
 
26
32
  // src/pages/home/index.tsx
27
- import { useEffect, useMemo, useState } from "react";
28
- import { useCategories, useLabels } from "@agg-market/hooks";
29
-
30
- // src/pages/home/home.constants.ts
31
- var ALL_CATEGORIES_TAB_VALUE = "trending";
32
- var DEFAULT_CATEGORIES_LIMIT = 100;
33
- var DEFAULT_ALL_CATEGORY_TAB_LABEL = "Trending";
34
- var getDefaultEventSectionItems = (labels) => {
35
- return [
36
- {
37
- id: "top-markets",
38
- title: labels.home.topMarkets,
39
- maxItemsPerRow: 3,
40
- limit: 3,
41
- maxVisibleItems: 3
42
- },
43
- {
44
- id: "new-markets",
45
- title: labels.home.newMarkets,
46
- maxItemsPerRow: 3,
47
- limit: 3,
48
- maxVisibleItems: 3
49
- }
50
- ];
51
- };
52
-
53
- // src/pages/home/home.utils.ts
54
- var resolveCategoryTabs = (categories, allCategoryTabLabel) => {
55
- const seenCategoryIds = /* @__PURE__ */ new Set();
56
- const tabs = [
57
- {
58
- value: ALL_CATEGORIES_TAB_VALUE,
59
- label: allCategoryTabLabel,
60
- iconName: "arrow-trend-up"
61
- }
62
- ];
63
- for (const category of categories) {
64
- if (seenCategoryIds.has(category.id))
65
- continue;
66
- seenCategoryIds.add(category.id);
67
- tabs.push({
68
- value: category.id,
69
- label: category.name.trim().toLowerCase(),
70
- categoryIds: [category.id]
71
- });
72
- }
73
- return tabs;
74
- };
75
- var resolveInitialTabValue = (tabs, defaultActiveTab) => {
76
- var _a, _b;
77
- if (defaultActiveTab) {
78
- const hasDefaultTab = tabs.some((tab) => tab.value === defaultActiveTab);
79
- if (hasDefaultTab)
80
- return defaultActiveTab;
81
- }
82
- return (_b = (_a = tabs[0]) == null ? void 0 : _a.value) != null ? _b : ALL_CATEGORIES_TAB_VALUE;
83
- };
84
-
85
- // src/pages/home/index.tsx
86
- import { jsx, jsxs } from "react/jsx-runtime";
87
- var HomePage = ({
88
- tabs,
89
- defaultActiveTab,
90
- onTabChange,
91
- eventSectionItems,
92
- classNames,
93
- categoriesLimit = DEFAULT_CATEGORIES_LIMIT,
94
- allCategoryTabLabel = DEFAULT_ALL_CATEGORY_TAB_LABEL
95
- }) => {
96
- const labels = useLabels();
97
- const hasCustomTabs = !!tabs && tabs.length > 0;
98
- const resolvedAllCategoryTabLabel = allCategoryTabLabel === DEFAULT_ALL_CATEGORY_TAB_LABEL ? labels.home.trending : allCategoryTabLabel;
99
- const { categories, isLoading: isCategoriesLoading } = useCategories({
100
- limit: categoriesLimit,
101
- enabled: !hasCustomTabs
102
- });
103
- const categoryTabs = useMemo(() => {
104
- return resolveCategoryTabs(categories, resolvedAllCategoryTabLabel);
105
- }, [categories, resolvedAllCategoryTabLabel]);
106
- const resolvedTabs = useMemo(() => {
107
- if (hasCustomTabs && tabs)
108
- return tabs;
109
- return categoryTabs;
110
- }, [categoryTabs, hasCustomTabs, tabs]);
111
- const resolvedEventSectionItems = eventSectionItems && eventSectionItems.length > 0 ? eventSectionItems : getDefaultEventSectionItems(labels);
112
- const [activeTabValue, setActiveTabValue] = useState(() => {
113
- return resolveInitialTabValue(resolvedTabs, defaultActiveTab);
114
- });
115
- useEffect(() => {
116
- setActiveTabValue((currentValue) => {
117
- const hasCurrentValue = resolvedTabs.some((tab) => tab.value === currentValue);
118
- if (hasCurrentValue)
119
- return currentValue;
120
- return resolveInitialTabValue(resolvedTabs, defaultActiveTab);
121
- });
122
- }, [defaultActiveTab, resolvedTabs]);
123
- const tabsItems = useMemo(() => {
124
- return resolvedTabs.map((tab) => {
125
- const isActive = tab.value === activeTabValue;
126
- return {
127
- value: tab.value,
128
- label: tab.label,
129
- icon: tab.iconName ? /* @__PURE__ */ jsx(
130
- Icon,
131
- {
132
- name: tab.iconName,
133
- size: "medium",
134
- color: isActive ? "var(--agg-color-primary)" : "var(--agg-color-foreground)"
135
- }
136
- ) : void 0,
137
- disabled: tab.disabled
138
- };
139
- });
140
- }, [activeTabValue, resolvedTabs]);
141
- const activeTab = useMemo(() => {
142
- return resolvedTabs.find((tab) => tab.value === activeTabValue);
143
- }, [activeTabValue, resolvedTabs]);
144
- const resolvedSectionItems = useMemo(() => {
145
- var _a, _b, _c, _d;
146
- if (activeTabValue === ALL_CATEGORIES_TAB_VALUE) {
147
- return resolvedEventSectionItems;
148
- }
149
- const maxItemsPerRow = (_b = (_a = resolvedEventSectionItems[0]) == null ? void 0 : _a.maxItemsPerRow) != null ? _b : 3;
150
- const firstSectionLimit = (_c = resolvedEventSectionItems[0]) == null ? void 0 : _c.limit;
151
- const limit = firstSectionLimit && Number.isFinite(firstSectionLimit) ? Math.max(9, Math.floor(firstSectionLimit)) : 9;
152
- return [
153
- {
154
- id: `${activeTabValue}-markets`,
155
- title: (_d = activeTab == null ? void 0 : activeTab.label) != null ? _d : activeTabValue,
156
- maxItemsPerRow,
157
- limit,
158
- maxVisibleItems: void 0,
159
- search: activeTab == null ? void 0 : activeTab.search,
160
- categoryIds: activeTab == null ? void 0 : activeTab.categoryIds
161
- }
162
- ];
163
- }, [activeTab, activeTabValue, resolvedEventSectionItems]);
164
- const handleTabChange = (value) => {
165
- setActiveTabValue(value);
166
- onTabChange == null ? void 0 : onTabChange(value);
167
- };
168
- if (!hasCustomTabs && isCategoriesLoading) {
169
- return /* @__PURE__ */ jsx("section", { className: cn("flex w-full flex-col", classNames == null ? void 0 : classNames.root), children: /* @__PURE__ */ jsx(
170
- "header",
171
- {
172
- className: cn(
173
- "w-full bg-agg-secondary border-b border-agg-separator",
174
- classNames == null ? void 0 : classNames.header
175
- ),
176
- children: /* @__PURE__ */ jsx("div", { className: cn("w-full px-4 md:px-10 h-10", classNames == null ? void 0 : classNames.tabs) })
177
- }
178
- ) });
179
- }
180
- return /* @__PURE__ */ jsxs("section", { className: cn("flex w-full flex-col", classNames == null ? void 0 : classNames.root), children: [
181
- /* @__PURE__ */ jsx(
182
- "header",
183
- {
184
- className: cn("w-full bg-agg-secondary border-b border-agg-separator", classNames == null ? void 0 : classNames.header),
185
- children: /* @__PURE__ */ jsx(
186
- Tabs,
187
- {
188
- ariaLabel: labels.home.categoryTabsAria,
189
- variant: "underline",
190
- className: cn("w-full px-4 md:px-10", classNames == null ? void 0 : classNames.tabs),
191
- items: tabsItems,
192
- value: activeTabValue,
193
- onChange: handleTabChange
194
- }
195
- )
196
- }
197
- ),
198
- /* @__PURE__ */ jsx(
199
- "main",
200
- {
201
- className: cn(
202
- "flex w-full flex-col gap-4 md:gap-10 px-4 md:px-10 py-4 md:py-8",
203
- classNames == null ? void 0 : classNames.sections
204
- ),
205
- children: resolvedSectionItems.map((eventSectionItem) => {
206
- var _a, _b, _c;
207
- return /* @__PURE__ */ jsx(
208
- EventList,
209
- {
210
- title: eventSectionItem.title,
211
- maxItemsPerRow: eventSectionItem.maxItemsPerRow,
212
- limit: eventSectionItem.limit,
213
- maxVisibleItems: eventSectionItem.maxVisibleItems,
214
- search: (_b = eventSectionItem.search) != null ? _b : activeTab == null ? void 0 : activeTab.search,
215
- categoryIds: (_c = eventSectionItem.categoryIds) != null ? _c : activeTab == null ? void 0 : activeTab.categoryIds
216
- },
217
- (_a = eventSectionItem.id) != null ? _a : eventSectionItem.title
218
- );
219
- })
220
- }
221
- )
222
- ] });
223
- };
224
- HomePage.displayName = "HomePage";
33
+ import { useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState2 } from "react";
34
+ import { useCategories, useLabels as useLabels2, useSdkUiConfig, useVenueEvents } from "@agg-market/hooks";
225
35
 
226
36
  // src/pages/event-market/index.tsx
227
- import { useEffect as useEffect2, useMemo as useMemo2, useState as useState2 } from "react";
228
- import { useVenueEvent, useLabels as useLabels2 } from "@agg-market/hooks";
37
+ import { useMemo, useState } from "react";
38
+ import { useVenueEvent, useLabels } from "@agg-market/hooks";
229
39
  import dayjs from "dayjs";
230
- import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
231
- var getMarketDateValue = (market, fallbackIndex) => {
232
- var _a, _b, _c;
233
- const candidateDate = (_c = (_b = (_a = market.endDate) != null ? _a : market.startDate) != null ? _b : market.creationDate) != null ? _c : null;
234
- if (!candidateDate)
235
- return Number.MAX_SAFE_INTEGER - 1 + fallbackIndex;
236
- const parsedDate = dayjs(candidateDate);
237
- if (!parsedDate.isValid()) {
238
- return Number.MAX_SAFE_INTEGER - 1 + fallbackIndex;
239
- }
240
- return parsedDate.valueOf();
241
- };
40
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
242
41
  var resolveHeroMarketId = (event, heroMarketId) => {
243
42
  var _a, _b;
244
43
  if (!((_a = event == null ? void 0 : event.venueMarkets) == null ? void 0 : _a.length))
@@ -262,32 +61,11 @@ var buildHeroEvent = (event, heroMarketId) => {
262
61
  venueMarkets: [heroMarket]
263
62
  });
264
63
  };
265
- var resolveDetailedMarkets = (event, heroMarketId) => {
266
- return event.venueMarkets.filter((market) => market.id !== heroMarketId).map((market, index) => ({
267
- market,
268
- index
269
- })).sort(
270
- (leftItem, rightItem) => {
271
- return getMarketDateValue(leftItem.market, leftItem.index) - getMarketDateValue(rightItem.market, rightItem.index);
272
- }
273
- ).map((item) => item.market);
274
- };
275
- var resolveInitialExpandedMarketId = (detailedMarkets, defaultExpandedMarketId) => {
276
- var _a, _b;
277
- if (!detailedMarkets.length)
278
- return null;
279
- if (defaultExpandedMarketId) {
280
- const matchingMarket = detailedMarkets.find((market) => market.id === defaultExpandedMarketId);
281
- if (matchingMarket)
282
- return matchingMarket.id;
283
- }
284
- return (_b = (_a = detailedMarkets[0]) == null ? void 0 : _a.id) != null ? _b : null;
285
- };
286
64
  var EventMarketPageMobileTrade = ({
287
65
  placeOrder,
288
66
  classNames
289
67
  }) => {
290
- const [isOpen, setIsOpen] = useState2(false);
68
+ const [isOpen, setIsOpen] = useState(false);
291
69
  const handleOpen = () => {
292
70
  setIsOpen(true);
293
71
  };
@@ -297,15 +75,15 @@ var EventMarketPageMobileTrade = ({
297
75
  const handleClose = () => {
298
76
  setIsOpen(false);
299
77
  };
300
- return /* @__PURE__ */ jsxs2(Fragment, { children: [
301
- /* @__PURE__ */ jsx2(
78
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
79
+ /* @__PURE__ */ jsx(
302
80
  "div",
303
81
  {
304
82
  className: cn(
305
83
  "fixed inset-x-0 bottom-0 z-20 flex justify-end p-4 lg:hidden",
306
84
  classNames == null ? void 0 : classNames.mobileTradeCta
307
85
  ),
308
- children: /* @__PURE__ */ jsx2(
86
+ children: /* @__PURE__ */ jsx(
309
87
  Button,
310
88
  {
311
89
  size: "large",
@@ -322,7 +100,7 @@ var EventMarketPageMobileTrade = ({
322
100
  )
323
101
  }
324
102
  ),
325
- /* @__PURE__ */ jsx2(Modal, { open: isOpen, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsx2(
103
+ /* @__PURE__ */ jsx(Modal, { open: isOpen, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsx(
326
104
  Modal.Container,
327
105
  {
328
106
  "aria-label": placeOrder.title,
@@ -334,7 +112,7 @@ var EventMarketPageMobileTrade = ({
334
112
  classNames == null ? void 0 : classNames.mobileTradeModal
335
113
  )
336
114
  },
337
- children: /* @__PURE__ */ jsx2(
115
+ children: /* @__PURE__ */ jsx(
338
116
  PlaceOrder,
339
117
  __spreadProps(__spreadValues({}, placeOrder), {
340
118
  isDismissible: true,
@@ -349,16 +127,16 @@ var EventMarketPageMobileTrade = ({
349
127
  var EventMarketPageUnavailableState = ({
350
128
  ariaLabel
351
129
  }) => {
352
- const labels = useLabels2();
353
- return /* @__PURE__ */ jsx2(
130
+ const labels = useLabels();
131
+ return /* @__PURE__ */ jsx(
354
132
  Card,
355
133
  {
356
134
  className: "rounded-agg-xl border border-agg-separator bg-agg-secondary p-6 shadow-none hover:shadow-none",
357
135
  role: "status",
358
136
  "aria-label": ariaLabel != null ? ariaLabel : labels.eventMarketPage.unavailableAria,
359
- children: /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-1", children: [
360
- /* @__PURE__ */ jsx2(Typography, { variant: "body-large-strong", children: labels.eventMarketPage.unavailableTitle }),
361
- /* @__PURE__ */ jsx2(Typography, { variant: "label", className: "text-agg-muted-foreground", children: labels.eventMarketPage.unavailableDescription })
137
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
138
+ /* @__PURE__ */ jsx(Typography, { variant: "body-large-strong", children: labels.eventMarketPage.unavailableTitle }),
139
+ /* @__PURE__ */ jsx(Typography, { variant: "label", className: "text-agg-muted-foreground", children: labels.eventMarketPage.unavailableDescription })
362
140
  ] })
363
141
  }
364
142
  );
@@ -366,8 +144,8 @@ var EventMarketPageUnavailableState = ({
366
144
  var EventMarketPageNotFoundState = ({
367
145
  ariaLabel
368
146
  }) => {
369
- const labels = useLabels2();
370
- return /* @__PURE__ */ jsx2(Card, { className: "overflow-hidden rounded-agg-xl border border-agg-separator bg-agg-secondary p-0 shadow-none hover:shadow-none", children: /* @__PURE__ */ jsx2(
147
+ const labels = useLabels();
148
+ return /* @__PURE__ */ jsx(Card, { className: "overflow-hidden rounded-agg-xl border border-agg-separator bg-agg-secondary p-0 shadow-none hover:shadow-none", children: /* @__PURE__ */ jsx(
371
149
  StateMessage,
372
150
  {
373
151
  ariaLabel: ariaLabel != null ? ariaLabel : labels.eventItemDetails.notFoundAria,
@@ -382,7 +160,7 @@ var EventMarketPageLoadingState = ({
382
160
  settlement,
383
161
  classNames
384
162
  }) => {
385
- const labels = useLabels2();
163
+ const labels = useLabels();
386
164
  const fallbackSettlement = settlement != null ? settlement : {
387
165
  sectionLabel: labels.trading.settlementSection,
388
166
  question: labels.eventMarketPage.loadingSettlementQuestion,
@@ -395,8 +173,8 @@ var EventMarketPageLoadingState = ({
395
173
  }
396
174
  ]
397
175
  };
398
- return /* @__PURE__ */ jsxs2("section", { className: cn("w-full pb-24 lg:pb-0", classNames == null ? void 0 : classNames.root), children: [
399
- /* @__PURE__ */ jsxs2(
176
+ return /* @__PURE__ */ jsxs("section", { className: cn("w-full pb-24 lg:pb-0", classNames == null ? void 0 : classNames.root), children: [
177
+ /* @__PURE__ */ jsxs(
400
178
  "div",
401
179
  {
402
180
  className: cn(
@@ -404,8 +182,8 @@ var EventMarketPageLoadingState = ({
404
182
  classNames == null ? void 0 : classNames.content
405
183
  ),
406
184
  children: [
407
- /* @__PURE__ */ jsxs2("div", { className: cn("flex min-w-0 flex-1 flex-col gap-6", classNames == null ? void 0 : classNames.main), children: [
408
- /* @__PURE__ */ jsx2(
185
+ /* @__PURE__ */ jsxs("div", { className: cn("flex min-w-0 flex-1 flex-col gap-6", classNames == null ? void 0 : classNames.main), children: [
186
+ /* @__PURE__ */ jsx(
409
187
  EventListItemDetails,
410
188
  {
411
189
  isLoading: true,
@@ -414,35 +192,35 @@ var EventMarketPageLoadingState = ({
414
192
  }
415
193
  }
416
194
  ),
417
- /* @__PURE__ */ jsxs2("div", { className: cn("flex flex-col gap-3", classNames == null ? void 0 : classNames.markets), children: [
418
- /* @__PURE__ */ jsx2(MarketDetails, { isLoading: true, isOpened: true, classNames: { root: "w-full" } }),
419
- /* @__PURE__ */ jsx2(MarketDetails, { isLoading: true, isOpened: false, classNames: { root: "w-full" } }),
420
- /* @__PURE__ */ jsx2(MarketDetails, { isLoading: true, isOpened: false, classNames: { root: "w-full" } })
195
+ /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-3", classNames == null ? void 0 : classNames.markets), children: [
196
+ /* @__PURE__ */ jsx(MarketDetails, { isLoading: true, isOpened: true, classNames: { root: "w-full" } }),
197
+ /* @__PURE__ */ jsx(MarketDetails, { isLoading: true, isOpened: false, classNames: { root: "w-full" } }),
198
+ /* @__PURE__ */ jsx(MarketDetails, { isLoading: true, isOpened: false, classNames: { root: "w-full" } })
421
199
  ] }),
422
- /* @__PURE__ */ jsx2("div", { className: "md:hidden", children: /* @__PURE__ */ jsx2(Settlement, __spreadProps(__spreadValues({}, fallbackSettlement), { isLoading: true, className: classNames == null ? void 0 : classNames.settlement })) }),
423
- /* @__PURE__ */ jsx2("div", { className: "hidden md:block", children: /* @__PURE__ */ jsx2(Settlement, __spreadProps(__spreadValues({}, fallbackSettlement), { isLoading: true, className: classNames == null ? void 0 : classNames.settlement })) })
200
+ /* @__PURE__ */ jsx("div", { className: "md:hidden", children: /* @__PURE__ */ jsx(Settlement, __spreadProps(__spreadValues({}, fallbackSettlement), { isLoading: true, className: classNames == null ? void 0 : classNames.settlement })) }),
201
+ /* @__PURE__ */ jsx("div", { className: "hidden md:block", children: /* @__PURE__ */ jsx(Settlement, __spreadProps(__spreadValues({}, fallbackSettlement), { isLoading: true, className: classNames == null ? void 0 : classNames.settlement })) })
424
202
  ] }),
425
- placeOrder ? /* @__PURE__ */ jsx2(
203
+ placeOrder ? /* @__PURE__ */ jsx(
426
204
  "aside",
427
205
  {
428
206
  className: cn(
429
207
  "hidden w-full shrink-0 lg:sticky lg:top-6 lg:block lg:w-[343px]",
430
208
  classNames == null ? void 0 : classNames.sidebar
431
209
  ),
432
- children: /* @__PURE__ */ jsx2(PlaceOrder, __spreadProps(__spreadValues({}, placeOrder), { isLoading: true, className: classNames == null ? void 0 : classNames.trade }))
210
+ children: /* @__PURE__ */ jsx(PlaceOrder, __spreadProps(__spreadValues({}, placeOrder), { isLoading: true, className: classNames == null ? void 0 : classNames.trade }))
433
211
  }
434
212
  ) : null
435
213
  ]
436
214
  }
437
215
  ),
438
- placeOrder ? /* @__PURE__ */ jsx2(
216
+ placeOrder ? /* @__PURE__ */ jsx(
439
217
  "div",
440
218
  {
441
219
  className: cn(
442
220
  "fixed inset-x-0 bottom-0 z-20 flex justify-end p-4 lg:hidden",
443
221
  classNames == null ? void 0 : classNames.mobileTradeCta
444
222
  ),
445
- children: /* @__PURE__ */ jsx2(
223
+ children: /* @__PURE__ */ jsx(
446
224
  Button,
447
225
  {
448
226
  size: "large",
@@ -461,59 +239,28 @@ var EventMarketPageContent = ({
461
239
  heroMarketId,
462
240
  defaultExpandedMarketId,
463
241
  expandedMarketId,
464
- onExpandedMarketChange,
465
242
  heroDefaultTimeRange,
466
243
  placeOrder,
467
244
  settlement,
468
245
  classNames,
469
246
  ariaLabel
470
247
  }) => {
471
- const labels = useLabels2();
472
- const resolvedHeroMarketId = useMemo2(() => {
248
+ const resolvedHeroMarketId = useMemo(() => {
473
249
  return resolveHeroMarketId(event, heroMarketId);
474
250
  }, [event, heroMarketId]);
475
- const heroEvent = useMemo2(() => {
251
+ const heroEvent = useMemo(() => {
476
252
  return buildHeroEvent(event, resolvedHeroMarketId);
477
253
  }, [event, resolvedHeroMarketId]);
478
- const detailedMarkets = useMemo2(() => {
479
- return resolveDetailedMarkets(event, resolvedHeroMarketId);
480
- }, [event, resolvedHeroMarketId]);
481
- const [internalExpandedMarketId, setInternalExpandedMarketId] = useState2(() => {
482
- return resolveInitialExpandedMarketId(detailedMarkets, defaultExpandedMarketId);
483
- });
484
- useEffect2(() => {
485
- if (typeof expandedMarketId === "undefined")
486
- return;
487
- setInternalExpandedMarketId(expandedMarketId);
488
- }, [expandedMarketId]);
489
- useEffect2(() => {
490
- if (typeof expandedMarketId !== "undefined")
491
- return;
492
- setInternalExpandedMarketId((currentExpandedMarketId) => {
493
- if (currentExpandedMarketId && detailedMarkets.some((market) => market.id === currentExpandedMarketId)) {
494
- return currentExpandedMarketId;
495
- }
496
- return resolveInitialExpandedMarketId(detailedMarkets, defaultExpandedMarketId);
497
- });
498
- }, [defaultExpandedMarketId, detailedMarkets, expandedMarketId]);
499
- const resolvedExpandedMarketId = typeof expandedMarketId === "undefined" ? internalExpandedMarketId : expandedMarketId;
500
- const handleExpandedMarketChange = (marketId, isOpened) => {
501
- const nextExpandedMarketId = isOpened ? marketId : null;
502
- if (typeof expandedMarketId === "undefined") {
503
- setInternalExpandedMarketId(nextExpandedMarketId);
504
- }
505
- onExpandedMarketChange == null ? void 0 : onExpandedMarketChange(nextExpandedMarketId);
506
- };
507
254
  if (!heroEvent || !event.venueMarkets.length) {
508
- return /* @__PURE__ */ jsx2(EventMarketPageUnavailableState, { ariaLabel });
255
+ return /* @__PURE__ */ jsx(EventMarketPageUnavailableState, { ariaLabel });
509
256
  }
510
- return /* @__PURE__ */ jsxs2(
257
+ return /* @__PURE__ */ jsxs(
511
258
  "section",
512
259
  {
513
260
  className: cn("w-full pb-24 lg:pb-0", classNames == null ? void 0 : classNames.root),
514
261
  "aria-label": ariaLabel != null ? ariaLabel : event.title,
515
262
  children: [
516
- /* @__PURE__ */ jsxs2(
263
+ /* @__PURE__ */ jsxs(
517
264
  "div",
518
265
  {
519
266
  className: cn(
@@ -521,8 +268,8 @@ var EventMarketPageContent = ({
521
268
  classNames == null ? void 0 : classNames.content
522
269
  ),
523
270
  children: [
524
- /* @__PURE__ */ jsxs2("div", { className: cn("flex min-w-0 flex-1 flex-col gap-6", classNames == null ? void 0 : classNames.main), children: [
525
- /* @__PURE__ */ jsx2(
271
+ /* @__PURE__ */ jsxs("div", { className: cn("flex min-w-0 flex-1 flex-col gap-6", classNames == null ? void 0 : classNames.main), children: [
272
+ /* @__PURE__ */ jsx(
526
273
  EventListItemDetails,
527
274
  {
528
275
  event: heroEvent,
@@ -532,37 +279,22 @@ var EventMarketPageContent = ({
532
279
  }
533
280
  }
534
281
  ),
535
- detailedMarkets.length > 0 ? /* @__PURE__ */ jsx2("div", { className: cn("flex flex-col gap-3", classNames == null ? void 0 : classNames.markets), children: detailedMarkets.map((market) => {
536
- const isOpened = resolvedExpandedMarketId === market.id;
537
- return /* @__PURE__ */ jsx2(
538
- MarketDetails,
539
- {
540
- venueMarkets: [market],
541
- isOpened,
542
- defaultTab: "order-book",
543
- ariaLabel: market.endDate && dayjs(market.endDate).isValid() ? labels.eventMarketPage.marketDetailsAriaByDate(
544
- dayjs(market.endDate).format("MMM D, YYYY")
545
- ) : labels.eventMarketPage.marketDetailsAriaByQuestion(market.question),
546
- onOpenChange: (nextIsOpened) => handleExpandedMarketChange(market.id, nextIsOpened)
547
- },
548
- market.id
549
- );
550
- }) }) : null,
551
- settlement ? /* @__PURE__ */ jsx2("div", { className: "md:hidden", children: /* @__PURE__ */ jsx2(Settlement, __spreadProps(__spreadValues({}, settlement), { className: classNames == null ? void 0 : classNames.settlement })) }) : null,
552
- settlement ? /* @__PURE__ */ jsx2("div", { className: "hidden md:block", children: /* @__PURE__ */ jsx2(Settlement, __spreadProps(__spreadValues({}, settlement), { className: classNames == null ? void 0 : classNames.settlement })) }) : null
282
+ /* @__PURE__ */ jsx(MarketDetailsList, { eventId: event.id }),
283
+ settlement ? /* @__PURE__ */ jsx("div", { className: "md:hidden", children: /* @__PURE__ */ jsx(Settlement, __spreadProps(__spreadValues({}, settlement), { className: classNames == null ? void 0 : classNames.settlement })) }) : null,
284
+ settlement ? /* @__PURE__ */ jsx("div", { className: "hidden md:block", children: /* @__PURE__ */ jsx(Settlement, __spreadProps(__spreadValues({}, settlement), { className: classNames == null ? void 0 : classNames.settlement })) }) : null
553
285
  ] }),
554
- placeOrder ? /* @__PURE__ */ jsx2(
286
+ placeOrder ? /* @__PURE__ */ jsx(
555
287
  "aside",
556
288
  {
557
289
  className: cn("hidden w-full lg:block lg:max-w-[360px]", classNames == null ? void 0 : classNames.sidebar),
558
290
  "data-testid": "event-market-page-desktop-trade",
559
- children: /* @__PURE__ */ jsx2(PlaceOrder, __spreadProps(__spreadValues({}, placeOrder), { className: classNames == null ? void 0 : classNames.trade }))
291
+ children: /* @__PURE__ */ jsx(PlaceOrder, __spreadProps(__spreadValues({}, placeOrder), { className: classNames == null ? void 0 : classNames.trade }))
560
292
  }
561
293
  ) : null
562
294
  ]
563
295
  }
564
296
  ),
565
- placeOrder ? /* @__PURE__ */ jsx2(EventMarketPageMobileTrade, { placeOrder, classNames }) : null
297
+ placeOrder ? /* @__PURE__ */ jsx(EventMarketPageMobileTrade, { placeOrder, classNames }) : null
566
298
  ]
567
299
  }
568
300
  );
@@ -579,13 +311,13 @@ var EventMarketPage = (props) => {
579
311
  enabled: !props.isLoading && !hasEventProp && !!props.eventId
580
312
  });
581
313
  if (props.isLoading) {
582
- return /* @__PURE__ */ jsx2(EventMarketPageLoadingState, { placeOrder: props.placeOrder, settlement: props.settlement });
314
+ return /* @__PURE__ */ jsx(EventMarketPageLoadingState, { placeOrder: props.placeOrder, settlement: props.settlement });
583
315
  }
584
316
  if ("event" in props && props.event) {
585
- return /* @__PURE__ */ jsx2(EventMarketPageContent, __spreadProps(__spreadValues({}, props), { event: props.event }));
317
+ return /* @__PURE__ */ jsx(EventMarketPageContent, __spreadProps(__spreadValues({}, props), { event: props.event }));
586
318
  }
587
319
  if (isFetchingEvent) {
588
- return /* @__PURE__ */ jsx2(
320
+ return /* @__PURE__ */ jsx(
589
321
  EventMarketPageLoadingState,
590
322
  {
591
323
  placeOrder: props.placeOrder,
@@ -596,14 +328,380 @@ var EventMarketPage = (props) => {
596
328
  }
597
329
  if (!fetchedEvent) {
598
330
  if (isErrorWithStatus(eventError, 404)) {
599
- return /* @__PURE__ */ jsx2(EventMarketPageNotFoundState, { ariaLabel: props.ariaLabel });
331
+ return /* @__PURE__ */ jsx(EventMarketPageNotFoundState, { ariaLabel: props.ariaLabel });
600
332
  }
601
- return /* @__PURE__ */ jsx2(EventMarketPageUnavailableState, { ariaLabel: props.ariaLabel });
333
+ return /* @__PURE__ */ jsx(EventMarketPageUnavailableState, { ariaLabel: props.ariaLabel });
602
334
  }
603
- return /* @__PURE__ */ jsx2(EventMarketPageContent, __spreadProps(__spreadValues({}, props), { event: fetchedEvent }));
335
+ return /* @__PURE__ */ jsx(EventMarketPageContent, __spreadProps(__spreadValues({}, props), { event: fetchedEvent }));
604
336
  };
605
337
  EventMarketPage.displayName = "EventMarketPage";
606
338
 
339
+ // src/pages/home/home.constants.ts
340
+ var ALL_CATEGORIES_TAB_VALUE = "trending";
341
+ var DEFAULT_CATEGORIES_LIMIT = 100;
342
+ var DEFAULT_ALL_CATEGORY_TAB_LABEL = "Trending";
343
+ var getDefaultEventSectionItems = (labels) => {
344
+ return [
345
+ {
346
+ id: "top-markets",
347
+ title: labels.home.topMarkets,
348
+ maxItemsPerRow: 3,
349
+ limit: 9,
350
+ maxVisibleItems: 9
351
+ }
352
+ ];
353
+ };
354
+
355
+ // src/pages/home/home.utils.ts
356
+ var resolveCategoryTabs = (categories, allCategoryTabLabel) => {
357
+ const seenCategoryIds = /* @__PURE__ */ new Set();
358
+ const tabs = [
359
+ {
360
+ value: ALL_CATEGORIES_TAB_VALUE,
361
+ label: allCategoryTabLabel,
362
+ iconName: "arrow-trend-up"
363
+ }
364
+ ];
365
+ for (const category of categories) {
366
+ if (seenCategoryIds.has(category.id))
367
+ continue;
368
+ seenCategoryIds.add(category.id);
369
+ tabs.push({
370
+ value: category.id,
371
+ label: category.name.trim().toLowerCase(),
372
+ categoryIds: [category.id]
373
+ });
374
+ }
375
+ return tabs;
376
+ };
377
+ var resolveInitialTabValue = (tabs, defaultActiveTab) => {
378
+ var _a, _b;
379
+ if (defaultActiveTab) {
380
+ const hasDefaultTab = tabs.some((tab) => tab.value === defaultActiveTab);
381
+ if (hasDefaultTab)
382
+ return defaultActiveTab;
383
+ }
384
+ return (_b = (_a = tabs[0]) == null ? void 0 : _a.value) != null ? _b : ALL_CATEGORIES_TAB_VALUE;
385
+ };
386
+
387
+ // src/pages/home/index.tsx
388
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
389
+ var MIN_SEARCH_LENGTH = 3;
390
+ var SEARCH_DEBOUNCE_MS = 300;
391
+ var SEARCH_RESULTS_LIMIT = 9;
392
+ var HomeSearchResults = ({
393
+ activeTabValue,
394
+ onTabChange,
395
+ query,
396
+ tabs,
397
+ resolvedTabs,
398
+ className
399
+ }) => {
400
+ const labels = useLabels2();
401
+ const { search: searchConfig } = useSdkUiConfig();
402
+ const [activeVenueTabValue, setActiveVenueTabValue] = useState2("matched");
403
+ const eventListTabs = useMemo2(() => {
404
+ return getDefaultEventListTabs(labels);
405
+ }, [labels]);
406
+ const activeVenueTab = useMemo2(() => {
407
+ return eventListTabs.find((tab) => tab.value === activeVenueTabValue);
408
+ }, [activeVenueTabValue, eventListTabs]);
409
+ const activeCategoryTab = useMemo2(() => {
410
+ return resolvedTabs.find((tab) => tab.value === activeTabValue);
411
+ }, [activeTabValue, resolvedTabs]);
412
+ const { events, isLoading, isError, fetchNextPage, hasNextPage, isFetchingNextPage } = useVenueEvents({
413
+ queryKeyScope: "home-search-results",
414
+ search: query,
415
+ categoryIds: activeTabValue === ALL_CATEGORIES_TAB_VALUE ? void 0 : activeCategoryTab == null ? void 0 : activeCategoryTab.categoryIds,
416
+ venues: resolveTabVenus(activeVenueTab),
417
+ limit: SEARCH_RESULTS_LIMIT
418
+ });
419
+ const loadMoreRef = useRef(null);
420
+ useEffect2(() => {
421
+ if (!hasNextPage)
422
+ return;
423
+ const target = loadMoreRef.current;
424
+ if (!target)
425
+ return;
426
+ const observer = new IntersectionObserver(
427
+ (entries) => {
428
+ const entry = entries[0];
429
+ if (!(entry == null ? void 0 : entry.isIntersecting))
430
+ return;
431
+ if (isLoading || isFetchingNextPage || !hasNextPage)
432
+ return;
433
+ void fetchNextPage();
434
+ },
435
+ {
436
+ rootMargin: "320px 0px"
437
+ }
438
+ );
439
+ observer.observe(target);
440
+ return () => {
441
+ observer.disconnect();
442
+ };
443
+ }, [fetchNextPage, hasNextPage, isFetchingNextPage, isLoading]);
444
+ const resultsTitle = labels.search.resultsSummary(
445
+ hasNextPage ? `${events.length}+` : `${events.length}`,
446
+ query
447
+ );
448
+ const searchResultTabs = useMemo2(() => {
449
+ return eventListTabs.map((tab) => {
450
+ const isActive = tab.value === activeVenueTabValue;
451
+ return {
452
+ value: tab.value,
453
+ label: tab.label,
454
+ icon: tab.iconName ? /* @__PURE__ */ jsx2(
455
+ Icon,
456
+ {
457
+ name: tab.iconName,
458
+ size: "small",
459
+ color: isActive ? "var(--agg-color-primary)" : "var(--agg-color-foreground)"
460
+ }
461
+ ) : tab.venueLogo ? /* @__PURE__ */ jsx2(
462
+ VenueLogo,
463
+ {
464
+ venue: tab.venueLogo,
465
+ size: "small",
466
+ className: cn(isActive ? "text-agg-primary" : "text-agg-foreground")
467
+ }
468
+ ) : void 0,
469
+ disabled: tab.disabled
470
+ };
471
+ });
472
+ }, [activeVenueTabValue, eventListTabs]);
473
+ const loadingPlaceholderCount = isFetchingNextPage ? 3 : 0;
474
+ if (isLoading) {
475
+ return /* @__PURE__ */ jsx2(Skeleton, { view: "event-list", ariaLabel: labels.search.loadingResults, className });
476
+ }
477
+ return /* @__PURE__ */ jsxs2("section", { className: cn("flex w-full flex-col gap-5", className), children: [
478
+ /* @__PURE__ */ jsx2("header", { className: "flex flex-col gap-5", children: /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between", children: [
479
+ /* @__PURE__ */ jsx2(Typography, { as: "h2", variant: "title", className: "min-w-0", children: resultsTitle }),
480
+ /* @__PURE__ */ jsx2(
481
+ Tabs,
482
+ {
483
+ ariaLabel: labels.eventList.tabsAria(resultsTitle),
484
+ items: searchResultTabs,
485
+ value: activeVenueTabValue,
486
+ onChange: setActiveVenueTabValue
487
+ }
488
+ )
489
+ ] }) }),
490
+ /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-1 gap-5 md:grid-cols-3", children: [
491
+ events.map((event) => /* @__PURE__ */ jsx2(
492
+ EventListItem,
493
+ {
494
+ event,
495
+ classNames: {
496
+ root: "w-full min-w-0 max-w-none"
497
+ },
498
+ onClick: (selectedEvent) => {
499
+ if (!selectedEvent)
500
+ return;
501
+ searchConfig.onSelect(selectedEvent);
502
+ }
503
+ },
504
+ event.id
505
+ )),
506
+ Array.from({ length: loadingPlaceholderCount }).map((_, index) => /* @__PURE__ */ jsx2(
507
+ EventListItem,
508
+ {
509
+ isLoading: true,
510
+ classNames: {
511
+ root: "w-full min-w-0 max-w-none"
512
+ }
513
+ },
514
+ `search-results-loading-${index}`
515
+ )),
516
+ !isError && events.length === 0 ? /* @__PURE__ */ jsx2(Card, { className: "col-span-full overflow-hidden shadow-none hover:shadow-none p-0! border-none! bg-transparent!", children: /* @__PURE__ */ jsx2(
517
+ StateMessage,
518
+ {
519
+ ariaLabel: labels.eventList.emptyAria,
520
+ title: labels.eventList.emptyTitle,
521
+ description: labels.eventList.emptyDescription
522
+ }
523
+ ) }) : null,
524
+ isError ? /* @__PURE__ */ jsx2(
525
+ Typography,
526
+ {
527
+ variant: "body",
528
+ className: "col-span-full flex h-32 w-full items-center justify-center",
529
+ children: labels.eventList.error
530
+ }
531
+ ) : null
532
+ ] }),
533
+ hasNextPage ? /* @__PURE__ */ jsx2("div", { ref: loadMoreRef, className: "h-px w-full", "aria-hidden": true }) : null
534
+ ] });
535
+ };
536
+ var HomePage = ({
537
+ tabs,
538
+ defaultActiveTab,
539
+ onTabChange,
540
+ eventSectionItems,
541
+ classNames,
542
+ categoriesLimit = DEFAULT_CATEGORIES_LIMIT,
543
+ allCategoryTabLabel = DEFAULT_ALL_CATEGORY_TAB_LABEL
544
+ }) => {
545
+ const labels = useLabels2();
546
+ const {
547
+ search: {
548
+ value: searchValue,
549
+ result: selectedEvent,
550
+ isShowingAllResults,
551
+ onSelect: onSelectEvent
552
+ }
553
+ } = useSdkUiConfig();
554
+ const hasCustomTabs = !!tabs && tabs.length > 0;
555
+ const normalizedSearchValue = searchValue.trim();
556
+ const [debouncedSearchValue, setDebouncedSearchValue] = useState2(() => {
557
+ return normalizedSearchValue.length >= MIN_SEARCH_LENGTH ? normalizedSearchValue : "";
558
+ });
559
+ useEffect2(() => {
560
+ if (normalizedSearchValue.length < MIN_SEARCH_LENGTH) {
561
+ setDebouncedSearchValue("");
562
+ return;
563
+ }
564
+ const timeoutId = window.setTimeout(() => {
565
+ setDebouncedSearchValue(normalizedSearchValue);
566
+ }, SEARCH_DEBOUNCE_MS);
567
+ return () => {
568
+ window.clearTimeout(timeoutId);
569
+ };
570
+ }, [normalizedSearchValue]);
571
+ const resolvedAllCategoryTabLabel = allCategoryTabLabel === DEFAULT_ALL_CATEGORY_TAB_LABEL ? labels.home.trending : allCategoryTabLabel;
572
+ const { categories, isLoading: isCategoriesLoading } = useCategories({
573
+ limit: categoriesLimit,
574
+ enabled: !hasCustomTabs
575
+ });
576
+ const categoryTabs = useMemo2(() => {
577
+ return resolveCategoryTabs(categories, resolvedAllCategoryTabLabel);
578
+ }, [categories, resolvedAllCategoryTabLabel]);
579
+ const resolvedTabs = useMemo2(() => {
580
+ if (hasCustomTabs && tabs)
581
+ return tabs;
582
+ return categoryTabs;
583
+ }, [categoryTabs, hasCustomTabs, tabs]);
584
+ const resolvedEventSectionItems = eventSectionItems && eventSectionItems.length > 0 ? eventSectionItems : getDefaultEventSectionItems(labels);
585
+ const [activeTabValue, setActiveTabValue] = useState2(() => {
586
+ return resolveInitialTabValue(resolvedTabs, defaultActiveTab);
587
+ });
588
+ useEffect2(() => {
589
+ setActiveTabValue((currentValue) => {
590
+ const hasCurrentValue = resolvedTabs.some((tab) => tab.value === currentValue);
591
+ if (hasCurrentValue)
592
+ return currentValue;
593
+ return resolveInitialTabValue(resolvedTabs, defaultActiveTab);
594
+ });
595
+ }, [defaultActiveTab, resolvedTabs]);
596
+ const tabsItems = useMemo2(() => {
597
+ return resolvedTabs.map((tab) => {
598
+ const isActive = tab.value === activeTabValue;
599
+ return {
600
+ value: tab.value,
601
+ label: tab.label,
602
+ icon: tab.iconName ? /* @__PURE__ */ jsx2(
603
+ Icon,
604
+ {
605
+ name: tab.iconName,
606
+ size: "medium",
607
+ color: isActive ? "var(--agg-color-primary)" : "var(--agg-color-foreground)"
608
+ }
609
+ ) : void 0,
610
+ disabled: tab.disabled
611
+ };
612
+ });
613
+ }, [activeTabValue, resolvedTabs]);
614
+ const activeTab = useMemo2(() => {
615
+ return resolvedTabs.find((tab) => tab.value === activeTabValue);
616
+ }, [activeTabValue, resolvedTabs]);
617
+ const resolvedSectionItems = useMemo2(() => {
618
+ var _a, _b, _c, _d;
619
+ if (activeTabValue === ALL_CATEGORIES_TAB_VALUE) {
620
+ return resolvedEventSectionItems;
621
+ }
622
+ const maxItemsPerRow = (_b = (_a = resolvedEventSectionItems[0]) == null ? void 0 : _a.maxItemsPerRow) != null ? _b : 3;
623
+ const firstSectionLimit = (_c = resolvedEventSectionItems[0]) == null ? void 0 : _c.limit;
624
+ const limit = firstSectionLimit && Number.isFinite(firstSectionLimit) ? Math.max(9, Math.floor(firstSectionLimit)) : 9;
625
+ return [
626
+ {
627
+ id: `${activeTabValue}-markets`,
628
+ title: (_d = activeTab == null ? void 0 : activeTab.label) != null ? _d : activeTabValue,
629
+ maxItemsPerRow,
630
+ limit,
631
+ maxVisibleItems: void 0,
632
+ search: activeTab == null ? void 0 : activeTab.search,
633
+ categoryIds: activeTab == null ? void 0 : activeTab.categoryIds
634
+ }
635
+ ];
636
+ }, [activeTab, activeTabValue, resolvedEventSectionItems]);
637
+ const handleTabChange = (value) => {
638
+ setActiveTabValue(value);
639
+ onTabChange == null ? void 0 : onTabChange(value);
640
+ };
641
+ return /* @__PURE__ */ jsxs2("section", { className: cn("flex w-full flex-col", classNames == null ? void 0 : classNames.root), children: [
642
+ /* @__PURE__ */ jsx2(Header, { searchProps: {} }),
643
+ !selectedEvent && !isShowingAllResults ? /* @__PURE__ */ jsx2(
644
+ "header",
645
+ {
646
+ className: cn(
647
+ "w-full bg-agg-secondary border-b border-agg-separator",
648
+ classNames == null ? void 0 : classNames.header
649
+ ),
650
+ children: /* @__PURE__ */ jsx2(
651
+ Tabs,
652
+ {
653
+ ariaLabel: labels.home.categoryTabsAria,
654
+ variant: "underline",
655
+ className: cn("w-full px-4 md:px-10", classNames == null ? void 0 : classNames.tabs),
656
+ items: tabsItems,
657
+ value: activeTabValue,
658
+ onChange: handleTabChange
659
+ }
660
+ )
661
+ }
662
+ ) : null,
663
+ /* @__PURE__ */ jsx2(
664
+ "main",
665
+ {
666
+ className: cn(
667
+ "flex w-full flex-col gap-4 md:gap-10 px-4 md:px-10 py-4 md:py-8",
668
+ classNames == null ? void 0 : classNames.sections
669
+ ),
670
+ children: selectedEvent ? /* @__PURE__ */ jsx2(EventMarketPage, { eventId: selectedEvent.id }) : isShowingAllResults && debouncedSearchValue ? /* @__PURE__ */ jsx2(
671
+ HomeSearchResults,
672
+ {
673
+ activeTabValue,
674
+ onTabChange: handleTabChange,
675
+ query: debouncedSearchValue,
676
+ tabs: tabsItems,
677
+ resolvedTabs
678
+ }
679
+ ) : resolvedSectionItems.map((eventSectionItem) => {
680
+ var _a, _b;
681
+ return /* @__PURE__ */ jsx2(
682
+ EventList,
683
+ {
684
+ title: eventSectionItem.title,
685
+ maxItemsPerRow: eventSectionItem.maxItemsPerRow,
686
+ limit: eventSectionItem.limit,
687
+ maxVisibleItems: eventSectionItem.maxVisibleItems,
688
+ search: debouncedSearchValue || eventSectionItem.search || (activeTab == null ? void 0 : activeTab.search),
689
+ categoryIds: (_b = eventSectionItem.categoryIds) != null ? _b : activeTab == null ? void 0 : activeTab.categoryIds,
690
+ onClick: (event) => {
691
+ if (!event)
692
+ return;
693
+ onSelectEvent(event);
694
+ }
695
+ },
696
+ (_a = eventSectionItem.id) != null ? _a : eventSectionItem.title
697
+ );
698
+ })
699
+ }
700
+ )
701
+ ] });
702
+ };
703
+ HomePage.displayName = "HomePage";
704
+
607
705
  // src/pages/user-profile/components/balance-display.tsx
608
706
  import { useState as useState3 } from "react";
609
707
 
@@ -1240,7 +1338,7 @@ var UserProfilePage = ({
1240
1338
  UserProfilePage.displayName = "UserProfilePage";
1241
1339
 
1242
1340
  export {
1243
- HomePage,
1244
1341
  EventMarketPage,
1342
+ HomePage,
1245
1343
  UserProfilePage
1246
1344
  };