@gloom-sh/terminal 0.20.17 → 0.20.19

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 (453) hide show
  1. package/package.json +3 -1
  2. package/src/account/auth-dialog.tsx +19 -1
  3. package/src/account/billing.ts +2 -1
  4. package/src/account/heard-from-question.tsx +235 -0
  5. package/src/account/heard-from.ts +97 -0
  6. package/src/api-client/cot.ts +5 -6
  7. package/src/api-client/data.ts +14 -3
  8. package/src/api-client/heard-from.ts +72 -0
  9. package/src/api-client/index.ts +64 -6
  10. package/src/api-client/mna.ts +18 -0
  11. package/src/api-client/request.ts +162 -40
  12. package/src/api-client/supply-chain.ts +9 -0
  13. package/src/api-client/types/billing.ts +35 -1
  14. package/src/api-client/types/news.ts +45 -0
  15. package/src/api-client/types/world-venues.ts +9 -0
  16. package/src/app/global-shortcuts.ts +5 -3
  17. package/src/app/pro-welcome/keys.ts +27 -0
  18. package/src/app/pro-welcome/model.ts +158 -0
  19. package/src/app/pro-welcome/row.tsx +176 -0
  20. package/src/app/pro-welcome/use-pro-welcome.ts +156 -0
  21. package/src/app/runtime/external-profile-changes.ts +135 -0
  22. package/src/app.tsx +37 -4
  23. package/src/architecture/core-builtin-allowlist.json +1 -1
  24. package/src/architecture/floating-promise-allowlist.json +1 -2
  25. package/src/architecture/shortcut-labels-allowlist.json +1 -0
  26. package/src/cli/alert-listing.ts +98 -0
  27. package/src/cli/commands/market.ts +191 -39
  28. package/src/cli/commands/overview.ts +7 -1
  29. package/src/cli/commands/plugins.ts +3 -2
  30. package/src/cli/commands/search.ts +30 -6
  31. package/src/cli/commands/ticker.ts +13 -6
  32. package/src/cli/context.ts +24 -5
  33. package/src/cli/csv-export.ts +2 -1
  34. package/src/cli/desktop-pane-shot-browser.ts +3 -1
  35. package/src/cli/desktop-pane-shot-view.ts +0 -1
  36. package/src/cli/desktop-pane-shot.ts +276 -52
  37. package/src/cli/errors.ts +3 -9
  38. package/src/cli/exit-codes.ts +1 -1
  39. package/src/cli/glossary.ts +65 -11
  40. package/src/cli/help.ts +1 -1
  41. package/src/cli/history-demergers.ts +117 -0
  42. package/src/cli/history-rows.ts +8 -4
  43. package/src/cli/index.ts +2 -1
  44. package/src/cli/known-gaps.ts +16 -0
  45. package/src/cli/known-us-stocks.ts +18 -0
  46. package/src/cli/listing-arg.ts +192 -38
  47. package/src/cli/pane-functions/catalog-snapshot-build.ts +83 -0
  48. package/src/cli/pane-functions/catalog-snapshot.json +877 -0
  49. package/src/cli/pane-functions/catalog-snapshot.ts +62 -0
  50. package/src/cli/pane-functions/catalog.ts +50 -16
  51. package/src/cli/pane-functions/data.ts +16 -4
  52. package/src/cli/pane-functions/dom.ts +54 -8
  53. package/src/cli/pane-functions/freshness.ts +39 -4
  54. package/src/cli/pane-functions/function-help.ts +3 -3
  55. package/src/cli/pane-functions/headless.ts +9 -1
  56. package/src/cli/pane-functions/index.ts +175 -50
  57. package/src/cli/pane-functions/report-notices.ts +10 -0
  58. package/src/cli/pane-functions/resolver.ts +11 -7
  59. package/src/cli/pane-functions/screenshot-assessment.ts +38 -10
  60. package/src/cli/pane-functions/screenshot-data-evidence.ts +7 -15
  61. package/src/cli/pane-functions/screenshot-payload.ts +36 -1
  62. package/src/cli/pane-functions/screenshot-render.ts +24 -9
  63. package/src/cli/pane-functions/screenshot-types.ts +9 -0
  64. package/src/cli/quote-answer.ts +33 -17
  65. package/src/cli/registry.ts +22 -2
  66. package/src/cli/result.ts +22 -4
  67. package/src/cli/scroll-truncation.ts +7 -2
  68. package/src/cli/series-search.ts +45 -6
  69. package/src/cli/shot-temp-dir.ts +4 -9
  70. package/src/cli/ticker-resolution.ts +1 -1
  71. package/src/cli/unreachable.ts +21 -0
  72. package/src/components/chart/composite/drawing-store.ts +11 -7
  73. package/src/components/chart/composite/format.ts +1 -0
  74. package/src/components/chart/composite/legend.tsx +48 -20
  75. package/src/components/chart/composite/panel-surface/panel-cursor.tsx +3 -3
  76. package/src/components/chart/composite/panel-surface/plot-gestures.ts +9 -2
  77. package/src/components/chart/composite/panel-surface.tsx +1 -1
  78. package/src/components/chart/composite/price-axis-labels.tsx +7 -5
  79. package/src/components/chart/composite/tools.ts +164 -39
  80. package/src/components/chart-table/header.tsx +11 -2
  81. package/src/components/chart-table/layout.ts +16 -17
  82. package/src/components/command-bar/pane-templates/items.ts +17 -1
  83. package/src/components/command-bar/routes/root/provider-search.ts +10 -1
  84. package/src/components/command-bar/routes/root/results.ts +34 -2
  85. package/src/components/command-bar/routes/root/runtime.ts +19 -4
  86. package/src/components/command-bar/routes/ticker-search/results.ts +5 -0
  87. package/src/components/command-bar/routes/ticker-search/route.ts +5 -0
  88. package/src/components/command-bar/selection-runtime.ts +29 -5
  89. package/src/components/command-bar/surface/index.tsx +4 -1
  90. package/src/components/command-bar/workflow/alert.ts +32 -13
  91. package/src/components/data-table/view.tsx +15 -2
  92. package/src/components/form-modal/content.tsx +9 -4
  93. package/src/components/index.ts +1 -1
  94. package/src/components/layout/header.tsx +9 -5
  95. package/src/components/layout/pane/capture-status.ts +6 -0
  96. package/src/components/layout/pane/footer/index.tsx +2 -0
  97. package/src/components/layout/pane/footer/model.ts +123 -17
  98. package/src/components/layout/pane/header.tsx +16 -2
  99. package/src/components/layout/pane/status-footer.ts +24 -0
  100. package/src/components/market-board/index.tsx +4 -2
  101. package/src/components/onboarding/onboarding-frame.tsx +6 -2
  102. package/src/components/onboarding/onboarding-keyboard.ts +7 -1
  103. package/src/components/onboarding/onboarding-wizard.tsx +3 -1
  104. package/src/components/onboarding/portfolio-step/positions-panel.tsx +24 -15
  105. package/src/components/onboarding/setup-cards.ts +36 -0
  106. package/src/components/onboarding/use-onboarding-progress.ts +22 -1
  107. package/src/components/onboarding/wizard-account.ts +6 -1
  108. package/src/components/onboarding/wizard-model.ts +32 -6
  109. package/src/components/onboarding/wizard-positions.ts +1 -1
  110. package/src/components/price-performance.tsx +26 -8
  111. package/src/components/reader/article-reader.tsx +12 -5
  112. package/src/components/sign-in-gate.tsx +3 -1
  113. package/src/components/toggle-list.tsx +6 -8
  114. package/src/components/ui/confirm-dialog.tsx +47 -7
  115. package/src/components/ui/data-table/opentui/index.tsx +7 -0
  116. package/src/components/ui/data-table/types.ts +8 -0
  117. package/src/components/ui/display.tsx +17 -2
  118. package/src/components/ui/index.ts +1 -1
  119. package/src/components/ui/stat-grid.tsx +4 -0
  120. package/src/components/ui/status.tsx +13 -1
  121. package/src/components/ui/table-layout.ts +34 -2
  122. package/src/components/use-pane-notice-footer.tsx +16 -3
  123. package/src/data/config/store/index.ts +31 -0
  124. package/src/data/config/store/node.ts +61 -11
  125. package/src/data/config/store/normalize.ts +4 -6
  126. package/src/data/config/store/shared-file.ts +309 -0
  127. package/src/data/profile-merge.ts +299 -0
  128. package/src/data/sqlite/checkpointer.ts +11 -1
  129. package/src/data/sqlite/database.ts +1 -1
  130. package/src/data/ticker-repository.ts +134 -10
  131. package/src/data/ticker-store.ts +67 -0
  132. package/src/data/ticker-writes.ts +5 -0
  133. package/src/i18n/es.ts +27 -0
  134. package/src/i18n/ja.ts +27 -0
  135. package/src/i18n/ko.ts +27 -0
  136. package/src/i18n/zh-cn.ts +27 -0
  137. package/src/i18n/zh-tw.ts +27 -0
  138. package/src/layout-marketplace/gallery-desktop.tsx +2 -2
  139. package/src/market-data/ah-pair.ts +122 -0
  140. package/src/market-data/coordinator/entries.ts +6 -4
  141. package/src/market-data/coordinator/index.ts +14 -3
  142. package/src/market-data/depositary-pair.ts +6 -2
  143. package/src/market-data/futures-board.ts +36 -29
  144. package/src/market-data/futures-contract.ts +37 -1
  145. package/src/market-data/hooks.tsx +33 -2
  146. package/src/market-data/market/change-basis.ts +11 -1
  147. package/src/market-data/market/header-market.ts +11 -0
  148. package/src/market-data/market/status.ts +40 -4
  149. package/src/market-data/performance.ts +127 -32
  150. package/src/market-data/quotes/time.ts +5 -2
  151. package/src/market-data/split-terms.ts +28 -0
  152. package/src/news/types.ts +28 -0
  153. package/src/notifications/app-badge.ts +2 -3
  154. package/src/notifications/app-notifier.ts +5 -0
  155. package/src/plugins/builtin/account-management/footer.ts +1 -1
  156. package/src/plugins/builtin/account-management/keyboard.ts +4 -0
  157. package/src/plugins/builtin/account-management/model.ts +1 -0
  158. package/src/plugins/builtin/account-management/pane.tsx +75 -7
  159. package/src/plugins/builtin/account-management/payment-recovery-row.tsx +12 -5
  160. package/src/plugins/builtin/account-management/pro-cancel.tsx +197 -0
  161. package/src/plugins/builtin/account-management/trial-cancel.ts +1 -1
  162. package/src/plugins/builtin/alerts/cli-move.ts +2 -2
  163. package/src/plugins/builtin/alerts/cli.ts +101 -48
  164. package/src/plugins/builtin/alerts/command.ts +39 -9
  165. package/src/plugins/builtin/alerts/constants.ts +10 -0
  166. package/src/plugins/builtin/alerts/earnings-listing.ts +20 -0
  167. package/src/plugins/builtin/alerts/event-rows.ts +9 -3
  168. package/src/plugins/builtin/alerts/events-pane.tsx +16 -10
  169. package/src/plugins/builtin/alerts/format.ts +24 -8
  170. package/src/plugins/builtin/alerts/headless.ts +12 -6
  171. package/src/plugins/builtin/alerts/index.tsx +97 -16
  172. package/src/plugins/builtin/alerts/move-checks.ts +7 -0
  173. package/src/plugins/builtin/alerts/option-contract.ts +197 -0
  174. package/src/plugins/builtin/alerts/pane.tsx +1 -1
  175. package/src/plugins/builtin/alerts/price.ts +30 -5
  176. package/src/plugins/builtin/alerts/pro-rules.ts +62 -0
  177. package/src/plugins/builtin/alerts/quotes.ts +26 -2
  178. package/src/plugins/builtin/alerts/research-builder.ts +5 -10
  179. package/src/plugins/builtin/alerts/scheduled.ts +6 -1
  180. package/src/plugins/builtin/alerts/types.ts +7 -0
  181. package/src/plugins/builtin/analytics/account-returns.ts +1 -1
  182. package/src/plugins/builtin/analytics/manual-value.ts +61 -0
  183. package/src/plugins/builtin/analytics/pane-model.ts +2 -2
  184. package/src/plugins/builtin/analytics/risk-book.ts +7 -7
  185. package/src/plugins/builtin/analytics/risk-client.ts +27 -14
  186. package/src/plugins/builtin/analytics/risk-headless.ts +13 -8
  187. package/src/plugins/builtin/analytics/risk-model.ts +92 -4
  188. package/src/plugins/builtin/analytics/risk-pane.tsx +85 -38
  189. package/src/plugins/builtin/awards/pane.tsx +1 -1
  190. package/src/plugins/builtin/broker-trading/orders.tsx +2 -2
  191. package/src/plugins/builtin/buildout/company/pane.tsx +4 -14
  192. package/src/plugins/builtin/catalysts/model.ts +2 -1
  193. package/src/plugins/builtin/central-bank-rates/model.ts +8 -2
  194. package/src/plugins/builtin/central-bank-rates/pane.tsx +5 -3
  195. package/src/plugins/builtin/chart-composer/chart-spec.ts +5 -0
  196. package/src/plugins/builtin/chart-composer/cli-options.ts +9 -5
  197. package/src/plugins/builtin/chart-composer/data-catalog-pane.tsx +2 -6
  198. package/src/plugins/builtin/chart-composer/headless-schema.ts +14 -10
  199. package/src/plugins/builtin/chart-composer/headless.ts +2 -0
  200. package/src/plugins/builtin/chart-composer/index.tsx +17 -5
  201. package/src/plugins/builtin/chart-composer/pane.tsx +19 -6
  202. package/src/plugins/builtin/chart-composer/viewport-labels.ts +2 -17
  203. package/src/plugins/builtin/chat/controller/notifications.ts +1 -0
  204. package/src/plugins/builtin/chat/index.tsx +0 -1
  205. package/src/plugins/builtin/cloud/auth-actions.tsx +11 -6
  206. package/src/plugins/builtin/cloud/company-picker.tsx +5 -3
  207. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  208. package/src/plugins/builtin/commodities-energy/index.tsx +1 -1
  209. package/src/plugins/builtin/company-kpis/headless.ts +10 -5
  210. package/src/plugins/builtin/company-kpis/latest.ts +45 -0
  211. package/src/plugins/builtin/company-kpis/model.ts +57 -15
  212. package/src/plugins/builtin/company-kpis/pane.tsx +22 -8
  213. package/src/plugins/builtin/composite/alt-data.ts +20 -0
  214. package/src/plugins/builtin/composite/application.ts +14 -0
  215. package/src/plugins/builtin/composite/broker.ts +12 -0
  216. package/src/plugins/builtin/composite/credit.ts +33 -0
  217. package/src/plugins/builtin/composite/crypto.ts +10 -0
  218. package/src/plugins/builtin/composite/earnings.ts +12 -0
  219. package/src/plugins/builtin/composite/filings.ts +13 -0
  220. package/src/plugins/builtin/composite/futures-commodities.ts +23 -0
  221. package/src/plugins/builtin/composite/global-markets.ts +12 -0
  222. package/src/plugins/builtin/composite/options-volatility.ts +23 -0
  223. package/src/plugins/builtin/composite/ownership.ts +23 -0
  224. package/src/plugins/builtin/composite/portfolio.ts +10 -0
  225. package/src/plugins/builtin/composite/quant.ts +15 -0
  226. package/src/plugins/builtin/composite/rates-macro.ts +30 -0
  227. package/src/plugins/builtin/composite/screeners.ts +11 -0
  228. package/src/plugins/builtin/composite/shared.ts +11 -0
  229. package/src/plugins/builtin/composite/ticker-core.ts +36 -0
  230. package/src/plugins/builtin/congress-trades/headless.ts +31 -3
  231. package/src/plugins/builtin/congress-trades/model.ts +9 -5
  232. package/src/plugins/builtin/correlation/index.tsx +13 -17
  233. package/src/plugins/builtin/correlation/matrix/model.ts +18 -0
  234. package/src/plugins/builtin/cot/client.ts +2 -3
  235. package/src/plugins/builtin/cot/headless.ts +16 -16
  236. package/src/plugins/builtin/cot/index.tsx +6 -6
  237. package/src/plugins/builtin/cot/model.ts +25 -5
  238. package/src/plugins/builtin/cot/pane.tsx +11 -6
  239. package/src/plugins/builtin/cot/series.ts +11 -8
  240. package/src/plugins/builtin/cpi/model.ts +15 -4
  241. package/src/plugins/builtin/cpi/pane.tsx +29 -7
  242. package/src/plugins/builtin/dividend-yield/client.ts +57 -16
  243. package/src/plugins/builtin/dividend-yield/headless.ts +17 -11
  244. package/src/plugins/builtin/dividend-yield/model.ts +4 -3
  245. package/src/plugins/builtin/dividend-yield/pane.tsx +22 -18
  246. package/src/plugins/builtin/dividend-yield/ranking.ts +1 -1
  247. package/src/plugins/builtin/dividend-yield/types.ts +4 -0
  248. package/src/plugins/builtin/dividend-yield/view.ts +23 -12
  249. package/src/plugins/builtin/doe/model.ts +30 -0
  250. package/src/plugins/builtin/doe/pane.tsx +8 -2
  251. package/src/plugins/builtin/earnings/board-table.ts +9 -4
  252. package/src/plugins/builtin/earnings/fiscal-quarter.ts +39 -0
  253. package/src/plugins/builtin/earnings/headless.ts +16 -6
  254. package/src/plugins/builtin/earnings/history-model.ts +6 -4
  255. package/src/plugins/builtin/earnings/history-table.ts +7 -4
  256. package/src/plugins/builtin/earnings-calls/calendar.tsx +4 -3
  257. package/src/plugins/builtin/earnings-calls/pane.tsx +8 -2
  258. package/src/plugins/builtin/earnings-ripple/pane.tsx +2 -2
  259. package/src/plugins/builtin/econ/calendar-model.ts +16 -0
  260. package/src/plugins/builtin/econ/index.tsx +7 -2
  261. package/src/plugins/builtin/equity-screener/headless.ts +4 -1
  262. package/src/plugins/builtin/equity-screener/model.ts +7 -6
  263. package/src/plugins/builtin/estimate-revisions/headless.ts +1 -1
  264. package/src/plugins/builtin/exposure/model.ts +10 -0
  265. package/src/plugins/builtin/exposure/pane.tsx +10 -3
  266. package/src/plugins/builtin/futures/model.ts +14 -1
  267. package/src/plugins/builtin/futures/series.ts +1 -8
  268. package/src/plugins/builtin/fx-matrix/amount.ts +15 -1
  269. package/src/plugins/builtin/fx-matrix/headless.ts +12 -6
  270. package/src/plugins/builtin/fx-matrix/index.tsx +25 -7
  271. package/src/plugins/builtin/fx-matrix/settings.ts +9 -4
  272. package/src/plugins/builtin/insider/detail.tsx +36 -7
  273. package/src/plugins/builtin/insider/filing-stories.ts +110 -0
  274. package/src/plugins/builtin/insider/headless.ts +37 -2
  275. package/src/plugins/builtin/insider/index.tsx +79 -10
  276. package/src/plugins/builtin/insider/model.ts +43 -5
  277. package/src/plugins/builtin/ipo-calendar/client.ts +11 -1
  278. package/src/plugins/builtin/ipo-calendar/model.ts +3 -7
  279. package/src/plugins/builtin/jobs/headless.ts +2 -1
  280. package/src/plugins/builtin/jobs/model.ts +6 -0
  281. package/src/plugins/builtin/jobs/pane.tsx +8 -3
  282. package/src/plugins/builtin/kelly-sizer/pane.tsx +9 -4
  283. package/src/plugins/builtin/market-valuation/pane.tsx +22 -10
  284. package/src/plugins/builtin/mna/detail.tsx +67 -6
  285. package/src/plugins/builtin/mna/headless.ts +128 -13
  286. package/src/plugins/builtin/mna/model.ts +219 -16
  287. package/src/plugins/builtin/mna/pane.tsx +34 -6
  288. package/src/plugins/builtin/money-markets/model.ts +14 -5
  289. package/src/plugins/builtin/money-markets/pane.tsx +4 -3
  290. package/src/plugins/builtin/news/wire/news/detail-view.tsx +118 -10
  291. package/src/plugins/builtin/news/wire/news/footer.ts +3 -8
  292. package/src/plugins/builtin/news/wire/news/story-evidence.ts +178 -0
  293. package/src/plugins/builtin/options/analytics.ts +1 -1
  294. package/src/plugins/builtin/options/view.tsx +18 -11
  295. package/src/plugins/builtin/options-positioning/model.ts +11 -0
  296. package/src/plugins/builtin/options-positioning/pane.tsx +22 -1
  297. package/src/plugins/builtin/options-scenario/client.ts +49 -8
  298. package/src/plugins/builtin/options-scenario/csp-screen-pane.tsx +22 -6
  299. package/src/plugins/builtin/options-scenario/csp-screen.ts +39 -12
  300. package/src/plugins/builtin/options-scenario/headless.ts +7 -3
  301. package/src/plugins/builtin/options-scenario/model.ts +33 -2
  302. package/src/plugins/builtin/options-scenario/pane.tsx +3 -4
  303. package/src/plugins/builtin/options-scenario/strategy-screen.ts +7 -5
  304. package/src/plugins/builtin/pe-band/client.ts +13 -1
  305. package/src/plugins/builtin/pe-band/headless.ts +2 -2
  306. package/src/plugins/builtin/pe-band/model.ts +63 -10
  307. package/src/plugins/builtin/pe-band/pane.tsx +5 -5
  308. package/src/plugins/builtin/perps/cascade.ts +4 -3
  309. package/src/plugins/builtin/perps/markets-section.tsx +5 -2
  310. package/src/plugins/builtin/perps/model.ts +4 -3
  311. package/src/plugins/builtin/portfolio-list/allocation-rows.ts +26 -7
  312. package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +66 -13
  313. package/src/plugins/builtin/portfolio-list/cli/render.ts +76 -33
  314. package/src/plugins/builtin/portfolio-list/headless.ts +69 -22
  315. package/src/plugins/builtin/portfolio-list/pane/data.ts +3 -3
  316. package/src/plugins/builtin/portfolio-list/pane/index.tsx +29 -14
  317. package/src/plugins/builtin/portfolio-list/summary/index.tsx +2 -2
  318. package/src/plugins/builtin/portfolio-list/table.tsx +3 -2
  319. package/src/plugins/builtin/relative-rotation/pane.tsx +2 -3
  320. package/src/plugins/builtin/research/corporate-actions-pane.tsx +33 -14
  321. package/src/plugins/builtin/research/event-model.ts +43 -19
  322. package/src/plugins/builtin/research/headless.ts +8 -1
  323. package/src/plugins/builtin/research/relative-valuation-pane.tsx +19 -17
  324. package/src/plugins/builtin/research-search/index.tsx +3 -1
  325. package/src/plugins/builtin/scanner/denied.tsx +16 -4
  326. package/src/plugins/builtin/scanner/flow-pane.tsx +1 -1
  327. package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
  328. package/src/plugins/builtin/sec/filing-display.tsx +14 -2
  329. package/src/plugins/builtin/sec/headless.ts +42 -4
  330. package/src/plugins/builtin/sec/index.tsx +21 -1
  331. package/src/plugins/builtin/sectors/index.tsx +6 -9
  332. package/src/plugins/builtin/sectors/sector-model.ts +1 -1
  333. package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -1
  334. package/src/plugins/builtin/shared/earnings-report.ts +49 -5
  335. package/src/plugins/builtin/shared/options-pro-copy.ts +34 -0
  336. package/src/plugins/builtin/shared/report-freshness.ts +2 -3
  337. package/src/plugins/builtin/shared/statement-currency.ts +23 -0
  338. package/src/plugins/builtin/shared/ticker-surface.ts +1 -1
  339. package/src/plugins/builtin/supply-chain/client.ts +34 -9
  340. package/src/plugins/builtin/supply-chain/evidence.ts +3 -2
  341. package/src/plugins/builtin/supply-chain/flow.tsx +4 -3
  342. package/src/plugins/builtin/supply-chain/graph-model.ts +14 -7
  343. package/src/plugins/builtin/supply-chain/graph-pane.tsx +3 -1
  344. package/src/plugins/builtin/supply-chain/graph.tsx +6 -3
  345. package/src/plugins/builtin/supply-chain/headless.ts +19 -4
  346. package/src/plugins/builtin/supply-chain/model.ts +50 -6
  347. package/src/plugins/builtin/supply-chain/pane.tsx +79 -18
  348. package/src/plugins/builtin/themes/headless.ts +4 -4
  349. package/src/plugins/builtin/themes/model.ts +11 -8
  350. package/src/plugins/builtin/themes/pane.tsx +2 -2
  351. package/src/plugins/builtin/ticker-detail/adr-pair/ah.ts +62 -0
  352. package/src/plugins/builtin/ticker-detail/adr-pair/headless.ts +119 -20
  353. package/src/plugins/builtin/ticker-detail/adr-pair/model.ts +51 -1
  354. package/src/plugins/builtin/ticker-detail/adr-pair/tab.tsx +25 -14
  355. package/src/plugins/builtin/ticker-detail/financials/model.ts +22 -32
  356. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +7 -9
  357. package/src/plugins/builtin/ticker-detail/headless-schema.ts +2 -0
  358. package/src/plugins/builtin/ticker-detail/headless.ts +28 -12
  359. package/src/plugins/builtin/ticker-detail/overview/board-lot.ts +21 -0
  360. package/src/plugins/builtin/ticker-detail/overview/model.ts +28 -2
  361. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +8 -0
  362. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +68 -13
  363. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +9 -2
  364. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +5 -2
  365. package/src/plugins/builtin/volatility/model.ts +17 -0
  366. package/src/plugins/builtin/volatility/pane.tsx +16 -7
  367. package/src/plugins/builtin/world-indices/index.tsx +2 -0
  368. package/src/plugins/builtin/world-indices/table.tsx +15 -0
  369. package/src/plugins/builtin/world-venue-map/evidence.ts +3 -2
  370. package/src/plugins/builtin/world-venue-map/headless.ts +32 -18
  371. package/src/plugins/builtin/world-venue-map/index.ts +19 -6
  372. package/src/plugins/builtin/world-venue-map/layered-pane.tsx +9 -5
  373. package/src/plugins/builtin/world-venue-map/layers.ts +33 -11
  374. package/src/plugins/builtin/world-venue-map/map.tsx +12 -0
  375. package/src/plugins/builtin/world-venue-map/model.ts +6 -1
  376. package/src/plugins/builtin/world-venue-map/pane.tsx +35 -6
  377. package/src/plugins/builtin/world-venue-map/place.ts +119 -0
  378. package/src/plugins/builtin/world-venue-map/venue-header.tsx +5 -3
  379. package/src/plugins/catalog-browser.ts +10 -1
  380. package/src/plugins/catalog-data.ts +20 -0
  381. package/src/plugins/catalog-lazy.ts +51 -0
  382. package/src/plugins/catalog-ui.ts +16 -18
  383. package/src/plugins/host-smoke.ts +5 -2
  384. package/src/portfolio/allocation.ts +79 -19
  385. package/src/portfolio/cash-balances.ts +76 -0
  386. package/src/portfolio/mutations.ts +43 -8
  387. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  388. package/src/renderers/browser/activity.ts +16 -0
  389. package/src/renderers/browser/app-badge-host.ts +14 -0
  390. package/src/renderers/browser/main.tsx +5 -0
  391. package/src/renderers/browser/notifications.ts +103 -0
  392. package/src/renderers/browser/ui-host.tsx +4 -0
  393. package/src/renderers/desktop/window-layouts.ts +14 -0
  394. package/src/renderers/dom/data-table/index.tsx +27 -4
  395. package/src/renderers/dom/data-table/row.tsx +2 -0
  396. package/src/renderers/dom/host/tabs.tsx +57 -8
  397. package/src/renderers/dom/styles.css +13 -5
  398. package/src/renderers/electrobun/bun/desktop/backend-requests.ts +4 -0
  399. package/src/renderers/electrobun/bun/desktop/backend.ts +22 -1
  400. package/src/renderers/electrobun/bun/window/native-min-size.ts +6 -1
  401. package/src/renderers/electrobun/shared/protocol.ts +4 -0
  402. package/src/renderers/electrobun/view/cli-pane-shot-frame.tsx +50 -12
  403. package/src/renderers/electrobun/view/http-fetch.ts +3 -2
  404. package/src/renderers/electrobun/view/remote/ticker-repository.ts +10 -0
  405. package/src/series/standalone-catalog.ts +5 -4
  406. package/src/series/standalone.ts +13 -7
  407. package/src/sources/gloomberb-cloud/index.ts +22 -9
  408. package/src/sources/gloomberb-cloud/news.ts +35 -0
  409. package/src/sources/gloomberb-cloud/perpetuals.ts +60 -3
  410. package/src/sources/provider-errors.ts +34 -7
  411. package/src/sources/provider-router/financials.ts +20 -13
  412. package/src/sources/provider-router/history.ts +32 -6
  413. package/src/sources/provider-router/index.ts +4 -0
  414. package/src/sources/provider-router/search.ts +1 -0
  415. package/src/sync/collections-contributor.ts +3 -1
  416. package/src/sync/config-merge.ts +10 -1
  417. package/src/sync/sanitize.ts +26 -2
  418. package/src/tickers/company-name-listing.ts +16 -2
  419. package/src/tickers/listing-fate.ts +12 -8
  420. package/src/tickers/renamed-listings.ts +43 -10
  421. package/src/tickers/search/home-listing.ts +28 -0
  422. package/src/tickers/search/index.ts +19 -7
  423. package/src/tickers/terminal-codes.ts +11 -1
  424. package/src/time-series/base-series.ts +39 -6
  425. package/src/time-series/chart-seed.ts +2 -2
  426. package/src/time-series/history-quality.ts +4 -1
  427. package/src/time-series/hooks.ts +2 -0
  428. package/src/time-series/price-comparison.ts +17 -23
  429. package/src/time-series/reporting.ts +1 -1
  430. package/src/time-series/resolution.ts +13 -0
  431. package/src/time-series/resolve-context.ts +6 -0
  432. package/src/time-series/resolve.ts +42 -3
  433. package/src/time-series/spec.ts +2 -2
  434. package/src/time-series/types.ts +3 -2
  435. package/src/types/data-provider.ts +11 -0
  436. package/src/types/financials.ts +48 -4
  437. package/src/types/headless.ts +1 -0
  438. package/src/types/issuer-listings.ts +2 -0
  439. package/src/types/plugin-notifications.ts +3 -0
  440. package/src/types/price-history.ts +6 -4
  441. package/src/types/ticker.ts +10 -2
  442. package/src/ui/host.tsx +2 -0
  443. package/src/utils/cli-output.ts +1 -1
  444. package/src/utils/declared-dividends.ts +13 -1
  445. package/src/utils/dividend-cash.ts +5 -1
  446. package/src/utils/exchange-announcements.ts +7 -2
  447. package/src/utils/forward-dividend.ts +4 -3
  448. package/src/utils/fundamentals.ts +40 -0
  449. package/src/utils/network-failure.ts +2 -0
  450. package/src/utils/price-history-integrity.ts +9 -1
  451. package/src/utils/remove-folder.ts +37 -0
  452. package/src/utils/trailing-dividend.ts +1 -1
  453. package/src/plugins/builtin/composite-plugins.ts +0 -285
