@zaly/tui 0.1.0 → 0.1.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 (245) hide show
  1. package/dist/{actions-DEIKF2ts.mjs → actions-AY6avfEV.mjs} +2 -3
  2. package/dist/{actions-DEIKF2ts.mjs.map → actions-AY6avfEV.mjs.map} +1 -1
  3. package/dist/{actions--ODlgCQ5.d.mts → actions-B0yyZ-Ww.d.mts} +4 -6
  4. package/dist/actions-B0yyZ-Ww.d.mts.map +1 -0
  5. package/dist/{ansi-CMv71xVr.mjs → ansi-CxgRPLA2.mjs} +3 -4
  6. package/dist/{ansi-CMv71xVr.mjs.map → ansi-CxgRPLA2.mjs.map} +1 -1
  7. package/dist/ansi.d.mts +1 -3
  8. package/dist/ansi.d.mts.map +1 -1
  9. package/dist/ansi.mjs +1 -1
  10. package/dist/{autocomplete-CD30kSe_.d.mts → autocomplete-wgceuhLr.d.mts} +5 -7
  11. package/dist/autocomplete-wgceuhLr.d.mts.map +1 -0
  12. package/dist/{box-C_N_7ChP.mjs → box-DToDoXlU.mjs} +8 -10
  13. package/dist/{box-C_N_7ChP.mjs.map → box-DToDoXlU.mjs.map} +1 -1
  14. package/dist/{builder-Chwtk0nQ.mjs → builder-BdYlK1Ew.mjs} +5 -6
  15. package/dist/{builder-Chwtk0nQ.mjs.map → builder-BdYlK1Ew.mjs.map} +1 -1
  16. package/dist/{callbacks-DLecWn7G.mjs → callbacks-DW8XKYKy.mjs} +8 -12
  17. package/dist/{callbacks-DLecWn7G.mjs.map → callbacks-DW8XKYKy.mjs.map} +1 -1
  18. package/dist/{client-D7qz4TZt.mjs → client-BWm6dNZF.mjs} +4 -5
  19. package/dist/{client-D7qz4TZt.mjs.map → client-BWm6dNZF.mjs.map} +1 -1
  20. package/dist/client-C69qWhMG.mjs +1 -0
  21. package/dist/{clipboard-CNPBTX7j.mjs → clipboard-UEoX9sup.mjs} +2 -3
  22. package/dist/{clipboard-CNPBTX7j.mjs.map → clipboard-UEoX9sup.mjs.map} +1 -1
  23. package/dist/clipboard.d.mts +0 -2
  24. package/dist/clipboard.d.mts.map +1 -1
  25. package/dist/clipboard.mjs +1 -1
  26. package/dist/{color-DBMQLv4Y.mjs → color-Cr1VoL49.mjs} +2 -3
  27. package/dist/{color-DBMQLv4Y.mjs.map → color-Cr1VoL49.mjs.map} +1 -1
  28. package/dist/ctx-CYEzzH-7.mjs +1 -0
  29. package/dist/{ctx-BaQ2hP5u.mjs → ctx-DBeFcZt6.mjs} +4 -5
  30. package/dist/{ctx-BaQ2hP5u.mjs.map → ctx-DBeFcZt6.mjs.map} +1 -1
  31. package/dist/{divider-BlNNN2OS.mjs → divider-qEj5prKE.mjs} +3 -4
  32. package/dist/{divider-BlNNN2OS.mjs.map → divider-qEj5prKE.mjs.map} +1 -1
  33. package/dist/{files-BvThQpOf.mjs → files-C3ZnFpvq.mjs} +3 -4
  34. package/dist/{files-BvThQpOf.mjs.map → files-C3ZnFpvq.mjs.map} +1 -1
  35. package/dist/{files-B_5HDBPp.d.mts → files-CdiDnwA_.d.mts} +3 -5
  36. package/dist/files-CdiDnwA_.d.mts.map +1 -0
  37. package/dist/{flex-Bguo-fUe.mjs → flex-CYp4etqn.mjs} +3 -4
  38. package/dist/{flex-Bguo-fUe.mjs.map → flex-CYp4etqn.mjs.map} +1 -1
  39. package/dist/{github-Cy2hfWJ7.mjs → github-CLveT9mq.mjs} +2 -3
  40. package/dist/{github-Cy2hfWJ7.mjs.map → github-CLveT9mq.mjs.map} +1 -1
  41. package/dist/{github-CyRwUQ3y.d.mts → github-DC0XemKa.d.mts} +3 -5
  42. package/dist/github-DC0XemKa.d.mts.map +1 -0
  43. package/dist/{image-BLls2F4t.d.mts → image-DdRDv7q6.d.mts} +2 -4
  44. package/dist/image-DdRDv7q6.d.mts.map +1 -0
  45. package/dist/{image-Cqtj3yRA.mjs → image-M--Bw4bs.mjs} +6 -7
  46. package/dist/{image-Cqtj3yRA.mjs.map → image-M--Bw4bs.mjs.map} +1 -1
  47. package/dist/image.d.mts +1 -3
  48. package/dist/image.d.mts.map +1 -1
  49. package/dist/image.mjs +1 -1
  50. package/dist/index.d.mts +3 -15
  51. package/dist/index.d.mts.map +1 -1
  52. package/dist/index.mjs +11 -14
  53. package/dist/index.mjs.map +1 -1
  54. package/dist/{input-ET2YEMcl.mjs → input-BkE4EpBw.mjs} +6 -7
  55. package/dist/{input-ET2YEMcl.mjs.map → input-BkE4EpBw.mjs.map} +1 -1
  56. package/dist/{input-NuD8TH8N.d.mts → input-C3kfYoEJ.d.mts} +3 -5
  57. package/dist/input-C3kfYoEJ.d.mts.map +1 -0
  58. package/dist/{inspect-Cxzs-W0g.mjs → inspect-Cli1beu8.mjs} +3 -4
  59. package/dist/{inspect-Cxzs-W0g.mjs.map → inspect-Cli1beu8.mjs.map} +1 -1
  60. package/dist/{inspect-B1uXxdKC.d.mts → inspect-hSl3U2BD.d.mts} +2 -6
  61. package/dist/inspect-hSl3U2BD.d.mts.map +1 -0
  62. package/dist/kitty-0sJ8axU_.mjs +1 -0
  63. package/dist/{kitty-JbCJC0iQ.mjs → kitty-BH_eK6lz.mjs} +2 -3
  64. package/dist/{kitty-JbCJC0iQ.mjs.map → kitty-BH_eK6lz.mjs.map} +1 -1
  65. package/dist/{log-B4djzy2m.mjs → log-96b1_J6G.mjs} +6 -7
  66. package/dist/{log-B4djzy2m.mjs.map → log-96b1_J6G.mjs.map} +1 -1
  67. package/dist/{logger-CvJCITzP.mjs → logger-DwfXp8LF.mjs} +5 -6
  68. package/dist/{logger-CvJCITzP.mjs.map → logger-DwfXp8LF.mjs.map} +1 -1
  69. package/dist/{markdown-D3ZtRn6C.mjs → markdown-CgRZBhIX.mjs} +11 -12
  70. package/dist/{markdown-D3ZtRn6C.mjs.map → markdown-CgRZBhIX.mjs.map} +1 -1
  71. package/dist/markdown.d.mts +2 -4
  72. package/dist/markdown.d.mts.map +1 -1
  73. package/dist/markdown.mjs +1 -1
  74. package/dist/math-Dk8hxbmz.mjs +1 -0
  75. package/dist/{math-Dd7a1irv.mjs → math-VPuwFCid.mjs} +1 -2
  76. package/dist/{math-Dd7a1irv.mjs.map → math-VPuwFCid.mjs.map} +1 -1
  77. package/dist/md.bun.d.mts +1 -3
  78. package/dist/md.bun.d.mts.map +1 -1
  79. package/dist/md.bun.mjs +2 -3
  80. package/dist/md.node.d.mts +1 -3
  81. package/dist/md.node.d.mts.map +1 -1
  82. package/dist/md.node.mjs +2 -3
  83. package/dist/{node-BZ7f6HzU.mjs → node-CXNobGaP.mjs} +3 -4
  84. package/dist/{node-BZ7f6HzU.mjs.map → node-CXNobGaP.mjs.map} +1 -1
  85. package/dist/{oklch-Bsh5swbC.mjs → oklch-Boh4YHEc.mjs} +3 -4
  86. package/dist/{oklch-Bsh5swbC.mjs.map → oklch-Boh4YHEc.mjs.map} +1 -1
  87. package/dist/{overlay-LvOjG7kn.mjs → overlay-CevDWgSF.mjs} +3 -4
  88. package/dist/{overlay-LvOjG7kn.mjs.map → overlay-CevDWgSF.mjs.map} +1 -1
  89. package/dist/{picker-f6xjgACX.mjs → picker-D9WrE3zF.mjs} +11 -16
  90. package/dist/{picker-f6xjgACX.mjs.map → picker-D9WrE3zF.mjs.map} +1 -1
  91. package/dist/{picker-B-OxKKnD.d.mts → picker-DsB6--GN.d.mts} +6 -8
  92. package/dist/picker-DsB6--GN.d.mts.map +1 -0
  93. package/dist/{queries-BUkBxkuM.mjs → queries-BIniKnLL.mjs} +3 -5
  94. package/dist/{queries-BUkBxkuM.mjs.map → queries-BIniKnLL.mjs.map} +1 -1
  95. package/dist/{queries-C75-wG1B.d.mts → queries-Dmd3IjSd.d.mts} +3 -51
  96. package/dist/queries-Dmd3IjSd.d.mts.map +1 -0
  97. package/dist/{reactive-f7NpAi69.mjs → reactive-DkP75TPk.mjs} +2 -3
  98. package/dist/{reactive-f7NpAi69.mjs.map → reactive-DkP75TPk.mjs.map} +1 -1
  99. package/dist/{registry-DUWpSPoo.mjs → registry-CQU0VwpM.mjs} +9 -14
  100. package/dist/{registry-DUWpSPoo.mjs.map → registry-CQU0VwpM.mjs.map} +1 -1
  101. package/dist/{render-B7LfNM5K.mjs → render-Bp2N2i6J.mjs} +4 -5
  102. package/dist/{render-B7LfNM5K.mjs.map → render-Bp2N2i6J.mjs.map} +1 -1
  103. package/dist/{renderer-BLsd-wrG.mjs → renderer-B9sAMA10.mjs} +25 -38
  104. package/dist/{renderer-BLsd-wrG.mjs.map → renderer-B9sAMA10.mjs.map} +1 -1
  105. package/dist/{renderer-aAtkFgll.mjs → renderer-BYl2pbdx.mjs} +3 -4
  106. package/dist/{renderer-aAtkFgll.mjs.map → renderer-BYl2pbdx.mjs.map} +1 -1
  107. package/dist/renderer-Ctz0hv5o.mjs +1 -0
  108. package/dist/{search-FvGnswRl.d.mts → search-DsHzamic.d.mts} +1 -9
  109. package/dist/search-DsHzamic.d.mts.map +1 -0
  110. package/dist/{select-BKE5LzdN.d.mts → select-BZCFXdjp.d.mts} +3 -5
  111. package/dist/select-BZCFXdjp.d.mts.map +1 -0
  112. package/dist/{select-m7NE6Rwa.mjs → select-CUmAFKJh.mjs} +5 -6
  113. package/dist/{select-m7NE6Rwa.mjs.map → select-CUmAFKJh.mjs.map} +1 -1
  114. package/dist/services/logger.d.mts +1 -1
  115. package/dist/services/logger.mjs +1 -1
  116. package/dist/services/notifier.d.mts +1 -3
  117. package/dist/services/notifier.d.mts.map +1 -1
  118. package/dist/services/notifier.mjs +3 -4
  119. package/dist/services/picker.d.mts +5 -7
  120. package/dist/services/picker.d.mts.map +1 -1
  121. package/dist/services/picker.mjs +8 -9
  122. package/dist/services/prompt.d.mts +4 -6
  123. package/dist/services/prompt.d.mts.map +1 -1
  124. package/dist/services/prompt.mjs +7 -8
  125. package/dist/shiki/server.mjs +6 -8
  126. package/dist/shiki/server.mjs.map +1 -1
  127. package/dist/{shiki-CJauRusM.mjs → shiki-BAf9PdIc.mjs} +4 -5
  128. package/dist/{shiki-CJauRusM.mjs.map → shiki-BAf9PdIc.mjs.map} +1 -1
  129. package/dist/{shiki-B4U0s8jT.mjs → shiki-DUUAIE6f.mjs} +4 -7
  130. package/dist/{shiki-B4U0s8jT.mjs.map → shiki-DUUAIE6f.mjs.map} +1 -1
  131. package/dist/{show-DR2x1YFc.mjs → show-D5XNXgZf.mjs} +4 -5
  132. package/dist/{show-DR2x1YFc.mjs.map → show-D5XNXgZf.mjs.map} +1 -1
  133. package/dist/{size-D8JogYLy.mjs → size-BHRJuRk9.mjs} +2 -3
  134. package/dist/{size-D8JogYLy.mjs.map → size-BHRJuRk9.mjs.map} +1 -1
  135. package/dist/{style-DslRHzI4.mjs → style-Cw_EuszU.mjs} +5 -6
  136. package/dist/{style-DslRHzI4.mjs.map → style-Cw_EuszU.mjs.map} +1 -1
  137. package/dist/style.d.mts +2 -4
  138. package/dist/style.d.mts.map +1 -1
  139. package/dist/style.mjs +3 -3
  140. package/dist/{text-BoJdKXLU.mjs → text-4arC3odI.mjs} +3 -4
  141. package/dist/{text-BoJdKXLU.mjs.map → text-4arC3odI.mjs.map} +1 -1
  142. package/dist/{text-DPrhma4x.mjs → text-BArwVVkg.mjs} +5 -6
  143. package/dist/{text-DPrhma4x.mjs.map → text-BArwVVkg.mjs.map} +1 -1
  144. package/dist/{text-CmxbA8lk.d.mts → text-DdkJXgoC.d.mts} +3 -5
  145. package/dist/text-DdkJXgoC.d.mts.map +1 -0
  146. package/dist/text.d.mts +1 -1
  147. package/dist/text.mjs +1 -1
  148. package/dist/{theme-C8LkcoaK.mjs → theme-B8hb1lPU.mjs} +3 -4
  149. package/dist/{theme-C8LkcoaK.mjs.map → theme-B8hb1lPU.mjs.map} +1 -1
  150. package/dist/{theme-DVX8dvGG.mjs → theme-BeSaXGNY.mjs} +3 -5
  151. package/dist/{theme-DVX8dvGG.mjs.map → theme-BeSaXGNY.mjs.map} +1 -1
  152. package/dist/themes.d.mts +1 -7
  153. package/dist/themes.d.mts.map +1 -1
  154. package/dist/themes.mjs +1 -1
  155. package/dist/{tree-CTvSpF9b.d.mts → tree-Berzv8Rz.d.mts} +3 -5
  156. package/dist/tree-Berzv8Rz.d.mts.map +1 -0
  157. package/dist/{tree-Bo1afYhe.mjs → tree-D6NvMQx8.mjs} +5 -6
  158. package/dist/{tree-Bo1afYhe.mjs.map → tree-D6NvMQx8.mjs.map} +1 -1
  159. package/dist/{types-C9ceMsbJ.d.mts → types-ByMHEdCF.d.mts} +1 -7
  160. package/dist/types-ByMHEdCF.d.mts.map +1 -0
  161. package/dist/{types-D3jk1rtk.d.mts → types-CUVUJPz6.d.mts} +1 -3
  162. package/dist/types-CUVUJPz6.d.mts.map +1 -0
  163. package/dist/{utils-3M4D_AXZ.mjs → utils-DHXAegVW.mjs} +1 -2
  164. package/dist/{utils-3M4D_AXZ.mjs.map → utils-DHXAegVW.mjs.map} +1 -1
  165. package/dist/{widget-BkMwhY2p.mjs → widget-sFveyrZE.mjs} +3 -4
  166. package/dist/{widget-BkMwhY2p.mjs.map → widget-sFveyrZE.mjs.map} +1 -1
  167. package/dist/{widget-DlF32PRp.d.mts → widget-sPJaKVU2.d.mts} +2 -4
  168. package/dist/widget-sPJaKVU2.d.mts.map +1 -0
  169. package/dist/widgets/autocomplete.d.mts +1 -1
  170. package/dist/widgets/autocomplete.mjs +5 -6
  171. package/dist/widgets/box.d.mts +1 -1
  172. package/dist/widgets/box.mjs +1 -1
  173. package/dist/widgets/code.d.mts +3 -5
  174. package/dist/widgets/code.d.mts.map +1 -1
  175. package/dist/widgets/code.mjs +10 -11
  176. package/dist/widgets/completions/actions.d.mts +1 -1
  177. package/dist/widgets/completions/actions.mjs +1 -1
  178. package/dist/widgets/completions/files.d.mts +1 -1
  179. package/dist/widgets/completions/files.mjs +1 -1
  180. package/dist/widgets/completions/github.d.mts +1 -1
  181. package/dist/widgets/completions/github.mjs +1 -1
  182. package/dist/widgets/completions/index.d.mts +3 -3
  183. package/dist/widgets/completions/index.mjs +3 -3
  184. package/dist/widgets/diff.d.mts +2 -4
  185. package/dist/widgets/diff.d.mts.map +1 -1
  186. package/dist/widgets/diff.mjs +7 -8
  187. package/dist/widgets/divider.d.mts +2 -4
  188. package/dist/widgets/divider.d.mts.map +1 -1
  189. package/dist/widgets/divider.mjs +1 -1
  190. package/dist/widgets/image.d.mts +1 -1
  191. package/dist/widgets/image.mjs +5 -6
  192. package/dist/widgets/input.d.mts +1 -1
  193. package/dist/widgets/input.mjs +1 -1
  194. package/dist/widgets/log.d.mts +1 -1
  195. package/dist/widgets/log.mjs +1 -1
  196. package/dist/widgets/markdown.d.mts +5 -7
  197. package/dist/widgets/markdown.d.mts.map +1 -1
  198. package/dist/widgets/markdown.mjs +1 -1
  199. package/dist/widgets/overlay.d.mts +1 -1
  200. package/dist/widgets/overlay.mjs +1 -1
  201. package/dist/widgets/picker.d.mts +1 -1
  202. package/dist/widgets/picker.mjs +1 -1
  203. package/dist/widgets/progress.d.mts +2 -4
  204. package/dist/widgets/progress.d.mts.map +1 -1
  205. package/dist/widgets/progress.mjs +4 -5
  206. package/dist/widgets/select.d.mts +1 -1
  207. package/dist/widgets/select.mjs +1 -1
  208. package/dist/widgets/show.d.mts +1 -3
  209. package/dist/widgets/show.d.mts.map +1 -1
  210. package/dist/widgets/show.mjs +1 -1
  211. package/dist/widgets/spinner.d.mts +2 -4
  212. package/dist/widgets/spinner.d.mts.map +1 -1
  213. package/dist/widgets/spinner.mjs +3 -4
  214. package/dist/widgets/text.d.mts +1 -1
  215. package/dist/widgets/text.mjs +1 -1
  216. package/dist/widgets/tree.d.mts +1 -1
  217. package/dist/widgets/tree.mjs +1 -1
  218. package/dist/widgets/widget.d.mts +1 -1
  219. package/dist/widgets/widget.mjs +1 -1
  220. package/dist/{worker-T6SdPzUH.mjs → worker-CtEowucz.mjs} +2 -3
  221. package/dist/{worker-T6SdPzUH.mjs.map → worker-CtEowucz.mjs.map} +1 -1
  222. package/dist/worker-Mqi380Et.mjs +1 -0
  223. package/package.json +3 -3
  224. package/dist/actions--ODlgCQ5.d.mts.map +0 -1
  225. package/dist/autocomplete-CD30kSe_.d.mts.map +0 -1
  226. package/dist/client-CNGt-dOt.mjs +0 -1
  227. package/dist/ctx-CndlTp1T.mjs +0 -1
  228. package/dist/files-B_5HDBPp.d.mts.map +0 -1
  229. package/dist/github-CyRwUQ3y.d.mts.map +0 -1
  230. package/dist/image-BLls2F4t.d.mts.map +0 -1
  231. package/dist/input-NuD8TH8N.d.mts.map +0 -1
  232. package/dist/inspect-B1uXxdKC.d.mts.map +0 -1
  233. package/dist/kitty-DKQYsQfH.mjs +0 -1
  234. package/dist/math-CU0wmC9N.mjs +0 -1
  235. package/dist/picker-B-OxKKnD.d.mts.map +0 -1
  236. package/dist/queries-C75-wG1B.d.mts.map +0 -1
  237. package/dist/renderer-YHbR7JZ4.mjs +0 -1
  238. package/dist/search-FvGnswRl.d.mts.map +0 -1
  239. package/dist/select-BKE5LzdN.d.mts.map +0 -1
  240. package/dist/text-CmxbA8lk.d.mts.map +0 -1
  241. package/dist/tree-CTvSpF9b.d.mts.map +0 -1
  242. package/dist/types-C9ceMsbJ.d.mts.map +0 -1
  243. package/dist/types-D3jk1rtk.d.mts.map +0 -1
  244. package/dist/widget-DlF32PRp.d.mts.map +0 -1
  245. package/dist/worker-C01jK2Ip.mjs +0 -1
