gloomberb 0.15.7 → 0.16.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 (524) hide show
  1. package/README.md +11 -2
  2. package/package.json +1 -1
  3. package/src/api-client/app-attention.ts +147 -0
  4. package/src/api-client/attention.ts +26 -0
  5. package/src/api-client/awards.ts +215 -0
  6. package/src/api-client/catalysts.ts +160 -0
  7. package/src/api-client/chat.ts +137 -14
  8. package/src/api-client/company-kpis.ts +153 -0
  9. package/src/api-client/cpi.ts +52 -0
  10. package/src/api-client/credit-documents.ts +107 -0
  11. package/src/api-client/data.ts +192 -3
  12. package/src/api-client/distress.ts +164 -0
  13. package/src/api-client/doe.ts +75 -0
  14. package/src/api-client/equity-screener.ts +11 -0
  15. package/src/api-client/exposure.ts +202 -0
  16. package/src/api-client/gpu.ts +93 -0
  17. package/src/api-client/hiring.ts +110 -0
  18. package/src/api-client/index.ts +78 -3
  19. package/src/api-client/normalizers.ts +31 -1
  20. package/src/api-client/paths.ts +3 -0
  21. package/src/api-client/perps.ts +127 -0
  22. package/src/api-client/power.ts +148 -0
  23. package/src/api-client/request.ts +58 -1
  24. package/src/api-client/research-activity.ts +172 -13
  25. package/src/api-client/socket.ts +75 -27
  26. package/src/api-client/supply-chain-graph.ts +40 -0
  27. package/src/api-client/supply-chain.ts +98 -0
  28. package/src/api-client/telemetry.ts +29 -0
  29. package/src/api-client/themes.ts +28 -0
  30. package/src/api-client/types.ts +33 -1
  31. package/src/api-client/wall-experiments.ts +100 -0
  32. package/src/api-client/wall-summary.ts +49 -0
  33. package/src/api-client/web-experiments.ts +136 -0
  34. package/src/app/pane-runtime/plugin-bindings.ts +5 -0
  35. package/src/app/pane-runtime/ticker-open-runtime.ts +8 -2
  36. package/src/app/runtime/update.ts +13 -1
  37. package/src/cli/commands/system.ts +2 -0
  38. package/src/cli/desktop-pane-shot.ts +3 -4
  39. package/src/cli/pane-functions/data.ts +78 -0
  40. package/src/cli/pane-functions/financial-ratio-shot.ts +160 -0
  41. package/src/cli/pane-functions/function-help.ts +220 -8
  42. package/src/cli/pane-functions/headless.ts +4 -0
  43. package/src/cli/pane-functions/screenshot-evidence.ts +21 -0
  44. package/src/cli/pane-functions/screenshot.ts +49 -5
  45. package/src/components/chart/composite/composite-chart.tsx +15 -2
  46. package/src/components/chart/composite/format.ts +24 -11
  47. package/src/components/chart/composite/rasterizer.ts +67 -16
  48. package/src/components/chart/composite/scene.ts +53 -2
  49. package/src/components/chart/composite/session-shading.ts +3 -2
  50. package/src/components/chart/composite/text-renderer.ts +52 -1
  51. package/src/components/chart/composite/time-axis.ts +100 -30
  52. package/src/components/chart/composite/tools.ts +2 -1
  53. package/src/components/chart/composite/types.ts +4 -0
  54. package/src/components/chart-table/index.ts +1 -0
  55. package/src/components/chart-table/layout.ts +15 -0
  56. package/src/components/command-bar/action-runtime.ts +1 -0
  57. package/src/components/command-bar/commands/direct/index.ts +32 -0
  58. package/src/components/command-bar/commands/registry.ts +7 -0
  59. package/src/components/command-bar/pane-templates/items.ts +11 -0
  60. package/src/components/command-bar/pane-templates/workflow.ts +19 -4
  61. package/src/components/command-bar/routes/root/command-items.ts +6 -0
  62. package/src/components/command-bar/routes/root/provider-search.ts +2 -0
  63. package/src/components/command-bar/routes/root/results.ts +64 -0
  64. package/src/components/command-bar/routes/root/runtime.ts +8 -0
  65. package/src/components/command-bar/routes/ticker-search/results.ts +89 -24
  66. package/src/components/command-bar/routes/ticker-search/route.ts +2 -0
  67. package/src/components/command-bar/surface/index.tsx +15 -0
  68. package/src/components/command-bar/view-model.ts +3 -0
  69. package/src/components/command-bar/workflow/collection-actions.ts +9 -7
  70. package/src/components/command-bar/workflow/ops.ts +19 -0
  71. package/src/components/command-bar/workflow/tickers.ts +5 -0
  72. package/src/components/company-logo.tsx +15 -2
  73. package/src/components/data-table/table-pane.ts +2 -1
  74. package/src/components/index.ts +1 -0
  75. package/src/components/layout/detached-pane-shell.tsx +12 -1
  76. package/src/components/layout/missing-pane.tsx +87 -23
  77. package/src/components/layout/pane/footer/index.tsx +64 -18
  78. package/src/components/layout/pane/footer/model.ts +85 -0
  79. package/src/components/layout/pane/sidebar.tsx +19 -1
  80. package/src/components/layout/shell/index.tsx +38 -28
  81. package/src/components/layout/shell/pane/management-shortcuts.ts +13 -1
  82. package/src/components/layout/status-bar.tsx +93 -28
  83. package/src/components/layout/status-widget-space.ts +72 -0
  84. package/src/components/onboarding/first-run-workspace.ts +8 -2
  85. package/src/components/onboarding/onboarding-wizard.tsx +35 -16
  86. package/src/components/onboarding/portfolio-step/positions-panel.tsx +14 -5
  87. package/src/components/onboarding/wizard-model.ts +13 -5
  88. package/src/components/onboarding/wizard-positions.ts +56 -7
  89. package/src/components/price-performance.tsx +31 -34
  90. package/src/components/ui/data-table/index.tsx +11 -8
  91. package/src/components/ui/display.tsx +15 -6
  92. package/src/components/ui/fields.tsx +5 -0
  93. package/src/components/ui/figure.tsx +94 -0
  94. package/src/components/ui/header-case.ts +25 -3
  95. package/src/components/ui/icon.tsx +3 -1
  96. package/src/components/ui/message-composer.tsx +8 -1
  97. package/src/components/ui/query-bar.tsx +8 -1
  98. package/src/components/ui/ratio-bar.tsx +84 -0
  99. package/src/components/ui/toggle.tsx +3 -1
  100. package/src/components/use-scrollbox-layout.ts +17 -0
  101. package/src/core/state/app/layout.ts +35 -1
  102. package/src/core/state/app/state.ts +15 -0
  103. package/src/core/state/app/types.ts +1 -0
  104. package/src/data/config/store/normalize.ts +24 -0
  105. package/src/i18n/es.ts +2 -0
  106. package/src/i18n/ja.ts +2 -0
  107. package/src/i18n/ko.ts +2 -0
  108. package/src/i18n/zh-cn.ts +2 -0
  109. package/src/i18n/zh-tw.ts +2 -0
  110. package/src/layout-marketplace/pane-imagery.ts +1 -0
  111. package/src/market-data/coordinator/entries.ts +13 -0
  112. package/src/market-data/coordinator/financials.ts +33 -8
  113. package/src/market-data/market/freshness.ts +16 -5
  114. package/src/market-data/market/trading-sessions.ts +65 -1
  115. package/src/market-data/published-cn-sessions.ts +25 -0
  116. package/src/market-data/published-nse-sessions.ts +20 -0
  117. package/src/news/aggregator.ts +4 -0
  118. package/src/plugins/builtin/account-management/model.ts +6 -1
  119. package/src/plugins/builtin/account-management/pane.tsx +36 -25
  120. package/src/plugins/builtin/alerts/catalysts.ts +77 -0
  121. package/src/plugins/builtin/alerts/events-pane.tsx +3 -0
  122. package/src/plugins/builtin/alerts/events.ts +10 -4
  123. package/src/plugins/builtin/alerts/history-pane.tsx +1 -1
  124. package/src/plugins/builtin/alerts/history.ts +1 -0
  125. package/src/plugins/builtin/alerts/index.tsx +6 -0
  126. package/src/plugins/builtin/alerts/research-builder.ts +10 -3
  127. package/src/plugins/builtin/alerts/research-rules.ts +15 -1
  128. package/src/plugins/builtin/analytics/risk-client.ts +15 -3
  129. package/src/plugins/builtin/analytics/risk-headless.ts +123 -18
  130. package/src/plugins/builtin/attention/client.ts +80 -0
  131. package/src/plugins/builtin/attention/evidence.ts +30 -0
  132. package/src/plugins/builtin/attention/headless.ts +33 -0
  133. package/src/plugins/builtin/attention/index.tsx +18 -0
  134. package/src/plugins/builtin/attention/model.ts +59 -0
  135. package/src/plugins/builtin/attention/pane.tsx +211 -0
  136. package/src/plugins/builtin/attention/trending.tsx +59 -0
  137. package/src/plugins/builtin/awards/alerts.ts +32 -0
  138. package/src/plugins/builtin/awards/client.ts +82 -0
  139. package/src/plugins/builtin/awards/detail.tsx +107 -0
  140. package/src/plugins/builtin/awards/evidence.ts +36 -0
  141. package/src/plugins/builtin/awards/headless.ts +55 -0
  142. package/src/plugins/builtin/awards/index.tsx +20 -0
  143. package/src/plugins/builtin/awards/model.ts +42 -0
  144. package/src/plugins/builtin/awards/pane.tsx +263 -0
  145. package/src/plugins/builtin/catalysts/client.ts +28 -0
  146. package/src/plugins/builtin/catalysts/detail.tsx +88 -0
  147. package/src/plugins/builtin/catalysts/evidence.ts +47 -0
  148. package/src/plugins/builtin/catalysts/headless.ts +42 -0
  149. package/src/plugins/builtin/catalysts/history.ts +26 -0
  150. package/src/plugins/builtin/catalysts/index.tsx +29 -0
  151. package/src/plugins/builtin/catalysts/model.ts +135 -0
  152. package/src/plugins/builtin/catalysts/pane.tsx +159 -0
  153. package/src/plugins/builtin/chart-composer/cli-options.ts +4 -0
  154. package/src/plugins/builtin/chart-composer/headless-schema.ts +6 -0
  155. package/src/plugins/builtin/chart-composer/index.tsx +8 -1
  156. package/src/plugins/builtin/chart-composer/pane.tsx +28 -1
  157. package/src/plugins/builtin/chat/attachments/desktop.tsx +610 -0
  158. package/src/plugins/builtin/chat/attachments/files.ts +45 -0
  159. package/src/plugins/builtin/chat/attachments/model.ts +164 -0
  160. package/src/plugins/builtin/chat/attachments/terminal.tsx +72 -0
  161. package/src/plugins/builtin/chat/attachments/transfer.ts +165 -0
  162. package/src/plugins/builtin/chat/content/channel-navigation.ts +13 -12
  163. package/src/plugins/builtin/chat/content/composer-runtime.ts +25 -4
  164. package/src/plugins/builtin/chat/content/composer.tsx +46 -4
  165. package/src/plugins/builtin/chat/content/footer.tsx +46 -8
  166. package/src/plugins/builtin/chat/content/index.tsx +263 -62
  167. package/src/plugins/builtin/chat/content/layout-metrics.ts +10 -2
  168. package/src/plugins/builtin/chat/content/open-targets.ts +17 -3
  169. package/src/plugins/builtin/chat/content/scroll.ts +7 -1
  170. package/src/plugins/builtin/chat/content/shortcuts.ts +36 -11
  171. package/src/plugins/builtin/chat/content/snapshot.ts +3 -0
  172. package/src/plugins/builtin/chat/content/transcript.tsx +17 -1
  173. package/src/plugins/builtin/chat/content/types.ts +7 -0
  174. package/src/plugins/builtin/chat/controller/attachments.ts +213 -0
  175. package/src/plugins/builtin/chat/controller/connections.ts +3 -1
  176. package/src/plugins/builtin/chat/controller/index.ts +114 -2
  177. package/src/plugins/builtin/chat/controller/lifecycle.ts +9 -0
  178. package/src/plugins/builtin/chat/controller/messages.ts +35 -2
  179. package/src/plugins/builtin/chat/controller/send.ts +128 -25
  180. package/src/plugins/builtin/chat/controller/state.ts +12 -1
  181. package/src/plugins/builtin/chat/controller/utils.ts +7 -5
  182. package/src/plugins/builtin/chat/controller/view.ts +2 -0
  183. package/src/plugins/builtin/chat/index.tsx +21 -0
  184. package/src/plugins/builtin/chat/layout.ts +9 -4
  185. package/src/plugins/builtin/chat/message/desktop.tsx +55 -20
  186. package/src/plugins/builtin/chat/message/header.tsx +30 -5
  187. package/src/plugins/builtin/chat/message/inline-tokens.tsx +9 -0
  188. package/src/plugins/builtin/chat/message/pending-send.ts +35 -0
  189. package/src/plugins/builtin/chat/message/profile-popover.tsx +5 -1
  190. package/src/plugins/builtin/chat/message/render-state.ts +12 -2
  191. package/src/plugins/builtin/chat/message/terminal.tsx +51 -4
  192. package/src/plugins/builtin/chat/message/types.ts +6 -1
  193. package/src/plugins/builtin/chat/pane-state.ts +59 -1
  194. package/src/plugins/builtin/chat/profile-popover.ts +50 -1
  195. package/src/plugins/builtin/chat/sidebar.tsx +8 -3
  196. package/src/plugins/builtin/chat/status-widget.tsx +29 -12
  197. package/src/plugins/builtin/chat/unread-inbox-pane.tsx +143 -0
  198. package/src/plugins/builtin/chat/unread-inbox.ts +91 -0
  199. package/src/plugins/builtin/clinical-trials/client.ts +237 -0
  200. package/src/plugins/builtin/clinical-trials/index.tsx +74 -0
  201. package/src/plugins/builtin/clinical-trials/pane.tsx +225 -0
  202. package/src/plugins/builtin/clinical-trials/types.ts +2 -0
  203. package/src/plugins/builtin/cloud/askg/controller.ts +37 -6
  204. package/src/plugins/builtin/cloud/askg/executor.ts +59 -44
  205. package/src/plugins/builtin/cloud/askg/host.ts +8 -1
  206. package/src/plugins/builtin/cloud/askg/manifest.ts +29 -2
  207. package/src/plugins/builtin/cloud/askg/model.ts +47 -13
  208. package/src/plugins/builtin/cloud/askg/notes.ts +100 -0
  209. package/src/plugins/builtin/cloud/askg/pane.tsx +50 -14
  210. package/src/plugins/builtin/cloud/askg/protocol.ts +39 -1
  211. package/src/plugins/builtin/cloud/askg/result-budget.ts +156 -0
  212. package/src/plugins/builtin/cloud/askg/user-data.ts +89 -0
  213. package/src/plugins/builtin/cloud/auth-actions.tsx +55 -31
  214. package/src/plugins/builtin/cloud/plugin.tsx +4 -1
  215. package/src/plugins/builtin/cloud/team/pane-sections.tsx +10 -1
  216. package/src/plugins/builtin/cloud/team/pane.tsx +3 -2
  217. package/src/plugins/builtin/cloud/thesis/board-pane.tsx +2 -2
  218. package/src/plugins/builtin/cloud/thesis/detail.tsx +1 -1
  219. package/src/plugins/builtin/cloud/thesis/ticker-tab.tsx +2 -2
  220. package/src/plugins/builtin/cloud/trial-offer-status-widget.tsx +202 -0
  221. package/src/plugins/builtin/cloud/upgrade-command.ts +1 -1
  222. package/src/plugins/builtin/cloud/upgrade-dialog.tsx +29 -3
  223. package/src/plugins/builtin/cloud/upgrade-status-widget.tsx +1 -1
  224. package/src/plugins/builtin/cloud-tweets/table.tsx +1 -1
  225. package/src/plugins/builtin/comment-letters/client.ts +342 -0
  226. package/src/plugins/builtin/comment-letters/index.tsx +74 -0
  227. package/src/plugins/builtin/comment-letters/pane.tsx +295 -0
  228. package/src/plugins/builtin/comment-letters/types.ts +43 -0
  229. package/src/plugins/builtin/company-attention/app-rank.tsx +79 -0
  230. package/src/plugins/builtin/company-attention/client.ts +69 -0
  231. package/src/plugins/builtin/company-attention/evidence.ts +45 -0
  232. package/src/plugins/builtin/company-attention/headless.ts +47 -0
  233. package/src/plugins/builtin/company-attention/index.tsx +30 -0
  234. package/src/plugins/builtin/company-attention/model.ts +129 -0
  235. package/src/plugins/builtin/company-attention/pane.tsx +183 -0
  236. package/src/plugins/builtin/company-kpis/client.ts +92 -0
  237. package/src/plugins/builtin/company-kpis/headless.ts +32 -0
  238. package/src/plugins/builtin/company-kpis/index.tsx +26 -0
  239. package/src/plugins/builtin/company-kpis/model.ts +124 -0
  240. package/src/plugins/builtin/company-kpis/pane.tsx +226 -0
  241. package/src/plugins/builtin/company-kpis/related.ts +11 -0
  242. package/src/plugins/builtin/company-kpis/screenshot-evidence.ts +44 -0
  243. package/src/plugins/builtin/composite-plugins.ts +34 -0
  244. package/src/plugins/builtin/correlation/history.ts +4 -1
  245. package/src/plugins/builtin/correlation/index.tsx +139 -80
  246. package/src/plugins/builtin/correlation/matrix/pair-chart.tsx +48 -0
  247. package/src/plugins/builtin/correlation/matrix/selection.ts +77 -0
  248. package/src/plugins/builtin/correlation/relationship/model.ts +2 -2
  249. package/src/plugins/builtin/cpi/client.ts +66 -0
  250. package/src/plugins/builtin/cpi/headless.ts +78 -0
  251. package/src/plugins/builtin/cpi/index.tsx +31 -0
  252. package/src/plugins/builtin/cpi/model.ts +198 -0
  253. package/src/plugins/builtin/cpi/pane.tsx +157 -0
  254. package/src/plugins/builtin/credit-documents/client.ts +99 -0
  255. package/src/plugins/builtin/credit-documents/detail.tsx +109 -0
  256. package/src/plugins/builtin/credit-documents/evidence.ts +64 -0
  257. package/src/plugins/builtin/credit-documents/gauge.tsx +55 -0
  258. package/src/plugins/builtin/credit-documents/headless.ts +40 -0
  259. package/src/plugins/builtin/credit-documents/index.tsx +19 -0
  260. package/src/plugins/builtin/credit-documents/model.ts +336 -0
  261. package/src/plugins/builtin/credit-documents/pane.tsx +185 -0
  262. package/src/plugins/builtin/custom-view/view-spec.ts +14 -2
  263. package/src/plugins/builtin/debt-maturities/pane.tsx +1 -0
  264. package/src/plugins/builtin/dividend-yield/pane.tsx +1 -1
  265. package/src/plugins/builtin/doe/client.ts +73 -0
  266. package/src/plugins/builtin/doe/headless.ts +93 -0
  267. package/src/plugins/builtin/doe/index.tsx +41 -0
  268. package/src/plugins/builtin/doe/model.ts +215 -0
  269. package/src/plugins/builtin/doe/pane.tsx +148 -0
  270. package/src/plugins/builtin/doe/range-bar.tsx +45 -0
  271. package/src/plugins/builtin/earnings/board.tsx +3 -0
  272. package/src/plugins/builtin/earnings/index.tsx +2 -0
  273. package/src/plugins/builtin/earnings-calls/pane.tsx +7 -1
  274. package/src/plugins/builtin/earnings-calls/transcript-view.tsx +7 -7
  275. package/src/plugins/builtin/earnings-ripple/client.ts +60 -0
  276. package/src/plugins/builtin/earnings-ripple/headless.ts +35 -0
  277. package/src/plugins/builtin/earnings-ripple/index.tsx +35 -0
  278. package/src/plugins/builtin/earnings-ripple/model.ts +98 -0
  279. package/src/plugins/builtin/earnings-ripple/pane.tsx +103 -0
  280. package/src/plugins/builtin/equity-screener/client.ts +1 -1
  281. package/src/plugins/builtin/equity-screener/criterion-editor.tsx +1 -1
  282. package/src/plugins/builtin/equity-screener/model.ts +74 -9
  283. package/src/plugins/builtin/equity-screener/pane.tsx +2 -0
  284. package/src/plugins/builtin/estimate-revisions/pane.tsx +3 -0
  285. package/src/plugins/builtin/executives/pane.tsx +7 -5
  286. package/src/plugins/builtin/exposure/charts.tsx +66 -0
  287. package/src/plugins/builtin/exposure/client.ts +53 -0
  288. package/src/plugins/builtin/exposure/drivers.ts +29 -0
  289. package/src/plugins/builtin/exposure/editor.tsx +61 -0
  290. package/src/plugins/builtin/exposure/evidence.ts +39 -0
  291. package/src/plugins/builtin/exposure/headless.ts +51 -0
  292. package/src/plugins/builtin/exposure/holdings.ts +56 -0
  293. package/src/plugins/builtin/exposure/index.tsx +13 -0
  294. package/src/plugins/builtin/exposure/model.ts +104 -0
  295. package/src/plugins/builtin/exposure/pane.tsx +247 -0
  296. package/src/plugins/builtin/fear-greed/charts.tsx +1 -1
  297. package/src/plugins/builtin/fear-greed/pane.tsx +2 -9
  298. package/src/plugins/builtin/filing-events/pane.tsx +2 -1
  299. package/src/plugins/builtin/gpu/board.tsx +163 -0
  300. package/src/plugins/builtin/gpu/changes.tsx +94 -0
  301. package/src/plugins/builtin/gpu/client.ts +130 -0
  302. package/src/plugins/builtin/gpu/equities.tsx +112 -0
  303. package/src/plugins/builtin/gpu/headless.ts +67 -0
  304. package/src/plugins/builtin/gpu/history.tsx +140 -0
  305. package/src/plugins/builtin/gpu/index.tsx +18 -0
  306. package/src/plugins/builtin/gpu/ladder.tsx +127 -0
  307. package/src/plugins/builtin/gpu/model.ts +317 -0
  308. package/src/plugins/builtin/gpu/pane.tsx +63 -0
  309. package/src/plugins/builtin/help/index.tsx +19 -2
  310. package/src/plugins/builtin/holders/pane.tsx +5 -9
  311. package/src/plugins/builtin/insider/detail.tsx +119 -0
  312. package/src/plugins/builtin/insider/display.ts +221 -0
  313. package/src/plugins/builtin/insider/headless.ts +24 -3
  314. package/src/plugins/builtin/insider/index.tsx +206 -108
  315. package/src/plugins/builtin/insider/insider-data.ts +31 -3
  316. package/src/plugins/builtin/insider/model.ts +53 -4
  317. package/src/plugins/builtin/insider/table-model.ts +226 -0
  318. package/src/plugins/builtin/insider/table.tsx +79 -0
  319. package/src/plugins/builtin/iv-history/screen-pane.tsx +1 -1
  320. package/src/plugins/builtin/jobs/pane.tsx +14 -7
  321. package/src/plugins/builtin/kelly-sizer/pane.tsx +1 -1
  322. package/src/plugins/builtin/macro-day/client.ts +50 -0
  323. package/src/plugins/builtin/macro-day/headless.ts +51 -0
  324. package/src/plugins/builtin/macro-day/index.tsx +21 -0
  325. package/src/plugins/builtin/macro-day/model.ts +137 -0
  326. package/src/plugins/builtin/macro-day/pane.tsx +118 -0
  327. package/src/plugins/builtin/macro-day/releases.ts +58 -0
  328. package/src/plugins/builtin/market-halts/model.ts +30 -17
  329. package/src/plugins/builtin/market-halts/pane.tsx +15 -21
  330. package/src/plugins/builtin/market-heatmap/data.ts +1 -1
  331. package/src/plugins/builtin/market-heatmap/index.tsx +198 -50
  332. package/src/plugins/builtin/market-heatmap/portfolio.ts +220 -0
  333. package/src/plugins/builtin/market-movers/index.tsx +1 -0
  334. package/src/plugins/builtin/market-movers/session-body.tsx +5 -2
  335. package/src/plugins/builtin/mna/distress/client.ts +326 -0
  336. package/src/plugins/builtin/mna/distress/detail.tsx +247 -0
  337. package/src/plugins/builtin/mna/distress/headless.ts +257 -0
  338. package/src/plugins/builtin/mna/distress/model.ts +427 -0
  339. package/src/plugins/builtin/mna/distress/pane.tsx +606 -0
  340. package/src/plugins/builtin/mna/index.tsx +15 -0
  341. package/src/plugins/builtin/mna/pane.tsx +42 -1
  342. package/src/plugins/builtin/news/index.tsx +62 -16
  343. package/src/plugins/builtin/news/wire/filter-articles.ts +54 -0
  344. package/src/plugins/builtin/news/wire/index.tsx +37 -3
  345. package/src/plugins/builtin/news/wire/industry-pane.tsx +29 -13
  346. package/src/plugins/builtin/news/wire/mutes.ts +253 -0
  347. package/src/plugins/builtin/news/wire/news/command-bar-search.ts +117 -0
  348. package/src/plugins/builtin/news/wire/news/footer.ts +4 -0
  349. package/src/plugins/builtin/news/wire/news/list-search.ts +34 -0
  350. package/src/plugins/builtin/news/wire/news/pop-out.tsx +158 -0
  351. package/src/plugins/builtin/news/wire/news/preset-pane.tsx +64 -19
  352. package/src/plugins/builtin/openfda/client.ts +300 -0
  353. package/src/plugins/builtin/openfda/index.tsx +71 -0
  354. package/src/plugins/builtin/openfda/pane.tsx +382 -0
  355. package/src/plugins/builtin/openfda/types.ts +76 -0
  356. package/src/plugins/builtin/options/footer.ts +1 -0
  357. package/src/plugins/builtin/options/view.tsx +1 -1
  358. package/src/plugins/builtin/options-calculator/pane.tsx +0 -1
  359. package/src/plugins/builtin/options-positioning/index.tsx +4 -2
  360. package/src/plugins/builtin/options-positioning/pane.tsx +1 -1
  361. package/src/plugins/builtin/pe-band/client.ts +61 -0
  362. package/src/plugins/builtin/pe-band/headless.ts +51 -0
  363. package/src/plugins/builtin/pe-band/index.tsx +20 -0
  364. package/src/plugins/builtin/pe-band/model.ts +267 -0
  365. package/src/plugins/builtin/pe-band/pane.tsx +159 -0
  366. package/src/plugins/builtin/perps/client.ts +66 -0
  367. package/src/plugins/builtin/perps/equity-row.tsx +28 -0
  368. package/src/plugins/builtin/perps/headless.ts +34 -0
  369. package/src/plugins/builtin/perps/index.tsx +14 -0
  370. package/src/plugins/builtin/perps/model.ts +58 -0
  371. package/src/plugins/builtin/perps/pane.tsx +185 -0
  372. package/src/plugins/builtin/plugin-marketplace/pane.tsx +0 -1
  373. package/src/plugins/builtin/portfolio-list/cli/render.ts +177 -87
  374. package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +6 -20
  375. package/src/plugins/builtin/portfolio-list/command-bar.ts +6 -2
  376. package/src/plugins/builtin/portfolio-list/headless.ts +237 -0
  377. package/src/plugins/builtin/portfolio-list/index.tsx +2 -0
  378. package/src/plugins/builtin/portfolio-list/mutations.ts +70 -1
  379. package/src/plugins/builtin/portfolio-list/pane/data.ts +17 -0
  380. package/src/plugins/builtin/portfolio-list/pane/index.tsx +88 -5
  381. package/src/plugins/builtin/portfolio-list/pane/remove-ticker.ts +85 -0
  382. package/src/plugins/builtin/portfolio-list/pane/streaming.ts +18 -12
  383. package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +6 -0
  384. package/src/plugins/builtin/power/client.ts +100 -0
  385. package/src/plugins/builtin/power/detail.tsx +82 -0
  386. package/src/plugins/builtin/power/evidence.ts +56 -0
  387. package/src/plugins/builtin/power/generation.tsx +37 -0
  388. package/src/plugins/builtin/power/headless.ts +43 -0
  389. package/src/plugins/builtin/power/index.tsx +16 -0
  390. package/src/plugins/builtin/power/model.ts +89 -0
  391. package/src/plugins/builtin/power/pane.tsx +209 -0
  392. package/src/plugins/builtin/power/query.ts +25 -0
  393. package/src/plugins/builtin/relative-rotation/pane.tsx +3 -3
  394. package/src/plugins/builtin/research/analyst-pane.tsx +1 -1
  395. package/src/plugins/builtin/research/corporate-actions-pane.tsx +13 -4
  396. package/src/plugins/builtin/research/equity-diagnostic-pane.tsx +11 -9
  397. package/src/plugins/builtin/research-search/pane.tsx +21 -7
  398. package/src/plugins/builtin/revenue-breakdown/pane.tsx +1 -1
  399. package/src/plugins/builtin/reverse-dcf/client.ts +35 -0
  400. package/src/plugins/builtin/reverse-dcf/headless.ts +44 -0
  401. package/src/plugins/builtin/reverse-dcf/index.tsx +20 -0
  402. package/src/plugins/builtin/reverse-dcf/model.ts +87 -0
  403. package/src/plugins/builtin/reverse-dcf/pane.tsx +107 -0
  404. package/src/plugins/builtin/risk-factors/pane.tsx +6 -5
  405. package/src/plugins/builtin/scanner/denied.tsx +4 -2
  406. package/src/plugins/builtin/scanner/feed.ts +1 -0
  407. package/src/plugins/builtin/scanner/flow-pane.tsx +3 -2
  408. package/src/plugins/builtin/scanner/hilo-pane.tsx +1 -1
  409. package/src/plugins/builtin/seasonality/client.ts +4 -1
  410. package/src/plugins/builtin/sec/command-bar-search.ts +217 -0
  411. package/src/plugins/builtin/sec/forms.ts +54 -0
  412. package/src/plugins/builtin/sec/headless.ts +31 -5
  413. package/src/plugins/builtin/sec/index.tsx +67 -11
  414. package/src/plugins/builtin/sec/model.ts +35 -5
  415. package/src/plugins/builtin/sectors/headless.ts +1 -0
  416. package/src/plugins/builtin/sectors/index.tsx +72 -26
  417. package/src/plugins/builtin/shared/cloud-upgrade.ts +143 -39
  418. package/src/plugins/builtin/shared/pro-feature-wall.tsx +8 -4
  419. package/src/plugins/builtin/shared/research-cells.tsx +107 -0
  420. package/src/plugins/builtin/shared/series-list-detail.tsx +5 -1
  421. package/src/plugins/builtin/shared/ticker-request.ts +1 -1
  422. package/src/plugins/builtin/shared/wall-teaser-catalog.ts +80 -0
  423. package/src/plugins/builtin/shared/wall-teaser.tsx +192 -0
  424. package/src/plugins/builtin/shared/wall-view-lifecycle.ts +43 -0
  425. package/src/plugins/builtin/short-interest/index.tsx +31 -0
  426. package/src/plugins/builtin/short-interest/watch-client.ts +70 -0
  427. package/src/plugins/builtin/short-interest/watch-headless.ts +49 -0
  428. package/src/plugins/builtin/short-interest/watch-model.ts +185 -0
  429. package/src/plugins/builtin/short-interest/watch-pane.tsx +169 -0
  430. package/src/plugins/builtin/short-volume/pane.tsx +1 -1
  431. package/src/plugins/builtin/social-mentions/pane.tsx +1 -1
  432. package/src/plugins/builtin/supply-chain/client.ts +104 -0
  433. package/src/plugins/builtin/supply-chain/disclosure-quote.tsx +17 -0
  434. package/src/plugins/builtin/supply-chain/evidence.ts +88 -0
  435. package/src/plugins/builtin/supply-chain/flow-layout.ts +133 -0
  436. package/src/plugins/builtin/supply-chain/flow.tsx +323 -0
  437. package/src/plugins/builtin/supply-chain/graph-client.ts +83 -0
  438. package/src/plugins/builtin/supply-chain/graph-evidence.ts +25 -0
  439. package/src/plugins/builtin/supply-chain/graph-model.ts +45 -0
  440. package/src/plugins/builtin/supply-chain/graph-pane.tsx +218 -0
  441. package/src/plugins/builtin/supply-chain/graph.tsx +163 -0
  442. package/src/plugins/builtin/supply-chain/headless.ts +105 -0
  443. package/src/plugins/builtin/supply-chain/index.tsx +17 -0
  444. package/src/plugins/builtin/supply-chain/model.ts +145 -0
  445. package/src/plugins/builtin/supply-chain/pane.tsx +276 -0
  446. package/src/plugins/builtin/supply-chain/row-evidence.tsx +96 -0
  447. package/src/plugins/builtin/supply-chain/trust.ts +34 -0
  448. package/src/plugins/builtin/themes/client.ts +39 -0
  449. package/src/plugins/builtin/themes/headless.ts +38 -0
  450. package/src/plugins/builtin/themes/model.ts +92 -0
  451. package/src/plugins/builtin/themes/pane.tsx +125 -0
  452. package/src/plugins/builtin/thirteenf/pane.tsx +6 -15
  453. package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +5 -6
  454. package/src/plugins/builtin/ticker-detail/data-panes/returns-model.ts +201 -0
  455. package/src/plugins/builtin/ticker-detail/data-panes/returns-pane.tsx +327 -0
  456. package/src/plugins/builtin/ticker-detail/financials/period-end-history.ts +5 -2
  457. package/src/plugins/builtin/ticker-detail/financials/ratios.ts +60 -12
  458. package/src/plugins/builtin/ticker-detail/financials/tab.tsx +2 -1
  459. package/src/plugins/builtin/ticker-detail/headless.ts +7 -2
  460. package/src/plugins/builtin/ticker-detail/index.tsx +22 -0
  461. package/src/plugins/builtin/ticker-detail/overview/components.tsx +53 -30
  462. package/src/plugins/builtin/ticker-detail/overview/pane.tsx +2 -0
  463. package/src/plugins/builtin/ticker-detail/overview-tab.tsx +112 -47
  464. package/src/plugins/builtin/ticker-detail/pane.tsx +50 -6
  465. package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +21 -42
  466. package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +3 -0
  467. package/src/plugins/builtin/time-sales/pane.tsx +1 -1
  468. package/src/plugins/builtin/world-indices/indices.ts +1 -0
  469. package/src/plugins/catalog-browser.ts +40 -0
  470. package/src/plugins/catalog-manifest.ts +3 -0
  471. package/src/plugins/catalog-ui.ts +6 -0
  472. package/src/plugins/current-target.ts +0 -9
  473. package/src/public/__snapshots__/public-api.test.ts.snap +1 -0
  474. package/src/renderers/browser/cloud-transport.ts +66 -1
  475. package/src/renderers/browser/main.tsx +2 -0
  476. package/src/renderers/dom/data-table/row.tsx +2 -0
  477. package/src/renderers/dom/desktop/controls.tsx +38 -25
  478. package/src/renderers/dom/desktop/icons.tsx +8 -0
  479. package/src/renderers/dom/host/chart-surface.tsx +36 -2
  480. package/src/renderers/dom/host/focus-scope.ts +11 -1
  481. package/src/renderers/dom/styles.css +28 -0
  482. package/src/renderers/electrobun/view/backend-rpc.ts +3 -2
  483. package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +1 -1
  484. package/src/renderers/electrobun/view/http-fetch.ts +2 -0
  485. package/src/renderers/electrobun/view/main.tsx +3 -1
  486. package/src/renderers/electrobun/view/rpc-timeout.ts +59 -0
  487. package/src/renderers/opentui/start.tsx +3 -0
  488. package/src/shares/api.ts +3 -1
  489. package/src/sources/gloomberb-cloud/index.ts +47 -13
  490. package/src/sources/history-result.ts +1 -0
  491. package/src/sources/history-retention.ts +16 -0
  492. package/src/sources/provider-router/history.ts +4 -2
  493. package/src/sources/sec-edgar/identity.ts +36 -0
  494. package/src/sources/sec-edgar.ts +1 -34
  495. package/src/state/app/context/index.tsx +8 -0
  496. package/src/sync/core-contributors.ts +20 -2
  497. package/src/telemetry/attention-counts.ts +164 -0
  498. package/src/telemetry/live-config.ts +7 -0
  499. package/src/test-support/rpc-loopback.ts +7 -3
  500. package/src/test-support/shell-pane-keys.tsx +34 -0
  501. package/src/tickers/instrument-kind.ts +12 -6
  502. package/src/tickers/open-target.ts +1 -1
  503. package/src/tickers/search/asset-classes.ts +91 -0
  504. package/src/tickers/search/index.ts +62 -15
  505. package/src/tickers/search/ranking.ts +22 -3
  506. package/src/tickers/search/upsert.ts +4 -1
  507. package/src/time-series/live-bars.ts +8 -3
  508. package/src/time-series/resolve.ts +224 -17
  509. package/src/time-series/spec.ts +1 -0
  510. package/src/time-series/types.ts +9 -1
  511. package/src/types/config.ts +23 -1
  512. package/src/types/data-provider.ts +2 -0
  513. package/src/types/headless.ts +17 -0
  514. package/src/types/price-history.ts +2 -0
  515. package/src/ui/host.tsx +6 -0
  516. package/src/utils/double-escape-close.ts +20 -0
  517. package/src/utils/exchanges.ts +1 -0
  518. package/src/utils/html-entities.ts +15 -0
  519. package/src/utils/http-proxy-response.ts +44 -7
  520. package/src/utils/plugin-proxy-hosts.json +3 -0
  521. package/src/utils/price-history.ts +35 -1
  522. package/src/utils/sec.ts +21 -2
  523. package/src/utils/text-wrap.ts +13 -8
  524. package/src/utils/zoned-date-time.ts +67 -0