@@ -20,16 +20,23 @@ export const ROLE_COLORS: Readonly<Record<SupplyRole, string>> = currentThemeCol
20
20
 
21
21
  /** A company, a customer the filer does not name, or a geographic or channel cohort that is not one company. */
22
22
  export type CounterpartyKind = "company" | "undisclosed" | "group";
23
- export const counterpartyKind = (row: SupplyRow): CounterpartyKind =>
23
+ export const counterpartyKind = (row: Pick<SupplyRow, "counterparty">): CounterpartyKind =>
24
24
  row.counterparty.aggregate ? "group" : row.counterparty.anonymous ? "undisclosed" : "company";
25
25
 
26
26
  const GENERIC_WORDS = /\b(And|Of|The|Based|End|Customers?|Suppliers?|Vendors?|Channel|Partners?|Undisclosed|Other|Carriers?|Networks?|Cellular|Distributors?|Retailers?)\b/g;
27
27
 
28
+ /**
29
+ * The measure a filer spells into an undisclosed customer's member ("Revenue Customer 1", "A/R Customer A"), which
30
+ * the share beside it already names: the label keeps what tells the customers apart.
31
+ */
32
+ const MEASURE_PREFIX = /^(?:revenues?|net sales|sales|a\/r|ar|accounts receivables?|receivables?|trade receivables?)\s+(?=(?:customer|client|supplier|vendor)\b)/i;
33
+
28
34
  /** The counterparty's name without the kind spelled into it; the kind travels as its own label. */
