@btndprojects/loam-ui-native 0.2.1 → 0.3.1

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 (365) hide show
  1. package/dist/accordion/index.js +4 -2
  2. package/dist/adaptive/index.js +12 -2
  3. package/dist/address-block/index.js +23 -0
  4. package/dist/alert/index.js +5 -2
  5. package/dist/analyzer/index.js +13 -5
  6. package/dist/announcement/index.js +15 -5
  7. package/dist/appearance-picker/index.js +15 -0
  8. package/dist/audio-player/index.js +26 -2
  9. package/dist/avatar/index.js +2 -2
  10. package/dist/avatar-group/index.js +5 -3
  11. package/dist/badge/index.js +6 -3
  12. package/dist/banner/index.js +3 -2
  13. package/dist/board/index.js +13 -6
  14. package/dist/button/index.js +6 -3
  15. package/dist/camera-permission/index.js +19 -11
  16. package/dist/capture-result/index.js +26 -16
  17. package/dist/card/index.js +7 -3
  18. package/dist/card-form/index.js +15 -9
  19. package/dist/carousel/index.js +3 -1
  20. package/dist/chart/index.js +15 -5
  21. package/dist/charts/index.js +18 -5
  22. package/dist/chat/index.js +35 -10
  23. package/dist/checkbox/index.js +6 -4
  24. package/dist/checklist/index.js +16 -7
  25. package/dist/checkout/index.js +25 -12
  26. package/dist/chip/index.js +7 -4
  27. package/dist/chunk-2BZD3NAP.js +1110 -0
  28. package/dist/chunk-2YKVID2V.js +35 -0
  29. package/dist/{chunk-H7DWSL4O.js → chunk-36DA3IPO.js} +115 -27
  30. package/dist/chunk-3A56MIAN.js +599 -0
  31. package/dist/{chunk-AEB7KCHQ.js → chunk-3SCKCWF5.js} +39 -28
  32. package/dist/chunk-3TZNDHKO.js +187 -0
  33. package/dist/chunk-43K3BLXV.js +9 -0
  34. package/dist/chunk-46ZJIQ2Z.js +208 -0
  35. package/dist/{chunk-PMMTGBBS.js → chunk-4CZMQDQL.js} +75 -22
  36. package/dist/chunk-4QCR3K2J.js +1 -0
  37. package/dist/{chunk-E2E3I5W2.js → chunk-5DTKORLI.js} +54 -45
  38. package/dist/{chunk-5VFZRGVD.js → chunk-5J4WFXFA.js} +32 -15
  39. package/dist/{chunk-JBMLWFSJ.js → chunk-5KJ7TEQ6.js} +83 -48
  40. package/dist/chunk-5NU33TXK.js +529 -0
  41. package/dist/chunk-6KSUS7DF.js +690 -0
  42. package/dist/{chunk-3WEZCGHX.js → chunk-6RV6UW2J.js} +140 -56
  43. package/dist/chunk-6RZM7RP2.js +520 -0
  44. package/dist/{chunk-JJLPBRVZ.js → chunk-75BDCC7K.js} +2 -0
  45. package/dist/{chunk-U5NLHYV6.js → chunk-7CGJBQUA.js} +333 -22
  46. package/dist/{chunk-I4FHVKEC.js → chunk-7IVF6JLJ.js} +16 -5
  47. package/dist/chunk-7IWCGXYA.js +143 -0
  48. package/dist/chunk-7LM4ASFH.js +172 -0
  49. package/dist/chunk-7MCEJFWV.js +341 -0
  50. package/dist/{chunk-2SY63FCH.js → chunk-7NGMUVNU.js} +66 -30
  51. package/dist/chunk-7PBSIXT7.js +355 -0
  52. package/dist/chunk-7QOYGENL.js +443 -0
  53. package/dist/{chunk-TDMG26JI.js → chunk-A7SWYDE5.js} +40 -9
  54. package/dist/chunk-ADHPJALR.js +3051 -0
  55. package/dist/{chunk-ZLTO5VQI.js → chunk-ALJYZLNQ.js} +131 -61
  56. package/dist/{chunk-GDKVKNR2.js → chunk-AQ5FIG74.js} +110 -30
  57. package/dist/chunk-B2MMZZQB.js +426 -0
  58. package/dist/{chunk-QYPE5JX3.js → chunk-B7JZ3N5G.js} +142 -105
  59. package/dist/{chunk-QHTVYA65.js → chunk-BL37SW6G.js} +388 -102
  60. package/dist/chunk-BTRMA7GC.js +21 -0
  61. package/dist/{chunk-FUMHAAF3.js → chunk-C7IUWIUZ.js} +243 -92
  62. package/dist/chunk-CA3DUVYD.js +10 -0
  63. package/dist/{chunk-FYWNRX4F.js → chunk-CBCJSO2B.js} +143 -13
  64. package/dist/chunk-CHPX4MFI.js +239 -0
  65. package/dist/chunk-CLGAMIOT.js +648 -0
  66. package/dist/chunk-CUE7VML6.js +1141 -0
  67. package/dist/{chunk-D5N5QWI7.js → chunk-CVU6S2E5.js} +497 -235
  68. package/dist/{chunk-U23FYWME.js → chunk-CXPQMA6Z.js} +101 -34
  69. package/dist/{chunk-36EC2T6P.js → chunk-D2LN4I7I.js} +1 -1
  70. package/dist/{chunk-TLCIR6RG.js → chunk-D34LNBO5.js} +411 -155
  71. package/dist/{chunk-FV6HMP7W.js → chunk-D4BCQICM.js} +207 -65
  72. package/dist/chunk-EABKIIA4.js +1 -0
  73. package/dist/chunk-EICSYRAG.js +341 -0
  74. package/dist/chunk-EMWAJMAS.js +83 -0
  75. package/dist/chunk-EOLZWRV6.js +149 -0
  76. package/dist/chunk-EOQVTGB6.js +350 -0
  77. package/dist/{chunk-ZVATDZOM.js → chunk-ESGUHNB2.js} +106 -28
  78. package/dist/{chunk-46MMSDGL.js → chunk-F2KNBPKY.js} +104 -73
  79. package/dist/{chunk-KQZ3GLHR.js → chunk-G7H3NX3G.js} +40 -17
  80. package/dist/{chunk-3QMEOFW5.js → chunk-GM7YIPB7.js} +421 -207
  81. package/dist/{chunk-QHAITQIF.js → chunk-GVQQG435.js} +256 -86
  82. package/dist/chunk-HE43OMEL.js +1056 -0
  83. package/dist/{chunk-XIDTBCBA.js → chunk-HHOMFQ7R.js} +1049 -207
  84. package/dist/chunk-HNAKS4Z3.js +207 -0
  85. package/dist/chunk-HP6ST2OW.js +352 -0
  86. package/dist/chunk-HW3OWDTU.js +1 -0
  87. package/dist/{chunk-QP3KMOVF.js → chunk-HZDB44K4.js} +24 -14
  88. package/dist/chunk-I6CUP2LW.js +1155 -0
  89. package/dist/chunk-ICV4Y2WY.js +27 -0
  90. package/dist/chunk-IHSIENOE.js +3950 -0
  91. package/dist/{chunk-T5LTPKX6.js → chunk-IMMALLRU.js} +53 -25
  92. package/dist/{chunk-C4GTDLRC.js → chunk-JA6TK7H2.js} +154 -67
  93. package/dist/{chunk-EVOIGUBI.js → chunk-JAVZ5JPV.js} +43 -13
  94. package/dist/{chunk-CPTOADB2.js → chunk-JCMTP3E4.js} +527 -201
  95. package/dist/{chunk-OJQUBQWA.js → chunk-JCXFFK64.js} +73 -16
  96. package/dist/{chunk-V2OEB75Z.js → chunk-JWCVBFDU.js} +75 -35
  97. package/dist/chunk-JXRTD5RI.js +414 -0
  98. package/dist/chunk-JYIUZUIQ.js +1567 -0
  99. package/dist/chunk-K3TK3GIV.js +219 -0
  100. package/dist/chunk-KEVZIHM2.js +1511 -0
  101. package/dist/{chunk-VAOAKWUK.js → chunk-KHZDNQQD.js} +42 -8
  102. package/dist/chunk-KL4GDV4V.js +131 -0
  103. package/dist/{chunk-Q6NKEPRE.js → chunk-KNILMM4H.js} +73 -28
  104. package/dist/chunk-KRBUZV45.js +25 -0
  105. package/dist/{chunk-7BUIKDD6.js → chunk-KXLDK6HB.js} +91 -30
  106. package/dist/chunk-KZ3X7TSL.js +196 -0
  107. package/dist/{chunk-5UTRIXQ6.js → chunk-L2WMOA2V.js} +187 -43
  108. package/dist/chunk-L4D5LHCH.js +109 -0
  109. package/dist/{chunk-W63AJTM7.js → chunk-LAUJPLDB.js} +236 -71
  110. package/dist/{chunk-TN2ZNJUI.js → chunk-LGNTP5XA.js} +47 -13
  111. package/dist/chunk-LUZFCCSD.js +271 -0
  112. package/dist/{chunk-XTORZWRF.js → chunk-LXJCP4PL.js} +111 -30
  113. package/dist/chunk-MCOZJWPU.js +731 -0
  114. package/dist/{chunk-SATMR6SG.js → chunk-MG4SKWLL.js} +780 -142
  115. package/dist/{chunk-JUYWSSKW.js → chunk-MPEPTSER.js} +95 -16
  116. package/dist/chunk-MWPJ4YGP.js +1 -0
  117. package/dist/{chunk-LUMVGO2K.js → chunk-N7AX4OA4.js} +80 -29
  118. package/dist/chunk-NHSLM6SE.js +523 -0
  119. package/dist/{chunk-IT6FUXXG.js → chunk-NNJLVA7M.js} +43 -11
  120. package/dist/{chunk-TQVAIKFD.js → chunk-NZG75DGA.js} +102 -62
  121. package/dist/chunk-O76QXRBV.js +431 -0
  122. package/dist/chunk-OANH27AK.js +223 -0
  123. package/dist/chunk-OCHPK5YV.js +609 -0
  124. package/dist/chunk-OMHVEVX4.js +436 -0
  125. package/dist/{chunk-SWS5JQIF.js → chunk-ONKQUJWD.js} +187 -60
  126. package/dist/chunk-OVTK7A6T.js +615 -0
  127. package/dist/{chunk-UXGIW7OK.js → chunk-PCEFCOLN.js} +5 -1
  128. package/dist/{chunk-QIKT7LIB.js → chunk-PFLNFIVB.js} +91 -23
  129. package/dist/chunk-PHSZY37H.js +300 -0
  130. package/dist/chunk-PJLTKDVY.js +18 -0
  131. package/dist/{chunk-SHHY5OMK.js → chunk-PK7BN3MI.js} +83 -15
  132. package/dist/{chunk-YXOAPXMU.js → chunk-PWFRDRGS.js} +101 -14
  133. package/dist/{chunk-TY4MTKQJ.js → chunk-PYPMD46W.js} +332 -66
  134. package/dist/chunk-Q6CCHDI7.js +331 -0
  135. package/dist/chunk-QFA5WS2A.js +750 -0
  136. package/dist/chunk-QJMMM4RC.js +124 -0
  137. package/dist/chunk-QYWEVAM6.js +407 -0
  138. package/dist/chunk-R5T4VZ7Z.js +126 -0
  139. package/dist/chunk-R77HFLZD.js +1 -0
  140. package/dist/{chunk-LMPHCVJJ.js → chunk-RAESDNU5.js} +162 -68
  141. package/dist/chunk-RBYQUXNL.js +1 -0
  142. package/dist/chunk-RCM3DT5E.js +1 -0
  143. package/dist/chunk-RGNY56L7.js +282 -0
  144. package/dist/chunk-RIK6UX2K.js +344 -0
  145. package/dist/{chunk-5LAAAXFP.js → chunk-RJA3RXO3.js} +63 -54
  146. package/dist/chunk-RJYRJ3LD.js +1 -0
  147. package/dist/chunk-RMA3NOY4.js +599 -0
  148. package/dist/{chunk-VDPK5CY4.js → chunk-RSWKKAHK.js} +143 -61
  149. package/dist/{chunk-B7N4ASYE.js → chunk-RVOIIX3V.js} +17 -45
  150. package/dist/chunk-SA2RRBGT.js +1077 -0
  151. package/dist/{chunk-7OVVSVEZ.js → chunk-SG3J4R45.js} +440 -169
  152. package/dist/chunk-SPUK7JD4.js +238 -0
  153. package/dist/chunk-SWXV2K5N.js +434 -0
  154. package/dist/chunk-SYJEPXP6.js +1303 -0
  155. package/dist/{chunk-LKFC4CS7.js → chunk-SZLI34TA.js} +18 -9
  156. package/dist/{chunk-NBEF4EPJ.js → chunk-T77WJA74.js} +131 -16
  157. package/dist/chunk-TDWWVJA4.js +630 -0
  158. package/dist/chunk-TFHI5XDR.js +610 -0
  159. package/dist/chunk-TH4PW2WU.js +17 -0
  160. package/dist/chunk-TTQ24HQX.js +12 -0
  161. package/dist/chunk-TUACVJNG.js +12 -0
  162. package/dist/{chunk-F5B3UINI.js → chunk-TUL5RUIA.js} +171 -62
  163. package/dist/{chunk-C6APNDVA.js → chunk-TYOSA7JG.js} +63 -34
  164. package/dist/chunk-TYQTMMEV.js +1 -0
  165. package/dist/{chunk-DW3L54DQ.js → chunk-TZO6YDS7.js} +53 -12
  166. package/dist/{chunk-67IZZ2MJ.js → chunk-U3ETF22F.js} +75 -30
  167. package/dist/{chunk-EDCBJV7J.js → chunk-U6BYHD2N.js} +87 -31
  168. package/dist/{chunk-ENP3BMZU.js → chunk-UF6EJXPQ.js} +16 -1
  169. package/dist/{chunk-IPUNJMAQ.js → chunk-UNNQIPGK.js} +304 -68
  170. package/dist/chunk-UQVO6AJV.js +171 -0
  171. package/dist/{chunk-FZGAAOKS.js → chunk-VFDQAAIW.js} +138 -32
  172. package/dist/chunk-VIUE3VQT.js +1 -0
  173. package/dist/{chunk-5RENVKBQ.js → chunk-VJLSSSGC.js} +126 -30
  174. package/dist/chunk-VLMT6KYT.js +350 -0
  175. package/dist/chunk-VMHGBUGS.js +35 -0
  176. package/dist/{chunk-4IZXHVFJ.js → chunk-VQKPBYW6.js} +228 -172
  177. package/dist/{chunk-G6UESEVN.js → chunk-VSSTWLC5.js} +49 -11
  178. package/dist/{chunk-TRGFFU6A.js → chunk-VZYYZRPN.js} +866 -330
  179. package/dist/{chunk-JLC6PM5S.js → chunk-WAIJCD2V.js} +128 -54
  180. package/dist/chunk-WFMQ3WKM.js +378 -0
  181. package/dist/chunk-WJ2KDRMY.js +66 -0
  182. package/dist/chunk-WKFZJO54.js +437 -0
  183. package/dist/{chunk-QEYFDRHR.js → chunk-WVVD3XOV.js} +146 -84
  184. package/dist/chunk-XAIWMSLB.js +1 -0
  185. package/dist/chunk-XBXUBBJZ.js +98 -0
  186. package/dist/chunk-XCU7MYBJ.js +1 -0
  187. package/dist/chunk-XHE4PGCI.js +717 -0
  188. package/dist/chunk-XRSJ32M3.js +331 -0
  189. package/dist/chunk-XTCVOEAW.js +1 -0
  190. package/dist/chunk-XWGXVQF6.js +58 -0
  191. package/dist/{chunk-MKSNFG7H.js → chunk-Y3XKKO5K.js} +191 -109
  192. package/dist/chunk-Y4QNMBLO.js +533 -0
  193. package/dist/chunk-Y5H4CTKO.js +1 -0
  194. package/dist/chunk-YBQIN75A.js +403 -0
  195. package/dist/{chunk-PNF3NKB5.js → chunk-YJ5PXOX3.js} +28 -11
  196. package/dist/{chunk-M656FYNH.js → chunk-YLRSRUPS.js} +63 -49
  197. package/dist/chunk-YM6MPJ4A.js +1 -0
  198. package/dist/chunk-YV7KZENV.js +200 -0
  199. package/dist/chunk-Z7I4ZSO6.js +316 -0
  200. package/dist/{chunk-EY4DD67D.js → chunk-ZIRMWD2B.js} +199 -126
  201. package/dist/chunk-ZPMG3FWU.js +75 -0
  202. package/dist/{chunk-QRUMA22E.js → chunk-ZTXMK2G7.js} +92 -43
  203. package/dist/{chunk-2OLKPG4E.js → chunk-ZVJCWXAL.js} +189 -87
  204. package/dist/{chunk-YAAHPATV.js → chunk-ZYQ23DPT.js} +49 -34
  205. package/dist/coachmark/index.js +7 -3
  206. package/dist/code-block/index.js +4 -3
  207. package/dist/color-field/index.js +12 -4
  208. package/dist/color-picker/index.js +23 -0
  209. package/dist/commerce/index.js +27 -16
  210. package/dist/confirm/index.js +31 -0
  211. package/dist/connection-card/index.js +34 -0
  212. package/dist/connectivity/index.js +3 -2
  213. package/dist/context-menu/index.js +10 -2
  214. package/dist/copy-button/index.js +3 -2
  215. package/dist/data-grid/index.js +30 -17
  216. package/dist/date-range-picker/index.js +19 -9
  217. package/dist/description-list/index.js +4 -1
  218. package/dist/device-frame/index.js +30 -0
  219. package/dist/dialog/index.js +8 -2
  220. package/dist/divider/index.js +2 -0
  221. package/dist/empty-state/index.js +13 -2
  222. package/dist/error-summary/index.js +7 -2
  223. package/dist/fab/index.js +4 -2
  224. package/dist/file-manager/index.js +33 -17
  225. package/dist/file-upload/index.js +12 -6
  226. package/dist/filter-bar/index.js +10 -6
  227. package/dist/flow-run/index.js +19 -12
  228. package/dist/form/index.js +30 -3
  229. package/dist/gallery/index.js +5 -2
  230. package/dist/hold-to-confirm/index.js +4 -2
  231. package/dist/hover-card/index.js +18 -0
  232. package/dist/icon-tile/index.js +10 -0
  233. package/dist/image/index.js +9 -0
  234. package/dist/index.d.ts +29826 -17941
  235. package/dist/index.js +197 -141
  236. package/dist/infinite-list/index.js +4 -2
  237. package/dist/inline-edit/index.js +5 -4
  238. package/dist/input/index.js +4 -3
  239. package/dist/interactions/index.js +4 -1
  240. package/dist/invoice/index.js +18 -9
  241. package/dist/job-row/index.js +22 -0
  242. package/dist/json-inspector/index.js +20 -0
  243. package/dist/kbd/index.js +2 -2
  244. package/dist/keyboard/index.js +7 -2
  245. package/dist/level-meter/index.js +9 -0
  246. package/dist/list-row/index.js +11 -3
  247. package/dist/log-viewer/index.js +9 -2
  248. package/dist/map-view/index.js +13 -2
  249. package/dist/markdown/index.js +8 -5
  250. package/dist/metric/index.js +6 -3
  251. package/dist/metric-strip/index.js +12 -0
  252. package/dist/money/index.js +11 -4
  253. package/dist/nav-drawer/index.js +6 -2
  254. package/dist/nav-header/index.js +10 -4
  255. package/dist/navigation/index.js +29 -2
  256. package/dist/notification-center/index.js +24 -10
  257. package/dist/number-roll/index.js +3 -1
  258. package/dist/onboarding-pager/index.js +22 -0
  259. package/dist/one-handed/index.js +2 -2
  260. package/dist/os-surfaces/index.js +6 -3
  261. package/dist/otp/index.js +5 -4
  262. package/dist/page-header/index.js +2 -1
  263. package/dist/pagination/index.js +4 -2
  264. package/dist/payment-method/index.js +17 -11
  265. package/dist/payment-status/index.js +22 -14
  266. package/dist/permission/index.js +18 -2
  267. package/dist/picker/index.js +17 -6
  268. package/dist/progress/index.js +7 -2
  269. package/dist/provenance/index.js +16 -0
  270. package/dist/pull-to-refresh/index.js +2 -2
  271. package/dist/qr-code/index.js +16 -0
  272. package/dist/query-builder/index.js +30 -0
  273. package/dist/radio-group/index.js +6 -4
  274. package/dist/rating/index.js +7 -2
  275. package/dist/receivables/index.js +31 -18
  276. package/dist/recording-indicator/index.js +21 -0
  277. package/dist/refund/index.js +24 -15
  278. package/dist/repeatable-rows/index.js +19 -0
  279. package/dist/save-status/index.js +5 -3
  280. package/dist/screen/index.js +3 -0
  281. package/dist/scroll-area/index.js +1 -1
  282. package/dist/search-field/index.js +8 -3
  283. package/dist/secret-field/index.js +19 -0
  284. package/dist/section-header/index.js +4 -0
  285. package/dist/segmented-control/index.js +2 -2
  286. package/dist/sheet/index.js +9 -3
  287. package/dist/shortcuts-sheet/index.js +2 -0
  288. package/dist/sign-in-screen/index.js +25 -0
  289. package/dist/skeleton/index.js +3 -1
  290. package/dist/slider/index.js +2 -1
  291. package/dist/sortable/index.js +4 -3
  292. package/dist/spinner/index.js +2 -1
  293. package/dist/split-button/index.js +17 -5
  294. package/dist/spotlight/index.js +7 -1
  295. package/dist/stack/index.js +2 -0
  296. package/dist/stage-timeline/index.js +6 -3
  297. package/dist/status-dot/index.js +6 -2
  298. package/dist/stepper/index.js +7 -3
  299. package/dist/streaming-text/index.js +2 -1
  300. package/dist/survey/index.js +24 -14
  301. package/dist/switch/index.js +6 -2
  302. package/dist/system-state/index.js +12 -4
  303. package/dist/tab-bar/index.js +10 -2
  304. package/dist/tabs/index.js +10 -2
  305. package/dist/tags-input/index.js +8 -5
  306. package/dist/text/index.js +4 -0
  307. package/dist/textarea/index.js +5 -4
  308. package/dist/thinking/index.js +4 -1
  309. package/dist/tile-rail/index.js +10 -0
  310. package/dist/time-field/index.js +15 -7
  311. package/dist/time-range-control/index.js +26 -12
  312. package/dist/timeline/index.js +2 -2
  313. package/dist/toast/index.js +4 -2
  314. package/dist/toolbar/index.js +3 -2
  315. package/dist/tour/index.js +12 -10
  316. package/dist/transcript/index.js +28 -0
  317. package/dist/truncation-notice/index.js +2 -2
  318. package/dist/update-notice/index.js +15 -8
  319. package/dist/video-player/index.js +26 -2
  320. package/dist/viewfinder/index.js +12 -4
  321. package/dist/widget/index.js +11 -4
  322. package/dist/wizard/index.js +7 -4
  323. package/package.json +13 -13
  324. package/dist/chunk-2PKYGLQ6.js +0 -268
  325. package/dist/chunk-2SWKL3AJ.js +0 -466
  326. package/dist/chunk-2TXERVVA.js +0 -1081
  327. package/dist/chunk-3DUWIYV5.js +0 -437
  328. package/dist/chunk-3NMD74ZU.js +0 -4
  329. package/dist/chunk-4DS5ZWVC.js +0 -83
  330. package/dist/chunk-6YAQBXB3.js +0 -93
  331. package/dist/chunk-74FLKD24.js +0 -237
  332. package/dist/chunk-CMTVNF3D.js +0 -104
  333. package/dist/chunk-DN7MNQIP.js +0 -799
  334. package/dist/chunk-DVGBZ3TX.js +0 -455
  335. package/dist/chunk-F3H33DQX.js +0 -300
  336. package/dist/chunk-FAJI7BSC.js +0 -443
  337. package/dist/chunk-G3AFC24V.js +0 -60
  338. package/dist/chunk-HJLPZA4X.js +0 -369
  339. package/dist/chunk-HYEOQWT7.js +0 -647
  340. package/dist/chunk-IDM7JJMO.js +0 -110
  341. package/dist/chunk-IVKMZ7BB.js +0 -326
  342. package/dist/chunk-IXKWIFWZ.js +0 -334
  343. package/dist/chunk-JV5YOTOB.js +0 -164
  344. package/dist/chunk-KFJGFLMW.js +0 -158
  345. package/dist/chunk-LQP4KEXZ.js +0 -214
  346. package/dist/chunk-NTQ2F3AU.js +0 -257
  347. package/dist/chunk-O5V4TG3V.js +0 -329
  348. package/dist/chunk-OWAMM2DK.js +0 -280
  349. package/dist/chunk-PID3NJB7.js +0 -405
  350. package/dist/chunk-QDZGFXQD.js +0 -176
  351. package/dist/chunk-QPWDDJJ4.js +0 -385
  352. package/dist/chunk-ROCUG24E.js +0 -416
  353. package/dist/chunk-RU3ZPNL6.js +0 -1986
  354. package/dist/chunk-RXSCIO6W.js +0 -153
  355. package/dist/chunk-SKWO3SZF.js +0 -2284
  356. package/dist/chunk-UQGBTPXH.js +0 -218
  357. package/dist/chunk-UYGDJWMN.js +0 -273
  358. package/dist/chunk-W74TXYFB.js +0 -107
  359. package/dist/chunk-WRDSPUE7.js +0 -417
  360. package/dist/chunk-XBZGDDMR.js +0 -105
  361. package/dist/chunk-XN4KG3P4.js +0 -1040
  362. package/dist/chunk-XQXMLMH3.js +0 -211
  363. package/dist/chunk-ZECZOOSB.js +0 -245
  364. /package/dist/{chunk-VFCUIDRT.js → chunk-3BKLBYPK.js} +0 -0
  365. /package/dist/{chunk-GEIGMWNF.js → chunk-QNZII37O.js} +0 -0