@@ -0,0 +1,198 @@
1
+ import type { CpiBoardPayload, CpiReleaseStatus, CpiRow } from "../../../api-client/cpi";
2
+ import type { ChartStripSpec } from "../../../components/chart-table/header";
3
+ import { staticSeries } from "../../../components/chart/static/series";
4
+ import type { ResolvedSeries } from "../../../time-series/types";
5
+
6
+ /**
7
+ * The rows Gloom Cloud serves, by the ids its board uses, so `CPI shelter`
8
+ * can open on one before the board has loaded. Aliases are the names a trader
9
+ * types for them.
10
+ */
11
+ export const CPI_ROW_OPTIONS: ReadonlyArray<{ value: string; label: string; aliases?: readonly string[] }> = [
12
+ { value: "all-items", label: "All items", aliases: ["headline"] },
13
+ { value: "core", label: "Core", aliases: ["ex food and energy"] },
14
+ { value: "food", label: "Food" },
15
+ { value: "food-at-home", label: "Food at home", aliases: ["groceries"] },
16
+ { value: "food-away", label: "Food away from home", aliases: ["restaurants"] },
17
+ { value: "energy", label: "Energy" },
18
+ { value: "gasoline", label: "Gasoline" },
19
+ { value: "electricity", label: "Electricity" },
20
+ { value: "utility-gas", label: "Utility gas service", aliases: ["natural gas"] },
21
+ { value: "core-goods", label: "Core goods" },
22
+ { value: "new-vehicles", label: "New vehicles" },
23
+ { value: "used-vehicles", label: "Used cars and trucks", aliases: ["used cars"] },
24
+ { value: "apparel", label: "Apparel" },
25
+ { value: "medical-goods", label: "Medical care goods" },
26
+ { value: "core-services", label: "Core services" },
27
+ { value: "shelter", label: "Shelter" },
28
+ { value: "rent", label: "Rent" },
29
+ { value: "oer", label: "Owners' equivalent rent" },
30
+ { value: "lodging", label: "Lodging away from home", aliases: ["hotels"] },
31
+ { value: "services-ex-shelter", label: "Services ex shelter", aliases: ["supercore"] },
32
+ { value: "medical-services", label: "Medical care services" },
33
+ { value: "transportation-services", label: "Transportation services" },
34
+ { value: "auto-insurance", label: "Motor vehicle insurance", aliases: ["car insurance", "auto insurance"] },
35
+ { value: "airfares", label: "Airline fares", aliases: ["airfare"] },
36
+ { value: "recreation-services", label: "Recreation services" },
37
+ { value: "education-communication", label: "Education and communication" },
38
+ ];
39
+
40
+ const squash = (value: string) => value.toLowerCase().replace(/[^a-z0-9]/g, "");
41
+
42
+ /** A typed row: its id, its label or one of its aliases ("shelter", "OER", "supercore"). */
43
+ export function cpiRowOption(input: string | undefined) {
44
+ const typed = squash(input ?? "");
45
+ if (!typed) return null;
46
+ return CPI_ROW_OPTIONS.find((option) => [option.value, option.label, ...(option.aliases ?? [])]
47
+ .some((name) => squash(name) === typed)) ?? null;
48
+ }
49
+
50
+ export type CpiSortColumn = "weight" | "change" | "annualized3m" | "annualized6m" | "yoy" | "contribution" | "contributionYoy";
51
+ export interface CpiSort {
52
+ columnId: CpiSortColumn | null;
53
+ direction: "asc" | "desc";
54
+ }
55
+ /** The release's own order: the BLS hierarchy, groups before their parts. */
56
+ export const CPI_TABLE_ORDER: CpiSort = { columnId: null, direction: "desc" };
57
+ const SORT_COLUMNS = new Set<string>(["weight", "change", "annualized3m", "annualized6m", "yoy", "contribution", "contributionYoy"]);
58
+ export const isCpiSortColumn = (value: string): value is CpiSortColumn => SORT_COLUMNS.has(value);
59
+
60
+ /**
61
+ * All items and core first, as served; the rest in the BLS hierarchy, or by
62
+ * a column with empty values last, so "what moved the headline" is one sort.
63
+ */
64
+ export function cpiRows(payload: CpiBoardPayload, sort: CpiSort = CPI_TABLE_ORDER): CpiRow[] {
65
+ const pinned = payload.rows.filter((row) => row.pinned);
66
+ const rest = payload.rows.filter((row) => !row.pinned);
67
+ const column = sort.columnId;
68
+ if (!column) return [...pinned, ...rest];
69
+ const sign = sort.direction === "asc" ? 1 : -1;
70
+ const sorted = rest
71
+ .map((row, index) => ({ row, index }))
72
+ .sort((a, b) => {
73
+ const left = a.row[column], right = b.row[column];
74
+ if (left == null || right == null) return left == null ? (right == null ? a.index - b.index : 1) : -1;
75
+ return (left - right) * sign || a.index - b.index;
76
+ })
77
+ .map(({ row }) => row);
78
+ return [...pinned, ...sorted];
79
+ }
80
+
81
+ /**
82
+ * The row's name, indented under its group while the table is in the
83
+ * release's order. The indent is no-break spaces: table cells do not wrap, and
84
+ * on the desktop that also folds ordinary leading spaces away.
85
+ */
86
+ export function cpiRowLabel(row: CpiRow, hierarchy: boolean): string {
87
+ return hierarchy ? `${"\u00a0\u00a0".repeat(row.depth)}${row.label}` : row.label;
88
+ }
89
+
90
+ /** A change that rounds to zero reads 0.00, never -0.00. */
91
+ function signed(value: number, decimals: number): string {
92
+ const text = Math.abs(value).toFixed(decimals);
93
+ return `${Number(text) === 0 ? "" : value > 0 ? "+" : "-"}${text}`;
94
+ }
95
+
96
+ /** Percent changes as the pane shows them: two decimals, signed, no unit (the header names it). */
97
+ export const formatCpiChange = (value: number | null) => value == null ? "--" : signed(value, 2);
98
+ /** Contributions in percentage points, two decimals, signed. */
99
+ export const formatCpiPoints = (value: number | null) => value == null ? "--" : signed(value, 2);
100
+ /** Share of the basket, percent: one decimal. */
101
+ export const formatCpiWeight = (value: number | null) => value == null ? "--" : value.toFixed(1);
102
+
103
+ const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
104
+
105
+ /** "Aug 2026" from 2026-08. */
106
+ export function cpiMonth(period: string): string {
107
+ return `${MONTHS[Number(period.slice(5, 7)) - 1]} ${period.slice(0, 4)}`;
108
+ }
109
+
110
+ /** A release instant on BLS's own clock: "Wed Oct 14 08:30 ET". */
111
+ function releaseTime(iso: string): string {
112
+ const parts = Object.fromEntries(new Intl.DateTimeFormat("en-US", {
113
+ timeZone: "America/New_York", weekday: "short", month: "short", day: "numeric",
114
+ hour: "2-digit", minute: "2-digit", hourCycle: "h23",
115
+ }).formatToParts(new Date(iso)).map((part) => [part.type, part.value]));
116
+ return `${parts.weekday} ${parts.month} ${parts.day} ${parts.hour}:${parts.minute} ET`;
117
+ }
118
+
119
+ /**
120
+ * The month the data covers, when it came out and when the next release is
121
+ * due, on one line: "Aug 2026 · released Fri Sep 11 08:30 ET · next Wed Oct
122
+ * 14 08:30 ET". A release past its time and not in yet reads "due".
123
+ */
124
+ export function cpiHeaderLine(release: CpiReleaseStatus, now = Date.now()): string | undefined {
125
+ if (!release.period) return undefined;
126
+ const parts = [cpiMonth(release.period)];
127
+ if (release.releasedAt) parts.push(`released ${releaseTime(release.releasedAt)}`);
128
+ if (release.nextReleaseAt) parts.push(`${Date.parse(release.nextReleaseAt) <= now ? "due" : "next"} ${releaseTime(release.nextReleaseAt)}`);
129
+ return parts.join(" · ");
130
+ }
131
+
132
+ /** The first of the month a change is for, which the chart plots it on. */
133
+ export const cpiMonthDate = (period: string) => new Date(Date.UTC(Number(period.slice(0, 4)), Number(period.slice(5, 7)) - 1, 1));
134
+
135
+ /**
136
+ * The chart's x axis over a row's months: a tick at each January, labelled
137
+ * with its year, and the cursor read as a month ("Aug 2026") rather than a day.
138
+ */
139
+ export function cpiTimeAxis(history: CpiRow["history"]) {
140
+ const first = history[0]?.[0], last = history.at(-1)?.[0];
141
+ if (!first || !last || first === last) return null;
142
+ const start = cpiMonthDate(first).getTime(), end = cpiMonthDate(last).getTime();
143
+ const ratio = (time: number) => (time - start) / (end - start);
144
+ const ticks = [];
145
+ for (let year = Number(first.slice(0, 4)) + 1; year <= Number(last.slice(0, 4)); year++)
146
+ ticks.push({ label: String(year), ratio: ratio(Date.UTC(year, 0, 1)) });
147
+ return {
148
+ viewport: { start: new Date(start), end: new Date(end) },
149
+ xAxis: {
150
+ ticks,
151
+ formatCursor: (xRatio: number) => {
152
+ const at = new Date(start + Math.min(1, Math.max(0, xRatio)) * (end - start) + 15 * 86_400_000);
153
+ return cpiMonth(at.toISOString().slice(0, 7));
154
+ },
155
+ },
156
+ };
157
+ }
158
+
159
+ export interface CpiChartColors {
160
+ positive: string;
161
+ negative: string;
162
+ warning: string;
163
+ textDim: string;
164
+ }
165
+
166
+ const MONTH_UNIT = { unit: "%", unitGroup: "cpi-month" } as const;
167
+ const YEAR_UNIT = { unit: "%", unitGroup: "cpi-year" } as const;
168
+
169
+ /**
170
+ * The selected row's monthly changes as columns on the left axis and its
171
+ * year-over-year change as a line on the right, with the headline's
172
+ * year-over-year line for reference (left out on the headline itself).
173
+ */
174
+ export function cpiChartSeries(row: CpiRow, headline: CpiRow | null, colors: CpiChartColors): ResolvedSeries[] {
175
+ const points = (history: CpiRow["history"], pick: 1 | 2) => history.flatMap(([period, ...values]) => {
176
+ const value = values[pick - 1];
177
+ if (value == null) return [];
178
+ const date = cpiMonthDate(period);
179
+ return [{ date, observedAt: date, value }];
180
+ });
181
+ const series: ResolvedSeries[] = [
182
+ { ...staticSeries(points(row.history, 1), { id: "month", label: `${row.label} m/m`, color: colors.positive,
183
+ negativeColor: colors.negative, style: "columns", calendarSpaced: true }), ...MONTH_UNIT, axis: "left" },
184
+ { ...staticSeries(points(row.history, 2), { id: "year", label: `${row.label} y/y`, color: colors.warning, calendarSpaced: true }),
185
+ ...YEAR_UNIT, axis: "right" },
186
+ ];
187
+ if (headline && headline.id !== row.id)
188
+ series.push({ ...staticSeries(points(headline.history, 2), { id: "headline", label: `${headline.label} y/y`, color: colors.textDim,
189
+ calendarSpaced: true }), ...YEAR_UNIT, axis: "right" });
190
+ return series.filter((entry) => entry.points.length > 0);
191
+ }
192
+
193
+ /** One row for a short pane: the row's year-over-year line and its latest value. */
194
+ export function cpiChartStrip(row: CpiRow, color: string): ChartStripSpec | null {
195
+ const values = row.history.flatMap(([, , yoy]) => (yoy == null ? [] : [yoy]));
196
+ if (values.length < 2 || row.yoy == null) return null;
197
+ return { label: `${row.label} y/y`, values, value: `${row.yoy.toFixed(2)}%`, color };
198
+ }
@@ -0,0 +1,157 @@
1
+ import { useCallback, useMemo } from "react";
2
+ import type { CpiBoardPayload, CpiRow } from "../../../api-client/cpi";
3
+ import {
4
+ ChartTableHeader,
5
+ CompositeChart,
6
+ DataTableView,
7
+ formatPercentAxis,
8
+ PaneStatusBody,
9
+ QueryBar,
10
+ usePaneNoticeFooter,
11
+ usePaneStatusFooter,
12
+ type ChartTableChart,
13
+ type DataTableColumn,
14
+ } from "../../../components";
15
+ import { usePaneRefreshKey } from "../../../components/data-table/table-pane";
16
+ import { useAsyncResource, useAutoRefresh, usePluginPaneState } from "../../../public/react";
17
+ import { usePaneInstance } from "../../../state/app/context";
18
+ import { priceColor } from "../../../theme/colors";
19
+ import { useThemeColors } from "../../../theme/theme-context";
20
+ import type { ResolvedSeries } from "../../../time-series/types";
21
+ import type { PaneProps } from "../../../types/plugin";
22
+ import { Box, Text, TextAttributes } from "../../../ui";
23
+ import { truncateToDisplayWidth } from "../../../utils/format";
24
+ import { nextHeaderSort } from "../../../utils/sort-values";
25
+ import { CPI_NOT_AVAILABLE, getCachedCpiBoard, loadCpiBoard } from "./client";
26
+ import {
27
+ CPI_TABLE_ORDER,
28
+ cpiChartSeries,
29
+ cpiChartStrip,
30
+ cpiHeaderLine,
31
+ cpiMonthDate,
32
+ cpiRowLabel,
33
+ cpiRows,
34
+ cpiTimeAxis,
35
+ formatCpiChange,
36
+ formatCpiPoints,
37
+ formatCpiWeight,
38
+ isCpiSortColumn,
39
+ type CpiSort,
40
+ } from "./model";
41
+
42
+ // The figures share the width a wide pane adds with the names, so they do not
43
+ // huddle at the right edge; in the terminal the name column takes it all.
44
+ const COLUMNS: DataTableColumn[] = [
45
+ { id: "name", label: "Component", width: 22, align: "left", flexGrow: 4 },
46
+ { id: "weight", label: "Wgt", width: 6, align: "right", flexGrow: 1 },
47
+ { id: "change", label: "M/M", width: 7, align: "right", flexGrow: 1 },
48
+ { id: "annualized3m", label: "3M Ann", width: 7, align: "right", flexGrow: 1 },
49
+ { id: "annualized6m", label: "6M Ann", width: 7, align: "right", flexGrow: 1 },
50
+ { id: "yoy", label: "Y/Y", width: 7, align: "right", flexGrow: 1 },
51
+ { id: "contribution", label: "M/M Pts", width: 8, align: "right", flexGrow: 1 },
52
+ { id: "contributionYoy", label: "Y/Y Pts", width: 8, align: "right", flexGrow: 1 },
53
+ ];
54
+ const PANELS = [{ id: "main" }];
55
+ /** Legend, four plot rows, the time axis and the read under it. */
56
+ const CHART_MIN_ROWS = 7;
57
+
58
+ /** Legend values in the table's units: changes in percent. */
59
+ const legendValue = (value: number) => `${value.toFixed(2)}%`;
60
+
61
+ /**
62
+ * The selected row's monthly changes as columns and its year over year as a
63
+ * line, with the headline's year over year for reference. The cursor rests on
64
+ * the latest month so the legend reads it; the plain read sits under the axis.
65
+ */
66
+ function CpiChart({ row, series, width, height }: { row: CpiRow; series: ResolvedSeries[]; width: number; height: number }) {
67
+ const colors = useThemeColors();
68
+ const latest = row.history.at(-1)?.[0] ?? null;
69
+ const axis = useMemo(() => cpiTimeAxis(row.history), [row.history]);
70
+ const read = row.read ? truncateToDisplayWidth(row.read, Math.max(0, width - 2)) : "";
71
+ return (
72
+ <Box width={width} height={height} flexDirection="column">
73
+ <CompositeChart series={series} panels={PANELS} width={width} height={Math.max(3, height - (read ? 1 : 0))}
74
+ focused={false} navigable={false} showLegend showTimeAxis cursorDate={latest ? cpiMonthDate(latest) : null}
75
+ viewport={axis?.viewport} xAxis={axis?.xAxis} clipToViewport={!!axis}
76
+ formatValue={legendValue} formatAxisValue={formatPercentAxis} remoteKind="cpi-component-history" />
77
+ {read ? <Box height={1} paddingX={1}><Text fg={colors.textMuted}>{read}</Text></Box> : null}
78
+ </Box>
79
+ );
80
+ }
81
+
82
+ function CpiBoard({ payload, initialRow, width, height, focused }: {
83
+ payload: CpiBoardPayload; initialRow: string | null; width: number; height: number; focused: boolean;
84
+ }) {
85
+ const colors = useThemeColors();
86
+ const [sort, setSort] = usePluginPaneState<CpiSort>("sort", CPI_TABLE_ORDER);
87
+ const rows = useMemo(() => cpiRows(payload, sort), [payload, sort]);
88
+ const hierarchy = sort.columnId == null;
89
+ const [selectedId, setSelectedId] = usePluginPaneState<string | null>("selected", initialRow);
90
+ const selected = rows.find((row) => row.id === selectedId) ?? rows[0] ?? null;
91
+ const headline = payload.rows.find((row) => row.code === "SA0") ?? null;
92
+ const series = useMemo(() => selected ? cpiChartSeries(selected, headline, colors) : [], [selected, headline, colors]);
93
+ const meta = cpiHeaderLine(payload.release);
94
+ const chart: ChartTableChart | null = selected ? {
95
+ render: (size) => <CpiChart row={selected} series={series} width={size.width} height={size.height} />,
96
+ minRows: CHART_MIN_ROWS,
97
+ strip: cpiChartStrip(selected, colors.warning),
98
+ empty: series.length ? undefined : `No history for ${selected.label}`,
99
+ } : null;
100
+ // A header click sorts largest first, then smallest, then back to the release's order.
101
+ const onHeaderClick = useCallback((columnId: string) => setSort((current) => (isCpiSortColumn(columnId)
102
+ ? nextHeaderSort(current, columnId, { firstDirection: "desc", resetTo: CPI_TABLE_ORDER })
103
+ : CPI_TABLE_ORDER)), [setSort]);
104
+ const signedCell = (value: number | null, text: string) => ({
105
+ text, value, color: value == null || Number(text) === 0 ? colors.textDim : priceColor(value, colors),
106
+ });
107
+ return (
108
+ <DataTableView<CpiRow> columns={COLUMNS} items={rows} focused={focused} rootWidth={width} rootHeight={height}
109
+ rootBefore={<ChartTableHeader width={width} height={height} tableRows={rows.length} tableColumns={COLUMNS}
110
+ query={meta ? <QueryBar width={width} meta={meta} /> : undefined} chart={chart} />}
111
+ selection={{ kind: "id", selectedId: selected?.id ?? null, getId: (row) => row.id, onChange: setSelectedId }}
112
+ onActivate={(row) => setSelectedId(row.id)} getItemKey={(row) => row.id}
113
+ sortColumnId={sort.columnId} sortDirection={sort.direction} onHeaderClick={onHeaderClick}
114
+ onSortChange={(columnId, direction) => setSort(isCpiSortColumn(columnId) ? { columnId, direction } : CPI_TABLE_ORDER)}
115
+ isColumnSortable={(column) => column.id !== "name"}
116
+ resetScrollKey={`${sort.columnId}:${sort.direction}`}
117
+ selectedTextOverridesCellColor
118
+ renderCell={(row, column) => {
119
+ switch (column.id) {
120
+ case "name":
121
+ return { text: cpiRowLabel(row, hierarchy), value: row.label,
122
+ color: row.pinned || (hierarchy && row.depth === 0) ? colors.textBright : colors.text,
123
+ attributes: row.pinned ? TextAttributes.BOLD : undefined };
124
+ case "weight": return { text: formatCpiWeight(row.weight), value: row.weight, color: colors.textMuted };
125
+ case "change": return signedCell(row.change, formatCpiChange(row.change));
126
+ case "annualized3m": return signedCell(row.annualized3m, formatCpiChange(row.annualized3m));
127
+ case "annualized6m": return signedCell(row.annualized6m, formatCpiChange(row.annualized6m));
128
+ case "yoy": return signedCell(row.yoy, formatCpiChange(row.yoy));
129
+ case "contribution": return signedCell(row.contribution, formatCpiPoints(row.contribution));
130
+ default: return signedCell(row.contributionYoy, formatCpiPoints(row.contributionYoy));
131
+ }
132
+ }}
133
+ emptyStateTitle="No components in this release yet." />
134
+ );
135
+ }
136
+
137
+ export function CpiPane({ width, height, focused }: PaneProps) {
138
+ const initialRow = usePaneInstance()?.params?.row ?? null;
139
+ const resource = useAsyncResource(loadCpiBoard, { initialData: getCachedCpiBoard });
140
+ const data = resource.data?.payload ?? null;
141
+ // The server not serving the board yet is a state of the data, not a failure.
142
+ const notAvailable = !data && resource.error === CPI_NOT_AVAILABLE;
143
+ useAutoRefresh(resource.updatedAt, resource.load);
144
+ usePaneRefreshKey(() => void resource.reload(), { focused });
145
+ usePaneNoticeFooter({ registrationId: "cpi:notices", focused,
146
+ notices: [...(data?.gaps ?? []), ...(resource.data?.refreshError ? [resource.data.refreshError] : [])] });
147
+ usePaneStatusFooter({ registrationId: "cpi", loading: resource.loading, error: notAvailable ? null : resource.error,
148
+ stale: !!data && resource.data?.stale });
149
+ return (
150
+ <Box width={width} height={height} flexDirection="column">
151
+ <PaneStatusBody loading={resource.loading && !data} error={!data && !notAvailable ? resource.error : null}
152
+ empty={notAvailable} emptyTitle={CPI_NOT_AVAILABLE} subject="US consumer prices">
153
+ {data ? <CpiBoard payload={data} initialRow={initialRow} width={width} height={height} focused={focused} /> : null}
154
+ </PaneStatusBody>
155
+ </Box>
156
+ );
157
+ }
@@ -0,0 +1,99 @@
1
+ import { isUsListingExchange, parsePublicTickerKey } from "../../../utils/exchanges";
2
+ import { apiClient } from "../../../api-client";
3
+ import type { CreditDocumentsPayload, CreditFact, CreditInstrument, CreditScreenPayload, CreditScreenQuery } from "../../../api-client/credit-documents";
4
+ import { createPluginCache } from "../../../data/plugin-cache";
5
+ import { cachedCloudResource, loadCloudResource, unavailableOnServer } from "../shared/cloud-resource";
6
+
7
+ /** SEC issuer symbols omit US listing qualifiers; foreign venue identity stays intact. */
8
+ export const creditIssuerSymbol = (symbol: string) => {
9
+ const parsed = parsePublicTickerKey(symbol.trim().toUpperCase());
10
+ return parsed.exchange && isUsListingExchange(parsed.exchange) ? parsed.symbol : symbol.trim().toUpperCase();
11
+ };
12
+ export const CREDIT_UNAVAILABLE = "Credit documents are not available for this issuer yet.";
13
+ export const creditCache = createPluginCache<CreditDocumentsPayload>({
14
+ kind: "credit-documents", source: "gloom-cloud", schemaVersion: 1,
15
+ policy: { staleMs: 60 * 60_000, expireMs: 7 * 86_400_000 },
16
+ });
17
+ const text = (value: unknown): value is string => typeof value === "string";
18
+ const finite = (value: unknown): value is number => typeof value === "number" && Number.isFinite(value);
19
+ const nullableNumber = (value: unknown) => value === null || finite(value);
20
+ const amount = (value: unknown) => value === null || (finite(value) && value >= 0);
21
+ const currency = (value: unknown) => value === null || (text(value) && /^[A-Z]{3}$/.test(value));
22
+ const day = (value: unknown): value is string => text(value) && /^\d{4}-\d{2}-\d{2}$/.test(value) && Number.isFinite(Date.parse(value)) && new Date(value).toISOString().slice(0, 10) === value;
23
+ const nullableDay = (value: unknown) => value === null || day(value);
24
+ const strings = (value: unknown): value is string[] => Array.isArray(value) && value.every(text);
25
+ const url = (value: unknown) => { try { return text(value) && ["https:", "http:"].includes(new URL(value).protocol); } catch { return false; } };
26
+ const unique = (rows: readonly { id: string }[]) => new Set(rows.map((row) => row.id)).size === rows.length;
27
+ function fact(row: CreditFact): boolean {
28
+ return !!row && [row.id, row.instrumentId, row.documentId, row.field, row.instrumentName, row.factKey, row.form, row.language].every(text)
29
+ && row.value !== undefined && day(row.asOf) && day(row.filedAt) && nullableDay(row.periodEnd)
30
+ && (row.effectiveDate === undefined || nullableDay(row.effectiveDate))
31
+ && currency(row.currency) && (row.unit === null || text(row.unit))
32
+ && finite(row.confidence) && row.confidence >= 0 && row.confidence <= 1
33
+ && text(row.quote) && row.quote.trim().length > 0 && url(row.filingUrl)
34
+ && Number.isInteger(row.quoteOffset) && row.quoteOffset >= 0 && Number.isInteger(row.quoteSourceLength) && row.quoteSourceLength > 0
35
+ && ["exact", "whitespace", "nfkc_whitespace"].includes(row.quoteMatchMode)
36
+ && ["active", "superseded", "pending"].includes(row.status) && (row.supersedesId === null || text(row.supersedesId));
37
+ }
38
+ export function validateCreditInstrument(row: CreditInstrument): CreditInstrument {
39
+ if (!row || ![row.id, row.key, row.name].every(text) || !currency(row.currency)
40
+ || (row.lifecycle !== undefined && row.lifecycle !== null && !text(row.lifecycle))
41
+ || (row.facilityType !== null && !text(row.facilityType)) || ![row.principal, row.commitment, row.drawn].every(amount)
42
+ || !nullableDay(row.maturity) || !Array.isArray(row.facts) || !row.facts.every(fact) || !unique(row.facts)
43
+ || row.facts.some((entry) => entry.instrumentId !== row.id || entry.status !== "active")
44
+ || (row.history !== undefined && (!Array.isArray(row.history) || !row.history.every(fact) || !unique(row.history) || row.history.some((entry) => entry.instrumentId !== row.id)))) {
45
+ throw new Error("The server returned unreadable credit instrument evidence");
46
+ }
47
+ return row;
48
+ }
49
+ export function validateCreditDocuments(data: CreditDocumentsPayload, symbol?: string): CreditDocumentsPayload {
50
+ const invalid = (): never => { throw new Error("The server returned unreadable credit documents"); };
51
+ if (!data || data.version !== 1 || !text(data.symbol) || (symbol && data.symbol !== symbol)
52
+ || !["available", "partial", "unavailable"].includes(data.status) || !nullableDay(data.asOf)
53
+ || !["full", "preview"].includes(data.access) || !Number.isInteger(data.lockedRows) || data.lockedRows < 0
54
+ || !(data.issuer === null || (data.issuer && [data.issuer.id, data.issuer.name, data.issuer.jurisdiction].every(text)))
55
+ || !strings(data.warnings) || !Array.isArray(data.instruments) || !unique(data.instruments)
56
+ || !Array.isArray(data.covenants) || !Array.isArray(data.maturities) || !Array.isArray(data.changeOfControl)) return invalid();
57
+ data.instruments.forEach(validateCreditInstrument);
58
+ const factOwners = new Map(data.instruments.flatMap((row) => row.facts.map((entry) => [entry.id, row.id] as const)));
59
+ const supported = (ids: unknown, instrumentId: string) => strings(ids) && ids.length > 0 && ids.every((id) => factOwners.get(id) === instrumentId);
60
+ for (const row of data.covenants) {
61
+ if (!row || ![row.id, row.instrumentId, row.instrumentName, row.metric].every(text) || !finite(row.threshold)
62
+ || !["maximum", "minimum"].includes(row.comparator) || (row.inclusive !== undefined && typeof row.inclusive !== "boolean") || ![row.current, row.headroomPercent].every(nullableNumber)
63
+ || !nullableDay(row.testDate) || !day(row.asOf) || !["compliant", "breach", "uncomputable", "stale", "conditional"].includes(row.status)
64
+ || (row.reason !== null && !text(row.reason)) || !supported(row.evidenceIds, row.instrumentId)
65
+ || (["uncomputable", "stale", "conditional"].includes(row.status) && row.headroomPercent !== null)) return invalid();
66
+ }
67
+ for (const row of data.maturities) if (!row || !Number.isInteger(row.year) || row.year < 1900 || row.year > 2300
68
+ || !currency(row.currency) || row.currency === null || !finite(row.principal) || row.principal < 0
69
+ || !Array.isArray(row.instruments) || row.instruments.some((entry) => !entry || !text(entry.id) || !text(entry.name) || !finite(entry.principal) || entry.principal < 0 || !supported(entry.evidenceIds, entry.id))) return invalid();
70
+ for (const row of data.changeOfControl) if (!row || !text(row.instrumentId) || !text(row.instrumentName) || !currency(row.currency)
71
+ || !amount(row.principal) || !text(row.trigger) || !amount(row.putPercent) || !supported(row.evidenceIds, row.instrumentId)) return invalid();
72
+ return data;
73
+ }
74
+ export function validateCreditScreen(data: CreditScreenPayload): CreditScreenPayload {
75
+ if (!data || !["full", "preview"].includes(data.access) || !Number.isInteger(data.lockedRows) || data.lockedRows < 0
76
+ || !text(data.asOf) || !Number.isFinite(Date.parse(data.asOf)) || typeof data.truncated !== "boolean" || !Array.isArray(data.rows) || data.rows.some((row) => !row
77
+ || ![row.symbol, row.issuerName, row.instrumentId, row.instrumentName, row.reason].every(text)
78
+ || !["headroom", "springing_maturity"].includes(row.kind) || !nullableNumber(row.value) || !nullableDay(row.date) || !currency(row.currency)
79
+ || !Array.isArray(row.evidence) || !row.evidence.length || !row.evidence.every((entry) => fact(entry) && entry.status === "active" && entry.instrumentId === row.instrumentId))) throw new Error("The server returned unreadable credit screening results");
80
+ return data;
81
+ }
82
+ export async function fetchCreditDocuments(symbol: string, client: Pick<typeof apiClient, "creditDocuments"> = apiClient) {
83
+ try { const issuer = creditIssuerSymbol(symbol); return validateCreditDocuments(await client.creditDocuments<CreditDocumentsPayload>(encodeURIComponent(issuer)), issuer); }
84
+ catch (error) { throw unavailableOnServer(error, CREDIT_UNAVAILABLE, [404, 503]); }
85
+ }
86
+ export async function fetchCreditInstrument(symbol: string, id: string, client: Pick<typeof apiClient, "creditDocuments"> = apiClient) {
87
+ const data = validateCreditInstrument(await client.creditDocuments<CreditInstrument>(`${encodeURIComponent(creditIssuerSymbol(symbol))}/instruments/${encodeURIComponent(id)}`));
88
+ if (data.id !== id) throw new Error("The server returned evidence for a different credit instrument");
89
+ return data;
90
+ }
91
+ export async function fetchCreditScreen(query: CreditScreenQuery = {}, client: Pick<typeof apiClient, "creditDocuments"> = apiClient) {
92
+ const params = new URLSearchParams();
93
+ for (const [key,value] of Object.entries(query)) if (value !== undefined) params.set(key,String(value));
94
+ return validateCreditScreen(await client.creditDocuments<CreditScreenPayload>(`screen?${params}`));
95
+ }
96
+ // Private credit evidence must never survive an account or entitlement change.
97
+ const key = (symbol: string, access: string) => `${symbol.toUpperCase()}:${access}`;
98
+ export const cachedCredit = (symbol: string, access: string) => cachedCloudResource(creditCache, key(symbol, access), (data) => validateCreditDocuments(data, creditIssuerSymbol(symbol)));
99
+ export const loadCredit = (symbol: string, access: string, force = false) => loadCloudResource(creditCache, key(symbol, access), () => fetchCreditDocuments(symbol), { force, validate: (data) => validateCreditDocuments(data, creditIssuerSymbol(symbol)) });
@@ -0,0 +1,109 @@
1
+ import { useCallback, useMemo, useRef, type ReactNode, type RefObject } from "react";
2
+ import type { CreditFact, CreditHeadroom, CreditInstrument } from "../../../api-client/credit-documents";
3
+ import { Button, ChartTableHeader, DataTableStackView, DetailScrollBody, ExternalLinkText, KeyValueRow, Notice, PaneStatusBody, QueryBar, Section, usePaneStatusFooter, type StatItem } from "../../../components";
4
+ import { useAsyncResource, usePluginPaneState } from "../../../public/react";
5
+ import { useThemeColors } from "../../../theme/theme-context";
6
+ import { Box, Text, TextAttributes, useRendererHost, useUiCapabilities, type ScrollBoxRenderable } from "../../../ui";
7
+ import { fetchCreditInstrument } from "./client";
8
+ import { comparatorSymbol, covenantNumber, covenantTerms, creditPercent, factColumns, factValue, fieldLabel, hasAmendments, headroomTone, NO_VALUE, sentence, structuredFields } from "./model";
9
+
10
+ const LABEL_WIDTH = 16;
11
+ const MATCH = { exact: "Exact", whitespace: "Whitespace normalized", nfkc_whitespace: "Unicode and whitespace normalized" } as Record<string, string>;
12
+
13
+ /** The verbatim filing text, set apart from the metadata by a rule; never reflowed or restyled. */
14
+ function Quote({ text, width }: { text: string; width: number }) {
15
+ const colors = useThemeColors(), desktop = useUiCapabilities().nativePaneChrome === true;
16
+ return <Box paddingLeft={1} border={desktop ? undefined : ["left"]} borderColor={colors.borderFocused}
17
+ style={desktop ? { borderLeft: `2px solid ${colors.borderFocused}`, paddingLeft: "calc(1.5 * var(--cell-w))" } : undefined} data-gloom-role="credit-quote">
18
+ <Text width={Math.max(1, width - 2)} wrapMode="word" wrapText fg={colors.textBright}>{text}</Text>
19
+ </Box>;
20
+ }
21
+ function LabeledRow({ label, children }: { label: string; children: ReactNode }) {
22
+ const colors = useThemeColors();
23
+ return <Box height={1} flexDirection="row" overflow="hidden">
24
+ <Box width={LABEL_WIDTH} flexShrink={0}><Text fg={colors.textDim}>{label}</Text></Box>
25
+ {children}
26
+ </Box>;
27
+ }
28
+ function CreditFactEvidence({ fact, width, scrollRef }: { fact: CreditFact; width: number; scrollRef: RefObject<ScrollBoxRenderable | null> }) {
29
+ const colors = useThemeColors(), host = useRendererHost();
30
+ const inner = Math.max(1, width - 2);
31
+ const terms = covenantTerms(fact), structured = terms ? null : structuredFields(fact);
32
+ const rows = terms?.fields ?? structured ?? [{ label: "Value", value: factValue(fact) }];
33
+ return <DetailScrollBody ref={scrollRef} resetScrollKey={fact.id}>
34
+ {rows.map((row) => <KeyValueRow key={row.label} label={row.label} value={row.value} detail={row.detail} labelWidth={LABEL_WIDTH}
35
+ tone={row.value === NO_VALUE || row.value === "Not computable" ? "muted" : undefined} />)}
36
+ {terms?.reason ? <Box paddingLeft={LABEL_WIDTH} width={inner}><Notice tone="muted">{terms.reason}</Notice></Box> : null}
37
+ {terms?.definition ? <Section title="Definition"><Text width={inner} wrapMode="word" wrapText fg={colors.text}>{terms.definition}</Text></Section> : null}
38
+ <Section title="Filing text"><Quote text={fact.quote} width={inner} /></Section>
39
+ <Section title="Source">
40
+ <LabeledRow label="Filing">
41
+ <Text fg={colors.text} attributes={TextAttributes.BOLD}>{`${fact.form} · filed ${fact.filedAt}`}</Text>
42
+ <Text fg={colors.textDim}>{" "}</Text>
43
+ <ExternalLinkText url={fact.filingUrl} label="Open filing" color={colors.borderFocused} onOpen={(url) => void host.openExternal(url)} />
44
+ </LabeledRow>
45
+ <KeyValueRow label="Period" value={fact.asOf} detail={fact.periodEnd && fact.periodEnd !== fact.asOf ? `period end ${fact.periodEnd}` : undefined} labelWidth={LABEL_WIDTH} />
46
+ {fact.effectiveDate && fact.effectiveDate !== fact.asOf && fact.effectiveDate !== fact.filedAt ? <KeyValueRow label="Effective" value={fact.effectiveDate} labelWidth={LABEL_WIDTH} tone={fact.status === "pending" ? "warning" : undefined} /> : null}
47
+ <KeyValueRow label="Revision" value={fieldLabel(fact.status)} detail={fact.status === "pending" ? "Not yet in effect" : fact.supersedesId ? "Supersedes earlier disclosure" : "Original observation"} labelWidth={LABEL_WIDTH} tone={fact.status === "pending" ? "warning" : undefined} />
48
+ <KeyValueRow label="Confidence" value={`${Math.round(fact.confidence * 100)}%`} labelWidth={LABEL_WIDTH} />
49
+ <KeyValueRow label="Text match" value={MATCH[fact.quoteMatchMode] ?? fieldLabel(fact.quoteMatchMode)} detail={`chars ${fact.quoteOffset}–${fact.quoteOffset + fact.quoteSourceLength} · ${fact.language}`} labelWidth={LABEL_WIDTH} />
50
+ </Section>
51
+ </DetailScrollBody>;
52
+ }
53
+ /** The covenant the detail was opened from: which test, where it stands, most important first so a short pane keeps the lead. */
54
+ function covenantFigures(covenant: CreditHeadroom, fact: CreditFact | undefined): StatItem[] {
55
+ return [
56
+ { id: "covenant", label: "Covenant", value: sentence(covenant.metric), wide: true },
57
+ { id: "headroom", label: "Headroom", value: creditPercent(covenant.headroomPercent), tone: headroomTone(covenant) ?? (covenant.headroomPercent === null ? "muted" : undefined) },
58
+ { id: "limit", label: "Limit", value: `${comparatorSymbol(covenant.comparator, covenant.inclusive)} ${covenantNumber(covenant.threshold, fact)}` },
59
+ { id: "reported", label: "Reported", value: covenantNumber(covenant.current, fact), tone: covenant.current === null ? "muted" : undefined, detail: covenant.current === null ? undefined : covenant.asOf },
60
+ { id: "status", label: "Status", value: fieldLabel(covenant.status), tone: covenant.status === "breach" ? "negative" : "muted" },
61
+ ];
62
+ }
63
+ export function CreditInstrumentDetail({ symbol, instrument, width, height, focused, accessKey, view, setView, covenant, captured, pro, onUpgrade, openId, setOpen }: {
64
+ openId: string | null; setOpen: (id: string | null) => void;
65
+ symbol: string; instrument: CreditInstrument; width: number; height: number; focused: boolean; accessKey: string;
66
+ view: string; setView: (view: string) => void; covenant?: CreditHeadroom | null; captured?: CreditInstrument | null; pro: boolean; onUpgrade: () => void;
67
+ }) {
68
+ const colors = useThemeColors(), host = useRendererHost();
69
+ const detailScrollRef = useRef<ScrollBoxRenderable | null>(null);
70
+ const loader = useCallback(() => captured ? Promise.resolve(captured) : fetchCreditInstrument(symbol, instrument.id), [symbol, instrument.id, accessKey, captured]);
71
+ const resource = useAsyncResource(loader, { initialData: () => captured ?? instrument });
72
+ const data = resource.data ?? instrument;
73
+ const [selectedId, setSelected] = usePluginPaneState<string | null>(`credit:fact:selected:${instrument.id}:${view}`, null);
74
+ const amended = hasAmendments(data);
75
+ const rows = useMemo(() => view === "history" ? amended ? [...data.history!].sort((a, b) => b.filedAt.localeCompare(a.filedAt) || a.field.localeCompare(b.field)) : []
76
+ : [...data.facts].sort((a, b) => a.field.localeCompare(b.field) || a.factKey.localeCompare(b.factKey)), [data, view, amended]);
77
+ // Opened from a covenant, the cursor starts on that covenant's terms.
78
+ const selected = rows.find((row) => row.id === selectedId) ?? rows.find((row) => row.id === covenant?.id) ?? rows[0] ?? null;
79
+ const open = rows.find((row) => row.id === openId) ?? null;
80
+ usePaneStatusFooter({ registrationId: "credit:instrument", loading: resource.loading, error: resource.error,
81
+ hints: selected ? [{ id: "credit:open-source", key: "o", label: "pen filing", onPress: () => void host.openExternal((open ?? selected).filingUrl) }] : [] });
82
+ const columns = useMemo(() => factColumns(view, width), [view, width]);
83
+ const query = <QueryBar width={width} view={{ value: view, options: [{ value: "terms", label: "Current terms" }, { value: "history", label: "Amendment history" }], onChange: (value) => { setView(value); setOpen(null); } }} />;
84
+ // Why headroom is missing stays beside the figures it explains.
85
+ const reason = covenant?.reason && covenant.status !== "compliant" && covenant.status !== "breach" ? covenant.reason : null;
86
+ const header = covenant ? <Box flexDirection="column">
87
+ <ChartTableHeader width={width} height={height - (reason ? 2 : 0)} tableRows={rows.length} tableColumns={columns} query={query} figures={covenantFigures(covenant, data.facts.find((fact) => fact.id === covenant.id))} />
88
+ {reason ? <Box paddingX={1} width={width}><Notice tone="muted">{reason}</Notice></Box> : null}
89
+ </Box> : query;
90
+ if (view === "history" && (!pro || !amended)) {
91
+ const first = [...data.facts].sort((a, b) => a.filedAt.localeCompare(b.filedAt))[0];
92
+ return <Box flexDirection="column" flexGrow={1} minHeight={0}>
93
+ {header}
94
+ <PaneStatusBody empty emptyTitle={pro ? "No amendments recorded." : "Amendment history is part of Gloom Pro."}
95
+ emptyMessage={pro && first ? `Tracked since the ${first.form} filed ${first.filedAt}.` : undefined}
96
+ actions={pro ? undefined : <Button label="Upgrade to Pro" onPress={onUpgrade} />} />
97
+ </Box>;
98
+ }
99
+ return <DataTableStackView<CreditFact> columns={columns} items={rows} sortColumnId={view === "history" ? "filed" : "field"} sortDirection={view === "history" ? "desc" : "asc"} focused={focused} rootWidth={width} rootHeight={height}
100
+ rootBefore={header}
101
+ getItemKey={(row) => row.id} selection={{ kind: "id", selectedId: selected?.id ?? null, getId: (row) => row.id, onChange: setSelected }}
102
+ renderCell={(row, column) => ({ text: column.id === "field" ? fieldLabel(row.field) : column.id === "value" ? factValue(row) : column.id === "asOf" ? row.asOf : column.id === "filed" ? row.filedAt : fieldLabel(row.status),
103
+ color: row.status === "superseded" ? colors.textDim : row.status === "pending" && column.id === "status" ? colors.warning : column.id === "field" ? colors.textBright : colors.text,
104
+ keepColorWhenSelected: row.status === "pending" && column.id === "status" })}
105
+ onActivate={(row) => setOpen(row.id)} detailOpen={!!open} onBack={() => setOpen(null)} detailTitle={open ? fieldLabel(open.field) : undefined}
106
+ detailScrollRef={detailScrollRef} detailContent={open ? <CreditFactEvidence scrollRef={detailScrollRef} fact={open} width={width} /> : null}
107
+ emptyStateTitle="No supported terms in this disclosure."
108
+ selectedTextOverridesCellColor freezeFirstColumn showHorizontalScrollbar />;
109
+ }
@@ -0,0 +1,64 @@
1
+ import type { CreditDocumentsPayload, CreditInstrument, CreditScreenPayload } from "../../../api-client/credit-documents";
2
+ import type { PaneScreenshotEvidenceHook } from "../../../cli/pane-functions/screenshot-evidence";
3
+ import { useRemoteUiNode } from "../../../remote/semantic-tree";
4
+ import { isRecord } from "../../../utils/guards";
5
+ import { fetchCreditDocuments, fetchCreditInstrument, fetchCreditScreen, validateCreditDocuments, validateCreditInstrument, validateCreditScreen } from "./client";
6
+ import { CREDIT_TABS, screenRowId } from "./model";
7
+ interface CreditEvidence {
8
+ kind: "credit-documents";
9
+ version: 1;
10
+ complete: boolean;
11
+ plottedValueCount: number;
12
+ payload: CreditDocumentsPayload;
13
+ screen: CreditScreenPayload | null;
14
+ instrument: CreditInstrument | null;
15
+ tab: string;
16
+ view: string;
17
+ rowIds: string[];
18
+ instrumentId: string | null;
19
+ factId: string | null;
20
+ }
21
+ export function useCreditEvidence(payload: CreditDocumentsPayload | null, screen: CreditScreenPayload | null, instrument: CreditInstrument | null, tab: string, view: string, rowIds: string[], instrumentId: string | null, factId: string | null) {
22
+ useRemoteUiNode({ role: "chart-data", label: "Rendered credit-document evidence", getMetadata: () => ({
23
+ kind: "credit-documents", version: 1, complete: !!payload && (tab !== "screen" || !!screen), ready: !!payload && (tab !== "screen" || !!screen),
24
+ plottedValueCount: rowIds.length, payload, screen, instrument, tab, view, rowIds, instrumentId, factId,
25
+ }) });
26
+ }
27
+ export const creditScreenshotEvidence: PaneScreenshotEvidenceHook<CreditEvidence> = {
28
+ paneId: "credit-documents", kind: "credit-documents", label: "credit documents",
29
+ async prepare({ resolved }) {
30
+ const symbol = resolved.createOptions?.symbol ?? resolved.createOptions?.arg;
31
+ if (!symbol) throw new Error("A credit-document screenshot requires an issuer ticker");
32
+ const payload = await fetchCreditDocuments(symbol);
33
+ const screen = resolved.options.tab === "screen" ? await fetchCreditScreen({ headroomBelow: Number(resolved.options.headroom ?? 20), springingWithinMonths: Number(resolved.options.months ?? 12), limit: 100 }) : null;
34
+ const instrument = resolved.options.instrument ? await fetchCreditInstrument(symbol, String(resolved.options.instrument)) : null;
35
+ return { settings: { creditSnapshot: payload, creditScreenSnapshot: screen, creditInstrumentSnapshot: instrument }, financials: [[symbol, { annualStatements: [], quarterlyStatements: [], priceHistory: [] }]] };
36
+ },
37
+ read(value) {
38
+ if (!isRecord(value) || value.kind !== "credit-documents" || value.version !== 1 || value.complete !== true || !CREDIT_TABS.some((tab) => tab.value === value.tab)
39
+ || !["terms", "history"].includes(String(value.view)) || !Array.isArray(value.rowIds) || !value.rowIds.every((id) => typeof id === "string") || value.plottedValueCount !== value.rowIds.length) return null;
40
+ try {
41
+ const payload = validateCreditDocuments(value.payload as CreditDocumentsPayload);
42
+ if (value.screen) validateCreditScreen(value.screen as CreditScreenPayload);
43
+ if (value.instrument) validateCreditInstrument(value.instrument as CreditInstrument);
44
+ const screen = value.screen as CreditScreenPayload | null;
45
+ const eligible = new Set(value.tab === "capital" ? payload.instruments.map((row) => row.id) : value.tab === "covenants" ? payload.covenants.map((row) => row.id) : value.tab === "screen" ? (screen?.rows ?? []).map(screenRowId) : payload.maturities.flatMap((row) => row.instruments.map((instrument) => `${row.year}:${instrument.id}`)));
46
+ if (new Set(value.rowIds).size !== value.rowIds.length || value.rowIds.some((id) => !eligible.has(id as string))) return null;
47
+ return value as unknown as CreditEvidence;
48
+ } catch { return null; }
49
+ },
50
+ mismatches(evidence, { resolved, payload }) {
51
+ const settings = payload.config.layout.instances.find((entry) => entry.instanceId === payload.paneId)?.settings;
52
+ const mismatches: string[] = [];
53
+ if (JSON.stringify(evidence.payload) !== JSON.stringify(settings?.creditSnapshot)) mismatches.push("Credit documents differ from captured filing evidence");
54
+ if (evidence.tab === "screen" && JSON.stringify(evidence.screen) !== JSON.stringify(settings?.creditScreenSnapshot)) mismatches.push("Credit screen differs from captured results");
55
+ if (resolved.options.instrument && JSON.stringify(evidence.instrument) !== JSON.stringify(settings?.creditInstrumentSnapshot)) mismatches.push("Instrument history differs from captured revisions");
56
+ if (evidence.tab !== (resolved.options.tab ?? "capital")) mismatches.push("Credit-document tab does not match");
57
+ if (resolved.options.instrument && evidence.instrumentId !== resolved.options.instrument) mismatches.push("Requested credit instrument is not open");
58
+ if (resolved.options.fact && evidence.factId !== resolved.options.fact) mismatches.push("Requested credit evidence is not open");
59
+ if (evidence.view !== (resolved.options.view ?? "terms")) mismatches.push("Credit-document evidence view does not match");
60
+ return mismatches;
61
+ },
62
+ unavailable(evidence) { return evidence?.complete ? [] : ["credit documents"]; },
63
+ symbols({ payload }) { return payload.financials.map(([symbol]) => symbol); },
64
+ };