@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,3813 @@
1
+ "use client";
2
+ import {
3
+ formatProbabilityCents,
4
+ resolveOrderEligibilityMessage
5
+ } from "./chunk-C7T56TJR.mjs";
6
+ import {
7
+ GeoBlockBanner
8
+ } from "./chunk-2QJXRRYP.mjs";
9
+ import {
10
+ Button,
11
+ Card,
12
+ CloseIcon,
13
+ CurrencyInput,
14
+ Icon,
15
+ InlineAlert,
16
+ LoadingIcon,
17
+ Modal,
18
+ RemoteImage,
19
+ Skeleton,
20
+ SuccessCheckIcon,
21
+ Typography,
22
+ UserTrustIcon,
23
+ VenueLogo,
24
+ __async,
25
+ __spreadProps,
26
+ __spreadValues,
27
+ cn,
28
+ formatUsd,
29
+ getMotionClassName,
30
+ skeletonViews
31
+ } from "./chunk-6NS7D73S.mjs";
32
+
33
+ // src/trading/types.ts
34
+ import { Venue, enumGuard, isFiniteNonNeg, safeParse } from "@agg-build/sdk";
35
+ var isVenue = enumGuard(Venue);
36
+ var parseVenue = (v) => safeParse(v, isVenue);
37
+ var parseAmount = (v) => safeParse(v, isFiniteNonNeg);
38
+
39
+ // src/trading/utils.ts
40
+ import { resolveAggUiLabels } from "@agg-build/hooks";
41
+ import dayjs from "dayjs";
42
+ var defaultLabels = resolveAggUiLabels("en-US");
43
+ var defaultSettlementSectionLabel = defaultLabels.trading.settlementSection;
44
+ var defaultSettlementDifferencesTitle = defaultLabels.trading.settlementDifferencesTitle;
45
+ var defaultTradingDisclaimer = defaultLabels.trading.disclaimer;
46
+ var getTradingDateLabel = (value) => {
47
+ const parsedValue = dayjs(value);
48
+ if (!parsedValue.isValid()) {
49
+ return typeof value === "string" ? value : "";
50
+ }
51
+ return parsedValue.format("MMM D, YYYY");
52
+ };
53
+ var getTradingVenueLabel = (venue, label) => {
54
+ var _a;
55
+ if (label) return label;
56
+ if (!venue) return "Unknown";
57
+ return (_a = defaultLabels.venues[venue]) != null ? _a : venue;
58
+ };
59
+ var getTradingValueLabel = ({
60
+ amount,
61
+ minimumFractionDigits = 0,
62
+ maximumFractionDigits = 2
63
+ }) => {
64
+ return amount.toLocaleString("en-US", {
65
+ style: "currency",
66
+ currency: "USD",
67
+ minimumFractionDigits,
68
+ maximumFractionDigits
69
+ });
70
+ };
71
+ var getTradingPriceLabel = (value) => {
72
+ return `${Math.round(value * 100)}\xA2`;
73
+ };
74
+ var getTradingAveragePriceLabel = (value) => {
75
+ return defaultLabels.trading.averagePrice(value);
76
+ };
77
+ var getTradingBalanceLabel = (value) => {
78
+ return defaultLabels.trading.balance(formatUsd(value));
79
+ };
80
+ var getTradingSharesLabel = (value) => {
81
+ return defaultLabels.trading.shares(value);
82
+ };
83
+ var getTradingSlippageLabel = (value) => {
84
+ return defaultLabels.trading.slippage(value);
85
+ };
86
+
87
+ // src/trading/settlement/index.tsx
88
+ import { useLabels, useSdkUiConfig } from "@agg-build/hooks";
89
+ import { useCallback, useEffect, useRef, useState } from "react";
90
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
91
+ var getSettlementHeaderClassName = () => {
92
+ return "flex items-center justify-between gap-4";
93
+ };
94
+ var Settlement = ({
95
+ sectionLabel = defaultSettlementSectionLabel,
96
+ question,
97
+ differencesTitle = defaultSettlementDifferencesTitle,
98
+ differences = [],
99
+ venues,
100
+ expandedVenue,
101
+ isLoading = false,
102
+ onExpandedVenueChange,
103
+ onShowMore,
104
+ className
105
+ }) => {
106
+ var _a, _b;
107
+ const labels = useLabels();
108
+ const {
109
+ features: { enableAnimations }
110
+ } = useSdkUiConfig();
111
+ const [internalExpandedVenue, setInternalExpandedVenue] = useState(
112
+ (_b = (_a = venues[0]) == null ? void 0 : _a.venue) != null ? _b : null
113
+ );
114
+ const [expandedDescriptionByVenue, setExpandedDescriptionByVenue] = useState({});
115
+ const [overflowingDescriptionByVenue, setOverflowingDescriptionByVenue] = useState({});
116
+ const [collapsedDescriptionByVenue, setCollapsedDescriptionByVenue] = useState({});
117
+ const descriptionWrapperRefs = useRef(/* @__PURE__ */ new Map());
118
+ const descriptionMeasureRefs = useRef(/* @__PURE__ */ new Map());
119
+ useEffect(() => {
120
+ if (expandedVenue === void 0) return;
121
+ setInternalExpandedVenue(expandedVenue);
122
+ }, [expandedVenue]);
123
+ const resolvedExpandedVenue = expandedVenue === void 0 ? internalExpandedVenue : expandedVenue;
124
+ const handleVenueClick = (venue) => {
125
+ const nextVenue = resolvedExpandedVenue === venue ? null : venue;
126
+ if (expandedVenue === void 0) {
127
+ setInternalExpandedVenue(nextVenue);
128
+ }
129
+ onExpandedVenueChange == null ? void 0 : onExpandedVenueChange(nextVenue);
130
+ };
131
+ const handleDescriptionWrapperRef = useCallback(
132
+ (venue, element) => {
133
+ if (!element) {
134
+ descriptionWrapperRefs.current.delete(venue);
135
+ return;
136
+ }
137
+ descriptionWrapperRefs.current.set(venue, element);
138
+ },
139
+ []
140
+ );
141
+ const handleDescriptionMeasureRef = useCallback(
142
+ (venue, element) => {
143
+ if (!element) {
144
+ descriptionMeasureRefs.current.delete(venue);
145
+ return;
146
+ }
147
+ descriptionMeasureRefs.current.set(venue, element);
148
+ },
149
+ []
150
+ );
151
+ const updateDescriptionLayout = useCallback(
152
+ (venue, description, showMoreLabel) => {
153
+ const descriptionWrapperElement = descriptionWrapperRefs.current.get(venue);
154
+ const descriptionMeasureElement = descriptionMeasureRefs.current.get(venue);
155
+ if (!descriptionWrapperElement || !descriptionMeasureElement) return;
156
+ const wrapperWidth = descriptionWrapperElement.clientWidth;
157
+ if (wrapperWidth <= 0) return;
158
+ const computedStyles = window.getComputedStyle(descriptionWrapperElement);
159
+ const parsedLineHeight = Number.parseFloat(computedStyles.lineHeight);
160
+ const lineHeight = Number.isFinite(parsedLineHeight) ? parsedLineHeight : 20;
161
+ const maxHeight = lineHeight * 2 + 1;
162
+ descriptionMeasureElement.style.width = `${wrapperWidth}px`;
163
+ const getHeight = (value) => {
164
+ descriptionMeasureElement.textContent = value;
165
+ return descriptionMeasureElement.scrollHeight;
166
+ };
167
+ const fullHeight = getHeight(description);
168
+ if (fullHeight <= maxHeight) {
169
+ setOverflowingDescriptionByVenue((currentState) => {
170
+ if (currentState[venue] === false) return currentState;
171
+ return __spreadProps(__spreadValues({}, currentState), {
172
+ [venue]: false
173
+ });
174
+ });
175
+ setCollapsedDescriptionByVenue((currentState) => {
176
+ if (currentState[venue] === description) return currentState;
177
+ return __spreadProps(__spreadValues({}, currentState), {
178
+ [venue]: description
179
+ });
180
+ });
181
+ return;
182
+ }
183
+ const suffix = `... ${showMoreLabel}`;
184
+ let left = 0;
185
+ let right = description.length;
186
+ let bestLength = 0;
187
+ while (left <= right) {
188
+ const middle = Math.floor((left + right) / 2);
189
+ const candidate = description.slice(0, middle).trimEnd();
190
+ const candidateHeight = getHeight(`${candidate}${suffix}`);
191
+ if (candidateHeight <= maxHeight) {
192
+ bestLength = middle;
193
+ left = middle + 1;
194
+ continue;
195
+ }
196
+ right = middle - 1;
197
+ }
198
+ const collapsedDescription = description.slice(0, bestLength).trimEnd();
199
+ setOverflowingDescriptionByVenue((currentState) => {
200
+ if (currentState[venue] === true) return currentState;
201
+ return __spreadProps(__spreadValues({}, currentState), {
202
+ [venue]: true
203
+ });
204
+ });
205
+ setCollapsedDescriptionByVenue((currentState) => {
206
+ if (currentState[venue] === collapsedDescription) return currentState;
207
+ return __spreadProps(__spreadValues({}, currentState), {
208
+ [venue]: collapsedDescription
209
+ });
210
+ });
211
+ },
212
+ []
213
+ );
214
+ useEffect(() => {
215
+ if (typeof window === "undefined") return;
216
+ if (!resolvedExpandedVenue) return;
217
+ if (expandedDescriptionByVenue[resolvedExpandedVenue]) return;
218
+ const expandedVenueItem = venues.find((venueItem) => venueItem.venue === resolvedExpandedVenue);
219
+ if (!expandedVenueItem) return;
220
+ const frameId = window.requestAnimationFrame(() => {
221
+ var _a2;
222
+ updateDescriptionLayout(
223
+ resolvedExpandedVenue,
224
+ expandedVenueItem.description,
225
+ (_a2 = expandedVenueItem.showMoreLabel) != null ? _a2 : "Show more"
226
+ );
227
+ });
228
+ return () => {
229
+ window.cancelAnimationFrame(frameId);
230
+ };
231
+ }, [expandedDescriptionByVenue, resolvedExpandedVenue, updateDescriptionLayout, venues]);
232
+ useEffect(() => {
233
+ if (!resolvedExpandedVenue) return;
234
+ if (expandedDescriptionByVenue[resolvedExpandedVenue]) return;
235
+ if (typeof ResizeObserver === "undefined") return;
236
+ const expandedVenueItem = venues.find((venueItem) => venueItem.venue === resolvedExpandedVenue);
237
+ if (!expandedVenueItem) return;
238
+ const descriptionWrapperElement = descriptionWrapperRefs.current.get(resolvedExpandedVenue);
239
+ if (!descriptionWrapperElement) return;
240
+ const resizeObserver = new ResizeObserver(() => {
241
+ var _a2;
242
+ updateDescriptionLayout(
243
+ resolvedExpandedVenue,
244
+ expandedVenueItem.description,
245
+ (_a2 = expandedVenueItem.showMoreLabel) != null ? _a2 : "Show more"
246
+ );
247
+ });
248
+ resizeObserver.observe(descriptionWrapperElement);
249
+ return () => {
250
+ resizeObserver.disconnect();
251
+ };
252
+ }, [expandedDescriptionByVenue, resolvedExpandedVenue, updateDescriptionLayout, venues]);
253
+ const handleDescriptionShowMoreClick = (event, venue) => {
254
+ event == null ? void 0 : event.stopPropagation();
255
+ setExpandedDescriptionByVenue((currentState) => {
256
+ if (currentState[venue]) return currentState;
257
+ return __spreadProps(__spreadValues({}, currentState), {
258
+ [venue]: true
259
+ });
260
+ });
261
+ onShowMore == null ? void 0 : onShowMore(venue);
262
+ };
263
+ if (isLoading) {
264
+ return /* @__PURE__ */ jsx(
265
+ Skeleton,
266
+ {
267
+ ariaLabel: labels.trading.settlementLoading,
268
+ className,
269
+ view: skeletonViews.settlement
270
+ }
271
+ );
272
+ }
273
+ return /* @__PURE__ */ jsxs(
274
+ Card,
275
+ {
276
+ className: cn(
277
+ "group/agg-settlement-card",
278
+ "flex flex-col w-full gap-5 rounded-agg-xl border border-agg-separator bg-agg-secondary p-5 shadow-none hover:shadow-none",
279
+ className
280
+ ),
281
+ children: [
282
+ /* @__PURE__ */ jsxs("div", { className: cn("agg-settlement-header", getSettlementHeaderClassName()), children: [
283
+ /* @__PURE__ */ jsx("p", { className: "text-agg-xs font-agg-bold leading-agg-4 uppercase text-agg-muted-foreground", children: sectionLabel === defaultSettlementSectionLabel ? labels.trading.settlementSection : sectionLabel }),
284
+ question ? /* @__PURE__ */ jsx("p", { className: "agg-settlement-question text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: question }) : null
285
+ ] }),
286
+ differences.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
287
+ /* @__PURE__ */ jsxs("div", { className: "agg-settlement-differences flex flex-col gap-2", children: [
288
+ /* @__PURE__ */ jsx("p", { className: "agg-settlement-differences-title text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground", children: differencesTitle === defaultSettlementDifferencesTitle ? labels.trading.settlementDifferencesTitle : differencesTitle }),
289
+ /* @__PURE__ */ jsx("ul", { className: "agg-settlement-differences-list list-disc pl-5 text-agg-sm leading-agg-5 text-agg-foreground", children: differences.map((difference) => /* @__PURE__ */ jsx("li", { children: difference }, difference)) })
290
+ ] }),
291
+ /* @__PURE__ */ jsx("div", { className: "h-px w-full bg-agg-separator" })
292
+ ] }) : null,
293
+ /* @__PURE__ */ jsx("div", { className: "agg-settlement-venues flex flex-col gap-3", children: venues.map((venue) => {
294
+ var _a2, _b2;
295
+ const venueLabel = getTradingVenueLabel(venue.venue, venue.label);
296
+ const isExpanded = resolvedExpandedVenue === venue.venue;
297
+ const isDescriptionExpanded = !!expandedDescriptionByVenue[venue.venue];
298
+ const isDescriptionOverflowing = !!overflowingDescriptionByVenue[venue.venue];
299
+ const shouldShowDescriptionCta = isExpanded && isDescriptionOverflowing && !isDescriptionExpanded;
300
+ const resolvedShowMoreLabel = (_a2 = venue.showMoreLabel) != null ? _a2 : "Show more";
301
+ return /* @__PURE__ */ jsxs("div", { className: "agg-settlement-venue flex flex-col", children: [
302
+ /* @__PURE__ */ jsxs(
303
+ "button",
304
+ {
305
+ type: "button",
306
+ className: cn(
307
+ "agg-settlement-venue-trigger",
308
+ "flex items-center gap-2 text-left",
309
+ "cursor-pointer disabled:cursor-not-allowed hover:opacity-50",
310
+ getMotionClassName(
311
+ enableAnimations,
312
+ "transition-[opacity,color] duration-200 ease-in-out"
313
+ )
314
+ ),
315
+ "aria-expanded": isExpanded,
316
+ "aria-label": labels.trading.settlementDetailsAria(venueLabel),
317
+ onClick: (e) => {
318
+ e.stopPropagation();
319
+ e.preventDefault();
320
+ handleVenueClick(venue.venue);
321
+ },
322
+ children: [
323
+ /* @__PURE__ */ jsx(
324
+ VenueLogo,
325
+ {
326
+ venue: venue.venue,
327
+ size: "small",
328
+ ariaLabel: venueLabel
329
+ }
330
+ ),
331
+ /* @__PURE__ */ jsx(
332
+ "span",
333
+ {
334
+ className: cn(
335
+ "text-agg-sm font-agg-bold leading-agg-5 text-agg-foreground",
336
+ "text-agg-foreground"
337
+ ),
338
+ children: venueLabel
339
+ }
340
+ ),
341
+ /* @__PURE__ */ jsx(
342
+ Icon,
343
+ {
344
+ name: isExpanded ? "chevron-up" : "chevron-down",
345
+ size: "small",
346
+ className: "text-agg-foreground",
347
+ color: "currentColor"
348
+ }
349
+ )
350
+ ]
351
+ }
352
+ ),
353
+ /* @__PURE__ */ jsx(
354
+ "div",
355
+ {
356
+ "aria-hidden": !isExpanded,
357
+ className: cn(
358
+ "grid overflow-hidden",
359
+ isExpanded ? "mt-2 grid-rows-[1fr] opacity-100" : "mt-0 grid-rows-[0fr] opacity-0",
360
+ !isExpanded && "pointer-events-none",
361
+ getMotionClassName(
362
+ enableAnimations,
363
+ "transition-[grid-template-rows,opacity,margin-top] duration-300 ease-in-out"
364
+ )
365
+ ),
366
+ children: /* @__PURE__ */ jsxs(
367
+ "div",
368
+ {
369
+ ref: (element) => handleDescriptionWrapperRef(venue.venue, element),
370
+ className: "agg-settlement-venue-content relative min-h-0",
371
+ children: [
372
+ /* @__PURE__ */ jsxs("p", { className: "agg-settlement-venue-description min-h-0 text-agg-sm leading-agg-5 text-agg-foreground", children: [
373
+ isDescriptionExpanded || !isDescriptionOverflowing ? venue.description : (_b2 = collapsedDescriptionByVenue[venue.venue]) != null ? _b2 : venue.description,
374
+ shouldShowDescriptionCta ? /* @__PURE__ */ jsxs(Fragment, { children: [
375
+ "... ",
376
+ /* @__PURE__ */ jsx(
377
+ "button",
378
+ {
379
+ type: "button",
380
+ tabIndex: isExpanded ? 0 : -1,
381
+ className: cn(
382
+ "agg-settlement-venue-action",
383
+ "cursor-pointer disabled:cursor-not-allowed",
384
+ "text-agg-sm leading-agg-5 text-agg-foreground underline-offset-2 hover:underline hover:font-agg-bold",
385
+ getMotionClassName(
386
+ enableAnimations,
387
+ "transition-[text-decoration] duration-200 ease-in-out"
388
+ )
389
+ ),
390
+ "aria-label": labels.trading.settlementShowMoreAria(
391
+ resolvedShowMoreLabel,
392
+ venueLabel
393
+ ),
394
+ onClick: (event) => handleDescriptionShowMoreClick(event, venue.venue),
395
+ children: resolvedShowMoreLabel
396
+ }
397
+ )
398
+ ] }) : null
399
+ ] }),
400
+ /* @__PURE__ */ jsx(
401
+ "p",
402
+ {
403
+ ref: (element) => handleDescriptionMeasureRef(venue.venue, element),
404
+ "aria-hidden": true,
405
+ className: "pointer-events-none invisible fixed top-0 left-0 -z-10 whitespace-normal text-agg-sm leading-agg-5"
406
+ }
407
+ )
408
+ ]
409
+ }
410
+ )
411
+ }
412
+ )
413
+ ] }, venue.venue);
414
+ }) })
415
+ ]
416
+ }
417
+ );
418
+ };
419
+ Settlement.displayName = "Settlement";
420
+
421
+ // src/trading/settlement/settlement-details.tsx
422
+ import { useEventTradingContext, useLabels as useLabels2 } from "@agg-build/hooks";
423
+ import { useMemo } from "react";
424
+
425
+ // src/trading/settlement/settlement-details.utils.ts
426
+ var SETTLEMENT_FIELD_KEYS = ["description", "rulesPrimary", "rulesSecondary"];
427
+ var FIELD_TO_LABEL_KEY = {
428
+ description: "settlementDescriptionLabel",
429
+ rulesPrimary: "settlementRulesPrimaryLabel",
430
+ rulesSecondary: "settlementRulesSecondaryLabel"
431
+ };
432
+ function mapVenueMarketsToSettlementSections(venueMarkets, labels, selectedMarketId) {
433
+ return SETTLEMENT_FIELD_KEYS.reduce((sections, fieldKey) => {
434
+ const venues = venueMarkets.filter((market) => {
435
+ const value = market[fieldKey];
436
+ return typeof value === "string" && value.trim().length > 0;
437
+ }).map(
438
+ (market) => market.id === selectedMarketId ? {
439
+ marketId: market.id,
440
+ venue: market.venue,
441
+ description: market[fieldKey]
442
+ } : null
443
+ ).filter((venue) => venue !== null);
444
+ if (venues.length > 0) {
445
+ sections.push({
446
+ key: fieldKey,
447
+ label: labels.trading[FIELD_TO_LABEL_KEY[fieldKey]],
448
+ venues
449
+ });
450
+ }
451
+ return sections;
452
+ }, []);
453
+ }
454
+
455
+ // src/trading/settlement/settlement-details.tsx
456
+ import { jsx as jsx2 } from "react/jsx-runtime";
457
+ var SettlementDetails = ({ className }) => {
458
+ var _a, _b, _c, _d, _e, _f;
459
+ const labels = useLabels2();
460
+ const tradingContext = useEventTradingContext();
461
+ const sections = useMemo(() => {
462
+ var _a2, _b2, _c2, _d2, _e2;
463
+ const venueMarkets = (_b2 = (_a2 = tradingContext == null ? void 0 : tradingContext.selectedEvent) == null ? void 0 : _a2.venueMarkets) != null ? _b2 : [];
464
+ if (!((_c2 = tradingContext == null ? void 0 : tradingContext.selectedMarket) == null ? void 0 : _c2.id)) return [];
465
+ return (_e2 = mapVenueMarketsToSettlementSections(
466
+ venueMarkets,
467
+ labels,
468
+ (_d2 = tradingContext == null ? void 0 : tradingContext.selectedMarket) == null ? void 0 : _d2.id
469
+ )) != null ? _e2 : [];
470
+ }, [(_a = tradingContext == null ? void 0 : tradingContext.selectedEvent) == null ? void 0 : _a.venueMarkets, (_b = tradingContext == null ? void 0 : tradingContext.selectedMarket) == null ? void 0 : _b.id, labels]);
471
+ if (!sections.length) return null;
472
+ return /* @__PURE__ */ jsx2("div", { className: "agg-settlement-list flex flex-col gap-6", children: /* @__PURE__ */ jsx2("div", { className: "agg-settlement-list-item", children: /* @__PURE__ */ jsx2(
473
+ Settlement,
474
+ {
475
+ question: (_e = (_c = tradingContext == null ? void 0 : tradingContext.selectedMarket) == null ? void 0 : _c.question) != null ? _e : (_d = tradingContext == null ? void 0 : tradingContext.selectedEvent) == null ? void 0 : _d.title,
476
+ venues: (_f = sections == null ? void 0 : sections[0]) == null ? void 0 : _f.venues,
477
+ className
478
+ }
479
+ ) }) });
480
+ };
481
+ SettlementDetails.displayName = "SettlementDetails";
482
+
483
+ // src/trading/place-order/index.tsx
484
+ import {
485
+ getWalletAddressFromUserProfile,
486
+ invalidateBalanceQueries,
487
+ invalidatePositionQueries,
488
+ requestAggAuthChooserOpen,
489
+ resolveEventTradingState,
490
+ resolveMarketTradingState,
491
+ resolveOrderEligibility,
492
+ useAggAuthContext,
493
+ useAggBalanceState,
494
+ useAggClient as useAggClient2,
495
+ useDebouncedValue,
496
+ useEventTradingContext as useEventTradingContext2,
497
+ useExecuteManaged,
498
+ useExecutionPositions,
499
+ useExecutionProgress,
500
+ useGeoBlock,
501
+ useLabels as useLabels3,
502
+ useLiveOutcomePrices,
503
+ useQueryClient,
504
+ useSdkUiConfig as useSdkUiConfig2,
505
+ useSmartRoute
506
+ } from "@agg-build/hooks";
507
+ import NumberFlow from "@number-flow/react";
508
+ import * as Dialog from "@radix-ui/react-dialog";
509
+ import { Fragment as Fragment2, useCallback as useCallback3, useEffect as useEffect3, useId, useMemo as useMemo3, useRef as useRef3, useState as useState4 } from "react";
510
+
511
+ // src/shared/deposit-modal-events.ts
512
+ var DEPOSIT_MODAL_OPEN_EVENT = "agg-deposit:open-modal";
513
+ var WITHDRAW_MODAL_OPEN_EVENT = "agg-withdraw:open-modal";
514
+ var requestAggDepositModalOpen = () => {
515
+ if (typeof window === "undefined") return;
516
+ window.dispatchEvent(new Event(DEPOSIT_MODAL_OPEN_EVENT));
517
+ };
518
+ var requestAggWithdrawModalOpen = () => {
519
+ if (typeof window === "undefined") return;
520
+ window.dispatchEvent(new Event(WITHDRAW_MODAL_OPEN_EVENT));
521
+ };
522
+
523
+ // src/trading/use-kalshi-kyc-flow.ts
524
+ import { useAggClient, useDepositAddresses } from "@agg-build/hooks";
525
+ import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
526
+ var KYC_PENDING_STORAGE_KEY = "agg_kyc_pending";
527
+ var getKycPendingState = () => {
528
+ var _a, _b;
529
+ const rawValue = sessionStorage.getItem(KYC_PENDING_STORAGE_KEY);
530
+ if (!rawValue) return null;
531
+ try {
532
+ const parsed = JSON.parse(rawValue);
533
+ if (parsed.venue !== "kalshi") return null;
534
+ return {
535
+ venue: "kalshi",
536
+ userId: (_a = parsed.userId) != null ? _a : null,
537
+ walletAddress: (_b = parsed.walletAddress) != null ? _b : null
538
+ };
539
+ } catch (e) {
540
+ return null;
541
+ }
542
+ };
543
+ var setKycPendingState = (state) => {
544
+ sessionStorage.setItem(KYC_PENDING_STORAGE_KEY, JSON.stringify(state));
545
+ };
546
+ var clearKycPendingState = () => {
547
+ sessionStorage.removeItem(KYC_PENDING_STORAGE_KEY);
548
+ };
549
+ var useKalshiKycFlow = ({
550
+ isKalshiVerified,
551
+ userId,
552
+ walletAddress,
553
+ onError
554
+ }) => {
555
+ const client = useAggClient();
556
+ const [isVerifyModalOpen, setIsVerifyModalOpen] = useState2(false);
557
+ const [showSuccessModal, setShowSuccessModal] = useState2(false);
558
+ const [isInitiating, setIsInitiating] = useState2(false);
559
+ const [needsDepositAddress, setNeedsDepositAddress] = useState2(false);
560
+ const initiationAttemptRef = useRef2(0);
561
+ const { isReady, isTimedOut } = useDepositAddresses({ enabled: needsDepositAddress, poll: true });
562
+ const pendingState = useMemo2(
563
+ () => ({
564
+ venue: "kalshi",
565
+ userId: userId != null ? userId : null,
566
+ walletAddress: walletAddress != null ? walletAddress : null
567
+ }),
568
+ [userId, walletAddress]
569
+ );
570
+ const resetInitiation = useCallback2(() => {
571
+ setIsInitiating(false);
572
+ setNeedsDepositAddress(false);
573
+ }, []);
574
+ const closeVerifyModal = useCallback2(() => {
575
+ initiationAttemptRef.current += 1;
576
+ clearKycPendingState();
577
+ resetInitiation();
578
+ setIsVerifyModalOpen(false);
579
+ }, [resetInitiation]);
580
+ const closeSuccessModal = useCallback2(() => {
581
+ setShowSuccessModal(false);
582
+ }, []);
583
+ const openVerifyModal = useCallback2(() => {
584
+ setIsVerifyModalOpen(true);
585
+ }, []);
586
+ const startVerification = useCallback2(() => {
587
+ initiationAttemptRef.current += 1;
588
+ setIsInitiating(true);
589
+ setNeedsDepositAddress(true);
590
+ }, []);
591
+ useEffect2(() => {
592
+ if (!isInitiating || !isReady) return;
593
+ const attemptId = initiationAttemptRef.current;
594
+ const redirectUri = window.location.href;
595
+ setKycPendingState(pendingState);
596
+ client.initiateKyc("kalshi", redirectUri).then((res) => {
597
+ if (initiationAttemptRef.current !== attemptId) return;
598
+ if (res.kycUrl) window.location.assign(res.kycUrl);
599
+ }).catch((err) => {
600
+ if (initiationAttemptRef.current !== attemptId) return;
601
+ clearKycPendingState();
602
+ onError == null ? void 0 : onError(err instanceof Error ? err : new Error(String(err)));
603
+ }).finally(() => {
604
+ if (initiationAttemptRef.current !== attemptId) return;
605
+ resetInitiation();
606
+ });
607
+ }, [client, isInitiating, isReady, onError, pendingState, resetInitiation]);
608
+ useEffect2(() => {
609
+ if (isTimedOut && isInitiating) {
610
+ clearKycPendingState();
611
+ resetInitiation();
612
+ onError == null ? void 0 : onError(new Error("Deposit address provisioning timed out"));
613
+ }
614
+ }, [isInitiating, isTimedOut, onError, resetInitiation]);
615
+ useEffect2(() => {
616
+ const storedPendingState = getKycPendingState();
617
+ const isMatchingSession = (storedPendingState == null ? void 0 : storedPendingState.venue) === "kalshi" && storedPendingState.userId === pendingState.userId && storedPendingState.walletAddress === pendingState.walletAddress;
618
+ if (isKalshiVerified && isMatchingSession) {
619
+ clearKycPendingState();
620
+ setShowSuccessModal(true);
621
+ }
622
+ }, [isKalshiVerified, pendingState]);
623
+ return {
624
+ isVerifyModalOpen,
625
+ showSuccessModal,
626
+ isInitiating,
627
+ openVerifyModal,
628
+ closeVerifyModal,
629
+ closeSuccessModal,
630
+ startVerification
631
+ };
632
+ };
633
+
634
+ // src/trading/place-order/index.place-order.constants.ts
635
+ var MIN_BUY_ORDER_AMOUNT = 1;
636
+ var DEFAULT_SLIPPAGE_VALUE = "0.5";
637
+ var HIGH_SLIPPAGE_THRESHOLD = 10;
638
+ var PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT = 3;
639
+ var PLACE_ORDER_CONTAINER_CLASS_NAME = "w-full overflow-hidden rounded-agg-xl border border-agg-separator bg-agg-secondary shadow-none hover:shadow-none";
640
+ var PLACE_ORDER_OUTCOME_BUTTON_CLASS_NAMES = {
641
+ activeNegative: "border-agg-error/50 bg-agg-error/15 font-agg-bold text-agg-error",
642
+ activePositive: "border-agg-success/50 bg-agg-success/15 font-agg-bold text-agg-success",
643
+ base: "flex h-10 flex-1 items-center justify-center rounded-agg-full border px-6 text-agg-base leading-agg-6",
644
+ inactive: "border-transparent bg-agg-secondary-hover font-agg-normal text-agg-foreground hover:bg-agg-tertiary"
645
+ };
646
+
647
+ // src/trading/place-order/index.place-order.utils.ts
648
+ var routePriceLabelFormatter = new Intl.NumberFormat("en-US", {
649
+ minimumFractionDigits: 0,
650
+ maximumFractionDigits: 1
651
+ });
652
+ var GEO_BLOCK_WARNING_PREFIX = "Venue not available in your region";
653
+ var isGeoBlockWarningReason = (reason) => reason.startsWith(GEO_BLOCK_WARNING_PREFIX);
654
+ var extractGeoBlockedVenues = (warnings) => {
655
+ if (!(warnings == null ? void 0 : warnings.length)) return /* @__PURE__ */ new Set();
656
+ return new Set(
657
+ warnings.filter((w) => w.venue && isGeoBlockWarningReason(w.reason)).map((w) => w.venue)
658
+ );
659
+ };
660
+ var getPlaceOrderContainerClassName = () => {
661
+ return PLACE_ORDER_CONTAINER_CLASS_NAME;
662
+ };
663
+ var resolveIsPositiveOutcome = (_outcome, index) => {
664
+ return index === 0;
665
+ };
666
+ var getOutcomeButtonClassName = ({
667
+ enableAnimations,
668
+ isActive,
669
+ isPositive
670
+ }) => {
671
+ return cn(
672
+ "cursor-pointer",
673
+ PLACE_ORDER_OUTCOME_BUTTON_CLASS_NAMES.base,
674
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
675
+ getMotionClassName(
676
+ enableAnimations,
677
+ "transition-[background-color,border-color,color,transform] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
678
+ ),
679
+ isActive ? isPositive ? PLACE_ORDER_OUTCOME_BUTTON_CLASS_NAMES.activePositive : PLACE_ORDER_OUTCOME_BUTTON_CLASS_NAMES.activeNegative : PLACE_ORDER_OUTCOME_BUTTON_CLASS_NAMES.inactive
680
+ );
681
+ };
682
+ var sortOutcomesYesFirst = (outcomes) => {
683
+ const hasYes = outcomes.some((o) => o.label.trim().toLowerCase() === "yes");
684
+ const hasNo = outcomes.some((o) => o.label.trim().toLowerCase() === "no");
685
+ if (!hasYes || !hasNo) return outcomes;
686
+ return [...outcomes].sort((a, b) => {
687
+ if (a.label.trim().toLowerCase() === "yes" && b.label.trim().toLowerCase() !== "yes") return -1;
688
+ if (a.label.trim().toLowerCase() !== "yes" && b.label.trim().toLowerCase() === "yes") return 1;
689
+ return 0;
690
+ });
691
+ };
692
+ var mapVenueMarketOutcomesToPlaceOrderOutcomes = (venueMarketOutcomes) => {
693
+ if (!(venueMarketOutcomes == null ? void 0 : venueMarketOutcomes.length)) return [];
694
+ return sortOutcomesYesFirst(venueMarketOutcomes).map((outcome) => {
695
+ var _a;
696
+ return {
697
+ id: outcome.id,
698
+ label: outcome.label,
699
+ title: (_a = outcome.title) != null ? _a : null,
700
+ price: outcome.price,
701
+ priceLabel: getTradingPriceLabel(outcome.price)
702
+ };
703
+ });
704
+ };
705
+ var mapQuoteDataToRoutingRows = (quoteData) => {
706
+ if (!(quoteData == null ? void 0 : quoteData.fills.length)) return [];
707
+ return quoteData.fills.map((fill) => ({
708
+ venue: fill.venue,
709
+ label: getTradingValueLabel({ amount: fill.venueQty * fill.avgPrice }),
710
+ priceLabel: getTradingRoutePriceLabel(fill.avgPrice),
711
+ resultLabel: getTradingValueLabel({
712
+ amount: fill.venueQty,
713
+ minimumFractionDigits: 2,
714
+ maximumFractionDigits: 2
715
+ })
716
+ }));
717
+ };
718
+ var deriveAggregateOrderStatus = (orderIds, terminalEvents) => {
719
+ if (!orderIds.length) return "pending";
720
+ const terminalById = new Map(terminalEvents.map((e) => [e.orderId, e]));
721
+ const allSettled = orderIds.every((id) => terminalById.has(id));
722
+ if (!allSettled) return "pending";
723
+ const events = orderIds.map((id) => terminalById.get(id));
724
+ if (events.every((e) => e.event === "filled")) return "full_success";
725
+ if (events.every((e) => e.event === "failed")) return "full_failure";
726
+ return "partial_failure";
727
+ };
728
+ var parseFilledAmountRawDollars = (filledAmountRaw) => {
729
+ if (!filledAmountRaw) return null;
730
+ const raw = Number(filledAmountRaw);
731
+ if (!Number.isFinite(raw) || raw <= 0) return null;
732
+ return raw / 1e6;
733
+ };
734
+ var resolvePlaceOrderQuoteResult = ({
735
+ labels,
736
+ quoteData,
737
+ tradeSide
738
+ }) => {
739
+ if (!quoteData || quoteData.totalFilled <= 0) return null;
740
+ const avgPrice = quoteData.rawExecCost / quoteData.totalFilled;
741
+ const quoteValue = tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled;
742
+ return {
743
+ hint: labels.averagePrice(avgPrice),
744
+ value: getTradingValueLabel({
745
+ amount: quoteValue,
746
+ minimumFractionDigits: 2,
747
+ maximumFractionDigits: 2
748
+ })
749
+ };
750
+ };
751
+ var getTradingRoutePriceLabel = (value) => {
752
+ const centsValue = Number.isFinite(value) ? value * 100 : 0;
753
+ return `${routePriceLabelFormatter.format(centsValue)}\xA2`;
754
+ };
755
+ var resolvePlaceOrderQuoteStatus = ({
756
+ amount,
757
+ labels,
758
+ quoteData,
759
+ selectedMarket
760
+ }) => {
761
+ var _a, _b, _c, _d;
762
+ if (!selectedMarket) {
763
+ return {
764
+ tone: "warning",
765
+ message: labels.noMarketSelected,
766
+ placement: "above-action"
767
+ };
768
+ }
769
+ if (!quoteData) return void 0;
770
+ if (quoteData.status === "no_orderbooks") {
771
+ return {
772
+ tone: "error",
773
+ message: labels.noOrderbooks,
774
+ placement: "above-action"
775
+ };
776
+ }
777
+ if (quoteData.status === "infeasible") {
778
+ return {
779
+ tone: "error",
780
+ message: labels.insufficientLiquidity,
781
+ placement: "above-action"
782
+ };
783
+ }
784
+ if (quoteData.status === "min_order_size_violated") {
785
+ return {
786
+ tone: "error",
787
+ message: (_a = quoteData.message) != null ? _a : labels.minOrderSizeViolated,
788
+ placement: "above-action"
789
+ };
790
+ }
791
+ if (quoteData.status === "insufficient_input_amount") {
792
+ return {
793
+ tone: "error",
794
+ message: (_b = quoteData.message) != null ? _b : labels.insufficientInputAmount,
795
+ placement: "above-action"
796
+ };
797
+ }
798
+ if (quoteData.status === "invalid_input") {
799
+ return {
800
+ tone: "error",
801
+ message: (_c = quoteData.message) != null ? _c : labels.quoteUnavailable,
802
+ placement: "above-action"
803
+ };
804
+ }
805
+ if (quoteData.status === "insufficient_position") {
806
+ const total = (_d = quoteData.positionAvailability) == null ? void 0 : _d.totalSellableShares;
807
+ const message = total != null ? labels.insufficientPosition(total) : labels.insufficientPositionGeneric;
808
+ return { tone: "error", message, placement: "above-action" };
809
+ }
810
+ if (quoteData.status === "insufficient_depth") {
811
+ return {
812
+ tone: "error",
813
+ message: labels.insufficientSellDepth,
814
+ placement: "above-action"
815
+ };
816
+ }
817
+ if (quoteData.status === "no_bids_above_min_price") {
818
+ return {
819
+ tone: "error",
820
+ message: labels.noBidsAboveMinPrice,
821
+ placement: "above-action"
822
+ };
823
+ }
824
+ if (quoteData.status === "insufficient_balance") {
825
+ return void 0;
826
+ }
827
+ if (quoteData.status !== "ok") {
828
+ return {
829
+ tone: "error",
830
+ message: labels.engineUnavailable,
831
+ placement: "above-action"
832
+ };
833
+ }
834
+ if (quoteData.totalFilled === 0 && amount > 0) {
835
+ return {
836
+ tone: "error",
837
+ message: labels.insufficientLiquidity,
838
+ placement: "above-action"
839
+ };
840
+ }
841
+ return void 0;
842
+ };
843
+ var buildLiveRouteCards = ({
844
+ labels,
845
+ quoteData,
846
+ tradeSide
847
+ }) => {
848
+ var _a, _b, _c;
849
+ const geoBlockedVenues = extractGeoBlockedVenues(quoteData.warnings);
850
+ const primaryResult = resolvePlaceOrderQuoteResult({ labels, quoteData, tradeSide });
851
+ const primaryVenue = (_a = quoteData.fills[0]) == null ? void 0 : _a.venue;
852
+ const parsedPrimaryVenue = parseVenue(primaryVenue);
853
+ const isSplit = quoteData.fills.length > 1;
854
+ const primaryWinnerVenue = quoteData.fills.length === 1 ? primaryVenue : void 0;
855
+ const isPrimaryRouteGeoBlocked = quoteData.fills.length > 0 && quoteData.fills.every((f) => geoBlockedVenues.has(f.venue));
856
+ const primaryCard = primaryResult ? isPrimaryRouteGeoBlocked ? {
857
+ id: "live-route",
858
+ hint: "",
859
+ kind: "venue",
860
+ label: getTradingVenueLabel(
861
+ parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
862
+ ),
863
+ numericValue: 0,
864
+ quoteData,
865
+ value: "",
866
+ venue: parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0,
867
+ isUnavailable: true
868
+ } : {
869
+ id: "live-route",
870
+ hint: primaryResult.hint,
871
+ kind: isSplit ? "split" : "venue",
872
+ label: isSplit ? labels.orderSplitting : getTradingVenueLabel(
873
+ parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
874
+ ),
875
+ numericValue: tradeSide === "sell" ? quoteData.rawExecCost : quoteData.totalFilled,
876
+ quoteData,
877
+ rows: mapQuoteDataToRoutingRows(quoteData),
878
+ value: primaryResult.value,
879
+ venue: isSplit ? void 0 : parsedPrimaryVenue.success ? parsedPrimaryVenue.data : void 0
880
+ } : null;
881
+ const soloCards = ((_b = quoteData.venueSoloQuotes) != null ? _b : []).filter(
882
+ (sq) => sq.status === "ok" && sq.avgPrice !== null && sq.filledQty > 0 && (sq.quoteId || quoteData.status === "insufficient_balance") && sq.venue !== primaryWinnerVenue
883
+ ).map((sq) => {
884
+ var _a2;
885
+ const parsedVenue = parseVenue(sq.venue);
886
+ const venue = parsedVenue.success ? parsedVenue.data : void 0;
887
+ if (geoBlockedVenues.has(sq.venue)) {
888
+ return {
889
+ id: `live-unavailable-${sq.venue}`,
890
+ hint: "",
891
+ kind: "venue",
892
+ label: getTradingVenueLabel(venue),
893
+ numericValue: 0,
894
+ quoteData,
895
+ value: "",
896
+ venue,
897
+ isUnavailable: true
898
+ };
899
+ }
900
+ const avgPrice = sq.avgPrice;
901
+ const soloQuoteData = __spreadProps(__spreadValues({}, quoteData), {
902
+ // Preview-only solos from `insufficient_balance` intentionally carry
903
+ // no executable quoteId; the card should still render for comparison,
904
+ // while the CTA stays disabled until the user is funded and requotes.
905
+ quoteId: (_a2 = sq.quoteId) != null ? _a2 : "",
906
+ fills: sq.fills.map((f) => __spreadValues({}, f)),
907
+ totalFilled: sq.filledQty,
908
+ rawExecCost: sq.rawExecCost,
909
+ estimatedPayout: sq.estimatedPayout,
910
+ estimatedProfit: sq.estimatedProfit,
911
+ returnPct: sq.returnPct,
912
+ // venueSoloQuotes stripped on solo card's quoteData (only the primary needs them)
913
+ venueSoloQuotes: void 0
914
+ });
915
+ return {
916
+ id: `live-solo-${sq.venue}`,
917
+ hint: labels.averagePrice(avgPrice),
918
+ kind: "venue",
919
+ label: getTradingVenueLabel(venue),
920
+ numericValue: sq.filledQty,
921
+ quoteData: soloQuoteData,
922
+ value: getTradingValueLabel({
923
+ amount: sq.filledQty,
924
+ minimumFractionDigits: 2,
925
+ maximumFractionDigits: 2
926
+ }),
927
+ venue
928
+ };
929
+ });
930
+ const unavailableCards = ((_c = quoteData.venueSoloQuotes) != null ? _c : []).filter((sq) => sq.status === "unavailable").map((sq) => {
931
+ const parsedVenue = parseVenue(sq.venue);
932
+ const venue = parsedVenue.success ? parsedVenue.data : void 0;
933
+ return {
934
+ id: `live-unavailable-${sq.venue}`,
935
+ hint: "",
936
+ kind: "venue",
937
+ label: getTradingVenueLabel(venue),
938
+ numericValue: 0,
939
+ quoteData,
940
+ value: "",
941
+ venue,
942
+ isUnavailable: true
943
+ };
944
+ });
945
+ const baseCards = primaryCard ? [primaryCard, ...soloCards] : soloCards;
946
+ const coveredVenueStrings = new Set(
947
+ [...baseCards, ...unavailableCards].flatMap((c) => c.venue ? [c.venue] : [])
948
+ );
949
+ const geoBlockedOnlyCards = [...geoBlockedVenues].filter((venueStr) => !coveredVenueStrings.has(venueStr)).map((venueStr) => {
950
+ const parsedVenue = parseVenue(venueStr);
951
+ const venue = parsedVenue.success ? parsedVenue.data : void 0;
952
+ return {
953
+ id: `live-geo-blocked-${venueStr}`,
954
+ hint: "",
955
+ kind: "venue",
956
+ label: getTradingVenueLabel(venue),
957
+ numericValue: 0,
958
+ quoteData,
959
+ value: "",
960
+ venue,
961
+ isUnavailable: true
962
+ };
963
+ });
964
+ return [...baseCards, ...unavailableCards, ...geoBlockedOnlyCards];
965
+ };
966
+ var resolveExecutionVenueFromQuote = (quoteData) => {
967
+ if (!(quoteData == null ? void 0 : quoteData.fills.length)) return void 0;
968
+ const dominantFill = [...quoteData.fills].sort((a, b) => b.venueQty - a.venueQty)[0];
969
+ const parsed = parseVenue(dominantFill == null ? void 0 : dominantFill.venue);
970
+ return parsed.success ? parsed.data : void 0;
971
+ };
972
+ var resolvePlaceOrderSuccessTone = ({
973
+ outcomeIndex,
974
+ tab
975
+ }) => {
976
+ const isNegativeOutcome = outcomeIndex > 0;
977
+ const isPositiveExposure = tab === "buy" && !isNegativeOutcome || tab === "sell" && isNegativeOutcome;
978
+ return isPositiveExposure ? "positive" : "negative";
979
+ };
980
+ var getPlaceOrderPotentialReturn = (quoteData) => {
981
+ var _a, _b;
982
+ if (!((_a = quoteData == null ? void 0 : quoteData.fills) == null ? void 0 : _a.length) || quoteData.fills.length < 2) return 0;
983
+ const bestSoloVenueFill = Math.max(
984
+ 0,
985
+ ...((_b = quoteData.venueSoloQuotes) != null ? _b : []).filter((quote) => quote.status === "ok" && quote.filledQty > 0).map((quote) => quote.filledQty)
986
+ );
987
+ if (bestSoloVenueFill <= 0) return 0;
988
+ return Math.max(0, quoteData.totalFilled - bestSoloVenueFill);
989
+ };
990
+ var resolvePrimarySubmittedOrderId = ({
991
+ allowOrderIdFallback = true,
992
+ orderId,
993
+ submittedOrders
994
+ }) => {
995
+ var _a;
996
+ const submittedOrderId = (_a = [...submittedOrders != null ? submittedOrders : []].sort((left, right) => left.timestamp - right.timestamp).find((submittedOrder) => submittedOrder.orderId.trim())) == null ? void 0 : _a.orderId;
997
+ if (submittedOrderId) return submittedOrderId;
998
+ if (!allowOrderIdFallback) return void 0;
999
+ if (orderId == null ? void 0 : orderId.trim()) return orderId;
1000
+ return void 0;
1001
+ };
1002
+ var normalizeOrderIdLabelInput = (orderId) => orderId.replace(/^#+/, "");
1003
+ var buildPlaceOrderExecutionStepGroups = ({
1004
+ labels,
1005
+ orderId,
1006
+ quoteData,
1007
+ submittedOrders
1008
+ }) => {
1009
+ var _a, _b;
1010
+ const submittedOrderId = resolvePrimarySubmittedOrderId({ orderId, submittedOrders });
1011
+ const baseGroup = [
1012
+ {
1013
+ id: "finding-route",
1014
+ label: labels.findingBestRoute,
1015
+ tone: "complete"
1016
+ },
1017
+ {
1018
+ id: "submitting-order",
1019
+ label: labels.submittingOrderProgress,
1020
+ tone: "complete"
1021
+ }
1022
+ ];
1023
+ if (submittedOrderId) {
1024
+ baseGroup.push({
1025
+ id: "order-submitted",
1026
+ label: labels.orderSubmittedProgress(normalizeOrderIdLabelInput(submittedOrderId)),
1027
+ tone: "complete"
1028
+ });
1029
+ }
1030
+ const fallbackVenueSteps = ((_a = quoteData == null ? void 0 : quoteData.fills) != null ? _a : []).map((fill, index) => {
1031
+ var _a2, _b2;
1032
+ const parsedVenue = parseVenue(fill.venue);
1033
+ const venue = parsedVenue.success ? parsedVenue.data : void 0;
1034
+ const venueLabel = getTradingVenueLabel(venue);
1035
+ return [
1036
+ {
1037
+ id: `executing-${venueLabel}-${index}`,
1038
+ label: labels.executingOnVenue(venueLabel),
1039
+ tone: "complete",
1040
+ venue
1041
+ },
1042
+ {
1043
+ id: `filled-${venueLabel}-${index}`,
1044
+ label: (_b2 = (_a2 = labels.orderFilledAtPrice) == null ? void 0 : _a2.call(labels, venueLabel, getTradingRoutePriceLabel(fill.avgPrice))) != null ? _b2 : `${venueLabel} order filled at ${getTradingRoutePriceLabel(fill.avgPrice)}`,
1045
+ tone: "complete"
1046
+ }
1047
+ ];
1048
+ });
1049
+ const submittedOrderSteps = Array.from(
1050
+ new Map(
1051
+ (submittedOrders != null ? submittedOrders : []).map((submittedOrder) => [submittedOrder.orderId, submittedOrder])
1052
+ ).values()
1053
+ ).sort((left, right) => left.timestamp - right.timestamp).map((submittedOrder, index) => {
1054
+ var _a2, _b2;
1055
+ const parsedVenue = parseVenue(submittedOrder.venue);
1056
+ const venue = parsedVenue.success ? parsedVenue.data : void 0;
1057
+ const venueLabel = getTradingVenueLabel(venue);
1058
+ return [
1059
+ {
1060
+ id: `executing-${submittedOrder.orderId}-${index}`,
1061
+ label: labels.executingOnVenue(venueLabel),
1062
+ tone: "complete",
1063
+ venue
1064
+ },
1065
+ {
1066
+ id: `filled-${submittedOrder.orderId}-${index}`,
1067
+ label: (_b2 = (_a2 = labels.orderFilledAtPrice) == null ? void 0 : _a2.call(
1068
+ labels,
1069
+ venueLabel,
1070
+ getTradingRoutePriceLabel(submittedOrder.price)
1071
+ )) != null ? _b2 : `${venueLabel} order filled at ${getTradingRoutePriceLabel(submittedOrder.price)}`,
1072
+ tone: "complete"
1073
+ }
1074
+ ];
1075
+ });
1076
+ return [
1077
+ baseGroup,
1078
+ ...submittedOrderSteps.length > 0 ? submittedOrderSteps : fallbackVenueSteps,
1079
+ [
1080
+ {
1081
+ id: "order-complete",
1082
+ label: (_b = labels.orderComplete) != null ? _b : "Order complete",
1083
+ tone: "complete"
1084
+ }
1085
+ ]
1086
+ ];
1087
+ };
1088
+ var groupPlaceOrderFailureSteps = (steps) => {
1089
+ if (!steps.length) return [];
1090
+ const baseStepIds = /* @__PURE__ */ new Set(["finding-route", "submitting-order", "order-submitted"]);
1091
+ const groupedSteps = [];
1092
+ const baseGroup = [];
1093
+ let currentGroup = [];
1094
+ for (const step of steps) {
1095
+ if (baseStepIds.has(step.id)) {
1096
+ if (currentGroup.length > 0) {
1097
+ groupedSteps.push(currentGroup);
1098
+ currentGroup = [];
1099
+ }
1100
+ baseGroup.push(step);
1101
+ continue;
1102
+ }
1103
+ if (step.id.startsWith("executing-")) {
1104
+ if (currentGroup.length > 0) {
1105
+ groupedSteps.push(currentGroup);
1106
+ }
1107
+ currentGroup = [step];
1108
+ continue;
1109
+ }
1110
+ if (currentGroup.length === 0) {
1111
+ currentGroup = [step];
1112
+ continue;
1113
+ }
1114
+ currentGroup.push(step);
1115
+ }
1116
+ if (baseGroup.length > 0) {
1117
+ groupedSteps.unshift(baseGroup);
1118
+ }
1119
+ if (currentGroup.length > 0) {
1120
+ groupedSteps.push(currentGroup);
1121
+ }
1122
+ return groupedSteps;
1123
+ };
1124
+ var buildPlaceOrderExecutionStepGroupsFromFailureSummary = ({
1125
+ labels,
1126
+ summary
1127
+ }) => {
1128
+ var _a;
1129
+ const failureStepGroups = groupPlaceOrderFailureSteps(summary.steps).map(
1130
+ (group) => group.map((step) => ({
1131
+ id: step.id,
1132
+ label: step.label,
1133
+ tone: step.tone,
1134
+ venue: step.venue
1135
+ }))
1136
+ );
1137
+ return [
1138
+ ...failureStepGroups,
1139
+ [
1140
+ {
1141
+ id: "order-complete",
1142
+ label: (_a = labels.orderComplete) != null ? _a : "Order complete",
1143
+ tone: "complete"
1144
+ }
1145
+ ]
1146
+ ];
1147
+ };
1148
+ var MARKET_RESOLVED_ERROR_PATTERN = /\b(resolved|no longer accepting orders|accepting orders|market closed|event closed)\b/i;
1149
+ var VENUE_UNAVAILABLE_ERROR_PATTERN = /\b(unavailable|unreachable|timeout|timed out|expired|canceled|cancelled|failed with no fills)\b/i;
1150
+ var ALCHEMY_SPONSORSHIP_ERROR_PATTERN = /\bsponsorship failed: sender has no balance of the token for erc20 sponsorship\b/i;
1151
+ var ALCHEMY_PREPARE_CALLS_ERROR_PATTERN = /\bwallet_prepareCalls\b/i;
1152
+ var tryParseJsonErrorValue = (value) => {
1153
+ try {
1154
+ return JSON.parse(value);
1155
+ } catch (e) {
1156
+ return null;
1157
+ }
1158
+ };
1159
+ var extractPlaceOrderErrorMessage = (value) => {
1160
+ if (!value) return null;
1161
+ if (typeof value === "string") {
1162
+ const trimmedValue = value.trim();
1163
+ if (!trimmedValue) return null;
1164
+ const parsedValue = tryParseJsonErrorValue(trimmedValue);
1165
+ if (parsedValue && parsedValue !== trimmedValue) {
1166
+ return extractPlaceOrderErrorMessage(parsedValue);
1167
+ }
1168
+ return trimmedValue;
1169
+ }
1170
+ if (typeof value !== "object") return null;
1171
+ if ("message" in value && typeof value.message === "string") {
1172
+ return extractPlaceOrderErrorMessage(value.message);
1173
+ }
1174
+ if ("error" in value) {
1175
+ return extractPlaceOrderErrorMessage(value.error);
1176
+ }
1177
+ return null;
1178
+ };
1179
+ var normalizePlaceOrderErrorMessage = ({
1180
+ errorMessage,
1181
+ fallbackMessage
1182
+ }) => {
1183
+ const extractedMessage = extractPlaceOrderErrorMessage(errorMessage);
1184
+ if (!extractedMessage) return fallbackMessage;
1185
+ if (ALCHEMY_SPONSORSHIP_ERROR_PATTERN.test(extractedMessage) || ALCHEMY_PREPARE_CALLS_ERROR_PATTERN.test(extractedMessage)) {
1186
+ return "Sponsored execution is temporarily unavailable. Please try again.";
1187
+ }
1188
+ return extractedMessage;
1189
+ };
1190
+ var resolvePlaceOrderFailureKind = ({
1191
+ errorMessage,
1192
+ terminalEvent
1193
+ }) => {
1194
+ var _a, _b, _c;
1195
+ if ((terminalEvent == null ? void 0 : terminalEvent.event) === "partial_fill") {
1196
+ return "partial_fill";
1197
+ }
1198
+ const normalizedErrorMessage = (_c = (_b = errorMessage == null ? void 0 : errorMessage.trim()) != null ? _b : (_a = terminalEvent == null ? void 0 : terminalEvent.errorReason) == null ? void 0 : _a.trim()) != null ? _c : "";
1199
+ if (!normalizedErrorMessage) {
1200
+ return terminalEvent ? "venue_unavailable" : "generic";
1201
+ }
1202
+ if (MARKET_RESOLVED_ERROR_PATTERN.test(normalizedErrorMessage)) {
1203
+ return "market_resolved";
1204
+ }
1205
+ if (terminalEvent && VENUE_UNAVAILABLE_ERROR_PATTERN.test(normalizedErrorMessage)) {
1206
+ return "venue_unavailable";
1207
+ }
1208
+ return "generic";
1209
+ };
1210
+ var resolveFailedVenueStep = ({
1211
+ kind,
1212
+ labels,
1213
+ terminalEvent
1214
+ }) => {
1215
+ var _a;
1216
+ if (!terminalEvent) return null;
1217
+ const parsedVenue = parseVenue(terminalEvent.venue);
1218
+ const venue = parsedVenue.success ? parsedVenue.data : void 0;
1219
+ const venueLabel = getTradingVenueLabel(venue);
1220
+ if (kind === "partial_fill") {
1221
+ return {
1222
+ id: `failed-${terminalEvent.orderId}`,
1223
+ label: labels.orderPartialFillStatus(venueLabel),
1224
+ tone: "warning"
1225
+ };
1226
+ }
1227
+ if (kind === "market_resolved") {
1228
+ return {
1229
+ id: `failed-${terminalEvent.orderId}`,
1230
+ label: labels.orderMarketResolvedStatus(venueLabel),
1231
+ tone: "error"
1232
+ };
1233
+ }
1234
+ if (kind === "venue_unavailable") {
1235
+ return {
1236
+ id: `failed-${terminalEvent.orderId}`,
1237
+ label: labels.orderVenueUnavailableStatus(venueLabel),
1238
+ tone: "error"
1239
+ };
1240
+ }
1241
+ return {
1242
+ id: `failed-${terminalEvent.orderId}`,
1243
+ label: (_a = terminalEvent.errorReason) != null ? _a : labels.orderFailureDescription(""),
1244
+ tone: "error"
1245
+ };
1246
+ };
1247
+ var resolvePlaceOrderFailureActions = ({
1248
+ canRetryRemaining = true,
1249
+ kind,
1250
+ labels,
1251
+ terminalEvent
1252
+ }) => {
1253
+ const parsedVenue = parseVenue(terminalEvent == null ? void 0 : terminalEvent.venue);
1254
+ const venue = parsedVenue.success ? parsedVenue.data : void 0;
1255
+ const venueLabel = getTradingVenueLabel(venue);
1256
+ if (kind === "partial_fill") {
1257
+ if (!canRetryRemaining) {
1258
+ return [
1259
+ {
1260
+ id: "skip",
1261
+ label: labels.orderSkip,
1262
+ variant: "skip"
1263
+ }
1264
+ ];
1265
+ }
1266
+ return [
1267
+ {
1268
+ id: "retry",
1269
+ label: labels.orderRetryRemaining,
1270
+ variant: "retry"
1271
+ },
1272
+ {
1273
+ id: "skip",
1274
+ label: labels.orderSkip,
1275
+ variant: "skip"
1276
+ }
1277
+ ];
1278
+ }
1279
+ if (kind === "venue_unavailable") {
1280
+ return [
1281
+ {
1282
+ id: "retry",
1283
+ label: labels.orderRetryVenue(venueLabel),
1284
+ variant: "retry"
1285
+ },
1286
+ {
1287
+ id: "dismiss",
1288
+ label: labels.orderDismiss,
1289
+ variant: "dismiss"
1290
+ }
1291
+ ];
1292
+ }
1293
+ if (kind === "market_resolved") {
1294
+ return [
1295
+ {
1296
+ id: "continue",
1297
+ label: labels.orderContinue,
1298
+ variant: "continue"
1299
+ }
1300
+ ];
1301
+ }
1302
+ return [
1303
+ {
1304
+ id: "retry",
1305
+ label: labels.orderRetry,
1306
+ variant: "retry"
1307
+ },
1308
+ {
1309
+ id: "dismiss",
1310
+ label: labels.orderDone,
1311
+ variant: "dismiss"
1312
+ }
1313
+ ];
1314
+ };
1315
+ var getPlaceOrderUnfilledRemaining = ({
1316
+ originalAmount,
1317
+ terminalOrderEvents
1318
+ }) => {
1319
+ const filled = (terminalOrderEvents != null ? terminalOrderEvents : []).reduce((acc, event) => {
1320
+ var _a;
1321
+ if (event.event !== "filled" && event.event !== "partial_fill") return acc;
1322
+ return acc + ((_a = parseFilledAmountRawDollars(event.filledAmountRaw)) != null ? _a : 0);
1323
+ }, 0);
1324
+ return Math.max(0, originalAmount - filled);
1325
+ };
1326
+ var buildPlaceOrderFailureSummary = ({
1327
+ actionLabel,
1328
+ canRetryRemaining,
1329
+ errorMessage,
1330
+ eventImage,
1331
+ eventSubtitle,
1332
+ eventTitle,
1333
+ labels,
1334
+ orderId,
1335
+ quoteData,
1336
+ submittedOrders,
1337
+ terminalOrderEvents
1338
+ }) => {
1339
+ var _a;
1340
+ const normalizedErrorMessage = normalizePlaceOrderErrorMessage({
1341
+ errorMessage,
1342
+ fallbackMessage: labels.orderFailed
1343
+ });
1344
+ const submittedOrderId = resolvePrimarySubmittedOrderId({
1345
+ orderId,
1346
+ submittedOrders,
1347
+ allowOrderIdFallback: false
1348
+ });
1349
+ const baseSteps = [
1350
+ {
1351
+ id: "finding-route",
1352
+ label: labels.findingBestRoute,
1353
+ tone: "complete"
1354
+ },
1355
+ {
1356
+ id: "submitting-order",
1357
+ label: labels.submittingOrderProgress,
1358
+ tone: "complete"
1359
+ }
1360
+ ];
1361
+ if (submittedOrderId) {
1362
+ baseSteps.push({
1363
+ id: "order-submitted",
1364
+ label: labels.orderSubmittedProgress(normalizeOrderIdLabelInput(submittedOrderId)),
1365
+ tone: "complete"
1366
+ });
1367
+ }
1368
+ const sortedEvents = [...terminalOrderEvents != null ? terminalOrderEvents : []].sort((a, b) => a.timestamp - b.timestamp);
1369
+ const hasAnyPartialFill = sortedEvents.some((e) => e.event === "partial_fill");
1370
+ const hasAnyFilled = sortedEvents.some((e) => e.event === "filled");
1371
+ const hasAnyFailed = sortedEvents.some((e) => e.event === "failed");
1372
+ const isMixedOutcome = (hasAnyPartialFill || hasAnyFilled) && hasAnyFailed;
1373
+ let overallFailureKind;
1374
+ if (hasAnyPartialFill || isMixedOutcome) {
1375
+ overallFailureKind = "partial_fill";
1376
+ } else {
1377
+ const firstFailedEvent = sortedEvents.find((e) => e.event === "failed");
1378
+ overallFailureKind = resolvePlaceOrderFailureKind({
1379
+ errorMessage: normalizedErrorMessage,
1380
+ terminalEvent: firstFailedEvent
1381
+ });
1382
+ }
1383
+ const venueSteps = sortedEvents.flatMap((terminalEvent, index) => {
1384
+ var _a2, _b, _c, _d, _e;
1385
+ const parsedVenue = parseVenue(terminalEvent.venue);
1386
+ const venue = parsedVenue.success ? parsedVenue.data : void 0;
1387
+ const venueLabel = getTradingVenueLabel(venue);
1388
+ const submittedOrder = (submittedOrders != null ? submittedOrders : []).find(
1389
+ (candidate) => candidate.orderId === terminalEvent.orderId
1390
+ );
1391
+ const fallbackPrice = (_a2 = quoteData == null ? void 0 : quoteData.fills[index]) == null ? void 0 : _a2.avgPrice;
1392
+ const priceLabel = getTradingRoutePriceLabel((_c = (_b = submittedOrder == null ? void 0 : submittedOrder.price) != null ? _b : fallbackPrice) != null ? _c : 0);
1393
+ const filledDollars = parseFilledAmountRawDollars(terminalEvent.filledAmountRaw);
1394
+ const amountLabel = filledDollars != null ? formatUsd(filledDollars) : null;
1395
+ const executingStep = {
1396
+ id: `executing-${terminalEvent.orderId}`,
1397
+ label: labels.executingOnVenue(venueLabel),
1398
+ tone: "complete",
1399
+ venue
1400
+ };
1401
+ if (terminalEvent.event === "filled") {
1402
+ const filledStepLabel = amountLabel ? labels.orderFilledAtPriceWithAmount(venueLabel, priceLabel, amountLabel) : (_e = (_d = labels.orderFilledAtPrice) == null ? void 0 : _d.call(labels, venueLabel, priceLabel)) != null ? _e : `${venueLabel} order filled at ${priceLabel}`;
1403
+ return [
1404
+ executingStep,
1405
+ {
1406
+ id: `filled-${terminalEvent.orderId}`,
1407
+ label: filledStepLabel,
1408
+ tone: "complete"
1409
+ }
1410
+ ];
1411
+ }
1412
+ if (terminalEvent.event === "partial_fill") {
1413
+ const partialStepLabel = amountLabel ? labels.orderPartiallyFilledAtPriceWithAmount(venueLabel, priceLabel, amountLabel) : labels.orderPartialFillStatus(venueLabel);
1414
+ return [
1415
+ executingStep,
1416
+ {
1417
+ id: `partial-${terminalEvent.orderId}`,
1418
+ label: partialStepLabel,
1419
+ tone: "warning"
1420
+ }
1421
+ ];
1422
+ }
1423
+ const perEventKind = resolvePlaceOrderFailureKind({
1424
+ errorMessage: normalizePlaceOrderErrorMessage({
1425
+ errorMessage: terminalEvent.errorReason,
1426
+ fallbackMessage: labels.orderFailed
1427
+ }),
1428
+ terminalEvent
1429
+ });
1430
+ const failedStep = resolveFailedVenueStep({ kind: perEventKind, labels, terminalEvent });
1431
+ return [executingStep, ...failedStep ? [failedStep] : []];
1432
+ });
1433
+ const fallbackFailureStep = sortedEvents.length === 0 ? {
1434
+ id: "failed-generic",
1435
+ label: normalizedErrorMessage,
1436
+ tone: "error"
1437
+ } : null;
1438
+ const primaryNonFilledEvent = (_a = sortedEvents.find((e) => e.event !== "filled")) != null ? _a : sortedEvents[0];
1439
+ return {
1440
+ actionLabel,
1441
+ actions: resolvePlaceOrderFailureActions({
1442
+ canRetryRemaining,
1443
+ kind: overallFailureKind,
1444
+ labels,
1445
+ terminalEvent: primaryNonFilledEvent
1446
+ }),
1447
+ errorMessage: normalizedErrorMessage,
1448
+ eventImage,
1449
+ eventSubtitle,
1450
+ eventTitle,
1451
+ kind: overallFailureKind,
1452
+ steps: [...baseSteps, ...venueSteps, ...fallbackFailureStep ? [fallbackFailureStep] : []]
1453
+ };
1454
+ };
1455
+ var buildPlaceOrderShareText = ({
1456
+ actionLabel,
1457
+ amountLabel,
1458
+ eventTitle,
1459
+ potentialReturnLabel,
1460
+ tab,
1461
+ toWinLabel,
1462
+ tradingLabels
1463
+ }) => {
1464
+ var _a, _b, _c;
1465
+ const lines = [
1466
+ actionLabel,
1467
+ eventTitle,
1468
+ `${tradingLabels.amount(tab)}: ${amountLabel}`,
1469
+ `${tradingLabels.toWin(tab)}: ${toWinLabel}`
1470
+ ];
1471
+ if (potentialReturnLabel) {
1472
+ lines.push(
1473
+ (_b = (_a = tradingLabels.potentialReturnBonus) == null ? void 0 : _a.call(tradingLabels, potentialReturnLabel)) != null ? _b : `+${potentialReturnLabel} Better Payout`
1474
+ );
1475
+ lines.push((_c = tradingLabels.withSmartRouting) != null ? _c : "with Smart Routing");
1476
+ }
1477
+ return lines.join("\n");
1478
+ };
1479
+ var resolveNextTabFromKey = ({
1480
+ currentTab,
1481
+ key
1482
+ }) => {
1483
+ switch (key) {
1484
+ case "ArrowLeft":
1485
+ case "ArrowRight":
1486
+ return currentTab === "buy" ? "sell" : "buy";
1487
+ case "Home":
1488
+ return "buy";
1489
+ case "End":
1490
+ return "sell";
1491
+ default:
1492
+ return null;
1493
+ }
1494
+ };
1495
+ var sanitizePercentageInput = (value) => {
1496
+ let sanitizedValue = value.replace(/%/g, "").replace(/[^\d.]/g, "");
1497
+ if (!sanitizedValue) return "";
1498
+ if (sanitizedValue.startsWith(".")) sanitizedValue = `0${sanitizedValue}`;
1499
+ const firstDecimalIndex = sanitizedValue.indexOf(".");
1500
+ if (firstDecimalIndex === -1) return sanitizedValue.replace(/^0+(?=\d)/, "");
1501
+ const wholeNumberPortion = sanitizedValue.slice(0, firstDecimalIndex).replace(/^0+(?=\d)/, "") || "0";
1502
+ const decimalPortion = sanitizedValue.slice(firstDecimalIndex + 1).replace(/\./g, "").slice(0, 2);
1503
+ return `${wholeNumberPortion}.${decimalPortion}`;
1504
+ };
1505
+ var finalizePercentageValue = (value) => {
1506
+ const sanitizedValue = sanitizePercentageInput(value != null ? value : "");
1507
+ if (!sanitizedValue) return "";
1508
+ if (sanitizedValue.endsWith(".")) return sanitizedValue.slice(0, -1) || "0";
1509
+ const numericValue = Number(sanitizedValue);
1510
+ if (!Number.isFinite(numericValue)) return "";
1511
+ return numericValue.toString();
1512
+ };
1513
+ var parsePercentageValue = (value) => {
1514
+ const finalizedValue = finalizePercentageValue(value);
1515
+ if (!finalizedValue) return null;
1516
+ const numericValue = Number(finalizedValue);
1517
+ return Number.isFinite(numericValue) ? numericValue : null;
1518
+ };
1519
+ var formatPercentageValue = (value) => {
1520
+ const finalizedValue = finalizePercentageValue(value);
1521
+ if (!finalizedValue) return "0%";
1522
+ return `${finalizedValue}%`;
1523
+ };
1524
+ var isPercentageBelowMinimum = (value, minimumValue) => {
1525
+ if (minimumValue === null) return false;
1526
+ const parsedValue = parsePercentageValue(value);
1527
+ if (parsedValue === null) return false;
1528
+ return parsedValue < minimumValue;
1529
+ };
1530
+
1531
+ // src/trading/place-order/index.place-order.failure.tsx
1532
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1533
+ var resolveFailureActionHandler = ({
1534
+ action,
1535
+ onDone,
1536
+ onRetry,
1537
+ onSkip
1538
+ }) => {
1539
+ if (action.variant === "retry") return onRetry;
1540
+ if (action.variant === "skip") return onSkip != null ? onSkip : onDone;
1541
+ return onDone;
1542
+ };
1543
+ var renderPartialFailureStep = (step) => {
1544
+ const isWarningStep = step.tone === "warning" || step.tone === "error";
1545
+ return /* @__PURE__ */ jsxs2(
1546
+ "div",
1547
+ {
1548
+ className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
1549
+ children: [
1550
+ /* @__PURE__ */ jsx3(
1551
+ Icon,
1552
+ {
1553
+ name: isWarningStep ? "warning-filled" : "check-circle",
1554
+ size: "small",
1555
+ className: cn("h-3 w-3 shrink-0", isWarningStep ? "text-agg-warning" : "text-agg-primary"),
1556
+ "aria-hidden": "true"
1557
+ }
1558
+ ),
1559
+ /* @__PURE__ */ jsx3("p", { className: "min-w-0 flex-1", children: step.label }),
1560
+ step.venue ? /* @__PURE__ */ jsx3(VenueLogo, { venue: step.venue, size: "small", className: "h-4 w-4 shrink-0" }) : null
1561
+ ]
1562
+ },
1563
+ step.id
1564
+ );
1565
+ };
1566
+ var PlaceOrderFailureView = ({
1567
+ className,
1568
+ enableAnimations: _enableAnimations = true,
1569
+ summary,
1570
+ tradingLabels,
1571
+ onRetry,
1572
+ onDone,
1573
+ onSkip
1574
+ }) => {
1575
+ var _a, _b, _c;
1576
+ const shouldShowPartialFailureLayout = summary.kind === "partial_fill";
1577
+ const failureStepGroups = shouldShowPartialFailureLayout ? groupPlaceOrderFailureSteps(summary.steps) : [];
1578
+ if (shouldShowPartialFailureLayout) {
1579
+ return /* @__PURE__ */ jsx3(Card, { className: cn("group/agg-order-panel", getPlaceOrderContainerClassName(), className), children: /* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-body flex flex-col gap-6 p-5", children: [
1580
+ /* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-header flex flex-col gap-2", children: [
1581
+ /* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-market flex items-center gap-3", children: [
1582
+ /* @__PURE__ */ jsx3(
1583
+ RemoteImage,
1584
+ {
1585
+ src: (_a = summary.eventImage) != null ? _a : null,
1586
+ alt: "",
1587
+ className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
1588
+ }
1589
+ ),
1590
+ /* @__PURE__ */ jsx3("p", { className: "min-w-0 flex-1 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground line-clamp-2", children: summary.eventTitle })
1591
+ ] }),
1592
+ summary.eventSubtitle ? /* @__PURE__ */ jsx3("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
1593
+ ] }),
1594
+ /* @__PURE__ */ jsxs2("div", { className: "flex min-h-12 w-full items-center justify-center gap-3 rounded-agg-full agg-bg-brand px-8 text-agg-base font-agg-bold leading-agg-6 text-agg-on-primary", children: [
1595
+ /* @__PURE__ */ jsx3(LoadingIcon, { size: "small", className: "text-agg-on-primary!" }),
1596
+ /* @__PURE__ */ jsx3("span", { children: summary.actionLabel })
1597
+ ] }),
1598
+ /* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-4", children: failureStepGroups.map((group, groupIndex) => /* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-2", children: group.map((step) => renderPartialFailureStep(step)) }, `failure-group-${groupIndex}`)) }),
1599
+ /* @__PURE__ */ jsx3("div", { className: "flex items-center gap-4", children: summary.actions.map((action) => /* @__PURE__ */ jsx3(
1600
+ Button,
1601
+ {
1602
+ variant: "tertiary",
1603
+ size: "medium",
1604
+ "aria-label": action.label,
1605
+ className: "text-agg-sm! leading-agg-5! text-agg-primary!",
1606
+ onClick: resolveFailureActionHandler({ action, onDone, onRetry, onSkip }),
1607
+ children: action.label
1608
+ },
1609
+ action.id
1610
+ )) })
1611
+ ] }) });
1612
+ }
1613
+ return /* @__PURE__ */ jsx3(Card, { className: cn("group/agg-order-panel", getPlaceOrderContainerClassName(), className), children: /* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-body flex flex-col gap-6 p-5", children: [
1614
+ /* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-header flex flex-col gap-2", children: [
1615
+ /* @__PURE__ */ jsxs2("div", { className: "agg-order-failure-market flex items-center gap-3", children: [
1616
+ /* @__PURE__ */ jsx3(
1617
+ RemoteImage,
1618
+ {
1619
+ src: (_b = summary.eventImage) != null ? _b : null,
1620
+ alt: "",
1621
+ className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
1622
+ }
1623
+ ),
1624
+ /* @__PURE__ */ jsx3("p", { className: "min-w-0 flex-1 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground line-clamp-2", children: summary.eventTitle })
1625
+ ] }),
1626
+ summary.eventSubtitle ? /* @__PURE__ */ jsx3("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventSubtitle }) : null
1627
+ ] }),
1628
+ /* @__PURE__ */ jsx3(
1629
+ InlineAlert,
1630
+ {
1631
+ tone: "error",
1632
+ variant: "surface",
1633
+ title: tradingLabels.orderFailureTitle,
1634
+ message: tradingLabels.orderFailureDescription((_c = summary.errorMessage) != null ? _c : "")
1635
+ }
1636
+ ),
1637
+ /* @__PURE__ */ jsx3("div", { className: "agg-order-failure-actions flex items-center gap-3", children: summary.actions.map((action) => /* @__PURE__ */ jsx3(
1638
+ Button,
1639
+ {
1640
+ variant: action.variant === "retry" ? "primary" : "secondary",
1641
+ size: "medium",
1642
+ className: "flex-1",
1643
+ "aria-label": action.label,
1644
+ onClick: resolveFailureActionHandler({ action, onDone, onRetry, onSkip }),
1645
+ children: action.label
1646
+ },
1647
+ action.id
1648
+ )) })
1649
+ ] }) });
1650
+ };
1651
+ PlaceOrderFailureView.displayName = "PlaceOrderFailureView";
1652
+
1653
+ // src/trading/place-order/index.place-order.success.tsx
1654
+ import { useState as useState3 } from "react";
1655
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1656
+ var resolveBuyToWinLabel = (shares) => {
1657
+ if (!shares) return "$0";
1658
+ return shares.startsWith("$") ? shares : `$${shares}`;
1659
+ };
1660
+ var PlaceOrderSuccessView = ({
1661
+ className,
1662
+ summary,
1663
+ tradingLabels,
1664
+ onDone,
1665
+ onShare: _onShare
1666
+ }) => {
1667
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1668
+ const [isExecutionDetailsExpanded, setIsExecutionDetailsExpanded] = useState3(true);
1669
+ const newTradeLabel = (_a = tradingLabels.orderNewTrade) != null ? _a : "New Trade";
1670
+ const _shareLabel = (_b = tradingLabels.orderShare) != null ? _b : "Share";
1671
+ const potentialReturnLabel = summary.potentialReturnLabel && tradingLabels.potentialReturnBonus ? tradingLabels.potentialReturnBonus(summary.potentialReturnLabel) : summary.potentialReturnLabel ? `+${summary.potentialReturnLabel} Better Payout` : null;
1672
+ const resolvedActionTone = (_c = summary.actionTone) != null ? _c : "positive";
1673
+ const resolvedActionLabel = (_d = summary.actionLabel) != null ? _d : tradingLabels.orderSuccessTitle;
1674
+ const resolvedTradeSide = (_e = summary.tradeSide) != null ? _e : "buy";
1675
+ const resolvedAmountLabel = (_f = summary.amountLabel) != null ? _f : resolvedTradeSide === "sell" ? summary.shares : summary.estimatedCost;
1676
+ const resolvedToWinLabel = (_g = summary.toWinLabel) != null ? _g : resolvedTradeSide === "sell" ? summary.estimatedCost : resolveBuyToWinLabel(summary.shares);
1677
+ const executionStepGroups = (_h = summary.executionStepGroups) != null ? _h : [];
1678
+ const finalStep = (_i = executionStepGroups.at(-1)) == null ? void 0 : _i[0];
1679
+ const detailedStepGroups = executionStepGroups.slice(0, -1);
1680
+ const hasExecutionDetails = detailedStepGroups.length > 0;
1681
+ const resolveStepIconName = (tone) => {
1682
+ return tone === "warning" || tone === "error" ? "warning-filled" : "check-circle";
1683
+ };
1684
+ const resolveStepIconClassName = (tone) => {
1685
+ return tone === "warning" || tone === "error" ? "text-agg-warning" : "text-agg-primary";
1686
+ };
1687
+ return /* @__PURE__ */ jsx4(Card, { className: cn("group/agg-order-panel", getPlaceOrderContainerClassName(), className), children: /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-body flex flex-col gap-6 p-5", children: [
1688
+ summary.eventTitle ? /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-header flex flex-col gap-2", children: [
1689
+ /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-market flex items-center gap-3", children: [
1690
+ /* @__PURE__ */ jsx4(
1691
+ RemoteImage,
1692
+ {
1693
+ src: (_j = summary.eventImage) != null ? _j : null,
1694
+ alt: "",
1695
+ className: "h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
1696
+ }
1697
+ ),
1698
+ /* @__PURE__ */ jsx4("p", { className: "min-w-0 flex-1 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground line-clamp-2", children: summary.eventTitle })
1699
+ ] }),
1700
+ summary.eventDateLabel ? /* @__PURE__ */ jsx4("p", { className: "text-agg-base leading-agg-6 text-agg-foreground", children: summary.eventDateLabel }) : null
1701
+ ] }) : null,
1702
+ /* @__PURE__ */ jsxs3(
1703
+ "div",
1704
+ {
1705
+ className: cn(
1706
+ "agg-order-success-pill flex min-h-12 w-full items-center justify-center gap-2 rounded-agg-full px-6 py-2.5 text-center text-agg-base font-agg-bold leading-agg-6 text-agg-on-primary",
1707
+ resolvedActionTone === "positive" ? "bg-agg-success" : "bg-agg-error"
1708
+ ),
1709
+ children: [
1710
+ /* @__PURE__ */ jsx4(Icon, { name: "success-check", size: "small", className: "h-4 w-4 shrink-0 text-current" }),
1711
+ /* @__PURE__ */ jsx4("span", { children: resolvedActionLabel })
1712
+ ]
1713
+ }
1714
+ ),
1715
+ executionStepGroups.length > 0 ? /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-timeline flex flex-col gap-2", children: [
1716
+ /* @__PURE__ */ jsx4(
1717
+ "div",
1718
+ {
1719
+ "aria-hidden": !isExecutionDetailsExpanded,
1720
+ className: cn(
1721
+ "grid overflow-hidden",
1722
+ isExecutionDetailsExpanded ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0",
1723
+ !isExecutionDetailsExpanded && "pointer-events-none",
1724
+ getMotionClassName(
1725
+ true,
1726
+ "transition-[grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
1727
+ )
1728
+ ),
1729
+ children: /* @__PURE__ */ jsx4("div", { className: "min-h-0", children: /* @__PURE__ */ jsx4("div", { className: "flex flex-col gap-4 pb-2", children: detailedStepGroups.map((group, groupIndex) => /* @__PURE__ */ jsx4("div", { className: "flex flex-col gap-2", children: group.map((step) => /* @__PURE__ */ jsxs3(
1730
+ "div",
1731
+ {
1732
+ className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
1733
+ children: [
1734
+ /* @__PURE__ */ jsx4(
1735
+ Icon,
1736
+ {
1737
+ name: resolveStepIconName(step.tone),
1738
+ size: "small",
1739
+ className: cn("h-3 w-3 shrink-0", resolveStepIconClassName(step.tone)),
1740
+ "aria-hidden": "true"
1741
+ }
1742
+ ),
1743
+ /* @__PURE__ */ jsx4("p", { className: "min-w-0 flex-1", children: step.label }),
1744
+ step.venue ? /* @__PURE__ */ jsx4(
1745
+ VenueLogo,
1746
+ {
1747
+ venue: step.venue,
1748
+ size: "small",
1749
+ className: "h-4 w-4"
1750
+ }
1751
+ ) : null
1752
+ ]
1753
+ },
1754
+ step.id
1755
+ )) }, `execution-group-${groupIndex}`)) }) })
1756
+ }
1757
+ ),
1758
+ finalStep ? hasExecutionDetails ? /* @__PURE__ */ jsxs3(
1759
+ "button",
1760
+ {
1761
+ type: "button",
1762
+ "aria-expanded": isExecutionDetailsExpanded,
1763
+ className: cn(
1764
+ "flex w-full items-center gap-2 text-left text-agg-sm leading-agg-5 text-agg-foreground",
1765
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
1766
+ "cursor-pointer"
1767
+ ),
1768
+ onClick: () => setIsExecutionDetailsExpanded((currentValue) => !currentValue),
1769
+ children: [
1770
+ /* @__PURE__ */ jsx4(
1771
+ Icon,
1772
+ {
1773
+ name: resolveStepIconName(finalStep.tone),
1774
+ size: "small",
1775
+ className: cn("h-3 w-3 shrink-0", resolveStepIconClassName(finalStep.tone)),
1776
+ "aria-hidden": "true"
1777
+ }
1778
+ ),
1779
+ /* @__PURE__ */ jsx4("p", { className: "min-w-0 flex-1", children: finalStep.label }),
1780
+ /* @__PURE__ */ jsx4(
1781
+ Icon,
1782
+ {
1783
+ name: isExecutionDetailsExpanded ? "chevron-up" : "chevron-down",
1784
+ size: "small",
1785
+ className: "h-4 w-4 shrink-0 text-agg-muted-foreground",
1786
+ "aria-hidden": "true"
1787
+ }
1788
+ )
1789
+ ]
1790
+ }
1791
+ ) : /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground", children: [
1792
+ /* @__PURE__ */ jsx4(
1793
+ Icon,
1794
+ {
1795
+ name: resolveStepIconName(finalStep.tone),
1796
+ size: "small",
1797
+ className: cn("h-3 w-3 shrink-0", resolveStepIconClassName(finalStep.tone)),
1798
+ "aria-hidden": "true"
1799
+ }
1800
+ ),
1801
+ /* @__PURE__ */ jsx4("p", { className: "min-w-0 flex-1", children: finalStep.label })
1802
+ ] }) : null
1803
+ ] }) : null,
1804
+ /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-summary flex items-center justify-between gap-4", children: [
1805
+ /* @__PURE__ */ jsx4("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.amount(resolvedTradeSide) }),
1806
+ /* @__PURE__ */ jsx4("p", { className: "text-right text-[30px] font-agg-bold leading-[36px] text-agg-foreground", children: resolvedAmountLabel })
1807
+ ] }),
1808
+ /* @__PURE__ */ jsxs3("div", { className: "agg-order-success-summary flex items-center justify-between gap-4", children: [
1809
+ /* @__PURE__ */ jsx4("p", { className: "text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.toWin(resolvedTradeSide) }),
1810
+ /* @__PURE__ */ jsx4("p", { className: "text-right text-[30px] font-agg-bold leading-[36px] text-agg-success", children: resolvedToWinLabel })
1811
+ ] }),
1812
+ summary.potentialReturnLabel ? /* @__PURE__ */ jsxs3("div", { className: "flex w-full flex-col items-center justify-center gap-1 overflow-hidden rounded-agg-lg border border-agg-primary/50 bg-gradient-to-b from-agg-primary/8 to-agg-primary/15 p-3 text-center", children: [
1813
+ /* @__PURE__ */ jsx4("p", { className: "bg-gradient-to-r from-agg-primary to-agg-primary-hover bg-clip-text text-agg-lg font-agg-bold leading-[28px] text-transparent", children: potentialReturnLabel }),
1814
+ /* @__PURE__ */ jsx4("p", { className: "text-agg-xs leading-agg-4 text-agg-foreground", children: (_k = tradingLabels.withSmartRouting) != null ? _k : "with Smart Routing" })
1815
+ ] }) : null,
1816
+ /* @__PURE__ */ jsx4("div", { className: "agg-order-success-actions flex gap-3", children: /* @__PURE__ */ jsx4(
1817
+ Button,
1818
+ {
1819
+ variant: "secondary",
1820
+ size: "large",
1821
+ className: "flex-1",
1822
+ "aria-label": newTradeLabel,
1823
+ onClick: onDone,
1824
+ children: newTradeLabel
1825
+ }
1826
+ ) })
1827
+ ] }) });
1828
+ };
1829
+ PlaceOrderSuccessView.displayName = "PlaceOrderSuccessView";
1830
+
1831
+ // src/trading/place-order/index.tsx
1832
+ import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1833
+ var DEFAULT_STEP_LABELS = {
1834
+ "check-balance": "Checking balance",
1835
+ "check-position": "Checking position",
1836
+ "lane-bridge": "Bridging funds",
1837
+ bridge: "Bridging funds",
1838
+ "bridge-to-user": "Transferring to wallet",
1839
+ "sweep-bridge": "Completing bridge",
1840
+ "submit-order": "Submitting order",
1841
+ "order-bridge-execute": "Executing order",
1842
+ "transfer-to-user": "Transferring to wallet"
1843
+ };
1844
+ var getDefaultStepLabel = (stepType) => {
1845
+ var _a;
1846
+ return (_a = DEFAULT_STEP_LABELS[stepType]) != null ? _a : stepType.replace(/-/g, " ").replace(/^\w/, (c) => c.toUpperCase());
1847
+ };
1848
+ var resolveRefetchedQuoteData = (result) => {
1849
+ if (!result || typeof result !== "object" || !("data" in result)) return null;
1850
+ const data = result.data;
1851
+ if (!data || typeof data !== "object" || !("quoteId" in data)) return null;
1852
+ return data;
1853
+ };
1854
+ var LoadingGlyph = ({
1855
+ className,
1856
+ enableAnimations
1857
+ }) => {
1858
+ return /* @__PURE__ */ jsx5(
1859
+ "span",
1860
+ {
1861
+ "aria-hidden": "true",
1862
+ className: cn(
1863
+ "inline-block rounded-full border-2 border-current border-r-transparent",
1864
+ getMotionClassName(enableAnimations, "animate-spin"),
1865
+ className
1866
+ )
1867
+ }
1868
+ );
1869
+ };
1870
+ var PlaceOrderSlippageControl = ({
1871
+ enableAnimations,
1872
+ onChange,
1873
+ value: slippageValue,
1874
+ defaultValue: slippageDefaultValue,
1875
+ minimumValue: slippageMinimumValue
1876
+ }) => {
1877
+ var _a, _b;
1878
+ const labels = useLabels3();
1879
+ const containerRef = useRef3(null);
1880
+ const triggerRef = useRef3(null);
1881
+ const inputRef = useRef3(null);
1882
+ const warningId = useId();
1883
+ const defaultValue = finalizePercentageValue(slippageDefaultValue);
1884
+ const committedValue = finalizePercentageValue(slippageValue) || defaultValue;
1885
+ const [draftValue, setDraftValue] = useState4(committedValue);
1886
+ const [isEditing, setIsEditing] = useState4(
1887
+ () => isPercentageBelowMinimum(committedValue, slippageMinimumValue)
1888
+ );
1889
+ const [shouldFocusInput, setShouldFocusInput] = useState4(false);
1890
+ useEffect3(() => {
1891
+ setDraftValue(committedValue);
1892
+ if (isPercentageBelowMinimum(committedValue, slippageMinimumValue)) {
1893
+ setIsEditing(true);
1894
+ }
1895
+ }, [committedValue, slippageMinimumValue]);
1896
+ useEffect3(() => {
1897
+ if (!shouldFocusInput) return;
1898
+ requestAnimationFrame(() => {
1899
+ var _a2, _b2;
1900
+ (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
1901
+ (_b2 = inputRef.current) == null ? void 0 : _b2.select();
1902
+ setShouldFocusInput(false);
1903
+ });
1904
+ }, [shouldFocusInput]);
1905
+ const resolvedSlippageValue = (_b = (_a = parsePercentageValue(draftValue)) != null ? _a : parsePercentageValue(committedValue)) != null ? _b : 0;
1906
+ const isLowSlippage = resolvedSlippageValue < slippageMinimumValue;
1907
+ const isHighSlippage = resolvedSlippageValue > HIGH_SLIPPAGE_THRESHOLD;
1908
+ const isUsingDefaultValue = finalizePercentageValue(draftValue) === defaultValue;
1909
+ const collapsedLabel = labels.trading.slippage(
1910
+ Number(committedValue || slippageDefaultValue || DEFAULT_SLIPPAGE_VALUE)
1911
+ );
1912
+ const resolvedAutoLabel = labels.trading.resetSlippage;
1913
+ const resolvedWarningMessage = useMemo3(() => {
1914
+ if (isLowSlippage) {
1915
+ return labels.trading.slippageLow(slippageMinimumValue);
1916
+ }
1917
+ if (isHighSlippage) {
1918
+ return labels.trading.slippageHigh(HIGH_SLIPPAGE_THRESHOLD);
1919
+ }
1920
+ return null;
1921
+ }, [isHighSlippage, isLowSlippage, labels, slippageMinimumValue]);
1922
+ const handleCommitDraft = (focusInputWhenInvalid = false) => {
1923
+ const nextValue = finalizePercentageValue(draftValue) || committedValue || defaultValue;
1924
+ setDraftValue(nextValue);
1925
+ onChange == null ? void 0 : onChange(formatPercentageValue(nextValue));
1926
+ if (isPercentageBelowMinimum(nextValue, slippageMinimumValue)) {
1927
+ setIsEditing(true);
1928
+ if (focusInputWhenInvalid) setShouldFocusInput(true);
1929
+ return;
1930
+ }
1931
+ setIsEditing(false);
1932
+ };
1933
+ const handleToggleEditing = () => {
1934
+ if (!isEditing) {
1935
+ setIsEditing(true);
1936
+ setShouldFocusInput(true);
1937
+ return;
1938
+ }
1939
+ handleCommitDraft(true);
1940
+ };
1941
+ const handleResetToAuto = () => {
1942
+ const nextValue = defaultValue || committedValue;
1943
+ setDraftValue(nextValue);
1944
+ setIsEditing(false);
1945
+ onChange == null ? void 0 : onChange(formatPercentageValue(nextValue));
1946
+ requestAnimationFrame(() => {
1947
+ var _a2;
1948
+ return (_a2 = triggerRef.current) == null ? void 0 : _a2.focus();
1949
+ });
1950
+ };
1951
+ const handleInputChange = (event) => {
1952
+ setDraftValue(sanitizePercentageInput(event.target.value));
1953
+ };
1954
+ const handleInputKeyDown = (event) => {
1955
+ if (event.key === "Enter") {
1956
+ event.preventDefault();
1957
+ handleCommitDraft();
1958
+ return;
1959
+ }
1960
+ if (event.key !== "Escape") return;
1961
+ event.preventDefault();
1962
+ setDraftValue(committedValue || defaultValue);
1963
+ setIsEditing(false);
1964
+ requestAnimationFrame(() => {
1965
+ var _a2;
1966
+ return (_a2 = triggerRef.current) == null ? void 0 : _a2.focus();
1967
+ });
1968
+ };
1969
+ const handleContainerBlur = (event) => {
1970
+ var _a2;
1971
+ const nextFocusTarget = event.relatedTarget;
1972
+ if ((_a2 = containerRef.current) == null ? void 0 : _a2.contains(nextFocusTarget)) return;
1973
+ if (!isEditing) return;
1974
+ handleCommitDraft(false);
1975
+ };
1976
+ return /* @__PURE__ */ jsxs4("div", { ref: containerRef, className: "agg-slippage-control w-full", onBlur: handleContainerBlur, children: [
1977
+ /* @__PURE__ */ jsxs4(
1978
+ "button",
1979
+ {
1980
+ ref: triggerRef,
1981
+ type: "button",
1982
+ "aria-label": collapsedLabel,
1983
+ "aria-expanded": isEditing,
1984
+ className: cn(
1985
+ "agg-slippage-trigger",
1986
+ "inline-flex cursor-pointer items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
1987
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
1988
+ getMotionClassName(
1989
+ enableAnimations,
1990
+ "transition-[color,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
1991
+ )
1992
+ ),
1993
+ onClick: handleToggleEditing,
1994
+ children: [
1995
+ /* @__PURE__ */ jsx5("span", { className: "agg-slippage-label", children: collapsedLabel }),
1996
+ /* @__PURE__ */ jsx5(
1997
+ Icon,
1998
+ {
1999
+ name: isEditing ? "chevron-up" : "pencil",
2000
+ size: "small",
2001
+ className: "h-3 w-3 text-agg-muted-foreground",
2002
+ color: "currentColor"
2003
+ }
2004
+ )
2005
+ ]
2006
+ }
2007
+ ),
2008
+ /* @__PURE__ */ jsx5(
2009
+ "div",
2010
+ {
2011
+ "aria-hidden": !isEditing,
2012
+ className: cn(
2013
+ "agg-slippage-editor",
2014
+ "grid overflow-hidden",
2015
+ isEditing ? "mt-2 grid-rows-[1fr] opacity-100" : "mt-0 grid-rows-[0fr] opacity-0",
2016
+ !isEditing && "pointer-events-none",
2017
+ getMotionClassName(
2018
+ enableAnimations,
2019
+ "transition-[grid-template-rows,opacity,margin-top] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)]"
2020
+ )
2021
+ ),
2022
+ children: /* @__PURE__ */ jsx5("div", { className: "min-h-0", children: /* @__PURE__ */ jsxs4("div", { className: "agg-slippage-editor-body flex flex-col gap-2", children: [
2023
+ /* @__PURE__ */ jsxs4("div", { className: "agg-slippage-input-row flex h-9 overflow-hidden rounded-agg-sm border border-agg-separator", children: [
2024
+ /* @__PURE__ */ jsxs4("div", { className: "agg-slippage-input-group flex min-w-0 flex-1 items-center gap-2 bg-agg-secondary px-3", children: [
2025
+ /* @__PURE__ */ jsx5(
2026
+ "input",
2027
+ {
2028
+ ref: inputRef,
2029
+ type: "text",
2030
+ inputMode: "decimal",
2031
+ autoComplete: "off",
2032
+ value: draftValue,
2033
+ "aria-describedby": resolvedWarningMessage ? warningId : void 0,
2034
+ "aria-invalid": isLowSlippage || void 0,
2035
+ className: "agg-slippage-input min-w-0 flex-1 bg-transparent text-agg-sm leading-agg-5 text-agg-foreground outline-none",
2036
+ onChange: handleInputChange,
2037
+ onKeyDown: handleInputKeyDown
2038
+ }
2039
+ ),
2040
+ /* @__PURE__ */ jsx5(
2041
+ "button",
2042
+ {
2043
+ type: "button",
2044
+ className: cn(
2045
+ "agg-slippage-reset",
2046
+ "shrink-0 cursor-pointer text-agg-sm font-agg-bold leading-agg-5 focus-visible:outline-none",
2047
+ isUsingDefaultValue ? "text-agg-muted-foreground" : "text-agg-primary",
2048
+ getMotionClassName(
2049
+ enableAnimations,
2050
+ "transition-colors duration-200 ease-in-out"
2051
+ )
2052
+ ),
2053
+ onClick: handleResetToAuto,
2054
+ children: resolvedAutoLabel
2055
+ }
2056
+ )
2057
+ ] }),
2058
+ /* @__PURE__ */ jsx5("div", { className: "h-full w-px bg-agg-separator", "aria-hidden": "true" }),
2059
+ /* @__PURE__ */ jsx5(
2060
+ "div",
2061
+ {
2062
+ className: "agg-slippage-suffix flex w-9 items-center justify-center bg-agg-secondary-hover text-agg-sm leading-agg-5 text-agg-muted-foreground",
2063
+ "aria-hidden": "true",
2064
+ children: "%"
2065
+ }
2066
+ )
2067
+ ] }),
2068
+ /* @__PURE__ */ jsx5(
2069
+ "div",
2070
+ {
2071
+ "aria-hidden": !resolvedWarningMessage,
2072
+ className: cn(
2073
+ "agg-slippage-warning",
2074
+ "grid overflow-hidden",
2075
+ resolvedWarningMessage ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0",
2076
+ !resolvedWarningMessage && "pointer-events-none",
2077
+ getMotionClassName(
2078
+ enableAnimations,
2079
+ "transition-[grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
2080
+ )
2081
+ ),
2082
+ children: /* @__PURE__ */ jsx5("div", { className: "min-h-0", children: /* @__PURE__ */ jsxs4(
2083
+ "div",
2084
+ {
2085
+ id: warningId,
2086
+ className: "agg-slippage-warning-message flex items-start gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
2087
+ children: [
2088
+ /* @__PURE__ */ jsx5(
2089
+ Icon,
2090
+ {
2091
+ name: "warning-filled",
2092
+ size: "small",
2093
+ className: "mt-0.5 !h-4 !w-4 shrink-0 text-agg-warning",
2094
+ color: "currentColor"
2095
+ }
2096
+ ),
2097
+ /* @__PURE__ */ jsx5("p", { children: resolvedWarningMessage != null ? resolvedWarningMessage : "" })
2098
+ ]
2099
+ }
2100
+ ) })
2101
+ }
2102
+ )
2103
+ ] }) })
2104
+ }
2105
+ )
2106
+ ] });
2107
+ };
2108
+ PlaceOrderSlippageControl.displayName = "PlaceOrderSlippageControl";
2109
+ var renderCardHeader = ({
2110
+ className,
2111
+ headerSubtitle,
2112
+ headerImage,
2113
+ headerTitle,
2114
+ onClose
2115
+ }) => {
2116
+ if (!headerTitle) return null;
2117
+ return /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-panel-header flex flex-col gap-2", className), children: [
2118
+ /* @__PURE__ */ jsxs4("div", { className: "agg-order-market-summary flex items-center gap-3", children: [
2119
+ /* @__PURE__ */ jsx5(
2120
+ RemoteImage,
2121
+ {
2122
+ src: headerImage,
2123
+ alt: "",
2124
+ className: "agg-order-market-image h-12 w-12 shrink-0 overflow-hidden rounded-agg-lg object-cover"
2125
+ }
2126
+ ),
2127
+ /* @__PURE__ */ jsx5("p", { className: "agg-order-market-title min-w-0 flex-1 text-agg-base font-agg-bold leading-agg-6 text-agg-foreground line-clamp-2", children: headerTitle }),
2128
+ onClose ? /* @__PURE__ */ jsx5(
2129
+ "button",
2130
+ {
2131
+ type: "button",
2132
+ className: "agg-order-close -mr-1 -mt-1 hidden shrink-0 cursor-pointer items-center justify-center p-1 text-agg-muted-foreground hover:text-agg-foreground sm:flex",
2133
+ "aria-label": "Close",
2134
+ onClick: onClose,
2135
+ children: /* @__PURE__ */ jsx5(CloseIcon, { className: "h-5 w-5" })
2136
+ }
2137
+ ) : null
2138
+ ] }),
2139
+ headerSubtitle ? /* @__PURE__ */ jsx5("p", { className: "agg-order-market-subtitle text-agg-base leading-agg-6 text-agg-foreground", children: headerSubtitle }) : null
2140
+ ] });
2141
+ };
2142
+ var PlaceOrderResolvedView = ({
2143
+ classNames,
2144
+ tradingState,
2145
+ resolvedClaim,
2146
+ className
2147
+ }) => {
2148
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2149
+ const labels = useLabels3();
2150
+ const tradingLabels = labels.trading;
2151
+ const extendedTradingLabels = tradingLabels;
2152
+ const winningOutcomeLabel = (_c = (_b = (_a = tradingState.winningOutcome) == null ? void 0 : _a.label) == null ? void 0 : _b.trim().toLowerCase()) != null ? _c : "";
2153
+ const isPositiveWinningOutcome = ["yes", "up", "buy", "long", "true"].includes(
2154
+ winningOutcomeLabel
2155
+ );
2156
+ const resolvedIconName = isPositiveWinningOutcome ? "success-check" : "close";
2157
+ const resolvedIconToneClassName = isPositiveWinningOutcome ? "text-agg-success" : "text-agg-error";
2158
+ const resolvedIconContainerClassName = isPositiveWinningOutcome ? "bg-agg-success/15" : "bg-agg-error/15";
2159
+ return /* @__PURE__ */ jsx5(
2160
+ Card,
2161
+ {
2162
+ className: cn(
2163
+ "group/agg-order-panel",
2164
+ getPlaceOrderContainerClassName(),
2165
+ classNames == null ? void 0 : classNames.root,
2166
+ className
2167
+ ),
2168
+ children: /* @__PURE__ */ jsxs4(
2169
+ "div",
2170
+ {
2171
+ className: cn(
2172
+ "agg-order-panel-body flex flex-col items-center gap-6 p-8",
2173
+ classNames == null ? void 0 : classNames.body
2174
+ ),
2175
+ children: [
2176
+ /* @__PURE__ */ jsx5(
2177
+ "div",
2178
+ {
2179
+ className: cn(
2180
+ "flex h-15 w-15 items-center justify-center rounded-full",
2181
+ resolvedIconContainerClassName
2182
+ ),
2183
+ children: /* @__PURE__ */ jsx5(Icon, { name: resolvedIconName, className: cn("h-6 w-6", resolvedIconToneClassName) })
2184
+ }
2185
+ ),
2186
+ /* @__PURE__ */ jsxs4(
2187
+ "div",
2188
+ {
2189
+ className: cn(
2190
+ "agg-order-panel-content flex flex-col items-center gap-1",
2191
+ classNames == null ? void 0 : classNames.content
2192
+ ),
2193
+ children: [
2194
+ tradingState.market ? /* @__PURE__ */ jsx5(Typography, { variant: "body", children: tradingState.market.question }) : null,
2195
+ tradingState.winningOutcome ? /* @__PURE__ */ jsx5(Typography, { variant: "body-large-strong", children: tradingLabels.outcome(tradingState.winningOutcome.label) }) : null
2196
+ ]
2197
+ }
2198
+ ),
2199
+ resolvedClaim ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2200
+ /* @__PURE__ */ jsx5("div", { className: "h-px w-full bg-agg-separator" }),
2201
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-5 p-6", children: [
2202
+ /* @__PURE__ */ jsx5(Typography, { variant: "body-strong", children: (_d = extendedTradingLabels.resolvedEarningsTitle) != null ? _d : "Your Earnings" }),
2203
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-3 text-agg-sm leading-agg-5 text-agg-foreground", children: [
2204
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
2205
+ /* @__PURE__ */ jsx5("span", { children: (_e = extendedTradingLabels.resolvedResolutionDateLabel) != null ? _e : "Resolution date" }),
2206
+ /* @__PURE__ */ jsx5("span", { className: "font-agg-bold", children: resolvedClaim.resolutionDateLabel })
2207
+ ] }),
2208
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
2209
+ /* @__PURE__ */ jsx5("span", { children: (_f = extendedTradingLabels.resolvedSharesLabel) != null ? _f : "Shares" }),
2210
+ /* @__PURE__ */ jsx5("span", { className: "font-agg-bold", children: resolvedClaim.sharesLabel })
2211
+ ] }),
2212
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-4", children: [
2213
+ /* @__PURE__ */ jsx5("span", { children: (_g = extendedTradingLabels.resolvedTotalPayoutLabel) != null ? _g : "Total payout" }),
2214
+ /* @__PURE__ */ jsx5("span", { className: "font-agg-bold", children: resolvedClaim.totalPayoutLabel })
2215
+ ] })
2216
+ ] }),
2217
+ resolvedClaim.onClaim ? /* @__PURE__ */ jsx5(
2218
+ Button,
2219
+ {
2220
+ size: "large",
2221
+ onClick: resolvedClaim.onClaim,
2222
+ isLoading: resolvedClaim.isClaiming,
2223
+ disabled: resolvedClaim.isClaiming,
2224
+ children: (_h = extendedTradingLabels.claimWinnings) != null ? _h : "Claim Winnings"
2225
+ }
2226
+ ) : null
2227
+ ] })
2228
+ ] }) : null
2229
+ ]
2230
+ }
2231
+ )
2232
+ }
2233
+ );
2234
+ };
2235
+ var renderRouteBreakdownRow = (row) => {
2236
+ var _a, _b;
2237
+ const venueLabel = getTradingVenueLabel(row.venue);
2238
+ const rowKey = `${row.venue}-${row.label}-${row.priceLabel}-${(_a = row.resultLabel) != null ? _a : ""}`;
2239
+ return /* @__PURE__ */ jsxs4(
2240
+ "div",
2241
+ {
2242
+ className: "agg-route-breakdown-row flex items-center justify-between gap-4 text-left",
2243
+ children: [
2244
+ /* @__PURE__ */ jsxs4("div", { className: "agg-route-breakdown-market flex min-w-0 items-center gap-2", children: [
2245
+ /* @__PURE__ */ jsx5(VenueLogo, { venue: row.venue, className: "!size-3", ariaLabel: venueLabel }),
2246
+ /* @__PURE__ */ jsx5("p", { className: "agg-route-breakdown-label truncate text-agg-sm leading-agg-5 text-agg-foreground", children: row.label })
2247
+ ] }),
2248
+ /* @__PURE__ */ jsxs4("div", { className: "agg-route-breakdown-value flex shrink-0 items-center gap-2 text-agg-sm leading-agg-5", children: [
2249
+ /* @__PURE__ */ jsx5("p", { className: "text-agg-muted-foreground", children: row.priceLabel }),
2250
+ /* @__PURE__ */ jsx5("p", { className: "text-agg-foreground", children: (_b = row.resultLabel) != null ? _b : "" })
2251
+ ] })
2252
+ ]
2253
+ },
2254
+ rowKey
2255
+ );
2256
+ };
2257
+ var renderRouteCard = ({
2258
+ card,
2259
+ enableAnimations,
2260
+ isExpanded,
2261
+ isSelected,
2262
+ onSelect,
2263
+ tradingLabels
2264
+ }) => {
2265
+ var _a, _b;
2266
+ const showSplitDetails = isSelected && isExpanded && card.kind === "split" && !!((_a = card.rows) == null ? void 0 : _a.length);
2267
+ const valueLabel = card.isUnavailable ? tradingLabels.venueUnavailableInRegion : card.value;
2268
+ const ariaLabel = [card.label, card.hint, valueLabel].filter(Boolean).join(" ");
2269
+ return /* @__PURE__ */ jsxs4(
2270
+ "button",
2271
+ {
2272
+ type: "button",
2273
+ "aria-pressed": isSelected,
2274
+ "aria-label": ariaLabel,
2275
+ disabled: card.isUnavailable,
2276
+ className: cn(
2277
+ "agg-route-card",
2278
+ "relative w-full cursor-pointer overflow-hidden rounded-agg-lg p-3 text-left",
2279
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
2280
+ getMotionClassName(
2281
+ enableAnimations,
2282
+ "transition-[background-color,border-color,color] duration-200 ease-in-out"
2283
+ ),
2284
+ isSelected && !card.isUnavailable ? "border border-agg-trade-highlight-border bg-gradient-to-b from-agg-trade-highlight-surface-from to-agg-trade-highlight-surface-to" : "border-transparent bg-agg-secondary-hover",
2285
+ card.isUnavailable && "cursor-not-allowed"
2286
+ ),
2287
+ onClick: () => onSelect(card.id),
2288
+ children: [
2289
+ isSelected && !card.isUnavailable ? /* @__PURE__ */ jsx5("div", { className: "agg-route-card-glow pointer-events-none absolute -inset-x-px -bottom-px h-11 bg-linear-to-b from-transparent to-agg-trade-highlight-glow" }) : null,
2290
+ /* @__PURE__ */ jsxs4("div", { className: "agg-route-card-content relative z-10 flex flex-col gap-3", children: [
2291
+ /* @__PURE__ */ jsxs4("div", { className: "agg-route-card-header flex items-center justify-between gap-4", children: [
2292
+ /* @__PURE__ */ jsxs4("div", { className: "agg-route-card-meta flex min-w-0 gap-3 items-center", children: [
2293
+ card.kind === "split" ? /* @__PURE__ */ jsx5(
2294
+ Icon,
2295
+ {
2296
+ name: "sparkles-filled",
2297
+ size: "small",
2298
+ className: cn(
2299
+ "mt-0.5 h-4 w-4 shrink-0",
2300
+ isSelected ? "text-agg-trade-highlight-accent" : "text-agg-muted-foreground/70"
2301
+ ),
2302
+ "aria-hidden": "true"
2303
+ }
2304
+ ) : card.venue ? /* @__PURE__ */ jsx5(
2305
+ VenueLogo,
2306
+ {
2307
+ venue: card.venue,
2308
+ size: "small",
2309
+ ariaLabel: getTradingVenueLabel(card.venue)
2310
+ }
2311
+ ) : null,
2312
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-1 min-w-0", children: [
2313
+ /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1.5", children: [
2314
+ /* @__PURE__ */ jsx5("p", { className: "agg-route-card-title truncate text-agg-sm leading-agg-5 text-agg-foreground", children: card.label }),
2315
+ card.kind === "split" && isSelected ? /* @__PURE__ */ jsx5(
2316
+ Icon,
2317
+ {
2318
+ name: showSplitDetails ? "chevron-up" : "chevron-down",
2319
+ size: "small",
2320
+ className: "h-4 w-4 shrink-0 text-agg-muted-foreground/50",
2321
+ "aria-hidden": "true"
2322
+ }
2323
+ ) : null
2324
+ ] }),
2325
+ card.hint ? /* @__PURE__ */ jsx5("p", { className: "agg-route-card-hint text-agg-xs leading-agg-4 text-agg-muted-foreground", children: card.hint }) : null
2326
+ ] })
2327
+ ] }),
2328
+ /* @__PURE__ */ jsx5(
2329
+ "p",
2330
+ {
2331
+ className: cn(
2332
+ "agg-route-card-value",
2333
+ "shrink-0 whitespace-nowrap",
2334
+ card.isUnavailable ? "text-agg-xs leading-agg-4 text-agg-muted-foreground" : isSelected ? "text-agg-lg font-agg-bold leading-agg-7 text-agg-trade-highlight-accent" : "text-agg-base leading-agg-6 text-agg-foreground"
2335
+ ),
2336
+ children: valueLabel
2337
+ }
2338
+ )
2339
+ ] }),
2340
+ showSplitDetails ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
2341
+ /* @__PURE__ */ jsx5("p", { className: "agg-route-card-description text-agg-xs leading-agg-4 text-agg-foreground", children: tradingLabels.splitOrderDescription }),
2342
+ /* @__PURE__ */ jsx5("div", { className: "agg-route-breakdown flex flex-col gap-3", children: (_b = card.rows) == null ? void 0 : _b.map((row) => renderRouteBreakdownRow(row)) })
2343
+ ] }) : null
2344
+ ] })
2345
+ ]
2346
+ }
2347
+ );
2348
+ };
2349
+ var normalizeOrderIdLabelInput2 = (orderId) => orderId.replace(/^#+/, "");
2350
+ var renderSubmissionSurface = ({
2351
+ actionLabel,
2352
+ className,
2353
+ classNames,
2354
+ enableAnimations,
2355
+ headerSubtitle,
2356
+ headerImage,
2357
+ headerTitle,
2358
+ progressState,
2359
+ tradingLabels
2360
+ }) => {
2361
+ const resolveStepGroups = () => {
2362
+ var _a, _b, _c;
2363
+ if (progressState.phase === "finding-route") {
2364
+ return [
2365
+ [
2366
+ {
2367
+ id: "finding-route",
2368
+ label: tradingLabels.findingBestRoute,
2369
+ status: "pending"
2370
+ }
2371
+ ]
2372
+ ];
2373
+ }
2374
+ const dag = progressState.dagProgress;
2375
+ if (dag && dag.totalSteps > 0) {
2376
+ const steps = [
2377
+ {
2378
+ id: "finding-route",
2379
+ label: tradingLabels.findingBestRoute,
2380
+ status: "complete"
2381
+ }
2382
+ ];
2383
+ for (let i = 1; i <= dag.totalSteps; i++) {
2384
+ const isCompleted = dag.completedSequences.includes(i);
2385
+ const isCurrent = i === dag.currentSequence && !isCompleted;
2386
+ const stepType = (_a = dag.stepTypes[i]) != null ? _a : null;
2387
+ const stepLabel = stepType ? getDefaultStepLabel(stepType) : `Step ${i} of ${dag.totalSteps}`;
2388
+ const prev = steps[steps.length - 1];
2389
+ if (prev && prev.label === stepLabel) {
2390
+ if (prev.status === "complete" && !isCompleted) {
2391
+ prev.status = "pending";
2392
+ }
2393
+ continue;
2394
+ }
2395
+ steps.push({
2396
+ id: `dag-step-${i}`,
2397
+ label: stepLabel,
2398
+ status: isCompleted ? "complete" : isCurrent ? "pending" : "pending"
2399
+ });
2400
+ }
2401
+ return [steps];
2402
+ }
2403
+ const baseSteps = [
2404
+ {
2405
+ id: "finding-route",
2406
+ label: tradingLabels.findingBestRoute,
2407
+ status: "complete"
2408
+ },
2409
+ {
2410
+ id: "submitting-order",
2411
+ label: tradingLabels.submittingOrderProgress,
2412
+ status: "complete"
2413
+ }
2414
+ ];
2415
+ const submittedOrderId = (_c = progressState.orderId) != null ? _c : (_b = progressState.orderIds) == null ? void 0 : _b[0];
2416
+ if (submittedOrderId) {
2417
+ baseSteps.push({
2418
+ id: "order-submitted",
2419
+ label: tradingLabels.orderSubmittedProgress(normalizeOrderIdLabelInput2(submittedOrderId)),
2420
+ status: "complete"
2421
+ });
2422
+ }
2423
+ return [
2424
+ baseSteps,
2425
+ [
2426
+ {
2427
+ id: "executing-order",
2428
+ label: tradingLabels.executingOnVenue(getTradingVenueLabel(progressState.executionVenue)),
2429
+ status: "pending",
2430
+ venue: progressState.executionVenue
2431
+ }
2432
+ ]
2433
+ ];
2434
+ };
2435
+ const stepGroups = resolveStepGroups();
2436
+ return /* @__PURE__ */ jsx5(
2437
+ Card,
2438
+ {
2439
+ className: cn(
2440
+ "group/agg-order-panel",
2441
+ getPlaceOrderContainerClassName(),
2442
+ classNames == null ? void 0 : classNames.root,
2443
+ className
2444
+ ),
2445
+ children: /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-submission-body flex flex-col gap-6 p-5", classNames == null ? void 0 : classNames.body), children: [
2446
+ renderCardHeader({
2447
+ className: classNames == null ? void 0 : classNames.header,
2448
+ headerSubtitle,
2449
+ headerImage,
2450
+ headerTitle
2451
+ }),
2452
+ /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-panel-content flex flex-col gap-6", classNames == null ? void 0 : classNames.content), children: [
2453
+ /* @__PURE__ */ jsxs4("div", { className: "agg-order-submission-status flex h-12 w-full items-center justify-center gap-3 rounded-agg-full bg-agg-primary-hover px-8 text-agg-base font-agg-bold leading-agg-6 text-agg-on-primary", children: [
2454
+ /* @__PURE__ */ jsx5(LoadingGlyph, { enableAnimations, className: "h-4 w-4 text-current" }),
2455
+ /* @__PURE__ */ jsx5("span", { children: actionLabel })
2456
+ ] }),
2457
+ /* @__PURE__ */ jsx5("div", { className: "agg-order-submission-steps flex flex-col gap-4", children: stepGroups.map((steps, groupIndex) => {
2458
+ return /* @__PURE__ */ jsx5(
2459
+ "div",
2460
+ {
2461
+ className: "agg-order-submission-group flex flex-col gap-2",
2462
+ children: steps.map((step) => {
2463
+ return /* @__PURE__ */ jsxs4(
2464
+ "div",
2465
+ {
2466
+ className: "agg-order-submission-step flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-foreground",
2467
+ children: [
2468
+ step.status === "complete" ? /* @__PURE__ */ jsx5(
2469
+ Icon,
2470
+ {
2471
+ name: "check-circle",
2472
+ size: "small",
2473
+ className: "h-3 w-3 shrink-0 text-agg-primary",
2474
+ "aria-hidden": "true"
2475
+ }
2476
+ ) : /* @__PURE__ */ jsx5(
2477
+ LoadingGlyph,
2478
+ {
2479
+ enableAnimations,
2480
+ className: "h-3 w-3 shrink-0 text-agg-primary"
2481
+ }
2482
+ ),
2483
+ /* @__PURE__ */ jsx5("p", { className: "min-w-0 flex-1", children: step.label }),
2484
+ step.venue ? /* @__PURE__ */ jsx5(
2485
+ VenueLogo,
2486
+ {
2487
+ venue: step.venue,
2488
+ size: "small",
2489
+ ariaLabel: getTradingVenueLabel(step.venue),
2490
+ className: "h-4 w-4"
2491
+ }
2492
+ ) : null
2493
+ ]
2494
+ },
2495
+ step.id
2496
+ );
2497
+ })
2498
+ },
2499
+ `step-group-${groupIndex}`
2500
+ );
2501
+ }) })
2502
+ ] })
2503
+ ] })
2504
+ }
2505
+ );
2506
+ };
2507
+ var InitiateKycButton = ({ label, onOpen }) => /* @__PURE__ */ jsx5(
2508
+ Button,
2509
+ {
2510
+ size: "large",
2511
+ variant: "primary",
2512
+ onClick: onOpen,
2513
+ className: "agg-order-kyc-action h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none mb-3",
2514
+ children: label
2515
+ }
2516
+ );
2517
+ var KycVerifyModal = ({
2518
+ open,
2519
+ onOpenChange,
2520
+ onStartVerification,
2521
+ isInitiating,
2522
+ labels
2523
+ }) => {
2524
+ return /* @__PURE__ */ jsx5(
2525
+ Modal,
2526
+ {
2527
+ open,
2528
+ onOpenChange: (next) => {
2529
+ onOpenChange(next);
2530
+ },
2531
+ children: /* @__PURE__ */ jsxs4(Modal.Container, { maxWidth: "480px", "aria-label": labels.title, children: [
2532
+ /* @__PURE__ */ jsx5(Dialog.Title, { className: "sr-only", children: labels.title }),
2533
+ /* @__PURE__ */ jsx5(Dialog.Description, { className: "sr-only", children: labels.description }),
2534
+ /* @__PURE__ */ jsxs4(Modal.Body, { classNames: { root: "sm:px-10 sm:py-12" }, children: [
2535
+ /* @__PURE__ */ jsx5(
2536
+ "button",
2537
+ {
2538
+ type: "button",
2539
+ className: "absolute right-8 top-7 flex items-center justify-center text-agg-foreground transition-colors hover:text-agg-foreground/80",
2540
+ onClick: () => onOpenChange(false),
2541
+ "aria-label": "Close",
2542
+ children: /* @__PURE__ */ jsx5(CloseIcon, { className: "h-6 w-6" })
2543
+ }
2544
+ ),
2545
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-8 text-center", children: [
2546
+ /* @__PURE__ */ jsx5("div", { className: "flex h-[60px] w-[60px] items-center justify-center text-agg-muted-foreground", children: /* @__PURE__ */ jsx5(UserTrustIcon, { className: "h-[60px] w-[60px]" }) }),
2547
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-3", children: [
2548
+ /* @__PURE__ */ jsx5("h3", { className: "text-agg-2xl leading-agg-8 font-agg-bold text-agg-foreground", children: labels.title }),
2549
+ /* @__PURE__ */ jsx5("p", { className: "agg-type-body text-agg-foreground", children: labels.description })
2550
+ ] }),
2551
+ /* @__PURE__ */ jsxs4("div", { className: "flex w-full flex-col items-center gap-5", children: [
2552
+ /* @__PURE__ */ jsx5(
2553
+ Button,
2554
+ {
2555
+ size: "large",
2556
+ variant: "primary",
2557
+ disabled: isInitiating,
2558
+ isLoading: isInitiating,
2559
+ onClick: onStartVerification,
2560
+ children: labels.startVerification
2561
+ }
2562
+ ),
2563
+ /* @__PURE__ */ jsx5(
2564
+ "button",
2565
+ {
2566
+ type: "button",
2567
+ className: "cursor-pointer text-agg-base font-agg-bold text-agg-primary hover:text-agg-primary/80 transition-colors",
2568
+ onClick: () => onOpenChange(false),
2569
+ children: labels.doItLater
2570
+ }
2571
+ )
2572
+ ] })
2573
+ ] })
2574
+ ] })
2575
+ ] })
2576
+ }
2577
+ );
2578
+ };
2579
+ var KycSuccessModal = ({
2580
+ open,
2581
+ onOpenChange,
2582
+ labels
2583
+ }) => /* @__PURE__ */ jsx5(Modal, { open, onOpenChange, children: /* @__PURE__ */ jsxs4(Modal.Container, { maxWidth: "480px", "aria-label": labels.title, children: [
2584
+ /* @__PURE__ */ jsx5(Dialog.Title, { className: "sr-only", children: labels.title }),
2585
+ /* @__PURE__ */ jsx5(Dialog.Description, { className: "sr-only", children: labels.description }),
2586
+ /* @__PURE__ */ jsxs4(Modal.Body, { classNames: { root: "px-10 py-12" }, children: [
2587
+ /* @__PURE__ */ jsx5(
2588
+ "button",
2589
+ {
2590
+ type: "button",
2591
+ className: "absolute right-8 top-7 flex items-center justify-center text-agg-foreground transition-colors hover:text-agg-foreground/80",
2592
+ onClick: () => onOpenChange(false),
2593
+ "aria-label": "Close",
2594
+ children: /* @__PURE__ */ jsx5(CloseIcon, { className: "h-6 w-6" })
2595
+ }
2596
+ ),
2597
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-8 text-center", children: [
2598
+ /* @__PURE__ */ jsx5("div", { className: "flex h-[60px] w-[60px] items-center justify-center rounded-full bg-agg-success/15", children: /* @__PURE__ */ jsx5(SuccessCheckIcon, { className: "h-6 w-6 text-agg-success" }) }),
2599
+ /* @__PURE__ */ jsxs4("div", { className: "flex flex-col items-center gap-3", children: [
2600
+ /* @__PURE__ */ jsx5("h3", { className: "text-agg-2xl leading-agg-8 font-agg-bold text-agg-foreground", children: labels.title }),
2601
+ /* @__PURE__ */ jsx5("p", { className: "agg-type-body text-agg-foreground", children: labels.description })
2602
+ ] }),
2603
+ /* @__PURE__ */ jsx5(
2604
+ Button,
2605
+ {
2606
+ variant: "secondary",
2607
+ size: "large",
2608
+ className: "w-[120px]",
2609
+ onClick: () => onOpenChange(false),
2610
+ children: labels.done
2611
+ }
2612
+ )
2613
+ ] })
2614
+ ] })
2615
+ ] }) });
2616
+ var PlaceOrder = ({
2617
+ className,
2618
+ classNames,
2619
+ eventTradingState,
2620
+ isLoading = false,
2621
+ isPrimaryActionDisabled = false,
2622
+ isPrimaryActionLoading = false,
2623
+ chainBalancesOverride,
2624
+ onAmountChange,
2625
+ onClose,
2626
+ onOutcomeChange,
2627
+ onPrimaryAction,
2628
+ onSlippageChange,
2629
+ onTabChange,
2630
+ onSuccess,
2631
+ onError,
2632
+ onExecutionStateChange,
2633
+ resolvedClaim
2634
+ }) => {
2635
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
2636
+ const {
2637
+ features: { enableAnimations },
2638
+ general: { locale }
2639
+ } = useSdkUiConfig2();
2640
+ const labels = useLabels3();
2641
+ const tradingLabels = labels.trading;
2642
+ const { isTradingBlocked } = useGeoBlock();
2643
+ const tradingContext = useEventTradingContext2();
2644
+ const selectedEvent = (_a = tradingContext == null ? void 0 : tradingContext.selectedEvent) != null ? _a : null;
2645
+ const selectedMarket = (_b = tradingContext == null ? void 0 : tradingContext.selectedMarket) != null ? _b : null;
2646
+ const selectedOutcomeId = (_c = tradingContext == null ? void 0 : tradingContext.selectedOutcomeId) != null ? _c : null;
2647
+ const resolvedEventTradingState = useMemo3(() => {
2648
+ return eventTradingState != null ? eventTradingState : resolveEventTradingState(selectedEvent);
2649
+ }, [eventTradingState, selectedEvent]);
2650
+ const scopedSelectedEvent = useMemo3(() => {
2651
+ var _a2;
2652
+ if (!selectedEvent) return null;
2653
+ const primaryMarketId = (_a2 = resolvedEventTradingState.primaryMarket) == null ? void 0 : _a2.id;
2654
+ if (!primaryMarketId) return selectedEvent;
2655
+ const isSelectedEventInScope = selectedEvent.venueMarkets.some(
2656
+ (market) => market.id === primaryMarketId
2657
+ );
2658
+ return isSelectedEventInScope ? selectedEvent : null;
2659
+ }, [(_d = resolvedEventTradingState.primaryMarket) == null ? void 0 : _d.id, selectedEvent]);
2660
+ const scopedSelectedMarket = useMemo3(() => {
2661
+ if (!selectedMarket) return resolvedEventTradingState.primaryMarket;
2662
+ const isSelectedMarketInScope = resolvedEventTradingState.marketStates.some(
2663
+ (item) => item.market.id === selectedMarket.id
2664
+ );
2665
+ return isSelectedMarketInScope ? selectedMarket : resolvedEventTradingState.primaryMarket;
2666
+ }, [
2667
+ resolvedEventTradingState.marketStates,
2668
+ resolvedEventTradingState.primaryMarket,
2669
+ selectedMarket
2670
+ ]);
2671
+ const scopedSelectedOutcome = (_g = (_f = (_e = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes.find((outcome) => outcome.id === selectedOutcomeId)) != null ? _e : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes.find(
2672
+ (outcome) => outcome.label.trim().toLowerCase() === "yes"
2673
+ )) != null ? _f : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes[0]) != null ? _g : null;
2674
+ const scopedSelectedOutcomeId = (_h = scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.id) != null ? _h : null;
2675
+ const resolvedTradingState = useMemo3(() => {
2676
+ return resolveMarketTradingState(scopedSelectedMarket);
2677
+ }, [scopedSelectedMarket]);
2678
+ const resolvedReadOnlyMarket = useMemo3(() => {
2679
+ var _a2;
2680
+ if (resolvedEventTradingState.kind !== "resolved") {
2681
+ return scopedSelectedMarket;
2682
+ }
2683
+ return (_a2 = resolvedEventTradingState.primaryMarket) != null ? _a2 : scopedSelectedMarket;
2684
+ }, [
2685
+ resolvedEventTradingState.kind,
2686
+ resolvedEventTradingState.primaryMarket,
2687
+ scopedSelectedMarket
2688
+ ]);
2689
+ const resolvedReadOnlyTradingState = useMemo3(() => {
2690
+ return resolveMarketTradingState(resolvedReadOnlyMarket);
2691
+ }, [resolvedReadOnlyMarket]);
2692
+ const orderEligibility = useMemo3(
2693
+ () => resolveOrderEligibility({
2694
+ event: scopedSelectedEvent,
2695
+ market: scopedSelectedMarket,
2696
+ outcome: scopedSelectedOutcome,
2697
+ eventTradingState: resolvedEventTradingState
2698
+ }),
2699
+ [scopedSelectedEvent, scopedSelectedMarket, scopedSelectedOutcome, resolvedEventTradingState]
2700
+ );
2701
+ const isResolvedOutcomeCtaLocked = resolvedEventTradingState.kind === "resolved" || resolvedTradingState.kind === "resolved";
2702
+ const { isAuthenticated, user } = useAggAuthContext();
2703
+ const { totalBalance, isLoading: isBalanceLoading } = useAggBalanceState();
2704
+ const executeManaged = useExecuteManaged();
2705
+ const aggClient = useAggClient2();
2706
+ const queryClient = useQueryClient();
2707
+ const livePrices = useLiveOutcomePrices(
2708
+ scopedSelectedMarket ? [scopedSelectedMarket] : void 0
2709
+ );
2710
+ const outcomes = useMemo3(
2711
+ () => mapVenueMarketOutcomesToPlaceOrderOutcomes(scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes),
2712
+ [scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venueMarketOutcomes]
2713
+ );
2714
+ const buyTabRef = useRef3(null);
2715
+ const sellTabRef = useRef3(null);
2716
+ const [internalTab, setInternalTab] = useState4("buy");
2717
+ const [internalAmount, setInternalAmount] = useState4(0);
2718
+ const [internalSlippage, setInternalSlippage] = useState4(DEFAULT_SLIPPAGE_VALUE);
2719
+ const [isRoutesExpanded, setIsRoutesExpanded] = useState4(false);
2720
+ const [selectedRouteCardId, setSelectedRouteCardId] = useState4(null);
2721
+ const [isSplitDetailOpen, setIsSplitDetailOpen] = useState4(false);
2722
+ const [submissionFeedback, setSubmissionFeedback] = useState4(null);
2723
+ const [submissionProgressState, setSubmissionProgressState] = useState4(null);
2724
+ const debouncedAmount = useDebouncedValue(internalAmount, 300);
2725
+ const isSell = useMemo3(() => internalTab === "sell", [internalTab]);
2726
+ const {
2727
+ positions: executionPositions,
2728
+ isLoading: isExecutionPositionsLoading,
2729
+ isFetching: isExecutionPositionsFetching
2730
+ } = useExecutionPositions({
2731
+ enabled: Boolean(isAuthenticated && isSell)
2732
+ });
2733
+ const smartRoute = useSmartRoute({
2734
+ venueMarketOutcomeId: scopedSelectedOutcomeId,
2735
+ maxSpend: isSell ? void 0 : debouncedAmount,
2736
+ sellShares: isSell ? debouncedAmount : void 0,
2737
+ chainBalances: chainBalancesOverride,
2738
+ // 1,000,000 bps = 10,000% — effectively unlimited slippage. Users rely on the avg
2739
+ // price in the quote to size their orders. A future FE feature will let users pick
2740
+ // their own slip cap; until then, don't let the engine clamp fills on their behalf.
2741
+ slipCapBps: 1e6,
2742
+ compareVenues: true,
2743
+ tradeSide: isSell ? "sell" : "buy",
2744
+ enabled: debouncedAmount > 0 && orderEligibility.canPlaceOrder
2745
+ });
2746
+ const currentSellableShares = useMemo3(() => {
2747
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
2748
+ const sharesFromQuote = (_b2 = (_a2 = smartRoute.data) == null ? void 0 : _a2.positionAvailability) == null ? void 0 : _b2.totalSellableShares;
2749
+ if (typeof sharesFromQuote === "number" && Number.isFinite(sharesFromQuote)) {
2750
+ return Math.max(0, sharesFromQuote);
2751
+ }
2752
+ if (!isSell || !scopedSelectedOutcome || !scopedSelectedMarket) return 0;
2753
+ const normalizedSelectedOutcomeLabel = scopedSelectedOutcome.label.trim().toLowerCase();
2754
+ const selectedMarketIds = [
2755
+ scopedSelectedMarket.id,
2756
+ (_c2 = scopedSelectedMarket.marketId) != null ? _c2 : void 0,
2757
+ (_d2 = scopedSelectedMarket.externalIdentifier) != null ? _d2 : void 0
2758
+ ].filter((value) => Boolean(value));
2759
+ const selectedMarketIdSet = new Set(selectedMarketIds);
2760
+ const selectedVenue = scopedSelectedMarket.venue;
2761
+ let resolvedShares = 0;
2762
+ for (const group of executionPositions) {
2763
+ const groupOutcomes = (_f2 = (_e2 = group.venueMarket) == null ? void 0 : _e2.venueMarketOutcomes) != null ? _f2 : [];
2764
+ for (const outcome of groupOutcomes) {
2765
+ if (outcome.label.trim().toLowerCase() !== normalizedSelectedOutcomeLabel) continue;
2766
+ for (const breakdown of (_g2 = outcome.venueBreakdown) != null ? _g2 : []) {
2767
+ if (breakdown.venue !== selectedVenue) continue;
2768
+ const matchesMarketId = selectedMarketIdSet.size === 0 || selectedMarketIdSet.has(breakdown.venueMarketId) || selectedMarketIdSet.has(group.targetMarketId);
2769
+ if (!matchesMarketId) continue;
2770
+ resolvedShares += Number.isFinite(breakdown.size) ? breakdown.size : 0;
2771
+ }
2772
+ }
2773
+ }
2774
+ return Math.max(0, resolvedShares);
2775
+ }, [
2776
+ executionPositions,
2777
+ isSell,
2778
+ scopedSelectedMarket,
2779
+ scopedSelectedOutcome,
2780
+ (_j = (_i = smartRoute.data) == null ? void 0 : _i.positionAvailability) == null ? void 0 : _j.totalSellableShares
2781
+ ]);
2782
+ const isCurrentSellableSharesLoading = isSell && isAuthenticated && !(typeof ((_l = (_k = smartRoute.data) == null ? void 0 : _k.positionAvailability) == null ? void 0 : _l.totalSellableShares) === "number") && (isExecutionPositionsLoading || isExecutionPositionsFetching);
2783
+ const displayedCurrentSellableShares = useMemo3(() => {
2784
+ if (!Number.isFinite(currentSellableShares)) return 0;
2785
+ return currentSellableShares;
2786
+ }, [currentSellableShares]);
2787
+ const routeCards = useMemo3(
2788
+ () => smartRoute.data ? buildLiveRouteCards({
2789
+ labels: tradingLabels,
2790
+ quoteData: smartRoute.data,
2791
+ tradeSide: isSell ? "sell" : "buy"
2792
+ }) : [],
2793
+ [smartRoute.data, tradingLabels, isSell]
2794
+ );
2795
+ const resolvedSelectedRouteCardId = useMemo3(() => {
2796
+ var _a2, _b2, _c2, _d2;
2797
+ if (routeCards.length === 0) return null;
2798
+ if (selectedRouteCardId && routeCards.some((card) => card.id === selectedRouteCardId && !card.isUnavailable)) {
2799
+ return selectedRouteCardId;
2800
+ }
2801
+ return (_d2 = (_c2 = (_a2 = routeCards.find((card) => !card.isUnavailable)) == null ? void 0 : _a2.id) != null ? _c2 : (_b2 = routeCards[0]) == null ? void 0 : _b2.id) != null ? _d2 : null;
2802
+ }, [routeCards, selectedRouteCardId]);
2803
+ useEffect3(() => {
2804
+ if (routeCards.length === 0) {
2805
+ setSelectedRouteCardId(null);
2806
+ setIsRoutesExpanded(false);
2807
+ setIsSplitDetailOpen(false);
2808
+ return;
2809
+ }
2810
+ if (resolvedSelectedRouteCardId !== selectedRouteCardId) {
2811
+ setSelectedRouteCardId(resolvedSelectedRouteCardId);
2812
+ }
2813
+ }, [resolvedSelectedRouteCardId, routeCards.length, selectedRouteCardId]);
2814
+ useEffect3(() => {
2815
+ setSubmissionFeedback(null);
2816
+ setSubmissionProgressState(null);
2817
+ }, [internalAmount, internalSlippage, internalTab, scopedSelectedOutcomeId]);
2818
+ const orderedRouteCards = routeCards;
2819
+ const selectedRouteCard = (_n = (_m = orderedRouteCards.find((card) => card.id === resolvedSelectedRouteCardId)) != null ? _m : orderedRouteCards[0]) != null ? _n : null;
2820
+ const isKalshiRoute = useMemo3(() => {
2821
+ if (selectedRouteCard) {
2822
+ return selectedRouteCard.venue === "kalshi" || selectedRouteCard.quoteData.fills.some((f) => f.venue === "kalshi");
2823
+ }
2824
+ return (scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.venue) === "kalshi";
2825
+ }, [selectedRouteCard, scopedSelectedMarket]);
2826
+ const isKalshiVerified = useMemo3(() => {
2827
+ var _a2;
2828
+ const kalshiAccount = (_a2 = user == null ? void 0 : user.venueAccounts) == null ? void 0 : _a2.find((va) => va.venue === "kalshi");
2829
+ return (kalshiAccount == null ? void 0 : kalshiAccount.kycStatus) === "verified";
2830
+ }, [user == null ? void 0 : user.venueAccounts]);
2831
+ const needsKycVerification = isAuthenticated && (user == null ? void 0 : user.venueAccounts) != null && isKalshiRoute && !isKalshiVerified;
2832
+ const {
2833
+ isVerifyModalOpen: isKycVerifyModalOpen,
2834
+ showSuccessModal: showKycSuccessModal,
2835
+ isInitiating: isKycInitiating,
2836
+ openVerifyModal,
2837
+ closeVerifyModal,
2838
+ closeSuccessModal,
2839
+ startVerification
2840
+ } = useKalshiKycFlow({
2841
+ isKalshiVerified,
2842
+ userId: user == null ? void 0 : user.id,
2843
+ walletAddress: (_o = getWalletAddressFromUserProfile(user)) != null ? _o : null,
2844
+ onError
2845
+ });
2846
+ const handleRouteCardSelect = useCallback3(
2847
+ (cardId) => {
2848
+ if (cardId === resolvedSelectedRouteCardId) {
2849
+ const card = routeCards.find((c) => c.id === cardId);
2850
+ if ((card == null ? void 0 : card.kind) === "split") {
2851
+ setIsSplitDetailOpen((prev) => !prev);
2852
+ return;
2853
+ }
2854
+ }
2855
+ setSelectedRouteCardId(cardId);
2856
+ },
2857
+ [resolvedSelectedRouteCardId, routeCards]
2858
+ );
2859
+ const executionProgress = useExecutionProgress({
2860
+ orderIds: (_p = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) != null ? _p : null,
2861
+ enabled: ((submissionProgressState == null ? void 0 : submissionProgressState.phase) === "submitting" || (submissionProgressState == null ? void 0 : submissionProgressState.phase) === "executing") && !!((_q = submissionProgressState == null ? void 0 : submissionProgressState.orderIds) == null ? void 0 : _q.length)
2862
+ });
2863
+ const selectedOutcomeLabel = (_t = (_s = (_r = outcomes.find((outcome) => outcome.id === scopedSelectedOutcomeId)) == null ? void 0 : _r.label) != null ? _s : scopedSelectedOutcome == null ? void 0 : scopedSelectedOutcome.label) != null ? _t : "";
2864
+ const headerImage = (_v = (_u = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.image) != null ? _u : scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.image) != null ? _v : null;
2865
+ const headerTitle = (_x = (_w = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _w : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _x : "";
2866
+ const headerSubtitle = (_y = scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _y : "";
2867
+ const buildExecutionSummary = useCallback3(
2868
+ (quoteData, executionVenue, orderId, partialFillSummary) => {
2869
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
2870
+ if (!quoteData) return void 0;
2871
+ const avgPriceValue = quoteData.totalFilled > 0 ? quoteData.rawExecCost / quoteData.totalFilled : 0;
2872
+ const avgPriceLabel = quoteData.totalFilled > 0 ? getTradingRoutePriceLabel(avgPriceValue) : "\u2014";
2873
+ const actionPriceLabel = quoteData.totalFilled > 0 ? `~${avgPriceLabel}` : avgPriceLabel;
2874
+ const selectedOutcomeIndex = outcomes.findIndex((o) => o.id === scopedSelectedOutcomeId);
2875
+ const actionTone = resolvePlaceOrderSuccessTone({
2876
+ outcomeIndex: selectedOutcomeIndex === -1 ? 0 : selectedOutcomeIndex,
2877
+ tab: internalTab
2878
+ });
2879
+ const actionLabel2 = internalTab === "buy" ? (_b2 = (_a2 = tradingLabels.boughtOutcomeAtPrice) == null ? void 0 : _a2.call(tradingLabels, selectedOutcomeLabel, actionPriceLabel)) != null ? _b2 : `Bought ${selectedOutcomeLabel} at ${actionPriceLabel}` : (_d2 = (_c2 = tradingLabels.soldOutcomeAtPrice) == null ? void 0 : _c2.call(tradingLabels, selectedOutcomeLabel, actionPriceLabel)) != null ? _d2 : `Sold ${selectedOutcomeLabel} at ${actionPriceLabel}`;
2880
+ const sharesLabel = quoteData.totalFilled.toLocaleString("en-US", {
2881
+ minimumFractionDigits: 2,
2882
+ maximumFractionDigits: 2
2883
+ });
2884
+ const payoutLabel = formatUsd(quoteData.rawExecCost);
2885
+ const amountLabel = internalTab === "sell" ? sharesLabel : payoutLabel;
2886
+ const toWinLabel = internalTab === "sell" ? payoutLabel : formatUsd(quoteData.totalFilled);
2887
+ const potentialReturnValue = getPlaceOrderPotentialReturn(quoteData);
2888
+ const potentialReturnLabel = potentialReturnValue > 0 ? formatUsd(potentialReturnValue) : void 0;
2889
+ const eventTitle = (_f2 = (_e2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title) != null ? _e2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question) != null ? _f2 : "";
2890
+ const eventDateSource = (_g2 = scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate) != null ? _g2 : scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate;
2891
+ return {
2892
+ tradeSide: internalTab,
2893
+ shares: sharesLabel,
2894
+ avgPrice: avgPriceLabel,
2895
+ estimatedCost: payoutLabel,
2896
+ venue: executionVenue,
2897
+ eventTitle,
2898
+ eventDateLabel: eventDateSource ? getTradingDateLabel(eventDateSource) : "",
2899
+ eventImage: headerImage,
2900
+ actionLabel: actionLabel2,
2901
+ actionTone,
2902
+ amountLabel,
2903
+ toWinLabel,
2904
+ potentialReturnLabel,
2905
+ executionStepGroups: (partialFillSummary == null ? void 0 : partialFillSummary.kind) === "partial_fill" ? buildPlaceOrderExecutionStepGroupsFromFailureSummary({
2906
+ labels: tradingLabels,
2907
+ summary: partialFillSummary
2908
+ }) : buildPlaceOrderExecutionStepGroups({
2909
+ labels: tradingLabels,
2910
+ orderId: orderId != null ? orderId : (_h2 = executionProgress.submittedOrders[0]) == null ? void 0 : _h2.orderId,
2911
+ quoteData,
2912
+ submittedOrders: executionProgress.submittedOrders
2913
+ }),
2914
+ shareText: buildPlaceOrderShareText({
2915
+ actionLabel: actionLabel2,
2916
+ amountLabel,
2917
+ eventTitle: eventTitle || tradingLabels.orderSuccessTitle,
2918
+ potentialReturnLabel,
2919
+ tab: internalTab != null ? internalTab : "buy",
2920
+ toWinLabel,
2921
+ tradingLabels
2922
+ })
2923
+ };
2924
+ },
2925
+ [
2926
+ executionProgress.submittedOrders,
2927
+ headerImage,
2928
+ internalTab,
2929
+ outcomes,
2930
+ scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.endDate,
2931
+ scopedSelectedEvent == null ? void 0 : scopedSelectedEvent.title,
2932
+ scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.endDate,
2933
+ scopedSelectedMarket == null ? void 0 : scopedSelectedMarket.question,
2934
+ scopedSelectedOutcomeId,
2935
+ selectedOutcomeLabel,
2936
+ tradingLabels
2937
+ ]
2938
+ );
2939
+ useEffect3(() => {
2940
+ if (executionProgress.phase === "order_submitted") {
2941
+ const submittedOrder = executionProgress.submittedOrders[0];
2942
+ setSubmissionProgressState((prev) => {
2943
+ var _a2;
2944
+ if (!prev || prev.phase !== "submitting") return prev;
2945
+ return __spreadProps(__spreadValues({}, prev), {
2946
+ phase: "executing",
2947
+ orderId: (_a2 = submittedOrder == null ? void 0 : submittedOrder.orderId) != null ? _a2 : prev.orderId
2948
+ });
2949
+ });
2950
+ }
2951
+ if (executionProgress.phase === "balance_updated") {
2952
+ setSubmissionProgressState((prev) => {
2953
+ var _a2, _b2;
2954
+ if (!prev || prev.phase !== "submitting" && prev.phase !== "executing") return prev;
2955
+ return __spreadProps(__spreadValues({}, prev), {
2956
+ phase: "success",
2957
+ summary: buildExecutionSummary(
2958
+ selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData,
2959
+ prev.executionVenue,
2960
+ (_b2 = prev.orderId) != null ? _b2 : (_a2 = executionProgress.submittedOrders[0]) == null ? void 0 : _a2.orderId
2961
+ )
2962
+ });
2963
+ });
2964
+ }
2965
+ }, [
2966
+ buildExecutionSummary,
2967
+ executionProgress.phase,
2968
+ executionProgress.submittedOrders,
2969
+ selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData
2970
+ ]);
2971
+ useEffect3(() => {
2972
+ const dp = executionProgress.dagProgress;
2973
+ if (!dp) return;
2974
+ setSubmissionProgressState((prev) => {
2975
+ if (!prev) return prev;
2976
+ if (dp.status === "failed") {
2977
+ const errorMessage = normalizePlaceOrderErrorMessage({
2978
+ errorMessage: dp.errorReason,
2979
+ fallbackMessage: tradingLabels.orderFailed
2980
+ });
2981
+ return __spreadProps(__spreadValues({}, prev), {
2982
+ phase: "failed",
2983
+ errorMessage,
2984
+ dagProgress: dp
2985
+ });
2986
+ }
2987
+ return __spreadProps(__spreadValues({}, prev), { dagProgress: dp });
2988
+ });
2989
+ }, [executionProgress.dagProgress, tradingLabels.orderFailed]);
2990
+ useEffect3(() => {
2991
+ const orderIds = submissionProgressState == null ? void 0 : submissionProgressState.orderIds;
2992
+ if (!(orderIds == null ? void 0 : orderIds.length)) return;
2993
+ const aggregateStatus = deriveAggregateOrderStatus(
2994
+ orderIds,
2995
+ executionProgress.terminalOrderEvents
2996
+ );
2997
+ if (aggregateStatus === "pending") return;
2998
+ setSubmissionProgressState((prev) => {
2999
+ var _a2, _b2, _c2;
3000
+ if (!prev || prev.phase === "success" || prev.phase === "failed") return prev;
3001
+ if (aggregateStatus === "full_success") {
3002
+ const primaryFilledEvent = executionProgress.terminalOrderEvents.find(
3003
+ (e) => e.event === "filled"
3004
+ );
3005
+ return __spreadProps(__spreadValues({}, prev), {
3006
+ phase: "success",
3007
+ orderId: (_a2 = primaryFilledEvent == null ? void 0 : primaryFilledEvent.orderId) != null ? _a2 : prev.orderId,
3008
+ summary: buildExecutionSummary(
3009
+ selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData,
3010
+ prev.executionVenue,
3011
+ (_b2 = primaryFilledEvent == null ? void 0 : primaryFilledEvent.orderId) != null ? _b2 : prev.orderId
3012
+ )
3013
+ });
3014
+ }
3015
+ if (aggregateStatus === "full_failure") {
3016
+ const firstFailedEvent = executionProgress.terminalOrderEvents.find(
3017
+ (e) => e.event === "failed"
3018
+ );
3019
+ const errorMessage = normalizePlaceOrderErrorMessage({
3020
+ errorMessage: firstFailedEvent == null ? void 0 : firstFailedEvent.errorReason,
3021
+ fallbackMessage: tradingLabels.orderFailed
3022
+ });
3023
+ return __spreadProps(__spreadValues({}, prev), {
3024
+ phase: "failed",
3025
+ orderId: (_c2 = firstFailedEvent == null ? void 0 : firstFailedEvent.orderId) != null ? _c2 : prev.orderId,
3026
+ errorMessage
3027
+ });
3028
+ }
3029
+ return __spreadProps(__spreadValues({}, prev), { phase: "failed" });
3030
+ });
3031
+ }, [
3032
+ buildExecutionSummary,
3033
+ executionProgress.terminalOrderEvents,
3034
+ selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData,
3035
+ submissionProgressState == null ? void 0 : submissionProgressState.orderIds,
3036
+ tradingLabels.orderFailed
3037
+ ]);
3038
+ useEffect3(() => {
3039
+ if (!submissionProgressState) return;
3040
+ onExecutionStateChange == null ? void 0 : onExecutionStateChange(submissionProgressState);
3041
+ if (submissionProgressState.phase === "success" && submissionProgressState.summary) {
3042
+ invalidateBalanceQueries(queryClient);
3043
+ invalidatePositionQueries(queryClient);
3044
+ onSuccess == null ? void 0 : onSuccess(submissionProgressState.summary);
3045
+ }
3046
+ if (submissionProgressState.phase === "failed" && submissionProgressState.errorMessage) {
3047
+ onError == null ? void 0 : onError(new Error(submissionProgressState.errorMessage));
3048
+ }
3049
+ }, [submissionProgressState, onExecutionStateChange, onSuccess, onError, queryClient]);
3050
+ const activeQuoteData = (_A = (_z = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _z : smartRoute.data) != null ? _A : null;
3051
+ const visibleRouteCards = orderedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT && !isRoutesExpanded ? orderedRouteCards.slice(0, PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT) : orderedRouteCards;
3052
+ const hasEnteredAmount = internalAmount > 0;
3053
+ const shouldPromptSignIn = orderEligibility.canPlaceOrder && !isAuthenticated && hasEnteredAmount;
3054
+ const isInsufficientBalance = !isSell && isAuthenticated && hasEnteredAmount && !isBalanceLoading && internalAmount > totalBalance;
3055
+ const isBelowMinimum = !isSell && hasEnteredAmount && internalAmount < MIN_BUY_ORDER_AMOUNT;
3056
+ const quoteStatus = useMemo3(() => {
3057
+ if (!orderEligibility.canPlaceOrder) return void 0;
3058
+ return resolvePlaceOrderQuoteStatus({
3059
+ amount: internalAmount,
3060
+ labels: tradingLabels,
3061
+ quoteData: activeQuoteData,
3062
+ selectedMarket: scopedSelectedMarket
3063
+ });
3064
+ }, [
3065
+ activeQuoteData,
3066
+ internalAmount,
3067
+ orderEligibility.canPlaceOrder,
3068
+ scopedSelectedMarket,
3069
+ tradingLabels
3070
+ ]);
3071
+ const smartRouteErrorMessage = useMemo3(() => {
3072
+ if (!smartRoute.error) return null;
3073
+ return normalizePlaceOrderErrorMessage({
3074
+ errorMessage: smartRoute.error.message,
3075
+ fallbackMessage: tradingLabels.quoteUnavailable
3076
+ });
3077
+ }, [smartRoute.error, tradingLabels.quoteUnavailable]);
3078
+ const progressActionLabel = (internalTab === "buy" ? tradingLabels.buyingOutcome(selectedOutcomeLabel) : tradingLabels.sellingOutcome(selectedOutcomeLabel)).trim();
3079
+ const canRetryRemaining = useMemo3(() => {
3080
+ if (isSell) return true;
3081
+ const remaining = getPlaceOrderUnfilledRemaining({
3082
+ originalAmount: internalAmount,
3083
+ terminalOrderEvents: executionProgress.terminalOrderEvents
3084
+ });
3085
+ return remaining >= MIN_BUY_ORDER_AMOUNT;
3086
+ }, [executionProgress.terminalOrderEvents, internalAmount, isSell]);
3087
+ const failureSummary = useMemo3(() => {
3088
+ var _a2;
3089
+ if ((submissionProgressState == null ? void 0 : submissionProgressState.phase) !== "failed") return void 0;
3090
+ return buildPlaceOrderFailureSummary({
3091
+ actionLabel: progressActionLabel,
3092
+ canRetryRemaining,
3093
+ errorMessage: submissionProgressState.errorMessage,
3094
+ eventImage: headerImage,
3095
+ eventSubtitle: headerSubtitle || void 0,
3096
+ eventTitle: headerTitle || tradingLabels.orderFailureTitle,
3097
+ labels: tradingLabels,
3098
+ orderId: submissionProgressState.orderId,
3099
+ quoteData: (_a2 = selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData) != null ? _a2 : activeQuoteData,
3100
+ submittedOrders: executionProgress.submittedOrders,
3101
+ terminalOrderEvents: executionProgress.terminalOrderEvents
3102
+ });
3103
+ }, [
3104
+ activeQuoteData,
3105
+ canRetryRemaining,
3106
+ executionProgress.submittedOrders,
3107
+ executionProgress.terminalOrderEvents,
3108
+ headerImage,
3109
+ headerSubtitle,
3110
+ headerTitle,
3111
+ progressActionLabel,
3112
+ selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData,
3113
+ submissionProgressState,
3114
+ tradingLabels
3115
+ ]);
3116
+ const displayedToWinHint = (_B = selectedRouteCard == null ? void 0 : selectedRouteCard.hint) != null ? _B : "";
3117
+ const displayedToWinValue = (_C = selectedRouteCard == null ? void 0 : selectedRouteCard.numericValue) != null ? _C : 0;
3118
+ const isActionLoading = isPrimaryActionLoading || executeManaged.isPending;
3119
+ const selectedRouteGeoBlocked = (_D = selectedRouteCard == null ? void 0 : selectedRouteCard.isUnavailable) != null ? _D : false;
3120
+ const geoBlockedVenuesFromWarnings = useMemo3(
3121
+ () => {
3122
+ var _a2;
3123
+ return extractGeoBlockedVenues((_a2 = smartRoute.data) == null ? void 0 : _a2.warnings);
3124
+ },
3125
+ [(_E = smartRoute.data) == null ? void 0 : _E.warnings]
3126
+ );
3127
+ const isPrimaryVenueGeoBlocked = useMemo3(() => {
3128
+ var _a2, _b2;
3129
+ if (!selectedRouteCard || selectedRouteCard.isUnavailable) return false;
3130
+ const fills = (_b2 = (_a2 = selectedRouteCard.quoteData) == null ? void 0 : _a2.fills) != null ? _b2 : [];
3131
+ return fills.length > 0 && fills.every((f) => geoBlockedVenuesFromWarnings.has(f.venue));
3132
+ }, [selectedRouteCard, geoBlockedVenuesFromWarnings]);
3133
+ const shouldShowGeoBlockBanner = isTradingBlocked || selectedRouteGeoBlocked || isPrimaryVenueGeoBlocked;
3134
+ const geoBlockVenueLabel = isTradingBlocked ? void 0 : selectedRouteGeoBlocked ? selectedRouteCard == null ? void 0 : selectedRouteCard.label : isPrimaryVenueGeoBlocked && (selectedRouteCard == null ? void 0 : selectedRouteCard.venue) ? getTradingVenueLabel(selectedRouteCard.venue) : void 0;
3135
+ const actionLabel = `${internalTab === "buy" ? tradingLabels.buy : tradingLabels.sell} ${selectedOutcomeLabel}`.trim();
3136
+ const isActionDisabled = isPrimaryActionDisabled || !orderEligibility.canPlaceOrder || isActionLoading || !hasEnteredAmount || !scopedSelectedMarket || isInsufficientBalance || isBelowMinimum || !selectedRouteCard || !selectedRouteCard.quoteData.quoteId || selectedRouteGeoBlocked || !isAuthenticated || quoteStatus !== void 0;
3137
+ const shouldShowSmartRouting = orderEligibility.canPlaceOrder && hasEnteredAmount && (orderedRouteCards.length > 0 || smartRoute.isFetching);
3138
+ const shouldShowRouteToggle = orderedRouteCards.length > PLACE_ORDER_ROUTE_COLLAPSED_CARD_COUNT;
3139
+ const handleStartNewTrade = useCallback3(() => {
3140
+ setSubmissionProgressState(null);
3141
+ setSubmissionFeedback(null);
3142
+ setInternalAmount(0);
3143
+ setInternalSlippage(DEFAULT_SLIPPAGE_VALUE);
3144
+ setInternalTab("buy");
3145
+ setIsRoutesExpanded(false);
3146
+ setSelectedRouteCardId(null);
3147
+ onAmountChange == null ? void 0 : onAmountChange(0);
3148
+ onSlippageChange == null ? void 0 : onSlippageChange(formatPercentageValue(DEFAULT_SLIPPAGE_VALUE));
3149
+ onTabChange == null ? void 0 : onTabChange("buy");
3150
+ if (scopedSelectedEvent) {
3151
+ tradingContext == null ? void 0 : tradingContext.initializeFromEvent(scopedSelectedEvent);
3152
+ }
3153
+ }, [onAmountChange, onSlippageChange, onTabChange, scopedSelectedEvent, tradingContext]);
3154
+ const handleShareTrade = () => {
3155
+ var _a2, _b2;
3156
+ const shareText = (_b2 = (_a2 = submissionProgressState == null ? void 0 : submissionProgressState.summary) == null ? void 0 : _a2.shareText) == null ? void 0 : _b2.trim();
3157
+ if (!shareText || typeof window === "undefined") return;
3158
+ const shareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(shareText)}`;
3159
+ window.open(shareUrl, "_blank", "noopener,noreferrer");
3160
+ };
3161
+ const handleExecuteQuote = useCallback3(
3162
+ (quoteData) => __async(null, null, function* () {
3163
+ const quoteId = quoteData == null ? void 0 : quoteData.quoteId;
3164
+ if (!quoteId) {
3165
+ throw new Error(tradingLabels.quoteUnavailable);
3166
+ }
3167
+ if (onPrimaryAction) {
3168
+ onPrimaryAction({ quoteId });
3169
+ return;
3170
+ }
3171
+ const response = yield executeManaged.mutateAsync({ quoteId });
3172
+ setSubmissionProgressState({
3173
+ executionVenue: resolveExecutionVenueFromQuote(quoteData),
3174
+ orderId: response.orderIds[0],
3175
+ orderIds: response.orderIds,
3176
+ phase: "submitting"
3177
+ });
3178
+ }),
3179
+ [executeManaged, onPrimaryAction, tradingLabels.quoteUnavailable]
3180
+ );
3181
+ const handleSkipToSuccess = useCallback3(() => {
3182
+ const primaryFilledEvent = executionProgress.terminalOrderEvents.find(
3183
+ (e) => e.event === "filled" || e.event === "partial_fill"
3184
+ );
3185
+ setSubmissionProgressState((prev) => {
3186
+ var _a2;
3187
+ if (!prev) return prev;
3188
+ const orderId = (_a2 = primaryFilledEvent == null ? void 0 : primaryFilledEvent.orderId) != null ? _a2 : prev.orderId;
3189
+ return __spreadProps(__spreadValues({}, prev), {
3190
+ phase: "success",
3191
+ orderId,
3192
+ summary: buildExecutionSummary(
3193
+ selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData,
3194
+ prev.executionVenue,
3195
+ orderId,
3196
+ failureSummary
3197
+ )
3198
+ });
3199
+ });
3200
+ }, [
3201
+ buildExecutionSummary,
3202
+ executionProgress.terminalOrderEvents,
3203
+ failureSummary,
3204
+ selectedRouteCard == null ? void 0 : selectedRouteCard.quoteData
3205
+ ]);
3206
+ const handleRetrySubmission = useCallback3(() => __async(null, null, function* () {
3207
+ var _a2, _b2, _c2;
3208
+ if (!orderEligibility.canPlaceOrder) {
3209
+ handleStartNewTrade();
3210
+ return;
3211
+ }
3212
+ setSubmissionFeedback(null);
3213
+ let retryAmount = internalAmount;
3214
+ let useRemainderRoute = false;
3215
+ if ((failureSummary == null ? void 0 : failureSummary.kind) === "partial_fill" && internalAmount > 0) {
3216
+ const remaining = getPlaceOrderUnfilledRemaining({
3217
+ originalAmount: internalAmount,
3218
+ terminalOrderEvents: executionProgress.terminalOrderEvents
3219
+ });
3220
+ if (remaining > 0) {
3221
+ retryAmount = remaining;
3222
+ useRemainderRoute = true;
3223
+ setInternalAmount(retryAmount);
3224
+ onAmountChange == null ? void 0 : onAmountChange(retryAmount);
3225
+ }
3226
+ }
3227
+ setSubmissionProgressState({ phase: "finding-route" });
3228
+ try {
3229
+ let refetchedQuoteData;
3230
+ if (useRemainderRoute && scopedSelectedOutcomeId) {
3231
+ refetchedQuoteData = yield aggClient.getSmartRoute({
3232
+ venueMarketOutcomeId: scopedSelectedOutcomeId,
3233
+ maxSpend: isSell ? void 0 : retryAmount,
3234
+ sellShares: isSell ? retryAmount : void 0,
3235
+ chainBalances: chainBalancesOverride,
3236
+ slipCapBps: 1e6,
3237
+ compareVenues: true,
3238
+ tradeSide: isSell ? "sell" : "buy"
3239
+ });
3240
+ } else {
3241
+ const refetchedQuoteResult = yield smartRoute.refetch();
3242
+ refetchedQuoteData = (_b2 = (_a2 = resolveRefetchedQuoteData(refetchedQuoteResult)) != null ? _a2 : smartRoute.data) != null ? _b2 : null;
3243
+ }
3244
+ if (!(refetchedQuoteData == null ? void 0 : refetchedQuoteData.quoteId)) {
3245
+ throw new Error(tradingLabels.quoteUnavailable);
3246
+ }
3247
+ const refreshedCards = buildLiveRouteCards({
3248
+ labels: tradingLabels,
3249
+ quoteData: refetchedQuoteData,
3250
+ tradeSide: internalTab
3251
+ });
3252
+ const refreshedSelectedCard = selectedRouteCardId ? refreshedCards.find((card) => card.id === selectedRouteCardId) : void 0;
3253
+ if (selectedRouteCardId && !refreshedSelectedCard) {
3254
+ setSubmissionProgressState(null);
3255
+ setSubmissionFeedback({
3256
+ message: tradingLabels.selectedVenueUnavailable,
3257
+ tone: "error"
3258
+ });
3259
+ return;
3260
+ }
3261
+ yield handleExecuteQuote((_c2 = refreshedSelectedCard == null ? void 0 : refreshedSelectedCard.quoteData) != null ? _c2 : refetchedQuoteData);
3262
+ } catch (error) {
3263
+ const errorMessage = normalizePlaceOrderErrorMessage({
3264
+ errorMessage: error instanceof Error ? error.message : String(error),
3265
+ fallbackMessage: tradingLabels.orderFailed
3266
+ });
3267
+ setSubmissionProgressState({
3268
+ phase: "failed",
3269
+ errorMessage
3270
+ });
3271
+ }
3272
+ }), [
3273
+ aggClient,
3274
+ chainBalancesOverride,
3275
+ executionProgress.terminalOrderEvents,
3276
+ failureSummary == null ? void 0 : failureSummary.kind,
3277
+ handleExecuteQuote,
3278
+ handleStartNewTrade,
3279
+ internalAmount,
3280
+ internalTab,
3281
+ isSell,
3282
+ onAmountChange,
3283
+ orderEligibility.canPlaceOrder,
3284
+ scopedSelectedOutcomeId,
3285
+ selectedRouteCardId,
3286
+ smartRoute,
3287
+ tradingLabels
3288
+ ]);
3289
+ const resolvedStatusClassName = cn(classNames == null ? void 0 : classNames.root, className);
3290
+ if (isLoading) {
3291
+ return /* @__PURE__ */ jsx5(
3292
+ Skeleton,
3293
+ {
3294
+ ariaLabel: labels.common.loading,
3295
+ className: resolvedStatusClassName,
3296
+ view: skeletonViews.placeOrder
3297
+ }
3298
+ );
3299
+ }
3300
+ if (submissionProgressState) {
3301
+ if (submissionProgressState.phase === "success" && submissionProgressState.summary) {
3302
+ return /* @__PURE__ */ jsx5(
3303
+ PlaceOrderSuccessView,
3304
+ {
3305
+ className: resolvedStatusClassName,
3306
+ summary: submissionProgressState.summary,
3307
+ tradingLabels,
3308
+ onDone: handleStartNewTrade,
3309
+ onShare: handleShareTrade
3310
+ }
3311
+ );
3312
+ }
3313
+ if (submissionProgressState.phase === "failed") {
3314
+ return /* @__PURE__ */ jsx5(
3315
+ PlaceOrderFailureView,
3316
+ {
3317
+ className: resolvedStatusClassName,
3318
+ enableAnimations,
3319
+ summary: failureSummary,
3320
+ tradingLabels,
3321
+ onRetry: handleRetrySubmission,
3322
+ onDone: handleStartNewTrade,
3323
+ onSkip: handleSkipToSuccess
3324
+ }
3325
+ );
3326
+ }
3327
+ return renderSubmissionSurface({
3328
+ actionLabel: progressActionLabel,
3329
+ className,
3330
+ classNames,
3331
+ enableAnimations,
3332
+ headerSubtitle,
3333
+ headerImage,
3334
+ headerTitle,
3335
+ progressState: submissionProgressState,
3336
+ tradingLabels
3337
+ });
3338
+ }
3339
+ const handleTabChange = (nextTab) => {
3340
+ if (!orderEligibility.canPlaceOrder) return;
3341
+ setInternalTab(nextTab);
3342
+ onTabChange == null ? void 0 : onTabChange(nextTab);
3343
+ };
3344
+ const handleOutcomeChange = (nextOutcomeId) => {
3345
+ if (isResolvedOutcomeCtaLocked) return;
3346
+ if (!orderEligibility.canPlaceOrder) return;
3347
+ onOutcomeChange == null ? void 0 : onOutcomeChange(nextOutcomeId);
3348
+ tradingContext == null ? void 0 : tradingContext.selectOutcome(nextOutcomeId);
3349
+ };
3350
+ const handleAmountChange = (nextValue) => {
3351
+ if (!orderEligibility.canPlaceOrder) return;
3352
+ const resolvedNextValue = nextValue != null ? nextValue : 0;
3353
+ setInternalAmount(resolvedNextValue);
3354
+ onAmountChange == null ? void 0 : onAmountChange(resolvedNextValue);
3355
+ };
3356
+ const handleFillSellableShares = () => {
3357
+ if (!isSell) return;
3358
+ if (displayedCurrentSellableShares <= 0) return;
3359
+ handleAmountChange(displayedCurrentSellableShares);
3360
+ };
3361
+ const handleSignInRequiredClick = () => {
3362
+ if (!shouldPromptSignIn) return;
3363
+ requestAggAuthChooserOpen();
3364
+ };
3365
+ const handleDepositRequiredClick = () => {
3366
+ if (!isInsufficientBalance) return;
3367
+ requestAggDepositModalOpen();
3368
+ };
3369
+ const handleTabKeyDown = (event, currentTab) => {
3370
+ if (!orderEligibility.canPlaceOrder) return;
3371
+ const nextTab = resolveNextTabFromKey({ currentTab, key: event.key });
3372
+ if (!nextTab) return;
3373
+ event.preventDefault();
3374
+ handleTabChange(nextTab);
3375
+ requestAnimationFrame(() => {
3376
+ var _a2;
3377
+ (_a2 = (nextTab === "buy" ? buyTabRef : sellTabRef).current) == null ? void 0 : _a2.focus();
3378
+ });
3379
+ };
3380
+ const handlePrimaryAction = () => __async(null, null, function* () {
3381
+ var _a2;
3382
+ if (!orderEligibility.canPlaceOrder) {
3383
+ setSubmissionFeedback({
3384
+ message: (_a2 = resolveOrderEligibilityMessage(labels, orderEligibility.reason)) != null ? _a2 : tradingLabels.orderFailed,
3385
+ tone: "error"
3386
+ });
3387
+ return;
3388
+ }
3389
+ if (!selectedRouteCard) return;
3390
+ setSubmissionFeedback(null);
3391
+ try {
3392
+ setSubmissionProgressState({ phase: "finding-route" });
3393
+ yield handleExecuteQuote(selectedRouteCard.quoteData);
3394
+ } catch (error) {
3395
+ const errorMessage = normalizePlaceOrderErrorMessage({
3396
+ errorMessage: error instanceof Error ? error.message : String(error),
3397
+ fallbackMessage: tradingLabels.orderFailed
3398
+ });
3399
+ setSubmissionProgressState({
3400
+ phase: "failed",
3401
+ errorMessage
3402
+ });
3403
+ }
3404
+ });
3405
+ if (!orderEligibility.canPlaceOrder && resolvedReadOnlyTradingState.kind !== "open") {
3406
+ return /* @__PURE__ */ jsx5(
3407
+ PlaceOrderResolvedView,
3408
+ {
3409
+ tradingState: resolvedReadOnlyTradingState,
3410
+ resolvedClaim,
3411
+ classNames,
3412
+ className
3413
+ }
3414
+ );
3415
+ }
3416
+ return /* @__PURE__ */ jsxs4(Fragment2, { children: [
3417
+ /* @__PURE__ */ jsx5(
3418
+ Card,
3419
+ {
3420
+ className: cn(
3421
+ "group/agg-order-panel",
3422
+ getPlaceOrderContainerClassName(),
3423
+ classNames == null ? void 0 : classNames.root,
3424
+ className
3425
+ ),
3426
+ children: /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-panel-body flex flex-col gap-6 p-5", classNames == null ? void 0 : classNames.body), children: [
3427
+ renderCardHeader({
3428
+ className: classNames == null ? void 0 : classNames.header,
3429
+ headerSubtitle,
3430
+ headerImage,
3431
+ headerTitle,
3432
+ onClose
3433
+ }),
3434
+ /* @__PURE__ */ jsxs4("div", { className: cn("agg-order-panel-content flex flex-col gap-6", classNames == null ? void 0 : classNames.content), children: [
3435
+ /* @__PURE__ */ jsx5(
3436
+ "div",
3437
+ {
3438
+ className: "agg-order-tabs flex items-end border-b border-agg-separator",
3439
+ role: "tablist",
3440
+ "aria-label": labels.common.tabsAria,
3441
+ children: [
3442
+ { value: "buy", label: tradingLabels.buy, ref: buyTabRef },
3443
+ { value: "sell", label: tradingLabels.sell, ref: sellTabRef }
3444
+ ].map((tabItem) => {
3445
+ const isActive = internalTab === tabItem.value;
3446
+ return /* @__PURE__ */ jsxs4(
3447
+ "button",
3448
+ {
3449
+ ref: tabItem.ref,
3450
+ type: "button",
3451
+ role: "tab",
3452
+ "aria-selected": isActive,
3453
+ tabIndex: isActive ? 0 : -1,
3454
+ className: cn(
3455
+ "agg-order-tab-trigger",
3456
+ "relative -mb-px cursor-pointer px-5 pb-2 text-agg-base leading-agg-6",
3457
+ "disabled:cursor-not-allowed disabled:opacity-60",
3458
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
3459
+ isActive ? "text-agg-primary" : "text-agg-foreground",
3460
+ getMotionClassName(
3461
+ enableAnimations,
3462
+ "transition-[color,opacity] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"
3463
+ )
3464
+ ),
3465
+ disabled: !orderEligibility.canPlaceOrder,
3466
+ onClick: () => handleTabChange(tabItem.value),
3467
+ onKeyDown: (event) => handleTabKeyDown(event, tabItem.value),
3468
+ children: [
3469
+ tabItem.label,
3470
+ /* @__PURE__ */ jsx5(
3471
+ "span",
3472
+ {
3473
+ "aria-hidden": "true",
3474
+ className: cn(
3475
+ "agg-order-tab-indicator",
3476
+ "pointer-events-none absolute inset-x-0 bottom-0 h-0.5 rounded-t-agg-sm bg-agg-primary",
3477
+ isActive ? "opacity-100" : "opacity-0",
3478
+ getMotionClassName(
3479
+ enableAnimations,
3480
+ "transition-opacity duration-200 ease-in-out"
3481
+ )
3482
+ )
3483
+ }
3484
+ )
3485
+ ]
3486
+ },
3487
+ tabItem.value
3488
+ );
3489
+ })
3490
+ }
3491
+ ),
3492
+ outcomes.length >= 2 ? /* @__PURE__ */ jsx5("div", { className: "agg-outcomes flex w-full max-w-full gap-2", children: outcomes.map((outcome, index) => {
3493
+ var _a2, _b2;
3494
+ const price = (_a2 = livePrices.get(outcome.id)) != null ? _a2 : outcome.price;
3495
+ const isActive = outcome.id === scopedSelectedOutcomeId;
3496
+ const isPositive = resolveIsPositiveOutcome(outcome, index);
3497
+ const displayLabel = ((_b2 = outcome.title) == null ? void 0 : _b2.trim()) || outcome.label;
3498
+ return /* @__PURE__ */ jsxs4(
3499
+ "button",
3500
+ {
3501
+ "data-id": outcome.id,
3502
+ type: "button",
3503
+ className: cn(
3504
+ "agg-outcome-button",
3505
+ getOutcomeButtonClassName({
3506
+ enableAnimations,
3507
+ isActive,
3508
+ isPositive
3509
+ }),
3510
+ "disabled:cursor-not-allowed disabled:opacity-60",
3511
+ "leading-agg-5! flex-1 min-w-0 gap-1 md:gap-2"
3512
+ ),
3513
+ "aria-pressed": isActive,
3514
+ "aria-label": `${displayLabel} ${formatProbabilityCents(price)}`,
3515
+ disabled: !orderEligibility.canPlaceOrder || isResolvedOutcomeCtaLocked,
3516
+ onClick: () => handleOutcomeChange(outcome.id),
3517
+ children: [
3518
+ /* @__PURE__ */ jsx5(
3519
+ Typography,
3520
+ {
3521
+ as: "span",
3522
+ variant: isActive ? "body-strong" : "body",
3523
+ className: cn("whitespace-nowrap truncate"),
3524
+ children: displayLabel
3525
+ }
3526
+ ),
3527
+ /* @__PURE__ */ jsx5(Typography, { as: "span", variant: isActive ? "body-strong" : "body", children: formatProbabilityCents(price) })
3528
+ ]
3529
+ },
3530
+ outcome.id
3531
+ );
3532
+ }) }) : null,
3533
+ /* @__PURE__ */ jsxs4("div", { className: "agg-order-amount-section flex items-start justify-between gap-4", children: [
3534
+ /* @__PURE__ */ jsxs4("div", { className: "agg-order-amount-meta flex flex-col", children: [
3535
+ /* @__PURE__ */ jsx5("p", { className: "agg-order-amount-label text-agg-base font-agg-bold leading-agg-6 text-agg-foreground whitespace-nowrap", children: tradingLabels.amount(internalTab) }),
3536
+ isAuthenticated ? isSell ? /* @__PURE__ */ jsx5(
3537
+ "button",
3538
+ {
3539
+ type: "button",
3540
+ className: cn(
3541
+ "agg-balance-value",
3542
+ "cursor-pointer disabled:cursor-not-allowed",
3543
+ "flex items-center gap-2 bg-transparent p-0 text-agg-sm leading-agg-5 text-agg-muted-foreground",
3544
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary disabled:opacity-60"
3545
+ ),
3546
+ "aria-label": tradingLabels.shares(displayedCurrentSellableShares),
3547
+ disabled: isCurrentSellableSharesLoading || !orderEligibility.canPlaceOrder || displayedCurrentSellableShares <= 0,
3548
+ onClick: handleFillSellableShares,
3549
+ children: isCurrentSellableSharesLoading ? /* @__PURE__ */ jsx5(LoadingIcon, { size: "small" }) : tradingLabels.shares(displayedCurrentSellableShares)
3550
+ }
3551
+ ) : /* @__PURE__ */ jsx5("p", { className: "agg-balance-value flex items-center gap-2 text-agg-sm leading-agg-5 text-agg-muted-foreground", children: isBalanceLoading ? /* @__PURE__ */ jsx5(LoadingIcon, { size: "small" }) : tradingLabels.balance(formatUsd(totalBalance)) }) : null
3552
+ ] }),
3553
+ /* @__PURE__ */ jsx5(
3554
+ CurrencyInput,
3555
+ {
3556
+ value: internalAmount,
3557
+ onChange: handleAmountChange,
3558
+ ariaLabel: tradingLabels.amount(internalTab),
3559
+ isInvalid: isInsufficientBalance,
3560
+ disabled: !orderEligibility.canPlaceOrder,
3561
+ prefix: internalTab === "buy" ? "$" : "",
3562
+ decimalPlaces: isSell ? 6 : 2,
3563
+ classNames: {
3564
+ input: cn(
3565
+ "agg-order-amount-input",
3566
+ "w-full max-w-[168px] text-right text-agg-3xl font-agg-bold leading-agg-9 tracking-agg-normal",
3567
+ hasEnteredAmount ? "text-agg-foreground" : "text-agg-separator caret-agg-foreground"
3568
+ )
3569
+ }
3570
+ }
3571
+ )
3572
+ ] }),
3573
+ shouldShowSmartRouting ? /* @__PURE__ */ jsxs4("div", { className: "agg-route-panel flex flex-col gap-3", children: [
3574
+ /* @__PURE__ */ jsxs4("div", { className: "agg-route-panel-header flex items-center justify-between gap-4", children: [
3575
+ /* @__PURE__ */ jsx5("p", { className: "agg-route-panel-title text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.smartRouting }),
3576
+ shouldShowRouteToggle ? /* @__PURE__ */ jsxs4(
3577
+ "button",
3578
+ {
3579
+ type: "button",
3580
+ className: "agg-route-toggle flex cursor-pointer items-center gap-1.5 text-agg-sm leading-agg-5 text-agg-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-agg-primary focus-visible:ring-offset-0 focus-visible:ring-offset-agg-secondary",
3581
+ "aria-label": isRoutesExpanded ? tradingLabels.hideRoutes : tradingLabels.viewAllRoutes(orderedRouteCards.length),
3582
+ onClick: () => setIsRoutesExpanded((currentValue) => !currentValue),
3583
+ children: [
3584
+ /* @__PURE__ */ jsx5("span", { children: isRoutesExpanded ? tradingLabels.hideRoutes : tradingLabels.viewAllRoutes(orderedRouteCards.length) }),
3585
+ /* @__PURE__ */ jsx5(
3586
+ Icon,
3587
+ {
3588
+ name: isRoutesExpanded ? "chevron-up" : "chevron-down",
3589
+ size: "small",
3590
+ className: "h-4 w-4 text-agg-foreground",
3591
+ "aria-hidden": "true"
3592
+ }
3593
+ )
3594
+ ]
3595
+ }
3596
+ ) : null
3597
+ ] }),
3598
+ /* @__PURE__ */ jsxs4("div", { className: "agg-route-list flex flex-col gap-2", children: [
3599
+ visibleRouteCards.map((card) => {
3600
+ return /* @__PURE__ */ jsx5(Fragment2, { children: renderRouteCard({
3601
+ card,
3602
+ enableAnimations,
3603
+ isExpanded: card.kind === "split" ? isSplitDetailOpen : isRoutesExpanded,
3604
+ isSelected: card.id === resolvedSelectedRouteCardId,
3605
+ onSelect: handleRouteCardSelect,
3606
+ tradingLabels
3607
+ }) }, card.id);
3608
+ }),
3609
+ smartRoute.isFetching ? /* @__PURE__ */ jsx5("div", { className: "agg-route-loading flex items-center justify-center py-2", children: /* @__PURE__ */ jsx5(LoadingIcon, { size: "small" }) }) : null
3610
+ ] })
3611
+ ] }) : null,
3612
+ hasEnteredAmount && selectedRouteCard && orderEligibility.canPlaceOrder ? /* @__PURE__ */ jsxs4("div", { className: "agg-order-summary flex items-start justify-between gap-4", children: [
3613
+ /* @__PURE__ */ jsxs4("div", { className: "agg-order-summary-meta flex flex-col", children: [
3614
+ /* @__PURE__ */ jsx5("p", { className: "agg-order-summary-label text-agg-base font-agg-bold leading-agg-6 text-agg-foreground", children: tradingLabels.toWin(internalTab) }),
3615
+ /* @__PURE__ */ jsx5("p", { className: "agg-order-summary-hint text-agg-sm leading-agg-5 text-agg-muted-foreground", children: displayedToWinHint })
3616
+ ] }),
3617
+ /* @__PURE__ */ jsx5(
3618
+ NumberFlow,
3619
+ {
3620
+ value: displayedToWinValue,
3621
+ locales: locale,
3622
+ format: {
3623
+ currency: "USD",
3624
+ maximumFractionDigits: 2,
3625
+ minimumFractionDigits: 2,
3626
+ style: "currency"
3627
+ },
3628
+ className: "agg-order-summary-value text-right text-agg-3xl font-agg-bold leading-agg-9 tracking-agg-normal text-agg-success"
3629
+ }
3630
+ )
3631
+ ] }) : null,
3632
+ /* @__PURE__ */ jsxs4(
3633
+ "div",
3634
+ {
3635
+ className: cn(
3636
+ "agg-order-panel-footer agg-order-actions flex flex-col gap-3",
3637
+ classNames == null ? void 0 : classNames.footer
3638
+ ),
3639
+ children: [
3640
+ !shouldShowGeoBlockBanner ? /* @__PURE__ */ jsxs4("div", { className: "agg-order-alerts flex flex-col gap-3 empty:hidden mb-3", children: [
3641
+ submissionFeedback ? /* @__PURE__ */ jsx5(
3642
+ InlineAlert,
3643
+ {
3644
+ tone: submissionFeedback.tone,
3645
+ message: submissionFeedback.message
3646
+ }
3647
+ ) : null,
3648
+ !submissionFeedback && orderEligibility.canPlaceOrder && isInsufficientBalance ? /* @__PURE__ */ jsx5(
3649
+ "div",
3650
+ {
3651
+ className: "agg-order-sign-in-alert flex items-center justify-center gap-2",
3652
+ role: "status",
3653
+ "aria-live": "polite",
3654
+ children: /* @__PURE__ */ jsx5(
3655
+ Button,
3656
+ {
3657
+ variant: "tertiary",
3658
+ "aria-label": tradingLabels.insufficientBalance,
3659
+ onClick: handleDepositRequiredClick,
3660
+ className: cn(
3661
+ "agg-order-sign-in-alert-trigger text-agg-sm! text-agg-foreground! font-agg-normal! hover:text-agg-muted-foreground!"
3662
+ ),
3663
+ children: /* @__PURE__ */ jsxs4("span", { className: "flex items-center gap-2", children: [
3664
+ /* @__PURE__ */ jsx5(
3665
+ Icon,
3666
+ {
3667
+ name: "warning-filled",
3668
+ size: "small",
3669
+ className: "h-4! w-4! shrink-0 text-agg-warning",
3670
+ "aria-hidden": "true"
3671
+ }
3672
+ ),
3673
+ /* @__PURE__ */ jsx5("span", { children: tradingLabels.insufficientBalance })
3674
+ ] })
3675
+ }
3676
+ )
3677
+ }
3678
+ ) : null,
3679
+ !submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && isBelowMinimum ? /* @__PURE__ */ jsx5(
3680
+ InlineAlert,
3681
+ {
3682
+ tone: "error",
3683
+ message: tradingLabels.minimumOrderAmount(MIN_BUY_ORDER_AMOUNT)
3684
+ }
3685
+ ) : null,
3686
+ !submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && quoteStatus ? /* @__PURE__ */ jsx5(InlineAlert, { tone: quoteStatus.tone, message: quoteStatus.message }) : null,
3687
+ !submissionFeedback && orderEligibility.canPlaceOrder && !isInsufficientBalance && !isBelowMinimum && !quoteStatus && isAuthenticated && hasEnteredAmount && smartRouteErrorMessage ? /* @__PURE__ */ jsx5(
3688
+ InlineAlert,
3689
+ {
3690
+ tone: "error",
3691
+ message: smartRouteErrorMessage,
3692
+ actionLabel: labels.common.retry,
3693
+ onAction: () => {
3694
+ void smartRoute.refetch();
3695
+ }
3696
+ }
3697
+ ) : null,
3698
+ !submissionFeedback && orderEligibility.canPlaceOrder && !quoteStatus && !isAuthenticated && hasEnteredAmount ? /* @__PURE__ */ jsx5(
3699
+ "div",
3700
+ {
3701
+ className: "agg-order-sign-in-alert flex items-center justify-center gap-2",
3702
+ role: "status",
3703
+ "aria-live": "polite",
3704
+ children: /* @__PURE__ */ jsx5(
3705
+ Button,
3706
+ {
3707
+ variant: "tertiary",
3708
+ "aria-label": tradingLabels.signInRequired,
3709
+ onClick: handleSignInRequiredClick,
3710
+ className: cn(
3711
+ "agg-order-sign-in-alert-trigger text-agg-sm! text-agg-foreground! font-agg-normal! hover:text-agg-muted-foreground!"
3712
+ ),
3713
+ children: /* @__PURE__ */ jsxs4("span", { className: "flex items-center gap-2", children: [
3714
+ /* @__PURE__ */ jsx5(
3715
+ Icon,
3716
+ {
3717
+ name: "warning-filled",
3718
+ size: "small",
3719
+ className: "h-4! w-4! shrink-0 text-agg-warning",
3720
+ "aria-hidden": "true"
3721
+ }
3722
+ ),
3723
+ /* @__PURE__ */ jsx5("span", { children: tradingLabels.signInRequired })
3724
+ ] })
3725
+ }
3726
+ )
3727
+ }
3728
+ ) : null
3729
+ ] }) : null,
3730
+ needsKycVerification && !submissionFeedback && !shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx5(InitiateKycButton, { label: tradingLabels.kycRequired, onOpen: openVerifyModal }) : /* @__PURE__ */ jsx5(
3731
+ Button,
3732
+ {
3733
+ size: "large",
3734
+ variant: hasEnteredAmount && !shouldShowGeoBlockBanner ? "primary" : "secondary",
3735
+ className: "agg-order-submit h-12 w-full px-8 text-agg-base leading-agg-6 shadow-none mb-3",
3736
+ disabled: isActionDisabled || shouldShowGeoBlockBanner,
3737
+ isLoading: isActionLoading,
3738
+ "aria-label": actionLabel,
3739
+ onClick: () => {
3740
+ void handlePrimaryAction();
3741
+ },
3742
+ children: actionLabel
3743
+ }
3744
+ ),
3745
+ shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx5(GeoBlockBanner, { venue: geoBlockVenueLabel }) : null,
3746
+ !shouldShowGeoBlockBanner ? /* @__PURE__ */ jsx5("p", { className: "agg-order-disclaimer text-center text-agg-xs leading-agg-4 text-agg-muted-foreground", children: tradingLabels.disclaimer }) : null
3747
+ ]
3748
+ }
3749
+ )
3750
+ ] })
3751
+ ] })
3752
+ }
3753
+ ),
3754
+ /* @__PURE__ */ jsx5(
3755
+ KycVerifyModal,
3756
+ {
3757
+ open: isKycVerifyModalOpen,
3758
+ onOpenChange: (next) => {
3759
+ if (!next) closeVerifyModal();
3760
+ },
3761
+ onStartVerification: startVerification,
3762
+ isInitiating: isKycInitiating,
3763
+ labels: {
3764
+ title: tradingLabels.kycVerifyModalTitle,
3765
+ description: tradingLabels.kycVerifyModalDescription,
3766
+ startVerification: tradingLabels.kycStartVerification,
3767
+ doItLater: tradingLabels.kycDoItLater
3768
+ }
3769
+ }
3770
+ ),
3771
+ /* @__PURE__ */ jsx5(
3772
+ KycSuccessModal,
3773
+ {
3774
+ open: showKycSuccessModal,
3775
+ onOpenChange: (next) => {
3776
+ if (!next) closeSuccessModal();
3777
+ },
3778
+ labels: {
3779
+ title: tradingLabels.kycSuccessTitle,
3780
+ description: tradingLabels.kycSuccessDescription,
3781
+ done: tradingLabels.kycSuccessDone
3782
+ }
3783
+ }
3784
+ )
3785
+ ] });
3786
+ };
3787
+ PlaceOrder.displayName = "PlaceOrder";
3788
+
3789
+ export {
3790
+ parseVenue,
3791
+ parseAmount,
3792
+ defaultSettlementSectionLabel,
3793
+ defaultSettlementDifferencesTitle,
3794
+ defaultTradingDisclaimer,
3795
+ getTradingDateLabel,
3796
+ getTradingVenueLabel,
3797
+ getTradingValueLabel,
3798
+ getTradingPriceLabel,
3799
+ getTradingAveragePriceLabel,
3800
+ getTradingBalanceLabel,
3801
+ getTradingSharesLabel,
3802
+ getTradingSlippageLabel,
3803
+ Settlement,
3804
+ mapVenueMarketsToSettlementSections,
3805
+ SettlementDetails,
3806
+ DEPOSIT_MODAL_OPEN_EVENT,
3807
+ WITHDRAW_MODAL_OPEN_EVENT,
3808
+ requestAggDepositModalOpen,
3809
+ requestAggWithdrawModalOpen,
3810
+ PlaceOrderFailureView,
3811
+ PlaceOrderSuccessView,
3812
+ PlaceOrder
3813
+ };