@agg-build/ui 1.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 (664) hide show
  1. package/README.md +287 -0
  2. package/dist/chunk-2QJXRRYP.mjs +37 -0
  3. package/dist/chunk-6NS7D73S.mjs +8811 -0
  4. package/dist/chunk-75IGOQ4N.mjs +3415 -0
  5. package/dist/chunk-C7T56TJR.mjs +748 -0
  6. package/dist/chunk-CGNDMLQL.mjs +3813 -0
  7. package/dist/chunk-DMKKNK76.mjs +3742 -0
  8. package/dist/chunk-I2WBGEWK.mjs +4512 -0
  9. package/dist/chunk-KHHFHXXD.mjs +1 -0
  10. package/dist/events.d.mts +1 -0
  11. package/dist/events.d.ts +1 -0
  12. package/dist/events.js +11414 -0
  13. package/dist/events.mjs +41 -0
  14. package/dist/index.d.mts +1 -0
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.js +25520 -0
  17. package/dist/index.mjs +978 -0
  18. package/dist/modals.d.mts +1 -0
  19. package/dist/modals.d.ts +1 -0
  20. package/dist/modals.js +7743 -0
  21. package/dist/modals.mjs +36 -0
  22. package/dist/pages.d.mts +1 -0
  23. package/dist/pages.d.ts +1 -0
  24. package/dist/pages.js +20230 -0
  25. package/dist/pages.mjs +33 -0
  26. package/dist/primitives.d.mts +1 -0
  27. package/dist/primitives.d.ts +1 -0
  28. package/dist/primitives.js +8599 -0
  29. package/dist/primitives.mjs +179 -0
  30. package/dist/styles.css +2 -0
  31. package/dist/tailwind.css +2 -0
  32. package/dist/trading.d.mts +1 -0
  33. package/dist/trading.d.ts +1 -0
  34. package/dist/trading.js +8658 -0
  35. package/dist/trading.mjs +49 -0
  36. package/dist/types/auth/connect-button-view/connect-button-view.constants.d.mts +30 -0
  37. package/dist/types/auth/connect-button-view/connect-button-view.constants.d.ts +30 -0
  38. package/dist/types/auth/connect-button-view/connect-button-view.types.d.mts +115 -0
  39. package/dist/types/auth/connect-button-view/connect-button-view.types.d.ts +115 -0
  40. package/dist/types/auth/connect-button-view/index.d.mts +7 -0
  41. package/dist/types/auth/connect-button-view/index.d.ts +7 -0
  42. package/dist/types/auth/index.d.mts +1 -0
  43. package/dist/types/auth/index.d.ts +1 -0
  44. package/dist/types/constants.d.mts +5 -0
  45. package/dist/types/constants.d.ts +5 -0
  46. package/dist/types/deposit/components/DepositQRCode.d.mts +12 -0
  47. package/dist/types/deposit/components/DepositQRCode.d.ts +12 -0
  48. package/dist/types/deposit/deposit-modal.constants.d.mts +10 -0
  49. package/dist/types/deposit/deposit-modal.constants.d.ts +10 -0
  50. package/dist/types/deposit/deposit-modal.types.d.mts +233 -0
  51. package/dist/types/deposit/deposit-modal.types.d.ts +233 -0
  52. package/dist/types/deposit/index.d.mts +22 -0
  53. package/dist/types/deposit/index.d.ts +22 -0
  54. package/dist/types/deposit/steps/card-deposit.d.mts +17 -0
  55. package/dist/types/deposit/steps/card-deposit.d.ts +17 -0
  56. package/dist/types/deposit/steps/card-payment-pending.d.mts +7 -0
  57. package/dist/types/deposit/steps/card-payment-pending.d.ts +7 -0
  58. package/dist/types/deposit/steps/card-provider.d.mts +14 -0
  59. package/dist/types/deposit/steps/card-provider.d.ts +14 -0
  60. package/dist/types/deposit/steps/card-purchase-success.d.mts +7 -0
  61. package/dist/types/deposit/steps/card-purchase-success.d.ts +7 -0
  62. package/dist/types/deposit/steps/card-widget.d.mts +6 -0
  63. package/dist/types/deposit/steps/card-widget.d.ts +6 -0
  64. package/dist/types/deposit/steps/crypto-transfer.d.mts +19 -0
  65. package/dist/types/deposit/steps/crypto-transfer.d.ts +19 -0
  66. package/dist/types/deposit/steps/deposit-method.d.mts +12 -0
  67. package/dist/types/deposit/steps/deposit-method.d.ts +12 -0
  68. package/dist/types/deposit/steps/venue-selection.d.mts +7 -0
  69. package/dist/types/deposit/steps/venue-selection.d.ts +7 -0
  70. package/dist/types/deposit/steps/wallet-form.d.mts +24 -0
  71. package/dist/types/deposit/steps/wallet-form.d.ts +24 -0
  72. package/dist/types/deposit/steps/wallet-processing.d.mts +7 -0
  73. package/dist/types/deposit/steps/wallet-processing.d.ts +7 -0
  74. package/dist/types/deposit/steps/wallet-success.d.mts +7 -0
  75. package/dist/types/deposit/steps/wallet-success.d.ts +7 -0
  76. package/dist/types/events/index.d.mts +5 -0
  77. package/dist/types/events/index.d.ts +5 -0
  78. package/dist/types/events/item/event-list-item.constants.d.mts +1 -0
  79. package/dist/types/events/item/event-list-item.constants.d.ts +1 -0
  80. package/dist/types/events/item/event-list-item.types.d.mts +71 -0
  81. package/dist/types/events/item/event-list-item.types.d.ts +71 -0
  82. package/dist/types/events/item/event-list-item.utils.d.mts +46 -0
  83. package/dist/types/events/item/event-list-item.utils.d.ts +46 -0
  84. package/dist/types/events/item/index.d.mts +6 -0
  85. package/dist/types/events/item/index.d.ts +6 -0
  86. package/dist/types/events/item-details/event-list-item-details-market-selector.d.mts +10 -0
  87. package/dist/types/events/item-details/event-list-item-details-market-selector.d.ts +10 -0
  88. package/dist/types/events/item-details/event-list-item-details.constants.d.mts +3 -0
  89. package/dist/types/events/item-details/event-list-item-details.constants.d.ts +3 -0
  90. package/dist/types/events/item-details/event-list-item-details.types.d.mts +116 -0
  91. package/dist/types/events/item-details/event-list-item-details.types.d.ts +116 -0
  92. package/dist/types/events/item-details/event-list-item-details.utils.d.mts +75 -0
  93. package/dist/types/events/item-details/event-list-item-details.utils.d.ts +75 -0
  94. package/dist/types/events/item-details/index.d.mts +8 -0
  95. package/dist/types/events/item-details/index.d.ts +8 -0
  96. package/dist/types/events/item-details/settlement-summary.d.mts +9 -0
  97. package/dist/types/events/item-details/settlement-summary.d.ts +9 -0
  98. package/dist/types/events/list/event-list-tabs.d.mts +44 -0
  99. package/dist/types/events/list/event-list-tabs.d.ts +44 -0
  100. package/dist/types/events/list/event-list.constants.d.mts +4 -0
  101. package/dist/types/events/list/event-list.constants.d.ts +4 -0
  102. package/dist/types/events/list/event-list.types.d.mts +48 -0
  103. package/dist/types/events/list/event-list.types.d.ts +48 -0
  104. package/dist/types/events/list/event-list.utils.d.mts +19 -0
  105. package/dist/types/events/list/event-list.utils.d.ts +19 -0
  106. package/dist/types/events/list/index.d.mts +6 -0
  107. package/dist/types/events/list/index.d.ts +6 -0
  108. package/dist/types/events/market-details/index.d.mts +12 -0
  109. package/dist/types/events/market-details/index.d.ts +12 -0
  110. package/dist/types/events/market-details/market-details-outcome-button.d.mts +13 -0
  111. package/dist/types/events/market-details/market-details-outcome-button.d.ts +13 -0
  112. package/dist/types/events/market-details/market-details.constants.d.mts +9 -0
  113. package/dist/types/events/market-details/market-details.constants.d.ts +9 -0
  114. package/dist/types/events/market-details/market-details.types.d.mts +143 -0
  115. package/dist/types/events/market-details/market-details.types.d.ts +143 -0
  116. package/dist/types/events/market-details/market-details.utils.d.mts +72 -0
  117. package/dist/types/events/market-details/market-details.utils.d.ts +72 -0
  118. package/dist/types/events/market-details/orderbook-aggregation.d.mts +30 -0
  119. package/dist/types/events/market-details/orderbook-aggregation.d.ts +30 -0
  120. package/dist/types/events/orderbook/index.d.mts +11 -0
  121. package/dist/types/events/orderbook/index.d.ts +11 -0
  122. package/dist/types/events/orderbook/orderbook-with-states.d.mts +35 -0
  123. package/dist/types/events/orderbook/orderbook-with-states.d.ts +35 -0
  124. package/dist/types/events/orderbook/orderbook.constants.d.mts +10 -0
  125. package/dist/types/events/orderbook/orderbook.constants.d.ts +10 -0
  126. package/dist/types/events/orderbook/orderbook.types.d.mts +65 -0
  127. package/dist/types/events/orderbook/orderbook.types.d.ts +65 -0
  128. package/dist/types/events/orderbook/orderbook.utils.d.mts +13 -0
  129. package/dist/types/events/orderbook/orderbook.utils.d.ts +13 -0
  130. package/dist/types/events/orderbook/use-center-orderbook-spread.d.mts +13 -0
  131. package/dist/types/events/orderbook/use-center-orderbook-spread.d.ts +13 -0
  132. package/dist/types/events/shared/chart-venue-selection.d.mts +20 -0
  133. package/dist/types/events/shared/chart-venue-selection.d.ts +20 -0
  134. package/dist/types/events/shared/event-trading-state.utils.d.mts +14 -0
  135. package/dist/types/events/shared/event-trading-state.utils.d.ts +14 -0
  136. package/dist/types/events/shared/venue-market-cluster.d.mts +11 -0
  137. package/dist/types/events/shared/venue-market-cluster.d.ts +11 -0
  138. package/dist/types/geo-block-banner/index.d.mts +12 -0
  139. package/dist/types/geo-block-banner/index.d.ts +12 -0
  140. package/dist/types/geo-block-modal/geo-block-modal.types.d.mts +13 -0
  141. package/dist/types/geo-block-modal/geo-block-modal.types.d.ts +13 -0
  142. package/dist/types/geo-block-modal/index.d.mts +6 -0
  143. package/dist/types/geo-block-modal/index.d.ts +6 -0
  144. package/dist/types/index.d.mts +10 -0
  145. package/dist/types/index.d.ts +10 -0
  146. package/dist/types/modals/index.d.mts +6 -0
  147. package/dist/types/modals/index.d.ts +6 -0
  148. package/dist/types/onboarding/index.d.mts +11 -0
  149. package/dist/types/onboarding/index.d.ts +11 -0
  150. package/dist/types/onboarding/onboarding-modal.constants.d.mts +10 -0
  151. package/dist/types/onboarding/onboarding-modal.constants.d.ts +10 -0
  152. package/dist/types/onboarding/onboarding-modal.types.d.mts +76 -0
  153. package/dist/types/onboarding/onboarding-modal.types.d.ts +76 -0
  154. package/dist/types/onboarding/steps/connect-accounts.d.mts +5 -0
  155. package/dist/types/onboarding/steps/connect-accounts.d.ts +5 -0
  156. package/dist/types/onboarding/steps/connect-kalshi-modal.d.mts +5 -0
  157. package/dist/types/onboarding/steps/connect-kalshi-modal.d.ts +5 -0
  158. package/dist/types/onboarding/steps/connect-onchain-modal.d.mts +5 -0
  159. package/dist/types/onboarding/steps/connect-onchain-modal.d.ts +5 -0
  160. package/dist/types/onboarding/steps/how-it-works.d.mts +5 -0
  161. package/dist/types/onboarding/steps/how-it-works.d.ts +5 -0
  162. package/dist/types/onboarding/steps/profile-setup.d.mts +5 -0
  163. package/dist/types/onboarding/steps/profile-setup.d.ts +5 -0
  164. package/dist/types/pages/event-market/event-market.types.d.mts +84 -0
  165. package/dist/types/pages/event-market/event-market.types.d.ts +84 -0
  166. package/dist/types/pages/event-market/event-market.utils.d.mts +14 -0
  167. package/dist/types/pages/event-market/event-market.utils.d.ts +14 -0
  168. package/dist/types/pages/event-market/index.d.mts +8 -0
  169. package/dist/types/pages/event-market/index.d.ts +8 -0
  170. package/dist/types/pages/home/home.constants.d.mts +6 -0
  171. package/dist/types/pages/home/home.constants.d.ts +6 -0
  172. package/dist/types/pages/home/home.types.d.mts +85 -0
  173. package/dist/types/pages/home/home.types.d.ts +85 -0
  174. package/dist/types/pages/home/home.utils.d.mts +7 -0
  175. package/dist/types/pages/home/home.utils.d.ts +7 -0
  176. package/dist/types/pages/home/index.d.mts +9 -0
  177. package/dist/types/pages/home/index.d.ts +9 -0
  178. package/dist/types/pages/home/use-home-page-modals.d.mts +32 -0
  179. package/dist/types/pages/home/use-home-page-modals.d.ts +32 -0
  180. package/dist/types/pages/home/use-scroll-restoration.d.mts +17 -0
  181. package/dist/types/pages/home/use-scroll-restoration.d.ts +17 -0
  182. package/dist/types/pages/index.d.mts +4 -0
  183. package/dist/types/pages/index.d.ts +4 -0
  184. package/dist/types/pages/user-profile/chain-display.d.mts +1 -0
  185. package/dist/types/pages/user-profile/chain-display.d.ts +1 -0
  186. package/dist/types/pages/user-profile/components/activity-row.d.mts +11 -0
  187. package/dist/types/pages/user-profile/components/activity-row.d.ts +11 -0
  188. package/dist/types/pages/user-profile/components/available-balance-card.d.mts +18 -0
  189. package/dist/types/pages/user-profile/components/available-balance-card.d.ts +18 -0
  190. package/dist/types/pages/user-profile/components/balance-display.d.mts +10 -0
  191. package/dist/types/pages/user-profile/components/balance-display.d.ts +10 -0
  192. package/dist/types/pages/user-profile/components/balances-card.d.mts +12 -0
  193. package/dist/types/pages/user-profile/components/balances-card.d.ts +12 -0
  194. package/dist/types/pages/user-profile/components/default-avatar.d.mts +8 -0
  195. package/dist/types/pages/user-profile/components/default-avatar.d.ts +8 -0
  196. package/dist/types/pages/user-profile/components/empty-state.d.mts +10 -0
  197. package/dist/types/pages/user-profile/components/empty-state.d.ts +10 -0
  198. package/dist/types/pages/user-profile/components/open-order-row.d.mts +12 -0
  199. package/dist/types/pages/user-profile/components/open-order-row.d.ts +12 -0
  200. package/dist/types/pages/user-profile/components/position-row.d.mts +15 -0
  201. package/dist/types/pages/user-profile/components/position-row.d.ts +15 -0
  202. package/dist/types/pages/user-profile/components/positions-activity.d.mts +51 -0
  203. package/dist/types/pages/user-profile/components/positions-activity.d.ts +51 -0
  204. package/dist/types/pages/user-profile/components/positions-value-card.d.mts +10 -0
  205. package/dist/types/pages/user-profile/components/positions-value-card.d.ts +10 -0
  206. package/dist/types/pages/user-profile/components/user-info-card.d.mts +15 -0
  207. package/dist/types/pages/user-profile/components/user-info-card.d.ts +15 -0
  208. package/dist/types/pages/user-profile/index.d.mts +10 -0
  209. package/dist/types/pages/user-profile/index.d.ts +10 -0
  210. package/dist/types/pages/user-profile/user-profile.constants.d.mts +9 -0
  211. package/dist/types/pages/user-profile/user-profile.constants.d.ts +9 -0
  212. package/dist/types/pages/user-profile/user-profile.types.d.mts +281 -0
  213. package/dist/types/pages/user-profile/user-profile.types.d.ts +281 -0
  214. package/dist/types/primitives/agg-logo/agg-logo.constants.d.mts +3 -0
  215. package/dist/types/primitives/agg-logo/agg-logo.constants.d.ts +3 -0
  216. package/dist/types/primitives/agg-logo/agg-logo.types.d.mts +2 -0
  217. package/dist/types/primitives/agg-logo/agg-logo.types.d.ts +2 -0
  218. package/dist/types/primitives/agg-logo/agg-logo.utils.d.mts +2 -0
  219. package/dist/types/primitives/agg-logo/agg-logo.utils.d.ts +2 -0
  220. package/dist/types/primitives/agg-logo/index.d.mts +7 -0
  221. package/dist/types/primitives/agg-logo/index.d.ts +7 -0
  222. package/dist/types/primitives/autocomplete-select/autocomplete-select.constants.d.mts +1 -0
  223. package/dist/types/primitives/autocomplete-select/autocomplete-select.constants.d.ts +1 -0
  224. package/dist/types/primitives/autocomplete-select/autocomplete-select.types.d.mts +26 -0
  225. package/dist/types/primitives/autocomplete-select/autocomplete-select.types.d.ts +26 -0
  226. package/dist/types/primitives/autocomplete-select/autocomplete-select.utils.d.mts +7 -0
  227. package/dist/types/primitives/autocomplete-select/autocomplete-select.utils.d.ts +7 -0
  228. package/dist/types/primitives/autocomplete-select/index.d.mts +7 -0
  229. package/dist/types/primitives/autocomplete-select/index.d.ts +7 -0
  230. package/dist/types/primitives/badge/badge.constants.d.mts +4 -0
  231. package/dist/types/primitives/badge/badge.constants.d.ts +4 -0
  232. package/dist/types/primitives/badge/badge.types.d.mts +27 -0
  233. package/dist/types/primitives/badge/badge.types.d.ts +27 -0
  234. package/dist/types/primitives/badge/badge.utils.d.mts +11 -0
  235. package/dist/types/primitives/badge/badge.utils.d.ts +11 -0
  236. package/dist/types/primitives/badge/index.d.mts +8 -0
  237. package/dist/types/primitives/badge/index.d.ts +8 -0
  238. package/dist/types/primitives/button/button.constants.d.mts +6 -0
  239. package/dist/types/primitives/button/button.constants.d.ts +6 -0
  240. package/dist/types/primitives/button/button.types.d.mts +18 -0
  241. package/dist/types/primitives/button/button.types.d.ts +18 -0
  242. package/dist/types/primitives/button/button.utils.d.mts +12 -0
  243. package/dist/types/primitives/button/button.utils.d.ts +12 -0
  244. package/dist/types/primitives/button/index.d.mts +7 -0
  245. package/dist/types/primitives/button/index.d.ts +7 -0
  246. package/dist/types/primitives/card/card.constants.d.mts +4 -0
  247. package/dist/types/primitives/card/card.constants.d.ts +4 -0
  248. package/dist/types/primitives/card/card.types.d.mts +8 -0
  249. package/dist/types/primitives/card/card.types.d.ts +8 -0
  250. package/dist/types/primitives/card/card.utils.d.mts +8 -0
  251. package/dist/types/primitives/card/card.utils.d.ts +8 -0
  252. package/dist/types/primitives/card/index.d.mts +6 -0
  253. package/dist/types/primitives/card/index.d.ts +6 -0
  254. package/dist/types/primitives/chart/chart-type-switch.constants.d.mts +2 -0
  255. package/dist/types/primitives/chart/chart-type-switch.constants.d.ts +2 -0
  256. package/dist/types/primitives/chart/chart-type-switch.d.mts +7 -0
  257. package/dist/types/primitives/chart/chart-type-switch.d.ts +7 -0
  258. package/dist/types/primitives/chart/chart-type-switch.types.d.mts +9 -0
  259. package/dist/types/primitives/chart/chart-type-switch.types.d.ts +9 -0
  260. package/dist/types/primitives/chart/chart-type-switch.utils.d.mts +13 -0
  261. package/dist/types/primitives/chart/chart-type-switch.utils.d.ts +13 -0
  262. package/dist/types/primitives/chart/chart.constants.d.mts +5 -0
  263. package/dist/types/primitives/chart/chart.constants.d.ts +5 -0
  264. package/dist/types/primitives/chart/chart.types.d.mts +59 -0
  265. package/dist/types/primitives/chart/chart.types.d.ts +59 -0
  266. package/dist/types/primitives/chart/chart.utils.d.mts +35 -0
  267. package/dist/types/primitives/chart/chart.utils.d.ts +35 -0
  268. package/dist/types/primitives/chart/index.d.mts +7 -0
  269. package/dist/types/primitives/chart/index.d.ts +7 -0
  270. package/dist/types/primitives/conditional-wrapper.d.mts +11 -0
  271. package/dist/types/primitives/conditional-wrapper.d.ts +11 -0
  272. package/dist/types/primitives/currency-input/currency-input.constants.d.mts +6 -0
  273. package/dist/types/primitives/currency-input/currency-input.constants.d.ts +6 -0
  274. package/dist/types/primitives/currency-input/currency-input.types.d.mts +36 -0
  275. package/dist/types/primitives/currency-input/currency-input.types.d.ts +36 -0
  276. package/dist/types/primitives/currency-input/currency-input.utils.d.mts +10 -0
  277. package/dist/types/primitives/currency-input/currency-input.utils.d.ts +10 -0
  278. package/dist/types/primitives/currency-input/index.d.mts +7 -0
  279. package/dist/types/primitives/currency-input/index.d.ts +7 -0
  280. package/dist/types/primitives/error-boundary/index.d.mts +24 -0
  281. package/dist/types/primitives/error-boundary/index.d.ts +24 -0
  282. package/dist/types/primitives/footer/agg-build-logo.d.mts +16 -0
  283. package/dist/types/primitives/footer/agg-build-logo.d.ts +16 -0
  284. package/dist/types/primitives/footer/footer.constants.d.mts +3 -0
  285. package/dist/types/primitives/footer/footer.constants.d.ts +3 -0
  286. package/dist/types/primitives/footer/footer.types.d.mts +25 -0
  287. package/dist/types/primitives/footer/footer.types.d.ts +25 -0
  288. package/dist/types/primitives/footer/index.d.mts +8 -0
  289. package/dist/types/primitives/footer/index.d.ts +8 -0
  290. package/dist/types/primitives/header/agg-logo.d.mts +2 -0
  291. package/dist/types/primitives/header/agg-logo.d.ts +2 -0
  292. package/dist/types/primitives/header/header.constants.d.mts +2 -0
  293. package/dist/types/primitives/header/header.constants.d.ts +2 -0
  294. package/dist/types/primitives/header/header.types.d.mts +42 -0
  295. package/dist/types/primitives/header/header.types.d.ts +42 -0
  296. package/dist/types/primitives/header/header.utils.d.mts +12 -0
  297. package/dist/types/primitives/header/header.utils.d.ts +12 -0
  298. package/dist/types/primitives/header/index.d.mts +8 -0
  299. package/dist/types/primitives/header/index.d.ts +8 -0
  300. package/dist/types/primitives/icon/icon.constants.d.mts +2 -0
  301. package/dist/types/primitives/icon/icon.constants.d.ts +2 -0
  302. package/dist/types/primitives/icon/icon.types.d.mts +12 -0
  303. package/dist/types/primitives/icon/icon.types.d.ts +12 -0
  304. package/dist/types/primitives/icon/icon.utils.d.mts +3 -0
  305. package/dist/types/primitives/icon/icon.utils.d.ts +3 -0
  306. package/dist/types/primitives/icon/index.d.mts +68 -0
  307. package/dist/types/primitives/icon/index.d.ts +68 -0
  308. package/dist/types/primitives/icon/registry.d.mts +286 -0
  309. package/dist/types/primitives/icon/registry.d.ts +286 -0
  310. package/dist/types/primitives/icon/svg/activity-chart.d.mts +5 -0
  311. package/dist/types/primitives/icon/svg/activity-chart.d.ts +5 -0
  312. package/dist/types/primitives/icon/svg/activity.d.mts +5 -0
  313. package/dist/types/primitives/icon/svg/activity.d.ts +5 -0
  314. package/dist/types/primitives/icon/svg/apple.d.mts +5 -0
  315. package/dist/types/primitives/icon/svg/apple.d.ts +5 -0
  316. package/dist/types/primitives/icon/svg/arbitrum.d.mts +5 -0
  317. package/dist/types/primitives/icon/svg/arbitrum.d.ts +5 -0
  318. package/dist/types/primitives/icon/svg/arrow-right.d.mts +5 -0
  319. package/dist/types/primitives/icon/svg/arrow-right.d.ts +5 -0
  320. package/dist/types/primitives/icon/svg/arrow-trend-up.d.mts +5 -0
  321. package/dist/types/primitives/icon/svg/arrow-trend-up.d.ts +5 -0
  322. package/dist/types/primitives/icon/svg/arrows-to-dot.d.mts +5 -0
  323. package/dist/types/primitives/icon/svg/arrows-to-dot.d.ts +5 -0
  324. package/dist/types/primitives/icon/svg/badge-check-thin.d.mts +5 -0
  325. package/dist/types/primitives/icon/svg/badge-check-thin.d.ts +5 -0
  326. package/dist/types/primitives/icon/svg/bank.d.mts +5 -0
  327. package/dist/types/primitives/icon/svg/bank.d.ts +5 -0
  328. package/dist/types/primitives/icon/svg/base.d.mts +5 -0
  329. package/dist/types/primitives/icon/svg/base.d.ts +5 -0
  330. package/dist/types/primitives/icon/svg/best-prices.d.mts +5 -0
  331. package/dist/types/primitives/icon/svg/best-prices.d.ts +5 -0
  332. package/dist/types/primitives/icon/svg/bnb.d.mts +5 -0
  333. package/dist/types/primitives/icon/svg/bnb.d.ts +5 -0
  334. package/dist/types/primitives/icon/svg/bolt.d.mts +5 -0
  335. package/dist/types/primitives/icon/svg/bolt.d.ts +5 -0
  336. package/dist/types/primitives/icon/svg/chart-candlestick.d.mts +5 -0
  337. package/dist/types/primitives/icon/svg/chart-candlestick.d.ts +5 -0
  338. package/dist/types/primitives/icon/svg/chart-line.d.mts +5 -0
  339. package/dist/types/primitives/icon/svg/chart-line.d.ts +5 -0
  340. package/dist/types/primitives/icon/svg/check-badge.d.mts +5 -0
  341. package/dist/types/primitives/icon/svg/check-badge.d.ts +5 -0
  342. package/dist/types/primitives/icon/svg/check-circle.d.mts +5 -0
  343. package/dist/types/primitives/icon/svg/check-circle.d.ts +5 -0
  344. package/dist/types/primitives/icon/svg/chevron-down-thin.d.mts +6 -0
  345. package/dist/types/primitives/icon/svg/chevron-down-thin.d.ts +6 -0
  346. package/dist/types/primitives/icon/svg/chevron-down.d.mts +5 -0
  347. package/dist/types/primitives/icon/svg/chevron-down.d.ts +5 -0
  348. package/dist/types/primitives/icon/svg/chevron-left.d.mts +5 -0
  349. package/dist/types/primitives/icon/svg/chevron-left.d.ts +5 -0
  350. package/dist/types/primitives/icon/svg/chevron-right.d.mts +5 -0
  351. package/dist/types/primitives/icon/svg/chevron-right.d.ts +5 -0
  352. package/dist/types/primitives/icon/svg/chevron-up.d.mts +5 -0
  353. package/dist/types/primitives/icon/svg/chevron-up.d.ts +5 -0
  354. package/dist/types/primitives/icon/svg/close.d.mts +5 -0
  355. package/dist/types/primitives/icon/svg/close.d.ts +5 -0
  356. package/dist/types/primitives/icon/svg/copy.d.mts +5 -0
  357. package/dist/types/primitives/icon/svg/copy.d.ts +5 -0
  358. package/dist/types/primitives/icon/svg/create-account.d.mts +5 -0
  359. package/dist/types/primitives/icon/svg/create-account.d.ts +5 -0
  360. package/dist/types/primitives/icon/svg/credit-card.d.mts +5 -0
  361. package/dist/types/primitives/icon/svg/credit-card.d.ts +5 -0
  362. package/dist/types/primitives/icon/svg/cross-circle.d.mts +5 -0
  363. package/dist/types/primitives/icon/svg/cross-circle.d.ts +5 -0
  364. package/dist/types/primitives/icon/svg/disconnect.d.mts +5 -0
  365. package/dist/types/primitives/icon/svg/disconnect.d.ts +5 -0
  366. package/dist/types/primitives/icon/svg/discord.d.mts +5 -0
  367. package/dist/types/primitives/icon/svg/discord.d.ts +5 -0
  368. package/dist/types/primitives/icon/svg/document.d.mts +5 -0
  369. package/dist/types/primitives/icon/svg/document.d.ts +5 -0
  370. package/dist/types/primitives/icon/svg/dots-horizontal.d.mts +5 -0
  371. package/dist/types/primitives/icon/svg/dots-horizontal.d.ts +5 -0
  372. package/dist/types/primitives/icon/svg/download.d.mts +5 -0
  373. package/dist/types/primitives/icon/svg/download.d.ts +5 -0
  374. package/dist/types/primitives/icon/svg/email.d.mts +5 -0
  375. package/dist/types/primitives/icon/svg/email.d.ts +5 -0
  376. package/dist/types/primitives/icon/svg/error-filled.d.mts +5 -0
  377. package/dist/types/primitives/icon/svg/error-filled.d.ts +5 -0
  378. package/dist/types/primitives/icon/svg/ethereum.d.mts +5 -0
  379. package/dist/types/primitives/icon/svg/ethereum.d.ts +5 -0
  380. package/dist/types/primitives/icon/svg/external-link.d.mts +5 -0
  381. package/dist/types/primitives/icon/svg/external-link.d.ts +5 -0
  382. package/dist/types/primitives/icon/svg/google.d.mts +5 -0
  383. package/dist/types/primitives/icon/svg/google.d.ts +5 -0
  384. package/dist/types/primitives/icon/svg/image.d.mts +5 -0
  385. package/dist/types/primitives/icon/svg/image.d.ts +5 -0
  386. package/dist/types/primitives/icon/svg/info.d.mts +5 -0
  387. package/dist/types/primitives/icon/svg/info.d.ts +5 -0
  388. package/dist/types/primitives/icon/svg/internet-security.d.mts +5 -0
  389. package/dist/types/primitives/icon/svg/internet-security.d.ts +5 -0
  390. package/dist/types/primitives/icon/svg/link-accounts.d.mts +5 -0
  391. package/dist/types/primitives/icon/svg/link-accounts.d.ts +5 -0
  392. package/dist/types/primitives/icon/svg/paper-plane.d.mts +5 -0
  393. package/dist/types/primitives/icon/svg/paper-plane.d.ts +5 -0
  394. package/dist/types/primitives/icon/svg/pencil.d.mts +5 -0
  395. package/dist/types/primitives/icon/svg/pencil.d.ts +5 -0
  396. package/dist/types/primitives/icon/svg/play-square.d.mts +5 -0
  397. package/dist/types/primitives/icon/svg/play-square.d.ts +5 -0
  398. package/dist/types/primitives/icon/svg/polygon.d.mts +5 -0
  399. package/dist/types/primitives/icon/svg/polygon.d.ts +5 -0
  400. package/dist/types/primitives/icon/svg/profile-about-tab.d.mts +6 -0
  401. package/dist/types/primitives/icon/svg/profile-about-tab.d.ts +6 -0
  402. package/dist/types/primitives/icon/svg/profile-accounts-wallets-tab.d.mts +6 -0
  403. package/dist/types/primitives/icon/svg/profile-accounts-wallets-tab.d.ts +6 -0
  404. package/dist/types/primitives/icon/svg/profile.d.mts +5 -0
  405. package/dist/types/primitives/icon/svg/profile.d.ts +5 -0
  406. package/dist/types/primitives/icon/svg/quotes-warning.d.mts +6 -0
  407. package/dist/types/primitives/icon/svg/quotes-warning.d.ts +6 -0
  408. package/dist/types/primitives/icon/svg/recenter.d.mts +5 -0
  409. package/dist/types/primitives/icon/svg/recenter.d.ts +5 -0
  410. package/dist/types/primitives/icon/svg/revenue-alt.d.mts +5 -0
  411. package/dist/types/primitives/icon/svg/revenue-alt.d.ts +5 -0
  412. package/dist/types/primitives/icon/svg/search.d.mts +5 -0
  413. package/dist/types/primitives/icon/svg/search.d.ts +5 -0
  414. package/dist/types/primitives/icon/svg/shield-trust.d.mts +5 -0
  415. package/dist/types/primitives/icon/svg/shield-trust.d.ts +5 -0
  416. package/dist/types/primitives/icon/svg/solana.d.mts +5 -0
  417. package/dist/types/primitives/icon/svg/solana.d.ts +5 -0
  418. package/dist/types/primitives/icon/svg/sparkles-filled.d.mts +5 -0
  419. package/dist/types/primitives/icon/svg/sparkles-filled.d.ts +5 -0
  420. package/dist/types/primitives/icon/svg/stay-in-control.d.mts +5 -0
  421. package/dist/types/primitives/icon/svg/stay-in-control.d.ts +5 -0
  422. package/dist/types/primitives/icon/svg/success-check.d.mts +5 -0
  423. package/dist/types/primitives/icon/svg/success-check.d.ts +5 -0
  424. package/dist/types/primitives/icon/svg/telegram.d.mts +5 -0
  425. package/dist/types/primitives/icon/svg/telegram.d.ts +5 -0
  426. package/dist/types/primitives/icon/svg/triangle-down.d.mts +5 -0
  427. package/dist/types/primitives/icon/svg/triangle-down.d.ts +5 -0
  428. package/dist/types/primitives/icon/svg/triangle-up-filled.d.mts +5 -0
  429. package/dist/types/primitives/icon/svg/triangle-up-filled.d.ts +5 -0
  430. package/dist/types/primitives/icon/svg/triangle-up.d.mts +5 -0
  431. package/dist/types/primitives/icon/svg/triangle-up.d.ts +5 -0
  432. package/dist/types/primitives/icon/svg/twitter.d.mts +5 -0
  433. package/dist/types/primitives/icon/svg/twitter.d.ts +5 -0
  434. package/dist/types/primitives/icon/svg/upload.d.mts +5 -0
  435. package/dist/types/primitives/icon/svg/upload.d.ts +5 -0
  436. package/dist/types/primitives/icon/svg/usdc.d.mts +5 -0
  437. package/dist/types/primitives/icon/svg/usdc.d.ts +5 -0
  438. package/dist/types/primitives/icon/svg/user-trust.d.mts +5 -0
  439. package/dist/types/primitives/icon/svg/user-trust.d.ts +5 -0
  440. package/dist/types/primitives/icon/svg/wallet-avatar.d.mts +5 -0
  441. package/dist/types/primitives/icon/svg/wallet-avatar.d.ts +5 -0
  442. package/dist/types/primitives/icon/svg/wallet-filled.d.mts +5 -0
  443. package/dist/types/primitives/icon/svg/wallet-filled.d.ts +5 -0
  444. package/dist/types/primitives/icon/svg/wallet.d.mts +5 -0
  445. package/dist/types/primitives/icon/svg/wallet.d.ts +5 -0
  446. package/dist/types/primitives/icon/svg/warning-filled.d.mts +5 -0
  447. package/dist/types/primitives/icon/svg/warning-filled.d.ts +5 -0
  448. package/dist/types/primitives/icon/svg/warning.d.mts +5 -0
  449. package/dist/types/primitives/icon/svg/warning.d.ts +5 -0
  450. package/dist/types/primitives/icon/types.d.mts +6 -0
  451. package/dist/types/primitives/icon/types.d.ts +6 -0
  452. package/dist/types/primitives/index.d.mts +25 -0
  453. package/dist/types/primitives/index.d.ts +25 -0
  454. package/dist/types/primitives/inline-alert/index.d.mts +7 -0
  455. package/dist/types/primitives/inline-alert/index.d.ts +7 -0
  456. package/dist/types/primitives/inline-alert/inline-alert.constants.d.mts +7 -0
  457. package/dist/types/primitives/inline-alert/inline-alert.constants.d.ts +7 -0
  458. package/dist/types/primitives/inline-alert/inline-alert.types.d.mts +24 -0
  459. package/dist/types/primitives/inline-alert/inline-alert.types.d.ts +24 -0
  460. package/dist/types/primitives/inline-alert/inline-alert.utils.d.mts +10 -0
  461. package/dist/types/primitives/inline-alert/inline-alert.utils.d.ts +10 -0
  462. package/dist/types/primitives/loading-icon/index.d.mts +7 -0
  463. package/dist/types/primitives/loading-icon/index.d.ts +7 -0
  464. package/dist/types/primitives/loading-icon/loading-icon.constants.d.mts +11 -0
  465. package/dist/types/primitives/loading-icon/loading-icon.constants.d.ts +11 -0
  466. package/dist/types/primitives/loading-icon/loading-icon.types.d.mts +15 -0
  467. package/dist/types/primitives/loading-icon/loading-icon.types.d.ts +15 -0
  468. package/dist/types/primitives/loading-icon/loading-icon.utils.d.mts +5 -0
  469. package/dist/types/primitives/loading-icon/loading-icon.utils.d.ts +5 -0
  470. package/dist/types/primitives/modal/index.d.mts +11 -0
  471. package/dist/types/primitives/modal/index.d.ts +11 -0
  472. package/dist/types/primitives/modal/modal.constants.d.mts +2 -0
  473. package/dist/types/primitives/modal/modal.constants.d.ts +2 -0
  474. package/dist/types/primitives/modal/modal.types.d.mts +78 -0
  475. package/dist/types/primitives/modal/modal.types.d.ts +78 -0
  476. package/dist/types/primitives/modal/modal.utils.d.mts +8 -0
  477. package/dist/types/primitives/modal/modal.utils.d.ts +8 -0
  478. package/dist/types/primitives/number-value.d.mts +12 -0
  479. package/dist/types/primitives/number-value.d.ts +12 -0
  480. package/dist/types/primitives/remote-image/index.d.mts +7 -0
  481. package/dist/types/primitives/remote-image/index.d.ts +7 -0
  482. package/dist/types/primitives/remote-image/remote-image.constants.d.mts +4 -0
  483. package/dist/types/primitives/remote-image/remote-image.constants.d.ts +4 -0
  484. package/dist/types/primitives/remote-image/remote-image.types.d.mts +28 -0
  485. package/dist/types/primitives/remote-image/remote-image.types.d.ts +28 -0
  486. package/dist/types/primitives/remote-image/remote-image.utils.d.mts +4 -0
  487. package/dist/types/primitives/remote-image/remote-image.utils.d.ts +4 -0
  488. package/dist/types/primitives/search/index.d.mts +7 -0
  489. package/dist/types/primitives/search/index.d.ts +7 -0
  490. package/dist/types/primitives/search/search-empty-icon.d.mts +5 -0
  491. package/dist/types/primitives/search/search-empty-icon.d.ts +5 -0
  492. package/dist/types/primitives/search/search.constants.d.mts +3 -0
  493. package/dist/types/primitives/search/search.constants.d.ts +3 -0
  494. package/dist/types/primitives/search/search.types.d.mts +57 -0
  495. package/dist/types/primitives/search/search.types.d.ts +57 -0
  496. package/dist/types/primitives/search/search.utils.d.mts +4 -0
  497. package/dist/types/primitives/search/search.utils.d.ts +4 -0
  498. package/dist/types/primitives/select/index.d.mts +7 -0
  499. package/dist/types/primitives/select/index.d.ts +7 -0
  500. package/dist/types/primitives/select/select.constants.d.mts +1 -0
  501. package/dist/types/primitives/select/select.constants.d.ts +1 -0
  502. package/dist/types/primitives/select/select.types.d.mts +25 -0
  503. package/dist/types/primitives/select/select.types.d.ts +25 -0
  504. package/dist/types/primitives/select/select.utils.d.mts +9 -0
  505. package/dist/types/primitives/select/select.utils.d.ts +9 -0
  506. package/dist/types/primitives/skeleton/index.d.mts +8 -0
  507. package/dist/types/primitives/skeleton/index.d.ts +8 -0
  508. package/dist/types/primitives/skeleton/skeleton-block.d.mts +8 -0
  509. package/dist/types/primitives/skeleton/skeleton-block.d.ts +8 -0
  510. package/dist/types/primitives/skeleton/skeleton.constants.d.mts +1 -0
  511. package/dist/types/primitives/skeleton/skeleton.constants.d.ts +1 -0
  512. package/dist/types/primitives/skeleton/skeleton.types.d.mts +27 -0
  513. package/dist/types/primitives/skeleton/skeleton.types.d.ts +27 -0
  514. package/dist/types/primitives/skeleton/skeleton.utils.d.mts +3 -0
  515. package/dist/types/primitives/skeleton/skeleton.utils.d.ts +3 -0
  516. package/dist/types/primitives/skeleton/views/event-list-item-details-skeleton-view.d.mts +5 -0
  517. package/dist/types/primitives/skeleton/views/event-list-item-details-skeleton-view.d.ts +5 -0
  518. package/dist/types/primitives/skeleton/views/event-list-item-skeleton-view.d.mts +9 -0
  519. package/dist/types/primitives/skeleton/views/event-list-item-skeleton-view.d.ts +9 -0
  520. package/dist/types/primitives/skeleton/views/event-list-skeleton-view.d.mts +5 -0
  521. package/dist/types/primitives/skeleton/views/event-list-skeleton-view.d.ts +5 -0
  522. package/dist/types/primitives/skeleton/views/market-details-skeleton-view.d.mts +12 -0
  523. package/dist/types/primitives/skeleton/views/market-details-skeleton-view.d.ts +12 -0
  524. package/dist/types/primitives/skeleton/views/place-order-skeleton-view.d.mts +5 -0
  525. package/dist/types/primitives/skeleton/views/place-order-skeleton-view.d.ts +5 -0
  526. package/dist/types/primitives/skeleton/views/search-skeleton-view.d.mts +5 -0
  527. package/dist/types/primitives/skeleton/views/search-skeleton-view.d.ts +5 -0
  528. package/dist/types/primitives/skeleton/views/settlement-skeleton-view.d.mts +5 -0
  529. package/dist/types/primitives/skeleton/views/settlement-skeleton-view.d.ts +5 -0
  530. package/dist/types/primitives/skeleton/views/user-profile-overview-skeleton-view.d.mts +5 -0
  531. package/dist/types/primitives/skeleton/views/user-profile-overview-skeleton-view.d.ts +5 -0
  532. package/dist/types/primitives/skeleton/views/user-profile-positions-activity-skeleton-view.d.mts +5 -0
  533. package/dist/types/primitives/skeleton/views/user-profile-positions-activity-skeleton-view.d.ts +5 -0
  534. package/dist/types/primitives/state-message/index.d.mts +7 -0
  535. package/dist/types/primitives/state-message/index.d.ts +7 -0
  536. package/dist/types/primitives/state-message/state-message.constants.d.mts +1 -0
  537. package/dist/types/primitives/state-message/state-message.constants.d.ts +1 -0
  538. package/dist/types/primitives/state-message/state-message.types.d.mts +24 -0
  539. package/dist/types/primitives/state-message/state-message.types.d.ts +24 -0
  540. package/dist/types/primitives/state-message/state-message.utils.d.mts +4 -0
  541. package/dist/types/primitives/state-message/state-message.utils.d.ts +4 -0
  542. package/dist/types/primitives/switch-button/index.d.mts +7 -0
  543. package/dist/types/primitives/switch-button/index.d.ts +7 -0
  544. package/dist/types/primitives/switch-button/switch-button.constants.d.mts +5 -0
  545. package/dist/types/primitives/switch-button/switch-button.constants.d.ts +5 -0
  546. package/dist/types/primitives/switch-button/switch-button.types.d.mts +19 -0
  547. package/dist/types/primitives/switch-button/switch-button.types.d.ts +19 -0
  548. package/dist/types/primitives/switch-button/switch-button.utils.d.mts +7 -0
  549. package/dist/types/primitives/switch-button/switch-button.utils.d.ts +7 -0
  550. package/dist/types/primitives/tabs/index.d.mts +7 -0
  551. package/dist/types/primitives/tabs/index.d.ts +7 -0
  552. package/dist/types/primitives/tabs/tabs.constants.d.mts +1 -0
  553. package/dist/types/primitives/tabs/tabs.constants.d.ts +1 -0
  554. package/dist/types/primitives/tabs/tabs.types.d.mts +36 -0
  555. package/dist/types/primitives/tabs/tabs.types.d.ts +36 -0
  556. package/dist/types/primitives/tabs/tabs.utils.d.mts +15 -0
  557. package/dist/types/primitives/tabs/tabs.utils.d.ts +15 -0
  558. package/dist/types/primitives/tooltip/index.d.mts +7 -0
  559. package/dist/types/primitives/tooltip/index.d.ts +7 -0
  560. package/dist/types/primitives/tooltip/tooltip.constants.d.mts +3 -0
  561. package/dist/types/primitives/tooltip/tooltip.constants.d.ts +3 -0
  562. package/dist/types/primitives/tooltip/tooltip.types.d.mts +27 -0
  563. package/dist/types/primitives/tooltip/tooltip.types.d.ts +27 -0
  564. package/dist/types/primitives/tooltip/tooltip.utils.d.mts +7 -0
  565. package/dist/types/primitives/tooltip/tooltip.utils.d.ts +7 -0
  566. package/dist/types/primitives/typography/index.d.mts +8 -0
  567. package/dist/types/primitives/typography/index.d.ts +8 -0
  568. package/dist/types/primitives/typography/typography.constants.d.mts +3 -0
  569. package/dist/types/primitives/typography/typography.constants.d.ts +3 -0
  570. package/dist/types/primitives/typography/typography.types.d.mts +12 -0
  571. package/dist/types/primitives/typography/typography.types.d.ts +12 -0
  572. package/dist/types/primitives/typography/typography.utils.d.mts +6 -0
  573. package/dist/types/primitives/typography/typography.utils.d.ts +6 -0
  574. package/dist/types/primitives/venue-logo/index.d.mts +9 -0
  575. package/dist/types/primitives/venue-logo/index.d.ts +9 -0
  576. package/dist/types/primitives/venue-logo/logo-props.d.mts +10 -0
  577. package/dist/types/primitives/venue-logo/logo-props.d.ts +10 -0
  578. package/dist/types/primitives/venue-logo/svg/default-venue.d.mts +2 -0
  579. package/dist/types/primitives/venue-logo/svg/default-venue.d.ts +2 -0
  580. package/dist/types/primitives/venue-logo/svg/logo-hyperliquid.d.mts +5 -0
  581. package/dist/types/primitives/venue-logo/svg/logo-hyperliquid.d.ts +5 -0
  582. package/dist/types/primitives/venue-logo/svg/logo-kalshi.d.mts +5 -0
  583. package/dist/types/primitives/venue-logo/svg/logo-kalshi.d.ts +5 -0
  584. package/dist/types/primitives/venue-logo/svg/logo-limitless.d.mts +5 -0
  585. package/dist/types/primitives/venue-logo/svg/logo-limitless.d.ts +5 -0
  586. package/dist/types/primitives/venue-logo/svg/logo-myriad.d.mts +5 -0
  587. package/dist/types/primitives/venue-logo/svg/logo-myriad.d.ts +5 -0
  588. package/dist/types/primitives/venue-logo/svg/logo-opinion.d.mts +5 -0
  589. package/dist/types/primitives/venue-logo/svg/logo-opinion.d.ts +5 -0
  590. package/dist/types/primitives/venue-logo/svg/logo-polymarket.d.mts +5 -0
  591. package/dist/types/primitives/venue-logo/svg/logo-polymarket.d.ts +5 -0
  592. package/dist/types/primitives/venue-logo/svg/logo-predict.d.mts +5 -0
  593. package/dist/types/primitives/venue-logo/svg/logo-predict.d.ts +5 -0
  594. package/dist/types/primitives/venue-logo/svg/logo-probable.d.mts +5 -0
  595. package/dist/types/primitives/venue-logo/svg/logo-probable.d.ts +5 -0
  596. package/dist/types/primitives/venue-logo/venue-logo.constants.d.mts +17 -0
  597. package/dist/types/primitives/venue-logo/venue-logo.constants.d.ts +17 -0
  598. package/dist/types/primitives/venue-logo/venue-logo.types.d.mts +24 -0
  599. package/dist/types/primitives/venue-logo/venue-logo.types.d.ts +24 -0
  600. package/dist/types/primitives/venue-logo/venue-logo.utils.d.mts +13 -0
  601. package/dist/types/primitives/venue-logo/venue-logo.utils.d.ts +13 -0
  602. package/dist/types/profile/index.d.mts +6 -0
  603. package/dist/types/profile/index.d.ts +6 -0
  604. package/dist/types/profile/profile-modal.constants.d.mts +17 -0
  605. package/dist/types/profile/profile-modal.constants.d.ts +17 -0
  606. package/dist/types/profile/profile-modal.types.d.mts +84 -0
  607. package/dist/types/profile/profile-modal.types.d.ts +84 -0
  608. package/dist/types/profile/tabs/about-tab.d.mts +18 -0
  609. package/dist/types/profile/tabs/about-tab.d.ts +18 -0
  610. package/dist/types/profile/tabs/accounts-wallets-tab.d.mts +33 -0
  611. package/dist/types/profile/tabs/accounts-wallets-tab.d.ts +33 -0
  612. package/dist/types/shared/constants.d.mts +33 -0
  613. package/dist/types/shared/constants.d.ts +33 -0
  614. package/dist/types/shared/deposit-modal-events.d.mts +4 -0
  615. package/dist/types/shared/deposit-modal-events.d.ts +4 -0
  616. package/dist/types/shared/query-error.d.mts +2 -0
  617. package/dist/types/shared/query-error.d.ts +2 -0
  618. package/dist/types/shared/types.d.mts +1 -0
  619. package/dist/types/shared/types.d.ts +1 -0
  620. package/dist/types/shared/utils.d.mts +15 -0
  621. package/dist/types/shared/utils.d.ts +15 -0
  622. package/dist/types/trading/index.d.mts +7 -0
  623. package/dist/types/trading/index.d.ts +7 -0
  624. package/dist/types/trading/place-order/index.d.mts +10 -0
  625. package/dist/types/trading/place-order/index.d.ts +10 -0
  626. package/dist/types/trading/place-order/index.place-order.constants.d.mts +18 -0
  627. package/dist/types/trading/place-order/index.place-order.constants.d.ts +18 -0
  628. package/dist/types/trading/place-order/index.place-order.failure.d.mts +14 -0
  629. package/dist/types/trading/place-order/index.place-order.failure.d.ts +14 -0
  630. package/dist/types/trading/place-order/index.place-order.success.d.mts +12 -0
  631. package/dist/types/trading/place-order/index.place-order.success.d.ts +12 -0
  632. package/dist/types/trading/place-order/index.place-order.types.d.mts +192 -0
  633. package/dist/types/trading/place-order/index.place-order.types.d.ts +192 -0
  634. package/dist/types/trading/place-order/index.place-order.utils.d.mts +100 -0
  635. package/dist/types/trading/place-order/index.place-order.utils.d.ts +100 -0
  636. package/dist/types/trading/settlement/index.d.mts +12 -0
  637. package/dist/types/trading/settlement/index.d.ts +12 -0
  638. package/dist/types/trading/settlement/settlement-details.d.mts +8 -0
  639. package/dist/types/trading/settlement/settlement-details.d.ts +8 -0
  640. package/dist/types/trading/settlement/settlement-details.utils.d.mts +7 -0
  641. package/dist/types/trading/settlement/settlement-details.utils.d.ts +7 -0
  642. package/dist/types/trading/trading-context/index.d.mts +2 -0
  643. package/dist/types/trading/trading-context/index.d.ts +2 -0
  644. package/dist/types/trading/types.d.mts +82 -0
  645. package/dist/types/trading/types.d.ts +82 -0
  646. package/dist/types/trading/use-kalshi-kyc-flow.d.mts +22 -0
  647. package/dist/types/trading/use-kalshi-kyc-flow.d.ts +22 -0
  648. package/dist/types/trading/utils.d.mts +16 -0
  649. package/dist/types/trading/utils.d.ts +16 -0
  650. package/dist/types/withdraw/index.d.mts +6 -0
  651. package/dist/types/withdraw/index.d.ts +6 -0
  652. package/dist/types/withdraw/steps/withdraw-amount.d.mts +17 -0
  653. package/dist/types/withdraw/steps/withdraw-amount.d.ts +17 -0
  654. package/dist/types/withdraw/steps/withdraw-method.d.mts +6 -0
  655. package/dist/types/withdraw/steps/withdraw-method.d.ts +6 -0
  656. package/dist/types/withdraw/steps/withdraw-provider.d.mts +10 -0
  657. package/dist/types/withdraw/steps/withdraw-provider.d.ts +10 -0
  658. package/dist/types/withdraw/steps/withdraw-success.d.mts +7 -0
  659. package/dist/types/withdraw/steps/withdraw-success.d.ts +7 -0
  660. package/dist/types/withdraw/withdraw-modal.constants.d.mts +5 -0
  661. package/dist/types/withdraw/withdraw-modal.constants.d.ts +5 -0
  662. package/dist/types/withdraw/withdraw-modal.types.d.mts +64 -0
  663. package/dist/types/withdraw/withdraw-modal.types.d.ts +64 -0
  664. package/package.json +128 -0
