@buoy-gg/ask-buoy 7.0.35 → 7.0.38

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 (286) hide show
  1. package/README.md +73 -15
  2. package/lib/commonjs/blocks/AskBlocks.js +1 -338
  3. package/lib/commonjs/blocks/BlockRenderer.js +1 -250
  4. package/lib/commonjs/blocks/ChromePrototypes.js +1 -514
  5. package/lib/commonjs/blocks/DataBlocks.js +1 -688
  6. package/lib/commonjs/blocks/ExtraBlocks.js +1 -1854
  7. package/lib/commonjs/blocks/MediaBlocks.js +1 -140
  8. package/lib/commonjs/blocks/ReceiptBlocks.js +1 -586
  9. package/lib/commonjs/blocks/blockText.js +1 -0
  10. package/lib/commonjs/blocks/blockText.test.js +1 -0
  11. package/lib/commonjs/blocks/context.js +1 -42
  12. package/lib/commonjs/blocks/icons.js +1 -96
  13. package/lib/commonjs/blocks/index.js +1 -95
  14. package/lib/commonjs/blocks/listRow.test.js +1 -55
  15. package/lib/commonjs/blocks/pageState.js +1 -34
  16. package/lib/commonjs/blocks/pageState.test.js +1 -57
  17. package/lib/commonjs/blocks/primitives.js +1 -401
  18. package/lib/commonjs/blocks/primitivesIndex.js +1 -62
  19. package/lib/commonjs/components/ApprovalCard.js +1 -140
  20. package/lib/commonjs/components/AskBuoyHeader.js +1 -164
  21. package/lib/commonjs/components/AskBuoyIcon.js +1 -19
  22. package/lib/commonjs/components/AskBuoyModal.js +1 -353
  23. package/lib/commonjs/components/AskBuoySettings.js +1 -69
  24. package/lib/commonjs/components/ChangesBar.js +1 -211
  25. package/lib/commonjs/components/Composer.js +1 -175
  26. package/lib/commonjs/components/EmptyState.js +1 -154
  27. package/lib/commonjs/components/KeyboardPad.js +1 -0
  28. package/lib/commonjs/components/Markdown.js +1 -252
  29. package/lib/commonjs/components/MessageList.js +1 -683
  30. package/lib/commonjs/components/QueuedMessages.js +1 -0
  31. package/lib/commonjs/components/ThinkingStrip.js +1 -223
  32. package/lib/commonjs/components/TypingDots.js +1 -63
  33. package/lib/commonjs/components/markdownParse.js +1 -0
  34. package/lib/commonjs/components/markdownParse.test.js +1 -0
  35. package/lib/commonjs/components/useCopyAction.js +1 -50
  36. package/lib/commonjs/index.js +1 -252
  37. package/lib/commonjs/preset.js +1 -90
  38. package/lib/commonjs/store/activityGroups.js +1 -0
  39. package/lib/commonjs/store/activityGroups.test.js +1 -0
  40. package/lib/commonjs/store/askBuoySettings.js +1 -67
  41. package/lib/commonjs/store/askBuoyStore.js +1 -365
  42. package/lib/commonjs/store/blockPlacement.js +1 -0
  43. package/lib/commonjs/store/blockPlacement.test.js +1 -0
  44. package/lib/commonjs/store/queue.test.js +1 -0
  45. package/lib/commonjs/store/resetConversation.js +1 -0
  46. package/lib/commonjs/store/restorePending.test.js +1 -0
  47. package/lib/commonjs/store/restoredIds.test.js +1 -47
  48. package/lib/commonjs/store/suggestions.js +1 -0
  49. package/lib/commonjs/store/suggestions.test.js +1 -0
  50. package/lib/commonjs/store/systemLine.test.js +1 -0
  51. package/lib/commonjs/store/ticketPrompt.js +1 -0
  52. package/lib/commonjs/store/traceText.js +1 -81
  53. package/lib/commonjs/store/traceText.test.js +1 -112
  54. package/lib/commonjs/store/transcriptPersistence.js +1 -208
  55. package/lib/commonjs/store/transcriptPersistence.test.js +1 -185
  56. package/lib/commonjs/store/turnRendering.test.js +1 -0
  57. package/lib/commonjs/store/useAskBuoy.js +1 -400
  58. package/lib/commonjs/store/useAskBuoySettings.js +1 -14
  59. package/lib/commonjs/sync/askBuoySyncAdapter.js +1 -119
  60. package/lib/commonjs/sync/askBuoySyncAdapter.test.js +1 -141
  61. package/lib/commonjs/sync/wire.js +1 -58
  62. package/lib/commonjs/types.js +1 -6
  63. package/lib/module/blocks/AskBlocks.js +1 -331
  64. package/lib/module/blocks/BlockRenderer.js +1 -245
  65. package/lib/module/blocks/ChromePrototypes.js +1 -503
  66. package/lib/module/blocks/DataBlocks.js +1 -674
  67. package/lib/module/blocks/ExtraBlocks.js +1 -1827
  68. package/lib/module/blocks/MediaBlocks.js +1 -135
  69. package/lib/module/blocks/ReceiptBlocks.js +1 -574
  70. package/lib/module/blocks/blockText.js +1 -0
  71. package/lib/module/blocks/blockText.test.js +1 -0
  72. package/lib/module/blocks/context.js +1 -35
  73. package/lib/module/blocks/icons.js +1 -91
  74. package/lib/module/blocks/index.js +1 -8
  75. package/lib/module/blocks/listRow.test.js +1 -56
  76. package/lib/module/blocks/pageState.js +1 -30
  77. package/lib/module/blocks/pageState.test.js +1 -56
  78. package/lib/module/blocks/primitives.js +1 -389
  79. package/lib/module/blocks/primitivesIndex.js +1 -5
  80. package/lib/module/components/ApprovalCard.js +1 -135
  81. package/lib/module/components/AskBuoyHeader.js +1 -161
  82. package/lib/module/components/AskBuoyIcon.js +1 -8
  83. package/lib/module/components/AskBuoyModal.js +1 -348
  84. package/lib/module/components/AskBuoySettings.js +1 -64
  85. package/lib/module/components/ChangesBar.js +1 -206
  86. package/lib/module/components/Composer.js +1 -170
  87. package/lib/module/components/EmptyState.js +1 -149
  88. package/lib/module/components/KeyboardPad.js +1 -0
  89. package/lib/module/components/Markdown.js +1 -246
  90. package/lib/module/components/MessageList.js +1 -677
  91. package/lib/module/components/QueuedMessages.js +1 -0
  92. package/lib/module/components/ThinkingStrip.js +1 -218
  93. package/lib/module/components/TypingDots.js +1 -58
  94. package/lib/module/components/markdownParse.js +1 -0
  95. package/lib/module/components/markdownParse.test.js +1 -0
  96. package/lib/module/components/useCopyAction.js +1 -46
  97. package/lib/module/index.js +1 -34
  98. package/lib/module/preset.js +1 -73
  99. package/lib/module/store/activityGroups.js +1 -0
  100. package/lib/module/store/activityGroups.test.js +1 -0
  101. package/lib/module/store/askBuoySettings.js +1 -62
  102. package/lib/module/store/askBuoyStore.js +1 -361
  103. package/lib/module/store/blockPlacement.js +1 -0
  104. package/lib/module/store/blockPlacement.test.js +1 -0
  105. package/lib/module/store/queue.test.js +1 -0
  106. package/lib/module/store/resetConversation.js +1 -0
  107. package/lib/module/store/restorePending.test.js +1 -0
  108. package/lib/module/store/restoredIds.test.js +1 -46
  109. package/lib/module/store/suggestions.js +1 -0
  110. package/lib/module/store/suggestions.test.js +1 -0
  111. package/lib/module/store/systemLine.test.js +1 -0
  112. package/lib/module/store/ticketPrompt.js +1 -0
  113. package/lib/module/store/traceText.js +1 -75
  114. package/lib/module/store/traceText.test.js +1 -111
  115. package/lib/module/store/transcriptPersistence.js +1 -198
  116. package/lib/module/store/transcriptPersistence.test.js +1 -184
  117. package/lib/module/store/turnRendering.test.js +1 -0
  118. package/lib/module/store/useAskBuoy.js +1 -394
  119. package/lib/module/store/useAskBuoySettings.js +1 -9
  120. package/lib/module/sync/askBuoySyncAdapter.js +1 -114
  121. package/lib/module/sync/askBuoySyncAdapter.test.js +1 -140
  122. package/lib/module/sync/wire.js +1 -47
  123. package/lib/module/types.js +1 -4
  124. package/lib/typescript/blocks/DataBlocks.d.ts +11 -0
  125. package/lib/typescript/blocks/ExtraBlocks.d.ts +18 -2
  126. package/lib/typescript/blocks/blockText.d.ts +14 -0
  127. package/lib/typescript/blocks/blockText.test.d.ts +2 -0
  128. package/lib/typescript/blocks/primitives.d.ts +16 -1
  129. package/lib/typescript/components/ApprovalCard.d.ts +9 -1
  130. package/lib/typescript/components/AskBuoyHeader.d.ts +31 -1
  131. package/lib/typescript/components/Composer.d.ts +16 -1
  132. package/lib/typescript/components/EmptyState.d.ts +5 -1
  133. package/lib/typescript/components/KeyboardPad.d.ts +33 -0
  134. package/lib/typescript/components/Markdown.d.ts +0 -10
  135. package/lib/typescript/components/MessageList.d.ts +7 -2
  136. package/lib/typescript/components/QueuedMessages.d.ts +10 -0
  137. package/lib/typescript/components/markdownParse.d.ts +49 -0
  138. package/lib/typescript/components/markdownParse.test.d.ts +2 -0
  139. package/lib/typescript/preset.d.ts +4 -2
  140. package/lib/typescript/store/activityGroups.d.ts +29 -0
  141. package/lib/typescript/store/activityGroups.test.d.ts +2 -0
  142. package/lib/typescript/store/askBuoySettings.d.ts +22 -0
  143. package/lib/typescript/store/askBuoyStore.d.ts +174 -9
  144. package/lib/typescript/store/blockPlacement.d.ts +30 -0
  145. package/lib/typescript/store/blockPlacement.test.d.ts +2 -0
  146. package/lib/typescript/store/queue.test.d.ts +2 -0
  147. package/lib/typescript/store/resetConversation.d.ts +38 -0
  148. package/lib/typescript/store/restorePending.test.d.ts +2 -0
  149. package/lib/typescript/store/suggestions.d.ts +32 -0
  150. package/lib/typescript/store/suggestions.test.d.ts +2 -0
  151. package/lib/typescript/store/systemLine.test.d.ts +2 -0
  152. package/lib/typescript/store/ticketPrompt.d.ts +11 -0
  153. package/lib/typescript/store/transcriptPersistence.d.ts +41 -2
  154. package/lib/typescript/store/turnRendering.test.d.ts +2 -0
  155. package/lib/typescript/store/useAskBuoy.d.ts +26 -3
  156. package/lib/typescript/sync/askBuoySyncAdapter.d.ts +29 -6
  157. package/package.json +10 -10
  158. package/lib/commonjs/blocks/AskBlocks.js.map +0 -1
  159. package/lib/commonjs/blocks/BlockRenderer.js.map +0 -1
  160. package/lib/commonjs/blocks/ChromePrototypes.js.map +0 -1
  161. package/lib/commonjs/blocks/DataBlocks.js.map +0 -1
  162. package/lib/commonjs/blocks/ExtraBlocks.js.map +0 -1
  163. package/lib/commonjs/blocks/MediaBlocks.js.map +0 -1
  164. package/lib/commonjs/blocks/ReceiptBlocks.js.map +0 -1
  165. package/lib/commonjs/blocks/context.js.map +0 -1
  166. package/lib/commonjs/blocks/icons.js.map +0 -1
  167. package/lib/commonjs/blocks/index.js.map +0 -1
  168. package/lib/commonjs/blocks/listRow.test.js.map +0 -1
  169. package/lib/commonjs/blocks/pageState.js.map +0 -1
  170. package/lib/commonjs/blocks/pageState.test.js.map +0 -1
  171. package/lib/commonjs/blocks/primitives.js.map +0 -1
  172. package/lib/commonjs/blocks/primitivesIndex.js.map +0 -1
  173. package/lib/commonjs/components/ApprovalCard.js.map +0 -1
  174. package/lib/commonjs/components/AskBuoyHeader.js.map +0 -1
  175. package/lib/commonjs/components/AskBuoyIcon.js.map +0 -1
  176. package/lib/commonjs/components/AskBuoyModal.js.map +0 -1
  177. package/lib/commonjs/components/AskBuoySettings.js.map +0 -1
  178. package/lib/commonjs/components/ChangesBar.js.map +0 -1
  179. package/lib/commonjs/components/Composer.js.map +0 -1
  180. package/lib/commonjs/components/EmptyState.js.map +0 -1
  181. package/lib/commonjs/components/Markdown.js.map +0 -1
  182. package/lib/commonjs/components/MessageList.js.map +0 -1
  183. package/lib/commonjs/components/ThinkingStrip.js.map +0 -1
  184. package/lib/commonjs/components/TypingDots.js.map +0 -1
  185. package/lib/commonjs/components/useCopyAction.js.map +0 -1
  186. package/lib/commonjs/index.js.map +0 -1
  187. package/lib/commonjs/preset.js.map +0 -1
  188. package/lib/commonjs/store/askBuoySettings.js.map +0 -1
  189. package/lib/commonjs/store/askBuoyStore.js.map +0 -1
  190. package/lib/commonjs/store/restoredIds.test.js.map +0 -1
  191. package/lib/commonjs/store/traceText.js.map +0 -1
  192. package/lib/commonjs/store/traceText.test.js.map +0 -1
  193. package/lib/commonjs/store/transcriptPersistence.js.map +0 -1
  194. package/lib/commonjs/store/transcriptPersistence.test.js.map +0 -1
  195. package/lib/commonjs/store/useAskBuoy.js.map +0 -1
  196. package/lib/commonjs/store/useAskBuoySettings.js.map +0 -1
  197. package/lib/commonjs/sync/askBuoySyncAdapter.js.map +0 -1
  198. package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +0 -1
  199. package/lib/commonjs/sync/wire.js.map +0 -1
  200. package/lib/commonjs/types.js.map +0 -1
  201. package/lib/module/blocks/AskBlocks.js.map +0 -1
  202. package/lib/module/blocks/BlockRenderer.js.map +0 -1
  203. package/lib/module/blocks/ChromePrototypes.js.map +0 -1
  204. package/lib/module/blocks/DataBlocks.js.map +0 -1
  205. package/lib/module/blocks/ExtraBlocks.js.map +0 -1
  206. package/lib/module/blocks/MediaBlocks.js.map +0 -1
  207. package/lib/module/blocks/ReceiptBlocks.js.map +0 -1
  208. package/lib/module/blocks/context.js.map +0 -1
  209. package/lib/module/blocks/icons.js.map +0 -1
  210. package/lib/module/blocks/index.js.map +0 -1
  211. package/lib/module/blocks/listRow.test.js.map +0 -1
  212. package/lib/module/blocks/pageState.js.map +0 -1
  213. package/lib/module/blocks/pageState.test.js.map +0 -1
  214. package/lib/module/blocks/primitives.js.map +0 -1
  215. package/lib/module/blocks/primitivesIndex.js.map +0 -1
  216. package/lib/module/components/ApprovalCard.js.map +0 -1
  217. package/lib/module/components/AskBuoyHeader.js.map +0 -1
  218. package/lib/module/components/AskBuoyIcon.js.map +0 -1
  219. package/lib/module/components/AskBuoyModal.js.map +0 -1
  220. package/lib/module/components/AskBuoySettings.js.map +0 -1
  221. package/lib/module/components/ChangesBar.js.map +0 -1
  222. package/lib/module/components/Composer.js.map +0 -1
  223. package/lib/module/components/EmptyState.js.map +0 -1
  224. package/lib/module/components/Markdown.js.map +0 -1
  225. package/lib/module/components/MessageList.js.map +0 -1
  226. package/lib/module/components/ThinkingStrip.js.map +0 -1
  227. package/lib/module/components/TypingDots.js.map +0 -1
  228. package/lib/module/components/useCopyAction.js.map +0 -1
  229. package/lib/module/index.js.map +0 -1
  230. package/lib/module/preset.js.map +0 -1
  231. package/lib/module/store/askBuoySettings.js.map +0 -1
  232. package/lib/module/store/askBuoyStore.js.map +0 -1
  233. package/lib/module/store/restoredIds.test.js.map +0 -1
  234. package/lib/module/store/traceText.js.map +0 -1
  235. package/lib/module/store/traceText.test.js.map +0 -1
  236. package/lib/module/store/transcriptPersistence.js.map +0 -1
  237. package/lib/module/store/transcriptPersistence.test.js.map +0 -1
  238. package/lib/module/store/useAskBuoy.js.map +0 -1
  239. package/lib/module/store/useAskBuoySettings.js.map +0 -1
  240. package/lib/module/sync/askBuoySyncAdapter.js.map +0 -1
  241. package/lib/module/sync/askBuoySyncAdapter.test.js.map +0 -1
  242. package/lib/module/sync/wire.js.map +0 -1
  243. package/lib/module/types.js.map +0 -1
  244. package/lib/typescript/blocks/AskBlocks.d.ts.map +0 -1
  245. package/lib/typescript/blocks/BlockRenderer.d.ts.map +0 -1
  246. package/lib/typescript/blocks/ChromePrototypes.d.ts.map +0 -1
  247. package/lib/typescript/blocks/DataBlocks.d.ts.map +0 -1
  248. package/lib/typescript/blocks/ExtraBlocks.d.ts.map +0 -1
  249. package/lib/typescript/blocks/MediaBlocks.d.ts.map +0 -1
  250. package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +0 -1
  251. package/lib/typescript/blocks/context.d.ts.map +0 -1
  252. package/lib/typescript/blocks/icons.d.ts.map +0 -1
  253. package/lib/typescript/blocks/index.d.ts.map +0 -1
  254. package/lib/typescript/blocks/listRow.test.d.ts.map +0 -1
  255. package/lib/typescript/blocks/pageState.d.ts.map +0 -1
  256. package/lib/typescript/blocks/pageState.test.d.ts.map +0 -1
  257. package/lib/typescript/blocks/primitives.d.ts.map +0 -1
  258. package/lib/typescript/blocks/primitivesIndex.d.ts.map +0 -1
  259. package/lib/typescript/components/ApprovalCard.d.ts.map +0 -1
  260. package/lib/typescript/components/AskBuoyHeader.d.ts.map +0 -1
  261. package/lib/typescript/components/AskBuoyIcon.d.ts.map +0 -1
  262. package/lib/typescript/components/AskBuoyModal.d.ts.map +0 -1
  263. package/lib/typescript/components/AskBuoySettings.d.ts.map +0 -1
  264. package/lib/typescript/components/ChangesBar.d.ts.map +0 -1
  265. package/lib/typescript/components/Composer.d.ts.map +0 -1
  266. package/lib/typescript/components/EmptyState.d.ts.map +0 -1
  267. package/lib/typescript/components/Markdown.d.ts.map +0 -1
  268. package/lib/typescript/components/MessageList.d.ts.map +0 -1
  269. package/lib/typescript/components/ThinkingStrip.d.ts.map +0 -1
  270. package/lib/typescript/components/TypingDots.d.ts.map +0 -1
  271. package/lib/typescript/components/useCopyAction.d.ts.map +0 -1
  272. package/lib/typescript/index.d.ts.map +0 -1
  273. package/lib/typescript/preset.d.ts.map +0 -1
  274. package/lib/typescript/store/askBuoySettings.d.ts.map +0 -1
  275. package/lib/typescript/store/askBuoyStore.d.ts.map +0 -1
  276. package/lib/typescript/store/restoredIds.test.d.ts.map +0 -1
  277. package/lib/typescript/store/traceText.d.ts.map +0 -1
  278. package/lib/typescript/store/traceText.test.d.ts.map +0 -1
  279. package/lib/typescript/store/transcriptPersistence.d.ts.map +0 -1
  280. package/lib/typescript/store/transcriptPersistence.test.d.ts.map +0 -1
  281. package/lib/typescript/store/useAskBuoy.d.ts.map +0 -1
  282. package/lib/typescript/store/useAskBuoySettings.d.ts.map +0 -1
  283. package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +0 -1
  284. package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +0 -1
  285. package/lib/typescript/sync/wire.d.ts.map +0 -1
  286. package/lib/typescript/types.d.ts.map +0 -1