@@ -1,4 +1,4 @@
1
- //#region src/widgets/completions/actions.ts
1
+ // src/widgets/completions/actions.ts
2
2
  /**
3
3
  * Completion source backed by the `Actions` registry — typical slash
4
4
  * command ergonomics. Items are raw `ActionInfo` objects augmented
@@ -42,7 +42,6 @@ function actionsSource(opts) {
42
42
  triggers: [trigger]
43
43
  };
44
44
  }
45
- //#endregion
46
45
  export { actionsSource as t };
47
46
 
48
- //# sourceMappingURL=actions-DEIKF2ts.mjs.map
47
+ //# sourceMappingURL=actions-AY6avfEV.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions-DEIKF2ts.mjs","names":[],"sources":["../src/widgets/completions/actions.ts"],"sourcesContent":["import type { ActionDef, Actions } from \"../../input/actions.ts\"\nimport type { CompletionSource } from \"../autocomplete.ts\"\nimport type { PickerItem } from \"../picker.ts\"\n\n/** Completion item produced by `actionsSource`. Carries the full\n * `ActionInfo` plus the action `id` so the source's `accept` can\n * dispatch without a secondary lookup. Items match the `MenuItem`\n * contract loosely via the overlapping `name`/... shape. */\nexport type ActionCompletionItem = ActionDef & PickerItem & { id: string; score: number }\n\nexport interface ActionsSourceOptions {\n /** Registry to read from. Usually `renderer.actions`. */\n actions: Actions\n /** Trigger regex. Default: `/^\\s*\\//` (slash at start of line). */\n trigger?: RegExp\n /** Keep predicate. Default skips `info.hidden`. Return `false` to\n * drop the entry from the completion list. */\n filter?: (id: string, info: ActionDef) => boolean\n}\n\n/**\n * Completion source backed by the `Actions` registry — typical slash\n * command ergonomics. Items are raw `ActionInfo` objects augmented\n * with their `id`; `accept` dispatches the action through the registry\n * and clears the trigger+query range, so the user's typed `/foo` is\n * removed once the action fires (no stale text left in the input).\n *\n * ```ts\n * autocomplete({\n * input: \"chat-input\",\n * sources: {\n * slash: actionsSource({ actions: renderer.actions }),\n * },\n * })\n * ```\n */\nexport function actionsSource(opts: ActionsSourceOptions): CompletionSource<ActionCompletionItem> {\n const trigger = opts.trigger ?? /^\\//\n const filter = opts.filter ?? ((_id, info): boolean => !info.hidden && !!info.cmd)\n\n return {\n accept(item): undefined {\n opts.actions.dispatch(item.id, { source: \"autocomplete\" })\n return undefined\n },\n complete(_query, match): ActionCompletionItem[] {\n const out: ActionCompletionItem[] = []\n for (const info of opts.actions.list()) {\n if (!filter(info.id, info)) continue\n const name = info.cmd ?? info.id\n const score = match(name)\n if (!score) continue\n out.push({ ...info, id: info.id, name, score, text: name })\n }\n return out\n },\n triggers: [trigger],\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,SAAgB,cAAc,MAAoE;CAChG,MAAM,UAAU,KAAK,WAAW;CAChC,MAAM,SAAS,KAAK,YAAY,KAAK,SAAkB,CAAC,KAAK,UAAU,CAAC,CAAC,KAAK;CAE9E,OAAO;EACL,OAAO,MAAiB;GACtB,KAAK,QAAQ,SAAS,KAAK,IAAI,EAAE,QAAQ,eAAe,CAAC;EAE3D;EACA,SAAS,QAAQ,OAA+B;GAC9C,MAAM,MAA8B,CAAC;GACrC,KAAK,MAAM,QAAQ,KAAK,QAAQ,KAAK,GAAG;IACtC,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,GAAG;IAC5B,MAAM,OAAO,KAAK,OAAO,KAAK;IAC9B,MAAM,QAAQ,MAAM,IAAI;IACxB,IAAI,CAAC,OAAO;IACZ,IAAI,KAAK;KAAE,GAAG;KAAM,IAAI,KAAK;KAAI;KAAM;KAAO,MAAM;IAAK,CAAC;GAC5D;GACA,OAAO;EACT;EACA,UAAU,CAAC,OAAO;CACpB;AACF"}
1
+ {"version":3,"file":"actions-AY6avfEV.mjs","names":[],"sources":["../src/widgets/completions/actions.ts"],"sourcesContent":["import type { ActionDef, Actions } from \"../../input/actions.ts\"\nimport type { CompletionSource } from \"../autocomplete.ts\"\nimport type { PickerItem } from \"../picker.ts\"\n\n/** Completion item produced by `actionsSource`. Carries the full\n * `ActionInfo` plus the action `id` so the source's `accept` can\n * dispatch without a secondary lookup. Items match the `MenuItem`\n * contract loosely via the overlapping `name`/... shape. */\nexport type ActionCompletionItem = ActionDef & PickerItem & { id: string; score: number }\n\nexport interface ActionsSourceOptions {\n /** Registry to read from. Usually `renderer.actions`. */\n actions: Actions\n /** Trigger regex. Default: `/^\\s*\\//` (slash at start of line). */\n trigger?: RegExp\n /** Keep predicate. Default skips `info.hidden`. Return `false` to\n * drop the entry from the completion list. */\n filter?: (id: string, info: ActionDef) => boolean\n}\n\n/**\n * Completion source backed by the `Actions` registry — typical slash\n * command ergonomics. Items are raw `ActionInfo` objects augmented\n * with their `id`; `accept` dispatches the action through the registry\n * and clears the trigger+query range, so the user's typed `/foo` is\n * removed once the action fires (no stale text left in the input).\n *\n * ```ts\n * autocomplete({\n * input: \"chat-input\",\n * sources: {\n * slash: actionsSource({ actions: renderer.actions }),\n * },\n * })\n * ```\n */\nexport function actionsSource(opts: ActionsSourceOptions): CompletionSource<ActionCompletionItem> {\n const trigger = opts.trigger ?? /^\\//\n const filter = opts.filter ?? ((_id, info): boolean => !info.hidden && !!info.cmd)\n\n return {\n accept(item): undefined {\n opts.actions.dispatch(item.id, { source: \"autocomplete\" })\n return undefined\n },\n complete(_query, match): ActionCompletionItem[] {\n const out: ActionCompletionItem[] = []\n for (const info of opts.actions.list()) {\n if (!filter(info.id, info)) continue\n const name = info.cmd ?? info.id\n const score = match(name)\n if (!score) continue\n out.push({ ...info, id: info.id, name, score, text: name })\n }\n return out\n },\n triggers: [trigger],\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,SAAgB,cAAc,MAAoE;CAChG,MAAM,UAAU,KAAK,WAAW;CAChC,MAAM,SAAS,KAAK,YAAY,KAAK,SAAkB,CAAC,KAAK,UAAU,CAAC,CAAC,KAAK;CAE9E,OAAO;EACL,OAAO,MAAiB;GACtB,KAAK,QAAQ,SAAS,KAAK,IAAI,EAAE,QAAQ,eAAe,CAAC;EAE3D;EACA,SAAS,QAAQ,OAA+B;GAC9C,MAAM,MAA8B,CAAC;GACrC,KAAK,MAAM,QAAQ,KAAK,QAAQ,KAAK,GAAG;IACtC,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,GAAG;IAC5B,MAAM,OAAO,KAAK,OAAO,KAAK;IAC9B,MAAM,QAAQ,MAAM,IAAI;IACxB,IAAI,CAAC,OAAO;IACZ,IAAI,KAAK;KAAE,GAAG;KAAM,IAAI,KAAK;KAAI;KAAM;KAAO,MAAM;IAAK,CAAC;GAC5D;GACA,OAAO;EACT;EACA,UAAU,CAAC,OAAO;CACpB;AACF"}
@@ -1,7 +1,6 @@
1
- import { Ht as Actions, Rt as ActionDef } from "./queries-C75-wG1B.mjs";
2
- import { n as PickerItem } from "./picker-B-OxKKnD.mjs";
3
- import { o as CompletionSource } from "./autocomplete-CD30kSe_.mjs";
4
- //#region src/widgets/completions/actions.d.ts
1
+ import { Ht as Actions, Rt as ActionDef } from "./queries-Dmd3IjSd.mjs";
2
+ import { n as PickerItem } from "./picker-DsB6--GN.mjs";
3
+ import { o as CompletionSource } from "./autocomplete-wgceuhLr.mjs";
5
4
  /** Completion item produced by `actionsSource`. Carries the full
6
5
  * `ActionInfo` plus the action `id` so the source's `accept` can
7
6
  * dispatch without a secondary lookup. Items match the `MenuItem`
@@ -36,6 +35,5 @@ interface ActionsSourceOptions {
36
35
  * ```
37
36
  */
38
37
  declare function actionsSource(opts: ActionsSourceOptions): CompletionSource<ActionCompletionItem>;
39
- //#endregion
40
38
  export { ActionsSourceOptions as n, actionsSource as r, ActionCompletionItem as t };
41
- //# sourceMappingURL=actions--ODlgCQ5.d.mts.map
39
+ //# sourceMappingURL=actions-B0yyZ-Ww.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions-B0yyZ-Ww.d.mts","names":[],"sources":["../src/widgets/completions/actions.ts"],"mappings":";;;;;;;KAQY,uBAAuB,YAAY;EAAe;EAAY;;UAEzD;;EAEf,SAAS;;EAET,UAAU;;;EAGV,UAAU,YAAY,MAAM;;;;;;;;;;;;;;;;;;iBAmBd,cAAc,MAAM,uBAAuB,iBAAiB"}
@@ -1,7 +1,7 @@
1
- import { i as toHex, n as isHexColor, r as parseHex } from "./color-DBMQLv4Y.mjs";
1
+ import { i as toHex, n as isHexColor, r as parseHex } from "./color-Cr1VoL49.mjs";
2
2
  import { sliceAnsi } from "@zaly/shared/ansi";
3
3
  import { hasColors } from "@zaly/shared/env";
4
- //#region src/style/ansi.ts
4
+ // src/style/ansi.ts
5
5
  const OSC8 = "\x1B]8;;";
6
6
  const ST = "\x1B\\";
7
7
  const RESET = "\x1B[0m";
@@ -207,7 +207,6 @@ function ansiBg(str, idx) {
207
207
  }
208
208
  return bg;
209
209
  }
210
- //#endregion
211
210
  export { hyperlink as a, stripAnsiBg as c, applyDefaultColors as i, styleAnsi as l, ansiBg as n, openAnsi as o, ansiColor as r, reapplyStyle as s, RESET as t };
212
211
 
213
- //# sourceMappingURL=ansi-CMv71xVr.mjs.map
212
+ //# sourceMappingURL=ansi-CxgRPLA2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ansi-CMv71xVr.mjs","names":[],"sources":["../src/style/ansi.ts"],"sourcesContent":["import type { AnsiColor, AnsiStyle } from \"./types.ts\"\n\nimport { sliceAnsi } from \"@zaly/shared/ansi\"\nimport { hasColors } from \"@zaly/shared/env\"\nimport { isHexColor, parseHex, toHex } from \"./color.ts\"\n\n/** Optional wrap mode: `\"word\"` (default) breaks at word boundaries;\n * `\"char\"` hard-wraps mid-word. */\nexport interface WrapOpts {\n mode?: \"word\" | \"char\"\n}\n\n// ---- ANSI escape categories -------------------------------------------\n// OSC 8 hyperlink sequence. ESC + backslash is the \"string terminator\" (ST)\n// that closes the OSC. Format: `ESC]8;;URL ST TEXT ESC]8;; ST`.\nconst OSC8 = \"\\x1b]8;;\"\nconst ST = \"\\x1b\\\\\"\nexport const RESET = \"\\x1b[0m\"\n\n// Attribute → SGR code. Order matters for stable output.\nconst ATTRS = [\n [\"bold\", 1],\n [\"dim\", 2],\n [\"italic\", 3],\n [\"underline\", 4],\n [\"inverse\", 7],\n [\"strikethrough\", 9],\n] as const satisfies readonly (readonly [keyof AnsiStyle, number])[]\n\n// Standard 8-color ANSI palette. Offsets from SGR 30 (fg) and 40 (bg).\nconst ANSI_OFFSET: Record<string, number> = {\n black: 0,\n blue: 4,\n cyan: 6,\n green: 2,\n magenta: 5,\n red: 1,\n white: 7,\n yellow: 3,\n}\n\nconst ANSI_BG: Record<number, AnsiColor> = {\n 100: \"gray\", // or \"brightBlack\" if that exists\n 101: \"brightRed\",\n 102: \"brightGreen\",\n 103: \"brightYellow\",\n 104: \"brightBlue\",\n 105: \"brightMagenta\",\n 106: \"brightCyan\",\n 107: \"brightWhite\",\n 40: \"black\",\n 41: \"red\",\n 42: \"green\",\n 43: \"yellow\",\n 44: \"blue\",\n 45: \"magenta\",\n 46: \"cyan\",\n 47: \"white\",\n}\n\nconst notFound = Symbol(\"not found\")\nconst colorCache = new Map<string, string | typeof notFound>()\n\n/**\n * Wrap `text` in an OSC 8 hyperlink pointing at `url`. Modern terminals\n * (iTerm2, kitty, WezTerm, VS Code, Ghostty, …) render the text as\n * clickable while falling back gracefully to plain text elsewhere.\n *\n * Safe to nest ANSI SGR styling inside the `text` argument — OSC 8 is a\n * separate escape category and doesn't conflict.\n *\n * An empty `url` short-circuits and returns `text` unchanged, so callers\n * can unconditionally pipe link text through this helper.\n *\n * @internal\n */\nexport function hyperlink(url: string, text: string): string {\n if (url === \"\") return text\n return `${OSC8}${url}${ST}${text}${OSC8}${ST}`\n}\n\nexport function ansiColor(color: AnsiColor, kind: \"fg\" | \"bg\"): string | undefined {\n if (!hasColors) return\n const key = `${color}-${kind}`\n let cached = colorCache.get(key)\n if (cached === undefined) colorCache.set(key, (cached = _ansiColor(color, kind)) ?? notFound)\n return cached === notFound ? undefined : cached\n}\n\nfunction _ansiColor(color: AnsiColor, kind: \"fg\" | \"bg\"): string | undefined {\n if (color === \"inherit\") return\n // Gray aliases to brightBlack.\n if (color === \"gray\" || color === \"grey\") return String(kind === \"fg\" ? 90 : 100)\n\n const base = color in ANSI_OFFSET ? color : undefined\n if (base !== undefined) return String((kind === \"fg\" ? 30 : 40) + ANSI_OFFSET[base])\n\n if (color.startsWith(\"bright\")) {\n const rest = color.slice(\"bright\".length).toLowerCase()\n if (rest in ANSI_OFFSET) return String((kind === \"fg\" ? 90 : 100) + ANSI_OFFSET[rest])\n }\n\n const rgb = isHexColor(color) ? parseHex(color) : undefined\n if (rgb) {\n const indicator = kind === \"fg\" ? 38 : 48\n return `${indicator};2;${rgb[0]};${rgb[1]};${rgb[2]}`\n }\n}\n\nexport function openAnsi(style: AnsiStyle) {\n if (!hasColors) return \"\"\n const params: (number | string | undefined)[] = []\n for (const [key, code] of ATTRS) if (style[key]) params.push(code)\n if (style.fg !== undefined) params.push(ansiColor(style.fg, \"fg\"))\n if (style.bg !== undefined) params.push(ansiColor(style.bg, \"bg\"))\n const attrs = params.filter((p) => p !== undefined)\n if (attrs.length === 0) return \"\"\n return `\\x1b[${attrs.join(\";\")}m`\n}\n\nexport function styleAnsi(text: string, style?: AnsiStyle): string {\n if (!style) return text\n const open = openAnsi(style)\n if (open === \"\") return text\n return `${open}${text}${RESET}`\n}\n\n/**\n * Post-process a styled string so an outer style is re-applied after any\n * inner full-reset (`\\x1b[0m`). Without this, a child's reset clobbers\n * the parent's bg/fg/attrs for the remainder of the line.\n *\n * `escape` is the already-built SGR run to re-emit after each reset\n * (typically the return value of `openStyle(parentStyle, theme)`). If\n * empty, the input is returned unchanged.\n *\n * Inlined indexOf loop rather than `String.prototype.replaceAll` — the\n * manual version avoids the regex/object allocation overhead of\n * `replaceAll` and runs meaningfully faster on short strings (hot in\n * the builder's `apply`, called once per styled span). Pattern taken\n * from ansis's nested-style resolver.\n *\n * @internal\n */\nexport function reapplyStyle(s: string, escape: string): string {\n if (escape === \"\" || !s.includes(RESET)) return s\n const replacement = RESET + escape\n const searchLength = RESET.length\n let result = \"\"\n let lastPos = 0\n let pos = s.indexOf(RESET)\n while (pos !== -1) {\n result += s.slice(lastPos, pos) + replacement\n lastPos = pos + searchLength\n pos = s.indexOf(RESET, lastPos)\n }\n return result + s.slice(lastPos)\n}\n\n/** Resolve terminal-default color resets without changing explicit child colors. */\nexport function applyDefaultColors(text: string, fg: string, bg: string): string {\n if ((!fg && !bg) || !text.includes(\"\\x1b[\")) return text\n const fgParams = fg.slice(2, -1)\n const bgParams = bg.slice(2, -1)\n return text.replaceAll(/\\x1b\\[([\\d;:]*)m/g, (match, raw: string) => {\n const params = raw.split(\";\")\n const next: string[] = []\n let changed = false\n for (let i = 0; i < params.length; i++) {\n const param = params[i]\n const code = Number(param)\n if (code === 0) {\n next.push(param, ...[fgParams, bgParams].filter(Boolean))\n changed = true\n } else if (code === 39 && fgParams) {\n next.push(fgParams)\n changed = true\n } else if (code === 49 && bgParams) {\n next.push(bgParams)\n changed = true\n } else {\n next.push(param)\n // RGB components and palette indexes can themselves be 0, 39, or 49.\n if (code === 38 || code === 48 || code === 58) {\n let count = 0\n if (params[i + 1] === \"2\") count = 4\n else if (params[i + 1] === \"5\") count = 2\n next.push(...params.slice(i + 1, i + 1 + count))\n i += count\n }\n }\n }\n return changed ? `\\x1b[${next.join(\";\")}m` : match\n })\n}\n\nexport function stripAnsiBg(s: string): string {\n return s.replaceAll(/\\x1b\\[([0-9;]*)m/g, (match, raw: string) => {\n const next = stripBgParams(raw)\n if (next === raw) return match\n return next === \"\" ? \"\" : `\\x1b[${next}m`\n })\n}\n\nfunction stripBgParams(raw: string): string {\n if (raw === \"\") return raw\n const params = raw.split(\";\").map(Number)\n const ret: number[] = []\n for (let i = 0; i < params.length; i++) {\n const p = params[i]\n if ((p >= 40 && p <= 47) || (p >= 100 && p <= 107) || p === 49) continue\n if (p === 48) {\n const mode = params[i + 1]\n if (mode === 2) {\n i += 4\n continue\n }\n if (mode === 5) {\n i += 2\n continue\n }\n continue\n }\n ret.push(p)\n }\n return ret.join(\";\")\n}\n\nexport function ansiBg(str: string, idx: number): AnsiColor | undefined {\n const cell = sliceAnsi(str, idx, idx + 1)\n\n let bg: AnsiColor | undefined\n\n for (const match of cell.matchAll(/\\x1b\\[([0-9;]*)m/g)) {\n const params = match[1].split(\";\").map(Number)\n\n for (let i = 0; i < params.length; i++) {\n const p = params[i]\n\n if ((p >= 40 && p <= 47) || (p >= 100 && p <= 107)) {\n bg = ANSI_BG[p]\n } else if (p === 48 && params[i + 1] === 2) {\n bg = toHex(params[i + 2], params[i + 3], params[i + 4])\n i += 4\n }\n }\n }\n\n return bg\n}\n"],"mappings":";;;;AAeA,MAAM,OAAO;AACb,MAAM,KAAK;AACX,MAAa,QAAQ;AAGrB,MAAM,QAAQ;CACZ,CAAC,QAAQ,CAAC;CACV,CAAC,OAAO,CAAC;CACT,CAA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zB,OAAO,SAAS,KAAK,KAAK,QAAQ,KAAK;CACzC,CAAC;AACH;AAEA,SAAS,cAAc,KAAqB;CAC1C,IAAI,QAAQ,IAAI,OAAO;CACvB,MAAM,SAAS,IAAI,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CACxC,MAAM,MAAgB,CAAC;CACvB,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,IAAI,OAAO;EACjB,IAAK,KAAK,MAAM,KAAK,MAAQ,KAAK,OAAO,KAAK,OAAQ,MAAM,IAAI;EAChE,IAAI,MAAM,IAAI;GACZ,MAAM,OAAO,OAAO,IAAI;GACxB,IAAI,SAAS,GAAG;IACd,KAAK;IACL;GACF;GACA,IAAI,SAAS,GAAG;IACd,KAAK;IACL;GACF;GACA;EACF;EACA,IAAI,KAAK,CAAC;CACZ;CACA,OAAO,IAAI,KAAK,GAAG;AACrB;AAEA,SAAgB,OAAO,KAAa,KAAoC;CACtE,MAAM,OAAO,UAAU,KAAK,KAAK,MAAM,CAAC;CAExC,IAAI;CAEJ,KAAK,MAAM,SAAS,KAAK,SAAS,mBAAmB,GAAG;EACtD,MAAM,SAAS,MAAM,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;EAE7C,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;GACtC,MAAM,IAAI,OAAO;GAEjB,IAAK,KAAK,MAAM,KAAK,MAAQ,KAAK,OAAO,KAAK,KAC5C,KAAK,QAAQ;QACR,IAAI,MAAM,MAAM,OAAO,IAAI,OAAO,GAAG;IAC1C,KAAK,MAAM,OAAO,IAAI,IAAI,OAAO,IAAI,IAAI,OAAO,IAAI,EAAE;IACtD,KAAK;GACP;EACF;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"ansi-CxgRPLA2.mjs","names":[],"sources":["../src/style/ansi.ts"],"sourcesContent":["import type { AnsiColor, AnsiStyle } from \"./types.ts\"\n\nimport { sliceAnsi } from \"@zaly/shared/ansi\"\nimport { hasColors } from \"@zaly/shared/env\"\nimport { isHexColor, parseHex, toHex } from \"./color.ts\"\n\n/** Optional wrap mode: `\"word\"` (default) breaks at word boundaries;\n * `\"char\"` hard-wraps mid-word. */\nexport interface WrapOpts {\n mode?: \"word\" | \"char\"\n}\n\n// ---- ANSI escape categories -------------------------------------------\n// OSC 8 hyperlink sequence. ESC + backslash is the \"string terminator\" (ST)\n// that closes the OSC. Format: `ESC]8;;URL ST TEXT ESC]8;; ST`.\nconst OSC8 = \"\\x1b]8;;\"\nconst ST = \"\\x1b\\\\\"\nexport const RESET = \"\\x1b[0m\"\n\n// Attribute → SGR code. Order matters for stable output.\nconst ATTRS = [\n [\"bold\", 1],\n [\"dim\", 2],\n [\"italic\", 3],\n [\"underline\", 4],\n [\"inverse\", 7],\n [\"strikethrough\", 9],\n] as const satisfies readonly (readonly [keyof AnsiStyle, number])[]\n\n// Standard 8-color ANSI palette. Offsets from SGR 30 (fg) and 40 (bg).\nconst ANSI_OFFSET: Record<string, number> = {\n black: 0,\n blue: 4,\n cyan: 6,\n green: 2,\n magenta: 5,\n red: 1,\n white: 7,\n yellow: 3,\n}\n\nconst ANSI_BG: Record<number, AnsiColor> = {\n 100: \"gray\", // or \"brightBlack\" if that exists\n 101: \"brightRed\",\n 102: \"brightGreen\",\n 103: \"brightYellow\",\n 104: \"brightBlue\",\n 105: \"brightMagenta\",\n 106: \"brightCyan\",\n 107: \"brightWhite\",\n 40: \"black\",\n 41: \"red\",\n 42: \"green\",\n 43: \"yellow\",\n 44: \"blue\",\n 45: \"magenta\",\n 46: \"cyan\",\n 47: \"white\",\n}\n\nconst notFound = Symbol(\"not found\")\nconst colorCache = new Map<string, string | typeof notFound>()\n\n/**\n * Wrap `text` in an OSC 8 hyperlink pointing at `url`. Modern terminals\n * (iTerm2, kitty, WezTerm, VS Code, Ghostty, …) render the text as\n * clickable while falling back gracefully to plain text elsewhere.\n *\n * Safe to nest ANSI SGR styling inside the `text` argument — OSC 8 is a\n * separate escape category and doesn't conflict.\n *\n * An empty `url` short-circuits and returns `text` unchanged, so callers\n * can unconditionally pipe link text through this helper.\n *\n * @internal\n */\nexport function hyperlink(url: string, text: string): string {\n if (url === \"\") return text\n return `${OSC8}${url}${ST}${text}${OSC8}${ST}`\n}\n\nexport function ansiColor(color: AnsiColor, kind: \"fg\" | \"bg\"): string | undefined {\n if (!hasColors) return\n const key = `${color}-${kind}`\n let cached = colorCache.get(key)\n if (cached === undefined) colorCache.set(key, (cached = _ansiColor(color, kind)) ?? notFound)\n return cached === notFound ? undefined : cached\n}\n\nfunction _ansiColor(color: AnsiColor, kind: \"fg\" | \"bg\"): string | undefined {\n if (color === \"inherit\") return\n // Gray aliases to brightBlack.\n if (color === \"gray\" || color === \"grey\") return String(kind === \"fg\" ? 90 : 100)\n\n const base = color in ANSI_OFFSET ? color : undefined\n if (base !== undefined) return String((kind === \"fg\" ? 30 : 40) + ANSI_OFFSET[base])\n\n if (color.startsWith(\"bright\")) {\n const rest = color.slice(\"bright\".length).toLowerCase()\n if (rest in ANSI_OFFSET) return String((kind === \"fg\" ? 90 : 100) + ANSI_OFFSET[rest])\n }\n\n const rgb = isHexColor(color) ? parseHex(color) : undefined\n if (rgb) {\n const indicator = kind === \"fg\" ? 38 : 48\n return `${indicator};2;${rgb[0]};${rgb[1]};${rgb[2]}`\n }\n}\n\nexport function openAnsi(style: AnsiStyle) {\n if (!hasColors) return \"\"\n const params: (number | string | undefined)[] = []\n for (const [key, code] of ATTRS) if (style[key]) params.push(code)\n if (style.fg !== undefined) params.push(ansiColor(style.fg, \"fg\"))\n if (style.bg !== undefined) params.push(ansiColor(style.bg, \"bg\"))\n const attrs = params.filter((p) => p !== undefined)\n if (attrs.length === 0) return \"\"\n return `\\x1b[${attrs.join(\";\")}m`\n}\n\nexport function styleAnsi(text: string, style?: AnsiStyle): string {\n if (!style) return text\n const open = openAnsi(style)\n if (open === \"\") return text\n return `${open}${text}${RESET}`\n}\n\n/**\n * Post-process a styled string so an outer style is re-applied after any\n * inner full-reset (`\\x1b[0m`). Without this, a child's reset clobbers\n * the parent's bg/fg/attrs for the remainder of the line.\n *\n * `escape` is the already-built SGR run to re-emit after each reset\n * (typically the return value of `openStyle(parentStyle, theme)`). If\n * empty, the input is returned unchanged.\n *\n * Inlined indexOf loop rather than `String.prototype.replaceAll` — the\n * manual version avoids the regex/object allocation overhead of\n * `replaceAll` and runs meaningfully faster on short strings (hot in\n * the builder's `apply`, called once per styled span). Pattern taken\n * from ansis's nested-style resolver.\n *\n * @internal\n */\nexport function reapplyStyle(s: string, escape: string): string {\n if (escape === \"\" || !s.includes(RESET)) return s\n const replacement = RESET + escape\n const searchLength = RESET.length\n let result = \"\"\n let lastPos = 0\n let pos = s.indexOf(RESET)\n while (pos !== -1) {\n result += s.slice(lastPos, pos) + replacement\n lastPos = pos + searchLength\n pos = s.indexOf(RESET, lastPos)\n }\n return result + s.slice(lastPos)\n}\n\n/** Resolve terminal-default color resets without changing explicit child colors. */\nexport function applyDefaultColors(text: string, fg: string, bg: string): string {\n if ((!fg && !bg) || !text.includes(\"\\x1b[\")) return text\n const fgParams = fg.slice(2, -1)\n const bgParams = bg.slice(2, -1)\n return text.replaceAll(/\\x1b\\[([\\d;:]*)m/g, (match, raw: string) => {\n const params = raw.split(\";\")\n const next: string[] = []\n let changed = false\n for (let i = 0; i < params.length; i++) {\n const param = params[i]\n const code = Number(param)\n if (code === 0) {\n next.push(param, ...[fgParams, bgParams].filter(Boolean))\n changed = true\n } else if (code === 39 && fgParams) {\n next.push(fgParams)\n changed = true\n } else if (code === 49 && bgParams) {\n next.push(bgParams)\n changed = true\n } else {\n next.push(param)\n // RGB components and palette indexes can themselves be 0, 39, or 49.\n if (code === 38 || code === 48 || code === 58) {\n let count = 0\n if (params[i + 1] === \"2\") count = 4\n else if (params[i + 1] === \"5\") count = 2\n next.push(...params.slice(i + 1, i + 1 + count))\n i += count\n }\n }\n }\n return changed ? `\\x1b[${next.join(\";\")}m` : match\n })\n}\n\nexport function stripAnsiBg(s: string): string {\n return s.replaceAll(/\\x1b\\[([0-9;]*)m/g, (match, raw: string) => {\n const next = stripBgParams(raw)\n if (next === raw) return match\n return next === \"\" ? \"\" : `\\x1b[${next}m`\n })\n}\n\nfunction stripBgParams(raw: string): string {\n if (raw === \"\") return raw\n const params = raw.split(\";\").map(Number)\n const ret: number[] = []\n for (let i = 0; i < params.length; i++) {\n const p = params[i]\n if ((p >= 40 && p <= 47) || (p >= 100 && p <= 107) || p === 49) continue\n if (p === 48) {\n const mode = params[i + 1]\n if (mode === 2) {\n i += 4\n continue\n }\n if (mode === 5) {\n i += 2\n continue\n }\n continue\n }\n ret.push(p)\n }\n return ret.join(\";\")\n}\n\nexport function ansiBg(str: string, idx: number): AnsiColor | undefined {\n const cell = sliceAnsi(str, idx, idx + 1)\n\n let bg: AnsiColor | undefined\n\n for (const match of cell.matchAll(/\\x1b\\[([0-9;]*)m/g)) {\n const params = match[1].split(\";\").map(Number)\n\n for (let i = 0; i < params.length; i++) {\n const p = params[i]\n\n if ((p >= 40 && p <= 47) || (p >= 100 && p <= 107)) {\n bg = ANSI_BG[p]\n } else if (p === 48 && params[i + 1] === 2) {\n bg = toHex(params[i + 2], params[i + 3], params[i + 4])\n i += 4\n }\n }\n }\n\n return bg\n}\n"],"mappings":";;;;AAeA,MAAM,OAAO;AACb,MAAM,KAAK;AACX,MAAa,QAAQ;AAGrB,MAAM,QAAQ;CACZ,CAAC,QAAQ,CAAC;CACV,CAAC,OAAO,CAAC;CACT,CAAC,UAAU,CAAC;CACZ,CAAC,aAAa,CAAC;CACf,CAAC,WAAW,CAAC;CACb,CAAC,iBAAiB,CAAC;AACrB;AAGA,MAAM,cAAsC;CAC1C,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,SAAS;CACT,KAAK;CACL,OAAO;CACP,QAAQ;AACV;AAEA,MAAM,UAAqC;CACzC,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KA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O;EACjB,IAAK,KAAK,MAAM,KAAK,MAAQ,KAAK,OAAO,KAAK,OAAQ,MAAM,IAAI;EAChE,IAAI,MAAM,IAAI;GACZ,MAAM,OAAO,OAAO,IAAI;GACxB,IAAI,SAAS,GAAG;IACd,KAAK;IACL;GACF;GACA,IAAI,SAAS,GAAG;IACd,KAAK;IACL;GACF;GACA;EACF;EACA,IAAI,KAAK,CAAC;CACZ;CACA,OAAO,IAAI,KAAK,GAAG;AACrB;AAEA,SAAgB,OAAO,KAAa,KAAoC;CACtE,MAAM,OAAO,UAAU,KAAK,KAAK,MAAM,CAAC;CAExC,IAAI;CAEJ,KAAK,MAAM,SAAS,KAAK,SAAS,mBAAmB,GAAG;EACtD,MAAM,SAAS,MAAM,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;EAE7C,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;GACtC,MAAM,IAAI,OAAO;GAEjB,IAAK,KAAK,MAAM,KAAK,MAAQ,KAAK,OAAO,KAAK,KAC5C,KAAK,QAAQ;QACR,IAAI,MAAM,MAAM,OAAO,IAAI,OAAO,GAAG;IAC1C,KAAK,MAAM,OAAO,IAAI,IAAI,OAAO,IAAI,IAAI,OAAO,IAAI,EAAE;IACtD,KAAK;GACP;EACF;CACF;CAEA,OAAO;AACT"}
package/dist/ansi.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- import { r as AnsiStyle, t as AnsiColor } from "./types-C9ceMsbJ.mjs";
2
- //#region src/style/ansi.d.ts
1
+ import { r as AnsiStyle, t as AnsiColor } from "./types-ByMHEdCF.mjs";
3
2
  /** Optional wrap mode: `"word"` (default) breaks at word boundaries;
4
3
  * `"char"` hard-wraps mid-word. */
5
4
  export interface WrapOpts {
@@ -45,5 +44,4 @@ export declare function reapplyStyle(s: string, escape: string): string;
45
44
  export declare function applyDefaultColors(text: string, fg: string, bg: string): string;
46
45
  export declare function stripAnsiBg(s: string): string;
47
46
  export declare function ansiBg(str: string, idx: number): AnsiColor | undefined;
48
- //#endregion
49
47
  //# sourceMappingURL=ansi.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ansi.d.mts","names":[],"sources":["../src/style/ansi.ts"],"mappings":";;;;iBAQiB;EACf;;qBAQW;;;;;;;;;;;;;;wBA2DG,UAAU,aAAa;wBAKvB,UAAU,OAAO,WAAW;wBA4B5B,SAAS,OAAO;wBAWhB,UAAU,cAAc,QAAQ;;;;;;;;;;;;;;;;;;wBAwBhC,aAAa,WAAW;;wBAgBxB,mBAAmB,cAAc,YAAY;wBAoC7C,YAAY;wBAgCZ,OAAO,aAAa,cAAc"}
1
+ {"version":3,"file":"ansi.d.mts","names":[],"sources":["../src/style/ansi.ts"],"mappings":";;;iBAQiB;EACf;;qBAQW;;;;;;;;;;;;;;wBA2DG,UAAU,aAAa;wBAKvB,UAAU,OAAO,WAAW;wBA4B5B,SAAS,OAAO;wBAWhB,UAAU,cAAc,QAAQ;;;;;;;;;;;;;;;;;;wBAwBhC,aAAa,WAAW;;wBAgBxB,mBAAmB,cAAc,YAAY;wBAoC7C,YAAY;wBAgCZ,OAAO,aAAa,cAAc"}
package/dist/ansi.mjs CHANGED
@@ -1 +1 @@
1
- export { t as RESET, n as ansiBg, r as ansiColor, i as applyDefaultColors, a as hyperlink, o as openAnsi, s as reapplyStyle, c as stripAnsiBg, l as styleAnsi } from "./ansi-CMv71xVr.mjs";
1
+ export { t as RESET, n as ansiBg, r as ansiColor, i as applyDefaultColors, a as hyperlink, o as openAnsi, s as reapplyStyle, c as stripAnsiBg, l as styleAnsi } from "./ansi-CxgRPLA2.mjs";
@@ -1,8 +1,7 @@
1
- import { $ as StyleState, I as RenderCtx, at as Ref, h as Node, it as Reactive, m as BaseEvents } from "./queries-C75-wG1B.mjs";
2
- import { t as Input } from "./input-NuD8TH8N.mjs";
3
- import { n as SearchOptions, t as SearchItems } from "./search-FvGnswRl.mjs";
4
- import { i as Select, n as OptionRender, t as Option } from "./select-BKE5LzdN.mjs";
5
- //#region src/widgets/autocomplete.d.ts
1
+ import { $ as StyleState, I as RenderCtx, at as Ref, h as Node, it as Reactive, m as BaseEvents } from "./queries-Dmd3IjSd.mjs";
2
+ import { t as Input } from "./input-C3kfYoEJ.mjs";
3
+ import { n as SearchOptions, t as SearchItems } from "./search-DsHzamic.mjs";
4
+ import { i as Select, n as OptionRender, t as Option } from "./select-BZCFXdjp.mjs";
6
5
  /** Called when the user picks `item` from this source. Return a string
7
6
  * to insert in place of the trigger + query range, or `undefined`
8
7
  * when the source handled the selection itself (dispatched an action,
@@ -95,6 +94,5 @@ declare class Autocomplete extends Node<AutocompleteState, AutocompleteEvents> {
95
94
  * Factory for `Autocomplete`. See the class doc for the full API.
96
95
  */
97
96
  declare function autocomplete(opts: AutocompleteOptions): Autocomplete;
98
- //#endregion
99
97
  export { AutocompleteState as a, AutocompleteOptions as i, Autocomplete as n, CompletionSource as o, AutocompleteEvents as r, autocomplete as s, AcceptFn as t };
100
- //# sourceMappingURL=autocomplete-CD30kSe_.d.mts.map
98
+ //# sourceMappingURL=autocomplete-wgceuhLr.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autocomplete-wgceuhLr.d.mts","names":[],"sources":["../src/widgets/autocomplete.ts"],"mappings":";;;;;;;;KAgBY,SAAS,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;UAkBnB,iBAAiB,UAAU,SAAS;EACnD,mBAAmB;EACnB,UAAU,SAAS,YAAY;EAC/B,SAAS,SAAS;EAClB,SAAS,aAAa;;UAIP,0BAA0B;UAE1B,4BAA4B;;;;;;;EAO3C,OAAO,QAAQ,IAAI;EAMnB,SAAS,eAAe;;EAExB,YAAY;EACZ,UAAU;EACV;;UAGe,2BAA2B;;;;EAI1C;IAAY;IAAgB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA6CvB,qBAAqB,KAAK,mBAAmB;;kBACxC;WACE;WAET,QAAQ;EAKjB,YAAY,MAAM;MAoDd;YAiFM,QAAQ,KAAK,uBAAuB;;;;;iBAmBhC,aAAa,MAAM,sBAAsB"}
@@ -1,10 +1,10 @@
1
- import { S as unwrap } from "./reactive-f7NpAi69.mjs";
2
- import { t as Node } from "./node-BZ7f6HzU.mjs";
3
- import { n as resolveSize, t as clamp } from "./size-D8JogYLy.mjs";
4
- import { a as zipRow, i as stackColumn, n as isFixedWidth, r as padRow, t as allocateRow } from "./flex-Bguo-fUe.mjs";
5
- import { r as textContent } from "./text-DPrhma4x.mjs";
1
+ import { S as unwrap } from "./reactive-DkP75TPk.mjs";
2
+ import { t as Node } from "./node-CXNobGaP.mjs";
3
+ import { n as resolveSize, t as clamp } from "./size-BHRJuRk9.mjs";
4
+ import { a as zipRow, i as stackColumn, n as isFixedWidth, r as padRow, t as allocateRow } from "./flex-CYp4etqn.mjs";
5
+ import { r as textContent } from "./text-BArwVVkg.mjs";
6
6
  import { sliceAnsi, stringWidth } from "@zaly/shared/ansi";
7
- //#region src/layout/border.ts
7
+ // src/layout/border.ts
8
8
  /** @internal */
9
9
  const borders = {
10
10
  double: {
@@ -104,8 +104,7 @@ function truncate(s, width) {
104
104
  if (width <= 1) return "…".repeat(width);
105
105
  return `${sliceAnsi(s, 0, width - 1)}…`;
106
106
  }
107
- //#endregion
108
- //#region src/widgets/box.ts
107
+ // src/widgets/box.ts
109
108
  var Box = class extends Node {
110
109
  async _render(ctx) {
111
110
  const style = this.state;
@@ -387,7 +386,6 @@ function resolvePadding(p) {
387
386
  p[3]
388
387
  ];
389
388
  }
390
- //#endregion
391
389
  export { box as n, Box as t };
392
390
 
393
- //# sourceMappingURL=box-C_N_7ChP.mjs.map
391
+ //# sourceMappingURL=box-DToDoXlU.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"box-C_N_7ChP.mjs","names":[],"sources":["../src/layout/border.ts","../src/widgets/box.ts"],"sourcesContent":["import type { StyleBuilder } from \"../style/builder.ts\"\n\nimport { sliceAnsi, stringWidth } from \"@zaly/shared/ansi\"\n\n/**\n * Border-character glyphs for drawing a box outline. Any single-cell string\n * is allowed (including multi-byte glyphs like rounded corners).\n */\nexport interface BorderChars {\n h: string\n v: string\n tl: string\n tr: string\n bl: string\n br: string\n}\n\nexport type BorderSpec = boolean | \"single\" | \"double\" | \"rounded\" | BorderChars\n\n/** @internal */\nexport const borders = {\n double: { bl: \"╚\", br: \"╝\", h: \"═\", tl: \"╔\", tr: \"╗\", v: \"║\" },\n rounded: { bl: \"╰\", br: \"╯\", h: \"─\", tl: \"╭\", tr: \"╮\", v: \"│\" },\n single: { bl: \"└\", br: \"┘\", h: \"─\", tl: \"┌\", tr: \"┐\", v: \"│\" },\n} as const satisfies Record<string, BorderChars>\n\n/** Resolve the `border` style value to a concrete BorderChars, or undefined.\n *\n * @internal*/\nexport function resolveBorder(spec: BorderSpec | undefined): BorderChars | undefined {\n if (spec === undefined || spec === false) return undefined\n if (spec === true) return borders.single\n if (typeof spec === \"string\") return borders[spec]\n return spec\n}\n\nexport type TitleAlign = \"left\" | \"center\" | \"right\"\n\nexport interface DrawBorderOpts {\n /**\n * Optional title embedded in the top border, with a single-cell space on\n * each side. Ellipsis-truncated when it overflows the budget.\n */\n title?: string\n /** Placement of `title` along the top border. Defaults to `\"left\"`. */\n titleAlign?: TitleAlign\n /**\n * Styled wrapper applied to the border glyphs (corners, horizontal,\n * vertical). Use `ctx.style.add(slotOrStyle)` at the call site so the\n * theme is resolved once per render.\n */\n borderStyle?: StyleBuilder\n /** Styled wrapper applied to the title text (including the padding spaces). */\n titleStyle?: StyleBuilder\n}\n\n/** Pass-through wrapper used when no style is supplied. */\nconst identity = (s: string): string => s\n\n/**\n * Wrap pre-rendered inner rows with a border, adding top/bottom border rows\n * and left/right border chars to each inner row. Inner rows must be padded\n * to a uniform width; the output rows are `innerWidth + 2` wide.\n *\n * Border glyphs and the optional title can be styled independently via\n * `borderStyle` / `titleStyle` — each is a pre-bound `StyleBuilder`, so\n * this helper stays purely about geometry and never touches SGR itself.\n *\n * @internal\n */\nexport function drawBorder(\n rows: readonly string[],\n chars: BorderChars,\n opts: DrawBorderOpts = {}\n): string[] {\n const { title, titleAlign } = opts\n const inner = rows.length > 0 ? stringWidth(rows[0]) : 0\n const wrapB = opts.borderStyle ?? identity\n const wrapT = opts.titleStyle ?? identity\n\n const out: string[] = []\n out.push(topRow({ align: titleAlign ?? \"left\", chars, inner, title, wrapB, wrapT }))\n const v = wrapB(chars.v)\n for (const row of rows) out.push(v + row + v)\n out.push(wrapB(chars.bl + chars.h.repeat(inner) + chars.br))\n return out\n}\n\ninterface TopRowArgs {\n align: TitleAlign\n chars: BorderChars\n inner: number\n title: string | undefined\n wrapB: (s: string) => string\n wrapT: (s: string) => string\n}\n\nfunction topRow({ align, chars, inner, title, wrapB, wrapT }: TopRowArgs): string {\n if (title === undefined || title === \"\") {\n return wrapB(chars.tl + chars.h.repeat(inner) + chars.tr)\n }\n // Chrome: h + space + title + space + h (4 cells of chrome around the title)\n const budget = inner - 4\n if (budget <= 0) return wrapB(chars.tl + chars.h.repeat(inner) + chars.tr)\n const shown = truncate(title, budget)\n const totalH = inner - 2 - stringWidth(shown)\n const { leading, trailing } = distributeH(totalH, align)\n const prefix = wrapB(`${chars.tl}${chars.h.repeat(leading)}`)\n const titleSeg = wrapT(` ${shown} `)\n const suffix = wrapB(`${chars.h.repeat(trailing)}${chars.tr}`)\n return prefix + titleSeg + suffix\n}\n\nfunction distributeH(totalH: number, align: TitleAlign): { leading: number; trailing: number } {\n if (align === \"left\") return { leading: 1, trailing: totalH - 1 }\n if (align === \"right\") return { leading: totalH - 1, trailing: 1 }\n // center: leading rounds down so odd slack biases the title slightly left.\n const leading = Math.floor(totalH / 2)\n return { leading, trailing: totalH - leading }\n}\n\nfunction truncate(s: string, width: number): string {\n if (stringWidth(s) <= width) return s\n if (width <= 1) return \"…\".repeat(width)\n return `${sliceAnsi(s, 0, width - 1)}…`\n}\n","import type { RenderCtx } from \"../core/ctx.ts\"\nimport type { State } from \"../core/state.ts\"\nimport type { BorderSpec, TitleAlign } from \"../layout/border.ts\"\nimport type { RowItem } from \"../layout/flex.ts\"\nimport type { AnyStyle, Style } from \"../style/types.ts\"\nimport type { TextContent } from \"./text.ts\"\n\nimport { stringWidth } from \"@zaly/shared/ansi\"\nimport { Node } from \"../core/node.ts\"\nimport { unwrap } from \"../core/reactive.ts\"\nimport { drawBorder, resolveBorder } from \"../layout/border.ts\"\nimport { allocateRow, isFixedWidth, padRow, stackColumn, zipRow } from \"../layout/flex.ts\"\nimport { clamp, resolveSize } from \"../layout/size.ts\"\nimport { textContent } from \"./text.ts\"\n\nexport type Padding =\n | number\n | readonly [v: number, h: number]\n | readonly [t: number, r: number, b: number, l: number]\n\nexport interface BoxStyle extends Style {\n flexDirection?: \"row\" | \"column\"\n gap?: number\n /** Fixed outer height in rows. When unset, the box's height emerges\n * naturally from its content + padding + border. When set, the\n * content area is truncated or padded with blank rows to land at\n * exactly this many rows of *outer* height. Pair with\n * `verticalAlign` to control which edge is anchored. */\n height?: number\n /** Anchor for the content when `height` truncates or extends.\n * `\"top\"` (default) keeps the top edge: extra rows added at the\n * bottom, overflow truncated from the bottom. `\"bottom\"` keeps the\n * bottom edge: extra rows prepended, overflow truncated from the\n * top. Other CSS-like values (`middle`) are not implemented. */\n verticalAlign?: \"top\" | \"bottom\"\n padding?: Padding\n border?: BorderSpec\n borderTitle?: TextContent\n /** Placement of `borderTitle` along the top border. Defaults to `\"left\"`. */\n borderTitleAlign?: TitleAlign\n /**\n * Style applied to the border glyphs. Either a theme slot name (resolved\n * via the active theme) or an inline `Style`. Defaults to the `\"border\"`\n * theme slot when a border is drawn.\n */\n borderStyle?: AnyStyle\n /**\n * Style applied to the border title. Defaults to the `\"borderTitle\"` theme\n * slot when a title is set.\n */\n borderTitleStyle?: AnyStyle\n}\n\nexport class Box<T extends object = {}> extends Node<BoxStyle & T> {\n protected async _render(ctx: RenderCtx): Promise<string[]> {\n const style = this.state\n\n const [padT, padR, padB, padL] = resolvePadding(style.padding)\n const bchars = resolveBorder(style.border)\n const hasBorder = bchars !== undefined\n const chrome = padL + padR + (hasBorder ? 2 : 0)\n\n let outer: number\n let contentRows: string[]\n let inner: number\n\n if (style.width === \"fit\") {\n // `fit`: render children at the parent's max inner width, measure\n // the natural max-row width, then clamp the box to that. Two-pass\n // — the first pass uses the upper bound as a measuring window,\n // the second re-pads each row to the chosen inner width.\n const upper = Math.max(0, ctx.width - chrome)\n const tentative = await this.#layoutChildren(upper, ctx)\n const natural = tentative.reduce((m, r) => Math.max(m, stringWidth(r)), 0)\n const fit = Math.min(ctx.width, natural + chrome)\n outer = clamp(fit, {\n available: ctx.width,\n max: style.maxWidth,\n min: style.minWidth,\n })\n inner = Math.max(0, outer - chrome)\n contentRows = tentative\n } else {\n const requested = resolveSize(style.width ?? \"fill\", ctx.width) ?? ctx.width\n outer = clamp(requested, {\n available: ctx.width,\n max: style.maxWidth,\n min: style.minWidth,\n })\n inner = Math.max(0, outer - chrome)\n contentRows = await this.#layoutChildren(inner, ctx)\n }\n\n const paddedWidth = Math.max(0, outer - (hasBorder ? 2 : 0))\n\n // Ensure each content row is exactly `inner` cells wide (absorbs slack).\n contentRows = contentRows.map((row) => padRow(row, inner))\n\n // Horizontal padding.\n if (padL > 0 || padR > 0) {\n const lp = \" \".repeat(padL)\n const rp = \" \".repeat(padR)\n contentRows = contentRows.map((row) => lp + row + rp)\n }\n\n // Vertical padding.\n const blank = \" \".repeat(paddedWidth)\n const top = Array.from({ length: padT }, () => blank)\n const bot = Array.from({ length: padB }, () => blank)\n let rows = [...top, ...contentRows, ...bot]\n\n // Fixed-height fit. The `height` field is the outer dimension —\n // border takes its 2 rows out before we measure against the\n // content area; padding is already baked into `rows`. `verticalAlign`\n // decides which end gets clipped (when too tall) or padded (when\n // too short). Default `\"top\"` matches the natural reading flow.\n if (style.height !== undefined) {\n const innerH = Math.max(0, style.height - (hasBorder ? 2 : 0))\n if (rows.length > innerH) {\n rows = style.verticalAlign === \"bottom\" ? rows.slice(-innerH) : rows.slice(0, innerH)\n } else if (rows.length < innerH) {\n const filler = Array.from({ length: innerH - rows.length }, () => blank)\n rows = style.verticalAlign === \"bottom\" ? [...filler, ...rows] : [...rows, ...filler]\n }\n }\n\n if (bchars) {\n rows = drawBorder(rows, bchars, {\n borderStyle: ctx.style.add(style.borderStyle ?? \"border\"),\n title: await textContent(style.borderTitle, ctx),\n titleAlign: style.borderTitleAlign,\n titleStyle: ctx.style.add(style.borderTitleStyle ?? \"borderTitle\"),\n })\n }\n\n const wrap = ctx.style.add(style)\n return rows.map((row) => wrap(row))\n }\n\n /**\n * Intrinsic content width derived from children (or the explicit\n * `width` when fixed). Lets parent flex containers size this Box\n * without falling back to a measure-render — important for\n * side-effecting children like `Image` whose first render allocates\n * a KGP placement: rendering twice would emit two placements and the\n * second render's `transmitOnce` returns no bytes, so the bytes from\n * the discarded measure pass would be lost.\n *\n * Row direction → bases sum (plus gaps). Column direction → bases\n * max. Both add chrome (padding + border) at the end.\n *\n * Children without `layout()` contribute 0 — the row allocator's\n * render-measure fallback still kicks in for them at allocation\n * time, but their absence here just means this Box reports a\n * smaller intrinsic. That's the safe direction: under-report and\n * let shrink/grow handle slack, never over-report.\n */\n override async layout(ctx: RenderCtx) {\n const s = this.state\n const [, padR, , padL] = resolvePadding(s.padding)\n const chrome = padL + padR + (resolveBorder(s.border) ? 2 : 0)\n\n // Fixed width wins outright.\n if (isFixedWidth(s.width)) {\n const w = resolveSize(s.width, ctx.width) ?? 0\n return { minWidth: w, width: w }\n }\n\n const kids = layoutNodes(this.children)\n if (kids.length === 0) return { minWidth: chrome, width: chrome }\n\n const isRow = (s.flexDirection ?? \"column\") === \"row\"\n const totalGap = isRow ? (s.gap ?? 0) * Math.max(0, kids.length - 1) : 0\n\n let widthAcc = 0\n let minAcc = 0\n for (const k of kids) {\n // oxlint-disable-next-line no-await-in-loop\n const l = (await k.getLayout(ctx)) ?? { minWidth: 0, width: 0 }\n if (isRow) {\n widthAcc += l.width\n minAcc += l.minWidth\n } else {\n widthAcc = Math.max(widthAcc, l.width)\n minAcc = Math.max(minAcc, l.minWidth)\n }\n }\n\n return { minWidth: minAcc + totalGap + chrome, width: widthAcc + totalGap + chrome }\n }\n\n async #layoutChildren(innerWidth: number, ctx: RenderCtx): Promise<string[]> {\n const children = layoutNodes(this.children)\n if (children.length === 0) return []\n const gap = this.state.gap ?? 0\n return (this.state.flexDirection ?? \"column\") === \"row\"\n ? this.#layoutRow(children, innerWidth, ctx, gap)\n : this.#layoutColumn(children, innerWidth, ctx, gap)\n }\n\n /**\n * Row direction — main axis is horizontal. CSS-style flex:\n * each child sizes to its intrinsic content width unless it claims\n * slack via `flexGrow > 0` or `width: \"fill\"`. Slack distributes by\n * grow weights; deficit distributes by `basis * flexShrink` clamped\n * at each child's `min-content` floor.\n *\n * Sizing strategy per child:\n * 1. `node.layout(ctx)` — sync, content-derived. If implemented,\n * use directly; no render needed for measurement.\n * 2. Otherwise fall back to render-at-innerWidth and measure the\n * widest emitted row. Cached; the paint pass reuses the result\n * whenever the allocated width matches the measurement width.\n *\n * In `fit` mode the parent has no slack to give, so the allocator's\n * available is capped at the natural sum.\n */\n async #layoutRow(\n children: readonly Node[],\n innerWidth: number,\n ctx: RenderCtx,\n gap: number\n ): Promise<string[]> {\n // Phase 1: figure out each child's intrinsic size.\n // - `layout()` short-circuits — sync, no render.\n // - Fallback: render at the upper bound (innerWidth or fixed spec)\n // and measure rows.\n const intrinsics = await Promise.all(children.map((c) => c.getLayout(ctx)))\n // For children with intrinsic sizing, skip the measure render\n // entirely. Others fall back to render-at-upper-bound (their fixed\n // width, or innerWidth if fluid).\n const measureWidths = children.map((c, i) => {\n if (intrinsics[i] !== undefined) return -1\n if (isFixedWidth(c.state.width)) {\n return resolveSize(c.state.width, innerWidth) ?? innerWidth\n }\n return innerWidth\n })\n const measureRows = await Promise.all(\n children.map((c, i): Promise<string[] | undefined> => {\n if (measureWidths[i] === -1) return Promise.resolve(undefined)\n return c.render({ ...ctx, width: measureWidths[i] })\n })\n )\n const naturals = children.map((c, i) => {\n // A fixed `state.width` is what the allocator will actually\n // assign this child — use it directly so the fit-mode\n // `allocAvailable` sum below matches what we'll consume. Falling\n // back to intrinsic when there's no override under-reports a\n // child like `text(\"x\", { width: 2 })` and shrinks every sibling\n // by the missing cells.\n if (isFixedWidth(c.state.width)) {\n return resolveSize(c.state.width, innerWidth) ?? 0\n }\n const intr = intrinsics[i]\n if (intr) return intr.width\n return (measureRows[i] ?? []).reduce((m, r) => Math.max(m, stringWidth(r)), 0)\n })\n const items: RowItem[] = children.map((c, i) => {\n const s = c.state\n return {\n flexGrow: s.flexGrow,\n flexShrink: s.flexShrink,\n intrinsicMin: intrinsics[i]?.minWidth,\n maxWidth: s.maxWidth,\n minWidth: s.minWidth,\n natural: naturals[i],\n width: s.width,\n }\n })\n const allocAvailable =\n this.state.width === \"fit\"\n ? naturals.reduce((a, b) => a + b, 0) + gap * Math.max(0, children.length - 1)\n : innerWidth\n const widths = allocateRow(items, { contentWidth: allocAvailable, gap })\n // Phase 2: paint at allocated widths. Reuse the measure-render when\n // the allocation matches; otherwise render fresh (cached).\n const childRows = await Promise.all(\n children.map((c, i): Promise<string[]> => {\n const cached = measureRows[i]\n if (cached !== undefined && widths[i] === measureWidths[i]) {\n return Promise.resolve(cached)\n }\n return c.render({ ...ctx, width: widths[i] })\n })\n )\n // `zipRow` expects rows to be exactly `widths[i]` wide. Children\n // that emit natural-width rows (text default, code default) get\n // padded here so the contract holds; over-wide rows get clipped.\n const padded = childRows.map((rows, i) => rows.map((row) => padRow(row, widths[i])))\n return zipRow(padded, { gap, widths })\n }\n\n /**\n * Column direction — main axis is vertical, cross axis horizontal.\n * Per CSS `align-items: stretch` (default), children with no\n * explicit `width` fill the cross axis. A child with a fixed `width`\n * (number / `Pct`) takes that width as its cross-axis size, with the\n * leftover padded as right slack (default `flex-start`). `min`/`max`\n * clamp the resolved width.\n *\n * In fit-mode (`width: \"fit\"`), the cross-axis target shrinks to the\n * widest child row instead of stretching to `innerWidth` — symmetric\n * to how row-direction caps allocator-available at the natural sum.\n */\n async #layoutColumn(\n children: readonly Node[],\n innerWidth: number,\n ctx: RenderCtx,\n gap: number\n ): Promise<string[]> {\n const widths = children.map((c) => {\n const s = c.state\n const fixed = isFixedWidth(s.width) ? resolveSize(s.width, innerWidth) : undefined\n const w = fixed ?? innerWidth\n return clamp(w, { available: innerWidth, max: s.maxWidth, min: s.minWidth })\n })\n const childRows = await Promise.all(\n children.map((c, i) => c.render({ ...ctx, width: widths[i] }))\n )\n const target =\n this.state.width === \"fit\"\n ? childRows.reduce((m, rows) => rows.reduce((mm, r) => Math.max(mm, stringWidth(r)), m), 0)\n : innerWidth\n // Pad each child's rows to the cross-axis target. For full-stretch\n // children this absorbs natural-row slack; for fixed-width\n // children it adds right-side slack (default `flex-start`\n // alignment). `stackColumn`'s contract requires uniform width.\n const padded = childRows.map((rows) => rows.map((row) => padRow(row, target)))\n return stackColumn(padded, { gap, width: target })\n }\n}\n\ntype Child = Node | false | null | undefined\n\n/**\n * Factory for `Box`. The style object is required (use `{}` if you don't\n * need any styling) — the previous style-less overload caused TS to fail\n * to discriminate between a Node child and an inferred-empty-state node\n * like `WidgetNode`. Pass `box({}, child1, child2)` for un-styled boxes.\n *\n * Falsy children (`false`, `null`, `undefined`) are filtered out, enabling\n * conditional JSX-like composition: `box({}, cond && child)`.\n */\nexport function box(style: State<BoxStyle>, ...children: Child[]): Box {\n const b = new Box(style)\n for (const c of children) if (c) b.add(c)\n return b\n}\n\n/**\n * Flatten fragment nodes (those that implement the `layoutChildren`\n * protocol — `show`, `errorBoundary`, `suspense`) into their currently\n * active leaves. Recursive: a fragment whose `layoutChildren()`\n * itself contains fragments unfolds completely.\n *\n * The fragment Node still lives in the tree (mounted, propagating\n * invalidates) — layout just sees through it so its children share\n * the parent box's flex distribution, gap, and cross-axis sizing\n * instead of collapsing into a single slot.\n */\nfunction layoutNodes(children: readonly Node[]): readonly Node[] {\n return children.flatMap((c) => c.layoutNodes).filter((c) => unwrap(c.state.visible) ?? true)\n}\n\nfunction resolvePadding(p: Padding | undefined): [t: number, r: number, b: number, l: number] {\n if (p === undefined) return [0, 0, 0, 0]\n if (typeof p === \"number\") return [p, p, p, p]\n if (p.length === 2) return [p[0], p[1], p[0], p[1]]\n return [p[0], p[1], p[2], p[3]]\n}\n"],"mappings":";;;;;;;;AAoBA,MAAa,UAAU;CACrB,QAAQ;EAAE,IAAI;EAAK,IAAI;EAAK,GAAG;EAAK,IAAI;EAAK,IAAI;EAAK,GAAG;CAAI;CAC7D,SAAS;EAAE,IAAI;EAAK,IAAI;EAAK,GAAG;EAAK,IAAI;EAAK,IAAI;EAAK,GAAG;CAAI;CAC9D,QAAQ;EAAE,IAAI;EAAK,IAAI;EAAK,GAAG;EAAK,IAAI;EAAK,IAAI;EAAK,GAAG;CAAI;AAC/D;;;;AAKA,SAAgB,cAAc,MAAuD;CACnF,IAAI,SAAS,KAAA,KAAa,SAAS,OAAO,OAAO,KAAA;CACjD,IAAI,SAAS,MAAM,OAAO,QAAQ;CAClC,IAAI,OAAO,SAAS,UAAU,OAAO,QAAQ;CAC7C,OAAO;AACT;;AAuBA,MAAM,YAAY,MAAsB;;;;;;;;;;;;AAaxC,SAAgB,WACd,MACA,OACA,OAAuB,CAAC,GACd;CACV,MAAM,EAAE,OAAO,eAAe;CAC9B,MAAM,QAAQ,KAAK,SAAS,IAAI,YAAY,KAAK,EAAE,IAAI;CACvD,MAAM,QAAQ,KAAK,eAAe;CAClC,MAAM,QAAQ,KAAK,cAAc;CAEjC,MAAM,MAAgB,CAAC;CACvB,IAAI,KAAK,OAAO;EAAE,OAAO,cAAc;EAAQ;EAAO;EAAO;EAAO;EAAO;CAAM,CAAC,CAAC;CACnF,MAAM,IAAI,MAAM,MAAM,CAAC;CACvB,KAAK,MAAM,OAAO,MAAM,IAAI,KAAK,IAAI,MAAM,CAAC;CAC5C,IAAI,KAAK,MAAM,MAAM,KAAK,MAAM,EAAE,OAAO,KAAK,IAAI,MAAM,EAAE,C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,MAAM,UAAU,OAAO;EAAC;EAAG;EAAG;EAAG;CAAC;CAC7C,IAAI,EAAE,WAAW,GAAG,OAAO;EAAC,EAAE;EAAI,EAAE;EAAI,EAAE;EAAI,EAAE;CAAE;CAClD,OAAO;EAAC,EAAE;EAAI,EAAE;EAAI,EAAE;EAAI,EAAE;CAAE;AAChC"}
1
+ {"version":3,"file":"box-DToDoXlU.mjs","names":[],"sources":["../src/layout/border.ts","../src/widgets/box.ts"],"sourcesContent":["import type { StyleBuilder } from \"../style/builder.ts\"\n\nimport { sliceAnsi, stringWidth } from \"@zaly/shared/ansi\"\n\n/**\n * Border-character glyphs for drawing a box outline. Any single-cell string\n * is allowed (including multi-byte glyphs like rounded corners).\n */\nexport interface BorderChars {\n h: string\n v: string\n tl: string\n tr: string\n bl: string\n br: string\n}\n\nexport type BorderSpec = boolean | \"single\" | \"double\" | \"rounded\" | BorderChars\n\n/** @internal */\nexport const borders = {\n double: { bl: \"╚\", br: \"╝\", h: \"═\", tl: \"╔\", tr: \"╗\", v: \"║\" },\n rounded: { bl: \"╰\", br: \"╯\", h: \"─\", tl: \"╭\", tr: \"╮\", v: \"│\" },\n single: { bl: \"└\", br: \"┘\", h: \"─\", tl: \"┌\", tr: \"┐\", v: \"│\" },\n} as const satisfies Record<string, BorderChars>\n\n/** Resolve the `border` style value to a concrete BorderChars, or undefined.\n *\n * @internal*/\nexport function resolveBorder(spec: BorderSpec | undefined): BorderChars | undefined {\n if (spec === undefined || spec === false) return undefined\n if (spec === true) return borders.single\n if (typeof spec === \"string\") return borders[spec]\n return spec\n}\n\nexport type TitleAlign = \"left\" | \"center\" | \"right\"\n\nexport interface DrawBorderOpts {\n /**\n * Optional title embedded in the top border, with a single-cell space on\n * each side. Ellipsis-truncated when it overflows the budget.\n */\n title?: string\n /** Placement of `title` along the top border. Defaults to `\"left\"`. */\n titleAlign?: TitleAlign\n /**\n * Styled wrapper applied to the border glyphs (corners, horizontal,\n * vertical). Use `ctx.style.add(slotOrStyle)` at the call site so the\n * theme is resolved once per render.\n */\n borderStyle?: StyleBuilder\n /** Styled wrapper applied to the title text (including the padding spaces). */\n titleStyle?: StyleBuilder\n}\n\n/** Pass-through wrapper used when no style is supplied. */\nconst identity = (s: string): string => s\n\n/**\n * Wrap pre-rendered inner rows with a border, adding top/bottom border rows\n * and left/right border chars to each inner row. Inner rows must be padded\n * to a uniform width; the output rows are `innerWidth + 2` wide.\n *\n * Border glyphs and the optional title can be styled independently via\n * `borderStyle` / `titleStyle` — each is a pre-bound `StyleBuilder`, so\n * this helper stays purely about geometry and never touches SGR itself.\n *\n * @internal\n */\nexport function drawBorder(\n rows: readonly string[],\n chars: BorderChars,\n opts: DrawBorderOpts = {}\n): string[] {\n const { title, titleAlign } = opts\n const inner = rows.length > 0 ? stringWidth(rows[0]) : 0\n const wrapB = opts.borderStyle ?? identity\n const wrapT = opts.titleStyle ?? identity\n\n const out: string[] = []\n out.push(topRow({ align: titleAlign ?? \"left\", chars, inner, title, wrapB, wrapT }))\n const v = wrapB(chars.v)\n for (const row of rows) out.push(v + row + v)\n out.push(wrapB(chars.bl + chars.h.repeat(inner) + chars.br))\n return out\n}\n\ninterface TopRowArgs {\n align: TitleAlign\n chars: BorderChars\n inner: number\n title: string | undefined\n wrapB: (s: string) => string\n wrapT: (s: string) => string\n}\n\nfunction topRow({ align, chars, inner, title, wrapB, wrapT }: TopRowArgs): string {\n if (title === undefined || title === \"\") {\n return wrapB(chars.tl + chars.h.repeat(inner) + chars.tr)\n }\n // Chrome: h + space + title + space + h (4 cells of chrome around the title)\n const budget = inner - 4\n if (budget <= 0) return wrapB(chars.tl + chars.h.repeat(inner) + chars.tr)\n const shown = truncate(title, budget)\n const totalH = inner - 2 - stringWidth(shown)\n const { leading, trailing } = distributeH(totalH, align)\n const prefix = wrapB(`${chars.tl}${chars.h.repeat(leading)}`)\n const titleSeg = wrapT(` ${shown} `)\n const suffix = wrapB(`${chars.h.repeat(trailing)}${chars.tr}`)\n return prefix + titleSeg + suffix\n}\n\nfunction distributeH(totalH: number, align: TitleAlign): { leading: number; trailing: number } {\n if (align === \"left\") return { leading: 1, trailing: totalH - 1 }\n if (align === \"right\") return { leading: totalH - 1, trailing: 1 }\n // center: leading rounds down so odd slack biases the title slightly left.\n const leading = Math.floor(totalH / 2)\n return { leading, trailing: totalH - leading }\n}\n\nfunction truncate(s: string, width: number): string {\n if (stringWidth(s) <= width) return s\n if (width <= 1) return \"…\".repeat(width)\n return `${sliceAnsi(s, 0, width - 1)}…`\n}\n","import type { RenderCtx } from \"../core/ctx.ts\"\nimport type { State } from \"../core/state.ts\"\nimport type { BorderSpec, TitleAlign } from \"../layout/border.ts\"\nimport type { RowItem } from \"../layout/flex.ts\"\nimport type { AnyStyle, Style } from \"../style/types.ts\"\nimport type { TextContent } from \"./text.ts\"\n\nimport { stringWidth } from \"@zaly/shared/ansi\"\nimport { Node } from \"../core/node.ts\"\nimport { unwrap } from \"../core/reactive.ts\"\nimport { drawBorder, resolveBorder } from \"../layout/border.ts\"\nimport { allocateRow, isFixedWidth, padRow, stackColumn, zipRow } from \"../layout/flex.ts\"\nimport { clamp, resolveSize } from \"../layout/size.ts\"\nimport { textContent } from \"./text.ts\"\n\nexport type Padding =\n | number\n | readonly [v: number, h: number]\n | readonly [t: number, r: number, b: number, l: number]\n\nexport interface BoxStyle extends Style {\n flexDirection?: \"row\" | \"column\"\n gap?: number\n /** Fixed outer height in rows. When unset, the box's height emerges\n * naturally from its content + padding + border. When set, the\n * content area is truncated or padded with blank rows to land at\n * exactly this many rows of *outer* height. Pair with\n * `verticalAlign` to control which edge is anchored. */\n height?: number\n /** Anchor for the content when `height` truncates or extends.\n * `\"top\"` (default) keeps the top edge: extra rows added at the\n * bottom, overflow truncated from the bottom. `\"bottom\"` keeps the\n * bottom edge: extra rows prepended, overflow truncated from the\n * top. Other CSS-like values (`middle`) are not implemented. */\n verticalAlign?: \"top\" | \"bottom\"\n padding?: Padding\n border?: BorderSpec\n borderTitle?: TextContent\n /** Placement of `borderTitle` along the top border. Defaults to `\"left\"`. */\n borderTitleAlign?: TitleAlign\n /**\n * Style applied to the border glyphs. Either a theme slot name (resolved\n * via the active theme) or an inline `Style`. Defaults to the `\"border\"`\n * theme slot when a border is drawn.\n */\n borderStyle?: AnyStyle\n /**\n * Style applied to the border title. Defaults to the `\"borderTitle\"` theme\n * slot when a title is set.\n */\n borderTitleStyle?: AnyStyle\n}\n\nexport class Box<T extends object = {}> extends Node<BoxStyle & T> {\n protected async _render(ctx: RenderCtx): Promise<string[]> {\n const style = this.state\n\n const [padT, padR, padB, padL] = resolvePadding(style.padding)\n const bchars = resolveBorder(style.border)\n const hasBorder = bchars !== undefined\n const chrome = padL + padR + (hasBorder ? 2 : 0)\n\n let outer: number\n let contentRows: string[]\n let inner: number\n\n if (style.width === \"fit\") {\n // `fit`: render children at the parent's max inner width, measure\n // the natural max-row width, then clamp the box to that. Two-pass\n // — the first pass uses the upper bound as a measuring window,\n // the second re-pads each row to the chosen inner width.\n const upper = Math.max(0, ctx.width - chrome)\n const tentative = await this.#layoutChildren(upper, ctx)\n const natural = tentative.reduce((m, r) => Math.max(m, stringWidth(r)), 0)\n const fit = Math.min(ctx.width, natural + chrome)\n outer = clamp(fit, {\n available: ctx.width,\n max: style.maxWidth,\n min: style.minWidth,\n })\n inner = Math.max(0, outer - chrome)\n contentRows = tentative\n } else {\n const requested = resolveSize(style.width ?? \"fill\", ctx.width) ?? ctx.width\n outer = clamp(requested, {\n available: ctx.width,\n max: style.maxWidth,\n min: style.minWidth,\n })\n inner = Math.max(0, outer - chrome)\n contentRows = await this.#layoutChildren(inner, ctx)\n }\n\n const paddedWidth = Math.max(0, outer - (hasBorder ? 2 : 0))\n\n // Ensure each content row is exactly `inner` cells wide (absorbs slack).\n contentRows = contentRows.map((row) => padRow(row, inner))\n\n // Horizontal padding.\n if (padL > 0 || padR > 0) {\n const lp = \" \".repeat(padL)\n const rp = \" \".repeat(padR)\n contentRows = contentRows.map((row) => lp + row + rp)\n }\n\n // Vertical padding.\n const blank = \" \".repeat(paddedWidth)\n const top = Array.from({ length: padT }, () => blank)\n const bot = Array.from({ length: padB }, () => blank)\n let rows = [...top, ...contentRows, ...bot]\n\n // Fixed-height fit. The `height` field is the outer dimension —\n // border takes its 2 rows out before we measure against the\n // content area; padding is already baked into `rows`. `verticalAlign`\n // decides which end gets clipped (when too tall) or padded (when\n // too short). Default `\"top\"` matches the natural reading flow.\n if (style.height !== undefined) {\n const innerH = Math.max(0, style.height - (hasBorder ? 2 : 0))\n if (rows.length > innerH) {\n rows = style.verticalAlign === \"bottom\" ? rows.slice(-innerH) : rows.slice(0, innerH)\n } else if (rows.length < innerH) {\n const filler = Array.from({ length: innerH - rows.length }, () => blank)\n rows = style.verticalAlign === \"bottom\" ? [...filler, ...rows] : [...rows, ...filler]\n }\n }\n\n if (bchars) {\n rows = drawBorder(rows, bchars, {\n borderStyle: ctx.style.add(style.borderStyle ?? \"border\"),\n title: await textContent(style.borderTitle, ctx),\n titleAlign: style.borderTitleAlign,\n titleStyle: ctx.style.add(style.borderTitleStyle ?? \"borderTitle\"),\n })\n }\n\n const wrap = ctx.style.add(style)\n return rows.map((row) => wrap(row))\n }\n\n /**\n * Intrinsic content width derived from children (or the explicit\n * `width` when fixed). Lets parent flex containers size this Box\n * without falling back to a measure-render — important for\n * side-effecting children like `Image` whose first render allocates\n * a KGP placement: rendering twice would emit two placements and the\n * second render's `transmitOnce` returns no bytes, so the bytes from\n * the discarded measure pass would be lost.\n *\n * Row direction → bases sum (plus gaps). Column direction → bases\n * max. Both add chrome (padding + border) at the end.\n *\n * Children without `layout()` contribute 0 — the row allocator's\n * render-measure fallback still kicks in for them at allocation\n * time, but their absence here just means this Box reports a\n * smaller intrinsic. That's the safe direction: under-report and\n * let shrink/grow handle slack, never over-report.\n */\n override async layout(ctx: RenderCtx) {\n const s = this.state\n const [, padR, , padL] = resolvePadding(s.padding)\n const chrome = padL + padR + (resolveBorder(s.border) ? 2 : 0)\n\n // Fixed width wins outright.\n if (isFixedWidth(s.width)) {\n const w = resolveSize(s.width, ctx.width) ?? 0\n return { minWidth: w, width: w }\n }\n\n const kids = layoutNodes(this.children)\n if (kids.length === 0) return { minWidth: chrome, width: chrome }\n\n const isRow = (s.flexDirection ?? \"column\") === \"row\"\n const totalGap = isRow ? (s.gap ?? 0) * Math.max(0, kids.length - 1) : 0\n\n let widthAcc = 0\n let minAcc = 0\n for (const k of kids) {\n // oxlint-disable-next-line no-await-in-loop\n const l = (await k.getLayout(ctx)) ?? { minWidth: 0, width: 0 }\n if (isRow) {\n widthAcc += l.width\n minAcc += l.minWidth\n } else {\n widthAcc = Math.max(widthAcc, l.width)\n minAcc = Math.max(minAcc, l.minWidth)\n }\n }\n\n return { minWidth: minAcc + totalGap + chrome, width: widthAcc + totalGap + chrome }\n }\n\n async #layoutChildren(innerWidth: number, ctx: RenderCtx): Promise<string[]> {\n const children = layoutNodes(this.children)\n if (children.length === 0) return []\n const gap = this.state.gap ?? 0\n return (this.state.flexDirection ?? \"column\") === \"row\"\n ? this.#layoutRow(children, innerWidth, ctx, gap)\n : this.#layoutColumn(children, innerWidth, ctx, gap)\n }\n\n /**\n * Row direction — main axis is horizontal. CSS-style flex:\n * each child sizes to its intrinsic content width unless it claims\n * slack via `flexGrow > 0` or `width: \"fill\"`. Slack distributes by\n * grow weights; deficit distributes by `basis * flexShrink` clamped\n * at each child's `min-content` floor.\n *\n * Sizing strategy per child:\n * 1. `node.layout(ctx)` — sync, content-derived. If implemented,\n * use directly; no render needed for measurement.\n * 2. Otherwise fall back to render-at-innerWidth and measure the\n * widest emitted row. Cached; the paint pass reuses the result\n * whenever the allocated width matches the measurement width.\n *\n * In `fit` mode the parent has no slack to give, so the allocator's\n * available is capped at the natural sum.\n */\n async #layoutRow(\n children: readonly Node[],\n innerWidth: number,\n ctx: RenderCtx,\n gap: number\n ): Promise<string[]> {\n // Phase 1: figure out each child's intrinsic size.\n // - `layout()` short-circuits — sync, no render.\n // - Fallback: render at the upper bound (innerWidth or fixed spec)\n // and measure rows.\n const intrinsics = await Promise.all(children.map((c) => c.getLayout(ctx)))\n // For children with intrinsic sizing, skip the measure render\n // entirely. Others fall back to render-at-upper-bound (their fixed\n // width, or innerWidth if fluid).\n const measureWidths = children.map((c, i) => {\n if (intrinsics[i] !== undefined) return -1\n if (isFixedWidth(c.state.width)) {\n return resolveSize(c.state.width, innerWidth) ?? innerWidth\n }\n return innerWidth\n })\n const measureRows = await Promise.all(\n children.map((c, i): Promise<string[] | undefined> => {\n if (measureWidths[i] === -1) return Promise.resolve(undefined)\n return c.render({ ...ctx, width: measureWidths[i] })\n })\n )\n const naturals = children.map((c, i) => {\n // A fixed `state.width` is what the allocator will actually\n // assign this child — use it directly so the fit-mode\n // `allocAvailable` sum below matches what we'll consume. Falling\n // back to intrinsic when there's no override under-reports a\n // child like `text(\"x\", { width: 2 })` and shrinks every sibling\n // by the missing cells.\n if (isFixedWidth(c.state.width)) {\n return resolveSize(c.state.width, innerWidth) ?? 0\n }\n const intr = intrinsics[i]\n if (intr) return intr.width\n return (measureRows[i] ?? []).reduce((m, r) => Math.max(m, stringWidth(r)), 0)\n })\n const items: RowItem[] = children.map((c, i) => {\n const s = c.state\n return {\n flexGrow: s.flexGrow,\n flexShrink: s.flexShrink,\n intrinsicMin: intrinsics[i]?.minWidth,\n maxWidth: s.maxWidth,\n minWidth: s.minWidth,\n natural: naturals[i],\n width: s.width,\n }\n })\n const allocAvailable =\n this.state.width === \"fit\"\n ? naturals.reduce((a, b) => a + b, 0) + gap * Math.max(0, children.length - 1)\n : innerWidth\n const widths = allocateRow(items, { contentWidth: allocAvailable, gap })\n // Phase 2: paint at allocated widths. Reuse the measure-render when\n // the allocation matches; otherwise render fresh (cached).\n const childRows = await Promise.all(\n children.map((c, i): Promise<string[]> => {\n const cached = measureRows[i]\n if (cached !== undefined && widths[i] === measureWidths[i]) {\n return Promise.resolve(cached)\n }\n return c.render({ ...ctx, width: widths[i] })\n })\n )\n // `zipRow` expects rows to be exactly `widths[i]` wide. Children\n // that emit natural-width rows (text default, code default) get\n // padded here so the contract holds; over-wide rows get clipped.\n const padded = childRows.map((rows, i) => rows.map((row) => padRow(row, widths[i])))\n return zipRow(padded, { gap, widths })\n }\n\n /**\n * Column direction — main axis is vertical, cross axis horizontal.\n * Per CSS `align-items: stretch` (default), children with no\n * explicit `width` fill the cross axis. A child with a fixed `width`\n * (number / `Pct`) takes that width as its cross-axis size, with the\n * leftover padded as right slack (default `flex-start`). `min`/`max`\n * clamp the resolved width.\n *\n * In fit-mode (`width: \"fit\"`), the cross-axis target shrinks to the\n * widest child row instead of stretching to `innerWidth` — symmetric\n * to how row-direction caps allocator-available at the natural sum.\n */\n async #layoutColumn(\n children: readonly Node[],\n innerWidth: number,\n ctx: RenderCtx,\n gap: number\n ): Promise<string[]> {\n const widths = children.map((c) => {\n const s = c.state\n const fixed = isFixedWidth(s.width) ? resolveSize(s.width, innerWidth) : undefined\n const w = fixed ?? innerWidth\n return clamp(w, { available: innerWidth, max: s.maxWidth, min: s.minWidth })\n })\n const childRows = await Promise.all(\n children.map((c, i) => c.render({ ...ctx, width: widths[i] }))\n )\n const target =\n this.state.width === \"fit\"\n ? childRows.reduce((m, rows) => rows.reduce((mm, r) => Math.max(mm, stringWidth(r)), m), 0)\n : innerWidth\n // Pad each child's rows to the cross-axis target. For full-stretch\n // children this absorbs natural-row slack; for fixed-width\n // children it adds right-side slack (default `flex-start`\n // alignment). `stackColumn`'s contract requires uniform width.\n const padded = childRows.map((rows) => rows.map((row) => padRow(row, target)))\n return stackColumn(padded, { gap, width: target })\n }\n}\n\ntype Child = Node | false | null | undefined\n\n/**\n * Factory for `Box`. The style object is required (use `{}` if you don't\n * need any styling) — the previous style-less overload caused TS to fail\n * to discriminate between a Node child and an inferred-empty-state node\n * like `WidgetNode`. Pass `box({}, child1, child2)` for un-styled boxes.\n *\n * Falsy children (`false`, `null`, `undefined`) are filtered out, enabling\n * conditional JSX-like composition: `box({}, cond && child)`.\n */\nexport function box(style: State<BoxStyle>, ...children: Child[]): Box {\n const b = new Box(style)\n for (const c of children) if (c) b.add(c)\n return b\n}\n\n/**\n * Flatten fragment nodes (those that implement the `layoutChildren`\n * protocol — `show`, `errorBoundary`, `suspense`) into their currently\n * active leaves. Recursive: a fragment whose `layoutChildren()`\n * itself contains fragments unfolds completely.\n *\n * The fragment Node still lives in the tree (mounted, propagating\n * invalidates) — layout just sees through it so its children share\n * the parent box's flex distribution, gap, and cross-axis sizing\n * instead of collapsing into a single slot.\n */\nfunction layoutNodes(children: readonly Node[]): readonly Node[] {\n return children.flatMap((c) => c.layoutNodes).filter((c) => unwrap(c.state.visible) ?? true)\n}\n\nfunction resolvePadding(p: Padding | undefined): [t: number, r: number, b: number, l: number] {\n if (p === undefined) return [0, 0, 0, 0]\n if (typeof p === \"number\") return [p, p, p, p]\n if (p.length === 2) return [p[0], p[1], p[0], p[1]]\n return [p[0], p[1], p[2], p[3]]\n}\n"],"mappings":";;;;;;;;AAoBA,MAAa,UAAU;CACrB,QAAQ;EAAE,IAAI;EAAK,IAAI;EAAK,GAAG;EAAK,IAAI;EAAK,IAAI;EAAK,GAAG;CAAI;CAC7D,SAAS;EAAE,IAAI;EAAK,IAAI;EAAK,GAAG;EAAK,IAAI;EAAK,IAAI;EAAK,GAAG;CAAI;CAC9D,QAAQ;EAAE,IAAI;EAAK,IAAI;EAAK,GAAG;EAAK,IAAI;EAAK,IAAI;EAAK,GAAG;CAAI;AAC/D;;;;AAKA,SAAgB,cAAc,MAAuD;CACnF,IAAI,SAAS,KAAA,KAAa,SAAS,OAAO,OAAO,KAAA;CACjD,IAAI,SAAS,MAAM,OAAO,QAAQ;CAClC,IAAI,OAAO,SAAS,UAAU,OAAO,QAAQ;CAC7C,OAAO;AACT;;AAuBA,MAAM,YAAY,MAAsB;;;;;;;;;;;;AAaxC,SAAgB,WACd,MACA,OACA,OAAuB,CAAC,GACd;CACV,MAAM,EAAE,OAAO,eAAe;CAC9B,MAAM,QAAQ,KAAK,SAAS,IAAI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,UAAwB;CACrE,MAAM,IAAI,IAAI,IAAI,KAAK;CACvB,KAAK,MAAM,KAAK,UAAU,IAAI,GAAG,EAAE,IAAI,CAAC;CACxC,OAAO;AACT;;;;;;;;;;;;AAaA,SAAS,YAAY,UAA4C;CAC/D,OAAO,SAAS,SAAS,MAAM,EAAE,WAAW,CAAC,CAAC,QAAQ,MAAM,OAAO,EAAE,MAAM,OAAO,KAAK,IAAI;AAC7F;AAEA,SAAS,eAAe,GAAsE;CAC5F,IAAI,MAAM,KAAA,GAAW,OAAO;EAAC;EAAG;EAAG;EAAG;CAAC;CACvC,IAAI,OAAO,MAAM,UAAU,OAAO;EAAC;EAAG;EAAG;EAAG;CAAC;CAC7C,IAAI,EAAE,WAAW,GAAG,OAAO;EAAC,EAAE;EAAI,EAAE;EAAI,EAAE;EAAI,EAAE;CAAE;CAClD,OAAO;EAAC,EAAE;EAAI,EAAE;EAAI,EAAE;EAAI,EAAE;CAAE;AAChC"}
@@ -1,7 +1,7 @@
1
- import { t as defaultTheme } from "./registry-DUWpSPoo.mjs";
2
- import { s as reapplyStyle, t as RESET } from "./ansi-CMv71xVr.mjs";
3
- import { r as resolveStyle, t as openStyle } from "./style-DslRHzI4.mjs";
4
- //#region src/style/builder.ts
1
+ import { t as defaultTheme } from "./registry-CQU0VwpM.mjs";
2
+ import { s as reapplyStyle, t as RESET } from "./ansi-CxgRPLA2.mjs";
3
+ import { r as resolveStyle, t as openStyle } from "./style-Cw_EuszU.mjs";
4
+ // src/style/builder.ts
5
5
  /**
6
6
  * Build styled strings via chainable property access.
7
7
  *
@@ -190,7 +190,6 @@ function build(state) {
190
190
  fn.theme = state.theme;
191
191
  return new Proxy(fn, proxyHandler);
192
192
  }
193
- //#endregion
194
193
  export { styleBuilder as t };
195
194
 
196
- //# sourceMappingURL=builder-Chwtk0nQ.mjs.map
195
+ //# sourceMappingURL=builder-BdYlK1Ew.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"builder-Chwtk0nQ.mjs","names":[],"sources":["../src/style/builder.ts"],"sourcesContent":["import type { Theme } from \"../themes/types.ts\"\nimport type {\n AnsiColorName,\n AnyStyle,\n BrightAnsiColorName,\n Color,\n Style,\n ThemeKey,\n} from \"./types.ts\"\n\nimport { defaultTheme } from \"../themes/registry.ts\"\nimport { reapplyStyle, RESET } from \"./ansi.ts\"\nimport { openStyle, resolveStyle } from \"./style.ts\"\n\ntype AttrName = \"bold\" | \"dim\" | \"italic\" | \"underline\" | \"inverse\" | \"strikethrough\"\n\n// Theme color slots that can chain as fg/bg. `fg`/`bg` become setter methods\n// below, so exclude them here to avoid naming collisions. `dim` is an attr on\n// the chain; users wanting theme-slot-dim for fg use `.fg(\"dim\")`.\ntype ChainSlot<Ansi extends boolean = true> =\n | Exclude<ThemeKey, \"fg\" | \"bg\" | AttrName>\n | (Ansi extends true ? AnsiColorName : never)\n | (Ansi extends true ? BrightAnsiColorName : never)\n\nexport type StyleBuilder<Ansi extends boolean = false> = {\n theme: Theme\n (text: string): string\n fg: (color: Color<Ansi>) => StyleBuilder<Ansi>\n bg: (color: Color<Ansi>) => StyleBuilder<Ansi>\n add: (slot?: ThemeKey | AnyStyle) => StyleBuilder<Ansi>\n lighten: (n: number) => StyleBuilder<Ansi>\n darken: (n: number) => StyleBuilder<Ansi>\n // oxlint-disable-next-line typescript/consistent-indexed-object-style -- mapped over a key union, not an open string index\n} & {\n readonly [\n K in\n | AttrName\n | ChainSlot<Ansi>\n | `bg${Capitalize<ChainSlot<Ansi>>}`\n | `fg${Capitalize<ChainSlot<Ansi>>}`\n ]: StyleBuilder<Ansi>\n}\n\n/**\n * Build styled strings via chainable property access.\n *\n * ```ts\n * style().red.bold(\"err\") // → \"\\x1b[1;31merr\\x1b[0m\"\n * style().primary.bgAccent(\"x\") // theme slots via the default theme\n * style(myTheme).primary(\"x\") // override the bound theme\n * style().fg(\"#82aaff\")(\"x\") // hex via the escape hatch\n * style().primary[300](\"x\") // tonal variant of the last color\n * style().bgDiffAdd[200].fgDiffAdd(\"x\") // per-channel variants on a Style slot\n * ```\n *\n * Each property access returns a fresh builder, so intermediates can be\n * reused and extended without mutation:\n *\n * ```ts\n * const err = style().red.bold\n * err(\"oops\"); err.underline(\"fatal\")\n * ```\n *\n * Calling an empty builder is a no-op: `styleBuilder()(\"x\")` returns `\"x\"` unchanged.\n */\nexport function styleBuilder<Ansi extends boolean = false>(\n theme: Theme | false = defaultTheme\n): StyleBuilder<Ansi> {\n return build({\n current: {},\n last: undefined,\n theme: theme === false ? { ...defaultTheme, enabled: false } : theme,\n }) as StyleBuilder<Ansi>\n}\n\nconst ATTRS = new Set<string>([\"bold\", \"dim\", \"italic\", \"underline\", \"inverse\", \"strikethrough\"])\n\n/** Pending \"arg-taking\" op on a chain. Set when the caller accesses\n * `.fg` / `.bg` / `.alpha` / `.add` — the chain is \"parked\" waiting\n * for its argument. Calling the parked chain consumes the arg and\n * produces the real child chain. */\ntype PendingOp = \"fg\" | \"bg\" | \"darken\" | \"add\" | \"lighten\"\n\n/** All the inputs a chain needs to behave correctly, gathered in one\n * object so we can pass it around cheaply instead of closing over\n * four separate vars. `current` is the accumulated Style, `last`\n * tracks which of `fg`/`bg` was most recently touched (for `[step]`\n * and `.alpha()`), `theme` is the resolved theme, `pending` is set\n * on parked arg-taking chains. */\ninterface BuilderState {\n current: Style\n last: \"fg\" | \"bg\" | undefined\n theme: Theme & { enabled?: boolean }\n pending?: PendingOp\n}\n\n/** The function wrapped by every chain's Proxy. Carries its own state\n * so module-level handlers can read it without closure gymnastics. */\ntype BuilderFn = {\n state: BuilderState\n theme: Theme\n} & (((text: string) => string) | ((arg: Color | number | Style | undefined) => StyleBuilder))\n\n// --- module-level handlers (shared across every chain) -----------------\n\nfunction applyStyle(state: BuilderState, text: string): string {\n if (!text || state.theme.enabled === false) return text\n const open = openStyle(state.current, state.theme)\n return open === \"\" ? text : open + reapplyStyle(text, open) + RESET\n}\n\nfunction applyOp(fn: BuilderFn, arg: Color | number | Style | undefined): StyleBuilder {\n // Cache primitive args on the call target itself via `defineProperty`\n // — repeated `.fg(\"#82aaff\")` hits the same child chain after the\n // first call, no rebuild. Object args (e.g. raw Style for `add`)\n // can't be property keys (`\"[object Object]\"` collision), so those\n // always rebuild.\n if (typeof arg === \"string\" || typeof arg === \"number\") {\n const key = String(arg)\n const hit = (fn as unknown as Record<string, unknown>)[key]\n if (hit !== undefined) return hit as StyleBuilder\n const child = fulfill(fn.state, arg)\n Reflect.defineProperty(fn, key, { configurable: false, value: child, writable: false })\n return child\n }\n return fulfill(fn.state, arg)\n}\n\n/** Turn a parked chain + its arg into the real child chain. */\nfunction fulfill(state: BuilderState, arg: unknown): StyleBuilder {\n const { current, last, theme, pending } = state\n switch (pending) {\n case \"fg\": {\n return build({ current: { ...current, fg: arg as Color }, last: \"fg\", theme })\n }\n case \"bg\": {\n return build({ current: { ...current, bg: arg as Color }, last: \"bg\", theme })\n }\n case \"lighten\":\n case \"darken\": {\n if (last === undefined) return build({ current, last, theme })\n const existing = current[last]\n if (typeof existing !== \"string\" || existing === \"inherit\") {\n return build({ current, last, theme })\n }\n const stripped = existing.replace(/[+-]\\d+$/, \"\")\n const n = Math.abs(arg as number)\n const next = `${stripped}${pending === \"lighten\" ? \"+\" : \"-\"}${n}` as Color\n return build({ current: { ...current, [last]: next }, last, theme })\n }\n default: {\n // \"add\" — no pending pending? defaults to rebuild with undef arg.\n return build({\n current: { ...current, ...resolveStyle(arg as string | Style | undefined, theme) },\n last,\n theme,\n })\n }\n }\n}\n\n/** Resolve a single property access on a chain to its child chain. */\nfunction compileKey(state: BuilderState, key: string): StyleBuilder | undefined {\n const { current, last, theme } = state\n\n // Arg-taking ops come back as chains parked in the `pending` state.\n if (key === \"fg\" || key === \"bg\" || key === \"lighten\" || key === \"darken\" || key === \"add\") {\n return build({ current, last, pending: key, theme })\n }\n\n if (ATTRS.has(key)) return build({ current: { ...current, [key]: true }, last, theme })\n\n // `bgFoo` / `fgFoo` → set the channel to the color at slot `foo`.\n // When the slot is a Style, `colorParams` extracts that channel.\n if (key.startsWith(\"bg\") && key.length > 2 && key[2] === key[2].toUpperCase()) {\n const color = (key[2].toLowerCase() + key.slice(3)) as Color\n return build({ current: { ...current, bg: color }, last: \"bg\", theme })\n }\n if (key.startsWith(\"fg\") && key.length > 2 && key[2] === key[2].toUpperCase()) {\n const color = (key[2].toLowerCase() + key.slice(3)) as Color\n return build({ current: { ...current, fg: color }, last: \"fg\", theme })\n }\n\n // Style-valued theme slot → merge its fields into the chain.\n // Anything else (ANSI color names, hex, unresolved slot refs) is\n // treated as a fg color by `colorParams` downstream.\n return build({ current: { ...current, ...resolveStyle(key, theme) }, last: \"fg\", theme })\n}\n\n/** Shared Proxy handler — one instance, used by every chain. Reads\n * state off the target (the `BuilderFn`), so chain construction\n * doesn't allocate a fresh handler object per `build()` call. */\nconst proxyHandler: ProxyHandler<BuilderFn> = {\n get(target, key) {\n if (typeof key !== \"string\") return undefined\n const cached = (target as unknown as Record<string, unknown>)[key]\n if (cached !== undefined) return cached\n // Parked chains can't be chained further — they're waiting for a call.\n if (target.state.pending !== undefined) return undefined\n const child = compileKey(target.state, key)\n if (child === undefined) return undefined\n Reflect.defineProperty(target, key, { configurable: false, value: child, writable: false })\n return child\n },\n}\n\nfunction build(state: BuilderState): StyleBuilder {\n // Two dedicated function shapes so V8 sees a stable signature on\n // each hot path — styling text vs. consuming an op arg are both\n // monomorphic after the build-time ternary.\n const fn = (\n state.pending === undefined\n ? function apply(text: string): string {\n return applyStyle(state, text)\n }\n : function applyOpCall(arg: Color | number | Style | undefined): StyleBuilder {\n return applyOp(fn, arg)\n }\n ) as BuilderFn\n fn.state = state\n fn.theme = state.theme\n return new Proxy(fn, proxyHandler) as unknown as StyleBuilder\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,aACd,QAAuB,cACH;CACpB,OAAO,MAAM;EACX,SAAS,CAAC;EACV,MAAM,KAAA;EACN,OAAO,UAAU,QAAQ;GAAE,GAAG;GAAc,SA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AAKA,MAAM,eAAwC,EAC5C,IAAI,QAAQ,KAAK;CACf,IAAI,OAAO,QAAQ,UAAU,OAAO,KAAA;CACpC,MAAM,SAAU,OAA8C;CAC9D,IAAI,WAAW,KAAA,GAAW,OAAO;CAEjC,IAAI,OAAO,MAAM,YAAY,KAAA,GAAW,OAAO,KAAA;CAC/C,MAAM,QAAQ,WAAW,OAAO,OAAO,GAAG;CAC1C,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,QAAQ,eAAe,QAAQ,KAAK;EAAE,cAAc;EAAO,OAAO;EAAO,UAAU;CAAM,CAAC;CAC1F,OAAO;AACT,EACF;AAEA,SAAS,MAAM,OAAmC;CAIhD,MAAM,KACJ,MAAM,YAAY,KAAA,IACd,SAAS,MAAM,MAAsB;EACnC,OAAO,WAAW,OAAO,IAAI;CAC/B,IACA,SAAS,YAAY,KAAuD;EAC1E,OAAO,QAAQ,IAAI,GAAG;CACxB;CAEN,GAAG,QAAQ;CACX,GAAG,QAAQ,MAAM;CACjB,OAAO,IAAI,MAAM,IAAI,YAAY;AACnC"}
1
+ {"version":3,"file":"builder-BdYlK1Ew.mjs","names":[],"sources":["../src/style/builder.ts"],"sourcesContent":["import type { Theme } from \"../themes/types.ts\"\nimport type {\n AnsiColorName,\n AnyStyle,\n BrightAnsiColorName,\n Color,\n Style,\n ThemeKey,\n} from \"./types.ts\"\n\nimport { defaultTheme } from \"../themes/registry.ts\"\nimport { reapplyStyle, RESET } from \"./ansi.ts\"\nimport { openStyle, resolveStyle } from \"./style.ts\"\n\ntype AttrName = \"bold\" | \"dim\" | \"italic\" | \"underline\" | \"inverse\" | \"strikethrough\"\n\n// Theme color slots that can chain as fg/bg. `fg`/`bg` become setter methods\n// below, so exclude them here to avoid naming collisions. `dim` is an attr on\n// the chain; users wanting theme-slot-dim for fg use `.fg(\"dim\")`.\ntype ChainSlot<Ansi extends boolean = true> =\n | Exclude<ThemeKey, \"fg\" | \"bg\" | AttrName>\n | (Ansi extends true ? AnsiColorName : never)\n | (Ansi extends true ? BrightAnsiColorName : never)\n\nexport type StyleBuilder<Ansi extends boolean = false> = {\n theme: Theme\n (text: string): string\n fg: (color: Color<Ansi>) => StyleBuilder<Ansi>\n bg: (color: Color<Ansi>) => StyleBuilder<Ansi>\n add: (slot?: ThemeKey | AnyStyle) => StyleBuilder<Ansi>\n lighten: (n: number) => StyleBuilder<Ansi>\n darken: (n: number) => StyleBuilder<Ansi>\n // oxlint-disable-next-line typescript/consistent-indexed-object-style -- mapped over a key union, not an open string index\n} & {\n readonly [\n K in\n | AttrName\n | ChainSlot<Ansi>\n | `bg${Capitalize<ChainSlot<Ansi>>}`\n | `fg${Capitalize<ChainSlot<Ansi>>}`\n ]: StyleBuilder<Ansi>\n}\n\n/**\n * Build styled strings via chainable property access.\n *\n * ```ts\n * style().red.bold(\"err\") // → \"\\x1b[1;31merr\\x1b[0m\"\n * style().primary.bgAccent(\"x\") // theme slots via the default theme\n * style(myTheme).primary(\"x\") // override the bound theme\n * style().fg(\"#82aaff\")(\"x\") // hex via the escape hatch\n * style().primary[300](\"x\") // tonal variant of the last color\n * style().bgDiffAdd[200].fgDiffAdd(\"x\") // per-channel variants on a Style slot\n * ```\n *\n * Each property access returns a fresh builder, so intermediates can be\n * reused and extended without mutation:\n *\n * ```ts\n * const err = style().red.bold\n * err(\"oops\"); err.underline(\"fatal\")\n * ```\n *\n * Calling an empty builder is a no-op: `styleBuilder()(\"x\")` returns `\"x\"` unchanged.\n */\nexport function styleBuilder<Ansi extends boolean = false>(\n theme: Theme | false = defaultTheme\n): StyleBuilder<Ansi> {\n return build({\n current: {},\n last: undefined,\n theme: theme === false ? { ...defaultTheme, enabled: false } : theme,\n }) as StyleBuilder<Ansi>\n}\n\nconst ATTRS = new Set<string>([\"bold\", \"dim\", \"italic\", \"underline\", \"inverse\", \"strikethrough\"])\n\n/** Pending \"arg-taking\" op on a chain. Set when the caller accesses\n * `.fg` / `.bg` / `.alpha` / `.add` — the chain is \"parked\" waiting\n * for its argument. Calling the parked chain consumes the arg and\n * produces the real child chain. */\ntype PendingOp = \"fg\" | \"bg\" | \"darken\" | \"add\" | \"lighten\"\n\n/** All the inputs a chain needs to behave correctly, gathered in one\n * object so we can pass it around cheaply instead of closing over\n * four separate vars. `current` is the accumulated Style, `last`\n * tracks which of `fg`/`bg` was most recently touched (for `[step]`\n * and `.alpha()`), `theme` is the resolved theme, `pending` is set\n * on parked arg-taking chains. */\ninterface BuilderState {\n current: Style\n last: \"fg\" | \"bg\" | undefined\n theme: Theme & { enabled?: boolean }\n pending?: PendingOp\n}\n\n/** The function wrapped by every chain's Proxy. Carries its own state\n * so module-level handlers can read it without closure gymnastics. */\ntype BuilderFn = {\n state: BuilderState\n theme: Theme\n} & (((text: string) => string) | ((arg: Color | number | Style | undefined) => StyleBuilder))\n\n// --- module-level handlers (shared across every chain) -----------------\n\nfunction applyStyle(state: BuilderState, text: string): string {\n if (!text || state.theme.enabled === false) return text\n const open = openStyle(state.current, state.theme)\n return open === \"\" ? text : open + reapplyStyle(text, open) + RESET\n}\n\nfunction applyOp(fn: BuilderFn, arg: Color | number | Style | undefined): StyleBuilder {\n // Cache primitive args on the call target itself via `defineProperty`\n // — repeated `.fg(\"#82aaff\")` hits the same child chain after the\n // first call, no rebuild. Object args (e.g. raw Style for `add`)\n // can't be property keys (`\"[object Object]\"` collision), so those\n // always rebuild.\n if (typeof arg === \"string\" || typeof arg === \"number\") {\n const key = String(arg)\n const hit = (fn as unknown as Record<string, unknown>)[key]\n if (hit !== undefined) return hit as StyleBuilder\n const child = fulfill(fn.state, arg)\n Reflect.defineProperty(fn, key, { configurable: false, value: child, writable: false })\n return child\n }\n return fulfill(fn.state, arg)\n}\n\n/** Turn a parked chain + its arg into the real child chain. */\nfunction fulfill(state: BuilderState, arg: unknown): StyleBuilder {\n const { current, last, theme, pending } = state\n switch (pending) {\n case \"fg\": {\n return build({ current: { ...current, fg: arg as Color }, last: \"fg\", theme })\n }\n case \"bg\": {\n return build({ current: { ...current, bg: arg as Color }, last: \"bg\", theme })\n }\n case \"lighten\":\n case \"darken\": {\n if (last === undefined) return build({ current, last, theme })\n const existing = current[last]\n if (typeof existing !== \"string\" || existing === \"inherit\") {\n return build({ current, last, theme })\n }\n const stripped = existing.replace(/[+-]\\d+$/, \"\")\n const n = Math.abs(arg as number)\n const next = `${stripped}${pending === \"lighten\" ? \"+\" : \"-\"}${n}` as Color\n return build({ current: { ...current, [last]: next }, last, theme })\n }\n default: {\n // \"add\" — no pending pending? defaults to rebuild with undef arg.\n return build({\n current: { ...current, ...resolveStyle(arg as string | Style | undefined, theme) },\n last,\n theme,\n })\n }\n }\n}\n\n/** Resolve a single property access on a chain to its child chain. */\nfunction compileKey(state: BuilderState, key: string): StyleBuilder | undefined {\n const { current, last, theme } = state\n\n // Arg-taking ops come back as chains parked in the `pending` state.\n if (key === \"fg\" || key === \"bg\" || key === \"lighten\" || key === \"darken\" || key === \"add\") {\n return build({ current, last, pending: key, theme })\n }\n\n if (ATTRS.has(key)) return build({ current: { ...current, [key]: true }, last, theme })\n\n // `bgFoo` / `fgFoo` → set the channel to the color at slot `foo`.\n // When the slot is a Style, `colorParams` extracts that channel.\n if (key.startsWith(\"bg\") && key.length > 2 && key[2] === key[2].toUpperCase()) {\n const color = (key[2].toLowerCase() + key.slice(3)) as Color\n return build({ current: { ...current, bg: color }, last: \"bg\", theme })\n }\n if (key.startsWith(\"fg\") && key.length > 2 && key[2] === key[2].toUpperCase()) {\n const color = (key[2].toLowerCase() + key.slice(3)) as Color\n return build({ current: { ...current, fg: color }, last: \"fg\", theme })\n }\n\n // Style-valued theme slot → merge its fields into the chain.\n // Anything else (ANSI color names, hex, unresolved slot refs) is\n // treated as a fg color by `colorParams` downstream.\n return build({ current: { ...current, ...resolveStyle(key, theme) }, last: \"fg\", theme })\n}\n\n/** Shared Proxy handler — one instance, used by every chain. Reads\n * state off the target (the `BuilderFn`), so chain construction\n * doesn't allocate a fresh handler object per `build()` call. */\nconst proxyHandler: ProxyHandler<BuilderFn> = {\n get(target, key) {\n if (typeof key !== \"string\") return undefined\n const cached = (target as unknown as Record<string, unknown>)[key]\n if (cached !== undefined) return cached\n // Parked chains can't be chained further — they're waiting for a call.\n if (target.state.pending !== undefined) return undefined\n const child = compileKey(target.state, key)\n if (child === undefined) return undefined\n Reflect.defineProperty(target, key, { configurable: false, value: child, writable: false })\n return child\n },\n}\n\nfunction build(state: BuilderState): StyleBuilder {\n // Two dedicated function shapes so V8 sees a stable signature on\n // each hot path — styling text vs. consuming an op arg are both\n // monomorphic after the build-time ternary.\n const fn = (\n state.pending === undefined\n ? function apply(text: string): string {\n return applyStyle(state, text)\n }\n : function applyOpCall(arg: Color | number | Style | undefined): StyleBuilder {\n return applyOp(fn, arg)\n }\n ) as BuilderFn\n fn.state = state\n fn.theme = state.theme\n return new Proxy(fn, proxyHandler) as unknown as StyleBuilder\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,aACd,QAAuB,cACH;CACpB,OAAO,MAAM;EACX,SAAS,CAAC;EACV,MAAM,KAAA;EACN,OAAO,UAAU,QAAQ;GAAE,GAAG;GAAc,SAAS;EAAM,IAAI;CACjE,CAAC;AACH;AAEA,MAAM,wBAAQ,IAAI,IAAY;CAAC;CAAQ;CAAO;CAAU;CAAa;CAAW;AAAe,CAAC;AA8BhG,SAAS,WAAW,OAAqB,MAAsB;CAC7D,IAAI,CAAC,QAAQ,MAAM,MAAM,YAAY,OAAO,OAAO;CACnD,MAAM,OAAO,UAAU,MAAM,SAAS,MAAM,KAAK;CACjD,OAAO,SAAS,KAAK,OAAO,OAAO,aAAa,MAAM,IAAI,IAAI;AAChE;AAEA,SAAS,QAAQ,IAAe,KAAuD;CAMrF,IAAI,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAAU;EACtD,MAAM,MAAM,OAAO,GAAG;EACtB,MAAM,MAAO,GAA0C;EACvD,IAAI,QAAQ,KAAA,GAAW,OAAO;EAC9B,MAAM,QAAQ,QAA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IACA,SAAS,YAAY,KAAuD;EAC1E,OAAO,QAAQ,IAAI,GAAG;CACxB;CAEN,GAAG,QAAQ;CACX,GAAG,QAAQ,MAAM;CACjB,OAAO,IAAI,MAAM,IAAI,YAAY;AACnC"}
@@ -1,8 +1,8 @@
1
- import { a as hyperlink } from "./ansi-CMv71xVr.mjs";
2
- import { t as allocateRow } from "./flex-Bguo-fUe.mjs";
3
- import { n as capitalize, o as formatText, t as calcLayout } from "./text-BoJdKXLU.mjs";
1
+ import { a as hyperlink } from "./ansi-CxgRPLA2.mjs";
2
+ import { t as allocateRow } from "./flex-CYp4etqn.mjs";
3
+ import { n as capitalize, o as formatText, t as calcLayout } from "./text-4arC3odI.mjs";
4
4
  import { splitAnsi, stringWidth } from "@zaly/shared/ansi";
5
- //#region src/markdown/code.ts
5
+ // src/markdown/code.ts
6
6
  /**
7
7
  * Build the `code` callback. The returned closure captures ctx/style/highlighter
8
8
  * and renders each fenced block: syntax-highlight (if available), pad lines to
@@ -31,8 +31,7 @@ function createCodeCallback(ctx) {
31
31
  return `\n${meta?.title === void 0 ? "" : `${s.mdCodeBlockTitle(meta.title)}\n`}${padded.join("\n")}\n\n`;
32
32
  };
33
33
  }
34
- //#endregion
35
- //#region src/markdown/list.ts
34
+ // src/markdown/list.ts
36
35
  const BULLETS = [
37
36
  "●",
38
37
  "○",
@@ -89,8 +88,7 @@ function createListCallbacks(ctx) {
89
88
  }
90
89
  };
91
90
  }
92
- //#endregion
93
- //#region src/markdown/table.ts
91
+ // src/markdown/table.ts
94
92
  /**
95
93
  * Build the table-related callbacks. They share a closure-local
96
94
  * `TableState` accumulator: `th`/`td` push cells, `tr` commits rows into
@@ -204,8 +202,7 @@ function padCell(text, width, align) {
204
202
  }
205
203
  return text + " ".repeat(slack);
206
204
  }
207
- //#endregion
208
- //#region src/markdown/callbacks.ts
205
+ // src/markdown/callbacks.ts
209
206
  const icons = {
210
207
  hr: "─",
211
208
  quote: "┃"
@@ -274,7 +271,6 @@ function createCallbacks(ctx) {
274
271
  ...createTableCallbacks(ctx)
275
272
  };
276
273
  }
277
- //#endregion
278
274
  export { createCallbacks };
279
275
 
280
- //# sourceMappingURL=callbacks-DLecWn7G.mjs.map
276
+ //# sourceMappingURL=callbacks-DW8XKYKy.mjs.map