@@ -0,0 +1,4512 @@
1
+ "use client";
2
+ import {
3
+ buildMarketDetailsModel,
4
+ formatProbabilityCents,
5
+ formatProbabilityPercent,
6
+ getTimeWindowByRange,
7
+ resolveHeaderOutcomeItems,
8
+ resolveInitialOutcomeLabel,
9
+ resolveInitialTab,
10
+ resolveMarketChartDisplaySeries,
11
+ resolveMarketChartLiveState,
12
+ resolveMarketChartVenueSeries,
13
+ resolveMarketFromVenueMarkets,
14
+ resolveOtherTabRows,
15
+ resolveOutcomesByVenue,
16
+ resolveSeriesColor,
17
+ resolveTradingStateBadgeClassName,
18
+ resolveTradingStatePresentation,
19
+ resolveUnifiedOrderBookEntries,
20
+ sortOutcomeSelectorOutcomes,
21
+ useEventTradingContext
22
+ } from "./chunk-C7T56TJR.mjs";
23
+ import {
24
+ AutocompleteSelect,
25
+ Badge,
26
+ Button,
27
+ Card,
28
+ DEFAULT_EVENTS_LIMIT,
29
+ Icon,
30
+ LineChart,
31
+ MOBILE_TABS_MEDIA_QUERY,
32
+ MarketDetailsOderbookSkeleton,
33
+ RemoteImage,
34
+ SearchEmptyIcon,
35
+ Skeleton,
36
+ StateMessage,
37
+ SwitchButton,
38
+ Tabs,
39
+ Tooltip,
40
+ Typography,
41
+ VenueLogo,
42
+ WarningIcon,
43
+ __objRest,
44
+ __spreadProps,
45
+ __spreadValues,
46
+ baseCardClassName,
47
+ cn,
48
+ dedupeVenueMarketsById,
49
+ detailsBaseCardClassName,
50
+ filterEventsByTabValue,
51
+ formatCountLabel,
52
+ formatMarketProbabilityPercent,
53
+ formatPriceGapPercent,
54
+ getDefaultEventListTabs,
55
+ getMarketDetailsTabs,
56
+ getMotionClassName,
57
+ isYesLabel,
58
+ mapEventToEventListItemEvent,
59
+ marketDetailsBaseCardClassName,
60
+ marketDetailsDefaultIsOpened,
61
+ normalizeProbability,
62
+ normalizeVenueMarketCluster,
63
+ orderBookRowLimitDefault,
64
+ resolveDisplayVolume,
65
+ resolveEventListItemEvent,
66
+ resolveOutcomeTitle,
67
+ resolveTabVenus,
68
+ resolveYesOutcome,
69
+ selectPrimaryVenueMarket,
70
+ sortMarketsByYesOddsDesc,
71
+ sortOutcomes,
72
+ splitEventsByLifecycle
73
+ } from "./chunk-6NS7D73S.mjs";
74
+
75
+ // src/events/item/index.tsx
76
+ import {
77
+ computePriceGaps,
78
+ optimizedImageUrl,
79
+ sortVenues,
80
+ useLabels,
81
+ useSdkUiConfig,
82
+ useVenueEvent,
83
+ useVenueMarketMidpoints,
84
+ useVenueMarkets
85
+ } from "@agg-build/hooks";
86
+ import { useCallback, useMemo, useState } from "react";
87
+
88
+ // src/shared/query-error.ts
89
+ var getErrorStatus = (error) => {
90
+ if (!error || typeof error !== "object") return null;
91
+ const status = error.status;
92
+ return typeof status === "number" ? status : null;
93
+ };
94
+ var isErrorWithStatus = (error, status) => {
95
+ return getErrorStatus(error) === status;
96
+ };
97
+
98
+ // src/events/item/index.tsx
99
+ import { jsx, jsxs } from "react/jsx-runtime";
100
+ var EventListItemLoadingState = ({
101
+ classNames,
102
+ ariaLabel
103
+ }) => {
104
+ const labels = useLabels();
105
+ return /* @__PURE__ */ jsx(
106
+ Skeleton,
107
+ {
108
+ view: "event-list-item",
109
+ className: classNames == null ? void 0 : classNames.root,
110
+ ariaLabel: ariaLabel != null ? ariaLabel : labels.eventItem.loading
111
+ }
112
+ );
113
+ };
114
+ var EventListItemUnavailableState = ({
115
+ classNames,
116
+ ariaLabel
117
+ }) => {
118
+ const labels = useLabels();
119
+ return /* @__PURE__ */ jsx(
120
+ Card,
121
+ {
122
+ className: cn(
123
+ "group/agg-event-card agg-event-card-unavailable",
124
+ baseCardClassName,
125
+ classNames == null ? void 0 : classNames.root
126
+ ),
127
+ role: "status",
128
+ "aria-label": ariaLabel != null ? ariaLabel : labels.eventItem.unavailableAria,
129
+ children: /* @__PURE__ */ jsxs("div", { className: cn("agg-event-card-header min-h-12 flex flex-col gap-1", classNames == null ? void 0 : classNames.header), children: [
130
+ /* @__PURE__ */ jsx(
131
+ Typography,
132
+ {
133
+ variant: "body-large-strong",
134
+ className: cn("agg-event-title truncate", classNames == null ? void 0 : classNames.title),
135
+ children: labels.eventItem.unavailableTitle
136
+ }
137
+ ),
138
+ /* @__PURE__ */ jsx(Typography, { variant: "body", className: "text-agg-muted-foreground", children: labels.eventItem.unavailableDescription })
139
+ ] })
140
+ }
141
+ );
142
+ };
143
+ var EventListItemNotFoundState = ({
144
+ classNames: _classNames,
145
+ ariaLabel: _ariaLabel
146
+ }) => {
147
+ const labels = useLabels();
148
+ return /* @__PURE__ */ jsx(
149
+ StateMessage,
150
+ {
151
+ title: labels.eventItemDetails.notFoundTitle,
152
+ description: labels.eventItemDetails.notFoundDescription,
153
+ icon: /* @__PURE__ */ jsx(SearchEmptyIcon, {}),
154
+ classNames: { root: "agg-event-card-state min-h-[280px] md:min-h-[320px]" }
155
+ }
156
+ );
157
+ };
158
+ var OUTCOMES_SCROLL_LOAD_THRESHOLD_PX = 16;
159
+ var isNoLabel = (label) => label.trim().toLowerCase() === "no";
160
+ var MARKET_ID_QUERY_PARAM = "marketId";
161
+ var OUTCOME_ID_QUERY_PARAM = "outcomeId";
162
+ var resolveMarketHrefFromEventHref = (eventHref, marketId, outcomeId) => {
163
+ if (!eventHref) return void 0;
164
+ if (typeof window === "undefined") return void 0;
165
+ try {
166
+ const url = new URL(eventHref, window.location.origin);
167
+ url.searchParams.set(MARKET_ID_QUERY_PARAM, marketId);
168
+ url.searchParams.set(OUTCOME_ID_QUERY_PARAM, outcomeId);
169
+ return url.toString();
170
+ } catch (e) {
171
+ return void 0;
172
+ }
173
+ };
174
+ var EventListItemContent = ({
175
+ event,
176
+ classNames,
177
+ arbitrageByOutcomeId,
178
+ onEventClick,
179
+ onMarketClick,
180
+ getMarketHref,
181
+ href,
182
+ ariaLabel
183
+ }) => {
184
+ const config = useSdkUiConfig();
185
+ const labels = useLabels();
186
+ const allVenueMarkets = useMemo(() => {
187
+ return dedupeVenueMarketsById(event.venueMarkets);
188
+ }, [event.venueMarkets]);
189
+ const _primaryVenueMarket = useMemo(() => {
190
+ return selectPrimaryVenueMarket(allVenueMarkets);
191
+ }, [allVenueMarkets]);
192
+ const resolvedTitle = event.title;
193
+ const resolvedImage = event.image;
194
+ const visibleVenueLogos = useMemo(() => {
195
+ var _a;
196
+ return sortVenues(Array.from(new Set(((_a = event.venues) != null ? _a : []).map((venue) => venue))));
197
+ }, [event.venues]);
198
+ const resolvedMarketCount = typeof event.marketCount === "number" && Number.isFinite(event.marketCount) ? Math.max(0, Math.floor(event.marketCount)) : allVenueMarkets.length;
199
+ const resolvedVenueCount = typeof event.venueCount === "number" && Number.isFinite(event.venueCount) ? Math.max(0, Math.floor(event.venueCount)) : visibleVenueLogos.length;
200
+ const [isLazyMarketsQueryEnabled, setIsLazyMarketsQueryEnabled] = useState(false);
201
+ const shouldEnableLazyMarketLoading = useMemo(() => {
202
+ if (allVenueMarkets.length <= 1) return false;
203
+ if (!event.id) return false;
204
+ const hasExplicitMarketCount = typeof event.marketCount === "number" && Number.isFinite(event.marketCount);
205
+ if (!hasExplicitMarketCount) return true;
206
+ return resolvedMarketCount > allVenueMarkets.length;
207
+ }, [allVenueMarkets.length, event.id, event.marketCount, resolvedMarketCount]);
208
+ const {
209
+ markets: lazyLoadedMarkets,
210
+ fetchNextPage: fetchNextLazyMarketsPage,
211
+ hasNextPage: hasNextLazyMarketsPage,
212
+ isLoading: isLoadingLazyMarkets,
213
+ isFetchingNextPage: isFetchingNextLazyMarketsPage
214
+ } = useVenueMarkets({
215
+ venueEventId: event.id,
216
+ enabled: shouldEnableLazyMarketLoading && isLazyMarketsQueryEnabled,
217
+ sortBy: "yesPrice",
218
+ sortDir: "desc"
219
+ });
220
+ const resolvedOutcomeMarkets = useMemo(() => {
221
+ if (!isLazyMarketsQueryEnabled || lazyLoadedMarkets.length === 0) return allVenueMarkets;
222
+ return dedupeVenueMarketsById([...allVenueMarkets, ...lazyLoadedMarkets]);
223
+ }, [allVenueMarkets, isLazyMarketsQueryEnabled, lazyLoadedMarkets]);
224
+ const midpointVenueMarketIds = useMemo(() => {
225
+ var _a;
226
+ const ids = [];
227
+ for (const market of resolvedOutcomeMarkets) {
228
+ ids.push(market.id);
229
+ for (const sibling of (_a = market.matchedVenueMarkets) != null ? _a : []) {
230
+ ids.push(sibling.id);
231
+ }
232
+ }
233
+ return [...new Set(ids)];
234
+ }, [resolvedOutcomeMarkets]);
235
+ const {
236
+ midpointsByVenueMarketId,
237
+ isLoading: isLoadingMidpoints,
238
+ isFetching: isFetchingMidpoints
239
+ } = useVenueMarketMidpoints({
240
+ venueMarketIds: midpointVenueMarketIds,
241
+ enabled: midpointVenueMarketIds.length > 0
242
+ });
243
+ const gapsByVenueMarketId = useMemo(
244
+ () => computePriceGaps({
245
+ markets: resolvedOutcomeMarkets,
246
+ midpointsByVenueMarketId
247
+ }),
248
+ [resolvedOutcomeMarkets, midpointsByVenueMarketId]
249
+ );
250
+ const isMidpointQueryInFlight = isLoadingMidpoints || isFetchingMidpoints;
251
+ const resolveMarketMidpoint = useCallback(
252
+ (marketId) => {
253
+ return normalizeProbability(midpointsByVenueMarketId.get(marketId));
254
+ },
255
+ [midpointsByVenueMarketId]
256
+ );
257
+ const shouldRenderLoadingOutcomeRow = shouldEnableLazyMarketLoading && isLazyMarketsQueryEnabled && (isLoadingLazyMarkets || isFetchingNextLazyMarketsPage);
258
+ const resolvedVolume = resolveDisplayVolume(event.volume, allVenueMarkets);
259
+ const volumeLabel = typeof resolvedVolume === "number" ? `${config.formatting.formatCompactCurrency(resolvedVolume)} ${labels.eventItem.volumeSuffix}` : "";
260
+ const shouldUseNativeLinkNavigation = (eventToHandle) => {
261
+ return eventToHandle.metaKey || eventToHandle.ctrlKey || eventToHandle.shiftKey || eventToHandle.altKey || eventToHandle.button === 1;
262
+ };
263
+ const handleClick = (eventToHandle) => {
264
+ if (!eventToHandle) {
265
+ onEventClick == null ? void 0 : onEventClick(event);
266
+ return;
267
+ }
268
+ if (!href) {
269
+ onEventClick == null ? void 0 : onEventClick(event);
270
+ return;
271
+ }
272
+ if (shouldUseNativeLinkNavigation(eventToHandle)) {
273
+ return;
274
+ }
275
+ if (!onEventClick) {
276
+ return;
277
+ }
278
+ eventToHandle.preventDefault();
279
+ eventToHandle.stopPropagation();
280
+ onEventClick(event);
281
+ };
282
+ const handleOutcomeBadgeClick = (eventToHandle, market, outcome, marketHref) => {
283
+ eventToHandle.preventDefault();
284
+ eventToHandle.stopPropagation();
285
+ if (marketHref && shouldUseNativeLinkNavigation(eventToHandle)) {
286
+ window.open(marketHref, "_blank", "noopener,noreferrer");
287
+ return;
288
+ }
289
+ if (onMarketClick) {
290
+ onMarketClick(event, market, outcome);
291
+ return;
292
+ }
293
+ if (marketHref) {
294
+ window.location.assign(marketHref);
295
+ }
296
+ };
297
+ const handleKeyDown = (eventToHandle) => {
298
+ if (href) {
299
+ if ((eventToHandle == null ? void 0 : eventToHandle.key) === " ") {
300
+ eventToHandle == null ? void 0 : eventToHandle.preventDefault();
301
+ eventToHandle.currentTarget.click();
302
+ }
303
+ return;
304
+ }
305
+ if (!onEventClick) return;
306
+ if ((eventToHandle == null ? void 0 : eventToHandle.key) === "Enter" || (eventToHandle == null ? void 0 : eventToHandle.key) === " ") {
307
+ eventToHandle == null ? void 0 : eventToHandle.preventDefault();
308
+ onEventClick == null ? void 0 : onEventClick(event);
309
+ }
310
+ };
311
+ const handleOutcomesScroll = useCallback(
312
+ (eventToHandle) => {
313
+ if (!shouldEnableLazyMarketLoading) return;
314
+ const element = eventToHandle.currentTarget;
315
+ const distanceToBottom = element.scrollHeight - element.scrollTop - element.clientHeight;
316
+ if (distanceToBottom > OUTCOMES_SCROLL_LOAD_THRESHOLD_PX) return;
317
+ if (!isLazyMarketsQueryEnabled) {
318
+ setIsLazyMarketsQueryEnabled(true);
319
+ return;
320
+ }
321
+ if (!hasNextLazyMarketsPage) return;
322
+ if (isLoadingLazyMarkets || isFetchingNextLazyMarketsPage) return;
323
+ void fetchNextLazyMarketsPage();
324
+ },
325
+ [
326
+ fetchNextLazyMarketsPage,
327
+ hasNextLazyMarketsPage,
328
+ isFetchingNextLazyMarketsPage,
329
+ isLazyMarketsQueryEnabled,
330
+ isLoadingLazyMarkets,
331
+ shouldEnableLazyMarketLoading
332
+ ]
333
+ );
334
+ const renderArbitrage = (value) => {
335
+ if (value == null) return null;
336
+ if (Math.abs(value) < config.market.arbitrageThreshold) return null;
337
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-1", "text-agg-success"), children: [
338
+ /* @__PURE__ */ jsx(Typography, { variant: "label-strong", className: "text-agg-success", children: config.formatting.formatPercent(value) }),
339
+ /* @__PURE__ */ jsx(
340
+ Icon,
341
+ {
342
+ name: "triangle-up",
343
+ size: "small",
344
+ title: labels.eventItem.arbitrage,
345
+ className: "size-2!"
346
+ }
347
+ )
348
+ ] });
349
+ };
350
+ const _renderPriceGapPill = (value) => {
351
+ const formattedPriceGap = formatPriceGapPercent(value);
352
+ if (!formattedPriceGap) return null;
353
+ return /* @__PURE__ */ jsxs(
354
+ "div",
355
+ {
356
+ className: cn(
357
+ "agg-price-gap-pill",
358
+ "inline-flex shrink-0 items-center gap-1 rounded-agg-sm border border-agg-success/50 px-2 py-0.5",
359
+ "bg-agg-success/10"
360
+ ),
361
+ children: [
362
+ /* @__PURE__ */ jsx(Typography, { variant: "overline", className: "text-agg-success", children: formattedPriceGap }),
363
+ /* @__PURE__ */ jsx(Typography, { variant: "overline", className: "text-agg-success uppercase", children: labels.eventItem.priceGap })
364
+ ]
365
+ }
366
+ );
367
+ };
368
+ const renderOutcomePriceBadge = (probability, venue, shouldRenderLoadingSkeleton, market, outcome) => {
369
+ var _a;
370
+ if (shouldRenderLoadingSkeleton) {
371
+ return /* @__PURE__ */ jsx(
372
+ "div",
373
+ {
374
+ "aria-hidden": "true",
375
+ className: cn(
376
+ "agg-outcome-price-loading bg-agg-separator animate-pulse h-8 w-[100px] rounded-agg-full"
377
+ )
378
+ }
379
+ );
380
+ }
381
+ if (typeof probability !== "number") return null;
382
+ const marketHref = (_a = getMarketHref == null ? void 0 : getMarketHref(event, market, outcome)) != null ? _a : resolveMarketHrefFromEventHref(href, market.id, outcome.id);
383
+ const isInteractive = Boolean(onMarketClick || marketHref);
384
+ return /* @__PURE__ */ jsx(
385
+ Badge,
386
+ {
387
+ text: formatMarketProbabilityPercent(probability, config.formatting.formatPercent),
388
+ prefix: /* @__PURE__ */ jsx(VenueLogo, { venue, size: "small" }),
389
+ size: "small",
390
+ classNames: {
391
+ root: cn(
392
+ "agg-outcome-price",
393
+ "h-8 min-w-25 justify-center px-4 text-agg-base leading-agg-6",
394
+ isInteractive && "cursor-pointer",
395
+ classNames == null ? void 0 : classNames.badge
396
+ ),
397
+ text: "text-agg-foreground"
398
+ },
399
+ onClick: isInteractive ? (eventToHandle) => {
400
+ handleOutcomeBadgeClick(eventToHandle, market, outcome, marketHref);
401
+ } : void 0,
402
+ onAuxClick: isInteractive ? (eventToHandle) => {
403
+ handleOutcomeBadgeClick(eventToHandle, market, outcome, marketHref);
404
+ } : void 0
405
+ }
406
+ );
407
+ };
408
+ return /* @__PURE__ */ jsxs(
409
+ Card,
410
+ {
411
+ className: cn(
412
+ "group/agg-event-card min-w-60 md:min-w-90",
413
+ baseCardClassName,
414
+ (onEventClick || href) && "cursor-pointer",
415
+ classNames == null ? void 0 : classNames.root
416
+ ),
417
+ role: !href && onEventClick ? "button" : void 0,
418
+ tabIndex: !href && onEventClick ? 0 : void 0,
419
+ href,
420
+ onClick: handleClick,
421
+ onKeyDown: handleKeyDown,
422
+ "aria-label": ariaLabel != null ? ariaLabel : resolvedTitle,
423
+ withGradient: true,
424
+ children: [
425
+ /* @__PURE__ */ jsxs(
426
+ "div",
427
+ {
428
+ className: cn("agg-event-card-header min-h-12 flex items-center gap-3", classNames == null ? void 0 : classNames.header),
429
+ children: [
430
+ /* @__PURE__ */ jsx(
431
+ RemoteImage,
432
+ {
433
+ src: optimizedImageUrl(resolvedImage, 40),
434
+ alt: "",
435
+ className: cn("agg-event-image h-10 w-10 rounded-agg-lg object-cover")
436
+ }
437
+ ),
438
+ /* @__PURE__ */ jsx(
439
+ Typography,
440
+ {
441
+ variant: "body-strong",
442
+ className: cn(
443
+ "agg-event-title",
444
+ "min-w-0 text-agg-base font-agg-bold leading-agg-6 ",
445
+ "truncate text-wrap wrap-break-word line-clamp-2",
446
+ classNames == null ? void 0 : classNames.title
447
+ ),
448
+ children: resolvedTitle
449
+ }
450
+ )
451
+ ]
452
+ }
453
+ ),
454
+ /* @__PURE__ */ jsxs(
455
+ "div",
456
+ {
457
+ className: cn(
458
+ "agg-outcomes flex flex-col gap-3 max-h-20 overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
459
+ classNames == null ? void 0 : classNames.outcomes
460
+ ),
461
+ onScroll: handleOutcomesScroll,
462
+ children: [
463
+ resolvedOutcomeMarkets.length === 1 ? sortOutcomes(resolvedOutcomeMarkets[0].venueMarketOutcomes).map((outcome) => {
464
+ const market = resolvedOutcomeMarkets[0];
465
+ const marketMidpoint = resolveMarketMidpoint(market.id);
466
+ const hasYesOutcome = market.venueMarketOutcomes.some(
467
+ (item) => isYesLabel(item.label)
468
+ );
469
+ const hasNoOutcome = market.venueMarketOutcomes.some((item) => isNoLabel(item.label));
470
+ const shouldUseMidpoint = hasYesOutcome && hasNoOutcome;
471
+ const probability = (() => {
472
+ if (!shouldUseMidpoint) {
473
+ return normalizeProbability(outcome.price);
474
+ }
475
+ if (marketMidpoint == null) {
476
+ if (isMidpointQueryInFlight) return void 0;
477
+ return normalizeProbability(outcome.price);
478
+ }
479
+ if (isYesLabel(outcome.label)) {
480
+ return marketMidpoint;
481
+ }
482
+ if (isNoLabel(outcome.label)) {
483
+ return normalizeProbability(1 - marketMidpoint);
484
+ }
485
+ return normalizeProbability(outcome.price);
486
+ })();
487
+ const shouldRenderMidpointSkeleton = shouldUseMidpoint && marketMidpoint == null && isMidpointQueryInFlight;
488
+ const arbitragePercent = arbitrageByOutcomeId == null ? void 0 : arbitrageByOutcomeId[outcome.id];
489
+ const _priceGapPct = gapsByVenueMarketId.get(market.id);
490
+ return /* @__PURE__ */ jsxs(
491
+ "div",
492
+ {
493
+ className: cn(
494
+ "agg-outcome-row",
495
+ "flex flex-row gap-3 w-full items-center justify-between",
496
+ classNames == null ? void 0 : classNames.outcomeRow
497
+ ),
498
+ children: [
499
+ /* @__PURE__ */ jsx("div", { className: "agg-outcome-label-row flex min-w-0 flex-row items-center justify-start gap-2", children: /* @__PURE__ */ jsx(
500
+ Typography,
501
+ {
502
+ variant: "body",
503
+ className: "agg-outcome-label min-w-0 truncate text-agg-sm leading-agg-5 md:text-agg-base md:leading-agg-6",
504
+ children: resolveOutcomeTitle(outcome)
505
+ }
506
+ ) }),
507
+ /* @__PURE__ */ jsxs("div", { className: "agg-outcome-meta flex flex-row items-center justify-end gap-3", children: [
508
+ renderArbitrage(arbitragePercent),
509
+ renderOutcomePriceBadge(
510
+ probability,
511
+ market.venue,
512
+ shouldRenderMidpointSkeleton,
513
+ market,
514
+ outcome
515
+ )
516
+ ] })
517
+ ]
518
+ },
519
+ outcome.id
520
+ );
521
+ }) : sortMarketsByYesOddsDesc(resolvedOutcomeMarkets).map((market) => {
522
+ var _a, _b;
523
+ const yesOutcome = resolveYesOutcome(market);
524
+ const displayOutcome = yesOutcome != null ? yesOutcome : (_b = market.venueMarketOutcomes) == null ? void 0 : _b.reduce(
525
+ (acc, o) => o.price > acc.price ? o : acc,
526
+ (_a = market.venueMarketOutcomes) == null ? void 0 : _a[0]
527
+ );
528
+ const marketMidpoint = resolveMarketMidpoint(market.id);
529
+ const probability = marketMidpoint != null ? marketMidpoint : isMidpointQueryInFlight ? void 0 : normalizeProbability(displayOutcome == null ? void 0 : displayOutcome.price);
530
+ const shouldRenderMidpointSkeleton = marketMidpoint == null && isMidpointQueryInFlight;
531
+ const arbitragePercent = arbitrageByOutcomeId == null ? void 0 : arbitrageByOutcomeId[market.id];
532
+ const outcomeTitle = market.question;
533
+ const _priceGapPct = gapsByVenueMarketId.get(market.id);
534
+ return /* @__PURE__ */ jsxs(
535
+ "div",
536
+ {
537
+ className: cn(
538
+ "agg-outcome-row",
539
+ "flex flex-row gap-3 w-full items-center justify-between",
540
+ classNames == null ? void 0 : classNames.outcomeRow
541
+ ),
542
+ children: [
543
+ /* @__PURE__ */ jsx("div", { className: "agg-outcome-label-row flex min-w-0 flex-row items-center justify-start gap-2", children: /* @__PURE__ */ jsx(
544
+ Typography,
545
+ {
546
+ variant: "body",
547
+ className: "agg-outcome-label min-w-0 truncate text-agg-sm leading-agg-5 md:text-agg-base md:leading-agg-6",
548
+ children: outcomeTitle
549
+ }
550
+ ) }),
551
+ /* @__PURE__ */ jsxs("div", { className: "agg-outcome-meta flex flex-row items-center justify-end gap-3", children: [
552
+ renderArbitrage(arbitragePercent),
553
+ renderOutcomePriceBadge(
554
+ probability,
555
+ market.venue,
556
+ shouldRenderMidpointSkeleton,
557
+ market,
558
+ displayOutcome
559
+ )
560
+ ] })
561
+ ]
562
+ },
563
+ `${market.id}`
564
+ );
565
+ }),
566
+ shouldRenderLoadingOutcomeRow ? /* @__PURE__ */ jsxs("div", { className: "agg-outcome-row-loading flex w-full items-center justify-between gap-3", children: [
567
+ /* @__PURE__ */ jsx(
568
+ "div",
569
+ {
570
+ "aria-hidden": "true",
571
+ className: "bg-agg-separator animate-pulse h-5 rounded-agg-sm w-[200px]"
572
+ }
573
+ ),
574
+ /* @__PURE__ */ jsx(
575
+ "div",
576
+ {
577
+ "aria-hidden": "true",
578
+ className: "bg-agg-separator animate-pulse h-9 w-[100px] rounded-agg-full"
579
+ }
580
+ )
581
+ ] }) : null
582
+ ]
583
+ }
584
+ ),
585
+ /* @__PURE__ */ jsxs(
586
+ "div",
587
+ {
588
+ className: cn(
589
+ "agg-event-card-footer",
590
+ "flex items-center justify-between gap-2",
591
+ "text-agg-muted-foreground",
592
+ classNames == null ? void 0 : classNames.footer
593
+ ),
594
+ children: [
595
+ /* @__PURE__ */ jsxs(
596
+ "div",
597
+ {
598
+ className: cn(
599
+ "agg-event-meta flex items-center gap-1 text-agg-sm leading-agg-5 truncate"
600
+ ),
601
+ children: [
602
+ /* @__PURE__ */ jsx("span", { className: "truncate text-agg-muted-foreground", children: formatCountLabel(
603
+ resolvedMarketCount,
604
+ labels.eventItem.marketSingular,
605
+ labels.eventItem.marketPlural
606
+ ) }),
607
+ /* @__PURE__ */ jsx("span", { className: "text-agg-muted-foreground", children: "\xD7" }),
608
+ /* @__PURE__ */ jsx("span", { className: "truncate text-agg-muted-foreground", children: formatCountLabel(
609
+ resolvedVenueCount,
610
+ labels.eventItem.venueSingular,
611
+ labels.eventItem.venuePlural
612
+ ) }),
613
+ visibleVenueLogos.length > 0 ? /* @__PURE__ */ jsx("span", { className: "agg-event-venues flex items-center gap-1 overflow-hidden", children: visibleVenueLogos.map((venue) => /* @__PURE__ */ jsx(
614
+ VenueLogo,
615
+ {
616
+ venue,
617
+ size: "small",
618
+ isMonochromatic: true,
619
+ className: "text-agg-muted-foreground! size-[14px]!"
620
+ },
621
+ venue
622
+ )) }) : null
623
+ ]
624
+ }
625
+ ),
626
+ volumeLabel ? /* @__PURE__ */ jsx(
627
+ Typography,
628
+ {
629
+ variant: "label",
630
+ className: "agg-event-volume max-w-16 sm:max-w-20 min-w-12 sm:min-w-14 truncate whitespace-pre text-agg-sm text-agg-muted-foreground line-clamp-1",
631
+ children: volumeLabel
632
+ }
633
+ ) : null
634
+ ]
635
+ }
636
+ )
637
+ ]
638
+ }
639
+ );
640
+ };
641
+ var EventListItemByEventId = (_a) => {
642
+ var _b = _a, {
643
+ eventId
644
+ } = _b, rest = __objRest(_b, [
645
+ "eventId"
646
+ ]);
647
+ const {
648
+ event: fetchedEvent,
649
+ error,
650
+ isError,
651
+ isLoading
652
+ } = useVenueEvent({
653
+ eventId: eventId != null ? eventId : "",
654
+ enabled: !!eventId
655
+ });
656
+ const resolvedEvent = useMemo(() => {
657
+ return resolveEventListItemEvent(fetchedEvent);
658
+ }, [fetchedEvent]);
659
+ if (!eventId) {
660
+ return /* @__PURE__ */ jsx(EventListItemUnavailableState, { classNames: rest.classNames, ariaLabel: rest.ariaLabel });
661
+ }
662
+ if (isLoading) {
663
+ return /* @__PURE__ */ jsx(EventListItemLoadingState, { classNames: rest.classNames, ariaLabel: rest.ariaLabel });
664
+ }
665
+ if (isErrorWithStatus(error, 404)) {
666
+ return /* @__PURE__ */ jsx(EventListItemNotFoundState, { classNames: rest.classNames, ariaLabel: rest.ariaLabel });
667
+ }
668
+ if (!fetchedEvent && !isError) {
669
+ return /* @__PURE__ */ jsx(EventListItemLoadingState, { classNames: rest.classNames, ariaLabel: rest.ariaLabel });
670
+ }
671
+ if (!resolvedEvent) {
672
+ return /* @__PURE__ */ jsx(EventListItemUnavailableState, { classNames: rest.classNames, ariaLabel: rest.ariaLabel });
673
+ }
674
+ return /* @__PURE__ */ jsx(EventListItemContent, __spreadValues({ event: resolvedEvent }, rest));
675
+ };
676
+ var EventListItem = (props) => {
677
+ if (props.isLoading) {
678
+ return /* @__PURE__ */ jsx(EventListItemLoadingState, { classNames: props.classNames, ariaLabel: props.ariaLabel });
679
+ }
680
+ if ("event" in props && props.event) {
681
+ const _a = props, { event } = _a, rest = __objRest(_a, ["event"]);
682
+ return /* @__PURE__ */ jsx(EventListItemContent, __spreadValues({ event }, rest));
683
+ }
684
+ return /* @__PURE__ */ jsx(EventListItemByEventId, __spreadValues({}, props));
685
+ };
686
+ EventListItem.displayName = "EventListItem";
687
+
688
+ // src/events/market-details/orderbook-aggregation.ts
689
+ import {
690
+ Venue
691
+ } from "@agg-build/hooks";
692
+ var PRICE_PRECISION = 1e6;
693
+ var SIZE_PRECISION = 1e8;
694
+ var POSITIVE_OUTCOME_KEYS = /* @__PURE__ */ new Set(["yes", "y", "true", "up", "buy", "long"]);
695
+ var NEGATIVE_OUTCOME_KEYS = /* @__PURE__ */ new Set(["no", "n", "false", "down", "sell", "short"]);
696
+ var roundTo = (value, precision) => {
697
+ return Math.round(value * precision) / precision;
698
+ };
699
+ var toScaled = (value, precision) => {
700
+ return Math.round(value * precision);
701
+ };
702
+ var fromScaled = (value, precision) => {
703
+ return value / precision;
704
+ };
705
+ var toPriceKey = (price) => {
706
+ return String(toScaled(price, PRICE_PRECISION));
707
+ };
708
+ var normalizeOutcomeLabel = (value) => {
709
+ if (typeof value !== "string") return "";
710
+ return value.trim().toLowerCase().replace(/[_-]+/g, " ").replace(/[^\p{L}\p{N}\s]/gu, " ").replace(/\s+/g, " ");
711
+ };
712
+ var toSemanticOutcomeLabel = (value) => {
713
+ const normalizedValue = normalizeOutcomeLabel(value);
714
+ if (!normalizedValue) return "";
715
+ if (POSITIVE_OUTCOME_KEYS.has(normalizedValue)) return "yes";
716
+ if (NEGATIVE_OUTCOME_KEYS.has(normalizedValue)) return "no";
717
+ return normalizedValue;
718
+ };
719
+ var getOutcomeLabelCandidates = (outcome) => {
720
+ return Array.from(
721
+ new Set(
722
+ [outcome.label, outcome.title].map((value) => typeof value === "string" ? value : "").filter(Boolean)
723
+ )
724
+ );
725
+ };
726
+ var matchesSelectedOutcomeLabel = (outcome, selectedOutcomeLabel) => {
727
+ const normalizedSelectedLabel = normalizeOutcomeLabel(selectedOutcomeLabel);
728
+ const semanticSelectedLabel = toSemanticOutcomeLabel(selectedOutcomeLabel);
729
+ return getOutcomeLabelCandidates(outcome).some((candidate) => {
730
+ const normalizedCandidate = normalizeOutcomeLabel(candidate);
731
+ if (!normalizedCandidate) return false;
732
+ return normalizedCandidate === normalizedSelectedLabel || toSemanticOutcomeLabel(candidate) === semanticSelectedLabel;
733
+ });
734
+ };
735
+ var isValidLevel = (level) => {
736
+ return level != null && Number.isFinite(level.price) && Number.isFinite(level.size) && level.price >= 0 && level.price <= 1 && level.size > 0;
737
+ };
738
+ var buildAttributedVenueLevels = (orderbook, venue, side) => {
739
+ return orderbook[side].flatMap((level) => {
740
+ var _a;
741
+ const attributedSize = (_a = level.venues) == null ? void 0 : _a[venue];
742
+ if (!Number.isFinite(attributedSize) || attributedSize == null || attributedSize <= 0) {
743
+ return [];
744
+ }
745
+ return [
746
+ {
747
+ price: level.price,
748
+ size: attributedSize
749
+ }
750
+ ];
751
+ }).filter(isValidLevel);
752
+ };
753
+ var resolveVenueLevels = (orderbook, venue, side) => {
754
+ var _a, _b, _c;
755
+ const explicitVenueLevels = (_c = (_b = (_a = orderbook.venueOrderbooks[venue]) == null ? void 0 : _a[side]) == null ? void 0 : _b.filter(isValidLevel)) != null ? _c : [];
756
+ const attributedVenueLevels = buildAttributedVenueLevels(orderbook.orderbook, venue, side);
757
+ if (explicitVenueLevels.length === 0) {
758
+ return attributedVenueLevels;
759
+ }
760
+ if (attributedVenueLevels.length === 0) {
761
+ return explicitVenueLevels;
762
+ }
763
+ const mergedByPrice = /* @__PURE__ */ new Map();
764
+ explicitVenueLevels.forEach((level) => {
765
+ mergedByPrice.set(toPriceKey(level.price), level);
766
+ });
767
+ attributedVenueLevels.forEach((level) => {
768
+ mergedByPrice.set(toPriceKey(level.price), level);
769
+ });
770
+ return [...mergedByPrice.values()].sort(
771
+ (left, right) => side === "asks" ? left.price - right.price : right.price - left.price
772
+ );
773
+ };
774
+ var resolvePrimaryVenue = (venueBreakdown, fallbackVenue) => {
775
+ var _a, _b;
776
+ const sortedVenues = Object.entries(venueBreakdown).filter(([, size]) => size > 0).sort((left, right) => {
777
+ if (right[1] !== left[1]) return right[1] - left[1];
778
+ return left[0].localeCompare(right[0]);
779
+ });
780
+ return (_b = (_a = sortedVenues[0]) == null ? void 0 : _a[0]) != null ? _b : fallbackVenue;
781
+ };
782
+ var resolveVenues = (venueBreakdown, fallbackVenue) => {
783
+ const venues = Object.entries(venueBreakdown).filter(([, size]) => size > 0).sort((left, right) => {
784
+ if (right[1] !== left[1]) return right[1] - left[1];
785
+ return left[0].localeCompare(right[0]);
786
+ }).map(([venue]) => venue);
787
+ if (venues.length > 0) return venues;
788
+ return [fallbackVenue];
789
+ };
790
+ var buildRowsFromAccumulator = ({
791
+ side,
792
+ tone,
793
+ levelsByPrice,
794
+ fallbackVenue
795
+ }) => {
796
+ const rows = [...levelsByPrice.values()].map((level) => {
797
+ const size = fromScaled(level.sizeScaled, SIZE_PRECISION);
798
+ const venueBreakdown = Object.fromEntries(
799
+ Object.entries(level.venueBreakdownScaled).filter(([, scaledSize]) => scaledSize > 0).map(([venue2, scaledSize]) => [venue2, fromScaled(scaledSize, SIZE_PRECISION)])
800
+ );
801
+ const resolvedFallbackVenue = fallbackVenue != null ? fallbackVenue : Venue.polymarket;
802
+ const venues = resolveVenues(venueBreakdown, resolvedFallbackVenue);
803
+ const venue = resolvePrimaryVenue(venueBreakdown, resolvedFallbackVenue);
804
+ return {
805
+ id: `${side}-${roundTo(level.price, PRICE_PRECISION)}`,
806
+ venue,
807
+ venues,
808
+ price: roundTo(level.price, PRICE_PRECISION),
809
+ size,
810
+ total: roundTo(level.price * size, SIZE_PRECISION),
811
+ tone,
812
+ barScale: 0,
813
+ venueBreakdown,
814
+ sourceOutcomeIds: [...level.sourceOutcomeIds]
815
+ };
816
+ }).sort((left, right) => side === "asks" ? left.price - right.price : right.price - left.price);
817
+ const maxTotal = rows.reduce((currentMax, row) => Math.max(currentMax, row.total), 0) || 1;
818
+ return rows.map((row) => __spreadProps(__spreadValues({}, row), {
819
+ barScale: row.total / maxTotal
820
+ }));
821
+ };
822
+ var accumulateSideLevels = ({
823
+ side,
824
+ eligibleOutcomes,
825
+ orderbooksByOutcomeId
826
+ }) => {
827
+ const levelsByPrice = /* @__PURE__ */ new Map();
828
+ const includedOutcomeIds = /* @__PURE__ */ new Set();
829
+ const missingOutcomeIds = /* @__PURE__ */ new Set();
830
+ eligibleOutcomes.forEach((eligibleOutcome) => {
831
+ const orderbook = orderbooksByOutcomeId[eligibleOutcome.outcomeId];
832
+ if (!orderbook) {
833
+ missingOutcomeIds.add(eligibleOutcome.outcomeId);
834
+ return;
835
+ }
836
+ const venueLevels = resolveVenueLevels(orderbook, eligibleOutcome.venue, side);
837
+ if (venueLevels.length === 0) {
838
+ return;
839
+ }
840
+ includedOutcomeIds.add(eligibleOutcome.outcomeId);
841
+ venueLevels.forEach((level) => {
842
+ var _a;
843
+ const priceKey = toPriceKey(level.price);
844
+ const scaledSize = toScaled(level.size, SIZE_PRECISION);
845
+ const currentLevel = levelsByPrice.get(priceKey);
846
+ if (currentLevel) {
847
+ currentLevel.sizeScaled += scaledSize;
848
+ currentLevel.venueBreakdownScaled[eligibleOutcome.venue] = ((_a = currentLevel.venueBreakdownScaled[eligibleOutcome.venue]) != null ? _a : 0) + scaledSize;
849
+ currentLevel.sourceOutcomeIds.add(eligibleOutcome.outcomeId);
850
+ return;
851
+ }
852
+ levelsByPrice.set(priceKey, {
853
+ price: level.price,
854
+ sizeScaled: scaledSize,
855
+ venueBreakdownScaled: {
856
+ [eligibleOutcome.venue]: scaledSize
857
+ },
858
+ sourceOutcomeIds: /* @__PURE__ */ new Set([eligibleOutcome.outcomeId])
859
+ });
860
+ });
861
+ });
862
+ return {
863
+ levelsByPrice,
864
+ includedOutcomeIds,
865
+ missingOutcomeIds
866
+ };
867
+ };
868
+ var collectEligibleVenueOutcomes = ({
869
+ venueMarkets,
870
+ selectedOutcomeLabel
871
+ }) => {
872
+ if (!selectedOutcomeLabel) return [];
873
+ const seenOutcomeIds = /* @__PURE__ */ new Set();
874
+ return venueMarkets.flatMap((market) => {
875
+ const matchedOutcome = sortOutcomes(market.venueMarketOutcomes).find(
876
+ (outcome) => matchesSelectedOutcomeLabel(outcome, selectedOutcomeLabel)
877
+ );
878
+ if (!matchedOutcome || seenOutcomeIds.has(matchedOutcome.id)) {
879
+ return [];
880
+ }
881
+ seenOutcomeIds.add(matchedOutcome.id);
882
+ return [
883
+ {
884
+ venue: market.venue,
885
+ market,
886
+ outcome: matchedOutcome,
887
+ outcomeId: matchedOutcome.id,
888
+ semanticLabel: toSemanticOutcomeLabel(selectedOutcomeLabel)
889
+ }
890
+ ];
891
+ });
892
+ };
893
+ var collectEligibleVenueOutcomeIds = ({
894
+ venueMarkets,
895
+ selectedOutcomeLabel
896
+ }) => {
897
+ return collectEligibleVenueOutcomes({ venueMarkets, selectedOutcomeLabel }).map(
898
+ (eligibleOutcome) => eligibleOutcome.outcomeId
899
+ );
900
+ };
901
+ var mergeVenueOutcomeOrderbooks = ({
902
+ eligibleOutcomes,
903
+ orderbooksByOutcomeId
904
+ }) => {
905
+ var _a, _b, _c, _d, _e, _f;
906
+ const bidState = accumulateSideLevels({
907
+ side: "bids",
908
+ eligibleOutcomes,
909
+ orderbooksByOutcomeId
910
+ });
911
+ const askState = accumulateSideLevels({
912
+ side: "asks",
913
+ eligibleOutcomes,
914
+ orderbooksByOutcomeId
915
+ });
916
+ const bidRows = buildRowsFromAccumulator({
917
+ side: "bids",
918
+ tone: "positive",
919
+ levelsByPrice: bidState.levelsByPrice,
920
+ fallbackVenue: (_a = eligibleOutcomes[0]) == null ? void 0 : _a.venue
921
+ });
922
+ const askRows = buildRowsFromAccumulator({
923
+ side: "asks",
924
+ tone: "negative",
925
+ levelsByPrice: askState.levelsByPrice,
926
+ fallbackVenue: (_b = eligibleOutcomes[0]) == null ? void 0 : _b.venue
927
+ });
928
+ const bestBid = (_d = (_c = bidRows[0]) == null ? void 0 : _c.price) != null ? _d : null;
929
+ const bestAsk = (_f = (_e = askRows[0]) == null ? void 0 : _e.price) != null ? _f : null;
930
+ return {
931
+ askRows,
932
+ bidRows,
933
+ midpoint: bestBid != null && bestAsk != null ? roundTo((bestBid + bestAsk) / 2, PRICE_PRECISION) : null,
934
+ spread: bestBid != null && bestAsk != null ? roundTo(bestAsk - bestBid, PRICE_PRECISION) : null,
935
+ hasNoOrderBook: askRows.length === 0 && bidRows.length === 0,
936
+ includedOutcomeIds: [
937
+ .../* @__PURE__ */ new Set([...bidState.includedOutcomeIds, ...askState.includedOutcomeIds])
938
+ ],
939
+ missingOutcomeIds: [.../* @__PURE__ */ new Set([...bidState.missingOutcomeIds, ...askState.missingOutcomeIds])]
940
+ };
941
+ };
942
+
943
+ // src/events/item-details/settlement-summary.tsx
944
+ import { useLabels as useLabels2 } from "@agg-build/hooks";
945
+ import { useCallback as useCallback2, useEffect, useId, useRef, useState as useState2 } from "react";
946
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
947
+ var SettlementSummary = ({
948
+ content,
949
+ onToggle,
950
+ className
951
+ }) => {
952
+ var _a;
953
+ const labels = useLabels2();
954
+ const contentId = useId();
955
+ const containerRef = useRef(null);
956
+ const measureRef = useRef(null);
957
+ const [isExpanded, setIsExpanded] = useState2(false);
958
+ const [canExpand, setCanExpand] = useState2(false);
959
+ const resolvedContent = (_a = content == null ? void 0 : content.trim()) != null ? _a : "";
960
+ const measureOverflow = useCallback2(() => {
961
+ const measureElement = measureRef.current;
962
+ if (!measureElement) return;
963
+ const nextCanExpand = measureElement.scrollWidth > measureElement.clientWidth + 1;
964
+ setCanExpand((currentValue) => {
965
+ if (currentValue === nextCanExpand) return currentValue;
966
+ return nextCanExpand;
967
+ });
968
+ }, []);
969
+ useEffect(() => {
970
+ if (!resolvedContent) {
971
+ setCanExpand(false);
972
+ setIsExpanded(false);
973
+ return;
974
+ }
975
+ setCanExpand(false);
976
+ setIsExpanded(false);
977
+ measureOverflow();
978
+ }, [measureOverflow, resolvedContent]);
979
+ useEffect(() => {
980
+ if (!resolvedContent) return;
981
+ const containerElement = containerRef.current;
982
+ if (!containerElement) return;
983
+ if (typeof ResizeObserver === "function") {
984
+ const resizeObserver = new ResizeObserver(() => {
985
+ measureOverflow();
986
+ });
987
+ resizeObserver.observe(containerElement);
988
+ return () => {
989
+ resizeObserver.disconnect();
990
+ };
991
+ }
992
+ const handleResize = () => {
993
+ measureOverflow();
994
+ };
995
+ window.addEventListener("resize", handleResize);
996
+ return () => {
997
+ window.removeEventListener("resize", handleResize);
998
+ };
999
+ }, [measureOverflow, resolvedContent]);
1000
+ if (!resolvedContent) return null;
1001
+ const shouldShowToggle = canExpand || isExpanded;
1002
+ const toggleLabel = isExpanded ? labels.settlementSummary.showLess : labels.settlementSummary.readFullDetails;
1003
+ const handleToggle = (event) => {
1004
+ event.preventDefault();
1005
+ event.stopPropagation();
1006
+ const nextExpanded = !isExpanded;
1007
+ setIsExpanded(nextExpanded);
1008
+ onToggle == null ? void 0 : onToggle(nextExpanded);
1009
+ };
1010
+ return /* @__PURE__ */ jsxs2("div", { className: cn("agg-settlement-summary flex w-full flex-col gap-2", className), children: [
1011
+ /* @__PURE__ */ jsx2(
1012
+ Typography,
1013
+ {
1014
+ variant: "caption-caps",
1015
+ className: "agg-settlement-summary-label text-agg-muted-foreground",
1016
+ children: labels.settlementSummary.title
1017
+ }
1018
+ ),
1019
+ /* @__PURE__ */ jsxs2("div", { ref: containerRef, className: "relative w-full", children: [
1020
+ /* @__PURE__ */ jsx2(
1021
+ "p",
1022
+ {
1023
+ ref: measureRef,
1024
+ "aria-hidden": "true",
1025
+ className: cn(
1026
+ "agg-settlement-summary-measure",
1027
+ "pointer-events-none absolute inset-x-0 top-0 block overflow-hidden whitespace-nowrap opacity-0",
1028
+ "text-agg-sm leading-agg-5 text-agg-foreground"
1029
+ ),
1030
+ children: resolvedContent
1031
+ }
1032
+ ),
1033
+ isExpanded ? /* @__PURE__ */ jsxs2("div", { className: "agg-settlement-summary-expanded flex flex-col gap-2", children: [
1034
+ /* @__PURE__ */ jsx2(
1035
+ "p",
1036
+ {
1037
+ id: contentId,
1038
+ className: cn(
1039
+ "agg-settlement-summary-text",
1040
+ "text-agg-sm leading-agg-5 text-agg-foreground",
1041
+ "break-words [overflow-wrap:anywhere]"
1042
+ ),
1043
+ children: resolvedContent
1044
+ }
1045
+ ),
1046
+ shouldShowToggle ? /* @__PURE__ */ jsx2(
1047
+ "button",
1048
+ {
1049
+ type: "button",
1050
+ className: cn(
1051
+ "agg-settlement-summary-toggle",
1052
+ "w-fit shrink-0 cursor-pointer whitespace-nowrap text-left text-agg-sm font-agg-bold leading-agg-5 text-agg-primary",
1053
+ "hover:opacity-80",
1054
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary"
1055
+ ),
1056
+ "aria-controls": contentId,
1057
+ "aria-expanded": isExpanded,
1058
+ onClick: handleToggle,
1059
+ children: toggleLabel
1060
+ }
1061
+ ) : null
1062
+ ] }) : /* @__PURE__ */ jsxs2("div", { className: "agg-settlement-summary-collapsed flex w-full items-start gap-3", children: [
1063
+ /* @__PURE__ */ jsx2(
1064
+ "p",
1065
+ {
1066
+ id: contentId,
1067
+ className: cn(
1068
+ "agg-settlement-summary-text",
1069
+ "min-w-0 flex-1 truncate text-agg-sm leading-agg-5 text-agg-foreground"
1070
+ ),
1071
+ children: resolvedContent
1072
+ }
1073
+ ),
1074
+ shouldShowToggle ? /* @__PURE__ */ jsx2(
1075
+ "button",
1076
+ {
1077
+ type: "button",
1078
+ className: cn(
1079
+ "agg-settlement-summary-toggle",
1080
+ "shrink-0 cursor-pointer whitespace-nowrap text-agg-sm font-agg-bold leading-agg-5 text-agg-primary",
1081
+ "hover:opacity-80",
1082
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary"
1083
+ ),
1084
+ "aria-controls": contentId,
1085
+ "aria-expanded": isExpanded,
1086
+ onClick: handleToggle,
1087
+ children: toggleLabel
1088
+ }
1089
+ ) : null
1090
+ ] })
1091
+ ] })
1092
+ ] });
1093
+ };
1094
+ SettlementSummary.displayName = "SettlementSummary";
1095
+
1096
+ // src/events/item-details/index.tsx
1097
+ import {
1098
+ CHART_TIME_RANGES,
1099
+ optimizedImageUrl as optimizedImageUrl2,
1100
+ resolveEventTradingState,
1101
+ timeRangeToInterval,
1102
+ useEventOrderbookData,
1103
+ useLabels as useLabels5,
1104
+ useLiveOutcomePrices,
1105
+ useMarketChart,
1106
+ useMidpoints,
1107
+ useSdkUiConfig as useSdkUiConfig2,
1108
+ useVenueEvent as useVenueEvent2
1109
+ } from "@agg-build/hooks";
1110
+ import { useEffect as useEffect3, useMemo as useMemo4, useRef as useRef3, useState as useState4 } from "react";
1111
+
1112
+ // src/primitives/chart/chart-type-switch.tsx
1113
+ import { useLabels as useLabels3 } from "@agg-build/hooks";
1114
+ import { useMemo as useMemo2 } from "react";
1115
+
1116
+ // src/primitives/chart/chart-type-switch.constants.ts
1117
+ var CHART_TYPE_SWITCH_OPTION_KEYS = ["line", "candlestick"];
1118
+
1119
+ // src/primitives/chart/chart-type-switch.utils.ts
1120
+ var resolveNextChartTypeIndex = ({
1121
+ currentIndex,
1122
+ direction,
1123
+ optionsLength
1124
+ }) => {
1125
+ return (currentIndex + direction + optionsLength) % optionsLength;
1126
+ };
1127
+ var resolveChartTypeOptionAriaLabel = ({
1128
+ chartType,
1129
+ candlestickLabel,
1130
+ lineLabel
1131
+ }) => {
1132
+ return chartType === "line" ? lineLabel : candlestickLabel;
1133
+ };
1134
+ var resolveChartTypeOptionIconName = (chartType) => {
1135
+ return chartType === "line" ? "chart-line" : "chart-candlestick";
1136
+ };
1137
+
1138
+ // src/primitives/chart/chart-type-switch.tsx
1139
+ import { jsx as jsx3 } from "react/jsx-runtime";
1140
+ var ChartTypeSwitch = ({
1141
+ value,
1142
+ onValueChange,
1143
+ className
1144
+ }) => {
1145
+ const labels = useLabels3();
1146
+ const options = useMemo2(
1147
+ () => CHART_TYPE_SWITCH_OPTION_KEYS.map((chartType) => ({
1148
+ value: chartType,
1149
+ iconName: resolveChartTypeOptionIconName(chartType),
1150
+ ariaLabel: resolveChartTypeOptionAriaLabel({
1151
+ chartType,
1152
+ lineLabel: labels.common.lineChartType,
1153
+ candlestickLabel: labels.common.candlestickChartType
1154
+ })
1155
+ })),
1156
+ [labels]
1157
+ );
1158
+ const handleKeyDown = (event, index) => {
1159
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") {
1160
+ return;
1161
+ }
1162
+ event.preventDefault();
1163
+ const direction = event.key === "ArrowRight" ? 1 : -1;
1164
+ const nextIndex = resolveNextChartTypeIndex({
1165
+ currentIndex: index,
1166
+ direction,
1167
+ optionsLength: options.length
1168
+ });
1169
+ const nextOption = options[nextIndex];
1170
+ if (!nextOption || nextOption.value === value) {
1171
+ return;
1172
+ }
1173
+ onValueChange(nextOption.value);
1174
+ };
1175
+ return /* @__PURE__ */ jsx3(
1176
+ "div",
1177
+ {
1178
+ className: cn("agg-chart-type-switch inline-flex items-center gap-2", className),
1179
+ role: "tablist",
1180
+ "aria-label": labels.common.chartTypeSwitchAria,
1181
+ children: options.map((option, index) => {
1182
+ const isActive = option.value === value;
1183
+ return /* @__PURE__ */ jsx3(
1184
+ "button",
1185
+ {
1186
+ type: "button",
1187
+ role: "tab",
1188
+ "aria-selected": isActive,
1189
+ "aria-label": option.ariaLabel,
1190
+ tabIndex: isActive ? 0 : -1,
1191
+ className: cn(
1192
+ "agg-chart-type-trigger",
1193
+ "cursor-pointer hover:text-agg-foreground",
1194
+ "inline-flex size-5 items-center justify-center rounded-agg-sm bg-transparent p-0",
1195
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-background",
1196
+ "transition-colors duration-200 ease-in-out",
1197
+ isActive ? "text-agg-foreground" : "text-agg-muted-foreground"
1198
+ ),
1199
+ onClick: (event) => {
1200
+ event.stopPropagation();
1201
+ event.preventDefault();
1202
+ if (isActive) {
1203
+ return;
1204
+ }
1205
+ onValueChange(option.value);
1206
+ },
1207
+ onKeyDown: (event) => {
1208
+ handleKeyDown(event, index);
1209
+ },
1210
+ children: /* @__PURE__ */ jsx3(Icon, { name: option.iconName, color: "currentColor", className: "h-5 w-5" })
1211
+ },
1212
+ option.value
1213
+ );
1214
+ })
1215
+ }
1216
+ );
1217
+ };
1218
+ ChartTypeSwitch.displayName = "ChartTypeSwitch";
1219
+
1220
+ // src/events/shared/chart-venue-selection.ts
1221
+ import { sortVenues as sortVenues2 } from "@agg-build/hooks";
1222
+ var resolveChartVenueOutcomes = ({
1223
+ eligibleVenueOutcomes,
1224
+ livePrices
1225
+ }) => {
1226
+ if (eligibleVenueOutcomes.length <= 1) return eligibleVenueOutcomes;
1227
+ const sortedEligibleVenueOutcomes = [...eligibleVenueOutcomes].sort((left, right) => {
1228
+ var _a, _b;
1229
+ const leftProbability = normalizeProbability(
1230
+ (_a = livePrices.get(left.outcome.id)) != null ? _a : left.outcome.price
1231
+ );
1232
+ const rightProbability = normalizeProbability(
1233
+ (_b = livePrices.get(right.outcome.id)) != null ? _b : right.outcome.price
1234
+ );
1235
+ const probabilityDifference = (leftProbability != null ? leftProbability : 2) - (rightProbability != null ? rightProbability : 2);
1236
+ if (probabilityDifference !== 0) return probabilityDifference;
1237
+ if (left.venue === right.venue) return 0;
1238
+ const sortedVenues = sortVenues2([left.venue, right.venue]);
1239
+ return sortedVenues[0] === left.venue ? -1 : 1;
1240
+ });
1241
+ const venueOutcomesByVenue = /* @__PURE__ */ new Map();
1242
+ sortedEligibleVenueOutcomes.forEach((eligibleVenueOutcome) => {
1243
+ if (venueOutcomesByVenue.has(eligibleVenueOutcome.venue)) return;
1244
+ venueOutcomesByVenue.set(eligibleVenueOutcome.venue, eligibleVenueOutcome);
1245
+ });
1246
+ return [...venueOutcomesByVenue.values()];
1247
+ };
1248
+ var filterChartVenueOutcomesByRenderableVenues = ({
1249
+ chartData,
1250
+ venueOutcomes
1251
+ }) => {
1252
+ if (!chartData) return venueOutcomes;
1253
+ const renderableVenues = new Set(
1254
+ Object.entries(chartData.venues).filter(([, venueData]) => venueData.candles.length > 0).map(([venue]) => venue)
1255
+ );
1256
+ if (renderableVenues.size === 0) return venueOutcomes;
1257
+ return venueOutcomes.filter((venueOutcome) => renderableVenues.has(venueOutcome.venue));
1258
+ };
1259
+
1260
+ // src/events/item-details/event-list-item-details-market-selector.tsx
1261
+ import { useLabels as useLabels4 } from "@agg-build/hooks";
1262
+ import { useEffect as useEffect2, useLayoutEffect, useMemo as useMemo3, useRef as useRef2, useState as useState3 } from "react";
1263
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1264
+ var MARKET_PILL_MAX_ROWS = 2;
1265
+ var MARKET_PILL_FALLBACK_CONTAINER_WIDTH = 640;
1266
+ var MARKET_PILL_FALLBACK_GAP = 8;
1267
+ var MARKET_PILL_FALLBACK_WIDTH = 72;
1268
+ var MARKET_PILL_FALLBACK_MORE_WIDTH = 88;
1269
+ var MARKET_PILL_MORE_LABEL = "More";
1270
+ var MARKET_DROPDOWN_MAX_VISIBLE_OPTIONS = 6;
1271
+ var MARKET_DROPDOWN_OPTION_HEIGHT = 48;
1272
+ var MARKET_DROPDOWN_MAX_HEIGHT = MARKET_DROPDOWN_MAX_VISIBLE_OPTIONS * MARKET_DROPDOWN_OPTION_HEIGHT;
1273
+ var estimateMarketPillWidth = (label) => {
1274
+ return Math.max(MARKET_PILL_FALLBACK_WIDTH, Math.min(320, Math.ceil(label.length * 7.5 + 32)));
1275
+ };
1276
+ var countWrappedRows = ({
1277
+ containerWidth,
1278
+ gap,
1279
+ itemWidths
1280
+ }) => {
1281
+ if (!Number.isFinite(containerWidth) || containerWidth <= 0) return 1;
1282
+ if (itemWidths.length === 0) return 0;
1283
+ let rowCount = 1;
1284
+ let usedWidth = 0;
1285
+ for (const itemWidth of itemWidths) {
1286
+ const resolvedWidth = Math.max(1, itemWidth);
1287
+ if (usedWidth === 0) {
1288
+ usedWidth = resolvedWidth;
1289
+ continue;
1290
+ }
1291
+ if (usedWidth + gap + resolvedWidth <= containerWidth) {
1292
+ usedWidth += gap + resolvedWidth;
1293
+ continue;
1294
+ }
1295
+ rowCount += 1;
1296
+ usedWidth = resolvedWidth;
1297
+ }
1298
+ return rowCount;
1299
+ };
1300
+ var resolveMarketPillLayout = ({
1301
+ items,
1302
+ containerWidth,
1303
+ moreButtonWidth,
1304
+ itemWidthByValue
1305
+ }) => {
1306
+ if (items.length === 0) {
1307
+ return {
1308
+ visibleItems: [],
1309
+ hiddenItems: []
1310
+ };
1311
+ }
1312
+ if (!Number.isFinite(containerWidth) || containerWidth <= 0) {
1313
+ return {
1314
+ visibleItems: items,
1315
+ hiddenItems: []
1316
+ };
1317
+ }
1318
+ const resolvedMoreButtonWidth = Math.max(1, moreButtonWidth || MARKET_PILL_FALLBACK_MORE_WIDTH);
1319
+ const buildVisibleIndices = (count) => {
1320
+ return new Set(Array.from({ length: count }, (_, index) => index));
1321
+ };
1322
+ const doesLayoutFit = (visibleIndices2) => {
1323
+ const visibleWidths = items.filter((_, index) => visibleIndices2.has(index)).map((item) => {
1324
+ var _a;
1325
+ return Math.max(1, (_a = itemWidthByValue.get(item.value)) != null ? _a : estimateMarketPillWidth(item.label));
1326
+ });
1327
+ if (visibleIndices2.size < items.length) {
1328
+ visibleWidths.push(resolvedMoreButtonWidth);
1329
+ }
1330
+ return countWrappedRows({
1331
+ containerWidth,
1332
+ gap: MARKET_PILL_FALLBACK_GAP,
1333
+ itemWidths: visibleWidths
1334
+ }) <= MARKET_PILL_MAX_ROWS;
1335
+ };
1336
+ let visibleIndices = buildVisibleIndices(items.length);
1337
+ if (!doesLayoutFit(visibleIndices)) {
1338
+ for (let count = items.length - 1; count >= 0; count -= 1) {
1339
+ const nextVisibleIndices = buildVisibleIndices(count);
1340
+ if (doesLayoutFit(nextVisibleIndices)) {
1341
+ visibleIndices = nextVisibleIndices;
1342
+ break;
1343
+ }
1344
+ }
1345
+ }
1346
+ return {
1347
+ visibleItems: items.filter((_, index) => visibleIndices.has(index)),
1348
+ hiddenItems: items.filter((_, index) => !visibleIndices.has(index))
1349
+ };
1350
+ };
1351
+ var EventListItemDetailsMarketSelector = ({
1352
+ className,
1353
+ options,
1354
+ selectedValue,
1355
+ onChange
1356
+ }) => {
1357
+ var _a;
1358
+ const labels = useLabels4();
1359
+ const containerRef = useRef2(null);
1360
+ const measurementContainerRef = useRef2(null);
1361
+ const moreButtonRef = useRef2(null);
1362
+ const dropdownInputRef = useRef2(null);
1363
+ const moreButtonMeasureRef = useRef2(null);
1364
+ const optionMeasureRefs = useRef2({});
1365
+ const [layout, setLayout] = useState3(() => ({
1366
+ visibleItems: options,
1367
+ hiddenItems: []
1368
+ }));
1369
+ const [isDropdownOpen, setIsDropdownOpen] = useState3(false);
1370
+ const [isMobileViewport, setIsMobileViewport] = useState3(false);
1371
+ const [searchValue, setSearchValue] = useState3("");
1372
+ const [dropdownPosition, setDropdownPosition] = useState3({
1373
+ left: 0,
1374
+ top: 0,
1375
+ width: 0
1376
+ });
1377
+ const selectedHiddenOption = useMemo3(() => {
1378
+ var _a2;
1379
+ return (_a2 = layout.hiddenItems.find((option) => option.value === selectedValue)) != null ? _a2 : null;
1380
+ }, [layout.hiddenItems, selectedValue]);
1381
+ const moreButtonLabel = (_a = selectedHiddenOption == null ? void 0 : selectedHiddenOption.label) != null ? _a : MARKET_PILL_MORE_LABEL;
1382
+ const isMoreButtonSelected = selectedHiddenOption != null;
1383
+ const filteredOptions = useMemo3(() => {
1384
+ const normalizedSearchValue = searchValue.trim().toLowerCase();
1385
+ if (!normalizedSearchValue) return options;
1386
+ return options.filter((option) => option.label.toLowerCase().includes(normalizedSearchValue));
1387
+ }, [options, searchValue]);
1388
+ const lastMeasuredKeyRef = useRef2(null);
1389
+ const measureFrameRef = useRef2(null);
1390
+ useLayoutEffect(() => {
1391
+ const measureLayout = () => {
1392
+ var _a2, _b, _c, _d, _e;
1393
+ const measurementContainer = measurementContainerRef.current;
1394
+ const fallbackWidth = ((_a2 = containerRef.current) == null ? void 0 : _a2.clientWidth) || (measurementContainer == null ? void 0 : measurementContainer.clientWidth) || MARKET_PILL_FALLBACK_CONTAINER_WIDTH;
1395
+ const containerWidth = Math.max(1, Math.ceil(fallbackWidth));
1396
+ const itemWidthByValue = /* @__PURE__ */ new Map();
1397
+ for (const option of options) {
1398
+ const element = optionMeasureRefs.current[option.value];
1399
+ const measuredWidth = (element == null ? void 0 : element.offsetWidth) || Math.ceil((_b = element == null ? void 0 : element.getBoundingClientRect().width) != null ? _b : 0) || estimateMarketPillWidth(option.label);
1400
+ itemWidthByValue.set(option.value, Math.max(1, measuredWidth));
1401
+ }
1402
+ const measuredMoreButtonWidth = ((_c = moreButtonMeasureRef.current) == null ? void 0 : _c.offsetWidth) || Math.ceil((_e = (_d = moreButtonMeasureRef.current) == null ? void 0 : _d.getBoundingClientRect().width) != null ? _e : 0) || estimateMarketPillWidth(moreButtonLabel);
1403
+ const measurementKey = [
1404
+ containerWidth,
1405
+ measuredMoreButtonWidth,
1406
+ moreButtonLabel,
1407
+ ...options.map((option) => {
1408
+ var _a3;
1409
+ return `${option.value}:${(_a3 = itemWidthByValue.get(option.value)) != null ? _a3 : 0}`;
1410
+ })
1411
+ ].join("|");
1412
+ if (lastMeasuredKeyRef.current === measurementKey) {
1413
+ return;
1414
+ }
1415
+ lastMeasuredKeyRef.current = measurementKey;
1416
+ const nextLayout = resolveMarketPillLayout({
1417
+ items: options,
1418
+ containerWidth,
1419
+ moreButtonWidth: measuredMoreButtonWidth,
1420
+ itemWidthByValue
1421
+ });
1422
+ setLayout((previousLayout) => {
1423
+ const previousVisible = previousLayout.visibleItems.map((item) => item.value).join("|");
1424
+ const nextVisible = nextLayout.visibleItems.map((item) => item.value).join("|");
1425
+ const previousHidden = previousLayout.hiddenItems.map((item) => item.value).join("|");
1426
+ const nextHidden = nextLayout.hiddenItems.map((item) => item.value).join("|");
1427
+ if (previousVisible === nextVisible && previousHidden === nextHidden) {
1428
+ return previousLayout;
1429
+ }
1430
+ return nextLayout;
1431
+ });
1432
+ };
1433
+ const scheduleMeasureLayout = () => {
1434
+ if (typeof window === "undefined") {
1435
+ measureLayout();
1436
+ return;
1437
+ }
1438
+ if (measureFrameRef.current != null) {
1439
+ window.cancelAnimationFrame(measureFrameRef.current);
1440
+ }
1441
+ measureFrameRef.current = window.requestAnimationFrame(() => {
1442
+ measureFrameRef.current = null;
1443
+ measureLayout();
1444
+ });
1445
+ };
1446
+ measureLayout();
1447
+ if (typeof ResizeObserver === "undefined") {
1448
+ window.addEventListener("resize", scheduleMeasureLayout);
1449
+ return () => {
1450
+ window.removeEventListener("resize", scheduleMeasureLayout);
1451
+ if (measureFrameRef.current != null) {
1452
+ window.cancelAnimationFrame(measureFrameRef.current);
1453
+ measureFrameRef.current = null;
1454
+ }
1455
+ };
1456
+ }
1457
+ const resizeObserver = new ResizeObserver(() => {
1458
+ scheduleMeasureLayout();
1459
+ });
1460
+ if (containerRef.current) {
1461
+ resizeObserver.observe(containerRef.current);
1462
+ }
1463
+ return () => {
1464
+ resizeObserver.disconnect();
1465
+ if (measureFrameRef.current != null) {
1466
+ window.cancelAnimationFrame(measureFrameRef.current);
1467
+ measureFrameRef.current = null;
1468
+ }
1469
+ };
1470
+ }, [moreButtonLabel, options]);
1471
+ useEffect2(() => {
1472
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
1473
+ const mediaQueryList = window.matchMedia(MOBILE_TABS_MEDIA_QUERY);
1474
+ const handleMediaQueryChange = (event) => {
1475
+ setIsMobileViewport(event.matches);
1476
+ };
1477
+ handleMediaQueryChange(mediaQueryList);
1478
+ if (typeof mediaQueryList.addEventListener === "function") {
1479
+ mediaQueryList.addEventListener("change", handleMediaQueryChange);
1480
+ return () => {
1481
+ mediaQueryList.removeEventListener("change", handleMediaQueryChange);
1482
+ };
1483
+ }
1484
+ mediaQueryList.addListener(handleMediaQueryChange);
1485
+ return () => {
1486
+ mediaQueryList.removeListener(handleMediaQueryChange);
1487
+ };
1488
+ }, []);
1489
+ useEffect2(() => {
1490
+ if (!isDropdownOpen) {
1491
+ setSearchValue("");
1492
+ return;
1493
+ }
1494
+ const animationFrameId = window.requestAnimationFrame(() => {
1495
+ var _a2;
1496
+ (_a2 = dropdownInputRef.current) == null ? void 0 : _a2.focus();
1497
+ });
1498
+ return () => {
1499
+ window.cancelAnimationFrame(animationFrameId);
1500
+ };
1501
+ }, [isDropdownOpen]);
1502
+ useLayoutEffect(() => {
1503
+ if (!isDropdownOpen || isMobileViewport) return;
1504
+ const updateDropdownPosition = () => {
1505
+ const containerElement = containerRef.current;
1506
+ const moreButtonElement = moreButtonRef.current;
1507
+ if (!containerElement || !moreButtonElement) return;
1508
+ const containerWidth = Math.max(1, containerElement.clientWidth);
1509
+ const dropdownWidth = Math.min(400, containerWidth);
1510
+ const maxLeft = Math.max(0, containerWidth - dropdownWidth);
1511
+ const nextLeft = Math.min(Math.max(0, moreButtonElement.offsetLeft), maxLeft);
1512
+ setDropdownPosition({
1513
+ left: nextLeft,
1514
+ top: moreButtonElement.offsetTop + moreButtonElement.offsetHeight + 8,
1515
+ width: dropdownWidth
1516
+ });
1517
+ };
1518
+ updateDropdownPosition();
1519
+ if (typeof ResizeObserver === "undefined") {
1520
+ window.addEventListener("resize", updateDropdownPosition);
1521
+ return () => {
1522
+ window.removeEventListener("resize", updateDropdownPosition);
1523
+ };
1524
+ }
1525
+ const resizeObserver = new ResizeObserver(() => {
1526
+ updateDropdownPosition();
1527
+ });
1528
+ if (containerRef.current) {
1529
+ resizeObserver.observe(containerRef.current);
1530
+ }
1531
+ if (moreButtonRef.current) {
1532
+ resizeObserver.observe(moreButtonRef.current);
1533
+ }
1534
+ return () => {
1535
+ resizeObserver.disconnect();
1536
+ };
1537
+ }, [isDropdownOpen, isMobileViewport, moreButtonLabel]);
1538
+ useEffect2(() => {
1539
+ if (!isDropdownOpen) return;
1540
+ const handlePointerDown = (event) => {
1541
+ var _a2;
1542
+ const eventTarget = event.target;
1543
+ if (!(eventTarget instanceof Node)) {
1544
+ return;
1545
+ }
1546
+ if ((_a2 = containerRef.current) == null ? void 0 : _a2.contains(eventTarget)) {
1547
+ return;
1548
+ }
1549
+ setIsDropdownOpen(false);
1550
+ };
1551
+ const handleEscapeKey = (event) => {
1552
+ if (event.key !== "Escape") return;
1553
+ setIsDropdownOpen(false);
1554
+ };
1555
+ document.addEventListener("mousedown", handlePointerDown);
1556
+ document.addEventListener("keydown", handleEscapeKey);
1557
+ return () => {
1558
+ document.removeEventListener("mousedown", handlePointerDown);
1559
+ document.removeEventListener("keydown", handleEscapeKey);
1560
+ };
1561
+ }, [isDropdownOpen]);
1562
+ const handleSelectMarket = (marketId) => {
1563
+ onChange(marketId);
1564
+ setIsDropdownOpen(false);
1565
+ };
1566
+ if (isMobileViewport) {
1567
+ return /* @__PURE__ */ jsx4(
1568
+ AutocompleteSelect,
1569
+ {
1570
+ options,
1571
+ value: selectedValue,
1572
+ onChange,
1573
+ placeholder: labels.eventItemDetails.marketSelectPlaceholder,
1574
+ searchPlaceholder: labels.eventItemDetails.marketSelectSearchPlaceholder,
1575
+ emptyLabel: labels.eventItemDetails.marketSelectEmpty,
1576
+ ariaLabel: labels.eventItemDetails.marketSelectPlaceholder,
1577
+ className: cn("agg-market-select-mobile w-full", className)
1578
+ }
1579
+ );
1580
+ }
1581
+ return /* @__PURE__ */ jsxs3("div", { ref: containerRef, className: cn("agg-market-select relative w-full", className), children: [
1582
+ /* @__PURE__ */ jsxs3("div", { className: "agg-market-pill-list flex flex-wrap gap-2", children: [
1583
+ layout.visibleItems.map((option) => {
1584
+ const isSelected = option.value === selectedValue;
1585
+ return /* @__PURE__ */ jsx4(
1586
+ "button",
1587
+ {
1588
+ type: "button",
1589
+ "aria-pressed": isSelected,
1590
+ className: cn(
1591
+ "agg-market-pill inline-flex min-h-8 items-center justify-center rounded-agg-full border px-4 py-1.5 text-left text-agg-sm leading-agg-5 text-agg-foreground transition-colors",
1592
+ "cursor-pointer hover:bg-agg-tertiary!",
1593
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
1594
+ isSelected ? "border-agg-primary bg-agg-secondary font-agg-bold" : "border-transparent bg-agg-secondary-hover font-agg-normal hover:bg-agg-secondary"
1595
+ ),
1596
+ onClick: (eventToHandle) => {
1597
+ eventToHandle.preventDefault();
1598
+ eventToHandle.stopPropagation();
1599
+ handleSelectMarket(option.value);
1600
+ },
1601
+ children: /* @__PURE__ */ jsx4("span", { className: "truncate", children: option.label })
1602
+ },
1603
+ option.value
1604
+ );
1605
+ }),
1606
+ layout.hiddenItems.length > 0 ? /* @__PURE__ */ jsxs3(
1607
+ "button",
1608
+ {
1609
+ ref: moreButtonRef,
1610
+ type: "button",
1611
+ "aria-pressed": isMoreButtonSelected,
1612
+ "aria-expanded": isDropdownOpen,
1613
+ "aria-haspopup": "listbox",
1614
+ "aria-controls": "agg-event-details-market-dropdown",
1615
+ className: cn(
1616
+ "agg-market-pill-more inline-flex max-w-full min-h-8 items-center justify-center gap-1.5 rounded-agg-full border px-4 py-1.5 text-agg-sm leading-agg-5 text-agg-foreground transition-colors",
1617
+ "cursor-pointer hover:bg-agg-tertiary!",
1618
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
1619
+ isMoreButtonSelected ? "border-agg-primary bg-agg-secondary font-agg-bold" : "border-transparent bg-agg-secondary-hover font-agg-normal hover:bg-agg-secondary"
1620
+ ),
1621
+ onClick: (eventToHandle) => {
1622
+ eventToHandle.preventDefault();
1623
+ eventToHandle.stopPropagation();
1624
+ setIsDropdownOpen((previousValue) => !previousValue);
1625
+ },
1626
+ children: [
1627
+ /* @__PURE__ */ jsx4("span", { className: "truncate", children: moreButtonLabel }),
1628
+ /* @__PURE__ */ jsx4(
1629
+ Icon,
1630
+ {
1631
+ name: isDropdownOpen ? "chevron-up" : "chevron-down",
1632
+ size: "small",
1633
+ color: "currentColor",
1634
+ className: "h-4 w-4",
1635
+ "aria-hidden": "true"
1636
+ }
1637
+ )
1638
+ ]
1639
+ }
1640
+ ) : null
1641
+ ] }),
1642
+ isDropdownOpen ? /* @__PURE__ */ jsxs3(
1643
+ "div",
1644
+ {
1645
+ id: "agg-event-details-market-dropdown",
1646
+ role: "presentation",
1647
+ className: cn(
1648
+ "absolute z-20 overflow-hidden rounded-agg-lg border border-agg-separator bg-agg-secondary shadow-[0px_8px_16px_0px_rgba(0,0,0,0.10)]"
1649
+ ),
1650
+ style: {
1651
+ left: dropdownPosition.left,
1652
+ top: dropdownPosition.top,
1653
+ width: dropdownPosition.width
1654
+ },
1655
+ onClick: (eventToHandle) => {
1656
+ eventToHandle.stopPropagation();
1657
+ },
1658
+ children: [
1659
+ /* @__PURE__ */ jsxs3("div", { className: "border-b border-agg-separator", children: [
1660
+ /* @__PURE__ */ jsx4("label", { className: "sr-only", htmlFor: "agg-event-details-market-search", children: labels.eventItemDetails.marketSelectSearchPlaceholder }),
1661
+ /* @__PURE__ */ jsx4(
1662
+ "input",
1663
+ {
1664
+ ref: dropdownInputRef,
1665
+ id: "agg-event-details-market-search",
1666
+ type: "text",
1667
+ value: searchValue,
1668
+ placeholder: labels.eventItemDetails.marketSelectSearchPlaceholder,
1669
+ "aria-label": labels.eventItemDetails.marketSelectSearchPlaceholder,
1670
+ className: cn(
1671
+ "h-12 w-full bg-transparent px-5 text-agg-sm leading-agg-5 text-agg-foreground placeholder:text-agg-muted-foreground",
1672
+ "focus:outline-none"
1673
+ ),
1674
+ onChange: (eventToHandle) => {
1675
+ setSearchValue(eventToHandle.target.value);
1676
+ },
1677
+ onClick: (eventToHandle) => {
1678
+ eventToHandle.stopPropagation();
1679
+ }
1680
+ }
1681
+ )
1682
+ ] }),
1683
+ /* @__PURE__ */ jsx4(
1684
+ "div",
1685
+ {
1686
+ role: "listbox",
1687
+ "aria-label": labels.eventItemDetails.marketSelectPlaceholder,
1688
+ className: "max-h-[288px] overflow-y-auto",
1689
+ style: { maxHeight: `${MARKET_DROPDOWN_MAX_HEIGHT}px` },
1690
+ children: filteredOptions.length > 0 ? filteredOptions.map((option) => {
1691
+ const isSelected = option.value === selectedValue;
1692
+ return /* @__PURE__ */ jsxs3(
1693
+ "button",
1694
+ {
1695
+ type: "button",
1696
+ role: "option",
1697
+ "aria-selected": isSelected,
1698
+ className: cn(
1699
+ "relative flex w-full items-center px-5 py-3 text-left text-agg-sm leading-agg-5 text-agg-foreground",
1700
+ "cursor-pointer",
1701
+ "focus-visible:bg-agg-secondary-hover focus-visible:outline-none",
1702
+ "hover:bg-agg-secondary-hover",
1703
+ isSelected ? "font-agg-bold" : "font-agg-normal"
1704
+ ),
1705
+ onClick: (eventToHandle) => {
1706
+ eventToHandle.preventDefault();
1707
+ eventToHandle.stopPropagation();
1708
+ handleSelectMarket(option.value);
1709
+ },
1710
+ children: [
1711
+ isSelected ? /* @__PURE__ */ jsx4(
1712
+ "span",
1713
+ {
1714
+ "aria-hidden": "true",
1715
+ className: "absolute bottom-2 left-0 top-2 w-1 bg-agg-primary"
1716
+ }
1717
+ ) : null,
1718
+ /* @__PURE__ */ jsx4("span", { className: "truncate", children: option.label })
1719
+ ]
1720
+ },
1721
+ option.value
1722
+ );
1723
+ }) : /* @__PURE__ */ jsx4("div", { className: "px-5 py-4 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: labels.eventItemDetails.marketSelectEmpty })
1724
+ }
1725
+ )
1726
+ ]
1727
+ }
1728
+ ) : null,
1729
+ /* @__PURE__ */ jsxs3(
1730
+ "div",
1731
+ {
1732
+ ref: measurementContainerRef,
1733
+ "aria-hidden": "true",
1734
+ className: "pointer-events-none invisible absolute inset-x-0 top-0 -z-10 flex flex-wrap gap-2",
1735
+ children: [
1736
+ options.map((option) => {
1737
+ const isSelected = option.value === selectedValue;
1738
+ return /* @__PURE__ */ jsx4(
1739
+ "button",
1740
+ {
1741
+ ref: (element) => {
1742
+ optionMeasureRefs.current[option.value] = element;
1743
+ },
1744
+ type: "button",
1745
+ tabIndex: -1,
1746
+ className: cn(
1747
+ "inline-flex min-h-8 items-center justify-center rounded-agg-full border px-4 py-1.5 text-agg-sm leading-agg-5",
1748
+ isSelected ? "border-agg-primary bg-agg-secondary font-agg-bold" : "border-transparent bg-agg-secondary-hover font-agg-normal"
1749
+ ),
1750
+ children: /* @__PURE__ */ jsx4("span", { className: "truncate", children: option.label })
1751
+ },
1752
+ option.value
1753
+ );
1754
+ }),
1755
+ /* @__PURE__ */ jsxs3(
1756
+ "button",
1757
+ {
1758
+ ref: moreButtonMeasureRef,
1759
+ type: "button",
1760
+ tabIndex: -1,
1761
+ className: "inline-flex min-h-8 items-center justify-center gap-1.5 rounded-agg-full border border-agg-primary bg-agg-secondary px-4 py-1.5 text-agg-sm leading-agg-5 text-agg-foreground",
1762
+ children: [
1763
+ /* @__PURE__ */ jsx4("span", { children: moreButtonLabel }),
1764
+ /* @__PURE__ */ jsx4(
1765
+ Icon,
1766
+ {
1767
+ name: "chevron-down",
1768
+ size: "small",
1769
+ color: "currentColor",
1770
+ className: "h-4 w-4",
1771
+ "aria-hidden": "true"
1772
+ }
1773
+ )
1774
+ ]
1775
+ }
1776
+ )
1777
+ ]
1778
+ }
1779
+ )
1780
+ ] });
1781
+ };
1782
+
1783
+ // src/events/item-details/index.tsx
1784
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1785
+ var resolveEventDetailsSyncKey = (event) => {
1786
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1787
+ const parts = [
1788
+ event.id,
1789
+ (_a = event.status) != null ? _a : "",
1790
+ (_b = event.startDate) != null ? _b : "",
1791
+ (_c = event.endDate) != null ? _c : "",
1792
+ (_d = event.creationDate) != null ? _d : ""
1793
+ ];
1794
+ for (const market of event.venueMarkets) {
1795
+ parts.push(
1796
+ market.id,
1797
+ market.venue,
1798
+ (_e = market.status) != null ? _e : "",
1799
+ market.question,
1800
+ market.volume == null ? "" : String(market.volume),
1801
+ (_f = market.startDate) != null ? _f : "",
1802
+ (_g = market.endDate) != null ? _g : "",
1803
+ (_h = market.resolutionDate) != null ? _h : ""
1804
+ );
1805
+ const matched = market.matchedVenueMarkets;
1806
+ if (matched && matched.length > 0) {
1807
+ parts.push(String(matched.length));
1808
+ for (const matchedVenueMarket of matched) {
1809
+ parts.push(matchedVenueMarket.id);
1810
+ }
1811
+ } else {
1812
+ parts.push("0");
1813
+ }
1814
+ for (const outcome of market.venueMarketOutcomes) {
1815
+ parts.push(
1816
+ outcome.id,
1817
+ outcome.label,
1818
+ String(outcome.price),
1819
+ outcome.winner == null ? "" : outcome.winner ? "1" : "0"
1820
+ );
1821
+ }
1822
+ }
1823
+ return parts.join("|");
1824
+ };
1825
+ var EventListItemDetailsLoadingState = ({
1826
+ classNames,
1827
+ ariaLabel
1828
+ }) => {
1829
+ const labels = useLabels5();
1830
+ return /* @__PURE__ */ jsx5(
1831
+ Skeleton,
1832
+ {
1833
+ view: "event-list-item-details",
1834
+ className: classNames == null ? void 0 : classNames.root,
1835
+ ariaLabel: ariaLabel != null ? ariaLabel : labels.eventItemDetails.loading
1836
+ }
1837
+ );
1838
+ };
1839
+ var EventListItemDetailsUnavailableState = ({
1840
+ classNames,
1841
+ ariaLabel
1842
+ }) => {
1843
+ const labels = useLabels5();
1844
+ return /* @__PURE__ */ jsx5(
1845
+ Card,
1846
+ {
1847
+ className: cn(detailsBaseCardClassName, classNames == null ? void 0 : classNames.root),
1848
+ role: "status",
1849
+ "aria-label": ariaLabel != null ? ariaLabel : labels.eventItemDetails.unavailableAria,
1850
+ children: /* @__PURE__ */ jsxs4("div", { className: cn("flex flex-col gap-1", classNames == null ? void 0 : classNames.header), children: [
1851
+ /* @__PURE__ */ jsx5(Typography, { variant: "body-large-strong", className: cn("truncate", classNames == null ? void 0 : classNames.title), children: labels.eventItemDetails.unavailableTitle }),
1852
+ /* @__PURE__ */ jsx5(Typography, { variant: "body", className: "text-agg-muted-foreground", children: labels.eventItemDetails.unavailableDescription })
1853
+ ] })
1854
+ }
1855
+ );
1856
+ };
1857
+ var EventListItemDetailsNotFoundState = ({
1858
+ classNames: _classNames,
1859
+ ariaLabel: _ariaLabel
1860
+ }) => {
1861
+ const labels = useLabels5();
1862
+ return /* @__PURE__ */ jsx5(
1863
+ StateMessage,
1864
+ {
1865
+ title: labels.eventItemDetails.notFoundTitle,
1866
+ description: labels.eventItemDetails.notFoundDescription,
1867
+ icon: /* @__PURE__ */ jsx5(SearchEmptyIcon, {}),
1868
+ classNames: { root: "min-h-[280px] md:min-h-[320px]" }
1869
+ }
1870
+ );
1871
+ };
1872
+ var EventListItemDetailsGraphSection = ({
1873
+ classNames,
1874
+ selectedChartType,
1875
+ venueMarkets,
1876
+ livePrices,
1877
+ live
1878
+ }) => {
1879
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1880
+ const labels = useLabels5();
1881
+ const tradingContext = useEventTradingContext();
1882
+ const [selectedGraphVenue, setSelectedGraphVenue] = useState4(null);
1883
+ const [chartOutcomeLabel, setChartOutcomeLabel] = useState4(
1884
+ (_c = (_b = (_a = tradingContext == null ? void 0 : tradingContext.selectedOutcome) == null ? void 0 : _a.label) == null ? void 0 : _b.trim()) != null ? _c : null
1885
+ );
1886
+ useEffect3(() => {
1887
+ var _a2, _b2, _c2;
1888
+ if (chartOutcomeLabel != null) return;
1889
+ const label = (_c2 = (_b2 = (_a2 = tradingContext == null ? void 0 : tradingContext.selectedOutcome) == null ? void 0 : _a2.label) == null ? void 0 : _b2.trim()) != null ? _c2 : null;
1890
+ if (label) {
1891
+ setChartOutcomeLabel(label);
1892
+ }
1893
+ }, [chartOutcomeLabel, (_d = tradingContext == null ? void 0 : tradingContext.selectedOutcome) == null ? void 0 : _d.label]);
1894
+ const {
1895
+ chart: { selectedChartTimeRange },
1896
+ formatting: { formatPercent },
1897
+ general: { theme }
1898
+ } = useSdkUiConfig2();
1899
+ const isDarkTheme = theme === "dark";
1900
+ const timeWindow = useMemo4(() => {
1901
+ return getTimeWindowByRange(selectedChartTimeRange);
1902
+ }, [selectedChartTimeRange]);
1903
+ const availableMarkets = useMemo4(() => {
1904
+ if (venueMarkets.length === 0) return [];
1905
+ return normalizeVenueMarketCluster(venueMarkets, tradingContext == null ? void 0 : tradingContext.selectedMarketId);
1906
+ }, [tradingContext == null ? void 0 : tradingContext.selectedMarketId, venueMarkets]);
1907
+ const resolvedChartOutcomeLabel = (_g = chartOutcomeLabel != null ? chartOutcomeLabel : (_f = (_e = tradingContext == null ? void 0 : tradingContext.selectedOutcome) == null ? void 0 : _e.label) == null ? void 0 : _f.trim()) != null ? _g : null;
1908
+ const availableVenueOutcomes = useMemo4(() => {
1909
+ return resolveChartVenueOutcomes({
1910
+ eligibleVenueOutcomes: collectEligibleVenueOutcomes({
1911
+ venueMarkets: availableMarkets,
1912
+ selectedOutcomeLabel: resolvedChartOutcomeLabel
1913
+ }),
1914
+ livePrices
1915
+ });
1916
+ }, [availableMarkets, livePrices, resolvedChartOutcomeLabel]);
1917
+ const chartPrimaryOutcomeId = (_i = (_h = availableVenueOutcomes[0]) == null ? void 0 : _h.outcome.id) != null ? _i : null;
1918
+ const {
1919
+ data: scopedMarketChartData,
1920
+ isLoading: isScopedMarketChartLoading,
1921
+ error: scopedMarketChartError,
1922
+ refetch: refetchScopedMarketChart
1923
+ } = useMarketChart({
1924
+ marketId: chartPrimaryOutcomeId,
1925
+ venueMarketIds: availableVenueOutcomes.map((item) => item.outcome.id),
1926
+ interval: timeRangeToInterval(selectedChartTimeRange),
1927
+ startTs: timeWindow.startTs * 1e3,
1928
+ endTs: timeWindow.endTs * 1e3,
1929
+ enabled: availableVenueOutcomes.length > 0,
1930
+ live
1931
+ });
1932
+ const selectedMarketOutcomes = useMemo4(() => {
1933
+ var _a2, _b2;
1934
+ const selectedMarket = (_b2 = (_a2 = tradingContext == null ? void 0 : tradingContext.selectedMarket) != null ? _a2 : availableMarkets[0]) != null ? _b2 : null;
1935
+ if (!selectedMarket) return [];
1936
+ return sortOutcomeSelectorOutcomes(selectedMarket.venueMarketOutcomes);
1937
+ }, [availableMarkets, tradingContext == null ? void 0 : tradingContext.selectedMarket]);
1938
+ const resolvedVenueChartSeries = useMemo4(() => {
1939
+ return resolveMarketChartVenueSeries({
1940
+ chartData: scopedMarketChartData,
1941
+ transformProbability: (v) => v
1942
+ }).map((seriesItem, index) => ({
1943
+ id: `${seriesItem.venue}-chart`,
1944
+ venue: seriesItem.venue,
1945
+ color: resolveSeriesColor(seriesItem.venue, index, isDarkTheme),
1946
+ points: seriesItem.points,
1947
+ lineWidth: 2,
1948
+ lineStyle: "solid"
1949
+ }));
1950
+ }, [isDarkTheme, scopedMarketChartData]);
1951
+ const chartAvailableVenueOutcomes = useMemo4(() => {
1952
+ return filterChartVenueOutcomesByRenderableVenues({
1953
+ chartData: scopedMarketChartData,
1954
+ venueOutcomes: availableVenueOutcomes
1955
+ });
1956
+ }, [availableVenueOutcomes, scopedMarketChartData]);
1957
+ const defaultCandlestickVenue = useMemo4(() => {
1958
+ var _a2, _b2, _c2, _d2, _e2, _f2;
1959
+ return (_f2 = (_e2 = (_c2 = (_a2 = chartAvailableVenueOutcomes.find((item) => item.venue === (tradingContext == null ? void 0 : tradingContext.selectedVenue))) == null ? void 0 : _a2.venue) != null ? _c2 : (_b2 = chartAvailableVenueOutcomes[0]) == null ? void 0 : _b2.venue) != null ? _e2 : (_d2 = availableVenueOutcomes[0]) == null ? void 0 : _d2.venue) != null ? _f2 : null;
1960
+ }, [availableVenueOutcomes, chartAvailableVenueOutcomes, tradingContext == null ? void 0 : tradingContext.selectedVenue]);
1961
+ const activeGraphVenue = selectedChartType === "candlestick" ? selectedGraphVenue != null ? selectedGraphVenue : defaultCandlestickVenue : selectedGraphVenue;
1962
+ const visibleChartSeries = useMemo4(() => {
1963
+ if (!activeGraphVenue) {
1964
+ return resolvedVenueChartSeries;
1965
+ }
1966
+ return resolvedVenueChartSeries.filter((seriesItem) => seriesItem.venue === activeGraphVenue);
1967
+ }, [activeGraphVenue, resolvedVenueChartSeries]);
1968
+ const chartLiveState = useMemo4(() => {
1969
+ return resolveMarketChartLiveState({
1970
+ chartData: scopedMarketChartData,
1971
+ selectedVenue: activeGraphVenue,
1972
+ transformProbability: (v) => v
1973
+ });
1974
+ }, [activeGraphVenue, scopedMarketChartData]);
1975
+ useEffect3(() => {
1976
+ if (!selectedGraphVenue) return;
1977
+ const hasSelectedGraphVenue = chartAvailableVenueOutcomes.some(
1978
+ (item) => item.venue === selectedGraphVenue
1979
+ );
1980
+ if (!hasSelectedGraphVenue) {
1981
+ setSelectedGraphVenue(null);
1982
+ }
1983
+ }, [chartAvailableVenueOutcomes, selectedGraphVenue]);
1984
+ const handleRetryMarketChart = () => {
1985
+ void refetchScopedMarketChart();
1986
+ };
1987
+ if (scopedMarketChartError) {
1988
+ return /* @__PURE__ */ jsx5("div", { className: cn("agg-chart-region w-full", classNames == null ? void 0 : classNames.chart), children: /* @__PURE__ */ jsx5(
1989
+ StateMessage,
1990
+ {
1991
+ title: labels.eventItemDetails.chartUnavailableTitle,
1992
+ description: labels.eventItemDetails.chartUnavailableDescription,
1993
+ icon: /* @__PURE__ */ jsx5(WarningIcon, {}),
1994
+ onAction: handleRetryMarketChart,
1995
+ classNames: { root: "min-h-[300px] px-5 py-10 md:px-10" }
1996
+ }
1997
+ ) });
1998
+ }
1999
+ return /* @__PURE__ */ jsx5(
2000
+ LineChart,
2001
+ {
2002
+ classNames: { root: cn("agg-chart-region", classNames == null ? void 0 : classNames.chart) },
2003
+ series: visibleChartSeries,
2004
+ height: 300,
2005
+ isLoading: isScopedMarketChartLoading,
2006
+ chartType: selectedChartType,
2007
+ liveCandle: selectedChartType === "candlestick" ? (_j = chartLiveState.liveCandle) != null ? _j : void 0 : void 0,
2008
+ lineValue: chartLiveState.lineValue,
2009
+ showSeriesControls: selectedMarketOutcomes.length > 0,
2010
+ renderSeriesControls: ({ handleSeriesChange }) => {
2011
+ var _a2, _b2, _c2, _d2;
2012
+ return /* @__PURE__ */ jsxs4(
2013
+ "div",
2014
+ {
2015
+ className: cn(
2016
+ "agg-chart-toolbar",
2017
+ "w-full flex flex-col gap-4",
2018
+ "md:flex-row md:items-center md:justify-between",
2019
+ "flex-col-reverse md:flex-col",
2020
+ classNames == null ? void 0 : classNames.summary
2021
+ ),
2022
+ children: [
2023
+ /* @__PURE__ */ jsx5(
2024
+ "div",
2025
+ {
2026
+ className: cn(
2027
+ "agg-market-badges",
2028
+ "flex min-w-0 gap-2 overflow-x-auto pb-1 md:flex-wrap md:overflow-visible md:pb-0",
2029
+ classNames == null ? void 0 : classNames.outcomeBadges
2030
+ ),
2031
+ children: chartAvailableVenueOutcomes.map((item) => {
2032
+ var _a3;
2033
+ const percentage = (_a3 = livePrices.get(item.outcome.id)) != null ? _a3 : item.outcome.price;
2034
+ const text = formatMarketProbabilityPercent(percentage, formatPercent);
2035
+ const seriesId = `${item.venue}-chart`;
2036
+ const isActiveVenue = activeGraphVenue === item.venue;
2037
+ return /* @__PURE__ */ jsx5(
2038
+ "button",
2039
+ {
2040
+ type: "button",
2041
+ "aria-label": `${item.venue} ${text}`,
2042
+ "aria-pressed": isActiveVenue,
2043
+ className: cn(
2044
+ "agg-market-badge",
2045
+ "cursor-pointer",
2046
+ "rounded-agg-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary-hover"
2047
+ ),
2048
+ onClick: (eventToHandle) => {
2049
+ eventToHandle.preventDefault();
2050
+ eventToHandle.stopPropagation();
2051
+ const nextSelectedGraphVenue = selectedChartType === "candlestick" ? item.venue : selectedGraphVenue === item.venue ? null : item.venue;
2052
+ setSelectedGraphVenue(nextSelectedGraphVenue);
2053
+ handleSeriesChange(seriesId);
2054
+ },
2055
+ children: /* @__PURE__ */ jsx5(
2056
+ Badge,
2057
+ {
2058
+ text,
2059
+ size: "large",
2060
+ prefix: /* @__PURE__ */ jsx5(
2061
+ VenueLogo,
2062
+ {
2063
+ venue: item.market.venue,
2064
+ size: "small",
2065
+ title: item.market.venue
2066
+ }
2067
+ ),
2068
+ classNames: {
2069
+ root: cn("h-9 shrink-0 border px-4 text-agg-base leading-agg-6")
2070
+ },
2071
+ isActive: isActiveVenue
2072
+ }
2073
+ )
2074
+ },
2075
+ item.outcome.id
2076
+ );
2077
+ })
2078
+ }
2079
+ ),
2080
+ /* @__PURE__ */ jsx5(
2081
+ SwitchButton,
2082
+ {
2083
+ ariaLabel: labels.eventItemDetails.outcomeSelectorAria,
2084
+ className: cn("agg-outcome-switch w-full md:w-fit", classNames == null ? void 0 : classNames.segmentedControl),
2085
+ value: (_d2 = (_c2 = (_a2 = selectedMarketOutcomes.find((o) => o.label === resolvedChartOutcomeLabel)) == null ? void 0 : _a2.id) != null ? _c2 : (_b2 = selectedMarketOutcomes[0]) == null ? void 0 : _b2.id) != null ? _d2 : "",
2086
+ onValueChange: (outcomeId) => {
2087
+ const outcome = selectedMarketOutcomes.find((o) => o.id === outcomeId);
2088
+ if (outcome) {
2089
+ setChartOutcomeLabel(outcome.label);
2090
+ }
2091
+ tradingContext == null ? void 0 : tradingContext.selectOutcome(outcomeId);
2092
+ },
2093
+ options: selectedMarketOutcomes.map((outcome) => {
2094
+ var _a3;
2095
+ const price = (_a3 = livePrices.get(outcome.id)) != null ? _a3 : outcome.price;
2096
+ return {
2097
+ value: outcome.id,
2098
+ label: `${outcome.label} ${formatProbabilityCents(price)}`,
2099
+ ariaLabel: `${outcome.label} ${formatProbabilityCents(price)}`
2100
+ };
2101
+ })
2102
+ }
2103
+ )
2104
+ ]
2105
+ }
2106
+ );
2107
+ }
2108
+ }
2109
+ );
2110
+ };
2111
+ var EventListItemDetailsContent = ({
2112
+ event,
2113
+ defaultMarketId,
2114
+ defaultOutcomeId,
2115
+ classNames,
2116
+ venueInfo,
2117
+ detailsStats,
2118
+ eventTradingState,
2119
+ ariaLabel,
2120
+ onClick
2121
+ }) => {
2122
+ var _a, _b;
2123
+ const [selectedChartType, setSelectedChartType] = useState4("line");
2124
+ const lastAppliedEventSyncKeyRef = useRef3(null);
2125
+ const lastAppliedDefaultRef = useRef3(null);
2126
+ const config = useSdkUiConfig2();
2127
+ const labels = useLabels5();
2128
+ const tradingContext = useEventTradingContext();
2129
+ const eventSyncKey = useMemo4(() => resolveEventDetailsSyncKey(event), [event]);
2130
+ const resolvedEventTradingState = useMemo4(() => {
2131
+ return eventTradingState != null ? eventTradingState : resolveEventTradingState(event);
2132
+ }, [event, eventTradingState]);
2133
+ const scopedSelectedMarket = (tradingContext == null ? void 0 : tradingContext.selectedEventId) === event.id ? (_a = tradingContext.selectedMarket) != null ? _a : resolvedEventTradingState.primaryMarket : resolvedEventTradingState.primaryMarket;
2134
+ const scopedSelectedMarketId = (tradingContext == null ? void 0 : tradingContext.selectedEventId) === event.id ? tradingContext.selectedMarketId : null;
2135
+ useEventOrderbookData(
2136
+ resolvedEventTradingState.isTradingDisabled ? [] : resolvedEventTradingState.displayMarkets,
2137
+ scopedSelectedMarketId
2138
+ );
2139
+ const wsLivePrices = useLiveOutcomePrices(resolvedEventTradingState.displayMarkets);
2140
+ const midpointsClusterMarkets = useMemo4(() => {
2141
+ if (resolvedEventTradingState.isTradingDisabled) return [];
2142
+ return normalizeVenueMarketCluster(
2143
+ resolvedEventTradingState.displayMarkets,
2144
+ scopedSelectedMarketId
2145
+ );
2146
+ }, [
2147
+ resolvedEventTradingState.displayMarkets,
2148
+ resolvedEventTradingState.isTradingDisabled,
2149
+ scopedSelectedMarketId
2150
+ ]);
2151
+ const { prices: restMidpoints } = useMidpoints(midpointsClusterMarkets);
2152
+ const livePrices = useMemo4(() => {
2153
+ if (!restMidpoints.size) return wsLivePrices;
2154
+ if (!wsLivePrices.size) return restMidpoints;
2155
+ const merged = new Map(restMidpoints);
2156
+ for (const [k, v] of wsLivePrices) merged.set(k, v);
2157
+ return merged;
2158
+ }, [restMidpoints, wsLivePrices]);
2159
+ useEffect3(() => {
2160
+ if (!tradingContext) return;
2161
+ if (lastAppliedEventSyncKeyRef.current === eventSyncKey) return;
2162
+ if ((tradingContext == null ? void 0 : tradingContext.selectedEventId) !== event.id) {
2163
+ tradingContext == null ? void 0 : tradingContext.initializeFromEvent(event);
2164
+ } else {
2165
+ tradingContext == null ? void 0 : tradingContext.syncEvent(event);
2166
+ }
2167
+ lastAppliedEventSyncKeyRef.current = eventSyncKey;
2168
+ }, [event, eventSyncKey, tradingContext]);
2169
+ useEffect3(() => {
2170
+ if (!tradingContext) return;
2171
+ if (!defaultMarketId) return;
2172
+ if (tradingContext.selectedEventId !== event.id) return;
2173
+ const applyKey = `${event.id}::${defaultMarketId}::${defaultOutcomeId != null ? defaultOutcomeId : ""}`;
2174
+ if (lastAppliedDefaultRef.current === applyKey) return;
2175
+ const nextMarket = event.venueMarkets.find((market) => market.id === defaultMarketId);
2176
+ if (!nextMarket) return;
2177
+ if (defaultOutcomeId) {
2178
+ const nextOutcome = nextMarket.venueMarketOutcomes.find(
2179
+ (outcome) => outcome.id === defaultOutcomeId
2180
+ );
2181
+ if (!nextOutcome) return;
2182
+ tradingContext.selectMarketAndOutcome(defaultMarketId, defaultOutcomeId);
2183
+ lastAppliedDefaultRef.current = applyKey;
2184
+ return;
2185
+ }
2186
+ tradingContext.selectMarket(defaultMarketId, nextMarket);
2187
+ lastAppliedDefaultRef.current = applyKey;
2188
+ }, [
2189
+ defaultMarketId,
2190
+ defaultOutcomeId,
2191
+ event.id,
2192
+ event.venueMarkets,
2193
+ tradingContext,
2194
+ tradingContext == null ? void 0 : tradingContext.selectedEventId
2195
+ ]);
2196
+ const venueMarkets = useMemo4(
2197
+ () => resolvedEventTradingState.displayMarkets,
2198
+ [resolvedEventTradingState.displayMarkets]
2199
+ );
2200
+ const sortedVenueMarkets = useMemo4(() => sortMarketsByYesOddsDesc(venueMarkets), [venueMarkets]);
2201
+ const marketOptions = useMemo4(
2202
+ () => sortedVenueMarkets.map((vm) => ({
2203
+ value: vm.id,
2204
+ label: vm.question
2205
+ })),
2206
+ [sortedVenueMarkets]
2207
+ );
2208
+ const volumeLabel = useMemo4(() => {
2209
+ const resolvedVolume = resolveDisplayVolume(event.volume, venueMarkets);
2210
+ if (typeof resolvedVolume !== "number") return "";
2211
+ return `${config.formatting.formatCompactCurrency(resolvedVolume)} ${labels.eventItemDetails.volumeSuffix}`;
2212
+ }, [config, event.volume, labels.eventItemDetails.volumeSuffix, venueMarkets]);
2213
+ return /* @__PURE__ */ jsxs4(
2214
+ Card,
2215
+ {
2216
+ className: cn("group/agg-event-details", detailsBaseCardClassName, classNames == null ? void 0 : classNames.root),
2217
+ "aria-label": ariaLabel != null ? ariaLabel : event.title,
2218
+ onClick: () => {
2219
+ onClick == null ? void 0 : onClick(event);
2220
+ },
2221
+ children: [
2222
+ /* @__PURE__ */ jsxs4(
2223
+ "div",
2224
+ {
2225
+ className: cn(
2226
+ "agg-event-details-header",
2227
+ "flex flex-row gap-3 md:gap-4",
2228
+ venueMarkets.length > 1 ? "items-start" : "items-center",
2229
+ "justify-start",
2230
+ classNames == null ? void 0 : classNames.header
2231
+ ),
2232
+ children: [
2233
+ /* @__PURE__ */ jsx5(
2234
+ RemoteImage,
2235
+ {
2236
+ src: optimizedImageUrl2(event.image, 60),
2237
+ alt: "",
2238
+ className: "agg-event-image size-10 rounded-agg-lg object-cover md:size-[60px]"
2239
+ }
2240
+ ),
2241
+ /* @__PURE__ */ jsxs4("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [
2242
+ /* @__PURE__ */ jsx5(
2243
+ Typography,
2244
+ {
2245
+ variant: "body-strong",
2246
+ className: cn(
2247
+ "agg-event-title",
2248
+ "min-w-0 text-agg-base font-agg-bold! leading-agg-6 md:text-agg-2xl md:leading-agg-8",
2249
+ "truncate text-wrap wrap-break-word line-clamp-2",
2250
+ classNames == null ? void 0 : classNames.title
2251
+ ),
2252
+ children: event.title
2253
+ }
2254
+ ),
2255
+ venueMarkets.length > 1 ? /* @__PURE__ */ jsx5(
2256
+ EventListItemDetailsMarketSelector,
2257
+ {
2258
+ className: classNames == null ? void 0 : classNames.headerPills,
2259
+ options: marketOptions,
2260
+ selectedValue: (_b = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.id) != null ? _b : "",
2261
+ onChange: (marketId) => {
2262
+ tradingContext == null ? void 0 : tradingContext.selectMarket(marketId);
2263
+ }
2264
+ }
2265
+ ) : null
2266
+ ] })
2267
+ ]
2268
+ }
2269
+ ),
2270
+ detailsStats && detailsStats.length > 0 ? /* @__PURE__ */ jsx5(
2271
+ "div",
2272
+ {
2273
+ className: cn(
2274
+ "agg-event-stats flex flex-wrap items-start gap-4 md:gap-6",
2275
+ classNames == null ? void 0 : classNames.headerStats
2276
+ ),
2277
+ children: detailsStats.map((statItem) => {
2278
+ const deltaClassName = statItem.deltaTone === "positive" ? "text-agg-success!" : statItem.deltaTone === "negative" ? "text-agg-error!" : "text-agg-muted-foreground";
2279
+ return /* @__PURE__ */ jsxs4(
2280
+ "div",
2281
+ {
2282
+ className: "agg-event-stat flex flex-col gap-1",
2283
+ children: [
2284
+ /* @__PURE__ */ jsx5(Typography, { variant: "caption-caps", className: "text-agg-muted-foreground", children: statItem.label }),
2285
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-baseline gap-1", children: [
2286
+ /* @__PURE__ */ jsx5(
2287
+ Typography,
2288
+ {
2289
+ variant: "body",
2290
+ className: "text-agg-lg leading-agg-7 text-agg-foreground",
2291
+ children: statItem.value
2292
+ }
2293
+ ),
2294
+ statItem.delta ? /* @__PURE__ */ jsx5(Typography, { variant: "label", className: cn(deltaClassName), children: statItem.delta }) : null
2295
+ ] })
2296
+ ]
2297
+ },
2298
+ `${statItem.label}-${statItem.value}`
2299
+ );
2300
+ })
2301
+ }
2302
+ ) : null,
2303
+ /* @__PURE__ */ jsxs4("div", { className: cn("agg-event-details-chart", "flex flex-col gap-2"), children: [
2304
+ /* @__PURE__ */ jsx5(
2305
+ EventListItemDetailsGraphSection,
2306
+ {
2307
+ classNames,
2308
+ selectedChartType,
2309
+ venueInfo,
2310
+ venueMarkets,
2311
+ livePrices,
2312
+ live: false
2313
+ }
2314
+ ),
2315
+ /* @__PURE__ */ jsxs4(
2316
+ "div",
2317
+ {
2318
+ className: cn(
2319
+ "agg-chart-footer flex flex-wrap items-center justify-between gap-4",
2320
+ classNames == null ? void 0 : classNames.footer
2321
+ ),
2322
+ children: [
2323
+ /* @__PURE__ */ jsx5(Typography, { variant: "label", className: "agg-chart-volume text-agg-muted-foreground", children: volumeLabel || "-" }),
2324
+ /* @__PURE__ */ jsxs4(
2325
+ "div",
2326
+ {
2327
+ className: cn(
2328
+ "agg-chart-time-ranges flex flex-wrap items-center gap-2 md:gap-3",
2329
+ classNames == null ? void 0 : classNames.timeRange
2330
+ ),
2331
+ children: [
2332
+ /* @__PURE__ */ jsx5(
2333
+ ChartTypeSwitch,
2334
+ {
2335
+ className: "agg-chart-type-switch",
2336
+ value: selectedChartType,
2337
+ onValueChange: setSelectedChartType
2338
+ }
2339
+ ),
2340
+ /* @__PURE__ */ jsx5("span", { "aria-hidden": "true", className: "hidden h-4 w-px bg-agg-separator md:block" }),
2341
+ CHART_TIME_RANGES.map((timeRange) => {
2342
+ const isActive = timeRange === config.chart.selectedChartTimeRange;
2343
+ return /* @__PURE__ */ jsx5(
2344
+ Button,
2345
+ {
2346
+ size: "small",
2347
+ variant: "tertiary",
2348
+ className: cn(
2349
+ "agg-chart-time-range-trigger",
2350
+ "h-auto min-w-0 rounded-none px-0 py-0 text-agg-xs leading-agg-4 md:text-agg-sm md:leading-agg-5",
2351
+ "border-0 bg-transparent shadow-none",
2352
+ "hover:text-agg-foreground!",
2353
+ isActive ? "font-agg-bold! text-agg-foreground!" : "font-agg-normal! text-agg-muted-foreground!"
2354
+ ),
2355
+ "aria-pressed": isActive,
2356
+ onClick: (e) => {
2357
+ e.stopPropagation();
2358
+ e.preventDefault();
2359
+ config.chart.setSelectedChartTimeRange(timeRange);
2360
+ },
2361
+ children: timeRange === "ALL" ? labels.eventItemDetails.allTimeRange : timeRange
2362
+ },
2363
+ timeRange
2364
+ );
2365
+ })
2366
+ ]
2367
+ }
2368
+ )
2369
+ ]
2370
+ }
2371
+ )
2372
+ ] }),
2373
+ event.description ? /* @__PURE__ */ jsx5(SettlementSummary, { content: event.description }) : null
2374
+ ]
2375
+ }
2376
+ );
2377
+ };
2378
+ var EventListItemDetailsByEventId = (_a) => {
2379
+ var _b = _a, {
2380
+ eventId
2381
+ } = _b, rest = __objRest(_b, [
2382
+ "eventId"
2383
+ ]);
2384
+ const resolvedEventId = eventId != null ? eventId : "";
2385
+ const {
2386
+ event: fetchedEvent,
2387
+ error,
2388
+ isError,
2389
+ isLoading
2390
+ } = useVenueEvent2({
2391
+ eventId: resolvedEventId,
2392
+ enabled: !!resolvedEventId
2393
+ });
2394
+ if (!resolvedEventId) {
2395
+ return /* @__PURE__ */ jsx5(
2396
+ EventListItemDetailsUnavailableState,
2397
+ {
2398
+ classNames: rest.classNames,
2399
+ ariaLabel: rest.ariaLabel
2400
+ }
2401
+ );
2402
+ }
2403
+ if (isLoading) {
2404
+ return /* @__PURE__ */ jsx5(EventListItemDetailsLoadingState, { classNames: rest.classNames, ariaLabel: rest.ariaLabel });
2405
+ }
2406
+ if (isErrorWithStatus(error, 404)) {
2407
+ return /* @__PURE__ */ jsx5(EventListItemDetailsNotFoundState, { classNames: rest.classNames, ariaLabel: rest.ariaLabel });
2408
+ }
2409
+ if (!fetchedEvent && !isError) {
2410
+ return /* @__PURE__ */ jsx5(EventListItemDetailsLoadingState, { classNames: rest.classNames, ariaLabel: rest.ariaLabel });
2411
+ }
2412
+ if (!fetchedEvent) {
2413
+ return /* @__PURE__ */ jsx5(
2414
+ EventListItemDetailsUnavailableState,
2415
+ {
2416
+ classNames: rest.classNames,
2417
+ ariaLabel: rest.ariaLabel
2418
+ }
2419
+ );
2420
+ }
2421
+ return /* @__PURE__ */ jsx5(EventListItemDetailsContent, __spreadValues({ event: fetchedEvent }, rest));
2422
+ };
2423
+ var EventListItemDetails = (props) => {
2424
+ if (props.isLoading) {
2425
+ return /* @__PURE__ */ jsx5(EventListItemDetailsLoadingState, { classNames: props.classNames, ariaLabel: props.ariaLabel });
2426
+ }
2427
+ if ("event" in props && props.event) {
2428
+ const _a = props, { event } = _a, rest = __objRest(_a, ["event"]);
2429
+ return /* @__PURE__ */ jsx5(EventListItemDetailsContent, __spreadValues({ event }, rest));
2430
+ }
2431
+ if ("eventId" in props && typeof props.eventId === "string") {
2432
+ const {
2433
+ classNames,
2434
+ defaultMarketId,
2435
+ defaultOutcomeId,
2436
+ venueInfo,
2437
+ detailsStats,
2438
+ ariaLabel: ariaLabelOverride,
2439
+ onClick
2440
+ } = props;
2441
+ const byEventIdProps = {
2442
+ eventId: props.eventId,
2443
+ isLoading: false,
2444
+ classNames,
2445
+ defaultMarketId,
2446
+ defaultOutcomeId,
2447
+ venueInfo,
2448
+ detailsStats,
2449
+ ariaLabel: ariaLabelOverride,
2450
+ onClick
2451
+ };
2452
+ return /* @__PURE__ */ jsx5(EventListItemDetailsByEventId, __spreadValues({}, byEventIdProps));
2453
+ }
2454
+ return /* @__PURE__ */ jsx5(
2455
+ EventListItemDetailsUnavailableState,
2456
+ {
2457
+ classNames: props.classNames,
2458
+ ariaLabel: props.ariaLabel
2459
+ }
2460
+ );
2461
+ };
2462
+ EventListItemDetails.displayName = "EventListItemDetails";
2463
+
2464
+ // src/events/orderbook/orderbook.constants.ts
2465
+ var orderbookRowLimitDefault = 4;
2466
+ var orderbookRowHeightPx = 36;
2467
+ var orderbookDividerHeightPx = 0;
2468
+ var orderbookRowGapPx = 0;
2469
+ var orderbookSpreadRowHeightPx = 36;
2470
+ var orderbookMaxVisibleVenues = 2;
2471
+ var orderbookDefaultLabels = {
2472
+ midPrice: "Mid Price",
2473
+ spread: "Spread",
2474
+ tradeOutcome: "Trade",
2475
+ price: "Price",
2476
+ shares: "Shares",
2477
+ total: "Total",
2478
+ asks: "Asks",
2479
+ bids: "Bids"
2480
+ };
2481
+
2482
+ // src/events/orderbook/use-center-orderbook-spread.ts
2483
+ import { useCallback as useCallback3, useLayoutEffect as useLayoutEffect2, useRef as useRef4 } from "react";
2484
+ var maxAutoCenterAttempts = 12;
2485
+ var userScrollKeys = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "PageDown", "PageUp", "Home", "End", " "]);
2486
+ var useCenterOrderbookSpread = ({
2487
+ containerRef,
2488
+ spreadRef,
2489
+ marketId,
2490
+ snapshotKey: _snapshotKey,
2491
+ rowCount,
2492
+ enabled = true
2493
+ }) => {
2494
+ const hasAutoCenteredRef = useRef4(false);
2495
+ const hasUserScrolledRef = useRef4(false);
2496
+ const animationFrameRef = useRef4(null);
2497
+ const retryCountRef = useRef4(0);
2498
+ const resetKey = marketId != null ? marketId : "";
2499
+ useLayoutEffect2(() => {
2500
+ const cancelPendingFrame = () => {
2501
+ if (animationFrameRef.current === null) return;
2502
+ window.cancelAnimationFrame(animationFrameRef.current);
2503
+ animationFrameRef.current = null;
2504
+ };
2505
+ hasAutoCenteredRef.current = false;
2506
+ hasUserScrolledRef.current = false;
2507
+ retryCountRef.current = 0;
2508
+ cancelPendingFrame();
2509
+ }, [resetKey]);
2510
+ useLayoutEffect2(() => {
2511
+ const container = containerRef.current;
2512
+ if (!container) return;
2513
+ const cancelPendingFrame = () => {
2514
+ if (animationFrameRef.current === null) return;
2515
+ window.cancelAnimationFrame(animationFrameRef.current);
2516
+ animationFrameRef.current = null;
2517
+ };
2518
+ const handleUserScrollIntent = () => {
2519
+ hasUserScrolledRef.current = true;
2520
+ cancelPendingFrame();
2521
+ };
2522
+ const handleKeyDown = (event) => {
2523
+ if (!userScrollKeys.has(event.key)) return;
2524
+ handleUserScrollIntent();
2525
+ };
2526
+ container.addEventListener("pointerdown", handleUserScrollIntent);
2527
+ container.addEventListener("wheel", handleUserScrollIntent, { passive: true });
2528
+ container.addEventListener("touchstart", handleUserScrollIntent, { passive: true });
2529
+ container.addEventListener("keydown", handleKeyDown);
2530
+ return () => {
2531
+ container.removeEventListener("pointerdown", handleUserScrollIntent);
2532
+ container.removeEventListener("wheel", handleUserScrollIntent);
2533
+ container.removeEventListener("touchstart", handleUserScrollIntent);
2534
+ container.removeEventListener("keydown", handleKeyDown);
2535
+ cancelPendingFrame();
2536
+ };
2537
+ }, [containerRef]);
2538
+ useLayoutEffect2(() => {
2539
+ if (!enabled) return;
2540
+ if (hasAutoCenteredRef.current || hasUserScrolledRef.current) return;
2541
+ let isCancelled = false;
2542
+ const cancelPendingFrame = () => {
2543
+ if (animationFrameRef.current === null) return;
2544
+ window.cancelAnimationFrame(animationFrameRef.current);
2545
+ animationFrameRef.current = null;
2546
+ };
2547
+ const scheduleMeasurement = () => {
2548
+ cancelPendingFrame();
2549
+ animationFrameRef.current = window.requestAnimationFrame(measureAndCenter);
2550
+ };
2551
+ const scheduleRetry = () => {
2552
+ if (isCancelled || hasUserScrolledRef.current || hasAutoCenteredRef.current) return;
2553
+ if (retryCountRef.current >= maxAutoCenterAttempts) return;
2554
+ retryCountRef.current += 1;
2555
+ scheduleMeasurement();
2556
+ };
2557
+ const measureAndCenter = () => {
2558
+ if (isCancelled) return;
2559
+ const container = containerRef.current;
2560
+ const spread = spreadRef.current;
2561
+ if (!container || !spread) {
2562
+ scheduleRetry();
2563
+ return;
2564
+ }
2565
+ const containerHeight = container.clientHeight;
2566
+ if (containerHeight <= 0) {
2567
+ scheduleRetry();
2568
+ return;
2569
+ }
2570
+ const containerRect = container.getBoundingClientRect();
2571
+ const spreadRect = spread.getBoundingClientRect();
2572
+ if (containerRect.height <= 0 || spreadRect.height <= 0) {
2573
+ scheduleRetry();
2574
+ return;
2575
+ }
2576
+ const spreadOffsetTop = container.scrollTop + (spreadRect.top - containerRect.top);
2577
+ const maxScrollTop = Math.max(0, container.scrollHeight - containerHeight);
2578
+ const targetScrollTop = Math.max(
2579
+ 0,
2580
+ Math.min(maxScrollTop, spreadOffsetTop - containerHeight / 2 + spreadRect.height / 2)
2581
+ );
2582
+ container.scrollTo({ top: targetScrollTop, behavior: "auto" });
2583
+ hasAutoCenteredRef.current = true;
2584
+ retryCountRef.current = 0;
2585
+ animationFrameRef.current = null;
2586
+ };
2587
+ scheduleMeasurement();
2588
+ return () => {
2589
+ isCancelled = true;
2590
+ cancelPendingFrame();
2591
+ };
2592
+ }, [containerRef, enabled, resetKey, rowCount, spreadRef]);
2593
+ const recenter = useCallback3(() => {
2594
+ const container = containerRef.current;
2595
+ const spread = spreadRef.current;
2596
+ if (!container || !spread) return;
2597
+ const containerRect = container.getBoundingClientRect();
2598
+ const spreadRect = spread.getBoundingClientRect();
2599
+ if (containerRect.height <= 0 || spreadRect.height <= 0) return;
2600
+ const spreadOffsetTop = container.scrollTop + (spreadRect.top - containerRect.top);
2601
+ const maxScrollTop = Math.max(0, container.scrollHeight - container.clientHeight);
2602
+ const targetScrollTop = Math.max(
2603
+ 0,
2604
+ Math.min(maxScrollTop, spreadOffsetTop - container.clientHeight / 2 + spreadRect.height / 2)
2605
+ );
2606
+ container.scrollTo({ top: targetScrollTop, behavior: "smooth" });
2607
+ hasUserScrolledRef.current = false;
2608
+ }, [containerRef, spreadRef]);
2609
+ return { recenter };
2610
+ };
2611
+
2612
+ // src/events/orderbook/index.tsx
2613
+ import { sortVenues as sortVenues3, useAggUiConfig } from "@agg-build/hooks";
2614
+ import { useEffect as useEffect4, useRef as useRef5 } from "react";
2615
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
2616
+ var OrderbookVenueLogos = ({ venues }) => {
2617
+ const visible = sortVenues3(venues).slice(0, orderbookMaxVisibleVenues);
2618
+ const overflow = venues.length - visible.length;
2619
+ return /* @__PURE__ */ jsxs5("div", { className: "flex flex-row items-center justify-start gap-0.5 md:gap-1", children: [
2620
+ visible.map((venue) => /* @__PURE__ */ jsx6(VenueLogo, { venue, size: "small" }, venue)),
2621
+ overflow > 0 ? /* @__PURE__ */ jsxs5("span", { className: "text-agg-xs font-agg-bold leading-agg-4 text-agg-muted-foreground", children: [
2622
+ "+",
2623
+ overflow
2624
+ ] }) : null
2625
+ ] });
2626
+ };
2627
+ var OrderbookRow = ({
2628
+ entry,
2629
+ formatNumber,
2630
+ formatCurrency,
2631
+ enableAnimations,
2632
+ showBadge,
2633
+ badgeLabel
2634
+ }) => {
2635
+ var _a;
2636
+ const isAsk = entry.kind === "ask";
2637
+ const priceClassName = isAsk ? "text-agg-orderbook-ask" : "text-agg-orderbook-bid";
2638
+ const barClassName = isAsk ? "bg-agg-orderbook-ask/10" : "bg-agg-orderbook-bid/10";
2639
+ const badgeBorderClassName = isAsk ? "border-agg-orderbook-ask/50 bg-agg-orderbook-ask/10" : "border-agg-orderbook-bid/50 bg-agg-orderbook-bid/10";
2640
+ const badgeTextClassName = isAsk ? "text-agg-orderbook-ask" : "text-agg-orderbook-bid";
2641
+ const venuesFromBreakdown = Object.entries((_a = entry.row.venueBreakdown) != null ? _a : {}).filter(([, size]) => typeof size === "number" && size > 0).sort((left, right) => {
2642
+ if (right[1] !== left[1]) return right[1] - left[1];
2643
+ return left[0].localeCompare(right[0]);
2644
+ }).map(([venue]) => venue);
2645
+ const venues = entry.row.venues && entry.row.venues.length > 0 ? entry.row.venues : venuesFromBreakdown.length > 0 ? venuesFromBreakdown : [entry.row.venue];
2646
+ const barPercent = Math.max(2, Number((entry.unifiedBarScale * 100).toFixed(2)));
2647
+ return /* @__PURE__ */ jsxs5("div", { className: "agg-orderbook-row relative flex h-9 items-center gap-2.5 overflow-clip md:gap-10 pr-2.5 md:pr-5", children: [
2648
+ /* @__PURE__ */ jsxs5("div", { className: "md:relative min-w-0 flex-1 self-stretch", children: [
2649
+ /* @__PURE__ */ jsx6(
2650
+ "div",
2651
+ {
2652
+ "aria-hidden": "true",
2653
+ className: cn(
2654
+ "agg-orderbook-bar absolute inset-y-0 left-0",
2655
+ barClassName,
2656
+ getMotionClassName(enableAnimations, "transition-[width] duration-200 ease-in-out")
2657
+ ),
2658
+ style: { width: `${barPercent}%` }
2659
+ }
2660
+ ),
2661
+ showBadge && badgeLabel ? /* @__PURE__ */ jsx6(
2662
+ "div",
2663
+ {
2664
+ className: cn(
2665
+ "absolute flex left-5 top-1/2 -translate-y-1/2 rounded-[4px] border px-2 py-0.5",
2666
+ badgeBorderClassName
2667
+ ),
2668
+ children: /* @__PURE__ */ jsx6(
2669
+ "span",
2670
+ {
2671
+ className: cn("text-[10px] font-bold uppercase leading-[14px]", badgeTextClassName),
2672
+ children: badgeLabel
2673
+ }
2674
+ )
2675
+ }
2676
+ ) : null
2677
+ ] }),
2678
+ /* @__PURE__ */ jsxs5("div", { className: "flex w-20 shrink-0 items-center justify-start gap-2 md:w-[120px]", children: [
2679
+ /* @__PURE__ */ jsx6(
2680
+ "span",
2681
+ {
2682
+ className: cn(
2683
+ "agg-orderbook-price",
2684
+ "w-9 min-w-9 md:min-w-10 md:w-10 text-agg-sm font-agg-bold leading-agg-5",
2685
+ priceClassName
2686
+ ),
2687
+ children: formatProbabilityCents(entry.row.price)
2688
+ }
2689
+ ),
2690
+ /* @__PURE__ */ jsx6(OrderbookVenueLogos, { venues })
2691
+ ] }),
2692
+ /* @__PURE__ */ jsx6("span", { className: "agg-orderbook-size w-20 shrink-0 truncate text-center text-agg-sm leading-agg-5 text-agg-foreground md:w-[120px]", children: formatNumber(entry.row.size) }),
2693
+ /* @__PURE__ */ jsx6("span", { className: "agg-orderbook-total w-20 shrink-0 truncate text-center text-agg-sm leading-agg-5 text-agg-foreground md:w-[120px]", children: formatCurrency(entry.row.total) })
2694
+ ] });
2695
+ };
2696
+ var Orderbook = ({
2697
+ entries,
2698
+ formatNumber,
2699
+ formatCurrency,
2700
+ visibleRows = orderbookRowLimitDefault,
2701
+ enableAnimations = true,
2702
+ marketId,
2703
+ snapshotKey,
2704
+ outcomeId,
2705
+ labels: labelsProp,
2706
+ className
2707
+ }) => {
2708
+ var _a, _b, _c, _d, _e;
2709
+ const { enableWebsocketsLogs } = useAggUiConfig();
2710
+ const labels = __spreadValues(__spreadValues({}, orderbookDefaultLabels), labelsProp);
2711
+ const scrollContainerRef = useRef5(null);
2712
+ const spreadRowRef = useRef5(null);
2713
+ const autoCenterMarketId = (_a = marketId != null ? marketId : outcomeId) != null ? _a : null;
2714
+ const maxVisibleRows = Math.max(1, visibleRows);
2715
+ const totalVisibleRows = maxVisibleRows * 2 + 1;
2716
+ const orderBookVisibleHeightPx = maxVisibleRows * 2 * orderbookRowHeightPx + Math.max(0, totalVisibleRows - 1) * (orderbookDividerHeightPx + orderbookRowGapPx) + orderbookSpreadRowHeightPx;
2717
+ const { recenter } = useCenterOrderbookSpread({
2718
+ containerRef: scrollContainerRef,
2719
+ spreadRef: spreadRowRef,
2720
+ marketId: autoCenterMarketId,
2721
+ snapshotKey,
2722
+ rowCount: entries.length
2723
+ });
2724
+ const askEntries = entries.filter((e) => e.kind === "ask");
2725
+ const bidEntries = entries.filter((e) => e.kind === "bid");
2726
+ const spreadEntry = entries.find(
2727
+ (e) => e.kind === "spread"
2728
+ );
2729
+ useEffect4(() => {
2730
+ var _a2, _b2;
2731
+ if (!enableWebsocketsLogs) return;
2732
+ console.debug("[AggUI][orderbook] component_rendered", {
2733
+ outcomeId: outcomeId != null ? outcomeId : null,
2734
+ marketId: marketId != null ? marketId : null,
2735
+ snapshotKey: snapshotKey != null ? snapshotKey : null,
2736
+ askCount: askEntries.length,
2737
+ bidCount: bidEntries.length,
2738
+ spreadMidPrice: (_a2 = spreadEntry == null ? void 0 : spreadEntry.midPrice) != null ? _a2 : null,
2739
+ spreadValue: (_b2 = spreadEntry == null ? void 0 : spreadEntry.spread) != null ? _b2 : null
2740
+ });
2741
+ }, [
2742
+ askEntries.length,
2743
+ bidEntries.length,
2744
+ enableWebsocketsLogs,
2745
+ marketId,
2746
+ outcomeId,
2747
+ snapshotKey,
2748
+ spreadEntry
2749
+ ]);
2750
+ return /* @__PURE__ */ jsxs5("div", { className: cn("agg-orderbook-unified flex flex-col", className), children: [
2751
+ /* @__PURE__ */ jsxs5("div", { className: "flex h-9 items-center gap-2.5 overflow-clip border-b border-agg-separator pr-5 md:gap-10", children: [
2752
+ /* @__PURE__ */ jsx6("span", { className: "flex min-w-0 flex-1 items-center gap-2 pl-5", children: /* @__PURE__ */ jsx6("span", { className: "text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground", children: labels.tradeOutcome }) }),
2753
+ /* @__PURE__ */ jsx6("span", { className: "w-20 shrink-0 text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground md:w-[120px]", children: labels.price }),
2754
+ /* @__PURE__ */ jsx6("span", { className: "w-20 shrink-0 text-center text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground md:w-[120px]", children: labels.shares }),
2755
+ /* @__PURE__ */ jsx6("span", { className: "w-20 shrink-0 text-center text-agg-xs font-agg-bold uppercase leading-agg-4 text-agg-muted-foreground md:w-[120px]", children: labels.total })
2756
+ ] }),
2757
+ /* @__PURE__ */ jsxs5("div", { className: "relative", children: [
2758
+ /* @__PURE__ */ jsxs5(
2759
+ "div",
2760
+ {
2761
+ ref: scrollContainerRef,
2762
+ className: "agg-orderbook-list flex flex-col overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
2763
+ style: { maxHeight: `${orderBookVisibleHeightPx}px` },
2764
+ role: "region",
2765
+ "aria-label": "Order book",
2766
+ tabIndex: 0,
2767
+ children: [
2768
+ askEntries.length > 0 ? /* @__PURE__ */ jsx6("div", { className: "agg-orderbook-asks flex flex-col", children: askEntries.map((entry, index) => /* @__PURE__ */ jsx6(
2769
+ OrderbookRow,
2770
+ {
2771
+ entry,
2772
+ formatNumber,
2773
+ formatCurrency,
2774
+ enableAnimations,
2775
+ showBadge: index === askEntries.length - 1,
2776
+ badgeLabel: labels.asks
2777
+ },
2778
+ entry.row.id
2779
+ )) }) : null,
2780
+ /* @__PURE__ */ jsxs5(
2781
+ "div",
2782
+ {
2783
+ ref: spreadRowRef,
2784
+ className: "agg-orderbook-spread flex items-center border-y border-agg-separator h-9 px-5 py-2 gap-3 md:gap-10",
2785
+ role: "separator",
2786
+ "aria-label": `${labels.midPrice}: ${formatProbabilityCents((_b = spreadEntry == null ? void 0 : spreadEntry.midPrice) != null ? _b : null)}, ${labels.spread}: ${formatProbabilityCents((_c = spreadEntry == null ? void 0 : spreadEntry.spread) != null ? _c : null)}`,
2787
+ children: [
2788
+ /* @__PURE__ */ jsxs5(
2789
+ Typography,
2790
+ {
2791
+ variant: "label",
2792
+ className: "min-w-0 md:flex-1 text-agg-foreground whitespace-nowrap text-ellipsis max-w-1/2 truncate md:max-w-unset",
2793
+ children: [
2794
+ "Last: ",
2795
+ labels.lastOutcome ? `${labels.lastOutcome} ` : "",
2796
+ formatProbabilityCents((_d = spreadEntry == null ? void 0 : spreadEntry.midPrice) != null ? _d : null)
2797
+ ]
2798
+ }
2799
+ ),
2800
+ /* @__PURE__ */ jsxs5(
2801
+ Typography,
2802
+ {
2803
+ variant: "label",
2804
+ className: "w-26 shrink-0 text-agg-foreground md:w-[120px] whitespace-nowrap text-ellipsis max-w-1/2 truncate md:max-w-unset",
2805
+ children: [
2806
+ labels.spread,
2807
+ ": ",
2808
+ formatProbabilityCents((_e = spreadEntry == null ? void 0 : spreadEntry.spread) != null ? _e : null)
2809
+ ]
2810
+ }
2811
+ ),
2812
+ /* @__PURE__ */ jsx6("div", { className: "hidden md:inline-flex w-20 shrink-0 md:w-[120px]" }),
2813
+ /* @__PURE__ */ jsx6("div", { className: "hidden md:inline-flex w-20 shrink-0 md:w-[120px]" })
2814
+ ]
2815
+ }
2816
+ ),
2817
+ bidEntries.length > 0 ? /* @__PURE__ */ jsx6("div", { className: "agg-orderbook-bids flex flex-col", children: bidEntries.map((entry, index) => /* @__PURE__ */ jsx6(
2818
+ OrderbookRow,
2819
+ {
2820
+ entry,
2821
+ formatNumber,
2822
+ formatCurrency,
2823
+ enableAnimations,
2824
+ showBadge: index === 0,
2825
+ badgeLabel: labels.bids
2826
+ },
2827
+ entry.row.id
2828
+ )) }) : null
2829
+ ]
2830
+ }
2831
+ ),
2832
+ /* @__PURE__ */ jsx6(
2833
+ "button",
2834
+ {
2835
+ type: "button",
2836
+ onClick: recenter,
2837
+ className: "absolute bottom-3 left-5 z-10 flex size-8 cursor-pointer items-center justify-center rounded-lg border border-agg-separator bg-agg-secondary text-agg-muted-foreground transition-colors hover:text-agg-foreground",
2838
+ "aria-label": "Re-center orderbook",
2839
+ children: /* @__PURE__ */ jsx6(Icon, { name: "recenter", size: "small", className: "!size-4 text-current" })
2840
+ }
2841
+ )
2842
+ ] })
2843
+ ] });
2844
+ };
2845
+ Orderbook.displayName = "Orderbook";
2846
+
2847
+ // src/events/orderbook/orderbook-with-states.tsx
2848
+ import { jsx as jsx7 } from "react/jsx-runtime";
2849
+ var stateMessageMinHeight = "min-h-[248px] px-5 py-10 md:min-h-[272px]";
2850
+ var OrderbookWithStates = (_a) => {
2851
+ var _b = _a, {
2852
+ state,
2853
+ wrapperClassName
2854
+ } = _b, orderbookProps = __objRest(_b, [
2855
+ "state",
2856
+ "wrapperClassName"
2857
+ ]);
2858
+ var _a2;
2859
+ if (state.kind === "loading") {
2860
+ return /* @__PURE__ */ jsx7("div", { className: cn("agg-orderbook flex flex-col gap-5", wrapperClassName), children: /* @__PURE__ */ jsx7(MarketDetailsOderbookSkeleton, {}) });
2861
+ }
2862
+ if (state.kind === "disabled") {
2863
+ return /* @__PURE__ */ jsx7("div", { className: cn("agg-orderbook flex flex-col gap-5", wrapperClassName), children: /* @__PURE__ */ jsx7(
2864
+ StateMessage,
2865
+ {
2866
+ title: state.title,
2867
+ description: state.description,
2868
+ icon: (_a2 = state.icon) != null ? _a2 : /* @__PURE__ */ jsx7(WarningIcon, {}),
2869
+ classNames: { root: stateMessageMinHeight }
2870
+ }
2871
+ ) });
2872
+ }
2873
+ if (state.kind === "error") {
2874
+ return /* @__PURE__ */ jsx7("div", { className: cn("agg-orderbook flex flex-col gap-5", wrapperClassName), children: /* @__PURE__ */ jsx7(
2875
+ StateMessage,
2876
+ {
2877
+ title: state.title,
2878
+ description: state.description,
2879
+ icon: /* @__PURE__ */ jsx7(WarningIcon, {}),
2880
+ onAction: state.onRetry,
2881
+ classNames: { root: stateMessageMinHeight }
2882
+ }
2883
+ ) });
2884
+ }
2885
+ if (state.kind === "resolved") {
2886
+ return /* @__PURE__ */ jsx7("div", { className: cn("agg-orderbook flex flex-col gap-5", wrapperClassName), children: /* @__PURE__ */ jsx7(
2887
+ StateMessage,
2888
+ {
2889
+ title: state.title,
2890
+ description: state.description,
2891
+ icon: /* @__PURE__ */ jsx7(WarningIcon, {}),
2892
+ classNames: { root: stateMessageMinHeight }
2893
+ }
2894
+ ) });
2895
+ }
2896
+ if (state.kind === "empty") {
2897
+ return /* @__PURE__ */ jsx7("div", { className: cn("agg-orderbook flex flex-col gap-5", wrapperClassName), children: /* @__PURE__ */ jsx7(
2898
+ StateMessage,
2899
+ {
2900
+ title: state.title,
2901
+ description: state.description,
2902
+ icon: /* @__PURE__ */ jsx7(SearchEmptyIcon, {}),
2903
+ classNames: { root: stateMessageMinHeight }
2904
+ }
2905
+ ) });
2906
+ }
2907
+ return /* @__PURE__ */ jsx7("div", { className: cn("agg-orderbook flex flex-col gap-5", wrapperClassName), children: /* @__PURE__ */ jsx7(Orderbook, __spreadValues({}, orderbookProps)) });
2908
+ };
2909
+ OrderbookWithStates.displayName = "OrderbookWithStates";
2910
+
2911
+ // src/events/market-details/index.tsx
2912
+ import {
2913
+ CHART_TIME_RANGES as CHART_TIME_RANGES2,
2914
+ findLivePriceById,
2915
+ MarketStatus,
2916
+ optimizedImageUrl as optimizedImageUrl3,
2917
+ resolveMarketTradingState,
2918
+ timeRangeToInterval as timeRangeToInterval2,
2919
+ useEventTradingContext as useEventTradingContext2,
2920
+ useLabels as useLabels6,
2921
+ useLiveOutcomePrices as useLiveOutcomePrices2,
2922
+ useMarketChart as useMarketChart2,
2923
+ useMarketOrderbook,
2924
+ useMidpoints as useMidpoints2,
2925
+ useSdkUiConfig as useSdkUiConfig3,
2926
+ useVenueMarkets as useVenueMarkets2,
2927
+ useViewportMidpoints
2928
+ } from "@agg-build/hooks";
2929
+ import { useEffect as useEffect5, useId as useId2, useMemo as useMemo5, useRef as useRef6, useState as useState5 } from "react";
2930
+
2931
+ // src/events/market-details/market-details-outcome-button.tsx
2932
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
2933
+ var marketDetailsOutcomeButtonToneClasses = {
2934
+ positive: {
2935
+ activeSurface: "bg-agg-success/15",
2936
+ border: "border-agg-success/50",
2937
+ defaultSurface: "bg-agg-success/5",
2938
+ hoverSurface: "hover:bg-agg-success/10",
2939
+ pressedSurface: "active:bg-agg-success/15",
2940
+ text: "text-agg-success!"
2941
+ },
2942
+ negative: {
2943
+ activeSurface: "bg-agg-error/15",
2944
+ border: "border-agg-error/50",
2945
+ defaultSurface: "bg-agg-error/5",
2946
+ hoverSurface: "hover:bg-agg-error/10",
2947
+ pressedSurface: "active:bg-agg-error/15",
2948
+ text: "text-agg-error!"
2949
+ }
2950
+ };
2951
+ var getMarketDetailsOutcomeButtonClassNames = ({
2952
+ enableAnimations,
2953
+ isSelected,
2954
+ tone
2955
+ }) => {
2956
+ const toneClasses = marketDetailsOutcomeButtonToneClasses[tone];
2957
+ return {
2958
+ root: cn(
2959
+ "w-[140px]",
2960
+ "flex h-9 shrink-0 cursor-pointer select-none items-center justify-center gap-2 rounded-agg-full border px-5 py-1.5 text-left shadow-none",
2961
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
2962
+ "disabled:cursor-not-allowed disabled:opacity-60",
2963
+ getMotionClassName(
2964
+ enableAnimations,
2965
+ "transition-[background-color,border-color,color] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
2966
+ ),
2967
+ isSelected ? cn(toneClasses.activeSurface, toneClasses.border) : cn("border-transparent", toneClasses.defaultSurface, toneClasses.hoverSurface),
2968
+ toneClasses.pressedSurface
2969
+ ),
2970
+ text: cn(isSelected ? toneClasses.text : "text-agg-foreground")
2971
+ };
2972
+ };
2973
+ var MarketDetailsOutcomeButton = ({
2974
+ ariaControls,
2975
+ enableAnimations,
2976
+ isSelected,
2977
+ item,
2978
+ onSelect
2979
+ }) => {
2980
+ const classNames = getMarketDetailsOutcomeButtonClassNames({
2981
+ enableAnimations,
2982
+ isSelected,
2983
+ tone: item.tone
2984
+ });
2985
+ return /* @__PURE__ */ jsxs6(
2986
+ "button",
2987
+ {
2988
+ type: "button",
2989
+ role: "tab",
2990
+ "data-id": item.id,
2991
+ "aria-controls": ariaControls,
2992
+ "aria-selected": isSelected,
2993
+ tabIndex: isSelected ? 0 : -1,
2994
+ className: cn(classNames.root, "flex-1 md:flex-auto", "gap-1!"),
2995
+ onClick: () => onSelect(item.label),
2996
+ children: [
2997
+ /* @__PURE__ */ jsx8(VenueLogo, { venue: item.venue, size: "small" }),
2998
+ /* @__PURE__ */ jsxs6("div", { className: "flex flex-row items-center gap-1 min-w-0", children: [
2999
+ /* @__PURE__ */ jsx8(
3000
+ Typography,
3001
+ {
3002
+ as: "span",
3003
+ variant: isSelected ? "body-strong" : "body",
3004
+ className: cn("whitespace-nowrap truncate", classNames.text),
3005
+ children: item.label
3006
+ }
3007
+ ),
3008
+ /* @__PURE__ */ jsx8(
3009
+ Typography,
3010
+ {
3011
+ as: "span",
3012
+ variant: isSelected ? "body-strong" : "body",
3013
+ className: cn(classNames.text),
3014
+ children: formatProbabilityCents(item.probability)
3015
+ }
3016
+ )
3017
+ ] })
3018
+ ]
3019
+ }
3020
+ );
3021
+ };
3022
+ MarketDetailsOutcomeButton.displayName = "MarketDetailsOutcomeButton";
3023
+
3024
+ // src/events/market-details/index.tsx
3025
+ import { Fragment, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
3026
+ var MarketDetailsLoadingState = ({
3027
+ isOpened = marketDetailsDefaultIsOpened,
3028
+ ariaLabel,
3029
+ classNames
3030
+ }) => {
3031
+ const labels = useLabels6();
3032
+ return /* @__PURE__ */ jsx9(
3033
+ Skeleton,
3034
+ {
3035
+ view: isOpened ? "market-details-detailed" : "market-details-minified",
3036
+ className: classNames == null ? void 0 : classNames.root,
3037
+ ariaLabel: ariaLabel != null ? ariaLabel : labels.marketDetails.loading
3038
+ }
3039
+ );
3040
+ };
3041
+ var MarketDetailsUnavailableState = ({
3042
+ ariaLabel,
3043
+ classNames
3044
+ }) => {
3045
+ const labels = useLabels6();
3046
+ return /* @__PURE__ */ jsx9(
3047
+ Card,
3048
+ {
3049
+ className: cn(
3050
+ "group/agg-market-card agg-market-card-unavailable",
3051
+ marketDetailsBaseCardClassName,
3052
+ classNames == null ? void 0 : classNames.root
3053
+ ),
3054
+ role: "status",
3055
+ "aria-label": ariaLabel != null ? ariaLabel : labels.marketDetails.unavailableAria,
3056
+ children: /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1 p-5", children: [
3057
+ /* @__PURE__ */ jsx9(Typography, { variant: "body-large-strong", children: labels.marketDetails.unavailableTitle }),
3058
+ /* @__PURE__ */ jsx9(Typography, { variant: "label", className: "text-agg-muted-foreground", children: labels.marketDetails.unavailableDescription })
3059
+ ] })
3060
+ }
3061
+ );
3062
+ };
3063
+ var MarketDetailsNotFoundState = ({
3064
+ ariaLabel: _ariaLabel,
3065
+ classNames: _classNames
3066
+ }) => {
3067
+ const labels = useLabels6();
3068
+ return /* @__PURE__ */ jsx9(
3069
+ StateMessage,
3070
+ {
3071
+ title: labels.marketDetails.notFoundTitle,
3072
+ description: labels.marketDetails.notFoundDescription,
3073
+ icon: /* @__PURE__ */ jsx9(SearchEmptyIcon, {}),
3074
+ classNames: { root: "min-h-[280px] md:min-h-[320px]" }
3075
+ }
3076
+ );
3077
+ };
3078
+ var MarketDetailsContent = ({
3079
+ venueMarkets,
3080
+ marketId,
3081
+ title,
3082
+ image,
3083
+ isOpened: controlledIsOpened = marketDetailsDefaultIsOpened,
3084
+ onOpenChange,
3085
+ defaultTab,
3086
+ defaultOutcomeLabel,
3087
+ orderBookDepth = orderBookRowLimitDefault,
3088
+ ariaLabel,
3089
+ classNames,
3090
+ otherContent,
3091
+ live,
3092
+ midpointsFallback
3093
+ }) => {
3094
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3095
+ const config = useSdkUiConfig3();
3096
+ const {
3097
+ features: { enableAnimations },
3098
+ formatting: { formatPercent },
3099
+ general: { theme }
3100
+ } = config;
3101
+ const isDarkTheme = theme === "dark";
3102
+ const labels = useLabels6();
3103
+ const tradingContext = useEventTradingContext2();
3104
+ const detailsContentId = useId2();
3105
+ const wsLivePrices = useLiveOutcomePrices2(venueMarkets);
3106
+ const model = useMemo5(() => {
3107
+ return buildMarketDetailsModel({
3108
+ venueMarkets,
3109
+ marketId,
3110
+ title,
3111
+ image,
3112
+ formatCompactCurrency: config.formatting.formatCompactCurrency,
3113
+ labels
3114
+ });
3115
+ }, [config.formatting.formatCompactCurrency, venueMarkets, image, labels, marketId, title]);
3116
+ const resolvedMarket = useMemo5(() => {
3117
+ return resolveMarketFromVenueMarkets(venueMarkets, marketId);
3118
+ }, [venueMarkets, marketId]);
3119
+ const clusterMidpointMarkets = useMemo5(() => {
3120
+ if (!controlledIsOpened || !resolvedMarket) return [];
3121
+ return resolvedMarket.venueMarkets;
3122
+ }, [controlledIsOpened, resolvedMarket]);
3123
+ const { prices: clusterMidpoints } = useMidpoints2(clusterMidpointMarkets);
3124
+ const livePrices = useMemo5(() => {
3125
+ const merged = /* @__PURE__ */ new Map();
3126
+ if (midpointsFallback == null ? void 0 : midpointsFallback.size) {
3127
+ for (const [outcomeId, price] of midpointsFallback) {
3128
+ merged.set(outcomeId, price);
3129
+ }
3130
+ }
3131
+ if (clusterMidpoints.size) {
3132
+ for (const [outcomeId, price] of clusterMidpoints) {
3133
+ merged.set(outcomeId, price);
3134
+ }
3135
+ }
3136
+ for (const [k, v] of wsLivePrices) merged.set(k, v);
3137
+ return merged;
3138
+ }, [clusterMidpoints, midpointsFallback, wsLivePrices]);
3139
+ const scopedMarketForCard = useMemo5(() => {
3140
+ var _a2;
3141
+ if (!model) return null;
3142
+ return (_a2 = model.market.venueMarkets.find((venueMarket) => venueMarket.id === model.market.id)) != null ? _a2 : model.primaryVenueMarket;
3143
+ }, [model]);
3144
+ const marketTradingState = useMemo5(() => {
3145
+ return resolveMarketTradingState(scopedMarketForCard);
3146
+ }, [scopedMarketForCard]);
3147
+ const isResolvedMarket = marketTradingState.kind === "resolved";
3148
+ const isOutcomeSelectionLocked = marketTradingState.isTradingDisabled;
3149
+ const isUpcomingMarket = marketTradingState.kind === "unopened";
3150
+ const marketStatePresentation = resolveTradingStatePresentation(labels, marketTradingState);
3151
+ const marketDetailsTabs = useMemo5(() => {
3152
+ return getMarketDetailsTabs(labels);
3153
+ }, [labels]);
3154
+ const [selectedTab, setSelectedTab] = useState5(
3155
+ () => resolveInitialTab(defaultTab)
3156
+ );
3157
+ const [isOpened, setIsOpened] = useState5(controlledIsOpened);
3158
+ useEffect5(() => {
3159
+ setSelectedTab(resolveInitialTab(defaultTab));
3160
+ }, [defaultTab]);
3161
+ useEffect5(() => {
3162
+ setIsOpened(controlledIsOpened);
3163
+ }, [controlledIsOpened]);
3164
+ const selectedTimeRange = config.chart.selectedChartTimeRange;
3165
+ const setSelectedTimeRange = config.chart.setSelectedChartTimeRange;
3166
+ const effectiveSelectedTab = isResolvedMarket ? "graph" : selectedTab;
3167
+ const effectiveChartTimeRange = isResolvedMarket ? "ALL" : selectedTimeRange;
3168
+ const [selectedChartType, setSelectedChartType] = useState5("line");
3169
+ const scopedSelectedOutcome = (_a = tradingContext == null ? void 0 : tradingContext.selectedOutcome) != null ? _a : null;
3170
+ const selectedOutcomeId = (_b = scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.id) != null ? _b : null;
3171
+ const selectedOutcomeLabel = (_c = scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.label) != null ? _c : null;
3172
+ const selectOutcome = tradingContext == null ? void 0 : tradingContext.selectOutcome;
3173
+ const [selectedGraphVenue, setSelectedGraphVenue] = useState5(null);
3174
+ const [chartOutcomeLabel, setChartOutcomeLabel] = useState5(selectedOutcomeLabel);
3175
+ useEffect5(() => {
3176
+ if (!isOpened) return;
3177
+ if (selectedOutcomeLabel) {
3178
+ setChartOutcomeLabel(selectedOutcomeLabel);
3179
+ }
3180
+ }, [isOpened]);
3181
+ useEffect5(() => {
3182
+ var _a2;
3183
+ if (!isOpened || !model) return;
3184
+ if (isOutcomeSelectionLocked) return;
3185
+ if (selectedOutcomeId) return;
3186
+ const initialLabel = resolveInitialOutcomeLabel(model.outcomeLabels, defaultOutcomeLabel);
3187
+ if (!initialLabel) return;
3188
+ const outcomes = resolveOutcomesByVenue(model.market.venueMarkets, initialLabel);
3189
+ const firstOutcomeId = (_a2 = outcomes[0]) == null ? void 0 : _a2.outcome.id;
3190
+ if (firstOutcomeId) {
3191
+ selectOutcome == null ? void 0 : selectOutcome(firstOutcomeId);
3192
+ }
3193
+ }, [
3194
+ defaultOutcomeLabel,
3195
+ isOpened,
3196
+ isOutcomeSelectionLocked,
3197
+ model,
3198
+ selectedOutcomeId,
3199
+ selectOutcome
3200
+ ]);
3201
+ const headerOutcomeItems = useMemo5(() => {
3202
+ if (!model) return [];
3203
+ const items = resolveHeaderOutcomeItems(model.market.venueMarkets);
3204
+ return items.map((item) => {
3205
+ const livePrice = findLivePriceById(livePrices, item.id);
3206
+ return livePrice != null ? __spreadProps(__spreadValues({}, item), { probability: livePrice }) : item;
3207
+ });
3208
+ }, [model, livePrices]);
3209
+ const headlineProbability = useMemo5(() => {
3210
+ var _a2, _b2;
3211
+ if (!model || !scopedMarketForCard) return void 0;
3212
+ const resolveLiveProbability = (outcomeId, fallbackPrice) => {
3213
+ const liveProbability = findLivePriceById(livePrices, outcomeId);
3214
+ return liveProbability != null ? liveProbability : fallbackPrice;
3215
+ };
3216
+ const yesOutcome = resolveYesOutcome(scopedMarketForCard);
3217
+ const displayOutcome = yesOutcome != null ? yesOutcome : (_b2 = scopedMarketForCard.venueMarketOutcomes) == null ? void 0 : _b2.reduce(
3218
+ (acc, outcome) => outcome.price > acc.price ? outcome : acc,
3219
+ (_a2 = scopedMarketForCard.venueMarketOutcomes) == null ? void 0 : _a2[0]
3220
+ );
3221
+ return resolveLiveProbability(displayOutcome.id, displayOutcome.price);
3222
+ }, [model, scopedMarketForCard, livePrices]);
3223
+ const selectedOutcomesByVenue = useMemo5(() => {
3224
+ if (!model) return [];
3225
+ return collectEligibleVenueOutcomes({
3226
+ venueMarkets: model.market.venueMarkets,
3227
+ selectedOutcomeLabel
3228
+ });
3229
+ }, [model, selectedOutcomeLabel]);
3230
+ const resolvedChartOutcomeLabel = chartOutcomeLabel != null ? chartOutcomeLabel : selectedOutcomeLabel;
3231
+ const chartOutcomesByVenue = useMemo5(() => {
3232
+ if (!model) return [];
3233
+ return resolveChartVenueOutcomes({
3234
+ eligibleVenueOutcomes: collectEligibleVenueOutcomes({
3235
+ venueMarkets: model.market.venueMarkets,
3236
+ selectedOutcomeLabel: resolvedChartOutcomeLabel
3237
+ }),
3238
+ livePrices
3239
+ });
3240
+ }, [livePrices, model, resolvedChartOutcomeLabel]);
3241
+ const chartEnabled = isOpened && effectiveSelectedTab === "graph";
3242
+ const orderBookEnabled = isOpened && effectiveSelectedTab === "order-book" && !marketTradingState.isTradingDisabled;
3243
+ const timeWindow = useMemo5(() => {
3244
+ return getTimeWindowByRange(effectiveChartTimeRange);
3245
+ }, [effectiveChartTimeRange]);
3246
+ const primaryVenueMarketId = (_e = (_d = selectedOutcomesByVenue[0]) == null ? void 0 : _d.market.id) != null ? _e : null;
3247
+ const primaryOutcomeId = (_g = (_f = selectedOutcomesByVenue[0]) == null ? void 0 : _f.outcome.id) != null ? _g : null;
3248
+ const chartPrimaryOutcomeId = (_i = (_h = chartOutcomesByVenue[0]) == null ? void 0 : _h.outcome.id) != null ? _i : null;
3249
+ const chartVenueOutcomeIds = useMemo5(() => {
3250
+ return chartOutcomesByVenue.map((item) => item.outcome.id);
3251
+ }, [chartOutcomesByVenue]);
3252
+ const {
3253
+ data: marketChartData,
3254
+ isLoading: isMarketChartLoading,
3255
+ error: marketChartError,
3256
+ refetch: refetchMarketChart
3257
+ } = useMarketChart2({
3258
+ marketId: chartPrimaryOutcomeId,
3259
+ venueMarketIds: chartVenueOutcomeIds,
3260
+ interval: timeRangeToInterval2(effectiveChartTimeRange),
3261
+ startTs: timeWindow.startTs * 1e3,
3262
+ endTs: timeWindow.endTs * 1e3,
3263
+ enabled: chartEnabled && !!chartPrimaryOutcomeId,
3264
+ live
3265
+ });
3266
+ const marketOrderbookResult = useMarketOrderbook({
3267
+ marketId: primaryVenueMarketId,
3268
+ enabled: orderBookEnabled && !!primaryVenueMarketId,
3269
+ venueOutcomes: selectedOutcomesByVenue.map((item) => ({
3270
+ venue: item.venue,
3271
+ venueMarketOutcomeId: item.outcomeId
3272
+ })),
3273
+ live
3274
+ });
3275
+ const marketOrderbookDataById = useMemo5(() => {
3276
+ var _a2;
3277
+ return (_a2 = marketOrderbookResult.dataById) != null ? _a2 : {};
3278
+ }, [marketOrderbookResult]);
3279
+ const isOrderBookLoading = marketOrderbookResult.isLoading;
3280
+ const orderBookError = marketOrderbookResult.error;
3281
+ const refetchOrderBook = marketOrderbookResult.refetch;
3282
+ const aggregatedOrderbookRows = useMemo5(() => {
3283
+ return mergeVenueOutcomeOrderbooks({
3284
+ eligibleOutcomes: selectedOutcomesByVenue,
3285
+ orderbooksByOutcomeId: marketOrderbookDataById
3286
+ });
3287
+ }, [marketOrderbookDataById, selectedOutcomesByVenue]);
3288
+ const askRows = aggregatedOrderbookRows.askRows;
3289
+ const bidRows = aggregatedOrderbookRows.bidRows;
3290
+ const unifiedEntries = useMemo5(() => {
3291
+ return resolveUnifiedOrderBookEntries({
3292
+ askRows,
3293
+ bidRows,
3294
+ midPrice: aggregatedOrderbookRows.midpoint,
3295
+ spread: aggregatedOrderbookRows.spread
3296
+ });
3297
+ }, [aggregatedOrderbookRows.midpoint, aggregatedOrderbookRows.spread, askRows, bidRows]);
3298
+ const orderbookSnapshotKey = useMemo5(() => {
3299
+ if (selectedOutcomesByVenue.length === 0) return null;
3300
+ return selectedOutcomesByVenue.map((item) => {
3301
+ var _a2, _b2;
3302
+ const snapshotVersion = (_b2 = (_a2 = marketOrderbookDataById[item.outcomeId]) == null ? void 0 : _a2.snapshotVersion) != null ? _b2 : 0;
3303
+ return `${item.outcomeId}:${snapshotVersion}`;
3304
+ }).join("|");
3305
+ }, [marketOrderbookDataById, selectedOutcomesByVenue]);
3306
+ const chartAvailableOutcomesByVenue = useMemo5(() => {
3307
+ return filterChartVenueOutcomesByRenderableVenues({
3308
+ chartData: marketChartData,
3309
+ venueOutcomes: chartOutcomesByVenue
3310
+ });
3311
+ }, [chartOutcomesByVenue, marketChartData]);
3312
+ const graphSeries = useMemo5(() => {
3313
+ var _a2, _b2, _c2, _d2;
3314
+ const baseColor = resolveSeriesColor(
3315
+ (_d2 = (_c2 = selectedGraphVenue != null ? selectedGraphVenue : (_a2 = chartAvailableOutcomesByVenue[0]) == null ? void 0 : _a2.venue) != null ? _c2 : (_b2 = chartOutcomesByVenue[0]) == null ? void 0 : _b2.venue) != null ? _d2 : "polymarket",
3316
+ 0,
3317
+ isDarkTheme
3318
+ );
3319
+ return resolveMarketChartDisplaySeries({
3320
+ chartData: marketChartData,
3321
+ selectedVenue: selectedGraphVenue,
3322
+ transformProbability: (value) => value
3323
+ }).map((seriesItem) => {
3324
+ return {
3325
+ id: `${resolvedChartOutcomeLabel != null ? resolvedChartOutcomeLabel : "graph"}-${seriesItem.venue}-${chartPrimaryOutcomeId != null ? chartPrimaryOutcomeId : "chart"}`,
3326
+ venue: selectedGraphVenue != null ? selectedGraphVenue : seriesItem.venue,
3327
+ color: seriesItem.venue === "aggregate" ? baseColor : resolveSeriesColor(seriesItem.venue, 0, isDarkTheme),
3328
+ points: seriesItem.points
3329
+ };
3330
+ });
3331
+ }, [
3332
+ isDarkTheme,
3333
+ chartPrimaryOutcomeId,
3334
+ marketChartData,
3335
+ selectedGraphVenue,
3336
+ resolvedChartOutcomeLabel,
3337
+ chartAvailableOutcomesByVenue,
3338
+ chartOutcomesByVenue
3339
+ ]);
3340
+ const graphLiveState = useMemo5(() => {
3341
+ return resolveMarketChartLiveState({
3342
+ chartData: marketChartData,
3343
+ selectedVenue: selectedGraphVenue,
3344
+ transformProbability: (value) => value
3345
+ });
3346
+ }, [marketChartData, selectedGraphVenue]);
3347
+ const otherRows = useMemo5(() => {
3348
+ if (!model) return [];
3349
+ return resolveOtherTabRows(model.market, labels);
3350
+ }, [labels, model]);
3351
+ const isOrderBookNotFound = orderBookError && typeof orderBookError === "object" && "status" in orderBookError && orderBookError.status === 404;
3352
+ const isMarketResolved = isOrderBookNotFound && "code" in orderBookError && (orderBookError.code === "market_resolved" || orderBookError.code === "market_closed");
3353
+ const hasOrderBookError = !!orderBookError && !isOrderBookNotFound;
3354
+ const isSnapshotUnavailableError = typeof orderBookError === "object" && orderBookError != null && "message" in orderBookError && typeof orderBookError.message === "string" && /^snapshot unavailable for\s+\S+/i.test(orderBookError.message);
3355
+ const orderBookErrorDescription = isSnapshotUnavailableError ? labels.marketDetails.orderBookUnavailableDescription : typeof orderBookError === "object" && orderBookError != null && "message" in orderBookError && typeof orderBookError.message === "string" && orderBookError.message.trim().length > 0 ? orderBookError.message : labels.marketDetails.orderBookUnavailableDescription;
3356
+ const hasNoOrderBook = isOrderBookNotFound && !isMarketResolved || !isOrderBookLoading && !hasOrderBookError && (selectedOutcomesByVenue.length === 0 || aggregatedOrderbookRows.hasNoOrderBook);
3357
+ const hasChartError = !!marketChartError;
3358
+ const selectHeaderOutcome = (item) => {
3359
+ if (isOutcomeSelectionLocked) return;
3360
+ if (item == null ? void 0 : item.id) {
3361
+ tradingContext == null ? void 0 : tradingContext.selectOutcome(item.id);
3362
+ }
3363
+ };
3364
+ const handleOutcomeKeyDown = (eventToHandle) => {
3365
+ if (isOutcomeSelectionLocked) return;
3366
+ if ((eventToHandle == null ? void 0 : eventToHandle.key) !== "ArrowLeft" && (eventToHandle == null ? void 0 : eventToHandle.key) !== "ArrowRight" && (eventToHandle == null ? void 0 : eventToHandle.key) !== "Home" && (eventToHandle == null ? void 0 : eventToHandle.key) !== "End") {
3367
+ return;
3368
+ }
3369
+ if (headerOutcomeItems.length <= 1) return;
3370
+ eventToHandle.preventDefault();
3371
+ const activeIndex = headerOutcomeItems.findIndex((item) => {
3372
+ return item.label === selectedOutcomeLabel;
3373
+ });
3374
+ if (eventToHandle.key === "Home") {
3375
+ selectHeaderOutcome(headerOutcomeItems[0]);
3376
+ return;
3377
+ }
3378
+ if (eventToHandle.key === "End") {
3379
+ selectHeaderOutcome(headerOutcomeItems[headerOutcomeItems.length - 1]);
3380
+ return;
3381
+ }
3382
+ const direction = eventToHandle.key === "ArrowRight" ? 1 : -1;
3383
+ const nextIndex = activeIndex < 0 ? 0 : (activeIndex + direction + headerOutcomeItems.length) % headerOutcomeItems.length;
3384
+ selectHeaderOutcome(headerOutcomeItems[nextIndex]);
3385
+ };
3386
+ const handleToggleExpanded = () => {
3387
+ if (!marketId) return;
3388
+ onOpenChange == null ? void 0 : onOpenChange(marketId);
3389
+ };
3390
+ const handleGraphVenueToggle = (venue) => {
3391
+ setSelectedGraphVenue((currentVenue) => {
3392
+ if (currentVenue === venue) return null;
3393
+ return venue;
3394
+ });
3395
+ };
3396
+ const handleRetryOrderBook = () => {
3397
+ void refetchOrderBook();
3398
+ };
3399
+ const handleRetryMarketChart = () => {
3400
+ void refetchMarketChart();
3401
+ };
3402
+ const orderbookState = marketTradingState.isTradingDisabled ? {
3403
+ kind: "disabled",
3404
+ title: marketStatePresentation.title,
3405
+ description: marketStatePresentation.description,
3406
+ icon: /* @__PURE__ */ jsx9(Icon, { name: marketStatePresentation.iconName, className: "h-5 w-5", "aria-hidden": "true" })
3407
+ } : isOrderBookLoading ? { kind: "loading" } : hasOrderBookError ? {
3408
+ kind: "error",
3409
+ title: labels.marketDetails.orderBookUnavailableTitle,
3410
+ description: orderBookErrorDescription,
3411
+ onRetry: handleRetryOrderBook
3412
+ } : isMarketResolved ? {
3413
+ kind: "resolved",
3414
+ title: labels.marketDetails.orderBookResolvedTitle,
3415
+ description: labels.marketDetails.orderBookResolvedDescription
3416
+ } : hasNoOrderBook ? {
3417
+ kind: "empty",
3418
+ title: labels.marketDetails.orderBookEmptyTitle,
3419
+ description: labels.marketDetails.orderBookEmptyDescription
3420
+ } : { kind: "data" };
3421
+ useEffect5(() => {
3422
+ if (!selectedGraphVenue) {
3423
+ return;
3424
+ }
3425
+ if (chartAvailableOutcomesByVenue.some((item) => item.venue === selectedGraphVenue)) {
3426
+ return;
3427
+ }
3428
+ setSelectedGraphVenue(null);
3429
+ }, [selectedGraphVenue, chartAvailableOutcomesByVenue]);
3430
+ if (marketId && !resolvedMarket) {
3431
+ return /* @__PURE__ */ jsx9(MarketDetailsNotFoundState, { ariaLabel, classNames });
3432
+ }
3433
+ if (!model) {
3434
+ return /* @__PURE__ */ jsx9(MarketDetailsUnavailableState, { ariaLabel, classNames });
3435
+ }
3436
+ return /* @__PURE__ */ jsxs7(
3437
+ Card,
3438
+ {
3439
+ className: cn(
3440
+ "group/agg-market-card",
3441
+ "w-full rounded-agg-2xl text-left outline-none",
3442
+ marketTradingState.isTradingDisabled && "agg-market-card-readonly",
3443
+ marketDetailsBaseCardClassName,
3444
+ classNames == null ? void 0 : classNames.root
3445
+ ),
3446
+ children: [
3447
+ /* @__PURE__ */ jsxs7(
3448
+ "div",
3449
+ {
3450
+ className: cn(
3451
+ "agg-market-card-header",
3452
+ "cursor-pointer",
3453
+ "flex flex-col items-stretch gap-3 px-5 py-3 md:flex-row md:flex-nowrap md:items-center md:justify-between",
3454
+ isOpened && "pb-3",
3455
+ classNames == null ? void 0 : classNames.header
3456
+ ),
3457
+ onClick: handleToggleExpanded,
3458
+ children: [
3459
+ /* @__PURE__ */ jsxs7(
3460
+ "button",
3461
+ {
3462
+ type: "button",
3463
+ className: cn(
3464
+ "agg-market-card-summary",
3465
+ "flex min-w-0 w-full items-center justify-between gap-4 text-left md:flex-1",
3466
+ "cursor-pointer rounded-agg-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary"
3467
+ ),
3468
+ "aria-expanded": isOpened,
3469
+ "aria-controls": detailsContentId,
3470
+ "aria-label": isOpened ? labels.marketDetails.toggleCloseDetailsAria(model.title) : labels.marketDetails.toggleOpenDetailsAria(model.title),
3471
+ onClick: handleToggleExpanded,
3472
+ children: [
3473
+ /* @__PURE__ */ jsxs7("div", { className: "agg-market-summary flex min-w-24 flex-1 items-center gap-3 md:gap-4", children: [
3474
+ /* @__PURE__ */ jsx9(
3475
+ RemoteImage,
3476
+ {
3477
+ src: optimizedImageUrl3(model.image, 60),
3478
+ alt: "",
3479
+ className: "agg-market-image size-12 rounded-agg-lg object-cover md:size-[60px]"
3480
+ }
3481
+ ),
3482
+ /* @__PURE__ */ jsxs7("div", { className: "flex min-w-24 flex-col", children: [
3483
+ /* @__PURE__ */ jsx9(Tooltip, { content: model.title, side: "top", children: /* @__PURE__ */ jsx9("div", { className: "min-w-0", children: /* @__PURE__ */ jsx9(
3484
+ Typography,
3485
+ {
3486
+ as: "h3",
3487
+ variant: "body-large-strong",
3488
+ className: "agg-market-title line-clamp-2",
3489
+ children: model.title
3490
+ }
3491
+ ) }) }),
3492
+ /* @__PURE__ */ jsx9("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsx9(
3493
+ Typography,
3494
+ {
3495
+ variant: "label",
3496
+ className: "agg-market-meta truncate text-agg-muted-foreground",
3497
+ children: model.subtitle
3498
+ }
3499
+ ) }),
3500
+ marketTradingState.isTradingDisabled && marketTradingState.kind !== "resolved" && !isUpcomingMarket ? /* @__PURE__ */ jsxs7("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: [
3501
+ /* @__PURE__ */ jsxs7(
3502
+ "span",
3503
+ {
3504
+ className: cn(
3505
+ "inline-flex items-center gap-2 rounded-agg-full border px-3 py-1 text-agg-xs font-agg-bold uppercase tracking-[0.08em]",
3506
+ resolveTradingStateBadgeClassName(marketTradingState.kind)
3507
+ ),
3508
+ children: [
3509
+ /* @__PURE__ */ jsx9(
3510
+ Icon,
3511
+ {
3512
+ name: marketStatePresentation.iconName,
3513
+ size: "small",
3514
+ className: "h-3.5 w-3.5"
3515
+ }
3516
+ ),
3517
+ /* @__PURE__ */ jsx9("span", { children: marketStatePresentation.badgeLabel })
3518
+ ]
3519
+ }
3520
+ ),
3521
+ marketStatePresentation.timestampLabel ? /* @__PURE__ */ jsx9(Typography, { variant: "label", className: "text-agg-muted-foreground", children: marketStatePresentation.timestampLabel }) : null,
3522
+ marketStatePresentation.winningOutcomeLabel ? /* @__PURE__ */ jsx9(Typography, { variant: "label", className: "text-agg-muted-foreground", children: marketStatePresentation.winningOutcomeLabel }) : null
3523
+ ] }) : null
3524
+ ] })
3525
+ ] }),
3526
+ /* @__PURE__ */ jsx9(Typography, { as: "div", variant: "heading", className: "agg-market-headline shrink-0", children: formatProbabilityPercent(headlineProbability, formatPercent) })
3527
+ ]
3528
+ }
3529
+ ),
3530
+ marketTradingState.kind === "resolved" && marketTradingState.winningOutcome ? /* @__PURE__ */ jsx9(
3531
+ "div",
3532
+ {
3533
+ className: "agg-outcomes flex w-full items-center justify-end md:w-auto md:shrink-0",
3534
+ onClick: (e) => e.stopPropagation(),
3535
+ children: /* @__PURE__ */ jsxs7(
3536
+ "span",
3537
+ {
3538
+ className: cn(
3539
+ "min-w-35 inline-flex h-9 items-center justify-center gap-2 rounded-agg-full",
3540
+ "border px-5 py-1.5 text-agg-sm font-agg-bold",
3541
+ getMotionClassName(
3542
+ enableAnimations,
3543
+ "transition-[background-color,border-color,color] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
3544
+ ),
3545
+ "border-transparent bg-agg-secondary-hover"
3546
+ ),
3547
+ children: [
3548
+ /* @__PURE__ */ jsx9(
3549
+ Icon,
3550
+ {
3551
+ name: marketTradingState.winningOutcome.label.trim().toLowerCase() === "yes" ? "check-circle" : "cross-circle",
3552
+ size: "small",
3553
+ className: cn(
3554
+ "h-4 w-4",
3555
+ marketTradingState.winningOutcome.label.trim().toLowerCase() === "yes" ? "text-agg-success" : "text-agg-error"
3556
+ )
3557
+ }
3558
+ ),
3559
+ /* @__PURE__ */ jsx9(Typography, { variant: "body", children: labels.eventMarketPage.resolvedOutcome(marketTradingState.winningOutcome.label) })
3560
+ ]
3561
+ }
3562
+ )
3563
+ }
3564
+ ) : isUpcomingMarket ? /* @__PURE__ */ jsx9(
3565
+ "div",
3566
+ {
3567
+ className: "agg-outcomes flex w-full items-center justify-end md:w-auto md:shrink-0",
3568
+ onClick: (e) => e.stopPropagation(),
3569
+ children: /* @__PURE__ */ jsxs7(
3570
+ "span",
3571
+ {
3572
+ className: cn(
3573
+ "min-w-35 inline-flex h-9 items-center justify-center gap-2 rounded-agg-full",
3574
+ "border px-5 py-1.5 text-agg-xs font-agg-bold uppercase tracking-[0.08em]",
3575
+ resolveTradingStateBadgeClassName(marketTradingState.kind)
3576
+ ),
3577
+ children: [
3578
+ /* @__PURE__ */ jsx9(
3579
+ Icon,
3580
+ {
3581
+ name: marketStatePresentation.iconName,
3582
+ size: "small",
3583
+ className: "h-3.5 w-3.5",
3584
+ "aria-hidden": "true"
3585
+ }
3586
+ ),
3587
+ /* @__PURE__ */ jsx9("span", { children: marketStatePresentation.badgeLabel })
3588
+ ]
3589
+ }
3590
+ )
3591
+ }
3592
+ ) : /* @__PURE__ */ jsx9(
3593
+ "div",
3594
+ {
3595
+ className: "agg-outcomes flex w-full flex-wrap gap-2 md:w-auto md:shrink-0 md:flex-nowrap",
3596
+ role: "tablist",
3597
+ "aria-label": labels.marketDetails.marketOutcomesAria,
3598
+ onClick: (e) => e.stopPropagation(),
3599
+ onKeyDown: (eventToHandle) => handleOutcomeKeyDown(eventToHandle),
3600
+ children: headerOutcomeItems.map((item) => {
3601
+ const isActiveOutcome = item.id === selectedOutcomeId;
3602
+ return /* @__PURE__ */ jsx9(
3603
+ MarketDetailsOutcomeButton,
3604
+ {
3605
+ item,
3606
+ isSelected: isActiveOutcome,
3607
+ enableAnimations: config.features.enableAnimations,
3608
+ ariaControls: detailsContentId,
3609
+ onSelect: (label) => {
3610
+ if (isOutcomeSelectionLocked) return;
3611
+ const selectedOutcomeItem = headerOutcomeItems.find(
3612
+ (headerOutcomeItem) => headerOutcomeItem.label === label
3613
+ );
3614
+ selectHeaderOutcome(selectedOutcomeItem);
3615
+ }
3616
+ },
3617
+ item.label
3618
+ );
3619
+ })
3620
+ }
3621
+ )
3622
+ ]
3623
+ }
3624
+ ),
3625
+ /* @__PURE__ */ jsx9(
3626
+ "div",
3627
+ {
3628
+ id: detailsContentId,
3629
+ className: cn(
3630
+ "grid overflow-hidden",
3631
+ getMotionClassName(
3632
+ config.features.enableAnimations,
3633
+ "transition-all duration-500 ease-in-out"
3634
+ ),
3635
+ isOpened ? "grid-rows-[1fr] opacity-100" : "pointer-events-none grid-rows-[0fr] opacity-0"
3636
+ ),
3637
+ "aria-hidden": !isOpened,
3638
+ children: /* @__PURE__ */ jsxs7("div", { className: "min-h-0", children: [
3639
+ /* @__PURE__ */ jsx9("div", { className: "h-px w-full bg-agg-separator" }),
3640
+ /* @__PURE__ */ jsxs7(
3641
+ "div",
3642
+ {
3643
+ className: cn(
3644
+ getMotionClassName(
3645
+ config.features.enableAnimations,
3646
+ "transition-all duration-500 ease-in-out"
3647
+ ),
3648
+ isOpened ? cn(
3649
+ "translate-y-0 opacity-100",
3650
+ getMotionClassName(config.features.enableAnimations, "delay-100")
3651
+ ) : "translate-y-5 opacity-0"
3652
+ ),
3653
+ children: [
3654
+ !isResolvedMarket ? /* @__PURE__ */ jsxs7(Fragment, { children: [
3655
+ /* @__PURE__ */ jsx9("div", { className: cn("block", classNames == null ? void 0 : classNames.tabs), children: /* @__PURE__ */ jsx9(
3656
+ Tabs,
3657
+ {
3658
+ ariaLabel: labels.marketDetails.tabsAria,
3659
+ items: marketDetailsTabs,
3660
+ value: selectedTab === "other" ? "order-book" : selectedTab,
3661
+ onChange: (nextValue) => setSelectedTab(nextValue),
3662
+ variant: "underline",
3663
+ className: "agg-market-tabs w-full px-5"
3664
+ }
3665
+ ) }),
3666
+ /* @__PURE__ */ jsx9("div", { className: "h-px w-full bg-agg-separator" })
3667
+ ] }) : null,
3668
+ /* @__PURE__ */ jsxs7("div", { className: cn("agg-market-card-body p-0", classNames == null ? void 0 : classNames.content), children: [
3669
+ effectiveSelectedTab === "order-book" ? /* @__PURE__ */ jsx9(
3670
+ OrderbookWithStates,
3671
+ {
3672
+ state: orderbookState,
3673
+ entries: unifiedEntries,
3674
+ formatNumber: config.formatting.formatNumber,
3675
+ formatCurrency: config.formatting.formatCurrency,
3676
+ visibleRows: orderBookDepth,
3677
+ enableAnimations: config.features.enableAnimations,
3678
+ marketId: primaryOutcomeId,
3679
+ snapshotKey: orderbookSnapshotKey,
3680
+ outcomeId: primaryOutcomeId,
3681
+ labels: {
3682
+ midPrice: labels.marketDetails.midPrice,
3683
+ spread: labels.marketDetails.spread,
3684
+ tradeOutcome: `${labels.marketDetails.tradePrefix} ${selectedOutcomeLabel != null ? selectedOutcomeLabel : ""}`.trim(),
3685
+ price: labels.marketDetails.priceColumn,
3686
+ shares: labels.marketDetails.sharesColumn,
3687
+ total: labels.marketDetails.totalColumn,
3688
+ asks: labels.marketDetails.asks,
3689
+ bids: labels.marketDetails.bids,
3690
+ lastOutcome: selectedOutcomeLabel != null ? selectedOutcomeLabel : void 0
3691
+ },
3692
+ wrapperClassName: classNames == null ? void 0 : classNames.orderBook
3693
+ }
3694
+ ) : null,
3695
+ effectiveSelectedTab === "graph" ? /* @__PURE__ */ jsxs7("div", { className: cn("agg-price-chart flex flex-col gap-5 p-5", classNames == null ? void 0 : classNames.graph), children: [
3696
+ hasChartError ? /* @__PURE__ */ jsx9(
3697
+ StateMessage,
3698
+ {
3699
+ title: labels.marketDetails.chartUnavailableTitle,
3700
+ description: labels.marketDetails.chartUnavailableDescription,
3701
+ icon: /* @__PURE__ */ jsx9(WarningIcon, {}),
3702
+ onAction: handleRetryMarketChart,
3703
+ classNames: { root: "min-h-[248px] px-5 py-10 md:min-h-[272px]" }
3704
+ }
3705
+ ) : /* @__PURE__ */ jsx9(
3706
+ LineChart,
3707
+ {
3708
+ series: graphSeries,
3709
+ height: 260,
3710
+ isLoading: isMarketChartLoading,
3711
+ chartType: selectedChartType,
3712
+ liveCandle: selectedChartType === "candlestick" ? (_j = graphLiveState.liveCandle) != null ? _j : void 0 : void 0,
3713
+ lineValue: graphLiveState.lineValue,
3714
+ classNames: { root: "agg-chart-region w-full" },
3715
+ showSeriesControls: chartAvailableOutcomesByVenue.length > 0 || headerOutcomeItems.length > 0,
3716
+ renderSeriesControls: () => {
3717
+ var _a2, _b2, _c2, _d2;
3718
+ return /* @__PURE__ */ jsxs7("div", { className: "agg-chart-toolbar w-full flex flex-col gap-4 md:flex-row md:items-center md:justify-between", children: [
3719
+ /* @__PURE__ */ jsx9("div", { className: "agg-market-venues flex flex-wrap gap-2", children: chartAvailableOutcomesByVenue.map((item) => {
3720
+ var _a3;
3721
+ const probability = formatProbabilityPercent(
3722
+ (_a3 = livePrices.get(item.outcome.id)) != null ? _a3 : item.outcome.price,
3723
+ formatPercent
3724
+ );
3725
+ const isActiveVenue = selectedGraphVenue === item.venue;
3726
+ return /* @__PURE__ */ jsxs7(
3727
+ "button",
3728
+ {
3729
+ type: "button",
3730
+ "aria-label": `${item.venue} ${probability}`,
3731
+ "aria-pressed": isActiveVenue,
3732
+ className: cn(
3733
+ "agg-market-venue",
3734
+ "cursor-pointer",
3735
+ "inline-flex items-center gap-2 rounded-agg-full border px-4 py-2",
3736
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary-hover",
3737
+ isActiveVenue ? "border-agg-primary bg-agg-secondary" : "border-transparent bg-agg-secondary-hover"
3738
+ ),
3739
+ onClick: (e) => {
3740
+ e.preventDefault();
3741
+ e.stopPropagation();
3742
+ handleGraphVenueToggle(item.venue);
3743
+ },
3744
+ children: [
3745
+ /* @__PURE__ */ jsx9(VenueLogo, { venue: item.venue, size: "small" }),
3746
+ /* @__PURE__ */ jsx9("span", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: probability })
3747
+ ]
3748
+ },
3749
+ `${item.market.id}-${item.outcome.id}`
3750
+ );
3751
+ }) }),
3752
+ !isOutcomeSelectionLocked ? /* @__PURE__ */ jsx9(
3753
+ SwitchButton,
3754
+ {
3755
+ ariaLabel: labels.marketDetails.outcomeSelectorAria,
3756
+ className: "agg-outcome-switch w-full shrink-0 md:w-fit",
3757
+ value: (_d2 = (_c2 = (_a2 = headerOutcomeItems.find(
3758
+ (outcome) => outcome.label === resolvedChartOutcomeLabel
3759
+ )) == null ? void 0 : _a2.id) != null ? _c2 : (_b2 = headerOutcomeItems[0]) == null ? void 0 : _b2.id) != null ? _d2 : "",
3760
+ onValueChange: (outcomeId) => {
3761
+ const outcome = headerOutcomeItems.find(
3762
+ (headerOutcomeItem) => headerOutcomeItem.id === outcomeId
3763
+ );
3764
+ if (!outcome) return;
3765
+ setChartOutcomeLabel(outcome.label);
3766
+ },
3767
+ options: headerOutcomeItems.map((outcome) => {
3768
+ var _a3;
3769
+ const price = (_a3 = livePrices.get(outcome.id)) != null ? _a3 : outcome.probability;
3770
+ const outcomeLabel = `${outcome.label} ${formatProbabilityCents(price)}`;
3771
+ return {
3772
+ value: outcome.id,
3773
+ label: outcomeLabel,
3774
+ ariaLabel: outcomeLabel
3775
+ };
3776
+ })
3777
+ }
3778
+ ) : null
3779
+ ] });
3780
+ }
3781
+ }
3782
+ ),
3783
+ /* @__PURE__ */ jsxs7(
3784
+ "div",
3785
+ {
3786
+ className: cn(
3787
+ "agg-chart-footer",
3788
+ "flex flex-row justify-between gap-2 text-agg-sm leading-agg-5 text-agg-muted-foreground md:flex-row md:items-center md:justify-between",
3789
+ classNames == null ? void 0 : classNames.footer
3790
+ ),
3791
+ children: [
3792
+ /* @__PURE__ */ jsx9("span", { children: typeof model.market.volume !== "number" ? labels.marketDetails.volumeUnavailable : model.market.volume > 0 ? `${config.formatting.formatCompactCurrency(model.market.volume)} ${labels.marketDetails.meta.volumeSuffix}` : "" }),
3793
+ /* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-center gap-3 md:gap-4", children: [
3794
+ /* @__PURE__ */ jsx9(
3795
+ ChartTypeSwitch,
3796
+ {
3797
+ className: "agg-chart-type-switch shrink-0",
3798
+ value: selectedChartType,
3799
+ onValueChange: setSelectedChartType
3800
+ }
3801
+ ),
3802
+ /* @__PURE__ */ jsx9(
3803
+ "span",
3804
+ {
3805
+ "aria-hidden": "true",
3806
+ className: "hidden h-4 w-px bg-agg-separator md:block"
3807
+ }
3808
+ ),
3809
+ CHART_TIME_RANGES2.map((timeRange) => {
3810
+ const isActive = effectiveChartTimeRange === timeRange;
3811
+ const isDisabled = isResolvedMarket && timeRange !== "ALL";
3812
+ return /* @__PURE__ */ jsx9(
3813
+ "button",
3814
+ {
3815
+ type: "button",
3816
+ disabled: isDisabled,
3817
+ className: cn(
3818
+ "agg-chart-time-range-trigger",
3819
+ "cursor-pointer text-agg-sm leading-agg-5",
3820
+ isDisabled && "cursor-not-allowed opacity-50",
3821
+ isActive ? "font-agg-bold text-agg-foreground" : "font-agg-normal text-agg-muted-foreground"
3822
+ ),
3823
+ "aria-pressed": isActive,
3824
+ "aria-disabled": isDisabled,
3825
+ onClick: (e) => {
3826
+ e.preventDefault();
3827
+ e.stopPropagation();
3828
+ if (isDisabled) return;
3829
+ setSelectedTimeRange(timeRange);
3830
+ },
3831
+ children: timeRange === "ALL" ? labels.eventItemDetails.allTimeRange : timeRange
3832
+ },
3833
+ timeRange
3834
+ );
3835
+ })
3836
+ ] })
3837
+ ]
3838
+ }
3839
+ )
3840
+ ] }) : null,
3841
+ effectiveSelectedTab === "other" ? /* @__PURE__ */ jsx9("div", { className: "agg-market-meta flex flex-col gap-4", children: otherContent != null ? otherContent : /* @__PURE__ */ jsx9("div", { className: "agg-market-meta-list grid grid-cols-1 gap-3", children: otherRows.map((row) => /* @__PURE__ */ jsxs7(
3842
+ "div",
3843
+ {
3844
+ className: "agg-market-meta-row flex items-center justify-between rounded-agg-xl bg-agg-secondary-hover px-4 py-3",
3845
+ children: [
3846
+ /* @__PURE__ */ jsx9(Typography, { variant: "label", className: "text-agg-muted-foreground", children: row.label }),
3847
+ /* @__PURE__ */ jsx9(Typography, { variant: "body", className: "text-right", children: row.value })
3848
+ ]
3849
+ },
3850
+ row.label
3851
+ )) }) }) : null
3852
+ ] })
3853
+ ]
3854
+ }
3855
+ )
3856
+ ] })
3857
+ }
3858
+ )
3859
+ ]
3860
+ }
3861
+ );
3862
+ };
3863
+ var MarketDetails = (_a) => {
3864
+ var _b = _a, { isOpened } = _b, props = __objRest(_b, ["isOpened"]);
3865
+ if (props.isLoading) {
3866
+ return /* @__PURE__ */ jsx9(MarketDetailsLoadingState, { isOpened, classNames: props.classNames });
3867
+ }
3868
+ if ("venueMarkets" in props && props.venueMarkets) {
3869
+ return /* @__PURE__ */ jsx9(
3870
+ MarketDetailsContent,
3871
+ __spreadProps(__spreadValues({}, props), {
3872
+ isOpened,
3873
+ onOpenChange: props.onOpenChange,
3874
+ venueMarkets: props.venueMarkets,
3875
+ midpointsFallback: props.midpointsFallback
3876
+ })
3877
+ );
3878
+ }
3879
+ const { classNames: fallbackClassNames } = props;
3880
+ return /* @__PURE__ */ jsx9(MarketDetailsUnavailableState, { classNames: fallbackClassNames });
3881
+ };
3882
+ MarketDetails.displayName = "MarketDetails";
3883
+ var AFFIRMATIVE_WINNER_LABELS = /* @__PURE__ */ new Set(["yes", "up", "buy", "long", "true"]);
3884
+ var isAffirmativeWinnerOutcomeLabel = (label) => {
3885
+ if (!label) return false;
3886
+ return AFFIRMATIVE_WINNER_LABELS.has(label.trim().toLowerCase());
3887
+ };
3888
+ var hasWinningOutcome = (market) => {
3889
+ return market.venueMarketOutcomes.some((outcome) => outcome.winner === true);
3890
+ };
3891
+ var hasAffirmativeWinningOutcome = (market) => {
3892
+ return market.venueMarketOutcomes.some((outcome) => {
3893
+ return outcome.winner === true && isAffirmativeWinnerOutcomeLabel(outcome.label);
3894
+ });
3895
+ };
3896
+ var moveMarketToFront = (markets, preferredMarketId) => {
3897
+ if (!preferredMarketId) return markets;
3898
+ const marketIndex = markets.findIndex((market) => market.id === preferredMarketId);
3899
+ if (marketIndex <= 0) return markets;
3900
+ return [
3901
+ markets[marketIndex],
3902
+ ...markets.slice(0, marketIndex),
3903
+ ...markets.slice(marketIndex + 1)
3904
+ ];
3905
+ };
3906
+ var resolveIsResolvedEvent = (sourceMarkets, eventTradingState) => {
3907
+ if (eventTradingState == null ? void 0 : eventTradingState.kind) {
3908
+ return eventTradingState.kind === "resolved";
3909
+ }
3910
+ if (sourceMarkets.length === 0) return false;
3911
+ return sourceMarkets.every((market) => resolveMarketTradingState(market).kind === "resolved");
3912
+ };
3913
+ var resolveResolvedWinnerMarketId = (sourceMarkets, eventTradingState) => {
3914
+ var _a, _b, _c, _d, _e;
3915
+ const preferredMarket = (_a = eventTradingState == null ? void 0 : eventTradingState.primaryMarket) != null ? _a : null;
3916
+ if (preferredMarket && sourceMarkets.some((market) => market.id === preferredMarket.id)) {
3917
+ if (resolveMarketTradingState(preferredMarket).kind === "resolved") {
3918
+ return preferredMarket.id;
3919
+ }
3920
+ }
3921
+ return (_e = (_d = (_b = sourceMarkets.find((market) => hasAffirmativeWinningOutcome(market))) == null ? void 0 : _b.id) != null ? _d : (_c = sourceMarkets.find((market) => hasWinningOutcome(market))) == null ? void 0 : _c.id) != null ? _e : null;
3922
+ };
3923
+ var MarketDetailsList = ({
3924
+ eventId,
3925
+ markets: providedMarkets,
3926
+ eventTradingState,
3927
+ onClick,
3928
+ onExpandedMarketChange,
3929
+ defaultTab,
3930
+ classNames,
3931
+ live
3932
+ }) => {
3933
+ var _a, _b;
3934
+ const labels = useLabels6();
3935
+ const tradingContext = useEventTradingContext2();
3936
+ const selectedMarketId = (_a = tradingContext == null ? void 0 : tradingContext.selectedMarketId) != null ? _a : null;
3937
+ const [expandedMarketId, setExpandedMarketId] = useState5(selectedMarketId);
3938
+ const previousSelectedMarketIdRef = useRef6(selectedMarketId);
3939
+ const [areResolvedMarketsVisible, setAreResolvedMarketsVisible] = useState5(false);
3940
+ const resolvedEventId = eventId || "";
3941
+ const {
3942
+ markets: rawMarkets,
3943
+ isLoading,
3944
+ error
3945
+ } = useVenueMarkets2({
3946
+ venueEventId: resolvedEventId,
3947
+ enabled: !providedMarkets && !!resolvedEventId,
3948
+ status: MarketStatus.open,
3949
+ sortBy: "yesPrice",
3950
+ sortDir: "desc"
3951
+ });
3952
+ const sourceMarkets = useMemo5(() => {
3953
+ var _a2;
3954
+ if ((_a2 = eventTradingState == null ? void 0 : eventTradingState.marketStates) == null ? void 0 : _a2.length) {
3955
+ return eventTradingState.marketStates.map((item) => item.market);
3956
+ }
3957
+ if (providedMarkets) return providedMarkets;
3958
+ return rawMarkets;
3959
+ }, [eventTradingState == null ? void 0 : eventTradingState.marketStates, providedMarkets, rawMarkets]);
3960
+ const isResolvedEvent = useMemo5(() => {
3961
+ return resolveIsResolvedEvent(sourceMarkets, eventTradingState);
3962
+ }, [eventTradingState, sourceMarkets]);
3963
+ const groupedMarkets = useMemo5(() => {
3964
+ const sortedMarkets = sortMarketsByYesOddsDesc(sourceMarkets);
3965
+ if (sortedMarkets.length === 0) {
3966
+ return {
3967
+ primary: [],
3968
+ closed: [],
3969
+ upcoming: [],
3970
+ resolved: []
3971
+ };
3972
+ }
3973
+ if (isResolvedEvent) {
3974
+ const winnerMarketId = resolveResolvedWinnerMarketId(sortedMarkets, eventTradingState);
3975
+ return {
3976
+ primary: moveMarketToFront(sortedMarkets, winnerMarketId),
3977
+ upcoming: [],
3978
+ resolved: []
3979
+ };
3980
+ }
3981
+ const primary = [];
3982
+ const upcoming = [];
3983
+ const resolved = [];
3984
+ const closed = [];
3985
+ sortedMarkets.forEach((market) => {
3986
+ const marketStateKind = resolveMarketTradingState(market).kind;
3987
+ if (marketStateKind === "resolved") {
3988
+ resolved.push(market);
3989
+ return;
3990
+ }
3991
+ if (marketStateKind === "unopened") {
3992
+ upcoming.push(market);
3993
+ return;
3994
+ }
3995
+ if (marketStateKind === "closed") {
3996
+ closed.push(market);
3997
+ return;
3998
+ }
3999
+ primary.push(market);
4000
+ });
4001
+ return { primary, upcoming, resolved, closed };
4002
+ }, [eventTradingState, isResolvedEvent, sourceMarkets]);
4003
+ const shouldShowResolvedToggle = !isResolvedEvent && groupedMarkets.resolved.length > 0;
4004
+ const visibleResolvedMarkets = useMemo5(() => {
4005
+ if (isResolvedEvent || areResolvedMarketsVisible) return groupedMarkets.resolved;
4006
+ return [];
4007
+ }, [areResolvedMarketsVisible, groupedMarkets.resolved, isResolvedEvent]);
4008
+ const displayedMarkets = useMemo5(() => {
4009
+ return [...groupedMarkets.primary, ...visibleResolvedMarkets];
4010
+ }, [groupedMarkets.primary, visibleResolvedMarkets]);
4011
+ const hasPrefetchedMarkets = !!providedMarkets || !!((_b = eventTradingState == null ? void 0 : eventTradingState.marketStates) == null ? void 0 : _b.length);
4012
+ const { prices: midpointsFallback } = useViewportMidpoints(displayedMarkets);
4013
+ useEffect5(() => {
4014
+ if (isResolvedEvent) {
4015
+ setAreResolvedMarketsVisible(false);
4016
+ return;
4017
+ }
4018
+ if (groupedMarkets.resolved.length === 0) {
4019
+ setAreResolvedMarketsVisible(false);
4020
+ }
4021
+ }, [groupedMarkets.resolved.length, isResolvedEvent]);
4022
+ useEffect5(() => {
4023
+ if (previousSelectedMarketIdRef.current === selectedMarketId) return;
4024
+ previousSelectedMarketIdRef.current = selectedMarketId;
4025
+ if (!selectedMarketId) return;
4026
+ if (!displayedMarkets.some((market) => market.id === selectedMarketId)) return;
4027
+ setExpandedMarketId(selectedMarketId);
4028
+ }, [displayedMarkets, selectedMarketId]);
4029
+ useEffect5(() => {
4030
+ if (displayedMarkets.length === 0) return;
4031
+ if (selectedMarketId && displayedMarkets.some((market) => market.id === selectedMarketId)) {
4032
+ return;
4033
+ }
4034
+ if (selectedMarketId && sourceMarkets.some((market) => market.id === selectedMarketId)) {
4035
+ return;
4036
+ }
4037
+ const fallbackSelectableMarket = displayedMarkets.find(
4038
+ (market) => !resolveMarketTradingState(market).isTradingDisabled
4039
+ );
4040
+ if (!fallbackSelectableMarket) {
4041
+ return;
4042
+ }
4043
+ if (!expandedMarketId) {
4044
+ setExpandedMarketId(fallbackSelectableMarket.id);
4045
+ }
4046
+ tradingContext == null ? void 0 : tradingContext.selectMarket(fallbackSelectableMarket.id, fallbackSelectableMarket);
4047
+ }, [displayedMarkets, expandedMarketId, selectedMarketId, sourceMarkets, tradingContext]);
4048
+ useEffect5(() => {
4049
+ var _a2, _b2;
4050
+ if (!expandedMarketId) return;
4051
+ if (displayedMarkets.some((market) => market.id === expandedMarketId)) return;
4052
+ if (selectedMarketId && displayedMarkets.some((market) => market.id === selectedMarketId)) {
4053
+ setExpandedMarketId(selectedMarketId);
4054
+ return;
4055
+ }
4056
+ setExpandedMarketId((_b2 = (_a2 = displayedMarkets[0]) == null ? void 0 : _a2.id) != null ? _b2 : null);
4057
+ }, [displayedMarkets, expandedMarketId, selectedMarketId]);
4058
+ const handleToggle = (marketId, market) => {
4059
+ if (marketId === expandedMarketId) {
4060
+ setExpandedMarketId(null);
4061
+ onExpandedMarketChange == null ? void 0 : onExpandedMarketChange(null);
4062
+ return;
4063
+ }
4064
+ setExpandedMarketId(marketId);
4065
+ onExpandedMarketChange == null ? void 0 : onExpandedMarketChange(marketId);
4066
+ if (marketId === selectedMarketId) return;
4067
+ if (resolveMarketTradingState(market).isTradingDisabled) return;
4068
+ tradingContext == null ? void 0 : tradingContext.selectMarket(market.id, market);
4069
+ };
4070
+ if (!hasPrefetchedMarkets && isLoading) {
4071
+ return /* @__PURE__ */ jsxs7("div", { className: cn("agg-market-list flex flex-col gap-3", classNames == null ? void 0 : classNames.root), children: [
4072
+ /* @__PURE__ */ jsx9(
4073
+ MarketDetailsLoadingState,
4074
+ {
4075
+ isOpened: true,
4076
+ classNames: { root: cn("agg-market-list-item", classNames == null ? void 0 : classNames.item) }
4077
+ }
4078
+ ),
4079
+ /* @__PURE__ */ jsx9(
4080
+ MarketDetailsLoadingState,
4081
+ {
4082
+ isOpened: false,
4083
+ classNames: { root: cn("agg-market-list-item", classNames == null ? void 0 : classNames.item) }
4084
+ }
4085
+ )
4086
+ ] });
4087
+ }
4088
+ if (!hasPrefetchedMarkets && error) {
4089
+ return /* @__PURE__ */ jsx9(
4090
+ StateMessage,
4091
+ {
4092
+ title: labels.marketDetails.unavailableTitle,
4093
+ description: labels.marketDetails.unavailableDescription,
4094
+ icon: /* @__PURE__ */ jsx9(SearchEmptyIcon, {}),
4095
+ classNames: { root: "min-h-[280px] md:min-h-[320px]" }
4096
+ }
4097
+ );
4098
+ }
4099
+ if (displayedMarkets.length === 0 && !shouldShowResolvedToggle) {
4100
+ const hasSourceMarkets = sourceMarkets.length > 0;
4101
+ return /* @__PURE__ */ jsx9(
4102
+ StateMessage,
4103
+ {
4104
+ title: hasSourceMarkets ? isResolvedEvent ? labels.markets.emptyResolved : labels.markets.emptyNoOpen : labels.marketDetails.notFoundTitle,
4105
+ description: hasSourceMarkets ? void 0 : labels.marketDetails.notFoundDescription,
4106
+ icon: /* @__PURE__ */ jsx9(SearchEmptyIcon, {}),
4107
+ classNames: { root: "min-h-[280px] md:min-h-[320px]" }
4108
+ }
4109
+ );
4110
+ }
4111
+ const renderMarketCard = (market) => /* @__PURE__ */ jsx9("div", { children: /* @__PURE__ */ jsx9(
4112
+ MarketDetails,
4113
+ {
4114
+ marketId: market.id,
4115
+ venueMarkets: sourceMarkets,
4116
+ isOpened: expandedMarketId === market.id,
4117
+ onOpenChange: (marketId) => {
4118
+ onClick == null ? void 0 : onClick(market);
4119
+ handleToggle(marketId, market);
4120
+ },
4121
+ defaultTab,
4122
+ ariaLabel: market.question,
4123
+ classNames: { root: cn("agg-market-list-item", classNames == null ? void 0 : classNames.item) },
4124
+ live,
4125
+ midpointsFallback
4126
+ }
4127
+ ) }, market.id);
4128
+ return /* @__PURE__ */ jsxs7("div", { className: cn("agg-market-list flex flex-col gap-3", classNames == null ? void 0 : classNames.root), children: [
4129
+ groupedMarkets.primary.map((market) => renderMarketCard(market)),
4130
+ shouldShowResolvedToggle ? /* @__PURE__ */ jsx9(
4131
+ Button,
4132
+ {
4133
+ variant: "tertiary",
4134
+ size: "small",
4135
+ className: "agg-market-view-resolved-toggle self-start",
4136
+ onClick: () => {
4137
+ setAreResolvedMarketsVisible((isVisible) => !isVisible);
4138
+ },
4139
+ "aria-expanded": areResolvedMarketsVisible,
4140
+ suffix: /* @__PURE__ */ jsx9(
4141
+ Icon,
4142
+ {
4143
+ name: areResolvedMarketsVisible ? "chevron-up" : "chevron-down",
4144
+ size: "small",
4145
+ className: "h-4 w-4",
4146
+ "aria-hidden": "true"
4147
+ }
4148
+ ),
4149
+ children: areResolvedMarketsVisible ? labels.marketDetails.hideResolved : labels.marketDetails.viewResolved
4150
+ }
4151
+ ) : null,
4152
+ visibleResolvedMarkets.map((market) => renderMarketCard(market))
4153
+ ] });
4154
+ };
4155
+ MarketDetailsList.displayName = "MarketDetailsList";
4156
+
4157
+ // src/events/list/index.tsx
4158
+ import { MarketStatus as MarketStatus2, useAppConfig as useAppConfig2, useLabels as useLabels8, useVenueEvents } from "@agg-build/hooks";
4159
+ import { VENUES } from "@agg-build/sdk";
4160
+ import { useEffect as useEffect7, useMemo as useMemo7, useRef as useRef8, useState as useState7 } from "react";
4161
+
4162
+ // src/events/list/event-list-tabs.tsx
4163
+ import { useAppConfig, useLabels as useLabels7 } from "@agg-build/hooks";
4164
+ import { useCallback as useCallback4, useEffect as useEffect6, useMemo as useMemo6, useRef as useRef7, useState as useState6 } from "react";
4165
+ import { jsx as jsx10 } from "react/jsx-runtime";
4166
+ var renderTabIcon = (tab, isActive) => {
4167
+ if (tab.venueLogo) {
4168
+ return /* @__PURE__ */ jsx10(VenueLogo, { venue: tab.venueLogo, size: "small" });
4169
+ }
4170
+ if (!tab.iconName) return null;
4171
+ return /* @__PURE__ */ jsx10(
4172
+ Icon,
4173
+ {
4174
+ name: tab.iconName,
4175
+ size: "small",
4176
+ color: isActive ? "var(--agg-color-primary)" : "var(--agg-color-foreground)"
4177
+ }
4178
+ );
4179
+ };
4180
+ var useEventListTabs = (tabs) => {
4181
+ const labels = useLabels7();
4182
+ const { disabledVenues } = useAppConfig();
4183
+ return useMemo6(() => {
4184
+ const baseTabs = tabs != null ? tabs : getDefaultEventListTabs(labels);
4185
+ if (disabledVenues.length === 0) return baseTabs;
4186
+ const disabled = new Set(disabledVenues);
4187
+ return baseTabs.filter((tab) => {
4188
+ if (!tab.venueLogo) return true;
4189
+ return !disabled.has(tab.venueLogo);
4190
+ });
4191
+ }, [tabs, labels, disabledVenues]);
4192
+ };
4193
+ var EventListTabs = ({
4194
+ tabs,
4195
+ activeTab,
4196
+ onTabChange,
4197
+ ariaLabel,
4198
+ className,
4199
+ overflowBehavior
4200
+ }) => {
4201
+ const resolvedTabs = useEventListTabs(tabs);
4202
+ useEffect6(() => {
4203
+ if (resolvedTabs.length === 0) return;
4204
+ if (resolvedTabs.some((tab) => tab.value === activeTab)) return;
4205
+ onTabChange(resolvedTabs[0].value);
4206
+ }, [activeTab, onTabChange, resolvedTabs]);
4207
+ const items = useMemo6(() => {
4208
+ return resolvedTabs.map((tab) => {
4209
+ const isActive = tab.value === activeTab;
4210
+ return {
4211
+ value: tab.value,
4212
+ label: tab.label,
4213
+ icon: renderTabIcon(tab, isActive),
4214
+ disabled: tab.disabled,
4215
+ isComingSoon: tab.isComingSoon
4216
+ };
4217
+ });
4218
+ }, [activeTab, resolvedTabs]);
4219
+ return /* @__PURE__ */ jsx10(
4220
+ Tabs,
4221
+ {
4222
+ ariaLabel,
4223
+ className,
4224
+ items,
4225
+ overflowBehavior,
4226
+ value: activeTab,
4227
+ onChange: onTabChange
4228
+ }
4229
+ );
4230
+ };
4231
+ EventListTabs.displayName = "EventListTabs";
4232
+ var useEventListTabsHeaderOverflow = (recomputeOn) => {
4233
+ const headerRef = useRef7(null);
4234
+ const titleRef = useRef7(null);
4235
+ const requiredTabsWidthRef = useRef7(0);
4236
+ const [shouldUseSelectOverflow, setShouldUseSelectOverflow] = useState6(false);
4237
+ const updateTabsOverflowBehavior = useCallback4(() => {
4238
+ if (typeof window === "undefined") return;
4239
+ const headerElement = headerRef.current;
4240
+ const titleElement = titleRef.current;
4241
+ if (!headerElement || !titleElement) return;
4242
+ const headerStyles = window.getComputedStyle(headerElement);
4243
+ const rawGap = headerStyles.columnGap || headerStyles.gap || "0";
4244
+ const horizontalGap = Number.parseFloat(rawGap) || 0;
4245
+ const availableTabsWidth = headerElement.clientWidth - titleElement.getBoundingClientRect().width - horizontalGap;
4246
+ if (availableTabsWidth <= 0) {
4247
+ setShouldUseSelectOverflow(true);
4248
+ return;
4249
+ }
4250
+ const tabListElement = headerElement.querySelector(".agg-tab-list");
4251
+ if (tabListElement) {
4252
+ const currentRequiredWidth = tabListElement.scrollWidth;
4253
+ if (currentRequiredWidth > 0) {
4254
+ requiredTabsWidthRef.current = currentRequiredWidth;
4255
+ }
4256
+ const hasRealOverflow = tabListElement.scrollWidth - tabListElement.clientWidth > 1;
4257
+ setShouldUseSelectOverflow(hasRealOverflow);
4258
+ return;
4259
+ }
4260
+ if (requiredTabsWidthRef.current <= 0) return;
4261
+ setShouldUseSelectOverflow(requiredTabsWidthRef.current > availableTabsWidth);
4262
+ }, []);
4263
+ useEffect6(() => {
4264
+ updateTabsOverflowBehavior();
4265
+ }, [recomputeOn, updateTabsOverflowBehavior]);
4266
+ useEffect6(() => {
4267
+ if (typeof window === "undefined") return;
4268
+ const handleResize = () => {
4269
+ updateTabsOverflowBehavior();
4270
+ };
4271
+ window.addEventListener("resize", handleResize);
4272
+ return () => {
4273
+ window.removeEventListener("resize", handleResize);
4274
+ };
4275
+ }, [updateTabsOverflowBehavior]);
4276
+ useEffect6(() => {
4277
+ if (typeof ResizeObserver === "undefined") return;
4278
+ const headerElement = headerRef.current;
4279
+ const titleElement = titleRef.current;
4280
+ if (!headerElement || !titleElement) return;
4281
+ const resizeObserver = new ResizeObserver(() => {
4282
+ updateTabsOverflowBehavior();
4283
+ });
4284
+ resizeObserver.observe(headerElement);
4285
+ resizeObserver.observe(titleElement);
4286
+ return () => {
4287
+ resizeObserver.disconnect();
4288
+ };
4289
+ }, [updateTabsOverflowBehavior]);
4290
+ return { headerRef, titleRef, shouldUseSelectOverflow };
4291
+ };
4292
+
4293
+ // src/events/list/index.tsx
4294
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
4295
+ var EventList = ({
4296
+ title,
4297
+ limit = DEFAULT_EVENTS_LIMIT,
4298
+ maxVisibleItems,
4299
+ search,
4300
+ categoryIds,
4301
+ onEventClick,
4302
+ onMarketClick,
4303
+ getMarketHref,
4304
+ getEventHref,
4305
+ initialVenueTab,
4306
+ initialLoadedPageCount,
4307
+ stateRef
4308
+ }) => {
4309
+ var _a, _b;
4310
+ const labels = useLabels8();
4311
+ const { disabledVenues } = useAppConfig2();
4312
+ const resolvedTabs = useEventListTabs();
4313
+ const visibleVenues = useMemo7(
4314
+ () => disabledVenues.length === 0 ? void 0 : VENUES.filter(
4315
+ (v) => !disabledVenues.includes(v)
4316
+ ),
4317
+ [disabledVenues]
4318
+ );
4319
+ const [activeTabValue, setActiveTabValue] = useState7(
4320
+ (_b = initialVenueTab != null ? initialVenueTab : (_a = resolvedTabs[0]) == null ? void 0 : _a.value) != null ? _b : "matched"
4321
+ );
4322
+ const { headerRef, titleRef, shouldUseSelectOverflow } = useEventListTabsHeaderOverflow(resolvedTabs);
4323
+ const activeTab = useMemo7(() => {
4324
+ return resolvedTabs.find((tab) => tab.value === activeTabValue);
4325
+ }, [activeTabValue, resolvedTabs]);
4326
+ const venues = useMemo7(() => {
4327
+ return resolveTabVenus(activeTab, visibleVenues);
4328
+ }, [activeTab, visibleVenues]);
4329
+ const matchStatus = useMemo7(() => {
4330
+ return activeTabValue === "matched" ? activeTab == null ? void 0 : activeTab.matchStatus : void 0;
4331
+ }, [activeTabValue, activeTab]);
4332
+ const resolvedMaxVisibleItems = useMemo7(() => {
4333
+ if (!Number.isFinite(maxVisibleItems)) return void 0;
4334
+ return Math.max(1, Math.floor(maxVisibleItems));
4335
+ }, [maxVisibleItems]);
4336
+ const requestLimit = resolvedMaxVisibleItems != null ? resolvedMaxVisibleItems : limit;
4337
+ const shouldPaginate = resolvedMaxVisibleItems == null;
4338
+ const endDateFrom = useMemo7(() => {
4339
+ if (search) return void 0;
4340
+ const BUCKET_MINUTES = 5;
4341
+ const bucket = /* @__PURE__ */ new Date();
4342
+ bucket.setMinutes(Math.floor(bucket.getMinutes() / BUCKET_MINUTES) * BUCKET_MINUTES, 0, 0);
4343
+ return bucket.toISOString();
4344
+ }, [search]);
4345
+ const {
4346
+ events,
4347
+ isLoading,
4348
+ isError,
4349
+ fetchNextPage,
4350
+ hasNextPage,
4351
+ isFetchingNextPage,
4352
+ isPlaceholderData,
4353
+ loadedPageCount
4354
+ } = useVenueEvents(__spreadProps(__spreadValues({
4355
+ queryKeyScope: "event-list",
4356
+ venues,
4357
+ search,
4358
+ categoryIds,
4359
+ matchStatus,
4360
+ limit: requestLimit,
4361
+ status: [MarketStatus2.open],
4362
+ sortBy: "volume24hr",
4363
+ sortDir: "desc",
4364
+ endDateFrom
4365
+ }, !search ? {
4366
+ minYesPrice: 0.03,
4367
+ maxYesPrice: 0.97
4368
+ } : {}), {
4369
+ initialPages: initialLoadedPageCount
4370
+ }));
4371
+ useEffect7(() => {
4372
+ if (stateRef) {
4373
+ stateRef.current = { venueTab: activeTabValue, loadedPageCount };
4374
+ }
4375
+ }, [stateRef, activeTabValue, loadedPageCount]);
4376
+ const filteredEvents = useMemo7(() => {
4377
+ return filterEventsByTabValue(events, activeTabValue);
4378
+ }, [events, activeTabValue]);
4379
+ const groupedEvents = useMemo7(() => {
4380
+ return splitEventsByLifecycle(filteredEvents);
4381
+ }, [filteredEvents]);
4382
+ const orderedEvents = useMemo7(() => {
4383
+ return groupedEvents.open;
4384
+ }, [groupedEvents.open]);
4385
+ const tileEvents = useMemo7(() => {
4386
+ const normalizedEvents = orderedEvents.map((event) => mapEventToEventListItemEvent(event)).filter((event) => event != null);
4387
+ if (resolvedMaxVisibleItems == null) return normalizedEvents;
4388
+ return normalizedEvents.slice(0, resolvedMaxVisibleItems);
4389
+ }, [orderedEvents, resolvedMaxVisibleItems]);
4390
+ const shouldRenderLoadingState = isLoading && !isPlaceholderData && tileEvents.length === 0;
4391
+ const shouldRenderEmptyState = !isLoading && !isError && tileEvents.length === 0;
4392
+ const shouldRenderPaginationLoadingItems = shouldPaginate && hasNextPage;
4393
+ const loadMoreRef = useRef8(null);
4394
+ useEffect7(() => {
4395
+ if (!shouldPaginate) return;
4396
+ if (!hasNextPage) return;
4397
+ if (typeof IntersectionObserver === "undefined") return;
4398
+ const target = loadMoreRef.current;
4399
+ if (!target) return;
4400
+ const observer = new IntersectionObserver(
4401
+ (entries) => {
4402
+ const entry = entries[0];
4403
+ if (!(entry == null ? void 0 : entry.isIntersecting)) return;
4404
+ if (isLoading || isFetchingNextPage || !hasNextPage) return;
4405
+ void fetchNextPage();
4406
+ },
4407
+ {
4408
+ rootMargin: "320px 0px"
4409
+ }
4410
+ );
4411
+ observer.observe(target);
4412
+ return () => {
4413
+ observer.disconnect();
4414
+ };
4415
+ }, [fetchNextPage, hasNextPage, isFetchingNextPage, isLoading, shouldPaginate]);
4416
+ const gridClassName = cn(
4417
+ "grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] md:grid-cols-[repeat(auto-fill,minmax(360px,1fr))] gap-4"
4418
+ );
4419
+ if (shouldRenderLoadingState) {
4420
+ return /* @__PURE__ */ jsx11(Skeleton, { view: "event-list", ariaLabel: labels.eventList.loading(title) });
4421
+ }
4422
+ return /* @__PURE__ */ jsxs8("section", { className: "agg-event-list flex w-full flex-col gap-5", children: [
4423
+ /* @__PURE__ */ jsxs8(
4424
+ "header",
4425
+ {
4426
+ ref: headerRef,
4427
+ className: cn(
4428
+ "agg-event-list-header",
4429
+ "flex flex-col w-full items-start justify-between",
4430
+ "gap-2 sm:flex-row sm:items-center sm:gap-4"
4431
+ ),
4432
+ children: [
4433
+ /* @__PURE__ */ jsx11("div", { ref: titleRef, className: "agg-event-list-title min-w-32", children: /* @__PURE__ */ jsx11(Typography, { as: "h2", variant: "title", className: "truncate first-letter:uppercase", children: title }) }),
4434
+ /* @__PURE__ */ jsx11(
4435
+ EventListTabs,
4436
+ {
4437
+ ariaLabel: labels.eventList.tabsAria(title),
4438
+ className: "agg-event-list-tabs min-w-0 max-w-full",
4439
+ activeTab: activeTabValue,
4440
+ onTabChange: setActiveTabValue,
4441
+ overflowBehavior: shouldUseSelectOverflow ? "select" : void 0
4442
+ }
4443
+ )
4444
+ ]
4445
+ }
4446
+ ),
4447
+ /* @__PURE__ */ jsxs8("div", { className: cn("agg-event-list-grid", isPlaceholderData && "opacity-60", gridClassName), children: [
4448
+ tileEvents.map((event) => /* @__PURE__ */ jsx11(
4449
+ EventListItem,
4450
+ {
4451
+ event,
4452
+ classNames: {
4453
+ root: "agg-event-list-item w-full min-w-0 max-w-none"
4454
+ },
4455
+ onEventClick,
4456
+ onMarketClick,
4457
+ getMarketHref,
4458
+ href: getEventHref == null ? void 0 : getEventHref(event)
4459
+ },
4460
+ event.id
4461
+ )),
4462
+ shouldRenderPaginationLoadingItems ? Array.from({ length: 6 }).map((_, index) => /* @__PURE__ */ jsx11(
4463
+ EventListItem,
4464
+ {
4465
+ isLoading: true,
4466
+ classNames: {
4467
+ root: "agg-event-list-item w-full min-w-0 max-w-none"
4468
+ }
4469
+ },
4470
+ `loading-${index}`
4471
+ )) : null,
4472
+ shouldRenderEmptyState ? /* @__PURE__ */ jsx11("div", { className: "col-span-full w-full", children: /* @__PURE__ */ jsx11(
4473
+ StateMessage,
4474
+ {
4475
+ title: labels.eventList.emptyTitle,
4476
+ description: labels.eventList.emptyDescription,
4477
+ icon: /* @__PURE__ */ jsx11(Icon, { name: "search-empty" })
4478
+ }
4479
+ ) }) : null,
4480
+ isError ? /* @__PURE__ */ jsx11(
4481
+ StateMessage,
4482
+ {
4483
+ title: labels.eventList.errorTitle,
4484
+ description: labels.eventList.errorDescription,
4485
+ icon: /* @__PURE__ */ jsx11(Icon, { name: "warning" })
4486
+ }
4487
+ ) : null
4488
+ ] }),
4489
+ shouldPaginate && hasNextPage ? /* @__PURE__ */ jsx11("div", { ref: loadMoreRef, className: "agg-event-list-sentinel h-px w-full", "aria-hidden": true }) : null
4490
+ ] });
4491
+ };
4492
+ EventList.displayName = "EventList";
4493
+
4494
+ export {
4495
+ isErrorWithStatus,
4496
+ EventListItem,
4497
+ collectEligibleVenueOutcomes,
4498
+ collectEligibleVenueOutcomeIds,
4499
+ mergeVenueOutcomeOrderbooks,
4500
+ SettlementSummary,
4501
+ EventListItemDetails,
4502
+ orderbookRowLimitDefault,
4503
+ useCenterOrderbookSpread,
4504
+ OrderbookWithStates,
4505
+ Orderbook,
4506
+ MarketDetails,
4507
+ MarketDetailsList,
4508
+ useEventListTabs,
4509
+ EventListTabs,
4510
+ useEventListTabsHeaderOverflow,
4511
+ EventList
4512
+ };