@@ -1,674 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Show blocks — data the user should see rather than read.
5
- * Every one honours a cap and says "+N more" rather than growing the page.
6
- */
7
- import { useState } from "react";
8
- import { Image, Pressable, StyleSheet, Text, View } from "react-native";
9
- import { AlertTriangle, Check, Info, night, X } from "@buoy-gg/shared-ui";
10
- import { DataViewer } from "@buoy-gg/shared-ui/dataViewer";
11
- import { CAPS } from "@buoy-gg/agent-core";
12
- import { ActionRow, blockStyles as b, Card, More, toneColor, useBlockHandlers, usePaged } from "./primitivesIndex";
13
- import { renderInline } from "../components/Markdown";
14
- import { BlockIcon } from "./icons";
15
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
- function fmt(v) {
17
- if (v === undefined) return "—";
18
- if (v === null) return "null";
19
- if (typeof v === "string") return v;
20
- if (typeof v === "number" || typeof v === "boolean") return String(v);
21
- try {
22
- const s = JSON.stringify(v);
23
- return s.length > 120 ? `${s.slice(0, 117)}…` : s;
24
- } catch {
25
- return String(v);
26
- }
27
- }
28
- export function Table({
29
- block
30
- }) {
31
- const paged = usePaged(block.rows, CAPS.tableRows);
32
- const {
33
- visible
34
- } = paged;
35
- const cols = block.columns.slice(0, 4);
36
- return /*#__PURE__*/_jsxs(Card, {
37
- title: block.title,
38
- source: block.source,
39
- testID: `buoy-block-table-${block.id}`,
40
- children: [/*#__PURE__*/_jsx(View, {
41
- style: styles.tableHead,
42
- children: cols.map((c, i) => /*#__PURE__*/_jsx(Text, {
43
- style: [styles.th, i === 0 && styles.firstCol],
44
- numberOfLines: 1,
45
- children: c
46
- }, c))
47
- }), visible.map((row, r) => /*#__PURE__*/_jsx(View, {
48
- style: [styles.tr, r > 0 && b.rowDivider],
49
- children: cols.map((_, i) => {
50
- const cell = row[i];
51
- const text = typeof cell === "string" ? cell : cell?.text ?? "";
52
- const tone = typeof cell === "string" ? undefined : cell?.tone;
53
- return /*#__PURE__*/_jsx(Text, {
54
- style: [styles.td, i === 0 && styles.firstCol, i === 0 && styles.tdFirst, tone && {
55
- color: toneColor(tone)
56
- }],
57
- numberOfLines: 2,
58
- children: renderInline(text, styles.td)
59
- }, i);
60
- })
61
- }, r)), /*#__PURE__*/_jsx(More, {
62
- paged: paged
63
- })]
64
- });
65
- }
66
- export function KeyValue({
67
- block
68
- }) {
69
- const paged = usePaged(block.pairs, CAPS.keyValuePairs);
70
- const {
71
- visible
72
- } = paged;
73
- const [open, setOpen] = useState(null);
74
- return /*#__PURE__*/_jsxs(Card, {
75
- title: block.title,
76
- source: block.source,
77
- testID: `buoy-block-keyvalue-${block.id}`,
78
- children: [visible.map((p, i) => {
79
- const long = typeof p.value === "object" && p.value !== null;
80
- const isOpen = open === p.key;
81
- return /*#__PURE__*/_jsxs(Pressable, {
82
- onPress: long ? () => setOpen(isOpen ? null : p.key) : undefined,
83
- style: [styles.kvRow, i > 0 && b.rowDivider],
84
- children: [/*#__PURE__*/_jsx(Text, {
85
- style: styles.kvKey,
86
- numberOfLines: 1,
87
- children: p.key
88
- }), /*#__PURE__*/_jsx(Text, {
89
- style: [styles.kvValue, isOpen && b.mono],
90
- numberOfLines: isOpen ? undefined : 2,
91
- selectable: true,
92
- children: isOpen ? JSON.stringify(p.value, null, 2) : fmt(p.value)
93
- })]
94
- }, p.key);
95
- }), /*#__PURE__*/_jsx(More, {
96
- paged: paged
97
- })]
98
- });
99
- }
100
-
101
- /**
102
- * Keys carry the index as well as the id.
103
- *
104
- * The ids in here come from the app's own data, and app data is not required
105
- * to be unique — a Poké Mart bag in this repo holds two lines sharing one
106
- * `lineId`, which is a bug in that app but must not be one in a devtool
107
- * rendering it. Paging made it visible: the duplicate sat past the initial cap,
108
- * so React only saw the collision on the first "Show more".
109
- */
110
- /**
111
- * What a tapped list row does.
112
- *
113
- * A row can carry a picture and an action, and they want the same gesture. The
114
- * picture wins the row body — looking at a thing must not fire it — and the
115
- * action keeps its label as its own control. A row with no picture is
116
- * unchanged: the whole row runs the action, which is what it did before rows
117
- * could open.
118
- */
119
- export function listRowBehaviour(item) {
120
- const canExpand = Boolean(item.image);
121
- return {
122
- canExpand,
123
- rowRunsAction: Boolean(item.action) && !canExpand,
124
- actionIsOwnControl: Boolean(item.action) && canExpand
125
- };
126
- }
127
- export function List({
128
- block
129
- }) {
130
- const h = useBlockHandlers();
131
- const paged = usePaged(block.items, CAPS.listItems);
132
- const {
133
- visible
134
- } = paged;
135
- // One row open at a time, keyed the same way the row is — the list can hold
136
- // duplicate ids (see the note above), so the index is part of the key.
137
- const [open, setOpen] = useState(null);
138
- return /*#__PURE__*/_jsxs(Card, {
139
- title: block.title,
140
- source: block.source,
141
- testID: `buoy-block-list-${block.id}`,
142
- children: [visible.map((it, i) => {
143
- const key = `${it.id ?? it.title}-${i}`;
144
- const expanded = open === key;
145
- // A row with a picture opens it; a row without one keeps the old
146
- // behaviour, where the whole row runs its action. When an item has
147
- // BOTH, the body toggles the image and the action label becomes its
148
- // own control — otherwise the two gestures would sit on one target and
149
- // looking at a thing would fire it.
150
- const {
151
- canExpand,
152
- rowRunsAction,
153
- actionIsOwnControl
154
- } = listRowBehaviour(it);
155
- const Row = canExpand || rowRunsAction ? Pressable : View;
156
- const rowProps = canExpand ? {
157
- onPress: () => setOpen(expanded ? null : key),
158
- accessibilityRole: "button",
159
- accessibilityState: {
160
- expanded
161
- },
162
- accessibilityLabel: `${it.title}, ${expanded ? "hide" : "show"} picture`,
163
- testID: `buoy-block-list-row-${key}`
164
- } : rowRunsAction ? {
165
- onPress: () => void h.runAction(it.action, block.id),
166
- accessibilityRole: "button"
167
- } : {};
168
- return /*#__PURE__*/_jsxs(View, {
169
- style: i > 0 ? b.rowDivider : undefined,
170
- children: [expanded && it.image ? /*#__PURE__*/_jsx(Pressable, {
171
- onPress: () => setOpen(null),
172
- accessibilityRole: "button",
173
- accessibilityLabel: `Hide ${it.title}`,
174
- testID: `buoy-block-list-hero-${key}`,
175
- style: styles.listHero,
176
- children: /*#__PURE__*/_jsx(Image, {
177
- source: {
178
- uri: it.image
179
- },
180
- style: styles.listHeroImage,
181
- resizeMode: "contain",
182
- accessibilityLabel: it.title
183
- })
184
- }) : null, /*#__PURE__*/_jsxs(Row, {
185
- ...rowProps,
186
- style: b.row,
187
- children: [it.image && !expanded ? /*#__PURE__*/_jsx(Image, {
188
- source: {
189
- uri: it.image
190
- },
191
- style: styles.thumb,
192
- resizeMode: "contain",
193
- accessibilityLabel: it.title
194
- }) : it.icon ? /*#__PURE__*/_jsx(BlockIcon, {
195
- name: it.icon
196
- }) : null, /*#__PURE__*/_jsxs(View, {
197
- style: styles.flex,
198
- children: [/*#__PURE__*/_jsx(Text, {
199
- style: [b.rowTitle, it.tone && {
200
- color: toneColor(it.tone)
201
- }],
202
- numberOfLines: expanded ? undefined : 2,
203
- children: renderInline(it.title, b.rowTitle)
204
- }), it.subtitle ? /*#__PURE__*/_jsx(Text, {
205
- style: b.rowSub,
206
- numberOfLines: expanded ? undefined : 2,
207
- children: renderInline(it.subtitle, b.rowSub)
208
- }) : null]
209
- }), it.trailing ? /*#__PURE__*/_jsx(Text, {
210
- style: [b.rowTrailing, it.tone && {
211
- color: toneColor(it.tone)
212
- }],
213
- numberOfLines: 1,
214
- children: it.trailing
215
- }) : null, it.action ? actionIsOwnControl ? /*#__PURE__*/_jsx(Pressable, {
216
- onPress: () => void h.runAction(it.action, block.id),
217
- accessibilityRole: "button",
218
- accessibilityLabel: it.action.label,
219
- hitSlop: 8,
220
- children: /*#__PURE__*/_jsx(Text, {
221
- style: styles.rowAction,
222
- children: it.action.label
223
- })
224
- }) : /*#__PURE__*/_jsx(Text, {
225
- style: styles.rowAction,
226
- children: it.action.label
227
- }) : null]
228
- })]
229
- }, key);
230
- }), /*#__PURE__*/_jsx(More, {
231
- paged: paged
232
- })]
233
- });
234
- }
235
- export function Diff({
236
- block
237
- }) {
238
- const paged = usePaged(block.changes, CAPS.keyValuePairs);
239
- return /*#__PURE__*/_jsxs(Card, {
240
- title: block.title ?? "What changed",
241
- source: block.source,
242
- testID: `buoy-block-diff-${block.id}`,
243
- children: [paged.visible.map((c, i) => {
244
- const added = c.before === undefined && c.after !== undefined;
245
- const removed = c.after === undefined && c.before !== undefined;
246
- return /*#__PURE__*/_jsxs(View, {
247
- style: [styles.diffRow, i > 0 && b.rowDivider],
248
- children: [/*#__PURE__*/_jsx(Text, {
249
- style: styles.diffPath,
250
- numberOfLines: 1,
251
- children: c.path
252
- }), !added ? /*#__PURE__*/_jsxs(View, {
253
- style: styles.diffLine,
254
- children: [/*#__PURE__*/_jsx(Text, {
255
- style: [styles.diffMark, {
256
- color: night.color.danger
257
- }],
258
- children: "\u2212"
259
- }), /*#__PURE__*/_jsx(Text, {
260
- style: [styles.diffValue, {
261
- color: night.color.danger
262
- }],
263
- numberOfLines: 3,
264
- selectable: true,
265
- children: fmt(c.before)
266
- })]
267
- }) : null, !removed ? /*#__PURE__*/_jsxs(View, {
268
- style: styles.diffLine,
269
- children: [/*#__PURE__*/_jsx(Text, {
270
- style: [styles.diffMark, {
271
- color: night.color.accent
272
- }],
273
- children: "+"
274
- }), /*#__PURE__*/_jsx(Text, {
275
- style: [styles.diffValue, {
276
- color: night.color.accent
277
- }],
278
- numberOfLines: 3,
279
- selectable: true,
280
- children: fmt(c.after)
281
- })]
282
- }) : null]
283
- }, `${c.path}-${i}`);
284
- }), /*#__PURE__*/_jsx(More, {
285
- paged: paged
286
- })]
287
- });
288
- }
289
- export function Chart({
290
- block
291
- }) {
292
- const bars = block.bars.slice(0, CAPS.chartBars);
293
- const max = block.max ?? Math.max(1, ...bars.map(x => x.value));
294
- return /*#__PURE__*/_jsx(Card, {
295
- title: block.title,
296
- source: block.source,
297
- testID: `buoy-block-chart-${block.id}`,
298
- children: /*#__PURE__*/_jsx(View, {
299
- style: styles.chart,
300
- children: bars.map((x, i) => /*#__PURE__*/_jsxs(View, {
301
- style: styles.barRow,
302
- children: [/*#__PURE__*/_jsx(Text, {
303
- style: styles.barLabel,
304
- numberOfLines: 1,
305
- children: x.label
306
- }), /*#__PURE__*/_jsx(View, {
307
- style: styles.barTrack,
308
- children: /*#__PURE__*/_jsx(View, {
309
- style: [styles.bar, {
310
- width: `${Math.max(2, Math.round(x.value / max * 100))}%`,
311
- backgroundColor: toneColor(x.tone ?? "accent")
312
- }]
313
- })
314
- }), /*#__PURE__*/_jsxs(Text, {
315
- style: styles.barValue,
316
- numberOfLines: 1,
317
- children: [x.value, x.unit ? ` ${x.unit}` : ""]
318
- })]
319
- }, `${x.label}-${i}`))
320
- })
321
- });
322
- }
323
- export function Steps({
324
- block
325
- }) {
326
- return /*#__PURE__*/_jsx(Card, {
327
- title: block.title,
328
- testID: `buoy-block-steps-${block.id}`,
329
- children: block.steps.map((s, i) => /*#__PURE__*/_jsxs(View, {
330
- style: [styles.step, i > 0 && b.rowDivider],
331
- children: [/*#__PURE__*/_jsx(View, {
332
- style: [styles.stepMark, s.state === "done" && styles.stepDone, s.state === "failed" && styles.stepFailed],
333
- children: s.state === "done" ? /*#__PURE__*/_jsx(Check, {
334
- size: 10,
335
- color: night.color.onAccent
336
- }) : s.state === "failed" ? /*#__PURE__*/_jsx(X, {
337
- size: 10,
338
- color: night.color.text
339
- }) : /*#__PURE__*/_jsx(Text, {
340
- style: styles.stepNum,
341
- children: i + 1
342
- })
343
- }), /*#__PURE__*/_jsx(Text, {
344
- style: [b.rowTitle, s.state === "done" && styles.stepTextDone],
345
- children: s.text
346
- })]
347
- }, i))
348
- });
349
- }
350
-
351
- /**
352
- * Parsed JSON, or `undefined` when the payload is not JSON at all.
353
- *
354
- * A bare string, number or boolean parses fine and is deliberately rejected:
355
- * `"hello"` is valid JSON and a tree of one leaf is a worse way to read it
356
- * than the line itself.
357
- */
358
- function parseJson(text) {
359
- try {
360
- const value = JSON.parse(text);
361
- return value !== null && typeof value === "object" ? value : undefined;
362
- } catch {
363
- return undefined;
364
- }
365
- }
366
-
367
- /**
368
- * A JSON payload, in the same explorer Storage and Network use.
369
- *
370
- * Worth the weight over a pretty-printed string: it collapses, it types its
371
- * values, and the thing you are usually hunting — one wrong field deep in a
372
- * response body — is findable instead of buried in forty lines of monospace.
373
- * The explorer's own lists run `scrollEnabled={false}` and grow to their
374
- * content, so nothing nests a scroller inside the transcript.
375
- */
376
- function JsonCode({
377
- block,
378
- value
379
- }) {
380
- return /*#__PURE__*/_jsx(Card, {
381
- title: block.title,
382
- testID: `buoy-block-code-${block.id}`,
383
- children: /*#__PURE__*/_jsx(View, {
384
- style: styles.viewer,
385
- children: /*#__PURE__*/_jsx(DataViewer, {
386
- title: block.title ?? "Payload",
387
- data: value,
388
- initialExpanded: true,
389
- showTypeFilter: false,
390
- testIDPrefix: `buoy-block-code-${block.id}`
391
- })
392
- })
393
- });
394
- }
395
-
396
- /** Anything that is not a JSON object: a log line, a stack, a snippet. */
397
- function TextCode({
398
- block
399
- }) {
400
- return /*#__PURE__*/_jsx(Card, {
401
- title: block.title,
402
- testID: `buoy-block-code-${block.id}`,
403
- children: /*#__PURE__*/_jsx(Text, {
404
- style: [b.mono, styles.code],
405
- selectable: true,
406
- children: block.text
407
- })
408
- });
409
- }
410
-
411
- /**
412
- * Router, per rule4: two specialised components rather than one that changes
413
- * shape. A `cond ? <A/> : <B/>` inside a single component is the Fabric
414
- * view-index hazard, and these two subtrees have nothing in common.
415
- */
416
- export function Code({
417
- block
418
- }) {
419
- const value = parseJson(block.text);
420
- if (value === undefined) return /*#__PURE__*/_jsx(TextCode, {
421
- block: block
422
- });
423
- return /*#__PURE__*/_jsx(JsonCode, {
424
- block: block,
425
- value: value
426
- });
427
- }
428
- export function Notice({
429
- block
430
- }) {
431
- const color = block.tone === "danger" ? night.color.danger : block.tone === "warning" ? night.color.warning : night.color.info;
432
- const Icon = block.tone === "info" ? Info : AlertTriangle;
433
- return /*#__PURE__*/_jsxs(Card, {
434
- tone: block.tone,
435
- testID: `buoy-block-notice-${block.id}`,
436
- children: [/*#__PURE__*/_jsxs(View, {
437
- style: styles.noticeRow,
438
- children: [/*#__PURE__*/_jsx(Icon, {
439
- size: 14,
440
- color: color
441
- }), /*#__PURE__*/_jsx(Text, {
442
- style: styles.noticeText,
443
- children: block.text
444
- })]
445
- }), /*#__PURE__*/_jsx(ActionRow, {
446
- actions: block.actions,
447
- blockId: block.id
448
- })]
449
- });
450
- }
451
- export function Finding({
452
- block
453
- }) {
454
- return /*#__PURE__*/_jsxs(Card, {
455
- title: block.title,
456
- source: block.source,
457
- testID: `buoy-block-finding-${block.id}`,
458
- tone: "warning",
459
- children: [block.evidence.map((e, i) => /*#__PURE__*/_jsxs(View, {
460
- style: [styles.kvRow, i > 0 && b.rowDivider],
461
- children: [/*#__PURE__*/_jsx(Text, {
462
- style: styles.kvKey,
463
- numberOfLines: 1,
464
- children: e.label
465
- }), /*#__PURE__*/_jsx(Text, {
466
- style: [styles.kvValue, e.tone && {
467
- color: toneColor(e.tone)
468
- }],
469
- numberOfLines: 3,
470
- children: e.value
471
- })]
472
- }, `${e.label}-${i}`)), /*#__PURE__*/_jsx(ActionRow, {
473
- actions: block.actions,
474
- blockId: block.id
475
- })]
476
- });
477
- }
478
- const styles = StyleSheet.create({
479
- flex: {
480
- flex: 1
481
- },
482
- tableHead: {
483
- flexDirection: "row",
484
- paddingHorizontal: 12,
485
- paddingVertical: 6,
486
- gap: 8,
487
- backgroundColor: night.color.fill
488
- },
489
- th: {
490
- flex: 1,
491
- color: night.color.textTertiary,
492
- fontSize: night.font.micro,
493
- fontWeight: "700",
494
- letterSpacing: 0.6,
495
- textTransform: "uppercase"
496
- },
497
- tr: {
498
- flexDirection: "row",
499
- paddingHorizontal: 12,
500
- paddingVertical: 8,
501
- gap: 8,
502
- alignItems: "center"
503
- },
504
- td: {
505
- flex: 1,
506
- color: night.color.textSecondary,
507
- fontSize: night.font.caption,
508
- lineHeight: 17
509
- },
510
- tdFirst: {
511
- color: night.color.text,
512
- fontWeight: "500"
513
- },
514
- firstCol: {
515
- flex: 1.4
516
- },
517
- kvRow: {
518
- flexDirection: "row",
519
- gap: 12,
520
- paddingHorizontal: 12,
521
- paddingVertical: 8,
522
- alignItems: "flex-start"
523
- },
524
- kvKey: {
525
- width: 110,
526
- color: night.color.textSecondary,
527
- fontSize: night.font.caption,
528
- paddingTop: 1
529
- },
530
- kvValue: {
531
- flex: 1,
532
- color: night.color.text,
533
- fontSize: night.font.caption,
534
- lineHeight: 17
535
- },
536
- thumb: {
537
- width: 40,
538
- height: 40,
539
- borderRadius: 8,
540
- backgroundColor: night.color.fill
541
- },
542
- // The enlarged picture, sitting above the row it belongs to. Same height and
543
- // fitting as `imageGrid`'s hero so the two blocks enlarge alike.
544
- listHero: {
545
- paddingHorizontal: 12,
546
- paddingTop: 12
547
- },
548
- listHeroImage: {
549
- width: "100%",
550
- height: 240,
551
- borderRadius: night.radius.row,
552
- backgroundColor: night.color.fill
553
- },
554
- rowAction: {
555
- color: night.color.accent,
556
- fontSize: night.font.caption,
557
- fontWeight: "600"
558
- },
559
- diffRow: {
560
- paddingHorizontal: 12,
561
- paddingVertical: 8,
562
- gap: 3
563
- },
564
- diffPath: {
565
- color: night.color.textSecondary,
566
- fontSize: night.font.micro,
567
- fontWeight: "600",
568
- letterSpacing: 0.3
569
- },
570
- diffLine: {
571
- flexDirection: "row",
572
- gap: 8,
573
- alignItems: "flex-start"
574
- },
575
- diffMark: {
576
- fontFamily: "Menlo",
577
- fontSize: 12,
578
- width: 10
579
- },
580
- diffValue: {
581
- flex: 1,
582
- fontFamily: "Menlo",
583
- fontSize: 12,
584
- lineHeight: 16
585
- },
586
- chart: {
587
- paddingHorizontal: 12,
588
- paddingVertical: 10,
589
- gap: 8
590
- },
591
- barRow: {
592
- flexDirection: "row",
593
- alignItems: "center",
594
- gap: 8
595
- },
596
- barLabel: {
597
- width: 96,
598
- color: night.color.textSecondary,
599
- fontSize: night.font.caption
600
- },
601
- barTrack: {
602
- flex: 1,
603
- height: 10,
604
- borderRadius: 5,
605
- backgroundColor: night.color.fill,
606
- overflow: "hidden"
607
- },
608
- bar: {
609
- height: 10,
610
- borderRadius: 5
611
- },
612
- barValue: {
613
- width: 72,
614
- textAlign: "right",
615
- color: night.color.text,
616
- fontSize: night.font.caption,
617
- fontWeight: "600"
618
- },
619
- step: {
620
- flexDirection: "row",
621
- alignItems: "center",
622
- gap: 10,
623
- paddingHorizontal: 12,
624
- paddingVertical: 9
625
- },
626
- stepMark: {
627
- width: 20,
628
- height: 20,
629
- borderRadius: 10,
630
- backgroundColor: night.color.fillTertiary,
631
- alignItems: "center",
632
- justifyContent: "center"
633
- },
634
- stepDone: {
635
- backgroundColor: night.color.accent
636
- },
637
- stepFailed: {
638
- backgroundColor: night.color.danger
639
- },
640
- stepNum: {
641
- color: night.color.text,
642
- fontSize: night.font.micro,
643
- fontWeight: "700"
644
- },
645
- stepTextDone: {
646
- color: night.color.textSecondary
647
- },
648
- // The explorer draws its own rows; this is only the inset that keeps them
649
- // off the card's edge, matching every other block's 12pt gutter.
650
- viewer: {
651
- paddingHorizontal: 4,
652
- paddingBottom: 8
653
- },
654
- code: {
655
- paddingHorizontal: 12,
656
- paddingVertical: 10,
657
- lineHeight: 17
658
- },
659
- noticeRow: {
660
- flexDirection: "row",
661
- alignItems: "flex-start",
662
- gap: 8,
663
- paddingHorizontal: 12,
664
- paddingTop: 10,
665
- paddingBottom: 4
666
- },
667
- noticeText: {
668
- flex: 1,
669
- color: night.color.text,
670
- fontSize: night.font.caption,
671
- lineHeight: 18
672
- }
673
- });
674
- //# sourceMappingURL=DataBlocks.js.map
1
+ "use strict";import{useState}from"react";import{Image,Pressable,StyleSheet,Text,View}from"react-native";import{AlertTriangle,Check,Info,night,X}from"@buoy-gg/shared-ui";import{DataViewer,TreeDiffViewer}from"@buoy-gg/shared-ui/dataViewer";import{CAPS}from"@buoy-gg/agent-core";import{ActionRow,blockStyles as b,Card,More,toneColor,useBlockHandlers,usePaged}from"./primitivesIndex";import{renderInline}from"../components/Markdown";import{useCopyAction}from"../components/useCopyAction";import{blockToText}from"./blockText";import{BlockIcon}from"./icons";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";function fmt(e){if(void 0===e)return"—";if(null===e)return"null";if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e)return String(e);try{const t=JSON.stringify(e);return t.length>120?`${t.slice(0,117)}…`:t}catch{return String(e)}}export function Table({block:e}){const t=usePaged(e.rows,CAPS.tableRows),{visible:o}=t,i=e.columns.slice(0,4);return _jsxs(Card,{title:e.title,source:e.source,testID:`buoy-block-table-${e.id}`,children:[_jsx(View,{style:styles.tableHead,children:i.map((e,t)=>_jsx(Text,{style:[styles.th,0===t&&styles.firstCol],numberOfLines:1,children:e},e))}),o.map((e,t)=>_jsx(View,{style:[styles.tr,t>0&&b.rowDivider],children:i.map((t,o)=>{const i=e[o],n="string"==typeof i?i:i?.text??"",l="string"==typeof i?void 0:i?.tone;return _jsx(Text,{style:[styles.td,0===o&&styles.firstCol,0===o&&styles.tdFirst,l&&{color:toneColor(l)}],numberOfLines:2,children:renderInline(n,styles.td)},o)})},t)),_jsx(More,{paged:t})]})}export function KeyValue({block:e}){const t=usePaged(e.pairs,CAPS.keyValuePairs),{visible:o}=t,[i,n]=useState(null);return _jsxs(Card,{title:e.title,source:e.source,testID:`buoy-block-keyvalue-${e.id}`,children:[o.map((e,t)=>{const o="object"==typeof e.value&&null!==e.value,l=i===e.key;return _jsxs(Pressable,{onPress:o?()=>n(l?null:e.key):void 0,style:[styles.kvRow,t>0&&b.rowDivider],children:[_jsx(Text,{style:styles.kvKey,numberOfLines:1,children:e.key}),_jsx(Text,{style:[styles.kvValue,l&&b.mono],numberOfLines:l?void 0:2,selectable:!0,children:l?JSON.stringify(e.value,null,2):fmt(e.value)})]},e.key)}),_jsx(More,{paged:t})]})}export function listRowBehaviour(e){const t=Boolean(e.image);return{canExpand:t,rowRunsAction:Boolean(e.action)&&!t,actionIsOwnControl:Boolean(e.action)&&t}}export function List({block:e}){const t=useBlockHandlers(),o=usePaged(e.items,CAPS.listItems),{visible:i}=o,[n,l]=useState(null);return _jsxs(Card,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[i.map((o,i)=>{const r=`${o.id??o.title}-${i}`,s=n===r,{canExpand:c,rowRunsAction:a,actionIsOwnControl:d}=listRowBehaviour(o),u=c||a?Pressable:View,f=c?{onPress:()=>l(s?null:r),accessibilityRole:"button",accessibilityState:{expanded:s},accessibilityLabel:`${o.title}, ${s?"hide":"show"} picture`,testID:`buoy-block-list-row-${r}`}:a?{onPress:()=>{t.runAction(o.action,e.id)},accessibilityRole:"button"}:{};return _jsxs(View,{style:i>0?b.rowDivider:void 0,children:[s&&o.image?_jsx(Pressable,{onPress:()=>l(null),accessibilityRole:"button",accessibilityLabel:`Hide ${o.title}`,testID:`buoy-block-list-hero-${r}`,style:styles.listHero,children:_jsx(Image,{source:{uri:o.image},style:styles.listHeroImage,resizeMode:"contain",accessibilityLabel:o.title})}):null,_jsxs(u,{...f,style:b.row,children:[o.image&&!s?_jsx(Image,{source:{uri:o.image},style:styles.thumb,resizeMode:"contain",accessibilityLabel:o.title}):o.icon?_jsx(BlockIcon,{name:o.icon}):null,_jsxs(View,{style:styles.flex,children:[_jsx(Text,{style:[b.rowTitle,o.tone&&{color:toneColor(o.tone)}],numberOfLines:s?void 0:2,children:renderInline(o.title,b.rowTitle)}),o.subtitle?_jsx(Text,{style:b.rowSub,numberOfLines:s?void 0:2,children:renderInline(o.subtitle,b.rowSub)}):null]}),o.trailing?_jsx(Text,{style:[b.rowTrailing,o.tone&&{color:toneColor(o.tone)}],numberOfLines:1,children:o.trailing}):null,o.action?d?_jsx(Pressable,{onPress:()=>{t.runAction(o.action,e.id)},accessibilityRole:"button",accessibilityLabel:o.action.label,hitSlop:8,children:_jsx(Text,{style:styles.rowAction,children:o.action.label})}):_jsx(Text,{style:styles.rowAction,children:o.action.label}):null]})]},r)}),_jsx(More,{paged:o})]})}function isStructured(e){return null!==e&&"object"==typeof e}function diffSummary(e){const t=e.map(e=>e.path),o=t.slice(0,3).join(", "),i=t.length-3;return`${1===t.length?"1 field":`${t.length} fields`} · ${o}${i>0?`, +${i}`:""}`}export function Diff({block:e}){const t=usePaged(e.changes,CAPS.keyValuePairs);return _jsxs(Card,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,collapsible:!0,summary:diffSummary(e.changes),children:[t.visible.map((e,t)=>{const o=void 0===e.before&&void 0!==e.after,i=void 0===e.after&&void 0!==e.before;return _jsxs(View,{style:[styles.diffRow,t>0&&b.rowDivider],children:[_jsx(Text,{style:styles.diffPath,numberOfLines:1,children:e.path}),isStructured(e.before)||isStructured(e.after)?_jsx(View,{style:styles.diffTree,children:_jsx(TreeDiffViewer,{oldValue:e.before,newValue:e.after,showUnchanged:!1,scrollEnabled:!1})}):_jsxs(_Fragment,{children:[o?null:_jsxs(View,{style:styles.diffLine,children:[_jsx(Text,{style:[styles.diffMark,{color:night.color.danger}],children:"−"}),_jsx(Text,{style:[styles.diffValue,{color:night.color.danger}],numberOfLines:3,selectable:!0,children:fmt(e.before)})]}),i?null:_jsxs(View,{style:styles.diffLine,children:[_jsx(Text,{style:[styles.diffMark,{color:night.color.accent}],children:"+"}),_jsx(Text,{style:[styles.diffValue,{color:night.color.accent}],numberOfLines:3,selectable:!0,children:fmt(e.after)})]})]})]},`${e.path}-${t}`)}),_jsx(More,{paged:t})]})}export function Chart({block:e}){const t=e.bars.slice(0,CAPS.chartBars),o=e.max??Math.max(1,...t.map(e=>e.value));return _jsx(Card,{title:e.title,source:e.source,testID:`buoy-block-chart-${e.id}`,children:_jsx(View,{style:styles.chart,children:t.map((e,t)=>_jsxs(View,{style:styles.barRow,children:[_jsx(Text,{style:styles.barLabel,numberOfLines:1,children:e.label}),_jsx(View,{style:styles.barTrack,children:_jsx(View,{style:[styles.bar,{width:`${Math.max(2,Math.round(e.value/o*100))}%`,backgroundColor:toneColor(e.tone??"accent")}]})}),_jsxs(Text,{style:styles.barValue,numberOfLines:1,children:[e.value,e.unit?` ${e.unit}`:""]})]},`${e.label}-${t}`))})})}export function Steps({block:e}){return _jsx(Card,{title:e.title,testID:`buoy-block-steps-${e.id}`,children:e.steps.map((e,t)=>_jsxs(View,{style:[styles.step,t>0&&b.rowDivider],children:[_jsx(View,{style:[styles.stepMark,"done"===e.state&&styles.stepDone,"failed"===e.state&&styles.stepFailed],children:"done"===e.state?_jsx(Check,{size:10,color:night.color.onAccent}):"failed"===e.state?_jsx(X,{size:10,color:night.color.text}):_jsx(Text,{style:styles.stepNum,children:t+1})}),_jsx(Text,{style:[b.rowTitle,"done"===e.state&&styles.stepTextDone],children:e.text})]},t))})}function parseJson(e){try{const t=JSON.parse(e);return null!==t&&"object"==typeof t?t:void 0}catch{return}}function JsonCode({block:e,value:t}){return _jsx(Card,{title:e.title,testID:`buoy-block-code-${e.id}`,children:_jsx(View,{style:styles.viewer,children:_jsx(DataViewer,{title:e.title??"Payload",data:t,initialExpanded:!0,showTypeFilter:!1,testIDPrefix:`buoy-block-code-${e.id}`})})})}function TextCode({block:e}){return _jsx(Card,{title:e.title,testID:`buoy-block-code-${e.id}`,children:_jsx(Text,{style:[b.mono,styles.code],selectable:!0,children:e.text})})}export function Code({block:e}){const t=parseJson(e.text);return void 0===t?_jsx(TextCode,{block:e}):_jsx(JsonCode,{block:e,value:t})}export function Notice({block:e}){const t="danger"===e.tone?night.color.danger:"warning"===e.tone?night.color.warning:night.color.info,o="info"===e.tone?Info:AlertTriangle;return _jsxs(Card,{tone:e.tone,testID:`buoy-block-notice-${e.id}`,children:[_jsxs(View,{style:styles.noticeRow,children:[_jsx(o,{size:14,color:t}),_jsx(Text,{style:styles.noticeText,children:e.text})]}),_jsx(ActionRow,{actions:e.actions,blockId:e.id})]})}export function Finding({block:e}){const{copied:t,copy:o}=useCopyAction(()=>blockToText(e)??e.title);return _jsxs(Card,{title:e.title,source:e.source,testID:`buoy-block-finding-${e.id}`,tone:"warning",children:[e.evidence.map((e,t)=>_jsxs(View,{style:[styles.kvRow,t>0&&b.rowDivider],children:[_jsx(Text,{style:styles.kvKey,numberOfLines:1,children:e.label}),_jsx(Text,{style:[styles.kvValue,e.tone&&{color:toneColor(e.tone)}],selectable:!0,children:e.value})]},`${e.label}-${t}`)),_jsx(View,{style:styles.findingFoot,children:_jsx(Pressable,{testID:`buoy-block-finding-copy-${e.id}`,accessibilityRole:"button",accessibilityLabel:t?"Copied":"Copy this finding",onPress:o,style:({pressed:e})=>[styles.findingCopy,e&&{opacity:.7}],children:_jsx(Text,{style:[styles.findingCopyText,t&&{color:night.color.accent}],children:t?"Copied":"Copy finding"})})}),_jsx(ActionRow,{actions:e.actions,blockId:e.id})]})}const styles=StyleSheet.create({flex:{flex:1},tableHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,gap:8,backgroundColor:night.color.fill},th:{flex:1,color:night.color.textTertiary,fontSize:night.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"center"},td:{flex:1,color:night.color.textSecondary,fontSize:night.font.caption,lineHeight:17},tdFirst:{color:night.color.text,fontWeight:"500"},firstCol:{flex:1.4},kvRow:{flexDirection:"row",gap:12,paddingHorizontal:12,paddingVertical:8,alignItems:"flex-start"},kvKey:{width:110,color:night.color.textSecondary,fontSize:night.font.caption,paddingTop:1},kvValue:{flex:1,color:night.color.text,fontSize:night.font.caption,lineHeight:17},findingFoot:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,borderTopWidth:StyleSheet.hairlineWidth,borderTopColor:night.color.separator},findingCopy:{paddingHorizontal:10,paddingVertical:5,borderRadius:night.radius.badge,backgroundColor:night.color.fill},findingCopyText:{color:night.color.textSecondary,fontSize:night.font.micro,fontWeight:"600"},thumb:{width:40,height:40,borderRadius:8,backgroundColor:night.color.fill},listHero:{paddingHorizontal:12,paddingTop:12},listHeroImage:{width:"100%",height:240,borderRadius:night.radius.row,backgroundColor:night.color.fill},rowAction:{color:night.color.accent,fontSize:night.font.caption,fontWeight:"600"},diffRow:{paddingHorizontal:12,paddingVertical:8,gap:3},diffPath:{color:night.color.textSecondary,fontSize:night.font.micro,fontWeight:"600",letterSpacing:.3},diffLine:{flexDirection:"row",gap:8,alignItems:"flex-start"},diffMark:{fontFamily:"Menlo",fontSize:12,width:10},diffValue:{flex:1,fontFamily:"Menlo",fontSize:12,lineHeight:16},diffTree:{borderRadius:night.radius.row,overflow:"hidden"},chart:{paddingHorizontal:12,paddingVertical:10,gap:8},barRow:{flexDirection:"row",alignItems:"center",gap:8},barLabel:{width:96,color:night.color.textSecondary,fontSize:night.font.caption},barTrack:{flex:1,height:10,borderRadius:5,backgroundColor:night.color.fill,overflow:"hidden"},bar:{height:10,borderRadius:5},barValue:{width:72,textAlign:"right",color:night.color.text,fontSize:night.font.caption,fontWeight:"600"},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:night.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:night.color.accent},stepFailed:{backgroundColor:night.color.danger},stepNum:{color:night.color.text,fontSize:night.font.micro,fontWeight:"700"},stepTextDone:{color:night.color.textSecondary},viewer:{paddingHorizontal:4,paddingBottom:8},code:{paddingHorizontal:12,paddingVertical:10,lineHeight:17},noticeRow:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:4},noticeText:{flex:1,color:night.color.text,fontSize:night.font.caption,lineHeight:18}});