29
- export function counterpartyLabel(row: SupplyRow): string {
35
+ export function counterpartyLabel(row: Pick<SupplyRow, "counterparty" | "pctBasis">): string {
30
36
  const kind = counterpartyKind(row);
31
37
  if (kind === "company") return row.counterparty.name;
32
- const name = counterpartyName(row).replace(/^Group: /, "").replace(/\s*\(undisclosed\)$/i, "");
38
+ const name = counterpartyName(row).replace(/^Group: /, "").replace(/\s*\(undisclosed\)$/i, "")
39
+ .replace(row.pctBasis ? MEASURE_PREFIX : /^$/, "");
33
40
  // Cohort labels arrive in title case from XBRL member names; generic words read lower case, names keep theirs.
34
41
  return name.replace(GENERIC_WORDS, (word) => word.toLowerCase()).replace(/^./, (first) => first.toUpperCase());
35
42
  }
@@ -54,8 +61,26 @@ export const counterpartyKindLabel = (row: SupplyRow, short = false) => {
54
61
  if (isRelatedParty(row)) return namedGroup(row) ? short ? "related group" : "related-party group" : "related party";
55
62
  return namedGroup(row) ? short ? "group" : "corporate group" : null;
56
63
  };
64
+ /**
65
+ * A row's role as the company it is read for sees it. An investee row runs
66
+ * from the holder to the company held, so read inbound its counterparty is
67
+ * the holder: Sinopec, whose interim report holds CATL shares, is CATL's
68
+ * investor, not its investee.
69
+ */
70
+ export const rowRoleLabel = (row: Pick<SupplyRow, "role"> & { direction?: SupplyRow["direction"] }) =>
71
+ row.role === "investee" && row.direction === "in" ? "Investor" : roleLabel(row.role);
57
72
  /** The relationship in words: "Related-party supplier" for a related-party trade, else the role. */
58
- export const relationshipLabel = (row: Pick<SupplyRow, "role" | "relatedParty">) => isRelatedParty(row) ? `Related-party ${row.role}` : roleLabel(row.role);
73
+ export const relationshipLabel = (row: Pick<SupplyRow, "role" | "relatedParty"> & { direction?: SupplyRow["direction"] }) =>
74
+ isRelatedParty(row) ? `Related-party ${rowRoleLabel(row).toLowerCase()}` : rowRoleLabel(row);
75
+
76
+ /**
77
+ * The end of a counterparty's label that tells it apart, which a narrow column keeps whole while it cuts what comes
78
+ * before: the letter or number of an undisclosed customer ("Customer 1", "Customer A"). Null for a company's name.
79
+ */
80
+ export function counterpartyLabelEnd(row: Pick<SupplyRow, "counterparty" | "pctBasis">): string | null {
81
+ if (counterpartyKind(row) !== "undisclosed") return null;
82
+ return / (?:\d{1,3}|[A-Z]|One|Two|Three|Four|Five|Six)$/i.exec(counterpartyLabel(row))?.[0] ?? null;
83
+ }
59
84
 
60
85
  /** A filer's segment or product scope in plain words: "Compute And Networking Segment" reads "Compute & Networking". */
61
86
  export function scopeWords(scope: string): string {
@@ -107,6 +132,15 @@ export function shareParts(row: SupplyRow, focusId?: string | null, { includeRep
107
132
  if (row.sourceKind === "xbrl" && scope) {
108
133
  if (taggedDimension(row, "ProductOrService"))
109
134
  return shareWords(value, [`of ${reporter}total ${basis} (${lowerFirst(scope)} sales)${owed}`, `of ${reporter}total ${basis}`, `${reporter}${basis}`]);
135
+ // A segment tag says where the revenue comes from or whose revenue it is a share of; the filing's sentence says
136
+ // which (`pctScopeBasis`): NVDA's 16% is of total revenue, from Compute & Networking; RPM's 24% of Consumer's own.
137
+ if (row.pctScopeBasis === "total")
138
+ return shareWords(value, [`of ${reporter}total ${basis}, from ${scope}${owed}`, `of ${reporter}total ${basis}`, `${reporter}${basis}`]);
139
+ if (row.pctScopeBasis === "segment")
140
+ return shareWords(value, [`of ${reporter}${scope} ${basis}${owed}`, `of ${reporter}segment ${basis}`, `${reporter}segment ${basis}`]);
141
+ // A segment tag not yet read is said as a tag, never as the share's base.
142
+ if (taggedDimension(row, "BusinessSegments") || /segment/i.test(row.pctScope ?? ""))
143
+ return shareWords(value, [`of ${reporter}${basis}, tagged ${scope}${owed}`, `of ${reporter}${basis}`, `${reporter}${basis}`]);
110
144
  return shareWords(value, [`of ${reporter}${basis} (${scope})${owed}`, `${reporter}${basis}`]);
111
145
  }
112
146
  const scoped = `${scope ? `${scope} ` : ""}${basis}`;
@@ -151,7 +185,7 @@ export function disclosureText(row: SupplyRow): string {
151
185
  .filter((part): part is string => !!part).join(", ") || "Tagged in the filing";
152
186
  }
153
187
 
154
- export function counterpartyName(row: SupplyRow): string {
188
+ export function counterpartyName(row: Pick<SupplyRow, "counterparty">): string {
155
189
  if (row.counterparty.aggregate) return `Group: ${row.counterparty.name.replace(/^Undisclosed customer \((.+)\)$/i, "$1")}`;
156
190
  if (!row.counterparty.anonymous) return row.counterparty.name;
157
191
  const name = row.counterparty.name;
@@ -220,6 +254,16 @@ export function supplyRoleCounts(data: Pick<SupplyChainPayload, "says" | "names"
220
254
  */
221
255
  export const earlierRows = (data: Pick<SupplyChainPayload, "earlier">, view: "says" | "names"): SupplyRow[] => data.earlier?.[view] ?? [];
222
256
 
257
+ /**
258
+ * The direction a table opens on before one is chosen: what the company says,
259
+ * unless its own reports name no one and others' name it (CATL: none of its
260
+ * own, ten from customers, competitors and a holder), not an empty table.
261
+ */
262
+ export function openingSupplyView(data: Pick<SupplyChainPayload, "says" | "names" | "earlier">, options: Required<SupplyOptions>): "says" | "names" {
263
+ const shown = (rows: SupplyRow[]) => rows.some((row) => matchesSupplyOptions(row, options));
264
+ return !shown(data.says) && !shown(earlierRows(data, "says")) && shown(data.names) ? "names" : "says";
265
+ }
266
+
223
267
  /** Disclosures a free preview withholds from these views: the server's counts less the rows it sent. */
224
268
  export function lockedDisclosures(data: Pick<SupplyChainPayload, "says" | "names" | "counts" | "earlier" | "earlierCounts">, views: readonly ("says" | "names")[]): number {
225
269
  const total = (counts: Record<SupplyRole, number> | undefined) => Object.values(counts ?? {}).reduce((a, b) => a + b, 0);
@@ -347,7 +391,7 @@ export const periodText = (row: Pick<SupplyRow, "period" | "periodMonths">) => {
347
391
  export const sourceLabel = (row: SupplyRow) => row.sourceKind === "xbrl" ? "XBRL" : row.sourceKind === "filing_text" ? row.form ?? "Filing" : row.sourceKind === "call" ? "Call" : row.sourceKind === "news" ? "News" : row.sourceKind === "press_release" ? "Release" : row.sourceKind === "web" ? "Web" : "Disclosure";
348
392
  export function cellText(row: SupplyRow, column: string): string {
349
393
  return column === "name" ? counterpartyName(row) : column === "ticker" ? entityTicker(row.counterparty) ?? MISSING_VALUE
350
- : column === "role" ? roleLabel(row.role) : column === "direction" ? row.direction === "in" ? "In" : row.direction === "out" ? "Out" : "Both"
394
+ : column === "role" ? rowRoleLabel(row) : column === "direction" ? row.direction === "in" ? "In" : row.direction === "out" ? "Out" : "Both"
351
395
  : column === "pct" ? percentage(row) : column === "usd" ? disclosedValue(row) : column === "fy" ? periodText(row)
352
396
  : column === "publisher" ? row.evidence?.find((item) => item.status === "active")?.publisher ?? row.reportingEntity.name
353
397
  : column === "corroboration" ? corroborationLabel(row)
@@ -11,7 +11,7 @@ import {
11
11
  import { staticSeries } from "../../../components/chart/static/series";
12
12
  import { ClippedText } from "../../../components/ui/display";
13
13
  import { RatioBar } from "../../../components/ui/ratio-bar";
14
- import { getTableWidth } from "../../../components/ui/table-layout";
14
+ import { getTableWidth, hiddenTableColumnRows, markHiddenTableColumns } from "../../../components/ui/table-layout";
15
15
  import { chromeBarRows } from "../../../components/layout/pane/sizing";
16
16
  import { usePaneRefreshKey } from "../../../components/data-table/table-pane";
17
17
  import { useAsyncResource, useAutoRefresh, usePaneSettingValue, usePluginAppActions, usePluginPaneState } from "../../../public/react";
@@ -31,11 +31,12 @@ import { SupplyFlow } from "./flow";
31
31
  import { SupplyGraphPane } from "./graph-pane";
32
32
  import { entityTicker } from "./graph-model";
33
33
  import {
34
- cellText, counterpartyKind, counterpartyKindLabel, counterpartyLabel, counterpartyName, disclosedValue, earlierRows, fitShareBasis, focusCompanyLabel, focusCompanyName, receivablesConcentration, lockedDisclosures, nativeValue, percentage, relationshipLabel, ROLE_COLORS, roleLabel,
34
+ cellText, counterpartyKind, disclosureText, isTaggedFact, counterpartyKindLabel, counterpartyLabel, counterpartyLabelEnd, counterpartyName, disclosedValue, earlierRows, fitShareBasis, focusCompanyLabel, focusCompanyName, receivablesConcentration, lockedDisclosures, nativeValue, percentage, relationshipLabel, ROLE_COLORS, openingSupplyView, rowRoleLabel,
35
35
  periodDate, shareParts, sortRows, supplyEmptyText, supplyPreviewNote, supplyRoleCounts, type SupplySort,
36
36
  } from "./model";
37
37
  import { RowEvidence } from "./row-evidence";
38
- import { evidenceDate, evidenceLabel, isUnconfirmed, matchesSupplyOptions, supplyOptions, TIER_OPTIONS } from "./trust";
38
+ import { DisclosureQuote } from "./disclosure-quote";
39
+ import { canShowQuote, evidenceDate, evidenceLabel, isUnconfirmed, matchesSupplyOptions, supplyOptions, TIER_OPTIONS } from "./trust";
39
40
  import { logFailure } from "../../../utils/log-failure";
40
41
 
41
42
  type Item = { kind: "edge"; row: SupplyRow } | { kind: "locked"; id: string };
@@ -79,6 +80,8 @@ function shareLayout(width: number, bases: BasisForms): ShareLayout {
79
80
  return { bar: 0, basis: Math.max(0, width - SHARE_FIGURE_CELLS - 1) };
80
81
  }
81
82
 
83
+ /** The most a name column widens to keep its longest name whole. */
84
+ const NAME_KEEP_MAX_CELLS = 34;
82
85
  /** A period end date ("31 Dec 2025"); its length, when the source states it, reads with it in a wider column. */
83
86
  const PERIOD_DATE_CELLS = 11;
84
87
  /**
@@ -91,7 +94,7 @@ const PERIOD_DATE_CELLS = 11;
91
94
  * Value shows only when some row discloses a value, retaining its original
92
95
  * currency and units.
93
96
  */
94
- function tableColumns(width: number, desktop: boolean, locked: boolean, valueWidth: number | null, bases: BasisForms, periodWidth = PERIOD_DATE_CELLS): DataTableColumn[] {
97
+ export function tableColumns(width: number, desktop: boolean, locked: boolean, valueWidth: number | null, bases: BasisForms, periodWidth = PERIOD_DATE_CELLS, nameCells = 0): DataTableColumn[] {
95
98
  const wide = width >= 150, medium = width >= 110;
96
99
  const name: DataTableColumn = { id: "name", label: "Counterparty", width: Math.max(locked && !desktop ? 34 : 0, wide ? 30 : medium ? 26 : 20), flexGrow: 1, align: "left" };
97
100
  // Wide enough for the longest whole wording beside its bar and figure ("27% of total revenue (gold sales)"), within a cap;
@@ -104,7 +107,8 @@ function tableColumns(width: number, desktop: boolean, locked: boolean, valueWid
104
107
  let columns: DataTableColumn[] = [
105
108
  name,
106
109
  { id: "evidence", label: "Evidence", width: 12, align: "left" },
107
- ...(medium ? [{ id: "ticker", label: "Ticker", width: 8, align: "left" as const }] : []),
110
+ // A listing as every function writes it: 000063:SZSE whole.
111
+ ...(medium ? [{ id: "ticker", label: "Ticker", width: 11, align: "left" as const }] : []),
108
112
  { id: "role", label: "Role", width: 11, align: "left" },
109
113
  share,
110
114
  ...(valueWidth !== null ? [{ id: "usd", label: "Value", width: Math.max(medium ? 10 : 8, valueWidth), align: "right" as const }] : []),
@@ -117,6 +121,7 @@ function tableColumns(width: number, desktop: boolean, locked: boolean, valueWid
117
121
  ];
118
122
  const preferred = { share: share.width, name: name.width };
119
123
  // The table ignores its last trailing gutter when deciding whether it fits.
124
+ const original = columns;
120
125
  const overflow = () => getTableWidth(columns) - width - 1;
121
126
  // Native units keep their column before the share keeps its bar or its whole wording.
122
127
  const withBar = SHARE_BAR_MIN_CELLS + 1;
@@ -128,7 +133,16 @@ function tableColumns(width: number, desktop: boolean, locked: boolean, valueWid
128
133
  share.width = Math.max(shareMin, share.width - Math.max(0, overflow()));
129
134
  name.width = Math.max(nameMin, name.width - Math.max(0, overflow()));
130
135
  };
131
- fit(shareFloor);
136
+ // A name keeps what tells it apart before a share keeps the words after its basis: "Hon Hai Precision Industry" whole
137
+ // beside "16% of total revenue", not "Hon Hai Precision In…" beside "…, from Compute & Networking", which the
138
+ // selected row's own words and its evidence still say. Within a cap, so one long name never takes the table.
139
+ const nameKeep = Math.min(NAME_KEEP_MAX_CELLS, Math.max(preferred.name, nameCells));
140
+ const shareShort = withBar + (valueWidth !== null ? bare : Math.max(bare, ...bases.map((forms) => forms[Math.min(1, forms.length - 1)]!)));
141
+ preferred.name = nameKeep;
142
+ fit(shareFloor, nameKeep);
143
+ if (overflow() > 0) fit(Math.min(shareFloor, shareShort), nameKeep);
144
+ // A pane too narrow for both gives way as before: the name, then the columns, then the share's shorter forms.
145
+ if (overflow() > 0) fit(shareFloor);
132
146
  for (const id of ["ticker", "fy"]) {
133
147
  if (overflow() <= 0) break;
134
148
  if (!columns.some((column) => column.id === id)) continue;
@@ -141,7 +155,7 @@ function tableColumns(width: number, desktop: boolean, locked: boolean, valueWid
141
155
  if (overflow() > 0 && shares) fit(plain + bare);
142
156
  if (overflow() > 0) fit(shares ? plain + bare : SHARE_FIGURE_CELLS + 2, 12);
143
157
  if (overflow() > 0 && shares) fit(plain + SHARE_BASIS_LAST_CELLS, 12);
144
- return columns;
158
+ return markHiddenTableColumns(original, columns);
145
159
  }
146
160
 
147
161
  /**
@@ -149,9 +163,13 @@ function tableColumns(width: number, desktop: boolean, locked: boolean, valueWid
149
163
  * disclosures a free preview locks: the strip that heads the table and the flow.
150
164
  */
151
165
  function supplyFigures(data: SupplyChainPayload, views: readonly ("says" | "names")[], options: Required<SupplyOptions>, company: string | null): StatItem[] {
166
+ // Investee rows that all run into the company are its investors (rowRoleLabel).
167
+ const stakes = views.flatMap((view) => data[view].filter((row) => row.role === "investee"));
168
+ const investors = stakes.length > 0 && stakes.every((row) => row.direction === "in");
152
169
  return [
153
170
  ...(data.entity && company ? [{ id: "company", label: "Company", value: company }] : []),
154
- ...supplyRoleCounts(data, views, options).map(({ role, counterparties, locked }) => ({ id: role, label: ROLE_PLURALS[role], value: String(counterparties),
171
+ ...supplyRoleCounts(data, views, options).map(({ role, counterparties, locked }) => ({ id: role,
172
+ label: role === "investee" && investors ? "Investors" : ROLE_PLURALS[role], value: String(counterparties),
155
173
  color: ROLE_COLORS[role], detail: locked ? `+${locked} locked` : undefined })),
156
174
  ];
157
175
  }
@@ -175,6 +193,27 @@ function ShareCell({ row, focusId, width, layout, selected }: { row: SupplyRow;
175
193
  </Box>;
176
194
  }
177
195
 
196
+ /** Rows a table must leave free before the selected relationship's own words take them: a heading and a few lines of quote. */
197
+ const DISCLOSURE_BAND_MIN_ROWS = 8;
198
+
199
+ /**
200
+ * The selected relationship's own words, in the rows a short table leaves
201
+ * free, as a chart takes a short table's spare rows: the quote the row rests
202
+ * on, or a tagged fact read out. Who said it and when are the row's own
203
+ * columns; `e` opens the whole evidence.
204
+ */
205
+ function SelectedDisclosure({ row, width, height }: { row: SupplyRow; width: number; height: number }) {
206
+ const desktop = !!useUiCapabilities().nativePaneChrome;
207
+ const item = row.evidence?.find((entry) => entry.status === "active" && canShowQuote(entry) && entry.quote);
208
+ const tagged = !item && isTaggedFact(row);
209
+ // The terminal gives it the rows the table leaves; the desktop sets it under the last row at its own height.
210
+ return <Box flexDirection="column" width={width} height={desktop ? undefined : height} flexShrink={desktop ? 0 : 1} minHeight={0} overflow="hidden" paddingX={desktop ? 0 : 1}
211
+ data-gloom-role="supply-selected-disclosure">
212
+ <DisclosureQuote role={row.role} quote={item?.quote ?? disclosureText(row)} quoteLanguage={item?.quoteLanguage ?? row.quoteLanguage}
213
+ width={Math.max(1, width - (desktop ? 0 : 2))} label={tagged ? "Tagged in the filing" : undefined} />
214
+ </Box>;
215
+ }
216
+
178
217
  export function SupplyChainPane({ width, height, focused }: PaneProps) {
179
218
  const { symbol, ticker } = usePaneTickerIdentity();
180
219
  return <SupplyView key={symbol ?? "empty"} symbol={symbol} listingName={ticker?.metadata.name ?? null} width={width} height={height} focused={focused} />;
@@ -198,14 +237,17 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
198
237
  const initialTiers = useMemo(() => supplyOptions(openingTab === "graph" || openingTab === "path" ? undefined : openingTiers).tiers, [openingTiers, openingTab]);
199
238
  const [savedTiers, setTiers] = usePluginPaneState<SupplyTierFilter[]>("supply:tiers", initialTiers);
200
239
  const options = useMemo(() => supplyOptions(savedTiers), [savedTiers]);
201
- const loader = useCallback((force: boolean) => snapshot ? Promise.resolve({ payload: snapshot, stale: false, refreshError: null }) : loadSupplyChain(symbol!, accessKey, force, options), [symbol, accessKey, snapshot, options]);
240
+ // `--as-of`: the disclosures known by that day, read by the server and never shown past it.
241
+ const [asOfSetting] = usePaneSettingValue<string>("asOf", "");
242
+ const read = useMemo(() => ({ ...options, ...asOfSetting ? { asOf: asOfSetting } : {} }), [options, asOfSetting]);
243
+ const loader = useCallback((force: boolean) => snapshot ? Promise.resolve({ payload: snapshot, stale: false, refreshError: null }) : loadSupplyChain(symbol!, accessKey, force, read), [symbol, accessKey, snapshot, read]);
202
244
  const resource = useAsyncResource(symbol && !graphTab ? loader : null, {
203
- initialData: () => symbol ? cachedSupplyChain(symbol, accessKey, options) : null, clearOnError: isAccessDenied,
245
+ initialData: () => symbol ? cachedSupplyChain(symbol, accessKey, read) : null, clearOnError: isAccessDenied,
204
246
  });
205
247
  const data = resource.data?.payload ?? null;
206
- const [openingView] = usePaneSettingValue("view", "says");
248
+ const [openingView] = usePaneSettingValue("view", "");
207
249
  const [savedView, setView] = usePluginPaneState<string>("supply:view", openingView);
208
- const view = savedView === "names" ? "names" : "says";
250
+ const view = savedView === "names" || savedView === "says" ? savedView : data ? openingSupplyView(data, options) : "says";
209
251
  const tooSmall = width < 70 || height < 13;
210
252
  const tab = graphTab ? savedTab : savedTab === "flow" && !tooSmall ? "flow" : "table";
211
253
  const [sort, setSort] = usePluginPaneState<SupplySort>("supply:sort", { column: "pct", direction: "desc" });
@@ -253,8 +295,10 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
253
295
  ] : []),
254
296
  ...(data?.truncated ? [{ id: "upgrade", key: CLOUD_PLAN_KEY, label: "upgrade", title: "Upgrade to Pro", onPress: openUpgrade }] : []),
255
297
  ];
298
+ // Dated by the newest disclosure the reader can see, as its Published column says, never by the latest period one covers.
299
+ const published = useMemo(() => allRows.map(evidenceDate).sort().at(-1) ?? null, [allRows]);
256
300
  usePaneStatusFooter({ registrationId: "supply-chain", enabled: !graphTab, loading: resource.loading, error: data ? resource.error : null, stale: resource.data?.stale,
257
- info: data?.asOf ? [{ id: "as-of", parts: [{ text: `as of ${data.asOf}`, tone: "muted" as const }] }] : [], hints });
301
+ info: published ? [{ id: "as-of", parts: [{ text: asOfSetting ? `known by ${asOfSetting}` : `as of ${published}`, tone: "muted" as const }] }] : [], hints });
258
302
  usePaneNoticeFooter({ registrationId: "supply-chain:notices", focused, enabled: !graphTab, notices: [
259
303
  ...(resource.data?.refreshError ? [resource.data.refreshError] : []),
260
304
  ...(savedTab === "flow" && tooSmall ? ["Flow needs a wider pane. Showing the table."] : []),
@@ -276,8 +320,13 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
276
320
  // no column; laid out a cell narrower, the table also clears its own scrollbar. Otherwise the
277
321
  // evidence view says it.
278
322
  const periodWidth = Math.max(PERIOD_DATE_CELLS, ...tableRows.map((row) => displayWidth(cellText(row, "fy"))));
279
- const dated = tableColumns(width, desktop, locked > 0, valueWidth, bases);
280
- const lengths = periodWidth > PERIOD_DATE_CELLS ? tableColumns(width - 1, desktop, locked > 0, valueWidth, bases, periodWidth) : null;
323
+ // What the longest name needs with its kind beside it ("Customer 1" and "undisclosed"), so the column can keep it whole.
324
+ const nameCells = Math.max(0, ...tableRows.map((row) => {
325
+ const kind = counterpartyKindLabel(row, true);
326
+ return displayWidth(counterpartyLabel(row)) + (kind ? displayWidth(kind) + 4 : 0);
327
+ }));
328
+ const dated = tableColumns(width, desktop, locked > 0, valueWidth, bases, PERIOD_DATE_CELLS, nameCells);
329
+ const lengths = periodWidth > PERIOD_DATE_CELLS ? tableColumns(width - 1, desktop, locked > 0, valueWidth, bases, periodWidth, nameCells) : null;
281
330
  const columns = lengths?.some((column) => column.id === "fy") && lengths.map((column) => column.id).join() === dated.map((column) => column.id).join() ? lengths : dated;
282
331
  const shareColumn = shareLayout(columns.find((column) => column.id === "pct")?.width ?? 0, bases);
283
332
  const renderCell = (entry: SectionedRow<Item>, column: DataTableColumn, _index: number, state: { selected: boolean }): DataTableCell => {
@@ -308,7 +357,8 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
308
357
  const room = Math.max(8, column.width - (kind ? displayWidth(kind) + 4 : 0) - (ticker ? displayWidth(ticker) + 1 : 0));
309
358
  // On the desktop the name gives way at the column's edge by CSS and the ticker and kind keep their room.
310
359
  return { text: cellText(row, "name"), content: <Box flexDirection="row" height={1} gap={ticker ? 1 : 2} overflow="hidden" {...(desktop ? { flexShrink: 1, minWidth: 0 } : {})}>
311
- <ClippedText fg={ink ?? (company ? colors.textBright : colors.textDim)} text={counterpartyLabel(row)} width={room} />
360
+ {/* A name cut short keeps the letter or number that tells two undisclosed customers apart ("Cu… 1"), in both renderers. */}
361
+ <ClippedText fg={ink ?? (company ? colors.textBright : colors.textDim)} text={counterpartyLabel(row)} width={room} keepEnd={counterpartyLabelEnd(row)} />
312
362
  {ticker ? <Text fg={ink ?? colors.textDim} style={desktop ? { flex: "0 0 auto" } : undefined}>{ticker}</Text> : null}
313
363
  {kind ? desktop ? <Badge label={kind} /> : <Text fg={ink ?? colors.textMuted}>{kind}</Text> : null}
314
364
  </Box> };
@@ -321,7 +371,7 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
321
371
  // The text a copy or export reads names a related party; the cell draws the role beside the name's chip.
322
372
  case "role": return { text: relationshipLabel(row), content: <Box flexDirection="row" height={1} overflow="hidden">
323
373
  <Text fg={ROLE_COLORS[row.role]}>●</Text>
324
- <Text fg={ink ?? ROLE_COLORS[row.role]}>{` ${roleLabel(row.role)}`}</Text>
374
+ <Text fg={ink ?? ROLE_COLORS[row.role]}>{` ${rowRoleLabel(row)}`}</Text>
325
375
  </Box> };
326
376
  case "pct": return { text: percentage(row) === MISSING_VALUE ? "" : `${shareParts(row, focusId)?.value ?? ""} ${shareParts(row, focusId)?.basis ?? ""}`.trim(), value: row.pctOfRevenue,
327
377
  content: <ShareCell row={row} focusId={focusId} width={column.width} layout={shareColumn} selected={state.selected} /> };
@@ -347,6 +397,11 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
347
397
  const header = concentrationChart
348
398
  ? <ChartTableHeader width={width} height={bodyHeight} tableRows={items.length} tableColumns={columns} figures={figures} chart={concentrationChart} query={query} />
349
399
  : <Box flexDirection="column" flexShrink={0}>{query}<StatGrid items={figures} width={width} /></Box>;
400
+ // The rows the table leaves free under its last row: the query bar, the figures, the column header and the rows,
401
+ // and a scrollbar row a wide table may draw.
402
+ const spareRows = bodyHeight - 1 - statGridRows(figures, width) - 1 - hiddenTableColumnRows(columns, items.length) - items.length - 1;
403
+ const disclosureBand = tab === "table" && !concentrationChart && !openRow && selected && spareRows >= DISCLOSURE_BAND_MIN_ROWS
404
+ ? <SelectedDisclosure row={selected} width={width} height={spareRows} /> : null;
350
405
  const flowFigureColumns = Math.min(Math.max(1, figures.length), Math.max(1, Math.floor(width / 24)));
351
406
  // A short flow keeps one row of figures, dropping the last roles, so the cards keep their room.
352
407
  const flowFigures = bodyHeight < 26 ? figures.slice(0, flowFigureColumns) : figures;
@@ -368,6 +423,9 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
368
423
  {data.truncated ? <Box paddingX={1}><UpgradeLabel text="Upgrade to see every relationship" onPress={openUpgrade} role="supply-upgrade" /></Box> : null}
369
424
  </Box> : <DataTableView<SectionedRow<Item>> columns={columns}
370
425
  items={items} focused={focused && !openRow} rootWidth={width} rootHeight={bodyHeight} rootBefore={header}
426
+ // The selected row's words follow the table in the terminal's spare rows; on the desktop they follow its last row,
427
+ // after the locked preview, and the table runs on to the footer below them.
428
+ {...disclosureBand && !desktop ? { rootAfter: disclosureBand, fitRows: true, virtualize: false } : {}}
371
429
  selection={{ kind: "id", selectedId: selected?.id ?? null, getId: (entry) => entry.key, onChange: (id) => setSelected(id) }} getItemKey={(entry) => entry.key}
372
430
  isNavigable={isSectionedItemRow}
373
431
  // The placeholders stand for every locked disclosure; the header says what free shows and counts those, as the figures do.
@@ -377,7 +435,10 @@ function SupplyView({ symbol, listingName, width, height, focused }: Pick<PanePr
377
435
  onHeaderClick={(column) => setSort((old) => ({ column, direction: old.column === column && old.direction === "desc" ? "asc" : "desc" }))}
378
436
  selectedTextOverridesCellColor showHorizontalScrollbar resetScrollKey={`${symbol}:${view}:${options.tiers.join(",")}`}
379
437
  emptyStateTitle={supplyEmptyText(data) ?? "No relationships for the selected evidence tiers."}
380
- bodyAfter={locked > 0 && desktop ? <LockedOverlay rows={Math.min(3, locked)} text="Upgrade to see every relationship" onPress={openUpgrade} role="supply-upgrade" /> : undefined} />}
438
+ bodyAfter={desktop && (locked > 0 || disclosureBand) ? <>
439
+ {locked > 0 ? <LockedOverlay rows={Math.min(3, locked)} text="Upgrade to see every relationship" onPress={openUpgrade} role="supply-upgrade" /> : null}
440
+ {disclosureBand}
441
+ </> : undefined} />}
381
442
  /> : null}
382
443
  </PaneStatusBody>
383
444
  </Box>;
@@ -6,7 +6,7 @@ import { formatRelativeAge } from "../../../utils/datetime-format";
6
6
  import { fetchThemeMembers, fetchThemes } from "./client";
7
7
  import {
8
8
  aggregateText, boardClose, boardYtdBase, DEFAULT_SORT, matchTheme, memberExtended, memberExtendedSessions, memberPrice, percent, periodLabel,
9
- isLiveBoard, SNAPSHOT_STALE_MS, sortMembers, sortThemes,
9
+ isLiveBoard, SNAPSHOT_STALE_MS, sortMembers, sortThemes, THEME_LISTING_SCOPE,
10
10
  } from "./model";
11
11
 
12
12
  /** The period columns; YTD names the close it is measured from, `YTD vs 31 Dec close`. */
@@ -71,10 +71,10 @@ function boardObservation(payload: ThemesPayload | ThemeMembersPayload, now = Da
71
71
  */
72
72
  function themeReportTitle(query: string | undefined, theme: Pick<ThemeSummary, "id" | "name"> | undefined): string {
73
73
  const typed = query?.trim();
74
- if (!typed) return "Thematic baskets";
75
- if (!theme) return `Thematic baskets | ${typed}`;
74
+ if (!typed) return `Thematic baskets · ${THEME_LISTING_SCOPE}`;
75
+ if (!theme) return `Thematic baskets · ${THEME_LISTING_SCOPE} | ${typed}`;
76
76
  const named = [theme.id, theme.name].some((label) => label.toLowerCase() === typed.toLowerCase());
77
- return `Thematic baskets | ${theme.name}${named ? "" : ` (matched ${typed})`}`;
77
+ return `Thematic baskets · ${THEME_LISTING_SCOPE} | ${theme.name}${named ? "" : ` (matched ${typed})`}`;
78
78
  }
79
79
 
80
80
  export const themesHeadless: HeadlessPaneDefinition<"rows"> = {
@@ -1,7 +1,7 @@
1
1
  import { MISSING_VALUE } from "../../../utils/format";
2
2
  import { THEME_PERIODS, type ThemeAggregate, type ThemeMember, type ThemePeriod, type ThemeSummary } from "../../../api-client/themes";
3
3
  import type { DataTableColumn } from "../../../components";
4
- import { dropColumnsToFit, getTableWidth } from "../../../components/ui/table-layout";
4
+ import { dropColumnsToFit, getTableWidth, TABLE_COLUMN_GAP } from "../../../components/ui/table-layout";
5
5
  import { extendedSessionStateLabel, type ExtendedSession } from "../../../market-data/market/status";
6
6
  import { yearToDateBaseLabel } from "../../../market-data/market/year-to-date";
7
7
  import { compareSortValues, type SortDirection } from "../../../utils/sort-values";
@@ -148,6 +148,7 @@ export function matchTheme(rows: readonly ThemeSummary[], input: string): ThemeS
148
148
  }
149
149
 
150
150
  const column = (id: string, label: string, width: number, align: "left" | "right" = "right"): DataTableColumn => ({ id, label, width, align });
151
+ export const THEME_LISTING_SCOPE = "US-listed";
151
152
  /** Room a header has in its column: the sort indicator takes two cells. */
152
153
  const HEADER_ROOM = 2;
153
154
  /**
@@ -163,7 +164,7 @@ export function themeColumns(width: number, rows: readonly ThemeSummary[], ytdBa
163
164
  const label = (period: ThemePeriod, room: number) => periodLabel(period, ytdBase, room) + " ".repeat(suffixWidth(period));
164
165
  // The board always keeps room for `YTD vs 31 Dec`, so even a narrow one says what its YTD is measured against.
165
166
  const leastRoom = ytdBase ? `YTD vs ${ytdBase}`.length : 0;
166
- const columns = [column("name", "Theme", 26, "left"), column("memberCount", "N", 3),
167
+ const columns = [column("name", `Theme · ${THEME_LISTING_SCOPE}`, 26, "left"), column("memberCount", "N", 3),
167
168
  ...THEME_PERIODS.map((period) => column(period, label(period, leastRoom), Math.max(metricWidth(period), label(period, leastRoom).length + HEADER_ROOM))),
168
169
  column("breadth", "Breadth" + " ".repeat(coverageWidth(rows.map((row) => row.breadth))), 7 + coverageWidth(rows.map((row) => row.breadth))),
169
170
  column("best", "Best 1D", 15), column("worst", "Worst 1D", 15)];
@@ -175,15 +176,17 @@ export function themeColumns(width: number, rows: readonly ThemeSummary[], ytdBa
175
176
  /**
176
177
  * The member table at `width`. Price and 1D are the regular session's; a
177
178
  * PRE-MKT or AFTER-HRS column, named as BI and MOST name it, follows 1D for
178
- * each session in `extendedSessions`. A narrow pane gives up the longer
179
- * windows first, then that column, then the name.
179
+ * each session in `extendedSessions`. Longer windows give way first, then
180
+ * extended sessions; the name shortens when the daily columns need the room.
180
181
  */
181
182
  export function memberColumns(width: number, extendedSessions: readonly ExtendedSession[] = [], ytdBase: string | null = null): DataTableColumn[] {
182
183
  const extended = extendedSessions.map((session) => column(session === "PRE" ? "preMarket" : "afterHours", extendedSessionStateLabel(session), 9));
183
184
  const [day, ...windows] = THEME_PERIODS.map((period) => column(period, periodLabel(period, ytdBase, 0), Math.max(9, periodLabel(period, ytdBase, 0).length + HEADER_ROOM)));
184
- const fitted = fitColumns([column("symbol", "Ticker", 7, "left"), column("name", "Name", 24, "left"), column("price", "Price $", 10),
185
- day!, ...extended, ...windows], width,
186
- ["return3MPercent", "returnYtdPercent", "return1MPercent", "return1WPercent", "preMarket", "afterHours", "name", "price"]);
185
+ const symbol = column("symbol", "Ticker", 7, "left");
186
+ const price = column("price", "Price $", 10);
187
+ const nameWidth = Math.max(8, Math.min(24, width - getTableWidth([symbol, price, day!]) - TABLE_COLUMN_GAP));
188
+ const fitted = fitColumns([symbol, column("name", "Name", nameWidth, "left"), price, day!, ...extended, ...windows], width,
189
+ ["return3MPercent", "returnYtdPercent", "return1MPercent", "return1WPercent", "preMarket", "afterHours"]);
187
190
  const ytd = fitted.find((col) => col.id === "returnYtdPercent");
188
191
  if (ytd) ytd.label = periodLabel("returnYtdPercent", ytdBase, ytd.width - HEADER_ROOM);
189
192
  return fitted;
@@ -193,7 +196,7 @@ function fitColumns(columns: DataTableColumn[], width: number, drop: string[]):
193
196
  const used = () => getTableWidth(columns);
194
197
  const name = columns.find((col) => col.id === "name") ?? columns[0]!;
195
198
  const spare = width - used();
196
- name.width = Math.max(8, name.width + Math.min(spare, Math.max(0, 36 - name.width)));
199
+ name.width += Math.min(Math.max(0, spare), Math.max(0, 36 - name.width));
197
200
  name.flexGrow = 1;
198
201
  // Wide boards share room across the figures instead of separating every name
199
202
  // from its daily move with an almost pane-wide blank name column.
@@ -14,7 +14,7 @@ import { useMembersMenu } from "../shared/members-menu";
14
14
  import { cachedMembers, cachedThemes, loadMembers, loadThemes } from "./client";
15
15
  import {
16
16
  aggregateText, boardYtdBase, coverageText, coverageWidth, DEFAULT_SORT, extendedMove, matchTheme, memberColumns, memberExtendedSessions, memberPrice, percent,
17
- isLiveBoard, LIVE_BOARD_REFRESH_MS, SNAPSHOT_STALE_MS, snapshotFooterText, sortMembers, sortThemes, themeColumns, type ThemeSort,
17
+ isLiveBoard, LIVE_BOARD_REFRESH_MS, SNAPSHOT_STALE_MS, snapshotFooterText, sortMembers, sortThemes, themeColumns, THEME_LISTING_SCOPE, type ThemeSort,
18
18
  } from "./model";
19
19
 
20
20
  const LIVE_LEAD = "live · ";
@@ -155,7 +155,7 @@ export function ThemesBoard({ width, height, focused, tabStrip, tabRows = 0 }: T
155
155
  {data ? <DataTableStackView<ThemeSummary> columns={columns} items={rows} rootWidth={width} rootHeight={bodyHeight} focused={focused}
156
156
  selection={{ kind: "id", selectedId: selected, getId: (row) => row.id, onChange: setSelected }}
157
157
  getItemKey={(row) => row.id} onActivate={(row) => setOpened(row.id)}
158
- detailOpen={!!opened} onBack={() => setOpened("")} detailTitle={theme?.name ?? opened}
158
+ detailOpen={!!opened} onBack={() => setOpened("")} detailTitle={theme ? `${theme.name} · ${THEME_LISTING_SCOPE}` : opened}
159
159
  detailContent={theme ? <Members key={theme.id} id={theme.id} width={width} height={Math.max(1, bodyHeight - 1)} focused={focused} />
160
160
  : <PaneStatusBody subject="theme" error="No matching theme. Return to the list to choose a basket." />}
161
161
  renderCell={renderCell} sortColumnId={sort.columnId} sortDirection={sort.direction}
@@ -0,0 +1,62 @@
1
+ import { useCallback } from "react";
2
+ import { useAsyncResource } from "../../../../react/async-resource";
3
+ import { useFxRateObservations, useQuoteEntry } from "../../../../market-data/hooks";
4
+ import { resolveEntryData } from "../../../../market-data/selectors";
5
+ import { pairPriceInput } from "../../../../market-data/depositary-pair";
6
+ import {
7
+ ahListingKey, ahPairOf, ahPairSide, ahSpotFromUsdValues, compareAhPair, type AhComparison, type AhPair,
8
+ } from "../../../../market-data/ah-pair";
9
+ import type { Quote } from "../../../../types/financials";
10
+ import { canonicalExchange, parsePublicTickerKey } from "../../../../utils/exchanges";
11
+ import { useAssetData } from "../../../runtime";
12
+
13
+ /** Venues an A+H company's lines trade on. */
14
+ const AH_VENUES = new Set(["HKEX", "SSE", "SZSE"]);
15
+
16
+ /** Whether a listing is on a venue an A+H company's line trades on, so its company's lines are worth reading. */
17
+ export function mayBeAhLine(symbol: string | null | undefined, exchange?: string | null): boolean {
18
+ if (!symbol) return false;
19
+ const venue = parsePublicTickerKey(ahListingKey(symbol, exchange)).exchange;
20
+ return AH_VENUES.has(canonicalExchange(venue ?? ""));
21
+ }
22
+
23
+ /** The listing's A+H pair and how its two prices compare, as the ADR tab and DES read it. */
24
+ export interface AhPairState {
25
+ pair: AhPair;
26
+ /** Which line the listing is. */
27
+ side: "h" | "a";
28
+ quotes: { h: Quote | null; a: Quote | null };
29
+ /** Null while a price is missing. */
30
+ comparison: AhComparison | null;
31
+ /** The other line's price is still being read. */
32
+ loading: boolean;
33
+ }
34
+
35
+ /**
36
+ * The A+H pair of the listing `symbol` (on `exchange`), from the company's
37
+ * lines Gloom Cloud holds (`getIssuerListings`), with the other line's price
38
+ * read through the quote path, both dollar rates, and the comparison. Null for
39
+ * a listing off those venues or of a company that is no A+H pair. `ownQuote`
40
+ * is the listing's own price as the pane already shows it.
41
+ */
42
+ export function useAhPair(symbol: string | null | undefined, exchange: string | null | undefined, ownQuote: Quote | null | undefined): AhPairState | null {
43
+ const dataProvider = useAssetData();
44
+ const reads = mayBeAhLine(symbol, exchange) && !!dataProvider?.getIssuerListings;
45
+ const loader = useCallback(
46
+ () => dataProvider!.getIssuerListings!(symbol!, exchange ?? undefined),
47
+ [dataProvider, exchange, symbol],
48
+ );
49
+ const issuer = useAsyncResource(reads ? loader : null);
50
+ const pair = reads ? ahPairOf(issuer.data) : null;
51
+ const side = pair && symbol ? ahPairSide(pair, symbol, exchange) : null;
52
+ const other = pair && side ? (side === "h" ? pair.a : pair.h) : null;
53
+ const otherEntry = useQuoteEntry(other, null);
54
+ const rates = useFxRateObservations(other ? ["CNY", "HKD"] : []);
55
+ if (!pair || !side) return null;
56
+ const otherQuote = resolveEntryData(otherEntry) ?? null;
57
+ const quotes = side === "h" ? { h: ownQuote ?? null, a: otherQuote } : { h: otherQuote, a: ownQuote ?? null };
58
+ const spot = ahSpotFromUsdValues(rates.get("CNY") ?? null, rates.get("HKD") ?? null);
59
+ const comparison = compareAhPair(pairPriceInput(pair.h, quotes.h), pairPriceInput(pair.a, quotes.a), spot);
60
+ const loading = !otherQuote && (!otherEntry || otherEntry.phase === "loading" || otherEntry.phase === "idle");
61
+ return { pair, side, quotes, comparison, loading };
62
+ }