@@ -0,0 +1,3950 @@
1
+ import { useElapsed, formatRecordingTime } from './chunk-VLMT6KYT.js';
2
+ import { LevelMeter } from './chunk-EOLZWRV6.js';
3
+ import { Markdown } from './chunk-ONKQUJWD.js';
4
+ import { Textarea } from './chunk-RIK6UX2K.js';
5
+ import { CopyButton } from './chunk-TYOSA7JG.js';
6
+ import { Progress } from './chunk-L2WMOA2V.js';
7
+ import { Checkbox } from './chunk-KNILMM4H.js';
8
+ import { Chip } from './chunk-7NGMUVNU.js';
9
+ import { Avatar } from './chunk-JWCVBFDU.js';
10
+ import { IconTile } from './chunk-XBXUBBJZ.js';
11
+ import { useThinkingPulse, Thinking } from './chunk-LUZFCCSD.js';
12
+ import { useFormFactor } from './chunk-AWKQIE5I.js';
13
+ import { Alert } from './chunk-Z7I4ZSO6.js';
14
+ import { Sheet } from './chunk-B7JZ3N5G.js';
15
+ import { Button } from './chunk-5DTKORLI.js';
16
+ import { Badge } from './chunk-LGNTP5XA.js';
17
+ import { Skeleton } from './chunk-YJ5PXOX3.js';
18
+ import { expandedProps } from './chunk-W23G6JLF.js';
19
+ import { SegmentedControl } from './chunk-NZG75DGA.js';
20
+ import { Input } from './chunk-KXLDK6HB.js';
21
+ import { haptics } from './chunk-NY2U3PBI.js';
22
+ import { isAndroidIdiom } from './chunk-TH4PW2WU.js';
23
+ import { useLabels } from './chunk-APCWFOZW.js';
24
+ import { Icon } from './chunk-PCEFCOLN.js';
25
+ import { springConfig, BREAKAWAY, resist, rubberband, useResolvedMotion } from './chunk-J64KGCGX.js';
26
+ import * as React10 from 'react';
27
+ import { Platform, UIManager, Animated, View, Text, Pressable, Image, ScrollView, I18nManager, PanResponder, LayoutAnimation, Easing, BackHandler, TextInput, AccessibilityInfo, KeyboardAvoidingView } from 'react-native';
28
+ import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
29
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
30
+
31
+ // src/chat/chat-labels.ts
32
+ function formatChatDuration(ms) {
33
+ if (ms < 1e3) return `${Math.round(ms)}ms`;
34
+ const s = ms / 1e3;
35
+ if (s < 60) return `${s < 10 ? s.toFixed(1) : Math.round(s)}s`;
36
+ const m = Math.floor(s / 60);
37
+ return `${m}m ${String(Math.round(s % 60)).padStart(2, "0")}s`;
38
+ }
39
+ function formatChatBytes(bytes) {
40
+ if (bytes < 1024) return `${bytes} B`;
41
+ if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;
42
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
43
+ }
44
+ var DEFAULT_CHAT_LABELS = {
45
+ chat: "Chat",
46
+ messages: "Messages",
47
+ emptyTitle: "How can I help?",
48
+ placeholder: "Send a message\u2026",
49
+ composer: "Message",
50
+ assistant: "Assistant",
51
+ you: "You",
52
+ attachFiles: "Attach files",
53
+ attachments: "Attachments",
54
+ dropFiles: "Drop files to attach",
55
+ send: "Send",
56
+ stop: "Stop",
57
+ replyingTo: (author) => `Replying to ${author}`,
58
+ cancelReply: "Cancel reply",
59
+ removeAttachment: (name) => `Remove ${name}`,
60
+ uploading: "Uploading\u2026",
61
+ uploadFailed: "Upload failed",
62
+ file: "File",
63
+ duration: formatChatDuration,
64
+ bytes: formatChatBytes,
65
+ elapsed: (s) => `${s}s`,
66
+ saidBy: (name) => `${name} said`,
67
+ responding: (name) => `${name} is responding\u2026`,
68
+ said: (name, text) => `${name} said: ${text}`,
69
+ stoppedAnnouncement: (name, text) => `${name} stopped. ${text}`,
70
+ stopped: "Stopped",
71
+ loadEarlier: "Load earlier messages",
72
+ loadingEarlier: "Loading earlier messages",
73
+ writing: "Writing\u2026",
74
+ newMessages: "New messages",
75
+ jumpToLatest: "Jump to latest",
76
+ followUps: "Suggested follow-ups",
77
+ copyMessage: "Copy message",
78
+ copy: "Copy",
79
+ copyResponse: "Copy response",
80
+ editMessage: "Edit message",
81
+ editNote: "Sending replaces this message and everything after it.",
82
+ editHint: "Long-press to edit",
83
+ reply: "Reply",
84
+ regenerate: "Regenerate",
85
+ retry: "Retry",
86
+ notSent: "Not sent.",
87
+ cancel: "Cancel",
88
+ goodResponse: "Good response",
89
+ badResponse: "Bad response",
90
+ feedbackTitle: "What went wrong?",
91
+ feedbackReasons: [
92
+ "Not accurate",
93
+ "Not helpful",
94
+ "Too long",
95
+ "Didn\u2019t follow instructions",
96
+ "Something else"
97
+ ],
98
+ feedbackNote: "Tell us more (optional)",
99
+ sendFeedback: "Send feedback",
100
+ thanks: "Thanks for the feedback.",
101
+ thinking: "Thinking\u2026",
102
+ reasoning: "Reasoning",
103
+ thoughtFor: (d) => `Thought for ${d}`,
104
+ steps: (n) => `${n} ${n === 1 ? "step" : "steps"}`,
105
+ working: (n) => `Working \xB7 ${n} ${n === 1 ? "step" : "steps"}`,
106
+ usedTools: (n, failed) => `Used ${n} ${n === 1 ? "tool" : "tools"}${failed ? ` \xB7 ${failed} failed` : ""}`,
107
+ toolRunning: "running",
108
+ toolDone: "done",
109
+ toolFailed: "failed",
110
+ moreSuggestions: "More suggestions",
111
+ previousSuggestions: "Previous suggestions",
112
+ suggestionsPage: (p, n) => `Suggestions page ${p} of ${n}`,
113
+ suggestionsPageOf: (p, n) => `Page ${p} of ${n}`,
114
+ loadingSuggestions: "Loading suggestions",
115
+ notUseful: "Not useful",
116
+ notUsefulFor: (label) => `Not useful: ${label}`,
117
+ why: (r) => `Why: ${r}`,
118
+ continue: "Continue",
119
+ dictate: "Dictate",
120
+ cancelRecording: "Cancel recording",
121
+ doneRecording: "Done",
122
+ listening: "Listening\u2026",
123
+ transcribing: "Transcribing\u2026",
124
+ micBlocked: "Microphone is blocked",
125
+ micHelp: "How to allow",
126
+ micOff: "Microphone is off for this app",
127
+ openSettings: "Settings",
128
+ context: "Context",
129
+ contextUsed: (p) => `Context ${p}% used`,
130
+ contextTokens: (u, t) => `${u} / ${t} tokens`,
131
+ summarise: "Summarise and continue",
132
+ chatFull: "This chat is full",
133
+ startNewChat: "Start new chat",
134
+ chatAlmostFull: "This chat is almost full",
135
+ contextExplain: "Older messages drop out of what the assistant can see. Starting over with a summary keeps the decisions so far.",
136
+ newChatWithSummary: "New chat with a summary",
137
+ keepGoing: "Keep going",
138
+ queuePlaceholder: "Write another\u2026",
139
+ queued: "Queued messages",
140
+ moreQueued: (n) => `+${n} queued`,
141
+ editQueued: "Edit",
142
+ removeQueued: "Remove",
143
+ sendNow: "Send now",
144
+ needsApproval: "Needs approval",
145
+ allow: "Allow",
146
+ deny: "Deny",
147
+ alwaysAllow: "Always allow in this chat",
148
+ expired: "Expired",
149
+ allowed: "Allowed",
150
+ denied: "Denied",
151
+ toolsWaiting: (n) => `${n} ${n === 1 ? "tool" : "tools"} waiting for you`,
152
+ review: "Review",
153
+ source: (n) => `Source ${n}`,
154
+ sources: "Sources",
155
+ moreSources: (n) => `${n} more sources`,
156
+ openSource: "Open source",
157
+ sourceUnavailable: "Unavailable",
158
+ versionOf: (i, n) => `${i} of ${n}`,
159
+ previousVersion: "Previous version",
160
+ nextVersion: "Next version",
161
+ commands: "Commands",
162
+ people: "People",
163
+ files: "Files",
164
+ noMatches: "No matches",
165
+ chats: "Chats",
166
+ newChat: "New chat",
167
+ searchChats: "Search chats",
168
+ more: "More",
169
+ renameChat: "Rename chat",
170
+ unread: "Unread",
171
+ answering: "Answering",
172
+ open: "Open",
173
+ preview: "Preview",
174
+ code: "Code",
175
+ close: "Close",
176
+ delete: "Delete",
177
+ save: "Save",
178
+ noChats: "No chats yet",
179
+ share: "Share",
180
+ artifactName: (title, kind) => `${title}, ${kind}`,
181
+ rows: (n) => `${n} ${n === 1 ? "row" : "rows"}`,
182
+ expand: "Expand",
183
+ download: "Download",
184
+ openExternal: "Open in new tab"
185
+ };
186
+ if (Platform.OS === "android" && UIManager.setLayoutAnimationEnabledExperimental) {
187
+ UIManager.setLayoutAnimationEnabledExperimental(true);
188
+ }
189
+ function useArrival(enabled, kind = "in", delayMs = 0) {
190
+ const theme = useLoamTheme("chat");
191
+ const [run] = React10.useState(enabled);
192
+ const p = React10.useRef(new Animated.Value(run ? 0 : 1)).current;
193
+ React10.useEffect(() => {
194
+ if (!run) return;
195
+ if (theme.reduceMotion) {
196
+ Animated.timing(p, { toValue: 1, duration: theme.duration.fast, delay: delayMs, useNativeDriver: true }).start();
197
+ return;
198
+ }
199
+ Animated.sequence([
200
+ Animated.delay(delayMs),
201
+ Animated.spring(p, { ...springConfig(theme, "ds"), toValue: 1, useNativeDriver: true })
202
+ ]).start();
203
+ }, [run, p, delayMs, theme]);
204
+ if (!run) return void 0;
205
+ if (theme.reduceMotion) return { opacity: p };
206
+ const rise = 8;
207
+ const scale = kind === "sent" ? 0.96 : kind === "card" ? 0.985 : 1;
208
+ return {
209
+ opacity: p.interpolate({ inputRange: [0, 1], outputRange: [0, 1], extrapolate: "clamp" }),
210
+ transform: [
211
+ { translateY: p.interpolate({ inputRange: [0, 1], outputRange: [rise, 0] }) },
212
+ { scale: p.interpolate({ inputRange: [0, 1], outputRange: [scale, 1] }) }
213
+ ]
214
+ };
215
+ }
216
+ function useAutoDisclosure(live, animate) {
217
+ const theme = useLoamTheme("chat");
218
+ const [open, setOpen] = React10.useState(live);
219
+ const owned = React10.useRef(false);
220
+ const ease = React10.useCallback(() => {
221
+ if (!animate) return;
222
+ const duration = theme.motion.expand.duration;
223
+ LayoutAnimation.configureNext({
224
+ duration,
225
+ update: { type: LayoutAnimation.Types.easeInEaseOut },
226
+ create: { type: LayoutAnimation.Types.easeInEaseOut, property: LayoutAnimation.Properties.opacity, duration },
227
+ delete: { type: LayoutAnimation.Types.easeInEaseOut, property: LayoutAnimation.Properties.opacity, duration }
228
+ });
229
+ }, [animate, theme.motion.expand.duration]);
230
+ React10.useEffect(() => {
231
+ if (owned.current) return;
232
+ ease();
233
+ setOpen(live);
234
+ }, [live, ease]);
235
+ const toggle = React10.useCallback(() => {
236
+ owned.current = true;
237
+ ease();
238
+ setOpen((o) => !o);
239
+ }, [ease]);
240
+ return [open, toggle];
241
+ }
242
+ function Disclosure({
243
+ open,
244
+ onToggle,
245
+ summary,
246
+ icon,
247
+ shimmer,
248
+ children
249
+ }) {
250
+ const { styles } = useStyles(sheet);
251
+ const theme = useLoamTheme("chat");
252
+ const pulse = useThinkingPulse(shimmer);
253
+ return /* @__PURE__ */ jsxs(View, { children: [
254
+ /* @__PURE__ */ jsxs(
255
+ Pressable,
256
+ {
257
+ role: "button",
258
+ accessibilityRole: "button",
259
+ accessibilityLabel: summary,
260
+ ...expandedProps(open),
261
+ accessibilityState: { expanded: open },
262
+ onPress: onToggle,
263
+ hitSlop: (theme.hit.sm - theme.ctl.sm) / 2,
264
+ style: ({ pressed }) => [styles.summary, pressed && styles.down],
265
+ children: [
266
+ icon,
267
+ /* @__PURE__ */ jsx(Animated.Text, { style: [styles.summaryText, pulse], children: summary }),
268
+ /* @__PURE__ */ jsx(View, { style: { transform: [{ rotate: open ? "90deg" : "0deg" }] }, children: /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: theme.icon.xs, color: theme.color.text2 }) })
269
+ ]
270
+ }
271
+ ),
272
+ open ? /* @__PURE__ */ jsx(View, { style: styles.panel, children }) : null
273
+ ] });
274
+ }
275
+ function ReasoningView({
276
+ part,
277
+ live,
278
+ animate,
279
+ labels: labelsProp
280
+ }) {
281
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
282
+ const { styles } = useStyles(sheet);
283
+ const theme = useLoamTheme("chat");
284
+ const [open, toggle] = useAutoDisclosure(live, animate);
285
+ const summary = live ? labels.thinking : part.durationMs != null ? labels.thoughtFor(labels.duration(part.durationMs)) : labels.reasoning;
286
+ return /* @__PURE__ */ jsx(
287
+ Disclosure,
288
+ {
289
+ open,
290
+ onToggle: toggle,
291
+ summary,
292
+ shimmer: live && animate,
293
+ icon: /* @__PURE__ */ jsx(Icon, { name: "brain", size: theme.icon.sm, color: theme.color.text3 }),
294
+ children: /* @__PURE__ */ jsx(View, { style: styles.rail, children: /* @__PURE__ */ jsx(Text, { style: styles.reasoning, children: part.text }) })
295
+ }
296
+ );
297
+ }
298
+ function ToolMark({ status, animate }) {
299
+ const theme = useLoamTheme("chat");
300
+ const pop = React10.useRef(new Animated.Value(status === "running" || !animate ? 1 : 0)).current;
301
+ const prev = React10.useRef(status);
302
+ React10.useEffect(() => {
303
+ if (prev.current === "running" && status !== "running" && animate) {
304
+ pop.setValue(0);
305
+ Animated.spring(pop, { toValue: 1, useNativeDriver: true, speed: 18, bounciness: 10 }).start();
306
+ }
307
+ prev.current = status;
308
+ }, [status, animate, pop]);
309
+ if (status === "running") {
310
+ return /* @__PURE__ */ jsx(Thinking, { label: "", size: "sm", announce: false, motion: animate ? "full" : "none" });
311
+ }
312
+ return /* @__PURE__ */ jsx(Animated.View, { style: { opacity: pop, transform: [{ scale: pop.interpolate({ inputRange: [0, 1], outputRange: [0.6, 1] }) }] }, children: /* @__PURE__ */ jsx(
313
+ Icon,
314
+ {
315
+ name: status === "error" ? "x" : "check",
316
+ size: theme.icon.xs,
317
+ color: status === "error" ? theme.color.danger : theme.color.good
318
+ }
319
+ ) });
320
+ }
321
+ function ToolGroupView({
322
+ tools,
323
+ animate,
324
+ labels: labelsProp
325
+ }) {
326
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
327
+ const { styles } = useStyles(sheet);
328
+ const theme = useLoamTheme("chat");
329
+ const running = tools.some((t) => t.status === "running");
330
+ const failed = tools.filter((t) => t.status === "error").length;
331
+ const [open, toggle] = useAutoDisclosure(running, animate);
332
+ const n = tools.length;
333
+ const summary = running ? labels.working(n) : labels.usedTools(n, failed);
334
+ return /* @__PURE__ */ jsx(
335
+ Disclosure,
336
+ {
337
+ open,
338
+ onToggle: toggle,
339
+ summary,
340
+ shimmer: running && animate,
341
+ icon: /* @__PURE__ */ jsx(Icon, { name: "wrench", size: theme.icon.sm, color: theme.color.text3 }),
342
+ children: /* @__PURE__ */ jsx(View, { accessibilityRole: "list", children: tools.map((tool, i) => /* @__PURE__ */ jsxs(View, { role: "listitem", style: styles.step, children: [
343
+ /* @__PURE__ */ jsxs(View, { style: styles.nodeCol, children: [
344
+ i > 0 ? /* @__PURE__ */ jsx(View, { style: [styles.line, styles.lineTop] }) : null,
345
+ i < n - 1 ? /* @__PURE__ */ jsx(View, { style: [styles.line, styles.lineBottom] }) : null,
346
+ /* @__PURE__ */ jsx(View, { style: [styles.node, tool.status === "error" && styles.nodeError], children: /* @__PURE__ */ jsx(
347
+ Icon,
348
+ {
349
+ name: tool.icon ?? "wrench",
350
+ size: theme.icon.xs,
351
+ color: tool.status === "error" ? theme.color.dangerOnSoft : theme.color.text2
352
+ }
353
+ ) })
354
+ ] }),
355
+ /* @__PURE__ */ jsxs(View, { style: styles.stepBody, children: [
356
+ /* @__PURE__ */ jsxs(View, { style: styles.stepHead, children: [
357
+ /* @__PURE__ */ jsx(Text, { style: styles.stepTitle, numberOfLines: 2, children: tool.title }),
358
+ /* @__PURE__ */ jsx(ToolMark, { status: tool.status, animate }),
359
+ tool.durationMs != null && tool.status !== "running" ? /* @__PURE__ */ jsx(Text, { style: styles.count, children: labels.duration(tool.durationMs) }) : null
360
+ ] }),
361
+ tool.detail ? /* @__PURE__ */ jsx(Text, { style: styles.meta, numberOfLines: 2, children: tool.detail }) : null
362
+ ] })
363
+ ] }, tool.id)) })
364
+ }
365
+ );
366
+ }
367
+ function WorkingIndicator({
368
+ phase: phaseProp,
369
+ startedAt,
370
+ animate,
371
+ labels: labelsProp
372
+ }) {
373
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
374
+ const phase = phaseProp ?? labels.thinking;
375
+ const { styles } = useStyles(sheet);
376
+ const pulse = useThinkingPulse(animate);
377
+ const [now, setNow] = React10.useState(() => Date.now());
378
+ React10.useEffect(() => {
379
+ if (startedAt == null) return;
380
+ const id = setInterval(() => setNow(Date.now()), 1e3);
381
+ return () => clearInterval(id);
382
+ }, [startedAt]);
383
+ const elapsed = startedAt != null ? Math.max(0, Math.floor((now - startedAt) / 1e3)) : null;
384
+ return /* @__PURE__ */ jsxs(View, { style: styles.working, role: "status", accessibilityLabel: phase, children: [
385
+ /* @__PURE__ */ jsx(Thinking, { label: "", size: "sm", announce: false, motion: animate ? "full" : "none" }),
386
+ /* @__PURE__ */ jsx(Animated.Text, { style: [styles.summaryText, pulse], children: phase }),
387
+ elapsed != null && elapsed > 0 ? /* @__PURE__ */ jsxs(Text, { style: styles.meta, children: [
388
+ "\xB7 ",
389
+ labels.elapsed(elapsed)
390
+ ] }) : null
391
+ ] });
392
+ }
393
+ function AttachmentChip({
394
+ attachment,
395
+ onRemove,
396
+ labels: labelsProp
397
+ }) {
398
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
399
+ const { styles } = useStyles(sheet);
400
+ const theme = useLoamTheme("chat");
401
+ const status = attachment.status ?? "done";
402
+ const image = attachment.type?.startsWith("image/") && attachment.previewUrl;
403
+ const sub = status === "uploading" ? labels.uploading : status === "error" ? labels.uploadFailed : attachment.size != null ? labels.bytes(attachment.size) : void 0;
404
+ return /* @__PURE__ */ jsxs(View, { style: [styles.chip, onRemove && styles.chipRemovable, status === "error" && styles.chipError], children: [
405
+ image ? /* @__PURE__ */ jsx(Image, { source: { uri: attachment.previewUrl }, style: styles.thumb, accessibilityIgnoresInvertColors: true }) : /* @__PURE__ */ jsx(View, { style: styles.fileIcon, children: /* @__PURE__ */ jsx(
406
+ Icon,
407
+ {
408
+ name: status === "uploading" ? "loader" : "file",
409
+ size: theme.icon.sm,
410
+ color: theme.color.text2
411
+ }
412
+ ) }),
413
+ /* @__PURE__ */ jsxs(View, { style: styles.chipText, children: [
414
+ /* @__PURE__ */ jsx(Text, { style: styles.chipName, numberOfLines: 1, children: attachment.name }),
415
+ sub ? /* @__PURE__ */ jsx(Text, { style: [styles.meta, status === "error" && { color: theme.color.dangerOnSoft }], children: sub }) : null
416
+ ] }),
417
+ onRemove ? /* @__PURE__ */ jsx(
418
+ Pressable,
419
+ {
420
+ accessibilityRole: "button",
421
+ accessibilityLabel: labels.removeAttachment(attachment.name),
422
+ onPress: onRemove,
423
+ hitSlop: (theme.hit.xs - theme.ctl.xs) / 2,
424
+ style: ({ pressed }) => [styles.remove, pressed && styles.down],
425
+ children: /* @__PURE__ */ jsx(Icon, { name: "x", size: theme.ctl.icon.xs, color: theme.color.text2 })
426
+ }
427
+ ) : null
428
+ ] });
429
+ }
430
+ var NODE = 22;
431
+ var sheet = createStyleSheet((theme) => ({
432
+ summary: {
433
+ flexDirection: "row",
434
+ alignItems: "center",
435
+ alignSelf: "flex-start",
436
+ gap: theme.space.s2,
437
+ // A ghost sm row: 30, r 8, px 8 pulled back by 8 so the glyph keeps the
438
+ // text column.
439
+ height: theme.ctl.sm,
440
+ paddingHorizontal: theme.space.s2,
441
+ marginStart: -theme.space.s2,
442
+ borderRadius: theme.ctl.r.sm
443
+ },
444
+ down: { backgroundColor: theme.state.pressed },
445
+ summaryText: {
446
+ fontFamily: theme.font.sans,
447
+ fontSize: theme.type.footnote.fontSize,
448
+ lineHeight: theme.type.footnote.lineHeight,
449
+ color: theme.color.text2
450
+ },
451
+ panel: { paddingTop: theme.space.s2 },
452
+ rail: {
453
+ borderStartWidth: theme.borderWidth.base,
454
+ borderStartColor: theme.color.border,
455
+ paddingStart: theme.space.s3,
456
+ marginStart: theme.space[6]
457
+ },
458
+ reasoning: {
459
+ fontFamily: theme.font.sans,
460
+ fontSize: theme.type.footnote.fontSize,
461
+ lineHeight: theme.type.footnote.lineHeight,
462
+ color: theme.color.text2
463
+ },
464
+ step: { flexDirection: "row", gap: theme.space.s3, paddingVertical: theme.space[6] },
465
+ nodeCol: { width: NODE, alignItems: "center" },
466
+ line: {
467
+ position: "absolute",
468
+ width: theme.borderWidth.base,
469
+ backgroundColor: theme.color.border,
470
+ left: (NODE - theme.borderWidth.base) / 2
471
+ },
472
+ lineTop: { top: -theme.space[6], height: theme.space[6] + theme.space[2] },
473
+ lineBottom: { top: theme.space[2] + NODE, bottom: -theme.space[6] },
474
+ node: {
475
+ marginTop: theme.space[2],
476
+ width: NODE,
477
+ height: NODE,
478
+ borderRadius: theme.radius[6],
479
+ borderWidth: theme.borderWidth.base,
480
+ borderColor: theme.color.border,
481
+ backgroundColor: theme.color.surface3,
482
+ alignItems: "center",
483
+ justifyContent: "center"
484
+ },
485
+ nodeError: { borderColor: theme.edge.danger, backgroundColor: theme.color.dangerSoft },
486
+ stepBody: { flex: 1, minWidth: 0, gap: theme.space[2], paddingTop: theme.space[4] },
487
+ stepHead: { flexDirection: "row", alignItems: "center", gap: theme.space.s2 },
488
+ stepTitle: {
489
+ flexShrink: 1,
490
+ fontFamily: theme.font.sans,
491
+ fontSize: theme.type.footnote.fontSize,
492
+ lineHeight: theme.type.footnote.lineHeight,
493
+ color: theme.color.text
494
+ },
495
+ meta: {
496
+ fontFamily: theme.font.sans,
497
+ fontSize: theme.type.caption1.fontSize,
498
+ lineHeight: theme.type.caption1.lineHeight,
499
+ color: theme.color.text2
500
+ },
501
+ count: {
502
+ fontFamily: theme.font.mono,
503
+ fontSize: theme.type.caption1.fontSize,
504
+ fontWeight: theme.fontWeight.medium,
505
+ fontVariant: ["tabular-nums"],
506
+ color: theme.color.text2
507
+ },
508
+ working: { flexDirection: "row", alignItems: "center", gap: theme.space.s2, minHeight: theme.ctl.sm },
509
+ chip: {
510
+ flexDirection: "row",
511
+ alignItems: "center",
512
+ gap: theme.space.s2,
513
+ maxWidth: theme.ctl.sm * 7,
514
+ // 44, the lg tier: a 30 thumb 7 in, concentric with the r 12 corner.
515
+ minHeight: theme.ctl.lg,
516
+ paddingStart: theme.space[7],
517
+ paddingEnd: theme.space[10],
518
+ borderRadius: theme.radius.md,
519
+ borderWidth: theme.borderWidth.base,
520
+ borderColor: theme.color.border,
521
+ backgroundColor: theme.color.surface
522
+ },
523
+ chipRemovable: { paddingEnd: (theme.ctl.lg - theme.ctl.xs) / 2 },
524
+ chipError: { borderColor: theme.edge.danger },
525
+ thumb: { width: theme.ctl.sm, height: theme.ctl.sm, borderRadius: theme.radius[6] },
526
+ fileIcon: {
527
+ width: theme.ctl.sm,
528
+ height: theme.ctl.sm,
529
+ borderRadius: theme.radius[6],
530
+ backgroundColor: theme.color.surface2,
531
+ alignItems: "center",
532
+ justifyContent: "center"
533
+ },
534
+ chipText: { flexShrink: 1, minWidth: 0 },
535
+ chipName: {
536
+ fontFamily: theme.font.sans,
537
+ fontSize: theme.type.footnote.fontSize,
538
+ lineHeight: theme.type.footnote.lineHeight,
539
+ fontWeight: theme.fontWeight.medium,
540
+ color: theme.color.text
541
+ },
542
+ remove: {
543
+ width: theme.ctl.xs,
544
+ height: theme.ctl.xs,
545
+ borderRadius: theme.ctl.r.xs,
546
+ alignItems: "center",
547
+ justifyContent: "center"
548
+ }
549
+ }));
550
+ function findChatTrigger(text, caret) {
551
+ const before = text.slice(0, caret);
552
+ const m = /(^|\s)([/@])([^\s/@]*)$/.exec(before);
553
+ if (!m) return null;
554
+ const char = m[2];
555
+ return { char, query: m[3] ?? "", start: before.length - (m[3]?.length ?? 0) - 1 };
556
+ }
557
+ function matches(name, query) {
558
+ return name.toLowerCase().includes(query.toLowerCase());
559
+ }
560
+ function chatSlashEntries(trigger, commands, mentions) {
561
+ if (trigger.char === "/") {
562
+ return commands.filter((c) => matches(c.name, trigger.query)).map((c) => ({ type: "command", key: `c:${c.id}`, name: c.name, command: c }));
563
+ }
564
+ return mentions.filter((m) => matches(m.name, trigger.query)).map((m) => ({
565
+ type: m.kind === "file" ? "file" : "person",
566
+ key: `m:${m.id}`,
567
+ name: m.name,
568
+ mention: m
569
+ })).sort((a, b) => a.type === b.type ? 0 : a.type === "person" ? -1 : 1);
570
+ }
571
+ function Matched({ text, query, style }) {
572
+ const theme = useLoamTheme("chat");
573
+ const at = query ? text.toLowerCase().indexOf(query.toLowerCase()) : -1;
574
+ if (at < 0) return /* @__PURE__ */ jsx(Text, { style, children: text });
575
+ return /* @__PURE__ */ jsxs(Text, { style, children: [
576
+ text.slice(0, at),
577
+ /* @__PURE__ */ jsx(Text, { style: { fontWeight: theme.fontWeight.semibold }, children: text.slice(at, at + query.length) }),
578
+ text.slice(at + query.length)
579
+ ] });
580
+ }
581
+ function ChatSlashMenu({
582
+ entries,
583
+ query,
584
+ onPick,
585
+ labels
586
+ }) {
587
+ const { styles } = useStyles(sheet2);
588
+ const theme = useLoamTheme("chat");
589
+ const sections = [];
590
+ for (const entry of entries) {
591
+ const title = entry.type === "command" ? labels.commands : entry.type === "person" ? labels.people : labels.files;
592
+ const last = sections[sections.length - 1];
593
+ if (last && last.title === title) last.rows.push(entry);
594
+ else sections.push({ title, rows: [entry] });
595
+ }
596
+ return /* @__PURE__ */ jsx(View, { style: styles.menu, testID: "chat-slash-menu", children: /* @__PURE__ */ jsxs(ScrollView, { keyboardShouldPersistTaps: "always", style: styles.scroll, children: [
597
+ sections.length === 0 ? /* @__PURE__ */ jsxs(Text, { style: [styles.desc, styles.empty], children: [
598
+ labels.noMatches,
599
+ query ? ` \u201C${query}\u201D` : ""
600
+ ] }) : null,
601
+ sections.map((s) => /* @__PURE__ */ jsxs(View, { role: "list", accessibilityLabel: s.title, children: [
602
+ /* @__PURE__ */ jsx(Text, { style: styles.overline, children: s.title }),
603
+ s.rows.map((entry) => /* @__PURE__ */ jsx(View, { role: "listitem", children: /* @__PURE__ */ jsx(
604
+ Pressable,
605
+ {
606
+ accessibilityRole: "button",
607
+ accessibilityLabel: entry.type === "command" ? `/${entry.name}${entry.command?.description ? `, ${entry.command.description}` : ""}` : entry.name,
608
+ onPress: () => onPick(entry),
609
+ style: ({ pressed }) => [
610
+ styles.row,
611
+ entry.type === "command" ? styles.rowTall : styles.rowShort,
612
+ pressed && styles.down
613
+ ],
614
+ children: entry.type === "command" ? /* @__PURE__ */ jsxs(Fragment, { children: [
615
+ /* @__PURE__ */ jsx(Icon, { name: entry.command?.icon ?? "terminal", size: theme.icon.sm, color: theme.color.text2 }),
616
+ /* @__PURE__ */ jsxs(View, { style: styles.text, children: [
617
+ /* @__PURE__ */ jsx(Matched, { text: `/${entry.name}`, query, style: styles.name }),
618
+ entry.command?.description ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles.desc, children: entry.command.description }) : null
619
+ ] })
620
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
621
+ entry.type === "person" ? /* @__PURE__ */ jsx(Avatar, { size: "sm", name: entry.name, src: entry.mention?.avatar }) : /* @__PURE__ */ jsx(Icon, { name: "file", size: theme.icon.sm, color: theme.color.text2 }),
622
+ /* @__PURE__ */ jsx(Matched, { text: entry.name, query, style: [styles.name, styles.grow] }),
623
+ entry.mention?.role ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles.desc, children: entry.mention.role }) : null
624
+ ] })
625
+ }
626
+ ) }, entry.key))
627
+ ] }, s.title))
628
+ ] }) });
629
+ }
630
+ var sheet2 = createStyleSheet((theme) => ({
631
+ empty: { paddingHorizontal: theme.space[8], paddingVertical: theme.space[8] },
632
+ menu: {
633
+ marginBottom: theme.space[8],
634
+ padding: theme.space[8],
635
+ borderRadius: theme.radius.md,
636
+ borderWidth: theme.borderWidth.base,
637
+ borderColor: theme.color.border,
638
+ backgroundColor: theme.color.surface,
639
+ ...theme.shadow.md
640
+ },
641
+ scroll: { maxHeight: theme.space[56] * 4 },
642
+ overline: {
643
+ ...theme.type.overline,
644
+ paddingHorizontal: theme.space[8],
645
+ paddingVertical: theme.space[4],
646
+ fontFamily: theme.font.sans,
647
+ color: theme.color.text3
648
+ },
649
+ row: {
650
+ flexDirection: "row",
651
+ alignItems: "center",
652
+ gap: theme.space.s3,
653
+ paddingHorizontal: theme.space[8],
654
+ borderRadius: theme.radius.sm
655
+ },
656
+ rowTall: { minHeight: theme.space[56] },
657
+ rowShort: { minHeight: theme.space[48] },
658
+ down: { backgroundColor: theme.state.pressed },
659
+ text: { flex: 1, minWidth: 0, gap: theme.space[2] },
660
+ grow: { flex: 1, minWidth: 0 },
661
+ name: {
662
+ fontFamily: theme.font.sans,
663
+ fontSize: theme.type.callout.fontSize,
664
+ lineHeight: theme.type.callout.lineHeight,
665
+ color: theme.color.text2
666
+ },
667
+ desc: {
668
+ flexShrink: 1,
669
+ fontFamily: theme.font.sans,
670
+ fontSize: theme.type.footnote.fontSize,
671
+ lineHeight: theme.type.footnote.lineHeight,
672
+ color: theme.color.text2
673
+ }
674
+ }));
675
+ function ChatComposer({
676
+ onSend,
677
+ replyTo,
678
+ onCancelReply,
679
+ running = false,
680
+ onStop,
681
+ value: valueProp,
682
+ defaultValue = "",
683
+ onValueChange,
684
+ placeholder: placeholderProp,
685
+ label: labelProp,
686
+ attachments = [],
687
+ onAttach,
688
+ onRemoveAttachment,
689
+ accept,
690
+ toolbar,
691
+ recall,
692
+ hint,
693
+ disabled = false,
694
+ queue = [],
695
+ onQueue,
696
+ onEditQueued,
697
+ onRemoveQueued,
698
+ onSendQueued,
699
+ voice,
700
+ context,
701
+ approvals,
702
+ inputRef,
703
+ commands,
704
+ mentions,
705
+ onCommand,
706
+ onMention,
707
+ maxRows = 8,
708
+ motion = "full",
709
+ style,
710
+ labels: labelsProp
711
+ }) {
712
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
713
+ const queueing = running && !!onQueue;
714
+ const placeholder = placeholderProp ?? (queueing ? labels.queuePlaceholder : labels.placeholder);
715
+ const label = labelProp ?? labels.composer;
716
+ const { styles } = useStyles(sheet3);
717
+ const theme = useLoamTheme("chat");
718
+ const animate = useResolvedMotion(motion, "chat") === "full";
719
+ const [inner, setInner] = React10.useState(defaultValue);
720
+ const value = valueProp ?? inner;
721
+ const setValue = (next) => {
722
+ if (valueProp === void 0) setInner(next);
723
+ onValueChange?.(next);
724
+ };
725
+ const [focused, setFocused] = React10.useState(false);
726
+ const [caret, setCaret] = React10.useState(null);
727
+ const [dismissed, setDismissed] = React10.useState(null);
728
+ const voiceStatus = voice?.status ?? "idle";
729
+ const recording = voiceStatus === "recording";
730
+ const transcribing = voiceStatus === "transcribing";
731
+ const full = !!context && context.used >= context.total;
732
+ const uploading = attachments.some((a) => a.status === "uploading");
733
+ const hasDraft = value.trim() !== "" || attachments.length > 0;
734
+ const canSend = !disabled && !running && !uploading && !full && !transcribing && hasDraft;
735
+ const canQueue = !disabled && queueing && !uploading && !full && hasDraft;
736
+ const showStop = running && !!onStop && !canQueue;
737
+ const [menuFor, setMenuFor] = React10.useState(null);
738
+ const swap = React10.useRef(new Animated.Value(showStop ? 1 : 0)).current;
739
+ React10.useEffect(() => {
740
+ Animated.timing(swap, {
741
+ toValue: showStop ? 1 : 0,
742
+ duration: animate ? theme.motion.swap.duration : 0,
743
+ easing: Easing.bezier(...theme.motion.swap.easing),
744
+ useNativeDriver: true
745
+ }).start();
746
+ }, [showStop, animate, swap, theme.motion.swap]);
747
+ const trigger = commands || mentions ? findChatTrigger(value, Math.min(caret ?? value.length, value.length)) : null;
748
+ const entries = trigger ? chatSlashEntries(trigger, commands ?? [], mentions ?? []) : [];
749
+ const menuOpen = !!trigger && entries.length > 0 && dismissed !== trigger.start && !disabled && !full;
750
+ const [tokens, setTokens] = React10.useState([]);
751
+ const [scrollY, setScrollY] = React10.useState(0);
752
+ const cancelReply = replyTo ? onCancelReply : void 0;
753
+ React10.useEffect(() => {
754
+ if (!cancelReply) return void 0;
755
+ const sub = BackHandler.addEventListener("hardwareBackPress", () => {
756
+ cancelReply();
757
+ return true;
758
+ });
759
+ return () => sub.remove();
760
+ }, [cancelReply]);
761
+ const pick = (entry) => {
762
+ if (!trigger) return;
763
+ const text = `${trigger.char}${entry.name} `;
764
+ setTokens((t) => t.includes(`${trigger.char}${entry.name}`) ? t : [...t, `${trigger.char}${entry.name}`]);
765
+ const end = trigger.start + 1 + trigger.query.length;
766
+ setValue(value.slice(0, trigger.start) + text + value.slice(end));
767
+ setCaret(trigger.start + text.length);
768
+ if (entry.command) onCommand?.(entry.command);
769
+ if (entry.mention) onMention?.(entry.mention);
770
+ };
771
+ const send = () => {
772
+ if (canQueue) {
773
+ onQueue?.(value.trim(), attachments);
774
+ setValue("");
775
+ setTokens([]);
776
+ return;
777
+ }
778
+ if (!canSend) return;
779
+ onSend(value.trim(), attachments);
780
+ setValue("");
781
+ setTokens([]);
782
+ };
783
+ const active = showStop || canSend || canQueue;
784
+ const slop = Math.max(0, (theme.hit.lg - theme.ctl.lg) / 2);
785
+ return /* @__PURE__ */ jsxs(View, { style: [styles.root, style], children: [
786
+ menuOpen && trigger ? /* @__PURE__ */ jsx(ChatSlashMenu, { entries, query: trigger.query, onPick: pick, labels }) : null,
787
+ /* @__PURE__ */ jsxs(View, { style: [styles.box, focused && styles.boxFocused, disabled && styles.disabled], children: [
788
+ full ? /* @__PURE__ */ jsx(Band, { icon: "alert-circle", iconColor: theme.color.dangerOnSoft, title: labels.chatFull, children: context?.onNewChat ? /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onPress: context.onNewChat, children: labels.startNewChat }) : null }) : null,
789
+ voiceStatus === "blocked" ? /* @__PURE__ */ jsx(Band, { icon: "mic-off", iconColor: theme.color.warnOnSoft, title: labels.micOff, children: voice?.onHelp ? /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onPress: voice.onHelp, children: labels.openSettings }) : null }) : null,
790
+ approvals && approvals.count > 0 ? /* @__PURE__ */ jsx(Band, { icon: "shield", iconColor: theme.color.accentOnSoft, title: labels.toolsWaiting(approvals.count), children: /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onPress: approvals.onReview, children: labels.review }) }) : null,
791
+ queue.length > 0 ? /* @__PURE__ */ jsxs(View, { accessibilityLabel: labels.queued, role: "list", children: [
792
+ queue.slice(0, 3).map((q) => /* @__PURE__ */ jsx(View, { role: "listitem", children: /* @__PURE__ */ jsxs(Band, { icon: "clock", quote: q.text, children: [
793
+ !running && onSendQueued ? /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onPress: () => onSendQueued(q.id), children: labels.sendNow }) : null,
794
+ onEditQueued || onRemoveQueued ? /* @__PURE__ */ jsx(
795
+ ToolButton,
796
+ {
797
+ icon: "more-horizontal",
798
+ label: labels.more,
799
+ size: "xs",
800
+ onPress: () => setMenuFor(q.id)
801
+ }
802
+ ) : null
803
+ ] }) }, q.id)),
804
+ queue.length > 3 ? /* @__PURE__ */ jsx(View, { style: styles.moreQueued, role: "listitem", children: /* @__PURE__ */ jsx(Text, { style: styles.moreQueuedText, children: labels.moreQueued(queue.length - 3) }) }) : null
805
+ ] }) : null,
806
+ replyTo ? /* @__PURE__ */ jsx(
807
+ ReplyBar,
808
+ {
809
+ reply: replyTo,
810
+ animate,
811
+ onCancel: onCancelReply,
812
+ labels
813
+ },
814
+ replyTo.text
815
+ ) : null,
816
+ attachments.length > 0 ? /* @__PURE__ */ jsx(
817
+ ScrollView,
818
+ {
819
+ horizontal: true,
820
+ showsHorizontalScrollIndicator: false,
821
+ contentContainerStyle: styles.chips,
822
+ children: attachments.map((a) => /* @__PURE__ */ jsx(
823
+ AttachmentChip,
824
+ {
825
+ attachment: a,
826
+ onRemove: onRemoveAttachment ? () => onRemoveAttachment(a.id) : void 0,
827
+ labels
828
+ },
829
+ a.id
830
+ ))
831
+ }
832
+ ) : null,
833
+ recording ? /* @__PURE__ */ jsx(Text, { style: [styles.input, styles.listening], children: labels.listening }) : transcribing ? /* @__PURE__ */ jsx(View, { style: [styles.input, styles.transcribing], children: /* @__PURE__ */ jsx(Thinking, { size: "sm", label: labels.transcribing }) }) : null,
834
+ /* @__PURE__ */ jsxs(View, { style: [(recording || transcribing) && styles.hidden], children: [
835
+ tokens.length ? /* @__PURE__ */ jsx(ComposerTokens, { value, tokens, maxRows, scrollY }) : null,
836
+ /* @__PURE__ */ jsx(
837
+ TextInput,
838
+ {
839
+ ref: inputRef,
840
+ accessibilityLabel: label,
841
+ placeholder,
842
+ placeholderTextColor: theme.color.text3,
843
+ editable: !disabled && !full,
844
+ accessibilityState: { disabled: !!disabled },
845
+ "aria-disabled": disabled || void 0,
846
+ multiline: true,
847
+ value,
848
+ onChangeText: (t) => {
849
+ setValue(t);
850
+ if (commands || mentions) setCaret(null);
851
+ },
852
+ onSelectionChange: commands || mentions ? (e) => setCaret(e.nativeEvent.selection.end) : void 0,
853
+ onScroll: tokens.length ? (e) => (
854
+ // Native reports contentOffset; react-native-web hands over the DOM event.
855
+ setScrollY(
856
+ e.nativeEvent.contentOffset?.y ?? e.target.scrollTop ?? 0
857
+ )
858
+ ) : void 0,
859
+ onFocus: () => setFocused(true),
860
+ onBlur: () => setFocused(false),
861
+ onKeyPress: (e) => {
862
+ if (e.nativeEvent.key === "Escape" && menuOpen && trigger) setDismissed(trigger.start);
863
+ if (e.nativeEvent.key === "ArrowUp" && value === "" && recall) setValue(recall);
864
+ },
865
+ style: [
866
+ styles.input,
867
+ { maxHeight: theme.type.body.lineHeight * maxRows }
868
+ ]
869
+ }
870
+ )
871
+ ] }),
872
+ recording ? /* @__PURE__ */ jsx(VoiceBar, { voice, labels }) : /* @__PURE__ */ jsxs(View, { style: styles.bar, children: [
873
+ onAttach ? /* @__PURE__ */ jsx(
874
+ ToolButton,
875
+ {
876
+ icon: "paperclip",
877
+ label: labels.attachFiles,
878
+ disabled,
879
+ onPress: () => onAttach(accept)
880
+ }
881
+ ) : null,
882
+ voice ? /* @__PURE__ */ jsx(
883
+ ToolButton,
884
+ {
885
+ icon: voiceStatus === "blocked" ? "mic-off" : "mic",
886
+ label: labels.dictate,
887
+ disabled: disabled || transcribing || voiceStatus === "blocked" || !voice.onStart,
888
+ onPress: () => {
889
+ haptics.impact("light");
890
+ voice.onStart?.();
891
+ }
892
+ }
893
+ ) : null,
894
+ toolbar,
895
+ /* @__PURE__ */ jsx(View, { style: styles.spacer }),
896
+ context ? /* @__PURE__ */ jsx(ContextMeter, { context, labels }) : null,
897
+ /* @__PURE__ */ jsxs(
898
+ Pressable,
899
+ {
900
+ accessibilityRole: "button",
901
+ accessibilityLabel: showStop ? labels.stop : labels.send,
902
+ accessibilityState: { disabled: !active },
903
+ disabled: !active,
904
+ onPress: showStop ? onStop : send,
905
+ hitSlop: slop,
906
+ style: [styles.send, !active && styles.sendIdle],
907
+ children: [
908
+ /* @__PURE__ */ jsx(
909
+ Animated.View,
910
+ {
911
+ style: [
912
+ styles.glyph,
913
+ {
914
+ opacity: swap.interpolate({ inputRange: [0, 1], outputRange: [1, 0] }),
915
+ transform: [
916
+ { scale: swap.interpolate({ inputRange: [0, 1], outputRange: [1, 0.5] }) }
917
+ ]
918
+ }
919
+ ],
920
+ children: /* @__PURE__ */ jsx(Icon, { name: "arrow-up", size: theme.ctl.icon.lg, color: theme.color.accentInk })
921
+ }
922
+ ),
923
+ /* @__PURE__ */ jsx(
924
+ Animated.View,
925
+ {
926
+ style: [
927
+ styles.glyph,
928
+ {
929
+ opacity: swap,
930
+ transform: [
931
+ { scale: swap.interpolate({ inputRange: [0, 1], outputRange: [0.5, 1] }) }
932
+ ]
933
+ }
934
+ ],
935
+ children: /* @__PURE__ */ jsx(Icon, { name: "stop", size: theme.ctl.icon.md, color: theme.color.accentInk })
936
+ }
937
+ )
938
+ ]
939
+ }
940
+ )
941
+ ] })
942
+ ] }),
943
+ menuFor !== null ? /* @__PURE__ */ jsxs(Sheet, { open: true, title: labels.queued, onClose: () => setMenuFor(null), children: [
944
+ onEditQueued ? /* @__PURE__ */ jsx(
945
+ SheetRow,
946
+ {
947
+ icon: "edit",
948
+ label: labels.editQueued,
949
+ onPress: () => {
950
+ const id = menuFor;
951
+ setMenuFor(null);
952
+ onEditQueued(id);
953
+ }
954
+ }
955
+ ) : null,
956
+ onRemoveQueued ? /* @__PURE__ */ jsx(
957
+ SheetRow,
958
+ {
959
+ icon: "x",
960
+ label: labels.removeQueued,
961
+ destructive: true,
962
+ onPress: () => {
963
+ const id = menuFor;
964
+ setMenuFor(null);
965
+ onRemoveQueued(id);
966
+ }
967
+ }
968
+ ) : null
969
+ ] }) : null,
970
+ hint ? /* @__PURE__ */ jsx(Text, { style: styles.hint, children: hint }) : null
971
+ ] });
972
+ }
973
+ function ReplyBar({
974
+ reply,
975
+ animate,
976
+ onCancel,
977
+ labels
978
+ }) {
979
+ const arrival = useArrival(animate, "card");
980
+ return /* @__PURE__ */ jsx(Animated.View, { style: arrival, role: "group", accessibilityLabel: labels.replyingTo(reply.author), children: /* @__PURE__ */ jsx(Band, { icon: "reply", title: labels.replyingTo(reply.author), small: true, quote: reply.text, children: onCancel ? /* @__PURE__ */ jsx(ToolButton, { icon: "x", label: labels.cancelReply, size: "xs", onPress: onCancel }) : null }) });
981
+ }
982
+ function Band({
983
+ icon,
984
+ iconColor,
985
+ title,
986
+ small = false,
987
+ quote,
988
+ children
989
+ }) {
990
+ const { styles } = useStyles(sheet3);
991
+ const theme = useLoamTheme("chat");
992
+ return /* @__PURE__ */ jsxs(View, { style: styles.band, children: [
993
+ /* @__PURE__ */ jsx(Icon, { name: icon, size: theme.icon.sm, color: iconColor ?? theme.color.text2 }),
994
+ /* @__PURE__ */ jsxs(View, { style: styles.bandBody, children: [
995
+ title ? /* @__PURE__ */ jsx(Text, { style: small ? styles.replyAuthor : styles.bandTitle, numberOfLines: 1, children: title }) : null,
996
+ quote ? /* @__PURE__ */ jsx(Text, { style: small ? styles.replyText : styles.bandQuote, numberOfLines: 1, children: quote }) : null
997
+ ] }),
998
+ children ? /* @__PURE__ */ jsx(View, { style: styles.bandActions, children }) : null
999
+ ] });
1000
+ }
1001
+ function ToolButton({
1002
+ icon,
1003
+ label,
1004
+ onPress,
1005
+ disabled = false,
1006
+ size = "lg",
1007
+ selected = false,
1008
+ variant = "ghost",
1009
+ children
1010
+ }) {
1011
+ const { styles } = useStyles(sheet3);
1012
+ const theme = useLoamTheme("chat");
1013
+ const box = theme.ctl[size];
1014
+ const slop = Math.max(0, (theme.hit[size] - box) / 2);
1015
+ const primary = variant === "primary";
1016
+ return /* @__PURE__ */ jsxs(
1017
+ Pressable,
1018
+ {
1019
+ accessibilityRole: "button",
1020
+ accessibilityLabel: label,
1021
+ accessibilityState: { disabled, selected },
1022
+ disabled,
1023
+ onPress,
1024
+ hitSlop: slop,
1025
+ style: ({ pressed }) => [
1026
+ styles.tool,
1027
+ { minWidth: box, height: box, borderRadius: theme.ctl.r[size] },
1028
+ primary && styles.toolPrimary,
1029
+ selected && styles.toolSelected,
1030
+ pressed && !primary && styles.toolDown,
1031
+ disabled && styles.disabled
1032
+ ],
1033
+ children: [
1034
+ children,
1035
+ icon ? /* @__PURE__ */ jsx(Icon, { name: icon, size: theme.ctl.icon[size], color: primary ? theme.color.accentInk : theme.color.text2 }) : null
1036
+ ]
1037
+ }
1038
+ );
1039
+ }
1040
+ function SheetRow({
1041
+ icon,
1042
+ label,
1043
+ destructive = false,
1044
+ onPress
1045
+ }) {
1046
+ const { styles } = useStyles(sheet3);
1047
+ const theme = useLoamTheme("chat");
1048
+ const color = destructive ? theme.color.danger : theme.color.text;
1049
+ return /* @__PURE__ */ jsxs(
1050
+ Pressable,
1051
+ {
1052
+ accessibilityRole: "button",
1053
+ accessibilityLabel: label,
1054
+ onPress,
1055
+ style: ({ pressed }) => [styles.sheetRow, pressed && styles.toolDown],
1056
+ children: [
1057
+ /* @__PURE__ */ jsx(Icon, { name: icon, size: theme.icon.sm, color: destructive ? color : theme.color.text2 }),
1058
+ /* @__PURE__ */ jsx(Text, { style: [styles.sheetRowText, { color }], children: label })
1059
+ ]
1060
+ }
1061
+ );
1062
+ }
1063
+ function VoiceBar({
1064
+ voice,
1065
+ labels
1066
+ }) {
1067
+ const { styles } = useStyles(sheet3);
1068
+ const elapsed = useElapsed(voice?.startedAt, true);
1069
+ return /* @__PURE__ */ jsxs(View, { style: styles.bar, testID: "chat-voice-bar", children: [
1070
+ /* @__PURE__ */ jsx(ToolButton, { icon: "x", label: labels.cancelRecording, onPress: voice?.onCancel }),
1071
+ /* @__PURE__ */ jsx(View, { style: styles.dotSlot, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: /* @__PURE__ */ jsx(View, { style: styles.dot }) }),
1072
+ /* @__PURE__ */ jsx(Text, { style: styles.timer, accessibilityRole: "timer", children: formatRecordingTime(elapsed) }),
1073
+ /* @__PURE__ */ jsx(View, { style: styles.wave, children: /* @__PURE__ */ jsx(LevelMeter, { level: voice?.level ?? 0, size: 24, bars: 48, showStatus: false }) }),
1074
+ /* @__PURE__ */ jsx(
1075
+ ToolButton,
1076
+ {
1077
+ icon: "check",
1078
+ variant: "primary",
1079
+ label: labels.doneRecording,
1080
+ onPress: () => {
1081
+ haptics.impact("light");
1082
+ voice?.onDone?.();
1083
+ }
1084
+ }
1085
+ )
1086
+ ] });
1087
+ }
1088
+ function compactTokens(n) {
1089
+ if (n >= 1e6) return `${Math.round(n / 1e5) / 10}M`;
1090
+ if (n >= 1e3) return `${Math.round(n / 1e3)}k`;
1091
+ return String(n);
1092
+ }
1093
+ var RING = 16;
1094
+ var RING_STROKE = 2;
1095
+ function ContextMeter({
1096
+ context,
1097
+ labels
1098
+ }) {
1099
+ const { styles } = useStyles(sheet3);
1100
+ const theme = useLoamTheme("chat");
1101
+ const [open, setOpen] = React10.useState(false);
1102
+ const ratio = context.total > 0 ? Math.min(1, Math.max(0, context.used / context.total)) : 0;
1103
+ const pct = Math.round(ratio * 100);
1104
+ const arc = pct >= 90 ? theme.color.danger : pct >= 75 ? theme.color.warn : theme.color.text2;
1105
+ const tone = pct >= 90 ? "danger" : pct >= 75 ? "warn" : "neutral";
1106
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1107
+ /* @__PURE__ */ jsxs(ToolButton, { label: labels.contextUsed(pct), selected: open, onPress: () => setOpen(true), children: [
1108
+ pct >= 90 ? /* @__PURE__ */ jsxs(Text, { style: [styles.count, pct >= 100 && { color: theme.color.dangerOnSoft }], children: [
1109
+ pct,
1110
+ "%"
1111
+ ] }) : null,
1112
+ /* @__PURE__ */ jsx(Ring, { ratio, color: arc, track: theme.color.borderStrong })
1113
+ ] }),
1114
+ /* @__PURE__ */ jsx(Sheet, { open: open || !!context.open, title: labels.context, onClose: () => setOpen(false), children: /* @__PURE__ */ jsxs(View, { style: styles.contextBody, children: [
1115
+ /* @__PURE__ */ jsxs(View, { style: styles.contextHead, children: [
1116
+ /* @__PURE__ */ jsx(Text, { style: styles.contextTitle, children: pct >= 100 ? labels.chatFull : labels.chatAlmostFull }),
1117
+ /* @__PURE__ */ jsxs(Text, { style: styles.count, children: [
1118
+ compactTokens(context.used),
1119
+ " / ",
1120
+ compactTokens(context.total)
1121
+ ] })
1122
+ ] }),
1123
+ /* @__PURE__ */ jsx(Progress, { value: pct, max: 100, size: "sm", tone, accessibilityLabel: labels.contextUsed(pct) }),
1124
+ /* @__PURE__ */ jsx(Text, { style: styles.contextExplain, children: labels.contextExplain }),
1125
+ /* @__PURE__ */ jsxs(View, { style: styles.contextActions, children: [
1126
+ context.onSummarise ? /* @__PURE__ */ jsx(
1127
+ Button,
1128
+ {
1129
+ fullWidth: true,
1130
+ onPress: () => {
1131
+ setOpen(false);
1132
+ context.onSummarise?.();
1133
+ },
1134
+ children: labels.newChatWithSummary
1135
+ }
1136
+ ) : null,
1137
+ /* @__PURE__ */ jsx(Button, { variant: "outline", fullWidth: true, onPress: () => setOpen(false), children: labels.keepGoing })
1138
+ ] })
1139
+ ] }) })
1140
+ ] });
1141
+ }
1142
+ function Ring({ ratio, color, track }) {
1143
+ const deg = ratio * 360;
1144
+ const half = RING / 2;
1145
+ const circle = {
1146
+ position: "absolute",
1147
+ width: RING,
1148
+ height: RING,
1149
+ borderRadius: half,
1150
+ borderWidth: RING_STROKE
1151
+ };
1152
+ const halfArc = (side, sweep) => /* @__PURE__ */ jsx(
1153
+ View,
1154
+ {
1155
+ style: {
1156
+ position: "absolute",
1157
+ width: half,
1158
+ height: RING,
1159
+ overflow: "hidden",
1160
+ [side === "right" ? "right" : "left"]: 0
1161
+ },
1162
+ children: /* @__PURE__ */ jsx(
1163
+ View,
1164
+ {
1165
+ style: [
1166
+ circle,
1167
+ side === "right" ? { right: 0 } : { left: 0 },
1168
+ {
1169
+ borderColor: "transparent",
1170
+ [side === "right" ? "borderTopColor" : "borderBottomColor"]: color,
1171
+ [side === "right" ? "borderRightColor" : "borderLeftColor"]: color,
1172
+ transform: [{ rotate: `${sweep - 135}deg` }]
1173
+ }
1174
+ ]
1175
+ }
1176
+ )
1177
+ }
1178
+ );
1179
+ return /* @__PURE__ */ jsxs(View, { testID: "chat-context-ring", style: { width: RING, height: RING }, children: [
1180
+ /* @__PURE__ */ jsx(View, { style: [circle, { borderColor: track }] }),
1181
+ deg > 0 ? halfArc("right", Math.min(180, deg)) : null,
1182
+ deg > 180 ? halfArc("left", deg - 180) : null
1183
+ ] });
1184
+ }
1185
+ var sheet3 = createStyleSheet((theme) => ({
1186
+ root: { gap: theme.space.s2 },
1187
+ band: {
1188
+ flexDirection: "row",
1189
+ alignItems: "center",
1190
+ gap: theme.space.s2,
1191
+ minHeight: theme.hit.sm,
1192
+ paddingVertical: theme.space[6],
1193
+ paddingStart: theme.space[14],
1194
+ paddingEnd: theme.space[5],
1195
+ borderBottomWidth: theme.borderWidth.base,
1196
+ borderBottomColor: theme.color.border
1197
+ },
1198
+ bandBody: { flex: 1, minWidth: 0 },
1199
+ bandActions: { flexDirection: "row", alignItems: "center", gap: theme.space.s1 },
1200
+ bandTitle: {
1201
+ fontFamily: theme.font.sans,
1202
+ fontSize: theme.type.subheadline.fontSize,
1203
+ lineHeight: theme.type.subheadline.lineHeight,
1204
+ fontWeight: theme.fontWeight.semibold,
1205
+ color: theme.color.text
1206
+ },
1207
+ bandQuote: {
1208
+ fontFamily: theme.font.sans,
1209
+ fontSize: theme.type.subheadline.fontSize,
1210
+ lineHeight: theme.type.subheadline.lineHeight,
1211
+ color: theme.color.text
1212
+ },
1213
+ replyAuthor: {
1214
+ fontFamily: theme.font.sans,
1215
+ fontSize: theme.type.caption1.fontSize,
1216
+ lineHeight: theme.type.caption1.lineHeight,
1217
+ fontWeight: theme.fontWeight.semibold,
1218
+ color: theme.color.text2
1219
+ },
1220
+ replyText: {
1221
+ fontFamily: theme.font.sans,
1222
+ fontSize: theme.type.footnote.fontSize,
1223
+ lineHeight: theme.type.footnote.lineHeight,
1224
+ color: theme.color.text
1225
+ },
1226
+ moreQueued: {
1227
+ minHeight: theme.hit.sm,
1228
+ justifyContent: "center",
1229
+ paddingStart: theme.space[38],
1230
+ borderBottomWidth: theme.borderWidth.base,
1231
+ borderBottomColor: theme.color.border
1232
+ },
1233
+ moreQueuedText: {
1234
+ fontFamily: theme.font.sans,
1235
+ fontSize: theme.type.footnote.fontSize,
1236
+ fontWeight: theme.fontWeight.medium,
1237
+ color: theme.color.text2
1238
+ },
1239
+ box: {
1240
+ overflow: "hidden",
1241
+ borderRadius: theme.radius[12],
1242
+ borderWidth: theme.borderWidth.strong,
1243
+ borderColor: theme.color.borderStrong,
1244
+ backgroundColor: theme.color.surface2
1245
+ },
1246
+ boxFocused: { borderColor: theme.focus.ringColor, backgroundColor: theme.color.surface },
1247
+ disabled: { opacity: theme.state.disabledOpacity },
1248
+ hidden: { display: "none" },
1249
+ tokens: {
1250
+ position: "absolute",
1251
+ top: 0,
1252
+ left: 0,
1253
+ right: 0,
1254
+ overflow: "hidden",
1255
+ pointerEvents: "none"
1256
+ },
1257
+ tokenText: { color: "transparent" },
1258
+ // loam-contrast-ignore — transparent-text highlight mirrored behind the input; a border would offset the glyph overlay.
1259
+ token: {
1260
+ backgroundColor: theme.color.accentSoft,
1261
+ color: "transparent"
1262
+ },
1263
+ chips: { gap: theme.space.s2, paddingHorizontal: theme.space[14], paddingTop: theme.space[10] },
1264
+ input: {
1265
+ minHeight: theme.type.body.lineHeight + theme.space[14],
1266
+ maxHeight: theme.type.body.lineHeight * 8,
1267
+ paddingHorizontal: theme.space[14],
1268
+ paddingTop: theme.space[10],
1269
+ paddingBottom: theme.space.s1,
1270
+ fontFamily: theme.font.sans,
1271
+ fontSize: theme.type.body.fontSize,
1272
+ lineHeight: theme.type.body.lineHeight,
1273
+ color: theme.color.text,
1274
+ textAlignVertical: "top"
1275
+ },
1276
+ listening: { color: theme.color.text3 },
1277
+ transcribing: { flexDirection: "row", alignItems: "center" },
1278
+ bar: {
1279
+ flexDirection: "row",
1280
+ alignItems: "center",
1281
+ gap: theme.space.s1,
1282
+ // lg 44 pieces (Final 12 iOS / Android "composer lg 44"; Refinement 37 F55
1283
+ // supersedes the sm 30 bar of Refinement 26 / the web row on native).
1284
+ minHeight: theme.ctl.lg + theme.space[10],
1285
+ paddingHorizontal: theme.space[5]
1286
+ },
1287
+ spacer: { flex: 1 },
1288
+ tool: {
1289
+ flexDirection: "row",
1290
+ gap: theme.space[6],
1291
+ paddingHorizontal: theme.space[7],
1292
+ alignItems: "center",
1293
+ justifyContent: "center"
1294
+ },
1295
+ toolPrimary: { backgroundColor: theme.color.accent },
1296
+ toolSelected: { backgroundColor: theme.state.selected },
1297
+ toolDown: { backgroundColor: theme.state.pressed },
1298
+ send: {
1299
+ width: theme.ctl.lg,
1300
+ height: theme.ctl.lg,
1301
+ borderRadius: theme.radius.full,
1302
+ backgroundColor: theme.color.accent,
1303
+ alignItems: "center",
1304
+ justifyContent: "center"
1305
+ },
1306
+ // Button's disabled state: a dim, never a repaint (R5).
1307
+ sendIdle: { opacity: theme.state.disabledOpacity },
1308
+ glyph: { position: "absolute" },
1309
+ dotSlot: { width: theme.ctl.sm, height: theme.ctl.sm, alignItems: "center", justifyContent: "center" },
1310
+ dot: {
1311
+ width: theme.space[8],
1312
+ height: theme.space[8],
1313
+ borderRadius: theme.radius[4],
1314
+ backgroundColor: theme.color.danger,
1315
+ // The 3 px danger-soft halo of the live dot.
1316
+ borderWidth: 0,
1317
+ boxShadow: `0 0 0 ${theme.space[3]}px ${theme.color.dangerSoft}`
1318
+ },
1319
+ timer: {
1320
+ fontFamily: theme.font.mono,
1321
+ fontSize: theme.type.caption1.fontSize,
1322
+ fontWeight: theme.fontWeight.medium,
1323
+ fontVariant: ["tabular-nums"],
1324
+ color: theme.color.text
1325
+ },
1326
+ wave: { flex: 1, minWidth: 0, marginHorizontal: theme.space.s2, overflow: "hidden", alignItems: "flex-end" },
1327
+ count: {
1328
+ fontFamily: theme.font.mono,
1329
+ fontSize: theme.type.caption1.fontSize,
1330
+ fontWeight: theme.fontWeight.medium,
1331
+ fontVariant: ["tabular-nums"],
1332
+ color: theme.color.text2
1333
+ },
1334
+ contextBody: { gap: theme.space[12], paddingBottom: theme.space.s4 },
1335
+ contextHead: { flexDirection: "row", alignItems: "baseline", justifyContent: "space-between", gap: theme.space.s2 },
1336
+ contextTitle: {
1337
+ flex: 1,
1338
+ fontFamily: theme.font.sans,
1339
+ fontSize: theme.type.subheadline.fontSize,
1340
+ lineHeight: theme.type.subheadline.lineHeight,
1341
+ fontWeight: theme.fontWeight.semibold,
1342
+ color: theme.color.text
1343
+ },
1344
+ contextExplain: {
1345
+ fontFamily: theme.font.sans,
1346
+ fontSize: theme.type.footnote.fontSize,
1347
+ lineHeight: theme.type.footnote.lineHeight,
1348
+ color: theme.color.text2
1349
+ },
1350
+ contextActions: { gap: theme.space.s2, marginTop: theme.space.s1 },
1351
+ sheetRow: {
1352
+ flexDirection: "row",
1353
+ alignItems: "center",
1354
+ gap: theme.space[12],
1355
+ minHeight: theme.space[48],
1356
+ paddingHorizontal: theme.space[12],
1357
+ borderRadius: theme.radius[12]
1358
+ },
1359
+ sheetRowText: {
1360
+ fontFamily: theme.font.sans,
1361
+ fontSize: theme.type.subheadline.fontSize,
1362
+ lineHeight: theme.type.subheadline.lineHeight
1363
+ },
1364
+ hint: {
1365
+ textAlign: "center",
1366
+ fontFamily: theme.font.sans,
1367
+ fontSize: theme.type.caption1.fontSize,
1368
+ lineHeight: theme.type.caption1.lineHeight,
1369
+ color: theme.color.text2
1370
+ }
1371
+ }));
1372
+ function ComposerTokens({
1373
+ value,
1374
+ tokens,
1375
+ maxRows,
1376
+ scrollY
1377
+ }) {
1378
+ const { styles } = useStyles(sheet3);
1379
+ const theme = useLoamTheme("chat");
1380
+ const escaped = tokens.map((t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).sort((a, b) => b.length - a.length);
1381
+ const re = new RegExp(`(^|\\s)(${escaped.join("|")})(?=\\s|$)`, "g");
1382
+ const out = [];
1383
+ let last = 0;
1384
+ for (const m of value.matchAll(re)) {
1385
+ const start = (m.index ?? 0) + m[1].length;
1386
+ if (start > last) out.push(value.slice(last, start));
1387
+ out.push(
1388
+ /* @__PURE__ */ jsx(Text, { testID: "chat-token", style: styles.token, children: m[2] }, start)
1389
+ );
1390
+ last = start + m[2].length;
1391
+ }
1392
+ out.push(value.slice(last));
1393
+ return /* @__PURE__ */ jsx(
1394
+ View,
1395
+ {
1396
+ "aria-hidden": true,
1397
+ importantForAccessibility: "no-hide-descendants",
1398
+ testID: "chat-tokens",
1399
+ style: [styles.tokens, { maxHeight: theme.type.body.lineHeight * maxRows }],
1400
+ children: /* @__PURE__ */ jsx(Text, { style: [styles.input, styles.tokenText, { maxHeight: void 0, transform: [{ translateY: -scrollY }] }], children: out })
1401
+ }
1402
+ );
1403
+ }
1404
+ function StepTile({ icon, tone }) {
1405
+ const { styles } = useStyles(sheet4);
1406
+ const theme = useLoamTheme("chat");
1407
+ const color = tone === "warn" ? theme.color.warnOnSoft : tone === "accent" ? theme.color.accentOnSoft : theme.color.text2;
1408
+ return /* @__PURE__ */ jsx(View, { style: [styles.tile, styles[`tile_${tone}`]], children: /* @__PURE__ */ jsx(Icon, { name: icon, size: theme.icon.xs, color }) });
1409
+ }
1410
+ function ApprovalView({
1411
+ part,
1412
+ animate,
1413
+ onAnswer,
1414
+ labels: labelsProp
1415
+ }) {
1416
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
1417
+ const { styles } = useStyles(sheet4);
1418
+ const theme = useLoamTheme("chat");
1419
+ const arrival = useArrival(animate && (part.status ?? "pending") === "pending", "card");
1420
+ const status = part.status ?? "pending";
1421
+ const [always, setAlways] = React10.useState(false);
1422
+ const icon = part.icon ?? "wrench";
1423
+ if (status !== "pending") {
1424
+ return /* @__PURE__ */ jsxs(View, { style: styles.step, children: [
1425
+ /* @__PURE__ */ jsx(StepTile, { icon, tone: "neutral" }),
1426
+ /* @__PURE__ */ jsxs(View, { style: styles.stepBody, children: [
1427
+ /* @__PURE__ */ jsxs(View, { style: styles.stepHead, children: [
1428
+ /* @__PURE__ */ jsx(Text, { style: styles.stepTitle, numberOfLines: 1, children: part.title }),
1429
+ status === "expired" ? /* @__PURE__ */ jsx(Badge, { variant: "neutral", size: "sm", children: labels.expired }) : /* @__PURE__ */ jsx(
1430
+ Icon,
1431
+ {
1432
+ name: status === "allowed" ? "check" : "x",
1433
+ size: theme.icon.xs,
1434
+ color: status === "allowed" ? theme.color.good : theme.color.danger,
1435
+ accessibilityLabel: status === "allowed" ? labels.allowed : labels.denied
1436
+ }
1437
+ )
1438
+ ] }),
1439
+ part.detail ? /* @__PURE__ */ jsx(Text, { style: styles.meta, children: part.detail }) : null
1440
+ ] })
1441
+ ] });
1442
+ }
1443
+ const warn = !!part.destructive;
1444
+ return /* @__PURE__ */ jsxs(Animated.View, { style: [styles.pending, arrival], children: [
1445
+ /* @__PURE__ */ jsxs(View, { style: styles.step, children: [
1446
+ /* @__PURE__ */ jsx(StepTile, { icon, tone: warn ? "warn" : "accent" }),
1447
+ /* @__PURE__ */ jsxs(View, { style: [styles.stepHead, styles.stepBody], children: [
1448
+ /* @__PURE__ */ jsx(Text, { style: styles.stepTitle, numberOfLines: 1, children: part.title }),
1449
+ /* @__PURE__ */ jsx(Badge, { variant: warn ? "warn" : "accent", size: "sm", outline: true, children: labels.needsApproval })
1450
+ ] })
1451
+ ] }),
1452
+ /* @__PURE__ */ jsxs(
1453
+ View,
1454
+ {
1455
+ role: "group",
1456
+ accessibilityLabel: part.tool,
1457
+ style: [styles.card, warn ? styles.cardWarn : styles.cardAccent],
1458
+ children: [
1459
+ /* @__PURE__ */ jsxs(View, { style: styles.band, children: [
1460
+ /* @__PURE__ */ jsx(
1461
+ Icon,
1462
+ {
1463
+ name: icon,
1464
+ size: theme.icon.sm,
1465
+ color: warn ? theme.color.warnOnSoft : theme.color.accentOnSoft
1466
+ }
1467
+ ),
1468
+ /* @__PURE__ */ jsx(Text, { style: styles.tool, children: part.tool }),
1469
+ part.target ? /* @__PURE__ */ jsx(Text, { style: styles.target, numberOfLines: 1, children: part.target }) : null
1470
+ ] }),
1471
+ part.args?.length ? /* @__PURE__ */ jsx(View, { style: styles.args, children: part.args.map((a) => /* @__PURE__ */ jsxs(View, { style: styles.arg, children: [
1472
+ /* @__PURE__ */ jsx(Text, { style: styles.argKey, children: a.key }),
1473
+ /* @__PURE__ */ jsx(Text, { style: styles.argValue, children: a.value })
1474
+ ] }, a.key)) }) : null,
1475
+ /* @__PURE__ */ jsx(View, { style: styles.always, children: /* @__PURE__ */ jsx(
1476
+ Checkbox,
1477
+ {
1478
+ label: labels.alwaysAllow,
1479
+ checked: always,
1480
+ onCheckedChange: setAlways,
1481
+ size: "md"
1482
+ }
1483
+ ) }),
1484
+ /* @__PURE__ */ jsxs(View, { style: styles.decide, children: [
1485
+ /* @__PURE__ */ jsx(View, { style: styles.decideCell, children: /* @__PURE__ */ jsx(
1486
+ Button,
1487
+ {
1488
+ variant: "outline",
1489
+ size: "lg",
1490
+ fullWidth: true,
1491
+ disabled: !onAnswer,
1492
+ onPress: () => onAnswer?.({ allow: false, always }),
1493
+ children: labels.deny
1494
+ }
1495
+ ) }),
1496
+ /* @__PURE__ */ jsx(View, { style: styles.decideCell, children: /* @__PURE__ */ jsx(
1497
+ Button,
1498
+ {
1499
+ variant: "primary",
1500
+ size: "lg",
1501
+ fullWidth: true,
1502
+ disabled: !onAnswer,
1503
+ leadingIcon: warn ? "alert-triangle" : void 0,
1504
+ onPress: () => onAnswer?.({ allow: true, always }),
1505
+ children: part.allowLabel ?? labels.allow
1506
+ }
1507
+ ) })
1508
+ ] })
1509
+ ]
1510
+ }
1511
+ )
1512
+ ] });
1513
+ }
1514
+ function CitationMark({
1515
+ n,
1516
+ source,
1517
+ active,
1518
+ onOpen,
1519
+ labels: labelsProp
1520
+ }) {
1521
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
1522
+ const { styles } = useStyles(sheet4);
1523
+ const theme = useLoamTheme("chat");
1524
+ const gone = !source || source.unavailable;
1525
+ const slop = Math.max(0, (theme.tapMin - theme.space[20]) / 2);
1526
+ return /* @__PURE__ */ jsx(
1527
+ Pressable,
1528
+ {
1529
+ accessibilityRole: "button",
1530
+ accessibilityLabel: gone ? `${labels.source(n)}, ${labels.sourceUnavailable}` : labels.source(n),
1531
+ accessibilityState: { disabled: !!gone, selected: active },
1532
+ disabled: !!gone,
1533
+ hitSlop: slop,
1534
+ onPress: () => source && onOpen?.(source),
1535
+ style: [styles.marker, active && styles.markerActive, !!gone && styles.markerGone],
1536
+ children: /* @__PURE__ */ jsx(Text, { style: [styles.markerText, !!gone && styles.struck], children: n })
1537
+ }
1538
+ );
1539
+ }
1540
+ var VISIBLE_SOURCES = 4;
1541
+ function SourcesRow({
1542
+ sources,
1543
+ onOpen,
1544
+ onOpenAll,
1545
+ labels: labelsProp
1546
+ }) {
1547
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
1548
+ const { styles } = useStyles(sheet4);
1549
+ const shown = sources.slice(0, VISIBLE_SOURCES);
1550
+ const rest = sources.length - shown.length;
1551
+ return /* @__PURE__ */ jsxs(View, { accessibilityLabel: labels.sources, role: "list", style: styles.chips, children: [
1552
+ shown.map((s, i) => /* @__PURE__ */ jsx(View, { role: "listitem", children: /* @__PURE__ */ jsx(
1553
+ Chip,
1554
+ {
1555
+ variant: "suggestion",
1556
+ size: "sm",
1557
+ disabled: s.unavailable,
1558
+ onPress: () => onOpen(s),
1559
+ accessibilityLabel: `${i + 1} ${s.unavailable ? labels.sourceUnavailable : s.domain ?? s.title}`,
1560
+ children: `${i + 1} ${s.unavailable ? labels.sourceUnavailable : s.domain ?? s.title}`
1561
+ }
1562
+ ) }, s.id)),
1563
+ rest > 0 ? /* @__PURE__ */ jsx(View, { role: "listitem", children: /* @__PURE__ */ jsx(
1564
+ Chip,
1565
+ {
1566
+ variant: "suggestion",
1567
+ size: "sm",
1568
+ accessibilityLabel: labels.moreSources(rest),
1569
+ onPress: onOpenAll,
1570
+ children: `+${rest}`
1571
+ }
1572
+ ) }) : null
1573
+ ] });
1574
+ }
1575
+ function Snippet({ text, quote }) {
1576
+ const { styles } = useStyles(sheet4);
1577
+ const at = quote ? text.indexOf(quote) : -1;
1578
+ if (!quote || at === -1) return /* @__PURE__ */ jsx(Text, { style: styles.snippet, children: text });
1579
+ return /* @__PURE__ */ jsxs(Text, { style: styles.snippet, children: [
1580
+ text.slice(0, at),
1581
+ /* @__PURE__ */ jsx(Text, { style: styles.quote, children: quote }),
1582
+ text.slice(at + quote.length)
1583
+ ] });
1584
+ }
1585
+ function SourcesSheet({
1586
+ open,
1587
+ sources,
1588
+ active,
1589
+ onClose,
1590
+ onOpenSource,
1591
+ labels: labelsProp
1592
+ }) {
1593
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
1594
+ const { styles } = useStyles(sheet4);
1595
+ const theme = useLoamTheme("chat");
1596
+ if (!open) return null;
1597
+ return /* @__PURE__ */ jsx(Sheet, { open: true, title: `${labels.sources} ${sources.length}`, onClose, closeLabel: labels.close, children: /* @__PURE__ */ jsx(View, { role: "list", accessibilityLabel: `${labels.sources} ${sources.length}`, style: styles.sourceList, children: sources.map((s, i) => {
1598
+ const chosen = active === s.id;
1599
+ return /* @__PURE__ */ jsxs(View, { role: "listitem", children: [
1600
+ /* @__PURE__ */ jsxs(
1601
+ Pressable,
1602
+ {
1603
+ accessibilityRole: "button",
1604
+ accessibilityLabel: `${i + 1}. ${s.title}${s.unavailable ? `, ${labels.sourceUnavailable}` : ""}`,
1605
+ accessibilityState: { disabled: !!s.unavailable, selected: chosen },
1606
+ disabled: s.unavailable,
1607
+ onPress: () => onOpenSource?.(s),
1608
+ style: ({ pressed }) => [
1609
+ styles.sourceRow,
1610
+ chosen && styles.sourceChosen,
1611
+ pressed && styles.down
1612
+ ],
1613
+ children: [
1614
+ /* @__PURE__ */ jsx(Text, { style: styles.sourceNumber, children: i + 1 }),
1615
+ /* @__PURE__ */ jsxs(View, { style: styles.sourceText, children: [
1616
+ /* @__PURE__ */ jsx(
1617
+ Text,
1618
+ {
1619
+ numberOfLines: 1,
1620
+ style: [styles.sourceTitle, s.unavailable && styles.sourceGone],
1621
+ children: s.title
1622
+ }
1623
+ ),
1624
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles.meta, children: s.unavailable ? labels.sourceUnavailable : s.detail ?? s.domain })
1625
+ ] }),
1626
+ s.unavailable ? null : /* @__PURE__ */ jsx(Icon, { name: "external-link", size: theme.icon.sm, color: theme.color.text2 })
1627
+ ]
1628
+ }
1629
+ ),
1630
+ chosen && s.snippet ? /* @__PURE__ */ jsx(View, { style: styles.snippetBox, children: /* @__PURE__ */ jsx(Snippet, { text: s.snippet, quote: s.quote }) }) : null
1631
+ ] }, s.id);
1632
+ }) }) });
1633
+ }
1634
+ function SwitchButton({
1635
+ icon,
1636
+ label,
1637
+ disabled,
1638
+ onPress
1639
+ }) {
1640
+ const { styles } = useStyles(sheet4);
1641
+ const theme = useLoamTheme("chat");
1642
+ return /* @__PURE__ */ jsx(
1643
+ Pressable,
1644
+ {
1645
+ accessibilityRole: "button",
1646
+ accessibilityLabel: label,
1647
+ accessibilityState: { disabled },
1648
+ disabled,
1649
+ onPress,
1650
+ hitSlop: (theme.hit.sm - theme.ctl.sm) / 2,
1651
+ style: ({ pressed }) => [
1652
+ styles.switchButton,
1653
+ disabled && styles.switchOff,
1654
+ pressed && styles.down
1655
+ ],
1656
+ children: /* @__PURE__ */ jsx(Icon, { name: icon, size: theme.ctl.icon.sm, color: theme.color.text2 })
1657
+ }
1658
+ );
1659
+ }
1660
+ function VersionSwitcher({
1661
+ index,
1662
+ count,
1663
+ streaming,
1664
+ onChange,
1665
+ rule,
1666
+ labels: labelsProp
1667
+ }) {
1668
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
1669
+ const { styles } = useStyles(sheet4);
1670
+ return /* @__PURE__ */ jsxs(View, { style: styles.switcher, children: [
1671
+ /* @__PURE__ */ jsx(
1672
+ SwitchButton,
1673
+ {
1674
+ icon: "chevron-left",
1675
+ label: labels.previousVersion,
1676
+ disabled: index <= 1 || !onChange,
1677
+ onPress: () => onChange?.(index - 1)
1678
+ }
1679
+ ),
1680
+ /* @__PURE__ */ jsx(Text, { accessibilityLiveRegion: "polite", style: styles.versionCount, children: labels.versionOf(index, count) }),
1681
+ streaming ? /* @__PURE__ */ jsx(View, { style: styles.switchSlot, children: /* @__PURE__ */ jsx(Thinking, { label: "", size: "sm", announce: false }) }) : /* @__PURE__ */ jsx(
1682
+ SwitchButton,
1683
+ {
1684
+ icon: "chevron-right",
1685
+ label: labels.nextVersion,
1686
+ disabled: index >= count || !onChange,
1687
+ onPress: () => onChange?.(index + 1)
1688
+ }
1689
+ ),
1690
+ rule ? /* @__PURE__ */ jsx(View, { accessibilityElementsHidden: true, style: styles.rule }) : null
1691
+ ] });
1692
+ }
1693
+ var sheet4 = createStyleSheet((theme) => ({
1694
+ pending: { gap: theme.space.s2 },
1695
+ step: { flexDirection: "row", gap: theme.space.s3, paddingVertical: theme.space[6] },
1696
+ stepBody: { flex: 1, minWidth: 0, gap: theme.space[2] },
1697
+ stepHead: { flexDirection: "row", alignItems: "center", gap: theme.space.s2, minHeight: theme.space[26] },
1698
+ stepTitle: {
1699
+ flexShrink: 1,
1700
+ fontFamily: theme.font.sans,
1701
+ fontSize: theme.type.footnote.fontSize,
1702
+ lineHeight: theme.type.footnote.lineHeight,
1703
+ color: theme.color.text
1704
+ },
1705
+ meta: {
1706
+ fontFamily: theme.font.sans,
1707
+ fontSize: theme.type.footnote.fontSize,
1708
+ lineHeight: theme.type.footnote.lineHeight,
1709
+ color: theme.color.text2
1710
+ },
1711
+ tile: {
1712
+ width: theme.space[22],
1713
+ height: theme.space[22],
1714
+ marginTop: theme.space[2],
1715
+ borderRadius: theme.radius[6],
1716
+ borderWidth: theme.borderWidth.base,
1717
+ alignItems: "center",
1718
+ justifyContent: "center"
1719
+ },
1720
+ tile_neutral: { borderColor: theme.color.border, backgroundColor: theme.color.surface3 },
1721
+ tile_accent: { borderColor: theme.edge.accent, backgroundColor: theme.color.accentSoft },
1722
+ tile_warn: { borderColor: theme.edge.warn, backgroundColor: theme.color.warnSoft },
1723
+ card: {
1724
+ overflow: "hidden",
1725
+ borderRadius: theme.radius.lg,
1726
+ borderWidth: theme.borderWidth.strong,
1727
+ backgroundColor: theme.color.surface
1728
+ },
1729
+ cardAccent: { borderColor: theme.edge.accent },
1730
+ cardWarn: { borderColor: theme.edge.warn },
1731
+ // The 40 band, the same as a code block's.
1732
+ band: {
1733
+ height: theme.space[40],
1734
+ flexDirection: "row",
1735
+ alignItems: "center",
1736
+ gap: theme.space.s2,
1737
+ paddingHorizontal: theme.space[12],
1738
+ borderBottomWidth: theme.borderWidth.base,
1739
+ borderBottomColor: theme.color.border
1740
+ },
1741
+ tool: {
1742
+ fontFamily: theme.font.sans,
1743
+ fontSize: theme.type.footnote.fontSize,
1744
+ fontWeight: theme.fontWeight.semibold,
1745
+ color: theme.color.text
1746
+ },
1747
+ target: {
1748
+ flex: 1,
1749
+ minWidth: 0,
1750
+ fontFamily: theme.font.mono,
1751
+ fontSize: theme.type.caption1.fontSize,
1752
+ fontWeight: theme.fontWeight.medium,
1753
+ color: theme.color.text2
1754
+ },
1755
+ args: { gap: theme.space[10], padding: theme.space[12] },
1756
+ arg: { gap: theme.space[2] },
1757
+ argKey: {
1758
+ fontFamily: theme.font.mono,
1759
+ fontSize: theme.type.caption1.fontSize,
1760
+ fontWeight: theme.fontWeight.medium,
1761
+ color: theme.color.text2
1762
+ },
1763
+ argValue: {
1764
+ fontFamily: theme.font.sans,
1765
+ fontSize: theme.type.subheadline.fontSize,
1766
+ lineHeight: theme.type.subheadline.lineHeight,
1767
+ color: theme.color.text
1768
+ },
1769
+ always: {
1770
+ minHeight: theme.space[48],
1771
+ justifyContent: "center",
1772
+ paddingHorizontal: theme.space[12],
1773
+ borderTopWidth: theme.borderWidth.base,
1774
+ borderTopColor: theme.color.border
1775
+ },
1776
+ decide: { flexDirection: "row", gap: theme.space.s2, padding: theme.space[8], paddingTop: 0 },
1777
+ decideCell: { flex: 1 },
1778
+ marker: {
1779
+ minWidth: theme.space[20],
1780
+ height: theme.space[20],
1781
+ paddingHorizontal: theme.space[5],
1782
+ marginHorizontal: theme.space[2],
1783
+ borderRadius: theme.radius.xs,
1784
+ // Final 12 "Marker": accent-soft / accent-on-soft (latest over Refinement 25's surface-3).
1785
+ backgroundColor: theme.color.accentSoft,
1786
+ borderWidth: theme.borderWidth.thin,
1787
+ borderColor: theme.edge.accent,
1788
+ alignItems: "center",
1789
+ justifyContent: "center"
1790
+ },
1791
+ markerActive: { backgroundColor: theme.state.selected },
1792
+ markerGone: { backgroundColor: theme.color.surface3 },
1793
+ markerText: {
1794
+ fontFamily: theme.font.mono,
1795
+ fontSize: theme.type.caption1.fontSize,
1796
+ lineHeight: theme.space[20],
1797
+ fontWeight: theme.fontWeight.medium,
1798
+ fontVariant: ["tabular-nums"],
1799
+ color: theme.color.accentOnSoft
1800
+ },
1801
+ struck: { textDecorationLine: "line-through", color: theme.color.text2 },
1802
+ chips: { flexDirection: "row", flexWrap: "wrap", gap: theme.space.s2 },
1803
+ sourceList: { gap: theme.space[2], padding: theme.space[8] },
1804
+ // 56 rows, r 12 inside the 8 pad of the r 24 sheet.
1805
+ sourceRow: {
1806
+ minHeight: theme.space[56],
1807
+ flexDirection: "row",
1808
+ alignItems: "center",
1809
+ gap: theme.space.s3,
1810
+ paddingHorizontal: theme.space[8],
1811
+ borderRadius: theme.radius.md
1812
+ },
1813
+ sourceChosen: { backgroundColor: theme.state.selected },
1814
+ down: { backgroundColor: theme.state.pressed },
1815
+ sourceNumber: {
1816
+ width: theme.space[20],
1817
+ textAlign: "center",
1818
+ fontFamily: theme.font.mono,
1819
+ fontSize: theme.type.caption1.fontSize,
1820
+ fontWeight: theme.fontWeight.medium,
1821
+ color: theme.color.text2
1822
+ },
1823
+ sourceText: { flex: 1, minWidth: 0, gap: theme.space[2] },
1824
+ sourceTitle: {
1825
+ fontFamily: theme.font.sans,
1826
+ fontSize: theme.type.callout.fontSize,
1827
+ lineHeight: theme.type.callout.lineHeight,
1828
+ fontWeight: theme.fontWeight.medium,
1829
+ color: theme.color.text
1830
+ },
1831
+ sourceGone: { textDecorationLine: "line-through", color: theme.color.text3 },
1832
+ snippetBox: { paddingHorizontal: theme.space[44], paddingBottom: theme.space[8] },
1833
+ snippet: {
1834
+ fontFamily: theme.font.sans,
1835
+ fontSize: theme.type.footnote.fontSize,
1836
+ lineHeight: theme.type.footnote.lineHeight,
1837
+ color: theme.color.text2
1838
+ },
1839
+ quote: { backgroundColor: theme.state.selected, color: theme.color.text },
1840
+ switcher: { flexDirection: "row", alignItems: "center" },
1841
+ switchButton: {
1842
+ width: theme.ctl.sm,
1843
+ height: theme.ctl.sm,
1844
+ borderRadius: theme.ctl.r.sm,
1845
+ alignItems: "center",
1846
+ justifyContent: "center"
1847
+ },
1848
+ switchOff: { opacity: theme.state.disabledOpacity },
1849
+ switchSlot: {
1850
+ width: theme.ctl.sm,
1851
+ height: theme.ctl.sm,
1852
+ alignItems: "center",
1853
+ justifyContent: "center"
1854
+ },
1855
+ versionCount: {
1856
+ minWidth: theme.space[52],
1857
+ textAlign: "center",
1858
+ fontFamily: theme.font.mono,
1859
+ fontSize: theme.type.footnote.fontSize,
1860
+ fontWeight: theme.fontWeight.medium,
1861
+ fontVariant: ["tabular-nums"],
1862
+ color: theme.color.text2
1863
+ },
1864
+ rule: {
1865
+ width: theme.borderWidth.base,
1866
+ height: theme.space[16],
1867
+ marginHorizontal: theme.space[4],
1868
+ backgroundColor: theme.color.borderStrong
1869
+ }
1870
+ }));
1871
+ function ChatArtifactCard({
1872
+ artifact,
1873
+ onOpen,
1874
+ open,
1875
+ labels: labelsProp
1876
+ }) {
1877
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
1878
+ const { styles } = useStyles(sheet5);
1879
+ const theme = useLoamTheme("chat");
1880
+ const meta = [artifact.kind, artifact.updated].filter(Boolean).join(" \xB7 ");
1881
+ return /* @__PURE__ */ jsxs(
1882
+ Pressable,
1883
+ {
1884
+ accessibilityRole: "button",
1885
+ accessibilityLabel: labels.artifactName(artifact.title, artifact.kind),
1886
+ accessibilityHint: labels.open,
1887
+ accessibilityState: { selected: !!open },
1888
+ onPress: onOpen,
1889
+ style: ({ pressed }) => [styles.card, open && styles.cardOpen, pressed && styles.down],
1890
+ children: [
1891
+ /* @__PURE__ */ jsx(IconTile, { icon: artifact.icon ?? "file-text", tone: "accent", size: "md" }),
1892
+ /* @__PURE__ */ jsxs(View, { style: styles.text, children: [
1893
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles.title, children: artifact.title }),
1894
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles.meta, children: meta })
1895
+ ] }),
1896
+ /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: theme.icon.sm, color: theme.color.text3 })
1897
+ ]
1898
+ }
1899
+ );
1900
+ }
1901
+ function ChatArtifactSheet({
1902
+ artifact,
1903
+ open,
1904
+ onClose,
1905
+ onVersionChange,
1906
+ onShare,
1907
+ labels: labelsProp
1908
+ }) {
1909
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
1910
+ const { styles } = useStyles(sheet5);
1911
+ const [view, setView] = React10.useState("preview");
1912
+ if (!open) return null;
1913
+ const v = artifact.version;
1914
+ return /* @__PURE__ */ jsxs(
1915
+ Sheet,
1916
+ {
1917
+ open: true,
1918
+ title: artifact.title,
1919
+ onClose,
1920
+ closeLabel: labels.close,
1921
+ detents: ["full"],
1922
+ initialDetent: "full",
1923
+ footer: onShare ? /* @__PURE__ */ jsx(View, { style: styles.footer, children: /* @__PURE__ */ jsx(Button, { variant: "outline", size: "lg", fullWidth: true, leadingIcon: "share", onPress: () => onShare(artifact), children: labels.share }) }) : void 0,
1924
+ children: [
1925
+ /* @__PURE__ */ jsxs(View, { style: styles.bar, children: [
1926
+ artifact.code != null ? /* @__PURE__ */ jsx(
1927
+ SegmentedControl,
1928
+ {
1929
+ size: "sm",
1930
+ accessibilityLabel: artifact.title,
1931
+ items: [
1932
+ { value: "preview", label: labels.preview },
1933
+ { value: "code", label: labels.code }
1934
+ ],
1935
+ value: view,
1936
+ onValueChange: (next) => setView(next)
1937
+ }
1938
+ ) : null,
1939
+ v && v.count > 1 ? /* @__PURE__ */ jsx(
1940
+ VersionSwitcher,
1941
+ {
1942
+ index: v.index,
1943
+ count: v.count,
1944
+ onChange: onVersionChange ? (i) => onVersionChange(artifact, i) : void 0,
1945
+ labels
1946
+ }
1947
+ ) : null
1948
+ ] }),
1949
+ /* @__PURE__ */ jsx(View, { style: styles.body, children: view === "code" && artifact.code != null ? /* @__PURE__ */ jsx(ScrollView, { horizontal: true, tabIndex: 0, children: /* @__PURE__ */ jsx(Text, { selectable: true, style: styles.code, children: artifact.code }) }) : artifact.preview })
1950
+ ]
1951
+ }
1952
+ );
1953
+ }
1954
+ var sheet5 = createStyleSheet((theme) => ({
1955
+ card: {
1956
+ minHeight: theme.space[56],
1957
+ flexDirection: "row",
1958
+ alignItems: "center",
1959
+ gap: theme.space.s3,
1960
+ paddingHorizontal: theme.space[12],
1961
+ borderRadius: theme.radius.lg,
1962
+ borderWidth: theme.borderWidth.base,
1963
+ borderColor: theme.color.border,
1964
+ backgroundColor: theme.color.surface
1965
+ },
1966
+ cardOpen: { backgroundColor: theme.state.selected },
1967
+ down: { backgroundColor: theme.state.pressed },
1968
+ text: { flex: 1, minWidth: 0, gap: theme.space[2] },
1969
+ title: {
1970
+ fontFamily: theme.font.sans,
1971
+ fontSize: theme.type.callout.fontSize,
1972
+ lineHeight: theme.type.callout.lineHeight,
1973
+ fontWeight: theme.fontWeight.semibold,
1974
+ color: theme.color.text
1975
+ },
1976
+ meta: {
1977
+ fontFamily: theme.font.sans,
1978
+ fontSize: theme.type.footnote.fontSize,
1979
+ lineHeight: theme.type.footnote.lineHeight,
1980
+ color: theme.color.text2
1981
+ },
1982
+ bar: {
1983
+ flexDirection: "row",
1984
+ alignItems: "center",
1985
+ justifyContent: "space-between",
1986
+ gap: theme.space.s3,
1987
+ paddingHorizontal: theme.space[16],
1988
+ paddingBottom: theme.space[8]
1989
+ },
1990
+ body: { padding: theme.space[16] },
1991
+ footer: { padding: theme.space[16] },
1992
+ code: {
1993
+ fontFamily: theme.font.mono,
1994
+ fontSize: theme.type.footnote.fontSize,
1995
+ lineHeight: theme.type.footnote.lineHeight,
1996
+ color: theme.color.text
1997
+ }
1998
+ }));
1999
+ var COLUMN = 120;
2000
+ function ChatInlineTable({
2001
+ part,
2002
+ onExpand,
2003
+ labels: labelsProp
2004
+ }) {
2005
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
2006
+ const { styles } = useStyles(sheet6);
2007
+ const total = part.total ?? part.rows.length;
2008
+ return /* @__PURE__ */ jsxs(View, { style: styles.root, role: "group", accessibilityLabel: part.title, children: [
2009
+ /* @__PURE__ */ jsxs(View, { style: styles.band, children: [
2010
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles.title, children: part.title }),
2011
+ /* @__PURE__ */ jsx(Text, { style: styles.count, children: labels.rows(total) }),
2012
+ onExpand ? /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onPress: () => onExpand(part), children: labels.expand }) : null
2013
+ ] }),
2014
+ /* @__PURE__ */ jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, tabIndex: 0, children: /* @__PURE__ */ jsxs(View, { role: "table", children: [
2015
+ /* @__PURE__ */ jsx(View, { role: "row", style: [styles.row, styles.head], children: part.columns.map((c) => /* @__PURE__ */ jsx(
2016
+ Text,
2017
+ {
2018
+ role: "columnheader",
2019
+ style: [styles.cell, styles.headText, { width: c.width ?? COLUMN }, c.align === "end" && styles.end],
2020
+ children: c.label
2021
+ },
2022
+ c.key
2023
+ )) }),
2024
+ part.rows.map((r, i) => /* @__PURE__ */ jsx(View, { role: "row", style: [styles.row, i > 0 && styles.ruled], children: part.columns.map((c) => /* @__PURE__ */ jsx(
2025
+ Text,
2026
+ {
2027
+ role: "cell",
2028
+ numberOfLines: 1,
2029
+ style: [styles.cell, styles.cellText, { width: c.width ?? COLUMN }, c.align === "end" && styles.end],
2030
+ children: r[c.key]
2031
+ },
2032
+ c.key
2033
+ )) }, i))
2034
+ ] }) })
2035
+ ] });
2036
+ }
2037
+ var sheet6 = createStyleSheet((theme) => ({
2038
+ root: {
2039
+ overflow: "hidden",
2040
+ borderRadius: theme.radius.lg,
2041
+ borderWidth: theme.borderWidth.base,
2042
+ borderColor: theme.color.border,
2043
+ backgroundColor: theme.color.surface
2044
+ },
2045
+ band: {
2046
+ height: theme.space[40],
2047
+ flexDirection: "row",
2048
+ alignItems: "center",
2049
+ gap: theme.space.s2,
2050
+ paddingHorizontal: theme.space[12],
2051
+ borderBottomWidth: theme.borderWidth.base,
2052
+ borderBottomColor: theme.color.border
2053
+ },
2054
+ title: {
2055
+ flex: 1,
2056
+ minWidth: 0,
2057
+ fontFamily: theme.font.sans,
2058
+ fontSize: theme.type.footnote.fontSize,
2059
+ fontWeight: theme.fontWeight.semibold,
2060
+ color: theme.color.text
2061
+ },
2062
+ count: {
2063
+ fontFamily: theme.font.mono,
2064
+ fontSize: theme.type.caption1.fontSize,
2065
+ color: theme.color.text2
2066
+ },
2067
+ row: { flexDirection: "row", height: theme.space[44], alignItems: "center" },
2068
+ head: { backgroundColor: theme.color.surface3 },
2069
+ ruled: { borderTopWidth: theme.borderWidth.base, borderTopColor: theme.color.border },
2070
+ cell: { paddingHorizontal: theme.space[12] },
2071
+ end: { textAlign: "right" },
2072
+ // Table header: footnote 13 / 600 on iOS, 12 / 500 on Android; cells at the subheadline.
2073
+ headText: {
2074
+ ...theme.type.footnote,
2075
+ fontFamily: theme.font.sans,
2076
+ fontWeight: theme.platform === "Android" ? theme.fontWeight.medium : theme.fontWeight.semibold,
2077
+ color: theme.color.text2
2078
+ },
2079
+ cellText: {
2080
+ ...theme.type.subheadline,
2081
+ fontFamily: theme.font.sans,
2082
+ color: theme.color.text
2083
+ }
2084
+ }));
2085
+
2086
+ // src/chat/chat-types.ts
2087
+ function chatMessageText(message) {
2088
+ return message.parts.filter((p) => p.kind === "text").map((p) => p.text).join("\n\n").trim();
2089
+ }
2090
+ function AssistantMark() {
2091
+ const { styles } = useStyles(sheet7);
2092
+ const theme = useLoamTheme("chat");
2093
+ return /* @__PURE__ */ jsx(View, { style: styles.mark, children: /* @__PURE__ */ jsx(Icon, { name: "sparkle", size: theme.icon.sm, color: theme.color.accentOnSoft }) });
2094
+ }
2095
+ function segment(parts) {
2096
+ const out = [];
2097
+ for (const part of parts) {
2098
+ const last = out[out.length - 1];
2099
+ if (part.kind === "tool") {
2100
+ if (last?.kind === "tools") last.tools.push(part);
2101
+ else out.push({ kind: "tools", id: part.id, tools: [part] });
2102
+ } else out.push({ kind: "part", part });
2103
+ }
2104
+ return out;
2105
+ }
2106
+ function Action({
2107
+ label,
2108
+ icon,
2109
+ onPress,
2110
+ pressed
2111
+ }) {
2112
+ const { styles } = useStyles(sheet7);
2113
+ const theme = useLoamTheme("chat");
2114
+ return /* @__PURE__ */ jsx(
2115
+ Pressable,
2116
+ {
2117
+ accessibilityRole: "button",
2118
+ accessibilityLabel: label,
2119
+ accessibilityState: pressed != null ? { selected: pressed } : void 0,
2120
+ "aria-pressed": pressed,
2121
+ onPress,
2122
+ hitSlop: (theme.hit.sm - theme.ctl.sm) / 2,
2123
+ style: ({ pressed: down }) => [
2124
+ styles.action,
2125
+ pressed && styles.actionSelected,
2126
+ down && styles.actionDown
2127
+ ],
2128
+ children: /* @__PURE__ */ jsx(Icon, { name: icon, size: theme.ctl.icon.sm, color: theme.color.text2 })
2129
+ }
2130
+ );
2131
+ }
2132
+ var REPLY_ARM = 56;
2133
+ function useSwipeReply(onReply, animate) {
2134
+ const theme = useLoamTheme("chat");
2135
+ const tx = React10.useRef(new Animated.Value(0)).current;
2136
+ const live = React10.useRef({ onReply, animate, theme });
2137
+ live.current = { onReply, animate, theme };
2138
+ const state = React10.useRef({ armed: false, broke: false });
2139
+ const sign = I18nManager.isRTL ? -1 : 1;
2140
+ const pan = React10.useRef(
2141
+ // One horizontal pull on a bubble inside a vertical list; no gesture
2142
+ // library is allowed on native, so `PanResponder`, as `Toast` does.
2143
+ // eslint-disable-next-line loam/no-pan-responder
2144
+ PanResponder.create({
2145
+ onMoveShouldSetPanResponder: (_e, g) => !!live.current.onReply && g.dx * sign > 8 && Math.abs(g.dx) > Math.abs(g.dy) * 1.5,
2146
+ onPanResponderGrant: () => {
2147
+ tx.stopAnimation();
2148
+ state.current = { armed: false, broke: false };
2149
+ },
2150
+ onPanResponderMove: (_e, g) => {
2151
+ const a = Math.max(0, g.dx * sign);
2152
+ const s = state.current;
2153
+ const armed = a >= REPLY_ARM;
2154
+ if (armed && !s.armed) haptics.selection();
2155
+ s.armed = armed;
2156
+ if (a < BREAKAWAY && !s.broke) return tx.setValue(sign * resist(a));
2157
+ const target = sign * (armed ? REPLY_ARM + rubberband(a - REPLY_ARM, REPLY_ARM * 4) : a);
2158
+ if (!s.broke && live.current.animate) {
2159
+ s.broke = true;
2160
+ Animated.spring(tx, {
2161
+ toValue: target,
2162
+ ...springConfig(live.current.theme, "fs"),
2163
+ useNativeDriver: true
2164
+ }).start();
2165
+ return;
2166
+ }
2167
+ s.broke = true;
2168
+ tx.setValue(target);
2169
+ },
2170
+ onPanResponderRelease: (_e, g) => {
2171
+ const { onReply: reply, animate: anim, theme: th } = live.current;
2172
+ if (anim) {
2173
+ Animated.spring(tx, {
2174
+ toValue: 0,
2175
+ ...springConfig(th, "fs", { velocity: g.vx }),
2176
+ useNativeDriver: true
2177
+ }).start();
2178
+ } else tx.setValue(0);
2179
+ if (state.current.armed) reply?.();
2180
+ state.current.armed = false;
2181
+ },
2182
+ onPanResponderTerminate: () => {
2183
+ state.current.armed = false;
2184
+ tx.setValue(0);
2185
+ }
2186
+ })
2187
+ ).current;
2188
+ const reveal = tx.interpolate({
2189
+ inputRange: sign > 0 ? [0, REPLY_ARM] : [-REPLY_ARM, 0],
2190
+ outputRange: sign > 0 ? [0, 1] : [1, 0],
2191
+ extrapolate: "clamp"
2192
+ });
2193
+ const cueScale = tx.interpolate({
2194
+ inputRange: sign > 0 ? [0, REPLY_ARM - 0.01, REPLY_ARM] : [-REPLY_ARM, -REPLY_ARM + 0.01, 0],
2195
+ outputRange: sign > 0 ? [0.5, 0.9, 1] : [1, 0.9, 0.5],
2196
+ extrapolate: "clamp"
2197
+ });
2198
+ return { tx, panHandlers: onReply ? pan.panHandlers : {}, reveal, cueScale };
2199
+ }
2200
+ function SwipeReply({
2201
+ onReply,
2202
+ animate,
2203
+ style,
2204
+ children
2205
+ }) {
2206
+ const { styles } = useStyles(sheet7);
2207
+ const theme = useLoamTheme("chat");
2208
+ const swipe = useSwipeReply(onReply, animate);
2209
+ return /* @__PURE__ */ jsxs(View, { style, children: [
2210
+ onReply ? /* @__PURE__ */ jsx(
2211
+ Animated.View,
2212
+ {
2213
+ pointerEvents: "none",
2214
+ importantForAccessibility: "no-hide-descendants",
2215
+ accessibilityElementsHidden: true,
2216
+ style: [
2217
+ styles.replyCue,
2218
+ { opacity: swipe.reveal, transform: [{ scale: swipe.cueScale }] }
2219
+ ],
2220
+ children: /* @__PURE__ */ jsx(Icon, { name: "reply", size: theme.icon.xs, color: theme.color.text2 })
2221
+ }
2222
+ ) : null,
2223
+ /* @__PURE__ */ jsx(
2224
+ Animated.View,
2225
+ {
2226
+ testID: "chat-swipe-reply",
2227
+ style: { transform: [{ translateX: swipe.tx }] },
2228
+ ...swipe.panHandlers,
2229
+ children
2230
+ }
2231
+ )
2232
+ ] });
2233
+ }
2234
+ var ChatMessageRow = React10.memo(function ChatMessageRow2(props) {
2235
+ return props.message.role === "user" ? /* @__PURE__ */ jsx(UserRow, { ...props }) : /* @__PURE__ */ jsx(AssistantRow, { ...props });
2236
+ });
2237
+ function UserRow({
2238
+ message,
2239
+ appearing,
2240
+ animate,
2241
+ user,
2242
+ running,
2243
+ onEdit,
2244
+ onRetry,
2245
+ onCopy,
2246
+ onReply,
2247
+ labels: labelsProp
2248
+ }) {
2249
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
2250
+ const { styles } = useStyles(sheet7);
2251
+ const theme = useLoamTheme("chat");
2252
+ const arrival = useArrival(appearing && animate, "sent");
2253
+ const [editing, setEditing] = React10.useState(false);
2254
+ const text = chatMessageText(message);
2255
+ const [draft, setDraft] = React10.useState(text);
2256
+ const status = message.status ?? "done";
2257
+ const failed = status === "failed";
2258
+ const canEdit = !!onEdit && !running && status === "done" && !!text;
2259
+ const reply = onReply && status === "done" && !editing ? () => onReply(message) : void 0;
2260
+ const save = () => {
2261
+ const t = draft.trim();
2262
+ setEditing(false);
2263
+ if (t && t !== text) onEdit?.(message, t);
2264
+ };
2265
+ return /* @__PURE__ */ jsxs(
2266
+ Animated.View,
2267
+ {
2268
+ role: "group",
2269
+ accessibilityLabel: labels.saidBy(user?.name ?? labels.you),
2270
+ accessibilityActions: reply ? [{ name: "reply", label: labels.reply }] : void 0,
2271
+ onAccessibilityAction: reply ? (e) => e.nativeEvent.actionName === "reply" && reply() : void 0,
2272
+ style: [styles.userRow, arrival],
2273
+ children: [
2274
+ message.attachments?.length ? /* @__PURE__ */ jsx(View, { style: styles.userAttachments, children: message.attachments.map((a) => /* @__PURE__ */ jsx(AttachmentChip, { attachment: a, labels }, a.id)) }) : null,
2275
+ editing ? /* @__PURE__ */ jsxs(View, { style: styles.edit, children: [
2276
+ /* @__PURE__ */ jsx(
2277
+ Textarea,
2278
+ {
2279
+ accessibilityLabel: labels.editMessage,
2280
+ value: draft,
2281
+ onChangeText: setDraft,
2282
+ autoFocus: true,
2283
+ autoGrow: true,
2284
+ minRows: 2,
2285
+ maxRows: 10
2286
+ }
2287
+ ),
2288
+ /* @__PURE__ */ jsx(Text, { style: styles.meta, children: labels.editNote }),
2289
+ /* @__PURE__ */ jsxs(View, { style: styles.editActions, children: [
2290
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onPress: () => setEditing(false), children: labels.cancel }),
2291
+ /* @__PURE__ */ jsx(Button, { size: "sm", onPress: save, disabled: !draft.trim(), children: labels.send })
2292
+ ] })
2293
+ ] }) : text ? /* @__PURE__ */ jsx(SwipeReply, { onReply: reply, animate, style: styles.userSwipe, children: /* @__PURE__ */ jsx(
2294
+ Pressable,
2295
+ {
2296
+ accessibilityHint: canEdit ? labels.editHint : void 0,
2297
+ accessibilityActions: canEdit ? [{ name: "edit", label: labels.editMessage }] : void 0,
2298
+ onAccessibilityAction: canEdit ? (e) => {
2299
+ if (e.nativeEvent.actionName !== "edit") return;
2300
+ setDraft(text);
2301
+ setEditing(true);
2302
+ } : void 0,
2303
+ onLongPress: canEdit ? () => {
2304
+ setDraft(text);
2305
+ setEditing(true);
2306
+ } : void 0,
2307
+ style: [
2308
+ styles.bubble,
2309
+ styles.bubbleFill,
2310
+ (failed || status === "sending") && styles.faded
2311
+ ],
2312
+ children: /* @__PURE__ */ jsx(Text, { style: styles.bubbleText, selectable: true, children: text })
2313
+ }
2314
+ ) }) : null,
2315
+ failed ? /* @__PURE__ */ jsxs(View, { style: styles.failed, accessibilityRole: "alert", children: [
2316
+ /* @__PURE__ */ jsx(Icon, { name: "alert-circle", size: theme.icon.xs, color: theme.color.dangerOnSoft }),
2317
+ /* @__PURE__ */ jsx(Text, { style: [styles.meta, { color: theme.color.dangerOnSoft }], children: labels.notSent }),
2318
+ onRetry ? /* @__PURE__ */ jsx(
2319
+ Pressable,
2320
+ {
2321
+ accessibilityRole: "button",
2322
+ onPress: () => onRetry(message),
2323
+ hitSlop: theme.space[12],
2324
+ children: /* @__PURE__ */ jsx(Text, { style: styles.retry, children: labels.retry })
2325
+ }
2326
+ ) : null
2327
+ ] }) : !editing ? /* @__PURE__ */ jsxs(View, { style: styles.actions, children: [
2328
+ message.time ? /* @__PURE__ */ jsx(Text, { style: [styles.meta, styles.time], children: message.time }) : null,
2329
+ text && onCopy ? /* @__PURE__ */ jsx(
2330
+ CopyButton,
2331
+ {
2332
+ value: text,
2333
+ size: "sm",
2334
+ accessibilityLabel: labels.copyMessage,
2335
+ onCopy: () => onCopy(message, text)
2336
+ }
2337
+ ) : null,
2338
+ canEdit ? /* @__PURE__ */ jsx(
2339
+ Action,
2340
+ {
2341
+ label: labels.editMessage,
2342
+ icon: "edit",
2343
+ onPress: () => {
2344
+ setDraft(text);
2345
+ setEditing(true);
2346
+ }
2347
+ }
2348
+ ) : null,
2349
+ reply ? /* @__PURE__ */ jsx(Action, { label: labels.reply, icon: "reply", onPress: reply }) : null
2350
+ ] }) : null
2351
+ ]
2352
+ }
2353
+ );
2354
+ }
2355
+ function FeedbackPanel({
2356
+ reasons,
2357
+ animate,
2358
+ onSubmit,
2359
+ onCancel,
2360
+ labels
2361
+ }) {
2362
+ const { styles } = useStyles(sheet7);
2363
+ const arrival = useArrival(animate, "card");
2364
+ const [reason, setReason] = React10.useState();
2365
+ const [note, setNote] = React10.useState("");
2366
+ return /* @__PURE__ */ jsxs(
2367
+ Animated.View,
2368
+ {
2369
+ style: [styles.feedback, arrival],
2370
+ role: "group",
2371
+ accessibilityLabel: labels.feedbackTitle,
2372
+ children: [
2373
+ /* @__PURE__ */ jsx(Text, { style: styles.feedbackTitle, children: labels.feedbackTitle }),
2374
+ /* @__PURE__ */ jsx(View, { style: styles.chips, children: reasons.map((r) => /* @__PURE__ */ jsx(
2375
+ Chip,
2376
+ {
2377
+ variant: "filter",
2378
+ size: "sm",
2379
+ selected: reason === r,
2380
+ onSelectedChange: (on) => setReason(on ? r : void 0),
2381
+ children: r
2382
+ },
2383
+ r
2384
+ )) }),
2385
+ /* @__PURE__ */ jsx(
2386
+ Textarea,
2387
+ {
2388
+ accessibilityLabel: labels.feedbackNote,
2389
+ placeholder: labels.feedbackNote,
2390
+ value: note,
2391
+ onChangeText: setNote,
2392
+ autoGrow: true,
2393
+ minRows: 2,
2394
+ maxRows: 6
2395
+ }
2396
+ ),
2397
+ /* @__PURE__ */ jsxs(View, { style: styles.editActions, children: [
2398
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onPress: onCancel, children: labels.cancel }),
2399
+ /* @__PURE__ */ jsx(
2400
+ Button,
2401
+ {
2402
+ size: "sm",
2403
+ disabled: !reason && !note.trim(),
2404
+ onPress: () => onSubmit(reason, note.trim()),
2405
+ children: labels.sendFeedback
2406
+ }
2407
+ )
2408
+ ] })
2409
+ ]
2410
+ }
2411
+ );
2412
+ }
2413
+ function AssistantRow({
2414
+ message,
2415
+ latest,
2416
+ appearing,
2417
+ animate,
2418
+ assistant,
2419
+ feedbackReasons,
2420
+ running,
2421
+ onRegenerate,
2422
+ onFeedback,
2423
+ onCopy,
2424
+ onReply,
2425
+ onLinkPress,
2426
+ onApproval,
2427
+ onOpenSource,
2428
+ onVersionChange,
2429
+ onContinue,
2430
+ onArtifactVersionChange,
2431
+ onShareArtifact,
2432
+ onExpandTable,
2433
+ labels: labelsProp
2434
+ }) {
2435
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
2436
+ const { styles } = useStyles(sheet7);
2437
+ const theme = useLoamTheme("chat");
2438
+ const arrival = useArrival(appearing && animate, "in");
2439
+ const sources = message.sources;
2440
+ const [sourcesOpen, setSourcesOpen] = React10.useState(null);
2441
+ const [artifactOpen, setArtifactOpen] = React10.useState(null);
2442
+ const openSource = (source) => {
2443
+ setSourcesOpen({ active: source.id });
2444
+ onOpenSource?.(message, source);
2445
+ };
2446
+ const renderCitation = sources?.length ? (ref) => {
2447
+ const idx = /^\d+$/.test(ref) ? Number(ref) - 1 : sources.findIndex((x) => x.id === ref);
2448
+ const source = sources[idx];
2449
+ return /* @__PURE__ */ jsx(
2450
+ CitationMark,
2451
+ {
2452
+ n: idx + 1 || Number(ref) || 0,
2453
+ source,
2454
+ active: !!source && sourcesOpen?.active === source.id,
2455
+ onOpen: openSource,
2456
+ labels
2457
+ }
2458
+ );
2459
+ } : void 0;
2460
+ const status = message.status ?? "done";
2461
+ const streaming = status === "streaming";
2462
+ const text = chatMessageText(message);
2463
+ const reply = onReply && !streaming && text ? () => onReply(message) : void 0;
2464
+ const [feedback, setFeedback] = React10.useState(message.feedback);
2465
+ const [asking, setAsking] = React10.useState(false);
2466
+ const [thanked, setThanked] = React10.useState(false);
2467
+ React10.useEffect(() => setFeedback(message.feedback), [message.feedback]);
2468
+ const lastPart = message.parts[message.parts.length - 1];
2469
+ const hasVisible = message.parts.some((p) => p.kind !== "text" || p.text.trim() !== "");
2470
+ const showWorking = streaming && (!hasVisible || lastPart?.kind === "tool" && lastPart.status !== "running");
2471
+ const rate = (value) => {
2472
+ if (feedback === value) return;
2473
+ setFeedback(value);
2474
+ if (value === "up") {
2475
+ setAsking(false);
2476
+ setThanked(true);
2477
+ onFeedback?.(message, { value });
2478
+ } else {
2479
+ setThanked(false);
2480
+ setAsking(true);
2481
+ }
2482
+ };
2483
+ return /* @__PURE__ */ jsxs(
2484
+ Animated.View,
2485
+ {
2486
+ role: "group",
2487
+ accessibilityLabel: labels.saidBy(assistant.name),
2488
+ "aria-busy": streaming || void 0,
2489
+ accessibilityActions: reply ? [{ name: "reply", label: labels.reply }] : void 0,
2490
+ onAccessibilityAction: reply ? (e) => e.nativeEvent.actionName === "reply" && reply() : void 0,
2491
+ style: [styles.assistantRow, arrival],
2492
+ children: [
2493
+ /* @__PURE__ */ jsx(View, { importantForAccessibility: "no-hide-descendants", accessibilityElementsHidden: true, children: assistant.avatar ?? /* @__PURE__ */ jsx(AssistantMark, {}) }),
2494
+ /* @__PURE__ */ jsxs(View, { style: styles.assistantBody, children: [
2495
+ /* @__PURE__ */ jsx(SwipeReply, { onReply: reply, animate, children: /* @__PURE__ */ jsxs(View, { style: styles.assistantParts, children: [
2496
+ segment(message.parts).map((seg) => {
2497
+ if (seg.kind === "tools")
2498
+ return /* @__PURE__ */ jsx(ToolGroupView, { tools: seg.tools, animate, labels }, seg.id);
2499
+ const part = seg.part;
2500
+ switch (part.kind) {
2501
+ case "text":
2502
+ return /* @__PURE__ */ jsx(
2503
+ Markdown,
2504
+ {
2505
+ content: part.text,
2506
+ streaming: streaming && part === lastPart,
2507
+ motion: animate ? "full" : "none",
2508
+ onLinkPress,
2509
+ renderCitation
2510
+ },
2511
+ part.id
2512
+ );
2513
+ case "approval":
2514
+ return /* @__PURE__ */ jsx(
2515
+ ApprovalView,
2516
+ {
2517
+ part,
2518
+ animate,
2519
+ onAnswer: onApproval ? (d) => onApproval(message, part, d) : void 0,
2520
+ labels
2521
+ },
2522
+ part.id
2523
+ );
2524
+ case "table":
2525
+ return /* @__PURE__ */ jsx(
2526
+ ChatInlineTable,
2527
+ {
2528
+ part,
2529
+ onExpand: onExpandTable ? (p) => onExpandTable(message, p) : void 0,
2530
+ labels
2531
+ },
2532
+ part.id
2533
+ );
2534
+ case "artifact":
2535
+ return /* @__PURE__ */ jsxs(React10.Fragment, { children: [
2536
+ /* @__PURE__ */ jsx(
2537
+ ChatArtifactCard,
2538
+ {
2539
+ artifact: part.artifact,
2540
+ open: artifactOpen === part.id,
2541
+ onOpen: () => setArtifactOpen(part.id),
2542
+ labels
2543
+ }
2544
+ ),
2545
+ /* @__PURE__ */ jsx(
2546
+ ChatArtifactSheet,
2547
+ {
2548
+ artifact: part.artifact,
2549
+ open: artifactOpen === part.id,
2550
+ onClose: () => setArtifactOpen(null),
2551
+ onVersionChange: onArtifactVersionChange ? (a, v) => onArtifactVersionChange(message, a, v) : void 0,
2552
+ onShare: onShareArtifact ? (a) => onShareArtifact(message, a) : void 0,
2553
+ labels
2554
+ }
2555
+ )
2556
+ ] }, part.id);
2557
+ case "reasoning":
2558
+ return /* @__PURE__ */ jsx(
2559
+ ReasoningView,
2560
+ {
2561
+ part,
2562
+ live: streaming && part === lastPart,
2563
+ animate,
2564
+ labels
2565
+ },
2566
+ part.id
2567
+ );
2568
+ case "error":
2569
+ return /* @__PURE__ */ jsx(Alert, { tone: "danger", size: "compact", title: part.message }, part.id);
2570
+ case "custom":
2571
+ return /* @__PURE__ */ jsx(CustomPart, { animate, children: part.content }, part.id);
2572
+ default:
2573
+ return null;
2574
+ }
2575
+ }),
2576
+ showWorking ? /* @__PURE__ */ jsx(
2577
+ WorkingIndicator,
2578
+ {
2579
+ phase: message.phase,
2580
+ startedAt: message.startedAt,
2581
+ animate,
2582
+ labels
2583
+ }
2584
+ ) : null
2585
+ ] }) }),
2586
+ !streaming && sources?.length ? /* @__PURE__ */ jsxs(Fragment, { children: [
2587
+ /* @__PURE__ */ jsx(
2588
+ SourcesRow,
2589
+ {
2590
+ sources,
2591
+ onOpen: openSource,
2592
+ onOpenAll: () => setSourcesOpen({}),
2593
+ labels
2594
+ }
2595
+ ),
2596
+ /* @__PURE__ */ jsx(
2597
+ SourcesSheet,
2598
+ {
2599
+ open: !!sourcesOpen,
2600
+ sources,
2601
+ active: sourcesOpen?.active,
2602
+ onClose: () => setSourcesOpen(null),
2603
+ onOpenSource: (source) => onOpenSource?.(message, source),
2604
+ labels
2605
+ }
2606
+ )
2607
+ ] }) : null,
2608
+ !streaming ? /* @__PURE__ */ jsxs(View, { style: styles.actions, children: [
2609
+ message.version && message.version.count > 1 ? /* @__PURE__ */ jsx(
2610
+ VersionSwitcher,
2611
+ {
2612
+ index: message.version.index,
2613
+ count: message.version.count,
2614
+ streaming: message.version.streaming,
2615
+ onChange: onVersionChange ? (i) => onVersionChange(message, i) : void 0,
2616
+ rule: true,
2617
+ labels
2618
+ }
2619
+ ) : null,
2620
+ status === "stopped" ? /* @__PURE__ */ jsxs(View, { style: styles.stopped, children: [
2621
+ /* @__PURE__ */ jsx(Icon, { name: "stop", size: theme.icon.xs, color: theme.color.text2 }),
2622
+ /* @__PURE__ */ jsx(Text, { style: styles.meta, children: labels.stopped })
2623
+ ] }) : null,
2624
+ status === "stopped" && latest && onContinue && !running ? /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", leadingIcon: "play", onPress: () => onContinue(message), children: labels.continue }) : null,
2625
+ text && onCopy ? /* @__PURE__ */ jsx(
2626
+ CopyButton,
2627
+ {
2628
+ value: text,
2629
+ size: "sm",
2630
+ accessibilityLabel: labels.copyResponse,
2631
+ onCopy: () => onCopy(message, text)
2632
+ }
2633
+ ) : null,
2634
+ onFeedback && text ? /* @__PURE__ */ jsxs(Fragment, { children: [
2635
+ /* @__PURE__ */ jsx(
2636
+ Action,
2637
+ {
2638
+ label: labels.goodResponse,
2639
+ icon: "thumbs-up",
2640
+ pressed: feedback === "up",
2641
+ onPress: () => rate("up")
2642
+ }
2643
+ ),
2644
+ /* @__PURE__ */ jsx(
2645
+ Action,
2646
+ {
2647
+ label: labels.badResponse,
2648
+ icon: "thumbs-down",
2649
+ pressed: feedback === "down",
2650
+ onPress: () => rate("down")
2651
+ }
2652
+ )
2653
+ ] }) : null,
2654
+ latest && onRegenerate && !running ? /* @__PURE__ */ jsx(Action, { label: labels.regenerate, icon: "refresh", onPress: () => onRegenerate(message) }) : null,
2655
+ reply ? /* @__PURE__ */ jsx(Action, { label: labels.reply, icon: "reply", onPress: reply }) : null,
2656
+ message.meta || message.time ? /* @__PURE__ */ jsxs(Text, { style: styles.meta, children: [
2657
+ message.meta,
2658
+ message.meta && message.time ? " \xB7 " : null,
2659
+ message.time ? /* @__PURE__ */ jsx(Text, { style: styles.time, children: message.time }) : null
2660
+ ] }) : null,
2661
+ thanked ? /* @__PURE__ */ jsx(Text, { style: styles.meta, accessibilityLiveRegion: "polite", role: "status", children: labels.thanks }) : null
2662
+ ] }) : null,
2663
+ asking ? /* @__PURE__ */ jsx(
2664
+ FeedbackPanel,
2665
+ {
2666
+ reasons: feedbackReasons,
2667
+ animate,
2668
+ labels,
2669
+ onCancel: () => {
2670
+ setAsking(false);
2671
+ setFeedback(message.feedback);
2672
+ },
2673
+ onSubmit: (reason, note) => {
2674
+ setAsking(false);
2675
+ setThanked(true);
2676
+ onFeedback?.(message, { value: "down", reason, note: note || void 0 });
2677
+ }
2678
+ }
2679
+ ) : null
2680
+ ] })
2681
+ ]
2682
+ }
2683
+ );
2684
+ }
2685
+ function CustomPart({ animate, children }) {
2686
+ const arrival = useArrival(animate, "card");
2687
+ return /* @__PURE__ */ jsx(Animated.View, { style: arrival, children });
2688
+ }
2689
+ var sheet7 = createStyleSheet((theme) => ({
2690
+ mark: {
2691
+ width: theme.ctl.sm,
2692
+ height: theme.ctl.sm,
2693
+ borderRadius: theme.radius.sm,
2694
+ backgroundColor: theme.color.accentSoft,
2695
+ borderWidth: theme.borderWidth.base,
2696
+ borderColor: theme.edge.accent,
2697
+ alignItems: "center",
2698
+ justifyContent: "center"
2699
+ },
2700
+ userRow: { alignItems: "flex-end", gap: theme.space[6] },
2701
+ userAttachments: {
2702
+ flexDirection: "row",
2703
+ flexWrap: "wrap",
2704
+ justifyContent: "flex-end",
2705
+ gap: theme.space.s2
2706
+ },
2707
+ bubble: {
2708
+ maxWidth: "85%",
2709
+ // Final 12 state "Bubble (user)": surface-2 (the written entry, latest over Ref 24's "fill unchanged").
2710
+ backgroundColor: theme.color.surface2,
2711
+ borderRadius: theme.radius.lg,
2712
+ borderBottomEndRadius: theme.radius.xs,
2713
+ paddingHorizontal: theme.space.s4,
2714
+ paddingVertical: theme.space[10]
2715
+ },
2716
+ // Sending / failed: a hint of "not yet delivered", never `disabledOpacity`
2717
+ // — at 0.38 the message itself fell to ~2:1 and could not be read back.
2718
+ // Same 0.72 as the web bubble.
2719
+ faded: { opacity: theme.opacity[72] },
2720
+ bubbleText: {
2721
+ fontFamily: theme.font.sans,
2722
+ fontSize: theme.type.body.fontSize,
2723
+ lineHeight: theme.type.body.lineHeight,
2724
+ color: theme.color.text
2725
+ },
2726
+ failed: { flexDirection: "row", alignItems: "center", gap: theme.space.s2 },
2727
+ retry: {
2728
+ fontFamily: theme.font.sans,
2729
+ fontSize: theme.type.caption1.fontSize,
2730
+ fontWeight: theme.fontWeight.semibold,
2731
+ color: theme.color.dangerOnSoft
2732
+ },
2733
+ edit: { alignSelf: "stretch", gap: theme.space.s2 },
2734
+ editActions: { flexDirection: "row", justifyContent: "flex-end", gap: theme.space.s2 },
2735
+ actions: { flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: theme.space.s1 },
2736
+ action: {
2737
+ width: theme.ctl.sm,
2738
+ height: theme.ctl.sm,
2739
+ borderRadius: theme.ctl.r.sm,
2740
+ alignItems: "center",
2741
+ justifyContent: "center"
2742
+ },
2743
+ actionSelected: { backgroundColor: theme.state.selected },
2744
+ actionDown: { backgroundColor: theme.state.pressed },
2745
+ meta: {
2746
+ fontFamily: theme.font.sans,
2747
+ fontSize: theme.type.caption1.fontSize,
2748
+ lineHeight: theme.type.caption1.lineHeight,
2749
+ color: theme.color.text2
2750
+ },
2751
+ // A clock time takes the count style.
2752
+ time: {
2753
+ fontFamily: theme.font.mono,
2754
+ fontWeight: theme.fontWeight.medium,
2755
+ fontVariant: ["tabular-nums"]
2756
+ },
2757
+ stopped: {
2758
+ flexDirection: "row",
2759
+ alignItems: "center",
2760
+ gap: theme.space[6],
2761
+ marginEnd: theme.space.s2
2762
+ },
2763
+ assistantRow: { flexDirection: "row", gap: theme.space.s3 },
2764
+ assistantBody: { flex: 1, minWidth: 0, gap: theme.space.s2 },
2765
+ assistantParts: { gap: theme.space.s2 },
2766
+ userSwipe: { maxWidth: "85%" },
2767
+ bubbleFill: { maxWidth: "100%" },
2768
+ replyCue: {
2769
+ position: "absolute",
2770
+ start: -theme.ctl.sm,
2771
+ top: "50%",
2772
+ marginTop: -theme.icon.sm,
2773
+ width: theme.icon.sm * 2,
2774
+ height: theme.icon.sm * 2,
2775
+ borderRadius: theme.radius.full,
2776
+ backgroundColor: theme.color.surface3,
2777
+ alignItems: "center",
2778
+ justifyContent: "center"
2779
+ },
2780
+ feedback: {
2781
+ gap: theme.space.s3,
2782
+ padding: theme.space.s3,
2783
+ borderRadius: theme.radius.lg,
2784
+ borderWidth: theme.borderWidth.base,
2785
+ borderColor: theme.color.border,
2786
+ backgroundColor: theme.color.surface
2787
+ },
2788
+ feedbackTitle: {
2789
+ fontFamily: theme.font.sans,
2790
+ fontSize: theme.type.footnote.fontSize,
2791
+ fontWeight: theme.fontWeight.semibold,
2792
+ color: theme.color.text
2793
+ },
2794
+ chips: { flexDirection: "row", flexWrap: "wrap", gap: theme.space.s2 }
2795
+ }));
2796
+ var keyOf = (s) => s.id ?? s.label;
2797
+ function paginate(list, perPage) {
2798
+ if (list.some((s) => s.page !== void 0)) {
2799
+ const by = /* @__PURE__ */ new Map();
2800
+ for (const s of list) {
2801
+ const p = s.page ?? 0;
2802
+ by.set(p, [...by.get(p) ?? [], s]);
2803
+ }
2804
+ return [...by.keys()].sort((a, b) => a - b).map((p) => by.get(p));
2805
+ }
2806
+ const size = Math.max(1, perPage);
2807
+ const out = [];
2808
+ for (let i = 0; i < list.length; i += size) out.push(list.slice(i, i + size));
2809
+ return out;
2810
+ }
2811
+ function sectionsOf(page) {
2812
+ const out = [];
2813
+ for (const s of page) {
2814
+ const hit = out.find((g) => g.title === s.group);
2815
+ if (hit) hit.items.push(s);
2816
+ else out.push({ title: s.group, items: [s] });
2817
+ }
2818
+ return out;
2819
+ }
2820
+ function ChatSuggestions({
2821
+ suggestions,
2822
+ perPage,
2823
+ onPick,
2824
+ onDismiss,
2825
+ loading = false,
2826
+ animate,
2827
+ labels: labelsProp
2828
+ }) {
2829
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
2830
+ const { styles } = useStyles(sheet8);
2831
+ const theme = useLoamTheme("chat");
2832
+ const [hidden, setHidden] = React10.useState(() => /* @__PURE__ */ new Set());
2833
+ const pages = React10.useMemo(
2834
+ () => paginate(suggestions.filter((s) => !hidden.has(keyOf(s))), perPage),
2835
+ [suggestions, hidden, perPage]
2836
+ );
2837
+ const [index, setIndex] = React10.useState(0);
2838
+ const [visit, setVisit] = React10.useState(0);
2839
+ const current = Math.min(index, Math.max(0, pages.length - 1));
2840
+ const [width, setWidth] = React10.useState(0);
2841
+ const scroller = React10.useRef(null);
2842
+ const settle = (next) => {
2843
+ if (next === current) return;
2844
+ setIndex(next);
2845
+ setVisit((v) => v + 1);
2846
+ };
2847
+ const goTo = (next) => {
2848
+ const clamped = Math.max(0, Math.min(pages.length - 1, next));
2849
+ scroller.current?.scrollTo({ x: clamped * width, animated: animate });
2850
+ settle(clamped);
2851
+ };
2852
+ const onScrollEnd = (e) => {
2853
+ if (width > 0) settle(Math.round(e.nativeEvent.contentOffset.x / width));
2854
+ };
2855
+ const dismiss = (s) => {
2856
+ if (animate) {
2857
+ LayoutAnimation.configureNext(
2858
+ LayoutAnimation.create(theme.motion.collapse.duration, LayoutAnimation.Types.easeInEaseOut, LayoutAnimation.Properties.opacity)
2859
+ );
2860
+ }
2861
+ setHidden((prev) => new Set(prev).add(keyOf(s)));
2862
+ onDismiss?.(s);
2863
+ };
2864
+ if (loading) {
2865
+ return (
2866
+ // One "Loading" for the whole card (the SkeletonText pattern); the bones
2867
+ // are decorative, or a screen reader says "Loading" a dozen times.
2868
+ /* @__PURE__ */ jsx(
2869
+ View,
2870
+ {
2871
+ style: styles.card,
2872
+ accessible: true,
2873
+ accessibilityRole: "image",
2874
+ accessibilityLabel: labels.loadingSuggestions,
2875
+ accessibilityState: { busy: true },
2876
+ children: Array.from({ length: Math.min(perPage, 4) }, (_, i) => /* @__PURE__ */ jsxs(View, { style: styles.skeletonRow, children: [
2877
+ /* @__PURE__ */ jsx(
2878
+ Skeleton,
2879
+ {
2880
+ variant: "rect",
2881
+ width: theme.icon.sm,
2882
+ height: theme.icon.sm,
2883
+ radius: "sm",
2884
+ decorative: true
2885
+ }
2886
+ ),
2887
+ /* @__PURE__ */ jsxs(View, { style: styles.rowText, children: [
2888
+ /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: theme.ctl.md * 4, decorative: true }),
2889
+ /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: theme.ctl.md * 2.5, decorative: true })
2890
+ ] })
2891
+ ] }, i))
2892
+ }
2893
+ )
2894
+ );
2895
+ }
2896
+ if (pages.length === 0) return null;
2897
+ return /* @__PURE__ */ jsxs(View, { style: styles.card, onLayout: (e) => setWidth(e.nativeEvent.layout.width - theme.space.s2 * 2), children: [
2898
+ /* @__PURE__ */ jsx(
2899
+ ScrollView,
2900
+ {
2901
+ ref: scroller,
2902
+ horizontal: true,
2903
+ pagingEnabled: true,
2904
+ scrollEnabled: pages.length > 1,
2905
+ showsHorizontalScrollIndicator: false,
2906
+ onMomentumScrollEnd: onScrollEnd,
2907
+ children: pages.map((page, p) => /* @__PURE__ */ jsx(
2908
+ View,
2909
+ {
2910
+ style: width ? { width } : styles.fill,
2911
+ accessibilityElementsHidden: p !== current,
2912
+ importantForAccessibility: p === current ? "auto" : "no-hide-descendants",
2913
+ children: /* @__PURE__ */ jsx(
2914
+ Page,
2915
+ {
2916
+ page,
2917
+ animate: animate && p === current,
2918
+ onPick,
2919
+ onDismiss: onDismiss ? dismiss : void 0,
2920
+ labels
2921
+ }
2922
+ )
2923
+ },
2924
+ p === current ? `on-${visit}` : `off-${p}`
2925
+ ))
2926
+ }
2927
+ ),
2928
+ pages.length > 1 ? /* @__PURE__ */ jsxs(View, { style: styles.pager, role: "group", accessibilityLabel: labels.moreSuggestions, children: [
2929
+ /* @__PURE__ */ jsx(PagerButton, { icon: "chevron-left", label: labels.previousSuggestions, disabled: current === 0, onPress: () => goTo(current - 1) }),
2930
+ /* @__PURE__ */ jsx(View, { style: styles.dots, children: pages.map((_, p) => /* @__PURE__ */ jsx(
2931
+ Dot,
2932
+ {
2933
+ index: p,
2934
+ count: pages.length,
2935
+ active: p === current,
2936
+ animate,
2937
+ onPress: () => goTo(p),
2938
+ labels
2939
+ },
2940
+ p
2941
+ )) }),
2942
+ /* @__PURE__ */ jsx(
2943
+ PagerButton,
2944
+ {
2945
+ icon: "chevron-right",
2946
+ label: labels.moreSuggestions,
2947
+ disabled: current === pages.length - 1,
2948
+ onPress: () => goTo(current + 1)
2949
+ }
2950
+ )
2951
+ ] }) : null
2952
+ ] });
2953
+ }
2954
+ function Page({
2955
+ page,
2956
+ animate,
2957
+ onPick,
2958
+ onDismiss,
2959
+ labels
2960
+ }) {
2961
+ const { styles } = useStyles(sheet8);
2962
+ let n = 0;
2963
+ return /* @__PURE__ */ jsx(View, { children: sectionsOf(page).map((section, si) => /* @__PURE__ */ jsxs(View, { style: si > 0 ? styles.sectionRule : void 0, children: [
2964
+ section.title ? /* @__PURE__ */ jsx(Rise, { i: n, animate, children: /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: styles.sectionTitle, children: section.title }) }) : null,
2965
+ section.items.map((s) => /* @__PURE__ */ jsx(Rise, { i: ++n, animate, children: /* @__PURE__ */ jsx(Row, { suggestion: s, onPick, onDismiss, labels }) }, keyOf(s)))
2966
+ ] }, section.title ?? `untitled-${si}`)) });
2967
+ }
2968
+ function Rise({ i, animate, children }) {
2969
+ const theme = useLoamTheme("chat");
2970
+ const style = useArrival(animate, "in", i * theme.duration.fast * 0.27);
2971
+ return /* @__PURE__ */ jsx(Animated.View, { style, children });
2972
+ }
2973
+ function Row({
2974
+ suggestion: s,
2975
+ onPick,
2976
+ onDismiss,
2977
+ labels
2978
+ }) {
2979
+ const { styles } = useStyles(sheet8);
2980
+ const theme = useLoamTheme("chat");
2981
+ const tone = {
2982
+ neutral: theme.color.text3,
2983
+ accent: theme.color.accent,
2984
+ good: theme.color.good,
2985
+ warn: theme.color.warn,
2986
+ danger: theme.color.danger
2987
+ };
2988
+ const swap = React10.useRef(new Animated.Value(0)).current;
2989
+ const fade = React10.useRef(new Animated.Value(1)).current;
2990
+ const to = (v) => Animated.timing(swap, {
2991
+ toValue: v,
2992
+ duration: theme.motion.swap.duration,
2993
+ easing: Easing.bezier(...theme.motion.swap.easing),
2994
+ useNativeDriver: true
2995
+ }).start();
2996
+ const lift = theme.space[3];
2997
+ const leave = () => {
2998
+ Animated.timing(fade, {
2999
+ toValue: 0,
3000
+ duration: theme.motion.exit.duration,
3001
+ easing: Easing.bezier(...theme.motion.exit.easing),
3002
+ useNativeDriver: true
3003
+ }).start(() => onDismiss?.(s));
3004
+ };
3005
+ return /* @__PURE__ */ jsxs(Animated.View, { style: [styles.row, { opacity: fade }], children: [
3006
+ /* @__PURE__ */ jsxs(
3007
+ Pressable,
3008
+ {
3009
+ accessibilityRole: "button",
3010
+ accessibilityLabel: s.label,
3011
+ accessibilityHint: [s.description, s.reason && labels.why(s.reason)].filter(Boolean).join(". ") || void 0,
3012
+ onPress: () => onPick(s),
3013
+ onPressIn: s.reason ? () => to(1) : void 0,
3014
+ onPressOut: s.reason ? () => to(0) : void 0,
3015
+ style: ({ pressed }) => [styles.rowPress, pressed && styles.rowPressed],
3016
+ children: [
3017
+ /* @__PURE__ */ jsx(Icon, { name: s.icon ?? "sparkle", size: theme.icon.xs, color: tone[s.tone ?? "neutral"] }),
3018
+ /* @__PURE__ */ jsxs(View, { style: styles.rowText, children: [
3019
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: styles.label, children: s.label }),
3020
+ s.description || s.reason ? /* @__PURE__ */ jsxs(View, { children: [
3021
+ /* @__PURE__ */ jsx(
3022
+ Animated.Text,
3023
+ {
3024
+ numberOfLines: 1,
3025
+ style: [
3026
+ styles.meta,
3027
+ s.reason && {
3028
+ opacity: swap.interpolate({ inputRange: [0, 1], outputRange: [1, 0] }),
3029
+ transform: [{ translateY: swap.interpolate({ inputRange: [0, 1], outputRange: [0, -lift] }) }]
3030
+ }
3031
+ ],
3032
+ children: s.description ?? " "
3033
+ }
3034
+ ),
3035
+ s.reason ? /* @__PURE__ */ jsx(
3036
+ Animated.Text,
3037
+ {
3038
+ numberOfLines: 1,
3039
+ importantForAccessibility: "no",
3040
+ accessibilityElementsHidden: true,
3041
+ style: [
3042
+ styles.meta,
3043
+ styles.reason,
3044
+ {
3045
+ opacity: swap,
3046
+ transform: [{ translateY: swap.interpolate({ inputRange: [0, 1], outputRange: [lift, 0] }) }]
3047
+ }
3048
+ ],
3049
+ children: s.reason
3050
+ }
3051
+ ) : null
3052
+ ] }) : null
3053
+ ] })
3054
+ ]
3055
+ }
3056
+ ),
3057
+ onDismiss ? /* @__PURE__ */ jsx(
3058
+ Pressable,
3059
+ {
3060
+ accessibilityRole: "button",
3061
+ accessibilityLabel: labels.notUsefulFor(s.label),
3062
+ onPress: leave,
3063
+ hitSlop: theme.space[8],
3064
+ style: ({ pressed }) => [styles.dismiss, pressed && styles.rowPressed],
3065
+ children: /* @__PURE__ */ jsx(Icon, { name: "x", size: theme.icon.xs, color: theme.color.text3 })
3066
+ }
3067
+ ) : null
3068
+ ] });
3069
+ }
3070
+ function Dot({
3071
+ index,
3072
+ count,
3073
+ active,
3074
+ animate,
3075
+ onPress,
3076
+ labels
3077
+ }) {
3078
+ const { styles } = useStyles(sheet8);
3079
+ const theme = useLoamTheme("chat");
3080
+ const p = React10.useRef(new Animated.Value(active ? 1 : 0)).current;
3081
+ React10.useEffect(() => {
3082
+ Animated.timing(p, {
3083
+ toValue: active ? 1 : 0,
3084
+ duration: animate ? theme.motion.indicator.duration : 0,
3085
+ easing: Easing.bezier(...theme.motion.indicator.easing),
3086
+ useNativeDriver: false
3087
+ }).start();
3088
+ }, [active, animate, p, theme.motion.indicator]);
3089
+ const dot = theme.space[6];
3090
+ return /* @__PURE__ */ jsx(
3091
+ Pressable,
3092
+ {
3093
+ accessibilityRole: "button",
3094
+ accessibilityLabel: labels.suggestionsPage(index + 1, count),
3095
+ accessibilityState: { selected: active },
3096
+ onPress,
3097
+ hitSlop: theme.space[8],
3098
+ children: /* @__PURE__ */ jsx(
3099
+ Animated.View,
3100
+ {
3101
+ style: [
3102
+ styles.dot,
3103
+ {
3104
+ width: p.interpolate({ inputRange: [0, 1], outputRange: [dot, dot * 2.67] }),
3105
+ backgroundColor: p.interpolate({ inputRange: [0, 1], outputRange: [theme.color.borderStrong, theme.color.accent] })
3106
+ }
3107
+ ]
3108
+ }
3109
+ )
3110
+ }
3111
+ );
3112
+ }
3113
+ function PagerButton({
3114
+ icon,
3115
+ label,
3116
+ disabled,
3117
+ onPress
3118
+ }) {
3119
+ const { styles } = useStyles(sheet8);
3120
+ const theme = useLoamTheme("chat");
3121
+ return /* @__PURE__ */ jsx(
3122
+ Pressable,
3123
+ {
3124
+ accessibilityRole: "button",
3125
+ accessibilityLabel: label,
3126
+ accessibilityState: { disabled },
3127
+ disabled,
3128
+ onPress,
3129
+ hitSlop: theme.space[8],
3130
+ style: ({ pressed }) => [styles.pagerButton, pressed && styles.rowPressed, disabled && styles.disabled],
3131
+ children: /* @__PURE__ */ jsx(Icon, { name: icon, size: theme.icon.sm, color: theme.color.text3 })
3132
+ }
3133
+ );
3134
+ }
3135
+ var sheet8 = createStyleSheet((theme) => ({
3136
+ card: {
3137
+ alignSelf: "stretch",
3138
+ padding: theme.space.s2,
3139
+ // Final 12 Suggestions: card r-lg, p 8 (rows r 8, 44 on the lg tier).
3140
+ borderRadius: theme.radius.lg,
3141
+ borderWidth: theme.borderWidth.base,
3142
+ borderColor: theme.color.border,
3143
+ backgroundColor: theme.color.surface,
3144
+ overflow: "hidden"
3145
+ },
3146
+ fill: { flex: 1 },
3147
+ sectionRule: {
3148
+ marginTop: theme.space.s1,
3149
+ paddingTop: theme.space.s1,
3150
+ borderTopWidth: theme.borderWidth.base,
3151
+ borderTopColor: theme.color.border
3152
+ },
3153
+ sectionTitle: {
3154
+ ...theme.type.overline,
3155
+ paddingHorizontal: theme.space.s3,
3156
+ paddingTop: theme.space.s2,
3157
+ paddingBottom: theme.space.s1,
3158
+ fontFamily: theme.font.sans,
3159
+ color: theme.color.text3
3160
+ },
3161
+ row: { flexDirection: "row", alignItems: "center", borderRadius: theme.radius.sm },
3162
+ rowPress: {
3163
+ flex: 1,
3164
+ flexDirection: "row",
3165
+ alignItems: "center",
3166
+ gap: theme.space.s3,
3167
+ minHeight: theme.ctl.lg,
3168
+ paddingHorizontal: theme.space.s3,
3169
+ paddingVertical: theme.space.s2,
3170
+ borderRadius: theme.radius.sm,
3171
+ borderWidth: theme.borderWidth.base,
3172
+ borderColor: "transparent"
3173
+ },
3174
+ // accent-soft never marks pressed or hover: the shared state layer does.
3175
+ rowPressed: { backgroundColor: theme.state.pressed },
3176
+ rowText: { flex: 1, gap: theme.space[2] },
3177
+ label: {
3178
+ fontFamily: theme.font.sans,
3179
+ fontSize: theme.fontSize[14],
3180
+ lineHeight: theme.space[20],
3181
+ fontWeight: theme.fontWeight.medium,
3182
+ color: theme.color.text
3183
+ },
3184
+ meta: {
3185
+ fontFamily: theme.font.sans,
3186
+ fontSize: theme.type.caption1.fontSize,
3187
+ lineHeight: theme.type.caption1.lineHeight,
3188
+ color: theme.color.text2
3189
+ },
3190
+ reason: { position: "absolute", start: 0, end: 0, top: 0, color: theme.color.accentStrong },
3191
+ dismiss: {
3192
+ width: theme.ctl.iconBtnSm,
3193
+ height: theme.ctl.iconBtnSm,
3194
+ borderRadius: theme.ctl.r.xs,
3195
+ alignItems: "center",
3196
+ justifyContent: "center"
3197
+ },
3198
+ skeletonRow: { flexDirection: "row", alignItems: "center", gap: theme.space.s3, padding: theme.space.s3 },
3199
+ pager: {
3200
+ flexDirection: "row",
3201
+ alignItems: "center",
3202
+ justifyContent: "space-between",
3203
+ marginTop: theme.space.s1,
3204
+ paddingTop: theme.space.s1,
3205
+ borderTopWidth: theme.borderWidth.base,
3206
+ borderTopColor: theme.color.border
3207
+ },
3208
+ pagerButton: {
3209
+ width: theme.ctl.iconBtnSm,
3210
+ height: theme.ctl.iconBtnSm,
3211
+ borderRadius: theme.ctl.r.xs,
3212
+ alignItems: "center",
3213
+ justifyContent: "center"
3214
+ },
3215
+ disabled: { opacity: theme.state.disabledOpacity },
3216
+ dots: { flexDirection: "row", alignItems: "center", gap: theme.space.s2 },
3217
+ dot: { height: theme.space[6], borderRadius: theme.radius.full }
3218
+ }));
3219
+ function useChatScroll({ threshold = 32 } = {}) {
3220
+ const ref = React10.useRef(null);
3221
+ const pinnedRef = React10.useRef(true);
3222
+ const [pinned, setPinnedState] = React10.useState(true);
3223
+ const driving = React10.useRef({ drag: false, momentum: false });
3224
+ const setPinned = React10.useCallback((next) => {
3225
+ if (pinnedRef.current === next) return;
3226
+ pinnedRef.current = next;
3227
+ setPinnedState(next);
3228
+ }, []);
3229
+ const scrollToBottom = React10.useCallback(
3230
+ (animated = true) => {
3231
+ setPinned(true);
3232
+ ref.current?.scrollToEnd({ animated });
3233
+ },
3234
+ [setPinned]
3235
+ );
3236
+ const follow = React10.useCallback(() => {
3237
+ if (pinnedRef.current) ref.current?.scrollToEnd({ animated: false });
3238
+ }, []);
3239
+ const scrollProps = React10.useMemo(
3240
+ () => ({
3241
+ ref,
3242
+ scrollEventThrottle: 16,
3243
+ onScroll: (e) => {
3244
+ const { contentOffset, contentSize, layoutMeasurement } = e.nativeEvent;
3245
+ const distance = contentSize.height - contentOffset.y - layoutMeasurement.height;
3246
+ if (distance <= threshold) setPinned(true);
3247
+ else if (driving.current.drag || driving.current.momentum) setPinned(false);
3248
+ },
3249
+ onScrollBeginDrag: () => {
3250
+ driving.current.drag = true;
3251
+ },
3252
+ onScrollEndDrag: () => {
3253
+ driving.current.drag = false;
3254
+ },
3255
+ onMomentumScrollBegin: () => {
3256
+ driving.current.momentum = true;
3257
+ },
3258
+ onMomentumScrollEnd: () => {
3259
+ driving.current.momentum = false;
3260
+ },
3261
+ onContentSizeChange: follow,
3262
+ onLayout: follow
3263
+ }),
3264
+ [follow, setPinned, threshold]
3265
+ );
3266
+ return { pinned, scrollToBottom, scrollProps };
3267
+ }
3268
+ var CHAT_FEEDBACK_REASONS = DEFAULT_CHAT_LABELS.feedbackReasons;
3269
+ function useArrivals(messages) {
3270
+ const seen = React10.useRef(null);
3271
+ const prevLast = React10.useRef(void 0);
3272
+ if (seen.current === null) {
3273
+ seen.current = new Set(messages.map((m) => m.id));
3274
+ prevLast.current = messages[messages.length - 1]?.id;
3275
+ }
3276
+ const boundary = prevLast.current ? messages.findIndex((m) => m.id === prevLast.current) : -1;
3277
+ const arriving = /* @__PURE__ */ new Set();
3278
+ messages.forEach((m, i) => {
3279
+ if (!seen.current.has(m.id) && i > boundary) arriving.add(m.id);
3280
+ });
3281
+ React10.useEffect(() => {
3282
+ for (const m of messages) seen.current.add(m.id);
3283
+ prevLast.current = messages[messages.length - 1]?.id;
3284
+ }, [messages]);
3285
+ return (id) => arriving.has(id);
3286
+ }
3287
+ function Staggered({
3288
+ i,
3289
+ animate,
3290
+ children
3291
+ }) {
3292
+ const theme = useLoamTheme("chat");
3293
+ const style = useArrival(animate, "in", i * theme.duration.fast * 0.27);
3294
+ return /* @__PURE__ */ jsx(Animated.View, { style, children });
3295
+ }
3296
+ function Chat({
3297
+ messages,
3298
+ running = false,
3299
+ onSend,
3300
+ onStop,
3301
+ onRegenerate,
3302
+ onEdit,
3303
+ onRetry,
3304
+ onFeedback,
3305
+ onCopy,
3306
+ onReply,
3307
+ onApproval,
3308
+ onOpenSource,
3309
+ onVersionChange,
3310
+ onContinue,
3311
+ onArtifactVersionChange,
3312
+ onShareArtifact,
3313
+ onExpandTable,
3314
+ feedbackReasons: feedbackReasonsProp,
3315
+ assistant: assistantProp,
3316
+ user,
3317
+ suggestions,
3318
+ suggestionAction = "send",
3319
+ suggestionsPerPage = 4,
3320
+ suggestionsLoading = false,
3321
+ onDismissSuggestion,
3322
+ followUps,
3323
+ emptyTitle: emptyTitleProp,
3324
+ emptyDescription,
3325
+ emptyState,
3326
+ hasOlder = false,
3327
+ loadingOlder = false,
3328
+ onLoadOlder,
3329
+ showJumpToLatest = false,
3330
+ draft: draftProp,
3331
+ onDraftChange,
3332
+ placeholder,
3333
+ attachments,
3334
+ onAttach,
3335
+ accept,
3336
+ onRemoveAttachment,
3337
+ composerToolbar,
3338
+ composerFeatures,
3339
+ disclaimer,
3340
+ disabled,
3341
+ header,
3342
+ onLinkPress,
3343
+ insets,
3344
+ label: labelProp,
3345
+ motion = "full",
3346
+ style,
3347
+ labels: labelsProp
3348
+ }) {
3349
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
3350
+ const assistant = React10.useMemo(
3351
+ () => assistantProp ?? { name: labels.assistant },
3352
+ [assistantProp, labels.assistant]
3353
+ );
3354
+ const feedbackReasons = feedbackReasonsProp ?? labels.feedbackReasons;
3355
+ const emptyTitle = emptyTitleProp ?? labels.emptyTitle;
3356
+ const label = labelProp ?? labels.chat;
3357
+ const { styles } = useStyles(sheet9);
3358
+ const theme = useLoamTheme("chat");
3359
+ const animate = useResolvedMotion(motion, "chat") === "full";
3360
+ const { pinned: scrollPinned, scrollToBottom, scrollProps } = useChatScroll();
3361
+ const pinned = scrollPinned && !showJumpToLatest;
3362
+ const { readingMeasure } = useFormFactor();
3363
+ const column = {
3364
+ width: "100%",
3365
+ maxWidth: readingMeasure + theme.ctl.sm + theme.space.s3 + theme.space.s4 * 2,
3366
+ alignSelf: "center"
3367
+ };
3368
+ const isArriving = useArrivals(messages);
3369
+ const inputRef = React10.useRef(null);
3370
+ const [innerDraft, setInnerDraft] = React10.useState("");
3371
+ const draft = draftProp ?? innerDraft;
3372
+ const setDraft = (next) => {
3373
+ if (draftProp === void 0) setInnerDraft(next);
3374
+ onDraftChange?.(next);
3375
+ };
3376
+ const last = messages[messages.length - 1];
3377
+ const latestAssistantId = [...messages].reverse().find((m) => m.role === "assistant")?.id;
3378
+ const [replyingTo, setReplyingTo] = React10.useState(null);
3379
+ const reply = onReply ? (m) => {
3380
+ setReplyingTo(m);
3381
+ onReply(m);
3382
+ inputRef.current?.focus();
3383
+ } : void 0;
3384
+ const send = (text, files) => {
3385
+ if (replyingTo) onSend(text, files, replyingTo);
3386
+ else onSend(text, files);
3387
+ setReplyingTo(null);
3388
+ scrollToBottom();
3389
+ };
3390
+ const pick = (s) => {
3391
+ const prompt = s.prompt ?? s.label;
3392
+ if (suggestionAction === "fill") {
3393
+ setDraft(prompt);
3394
+ inputRef.current?.focus();
3395
+ } else send(prompt, []);
3396
+ };
3397
+ const [unseen, setUnseen] = React10.useState(false);
3398
+ const prevCount = React10.useRef(messages.length);
3399
+ React10.useEffect(() => {
3400
+ if (pinned) setUnseen(false);
3401
+ else if (messages.length > prevCount.current) setUnseen(true);
3402
+ prevCount.current = messages.length;
3403
+ }, [messages.length, pinned]);
3404
+ const pillLabel = running ? labels.writing : unseen ? labels.newMessages : labels.jumpToLatest;
3405
+ const pill = React10.useRef(new Animated.Value(pinned ? 0 : 1)).current;
3406
+ React10.useEffect(() => {
3407
+ Animated.timing(pill, {
3408
+ toValue: pinned ? 0 : 1,
3409
+ duration: animate ? theme.motion.enter.duration : 0,
3410
+ useNativeDriver: true
3411
+ }).start();
3412
+ }, [pinned, animate, pill, theme.motion.enter.duration]);
3413
+ const streamingId = messages.find((m) => m.status === "streaming")?.id;
3414
+ const prevStreaming = React10.useRef(streamingId);
3415
+ const prevRunning = React10.useRef(running);
3416
+ React10.useEffect(() => {
3417
+ if (running && !prevRunning.current) {
3418
+ AccessibilityInfo.announceForAccessibility?.(labels.responding(assistant.name));
3419
+ }
3420
+ if (prevStreaming.current && prevStreaming.current !== streamingId) {
3421
+ const m = messages.find((x) => x.id === prevStreaming.current);
3422
+ if (m)
3423
+ AccessibilityInfo.announceForAccessibility?.(labels.said(assistant.name, chatMessageText(m)));
3424
+ }
3425
+ prevStreaming.current = streamingId;
3426
+ prevRunning.current = running;
3427
+ }, [running, streamingId, messages, assistant.name, labels]);
3428
+ const lastUserText = React10.useMemo(() => {
3429
+ const m = [...messages].reverse().find((x) => x.role === "user");
3430
+ return m ? chatMessageText(m) : void 0;
3431
+ }, [messages]);
3432
+ const pendingReply = running && last?.role === "user";
3433
+ const showFollowUps = !running && !!followUps?.length && last?.role === "assistant" && (last.status ?? "done") === "done";
3434
+ return /* @__PURE__ */ jsxs(
3435
+ KeyboardAvoidingView,
3436
+ {
3437
+ accessibilityLabel: label,
3438
+ behavior: Platform.OS === "ios" ? "padding" : void 0,
3439
+ keyboardVerticalOffset: insets?.top ?? 0,
3440
+ style: [styles.root, style],
3441
+ children: [
3442
+ header,
3443
+ /* @__PURE__ */ jsxs(View, { style: styles.stage, children: [
3444
+ /* @__PURE__ */ jsxs(
3445
+ ScrollView,
3446
+ {
3447
+ ...scrollProps,
3448
+ accessibilityLabel: labels.messages,
3449
+ keyboardShouldPersistTaps: "handled",
3450
+ keyboardDismissMode: "interactive",
3451
+ contentContainerStyle: [styles.content, column],
3452
+ onScroll: (e) => {
3453
+ scrollProps.onScroll(e);
3454
+ if (hasOlder && !loadingOlder && e.nativeEvent.contentOffset.y < theme.space.s8)
3455
+ onLoadOlder?.();
3456
+ },
3457
+ children: [
3458
+ hasOlder ? /* @__PURE__ */ jsx(View, { style: styles.older, children: loadingOlder ? /* @__PURE__ */ jsx(Thinking, { label: labels.loadingEarlier, size: "sm", motion }) : /* @__PURE__ */ jsx(
3459
+ Pressable,
3460
+ {
3461
+ accessibilityRole: "button",
3462
+ onPress: onLoadOlder,
3463
+ hitSlop: theme.space[8],
3464
+ children: /* @__PURE__ */ jsx(Text, { style: styles.olderText, children: labels.loadEarlier })
3465
+ }
3466
+ ) }) : null,
3467
+ messages.length === 0 ? emptyState ?? /* @__PURE__ */ jsxs(View, { style: styles.empty, children: [
3468
+ /* @__PURE__ */ jsx(Staggered, { i: 0, animate, children: /* @__PURE__ */ jsxs(View, { style: styles.emptyHead, children: [
3469
+ /* @__PURE__ */ jsx(AssistantMark, {}),
3470
+ /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: styles.emptyTitle, children: emptyTitle }),
3471
+ emptyDescription ? /* @__PURE__ */ jsx(Text, { style: styles.emptyText, children: emptyDescription }) : null
3472
+ ] }) }),
3473
+ suggestionsLoading || suggestions?.length ? /* @__PURE__ */ jsx(Staggered, { i: 2, animate, children: /* @__PURE__ */ jsx(
3474
+ ChatSuggestions,
3475
+ {
3476
+ suggestions: suggestions ?? [],
3477
+ perPage: suggestionsPerPage,
3478
+ loading: suggestionsLoading,
3479
+ onPick: pick,
3480
+ onDismiss: onDismissSuggestion,
3481
+ animate,
3482
+ labels
3483
+ }
3484
+ ) }) : null
3485
+ ] }) : messages.map((m, i) => /* @__PURE__ */ jsxs(React10.Fragment, { children: [
3486
+ m.day && m.day !== messages[i - 1]?.day ? /* @__PURE__ */ jsxs(View, { style: styles.day, accessibilityRole: "header", accessibilityLabel: m.day, children: [
3487
+ /* @__PURE__ */ jsx(View, { style: styles.dayLine }),
3488
+ /* @__PURE__ */ jsx(Text, { style: styles.dayText, children: m.day }),
3489
+ /* @__PURE__ */ jsx(View, { style: styles.dayLine })
3490
+ ] }) : null,
3491
+ /* @__PURE__ */ jsx(
3492
+ ChatMessageRow,
3493
+ {
3494
+ message: m,
3495
+ latest: m.id === latestAssistantId,
3496
+ appearing: isArriving(m.id),
3497
+ animate,
3498
+ assistant,
3499
+ user,
3500
+ feedbackReasons,
3501
+ running,
3502
+ onRegenerate,
3503
+ onEdit,
3504
+ onRetry,
3505
+ onFeedback,
3506
+ onCopy,
3507
+ onReply: reply,
3508
+ onLinkPress,
3509
+ onApproval,
3510
+ onOpenSource,
3511
+ onVersionChange,
3512
+ onContinue,
3513
+ onArtifactVersionChange,
3514
+ onShareArtifact,
3515
+ onExpandTable,
3516
+ labels
3517
+ }
3518
+ )
3519
+ ] }, m.id)),
3520
+ pendingReply ? /* @__PURE__ */ jsxs(View, { style: styles.pending, children: [
3521
+ assistant.avatar ?? /* @__PURE__ */ jsx(AssistantMark, {}),
3522
+ /* @__PURE__ */ jsx(WorkingIndicator, { animate, labels })
3523
+ ] }) : null,
3524
+ showFollowUps ? /* @__PURE__ */ jsx(View, { style: styles.followUps, role: "group", accessibilityLabel: labels.followUps, children: followUps.map((s, i) => /* @__PURE__ */ jsx(Staggered, { i, animate, children: /* @__PURE__ */ jsxs(
3525
+ Pressable,
3526
+ {
3527
+ accessibilityRole: "button",
3528
+ accessibilityLabel: s.label,
3529
+ onPress: () => send(s.prompt ?? s.label, []),
3530
+ style: ({ pressed }) => [styles.followUp, pressed && styles.pressed],
3531
+ children: [
3532
+ /* @__PURE__ */ jsx(
3533
+ Icon,
3534
+ {
3535
+ name: s.icon ?? "arrow-right",
3536
+ size: theme.icon.xs,
3537
+ color: theme.color.text3
3538
+ }
3539
+ ),
3540
+ /* @__PURE__ */ jsx(Text, { style: styles.followUpText, children: s.label })
3541
+ ]
3542
+ }
3543
+ ) }, s.id ?? s.label)) }) : null
3544
+ ]
3545
+ }
3546
+ ),
3547
+ /* @__PURE__ */ jsx(
3548
+ Animated.View,
3549
+ {
3550
+ pointerEvents: pinned ? "none" : "box-none",
3551
+ importantForAccessibility: pinned ? "no-hide-descendants" : "auto",
3552
+ accessibilityElementsHidden: pinned,
3553
+ style: [
3554
+ styles.pillWrap,
3555
+ {
3556
+ opacity: pill,
3557
+ transform: [
3558
+ {
3559
+ translateY: pill.interpolate({
3560
+ inputRange: [0, 1],
3561
+ outputRange: [theme.space[8], 0]
3562
+ })
3563
+ }
3564
+ ]
3565
+ }
3566
+ ],
3567
+ children: /* @__PURE__ */ jsxs(
3568
+ Pressable,
3569
+ {
3570
+ accessibilityRole: "button",
3571
+ accessibilityLabel: pillLabel,
3572
+ onPress: () => scrollToBottom(),
3573
+ style: styles.pill,
3574
+ children: [
3575
+ running ? /* @__PURE__ */ jsx(Thinking, { label: "", size: "sm", announce: false, motion }) : /* @__PURE__ */ jsx(Icon, { name: "arrow-down", size: theme.icon.xs, color: theme.color.text }),
3576
+ /* @__PURE__ */ jsx(Text, { style: styles.pillText, children: pillLabel })
3577
+ ]
3578
+ }
3579
+ )
3580
+ }
3581
+ )
3582
+ ] }),
3583
+ /* @__PURE__ */ jsx(
3584
+ ChatComposer,
3585
+ {
3586
+ inputRef,
3587
+ value: draft,
3588
+ onValueChange: setDraft,
3589
+ onSend: send,
3590
+ replyTo: replyingTo ? {
3591
+ author: replyingTo.role === "user" ? user?.name ?? labels.you : assistant.name,
3592
+ text: chatMessageText(replyingTo)
3593
+ } : null,
3594
+ onCancelReply: () => setReplyingTo(null),
3595
+ running,
3596
+ onStop,
3597
+ placeholder,
3598
+ attachments,
3599
+ onAttach,
3600
+ accept,
3601
+ recall: lastUserText,
3602
+ onRemoveAttachment,
3603
+ toolbar: composerToolbar,
3604
+ hint: disclaimer,
3605
+ disabled,
3606
+ motion,
3607
+ labels,
3608
+ style: [styles.composer, column],
3609
+ ...composerFeatures
3610
+ }
3611
+ )
3612
+ ]
3613
+ }
3614
+ );
3615
+ }
3616
+ var sheet9 = createStyleSheet((theme) => ({
3617
+ root: { flex: 1, backgroundColor: theme.color.surface },
3618
+ stage: { flex: 1 },
3619
+ content: { flexGrow: 1, gap: theme.space.s6, padding: theme.space.s4 },
3620
+ older: { alignItems: "center" },
3621
+ olderText: {
3622
+ fontFamily: theme.font.sans,
3623
+ fontSize: theme.type.caption1.fontSize,
3624
+ color: theme.color.text3
3625
+ },
3626
+ empty: {
3627
+ flex: 1,
3628
+ justifyContent: "center",
3629
+ gap: theme.space.s2,
3630
+ paddingVertical: theme.space.s8
3631
+ },
3632
+ emptyHead: { alignItems: "center", gap: theme.space.s3, marginBottom: theme.space.s4 },
3633
+ emptyTitle: {
3634
+ fontFamily: theme.font.display,
3635
+ fontSize: theme.type.title3.fontSize,
3636
+ lineHeight: theme.type.title3.lineHeight,
3637
+ fontWeight: theme.fontWeight.bold,
3638
+ color: theme.color.text,
3639
+ textAlign: "center"
3640
+ },
3641
+ emptyText: {
3642
+ fontFamily: theme.font.sans,
3643
+ fontSize: theme.type.footnote.fontSize,
3644
+ lineHeight: theme.type.footnote.lineHeight,
3645
+ color: theme.color.text2,
3646
+ textAlign: "center"
3647
+ },
3648
+ pressed: { backgroundColor: theme.state.pressed },
3649
+ meta: {
3650
+ fontFamily: theme.font.sans,
3651
+ fontSize: theme.type.caption1.fontSize,
3652
+ lineHeight: theme.type.caption1.lineHeight,
3653
+ color: theme.color.text3
3654
+ },
3655
+ day: { flexDirection: "row", alignItems: "center", gap: theme.space.s3 },
3656
+ dayLine: { flex: 1, height: theme.borderWidth.base, backgroundColor: theme.color.border },
3657
+ dayText: {
3658
+ fontFamily: theme.font.sans,
3659
+ fontSize: theme.type.caption1.fontSize,
3660
+ fontWeight: theme.fontWeight.bold,
3661
+ color: theme.color.text3
3662
+ },
3663
+ pending: { flexDirection: "row", gap: theme.space.s3, alignItems: "center" },
3664
+ followUps: {
3665
+ flexDirection: "row",
3666
+ flexWrap: "wrap",
3667
+ gap: theme.space.s2,
3668
+ paddingLeft: theme.ctl.sm + theme.space.s3
3669
+ },
3670
+ followUp: {
3671
+ flexDirection: "row",
3672
+ alignItems: "center",
3673
+ gap: theme.space[6],
3674
+ paddingHorizontal: theme.space.s3,
3675
+ paddingVertical: theme.space.s2,
3676
+ borderRadius: theme.radius.full,
3677
+ borderWidth: theme.borderWidth.base,
3678
+ borderColor: theme.color.border
3679
+ },
3680
+ followUpText: {
3681
+ fontFamily: theme.font.sans,
3682
+ fontSize: theme.type.footnote.fontSize,
3683
+ color: theme.color.text2
3684
+ },
3685
+ pillWrap: {
3686
+ position: "absolute",
3687
+ left: 0,
3688
+ right: 0,
3689
+ bottom: theme.space.s3,
3690
+ alignItems: "center"
3691
+ },
3692
+ pill: {
3693
+ flexDirection: "row",
3694
+ alignItems: "center",
3695
+ gap: theme.space[6],
3696
+ paddingHorizontal: theme.space.s3,
3697
+ paddingVertical: theme.space.s2,
3698
+ borderRadius: theme.radius.full,
3699
+ borderWidth: theme.borderWidth.base,
3700
+ borderColor: theme.color.border,
3701
+ backgroundColor: theme.color.surface,
3702
+ ...theme.shadow.md
3703
+ },
3704
+ // The sm tier's label role, so the pill reads beside the sm actions (R12).
3705
+ pillText: {
3706
+ ...theme.ctl.label.sm,
3707
+ fontFamily: theme.font.sans,
3708
+ color: theme.color.text
3709
+ },
3710
+ composer: { paddingHorizontal: theme.space.s4, paddingBottom: theme.space.s4 }
3711
+ }));
3712
+ function ChatHistory({
3713
+ conversations,
3714
+ activeId,
3715
+ onSelect,
3716
+ onNew,
3717
+ onRename,
3718
+ onDelete,
3719
+ query: queryProp,
3720
+ defaultQuery = "",
3721
+ defaultRenamingId,
3722
+ onQueryChange,
3723
+ labels: labelsProp
3724
+ }) {
3725
+ const labels = useLabels("chat", DEFAULT_CHAT_LABELS, labelsProp);
3726
+ const { styles } = useStyles(sheet10);
3727
+ const theme = useLoamTheme("chat");
3728
+ const android = isAndroidIdiom(theme);
3729
+ const [inner, setInner] = React10.useState(defaultQuery);
3730
+ const query = queryProp ?? inner;
3731
+ const initialRename = onRename ? conversations.find((c) => c.id === defaultRenamingId) ?? null : null;
3732
+ const [menuFor, setMenuFor] = React10.useState(initialRename);
3733
+ const [renaming, setRenaming] = React10.useState(initialRename !== null);
3734
+ const [draft, setDraft] = React10.useState(initialRename?.title ?? "");
3735
+ const shown = conversations.filter((c) => c.title.toLowerCase().includes(query.trim().toLowerCase()));
3736
+ const groups = [];
3737
+ for (const c of shown) {
3738
+ const last = groups[groups.length - 1];
3739
+ if (last && last.title === c.group) last.rows.push(c);
3740
+ else groups.push({ title: c.group, rows: [c] });
3741
+ }
3742
+ const hasMenu = !!onRename || !!onDelete;
3743
+ const closeMenu = () => {
3744
+ setMenuFor(null);
3745
+ setRenaming(false);
3746
+ };
3747
+ return /* @__PURE__ */ jsxs(View, { style: styles.root, role: "navigation", accessibilityLabel: labels.chats, children: [
3748
+ /* @__PURE__ */ jsxs(View, { style: styles.head, children: [
3749
+ /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: styles.title, children: labels.chats }),
3750
+ onNew ? /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", leadingIcon: "plus", onPress: onNew, children: labels.newChat }) : null
3751
+ ] }),
3752
+ /* @__PURE__ */ jsx(View, { style: styles.search, children: /* @__PURE__ */ jsx(
3753
+ Input,
3754
+ {
3755
+ accessibilityLabel: labels.searchChats,
3756
+ placeholder: labels.searchChats,
3757
+ leadingIcon: "search",
3758
+ value: query,
3759
+ onChangeText: (t) => {
3760
+ if (queryProp === void 0) setInner(t);
3761
+ onQueryChange?.(t);
3762
+ }
3763
+ }
3764
+ ) }),
3765
+ /* @__PURE__ */ jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.list, children: [
3766
+ shown.length === 0 ? /* @__PURE__ */ jsx(Text, { style: styles.empty, children: labels.noChats }) : null,
3767
+ groups.map((g, i) => /* @__PURE__ */ jsxs(View, { role: "list", accessibilityLabel: g.title, children: [
3768
+ g.title ? /* @__PURE__ */ jsx(Text, { style: styles.group, children: g.title }) : null,
3769
+ g.rows.map((c) => {
3770
+ const active = c.id === activeId;
3771
+ return /* @__PURE__ */ jsx(View, { role: "listitem", children: /* @__PURE__ */ jsxs(
3772
+ Pressable,
3773
+ {
3774
+ accessibilityRole: "button",
3775
+ accessibilityLabel: c.title,
3776
+ accessibilityState: { selected: active },
3777
+ "aria-current": active ? "page" : void 0,
3778
+ accessibilityActions: hasMenu ? [
3779
+ ...onRename ? [{ name: "rename", label: labels.renameChat }] : [],
3780
+ ...onDelete ? [{ name: "delete", label: labels.delete }] : []
3781
+ ] : void 0,
3782
+ onAccessibilityAction: (e) => {
3783
+ if (e.nativeEvent.actionName === "delete") onDelete?.(c.id);
3784
+ if (e.nativeEvent.actionName === "rename") {
3785
+ setDraft(c.title);
3786
+ setMenuFor(c);
3787
+ setRenaming(true);
3788
+ }
3789
+ },
3790
+ onPress: () => onSelect?.(c.id),
3791
+ onLongPress: hasMenu ? () => setMenuFor(c) : void 0,
3792
+ style: ({ pressed }) => [
3793
+ styles.row,
3794
+ // OS list row: 48 on iOS, 56 on Android.
3795
+ android && { minHeight: theme.space[56] },
3796
+ active && styles.rowActive,
3797
+ pressed && styles.down
3798
+ ],
3799
+ children: [
3800
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles.rowTitle, active && styles.rowTitleActive], children: c.title }),
3801
+ c.status === "answering" ? /* @__PURE__ */ jsx(Thinking, { size: "sm", label: labels.answering, announce: false }) : c.status === "unseen" ? /* @__PURE__ */ jsx(View, { accessibilityLabel: labels.unread, role: "img", style: styles.dot }) : null
3802
+ ]
3803
+ }
3804
+ ) }, c.id);
3805
+ })
3806
+ ] }, `${g.title ?? ""}${i}`))
3807
+ ] }),
3808
+ menuFor ? /* @__PURE__ */ jsx(Sheet, { open: true, title: menuFor.title, onClose: closeMenu, closeLabel: labels.close, children: renaming ? /* @__PURE__ */ jsxs(View, { style: styles.rename, children: [
3809
+ /* @__PURE__ */ jsx(
3810
+ Input,
3811
+ {
3812
+ accessibilityLabel: labels.renameChat,
3813
+ value: draft,
3814
+ onChangeText: setDraft,
3815
+ autoFocus: true
3816
+ }
3817
+ ),
3818
+ /* @__PURE__ */ jsxs(View, { style: styles.renameActions, children: [
3819
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "lg", onPress: closeMenu, children: labels.cancel }),
3820
+ /* @__PURE__ */ jsx(
3821
+ Button,
3822
+ {
3823
+ size: "lg",
3824
+ disabled: !draft.trim(),
3825
+ onPress: () => {
3826
+ onRename?.(menuFor.id, draft.trim());
3827
+ closeMenu();
3828
+ },
3829
+ children: labels.save
3830
+ }
3831
+ )
3832
+ ] })
3833
+ ] }) : /* @__PURE__ */ jsxs(View, { style: styles.menu, children: [
3834
+ onRename ? /* @__PURE__ */ jsx(
3835
+ MenuRow,
3836
+ {
3837
+ icon: "edit",
3838
+ label: labels.renameChat,
3839
+ onPress: () => {
3840
+ setDraft(menuFor.title);
3841
+ setRenaming(true);
3842
+ }
3843
+ }
3844
+ ) : null,
3845
+ onDelete ? /* @__PURE__ */ jsx(
3846
+ MenuRow,
3847
+ {
3848
+ icon: "trash",
3849
+ label: labels.delete,
3850
+ danger: true,
3851
+ onPress: () => {
3852
+ onDelete(menuFor.id);
3853
+ closeMenu();
3854
+ }
3855
+ }
3856
+ ) : null
3857
+ ] }) }) : null
3858
+ ] });
3859
+ function MenuRow({
3860
+ icon,
3861
+ label,
3862
+ danger,
3863
+ onPress
3864
+ }) {
3865
+ return /* @__PURE__ */ jsxs(
3866
+ Pressable,
3867
+ {
3868
+ accessibilityRole: "button",
3869
+ accessibilityLabel: label,
3870
+ onPress,
3871
+ style: ({ pressed }) => [styles.menuRow, pressed && styles.down],
3872
+ children: [
3873
+ /* @__PURE__ */ jsx(Icon, { name: icon, size: theme.icon.sm, color: danger ? theme.color.dangerOnSoft : theme.color.text2 }),
3874
+ /* @__PURE__ */ jsx(Text, { style: [styles.rowTitle, danger && { color: theme.color.dangerOnSoft }], children: label })
3875
+ ]
3876
+ }
3877
+ );
3878
+ }
3879
+ }
3880
+ var sheet10 = createStyleSheet((theme) => ({
3881
+ root: { flex: 1, backgroundColor: theme.color.surface },
3882
+ head: {
3883
+ minHeight: theme.space[56],
3884
+ flexDirection: "row",
3885
+ alignItems: "center",
3886
+ justifyContent: "space-between",
3887
+ paddingHorizontal: theme.space[16]
3888
+ },
3889
+ title: {
3890
+ fontFamily: theme.font.sans,
3891
+ fontSize: theme.type.headline.fontSize,
3892
+ fontWeight: theme.fontWeight.semibold,
3893
+ color: theme.color.text
3894
+ },
3895
+ search: { paddingHorizontal: theme.space[12], paddingBottom: theme.space[8] },
3896
+ scroll: { flex: 1 },
3897
+ list: { padding: theme.space[8], gap: theme.space[8] },
3898
+ group: {
3899
+ ...theme.type.overline,
3900
+ paddingHorizontal: theme.space[8],
3901
+ paddingVertical: theme.space[4],
3902
+ fontFamily: theme.font.sans,
3903
+ color: theme.color.text3
3904
+ },
3905
+ empty: {
3906
+ padding: theme.space[16],
3907
+ textAlign: "center",
3908
+ fontFamily: theme.font.sans,
3909
+ fontSize: theme.type.footnote.fontSize,
3910
+ color: theme.color.text2
3911
+ },
3912
+ row: {
3913
+ minHeight: theme.space[48],
3914
+ flexDirection: "row",
3915
+ alignItems: "center",
3916
+ gap: theme.space.s3,
3917
+ paddingHorizontal: theme.space[12],
3918
+ borderRadius: theme.radius.md
3919
+ },
3920
+ rowActive: { backgroundColor: theme.state.selected },
3921
+ down: { backgroundColor: theme.state.pressed },
3922
+ rowTitle: {
3923
+ flex: 1,
3924
+ minWidth: 0,
3925
+ fontFamily: theme.font.sans,
3926
+ fontSize: theme.type.callout.fontSize,
3927
+ lineHeight: theme.type.callout.lineHeight,
3928
+ color: theme.color.text
3929
+ },
3930
+ rowTitleActive: { fontWeight: theme.fontWeight.medium },
3931
+ dot: {
3932
+ width: theme.space[8],
3933
+ height: theme.space[8],
3934
+ borderRadius: theme.radius.full,
3935
+ backgroundColor: theme.color.accent
3936
+ },
3937
+ menu: { padding: theme.space[8] },
3938
+ menuRow: {
3939
+ minHeight: theme.space[48],
3940
+ flexDirection: "row",
3941
+ alignItems: "center",
3942
+ gap: theme.space.s3,
3943
+ paddingHorizontal: theme.space[12],
3944
+ borderRadius: theme.radius.md
3945
+ },
3946
+ rename: { padding: theme.space[16], gap: theme.space[12] },
3947
+ renameActions: { flexDirection: "row", justifyContent: "flex-end", gap: theme.space.s2 }
3948
+ }));
3949
+
3950
+ export { ApprovalView, CHAT_FEEDBACK_REASONS, Chat, ChatArtifactCard, ChatArtifactSheet, ChatComposer, ChatHistory, ChatInlineTable, ChatSlashMenu, CitationMark, SourcesRow, SourcesSheet, VersionSwitcher, chatMessageText, chatSlashEntries, findChatTrigger };